1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2012 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 * Taito X1-017 board, battery backed
\r
26 static uint8 regs[9], ctrl;
\r
27 static uint8 *WRAM=NULL;
\r
28 static uint32 WRAMSIZE;
\r
30 static SFORMAT StateRegs[]=
\r
37 static void Sync(void)
\r
39 uint32 swap = ((ctrl & 2) << 11);
\r
40 setchr2(0x0000^swap,regs[0]>>1);
\r
41 setchr2(0x0800^swap,regs[1]>>1);
\r
42 setchr1(0x1000^swap,regs[2]);
\r
43 setchr1(0x1400^swap,regs[3]);
\r
44 setchr1(0x1800^swap,regs[4]);
\r
45 setchr1(0x1c00^swap,regs[5]);
\r
46 setprg8r(0x10,0x6000,0);
\r
47 setprg8(0x8000,regs[6]);
\r
48 setprg8(0xA000,regs[7]);
\r
49 setprg8(0xC000,regs[8]);
\r
51 setmirror(ctrl & 1);
\r
54 static DECLFW(M82Write)
\r
61 case 0x7ef6: ctrl = V & 3; break;
\r
62 case 0x7efa: regs[6] = V >> 2; break;
\r
63 case 0x7efb: regs[7] = V >> 2; break;
\r
64 case 0x7efc: regs[8] = V >> 2; break;
\r
69 static void M82Power(void)
\r
72 SetReadHandler(0x6000,0xffff,CartBR);
\r
73 SetWriteHandler(0x6000,0x7fff,CartBW);
\r
74 SetWriteHandler(0x7ef0,0x7efc,M82Write); // external WRAM might end at $73FF
\r
77 static void M82Close(void)
\r
84 static void StateRestore(int version)
\r
89 void Mapper82_Init(CartInfo *info)
\r
91 info->Power=M82Power;
\r
92 info->Power=M82Close;
\r
95 WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
\r
96 SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
\r
97 AddExState(WRAM, WRAMSIZE, 0, "WRAM");
\r
100 info->SaveGame[0]=WRAM;
\r
101 info->SaveGameLen[0]=WRAMSIZE;
\r
103 GameStateRestore=StateRestore;
\r
104 AddExState(&StateRegs, ~0, 0, 0);
\r