|
|
| version 1.1, 2003/10/16 17:58:00 | version 1.9, 2007/11/03 00:00:19 |
|---|---|
| Line 9 | Line 9 |
| #include "s98.h" | #include "s98.h" |
| static void IOOUTCALL opn_o088(UINT port, BYTE dat) { | static void IOOUTCALL opn_o088(UINT port, REG8 dat) { |
| opn.opn2reg = dat; | opn.addr2 = dat; |
| opn.data2 = dat; | |
| (void)port; | (void)port; |
| } | } |
| static void IOOUTCALL opn_o08a(UINT port, BYTE dat) { | static void IOOUTCALL opn_o08a(UINT port, REG8 dat) { |
| if (opn.opn2reg < 0x10) { | UINT addr; |
| if (opn.opn2reg != 0x0e) { | |
| psggen_setreg(&psg2, opn.opn2reg, dat); | opn.data2 = dat; |
| addr = opn.addr2; | |
| if (addr < 0x10) { | |
| if (addr != 0x0e) { | |
| psggen_setreg(&psg1, addr, dat); | |
| } | } |
| } | } |
| else { | else { |
| if (opn.opn2reg < 0x30) { | if (addr < 0x30) { |
| if (opn.opn2reg == 0x28) { | if (addr == 0x28) { |
| if ((dat & 0x0f) < 3) { | if ((dat & 0x0f) < 3) { |
| opngen_keyon((dat & 0x0f), dat); | opngen_keyon(dat & 0x0f, dat); |
| } | } |
| } | } |
| else { | else { |
| fmtimer_setreg(opn.opn2reg, dat); | fmtimer_setreg(addr, dat); |
| if (opn.opn2reg == 0x27) { | if (addr == 0x27) { |
| opnch[2].extop = dat & 0xc0; | opnch[2].extop = dat & 0xc0; |
| } | } |
| } | } |
| } | } |
| else if (opn.opn2reg < 0xc0) { | else if (addr < 0xc0) { |
| opngen_setreg(0, opn.opn2reg, dat); | opngen_setreg(0, addr, dat); |
| } | } |
| opn.reg[opn.opn2reg + 0x200] = dat; | opn.reg[addr + 0x200] = dat; |
| } | } |
| (void)port; | (void)port; |
| } | } |
| static BYTE IOINPCALL opn_i088(UINT port) { | static REG8 IOINPCALL opn_i088(UINT port) { |
| (void)port; | (void)port; |
| return(fmtimer.status); | return(fmtimer.status); |
| } | } |
| static BYTE IOINPCALL opn_i08a(UINT port) { | static REG8 IOINPCALL opn_i08a(UINT port) { |
| UINT addr; | |
| if (opn.opn2reg == 0x0e) { | addr = opn.addr2; |
| if (addr == 0x0e) { | |
| return(0xff); | return(0xff); |
| } | } |
| if (opn.opn2reg < 0x10) { | if (addr < 0x10) { |
| return(psggen_getreg(&psg2, opn.opn2reg)); | return(psggen_getreg(&psg1, addr)); |
| } | |
| else { | |
| (void)port; | |
| return(opn.data2); | |
| } | } |
| (void)port; | |
| return(0xff); | |
| } | } |
| // ---- | // ---- |
| static void IOOUTCALL opna_o188(UINT port, BYTE dat) { | static void IOOUTCALL opna_o188(UINT port, REG8 dat) { |
| opn.opnreg = dat; | opn.addr = dat; |
| opn.data = dat; | |
| (void)port; | (void)port; |
| } | } |
| static void IOOUTCALL opna_o18a(UINT port, BYTE dat) { | static void IOOUTCALL opna_o18a(UINT port, REG8 dat) { |
| UINT addr; | |
| S98_put(NORMAL2608, opn.opnreg, dat); | opn.data = dat; |
| if (opn.opnreg < 0x10) { | addr = opn.addr; |
| if (opn.opnreg != 0x0e) { | if (addr >= 0x100) { |
| psggen_setreg(&psg1, opn.opnreg, dat); | return; |
| } | |
| S98_put(NORMAL2608, addr, dat); | |
| if (addr < 0x10) { | |
| if (addr != 0x0e) { | |
| psggen_setreg(&psg2, addr, dat); | |
| } | } |
| } | } |
| else { | else { |
| if (opn.opnreg < 0x20) { | if (addr < 0x20) { |
| if (opn.extend) { | if (opn.extend) { |
| rhythm_setreg(&rhythm, opn.opnreg, dat); | rhythm_setreg(&rhythm, addr, dat); |
| } | } |
| } | } |
| else if (opn.opnreg < 0x30) { | else if (addr < 0x30) { |
| if (opn.opnreg == 0x28) { | if (addr == 0x28) { |
| if ((dat & 0x0f) < 3) { | if ((dat & 0x0f) < 3) { |
| opngen_keyon((dat & 0x0f)+3, dat); | opngen_keyon((dat & 0x0f) + 3, dat); |
| } | } |
| else if (((dat & 0x0f) != 3) && | else if (((dat & 0x0f) != 3) && |
| ((dat & 0x0f) < 7)) { | ((dat & 0x0f) < 7)) { |
| opngen_keyon((dat & 0x0f)+2, dat); | opngen_keyon((dat & 0x0f) + 2, dat); |
| } | } |
| } | } |
| else { | else { |
| fmtimer_setreg(opn.opnreg, dat); | fmtimer_setreg(addr, dat); |
| if (opn.opnreg == 0x27) { | if (addr == 0x27) { |
| opnch[2].extop = dat & 0xc0; | opnch[2].extop = dat & 0xc0; |
| } | } |
| } | } |
| } | } |
| else if (opn.opnreg < 0xc0) { | else if (addr < 0xc0) { |
| opngen_setreg(3, opn.opnreg, dat); | opngen_setreg(3, addr, dat); |
| } | } |
| opn.reg[opn.opnreg] = dat; | opn.reg[addr] = dat; |
| } | } |
| (void)port; | (void)port; |
| } | } |
| static void IOOUTCALL opna_o18c(UINT port, BYTE dat) { | static void IOOUTCALL opna_o18c(UINT port, REG8 dat) { |
| opn.extreg = dat; | if (opn.extend) { |
| opn.addr = dat + 0x100; | |
| opn.data = dat; | |
| } | |
| (void)port; | (void)port; |
| } | } |
| static void IOOUTCALL opna_o18e(UINT port, BYTE dat) { | static void IOOUTCALL opna_o18e(UINT port, REG8 dat) { |
| S98_put(EXTEND2608, opn.extreg, dat); | UINT addr; |
| opn.reg[opn.extreg + 0x100] = dat; | |
| if (opn.extreg >= 0x30) { | if (!opn.extend) { |
| opngen_setreg(6, opn.extreg, dat); | return; |
| } | |
| addr = opn.addr - 0x100; | |
| if (addr >= 0x100) { | |
| return; | |
| } | |
| S98_put(EXTEND2608, addr, dat); | |
| opn.reg[addr + 0x100] = dat; | |
| if (addr >= 0x30) { | |
| opngen_setreg(6, addr, dat); | |
| } | } |
| else { | else { |
| if (opn.extreg == 0x10) { | if (addr == 0x10) { |
| if (!(dat & 0x80)) { | if (!(dat & 0x80)) { |
| opn.adpcmmask = ~(dat & 0x1c); | opn.adpcmmask = ~(dat & 0x1c); |
| } | } |
| Line 133 static void IOOUTCALL opna_o18e(UINT por | Line 163 static void IOOUTCALL opna_o18e(UINT por |
| (void)port; | (void)port; |
| } | } |
| static BYTE IOINPCALL opna_i188(UINT port) { | static REG8 IOINPCALL opna_i188(UINT port) { |
| (void)port; | (void)port; |
| return(fmtimer.status); | return(fmtimer.status); |
| } | } |
| static BYTE IOINPCALL opna_i18a(UINT port) { | static REG8 IOINPCALL opna_i18a(UINT port) { |
| if (opn.opnreg == 0x0e) { | UINT addr; |
| return(fmboard_getjoy(&psg1)); | |
| addr = opn.addr; | |
| if (addr == 0x0e) { | |
| return(fmboard_getjoy(&psg2)); | |
| } | } |
| else if (opn.opnreg < 0x10) { | else if (addr < 0x10) { |
| return(psggen_getreg(&psg1, opn.opnreg)); | return(psggen_getreg(&psg2, addr)); |
| } | |
| else if (addr == 0xff) { | |
| return(1); | |
| } | |
| else { | |
| (void)port; | |
| return(opn.data); | |
| } | } |
| (void)port; | |
| return(opn.reg[opn.opnreg]); | |
| } | } |
| static BYTE IOINPCALL opna_i18c(UINT port) { | static REG8 IOINPCALL opna_i18c(UINT port) { |
| if (opn.extend) { | if (opn.extend) { |
| return((fmtimer.status & 3) | (opn.adpcmmask & 8)); | return((fmtimer.status & 3) | (opn.adpcmmask & 8)); |
| Line 160 static BYTE IOINPCALL opna_i18c(UINT por | Line 198 static BYTE IOINPCALL opna_i18c(UINT por |
| return(0xff); | return(0xff); |
| } | } |
| static BYTE IOINPCALL opna_i18e(UINT port) { | static REG8 IOINPCALL opna_i18e(UINT port) { |
| if (opn.extend) { | if (opn.extend) { |
| return(opn.reg[opn.opnreg]); | UINT addr = opn.addr - 0x100; |
| if ((addr == 0x08) || (addr == 0x0f)) { | |
| return(opn.reg[addr + 0x100]); | |
| } | |
| return(opn.data); | |
| } | } |
| (void)port; | (void)port; |
| return(0xff); | return(0xff); |
| } | } |
| static void extendchannel(BYTE enable) { | static void extendchannel(REG8 enable) { |
| opn.extend = enable; | opn.extend = enable; |
| if (enable) { | if (enable) { |
| Line 199 static const IOINP opna_i[4] = { | Line 241 static const IOINP opna_i[4] = { |
| opna_i188, opna_i18a, opna_i18c, opna_i18e}; | opna_i188, opna_i18a, opna_i18c, opna_i18e}; |
| void boardx2_reset(void) { | void boardx2_reset(const NP2CFG *pConfig) { |
| fmtimer_reset(0xc0); | fmtimer_reset(0xc0); |
| opn.channels = 6; | opn.channels = 6; |
| opngen_setcfg(6, OPN_STEREO | 0x1c0); | opngen_setcfg(6, OPN_STEREO | 0x1c0); |
| soundrom_load(0xcc000, "86"); | soundrom_load(0xcc000, OEMTEXT("86")); |
| fmboard_extreg(extendchannel); | fmboard_extreg(extendchannel); |
| (void)pConfig; | |
| } | } |
| void boardx2_bind(void) { | void boardx2_bind(void) { |
| fmboard_fmrestore(0, 2); | |
| fmboard_fmrestore(3, 0); | |
| fmboard_fmrestore(6, 1); | |
| psggen_restore(&psg1); | |
| psggen_restore(&psg2); | |
| fmboard_rhyrestore(&rhythm, 0); | |
| sound_streamregist(&opngen, (SOUNDCB)opngen_getpcm); | sound_streamregist(&opngen, (SOUNDCB)opngen_getpcm); |
| sound_streamregist(&psg1, (SOUNDCB)psggen_getpcm); | sound_streamregist(&psg1, (SOUNDCB)psggen_getpcm); |
| sound_streamregist(&psg2, (SOUNDCB)psggen_getpcm); | sound_streamregist(&psg2, (SOUNDCB)psggen_getpcm); |
| sound_streamregist(&rhythm, (SOUNDCB)rhythm_getpcm); | rhythm_bind(&rhythm); |
| pcm86io_bind(); | pcm86io_bind(); |
| cbuscore_attachsndex(0x088, opn_o, opn_i); | cbuscore_attachsndex(0x088, opn_o, opn_i); |
| cbuscore_attachsndex(0x188, opna_o, opna_i); | cbuscore_attachsndex(0x188, opna_o, opna_i); |