merge mapper code from FCEUX
[fceu.git] / boards / n625092.c
CommitLineData
386f5371 1/* FCE Ultra - NES/Famicom Emulator\r
2 *\r
3 * Copyright notice for this file:\r
4 * Copyright (C) 2006 CaH4e3\r
5 *\r
6 * This program is free software; you can redistribute it and/or modify\r
7 * it under the terms of the GNU General Public License as published by\r
8 * the Free Software Foundation; either version 2 of the License, or\r
9 * (at your option) any later version.\r
10 *\r
11 * This program is distributed in the hope that it will be useful,\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
14 * GNU General Public License for more details.\r
15 *\r
16 * You should have received a copy of the GNU General Public License\r
17 * along with this program; if not, write to the Free Software\r
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
19 * 700in1 and 400in1 carts\r
20 */\r
21 \r
22\r
23#include "mapinc.h"\r
24\r
25static uint16 cmd, bank;\r
26\r
27static SFORMAT StateRegs[]=\r
28{\r
29 {&cmd, 2, "CMD"},\r
30 {&bank, 2, "BANK"},\r
31 {0}\r
32};\r
33\r
34static void Sync(void)\r
35{\r
36 setmirror((cmd&1)^1);\r
37 setchr8(0);\r
38 if(cmd&2)\r
39 {\r
40 if(cmd&0x100)\r
41 {\r
42 setprg16(0x8000,((cmd&0xe0)>>2)|bank);\r
43 setprg16(0xC000,((cmd&0xe0)>>2)|7); \r
44 }\r
45 else\r
46 {\r
47 setprg16(0x8000,((cmd&0xe0)>>2)|(bank&6));\r
48 setprg16(0xC000,((cmd&0xe0)>>2)|((bank&6)|1)); \r
49 }\r
50 }\r
51 else\r
52 {\r
53 setprg16(0x8000,((cmd&0xe0)>>2)|bank);\r
54 setprg16(0xC000,((cmd&0xe0)>>2)|bank);\r
55 } \r
56}\r
57\r
58static DECLFW(UNLN625092WriteCommand)\r
59{\r
60 cmd=A; \r
61 Sync();\r
62}\r
63\r
64static DECLFW(UNLN625092WriteBank)\r
65{ \r
66 bank=A&7;\r
67 Sync();\r
68}\r
69\r
70static void UNLN625092Power(void)\r
71{\r
72 cmd=0;\r
73 bank=0;\r
74 Sync();\r
75 SetReadHandler(0x8000,0xFFFF,CartBR);\r
76 SetWriteHandler(0x8000,0xBFFF,UNLN625092WriteCommand);\r
77 SetWriteHandler(0xC000,0xFFFF,UNLN625092WriteBank);\r
78}\r
79\r
80static void UNLN625092Reset(void)\r
81{\r
82 cmd=0;\r
83 bank=0;\r
84}\r
85\r
86static void StateRestore(int version)\r
87{\r
88 Sync();\r
89}\r
90\r
91void UNLN625092_Init(CartInfo *info)\r
92{\r
93 info->Reset=UNLN625092Reset;\r
94 info->Power=UNLN625092Power;\r
95 GameStateRestore=StateRestore;\r
96 AddExState(&StateRegs, ~0, 0, 0);\r
97}\r