X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdos_comm.c;h=503ff6dc5ae52df075e214ca5e9cfb538e3c0590;hb=52483d8c2e16d2298a30e8b5aca4a90c07ea1816;hp=371294266200becc8790e5dbc51418b0e6c05ed4;hpb=8546b30d561c27e4b1eab164e17baf4c84a5c42e;p=16.git diff --git a/src/lib/dos_comm.c b/src/lib/dos_comm.c index 37129426..503ff6dc 100644 --- a/src/lib/dos_comm.c +++ b/src/lib/dos_comm.c @@ -1,45 +1,48 @@ /* Thanks to Alex Russell for example code */ /* Thanks to Gary Neal for example code */ -#include "src\lib\dos_comm.h" - -// Q code -byte kee; -byte keer[128]; /* key pressed */ -byte keep[128]; /* key released */ +#include "src\lib\dos_comm.h" + +// keyboard buffer +static byte key[NUM_SCANCODES]; // pressed +static byte kea[NUM_SCANCODES]; // released -#ifdef __cplusplus /* Functions must be declared C style */ +#ifdef __cplusplus /* Function must be declared C style */ extern "C" { -#endif -extern void interrupt (far *oldkb)(void) = NULL; /* BIOS keyboard handler */ +#endif +static void interrupt (far *oldkb)(void) = NULL; /* BIOS keyboard handler */ #ifdef __cplusplus } #endif /*****************NEW KEYBOARD 09h ISR***********************/ -void interrupt newkb(void){ +void interrupt newkb(void){ + byte kee; register char qx; kee = inp(0x60); /* Read the keyboard scan code */ - + /* Clear keyboard controller on XT machines */ - qx = inp(0x61); + qx = inp(0x61); /* Get keyboard control register */ qx |= 0x82; - outp(0x61, qx); + outp(0x61, qx); /* Toggle acknowledge bit high */ qx &= 0x7F; - outp(0x61, qx); + outp(0x61, qx); /* Toggle acknowledge bit low */ - /* Interpret the scan code and set our flags */ + /* Interpret the scan code and set our flags */ +//tt printf("%d[%d]\n",kee,key[kee]); if(kee & 0x80) - keep[kee & 0x7F] = 0; + key[kee & 0x7F] = 0; // a key is released else - keep[kee] = keer[kee] = 1; - - outp(0x20, 0x20); + key[kee] = kea[kee] = 1; // a key is pressed + + /* Acknowledge the interrupt to the programmable interrupt controller */ + outp(0x20, 0x20); /* Signal non specific end of interrupt */ } /* ---------------------- init_keyboard() ---------------- April 17,1993 */ /* restore the bios keyboard handler */ /* ---------------------- deinit_keyboard() -------------- April 17,1993 */ -void setkb(int vq){ +void setkb(int vq){ + int i; /* Index variable */ if(!vq){ // deinitiation /* Abort if our function pointer has no valid address */ if(oldkb == NULL) return; @@ -47,23 +50,30 @@ void setkb(int vq){ _dos_setvect(9, oldkb); /* Reset our function pointer to contain no valid address */ oldkb = NULL; + /* Print the key heap */ + printf("\n"); + for(i=0; i