--- np2/sound/opngenc.c 2005/05/13 05:47:25 1.11 +++ np2/sound/opngenc.c 2011/02/04 14:43:55 1.14 @@ -54,8 +54,10 @@ void opngen_initialize(UINT rate) { UINT ratebit; int i; + char sft; int j; double pom; + long detune; double freq; UINT32 calcrate; @@ -73,7 +75,6 @@ void opngen_initialize(UINT rate) { for (i=0; i= 21) - freq = FREQBASE4096 * dttable[i*32 + j] * - (1 << (FREQ_BITS-21)); -#else - freq = FREQBASE4096 * dttable[i*32 + j] / - (1 << (21-FREQ_BITS)); -#endif - detunetable[i][j] = (long)freq; - detunetable[i+4][j] = (long)-freq; + detune = dttable[i*32 + j]; + sft = ratebit + (FREQ_BITS - 21); + if (sft >= 0) { + detune <<= sft; + } + else { + detune >>= (0 - sft); + } + + detunetable[i][j] = detune; + detunetable[i+4][j] = -detune; } } for (i=0; i<4; i++) { @@ -164,10 +167,10 @@ void opngen_initialize(UINT rate) { decaytable[i] = (long)(freq / OPM_DRRATE); #endif if (attacktable[i] >= EC_DECAY) { - TRACEOUT(("attacktable %d %d %d", i, attacktable[i], EC_DECAY)); + TRACEOUT(("attacktable %d %d %ld", i, attacktable[i], EC_DECAY)); } if (decaytable[i] >= EC_DECAY) { - TRACEOUT(("decaytable %d %d %d", i, decaytable[i], EC_DECAY)); + TRACEOUT(("decaytable %d %d %ld", i, decaytable[i], EC_DECAY)); } } attacktable[62] = EC_DECAY - 1; @@ -442,7 +445,7 @@ void opngen_reset(void) { } } -void opngen_setcfg(REG8 maxch, UINT flag) { +void opngen_setcfg(REG8 maxch, UINT32 flag) { OPNCH *ch; UINT i;