Skip to content

Commit

Permalink
core, some support for j-cart
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Oct 14, 2024
1 parent f70b6ca commit da0e1b4
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 13 deletions.
2 changes: 2 additions & 0 deletions pico/cart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
49 changes: 39 additions & 10 deletions pico/carthw.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
51 changes: 50 additions & 1 deletion pico/carthw/carthw.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions pico/carthw/carthw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
6 changes: 6 additions & 0 deletions pico/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions pico/pico_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion platform/common/menu_pico.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] =
{
Expand Down
2 changes: 1 addition & 1 deletion platform/libpicofe
Submodule libpicofe updated 1 files
+10 −2 input.c

0 comments on commit da0e1b4

Please sign in to comment.