eccf9c2df89a6ec8ae070f85f059d75cad5155d8
[fceu.git] / boards / karaoke.c
1 /* FCE Ultra - NES/Famicom Emulator
2  *
3  * Copyright notice for this file:
4  *  Copyright (C) 2002 Xodnizel
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
23 static uint8 DReg;
24 static SFORMAT StateRegs[]=
25 {
26   {&DReg, 1, "DREG"},
27   {0}
28 };
29
30 static void Sync(void)
31 {
32   if(DReg)
33   {
34     if(DReg & 0x10)
35       setprg16(0x8000,(DReg&7));
36     else
37       setprg16(0x8000,(DReg&7)|8);
38   }
39   else
40     setprg16(0x8000,7);
41 }
42
43 static void StateRestore(int version)
44 {
45   Sync();
46 }
47
48 static DECLFW(M188Write)
49 {
50   DReg=V;
51   Sync();
52 }
53
54 static DECLFR(testr)
55 {
56   return(3);
57 }
58
59
60 static void Power(void)
61 {
62   setchr8(0);
63   setprg8(0xc000,0xE);
64   setprg8(0xe000,0xF);
65   DReg = 0;
66   Sync();
67   SetReadHandler(0x6000,0x7FFF,testr);
68   SetReadHandler(0x8000,0xFFFF,CartBR);
69   SetWriteHandler(0x8000,0xFFFF,M188Write);
70 }
71
72
73 void Mapper188_Init(CartInfo *info)
74 {
75   info->Power=Power;
76   GameStateRestore=StateRestore;
77   AddExState(&StateRegs, ~0, 0, 0);
78 }