merge mapper code from FCEUX
[fceu.git] / ines.h
1 /* FCE Ultra - NES/Famicom Emulator\r
2  *\r
3  * Copyright notice for this file:\r
4  *  Copyright (C) 1998 Bero\r
5  *  Copyright (C) 2002 Xodnizel\r
6  *\r
7  * This program is free software; you can redistribute it and/or modify\r
8  * it under the terms of the GNU General Public License as published by\r
9  * the Free Software Foundation; either version 2 of the License, or\r
10  * (at your option) any later version.\r
11  *\r
12  * This program is distributed in the hope that it will be useful,\r
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15  * GNU General Public License for more details.\r
16  *\r
17  * You should have received a copy of the GNU General Public License\r
18  * along with this program; if not, write to the Free Software\r
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
20  */\r
21 \r
22 #ifndef _INES_H_\r
23 #define _INES_H_\r
24 #include <stdlib.h>\r
25 #include <string.h>\r
26 #include "cart.h"\r
27 #ifdef INESPRIV\r
28 \r
29 void iNESStateRestore(int version);\r
30 extern uint32 iNESGameCRC32;\r
31 \r
32 extern uint32 VROM_size;\r
33 extern uint32 ROM_size;\r
34 \r
35 extern void (*MapStateRestore)(int version);\r
36 extern void (*MapClose)(void);\r
37 extern void (*MapperReset)(void);\r
38 \r
39 /* This order is necessary */\r
40 #define WRAM    (GameMemBlock)\r
41 #define sizeofWRAM    8192\r
42 \r
43 #define MapperExRAM   (GameMemBlock+sizeofWRAM)\r
44 #define sizeofMapperExRAM  32768\r
45 /* for the MMC5 code to work properly.  It might be fixed later... */\r
46 \r
47 #define CHRRAM  (GameMemBlock+sizeofWRAM+sizeofMapperExRAM)\r
48 #define sizeofCHRRAM 8192\r
49 \r
50 #define ExtraNTARAM   (GameMemBlock+sizeofWRAM+sizeofMapperExRAM+sizeofCHRRAM)\r
51 #define sizeofExtraNTARAM 2048\r
52 \r
53 #define PRGBankList    (ExtraNTARAM+sizeofExtraNTARAM)\r
54 \r
55 #define mapbyte1       (PRGBankList+4)\r
56 #define mapbyte2       (mapbyte1+8)\r
57 #define mapbyte3       (mapbyte2+8)\r
58 #define mapbyte4       (mapbyte3+8)\r
59 extern uint16 iNESCHRBankList[8];\r
60 extern int32 iNESIRQLatch,iNESIRQCount;\r
61 extern uint8 iNESMirroring;\r
62 extern uint8 iNESIRQa;\r
63 \r
64 #define IRQa iNESIRQa\r
65 #define Mirroring iNESMirroring\r
66 #define IRQCount iNESIRQCount\r
67 #define IRQLatch iNESIRQLatch\r
68 #define CHRBankList iNESCHRBankList\r
69 #else\r
70 #endif\r
71 \r
72 #if 0\r
73 struct TMasterRomInfo\r
74 {\r
75         uint64 md5lower;\r
76         const char* params;\r
77 };\r
78 \r
79 class TMasterRomInfoParams : public std::map<std::string,std::string> \r
80 {\r
81 public:\r
82         bool ContainsKey(const std::string& key) { return find(key) != end(); }\r
83 };\r
84 #endif\r
85 \r
86 //mbg merge 6/29/06\r
87 extern uint8 *ROM;\r
88 extern uint8 *VROM;\r
89 extern uint32 VROM_size;\r
90 extern uint32 ROM_size;\r
91 extern int iNesSave(); //bbit Edited: line added\r
92 extern int iNesSaveAs(char* name);\r
93 extern char LoadedRomFName[2048]; //bbit Edited: line added\r
94 //extern const TMasterRomInfo* MasterRomInfo;\r
95 //extern TMasterRomInfoParams MasterRomInfoParams;\r
96 \r
97 //mbg merge 7/19/06 changed to c++ decl format\r
98 struct iNES_HEADER {\r
99     char ID[4]; /*NES^Z*/\r
100     uint8 ROM_size;\r
101     uint8 VROM_size;\r
102     uint8 ROM_type;\r
103     uint8 ROM_type2;\r
104     uint8 reserve[8];\r
105 };\r
106 \r
107 extern struct iNES_HEADER head; //for mappers usage\r
108 \r
109 void VRAM_BANK1(uint32 A, uint8 V);\r
110 void VRAM_BANK4(uint32 A,uint32 V);\r
111 \r
112 void VROM_BANK1(uint32 A,uint32 V);\r
113 void VROM_BANK2(uint32 A,uint32 V);\r
114 void VROM_BANK4(uint32 A, uint32 V);\r
115 void VROM_BANK8(uint32 V);\r
116 void ROM_BANK8(uint32 A, uint32 V);\r
117 void ROM_BANK16(uint32 A, uint32 V);\r
118 void ROM_BANK32(uint32 V);\r
119 \r
120 extern uint8 vmask;\r
121 extern uint32 vmask1;\r
122 extern uint32 vmask2;\r
123 extern uint32 vmask4;\r
124 extern uint32 pmask8;\r
125 extern uint8 pmask16;\r
126 extern uint8 pmask32;\r
127 \r
128 void onemir(uint8 V);\r
129 void MIRROR_SET2(uint8 V);\r
130 void MIRROR_SET(uint8 V);\r
131 \r
132 void Mapper0_init(void);\r
133 void Mapper1_init(void);\r
134 //void Mapper2_init(void);\r
135 //void Mapper3_init(void);\r
136 void Mapper6_init(void);\r
137 //void Mapper7_init(void);\r
138 void Mapper8_init(void);\r
139 void Mapper9_init(void);\r
140 void Mapper10_init(void);\r
141 //void Mapper11_init(void);\r
142 void Mapper12_init(void);\r
143 //void Mapper13_init(void);\r
144 void Mapper14_init(void);\r
145 //void Mapper15_init(void);\r
146 //void Mapper16_init(void);\r
147 void Mapper17_init(void);\r
148 void Mapper18_init(void);\r
149 void Mapper19_init(void);\r
150 void Mapper20_init(void);\r
151 void Mapper21_init(void);\r
152 void Mapper22_init(void);\r
153 //void Mapper23_init(void);\r
154 void Mapper24_init(void);\r
155 void Mapper25_init(void);\r
156 void Mapper26_init(void);\r
157 void Mapper27_init(void);\r
158 void Mapper28_init(void);\r
159 void Mapper29_init(void);\r
160 void Mapper30_init(void);\r
161 void Mapper31_init(void);\r
162 void Mapper32_init(void);\r
163 void Mapper33_init(void);\r
164 void Mapper34_init(void);\r
165 void Mapper35_init(void);\r
166 void Mapper36_init(void);\r
167 //void Mapper37_init(void);\r
168 //void Mapper38_init(void);\r
169 //void Mapper39_init(void);\r
170 void Mapper40_init(void);\r
171 void Mapper41_init(void);\r
172 void Mapper42_init(void);\r
173 //void Mapper43_init(void);\r
174 void Mapper44_init(void);\r
175 void Mapper45_init(void);\r
176 void Mapper46_init(void);\r
177 void Mapper47_init(void);\r
178 void Mapper48_init(void);\r
179 void Mapper49_init(void);\r
180 void Mapper50_init(void);\r
181 void Mapper51_init(void);\r
182 void Mapper53_init(void);\r
183 void Mapper54_init(void);\r
184 void Mapper55_init(void);\r
185 void Mapper56_init(void);\r
186 void Mapper59_init(void);\r
187 void Mapper60_init(void);\r
188 void Mapper61_init(void);\r
189 void Mapper62_init(void);\r
190 void Mapper63_init(void);\r
191 void Mapper64_init(void);\r
192 void Mapper65_init(void);\r
193 //void Mapper66_init(void);\r
194 void Mapper67_init(void);\r
195 //void Mapper68_init(void);\r
196 void Mapper69_init(void);\r
197 //void Mapper70_init(void);\r
198 void Mapper71_init(void);\r
199 void Mapper72_init(void);\r
200 void Mapper73_init(void);\r
201 void Mapper74_init(void);\r
202 void Mapper75_init(void);\r
203 void Mapper76_init(void);\r
204 void Mapper77_init(void);\r
205 //void Mapper78_init(void);\r
206 void Mapper79_init(void);\r
207 void Mapper80_init(void);\r
208 void Mapper81_init(void);\r
209 void Mapper82_init(void);\r
210 void Mapper83_init(void);\r
211 void Mapper84_init(void);\r
212 void Mapper85_init(void);\r
213 void Mapper86_init(void);\r
214 //void Mapper87_init(void);\r
215 void Mapper88_init(void);\r
216 void Mapper89_init(void);\r
217 void Mapper91_init(void);\r
218 void Mapper92_init(void);\r
219 //void Mapper93_init(void);\r
220 //void Mapper94_init(void);\r
221 void Mapper96_init(void);\r
222 void Mapper97_init(void);\r
223 void Mapper98_init(void);\r
224 void Mapper99_init(void);\r
225 void Mapper100_init(void);\r
226 //void Mapper101_init(void);\r
227 //void Mapper103_init(void);\r
228 void Mapper104_init(void);\r
229 //void Mapper106_init(void);\r
230 //void Mapper107_init(void);\r
231 //void Mapper108_init(void);\r
232 void Mapper109_init(void);\r
233 void Mapper110_init(void);\r
234 void Mapper111_init(void);\r
235 //void Mapper113_init(void);\r
236 void Mapper115_init(void);\r
237 void Mapper116_init(void);\r
238 //void Mapper117_init(void);\r
239 //void Mapper120_init(void);\r
240 //void Mapper121_init(void);\r
241 void Mapper122_init(void);\r
242 void Mapper123_init(void);\r
243 void Mapper124_init(void);\r
244 void Mapper126_init(void);\r
245 void Mapper127_init(void);\r
246 void Mapper128_init(void);\r
247 void Mapper129_init(void);\r
248 void Mapper130_init(void);\r
249 void Mapper131_init(void);\r
250 void Mapper132_init(void);\r
251 //void Mapper134_init(void);\r
252 void Mapper135_init(void);\r
253 void Mapper136_init(void);\r
254 void Mapper137_init(void);\r
255 void Mapper139_init(void);\r
256 //void Mapper140_init(void);\r
257 void Mapper141_init(void);\r
258 //void Mapper142_init(void);\r
259 void Mapper143_init(void);\r
260 //void Mapper144_init(void);\r
261 void Mapper150_init(void);\r
262 void Mapper151_init(void);\r
263 //void Mapper152_init(void);\r
264 //void Mapper153_init(void);\r
265 void Mapper154_init(void);\r
266 void Mapper157_init(void);\r
267 //void Mapper158_init(void);\r
268 void Mapper159_init(void);\r
269 void Mapper160_init(void);\r
270 void Mapper161_init(void);\r
271 void Mapper162_init(void);\r
272 void Mapper166_init(void);\r
273 void Mapper167_init(void);\r
274 void Mapper168_init(void);\r
275 //void Mapper169_init(void);\r
276 void Mapper170_init(void);\r
277 //void Mapper171_init(void);\r
278 //void Mapper172_init(void);\r
279 //void Mapper173_init(void);\r
280 void Mapper174_init(void);\r
281 void Mapper175_init(void);\r
282 void Mapper176_init(void);\r
283 //void Mapper177_init(void);\r
284 //void Mapper178_init(void);\r
285 //void Mapper179_init(void);\r
286 //void Mapper180_init(void);\r
287 //void Mapper181_init(void);\r
288 //void Mapper184_init(void);\r
289 //void Mapper185_init(void);\r
290 //void Mapper189_init(void);\r
291 //void Mapper192_init(void);\r
292 void Mapper193_init(void);\r
293 //void Mapper194_init(void);\r
294 //void Mapper195_init(void);\r
295 //void Mapper196_init(void);\r
296 //void Mapper197_init(void);\r
297 //void Mapper198_init(void);\r
298 void Mapper199_init(void);\r
299 //void Mapper200_init(void);\r
300 void Mapper201_init(void);\r
301 void Mapper202_init(void);\r
302 void Mapper203_init(void);\r
303 void Mapper204_init(void);\r
304 void Mapper207_init(void);\r
305 //void Mapper211_init(void);\r
306 void Mapper212_init(void);\r
307 void Mapper213_init(void);\r
308 void Mapper214_init(void);\r
309 //void Mapper218_init(void);\r
310 void Mapper219_init(void);\r
311 //void Mapper220_init(void);\r
312 void Mapper221_init(void);\r
313 //void Mapper222_init(void);\r
314 void Mapper223_init(void);\r
315 void Mapper224_init(void);\r
316 void Mapper225_init(void);\r
317 //void Mapper226_init(void);\r
318 void Mapper227_init(void);\r
319 void Mapper228_init(void);\r
320 void Mapper229_init(void);\r
321 void Mapper230_init(void);\r
322 void Mapper231_init(void);\r
323 void Mapper232_init(void);\r
324 void Mapper233_init(void);\r
325 void Mapper234_init(void);\r
326 //void Mapper235_init(void);\r
327 void Mapper236_init(void);\r
328 void Mapper237_init(void);\r
329 void Mapper238_init(void);\r
330 void Mapper239_init(void);\r
331 void Mapper240_init(void);\r
332 void Mapper241_init(void);\r
333 void Mapper242_init(void);\r
334 void Mapper244_init(void);\r
335 void Mapper245_init(void);\r
336 void Mapper246_init(void);\r
337 void Mapper247_init(void);\r
338 void Mapper249_init(void);\r
339 void Mapper251_init(void);\r
340 void Mapper252_init(void);\r
341 //void Mapper253_init(void);\r
342 void Mapper255_init(void);\r
343 \r
344 void NSFVRC6_Init(void);\r
345 void NSFMMC5_Init(void);\r
346 void NSFAY_Init(void);\r
347 void NSFN106_Init(void);\r
348 void NSFVRC7_Init(void);\r
349 void Mapper19_ESI(void);\r
350 \r
351 void Mapper1_Init(CartInfo *);\r
352 void Mapper4_Init(CartInfo *);\r
353 void Mapper5_Init(CartInfo *);\r
354 void Mapper11_Init(CartInfo *);\r
355 void Mapper12_Init(CartInfo *);\r
356 void Mapper15_Init(CartInfo *);\r
357 void Mapper16_Init(CartInfo *);\r
358 void Mapper19_Init(CartInfo *);\r
359 void Mapper23_Init(CartInfo *);\r
360 void Mapper36_Init(CartInfo *);\r
361 void Mapper37_Init(CartInfo *);\r
362 void Mapper38_Init(CartInfo *);\r
363 void Mapper43_Init(CartInfo *);\r
364 void Mapper44_Init(CartInfo *);\r
365 void Mapper45_Init(CartInfo *);\r
366 void Mapper47_Init(CartInfo *);\r
367 void Mapper49_Init(CartInfo *);\r
368 void Mapper52_Init(CartInfo *);\r
369 void Mapper57_Init(CartInfo *);\r
370 //void Mapper58_Init(CartInfo *);\r
371 void Mapper68_Init(CartInfo *);\r
372 void Mapper70_Init(CartInfo *);\r
373 void Mapper74_Init(CartInfo *);\r
374 void Mapper78_Init(CartInfo *);\r
375 void Mapper87_Init(CartInfo *);\r
376 void Mapper88_Init(CartInfo *);\r
377 void Mapper90_Init(CartInfo *);\r
378 void Mapper93_Init(CartInfo *);\r
379 void Mapper94_Init(CartInfo *);\r
380 void Mapper95_Init(CartInfo *);\r
381 void Mapper101_Init(CartInfo *);\r
382 void Mapper103_Init(CartInfo *);\r
383 void Mapper105_Init(CartInfo *);\r
384 void Mapper106_Init(CartInfo *);\r
385 void Mapper107_Init(CartInfo *);\r
386 void Mapper108_Init(CartInfo *);\r
387 void Mapper112_Init(CartInfo *);\r
388 void Mapper113_Init(CartInfo *);\r
389 void Mapper114_Init(CartInfo *);\r
390 void Mapper115_Init(CartInfo *);\r
391 void Mapper116_Init(CartInfo *);\r
392 void Mapper117_Init(CartInfo *);\r
393 void Mapper118_Init(CartInfo *);\r
394 void Mapper119_Init(CartInfo *);\r
395 void Mapper120_Init(CartInfo *);\r
396 void Mapper121_Init(CartInfo *);\r
397 void Mapper125_Init(CartInfo *);\r
398 void Mapper134_Init(CartInfo *);\r
399 void Mapper140_Init(CartInfo *);\r
400 void Mapper144_Init(CartInfo *);\r
401 void Mapper152_Init(CartInfo *);\r
402 void Mapper153_Init(CartInfo *);\r
403 void Mapper154_Init(CartInfo *);\r
404 void Mapper155_Init(CartInfo *);\r
405 void Mapper156_Init(CartInfo *);\r
406 void Mapper159_Init(CartInfo *);\r
407 void Mapper163_Init(CartInfo *);\r
408 void Mapper164_Init(CartInfo *);\r
409 void Mapper165_Init(CartInfo *);\r
410 //void Mapper169_Init(CartInfo *);\r
411 void Mapper171_Init(CartInfo *);\r
412 void Mapper172_Init(CartInfo *);\r
413 void Mapper173_Init(CartInfo *);\r
414 void Mapper175_Init(CartInfo *);\r
415 void Mapper176_Init(CartInfo *);\r
416 void Mapper177_Init(CartInfo *);\r
417 void Mapper178_Init(CartInfo *);\r
418 void Mapper180_Init(CartInfo *);\r
419 void Mapper181_Init(CartInfo *);\r
420 //void Mapper182_Init(CartInfo *);\r
421 void Mapper183_Init(CartInfo *);\r
422 void Mapper184_Init(CartInfo *);\r
423 void Mapper185_Init(CartInfo *);\r
424 void Mapper186_Init(CartInfo *);\r
425 void Mapper187_Init(CartInfo *);\r
426 void Mapper188_Init(CartInfo *);\r
427 void Mapper189_Init(CartInfo *);\r
428 void Mapper191_Init(CartInfo *);\r
429 void Mapper192_Init(CartInfo *);\r
430 void Mapper194_Init(CartInfo *);\r
431 void Mapper195_Init(CartInfo *);\r
432 void Mapper196_Init(CartInfo *);\r
433 void Mapper197_Init(CartInfo *);\r
434 void Mapper198_Init(CartInfo *);\r
435 void Mapper199_Init(CartInfo *);\r
436 void Mapper200_Init(CartInfo *);\r
437 void Mapper205_Init(CartInfo *);\r
438 void Mapper208_Init(CartInfo *);\r
439 void Mapper209_Init(CartInfo *);\r
440 void Mapper210_Init(CartInfo *);\r
441 void Mapper211_Init(CartInfo *);\r
442 //void Mapper215_Init(CartInfo *);\r
443 void Mapper216_Init(CartInfo *);\r
444 //void Mapper217_Init(CartInfo *);\r
445 void Mapper220_Init(CartInfo *);\r
446 void Mapper222_Init(CartInfo *);\r
447 void Mapper226_Init(CartInfo *);\r
448 void Mapper235_Init(CartInfo *);\r
449 void Mapper236_Init(CartInfo *);\r
450 void Mapper237_Init(CartInfo *);\r
451 void Mapper240_Init(CartInfo *);\r
452 void Mapper245_Init(CartInfo *);\r
453 void Mapper249_Init(CartInfo *);\r
454 void Mapper250_Init(CartInfo *);\r
455 void Mapper253_Init(CartInfo *);\r
456 void Mapper254_Init(CartInfo *);\r
457 \r
458 #endif\r