--- /dev/null
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ * Copyright (C) 2011 CaH4e3\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * FDS Conversion\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg, mirr;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+ {®, 1, "REG"},\r
+ {&mirr, 1, "MIRR"},\r
+ {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+ setprg8(0x6000, reg);\r
+ setprg32r(1, 0x8000, 0);\r
+ setchr8(0);\r
+ setmirror(mirr);\r
+}\r
+\r
+static DECLFW(AC08Mirr)\r
+{\r
+ mirr = ((V&8)>>3)^1;\r
+ Sync();\r
+}\r
+\r
+static DECLFW(AC08Write)\r
+{\r
+ if(A == 0x8001) // Green Berret bank switching is only 100x xxxx xxxx xxx1 mask\r
+ reg = (V >> 1) & 0xf;\r
+ else\r
+ reg = V & 0xf; // Sad But True, 2-in-1 mapper, Green Berret need value shifted left one byte, Castlevania doesn't\r
+ Sync();\r
+}\r
+\r
+static void AC08Power(void)\r
+{\r
+ reg = 0;\r
+ Sync();\r
+ SetReadHandler(0x6000,0xFFFF,CartBR);\r
+ SetWriteHandler(0x4025,0x4025,AC08Mirr);\r
+ SetWriteHandler(0x8000,0xFFFF,AC08Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+ Sync();\r
+}\r
+\r
+void AC08_Init(CartInfo *info)\r
+{\r
+ info->Power=AC08Power;\r
+ GameStateRestore=StateRestore;\r
+ AddExState(&StateRegs, ~0, 0, 0);\r
+}\r