Selaa lähdekoodia

Add sweep limits to APU square channels

master
Nathaniel Walizer 11 kuukautta sitten
vanhempi
commit
4468c8aed5
1 muutettua tiedostoa jossa 8 lisäystä ja 2 poistoa
  1. +8
    -2
      src/apu.c

+ 8
- 2
src/apu.c Näytä tiedosto

@@ -239,7 +239,11 @@ static inline void nes_apu_clock_sweep(nes_apu_Channel* channel,

if (channel->sweep_delay == 0) {
decrement = 0;
if ( (channel->reg[1] & apu_Square_Enable) &&
if (channel->period < 8 * nes_clock_cpu_div) {
channel->period = 0;
channel->length = 0;

} else if ( (channel->reg[1] & apu_Square_Enable) &&
0 != (channel->reg[1] & apu_Square_Shift)) {
int delta = (
apu_channel_raw_timer_value(channel) >>
@@ -249,8 +253,10 @@ static inline void nes_apu_clock_sweep(nes_apu_Channel* channel,
delta = adjust - delta;
}
channel->period += delta * nes_clock_apu_div;
if (channel->period < 0) {
if ( channel < 0 ||
channel->period > 0x7FFU * nes_clock_cpu_div) {
channel->period = 0;
channel->length = 0;
}
}
}


Loading…
Peruuta
Tallenna