Skip to content

Commit

Permalink
Merge remote-tracking branch 'irixxxx/master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Oct 18, 2024
2 parents fc72a81 + 890e527 commit f456ee5
Show file tree
Hide file tree
Showing 49 changed files with 1,190 additions and 521 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ jobs:
- name: make
run: LDFLAGS=-Wl,--no-undefined make -j$(getconf _NPROCESSORS_ONLN) -f Makefile.libretro

build-win32:
runs-on: ubuntu-latest
container: ghcr.io/irixxxx/toolchain-win32
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: build
run: |
git config --global --add safe.directory $PWD
ver=$(cut -d'"' -f2 platform/common/version.h)-$(git rev-parse --short HEAD)
./configure --platform=win32
make -j$(getconf _NPROCESSORS_ONLN)
mv PicoDrive.zip PicoDrive-win32-$ver.zip
- name: artifacts
uses: actions/upload-artifact@v4
with:
name: Win32
path: PicoDrive-win32*.zip


build-gp2x:
runs-on: ubuntu-latest
Expand Down
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ PicoDrive.zip: $(TARGET)
all: PicoDrive.zip
endif

ifeq "$(PLATFORM)" "win32"
PicoDrive.zip: $(TARGET)
$(RM) -rf .od_data
mkdir .od_data
cp -r platform/linux/skin .od_data
cp platform/game_def.cfg .od_data
$(STRIP) $< -o .od_data/PicoDrive.exe
cd .od_data && zip -9 -r ../$@ *
all: PicoDrive.zip
endif

ifeq "$(PLATFORM)" "opendingux"
.od_data: $(TARGET)
$(RM) -rf .od_data
Expand Down Expand Up @@ -247,6 +258,14 @@ OBJS += platform/ps2/emu.o
OBJS += platform/ps2/in_ps2.o
USE_FRONTEND = 1
endif
ifeq "$(PLATFORM)" "win32"
CFLAGS += -DSDL_OVERLAY_2X -DSDL_BUFFER_3X -DSDL_REDRAW_EVT
OBJS += platform/win32/plat.o
OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
OBJS += platform/common/plat_sdl.o platform/common/inputmap_kbd.o
OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
USE_FRONTEND = 1
endif
ifeq "$(PLATFORM)" "libretro"
OBJS += platform/libretro/libretro.o
ifneq ($(STATIC_LINKING), 1)
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ At present, most development activity occurs in
[irixxxx's fork](https://github.com/irixxxx/picodrive);
[notaz's repo](https://github.com/notaz/picodrive) is updated less frequently.

### Using MSU, MD+/32X+, and Mode 1 on Sega/Mega CD

PicoDrive supports using CD audio enhanced cartridge games in all 3 formats.
To start an enhanced cartridge, load the .cue or .chd file. The cartridge
file should have the same base name and be placed in the same directory.
Further instructions can be found in `platform/base_readme.txt`.

### Sega Pico and Storyware Pages

PicoDrive can use Storyware pages and pad overlays in png format in the same
Expand Down
7 changes: 5 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ check_define()
# "" means "autodetect".

# TODO this is annoyingly messy. should have platform and device
platform_list="generic pandora gph dingux retrofw opendingux[-gcw0] odbeta[-gcw0] miyoo rpi1 rpi2 ps2 psp"
platform_list="generic pandora gph dingux retrofw opendingux[-gcw0] odbeta[-gcw0] miyoo rpi1 rpi2 ps2 psp win32"
platform="generic"
sound_driver_list="oss alsa sdl"
sound_drivers=""
Expand Down Expand Up @@ -160,6 +160,9 @@ set_platform()
CFLAGS="$CFLAGS -D_EE -G0 -I${PS2SDK}/ee/include -I${PS2SDK}/common/include -I${PS2DEV}/gsKit/include -I${PS2SDK}/ports/include"
LDFLAGS="$LDFLAGS -Wl,-zmax-page-size=128 -T${PS2SDK}/ee/startup/linkfile -L${PS2SDK}/ee/lib -L${PS2DEV}/gsKit/lib -L${PS2SDK}/ports/lib"
;;
win32)
MFLAGS=""
;;
*)
fail "unsupported platform: $platform"
;;
Expand Down Expand Up @@ -286,7 +289,7 @@ arm*)
esac

case "$platform" in
rpi1 | rpi2 | generic | opendingux)
rpi1 | rpi2 | generic | opendingux | win32)
need_sdl="yes"
;;
esac
Expand Down
6 changes: 2 additions & 4 deletions pico/32x/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1172,11 +1172,9 @@ static void PicoWrite16_32x_on_io_cd(u32 a, u32 d)

static void PicoWrite16_32x_on_io_ssf2(u32 a, u32 d)
{
PicoWrite16_io(a, d);
if ((a & ~0x0f) == 0xa130f0) {
carthw_ssf2_write8(a + 1, d);
carthw_ssf2_write16(a, d);
if (a == 0x130f0)
bank_switch_rom_68k(Pico32x.regs[4 / 2]);
}
}

// before ADEN
Expand Down
28 changes: 14 additions & 14 deletions pico/cart.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,12 +797,6 @@ int PicoCartLoad(pm_file *f, const unsigned char *rom, unsigned int romsize,

if (!is_sms)
{
// maybe we are loading MegaCD BIOS?
if (!(PicoIn.AHW & PAHW_MCD) && size == 0x20000 && (!strncmp((char *)rom_data+0x124, "BOOT", 4) ||
!strncmp((char *)rom_data+0x128, "BOOT", 4))) {
PicoIn.AHW |= PAHW_MCD;
}

// Check for SMD:
if (size >= 0x4200 && (size&0x3fff) == 0x200 &&
((rom_data[0x2280] == 'S' && rom_data[0x280] == 'E') || (rom_data[0x280] == 'S' && rom_data[0x2281] == 'E'))) {
Expand Down Expand Up @@ -859,7 +853,7 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_
PicoLoadStateHook = NULL;
carthw_chunks = NULL;

if (!(PicoIn.AHW & (PAHW_MCD|PAHW_SMS|PAHW_PICO)))
if (!(PicoIn.AHW & (PAHW_SMS|PAHW_PICO)))
PicoCartDetect(carthw_cfg);
if (PicoIn.AHW & PAHW_SMS)
PicoCartDetectMS();
Expand Down Expand Up @@ -932,14 +926,18 @@ static unsigned int rom_crc32(int size)
return crc;
}

static int rom_strcmp(int rom_offset, const char *s1)
int rom_strcmp(void *rom, int size, int offset, const char *s1)
{
int i, len = strlen(s1);
const char *s_rom = (const char *)Pico.rom;
if (rom_offset + len > Pico.romsize)
return 0;
const char *s_rom = (const char *)rom;
if (offset + len > size)
return 1;

if (PicoIn.AHW & PAHW_SMS)
return strncmp(s_rom + offset, s1, strlen(s1));

for (i = 0; i < len; i++)
if (s1[i] != s_rom[MEM_BE2(i + rom_offset)])
if (s1[i] != s_rom[MEM_BE2(i + offset)])
return 1;
return 0;
}
Expand Down Expand Up @@ -1063,7 +1061,7 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram,
{
int offs;
offs = strtoul(p, &r, 0);
if (offs < 0 || offs > Pico.romsize) {
if (offs < 0) {
elprintf(EL_STATUS, "carthw:%d: check_str offs out of range: %d\n", line, offs);
goto bad;
}
Expand All @@ -1079,7 +1077,7 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram,
goto bad;
*r = 0;

if (rom_strcmp(offs, p) == 0)
if (rom_strcmp(Pico.rom, Pico.romsize, offs, p) == 0)
any_checks_passed = 1;
else
skip_sect = 1;
Expand Down Expand Up @@ -1138,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
3 changes: 3 additions & 0 deletions pico/carthw/carthw.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern int carthw_ssf2_active;
extern unsigned char carthw_ssf2_banks[8];
void carthw_ssf2_startup(void);
void carthw_ssf2_write8(u32 a, u32 d);
void carthw_ssf2_write16(u32 a, u32 d);

/* misc */
void carthw_Xin1_startup(void);
Expand All @@ -37,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);
Loading

0 comments on commit f456ee5

Please sign in to comment.