merge mappers from FCEU-mm
[fceu.git] / boards / KS7031.c
diff --git a/boards/KS7031.c b/boards/KS7031.c
new file mode 100644 (file)
index 0000000..e2b8769
--- /dev/null
@@ -0,0 +1,85 @@
+/* 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
+ * FDS Conversion\r
+ *\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg[4];\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {reg, 4, "REGS"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg2(0x6000,reg[0]);\r
+  setprg2(0x6800,reg[1]);\r
+  setprg2(0x7000,reg[2]);\r
+  setprg2(0x7800,reg[3]);\r
+\r
+  setprg2(0x8000,15);\r
+  setprg2(0x8800,14);\r
+  setprg2(0x9000,13);\r
+  setprg2(0x9800,12);\r
+  setprg2(0xa000,11);\r
+  setprg2(0xa800,10);\r
+  setprg2(0xb000,9);\r
+  setprg2(0xb800,8);\r
+\r
+  setprg2(0xc000,7);\r
+  setprg2(0xc800,6);\r
+  setprg2(0xd000,5);\r
+  setprg2(0xd800,4);\r
+  setprg2(0xe000,3);\r
+  setprg2(0xe800,2);\r
+  setprg2(0xf000,1);\r
+  setprg2(0xf800,0);\r
+\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(UNLKS7031Write)\r
+{\r
+  reg[(A >> 11) & 3] = V;\r
+  Sync();\r
+}\r
+\r
+static void UNLKS7031Power(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x6000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xffff,UNLKS7031Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void UNLKS7031_Init(CartInfo *info)\r
+{\r
+  info->Power=UNLKS7031Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r