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 // brk is a system call in *nix, and is an illegal variable name - soules
\r
25 static uint8 chrcmd[8], prg0, prg1, bbrk, mirr, swap;
\r
26 static SFORMAT StateRegs[]=
\r
28 {chrcmd, 8, "CHRCMD"},
\r
37 static void Sync(void)
\r
40 setprg8(0x8000,prg0);
\r
41 setprg8(0xA000,prg1);
\r
45 setchr1(i<<10,chrcmd[i]);
\r
49 static void UNLSL1632CW(uint32 A, uint8 V)
\r
51 int cbase=(MMC3_cmd&0x80)<<5;
\r
52 int page0=(bbrk&0x08)<<5;
\r
53 int page1=(bbrk&0x20)<<3;
\r
54 int page2=(bbrk&0x80)<<1;
\r
55 setchr1(cbase^0x0000,page0|(DRegBuf[0]&(~1)));
\r
56 setchr1(cbase^0x0400,page0|DRegBuf[0]|1);
\r
57 setchr1(cbase^0x0800,page0|(DRegBuf[1]&(~1)));
\r
58 setchr1(cbase^0x0C00,page0|DRegBuf[1]|1);
\r
59 setchr1(cbase^0x1000,page1|DRegBuf[2]);
\r
60 setchr1(cbase^0x1400,page1|DRegBuf[3]);
\r
61 setchr1(cbase^0x1800,page2|DRegBuf[4]);
\r
62 setchr1(cbase^0x1c00,page2|DRegBuf[5]);
\r
65 static DECLFW(UNLSL1632CMDWrite)
\r
73 FixMMC3PRG(MMC3_cmd);
\r
74 FixMMC3CHR(MMC3_cmd);
\r
82 if((A>=0xB000)&&(A<=0xE003))
\r
84 int ind=((((A&2)|(A>>10))>>1)+2)&7;
\r
86 chrcmd[ind]=(chrcmd[ind]&(0xF0>>sar))|((V&0x0F)<<sar);
\r
91 case 0x8000: prg0=V; break;
\r
92 case 0xA000: prg1=V; break;
\r
93 case 0x9000: mirr=V&1; break;
\r
99 static void StateRestore(int version)
\r
103 FixMMC3PRG(MMC3_cmd);
\r
104 FixMMC3CHR(MMC3_cmd);
\r
110 static void UNLSL1632Power(void)
\r
113 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
114 SetWriteHandler(0x4100,0xFFFF,UNLSL1632CMDWrite);
\r
117 void UNLSL1632_Init(CartInfo *info)
\r
119 GenMMC3_Init(info, 256, 512, 0, 0);
\r
121 info->Power=UNLSL1632Power;
\r
122 GameStateRestore=StateRestore;
\r
123 AddExState(&StateRegs, ~0, 0, 0);
\r