|
|
| version 1.1, 2003/10/16 17:58:01 | version 1.7, 2004/03/30 08:48:46 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "dosio.h" | #include "cpucore.h" |
| #include "i286.h" | |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "pcm86io.h" | |
| #include "sound.h" | #include "sound.h" |
| #include "fmboard.h" | #include "fmboard.h" |
| #include "pcm86io.h" | |
| extern PCM86CFG pcm86cfg; | extern PCM86CFG pcm86cfg; |
| static const BYTE pcm86bits[] = {1, 1, 1, 2, 0, 0, 0, 1}; | static const UINT8 pcm86bits[] = {1, 1, 1, 2, 0, 0, 0, 1}; |
| static const SINT32 pcm86rescue[] = {PCM86_RESCUE * 32, PCM86_RESCUE * 24, | static const SINT32 pcm86rescue[] = {PCM86_RESCUE * 32, PCM86_RESCUE * 24, |
| PCM86_RESCUE * 16, PCM86_RESCUE * 12, | PCM86_RESCUE * 16, PCM86_RESCUE * 12, |
| PCM86_RESCUE * 8, PCM86_RESCUE * 6, | PCM86_RESCUE * 8, PCM86_RESCUE * 6, |
| PCM86_RESCUE * 4, PCM86_RESCUE * 3}; | PCM86_RESCUE * 4, PCM86_RESCUE * 3}; |
| static void IOOUTCALL pcm86_oa460(UINT port, BYTE val) { | static void IOOUTCALL pcm86_oa460(UINT port, REG8 val) { |
| pcm86.extfunc = val; | pcm86.extfunc = val; |
| fmboard_extenable((BYTE)(val & 1)); | fmboard_extenable((REG8)(val & 1)); |
| (void)port; | (void)port; |
| } | } |
| static void IOOUTCALL pcm86_oa466(UINT port, BYTE val) { | static void IOOUTCALL pcm86_oa466(UINT port, REG8 val) { |
| if ((val & 0xe0) == 0xa0) { | if ((val & 0xe0) == 0xa0) { |
| sound_sync(); | sound_sync(); |
| Line 35 static void IOOUTCALL pcm86_oa466(UINT p | Line 34 static void IOOUTCALL pcm86_oa466(UINT p |
| (void)port; | (void)port; |
| } | } |
| static void IOOUTCALL pcm86_oa468(UINT port, BYTE val) { | static void IOOUTCALL pcm86_oa468(UINT port, REG8 val) { |
| BYTE xchgbit; | REG8 xchgbit; |
| sound_sync(); | sound_sync(); |
| xchgbit = pcm86.fifo ^ val; | xchgbit = pcm86.fifo ^ val; |
| Line 47 static void IOOUTCALL pcm86_oa468(UINT p | Line 46 static void IOOUTCALL pcm86_oa468(UINT p |
| pcm86.wrtpos = 0; | pcm86.wrtpos = 0; |
| pcm86.realbuf = 0; | pcm86.realbuf = 0; |
| pcm86.virbuf = 0; | pcm86.virbuf = 0; |
| pcm86.lastclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK; | |
| pcm86.lastclock <<= 6; | |
| } | |
| if ((xchgbit & 0x10) && (!(val & 0x10))) { | |
| pcm86.write = 0; | pcm86.write = 0; |
| pcm86.reqirq = 0; | pcm86.reqirq = 0; |
| pcm86.lastclock = nevent.clock + nevent.baseclock - | |
| nevent.remainclock; | |
| pcm86.lastclock <<= 6; | |
| } | } |
| // サンプリングレート変更 | // サンプリングレート変更 |
| if (xchgbit & 7) { | if (xchgbit & 7) { |
| Line 60 static void IOOUTCALL pcm86_oa468(UINT p | Line 60 static void IOOUTCALL pcm86_oa468(UINT p |
| } | } |
| pcm86.fifo = val & (~0x10); | pcm86.fifo = val & (~0x10); |
| if ((xchgbit & 0x80) && (val & 0x80)) { | if ((xchgbit & 0x80) && (val & 0x80)) { |
| pcm86.lastclock = nevent.clock + nevent.baseclock - | pcm86.lastclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK; |
| nevent.remainclock; | |
| pcm86.lastclock <<= 6; | pcm86.lastclock <<= 6; |
| } | } |
| pcm86.write = 1; | |
| pcm86_setnextintr(); | pcm86_setnextintr(); |
| (void)port; | (void)port; |
| } | } |
| static void IOOUTCALL pcm86_oa46a(UINT port, BYTE val) { | static void IOOUTCALL pcm86_oa46a(UINT port, REG8 val) { |
| sound_sync(); | sound_sync(); |
| if (pcm86.fifo & 0x20) { | if (pcm86.fifo & 0x20) { |
| Line 97 static void IOOUTCALL pcm86_oa46a(UINT p | Line 95 static void IOOUTCALL pcm86_oa46a(UINT p |
| (void)port; | (void)port; |
| } | } |
| static void IOOUTCALL pcm86_oa46c(UINT port, BYTE val) { | static void IOOUTCALL pcm86_oa46c(UINT port, REG8 val) { |
| if (pcm86.virbuf < PCM86_LOGICALBUF) { | if (pcm86.virbuf < PCM86_LOGICALBUF) { |
| pcm86.virbuf++; | pcm86.virbuf++; |
| Line 115 static void IOOUTCALL pcm86_oa46c(UINT p | Line 113 static void IOOUTCALL pcm86_oa46c(UINT p |
| (void)port; | (void)port; |
| } | } |
| static BYTE IOINPCALL pcm86_ia460(UINT port) { | static REG8 IOINPCALL pcm86_ia460(UINT port) { |
| (void)port; | (void)port; |
| return(0x40 | (pcm86.extfunc & 1)); | return(0x40 | (pcm86.extfunc & 1)); |
| } | } |
| static BYTE IOINPCALL pcm86_ia466(UINT port) { | static REG8 IOINPCALL pcm86_ia466(UINT port) { |
| UINT32 nowclk; | |
| UINT32 past; | UINT32 past; |
| BYTE ret; | UINT32 cnt; |
| UINT32 stepclock; | |
| sound_sync(); | REG8 ret; |
| nowclk = nevent.clock + nevent.baseclock - nevent.remainclock; | |
| nowclk <<= 6; | past = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK; |
| past = nowclk - pcm86.lastclock; | past <<= 6; |
| if (past >= pcm86.stepclock) { | past -= pcm86.lastclock; |
| RECALC_NOWCLKWAIT; | stepclock = pcm86.stepclock; |
| past = nowclk - pcm86.lastclock; | if (past >= stepclock) { |
| cnt = past / stepclock; | |
| pcm86.lastclock += (cnt * stepclock); | |
| past -= cnt * stepclock; | |
| if (pcm86.fifo & 0x80) { | |
| sound_sync(); | |
| RECALC_NOWCLKWAIT(cnt); | |
| } | |
| } | } |
| ret = ((past << 1) >= pcm86.stepclock)?1:0; | ret = ((past << 1) >= stepclock)?1:0; |
| if (pcm86.virbuf >= PCM86_LOGICALBUF) { // バッファフル | if (pcm86.virbuf >= PCM86_LOGICALBUF) { // バッファフル |
| ret |= 0x80; | ret |= 0x80; |
| } | } |
| Line 146 static BYTE IOINPCALL pcm86_ia466(UINT p | Line 150 static BYTE IOINPCALL pcm86_ia466(UINT p |
| return(ret); | return(ret); |
| } | } |
| static BYTE IOINPCALL pcm86_ia468(UINT port) { | static REG8 IOINPCALL pcm86_ia468(UINT port) { |
| BYTE ret; | REG8 ret; |
| ret = pcm86.fifo & (~0x10); | ret = pcm86.fifo & (~0x10); |
| #if 1 | |
| if (pcm86gen_intrq()) { | |
| ret |= 0x10; | |
| } | |
| #elif 1 // むしろこう? | |
| if (pcm86.fifo & 0x20) { | |
| sound_sync(); | |
| if (pcm86.virbuf <= pcm86.fifosize) { | |
| if (pcm86.write) { | |
| pcm86.write = 0; | |
| } | |
| else { | |
| ret |= 0x10; | |
| } | |
| } | |
| } | |
| #else | |
| if ((pcm86.write) && (pcm86.fifo & 0x20)) { | if ((pcm86.write) && (pcm86.fifo & 0x20)) { |
| // pcm86.write = 0; | // pcm86.write = 0; |
| sound_sync(); | sound_sync(); |
| Line 159 static BYTE IOINPCALL pcm86_ia468(UINT p | Line 180 static BYTE IOINPCALL pcm86_ia468(UINT p |
| ret |= 0x10; | ret |= 0x10; |
| } | } |
| } | } |
| #endif | |
| (void)port; | (void)port; |
| return(ret); | return(ret); |
| } | } |
| static BYTE IOINPCALL pcm86_ia46a(UINT port) { | static REG8 IOINPCALL pcm86_ia46a(UINT port) { |
| (void)port; | (void)port; |
| return(pcm86.dactrl); | return(pcm86.dactrl); |
| } | } |
| static BYTE IOINPCALL pcm86_inpdummy(UINT port) { | static REG8 IOINPCALL pcm86_inpdummy(UINT port) { |
| (void)port; | (void)port; |
| return(0); | return(0); |