1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Xodnizel
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
23 static uint8 cmd,mir,rmode,IRQmode;
24 static uint8 DRegs[11];
25 static uint8 IRQCount,IRQa,IRQLatch;
27 static SFORMAT Rambo_StateRegs[]={
31 {&IRQmode, 1, "IRQM"},
32 {&IRQCount, 1, "IRQC"},
34 {&IRQLatch, 1, "IRQL"},
39 static void FP_FASTAPASS(2) (*setchr1wrap)(unsigned int A, unsigned int V);
42 static void FP_FASTAPASS(1) RAMBO1_IRQHook(int a)
44 static int smallcount;
53 if(IRQa) X6502_IRQBegin(FCEU_IQEXT);
57 static void RAMBO1_hb(void)
60 if(scanline==240) return; /* hmm. Maybe that should be an mmc3-only call in fce.c. */
68 X6502_IRQBegin(FCEU_IQEXT);
73 static void Synco(void)
79 setchr1wrap(0x0000,DRegs[0]);
80 setchr1wrap(0x0800,DRegs[1]);
81 setchr1wrap(0x0400,DRegs[8]);
82 setchr1wrap(0x0c00,DRegs[9]);
86 setchr1wrap(0x0000,(DRegs[0]&0xFE));
87 setchr1wrap(0x0400,(DRegs[0]&0xFE)|1);
88 setchr1wrap(0x0800,(DRegs[1]&0xFE));
89 setchr1wrap(0x0C00,(DRegs[1]&0xFE)|1);
93 setchr1wrap(0x1000+x*0x400,DRegs[2+x]);
95 setprg8(0x8000,DRegs[6]);
96 setprg8(0xA000,DRegs[7]);
98 setprg8(0xC000,DRegs[10]);
102 static DECLFW(RAMBO1_write)
106 case 0xa000: mir=V&1;
110 case 0x8000: cmd = V;
112 case 0x8001: if((cmd&0xF)<10)
114 else if((cmd&0xF)==0xF)
118 case 0xc000: IRQLatch=V;
122 case 0xc001: rmode=1;
127 X6502_IRQEnd(FCEU_IQEXT);
138 static void RAMBO1_Restore(int version)
145 static void RAMBO1_init(void)
154 GameHBIRQHook=RAMBO1_hb;
155 MapIRQHook=RAMBO1_IRQHook;
156 GameStateRestore=RAMBO1_Restore;
157 SetWriteHandler(0x8000,0xffff,RAMBO1_write);
158 AddExState(Rambo_StateRegs, ~0, 0, 0);
161 static void FP_FASTAPASS(2) CHRWrap(unsigned int A, unsigned int V)
166 void Mapper64_init(void)
173 static int MirCache[8];
174 static unsigned int PPUCHRBus;
176 static void FP_FASTAPASS(2) MirWrap(unsigned int A, unsigned int V)
178 MirCache[A>>10]=(V>>7)&1;
179 if(PPUCHRBus==(A>>10))
180 setmirror(MI_0+((V>>7)&1));
184 static void FP_FASTAPASS(1) MirrorFear(uint32 A)
189 setmirror(MI_0+MirCache[A]);
192 void Mapper158_init(void)