gp2x_test added, cli removed
[fceu.git] / boards / 186.c
CommitLineData
e2d0dd92 1/* FCE Ultra - NES/Famicom Emulator
2 *
3 * Copyright notice for this file:
4 * Copyright (C) 2005 CaH4e3
5 *
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.
10 *
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.
15 *
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
19 *
20 * Family Study Box by Fukutake Shoten
21 */
22
23#include "mapinc.h"
24
25static uint8 SWRAM[2816];
26static uint8 *WRAM=NULL;
27static uint8 regs[4];
28
29static SFORMAT StateRegs[]=
30{
31 {regs, 4, "DREG"},
32 {SWRAM, 2816, "SWRAM"},
33 {0}
34};
35
36static void Sync(void)
37{
38 setprg8r(0x10,0x6000,regs[0]>>6);
39 setprg16(0x8000,regs[1]);
40 setprg16(0xc000,0);
41}
42
43static DECLFW(M186Write)
44{
45 if(A&0x4203) regs[A&3]=V;
46 Sync();
47}
48
49static DECLFR(M186Read)
50{
51 switch(A)
52 {
53 case 0x4200: return 0x00; break;
54 case 0x4201: return 0x00; break;
55 case 0x4202: return 0x40; break;
56 case 0x4203: return 0x00; break;
57 }
58 return 0xFF;
59}
60
61static DECLFR(ASWRAM)
62{
63 return(SWRAM[A-0x4400]);
64}
65static DECLFW(BSWRAM)
66{
67 SWRAM[A-0x4400]=V;
68}
69
70static void M186Power(void)
71{
72 setchr8(0);
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];
80 Sync();
81}
82
83static void M186Close(void)
84{
85 if(WRAM)
86 FCEU_gfree(WRAM);
87 WRAM=NULL;
88}
89
90static void M186Restore(int version)
91{
92 Sync();
93}
94
95void Mapper186_Init(CartInfo *info)
96{
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);
104}