menubg, png, bugfix
[fceu.git] / boards / 112.c
CommitLineData
d97315ac 1/* FCE Ultra - NES/Famicom Emulator
2 *
3 * Copyright notice for this file:
4 * Copyright (C) 2005 CaH4e3
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include "mapinc.h"
22
23static uint8 reg[8];
24static uint8 mirror, cmd;
25static uint8 *WRAM=NULL;
e2d0dd92 26
d97315ac 27static SFORMAT StateRegs[]=
28{
29 {&cmd, 1, "CMD"},
30 {&mirror, 1, "MIRR"},
31 {reg, 8, "REGS"},
32 {0}
33};
34
35static void Sync(void)
36{
37 setmirror(mirror^1);
38 setprg8(0x8000,reg[0]);
39 setprg8(0xA000,reg[1]);
40 setchr2(0x0000,reg[2]>>1);
41 setchr2(0x0800,reg[3]>>1);
42 setchr1(0x1000,reg[4]);
43 setchr1(0x1400,reg[5]);
44 setchr1(0x1800,reg[6]);
45 setchr1(0x1C00,reg[7]);
46}
47
48static DECLFW(M112Write)
49{
50 switch(A)
51 {
52 case 0xe000: mirror=V&1; Sync(); ;break;
53 case 0x8000: cmd=V&7; break;
54 case 0xa000: reg[cmd]=V; Sync(); break;
55 }
e2d0dd92 56FCEU_printf("%04x:%04x %d\n",A,V,scanline);
d97315ac 57}
58
59static void M112Close(void)
60{
61 if(WRAM)
62 FCEU_gfree(WRAM);
63 WRAM = NULL;
64}
65
66static void M112Power(void)
67{
d97315ac 68 setprg16(0xC000,~0);
69 setprg8r(0x10,0x6000,0);
70 SetReadHandler(0x8000,0xFFFF,CartBR);
71 SetWriteHandler(0x8000,0xFFFF,M112Write);
72 SetReadHandler(0x6000,0x7FFF,CartBR);
73 SetWriteHandler(0x6000,0x7FFF,CartBW);
74}
75
76static void StateRestore(int version)
77{
78 Sync();
79}
80
81void Mapper112_Init(CartInfo *info)
82{
83 info->Power=M112Power;
84 info->Close=M112Close;
85 GameStateRestore=StateRestore;
86 WRAM=(uint8*)FCEU_gmalloc(8192);
87 SetupCartPRGMapping(0x10,WRAM,8192,1);
88 AddExState(WRAM, 8192, 0, "WRAM");
89 AddExState(&StateRegs, ~0, 0, 0);
90}