Browse Source

Fix APU DMC direct load

master
Nathaniel Walizer 10 months ago
parent
commit
daddf0ed2d
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      src/apu.c

+ 5
- 4
src/apu.c View File

@@ -386,14 +386,15 @@ static int channel_update(nes_apu_Channel* channel) {
static void nes_apu_run_dmc(nes_apu* apu, static void nes_apu_run_dmc(nes_apu* apu,
nes_apu_Channel* channel, nes_apu_Channel* channel,
int cycles) { int cycles) {
if (channel->length <= 0 || channel->period <= 0) return;

// Always do this in order to support direct load
int time = apu->time; int time = apu->time;
int delta = channel_update(channel); int delta = channel_update(channel);
if (delta) { if (delta) {
blip_add_delta(apu->blip, time, delta); blip_add_delta(apu->blip, time, delta);
} }


if (channel->length <= 0 || channel->period <= 0) return;

while (cycles > 0) { while (cycles > 0) {
int run = cycles; int run = cycles;
if (run > channel->delay) { if (run > channel->delay) {
@@ -587,7 +588,7 @@ nes_apu_Result nes_apu_run(nes_apu* apu, int cycles) {
apu->frame_delay -= run; apu->frame_delay -= run;


if (apu->frame_delay <= 0) { if (apu->frame_delay <= 0) {
APU_LOG("APU: End of quarter frame: %d\n", apu->frame_time_elapsed);
// APU_LOG("APU: End of quarter frame: %d\n", apu->frame_time_elapsed);


int end = 0; int end = 0;
int quarter_frame = 1; int quarter_frame = 1;
@@ -624,7 +625,7 @@ nes_apu_Result nes_apu_run(nes_apu* apu, int cycles) {
if (end) { if (end) {
if (0 == apu->frame_reg) { if (0 == apu->frame_reg) {
apu->status |= apu_Status_Frame_Int; apu->status |= apu_Status_Frame_Int;
APU_LOG("APU: Frame Interrupt @ %d\n", apu->frame_time_elapsed);
// APU_LOG("APU: Frame Interrupt @ %d\n", apu->frame_time_elapsed);
} }
apu->frame = 0; apu->frame = 0;
apu->frame_time_elapsed = 0; apu->frame_time_elapsed = 0;


Loading…
Cancel
Save