added zram clearing on reset for Psycho Pinball (does it happen on hw?)
[picodrive.git] / Pico / carthw / carthw.c
index c3e80f8..eab13b8 100644 (file)
@@ -1,12 +1,26 @@
 /*
- * 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)
 {
        // ??
@@ -26,6 +40,7 @@ static void carthw_12in1_write8(unsigned int a, unsigned int d, int realsize)
                return;
        }
 
+       carthw_12in1_baddr = a;
        a &= 0x3f; a <<= 16;
        len = Pico.romsize - a;
        if (len <= 0) {
@@ -41,6 +56,11 @@ static void carthw_12in1_reset(void)
        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;
@@ -59,6 +79,8 @@ void carthw_12in1_startup(void)
        PicoRead16Hook = carthw_12in1_read16;
        PicoWrite8Hook = carthw_12in1_write8;
        PicoResetHook  = carthw_12in1_reset;
+       PicoLoadStateHook = carthw_12in1_statef;
+       carthw_chunks     = carthw_12in1_state;
 }
 
 
@@ -94,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))
        {