--- np2/io/serial.c 2003/12/04 16:48:15 1.6 +++ np2/io/serial.c 2004/02/11 17:39:59 1.10 @@ -4,7 +4,7 @@ #include "iocore.h" -static const BYTE joykeytable[12] = { +static const UINT8 joykeytable[12] = { 0x2a, 0x34, 0x29, 0x1c, 0x3c, 0x48, @@ -12,7 +12,7 @@ static const BYTE joykeytable[12] = { 0x3d, 0x4b, 0x3a, 0x43}; -static const BYTE kbexflag[0x80] = { +static const UINT8 kbexflag[0x80] = { // ESC, £±, £², £³, £´, £µ, £¶, £· ; 00h 0, 0, 0, 0, 0, 0, 0, 0, // £¸, £¹, £°, ¡Ý, ¡°, ¡ï, BS, TAB ; 08h @@ -47,49 +47,46 @@ static const BYTE kbexflag[0x80] = { 0, 0, 0, 0, 0, 0, 0, 0}; -static void keyb_int(BOOL absolute) { +static void keybrd_int(BOOL absolute) { - if (keyb.buffers) { - if (!((pic.pi[0].irr | pic.pi[0].isr) & PIC_KEYBOARD)) { - keyb.status |= 2; - keyb.data = keyb.buf[keyb.pos]; - keyb.pos = (keyb.pos + 1) & KB_BUFMASK; - keyb.buffers--; - pic_setirq(1); + if (keybrd.buffers) { + if (!(keybrd.status & 2)) { + keybrd.status |= 2; + keybrd.data = keybrd.buf[keybrd.pos]; + keybrd.pos = (keybrd.pos + 1) & KB_BUFMASK; + keybrd.buffers--; } - nevent_set(NEVENT_KEYBOARD, pc.keyboardclock, - keyb_callback, absolute); - } - else { - keyb.status &= ~2; + pic_setirq(1); + nevent_set(NEVENT_KEYBOARD, keybrd.xferclock, + keybrd_callback, absolute); } } -void keyb_callback(NEVENTITEM item) { +void keybrd_callback(NEVENTITEM item) { if (item->flag & NEVENT_SETEVENT) { - keyb_int(NEVENT_RELATIVE); + keybrd_int(NEVENT_RELATIVE); } } -static void keyb_out(BYTE data) { +static void keybrd_out(REG8 data) { - if (keyb.buffers < KB_BUF) { - keyb.buf[(keyb.pos + keyb.buffers) & KB_BUFMASK] = data; - keyb.buffers++; + if (keybrd.buffers < KB_BUF) { + keybrd.buf[(keybrd.pos + keybrd.buffers) & KB_BUFMASK] = data; + keybrd.buffers++; if (!nevent_iswork(NEVENT_KEYBOARD)) { - keyb_int(NEVENT_ABSOLUTE); + keybrd_int(NEVENT_ABSOLUTE); } } else { - keyb.status |= 0x10; + keybrd.status |= 0x10; } } // ---- - BYTE keystat[0x80]; +static UINT8 keystat[0x80]; void keystat_reset(void) { @@ -97,10 +94,12 @@ void keystat_reset(void) { } -void keystat_senddata(BYTE data) { +void keystat_senddata(REG8 data) { - BYTE key; + REG8 key; BOOL keynochange; +const UINT8 *user; + UINT i; key = data & 0x7f; keynochange = FALSE; @@ -113,6 +112,17 @@ void keystat_senddata(BYTE data) { data = key | (keystat[key] & 0x80); keystat[key] ^= 0x80; } + else if ((key == 0x76) || (key == 0x77)) { // user key + user = np2cfg.userkey[key - 0x76]; + for (i=0; iwrite(cm_rs232c, dat); + cm_rs232c->write(cm_rs232c, (UINT8)dat); } if (sysport.c & 4) { rs232c.send = 0; @@ -460,7 +493,7 @@ static void IOOUTCALL rs232c_o30(UINT po (void)port; } -static void IOOUTCALL rs232c_o32(UINT port, BYTE dat) { +static void IOOUTCALL rs232c_o32(UINT port, REG8 dat) { if (!(dat & 0xfd)) { rs232c.dummyinst++; @@ -518,13 +551,13 @@ static void IOOUTCALL rs232c_o32(UINT po (void)port; } -static BYTE IOINPCALL rs232c_i30(UINT port) { +static REG8 IOINPCALL rs232c_i30(UINT port) { (void)port; return(rs232c.data); } -static BYTE IOINPCALL rs232c_i32(UINT port) { +static REG8 IOINPCALL rs232c_i32(UINT port) { if (!(rs232c_stat() & 0x20)) { return(rs232c.result | 0x80);