1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2005 CaH4e3
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 static uint8 mirror, cmd, bank;
26 static uint8 *WRAM=NULL;
28 static SFORMAT StateRegs[]=
37 static void Sync(void)
40 setprg8(0x8000,reg[0]);
41 setprg8(0xA000,reg[1]);
42 setchr2(0x0000,(reg[2]>>1));
43 setchr2(0x0800,(reg[3]>>1));
44 setchr1(0x1000,((bank&0x10)<<4)|reg[4]);
45 setchr1(0x1400,((bank&0x20)<<3)|reg[5]);
46 setchr1(0x1800,((bank&0x40)<<2)|reg[6]);
47 setchr1(0x1C00,((bank&0x80)<<1)|reg[7]);
50 static DECLFW(M112Write)
54 case 0xe000: mirror=V&1; Sync(); ;break;
55 case 0x8000: cmd=V&7; break;
56 case 0xa000: reg[cmd]=V; Sync(); break;
57 case 0xc000: bank=V; Sync(); break;
61 static void M112Close(void)
68 static void M112Power(void)
72 setprg8r(0x10,0x6000,0);
73 SetReadHandler(0x8000,0xFFFF,CartBR);
74 SetWriteHandler(0x8000,0xFFFF,M112Write);
75 SetWriteHandler(0x4020,0x5FFF,M112Write);
76 SetReadHandler(0x6000,0x7FFF,CartBR);
77 SetWriteHandler(0x6000,0x7FFF,CartBW);
80 static void StateRestore(int version)
85 void Mapper112_Init(CartInfo *info)
87 info->Power=M112Power;
88 info->Close=M112Close;
89 GameStateRestore=StateRestore;
90 WRAM=(uint8*)FCEU_gmalloc(8192);
91 SetupCartPRGMapping(0x10,WRAM,8192,1);
92 AddExState(WRAM, 8192, 0, "WRAM");
93 AddExState(&StateRegs, ~0, 0, 0);