random warning fixes
[fceu.git] / boards / lh32.c
1 /* FCE Ultra - NES/Famicom Emulator\r
2  *\r
3  * Copyright notice for this file:\r
4  *  Copyright (C) 2007 CaH4e3\r
5  *\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
10  *\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
15  *\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
19  *\r
20  * FDS Conversion\r
21  *\r
22  */\r
23 \r
24 #include "mapinc.h"\r
25 \r
26 static uint8 reg;\r
27 static uint8 *WRAM=NULL;\r
28 static uint32 WRAMSIZE;\r
29 \r
30 static SFORMAT StateRegs[]=\r
31 {\r
32   {&reg, 1, "REG"},\r
33   {0}\r
34 };\r
35 \r
36 static void Sync(void)\r
37 {\r
38   setprg8(0x6000,reg);\r
39   setprg8(0x8000,~3);\r
40   setprg8(0xa000,~2);\r
41   setprg8r(0x10,0xc000,0);\r
42   setprg8(0xe000,~0);\r
43   setchr8(0);\r
44 }\r
45 \r
46 static DECLFW(LH32Write)\r
47 {\r
48   reg=V;\r
49   Sync();\r
50 }\r
51 \r
52 static void LH32Power(void)\r
53 {\r
54   Sync();\r
55   SetReadHandler(0x6000,0xFFFF,CartBR);\r
56   SetWriteHandler(0xC000,0xDFFF,CartBW);\r
57   SetWriteHandler(0x6000,0x6000,LH32Write);\r
58 }\r
59 \r
60 static void LH32Close(void)\r
61 {\r
62   if(WRAM)\r
63     FCEU_gfree(WRAM);\r
64   WRAM=NULL;\r
65 }\r
66 \r
67 static void StateRestore(int version)\r
68 {\r
69   Sync();\r
70 }\r
71 \r
72 void LH32_Init(CartInfo *info)\r
73 {\r
74   info->Power=LH32Power;\r
75   info->Close=LH32Close;\r
76 \r
77   WRAMSIZE=8192;\r
78   WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);\r
79   SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);\r
80   AddExState(WRAM, WRAMSIZE, 0, "WRAM");\r
81 \r
82   GameStateRestore=StateRestore;\r
83   AddExState(&StateRegs, ~0, 0, 0);\r
84 }\r