merge mapper code from FCEUX
[fceu.git] / boards / 108.c
similarity index 57%
rename from boards/bmcgk192.c
rename to boards/108.c
index b66d831..fc3aebd 100644 (file)
@@ -1,67 +1,62 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2005 CaH4e3
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "mapinc.h"
-
-static uint16 addrlatche;
-
-static void Sync(void)
-{
-  if(addrlatche&0x40)
-  {
-    setprg16(0x8000,addrlatche&7);
-    setprg16(0xC000,addrlatche&7);
-  }
-  else
-    setprg32(0x8000,(addrlatche>>1)&3);
-  setchr8((addrlatche>>3)&7);
-  setmirror(((addrlatche&0x80)>>7)^1);
-}
-
-static DECLFW(BMCGK192Write)
-{
-  addrlatche=A;
-  Sync();
-}
-
-static void BMCGK192Reset(void)
-{
-  setprg32(0x8000,0);
-}
-
-static void BMCGK192Power(void)
-{
-  setprg32(0x8000,0);
-  SetReadHandler(0x8000,0xFFFF,CartBR);
-  SetWriteHandler(0x8000,0xffff,BMCGK192Write);
-}
-
-static void StateRestore(int version)
-{
-  Sync();
-}
-
-void Mapper58_Init(CartInfo *info)
-{
-  info->Power=BMCGK192Power;
-  info->Reset=BMCGK192Reset;
-  GameStateRestore=StateRestore;
-  AddExState(&addrlatche, 2, 0, "ALATC");
-}
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 reg;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&reg, 1, "REG"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  setprg8(0x6000,reg);\r
+  setprg32(0x8000,~0);\r
+  setchr8(0);\r
+}\r
+\r
+static DECLFW(M108Write)\r
+{\r
+   reg=V;\r
+   Sync();\r
+}\r
+\r
+static void M108Power(void)\r
+{\r
+  Sync();\r
+  SetReadHandler(0x6000,0x7FFF,CartBR);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8FFF,0x8FFF,M108Write);\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper108_Init(CartInfo *info)\r
+{\r
+  info->Power=M108Power;\r
+  GameStateRestore=StateRestore;\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r