Skip to content

Commit

Permalink
NES GTROM cannot use CHR-ROM
Browse files Browse the repository at this point in the history
Mesen will detect MMC1 if CHR-ROM is present, since there is a conflict
for mapper 111 with a Chinese fan translation of Ninja Gaiden.
  • Loading branch information
mysterymath committed Dec 11, 2023
1 parent 52419cd commit 2e9e206
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 57 deletions.
11 changes: 3 additions & 8 deletions mos-platform/nes-gtrom/common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@

INCLUDE nes.ld

ASSERT(__prg_rom_size <= 512,
"GTROM only supports up to 512 KiB of PRG.")
ASSERT(__prg_rom_size <= 512, "GTROM only supports up to 512 KiB of PRG.")

ASSERT(__chr_rom_size <= 16,
"GTROM only supports up to 16 KiB of CHR-ROM.")
ASSERT(__chr_ram_size + __chr_nvram_size <= 16,
"GTROM only supports up to 16 KiB of CHR-(NV)RAM.")

ASSERT(__prg_ram_size == 0,
"GTROM does not support PRG-RAM")
ASSERT(__prg_nvram_size == 0,
"GTROM does not support PRG-NVRAM")
ASSERT(__prg_ram_size == 0, "GTROM does not support PRG-RAM")
ASSERT(__prg_nvram_size == 0, "GTROM does not support PRG-NVRAM")
4 changes: 2 additions & 2 deletions mos-platform/nes-gtrom/ines.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
__mapper = 111

; GTROM boards come with CHR-RAM by default.
; Setting this to 0 gives CHR-ROM.
.weak __chr_ram_size
__chr_ram_size = 16
.weak __chr_rom_size

.globl __chr_rom_size
__chr_rom_size = 0
1 change: 0 additions & 1 deletion test/nes-gtrom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ project(test-nes-gtrom LANGUAGES C)
include(../test.cmake)

add_nes_test(chr-ram)
add_nes_test(chr-rom)
add_nes_test(chr-swap-split)
add_nes_test(minimal)
add_nes_test(prg-rom-512)
Expand Down
3 changes: 0 additions & 3 deletions test/nes-gtrom/chr-ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
#include <peekpoke.h>
#include <stdlib.h>

MAPPER_CHR_ROM_KB(0);
MAPPER_CHR_RAM_KB(16);

void poke_ppu(unsigned addr, char val) {
PPU.vram.address = addr >> 8;
PPU.vram.address = (char)addr;
Expand Down
35 changes: 0 additions & 35 deletions test/nes-gtrom/chr-rom.c

This file was deleted.

21 changes: 13 additions & 8 deletions test/nes-gtrom/chr-swap-split.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
#include <peekpoke.h>
#include <stdlib.h>

MAPPER_CHR_ROM_KB(16);
MAPPER_CHR_RAM_KB(0);

__attribute__((used, section(".chr_rom_0")))
const char cr0[8192] = {1, [8191] = 2};
__attribute__((used, section(".chr_rom_1")))
const char cr1[8192] = {3, [8191] = 4};

volatile char frame_count;

asm(".section .nmi,\"axR\",@progbits\n"
Expand All @@ -22,6 +14,12 @@ void ppu_wait_vblank(void) {
;
}

char write_ppu(unsigned addr, char val) {
PPU.vram.address = addr >> 8;
PPU.vram.address = (char)addr;
PPU.vram.data = val;
}

char read_ppu(unsigned ppu_addr) {
(void)PPU.status;
PPU.vram.address = (unsigned)ppu_addr >> 8;
Expand All @@ -31,6 +29,13 @@ char read_ppu(unsigned ppu_addr) {
}

int main(void) {
set_chr_bank(0);
write_ppu(0, 1);
write_ppu(8191, 2);
set_chr_bank(3);
write_ppu(0, 3);
write_ppu(8191, 4);

// Enable NMI generation.
PPU.control = 0x80;

Expand Down

0 comments on commit 2e9e206

Please sign in to comment.