1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 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 DRegs[8];
26 static uint8 MirCache[8];
28 static SFORMAT DB_StateRegs[]={
35 static void FP_FASTAPASS(1) dragonbust_ppu(uint32 A)
54 static void toot(void)
58 MirCache[0]=MirCache[1]=(DRegs[0]>>4)&1;
59 MirCache[2]=MirCache[3]=(DRegs[1]>>4)&1;
62 MirCache[4+x]=(DRegs[2+x]>>5)&1;
63 onemir(MirCache[lastA]);
66 static DECLFW(Mapper95_write)
78 case 0: DRegs[0]=(V&0x3F)>>1;toot();V>>=1;setchr2(0x0000,V&0x1F);break;
79 case 1: DRegs[1]=(V&0x3F)>>1;toot();V>>=1;setchr2(0x0800,V&0x1F);break;
80 case 2: DRegs[2]=V&0x3F;toot();setchr1(0x1000,V&0x1F); break;
81 case 3: DRegs[3]=V&0x3F;toot();setchr1(0x1400,V&0x1F); break;
82 case 4: DRegs[4]=V&0x3F;toot();setchr1(0x1800,V&0x1F); break;
83 case 5: DRegs[5]=V&0x3F;toot();setchr1(0x1C00,V&0x1F); break;
84 case 6: DRegs[6]=V&0x3F;
87 case 7: DRegs[7]=V&0x3F;
99 setchr2(0x0000,DRegs[0]);
100 setchr2(0x0800,DRegs[1]);
103 setchr1(0x1000+x*0x400,DRegs[2+x]);
105 setprg8(0x8000,DRegs[6]);
106 setprg8(0xa000,DRegs[7]);
110 static void DBPower(void)
112 memset(DRegs,0x3F,8);
113 DRegs[0]=DRegs[1]=0x1F;
117 setprg8(0xc000,0x3E);
118 setprg8(0xe000,0x3F);
120 SetReadHandler(0x8000,0xffff,CartBR);
121 SetWriteHandler(0x8000,0xffff,Mapper95_write);
124 static void StateRestore(int version)
129 void Mapper95_Init(CartInfo *info)
132 AddExState(DB_StateRegs, ~0, 0, 0);
133 PPU_hook=dragonbust_ppu;
134 GameStateRestore=StateRestore;