43725da7 |
1 | /* FCE Ultra - NES/Famicom Emulator\r |
2 | *\r |
3 | * Copyright notice for this file:\r |
4 | * Copyright (C) 2011 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 | * Just another pirate cart with pirate mapper, instead of original MMC1\r |
21 | * Kaiser Highway Star\r |
22 | *\r |
23 | */\r |
24 | \r |
25 | #include "mapinc.h"\r |
26 | \r |
27 | static uint8 reg, mirr;\r |
28 | \r |
29 | static SFORMAT StateRegs[]=\r |
30 | {\r |
31 | {®, 1, "REGS"},\r |
32 | {&mirr, 1, "MIRR"},\r |
33 | {0}\r |
34 | };\r |
35 | \r |
36 | static void Sync(void)\r |
37 | {\r |
38 | setprg16(0x8000,reg);\r |
39 | setprg16(0xc000,~0);\r |
40 | setmirror(mirr);\r |
41 | setchr8(0);\r |
42 | }\r |
43 | \r |
44 | static DECLFW(UNLKS7013BLoWrite)\r |
45 | {\r |
46 | reg = V;\r |
47 | Sync();\r |
48 | }\r |
49 | \r |
50 | static DECLFW(UNLKS7013BHiWrite)\r |
51 | {\r |
52 | mirr = (V & 1) ^ 1;\r |
53 | Sync();\r |
54 | }\r |
55 | \r |
56 | static void UNLKS7013BPower(void)\r |
57 | {\r |
58 | reg = 0;\r |
59 | mirr = 0;\r |
60 | Sync();\r |
61 | SetWriteHandler(0x6000,0x7FFF,UNLKS7013BLoWrite);\r |
62 | SetReadHandler(0x8000,0xFFFF,CartBR);\r |
63 | SetWriteHandler(0x8000,0xFFFF,UNLKS7013BHiWrite);\r |
64 | }\r |
65 | \r |
66 | static void UNLKS7013BReset(void)\r |
67 | {\r |
68 | reg = 0;\r |
69 | Sync();\r |
70 | }\r |
71 | \r |
72 | static void StateRestore(int version)\r |
73 | {\r |
74 | Sync();\r |
75 | }\r |
76 | \r |
77 | void UNLKS7013B_Init(CartInfo *info)\r |
78 | {\r |
79 | info->Power=UNLKS7013BPower;\r |
80 | info->Reset=UNLKS7013BReset;\r |
81 | \r |
82 | GameStateRestore=StateRestore;\r |
83 | AddExState(&StateRegs, ~0, 0, 0);\r |
84 | }\r |