Diff for /xmil/io/ctc.c between versions 1.17 and 1.18

version 1.17, 2005/02/04 06:42:11 version 1.18, 2008/06/02 20:07:31
Line 1 Line 1
   
 // #define      CTCCOUNTER  /* #define CTCCOUNTER */
 #define CTCFAST  #define CTCFAST
   
 #include        "compiler.h"  #include        "compiler.h"
 #include        "z80core.h"  #include        "z80core.h"
Line 56  static REG8 ctcwork(CTCCH *ch) { Line 56  static REG8 ctcwork(CTCCH *ch) {
   
         baseclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK;          baseclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK;
         stepclock = baseclock - ch->s.baseclock;          stepclock = baseclock - ch->s.baseclock;
 #if defined(FIX_Z80A)                   // 2x2MHz  #if defined(FIX_Z80A)                   /* 2x2MHz */
         ch->s.baseclock += stepclock & (~1);          ch->s.baseclock += stepclock & (~1);
         stepclock = stepclock >> 1;          stepclock = stepclock >> 1;
 #else  #else
Line 67  static REG8 ctcwork(CTCCH *ch) { Line 67  static REG8 ctcwork(CTCCH *ch) {
         intr = 0;          intr = 0;
         pulse3 = 0;          pulse3 = 0;
   
         // 0          /* 0 */
         if (!(ch->s.cmd[0] & 0x02)) {          if (!(ch->s.cmd[0] & 0x02)) {
                 pulse = stepclock;                  pulse = stepclock;
                 count = ch->s.count[0];                  count = ch->s.count[0];
Line 91  static REG8 ctcwork(CTCCH *ch) { Line 91  static REG8 ctcwork(CTCCH *ch) {
                 ch->s.count[0] = count;                  ch->s.count[0] = count;
         }          }
   
         // 3          /* 3 */
         if (!(ch->s.cmd[3] & 0x02)) {          if (!(ch->s.cmd[3] & 0x02)) {
                 if (!(ch->s.cmd[3] & 0x40)) {                  if (!(ch->s.cmd[3] & 0x40)) {
                         pulse3 = stepclock;                          pulse3 = stepclock;
Line 108  static REG8 ctcwork(CTCCH *ch) { Line 108  static REG8 ctcwork(CTCCH *ch) {
                         count = ch->s.countmax[3] - ((0 - count) % ch->s.countmax[3]);                          count = ch->s.countmax[3] - ((0 - count) % ch->s.countmax[3]);
 #endif  #endif
                         intr |= (ch->s.cmd[3] & 0x80) >> (7 - 3);                          intr |= (ch->s.cmd[3] & 0x80) >> (7 - 3);
 //                      TRACEOUT(("<- ch.3 %.8x [%.2x:%.2x %.2x:%.2x]", baseclock,  #if 0
 //                                                              ch->s.basecnt[0], ch->s.cmd[0],                          TRACEOUT(("<- ch.3 %.8x [%.2x:%.2x %.2x:%.2x]", baseclock,
 //                                                              ch->s.basecnt[3], ch->s.cmd[3]));                                                                  ch->s.basecnt[0], ch->s.cmd[0],
                                                                   ch->s.basecnt[3], ch->s.cmd[3]));
   #endif
                 }                  }
                 ch->s.count[3] = count;                  ch->s.count[3] = count;
         }          }
   
         // 1          /* 1 */
         if (!(ch->s.cmd[1] & 0x02)) {          if (!(ch->s.cmd[1] & 0x02)) {
                 pulse = stepclock;                  pulse = stepclock;
                 count = ch->s.count[1];                  count = ch->s.count[1];
Line 127  static REG8 ctcwork(CTCCH *ch) { Line 129  static REG8 ctcwork(CTCCH *ch) {
                 ch->s.count[1] = count;                  ch->s.count[1] = count;
         }          }
   
         // 2          /* 2 */
         if (!(ch->s.cmd[2] & 0x02)) {          if (!(ch->s.cmd[2] & 0x02)) {
                 pulse = stepclock;                  pulse = stepclock;
                 count = ch->s.count[2];                  count = ch->s.count[2];
Line 196  BRESULT ieitem_ctc(UINT id) { Line 198  BRESULT ieitem_ctc(UINT id) {
         intr |= ch->s.intr;          intr |= ch->s.intr;
         r = FALSE;          r = FALSE;
         if (intr) {          if (intr) {
   #if 1
                 for (i=0, bit=1; i<4; i++, bit<<=1)                  for (i=0, bit=1; i<4; i++, bit<<=1)
 //              for (i=4, bit=8; i--; bit>>=1)  #else   /* 1 */
                   for (i=4, bit=8; i--; bit>>=1)
   #endif  /* 1 */
                 {                  {
                         if (intr & bit) {                          if (intr & bit) {
                                 if (!(ch->s.cmd[i] & 0x80)) {                                  if (!(ch->s.cmd[i] & 0x80)) {
Line 207  BRESULT ieitem_ctc(UINT id) { Line 212  BRESULT ieitem_ctc(UINT id) {
                                         r = TRUE;                                          r = TRUE;
                                         intr ^= bit;                                          intr ^= bit;
                                         ch->s.irq = (UINT8)i;                                          ch->s.irq = (UINT8)i;
 //      TRACEOUT(("ctc int %d %d [%.2x]", ch->s.num, i, ch->s.cmd[i]));                                          /* TRACEOUT(("ctc int %d %d [%.2x]", ch->s.num, i, ch->s.cmd[i])); */
                                         Z80_INTERRUPT((REG8)(ch->s.vector + (i << 1)));                                          Z80_INTERRUPT((REG8)(ch->s.vector + (i << 1)));
                                 }                                  }
                         }                          }
Line 232  void ieeoi_ctc(UINT id) { Line 237  void ieeoi_ctc(UINT id) {
         ch = ctc.ch + (id - IEVENT_CTC0);          ch = ctc.ch + (id - IEVENT_CTC0);
         intr = ctcwork(ch) | ch->s.intr;          intr = ctcwork(ch) | ch->s.intr;
         curirq = ch->s.irq;          curirq = ch->s.irq;
         if (intr & (1 << curirq)) {                     // 割り込み中に割り込んだ…          if (intr & (1 << curirq)) {                     /* 割り込み中に割り込んだ… */
                 // カウンタが0でなければ割り込みを消す                  /* カウンタが0でなければ割り込みを消す */
                 if ((ch->s.countmax[curirq] - ch->s.count[curirq])                  if ((ch->s.countmax[curirq] - ch->s.count[curirq])
                                                                                                         >= ch->s.range[curirq]) {                                                                                                          >= ch->s.range[curirq]) {
                         intr ^= (1 << curirq);                          intr ^= (1 << curirq);
Line 249  void ieeoi_ctc(UINT id) { Line 254  void ieeoi_ctc(UINT id) {
 }  }
   
   
 // ----  /* ---- */
   
 static void ctcch_o(CTCCH *ch, UINT port, REG8 value) {  static void ctcch_o(CTCCH *ch, UINT port, REG8 value) {
   
Line 282  static void ctcch_o(CTCCH *ch, UINT port Line 287  static void ctcch_o(CTCCH *ch, UINT port
                 ch->s.cmd[port] = value;                  ch->s.cmd[port] = value;
                 ctcnextevent(ch);                  ctcnextevent(ch);
         }          }
         else if (!port) {                                                                                               // ver0.25          else if (!port) {                                                                                               /* ver0.25 */
                 ch->s.vector = (UINT8)(value & 0xf8);                  ch->s.vector = (UINT8)(value & 0xf8);
         }          }
 }  }
Line 300  static REG8 ctcch_i(CTCCH *ch, UINT port Line 305  static REG8 ctcch_i(CTCCH *ch, UINT port
 }  }
   
   
 // ----  /* ---- */
   
 static CTCCH *getctcch(UINT port) {  static CTCCH *getctcch(UINT port) {
   
Line 321  void IOOUTCALL ctc_o(UINT port, REG8 val Line 326  void IOOUTCALL ctc_o(UINT port, REG8 val
   
         CTCCH   *ch;          CTCCH   *ch;
   
 //      TRACEOUT(("ctc - %.4x %.2x [%.4x]", port, value, Z80_PC));          /* TRACEOUT(("ctc - %.4x %.2x [%.4x]", port, value, Z80_PC)); */
         ch = getctcch(port);          ch = getctcch(port);
         if (ch != NULL) {          if (ch != NULL) {
                 ctcch_o(ch, port, value);                  ctcch_o(ch, port, value);
Line 342  REG8 IOINPCALL ctc_i(UINT port) { Line 347  REG8 IOINPCALL ctc_i(UINT port) {
 }  }
   
   
 // ----  /* ---- */
   
 void ctc_reset(void) {  void ctc_reset(void) {
   

Removed from v.1.17  
changed lines
  Added in v.1.18


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