merge mappers from FCEU-mm
[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
43725da7 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
19 *\r
386f5371 20 * 700in1 and 400in1 carts\r
43725da7 21 *\r
386f5371 22 */\r
23 \r
24\r
25#include "mapinc.h"\r
26\r
27static uint16 cmd, bank;\r
28\r
29static SFORMAT StateRegs[]=\r
30{\r
31 {&cmd, 2, "CMD"},\r
32 {&bank, 2, "BANK"},\r
33 {0}\r
34};\r
35\r
36static void Sync(void)\r
37{\r
38 setmirror((cmd&1)^1);\r
39 setchr8(0);\r
40 if(cmd&2)\r
41 {\r
42 if(cmd&0x100)\r
43 {\r
43725da7 44 setprg16(0x8000,((cmd&0xfc)>>2)|bank);\r
45 setprg16(0xC000,((cmd&0xfc)>>2)|7); \r
386f5371 46 }\r
47 else\r
48 {\r
43725da7 49 setprg16(0x8000,((cmd&0xfc)>>2)|(bank&6));\r
50 setprg16(0xC000,((cmd&0xfc)>>2)|((bank&6)|1)); \r
386f5371 51 }\r
52 }\r
53 else\r
54 {\r
43725da7 55 setprg16(0x8000,((cmd&0xfc)>>2)|bank);\r
56 setprg16(0xC000,((cmd&0xfc)>>2)|bank);\r
386f5371 57 } \r
58}\r
59\r
43725da7 60static uint16 ass = 0;\r
61\r
386f5371 62static DECLFW(UNLN625092WriteCommand)\r
63{\r
64 cmd=A; \r
43725da7 65 if(A==0x80F8)\r
66 {\r
67 setprg16(0x8000,ass);\r
68 setprg16(0xC000,ass);\r
69 }\r
70 else\r
71 {\r
72 Sync();\r
73 }\r
386f5371 74}\r
75\r
76static DECLFW(UNLN625092WriteBank)\r
77{ \r
78 bank=A&7;\r
79 Sync();\r
80}\r
81\r
82static void UNLN625092Power(void)\r
83{\r
84 cmd=0;\r
85 bank=0;\r
86 Sync();\r
87 SetReadHandler(0x8000,0xFFFF,CartBR);\r
88 SetWriteHandler(0x8000,0xBFFF,UNLN625092WriteCommand);\r
89 SetWriteHandler(0xC000,0xFFFF,UNLN625092WriteBank);\r
90}\r
91\r
92static void UNLN625092Reset(void)\r
93{\r
94 cmd=0;\r
95 bank=0;\r
43725da7 96 ass++;\r
97 FCEU_printf("%04x\n",ass);\r
386f5371 98}\r
99\r
100static void StateRestore(int version)\r
101{\r
102 Sync();\r
103}\r
104\r
105void UNLN625092_Init(CartInfo *info)\r
106{\r
107 info->Reset=UNLN625092Reset;\r
108 info->Power=UNLN625092Power;\r
109 GameStateRestore=StateRestore;\r
110 AddExState(&StateRegs, ~0, 0, 0);\r
111}\r