1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2009 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 * Wario Land II (Kirby hack) VRC4
\r
25 static uint8 reg[8], chr[8];
\r
26 static uint8 *WRAM=NULL;
\r
27 static uint32 WRAMSIZE;
\r
28 static uint16 IRQCount, IRQa;
\r
30 static SFORMAT StateRegs[]=
\r
34 {&IRQCount, 16, "IRQc"},
\r
35 {&IRQa, 16, "IRQa"},
\r
39 static void Sync(void)
\r
42 setprg8(0x8000,reg[0]);
\r
43 setprg8(0xA000,reg[1]);
\r
44 setprg8(0xC000,reg[2]);
\r
46 setchr1(i << 10,chr[i]);
\r
47 setmirror(reg[3]^1);
\r
50 static DECLFW(UNLSC127Write)
\r
54 case 0x8000: reg[0] = V; break;
\r
55 case 0x8001: reg[1] = V; break;
\r
56 case 0x8002: reg[2] = V; break;
\r
57 case 0x9000: chr[0] = V; break;
\r
58 case 0x9001: chr[1] = V; break;
\r
59 case 0x9002: chr[2] = V; break;
\r
60 case 0x9003: chr[3] = V; break;
\r
61 case 0x9004: chr[4] = V; break;
\r
62 case 0x9005: chr[5] = V; break;
\r
63 case 0x9006: chr[6] = V; break;
\r
64 case 0x9007: chr[7] = V; break;
\r
65 case 0xC002: IRQa=0; X6502_IRQEnd(FCEU_IQEXT); break;
\r
66 case 0xC005: IRQCount=V; break;
\r
67 case 0xC003: IRQa=1; break;
\r
68 case 0xD001: reg[3] = V; break;
\r
73 static void UNLSC127Power(void)
\r
76 setprg8r(0x10,0x6000,0);
\r
78 SetReadHandler(0x6000,0x7fff,CartBR);
\r
79 SetWriteHandler(0x6000,0x7fff,CartBW);
\r
80 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
81 SetWriteHandler(0x8000,0xFFFF,UNLSC127Write);
\r
84 static void UNLSC127IRQ(void)
\r
91 X6502_IRQBegin(FCEU_IQEXT);
\r
97 static void UNLSC127Reset(void)
\r
101 static void UNLSC127Close(void)
\r
108 static void StateRestore(int version)
\r
113 void UNLSC127_Init(CartInfo *info)
\r
115 info->Reset=UNLSC127Reset;
\r
116 info->Power=UNLSC127Power;
\r
117 info->Close=UNLSC127Close;
\r
118 GameHBIRQHook=UNLSC127IRQ;
\r
119 GameStateRestore=StateRestore;
\r
121 WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
\r
122 SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
\r
123 AddExState(WRAM, WRAMSIZE, 0, "WRAM");
\r
124 AddExState(&StateRegs, ~0, 0, 0);
\r