1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2007 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, mirr;
\r
27 static int32 IRQa, IRQCount, IRQLatch;
\r
28 static uint8 *WRAM=NULL;
\r
29 static uint32 WRAMSIZE;
\r
31 static SFORMAT StateRegs[]=
\r
36 {&IRQCount, 4, "IRQC"},
\r
37 {&IRQLatch, 4, "IRQL"},
\r
41 static void Sync(void)
\r
43 setprg16(0x8000,reg);
\r
48 static DECLFW(UNLKS7017Write)
\r
50 // FCEU_printf("bs %04x %02x\n",A,V);
\r
51 if((A & 0xFF00) == 0x4A00)
\r
53 reg = ((A >> 2) & 3)|((A >> 4) & 4);
\r
55 else if ((A & 0xFF00) == 0x5100)
\r
59 else if (A == 0x4020)
\r
61 X6502_IRQEnd(FCEU_IQEXT);
\r
65 else if (A == 0x4021)
\r
67 X6502_IRQEnd(FCEU_IQEXT);
\r
72 else if (A == 0x4025)
\r
74 mirr = ((V & 8) >> 3) ^ 1;
\r
78 static DECLFR(FDSRead4030)
\r
80 X6502_IRQEnd(FCEU_IQEXT);
\r
81 return X.IRQlow&FCEU_IQEXT?1:0;
\r
84 static void FP_FASTAPASS(1) UNL7017IRQ(int a)
\r
92 X6502_IRQBegin(FCEU_IQEXT);
\r
97 static void UNLKS7017Power(void)
\r
101 setprg8r(0x10,0x6000,0);
\r
102 SetReadHandler(0x6000,0x7FFF,CartBR);
\r
103 SetWriteHandler(0x6000,0x7FFF,CartBW);
\r
104 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
105 SetReadHandler(0x4030,0x4030,FDSRead4030);
\r
106 SetWriteHandler(0x4020,0x5FFF,UNLKS7017Write);
\r
109 static void UNLKS7017Close(void)
\r
116 static void StateRestore(int version)
\r
121 void UNLKS7017_Init(CartInfo *info)
\r
123 info->Power=UNLKS7017Power;
\r
124 info->Close=UNLKS7017Close;
\r
125 MapIRQHook=UNL7017IRQ;
\r
128 WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
\r
129 SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
\r
130 AddExState(WRAM, WRAMSIZE, 0, "WRAM");
\r
132 GameStateRestore=StateRestore;
\r
133 AddExState(&StateRegs, ~0, 0, 0);
\r