1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2007 CaH4e3
\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
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
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
23 static uint8 reg[3];
\r
24 static uint8 *WRAM=NULL;
\r
25 static uint32 WRAMSIZE;
\r
27 static SFORMAT StateRegs[]=
\r
33 static void Sync(void)
\r
36 setprg8r(0x10,0x6000,0);
\r
38 setprg32(0x8000,(reg[1]+reg[2]));
\r
41 static DECLFW(M178Write0)
\r
47 static DECLFW(M178Write1)
\r
53 static DECLFW(M178Write2)
\r
59 static void M178Power(void)
\r
61 reg[0]=1; reg[1]=0; reg[2]=0;
\r
63 SetReadHandler(0x6000,0x7FFF,CartBR);
\r
64 SetWriteHandler(0x6000,0x7FFF,CartBW);
\r
65 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
66 SetWriteHandler(0x4800,0x4800,M178Write0);
\r
67 SetWriteHandler(0x4801,0x4801,M178Write1);
\r
68 SetWriteHandler(0x4802,0x4802,M178Write2);
\r
71 static void M178Close(void)
\r
79 static void StateRestore(int version)
\r
84 void Mapper178_Init(CartInfo *info)
\r
86 info->Power=M178Power;
\r
87 info->Close=M178Close;
\r
88 GameStateRestore=StateRestore;
\r
91 WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
\r
92 SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
\r
95 info->SaveGame[0]=WRAM;
\r
96 info->SaveGameLen[0]=WRAMSIZE;
\r
98 AddExState(WRAM, WRAMSIZE, 0, "WRAM");
\r
100 AddExState(&StateRegs, ~0, 0, 0);
\r