본문 바로가기
코드

keyscan

by umaking 2023. 11. 17.

/*********************

  K.C.Y 1993

*********************/

#include <dos.h>

void interrupt far (*oldKBD)(void);

unsigned char scancode[128]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};

unsigned char touchcode[128]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};

void interrupt ScanKey()
{
    unsigned char key,key2;

    __emit__(0xFB);
    key = inportb(0x60);

    if (key>127) scancode[key-128]=0;
    else if(!scancode[key]) {
   scancode[key]=1;
   touchcode[key]=1;
 }

    key2 = inportb(0x61);
    key=key2;
    key2=key2 | 0x80;
    outportb(0x61,key2);
    outportb(0x61,key);
    __emit__(0xFA);
    outportb(0x20,0x20);
}

void NewKey()
{
  oldKBD=getvect(0x9);
  setvect(0x9,ScanKey);
  return;
}

void OldKey()
{
  setvect(0x9,oldKBD);
  return;
}