1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
20 * Super Bros. Pocker Mali (VRC4 mapper)
\r
25 static uint8 IRQCount;//, IRQPre;
\r
27 static uint8 prg_reg[2];
\r
28 static uint8 chr_reg[8];
\r
31 static SFORMAT StateRegs[]=
\r
33 {&IRQCount, 1, "IRQC"},
\r
35 {prg_reg, 2, "PRG"},
\r
36 {chr_reg, 8, "CHR"},
\r
42 static void UNLAX5705IRQ(void)
\r
49 X6502_IRQBegin(FCEU_IQEXT);
\r
55 static void Sync(void)
\r
57 setprg8(0x8000,prg_reg[0]);
\r
58 setprg8(0xA000,prg_reg[1]);
\r
63 setchr1(i<<10,chr_reg[i]);
\r
67 static DECLFW(UNLAX5705Write)
\r
69 // if((A>=0xA008)&&(A<=0xE003))
\r
71 // int ind=(((A>>11)-6)|(A&1))&7;
\r
72 // int sar=((A&2)<<1);
\r
73 // chr_reg[ind]=(chr_reg[ind]&(0xF0>>sar))|((V&0x0F)<<sar);
\r
79 case 0x8000: prg_reg[0]=((V&2)<<2)|((V&8)>>2)|(V&5); break; // EPROM dump have mixed PRG and CHR banks, data lines to mapper seems to be mixed
\r
80 case 0x8008: mirr=V&1; break;
\r
81 case 0xA000: prg_reg[1]=((V&2)<<2)|((V&8)>>2)|(V&5); break;
\r
82 case 0xA008: chr_reg[0]=(chr_reg[0]&0xF0)|(V&0x0F); break;
\r
83 case 0xA009: chr_reg[0]=(chr_reg[0]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;
\r
84 case 0xA00A: chr_reg[1]=(chr_reg[1]&0xF0)|(V&0x0F); break;
\r
85 case 0xA00B: chr_reg[1]=(chr_reg[1]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;
\r
86 case 0xC000: chr_reg[2]=(chr_reg[2]&0xF0)|(V&0x0F); break;
\r
87 case 0xC001: chr_reg[2]=(chr_reg[2]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;
\r
88 case 0xC002: chr_reg[3]=(chr_reg[3]&0xF0)|(V&0x0F); break;
\r
89 case 0xC003: chr_reg[3]=(chr_reg[3]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;
\r
90 case 0xC008: chr_reg[4]=(chr_reg[4]&0xF0)|(V&0x0F); break;
\r
91 case 0xC009: chr_reg[4]=(chr_reg[4]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;
\r
92 case 0xC00A: chr_reg[5]=(chr_reg[5]&0xF0)|(V&0x0F); break;
\r
93 case 0xC00B: chr_reg[5]=(chr_reg[5]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;
\r
94 case 0xE000: chr_reg[6]=(chr_reg[6]&0xF0)|(V&0x0F); break;
\r
95 case 0xE001: chr_reg[6]=(chr_reg[6]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;
\r
96 case 0xE002: chr_reg[7]=(chr_reg[7]&0xF0)|(V&0x0F); break;
\r
97 case 0xE003: chr_reg[7]=(chr_reg[7]&0x0F)|((((V&4)>>1)|((V&2)<<1)|(V&0x09))<<4); break;
\r
98 // case 0x800A: X6502_IRQEnd(FCEU_IQEXT); IRQa=0; break;
\r
99 // case 0xE00B: X6502_IRQEnd(FCEU_IQEXT); IRQa=IRQCount=V; /*if(scanline<240) IRQCount-=8; else IRQCount+=4;*/ break;
\r
104 static void UNLAX5705Power(void)
\r
107 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
108 SetWriteHandler(0x8000,0xFFFF,UNLAX5705Write);
\r
111 static void StateRestore(int version)
\r
116 void UNLAX5705_Init(CartInfo *info)
\r
118 info->Power=UNLAX5705Power;
\r
119 // GameHBIRQHook=UNLAX5705IRQ;
\r
120 GameStateRestore=StateRestore;
\r
121 AddExState(&StateRegs, ~0, 0, 0);
\r