关于按键函数的疑问
下面这段代码怎么也看不懂,望哪位高手赐教...
void far interrupt NewInt9(void)
{
unsigned char ScanCode,temp;
ScanCode=inportb(0x60);
temp=inportb(0x61);
outportb(0x61,temp | 0x80);
outportb(0x61,temp & 0x7f);
if(ScanCode&0x80)
{
ScanCode&=0x7f;
key_state[ScanCode]=0;
}
else
{
key_state[ScanCode]=1;
key_pressed[ScanCode]=1;
}
outportb(0x20,0x20);
}
void InstallKeyboard(void)
{
int i;
for(i=0;i<128;i++)
key_state[i]=key_pressed[i]=0;
OldInt9Handler=getvect(9); /*中断向量值*/
setvect(9,NewInt9); /*中断程序NewInt9地址存入指定的中断向量表中INT 09H*/
}
void ShutDownKeyboard(void)
{
setvect(9,OldInt9Handler);
}
int GetKey(int ScanCode)
{
int res;
res=key_state[ScanCode]|key_pressed[ScanCode];
key_pressed[ScanCode]=0;
return res;
}