merge mappers from FCEU-mm
[fceu.git] / boards / 96.c
diff --git a/boards/96.c b/boards/96.c
new file mode 100644 (file)
index 0000000..aa9d8a7
--- /dev/null
@@ -0,0 +1,84 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 1998 BERO\r
+ *  Copyright (C) 2002 Xodnizel\r
+ *  Copyright (C) 2012 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
+ * Oeka-kids board\r
+ *\r
+ * I might want to add some code to the mapper 96 PPU hook function\r
+ * to not change CHR banks if the attribute table is being accessed,\r
+ * if I make emulation a little more accurate in the future.\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg, ppulatch;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REG"},\r
+  {&ppulatch, 1, "PPUL"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setmirror(MI_0);\r
+  setprg32(0x8000,reg & 3);\r
+  setchr4(0x0000,(reg & 4) | ppulatch);\r
+  setchr4(0x1000,(reg & 4) | 3);\r
+}\r
+\r
+static DECLFW(M96Write)\r
+{\r
+  reg = V;\r
+  Sync();\r
+}\r
+\r
+static void FP_FASTAPASS(1) M96Hook(uint32 A)\r
+{\r
+  if((A & 0x3000) == 0x2000)\r
+  {\r
+    ppulatch = (A>>8) & 3;\r
+    Sync();\r
+  }\r
+}\r
+\r
+static void M96Power(void)\r
+{\r
+  reg = ppulatch = 0;\r
+  Sync();\r
+  SetReadHandler(0x8000,0xffff,CartBR);\r
+  SetWriteHandler(0x8000,0xffff,M96Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper96_Init(CartInfo *info)\r
+{\r
+  info->Power=M96Power;\r
+  PPU_hook=M96Hook;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r
+\r