merge mappers from FCEU-mm
[fceu.git] / boards / 168.c
diff --git a/boards/168.c b/boards/168.c
new file mode 100644 (file)
index 0000000..170521a
--- /dev/null
@@ -0,0 +1,89 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2009 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
+ * RacerMate Chalenge II\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg;\r
+static uint8 *CHRRAM=NULL;\r
+static uint32 CHRRAMSIZE;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setchr4r(0x10,0x0000,0);\r
+  setchr4r(0x10,0x1000,reg&0x0f);\r
+  setprg16(0x8000,reg>>6);\r
+  setprg16(0xc000,~0);\r
+}\r
+\r
+static DECLFW(M168Write)\r
+{\r
+  reg=V;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(M168Dummy)\r
+{\r
+}\r
+\r
+static void M168Power(void)\r
+{\r
+  reg=0;\r
+  Sync();\r
+  SetWriteHandler(0x4020,0x7fff,M168Dummy);\r
+  SetWriteHandler(0xB000,0xB000,M168Write);\r
+  SetWriteHandler(0xF000,0xF000,M168Dummy);\r
+  SetWriteHandler(0xF080,0xF080,M168Dummy);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+}\r
+\r
+static void MNNNClose(void)\r
+{\r
+  if(CHRRAM)\r
+    FCEU_gfree(CHRRAM);\r
+  CHRRAM=NULL;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper168_Init(CartInfo *info)\r
+{\r
+  info->Power=M168Power;\r
+  info->Close=MNNNClose;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+\r
+  CHRRAMSIZE=8192*8;\r
+  CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSIZE);\r
+  SetupCartCHRMapping(0x10,CHRRAM,CHRRAMSIZE,1);\r
+  AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM");\r
+\r
+}\r