X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2Fcarthw%2Fcarthw.c;h=eb71bbe681e96811daaedc3a8028a863951877b6;hb=5ed2561c910308a0b5a4d4621e35f2a3806c30eb;hp=d22a23579ecaa0a7009ca42370bf7da0e252f656;hpb=bdec53c90b6e53990fc206cabaec31b844f34d1e;p=picodrive.git diff --git a/Pico/carthw/carthw.c b/Pico/carthw/carthw.c index d22a235..eb71bbe 100644 --- a/Pico/carthw/carthw.c +++ b/Pico/carthw/carthw.c @@ -1,12 +1,18 @@ /* - * should better do some pointer stuff here. But as none of these bankswitch + * Support for a few cart mappers. + * + * (c) Copyright 2008, Grazvydas "notaz" Ignotas + * Free for non-commercial use. + * + * + * I should better do some pointer stuff here. But as none of these bankswitch * while the game runs, memcpy will suffice. */ #include "../PicoInt.h" -/* 12-in-1 and 4-in-1. Assuming 2MB ROMs here. */ +/* 12-in-1 and 4-in-1. Assuming >= 2MB ROMs here. */ static unsigned int carthw_12in1_baddr = 0; static carthw_state_chunk carthw_12in1_state[] = @@ -38,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; } @@ -110,7 +116,7 @@ static void carthw_realtec_write8(unsigned int a, unsigned int d, int realsize) } else elprintf(EL_ANOMALY, "realtec: unexpected write [%06x] %02x @ %06x", a, d, SekPc); - + if (realtec_bank >= 0 && realtec_size >= 0 && (realtec_bank != bank_old || realtec_size != size_old)) { @@ -126,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 */ @@ -156,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; +} + +