--- np2/sound/cs4231c.c 2003/10/16 17:58:08 1.1 +++ np2/sound/cs4231c.c 2003/12/08 00:55:33 1.4 @@ -1,11 +1,13 @@ #include "compiler.h" -#include "memory.h" #include "pccore.h" #include "iocore.h" #include "sound.h" #include "fmboard.h" + CS4231CFG cs4231cfg; + + static const UINT16 cs4231samprate[] = { 8000, 5510, 16000, 11025, 27420, 18900, 32000, 22050, @@ -18,7 +20,7 @@ static const BYTE dmairq[] = {0xff, 0x03 void cs4231_initialize(UINT rate) { - (void)rate; + cs4231cfg.rate = rate; } void cs4231_setvol(UINT vol) { @@ -29,7 +31,7 @@ void cs4231_setvol(UINT vol) { void cs4231_dma(NEVENTITEM item) { - BYTE ret; + REG8 ret; SINT32 cnt; if (item->flag & NEVENT_SETEVENT) { @@ -42,20 +44,24 @@ void cs4231_dma(NEVENTITEM item) { pic_setirq(0x0c); } } - cnt = pc.realclock * 16 / opna_rate; - nevent_set(NEVENT_CS4231, cnt, cs4231_dma, NEVENT_RELATIVE); + if (cs4231cfg.rate) { + cnt = pc.realclock * 16 / cs4231cfg.rate; + nevent_set(NEVENT_CS4231, cnt, cs4231_dma, NEVENT_RELATIVE); + } } (void)item; } -BYTE DMACCALL cs4231dmafunc(BYTE func) { +REG8 DMACCALL cs4231dmafunc(REG8 func) { SINT32 cnt; switch(func) { case DMAEXT_START: - cnt = pc.realclock * 16 / opna_rate; - nevent_set(NEVENT_CS4231, cnt, cs4231_dma, NEVENT_ABSOLUTE); + if (cs4231cfg.rate) { + cnt = pc.realclock * 16 / cs4231cfg.rate; + nevent_set(NEVENT_CS4231, cnt, cs4231_dma, NEVENT_ABSOLUTE); + } break; case DMAEXT_BREAK: @@ -78,7 +84,7 @@ void cs4231_update(void) { } -void cs4231_control(UINT index, BYTE value) { +void cs4231_control(UINT index, REG8 value) { *(((BYTE *)(&cs4231.reg)) + index) = value; switch(index) {