From: notaz Date: Fri, 13 Jun 2008 12:29:07 +0000 (+0000) Subject: Radica mapper added X-Git-Tag: v1.85~470 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b35350da642c6de77de35a226e3692f1841d6e4;p=picodrive.git Radica mapper added git-svn-id: file:///home/notaz/opt/svn/PicoDrive@482 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/Pico/Cart.c b/Pico/Cart.c index 4de0fd44..a0d38a0b 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -707,6 +707,12 @@ static void PicoCartDetect(void) carthw_realtec_startup(); } + // Radica mapper + else if (name_cmp("KID CHAMELEON") == 0 && Pico.romsize > 0x100000) + { + carthw_radica_startup(); + } + // Some games malfunction if SRAM is not filled with 0xff if (name_cmp("DINO DINI'S SOCCER") == 0 || name_cmp("MICRO MACHINES II") == 0) diff --git a/Pico/carthw/carthw.c b/Pico/carthw/carthw.c index eab13b8e..eb71bbe6 100644 --- a/Pico/carthw/carthw.c +++ b/Pico/carthw/carthw.c @@ -44,7 +44,7 @@ static void carthw_12in1_write8(unsigned int a, unsigned int d, int realsize) a &= 0x3f; a <<= 16; len = Pico.romsize - a; if (len <= 0) { - elprintf(EL_ANOMALY, "12-in-1: missing bank @ %06x", a); + elprintf(EL_ANOMALY|EL_STATUS, "12-in-1: missing bank @ %06x", a); return; } @@ -132,7 +132,7 @@ static void carthw_realtec_write8(unsigned int a, unsigned int d, int realsize) } } -void carthw_realtec_reset(void) +static void carthw_realtec_reset(void) { int i; /* map boot code */ @@ -162,3 +162,64 @@ void carthw_realtec_startup(void) PicoResetHook = carthw_realtec_reset; } +/* Radica mapper, based on DevSter's info + * http://devster.monkeeh.com/sega/radica/ + */ +static unsigned int carthw_radica_baddr = 0; + +static carthw_state_chunk carthw_radica_state[] = +{ + { CHUNK_CARTHW, sizeof(carthw_radica_baddr), &carthw_radica_baddr }, + { 0, 0, NULL } +}; + +static unsigned int carthw_radica_read16(unsigned int a, int realsize) +{ + if ((a & 0xffff80) != 0xa13000) { + elprintf(EL_UIO, "radica: r16 %06x", a); + return 0; + } + + carthw_radica_baddr = a; + a = (a & 0x7e) << 15; + if (a >= Pico.romsize) { + elprintf(EL_ANOMALY|EL_STATUS, "radica: missing bank @ %06x", a); + return 0; + } + memcpy(Pico.rom, Pico.rom + Pico.romsize + a, Pico.romsize - a); + + return 0; +} + +static void carthw_radica_statef(void) +{ + carthw_radica_read16(carthw_radica_baddr, 0); +} + +static void carthw_radica_reset(void) +{ + memcpy(Pico.rom, Pico.rom + Pico.romsize, Pico.romsize); +} + +void carthw_radica_startup(void) +{ + void *tmp; + + elprintf(EL_STATUS, "Radica mapper detected"); + + tmp = realloc(Pico.rom, Pico.romsize * 2); + if (tmp == NULL) + { + elprintf(EL_STATUS, "OOM"); + return; + } + Pico.rom = tmp; + memcpy(Pico.rom + Pico.romsize, Pico.rom, Pico.romsize); + + PicoRead16Hook = carthw_radica_read16; + PicoResetHook = carthw_radica_reset; + PicoLoadStateHook = carthw_radica_statef; + carthw_chunks = carthw_radica_state; +} + + diff --git a/Pico/carthw/carthw.h b/Pico/carthw/carthw.h index 29ec7b6b..6813205f 100644 --- a/Pico/carthw/carthw.h +++ b/Pico/carthw/carthw.h @@ -20,3 +20,4 @@ void PicoSVPWrite16(unsigned int a, unsigned int d, int realsize); /* misc */ void carthw_12in1_startup(void); void carthw_realtec_startup(void); +void carthw_radica_startup(void);