--- xmil/io/ctc.c 2004/08/13 06:49:31 1.11 +++ xmil/io/ctc.c 2004/08/15 15:18:00 1.14 @@ -155,7 +155,9 @@ BRESULT ieitem_ctc(UINT id) { intr |= ch->intr; r = FALSE; if (intr) { - 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) + { if (intr & bit) { if (!(ch->cmd[i] & 0x80)) { intr ^= bit; @@ -163,6 +165,8 @@ BRESULT ieitem_ctc(UINT id) { #if 0 // アークスのタイミング→あとで修正 else if (0) #elif 1 + else if ((ch->countmax[i] - ch->count[i]) >= ch->range[i]) +#elif 0 else if (((ch->cmd[i] & 0x10) == 0) && ((ch->countmax[i] - ch->count[i]) >= (256 >> 1))) #else @@ -174,7 +178,7 @@ BRESULT ieitem_ctc(UINT id) { else if (!r) { r = TRUE; intr ^= bit; -// TRACEOUT(("ctc int %d %d", ch->num, i)); + TRACEOUT(("ctc int %d %d [%.2x]", ch->num, i, ch->cmd[i])); Z80_INTERRUPT((REG8)(ch->vector + (i << 1))); } } @@ -212,10 +216,11 @@ static void ctcch_o(CTCCH *ch, UINT port scale = 4 - 1; } } - count <<= scale; ch->scale[port] = scale; - ch->countmax[port] = count; - ch->count[port] = count; + ch->countmax[port] = count << scale; + ch->count[port] = count << scale; +// ch->range[port] = ((count + 3) >> 2) << scale; + ch->range[port] = 4 << scale; ch->cmd[port] &= ~6; ctcnextevent(ch); }