1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
24 static uint8 IRQCount;
\r
26 static uint8 prg_reg[2];
\r
27 static uint8 chr_reg[8];
\r
30 static SFORMAT StateRegs[]=
\r
32 {&IRQCount, 1, "IRQC"},
\r
34 {prg_reg, 2, "PRG"},
\r
35 {chr_reg, 8, "CHR"},
\r
40 static void M222IRQ(void)
\r
47 X6502_IRQBegin(FCEU_IQEXT);
\r
53 static void Sync(void)
\r
56 setprg8(0x8000,prg_reg[0]);
\r
57 setprg8(0xA000,prg_reg[1]);
\r
59 setchr1(i<<10,chr_reg[i]);
\r
63 static DECLFW(M222Write)
\r
67 case 0x8000: prg_reg[0]=V; break;
\r
68 case 0x9000: mirr=V&1; break;
\r
69 case 0xA000: prg_reg[1]=V; break;
\r
70 case 0xB000: chr_reg[0]=V; break;
\r
71 case 0xB002: chr_reg[1]=V; break;
\r
72 case 0xC000: chr_reg[2]=V; break;
\r
73 case 0xC002: chr_reg[3]=V; break;
\r
74 case 0xD000: chr_reg[4]=V; break;
\r
75 case 0xD002: chr_reg[5]=V; break;
\r
76 case 0xE000: chr_reg[6]=V; break;
\r
77 case 0xE002: chr_reg[7]=V; break;
\r
78 // case 0xF000: FCEU_printf("%04x:%02x %d\n",A,V,scanline); IRQa=V; if(!V)IRQPre=0; X6502_IRQEnd(FCEU_IQEXT); break;
\r
79 // / case 0xF001: FCEU_printf("%04x:%02x %d\n",A,V,scanline); IRQCount=V; break;
\r
80 // case 0xF002: FCEU_printf("%04x:%02x %d\n",A,V,scanline); break;
\r
81 // case 0xD001: IRQa=V; X6502_IRQEnd(FCEU_IQEXT); FCEU_printf("%04x:%02x %d\n",A,V,scanline); break;
\r
82 // case 0xC001: IRQPre=16; FCEU_printf("%04x:%02x %d\n",A,V,scanline); break;
\r
83 case 0xF000: IRQa=IRQCount=V; if(scanline<240) IRQCount-=8; else IRQCount+=4; X6502_IRQEnd(FCEU_IQEXT); break;
\r
88 static void M222Power(void)
\r
90 setprg16(0xC000,~0);
\r
91 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
92 SetWriteHandler(0x8000,0xFFFF,M222Write);
\r
95 static void StateRestore(int version)
\r
100 void Mapper222_Init(CartInfo *info)
\r
102 info->Power=M222Power;
\r
103 GameHBIRQHook=M222IRQ;
\r
104 GameStateRestore=StateRestore;
\r
105 AddExState(&StateRegs, ~0, 0, 0);
\r