Diff for /np2/keystat.c between versions 1.7 and 1.12

version 1.7, 2004/03/28 19:50:25 version 1.12, 2004/03/31 19:23:37
Line 18  typedef struct { Line 18  typedef struct {
         UINT8   d_rt;          UINT8   d_rt;
 } KEYSTAT;  } KEYSTAT;
   
   
                 NKEYTBL         nkeytbl;                  NKEYTBL         nkeytbl;
                 KEYCTRL         keyctrl;                  KEYCTRL         keyctrl;
 static  KEYSTAT         keystat;  static  KEYSTAT         keystat;
Line 28  void keystat_initialize(void) { Line 27  void keystat_initialize(void) {
   
         char    path[MAX_PATH];          char    path[MAX_PATH];
   
           ZeroMemory(&keyctrl, sizeof(keyctrl));
           keyctrl.keyrep = 0x21;
           keyctrl.capsref = NKEYREF_NC;
           keyctrl.kanaref = NKEYREF_NC;
   
         ZeroMemory(&keystat, sizeof(keystat));          ZeroMemory(&keystat, sizeof(keystat));
         FillMemory(keystat.ref, sizeof(keystat.ref), NKEYREF_NC);          FillMemory(keystat.ref, sizeof(keystat.ref), NKEYREF_NC);
         keystat_tblreset();          keystat_tblreset();
Line 157  kstbl_err: Line 161  kstbl_err:
   
 // ----  // ----
   
   static REG8 getledstat(void) {
   
           REG8    ret;
   
           ret = 0;
           if (keyctrl.kanaref != NKEYREF_NC) {
                   ret |= 8;
           }
           if (keyctrl.capsref != NKEYREF_NC) {
                   ret |= 4;
           }
           return(ret);
   }
   
   static void reloadled(void) {
   
           keyctrl.kanaref = keystat.ref[0x72];
           keyctrl.capsref = keystat.ref[0x71];
   }
   
   void keystat_ctrlreset(void) {
   
           keyctrl.reqparam = 0;
           keystat.ref[0x72] = keyctrl.kanaref;
           keystat.ref[0x71] = keyctrl.capsref;
   }
   
   void keystat_ctrlsend(REG8 dat) {
   
           if (!keyctrl.reqparam) {
                   keyctrl.mode = dat;
                   switch(dat) {
   #if defined(SUPPORT_PC9801_119)
                           case 0x95:
   #endif
                           case 0x9c:
                           case 0x9d:
                                   keyctrl.reqparam = 1;
                                   keyboard_ctrl(0xfa);
                                   break;
   
   #if defined(SUPPORT_PC9801_119)
                           case 0x96:
                                   keyboard_ctrl(0xfa);
                                   keyboard_ctrl(0xa0);
                                   keyboard_ctrl(0x83);
                                   break;
   #endif
   
                           case 0x9f:
                                   keyboard_ctrl(0xfa);
                                   keyboard_ctrl(0xa0);
                                   keyboard_ctrl(0x80);
                                   break;
   
                           default:
                                   keyboard_ctrl(0xfc);
                                   break;
                   }
           }
           else {
                   switch(keyctrl.mode) {
   #if defined(SUPPORT_PC9801_119)
                           case 0x95:
                                   keyctrl.kbdtype = dat;
                                   keyboard_ctrl(0xfa);
                                   break;
   #endif
                           case 0x9c:
                                   keyboard_ctrl(0xfa);
                                   break;
   
                           case 0x9d:
                                   if (dat == 0x60) {
                                           keyboard_ctrl(0xfa);
                                           keyboard_ctrl((REG8)(0x70 + getledstat()));
                                   }
                                   else if ((dat & 0xf0) == 0x70) {
                                           keyboard_ctrl(0xfa);
                                           keystat.ref[0x72] = (dat & 8)?NKEYREF_uPD8255:NKEYREF_NC;
                                           keystat.ref[0x71] = (dat & 4)?NKEYREF_uPD8255:NKEYREF_NC;
                                           reloadled();
                                   }
                                   break;
                   }
                   keyctrl.reqparam = 0;
           }
   }
   
   
   // ----
   
 void keystat_down(const UINT8 *key, REG8 keys, REG8 ref) {  void keystat_down(const UINT8 *key, REG8 keys, REG8 ref) {
   
         UINT8   keydata;          UINT8   keydata;
Line 174  void keystat_down(const UINT8 *key, REG8 Line 270  void keystat_down(const UINT8 *key, REG8
                         keystat.ref[keycode] = ref;                          keystat.ref[keycode] = ref;
                 }                  }
                 else {                  else {
 #if defined(SUPPORT_PC9801119)  #if defined(SUPPORT_PC9801_119)
                         if ((keyctrl.kbdtype != 0x03) && (keycode >= 0x75)) {                          if (keyctrl.kbdtype != 0x03)
                                 continue;  
                         }  
 #else  
                         if (keycode >= 0x75) {  
                                 continue;  
                         }  
 #endif  #endif
                           {
                                   if (keycode == 0x7d) {
                                           keycode = 0x70;
                                   }
                                   else if (keycode >= 0x75) {
                                           continue;
                                   }
                           }
                         if ((np2cfg.XSHIFT) &&                          if ((np2cfg.XSHIFT) &&
                                 (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) ||                                  (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) ||
                                 ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) ||                                  ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) ||
Line 206  void keystat_down(const UINT8 *key, REG8 Line 304  void keystat_down(const UINT8 *key, REG8
                                 }                                  }
                                 keyboard_send(data);                                  keyboard_send(data);
                         }                          }
                           if ((keycode == 0x71) || (keycode == 0x72)) {
                                   reloadled();
                           }
                 }                  }
         }          }
 }  }
Line 225  void keystat_up(const UINT8 *key, REG8 k Line 326  void keystat_up(const UINT8 *key, REG8 k
                         }                          }
                 }                  }
                 else {                  else {
 #if defined(SUPPORT_PC9801119)  #if defined(SUPPORT_PC9801_119)
                         if ((keyctrl.kbdtype != 0x03) && (keycode >= 0x75)) {                          if (keyctrl.kbdtype != 0x03)
                                 continue;  
                         }  
 #else  
                         if (keycode >= 0x75) {  
                                 continue;  
                         }  
 #endif  #endif
                           {
                                   if (keycode == 0x7d) {
                                           keycode = 0x70;
                                   }
                                   else if (keycode >= 0x75) {
                                           continue;
                                   }
                           }
                         if ((np2cfg.XSHIFT) &&                          if ((np2cfg.XSHIFT) &&
                                 (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) ||                                  (((keycode == 0x70) && (np2cfg.XSHIFT & 1)) ||
                                 ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) ||                                  ((keycode == 0x74) && (np2cfg.XSHIFT & 2)) ||
Line 244  void keystat_up(const UINT8 *key, REG8 k Line 347  void keystat_up(const UINT8 *key, REG8 k
                                 if (keystat.ref[keycode] != NKEYREF_NC) {                                  if (keystat.ref[keycode] != NKEYREF_NC) {
                                         keystat.ref[keycode] = NKEYREF_NC;                                          keystat.ref[keycode] = NKEYREF_NC;
                                         keyboard_send((REG8)(keycode + 0x80));                                          keyboard_send((REG8)(keycode + 0x80));
                                           if ((keycode == 0x71) || (keycode == 0x72)) {
                                                   reloadled();
                                           }
                                 }                                  }
                         }                          }
                 }                  }
Line 336  void keystat_resetjoykey(void) { Line 442  void keystat_resetjoykey(void) {
 void keystat_releasekey(REG8 key) {  void keystat_releasekey(REG8 key) {
   
         key &= 0x7f;          key &= 0x7f;
         if (keystat.ref[key] != NKEYREF_NC) {          if ((key != 0x71) && (key != 0x72)) {
                 keystat.ref[key] = NKEYREF_NC;                  if (keystat.ref[key] != NKEYREF_NC) {
                 keyboard_send((REG8)(key + 0x80));                          keystat.ref[key] = NKEYREF_NC;
                           keyboard_send((REG8)(key + 0x80));
                   }
         }          }
 }  }
   

Removed from v.1.7  
changed lines
  Added in v.1.12


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