1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2006 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
23 static uint16 latche, latcheinit;
\r
24 static uint16 addrreg0, addrreg1;
\r
25 static void(*WSync)(void);
\r
26 static readfunc defread;
\r
28 static DECLFW(LatchWrite)
\r
30 FCEU_printf("%04x:%02x\n",A,V);
\r
35 static void LatchReset(void)
\r
41 static void LatchPower(void)
\r
45 SetReadHandler(0x8000,0xFFFF,defread);
\r
46 SetWriteHandler(addrreg0,addrreg1,LatchWrite);
\r
49 static void StateRestore(int version)
\r
54 static void Latch_Init(CartInfo *info, void (*proc)(void), readfunc func, uint16 init, uint16 adr0, uint16 adr1)
\r
64 info->Power=LatchPower;
\r
65 info->Reset=LatchReset;
\r
66 GameStateRestore=StateRestore;
\r
67 AddExState(&latche, 2, 0, "LATC");
\r
70 //------------------ UNLCC21 ---------------------------
\r
72 static void UNLCC21Sync(void)
\r
76 setmirror(MI_0+((latche&2)>>1));
\r
79 void UNLCC21_Init(CartInfo *info)
\r
81 Latch_Init(info, UNLCC21Sync, 0, 0, 0x8000, 0xFFFF);
\r
84 //------------------ BMCD1038 ---------------------------
\r
86 static uint8 dipswitch;
\r
87 static void BMCD1038Sync(void)
\r
91 setprg16(0x8000,(latche&0x70)>>4);
\r
92 setprg16(0xC000,(latche&0x70)>>4);
\r
95 setprg32(0x8000,(latche&0x60)>>5);
\r
97 setmirror(((latche&8)>>3)^1);
\r
100 static DECLFR(BMCD1038Read)
\r
108 static void BMCD1038Reset(void)
\r
114 void BMCD1038_Init(CartInfo *info)
\r
116 Latch_Init(info, BMCD1038Sync, BMCD1038Read, 0, 0x8000, 0xFFFF);
\r
117 info->Reset=BMCD1038Reset;
\r
118 AddExState(&dipswitch, 1, 0, "DIPSW");
\r
122 //------------------ Map 058 ---------------------------
\r
124 static void BMCGK192Sync(void)
\r
128 setprg16(0x8000,latche&7);
\r
129 setprg16(0xC000,latche&7);
\r
132 setprg32(0x8000,(latche>>1)&3);
\r
133 setchr8((latche>>3)&7);
\r
134 setmirror(((latche&0x80)>>7)^1);
\r
137 void BMCGK192_Init(CartInfo *info)
\r
139 Latch_Init(info, BMCGK192Sync, 0, 0, 0x8000, 0xFFFF);
\r
142 //------------------ Map 200 ---------------------------
\r
144 static void M200Sync(void)
\r
146 // FCEU_printf("A\n");
\r
147 setprg16(0x8000,latche&7);
\r
148 setprg16(0xC000,latche&7);
\r
150 setmirror((latche&8)>>3);
\r
153 void Mapper200_Init(CartInfo *info)
\r
155 Latch_Init(info, M200Sync, 0, 0xff, 0x8000, 0xFFFF);
\r
158 //------------------ 190in1 ---------------------------
\r
160 static void BMC190in1Sync(void)
\r
162 setprg16(0x8000,(latche>>2)&0x07);
\r
163 setprg16(0xC000,(latche>>2)&0x07);
\r
164 setchr8((latche>>2)&0x07);
\r
165 setmirror((latche&1)^1);
\r
168 void BMC190in1_Init(CartInfo *info)
\r
170 Latch_Init(info, BMC190in1Sync, 0, 0, 0x8000, 0xFFFF);
\r