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 prgreg[4], chrreg[8], mirror;
24 static uint8 IRQa, IRQCount, IRQLatch;
26 static SFORMAT StateRegs[]=
29 {&IRQCount, 1, "IRQC"},
30 {&IRQLatch, 1, "IRQL"},
37 static void Sync(void)
39 setprg8(0x8000,prgreg[0]);
40 setprg8(0xa000,prgreg[1]);
41 setprg8(0xc000,prgreg[2]);
42 setprg8(0xe000,prgreg[3]);
45 setchr1(i<<10,chrreg[i]);
49 static DECLFW(M117Write)
56 else if((A>=0xA000)&&(A<=0xA007))
63 case 0xc001: IRQLatch=V; break;
64 case 0xc003: IRQCount=IRQLatch; IRQa|=2; break;
65 case 0xe000: IRQa&=~1; IRQa|=V&1; X6502_IRQEnd(FCEU_IQEXT); break;
66 case 0xc002: X6502_IRQEnd(FCEU_IQEXT); break;
67 case 0xd000: mirror=V&1;
71 static void M117Power(void)
73 prgreg[0]=~3; prgreg[1]=~2; prgreg[2]=~1; prgreg[3]=~0;
75 SetReadHandler(0x8000,0xFFFF,CartBR);
76 SetWriteHandler(0x8000,0xFFFF,M117Write);
79 static void M117IRQHook(void)
87 X6502_IRQBegin(FCEU_IQEXT);
92 static void StateRestore(int version)
97 void Mapper117_Init(CartInfo *info)
99 info->Power=M117Power;
100 GameHBIRQHook=M117IRQHook;
101 GameStateRestore=StateRestore;
102 AddExState(&StateRegs, ~0, 0, 0);