451ab91e |
1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | * Mupen64plus - rom.h * |
3 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * |
4 | * Copyright (C) 2008 Tillin9 * |
5 | * Copyright (C) 2002 Hacktarux * |
6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * |
11 | * * |
12 | * This program is distributed in the hope that it will be useful, * |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
15 | * GNU General Public License for more details. * |
16 | * * |
17 | * You should have received a copy of the GNU General Public License * |
18 | * along with this program; if not, write to the * |
19 | * Free Software Foundation, Inc., * |
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
21 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
22 | |
23 | #ifndef __ROM_H__ |
24 | #define __ROM_H__ |
25 | |
26 | #include "api/m64p_types.h" |
27 | #include "md5.h" |
28 | |
29 | /* ROM Loading and Saving functions */ |
30 | |
31 | m64p_error open_rom(const unsigned char* romimage, unsigned int size); |
32 | m64p_error close_rom(void); |
33 | |
34 | extern unsigned char* rom; |
35 | extern int rom_size; |
36 | |
37 | extern unsigned char isGoldeneyeRom; |
38 | |
39 | typedef struct _rom_params |
40 | { |
41 | m64p_system_type systemtype; |
42 | int vilimit; |
43 | int aidacrate; |
44 | char headername[21]; /* ROM Name as in the header, removing trailing whitespace */ |
45 | } rom_params; |
46 | |
47 | extern m64p_rom_header ROM_HEADER; |
48 | extern rom_params ROM_PARAMS; |
49 | extern m64p_rom_settings ROM_SETTINGS; |
50 | |
51 | /* Supported rom compressiontypes. */ |
52 | enum |
53 | { |
54 | UNCOMPRESSED, |
55 | ZIP_COMPRESSION, |
56 | GZIP_COMPRESSION, |
57 | BZIP2_COMPRESSION, |
58 | LZMA_COMPRESSION, |
59 | SZIP_COMPRESSION |
60 | }; |
61 | |
62 | /* Supported rom image types. */ |
63 | enum |
64 | { |
65 | Z64IMAGE, |
66 | V64IMAGE, |
67 | N64IMAGE |
68 | }; |
69 | |
70 | /* Supported CIC chips. */ |
71 | enum |
72 | { |
73 | CIC_NUS_6101, |
74 | CIC_NUS_6102, |
75 | CIC_NUS_6103, |
76 | CIC_NUS_6105, |
77 | CIC_NUS_6106 |
78 | }; |
79 | |
80 | /* Supported save types. */ |
81 | enum |
82 | { |
83 | EEPROM_4KB, |
84 | EEPROM_16KB, |
85 | SRAM, |
86 | FLASH_RAM, |
87 | CONTROLLER_PACK, |
88 | NONE |
89 | }; |
90 | |
91 | /* Rom INI database structures and functions */ |
92 | |
93 | /* The romdatabase contains the items mupen64plus indexes for each rom. These |
94 | * include the goodname (from the GoodN64 project), the current status of the rom |
95 | * in mupen, the N64 savetype used in the original cartridge (often necessary for |
96 | * booting the rom in mupen), the number of players (including netplay options), |
97 | * and whether the rom can make use of the N64's rumble feature. Md5, crc1, and |
98 | * crc2 used for rom lookup. Md5s are unique hashes of the ENTIRE rom. Crcs are not |
99 | * unique and read from the rom header, meaning corrupt crcs are also a problem. |
100 | * Crcs were widely used (mainly in the cheat system). Refmd5s allows for a smaller |
101 | * database file and need not be used outside database loading. |
102 | */ |
103 | typedef struct |
104 | { |
105 | char* goodname; |
106 | md5_byte_t md5[16]; |
107 | md5_byte_t* refmd5; |
108 | unsigned int crc1; |
109 | unsigned int crc2; |
110 | unsigned char status; /* Rom status on a scale from 0-5. */ |
111 | unsigned char savetype; |
112 | unsigned char players; /* Local players 0-4, 2/3/4 way Netplay indicated by 5/6/7. */ |
113 | unsigned char rumble; /* 0 - No, 1 - Yes boolean for rumble support. */ |
2d262872 |
114 | /*SEB*/ |
115 | signed char delay_si; /* -1 = no value, 0 = off, 1 = on */ |
116 | signed char count_per_op; /* -1 = no value, 0..3 = value */ |
451ab91e |
117 | } romdatabase_entry; |
118 | |
119 | typedef struct _romdatabase_search |
120 | { |
121 | romdatabase_entry entry; |
122 | struct _romdatabase_search* next_entry; |
123 | struct _romdatabase_search* next_crc; |
124 | struct _romdatabase_search* next_md5; |
125 | } romdatabase_search; |
126 | |
127 | typedef struct |
128 | { |
129 | int have_database; |
130 | romdatabase_search* crc_lists[256]; |
131 | romdatabase_search* md5_lists[256]; |
132 | romdatabase_search* list; |
133 | } _romdatabase; |
134 | |
135 | void romdatabase_open(void); |
136 | void romdatabase_close(void); |
137 | /* Should be used by current cheat system (isn't), when cheat system is |
138 | * migrated to md5s, will be fully depreciated. |
139 | */ |
140 | romdatabase_entry* ini_search_by_crc(unsigned int crc1, unsigned int crc2); |
141 | |
142 | #endif /* __ROM_H__ */ |
143 | |