2 /* FCE Ultra - NES/Famicom Emulator
\r
4 * Copyright notice for this file:
\r
5 * Copyright (C) 2007 CaH4e3
\r
7 * This program is free software; you can redistribute it and/or modify
\r
8 * it under the terms of the GNU General Public License as published by
\r
9 * the Free Software Foundation; either version 2 of the License, or
\r
10 * (at your option) any later version.
\r
12 * This program is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 * GNU General Public License for more details.
\r
17 * You should have received a copy of the GNU General Public License
\r
18 * along with this program; if not, write to the Free Software
\r
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
24 static uint8 chr_cmd, prg_cmd, mirror;
\r
25 static uint8 chr_reg[6], prg_reg[4];
\r
27 static SFORMAT StateRegs[]=
\r
29 {&chr_cmd, 1, "CHRCMD"},
\r
30 {&prg_cmd, 1, "PRGCMD"},
\r
31 {&mirror, 1, "MIRR"},
\r
32 {chr_reg, 6, "CREGS"},
\r
33 {prg_reg, 4, "PREGS"},
\r
37 static void Sync(void)
\r
39 setprg8(0x8000, prg_reg[0]);
\r
40 setprg8(0xA000, prg_reg[1]);
\r
41 setprg8(0xC000, prg_reg[2]);
\r
42 setprg8(0xE000, prg_reg[3]);
\r
44 setchr2(0x0000, chr_reg[0]);
\r
45 setchr2(0x0800, chr_reg[1]);
\r
46 setchr1(0x1000, chr_reg[2]);
\r
47 setchr1(0x1400, chr_reg[3]);
\r
48 setchr1(0x1800, chr_reg[4]);
\r
49 setchr1(0x1c00, chr_reg[5]);
\r
54 static DECLFW(UNLA9746Write)
\r
57 // FCEU_printf("write raw %04x:%02x\n",A,V);
\r
60 // case 0xA000: mirror = V; break;
\r
61 case 0x8000: chr_cmd = V; prg_cmd = 0; break;
\r
62 case 0x8002: prg_cmd = V; chr_cmd = 0; break;
\r
63 case 0x8001: bits_rev = ((V&0x20)>>5)|((V&0x10)>>3)|((V&0x08)>>1)|((V&0x04)<<1);
\r
65 // prg_reg[(0x26-prg_cmd)&3] = bits_rev;
\r
68 case 0x08: chr_reg[0] = (V << 3); break;
\r
69 case 0x09: chr_reg[0] = chr_reg[0]|(V >> 2); break;
\r
70 case 0x0e: chr_reg[1] = (V << 3); break;
\r
71 case 0x0d: chr_reg[1] = chr_reg[1]|(V >> 2); break;
\r
72 case 0x12: chr_reg[2] = (V << 4); break;
\r
73 case 0x11: chr_reg[2] = chr_reg[2]|(V >> 1); FCEU_printf("Sync CHR 0x1000:%02x\n",chr_reg[2]); break;
\r
74 case 0x16: chr_reg[3] = (V << 4); break;
\r
75 case 0x15: chr_reg[3] = chr_reg[3]|(V >> 1); break;
\r
76 case 0x1a: chr_reg[4] = (V << 4); break;
\r
77 case 0x19: chr_reg[4] = chr_reg[4]|(V >> 1); break;
\r
78 case 0x1e: chr_reg[5] = (V << 4); break;
\r
79 case 0x1d: chr_reg[5] = chr_reg[5]|(V >> 1); break;
\r
86 static void UNLA9746Power(void)
\r
91 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
92 SetWriteHandler(0x8000,0xbfff,UNLA9746Write);
\r
95 static void StateRestore(int version)
\r
100 void UNLA9746_Init(CartInfo *info)
\r
102 info->Power=UNLA9746Power;
\r
103 AddExState(&StateRegs, ~0, 0, 0);
\r
107 /* FCE Ultra - NES/Famicom Emulator
\r
109 * Copyright notice for this file:
\r
110 * Copyright (C) 2007 CaH4e3
\r
112 * This program is free software; you can redistribute it and/or modify
\r
113 * it under the terms of the GNU General Public License as published by
\r
114 * the Free Software Foundation; either version 2 of the License, or
\r
115 * (at your option) any later version.
\r
117 * This program is distributed in the hope that it will be useful,
\r
118 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
119 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
120 * GNU General Public License for more details.
\r
122 * You should have received a copy of the GNU General Public License
\r
123 * along with this program; if not, write to the Free Software
\r
124 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
127 #include "mapinc.h"
\r
130 static DECLFW(UNLA9746Write)
\r
132 // FCEU_printf("write raw %04x:%02x\n",A,V);
\r
135 case 0x8000: EXPREGS[1]=V; EXPREGS[0]=0; break;
\r
136 case 0x8002: EXPREGS[0]=V; EXPREGS[1]=0; break;
\r
138 uint8 bits_rev = ((V&0x20)>>5)|((V&0x10)>>3)|((V&0x08)>>1)|((V&0x04)<<1);
\r
141 case 0x26: setprg8(0x8000, bits_rev); break;
\r
142 case 0x25: setprg8(0xA000, bits_rev); break;
\r
143 case 0x24: setprg8(0xC000, bits_rev); break;
\r
144 case 0x23: setprg8(0xE000, bits_rev); break;
\r
149 case 0x08: EXPREGS[2] = (V << 4); break;
\r
150 case 0x09: setchr1(0x0000, EXPREGS[2]|(V >> 1)); break;
\r
151 case 0x0b: setchr1(0x0400, EXPREGS[2]|(V >> 1)|1); break;
\r
153 case 0x0e: EXPREGS[2] = (V << 4); break;
\r
154 case 0x0d: setchr1(0x0800, EXPREGS[2]|(V >> 1)); break;
\r
155 case 0x0f: setchr1(0x0c00, EXPREGS[2]|(V >> 1)|1); break;
\r
157 case 0x12: EXPREGS[2] = (V << 4); break;
\r
158 case 0x11: setchr1(0x1000, EXPREGS[2]|(V >> 1)); break;
\r
160 case 0x16: EXPREGS[2] = (V << 4); break;
\r
161 case 0x15: setchr1(0x1400, EXPREGS[2]|(V >> 1)); break;
\r
163 case 0x1a: EXPREGS[2] = (V << 4); break;
\r
164 case 0x19: setchr1(0x1800, EXPREGS[2]|(V >> 1)); break;
\r
166 case 0x1e: EXPREGS[2] = (V << 4); break;
\r
167 case 0x1d: setchr1(0x1c00, EXPREGS[2]|(V >> 1)); break;
\r
174 static void UNLA9746Power(void)
\r
177 SetWriteHandler(0x8000,0xbfff,UNLA9746Write);
\r
180 void UNLA9746_Init(CartInfo *info)
\r
182 GenMMC3_Init(info, 128, 256, 0, 0);
\r
183 info->Power=UNLA9746Power;
\r
184 AddExState(EXPREGS, 6, 0, "EXPR");
\r