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