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
24 static uint8 mirror, cmd;
25 static uint8 *WRAM=NULL;
27 static SFORMAT StateRegs[]=
35 static void Sync(void)
38 setprg8(0x8000,reg[0]);
39 setprg8(0xA000,reg[1]);
40 setchr2(0x0000,reg[2]>>1);
41 setchr2(0x0800,reg[3]>>1);
42 setchr1(0x1000,reg[4]);
43 setchr1(0x1400,reg[5]);
44 setchr1(0x1800,reg[6]);
45 setchr1(0x1C00,reg[7]);
48 static DECLFW(M112Write)
52 case 0xe000: mirror=V&1; Sync(); ;break;
53 case 0x8000: cmd=V&7; break;
54 case 0xa000: reg[cmd]=V; Sync(); break;
56 FCEU_printf("%04x:%04x %d\n",A,V,scanline);
59 static void M112Close(void)
66 static void M112Power(void)
69 setprg8r(0x10,0x6000,0);
70 SetReadHandler(0x8000,0xFFFF,CartBR);
71 SetWriteHandler(0x8000,0xFFFF,M112Write);
72 SetReadHandler(0x6000,0x7FFF,CartBR);
73 SetWriteHandler(0x6000,0x7FFF,CartBW);
76 static void StateRestore(int version)
81 void Mapper112_Init(CartInfo *info)
83 info->Power=M112Power;
84 info->Close=M112Close;
85 GameStateRestore=StateRestore;
86 WRAM=(uint8*)FCEU_gmalloc(8192);
87 SetupCartPRGMapping(0x10,WRAM,8192,1);
88 AddExState(WRAM, 8192, 0, "WRAM");
89 AddExState(&StateRegs, ~0, 0, 0);