1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2006 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
24 static uint16 latchea;
\r
25 static uint8 latched;
\r
26 static uint8 *WRAM=NULL;
\r
27 static uint32 WRAMSIZE;
\r
28 static SFORMAT StateRegs[]=
\r
30 {&latchea, 2, "AREG"},
\r
31 {&latched, 1, "DREG"},
\r
35 static void Sync(void)
\r
38 setmirror(((latched>>6)&1)^1);
\r
43 setprg8(0x8000+(i<<13),(((latched&0x7F)<<1)+i)^(latched>>7));
\r
47 setprg8(0x8000+(i<<13),((latched&0x7F)<<1)+(latched>>7));
\r
55 if(i>=2 && !(latchea&0x2))
\r
57 setprg8(0x8000+(i<<13),(i&1)+((b<<1)^(latched>>7)));
\r
63 static DECLFW(M15Write)
\r
70 static void StateRestore(int version)
\r
75 static void M15Power(void)
\r
80 setprg8r(0x10,0x6000,0);
\r
81 SetReadHandler(0x6000,0x7FFF,CartBR);
\r
82 SetWriteHandler(0x6000,0x7FFF,CartBW);
\r
83 SetWriteHandler(0x8000,0xFFFF,M15Write);
\r
84 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
88 static void M15Reset(void)
\r
95 static void M15Close(void)
\r
102 void Mapper15_Init(CartInfo *info)
\r
104 info->Power=M15Power;
\r
105 info->Reset=M15Reset;
\r
106 info->Close=M15Close;
\r
107 GameStateRestore=StateRestore;
\r
109 WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
\r
110 SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
\r
113 info->SaveGame[0]=WRAM;
\r
114 info->SaveGameLen[0]=WRAMSIZE;
\r
116 AddExState(WRAM, WRAMSIZE, 0, "WRAM");
\r
117 AddExState(&StateRegs, ~0, 0, 0);
\r