md, add more unlicensed
authorkub <derkub@gmail.com>
Tue, 3 Sep 2024 20:44:09 +0000 (22:44 +0200)
committerkub <derkub@gmail.com>
Tue, 3 Sep 2024 20:44:09 +0000 (22:44 +0200)
pico/cart.c
pico/carthw.cfg
pico/carthw/carthw.c
pico/carthw/carthw.h
pico/carthw_cfg.c

index a196dfd..a432cf0 100644 (file)
@@ -922,7 +922,7 @@ void PicoCartUnload(void)
 static unsigned int rom_crc32(int size)\r
 {\r
   unsigned int crc;\r
-  elprintf(EL_STATUS, "caclulating CRC32..");\r
+  elprintf(EL_STATUS, "calculating CRC32..");\r
   if (size <= 0 || size > Pico.romsize) size = Pico.romsize;\r
 \r
   // have to unbyteswap for calculation..\r
@@ -1140,6 +1140,8 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram,
         PicoIn.AHW = PAHW_PICO;\r
       else if (strcmp(p, "prot") == 0)\r
         carthw_sprot_startup();\r
+      else if (strcmp(p, "flash") == 0)\r
+        carthw_flash_startup();\r
       else if (strcmp(p, "ssf2_mapper") == 0)\r
         carthw_ssf2_startup();\r
       else if (strcmp(p, "x_in_1_mapper") == 0)\r
index 5932dd7..5c90080 100644 (file)
@@ -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
index ccafe72..edace51 100644 (file)
@@ -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<<M68K_MEM_SHIFT)-1;
+  switch (++flash_writecount) {
+    case 3: cpu68k_map_set(m68k_read16_map, 0, banksz, PicoRead16_flash, 1);
+            break;
+    case 4: cpu68k_map_read_mem(0, banksz, Pico.rom, 0);
+            flash_writecount = 0;
+            break;
+  }
+}
+
+static void carthw_flash_mem_setup(void)
+{
+  cpu68k_map_set(m68k_write16_map, 0, 0x7fffff, PicoWrite16_flash, 1);
+}
+
+void carthw_flash_startup(void)
+{
+  elprintf(EL_STATUS, "Flash prot emu startup");
+
+  PicoCartMemSetup   = carthw_flash_mem_setup;
+  carthw_chunks      = carthw_flash_state;
+}
+
 /* Simple unlicensed ROM protection emulation */
 static struct {
   u32 addr;
index bcf91da..de571f7 100644 (file)
@@ -30,6 +30,7 @@ void carthw_sf001_startup(void);
 void carthw_sf002_startup(void);
 void carthw_sf004_startup(void);
 
+void carthw_flash_startup(void);
 void carthw_sprot_startup(void);
 void carthw_sprot_new_location(unsigned int a,
        unsigned int mask, unsigned short val, int is_ro);
index 8c46a5f..0ea1ee7 100644 (file)
@@ -66,6 +66,9 @@ static const char builtin_carthw_cfg[] =
   "hw=sf004_mapper\n"
   "sram_range=0x200000,0x207fff\n"
   "[]\n"
+  "check_str=0x120,\"Escape 2042\"\n"
+  "hw=flash\n"
+  "[]\n"
   "check_str=0x120,\"FLICKY\"\n"
   "check_size_gt=0x020000\n"
   "hw=x_in_1_mapper\n"
@@ -99,7 +102,6 @@ static const char builtin_carthw_cfg[] =
   "hw=radica_mapper\n"
   "[]\n"
   "check_str=0x150,\"STREET FIGHTER\"\n"
-  "check_str=0x161,\"SPECIAL CHAMPION EDITION\"\n"
   "check_size_gt=0x300000\n"
   "hw=radica_mapper\n"
   "[]\n"
@@ -400,6 +402,14 @@ static const char builtin_carthw_cfg[] =
   "prot_ro_value16=0x400004,-2,0xc900\n"
   "prot_ro_value16=0x400006,-2,0xf000\n"
   "[]\n"
+  "check_str=0x104,\"                \"\n"
+  "check_crc32=0x83397760\n"
+  "hw=prot\n"
+  "prot_ro_value16=0x400000,-2,0x6300\n"
+  "prot_ro_value16=0x400002,-2,0x9800\n"
+  "prot_ro_value16=0x400004,-2,0xaa00\n"
+  "prot_ro_value16=0x400006,-2,0xf000\n"
+  "[]\n"
   "check_csum=0xffff\n"
   "check_crc32=0xdd02797c\n"
   "hw=prot\n"