+/* 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
+ * PCB-018 board, discrete multigame cart 110-in-1\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 prot[4], prg, mode, chr, mirr;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+ {prot, 4, "PROT"},\r
+ {&prg, 1, "PRG"},\r
+ {&chr, 1, "CHR"},\r
+ {&mode, 1, "MODE"},\r
+ {&mirr, 1, "MIRR"},\r
+ {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+ if(mode)\r
+ {\r
+ setprg16(0x8000,prg);\r
+ setprg16(0xC000,prg);\r
+ }\r
+ else\r
+ setprg32(0x8000,prg>>1);\r
+ setchr8(chr);\r
+ setmirror(mirr);\r
+}\r
+\r
+static DECLFW(M225Write)\r
+{\r
+ uint32 bank = (A >> 14) & 1;\r
+ mirr = (A >> 13) & 1;\r
+ mode = (A >> 12) & 1;\r
+ chr = (A & 0x3f) | (bank << 6);\r
+ prg = ((A >> 6) & 0x3f) | (bank << 6);\r
+ Sync();\r
+}\r
+\r
+static DECLFW(M225LoWrite)\r
+{\r
+}\r
+\r
+static DECLFR(M225LoRead)\r
+{\r
+ return 0;\r
+}\r
+\r
+static void M225Power(void)\r
+{ \r
+ prg = 0;\r
+ mode = 0;\r
+ Sync();\r
+ SetReadHandler(0x5000,0x5fff,M225LoRead);\r
+ SetWriteHandler(0x5000,0x5fff,M225LoWrite);\r
+ SetReadHandler(0x8000,0xFFFF,CartBR);\r
+ SetWriteHandler(0x8000,0xFFFF,M225Write);\r
+}\r
+\r
+static void M225Reset(void)\r
+{\r
+ prg = 0;\r
+ mode = 0;\r
+ Sync();\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+ Sync();\r
+}\r
+\r
+void Mapper225_Init(CartInfo *info)\r
+{\r
+ info->Reset=M225Reset;\r
+ info->Power=M225Power;\r
+ GameStateRestore=StateRestore;\r
+ AddExState(&StateRegs, ~0, 0, 0);\r
+}\r