--- np2/sound/psggenc.c 2003/12/08 00:55:33 1.8 +++ np2/sound/psggenc.c 2005/05/13 05:47:25 1.12 @@ -7,10 +7,10 @@ PSGGENCFG psggencfg; -static const BYTE psggen_deftbl[0x10] = +static const UINT8 psggen_deftbl[0x10] = {0, 0, 0, 0, 0, 0, 0, 0xbf, 0, 0, 0, 0, 0, 0, 0xff, 0xff}; -static const BYTE psgenv_pat[16] = { +static const UINT8 psgenv_pat[16] = { PSGENV_ONESHOT, PSGENV_ONESHOT, PSGENV_ONESHOT, @@ -67,23 +67,32 @@ void psggen_reset(PSGGEN psg) { ZeroMemory(psg, sizeof(_PSGGEN)); for (i=0; i<3; i++) { - psg->tone[i].pvol = &psg->envvol; + psg->tone[i].pvol = psggencfg.volume + 0; } for (i=0; ireg)[i]); + } +} + +void psggen_setreg(PSGGEN psg, UINT reg, REG8 value) { - UINT freq; UINT ch; + UINT freq; - reg &= 15; + reg = reg & 15; if (reg < 14) { sound_sync(); } - ((BYTE *)&psg->reg)[reg] = value; + ((UINT8 *)&psg->reg)[reg] = value; switch(reg) { case 0: case 1: @@ -121,12 +130,12 @@ void psggen_setreg(PSGGEN psg, REG8 reg, case 9: case 10: ch = reg - 8; - keydisp_psgvol(psg, (BYTE)ch); + keydisp_psgvol(psg, (UINT8)ch); if (value & 0x10) { - psg->tone[ch].pvol = &psg->envvol; + psg->tone[ch].pvol = &psg->evol; } else { - psg->tone[ch].pvol = ((BYTE *)&psg->reg) + reg; + psg->tone[ch].pvol = psggencfg.volume + (value & 15); } psg->tone[ch].puchi = psggencfg.puchidec; psg->puchicount = psggencfg.puchidec; @@ -151,9 +160,9 @@ void psggen_setreg(PSGGEN psg, REG8 reg, } } -REG8 psggen_getreg(PSGGEN psg, REG8 reg) { +REG8 psggen_getreg(PSGGEN psg, UINT reg) { - return(((BYTE *)&psg->reg)[reg & 15]); + return(((UINT8 *)&psg->reg)[reg & 15]); } void psggen_setpan(PSGGEN psg, UINT ch, REG8 pan) {