Diff for /np2/io/serial.c between versions 1.5 and 1.10

version 1.5, 2003/11/13 07:47:17 version 1.10, 2004/02/11 17:39:59
Line 4 Line 4
 #include        "iocore.h"  #include        "iocore.h"
   
   
 static const BYTE joykeytable[12] = {  static const UINT8 joykeytable[12] = {
                                 0x2a,   0x34,                                  0x2a,   0x34,
                                 0x29,   0x1c,                                  0x29,   0x1c,
                                 0x3c,   0x48,                                  0x3c,   0x48,
Line 12  static const BYTE joykeytable[12] = { Line 12  static const BYTE joykeytable[12] = {
                                 0x3d,   0x4b,                                  0x3d,   0x4b,
                                 0x3a,   0x43};                                  0x3a,   0x43};
   
 static const BYTE kbexflag[0x80] = {  static const UINT8 kbexflag[0x80] = {
                 //       ESC,  £±,  £²,  £³,  £´,  £µ,  £¶,  £·         ; 00h                  //       ESC,  £±,  £²,  £³,  £´,  £µ,  £¶,  £·         ; 00h
                            0,   0,   0,   0,   0,   0,   0,   0,                             0,   0,   0,   0,   0,   0,   0,   0,
                 //        £¸,  £¹,  £°,  ¡Ý,  ¡°,  ¡ï,  BS, TAB         ; 08h                  //        £¸,  £¹,  £°,  ¡Ý,  ¡°,  ¡ï,  BS, TAB         ; 08h
Line 47  static const BYTE kbexflag[0x80] = { Line 47  static const BYTE kbexflag[0x80] = {
                            0,   0,   0,   0,   0,   0,   0,   0};                             0,   0,   0,   0,   0,   0,   0,   0};
   
   
 static void keyb_int(BOOL absolute) {  static void keybrd_int(BOOL absolute) {
   
         if (keyb.buffers) {          if (keybrd.buffers) {
                 if (!((pic.pi[0].irr | pic.pi[0].isr) & PIC_KEYBOARD)) {                  if (!(keybrd.status & 2)) {
                         keyb.status |= 2;                          keybrd.status |= 2;
                         keyb.data = keyb.buf[keyb.pos];                          keybrd.data = keybrd.buf[keybrd.pos];
                         keyb.pos = (keyb.pos + 1) & KB_BUFMASK;                          keybrd.pos = (keybrd.pos + 1) & KB_BUFMASK;
                         keyb.buffers--;                          keybrd.buffers--;
                         pic_setirq(1);  
                 }                  }
                 nevent_set(NEVENT_KEYBOARD, pc.keyboardclock,                  pic_setirq(1);
                                                                                         keyb_callback, absolute);                  nevent_set(NEVENT_KEYBOARD, keybrd.xferclock,
         }                                                                                          keybrd_callback, absolute);
         else {  
                 keyb.status &= ~2;  
         }          }
 }  }
   
 void keyb_callback(NEVENTITEM item) {  void keybrd_callback(NEVENTITEM item) {
   
         if (item->flag & NEVENT_SETEVENT) {          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) {          if (keybrd.buffers < KB_BUF) {
                 keyb.buf[(keyb.pos + keyb.buffers) & KB_BUFMASK] = data;                  keybrd.buf[(keybrd.pos + keybrd.buffers) & KB_BUFMASK] = data;
                 keyb.buffers++;                  keybrd.buffers++;
                 if (!nevent_iswork(NEVENT_KEYBOARD)) {                  if (!nevent_iswork(NEVENT_KEYBOARD)) {
                         keyb_int(NEVENT_ABSOLUTE);                          keybrd_int(NEVENT_ABSOLUTE);
                 }                  }
         }          }
         else {          else {
                 keyb.status |= 0x10;                  keybrd.status |= 0x10;
         }          }
 }  }
   
   
 // ----  // ----
   
         BYTE    keystat[0x80];  static  UINT8   keystat[0x80];
   
 void keystat_reset(void) {  void keystat_reset(void) {
   
Line 97  void keystat_reset(void) { Line 94  void keystat_reset(void) {
 }  }
   
   
 void keystat_senddata(BYTE data) {  void keystat_senddata(REG8 data) {
   
         BYTE    key;          REG8    key;
         BOOL    keynochange;          BOOL    keynochange;
   const UINT8     *user;
           UINT    i;
   
         key = data & 0x7f;          key = data & 0x7f;
         keynochange = FALSE;          keynochange = FALSE;
   
         // CTRL:¥«¥Ê 0x71,0x72 bit7==0¤Ç¥È¥ë¥°½èÍý (ɸ½à½èÍý)          // CTRL:¥«¥Ê 0x71,0x72 bit7==0¤Ç¥È¥°¥ë½èÍý (ɸ½à½èÍý)
         if ((key == 0x71) || (key == 0x72)) {          if ((key == 0x71) || (key == 0x72)) {
                 if (data & 0x80) {                  if (data & 0x80) {
                         return;                          return;
Line 113  void keystat_senddata(BYTE data) { Line 112  void keystat_senddata(BYTE data) {
                 data = key | (keystat[key] & 0x80);                  data = key | (keystat[key] & 0x80);
                 keystat[key] ^= 0x80;                  keystat[key] ^= 0x80;
         }          }
           else if ((key == 0x76) || (key == 0x77)) {              // user key
                   user = np2cfg.userkey[key - 0x76];
                   for (i=0; i<user[0]; i++) {
                           key = user[i+1] & 0x7f;
                           if (!((keystat[key] ^ data) & 0x80)) {
                                   keystat[key] ^= 0x80;
                                   keybrd_out((REG8)(key | (data & 0x80)));
                           }
                   }
                   return;
           }
         else {          else {
                 if ((np2cfg.XSHIFT) &&                  if ((np2cfg.XSHIFT) &&
                         (((key == 0x70) && (np2cfg.XSHIFT & 1)) ||                          (((key == 0x70) && (np2cfg.XSHIFT & 1)) ||
Line 147  void keystat_senddata(BYTE data) { Line 157  void keystat_senddata(BYTE data) {
                         if (data & 0x80) {                                              // ver0.30                          if (data & 0x80) {                                              // ver0.30
                                 return;                                  return;
                         }                          }
                         keyb_out((BYTE)(data ^ 0x80));                          keybrd_out((REG8)(data ^ 0x80));
                   }
                   keybrd_out(data);
           }
   }
   
   void keystat_forcerelease(REG8 value) {
   
           REG8    key;
   const UINT8     *user;
           UINT    i;
   
           key = value & 0x7f;
           if ((key != 0x76) && (key != 0x77)) {
                   if (keystat[key] & 0x80) {
                           keystat[key] &= ~0x80;
                           keybrd_out((REG8)(key | 0x80));
                   }
           }
           else {
                   user = np2cfg.userkey[key - 0x76];
                   for (i=0; i<user[0]; i++) {
                           key = user[i+1] & 0x7f;
                           if (keystat[key] & 0x80) {
                                   keystat[key] &= ~0x80;
                                   keybrd_out((REG8)(key | 0x80));
                           }
                 }                  }
                 keyb_out(data);  
         }          }
 }  }
   
 void keystat_resetcopyhelp(void) {  void keystat_resetcopyhelp(void) {
   
         BYTE    i;          REG8    i;
   
         for (i=0x60; i<0x62; i++) {          for (i=0x60; i<0x62; i++) {
                 if (keystat[i] & 0x80) {                  if (keystat[i] & 0x80) {
                         keystat[i] &= 0x7f;                          keystat[i] &= 0x7f;
                         keyb_out((BYTE)(i | 0x80));                          keybrd_out((REG8)(i | 0x80));
                 }                  }
         }          }
 }  }
   
 void keystat_allrelease(void) {  void keystat_allrelease(void) {
   
         UINT    i;          REG8    i;
   
         for (i=0; i<0x80; i++) {          for (i=0; i<0x80; i++) {
                 if (keystat[i] & 0x80) {                  if (keystat[i] & 0x80) {
                         keystat[i] &= ~0x80;                          keystat[i] &= ~0x80;
                         keyb_out((BYTE)(i + 0x80));                          keybrd_out((REG8)(i | 0x80));
                 }                  }
         }          }
 }  }
   
 void keystat_forcerelease(BYTE value) {  
   
         if (keystat[value & 0x7f] & 0x80) {  
                 keystat[value & 0x7f] &= ~0x80;  
                 keyb_out((BYTE)(value | 0x80));  
         }  
 }  
   
 void keystat_resetjoykey(void) {  void keystat_resetjoykey(void) {
   
         int             i;          int             i;
         BYTE    key;          REG8    key;
   
         for (i=0; i<12; i++) {          for (i=0; i<12; i++) {
                 key = joykeytable[i];                  key = joykeytable[i];
                 if (keystat[key] & 0x80) {                  if (keystat[key] & 0x80) {
                         keystat[key] &= 0x7f;                          keystat[key] &= 0x7f;
                         keyb_out((BYTE)(key | 0x80));                          keybrd_out((REG8)(key | 0x80));
                 }                  }
         }          }
 }  }
Line 203  void keystat_resetjoykey(void) { Line 230  void keystat_resetjoykey(void) {
 // ----  // ----
   
 typedef struct {  typedef struct {
         BYTE    joysync;          UINT8   joysync;
         BYTE    joylast;          UINT8   joylast;
         BYTE    mouselast;          UINT8   mouselast;
         BYTE    padding;          UINT8   padding;
         BYTE    d_up;          UINT8   d_up;
         BYTE    d_dn;          UINT8   d_dn;
         BYTE    d_lt;          UINT8   d_lt;
         BYTE    d_rt;          UINT8   d_rt;
 } KEYEXT;  } KEYEXT;
   
 static  KEYEXT  keyext;  static  KEYEXT  keyext;
 static const BYTE mousedelta[] = {1, 1, 1, 1,  static const UINT8 mousedelta[] = {1, 1, 1, 1,
                                                                         2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4};                                                                          2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4};
 #define MOUSESTEPMAX ((sizeof(mousedelta) / sizeof(BYTE)) - 1)  #define MOUSESTEPMAX ((sizeof(mousedelta) / sizeof(UINT8)) - 1)
   
 void keyext_flash(void) {  void keyext_flash(void) {
   
Line 313  BYTE keyext_getmouse(SINT16 *x, SINT16 * Line 340  BYTE keyext_getmouse(SINT16 *x, SINT16 *
   
 // ----  // ----
   
 static void IOOUTCALL keyb_o41(UINT port, BYTE dat) {  static void IOOUTCALL keybrd_o41(UINT port, REG8 dat) {
   
         keyb.mode = dat;          keybrd.mode = dat;
         (void)port;          (void)port;
 }  }
   
 static void IOOUTCALL keyb_o43(UINT port, BYTE dat) {  static void IOOUTCALL keybrd_o43(UINT port, REG8 dat) {
   
         if ((!(dat & 0x08)) && (keyb.cmd & 0x08)) {          if ((!(dat & 0x08)) && (keybrd.cmd & 0x08)) {
                 keyboard_resetsignal();                  keyboard_resetsignal();
         }          }
         if (dat & 0x10) {          if (dat & 0x10) {
                 keyb.status &= ~(0x38);                  keybrd.status &= ~(0x38);
         }          }
         keyb.cmd = dat;          keybrd.cmd = dat;
         (void)port;          (void)port;
 }  }
   
 static BYTE IOINPCALL keyb_i41(UINT port) {  static REG8 IOINPCALL keybrd_i41(UINT port) {
   
         (void)port;          (void)port;
         return(keyb.data);          keybrd.status &= ~2;
           return(keybrd.data);
 }  }
   
 static BYTE IOINPCALL keyb_i43(UINT port) {  static REG8 IOINPCALL keybrd_i43(UINT port) {
   
         (void)port;          (void)port;
         return(keyb.status);          return(keybrd.status);
 }  }
   
   
 // ----  // ----
   
 static const IOOUT keybo41[2] = {  static const IOOUT keybrdo41[2] = {
                                         keyb_o41,       keyb_o43};                                          keybrd_o41,     keybrd_o43};
   
 static const IOINP keybi41[2] = {  static const IOINP keybrdi41[2] = {
                                         keyb_i41,       keyb_i43};                                          keybrd_i41,     keybrd_i43};
   
   
 void keyboard_reset(void) {  void keyboard_reset(void) {
   
         ZeroMemory(&keyb, sizeof(keyb));          ZeroMemory(&keybrd, sizeof(keybrd));
         keyb.data = 0xff;          keybrd.data = 0xff;
         keyb.mode = 0x5e;          keybrd.mode = 0x5e;
 }  }
   
 void keyboard_bind(void) {  void keyboard_bind(void) {
   
         iocore_attachsysoutex(0x0041, 0x0cf1, keybo41, 2);          keybrd.xferclock = pccore.realclock / 1920;
         iocore_attachsysinpex(0x0041, 0x0cf1, keybi41, 2);          iocore_attachsysoutex(0x0041, 0x0cf1, keybrdo41, 2);
           iocore_attachsysinpex(0x0041, 0x0cf1, keybrdi41, 2);
 }  }
   
 void keyboard_resetsignal(void) {                                                                       // ver0.29  void keyboard_resetsignal(void) {                                                                       // ver0.29
   
         int             i;          int             i;
   
         keyboard_reset();          keybrd.mode = 0x5e;
           keybrd.cmd = 0;
           keybrd.status = 0;
           keybrd.buffers = 0;
           keybrd.pos = 0;
         for (i=0; i<0x80; i++) {          for (i=0; i<0x80; i++) {
                 if (keystat[i]) {                  if (keystat[i]) {
                         keyb_out((BYTE)i);                          keybrd_out((REG8)i);
                 }                  }
         }          }
 }  }
Line 445  void rs232c_midipanic(void) { Line 478  void rs232c_midipanic(void) {
   
 // ----  // ----
   
 static void IOOUTCALL rs232c_o30(UINT port, BYTE dat) {  static void IOOUTCALL rs232c_o30(UINT port, REG8 dat) {
   
         if (cm_rs232c) {          if (cm_rs232c) {
                 cm_rs232c->write(cm_rs232c, dat);                  cm_rs232c->write(cm_rs232c, (UINT8)dat);
         }          }
         if (sysport.c & 4) {          if (sysport.c & 4) {
                 rs232c.send = 0;                  rs232c.send = 0;
Line 460  static void IOOUTCALL rs232c_o30(UINT po Line 493  static void IOOUTCALL rs232c_o30(UINT po
         (void)port;          (void)port;
 }  }
   
 static void IOOUTCALL rs232c_o32(UINT port, BYTE dat) {  static void IOOUTCALL rs232c_o32(UINT port, REG8 dat) {
   
         if (!(dat & 0xfd)) {          if (!(dat & 0xfd)) {
                 rs232c.dummyinst++;                  rs232c.dummyinst++;
Line 518  static void IOOUTCALL rs232c_o32(UINT po Line 551  static void IOOUTCALL rs232c_o32(UINT po
         (void)port;          (void)port;
 }  }
   
 static BYTE IOINPCALL rs232c_i30(UINT port) {  static REG8 IOINPCALL rs232c_i30(UINT port) {
   
         (void)port;          (void)port;
         return(rs232c.data);          return(rs232c.data);
 }  }
   
 static BYTE IOINPCALL rs232c_i32(UINT port) {  static REG8 IOINPCALL rs232c_i32(UINT port) {
   
         if (!(rs232c_stat() & 0x20)) {          if (!(rs232c_stat() & 0x20)) {
                 return(rs232c.result | 0x80);                  return(rs232c.result | 0x80);

Removed from v.1.5  
changed lines
  Added in v.1.10


RetroPC.NET-CVS <cvs@retropc.net>