Diff for /np2/io/pit.c between versions 1.4 and 1.5

version 1.4, 2003/10/25 21:03:43 version 1.5, 2003/11/12 20:02:54
Line 32  static void setsystimerevent(BOOL absolu Line 32  static void setsystimerevent(BOOL absolu
   
         SINT32  cnt;          SINT32  cnt;
   
         cnt = pit.value[0].w;          cnt = pit.value[0];
         if (cnt > 8) {                                                                  // º¬µò¤Ê¤·          if (cnt > 8) {                                                                  // º¬µò¤Ê¤·
                 cnt *= pc.multiple;                  cnt *= pc.multiple;
         }          }
Line 63  static void setbeepevent(BOOL absolute)  Line 63  static void setbeepevent(BOOL absolute) 
   
         SINT32  cnt;          SINT32  cnt;
   
         cnt = pit.value[1].w;          cnt = pit.value[1];
         if (cnt > 2) {          if (cnt > 2) {
                 cnt *= pc.multiple;                  cnt *= pc.multiple;
         }          }
Line 97  static void setrs232cevent(BOOL absolute Line 97  static void setrs232cevent(BOOL absolute
   
         SINT32  cnt;          SINT32  cnt;
   
         if (pit.value[2].w > 1) {          if (pit.value[2] > 1) {
                 cnt = pc.multiple * pit.value[2].w * rs232c.mul;                        // ver0.29                  cnt = pc.multiple * pit.value[2] * rs232c.mul;
         }          }
         else {          else {
                 cnt = (pc.multiple << 16) * rs232c.mul;                                         // ver0.29                  cnt = (pc.multiple << 16) * rs232c.mul;
         }          }
         nevent_set(NEVENT_RS232C, cnt, rs232ctimer, absolute);          nevent_set(NEVENT_RS232C, cnt, rs232ctimer, absolute);
 }  }
Line 127  static UINT16 itimer_latch(int ch) { Line 127  static UINT16 itimer_latch(int ch) {
                 switch(pit.mode[1] & 0x06) {                  switch(pit.mode[1] & 0x06) {
                         case 0x00:                          case 0x00:
                         case 0x04:                          case 0x04:
                                 return(pit.value[1].w);                                  return(pit.value[1]);
 #ifdef uPD71054  #ifdef uPD71054
                         case 0x06:                          case 0x06:
                                 return(pit.value[1].w & 0xfffe);                                  return(pit.value[1] & 0xfffe);
 #endif  #endif
                 }                  }
         }          }
Line 150  void itimer_setflag(int ch, BYTE value)  Line 150  void itimer_setflag(int ch, BYTE value) 
         }          }
         else {                                                                                                          // latch          else {                                                                                                          // latch
                 pit.mode[ch] &= ~0x30;                  pit.mode[ch] &= ~0x30;
                 pit.latch[ch].w = itimer_latch(ch);                  pit.latch[ch] = itimer_latch(ch);
         }          }
 }  }
   
Line 158  BOOL itimer_setcount(int ch, BYTE value) Line 158  BOOL itimer_setcount(int ch, BYTE value)
   
         switch(pit.mode[ch] & 0x30) {          switch(pit.mode[ch] & 0x30) {
                 case 0x10:              // access low                  case 0x10:              // access low
                         pit.value[ch].w = value;                          pit.value[ch] = value;
                         break;                          break;
   
                 case 0x20:              // access high                  case 0x20:              // access high
                         pit.value[ch].w = value << 8;                          pit.value[ch] = value << 8;
                         break;                          break;
   
                 case 0x30:              // access word                  case 0x30:              // access word
                         if (!(pit.flag[ch] & 2)) {                          if (!(pit.flag[ch] & 2)) {
                                 pit.value[ch].w &= 0xff00;                                  pit.value[ch] &= 0xff00;
                                 pit.value[ch].w += value;                                  pit.value[ch] += value;
                                 pit.flag[ch] ^= 2;                                  pit.flag[ch] ^= 2;
                                 return(TRUE);                                  return(TRUE);
                         }                          }
                         pit.value[ch].w &= 0x00ff;                          pit.value[ch] &= 0x00ff;
                         pit.value[ch].w += value << 8;                          pit.value[ch] += value << 8;
                         pit.flag[ch] ^= 2;                          pit.flag[ch] ^= 2;
                         break;                          break;
         }          }
Line 183  BOOL itimer_setcount(int ch, BYTE value) Line 183  BOOL itimer_setcount(int ch, BYTE value)
 BYTE itimer_getcount(int ch) {  BYTE itimer_getcount(int ch) {
   
         BYTE    ret;          BYTE    ret;
         union {          UINT16  w;
                 BYTE    b[2];  
                 UINT16  w;  
         } tim;  
   
         if (!(pit.mode[ch] & 0x30)) {          if (!(pit.mode[ch] & 0x30)) {
                 tim.w = pit.latch[ch].w;                  w = pit.latch[ch];
         }          }
         else {          else {
                 tim.w = itimer_latch(ch);                                                                       // ver0.30                  w = itimer_latch(ch);
         }          }
         switch(pit.mode[ch] & 0x30) {          switch(pit.mode[ch] & 0x30) {
                 case 0x10:                                              // access low                  case 0x10:                                              // access low
                         return((BYTE)tim.w);                          return((BYTE)w);
   
                 case 0x20:                                              // access high                  case 0x20:                                              // access high
                         return((BYTE)(tim.w >> 8));                          return((BYTE)(w >> 8));
         }          }
                                                                                 // access word                                                                                  // access word
         if (!(pit.flag[ch] & 1)) {          if (!(pit.flag[ch] & 1)) {
                 ret = (BYTE)tim.w;                  ret = (BYTE)w;
         }          }
         else {          else {
                 ret = (BYTE)(tim.w >> 8);                  ret = (BYTE)(w >> 8);
         }          }
         pit.flag[ch] ^= 1;          pit.flag[ch] ^= 1;
         return(ret);          return(ret);
Line 238  static void IOOUTCALL pit_o73(UINT port, Line 235  static void IOOUTCALL pit_o73(UINT port,
                 beep_lheventset(1);                  beep_lheventset(1);
         }          }
         else {          else {
                 beep_hzset(pit.value[1].w);                  beep_hzset(pit.value[1]);
         }          }
         (void)port;          (void)port;
 }  }
Line 294  void itimer_reset(void) { Line 291  void itimer_reset(void) {
   
         ZeroMemory(&pit, sizeof(pit));          ZeroMemory(&pit, sizeof(pit));
         if (pc.cpumode & CPUMODE_8MHz) {          if (pc.cpumode & CPUMODE_8MHz) {
                 pit.value[1].w = 998;                   // 4MHz                  pit.value[1] = 998;                             // 4MHz
         }          }
         else {          else {
                 pit.value[1].w = 1229;                  // 5MHz                  pit.value[1] = 1229;                    // 5MHz
         }          }
         pit.mode[0] = 0x30;          pit.mode[0] = 0x30;
         pit.mode[1] = 0x56;          pit.mode[1] = 0x56;
         pit.mode[2] = 0xb6;          pit.mode[2] = 0xb6;
         pit.mode[3] = 0x36;          pit.mode[3] = 0x36;
         setsystimerevent(NEVENT_ABSOLUTE);          setsystimerevent(NEVENT_ABSOLUTE);
         beep_hzset(pit.value[1].w);          beep_hzset(pit.value[1]);
 }  }
   
 void itimer_bind(void) {  void itimer_bind(void) {

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


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