Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split RC_CONSOLE_FAMICOM_DISK_SYSTEM from RC_CONSOLE_NINTENDO #387

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/rc_consoles.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ enum {
RC_CONSOLE_NINTENDO_DSI = 78,
RC_CONSOLE_TI83 = 79,
RC_CONSOLE_UZEBOX = 80,
RC_CONSOLE_FAMICOM_DISK_SYSTEM = 81,

RC_CONSOLE_HUBS = 100,
RC_CONSOLE_EVENTS = 101,
Expand Down
38 changes: 25 additions & 13 deletions src/rcheevos/consoleinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const char* rc_console_name(uint32_t console_id)
case RC_CONSOLE_FAIRCHILD_CHANNEL_F:
return "Fairchild Channel F";

case RC_CONSOLE_FAMICOM_DISK_SYSTEM:
return "Famicom Disk System";

case RC_CONSOLE_FM_TOWNS:
return "FM Towns";

Expand Down Expand Up @@ -427,6 +430,24 @@ static const rc_memory_region_t _rc_memory_regions_fairchild_channel_f[] = {
};
static const rc_memory_regions_t rc_memory_regions_fairchild_channel_f = { _rc_memory_regions_fairchild_channel_f, 4 };

/* ===== Famicon Disk System ===== */
/* https://fms.komkon.org/EMUL8/NES.html */
static const rc_memory_region_t _rc_memory_regions_famicom_disk_system[] = {
{ 0x0000U, 0x07FFU, 0x0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
{ 0x0800U, 0x0FFFU, 0x0000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirror RAM" }, /* duplicates memory from $0000-$07FF */
{ 0x1000U, 0x17FFU, 0x0000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirror RAM" }, /* duplicates memory from $0000-$07FF */
{ 0x1800U, 0x1FFFU, 0x0000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirror RAM" }, /* duplicates memory from $0000-$07FF */
{ 0x2000U, 0x2007U, 0x2000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "PPU Register" },
{ 0x2008U, 0x3FFFU, 0x2008U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirrored PPU Register" }, /* repeats every 8 bytes */
{ 0x4000U, 0x4017U, 0x4000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "APU and I/O register" },
{ 0x4018U, 0x401FU, 0x4018U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "APU and I/O test register" },
{ 0x4020U, 0x40FFU, 0x4020U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "FDS I/O registers"},
{ 0x4100U, 0x5FFFU, 0x4100U, RC_MEMORY_TYPE_READONLY, "Cartridge data"}, /* varies by mapper */
{ 0x6000U, 0xDFFFU, 0x6000U, RC_MEMORY_TYPE_SYSTEM_RAM, "FDS RAM"},
{ 0xE000U, 0xFFFFU, 0xE000U, RC_MEMORY_TYPE_READONLY, "FDS BIOS ROM"},
};
static const rc_memory_regions_t rc_memory_regions_famicom_disk_system = { _rc_memory_regions_famicom_disk_system, 12 };

/* ===== GameBoy / MegaDuck ===== */
static const rc_memory_region_t _rc_memory_regions_gameboy[] = {
{ 0x000000U, 0x0000FFU, 0x000000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Interrupt vector" },
Expand Down Expand Up @@ -698,18 +719,6 @@ static const rc_memory_region_t _rc_memory_regions_nes[] = {
{ 0x4020U, 0x5FFFU, 0x4020U, RC_MEMORY_TYPE_READONLY, "Cartridge data"}, /* varies by mapper */
{ 0x6000U, 0x7FFFU, 0x6000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM"},
{ 0x8000U, 0xFFFFU, 0x8000U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM"},

/* NOTE: these are the correct mappings for FDS: https://fms.komkon.org/EMUL8/NES.html
* 0x6000-0xDFFF is RAM on the FDS system and 0xE000-0xFFFF is FDS BIOS.
* If the core implements a memory map, we should still be able to translate the addresses
* correctly as we only use the classifications when a memory map is not provided

{ 0x4020U, 0x40FFU, 0x4020U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "FDS I/O registers"},
{ 0x4100U, 0x5FFFU, 0x4100U, RC_MEMORY_TYPE_READONLY, "Cartridge data"}, // varies by mapper
{ 0x6000U, 0xDFFFU, 0x6000U, RC_MEMORY_TYPE_SYSTEM_RAM, "FDS RAM"},
{ 0xE000U, 0xFFFFU, 0xE000U, RC_MEMORY_TYPE_READONLY, "FDS BIOS ROM"},

*/
};
static const rc_memory_regions_t rc_memory_regions_nes = { _rc_memory_regions_nes, 11 };

Expand Down Expand Up @@ -1058,7 +1067,10 @@ const rc_memory_regions_t* rc_console_memory_regions(uint32_t console_id)

case RC_CONSOLE_FAIRCHILD_CHANNEL_F:
return &rc_memory_regions_fairchild_channel_f;


case RC_CONSOLE_FAMICOM_DISK_SYSTEM:
return &rc_memory_regions_famicom_disk_system;

case RC_CONSOLE_GAMEBOY:
return &rc_memory_regions_gameboy;

Expand Down
1 change: 1 addition & 0 deletions src/rcheevos/rc_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ static int rc_validate_memref(const rc_memref_t* memref, char result[], const si

switch (console_id) {
case RC_CONSOLE_NINTENDO:
case RC_CONSOLE_FAMICOM_DISK_SYSTEM:
if (memref->address >= 0x0800 && memref->address <= 0x1FFF) {
snprintf(result, result_size, "Mirror RAM may not be exposed by emulator (address %04X)", memref->address);
return 0;
Expand Down
10 changes: 8 additions & 2 deletions src/rhash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -3142,6 +3142,7 @@ int rc_hash_generate_from_buffer(char hash[33], uint32_t console_id, const uint8
case RC_CONSOLE_ATARI_LYNX:
return rc_hash_lynx(hash, buffer, buffer_size);

case RC_CONSOLE_FAMICOM_DISK_SYSTEM:
case RC_CONSOLE_NINTENDO:
return rc_hash_nes(hash, buffer, buffer_size);

Expand Down Expand Up @@ -3447,6 +3448,7 @@ int rc_hash_generate_from_file(char hash[33], uint32_t console_id, const char* p
case RC_CONSOLE_ARDUBOY:
case RC_CONSOLE_ATARI_7800:
case RC_CONSOLE_ATARI_LYNX:
case RC_CONSOLE_FAMICOM_DISK_SYSTEM:
case RC_CONSOLE_NINTENDO:
case RC_CONSOLE_PC_ENGINE:
case RC_CONSOLE_SUPER_CASSETTEVISION:
Expand Down Expand Up @@ -3647,7 +3649,11 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
break;

case 'a':
if (rc_path_compare_extension(ext, "a78"))
if (rc_path_compare_extension(ext, "a26"))
{
iterator->consoles[0] = RC_CONSOLE_ATARI_2600;
}
else if (rc_path_compare_extension(ext, "a78"))
{
iterator->consoles[0] = RC_CONSOLE_ATARI_7800;
}
Expand Down Expand Up @@ -3789,7 +3795,7 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
}
else if (rc_path_compare_extension(ext, "fds"))
{
iterator->consoles[0] = RC_CONSOLE_NINTENDO;
iterator->consoles[0] = RC_CONSOLE_FAMICOM_DISK_SYSTEM;
}
else if (rc_path_compare_extension(ext, "fd"))
{
Expand Down
4 changes: 3 additions & 1 deletion test/rcheevos/test_consoleinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ void test_consoleinfo(void) {
TEST_PARAMS2(test_name, 78, "Nintendo DSi");
TEST_PARAMS2(test_name, 79, "TI-83");
TEST_PARAMS2(test_name, 80, "Uzebox");
TEST_PARAMS2(test_name, 81, "Unknown");
TEST_PARAMS2(test_name, 81, "Famicom Disk System");
TEST_PARAMS2(test_name, 82, "Unknown");

TEST_PARAMS2(test_name, 100, "Hubs");
TEST_PARAMS2(test_name, 101, "Events");
Expand All @@ -144,6 +145,7 @@ void test_consoleinfo(void) {
TEST_PARAMS2(test_memory, RC_CONSOLE_DREAMCAST, 0x01000000);
TEST_PARAMS2(test_memory, RC_CONSOLE_ELEKTOR_TV_GAMES_COMPUTER, 0x001800);
TEST_PARAMS2(test_memory, RC_CONSOLE_FAIRCHILD_CHANNEL_F, 0x010C40);
TEST_PARAMS2(test_memory, RC_CONSOLE_FAMICOM_DISK_SYSTEM, 0x010000);
TEST_PARAMS2(test_memory, RC_CONSOLE_GAMEBOY, 0x034000);
TEST_PARAMS2(test_memory, RC_CONSOLE_GAMEBOY_COLOR, 0x034000);
TEST_PARAMS2(test_memory, RC_CONSOLE_GAMEBOY_ADVANCE, 0x058000);
Expand Down
Loading