Skip to content

Commit

Permalink
Add missed test files
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterymath committed Dec 13, 2023
1 parent 623c138 commit 134c178
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/nes-mmc3/banked-8-128k.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <mapper.h>
#include <stdlib.h>

MAPPER_PRG_ROM_KB(128);

volatile const char large_array[0x5000] = {
[0] = 1, [0x2000] = 2, [0x4000] = 3, [0x4fff] = 4};

__attribute__((section(".prg_rom_0"))) volatile const char bank_0[0x2000] = {
[0] = 1, [0x1fff] = 2};
__attribute__((section(".prg_rom_1"))) volatile const char bank_1[0x2000] = {
[0] = 3, [0x1fff] = 4};

int main(void) {
if ((unsigned)large_array < 0xa000)
return EXIT_FAILURE;
if (large_array[0] != 1)
return EXIT_FAILURE;
if (large_array[0x2000] != 2)
return EXIT_FAILURE;
if (large_array[0x4000] != 3)
return EXIT_FAILURE;
if (large_array[0x4fff] != 4)
return EXIT_FAILURE;

if ((unsigned)bank_0 >= 0xa000)
return EXIT_FAILURE;
set_prg_8000(0);
if (bank_0[0] != 1)
return EXIT_FAILURE;
if (bank_0[0x1fff] != 2)
return EXIT_FAILURE;

if ((unsigned)bank_1 >= 0xa000)
return EXIT_FAILURE;
set_prg_bank(1, (unsigned)bank_1 >> 8);
if (bank_1[0] != 3)
return EXIT_FAILURE;
if (bank_1[0x1fff] != 4)
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
42 changes: 42 additions & 0 deletions test/nes-mmc3/banked-8-256k.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <mapper.h>
#include <stdlib.h>

MAPPER_PRG_ROM_KB(256);

volatile const char large_array[0x5000] = {
[0] = 1, [0x2000] = 2, [0x4000] = 3, [0x4fff] = 4};

__attribute__((section(".prg_rom_0"))) volatile const char bank_0[0x2000] = {
[0] = 1, [0x1fff] = 2};
__attribute__((section(".prg_rom_1"))) volatile const char bank_1[0x2000] = {
[0] = 3, [0x1fff] = 4};

int main(void) {
if ((unsigned)large_array < 0xa000)
return EXIT_FAILURE;
if (large_array[0] != 1)
return EXIT_FAILURE;
if (large_array[0x2000] != 2)
return EXIT_FAILURE;
if (large_array[0x4000] != 3)
return EXIT_FAILURE;
if (large_array[0x4fff] != 4)
return EXIT_FAILURE;

if ((unsigned)bank_0 >= 0xa000)
return EXIT_FAILURE;
set_prg_8000(0);
if (bank_0[0] != 1)
return EXIT_FAILURE;
if (bank_0[0x1fff] != 2)
return EXIT_FAILURE;

if ((unsigned)bank_1 >= 0xa000)
return EXIT_FAILURE;
set_prg_bank(1, (unsigned)bank_1 >> 8);
if (bank_1[0] != 3)
return EXIT_FAILURE;
if (bank_1[0x1fff] != 4)
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
42 changes: 42 additions & 0 deletions test/nes-mmc3/banked-8-64k.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <mapper.h>
#include <stdlib.h>

MAPPER_PRG_ROM_KB(64);

volatile const char large_array[0x5000] = {
[0] = 1, [0x2000] = 2, [0x4000] = 3, [0x4fff] = 4};

__attribute__((section(".prg_rom_0"))) volatile const char bank_0[0x2000] = {
[0] = 1, [0x1fff] = 2};
__attribute__((section(".prg_rom_1"))) volatile const char bank_1[0x2000] = {
[0] = 3, [0x1fff] = 4};

int main(void) {
if ((unsigned)large_array < 0xa000)
return EXIT_FAILURE;
if (large_array[0] != 1)
return EXIT_FAILURE;
if (large_array[0x2000] != 2)
return EXIT_FAILURE;
if (large_array[0x4000] != 3)
return EXIT_FAILURE;
if (large_array[0x4fff] != 4)
return EXIT_FAILURE;

if ((unsigned)bank_0 >= 0xa000)
return EXIT_FAILURE;
set_prg_8000(0);
if (bank_0[0] != 1)
return EXIT_FAILURE;
if (bank_0[0x1fff] != 2)
return EXIT_FAILURE;

if ((unsigned)bank_1 >= 0xa000)
return EXIT_FAILURE;
set_prg_bank(1, (unsigned)bank_1 >> 8);
if (bank_1[0] != 3)
return EXIT_FAILURE;
if (bank_1[0x1fff] != 4)
return EXIT_FAILURE;
return EXIT_SUCCESS;
}

0 comments on commit 134c178

Please sign in to comment.