1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2005 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
25 static uint8 UNL8237_perm[8] = {0, 2, 6, 1, 7, 3, 4, 5};
27 static void UNL8237CW(uint32 A, uint8 V)
29 setchr1(A,((EXPREGS[1]&4)<<6)|V);
32 static void UNL8237PW(uint32 A, uint8 V)
37 setprg32(0x8000,(EXPREGS[0]&0xF)>>1);
40 setprg16(0x8000,(EXPREGS[0]&0x1F));
41 setprg16(0xC000,(EXPREGS[0]&0x1F));
48 static DECLFW(UNL8237Write)
50 if((A&0xF000)==0xF000)
52 else if((A&0xF000)==0xE000)
53 X6502_IRQEnd(FCEU_IQEXT);
56 case 0x8000: setmirror(((V|(V>>7))&1)^1); break;
57 case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(UNL8237_perm[V&7])); cmdin=1; break;
58 case 0xC000: if(cmdin)
60 MMC3_CMDWrite(0x8001,V);
67 static DECLFW(UNL8237ExWrite)
71 case 0x5000: EXPREGS[0]=V; FixMMC3PRG(MMC3_cmd); break;
72 case 0x5001: EXPREGS[1]=V; FixMMC3CHR(MMC3_cmd); break;
76 static void UNL8237Power(void)
79 EXPREGS[0]=EXPREGS[1]=0;
81 SetWriteHandler(0x8000,0xFFFF,UNL8237Write);
82 SetWriteHandler(0x5000,0x7FFF,UNL8237ExWrite);
85 void UNL8237_Init(CartInfo *info)
87 GenMMC3_Init(info, 256, 256, 0, 0);
90 info->Power=UNL8237Power;
91 AddExState(EXPREGS, 3, 0, "EXPR");
92 AddExState(&cmdin, 1, 0, "CMDIN");