--- np2/sound/fmtimer.c 2004/03/30 07:12:03 1.10 +++ np2/sound/fmtimer.c 2007/10/26 14:38:33 1.12 @@ -9,6 +9,37 @@ static const UINT8 irqtable[4] = {0x03, 0x0d, 0x0a, 0x0c}; +static void set_fmtimeraevent(BOOL absolute) { + + SINT32 l; + + l = 18 * (1024 - fmtimer.timera); + if (pccore.cpumode & CPUMODE_8MHZ) { // 4MHz + l = (l * 1248 / 625) * pccore.multiple; + } + else { // 5MHz + l = (l * 1536 / 625) * pccore.multiple; + } +// TRACEOUT(("FMTIMER-A: %08x-%d", l, absolute)); + nevent_set(NEVENT_FMTIMERA, l, fmport_a, absolute); +} + +static void set_fmtimerbevent(BOOL absolute) { + + SINT32 l; + + l = 288 * (256 - fmtimer.timerb); + if (pccore.cpumode & CPUMODE_8MHZ) { // 4MHz + l = (l * 1248 / 625) * pccore.multiple; + } + else { // 5MHz + l = (l * 1536 / 625) * pccore.multiple; + } +// TRACEOUT(("FMTIMER-B: %08x-%d", l, absolute)); + nevent_set(NEVENT_FMTIMERB, l, fmport_b, absolute); +} + + void fmport_a(NEVENTITEM item) { BOOL intreq = FALSE; @@ -20,13 +51,11 @@ void fmport_a(NEVENTITEM item) { intreq = TRUE; } if (intreq) { -// pcm86.write = 1; pic_setirq(fmtimer.irq); // TRACEOUT(("fm int-A")); } -// TRACE_("A: fifo = ", pcm86.fifo); -// TRACE_("A: virbuf = ", pcm86.virbuf); -// TRACE_("A: fifosize = ", pcm86.fifosize); + + set_fmtimeraevent(FALSE); } } @@ -40,51 +69,13 @@ void fmport_b(NEVENTITEM item) { fmtimer.status |= 0x02; intreq = TRUE; } -#if 0 - if (pcm86.fifo & 0x20) { - sound_sync(); - if (pcm86.virbuf <= pcm86.fifosize) { - intreq = TRUE; - } - } -#endif if (intreq) { -// pcm86.write = 1; pic_setirq(fmtimer.irq); // TRACEOUT(("fm int-B")); } -// TRACE_("B: fifo = ", pcm86.fifo); -// TRACE_("B: virbuf = ", pcm86.virbuf); -// TRACE_("B: fifosize = ", pcm86.fifosize); - } -} - -static void set_fmtimeraevent(BOOL absolute) { - - SINT32 l; - - l = 18 * (1024 - fmtimer.timera); - if (pccore.cpumode & CPUMODE_8MHZ) { // 4MHz - l = (l * 1248 / 625) * pccore.multiple; - } - else { // 5MHz - l = (l * 1536 / 625) * pccore.multiple; - } - nevent_set(NEVENT_FMTIMERA, l, fmport_a, absolute); -} - -static void set_fmtimerbevent(BOOL absolute) { - SINT32 l; - - l = 288 * (256 - fmtimer.timerb); - if (pccore.cpumode & CPUMODE_8MHZ) { // 4MHz - l = (l * 1248 / 625) * pccore.multiple; - } - else { // 5MHz - l = (l * 1536 / 625) * pccore.multiple; + set_fmtimerbevent(FALSE); } - nevent_set(NEVENT_FMTIMERB, l, fmport_b, absolute); } void fmtimer_reset(UINT irq) { @@ -96,7 +87,7 @@ void fmtimer_reset(UINT irq) { // pic_registext(fmtimer.irq); } -void fmtimer_setreg(REG8 reg, REG8 value) { +void fmtimer_setreg(UINT reg, REG8 value) { // TRACEOUT(("fm %x %x [%.4x:%.4x]", reg, value, CPU_CS, CPU_IP)); @@ -124,6 +115,7 @@ void fmtimer_setreg(REG8 reg, REG8 value else { nevent_reset(NEVENT_FMTIMERA); } + if (value & 0x02) { if (!nevent_iswork(NEVENT_FMTIMERB)) { set_fmtimerbevent(NEVENT_ABSOLUTE); @@ -132,6 +124,7 @@ void fmtimer_setreg(REG8 reg, REG8 value else { nevent_reset(NEVENT_FMTIMERB); } + if (!(value & 0x03)) { pic_resetirq(fmtimer.irq); }