www.pudn.com > SuperMario.zip > KEY.CPP


#include 
#ifdef __cplusplus 
    #define __CPPARGS ... 
#else 
    #define __CPPARGS 
#endif 
 
#define ESC      1 
#define UP       72 
#define LEFT     75 
#define RIGHT    77 
#define DOWN     80 
#define ENTER    28 
#define SPACE    57 
#define ALT      56 
#define CTRL     29 
 
int key[128]; 
 
int ti=0; 
 
void  interrupt far time_handler(__CPPARGS) 
  {  disable(); 
     ti++; 
enable(); 
} 
 
 
void  interrupt far key_handler(__CPPARGS) 
{ 
  int k; 
  disable(); 
  asm{ 
     sti 
     in al,60H 
     xor ah,ah 
     mov k,ax 
     in al,61h 
     or al,82h 
     out 61h,al 
     and al,7fh 
     out 61h,al 
     mov al,20h 
     out 20h,al 
     } 
  if(k<128) 
    key[k]=1; 
  else 
    key[k-128]=0; 
 enable(); 
} 
 
void set_time(int time) 
{ 
    int tt,ttt; 
    tt=time&0x00ff; 
    ttt=(time>>8)&0x00ff; 
    outp(0x43,0x3c); 
    outp(0x40,tt); 
    outp(0x40,ttt); 
 
}