|
|
|
@@ -263,23 +263,6 @@ static inline int f6502_write(nes_Memory* mem, |
|
|
|
|
|
|
|
case 0x4000: |
|
|
|
switch (addr & 0x1FU) { |
|
|
|
case 0x17: // APU Frame |
|
|
|
{ f6502_Core* core = container_of(mem, f6502_Core, memory); |
|
|
|
nes* sys = container_of(core, nes, core); |
|
|
|
nes_APU* apu = &sys->apu; |
|
|
|
|
|
|
|
// printf("APU: $%04X < %02X\n", addr, val); |
|
|
|
|
|
|
|
apu->frame_reg = val; |
|
|
|
apu->frame = 0; |
|
|
|
apu->frame_delay = nes_apu_quarter_frame_ticks; |
|
|
|
|
|
|
|
// Clear this ASAP |
|
|
|
if (val & apu_Frame_Inhibit) { |
|
|
|
mem->apu.status &= ~apu_Status_Frame_Int; |
|
|
|
f6502_set_IRQ(core, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
case 0x00: |
|
|
|
case 0x01: |
|
|
|
case 0x02: |
|
|
|
@@ -301,6 +284,7 @@ static inline int f6502_write(nes_Memory* mem, |
|
|
|
case 0x12: |
|
|
|
case 0x13: |
|
|
|
case 0x15: // APU Status |
|
|
|
case 0x17: // APU Frame |
|
|
|
if (mem->apu.n_events >= APU_MAX_EVENTS) { |
|
|
|
LOGE("APU event buffer full"); |
|
|
|
} else { |
|
|
|
@@ -310,6 +294,18 @@ static inline int f6502_write(nes_Memory* mem, |
|
|
|
.val = val, |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
// APU Frame |
|
|
|
if (0x17 == (addr & 0x1FU)) { |
|
|
|
f6502_Core* core = container_of(mem, f6502_Core, memory); |
|
|
|
nes* sys = container_of(core, nes, core); |
|
|
|
nes_APU* apu = &sys->apu; |
|
|
|
nes_apu_process(apu, mem); |
|
|
|
|
|
|
|
if (val & apu_Frame_Inhibit) { |
|
|
|
f6502_set_IRQ(core, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case 0x14: // OAM DMA |
|
|
|
|