386f5371 |
1 | /* FCE Ultra - NES/Famicom Emulator\r |
2 | *\r |
3 | * Copyright notice for this file:\r |
4 | * Copyright (C) 2005 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 |
386f5371 |
19 | *\r |
20 | */\r |
21 | \r |
22 | #include "mapinc.h"\r |
23 | \r |
24 | static uint8 *DummyCHR=NULL;\r |
25 | static uint8 datareg;\r |
26 | static void(*Sync)(void);\r |
27 | \r |
28 | \r |
29 | static SFORMAT StateRegs[]=\r |
30 | {\r |
31 | {&datareg, 1, "DREG"},\r |
32 | {0}\r |
33 | };\r |
34 | \r |
35 | // on off\r |
36 | //1 0x0F, 0xF0 - Bird Week\r |
37 | //2 0x33, 0x00 - B-Wings\r |
38 | //3 0x11, 0x00 - Mighty Bomb Jack\r |
39 | //4 0x22, 0x20 - Sansuu 1 Nen, Sansuu 2 Nen\r |
40 | //5 0xFF, 0x00 - Sansuu 3 Nen\r |
41 | //6 0x21, 0x13 - Spy vs Spy\r |
42 | //7 0x20, 0x21 - Seicross\r |
43 | \r |
44 | static void Sync185(void)\r |
45 | {\r |
46 | // little dirty eh? ;_)\r |
47 | if((datareg&3)&&(datareg!=0x13)) // 1, 2, 3, 4, 5, 6\r |
48 | setchr8(0);\r |
49 | else\r |
50 | setchr8r(0x10,0);\r |
51 | }\r |
52 | \r |
53 | static void Sync181(void)\r |
54 | {\r |
55 | if(!(datareg&1)) // 7\r |
56 | setchr8(0);\r |
57 | else\r |
58 | setchr8r(0x10,0);\r |
59 | }\r |
60 | \r |
61 | static DECLFW(MWrite)\r |
62 | {\r |
63 | datareg=V;\r |
64 | Sync();\r |
65 | }\r |
66 | \r |
67 | static void MPower(void)\r |
68 | {\r |
69 | datareg=0;\r |
70 | Sync();\r |
71 | setprg16(0x8000,0);\r |
72 | setprg16(0xC000,~0);\r |
73 | SetWriteHandler(0x8000,0xFFFF,MWrite);\r |
74 | SetReadHandler(0x8000,0xFFFF,CartBR);\r |
75 | }\r |
76 | \r |
77 | static void MClose(void)\r |
78 | {\r |
79 | if(DummyCHR)\r |
80 | FCEU_gfree(DummyCHR);\r |
81 | DummyCHR=NULL;\r |
82 | }\r |
83 | \r |
84 | static void MRestore(int version)\r |
85 | {\r |
86 | Sync();\r |
87 | }\r |
88 | \r |
89 | void Mapper185_Init(CartInfo *info)\r |
90 | {\r |
386f5371 |
91 | Sync=Sync185;\r |
92 | info->Power=MPower;\r |
93 | info->Close=MClose;\r |
94 | GameStateRestore=MRestore;\r |
95 | DummyCHR=(uint8*)FCEU_gmalloc(8192);\r |
43725da7 |
96 | int x;\r |
386f5371 |
97 | for(x=0;x<8192;x++)\r |
98 | DummyCHR[x]=0xff;\r |
99 | SetupCartCHRMapping(0x10,DummyCHR,8192,0);\r |
100 | AddExState(StateRegs, ~0, 0, 0);\r |
101 | }\r |
102 | \r |
103 | void Mapper181_Init(CartInfo *info)\r |
104 | {\r |
386f5371 |
105 | Sync=Sync181;\r |
106 | info->Power=MPower;\r |
107 | info->Close=MClose;\r |
108 | GameStateRestore=MRestore;\r |
109 | DummyCHR=(uint8*)FCEU_gmalloc(8192);\r |
43725da7 |
110 | int x;\r |
386f5371 |
111 | for(x=0;x<8192;x++)\r |
112 | DummyCHR[x]=0xff;\r |
113 | SetupCartCHRMapping(0x10,DummyCHR,8192,0);\r |
114 | AddExState(StateRegs, ~0, 0, 0);\r |
115 | }\r |