diff --git a/pico/cart.c b/pico/cart.c index 2a5d12e3e..2d4ea6fd0 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -1136,6 +1136,8 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram, PicoIn.AHW = PAHW_SVP; else if (strcmp(p, "pico") == 0) PicoIn.AHW = PAHW_PICO; + else if (strcmp(p, "j_cart") == 0) + carthw_jcart_startup(); else if (strcmp(p, "prot") == 0) carthw_sprot_startup(); else if (strcmp(p, "flash") == 0) diff --git a/pico/carthw.cfg b/pico/carthw.cfg index 5c90080b5..a5669e184 100644 --- a/pico/carthw.cfg +++ b/pico/carthw.cfg @@ -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 diff --git a/pico/carthw/carthw.c b/pico/carthw/carthw.c index edace51b8..629262a1d 100644 --- a/pico/carthw/carthw.c +++ b/pico/carthw/carthw.c @@ -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 diff --git a/pico/carthw/carthw.h b/pico/carthw/carthw.h index e221d9eb6..e885101fd 100644 --- a/pico/carthw/carthw.h +++ b/pico/carthw/carthw.h @@ -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); diff --git a/pico/memory.c b/pico/memory.c index 1d52a8586..b0ee21c27 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -432,6 +432,12 @@ static NOINLINE u32 port_read(int i) return (in & ~ctrl_reg) | (data_reg & ctrl_reg); } +// pad export for J-Cart +u32 PicoReadPad(int i, u32 out_bits) +{ + return read_pad_3btn(i, out_bits); +} + void PicoSetInputDevice(int port, enum input_device device) { port_read_func *func; diff --git a/pico/pico_int.h b/pico/pico_int.h index a7da9123c..0c71233ad 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -750,6 +750,7 @@ u32 PicoRead8_io(u32 a); u32 PicoRead16_io(u32 a); void PicoWrite8_io(u32 a, u32 d); void PicoWrite16_io(u32 a, u32 d); +u32 PicoReadPad(int i, u32 mask); // pico/memory.c PICO_INTERNAL void PicoMemSetupPico(void); diff --git a/platform/common/menu_pico.c b/platform/common/menu_pico.c index 0900bf8c5..934a1d2f5 100644 --- a/platform/common/menu_pico.c +++ b/platform/common/menu_pico.c @@ -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[] = { diff --git a/platform/libpicofe b/platform/libpicofe index fbbf5e3fc..86a086ed6 160000 --- a/platform/libpicofe +++ b/platform/libpicofe @@ -1 +1 @@ -Subproject commit fbbf5e3fc0aff858e206dd98ce4605b960d397cb +Subproject commit 86a086ed64aadc1e87fc58a90703a07d91c9cdbe