From 0a5945d13eaab0ce320e1f3d1572afe11f527108 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Tue, 26 Nov 2024 07:41:14 -0700 Subject: [PATCH 1/2] split RC_CONSOLE_FAMICOM_DISK_SYSTEM from RC_CONSOLE_NINTENDO --- include/rc_consoles.h | 1 + src/rcheevos/consoleinfo.c | 38 +++++++++++++++++++++----------- src/rcheevos/rc_validate.c | 1 + src/rhash/hash.c | 10 +++++++-- test/rcheevos/test_consoleinfo.c | 4 +++- 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/include/rc_consoles.h b/include/rc_consoles.h index 26987920..5f788855 100644 --- a/include/rc_consoles.h +++ b/include/rc_consoles.h @@ -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, diff --git a/src/rcheevos/consoleinfo.c b/src/rcheevos/consoleinfo.c index 7632ffdd..fd16553a 100644 --- a/src/rcheevos/consoleinfo.c +++ b/src/rcheevos/consoleinfo.c @@ -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"; @@ -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" }, @@ -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 }; @@ -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; diff --git a/src/rcheevos/rc_validate.c b/src/rcheevos/rc_validate.c index 98b24212..c09603f4 100644 --- a/src/rcheevos/rc_validate.c +++ b/src/rcheevos/rc_validate.c @@ -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; diff --git a/src/rhash/hash.c b/src/rhash/hash.c index 8d902b67..49512ceb 100644 --- a/src/rhash/hash.c +++ b/src/rhash/hash.c @@ -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); @@ -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: @@ -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; } @@ -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")) { diff --git a/test/rcheevos/test_consoleinfo.c b/test/rcheevos/test_consoleinfo.c index 41dc18f6..bc3b80f6 100644 --- a/test/rcheevos/test_consoleinfo.c +++ b/test/rcheevos/test_consoleinfo.c @@ -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"); @@ -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); From ec1e35af141be207bc7403ce39b35813eab4f3b8 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Sat, 30 Nov 2024 16:01:51 -0700 Subject: [PATCH 2/2] fix c89 build --- src/rcheevos/consoleinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rcheevos/consoleinfo.c b/src/rcheevos/consoleinfo.c index fd16553a..0fa9f14d 100644 --- a/src/rcheevos/consoleinfo.c +++ b/src/rcheevos/consoleinfo.c @@ -442,7 +442,7 @@ static const rc_memory_region_t _rc_memory_regions_famicom_disk_system[] = { { 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 + { 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"}, };