/*
- * 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[] =
+{
+ { CHUNK_CARTHW, sizeof(carthw_12in1_baddr), &carthw_12in1_baddr },
+ { 0, 0, NULL }
+};
+
static unsigned int carthw_12in1_read16(unsigned int a, int realsize)
{
// ??
return;
}
+ carthw_12in1_baddr = a;
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;
}
carthw_12in1_write8(0xA13000, 0, 0);
}
+static void carthw_12in1_statef(void)
+{
+ carthw_12in1_write8(carthw_12in1_baddr, 0, 0);
+}
+
void carthw_12in1_startup(void)
{
void *tmp;
PicoRead16Hook = carthw_12in1_read16;
PicoWrite8Hook = carthw_12in1_write8;
PicoResetHook = carthw_12in1_reset;
+ PicoLoadStateHook = carthw_12in1_statef;
+ carthw_chunks = carthw_12in1_state;
}
}
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))
{
}
}
-void carthw_realtec_reset(void)
+static void carthw_realtec_reset(void)
{
int i;
/* map boot code */
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;
+}
+
+