|
|
| version 1.10, 2004/08/13 03:47:23 | version 1.12, 2004/08/14 12:16:17 |
|---|---|
| Line 16 static SINT32 minclock(const CTCCH *ch) | Line 16 static SINT32 minclock(const CTCCH *ch) |
| for (i=0; i<3; i++) { | for (i=0; i<3; i++) { |
| if ((ch->cmd[i] & 0x82) == 0x80) { | if ((ch->cmd[i] & 0x82) == 0x80) { |
| clock = ch->count[i]; | clock = ch->count[i]; |
| if (ch->cmd[i] & 0x40) { | |
| clock = clock * 2; | |
| } | |
| event = min(event, clock); | event = min(event, clock); |
| } | } |
| } | } |
| Line 27 static SINT32 minclock(const CTCCH *ch) | Line 24 static SINT32 minclock(const CTCCH *ch) |
| if (ch->cmd[3] & 0x40) { | if (ch->cmd[3] & 0x40) { |
| clock = (clock - 1) * ch->countmax[0]; | clock = (clock - 1) * ch->countmax[0]; |
| clock += ch->count[0]; | clock += ch->count[0]; |
| if (ch->cmd[0] & 0x40) { | |
| clock = clock * 2; | |
| } | |
| } | } |
| event = min(event, clock); | event = min(event, clock); |
| } | } |
| event = event / 2; | |
| if (event == 0) { | if (event == 0) { |
| event = 1; | event = 1; |
| } | } |
| Line 59 static REG8 ctcwork(CTCCH *ch) { | Line 52 static REG8 ctcwork(CTCCH *ch) { |
| // 0 | // 0 |
| if (!(ch->cmd[0] & 0x02)) { | if (!(ch->cmd[0] & 0x02)) { |
| pulse = stepclock; // 2MHz | pulse = stepclock; |
| if (!(ch->cmd[0] & 0x40)) { | |
| pulse = pulse * 2; // 4MHz | |
| } | |
| count = ch->count[0]; | count = ch->count[0]; |
| count -= pulse; | count -= pulse; |
| if (count <= 0) { | if (count <= 0) { |
| Line 77 static REG8 ctcwork(CTCCH *ch) { | Line 67 static REG8 ctcwork(CTCCH *ch) { |
| // 3 | // 3 |
| if (!(ch->cmd[3] & 0x02)) { | if (!(ch->cmd[3] & 0x02)) { |
| if (!(ch->cmd[3] & 0x40)) { | if (!(ch->cmd[3] & 0x40)) { |
| pulse3 = stepclock * 2; // 4MHz | pulse3 = stepclock; |
| } | } |
| count = ch->count[3]; | count = ch->count[3]; |
| count -= pulse3; | count -= pulse3; |
| if (count <= 0) { | if (count <= 0) { |
| count = ch->countmax[3] - ((0 - count) % ch->countmax[3]); | count = ch->countmax[3] - ((0 - count) % ch->countmax[3]); |
| intr |= (ch->cmd[3] & 0x80) >> (7 - 3); | intr |= (ch->cmd[3] & 0x80) >> (7 - 3); |
| TRACEOUT(("ctc3 !")); | |
| } | } |
| ch->count[3] = count; | ch->count[3] = count; |
| } | } |
| // 1 | // 1 |
| if (!(ch->cmd[1] & 0x02)) { | if (!(ch->cmd[1] & 0x02)) { |
| pulse = stepclock; // 2MHz | pulse = stepclock; |
| if (!(ch->cmd[1] & 0x40)) { | |
| pulse = pulse * 2; // 4MHz | |
| } | |
| count = ch->count[1]; | count = ch->count[1]; |
| count -= pulse; | count -= pulse; |
| if (count <= 0) { | if (count <= 0) { |
| Line 105 static REG8 ctcwork(CTCCH *ch) { | Line 93 static REG8 ctcwork(CTCCH *ch) { |
| // 2 | // 2 |
| if (!(ch->cmd[2] & 0x02)) { | if (!(ch->cmd[2] & 0x02)) { |
| pulse = stepclock; // 2MHz | pulse = stepclock; |
| if (!(ch->cmd[2] & 0x40)) { | |
| pulse = pulse * 2; // 4MHz | |
| } | |
| count = ch->count[2]; | count = ch->count[2]; |
| count -= pulse; | count -= pulse; |
| if (count <= 0) { | if (count <= 0) { |
| Line 180 BRESULT ieitem_ctc(UINT id) { | Line 165 BRESULT ieitem_ctc(UINT id) { |
| else if (0) | else if (0) |
| #elif 1 | #elif 1 |
| else if (((ch->cmd[i] & 0x10) == 0) && | else if (((ch->cmd[i] & 0x10) == 0) && |
| ((ch->countmax[i] - ch->count[i]) >= 256)) | ((ch->countmax[i] - ch->count[i]) >= (256 >> 1))) |
| #elif 0 | |
| else if (((ch->count[i] * 17) >> 4) < ch->countmax[i]) | |
| #else | #else |
| else if (ch->count[i] != ch->countmax[i]) | else if (ch->count[i] != ch->countmax[i]) |
| #endif | #endif |
| Line 192 BRESULT ieitem_ctc(UINT id) { | Line 175 BRESULT ieitem_ctc(UINT id) { |
| else if (!r) { | else if (!r) { |
| r = TRUE; | r = TRUE; |
| intr ^= bit; | intr ^= bit; |
| // TRACEOUT(("ctc int %d %d", ch->num, i)); | TRACEOUT(("ctc int %d %d", ch->num, i)); |
| Z80_INTERRUPT((REG8)(ch->vector + (i << 1))); | Z80_INTERRUPT((REG8)(ch->vector + (i << 1))); |
| } | } |
| } | } |
| Line 220 static void ctcch_o(CTCCH *ch, UINT port | Line 203 static void ctcch_o(CTCCH *ch, UINT port |
| if (ch->cmd[port] & 0x04) { | if (ch->cmd[port] & 0x04) { |
| ctcstep(ch); | ctcstep(ch); |
| ch->basecnt[port] = value; | ch->basecnt[port] = value; |
| count = 256; | count = ((value - 1) & 0xff) + 1; |
| if (value) { | |
| count = (SINT32)value; | |
| } | |
| scale = 0; | scale = 0; |
| if (!(ch->cmd[port] & 0x40)) { | if (!(ch->cmd[port] & 0x40)) { |
| if (ch->cmd[port] & 0x20) { | if (ch->cmd[port] & 0x20) { |
| scale = 8; | scale = 8 - 1; |
| } | } |
| else { | else { |
| scale = 4; | scale = 4 - 1; |
| } | } |
| } | } |
| count <<= scale; | count <<= scale; |
| Line 316 void ctc_reset(void) { | Line 296 void ctc_reset(void) { |
| for (i=0; i<3; i++) { | for (i=0; i<3; i++) { |
| ctc.ch[i].num = (UINT8)i; | ctc.ch[i].num = (UINT8)i; |
| for (j=0; j<4; j++) { | for (j=0; j<4; j++) { |
| ctc.ch[i].cmd[j] = 0x03; | ctc.ch[i].cmd[j] = 0x23; |
| ctc.ch[i].scale[j] = 8; | ctc.ch[i].scale[j] = 7; |
| ctc.ch[i].count[j] = 256 << 8; | ctc.ch[i].count[j] = 256 << 7; |
| ctc.ch[i].countmax[j] = 256 << 8; | ctc.ch[i].countmax[j] = 256 << 7; |
| } | } |
| } | } |
| } | } |