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];
24 static uint8 IRQa, IRQCount, IRQLatch;
26 static SFORMAT StateRegs[]=
29 {&IRQCount, 1, "IRQC"},
30 {&IRQLatch, 1, "IRQL"},
36 static void Sync(void)
38 setprg8(0x8000,prgreg[0]);
39 setprg8(0xa000,prgreg[1]);
40 setprg8(0xc000,prgreg[2]);
41 setprg8(0xe000,prgreg[3]);
44 setchr1(i<<10,chrreg[i]);
47 static DECLFW(M117Write)
54 else if((A>=0xA000)&&(A<=0xA007))
61 case 0xc001: IRQLatch=V; break;
62 case 0xc003: IRQCount=IRQLatch; IRQa|=2; break;
63 case 0xe000: IRQa&=~1; IRQa|=V&1; X6502_IRQEnd(FCEU_IQEXT); break;
64 case 0xc002: X6502_IRQEnd(FCEU_IQEXT); break;
68 static void M117Power(void)
70 prgreg[0]=~3; prgreg[1]=~2; prgreg[2]=~1; prgreg[3]=~0;
72 SetReadHandler(0x8000,0xFFFF,CartBR);
73 SetWriteHandler(0x8000,0xFFFF,M117Write);
76 static void M117IRQHook(void)
84 X6502_IRQBegin(FCEU_IQEXT);
89 static void StateRestore(int version)
94 void Mapper117_Init(CartInfo *info)
96 info->Power=M117Power;
97 GameHBIRQHook=M117IRQHook;
98 GameStateRestore=StateRestore;
99 AddExState(&StateRegs, ~0, 0, 0);