merge mappers from FCEU-mm
[fceu.git] / boards / 208.c
CommitLineData
386f5371 1/* FCE Ultra - NES/Famicom Emulator\r
2 *\r
3 * Copyright notice for this file:\r
4 * Copyright (C) 2005 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
386f5371 19 */\r
20\r
21#include "mapinc.h"\r
22#include "mmc3.h"\r
23\r
24static uint8 lut[256]={\r
43725da7 25 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,\r
26 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,\r
27 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,\r
28 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,\r
29 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
30 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
31 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
32 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
33 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08,\r
34 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00,\r
35 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08,\r
36 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00,\r
37 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
38 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
39 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
40 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
386f5371 41};\r
42\r
43static void M208PW(uint32 A, uint8 V)\r
44{\r
45 setprg32(0x8000,EXPREGS[5]);\r
46}\r
47\r
48static DECLFW(M208Write)\r
49{\r
50 EXPREGS[5]=(V&0x1)|((V>>3)&0x2);\r
51 FixMMC3PRG(MMC3_cmd);\r
52}\r
53\r
54static DECLFW(M208ProtWrite)\r
55{\r
56 if(A<=0x57FF)\r
57 EXPREGS[4]=V;\r
58 else\r
59 EXPREGS[(A&0x03)]=V^lut[EXPREGS[4]];\r
60}\r
61\r
62static DECLFR(M208ProtRead)\r
63{\r
64 return(EXPREGS[(A&0x3)]);\r
65}\r
66\r
67static void M208Power(void)\r
68{\r
69 EXPREGS[5]=3;\r
70 GenMMC3Power();\r
71 SetWriteHandler(0x4800,0x4FFF,M208Write);\r
72 SetWriteHandler(0x5000,0x5fff,M208ProtWrite);\r
73 SetReadHandler(0x5800,0x5FFF,M208ProtRead);\r
74 SetReadHandler(0x8000,0xffff,CartBR);\r
75}\r
76\r
77void Mapper208_Init(CartInfo *info)\r
78{\r
79 GenMMC3_Init(info, 128, 256, 0, 0);\r
80 pwrap=M208PW;\r
81 info->Power=M208Power;\r
82 AddExState(EXPREGS, 6, 0, "EXPR");\r
83}\r