1
/* FCE Ultra - NES/Famicom Emulator
3
* Copyright notice for this file:
4
* Copyright (C) 2007 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
23
static uint8 reg[16], IRQa;
24
static uint32 IRQCount;
25
static uint8 *WRAM=NULL;
26
static uint32 WRAMSIZE;
28
static SFORMAT StateRegs[]=
31
{&IRQCount, 4, "IRQCOUNT"},
36
static void Sync(void)
38
setchr1(0x0000,reg[0]&0xfe);
39
setchr1(0x0400,reg[1]|1);
40
setchr1(0x0800,reg[2]&0xfe);
41
setchr1(0x0c00,reg[3]|1);
42
setchr1(0x1000,reg[4]);
43
setchr1(0x1400,reg[5]);
44
setchr1(0x1800,reg[6]);
45
setchr1(0x1c00,reg[7]);
46
setprg8r(0x10,0x6000,0);
47
setprg8(0x8000,(reg[0x8]&0xf)|0x10);
48
setprg8(0xA000,(reg[0x9]&0x1f));
49
setprg8(0xC000,(reg[0xa]&0x1f));
50
setprg8(0xE000,(reg[0xb]&0xf)|0x10);
51
setmirror((reg[0xc]&1)^1);
54
static DECLFW(M106Write)
59
case 0xD: IRQa=0; IRQCount=0; X6502_IRQEnd(FCEU_IQEXT); break;
60
case 0xE: IRQCount=(IRQCount&0xFF00)|V; break;
61
case 0xF: IRQCount=(IRQCount&0x00FF)|(V<<8); IRQa=1; break;
62
default: reg[A]=V; Sync(); break;
66
static void M106Power(void)
68
reg[8]=reg[9]=reg[0xa]=reg[0xb]=-1;
70
SetReadHandler(0x6000,0x7FFF,CartBR);
71
SetReadHandler(0x8000,0xFFFF,CartBR);
72
SetWriteHandler(0x6000,0x7FFF,CartBW);
73
SetWriteHandler(0x8000,0xFFFF,M106Write);
76
static void M106Reset(void)
80
static void M106Close(void)
87
void M106CpuHook(int a)
94
X6502_IRQBegin(FCEU_IQEXT);
100
static void StateRestore(int version)
105
void Mapper106_Init(CartInfo *info)
107
info->Reset=M106Reset;
108
info->Power=M106Power;
109
info->Close=M106Close;
110
MapIRQHook=M106CpuHook;
111
GameStateRestore=StateRestore;
114
WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
115
SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
116
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
118
AddExState(&StateRegs, ~0, 0, 0);