merge mappers from FCEU-mm
[fceu.git] / boards / 99.c
CommitLineData
43725da7 1/* FCE Ultra - NES/Famicom Emulator\r
2 *\r
3 * Copyright notice for this file:\r
4 * Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
19 *\r
20 * VS Super Mario Bros has a problem, FCEUX doesn't!\r
21 */\r
22\r
23#include "mapinc.h"\r
24\r
25static uint8 latch;\r
26static writefunc old4016;\r
27\r
28static SFORMAT StateRegs[]=\r
29{\r
30 {&latch, 1, "LATC"},\r
31 {0}\r
32};\r
33\r
34static void Sync(void)\r
35{\r
36 setchr8((latch >> 2) & 1);\r
37 setprg32(0x8000,0);\r
38 setprg8(0x8000,latch & 4); /* Special for VS Gumshoe */\r
39}\r
40\r
41static DECLFW(M99Write)\r
42{\r
43 latch = V;\r
44 Sync();\r
45 old4016(A,V);\r
46}\r
47\r
48static void M99Power(void)\r
49{\r
50 latch = 0;\r
51 Sync();\r
52 old4016=GetWriteHandler(0x4016);\r
53 SetWriteHandler(0x4016,0x4016,M99Write);\r
54 SetReadHandler(0x8000,0xFFFF,CartBR);\r
55}\r
56\r
57static void StateRestore(int version)\r
58{\r
59 Sync();\r
60}\r
61\r
62void Mapper99_Init(CartInfo *info)\r
63{\r
64 info->Power=M99Power;\r
65 GameStateRestore=StateRestore;\r
66 AddExState(&StateRegs, ~0, 0, 0);\r
67}\r