core, some support for j-cart
authorkub <derkub@gmail.com>
Sun, 13 Oct 2024 06:46:01 +0000 (08:46 +0200)
committerkub <derkub@gmail.com>
Tue, 15 Oct 2024 22:28:02 +0000 (00:28 +0200)
pico/cart.c
pico/carthw.cfg
pico/carthw/carthw.c
pico/carthw/carthw.h
pico/carthw_cfg.c
pico/memory.c
pico/pico_int.h
platform/common/menu_pico.c
platform/libpicofe

index 2a5d12e..2d4ea6f 100644 (file)
@@ -1136,6 +1136,8 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram,
         PicoIn.AHW = PAHW_SVP;\r
       else if (strcmp(p, "pico") == 0)\r
         PicoIn.AHW = PAHW_PICO;\r
+      else if (strcmp(p, "j_cart") == 0)\r
+        carthw_jcart_startup();\r
       else if (strcmp(p, "prot") == 0)\r
         carthw_sprot_startup();\r
       else if (strcmp(p, "flash") == 0)\r
index 5c90080..a5669e1 100644 (file)
@@ -3,6 +3,7 @@
 #  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
+#  j_cart   - 2 additional joypad ports on cart
 #
 # cartridge properties (prop = ...):
 #  no_sram         - don't emulate sram/EEPROM even if ROM headers tell it's there
@@ -88,15 +89,30 @@ prop = no_sram
 check_str = 0x150, "DINO DINI'S SOCCER"
 prop = filled_sram
 
-[Micro Machines 2 - Turbo Tournament]
-check_str = 0x150, "MICRO MACHINES II"
-prop = filled_sram
-
 # bad headers
 [HardBall III]
 check_str = 0x150, "  HardBall III"
 sram_range = 0x200000,0x20ffff
 
+# J-Cart
+[Super Skidmarks, Micro Machines Military]
+check_str = 0x150, "                "
+check_csum = 0x168b
+hw = j_cart
+
+[Pete Sampras Tennis, Micro Machines Turbo Tournament 96]
+check_str = 0x150, "                "
+check_csum = 0x165e
+hw = j_cart
+
+[Micro Machines 2 - Turbo Tournament]
+check_str = 0x150, "MICRO MACHINES II"
+hw = j_cart
+
+[Pete Sampras Tennis 96]
+check_str = 0x150, "PETE SAMPRAS TENNIS '96"
+hw = j_cart
+
 # The SSF2 mapper
 [Mega Everdrive]
 check_str = 0x100, "SEGA SSF"
@@ -214,37 +230,50 @@ sram_range = 0x200000,0x200001
 eeprom_type = 1
 eeprom_lines = 1,0,0
 
-[MICRO MACHINES II]
+[Micro Machines 2 - Turbo Tournament]
 check_str = 0x150, "MICRO MACHINES II"
-sram_range = 0x300000,0x380001
+prop = filled_sram
+sram_range = 0x300000,0x37ffff
 eeprom_type = 2
 eeprom_lines = 9,8,7
 
 [Micro Machines - Turbo Tournament '96]
 check_str = 0x150, "                "
 check_csum = 0x165e
-sram_range = 0x300000,0x380001
+sram_range = 0x300000,0x37ffff
 eeprom_type = 2
 eeprom_lines = 9,8,7
 
 [Micro Machines - Turbo Tournament '96]
 check_str = 0x150, "                "
 check_csum = 0x2c41
-sram_range = 0x300000,0x380001
+sram_range = 0x300000,0x37ffff
 eeprom_type = 2
 eeprom_lines = 9,8,7
 
 [Micro Machines Military]
 check_str = 0x150, "                "
 check_csum = 0x168b
-sram_range = 0x300000,0x380001
+sram_range = 0x300000,0x37ffff
 eeprom_type = 2
 eeprom_lines = 9,8,7
 
 [Micro Machines Military]
 check_str = 0x150, "                "
 check_csum = 0xcee0
-sram_range = 0x300000,0x380001
+sram_range = 0x300000,0x37ffff
+eeprom_type = 2
+eeprom_lines = 9,8,7
+
+[Brian Lara Cricket]
+check_str = 0x150, "BRIAN LARA CRICKET"
+sram_range = 0x300000,0x3fffff
+eeprom_type = 2
+eeprom_lines = 9,8,7
+
+[Brian Lara Cricket 96]
+check_str = 0x150, "BRIAN LARA 96"
+sram_range = 0x300000,0x3fffff
 eeprom_type = 2
 eeprom_lines = 9,8,7
 
index edace51..629262a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Support for a few cart mappers and some protection.
  * (C) notaz, 2008-2011
- * (C) irixxxx, 2021-2022
+ * (C) irixxxx, 2021-2024
  *
  * This work is licensed under the terms of MAME license.
  * See COPYING file in the top-level directory.
@@ -1163,4 +1163,53 @@ void carthw_smw64_startup(void)
   carthw_chunks     = carthw_smw64_state;
 }
 
+/* J-Cart */
+unsigned char carthw_jcart_th;
+
+static carthw_state_chunk carthw_jcart_state[] =
+{
+  { CHUNK_CARTHW, sizeof(carthw_jcart_th), &carthw_jcart_th },
+  { 0,            0,                       NULL }
+};
+
+static void carthw_jcart_write8(u32 a, u32 d)
+{
+  carthw_jcart_th = (d&1) << 6;
+}
+
+static void carthw_jcart_write16(u32 a, u32 d)
+{
+  carthw_jcart_write8(a+1, d);
+}
+
+static u32 carthw_jcart_read8(u32 a)
+{
+  u32 v = PicoReadPad(2 + (a&1), 0x3f | carthw_jcart_th);
+  // some carts additionally have an EEPROM; SDA is also readable in this range
+  if (Pico.m.sram_reg & SRR_MAPPED)
+    v |= EEPROM_read() & 0x80; // SDA is always on bit 7 for J-Carts
+  return v;
+}
+
+static u32 carthw_jcart_read16(u32 a)
+{
+  return carthw_jcart_read8(a) | (carthw_jcart_read8(a+1) << 8);
+}
+
+static void carthw_jcart_mem_setup(void)
+{
+  cpu68k_map_set(m68k_write8_map,  0x380000, 0x3fffff, carthw_jcart_write8, 1);
+  cpu68k_map_set(m68k_write16_map, 0x380000, 0x3fffff, carthw_jcart_write16, 1);
+  cpu68k_map_set(m68k_read8_map,  0x380000, 0x3fffff, carthw_jcart_read8, 1);
+  cpu68k_map_set(m68k_read16_map, 0x380000, 0x3fffff, carthw_jcart_read16, 1);
+}
+
+void carthw_jcart_startup(void)
+{
+  elprintf(EL_STATUS, "J-Cart startup");
+
+  PicoCartMemSetup  = carthw_jcart_mem_setup;
+  carthw_chunks     = carthw_jcart_state;
+}
+
 // vim:ts=2:sw=2:expandtab
index e221d9e..e885101 100644 (file)
@@ -38,3 +38,5 @@ void carthw_sprot_new_location(unsigned int a,
 
 void carthw_lk3_startup(void);
 void carthw_smw64_startup(void);
+
+void carthw_jcart_startup(void);
index 0ea1ee7..802e1bf 100644 (file)
@@ -37,12 +37,23 @@ static const char builtin_carthw_cfg[] =
   "check_str=0x150,\"DINO DINI'S SOCCER\"\n"
   "prop=filled_sram\n"
   "[]\n"
-  "check_str=0x150,\"MICRO MACHINES II\"\n"
-  "prop=filled_sram\n"
-  "[]\n"
   "check_str=0x150,\"  HardBall III\"\n"
   "sram_range=0x200000,0x20ffff\n"
   "[]\n"
+  "check_str=0x150,\"                \"\n"
+  "check_csum=0x168b\n"
+  "hw=j_cart\n"
+  "[]\n"
+  "check_str=0x150,\"                \"\n"
+  "check_csum=0x165e\n"
+  "hw=j_cart\n"
+  "[]\n"
+  "check_str=0x150,\"MICRO MACHINES II\"\n"
+  "hw=j_cart\n"
+  "[]\n"
+  "check_str=0x150,\"PETE SAMPRAS TENNIS '96\"\n"
+  "hw=j_cart\n"
+  "[]\n"
   "check_str=0x100,\"SEGA SSF\"\n"
   "hw=ssf2_mapper\n"
   "[]\n"
@@ -128,31 +139,42 @@ static const char builtin_carthw_cfg[] =
   "eeprom_lines=1,0,0\n"
   "[]\n"
   "check_str=0x150,\"MICRO MACHINES II\"\n"
-  "sram_range=0x300000,0x380001\n"
+  "prop=filled_sram\n"
+  "sram_range=0x300000,0x37ffff\n"
   "eeprom_type=2\n"
   "eeprom_lines=9,8,7\n"
   "[]\n"
   "check_str=0x150,\"                \"\n"
   "check_csum=0x165e\n"
-  "sram_range=0x300000,0x380001\n"
+  "sram_range=0x300000,0x37ffff\n"
   "eeprom_type=2\n"
   "eeprom_lines=9,8,7\n"
   "[]\n"
   "check_str=0x150,\"                \"\n"
   "check_csum=0x2c41\n"
-  "sram_range=0x300000,0x380001\n"
+  "sram_range=0x300000,0x37ffff\n"
   "eeprom_type=2\n"
   "eeprom_lines=9,8,7\n"
   "[]\n"
   "check_str=0x150,\"                \"\n"
   "check_csum=0x168b\n"
-  "sram_range=0x300000,0x380001\n"
+  "sram_range=0x300000,0x37ffff\n"
   "eeprom_type=2\n"
   "eeprom_lines=9,8,7\n"
   "[]\n"
   "check_str=0x150,\"                \"\n"
   "check_csum=0xcee0\n"
-  "sram_range=0x300000,0x380001\n"
+  "sram_range=0x300000,0x37ffff\n"
+  "eeprom_type=2\n"
+  "eeprom_lines=9,8,7\n"
+  "[]\n"
+  "check_str=0x150,\"BRIAN LARA CRICKET\"\n"
+  "sram_range=0x300000,0x3fffff\n"
+  "eeprom_type=2\n"
+  "eeprom_lines=9,8,7\n"
+  "[]\n"
+  "check_str=0x150,\"BRIAN LARA 96\"\n"
+  "sram_range=0x300000,0x3fffff\n"
   "eeprom_type=2\n"
   "eeprom_lines=9,8,7\n"
   "[]\n"
index 1d52a85..b0ee21c 100644 (file)
@@ -432,6 +432,12 @@ static NOINLINE u32 port_read(int i)
   return (in & ~ctrl_reg) | (data_reg & ctrl_reg);\r
 }\r
 \r
+// pad export for J-Cart\r
+u32 PicoReadPad(int i, u32 out_bits)\r
+{\r
+  return read_pad_3btn(i, out_bits);\r
+}\r
+\r
 void PicoSetInputDevice(int port, enum input_device device)\r
 {\r
   port_read_func *func;\r
index a7da912..0c71233 100644 (file)
@@ -750,6 +750,7 @@ u32 PicoRead8_io(u32 a);
 u32 PicoRead16_io(u32 a);\r
 void PicoWrite8_io(u32 a, u32 d);\r
 void PicoWrite16_io(u32 a, u32 d);\r
+u32 PicoReadPad(int i, u32 mask);\r
 \r
 // pico/memory.c\r
 PICO_INTERNAL void PicoMemSetupPico(void);\r
index 0900bf8..934a1d2 100644 (file)
@@ -424,7 +424,7 @@ const char *indev0_names[] = { "none", "3 button pad", "6 button pad", "Team pla
 const char *indev1_names[] = { "none", "3 button pad", "6 button pad", NULL };
 
 static char h_play34[] = "Works only for Mega Drive/CD/32X games having\n"
-                               "support for Team player or 4 way play";
+                               "support for Team player, 4 way play, or J-cart";
 
 static menu_entry e_menu_keyconfig[] =
 {
index fbbf5e3..86a086e 160000 (submodule)
@@ -1 +1 @@
-Subproject commit fbbf5e3fc0aff858e206dd98ce4605b960d397cb
+Subproject commit 86a086ed64aadc1e87fc58a90703a07d91c9cdbe