C语言扫描码的问题?
/* Note:Your choice is C IDE */ #include <process.h>
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <dos.h>
#include <conio.h>
/* define Keys scan code */ /* 定义各键的扫描码 */
#define Key_DOWN 80
#define Key_UP 72
#define Key_A 30
#define Key_B 48
#define Key_C 46
#define Key_Q 18
#define Key_ENTER 28
int key();
main()
{
int ky,y;
char ch;
textbackground(0);
clrscr();
do
{
textmode(C80);
textbackground(13);
textcolor(RED);
window(7,8,19,15);
clrscr();
textbackground(1);
textcolor(RED);
window(8,9,18,14);
clrscr();
gotoxy(3,3);
cprintf("Q:quit\r\n");
gotoxy(3,4);
cprintf("A:dir\r\n");
gotoxy(3,5);
cprintf("B:dir/p\r\n");
gotoxy(3,6);
cprintf("C:dir/w\r\n");
y=10;
upbar(y-1);
do
{
ky=key();
switch(ky)
{
case Key_A:
{
y=12,
ky=Key_ENTER;
};
break;
case Key_B:
{
y=13,
ky=Key_ENTER;
};
break;
case Key_C:
{
y=14,
ky=Key_ENTER;
};
break;
case Key_Q:
{
y=11,
ky=Key_ENTER;
};
break;
case Key_DOWN:
if(y<13)
{
upbar(y);
y++;
};
break;
case Key_UP:
if(y>10)
{
downbar(y);
y--;
};
break;
}
}while(ky!=Key_ENTER);
textcolor(WHITE);
switch(y)
{
case 11:
ch='%';
break;
case 12:
{
systen("dir");
getch();
};
break;
case 13:
{
systen("dir/p");
getch();
};
break;
case 14:
{
systen("dir/w");
getch();
};
break;
} ;
if(ch=='%')
break;
}while(1);
clrscr();
}
int key()
{
union REGS rg;
rg.h.ah=0;
int86(0x16,&rg,&rg);
return rg.h.ah;
}
upbar(int y)
{
int i;
typedef struct texel_struct
{
unsigned char ch;
unsigned char attr;
}texel;
texel t;
for(i=9;i<=17;i++)
{
gettext(i,y,i,y,&t);
t.attr=0x1f;
puttext(i,y,i,y,&t);
gettext(i,y+1,i,y+1,&t);
t.attr=0x4f;
puttext(i,y+1,i,y+1,&t);
};
gotoxy(3,y+1);
return;
}
downbar(int y)
{
int i;
typedef struct texel_struct
{
unsigned char ch;
unsigned char attr;
}texel;
texel t;
for(i=9;i<=17;i++)
{
gettext(i,y,i,y,&t);
t.attr=0x1f;
puttext(i,y,i,y,&t);
gettext(i,y-1,i,y-1,&t);
t.attr=0x4f;
puttext(i,y-1,i,y-1,&t);
};
gotoxy(3,y+1);
return;
}
各位大虾能帮我看看以上程序中/* define Keys scan code */ /* 定义各键的扫描码 */ 下面定义各键的扫描码是什么意思吗?还有swich语句里y=12等等是什么意思为什么啊?为什么其他书上或网上的扫描码和它的不一样啊,是不是扫描码是可以自己定的啊?最好有高手帮我解释一下此段程序中的全部意思,越详细越好,非常感谢!急!急!急!