1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2011 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
26 static uint8 reg[8], cmd;
\r
27 static uint8 *WRAM=NULL;
\r
28 static uint32 WRAMSIZE;
\r
30 static void(*WSync)(void);
\r
32 static SFORMAT StateRegs[]=
\r
39 static void SyncKS7037(void)
\r
41 setprg4r(0x10,0x6000,0);
\r
43 setprg8(0x8000,reg[6]);
\r
45 setprg4r(0x10,0xB000,1);
\r
46 setprg8(0xC000,reg[7]);
\r
49 setmirrorw(reg[2]&1,reg[4]&1,reg[3]&1,reg[5]&1);
\r
52 static void SyncLH10(void)
\r
55 setprg8(0x8000,reg[6]);
\r
56 setprg8(0xA000,reg[7]);
\r
57 setprg8r(0x10,0xC000,0);
\r
63 static DECLFW(UNLKS7037Write)
\r
67 case 0x8000: cmd = V & 7; break;
\r
68 case 0x8001: reg[cmd] = V; WSync(); break;
\r
72 static void UNLKS7037Power(void)
\r
74 reg[0]=reg[1]=reg[2]=reg[3]=reg[4]=reg[5]=reg[6]=reg[7]=0;
\r
76 SetReadHandler(0x6000,0xFFFF,CartBR);
\r
77 SetWriteHandler(0x6000,0x7FFF,CartBW);
\r
78 SetWriteHandler(0x8000,0x9FFF,UNLKS7037Write);
\r
79 SetWriteHandler(0xA000,0xBFFF,CartBW);
\r
80 SetWriteHandler(0xC000,0xFFFF,UNLKS7037Write);
\r
83 static void LH10Power(void)
\r
85 reg[0]=reg[1]=reg[2]=reg[3]=reg[4]=reg[5]=reg[6]=reg[7]=0;
\r
87 SetReadHandler(0x6000,0xFFFF,CartBR);
\r
88 SetWriteHandler(0x8000,0xBFFF,UNLKS7037Write);
\r
89 SetWriteHandler(0xC000,0xDFFF,CartBW);
\r
90 SetWriteHandler(0xE000,0xFFFF,UNLKS7037Write);
\r
93 static void Close(void)
\r
100 static void StateRestore(int version)
\r
105 void UNLKS7037_Init(CartInfo *info)
\r
107 info->Power=UNLKS7037Power;
\r
110 WSync = SyncKS7037;
\r
113 WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
\r
114 SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
\r
115 AddExState(WRAM, WRAMSIZE, 0, "WRAM");
\r
117 GameStateRestore=StateRestore;
\r
118 AddExState(&StateRegs, ~0, 0, 0);
\r
121 void LH10_Init(CartInfo *info)
\r
123 info->Power=LH10Power;
\r
129 WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
\r
130 SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
\r
131 AddExState(WRAM, WRAMSIZE, 0, "WRAM");
\r
133 GameStateRestore=StateRestore;
\r
134 AddExState(&StateRegs, ~0, 0, 0);
\r