merge mapper code from FCEUX
[fceu.git] / boards / 411120-c.c
diff --git a/boards/411120-c.c b/boards/411120-c.c
new file mode 100644 (file)
index 0000000..479a9bf
--- /dev/null
@@ -0,0 +1,70 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+// actually cart ID is 811120-C, sorry ;) K-3094 - another ID\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 reset_flag = 0;\r
+\r
+static void BMC411120CCW(uint32 A, uint8 V)\r
+{\r
+    setchr1(A,V|((EXPREGS[0]&3)<<7));\r
+}\r
+\r
+static void BMC411120CPW(uint32 A, uint8 V)\r
+{\r
+    if(EXPREGS[0]&(8|reset_flag))\r
+      setprg32(0x8000,((EXPREGS[0]>>4)&3)|(0x0C));\r
+    else\r
+      setprg8(A,(V&0x0F)|((EXPREGS[0]&3)<<4));\r
+}\r
+\r
+static DECLFW(BMC411120CLoWrite)\r
+{\r
+  EXPREGS[0] = A;\r
+  FixMMC3PRG(MMC3_cmd);\r
+  FixMMC3CHR(MMC3_cmd);\r
+}\r
+\r
+static void BMC411120CReset(void)\r
+{\r
+  EXPREGS[0]=0;\r
+  reset_flag ^=4;\r
+  MMC3RegReset();\r
+}\r
+\r
+static void BMC411120CPower(void)\r
+{\r
+  EXPREGS[0] = 0;\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x6000,0x7FFF,BMC411120CLoWrite);\r
+}\r
+\r
+void BMC411120C_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 128, 128, 8, 0);\r
+  pwrap=BMC411120CPW;\r
+  cwrap=BMC411120CCW;\r
+  info->Power=BMC411120CPower;\r
+  info->Reset=BMC411120CReset;\r
+  AddExState(EXPREGS, 1, 0, "EXPR");\r
+}\r