1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2012 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 preg[4], creg[8];
\r
27 static uint8 IRQa, mirr;
\r
28 static int32 IRQCount, IRQLatch;
\r
30 static SFORMAT StateRegs[]=
\r
36 {&IRQCount, 4, "IRQC"},
\r
37 {&IRQLatch, 4, "IRQL"},
\r
41 static void Sync(void)
\r
44 for(i=0; i<8; i++) setchr1(i<<10,creg[i]);
\r
45 setprg8(0x8000,preg[0]);
\r
46 setprg8(0xA000,preg[1]);
\r
47 setprg8(0xC000,preg[2]);
\r
48 setprg8(0xE000,preg[3]);
\r
50 case 0: setmirror(MI_0); break;
\r
51 case 1: setmirror(MI_1); break;
\r
52 case 2: setmirror(MI_H); break;
\r
53 case 3: setmirror(MI_V); break;
\r
57 static DECLFW(M17WriteMirr)
\r
59 mirr = ((A << 1) & 2)|((V >> 4) & 1);
\r
63 static DECLFW(M17WriteIRQ)
\r
66 case 0x4501: IRQa=0; X6502_IRQEnd(FCEU_IQEXT); break;
\r
67 case 0x4502: IRQCount&=0xFF00; IRQCount|=V; break;
\r
68 case 0x4503: IRQCount&=0x00FF; IRQCount|=V<<8; IRQa=1; break;
\r
72 static DECLFW(M17WritePrg)
\r
78 static DECLFW(M17WriteChr)
\r
84 static void M17Power(void)
\r
88 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
89 SetWriteHandler(0x42FE,0x42FF,M17WriteMirr);
\r
90 SetWriteHandler(0x4500,0x4503,M17WriteIRQ);
\r
91 SetWriteHandler(0x4504,0x4507,M17WritePrg);
\r
92 SetWriteHandler(0x4510,0x4517,M17WriteChr);
\r
95 static void FP_FASTAPASS(1) M17IRQHook(int a)
\r
100 if(IRQCount>=0x10000)
\r
102 X6502_IRQBegin(FCEU_IQEXT);
\r
109 static void StateRestore(int version)
\r
114 void Mapper17_Init(CartInfo *info)
\r
116 info->Power=M17Power;
\r
117 GameHBIRQHook=M17IRQHook;
\r
118 GameStateRestore=StateRestore;
\r
120 AddExState(&StateRegs, ~0, 0, 0);
\r