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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 static uint8 mirror, cmd, bank;
28 static uint8 *WRAM=NULL;
30 static SFORMAT StateRegs[]=
39 static void Sync(void)
42 setprg8(0x8000,reg[0]);
43 setprg8(0xA000,reg[1]);
44 setchr2(0x0000,(reg[2]>>1));
45 setchr2(0x0800,(reg[3]>>1));
46 setchr1(0x1000,((bank&0x10)<<4)|reg[4]);
47 setchr1(0x1400,((bank&0x20)<<3)|reg[5]);
48 setchr1(0x1800,((bank&0x40)<<2)|reg[6]);
49 setchr1(0x1C00,((bank&0x80)<<1)|reg[7]);
52 static DECLFW(M112Write)
56 case 0xe000: mirror=V&1; Sync(); ;break;
57 case 0x8000: cmd=V&7; break;
58 case 0xa000: reg[cmd]=V; Sync(); break;
59 case 0xc000: bank=V; Sync(); break;
63 static void M112Close(void)
70 static void M112Power(void)
74 setprg8r(0x10,0x6000,0);
75 SetReadHandler(0x8000,0xFFFF,CartBR);
76 SetWriteHandler(0x8000,0xFFFF,M112Write);
77 SetWriteHandler(0x4020,0x5FFF,M112Write);
78 SetReadHandler(0x6000,0x7FFF,CartBR);
79 SetWriteHandler(0x6000,0x7FFF,CartBW);
82 static void StateRestore(int version)
87 void Mapper112_Init(CartInfo *info)
89 info->Power=M112Power;
90 info->Close=M112Close;
91 GameStateRestore=StateRestore;
92 WRAM=(uint8*)FCEU_gmalloc(8192);
93 SetupCartPRGMapping(0x10,WRAM,8192,1);
94 AddExState(WRAM, 8192, 0, "WRAM");
95 AddExState(&StateRegs, ~0, 0, 0);