Diff for /np2/io/serial.c between versions 1.8 and 1.11

version 1.8, 2004/01/13 05:30:58 version 1.11, 2004/02/13 08:33:48
Line 47  static const UINT8 kbexflag[0x80] = { Line 47  static const UINT8 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, pccore.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(REG8 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;
         }          }
 }  }
   
   
 // ----  // ----
   
         UINT8   keystat[0x80];  static  UINT8   keystat[0x80];
   
 void keystat_reset(void) {  void keystat_reset(void) {
   
Line 99  void keystat_reset(void) { Line 96  void keystat_reset(void) {
   
 void keystat_senddata(REG8 data) {  void keystat_senddata(REG8 data) {
   
         REG8    key;          REG8            key;
         BOOL    keynochange;          BOOL            keynochange;
   const _NKEYM    *user;
           UINT            i;
   
         key = data & 0x7f;          key = data & 0x7f;
         keynochange = FALSE;          keynochange = FALSE;
Line 113  void keystat_senddata(REG8 data) { Line 112  void keystat_senddata(REG8 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->keys; i++) {
                           key = user->key[i] & 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(REG8 data) { Line 157  void keystat_senddata(REG8 data) {
                         if (data & 0x80) {                                              // ver0.30                          if (data & 0x80) {                                              // ver0.30
                                 return;                                  return;
                         }                          }
                         keyb_out((REG8)(data ^ 0x80));                          keybrd_out((REG8)(data ^ 0x80));
                   }
                   keybrd_out(data);
           }
   }
   
   void keystat_forcerelease(REG8 value) {
   
           REG8            key;
   const _NKEYM    *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->keys; i++) {
                           key = user->key[i] & 0x7f;
                           if (keystat[key] & 0x80) {
                                   keystat[key] &= ~0x80;
                                   keybrd_out((REG8)(key | 0x80));
                           }
                 }                  }
                 keyb_out(data);  
         }          }
 }  }
   
Line 160  void keystat_resetcopyhelp(void) { Line 195  void keystat_resetcopyhelp(void) {
         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((REG8)(i | 0x80));                          keybrd_out((REG8)(i | 0x80));
                 }                  }
         }          }
 }  }
Line 172  void keystat_allrelease(void) { Line 207  void keystat_allrelease(void) {
         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((REG8)(i | 0x80));                          keybrd_out((REG8)(i | 0x80));
                 }                  }
         }          }
 }  }
   
 void keystat_forcerelease(REG8 value) {  
   
         if (keystat[value & 0x7f] & 0x80) {  
                 keystat[value & 0x7f] &= ~0x80;  
                 keyb_out((REG8)(value | 0x80));  
         }  
 }  
   
 void keystat_resetjoykey(void) {  void keystat_resetjoykey(void) {
   
         int             i;          int             i;
Line 194  void keystat_resetjoykey(void) { Line 221  void keystat_resetjoykey(void) {
                 key = joykeytable[i];                  key = joykeytable[i];
                 if (keystat[key] & 0x80) {                  if (keystat[key] & 0x80) {
                         keystat[key] &= 0x7f;                          keystat[key] &= 0x7f;
                         keyb_out((REG8)(key | 0x80));                          keybrd_out((REG8)(key | 0x80));
                 }                  }
         }          }
 }  }
Line 313  BYTE keyext_getmouse(SINT16 *x, SINT16 * Line 340  BYTE keyext_getmouse(SINT16 *x, SINT16 *
   
 // ----  // ----
   
 static void IOOUTCALL keyb_o41(UINT port, REG8 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, REG8 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 REG8 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 REG8 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((REG8)i);                          keybrd_out((REG8)i);
                 }                  }
         }          }
 }  }

Removed from v.1.8  
changed lines
  Added in v.1.11


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