1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Xodnizel 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 static uint8 cmd, laststrobe, trigger;
24 static uint8 DRegs[8];
25 static SFORMAT StateRegs[]=
28 {&laststrobe, 1, "STB"},
34 static void Sync(void)
36 setprg32(0x8000,(DRegs[0]<<4)|(DRegs[1]&0xF));
39 static void StateRestore(int version)
44 static DECLFR(ReadLow)
48 case 0x5100: return DRegs[2]; break;
49 case 0x5500: if(trigger)
61 case 0x5100: DRegs[0]=V; Sync(); break;
62 case 0x5000: DRegs[1]=V; Sync(); break;
63 case 0x5300: DRegs[2]=V; break;
76 }else if(A==0x5100&&V==6) //damn thoose protected games
81 case 0x5200: DRegs[0]=V; Sync(); break;
82 case 0x5000: DRegs[1]=V; Sync(); if(!(DRegs[1]&0x80)&&(scanline<128)) setchr8(0); break;
83 case 0x5300: DRegs[2]=V; break;
87 static uint8 WRAM[8192];
90 return(WRAM[A-0x6000]);
98 static void Power(void)
103 SetReadHandler(0x8000,0xFFFF,CartBR);
104 SetWriteHandler(0x4020,0x5FFF,Write);
105 SetReadHandler(0x6000,0x7FFF,AWRAM);
106 SetWriteHandler(0x6000,0x7FFF,BWRAM);
111 static void M163HB(void)
120 else if(scanline==127)
128 static void Power2(void)
134 SetReadHandler(0x8000,0xFFFF,CartBR);
135 SetWriteHandler(0x4020,0x5FFF,Write2);
136 SetReadHandler(0x6000,0x7FFF,AWRAM);
137 SetWriteHandler(0x6000,0x7FFF,BWRAM);
138 SetReadHandler(0x5000,0x5FFF,ReadLow);
143 void Mapper164_Init(CartInfo *info)
146 GameStateRestore=StateRestore;
147 AddExState(&StateRegs, ~0, 0, 0);
148 AddExState(WRAM, 8192, 0, "WRAM");
149 info->SaveGame[0]=WRAM;
\r
150 info->SaveGameLen[0]=8192;
153 void Mapper163_Init(CartInfo *info)
156 GameHBIRQHook=M163HB;
157 GameStateRestore=StateRestore;
158 AddExState(&StateRegs, ~0, 0, 0);
159 AddExState(WRAM, 8192, 0, "WRAM");