1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2003 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
24 static uint8 PBuf[4],PSel;
26 static uint8 DRegs[8];
27 static uint32 count=0;
30 static DECLFW(M208Write1)
32 PRGSel=(V&0x1)|((V>>3)&0x2);
33 setprg32(0x8000,PRGSel);
36 static DECLFW(M208Write2)
38 static uint8 lut[256]={
39 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,
40 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,
41 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,
42 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,
43 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08,
48 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00,
49 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08,
50 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00,
51 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
59 PBuf[(A&0x03)]=V^lut[PSel];
62 static DECLFR(M208Read)
64 return(PBuf[(A&0x3)]);
67 static void Sync(void)
71 setchr2(0x0000,DRegs[0]>>1);
72 setchr2(0x0800,DRegs[1]>>1);
74 setchr1(0x1000+x*0x400,DRegs[2+x]);
77 static DECLFW(M208HWrite)
81 case 0xc000:IRQLatch=IRQCount=V;break;
82 case 0xc001:IRQCount=IRQLatch;last=count=0;break;
83 case 0xe000:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break;
84 case 0xe001:IRQa=1;break;
85 case 0x8000:cmd=V;break;
86 case 0x8001:DRegs[cmd&7]=V;
93 static void M208Power(void)
97 SetWriteHandler(0x4800,0x4FFF,M208Write1);
98 SetWriteHandler(0x5000,0x5fff,M208Write2);
99 SetWriteHandler(0x8000,0xFFFF,M208HWrite);
100 SetReadHandler(0x5800,0x5FFF,M208Read);
101 SetReadHandler(0x8000,0xffff,CartBR);
113 X6502_IRQBegin(FCEU_IQEXT);
119 static void FP_FASTAPASS(1) foo(uint32 A)
121 if((A&0x2000) && !(last&0x2000))
133 void Mapper208_Init(CartInfo *info)
135 info->Power=M208Power;