--- np2/sound/fmtimer.c 2003/10/16 17:58:02 1.1.1.1 +++ np2/sound/fmtimer.c 2005/05/13 05:47:25 1.11 @@ -1,11 +1,12 @@ #include "compiler.h" +#include "cpucore.h" #include "pccore.h" #include "iocore.h" #include "sound.h" #include "fmboard.h" -static const BYTE irqtable[4] = {0x03, 0x0d, 0x0a, 0x0c}; +static const UINT8 irqtable[4] = {0x03, 0x0d, 0x0a, 0x0c}; void fmport_a(NEVENTITEM item) { @@ -13,19 +14,15 @@ void fmport_a(NEVENTITEM item) { BOOL intreq = FALSE; if (item->flag & NEVENT_SETEVENT) { + intreq = pcm86gen_intrq(); if (fmtimer.reg & 0x04) { fmtimer.status |= 0x01; intreq = TRUE; } - if (pcm86.fifo & 0x20) { - sound_sync(); - if (pcm86.virbuf <= pcm86.fifosize) { - intreq = TRUE; - } - } if (intreq) { - pcm86.write = 1; +// pcm86.write = 1; pic_setirq(fmtimer.irq); +// TRACEOUT(("fm int-A")); } // TRACE_("A: fifo = ", pcm86.fifo); // TRACE_("A: virbuf = ", pcm86.virbuf); @@ -38,19 +35,23 @@ void fmport_b(NEVENTITEM item) { BOOL intreq = FALSE; if (item->flag & NEVENT_SETEVENT) { + intreq = pcm86gen_intrq(); if (fmtimer.reg & 0x08) { 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; +// pcm86.write = 1; pic_setirq(fmtimer.irq); +// TRACEOUT(("fm int-B")); } // TRACE_("B: fifo = ", pcm86.fifo); // TRACE_("B: virbuf = ", pcm86.virbuf); @@ -60,46 +61,44 @@ void fmport_b(NEVENTITEM item) { static void set_fmtimeraevent(BOOL absolute) { - long l = 18 * (1024 - fmtimer.timera); + SINT32 l; - if (pc.cpumode & CPUMODE_8MHz) { // 4MHz - l = (l * 1248 / 625) * pc.multiple; + l = 18 * (1024 - fmtimer.timera); + if (pccore.cpumode & CPUMODE_8MHZ) { // 4MHz + l = (l * 1248 / 625) * pccore.multiple; } - else { // 5MHz - l = (l * 1536 / 625) * pc.multiple; + else { // 5MHz + l = (l * 1536 / 625) * pccore.multiple; } nevent_set(NEVENT_FMTIMERA, l, fmport_a, absolute); } static void set_fmtimerbevent(BOOL absolute) { - long l = 288 * (256 - fmtimer.timerb); + SINT32 l; - if (pc.cpumode & CPUMODE_8MHz) { // 4MHz - l = (l * 1248 / 625) * pc.multiple; + l = 288 * (256 - fmtimer.timerb); + if (pccore.cpumode & CPUMODE_8MHZ) { // 4MHz + l = (l * 1248 / 625) * pccore.multiple; } - else { // 5MHz - l = (l * 1536 / 625) * pc.multiple; + else { // 5MHz + l = (l * 1536 / 625) * pccore.multiple; } nevent_set(NEVENT_FMTIMERB, l, fmport_b, absolute); } -void fmtimer_reset(BYTE irq) { +void fmtimer_reset(UINT irq) { ZeroMemory(&fmtimer, sizeof(fmtimer)); - -#if 1 - fmtimer.reg = 0x3f; // !! - set_fmtimeraevent(NEVENT_ABSOLUTE); - set_fmtimerbevent(NEVENT_ABSOLUTE); -#endif fmtimer.intr = irq & 0xc0; fmtimer.intdisabel = irq & 0x10; fmtimer.irq = irqtable[irq >> 6]; - pic_registext(fmtimer.irq); +// pic_registext(fmtimer.irq); } -void fmtimer_setreg(BYTE reg, BYTE value) { +void fmtimer_setreg(UINT reg, REG8 value) { + +// TRACEOUT(("fm %x %x [%.4x:%.4x]", reg, value, CPU_CS, CPU_IP)); switch(reg) { case 0x24: @@ -115,7 +114,6 @@ void fmtimer_setreg(BYTE reg, BYTE value break; case 0x27: -#if 1 fmtimer.reg = value; fmtimer.status &= ~((value & 0x30) >> 4); if (value & 0x01) { @@ -137,16 +135,6 @@ void fmtimer_setreg(BYTE reg, BYTE value if (!(value & 0x03)) { pic_resetirq(fmtimer.irq); } -#else - fmtimer.reg = value; - fmtimer.status &= ~((value & 0x30) >> 4); - if ((value & 0x10) && (!nevent_iswork(NEVENT_FMTIMERA))) { - set_fmtimeraevent(NEVENT_ABSOLUTE); - } - if ((value & 0x20) && (!nevent_iswork(NEVENT_FMTIMERB))) { - set_fmtimerbevent(NEVENT_ABSOLUTE); - } -#endif break; } }