merge mappers from FCEU-mm
[fceu.git] / boards / lh32.c
CommitLineData
386f5371 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
43725da7 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
19 *\r
20 * FDS Conversion\r
21 *\r
386f5371 22 */\r
23\r
24#include "mapinc.h"\r
25\r
43725da7 26static uint8 reg;\r
386f5371 27static uint8 *WRAM=NULL;\r
28static uint32 WRAMSIZE;\r
29\r
30static SFORMAT StateRegs[]=\r
31{\r
43725da7 32 {&reg, 1, "REG"},\r
386f5371 33 {0}\r
34};\r
35\r
36static void Sync(void)\r
37{\r
43725da7 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
386f5371 43 setchr8(0);\r
386f5371 44}\r
45\r
43725da7 46static DECLFW(LH32Write)\r
386f5371 47{\r
43725da7 48 reg=V;\r
386f5371 49 Sync();\r
50}\r
51\r
43725da7 52static void LH32Power(void)\r
386f5371 53{\r
386f5371 54 Sync();\r
43725da7 55 SetReadHandler(0x6000,0xFFFF,CartBR);\r
56 SetWriteHandler(0xC000,0xDFFF,CartBW);\r
57 SetWriteHandler(0x6000,0x6000,LH32Write);\r
386f5371 58}\r
59\r
43725da7 60static void LH32Close(void)\r
386f5371 61{\r
62 if(WRAM)\r
63 FCEU_gfree(WRAM);\r
64 WRAM=NULL;\r
65}\r
66\r
67static void StateRestore(int version)\r
68{\r
69 Sync();\r
70}\r
71\r
43725da7 72void LH32_Init(CartInfo *info)\r
386f5371 73{\r
43725da7 74 info->Power=LH32Power;\r
75 info->Close=LH32Close;\r
386f5371 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
386f5371 81\r
43725da7 82 GameStateRestore=StateRestore;\r
386f5371 83 AddExState(&StateRegs, ~0, 0, 0);\r
84}\r