merge mapper code from FCEUX
[fceu.git] / boards / 830118C.c
diff --git a/boards/830118C.c b/boards/830118C.c
new file mode 100644 (file)
index 0000000..8b6ce60
--- /dev/null
@@ -0,0 +1,82 @@
+/* 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
+// M-022 MMC3 based 830118C T-106 4M + 4M\r
+\r
+#include "mapinc.h"\r
+#include "mmc3.h"\r
+\r
+static uint8 reset_flag = 0;\r
+\r
+static void BMC830118CCW(uint32 A, uint8 V)\r
+{\r
+    setchr1(A,(V&0x7F)|((EXPREGS[0]&0x0c)<<5));\r
+}\r
+\r
+static void BMC830118CPW(uint32 A, uint8 V)\r
+{\r
+      if((EXPREGS[0]&0x0C)==0x0C) \r
+      {  \r
+         if(A==0x8000)\r
+         {\r
+           setprg8(A,(V&0x0F)|((EXPREGS[0]&0x0c)<<2));\r
+           setprg8(0xC000,(V&0x0F)|0x32);\r
+         }\r
+         else if(A==0xA000)\r
+         {\r
+           setprg8(A,(V&0x0F)|((EXPREGS[0]&0x0c)<<2));\r
+           setprg8(0xE000,(V&0x0F)|0x32);\r
+         }\r
+      }\r
+      else\r
+      {\r
+         setprg8(A,(V&0x0F)|((EXPREGS[0]&0x0c)<<2));\r
+      }\r
+}\r
+\r
+static DECLFW(BMC830118CLoWrite)\r
+{\r
+  EXPREGS[0] = V;\r
+  FixMMC3PRG(MMC3_cmd);\r
+  FixMMC3CHR(MMC3_cmd);\r
+}\r
+\r
+static void BMC830118CReset(void)\r
+{\r
+  EXPREGS[0]=0;\r
+  MMC3RegReset();\r
+}\r
+\r
+static void BMC830118CPower(void)\r
+{\r
+  EXPREGS[0] = 0;\r
+  GenMMC3Power();\r
+  SetWriteHandler(0x6800,0x68FF,BMC830118CLoWrite);\r
+}\r
+\r
+void BMC830118C_Init(CartInfo *info)\r
+{\r
+  GenMMC3_Init(info, 128, 128, 8, 0);\r
+  pwrap=BMC830118CPW;\r
+  cwrap=BMC830118CCW;\r
+  info->Power=BMC830118CPower;\r
+  info->Reset=BMC830118CReset;\r
+  AddExState(EXPREGS, 1, 0, "EXPR");\r
+}\r