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
20 * Family Study Box by Fukutake Shoten
25 static uint8 SWRAM[2816];
26 static uint8 *WRAM=NULL;
29 static SFORMAT StateRegs[]=
32 {SWRAM, 2816, "SWRAM"},
36 static void Sync(void)
38 setprg8r(0x10,0x6000,regs[0]>>6);
39 setprg16(0x8000,regs[1]);
43 static DECLFW(M186Write)
45 if(A&0x4203) regs[A&3]=V;
49 static DECLFR(M186Read)
53 case 0x4200: return 0x00; break;
54 case 0x4201: return 0x00; break;
55 case 0x4202: return 0x40; break;
56 case 0x4203: return 0x00; break;
63 return(SWRAM[A-0x4400]);
70 static void M186Power(void)
73 SetReadHandler(0x6000,0xFFFF,CartBR);
74 SetWriteHandler(0x6000,0xFFFF,CartBW);
75 SetReadHandler(0x4200,0x43FF,M186Read);
76 SetWriteHandler(0x4200,0x43FF,M186Write);
77 SetReadHandler(0x4400,0x4EFF,ASWRAM);
78 SetWriteHandler(0x4400,0x4EFF,BSWRAM);
79 regs[0]=regs[1]=regs[2]=regs[3];
83 static void M186Close(void)
90 static void M186Restore(int version)
95 void Mapper186_Init(CartInfo *info)
97 info->Power=M186Power;
98 info->Close=M186Close;
99 GameStateRestore=M186Restore;
100 WRAM=(uint8*)FCEU_gmalloc(32384);
101 SetupCartPRGMapping(0x10,WRAM,32384,1);
102 AddExState(WRAM, 32384, 0, "WRAM");
103 AddExState(StateRegs, ~0, 0, 0);