VOGONS


First post, by thrawn235

User metadata
Rank Newbie
Rank
Newbie

I use DJGPP and ive installed a Keyboard ISR.
everything works fine.
The only Problem is, that when i quit the Program, all the Keypresses that i did (during program execution) show up on the Dos promt.

Is there a way to clear the Buffer at the End of the Game or not have it record keypresses in the first place ?
Or rather, what is the usual way of doing that ?

thanks.

Reply 1 of 3, by Ringding

User metadata
Rank Member
Rank
Member

There is a ring buffer somewhere in the BIOS area, whose head and tail positions can be set. I forgot the details. But how does your application handle keyboard input? Does it handle int 9 itself? If it does it on its own, then there should be no need to call the original int 9 handler, thus nothing would end up in the keyboard buffer.

Reply 2 of 3, by thrawn235

User metadata
Rank Newbie
Rank
Newbie

Thats basically what im doing:


//============= global Variables for the Interrupt Service Routine ========
bool keys[256];
//=========================================================================

//============ global Function that is to be installed as ISR =============
void KeyboardInterruptRoutine()
{
unsigned char scanCode = 0;
scanCode = inportb( 0x60 );
if( scanCode != 0 )
{
if( scanCode <= 80 && scanCode )
{
keys[scanCode] = true;
}
else
{
keys[scanCode - 0x80] = false;
}
if( scanCode == 0xe0 )
{
unsigned char scanCode2 = 0;
scanCode2 = inportb( 0x60 );
if( scanCode2 <= 80 )
{
keys[scanCode2+100] = true;
}
else
{
keys[scanCode2+100 - 0x80] = false;
}
}
}

char temp;
outportb( 0x61, ( temp = inportb( 0x61 )) | 0x80 );
outportb( 0x61, temp );
}
//unused dummy functions. meant to calculate the size of KeyboardInterruptRoutine()
void KeyboardInterruptRoutineEnd() {}
//======================================================================

void DOSInputEngine::InstallKeyboardInterrupt()
{
_go32_dpmi_lock_data( ( void* )keys, ( long )sizeof( keys ) );
_go32_dpmi_lock_code( ( void* )KeyboardInterruptRoutine, 1000 );
_go32_dpmi_get_protected_mode_interrupt_vector( 0x09, &OldISR );

NewISR.pm_offset = ( int )KeyboardInterruptRoutine;
NewISR.pm_selector = _go32_my_cs();

_go32_dpmi_chain_protected_mode_interrupt_vector( 0x09, &NewISR );
}

After thinking about it, the Problem is probably that i chain the the interrupt.

Does anybody know how to just overwrite it ?