1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2005 CaH4e3
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
24 static uint16 IRQCount;
26 static uint8 prg_reg[2];
27 static uint8 chr_reg[8];
29 static SFORMAT StateRegs[]=
31 {&IRQCount, 2, "IRQC"},
38 static void M222IRQ(void)
45 X6502_IRQBegin(FCEU_IQEXT);
51 static void Sync(void)
53 setprg8(0x8000,prg_reg[0]);
54 setprg8(0xA000,prg_reg[1]);
57 setchr1(i<<10,chr_reg[i]);
60 static DECLFW(M222Write)
64 case 0x8000: prg_reg[0]=V; break;
65 case 0xA000: prg_reg[1]=V; break;
66 case 0xB000: chr_reg[0]=V; break;
67 case 0xB002: chr_reg[1]=V; break;
68 case 0xC000: chr_reg[2]=V; break;
69 case 0xC002: chr_reg[3]=V; break;
70 case 0xD000: chr_reg[4]=V; break;
71 case 0xD002: chr_reg[5]=V; break;
72 case 0xE000: chr_reg[6]=V; break;
73 case 0xE002: chr_reg[7]=V; break;
74 case 0xF000: IRQCount=IRQa=V;
75 X6502_IRQEnd(FCEU_IQEXT);
81 static void M222Power(void)
84 SetReadHandler(0x8000,0xFFFF,CartBR);
85 SetWriteHandler(0x8000,0xFFFF,M222Write);
88 static void StateRestore(int version)
93 void Mapper222_Init(CartInfo *info)
95 info->Power=M222Power;
96 GameHBIRQHook=M222IRQ;
97 GameStateRestore=StateRestore;
98 AddExState(&StateRegs, ~0, 0, 0);