From 439b2cdaba1d2de236d2a107e8df20a31c63e000 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Thu, 5 Nov 2026 19:32:56 +0100 Subject: [PATCH] fix: split the np2 V98 font from font.bmp NP2kai and meowPC98 read font.bmp (PC-98 bitmap) and FONT.ROM (V98) as separate files, each through its own reader (NP2kai font/font.c:192-195, meowPC98 font/font.c:180-181). The V98 names hung on font.bmp as aliases let a collection without font.bmp serve the PC-88 2 KB font.rom there. FONT.ROM is now its own entry, at least 0x46800 bytes (fontv98.c:8, 51). Manifests: np2/FONT.ROM and np2kai/FONT.ROM are added where the platform did not declare them, served by the V98 font bios/NEC/PC-98/font.rom. --- database.json | 8 ++-- emulators/nekop2.yml | 18 +++++++-- emulators/np2kai.yml | 17 +++++++-- install/amberelec.json | 30 ++++++++++++--- install/batocera.json | 13 ++++++- install/emudeck.json | 30 ++++++++++++--- install/emuelec.json | 30 ++++++++++++--- install/knulli.json | 13 ++++++- install/lakka.json | 34 ++++++++++++++--- install/retroarch.json | 34 ++++++++++++++--- install/retrobat.json | 34 ++++++++++++++--- install/retrodeck.json | 36 +++++++++++++++--- install/retropie.json | 34 ++++++++++++++--- install/rocknix.json | 30 ++++++++++++--- install/romm.json | 24 +++++++++++- tests/test_np2_fonts.py | 81 +++++++++++++++++++++++++++++++++++++++++ 16 files changed, 406 insertions(+), 60 deletions(-) create mode 100644 tests/test_np2_fonts.py diff --git a/database.json b/database.json index c3a0393d4..b1c91028e 100644 --- a/database.json +++ b/database.json @@ -1,6 +1,6 @@ { "schema_version": 1, - "generated_at": "2026-11-05T14:56:18Z", + "generated_at": "2026-11-05T18:31:29Z", "total_files": 19944, "total_size": 16892646538, "bios_dir": "bios", @@ -281984,12 +281984,12 @@ "Parallel.rom": [ "c75c751589cbcc1ad4ab4f63676af7abadd86f5b" ], - "POCKSTAT.ROM": [ - "6ae880493ddde880827d1e9f08e9cb2c38f9f2ec" - ], "FONT.BMP": [ "b4f14e58030ed40fff2dc312b58ea4440bdf8cc5" ], + "POCKSTAT.ROM": [ + "6ae880493ddde880827d1e9f08e9cb2c38f9f2ec" + ], "bank3.bin": [ "0877ffb4b4d1c18283468be3579b72ed8c22e3ac" ], diff --git a/emulators/nekop2.yml b/emulators/nekop2.yml index 2c913ced7..349b12116 100644 --- a/emulators/nekop2.yml +++ b/emulators/nekop2.yml @@ -77,12 +77,22 @@ files: path: "np2/font.bmp" required: false hle_fallback: true - aliases: ["FONT.ROM"] + aliases: ["FONT.BMP"] note: > - PC-98 font bitmap (288 KB). Required for correct Japanese kanji display. + PC-98 font bitmap. Required for correct Japanese kanji display. Without this, only basic ASCII renders using built-in 8x8 data. - FONT.ROM (V98 format) is also accepted. - source_ref: "libretro/libretro.c:872, font/font.c:113, font/fontdata.c:12" + source_ref: "libretro/libretro.c:872, font/font.c:74-104, 180, font/fontdata.c:11" + + - name: "FONT.ROM" + path: "np2/FONT.ROM" + required: false + hle_fallback: true + min_size: 288768 + validation: [size] + note: > + V98 font, read after font.bmp and filling only the glyphs it left + out. fontv98_read refuses a file shorter than 0x46800 bytes. + source_ref: "libretro/libretro.c:196, 868, font/font.c:181, font/fontdata.c:12, font/fontv98.c:8, 45-51" # -- Sound BIOS ROM -- # Loaded by soundrom_load() via loadsoundrom() in sound/soundrom.c:21-55. diff --git a/emulators/np2kai.yml b/emulators/np2kai.yml index 2ccbae0a4..c002e341e 100644 --- a/emulators/np2kai.yml +++ b/emulators/np2kai.yml @@ -66,12 +66,23 @@ files: path: "np2kai/font.bmp" required: false hle_fallback: true - aliases: ["FONT.ROM", "font.rom", "FONT.BMP"] + aliases: ["FONT.BMP"] note: > PC-98 font bitmap. Required for correct Japanese kanji display. Without this, only basic ASCII renders using built-in 8x8 data. - FONT.ROM (V98 format) is also accepted. - source_ref: "source sdl/libretro/libretro.c:1830, source font/font.c:86-125, upstream font/fontdata.c:11" + source_ref: "source sdl/libretro/libretro.c:1830, source font/font.c:77-116, 192-193, source font/fontdata.c:11-12" + + - name: "FONT.ROM" + path: "np2kai/FONT.ROM" + required: false + hle_fallback: true + min_size: 288768 + validation: [size] + aliases: ["font.rom"] + note: > + V98 font, read after font.bmp and filling only the glyphs it left + out. fontv98_read refuses a file shorter than 0x46800 bytes. + source_ref: "source sdl/libretro/libretro.c:1830-1831, source font/font.c:194-195, source font/fontdata.c:13-14, source font/fontv98.c:8, 45-51" # -- Sound BIOS ROM -- # Loaded by soundrom_load() in soundrom.c:93-106 via loadsoundrom(). diff --git a/install/amberelec.json b/install/amberelec.json index 8d717efdd..2526c393b 100644 --- a/install/amberelec.json +++ b/install/amberelec.json @@ -6,7 +6,7 @@ "platform": "amberelec", "display_name": "AmberELEC", "version": "prerelease-20261019_1835", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "", "detect": [ { @@ -29,10 +29,10 @@ } ], "standalone_copies": [], - "total_files": 4956, - "total_size": 5347524625, - "pack_files": 5150, - "pack_size": 5347624969, + "total_files": 4958, + "total_size": 5348102161, + "pack_files": 5152, + "pack_size": 5348202505, "total_omitted": 285, "omitted_files": [ { @@ -63632,6 +63632,16 @@ "nekop2" ] }, + { + "dest": "bios/np2/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "nekop2" + ] + }, { "dest": "bios/np2/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", @@ -63869,6 +63879,16 @@ "np2kai" ] }, + { + "dest": "bios/np2kai/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ] + }, { "dest": "bios/np2kai/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", diff --git a/install/batocera.json b/install/batocera.json index eb213c411..e20ab7152 100644 --- a/install/batocera.json +++ b/install/batocera.json @@ -6,7 +6,7 @@ "platform": "batocera", "display_name": "Batocera", "version": "43.1", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "bios", "detect": [ { @@ -10343,6 +10343,17 @@ "cores": null, "systems": [ "nec-pc-98" + ], + "alternatives": [ + { + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ] + } ] }, { diff --git a/install/emudeck.json b/install/emudeck.json index 48104d726..c6fcc998f 100644 --- a/install/emudeck.json +++ b/install/emudeck.json @@ -6,7 +6,7 @@ "platform": "emudeck", "display_name": "EmuDeck", "version": "2.7EA", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "bios", "detect": [ { @@ -305,10 +305,10 @@ } } ], - "total_files": 8430, - "total_size": 7887249450, - "pack_files": 8432, - "pack_size": 7887249450, + "total_files": 8432, + "total_size": 7887826986, + "pack_files": 8434, + "pack_size": 7887826986, "total_omitted": 37, "omitted_files": [ { @@ -89584,6 +89584,16 @@ "nekop2" ] }, + { + "dest": "np2/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "nekop2" + ] + }, { "dest": "np2/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", @@ -89863,6 +89873,16 @@ "np2kai" ] }, + { + "dest": "np2kai/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ] + }, { "dest": "np2kai/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", diff --git a/install/emuelec.json b/install/emuelec.json index 6a423c1cd..dfc4309cb 100644 --- a/install/emuelec.json +++ b/install/emuelec.json @@ -6,7 +6,7 @@ "platform": "emuelec", "display_name": "EmuELEC", "version": "4.8", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "", "detect": [ { @@ -20,10 +20,10 @@ } ], "standalone_copies": [], - "total_files": 5295, - "total_size": 4142496885, - "pack_files": 5489, - "pack_size": 4142597229, + "total_files": 5297, + "total_size": 4143074421, + "pack_files": 5491, + "pack_size": 4143174765, "total_omitted": 389, "omitted_files": [ { @@ -67528,6 +67528,16 @@ "nekop2" ] }, + { + "dest": "bios/np2/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "nekop2" + ] + }, { "dest": "bios/np2/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", @@ -67765,6 +67775,16 @@ "np2kai" ] }, + { + "dest": "bios/np2kai/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ] + }, { "dest": "bios/np2kai/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", diff --git a/install/knulli.json b/install/knulli.json index 3d3b0a8be..10324a716 100644 --- a/install/knulli.json +++ b/install/knulli.json @@ -6,7 +6,7 @@ "platform": "knulli", "display_name": "KNULLI", "version": "20260511", - "generated": "2026-11-05T12:13:24Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "bios", "detect": [ { @@ -9186,6 +9186,17 @@ "cores": null, "systems": [ "nec-pc-98" + ], + "alternatives": [ + { + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ] + } ] }, { diff --git a/install/lakka.json b/install/lakka.json index 8fee19321..3890ede25 100644 --- a/install/lakka.json +++ b/install/lakka.json @@ -6,7 +6,7 @@ "platform": "lakka", "display_name": "Lakka", "version": "v6.1", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "system", "detect": [ { @@ -20,10 +20,10 @@ } ], "standalone_copies": [], - "total_files": 8342, - "total_size": 7039319693, - "pack_files": 8652, - "pack_size": 7061212577, + "total_files": 8343, + "total_size": 7039608461, + "pack_files": 8653, + "pack_size": 7061501345, "total_omitted": 37, "omitted_files": [ { @@ -5747,6 +5747,17 @@ "cores": null, "systems": [ "nec-pc-98" + ], + "alternatives": [ + { + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ] + } ] }, { @@ -113637,6 +113648,19 @@ "nec-pc-98" ] }, + { + "dest": "np2/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "nekop2" + ], + "systems": [ + "nec-pc-98" + ] + }, { "dest": "np2/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", diff --git a/install/retroarch.json b/install/retroarch.json index 897459252..45faaba16 100644 --- a/install/retroarch.json +++ b/install/retroarch.json @@ -6,7 +6,7 @@ "platform": "retroarch", "display_name": "RetroArch", "version": "v1.22.2", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "system", "detect": [ { @@ -631,10 +631,10 @@ } } ], - "total_files": 8350, - "total_size": 7132502545, - "pack_files": 10993, - "pack_size": 7174694399, + "total_files": 8351, + "total_size": 7132791313, + "pack_files": 10994, + "pack_size": 7174983167, "total_omitted": 37, "omitted_files": [ { @@ -6312,6 +6312,17 @@ "cores": null, "systems": [ "nec-pc-98" + ], + "alternatives": [ + { + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ] + } ] }, { @@ -114694,6 +114705,19 @@ "nec-pc-98" ] }, + { + "dest": "np2/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "nekop2" + ], + "systems": [ + "nec-pc-98" + ] + }, { "dest": "np2/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", diff --git a/install/retrobat.json b/install/retrobat.json index 34721a3d0..1e5d47bc7 100644 --- a/install/retrobat.json +++ b/install/retrobat.json @@ -6,7 +6,7 @@ "platform": "retrobat", "display_name": "RetroBat", "version": "8.3.1", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "bios", "detect": [ { @@ -284,10 +284,10 @@ } } ], - "total_files": 5561, - "total_size": 8544495803, - "pack_files": 5563, - "pack_size": 8544495803, + "total_files": 5562, + "total_size": 8544784571, + "pack_files": 5564, + "pack_size": 8544784571, "total_omitted": 203, "omitted_files": [ { @@ -8239,6 +8239,17 @@ "cores": null, "systems": [ "nec-pc-98" + ], + "alternatives": [ + { + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ] + } ] }, { @@ -73066,6 +73077,19 @@ "nec-pc-98" ] }, + { + "dest": "np2/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "nekop2" + ], + "systems": [ + "nec-pc-98" + ] + }, { "dest": "ps2-0230a-20080220.bin", "sha1": "f9229fe159d0353b9f0632f3fdc66819c9030458", diff --git a/install/retrodeck.json b/install/retrodeck.json index c35787abf..9c21dbde1 100644 --- a/install/retrodeck.json +++ b/install/retrodeck.json @@ -6,7 +6,7 @@ "platform": "retrodeck", "display_name": "RetroDECK", "version": "0.10.10b", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "", "detect": [ { @@ -292,10 +292,10 @@ "source": "bios/dc/dc_nvmem.bin" } ], - "total_files": 8904, - "total_size": 9019527558, - "pack_files": 8906, - "pack_size": 9019527558, + "total_files": 8906, + "total_size": 9020105094, + "pack_files": 8908, + "pack_size": 9020105094, "total_omitted": 66, "omitted_files": [ { @@ -133242,6 +133242,19 @@ "nec-pc-98" ] }, + { + "dest": "bios/np2/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "nekop2" + ], + "systems": [ + "nec-pc-98" + ] + }, { "dest": "bios/np2/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", @@ -133411,6 +133424,19 @@ "nec-pc-98" ] }, + { + "dest": "bios/np2kai/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ], + "systems": [ + "nec-pc-98" + ] + }, { "dest": "bios/np2kai/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", diff --git a/install/retropie.json b/install/retropie.json index a6e1e4ad8..c02fee8a5 100644 --- a/install/retropie.json +++ b/install/retropie.json @@ -6,7 +6,7 @@ "platform": "retropie", "display_name": "RetroPie", "version": "4.8.12", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "BIOS", "detect": [ { @@ -16,10 +16,10 @@ } ], "standalone_copies": [], - "total_files": 8725, - "total_size": 8826568678, - "pack_files": 11281, - "pack_size": 8859935748, + "total_files": 8726, + "total_size": 8826857446, + "pack_files": 11282, + "pack_size": 8860224516, "total_omitted": 347, "omitted_files": [ { @@ -9247,6 +9247,17 @@ "cores": null, "systems": [ "nec-pc-98" + ], + "alternatives": [ + { + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ] + } ] }, { @@ -119963,6 +119974,19 @@ "nec-pc-98" ] }, + { + "dest": "np2/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "nekop2" + ], + "systems": [ + "nec-pc-98" + ] + }, { "dest": "np2/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", diff --git a/install/rocknix.json b/install/rocknix.json index d3f78ec94..5b25c4309 100644 --- a/install/rocknix.json +++ b/install/rocknix.json @@ -6,7 +6,7 @@ "platform": "rocknix", "display_name": "ROCKNIX", "version": "20261001", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "bios", "detect": [ { @@ -21,10 +21,10 @@ } ], "standalone_copies": [], - "total_files": 7355, - "total_size": 8271344313, - "pack_files": 7357, - "pack_size": 8271344313, + "total_files": 7357, + "total_size": 8271921849, + "pack_files": 7359, + "pack_size": 8271921849, "total_omitted": 115, "omitted_files": [ { @@ -76166,6 +76166,16 @@ "nekop2" ] }, + { + "dest": "np2/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "nekop2" + ] + }, { "dest": "np2/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", @@ -76409,6 +76419,16 @@ "np2kai" ] }, + { + "dest": "np2kai/FONT.ROM", + "sha1": "78ba9960f135372825ab7244b5e4e73a810002ff", + "sha256": "8db165d567e13bce3f50ee495975671faa5a0ff332dcb08e187aa91125c81ec6", + "size": 288768, + "repo_path": "bios/NEC/PC-98/font.rom", + "cores": [ + "np2kai" + ] + }, { "dest": "np2kai/sound.rom", "sha1": "d5dbc4fea3b8367024d363f5351baecd6adcd8ef", diff --git a/install/romm.json b/install/romm.json index bdb7b2763..f63923825 100644 --- a/install/romm.json +++ b/install/romm.json @@ -6,7 +6,7 @@ "platform": "romm", "display_name": "RomM", "version": "5.4.0", - "generated": "2026-11-05T14:56:18Z", + "generated": "2026-11-05T18:31:29Z", "base_destination": "bios", "detect": [ { @@ -26,7 +26,7 @@ "total_size": 872654387, "pack_files": 467, "pack_size": 872654387, - "total_omitted": 775, + "total_omitted": 777, "omitted_files": [ { "dest": "32X_G_BIOS.BIN", @@ -4072,6 +4072,16 @@ "fbneo" ] }, + { + "dest": "np2/FONT.ROM", + "name": "FONT.ROM", + "system": "", + "required": false, + "reason": "below_platform_folder", + "cores": [ + "nekop2" + ] + }, { "dest": "np2/bios9821.rom", "name": "bios9821.rom", @@ -4162,6 +4172,16 @@ "np2kai" ] }, + { + "dest": "np2kai/FONT.ROM", + "name": "FONT.ROM", + "system": "", + "required": false, + "reason": "below_platform_folder", + "cores": [ + "np2kai" + ] + }, { "dest": "np2kai/ide.rom", "name": "ide.rom", diff --git a/tests/test_np2_fonts.py b/tests/test_np2_fonts.py new file mode 100644 index 000000000..fe417bff0 --- /dev/null +++ b/tests/test_np2_fonts.py @@ -0,0 +1,81 @@ +"""NP2kai and meowPC98 read font.bmp and FONT.ROM as two files. + +font_load reads the PC-98 bitmap (font.bmp, FONT.BMP) and then the V98 ROM +(FONT.ROM, font.rom), each through its own reader (NP2kai font/font.c:192-195, +meowPC98 font/font.c:180-181). Hung on font.bmp as aliases, the V98 names let +a collection without font.bmp serve the PC-88's 2 KB font.rom as np2kai/font.bmp, +which fontpc98_read cannot parse, and FONT.ROM was never placed under its name. +""" + +from __future__ import annotations + +import hashlib +import os +import shutil +import sys +import tempfile +import unittest +from pathlib import Path + +import yaml + +REPO_ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(REPO_ROOT / "scripts")) + +from common import resolve_local_file # noqa: E402 + +V98_SIZE = 0x46800 + + +def _entry(profile: str, name: str) -> dict: + with open(REPO_ROOT / "emulators" / f"{profile}.yml") as handle: + files = yaml.safe_load(handle)["files"] + entry = next(f for f in files if f.get("name") == name) + return {**entry, "source_profile": profile} + + +class FontFormatsAreSeparateFiles(unittest.TestCase): + def setUp(self): + (REPO_ROOT / "tmp").mkdir(exist_ok=True) + self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp")) + self.addCleanup(shutil.rmtree, self.root, True) + self.addCleanup(os.chdir, os.getcwd()) + os.chdir(self.root) + self.db = {"files": {}, "indexes": { + "by_md5": {}, "by_name": {}, "by_crc32": {}, "by_path_suffix": {}, + }} + self.pc88 = self._hold("bios/NEC/PC-88/font.rom", b"8" * 2048) + self.v98 = self._hold("bios/NEC/PC-98/font.rom", b"V" * V98_SIZE) + + def _hold(self, rel: str, data: bytes) -> str: + target = self.root / rel + target.parent.mkdir(parents=True, exist_ok=True) + target.write_bytes(data) + sha1 = hashlib.sha1(data).hexdigest() + name = rel.rsplit("/", 1)[-1] + self.db["files"][sha1] = { + "path": rel, "name": name, "size": len(data), + "md5": hashlib.md5(data).hexdigest(), "crc32": "", + } + self.db["indexes"]["by_name"].setdefault(name, []).append(sha1) + return rel + + def test_no_v98_name_answers_for_the_bitmap(self): + for profile in ("np2kai", "nekop2"): + with self.subTest(profile=profile): + entry = _entry(profile, "font.bmp") + self.assertEqual(resolve_local_file(entry, self.db), (None, "not_found")) + + def test_the_v98_font_is_its_own_entry_and_skips_the_pc88_font(self): + for profile in ("np2kai", "nekop2"): + with self.subTest(profile=profile): + entry = _entry(profile, "FONT.ROM") + self.db["indexes"]["by_name"]["FONT.ROM"] = ( + self.db["indexes"]["by_name"]["font.rom"] + ) + path, _status = resolve_local_file(entry, self.db) + self.assertEqual(path, self.v98) + + +if __name__ == "__main__": + unittest.main()