PowerNoise: octave 5+ fix

from upstream
This commit is contained in:
tildearrow 2024-01-25 01:30:39 -05:00
parent ee243a68c6
commit 9a6b5fb850
2 changed files with 4 additions and 5 deletions

View file

@ -47,9 +47,9 @@ void pwrnoise_noise_step(noise_channel_t *chan, uint16_t cycles) {
}
chan->octave_counter += cycles;
if ((cycles > 2) || (!(((chan->octave_counter - 1) >> chan->octave) & 0x0001) && ((chan->octave_counter >> chan->octave) & 0x0001))) {
if (((cycles >= 2) && ((cycles >> (chan->octave + 1)) != 0)) || (!(((chan->octave_counter - 1) >> chan->octave) & 0x0001) && ((chan->octave_counter >> chan->octave) & 0x0001))) {
chan->period_counter += (cycles >> (chan->octave + 1));
if (cycles == 1) ++chan->period_counter;
if ((cycles >> (chan->octave + 1)) == 0) ++chan->period_counter;
if (chan->period_counter >= 4096) {
chan->prev = (uint8_t)(chan->lfsr >> 15);
@ -107,9 +107,9 @@ void pwrnoise_slope_step(slope_channel_t *chan, uint16_t cycles, bool force_zero
}
chan->octave_counter += cycles;
if ((cycles > 2) || (!(((chan->octave_counter - 1) >> chan->octave) & 0x0001) && ((chan->octave_counter >> chan->octave) & 0x0001))) {
if (((cycles >= 2) && ((cycles >> (chan->octave + 1)) != 0)) || (!(((chan->octave_counter - 1) >> chan->octave) & 0x0001) && ((chan->octave_counter >> chan->octave) & 0x0001))) {
chan->period_counter += (cycles >> (chan->octave + 1));
if (cycles == 1) ++chan->period_counter;
if ((cycles >> (chan->octave + 1)) == 0) ++chan->period_counter;
if (chan->period_counter >= 4096) {
if (!chan->portion) {

View file

@ -214,7 +214,6 @@ void DivPlatformPowerNoise::tick(bool sysTick) {
chan[i].fNum=0x1000-(chan[i].freq>>chan[i].octave);
if (chan[i].fNum<0) chan[i].fNum=0;
if (chan[i].fNum>4095) chan[i].fNum=4095;
logV("%.4x (%x, %x)",chan[i].fNum,chan[i].octave,chan[i].freq);
chWrite(i,0x01,chan[i].fNum&0xff);
chWrite(i,0x02,(chan[i].fNum>>8)|(chan[i].octave<<4));