Skip to content

Commit

Permalink
Fixed MMC3 mappers.
Browse files Browse the repository at this point in the history
  • Loading branch information
punesemu committed Oct 3, 2023
1 parent 2fe70c6 commit a3fdf72
Show file tree
Hide file tree
Showing 96 changed files with 123 additions and 122 deletions.
2 changes: 1 addition & 1 deletion src/core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ enum cpu_opcode_type { RD_OP, WR_OP };
_RDD;\
_RDX((nes[nidx].c.cpu.SP | STACK), TRUE);\
nes[nidx].c.cpu.PC.b[0] = _PUL;\
nes[nidx].c.cpu.PC.b[1] = _PUL; \
nes[nidx].c.cpu.PC.b[1] = _PUL;\
_RDP;
// RTI
#define RTI\
Expand Down
2 changes: 1 addition & 1 deletion src/core/emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void emu_frame(void) {
// eseguo CPU, PPU e APU
while (info.exec_cpu_op.w) {
#if defined (DEBUG)
if (nes[1].c.cpu.PC.w == PCBREAK) {
if (nes[0].c.cpu.PC.w == PCBREAK) {
BYTE pippo = 5;
pippo = pippo + 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/irqA12.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "ppu_inline.h"
#include "irqA12.h"

BYTE irqA12_delay;
BYTE irqA12_delay = 0;

void irqA12_IO(BYTE nidx, WORD value, WORD value_old) {
if (!(value_old & 0x1000) && (value & 0x1000)) {
Expand All @@ -46,7 +46,7 @@ void irqA12_IO(BYTE nidx, WORD value, WORD value_old) {
}
}
void irqA12_BS(BYTE nidx) {
BYTE n_spr;
BYTE n_spr = 0;

if (nes[nidx].irqA12.a12BS || ((nes[nidx].p.ppu.frame_x & 0x0007) != 0x0003)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/core/mappers/mapper_004.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <string.h>
#include "mappers.h"
#include "info.h"
#include "irqA12.h"

void wram_fix_004_mmc6(void);

Expand Down Expand Up @@ -60,10 +61,9 @@ void map_init_004(void) {
}

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
}

BYTE extcl_cpu_rd_mem_004_mmc6(BYTE nidx, WORD address, BYTE openbus) {
if ((address >= 0x7000) && (address <= 0x7FFF)) {
return (memmap_adr_is_readable(nidx, MMCPU(address))
Expand Down
3 changes: 2 additions & 1 deletion src/core/mappers/mapper_012.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <string.h>
#include "mappers.h"
#include "save_slot.h"
#include "irqA12.h"

void prg_swap_mmc3_012(WORD address, WORD value);
void chr_swap_mmc3_012(WORD address, WORD value);
Expand Down Expand Up @@ -58,7 +59,7 @@ void map_init_012(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
}
void extcl_cpu_wr_mem_012(BYTE nidx, WORD address, BYTE value) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_014.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void map_init_014(void) {
VRC2and4_chr_swap = chr_swap_vrc2and4_014;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_after_mapper_init_014(void) {
if (m014.reg & 0x02) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_037.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void map_init_037(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_037(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x7FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_044.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void map_init_044(void) {
MMC3_chr_swap = chr_swap_mmc3_044;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_044(BYTE nidx, WORD address, BYTE value) {
extcl_cpu_wr_mem_MMC3(nidx, address, value);
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_045.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void map_init_045(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_045(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x7FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_047.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void map_init_047(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_047(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x7FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_048.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void map_init_048(void) {
}

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 7;
irqA12_delay = 7;
}
void extcl_after_mapper_init_048(void) {
prg_fix_048();
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_049.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void map_init_049(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_049(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x7FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_052.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void map_init_052(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_052(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x7FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_074.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void map_init_074(void) {
MMC3_chr_swap = chr_swap_mmc3_074;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}

void prg_swap_mmc3_074(WORD address, WORD value) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_100.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void map_init_100(void) {
m100.chr[7] = 7;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_after_mapper_init_100(void) {
extcl_after_mapper_init_MMC3();
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_114.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void map_init_114(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_114(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x7FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_115.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void map_init_115(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_115(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x7FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_116.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void map_init_116(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_after_mapper_init_116(void) {
switch_mode();
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_118.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void map_init_118(void) {
MMC3_mirroring_fix = mirroring_fix_mmc3_118;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_118(BYTE nidx, WORD address, BYTE value) {
switch (address & 0xE001) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_119.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void map_init_119(void) {
MMC3_chr_swap = chr_swap_mmc3_119;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}

void chr_swap_mmc3_119(WORD address, WORD value) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_121.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void map_init_121(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_121(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x5000) && (address <= 0x5FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_123.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void map_init_123(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_123(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x5000) && (address <= 0x5FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_134.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void map_init_134(void) {
info.mapper.extend_rd = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_134(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x7FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_165.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void map_init_165(void) {
mmc3.reg[4] = 0;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_165(BYTE nidx, WORD address, BYTE value) {
if (address >= 0x8000) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/mappers/mapper_176.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void map_init_176(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_after_mapper_init_176(void) {
prg_fix_176();
Expand Down Expand Up @@ -189,7 +189,7 @@ void extcl_cpu_wr_mem_176(BYTE nidx, WORD address, BYTE value) {
extcl_cpu_wr_mem_MMC3(nidx, address, value);
m176.cpu8xxx[0] = value;
extcl_after_mapper_init_176();
break;
return;
}
}
BYTE extcl_save_mapper_176(BYTE mode, BYTE slot, FILE *fp) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_187.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void map_init_187(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_187(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x5000) && (address <= 0x5FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_189.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void map_init_189(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_189(BYTE nidx, WORD address, BYTE value) {
switch (address & 0xF000) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_191.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void map_init_191(void) {
MMC3_chr_swap = chr_swap_mmc3_191;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}

void prg_swap_mmc3_191(WORD address, WORD value) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_192.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void map_init_192(void) {
MMC3_chr_swap = chr_swap_mmc3_192;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}

void prg_swap_mmc3_192(WORD address, WORD value) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_194.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void map_init_194(void) {
MMC3_chr_swap = chr_swap_mmc3_194;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}

void prg_swap_mmc3_194(WORD address, WORD value) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_195.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void map_init_195(void) {
MMC3_wram_fix = wram_fix_mmc3_195;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_195(BYTE nidx, WORD address, BYTE value) {
if ((address & 0xE001) == 0xA001) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_196.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void map_init_196(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_196(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x6FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_197.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void map_init_197(void) {
}

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_197(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x7FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_198.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void map_init_198(void) {
MMC3_wram_fix = wram_fix_mmc3_198;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}

void prg_swap_mmc3_198(WORD address, WORD value) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_199.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void map_init_199(void) {
MMC3_wram_fix = wram_fix_mmc3_199;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}

void chr_swap_mmc3_199(WORD address, UNUSED(WORD value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_205.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void map_init_205(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_205(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x6000) && (address <= 0x7FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_208.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void map_init_208(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_208(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x4000) && (address <= 0x5FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_215.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void map_init_215(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_215(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x5000) && (address <= 0x5FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_219.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void map_init_219(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_219(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x5000) && (address <= 0x5FFF)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_238.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void map_init_238(void) {
info.mapper.extend_wr = TRUE;

nes[0].irqA12.present = TRUE;
nes[0].irqA12.delay = 1;
irqA12_delay = 1;
}
void extcl_cpu_wr_mem_238(BYTE nidx, WORD address, BYTE value) {
if ((address >= 0x4020) && (address <= 0x7FFF)) {
Expand Down
Loading

0 comments on commit a3fdf72

Please sign in to comment.