merge mappers from FCEU-mm
[fceu.git] / boards / 99.c
diff --git a/boards/99.c b/boards/99.c
new file mode 100644 (file)
index 0000000..826af3e
--- /dev/null
@@ -0,0 +1,67 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\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
+ * VS Super Mario Bros has a problem, FCEUX doesn't!\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 latch;\r
+static writefunc old4016;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&latch, 1, "LATC"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr8((latch >> 2) & 1);\r
+  setprg32(0x8000,0);\r
+  setprg8(0x8000,latch & 4);        /* Special for VS Gumshoe */\r
+}\r
+\r
+static DECLFW(M99Write)\r
+{\r
+  latch = V;\r
+  Sync();\r
+  old4016(A,V);\r
+}\r
+\r
+static void M99Power(void)\r
+{\r
+  latch = 0;\r
+  Sync();\r
+  old4016=GetWriteHandler(0x4016);\r
+  SetWriteHandler(0x4016,0x4016,M99Write);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper99_Init(CartInfo *info)\r
+{\r
+  info->Power=M99Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r