merge mappers from FCEU-mm
[fceu.git] / boards / KS7013.c
diff --git a/boards/KS7013.c b/boards/KS7013.c
new file mode 100644 (file)
index 0000000..8476003
--- /dev/null
@@ -0,0 +1,84 @@
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2011 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
+ * Just another pirate cart with pirate mapper, instead of original MMC1\r
+ * Kaiser Highway Star\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg, mirr;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REGS"},\r
+  {&mirr, 1, "MIRR"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg16(0x8000,reg);\r
+  setprg16(0xc000,~0);\r
+  setmirror(mirr);\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(UNLKS7013BLoWrite)\r
+{\r
+  reg = V;\r
+  Sync();\r
+}\r
+\r
+static DECLFW(UNLKS7013BHiWrite)\r
+{\r
+  mirr = (V & 1) ^ 1;\r
+  Sync();\r
+}\r
+\r
+static void UNLKS7013BPower(void)\r
+{\r
+  reg = 0;\r
+  mirr = 0;\r
+  Sync();\r
+  SetWriteHandler(0x6000,0x7FFF,UNLKS7013BLoWrite);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,UNLKS7013BHiWrite);\r
+}\r
+\r
+static void UNLKS7013BReset(void)\r
+{\r
+  reg = 0;\r
+  Sync();\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNLKS7013B_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLKS7013BPower;\r
+  info->Reset=UNLKS7013BReset;\r
+\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r