--- /dev/null
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ * Copyright (C) 2006 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
+ * 700in1 and 400in1 carts\r
+ */\r
+ \r
+\r
+#include "mapinc.h"\r
+\r
+static uint16 cmd, bank;\r
+\r
+static SFORMAT StateRegs[]=\r
+{\r
+ {&cmd, 2, "CMD"},\r
+ {&bank, 2, "BANK"},\r
+ {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+ setmirror((cmd&1)^1);\r
+ setchr8(0);\r
+ if(cmd&2)\r
+ {\r
+ if(cmd&0x100)\r
+ {\r
+ setprg16(0x8000,((cmd&0xe0)>>2)|bank);\r
+ setprg16(0xC000,((cmd&0xe0)>>2)|7); \r
+ }\r
+ else\r
+ {\r
+ setprg16(0x8000,((cmd&0xe0)>>2)|(bank&6));\r
+ setprg16(0xC000,((cmd&0xe0)>>2)|((bank&6)|1)); \r
+ }\r
+ }\r
+ else\r
+ {\r
+ setprg16(0x8000,((cmd&0xe0)>>2)|bank);\r
+ setprg16(0xC000,((cmd&0xe0)>>2)|bank);\r
+ } \r
+}\r
+\r
+static DECLFW(UNLN625092WriteCommand)\r
+{\r
+ cmd=A; \r
+ Sync();\r
+}\r
+\r
+static DECLFW(UNLN625092WriteBank)\r
+{ \r
+ bank=A&7;\r
+ Sync();\r
+}\r
+\r
+static void UNLN625092Power(void)\r
+{\r
+ cmd=0;\r
+ bank=0;\r
+ Sync();\r
+ SetReadHandler(0x8000,0xFFFF,CartBR);\r
+ SetWriteHandler(0x8000,0xBFFF,UNLN625092WriteCommand);\r
+ SetWriteHandler(0xC000,0xFFFF,UNLN625092WriteBank);\r
+}\r
+\r
+static void UNLN625092Reset(void)\r
+{\r
+ cmd=0;\r
+ bank=0;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+ Sync();\r
+}\r
+\r
+void UNLN625092_Init(CartInfo *info)\r
+{\r
+ info->Reset=UNLN625092Reset;\r
+ info->Power=UNLN625092Power;\r
+ GameStateRestore=StateRestore;\r
+ AddExState(&StateRegs, ~0, 0, 0);\r
+}\r