1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2007 CaH4e3
\r
5 * Copyright (C) 2012 FCEUX team
\r
7 * This program is free software; you can redistribute it and/or modify
\r
8 * it under the terms of the GNU General Public License as published by
\r
9 * the Free Software Foundation; either version 2 of the License, or
\r
10 * (at your option) any later version.
\r
12 * This program is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 * GNU General Public License for more details.
\r
17 * You should have received a copy of the GNU General Public License
\r
18 * along with this program; if not, write to the Free Software
\r
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
24 extern uint32 ROM_size;
\r
26 static uint8 prg[4], chr, sbw, we_sram;
\r
27 static uint8 *WRAM=NULL;
\r
28 static uint32 WRAMSIZE;
\r
30 static SFORMAT StateRegs[]=
\r
38 static void Sync(void)
\r
40 setprg8r(0x10,0x6000,0);
\r
41 setprg8(0x8000,prg[0]);
\r
42 setprg8(0xA000,prg[1]);
\r
43 setprg8(0xC000,prg[2]);
\r
44 setprg8(0xE000,prg[3]);
\r
49 static DECLFW(M176Write_5001)
\r
51 printf("%04X = $%02X\n",A,V);
\r
62 static DECLFW(M176Write_5010)
\r
64 printf("%04X = $%02X\n",A,V);
\r
65 if(V == 0x24) sbw = 1;
\r
69 static DECLFW(M176Write_5011)
\r
71 printf("%04X = $%02X\n",A,V);
\r
83 static DECLFW(M176Write_5FF1)
\r
85 printf("%04X = $%02X\n",A,V);
\r
94 static DECLFW(M176Write_5FF2)
\r
96 printf("%04X = $%02X\n",A,V);
\r
101 static DECLFW(M176Write_A001)
\r
103 we_sram = V & 0x03;
\r
106 static DECLFW(M176Write_WriteSRAM)
\r
112 static void M176Power(void)
\r
114 SetReadHandler(0x6000,0x7fff,CartBR);
\r
115 SetWriteHandler(0x6000,0x7fff,M176Write_WriteSRAM);
\r
116 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
117 SetWriteHandler(0xA001,0xA001,M176Write_A001);
\r
118 SetWriteHandler(0x5001,0x5001,M176Write_5001);
\r
119 SetWriteHandler(0x5010,0x5010,M176Write_5010);
\r
120 SetWriteHandler(0x5011,0x5011,M176Write_5011);
\r
121 SetWriteHandler(0x5ff1,0x5ff1,M176Write_5FF1);
\r
122 SetWriteHandler(0x5ff2,0x5ff2,M176Write_5FF2);
\r
128 prg[2] = (ROM_size-2)&63;
\r
129 prg[3] = (ROM_size-1)&63;
\r
134 static void M176Close(void)
\r
141 static void StateRestore(int version)
\r
146 void Mapper176_Init(CartInfo *info)
\r
148 info->Power=M176Power;
\r
149 info->Close=M176Close;
\r
151 GameStateRestore=StateRestore;
\r
154 WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
\r
155 SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
\r
156 AddExState(WRAM, WRAMSIZE, 0, "WRAM");
\r
157 AddExState(&StateRegs, ~0, 0, 0);
\r