From fe9a06d2ac54b6bce9040b9c67082e3fffb01bcc Mon Sep 17 00:00:00 2001 From: kub Date: Tue, 3 Sep 2024 22:44:09 +0200 Subject: [PATCH] md, add more unlicensed --- pico/cart.c | 4 +++- pico/carthw.cfg | 17 ++++++++++++++++- pico/carthw/carthw.c | 36 ++++++++++++++++++++++++++++++++++++ pico/carthw/carthw.h | 1 + pico/carthw_cfg.c | 12 +++++++++++- 5 files changed, 67 insertions(+), 3 deletions(-) diff --git a/pico/cart.c b/pico/cart.c index a196dfdf..a432cf07 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -922,7 +922,7 @@ void PicoCartUnload(void) static unsigned int rom_crc32(int size) { unsigned int crc; - elprintf(EL_STATUS, "caclulating CRC32.."); + elprintf(EL_STATUS, "calculating CRC32.."); if (size <= 0 || size > Pico.romsize) size = Pico.romsize; // have to unbyteswap for calculation.. @@ -1140,6 +1140,8 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram, PicoIn.AHW = PAHW_PICO; else if (strcmp(p, "prot") == 0) carthw_sprot_startup(); + else if (strcmp(p, "flash") == 0) + carthw_flash_startup(); else if (strcmp(p, "ssf2_mapper") == 0) carthw_ssf2_startup(); else if (strcmp(p, "x_in_1_mapper") == 0) diff --git a/pico/carthw.cfg b/pico/carthw.cfg index 5932dd7c..5c90080b 100644 --- a/pico/carthw.cfg +++ b/pico/carthw.cfg @@ -2,6 +2,7 @@ # svp - Sega Virtua Processor # pico - Sega Pico (not really cart hw, but convenient to support here) # prot - simple copy protection devices in unlicensed cartridges (see prot. below) +# flash - protection through reading the flash chip ID # # cartridge properties (prop = ...): # no_sram - don't emulate sram/EEPROM even if ROM headers tell it's there @@ -129,6 +130,11 @@ check_str = 0x150, "STAR ODYSSEY" hw = sf004_mapper sram_range = 0x200000,0x207fff +# Escape 2042, reads flash ID for protection +[Escape 2042] +check_str = 0x120, "Escape 2042" +hw = flash + # detect *_in_1 based on first game and if it's larger than it should be, # as some dumps look like to be incomplete. # This will also pick overdumps, but those should still work with the mapper applied. @@ -534,13 +540,22 @@ prot_ro_value16 = 0x400002,-2,0x0f00 prot_ro_value16 = 0x400004,-2,0xaa00 prot_ro_value16 = 0x400006,-2,0xf000 -[16 Tiles Mahjong 1+2 (Unl)] # Zhang majiang +[16 Tiles Mahjong 1+2 (Unl)] # Shi liu zhang majiang check_str = 0xfe, "WISEGAME IS TRADE MARKER" hw = prot prot_ro_value16 = 0x400002,-2,0xaa00 prot_ro_value16 = 0x400004,-2,0xc900 prot_ro_value16 = 0x400006,-2,0xf000 +[13 Tiles Mahjong] # Shi san zhang majiang +check_str = 0x104, " " +check_crc32 = 0x83397760 +hw = prot +prot_ro_value16 = 0x400000,-2,0x6300 +prot_ro_value16 = 0x400002,-2,0x9800 +prot_ro_value16 = 0x400004,-2,0xaa00 +prot_ro_value16 = 0x400006,-2,0xf000 + [Super Poker (Unl)] # Chaoji puke check_csum = 0xffff check_crc32 = 0xdd02797c diff --git a/pico/carthw/carthw.c b/pico/carthw/carthw.c index ccafe726..edace51b 100644 --- a/pico/carthw/carthw.c +++ b/pico/carthw/carthw.c @@ -737,6 +737,42 @@ void carthw_sf004_startup(void) carthw_chunks = carthw_sf00x_state; } +/* Simple protection through reading flash ID */ +static int flash_writecount; + +static carthw_state_chunk carthw_flash_state[] = +{ + { CHUNK_CARTHW, sizeof(flash_writecount), &flash_writecount }, + { 0, 0, NULL } +}; + +static u32 PicoRead16_flash(u32 a) { return (a&6) ? 0x2257 : 0x0020; } + +static void PicoWrite16_flash(u32 a, u32 d) +{ + int banksz = (1<