From 862d44010ebeae34b23d9c157f7273f7fcc82ecc Mon Sep 17 00:00:00 2001 From: Yourtion Date: Mon, 11 Apr 2016 17:29:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BC=A0=E6=A0=87=E8=A7=A3=E8=AF=BB=EF=BC=881?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 08_day/bootpack.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/08_day/bootpack.c b/08_day/bootpack.c index 8d2618d..86ae15e 100644 --- a/08_day/bootpack.c +++ b/08_day/bootpack.c @@ -11,6 +11,7 @@ void HariMain(void) { struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO; char s[40], mcursor[256], keybuf[32], mousebuf[128]; + unsigned char mouse_dbuf[3], mouse_phase; int mx, my, i; init_gdtidt(); @@ -34,6 +35,7 @@ void HariMain(void) putfonts8_asc(binfo->vram, binfo->scrnx, 0, 0, COL8_FFFFFF, s); enable_mouse(); + mouse_phase = 0; /* 进入到等待鼠标的0xfa的状态 */ for (;;) { io_cli(); @@ -49,10 +51,29 @@ void HariMain(void) } else if (fifo8_status(&mousefifo) != 0) { i = fifo8_get(&mousefifo); io_sti(); - sprintf(s, "%02X", i); - boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 32, 16, 47, 31); - putfonts8_asc(binfo->vram, binfo->scrnx, 32, 16, COL8_FFFFFF, s); - } + if (mouse_phase == 0) { + /* 等待鼠标的0xfa的状态 */ + if (i == 0xfa) { + mouse_phase = 1; + } + } else if (mouse_phase == 1) { + /* 等待鼠标的第一字节 */ + mouse_dbuf[0] = i; + mouse_phase = 2; + } else if (mouse_phase == 2) { + /* 等待鼠标的第二字节 */ + mouse_dbuf[1] = i; + mouse_phase = 3; + } else if (mouse_phase == 3) { + /* 等待鼠标的第三字节 */ + mouse_dbuf[2] = i; + mouse_phase = 1; + /* 鼠标的3个字节都齐了,显示出来 */ + sprintf(s, "%02X %02X %02X", mouse_dbuf[0], mouse_dbuf[1], mouse_dbuf[2]); + boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 32, 16, 32 + 8 * 8 - 1, 31); + putfonts8_asc(binfo->vram, binfo->scrnx, 32, 16, COL8_FFFFFF, s); + } + } } } }