1 | /*****************************************************************************\ |
2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. |
3 | This file is licensed under the Snes9x License. |
4 | For further information, consult the LICENSE file in the root directory. |
5 | \*****************************************************************************/ |
6 | |
7 | #ifndef _MEMMAP_H_ |
8 | #define _MEMMAP_H_ |
9 | |
10 | #define MEMMAP_BLOCK_SIZE (0x1000) |
11 | #define MEMMAP_NUM_BLOCKS (0x1000000 / MEMMAP_BLOCK_SIZE) |
12 | #define MEMMAP_SHIFT (12) |
13 | #define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1) |
14 | |
15 | struct CMemory |
16 | { |
17 | enum |
18 | { MAX_ROM_SIZE = 0x800000 }; |
19 | |
20 | enum file_formats |
21 | { FILE_ZIP, FILE_JMA, FILE_DEFAULT }; |
22 | |
23 | enum |
24 | { NOPE, YEAH, BIGFIRST, SMALLFIRST }; |
25 | |
26 | enum |
27 | { MAP_TYPE_I_O, MAP_TYPE_ROM, MAP_TYPE_RAM }; |
28 | |
29 | enum |
30 | { |
31 | MAP_CPU, |
32 | MAP_PPU, |
33 | MAP_LOROM_SRAM, |
34 | MAP_LOROM_SRAM_B, |
35 | MAP_HIROM_SRAM, |
36 | MAP_DSP, |
37 | MAP_SA1RAM, |
38 | MAP_BWRAM, |
39 | MAP_BWRAM_BITMAP, |
40 | MAP_BWRAM_BITMAP2, |
41 | MAP_SPC7110_ROM, |
42 | MAP_SPC7110_DRAM, |
43 | MAP_RONLY_SRAM, |
44 | MAP_C4, |
45 | MAP_OBC_RAM, |
46 | MAP_SETA_DSP, |
47 | MAP_SETA_RISC, |
48 | MAP_BSX, |
49 | MAP_NONE, |
50 | MAP_LAST |
51 | }; |
52 | |
53 | uint8 [32]; |
54 | int32 ; |
55 | |
56 | uint8 *RAM; |
57 | uint8 *ROM; |
58 | uint8 *SRAM; |
59 | uint8 *VRAM; |
60 | uint8 *FillRAM; |
61 | uint8 *BWRAM; |
62 | uint8 *C4RAM; |
63 | uint8 *OBC1RAM; |
64 | uint8 *BSRAM; |
65 | uint8 *BIOSROM; |
66 | |
67 | uint8 *Map[MEMMAP_NUM_BLOCKS]; |
68 | uint8 *WriteMap[MEMMAP_NUM_BLOCKS]; |
69 | uint8 BlockIsRAM[MEMMAP_NUM_BLOCKS]; |
70 | uint8 BlockIsROM[MEMMAP_NUM_BLOCKS]; |
71 | uint8 ExtendedFormat; |
72 | |
73 | char ROMFilename[PATH_MAX + 1]; |
74 | char ROMName[ROM_NAME_LEN]; |
75 | char RawROMName[ROM_NAME_LEN]; |
76 | char ROMId[5]; |
77 | int32 CompanyId; |
78 | uint8 ROMRegion; |
79 | uint8 ROMSpeed; |
80 | uint8 ROMType; |
81 | uint8 ROMSize; |
82 | uint32 ROMChecksum; |
83 | uint32 ROMComplementChecksum; |
84 | uint32 ROMCRC32; |
85 | unsigned char ROMSHA256[32]; |
86 | int32 ROMFramesPerSecond; |
87 | |
88 | bool8 HiROM; |
89 | bool8 LoROM; |
90 | uint8 SRAMSize; |
91 | uint32 SRAMMask; |
92 | uint32 CalculatedSize; |
93 | uint32 CalculatedChecksum; |
94 | |
95 | // ports can assign this to perform some custom action upon loading a ROM (such as adjusting controls) |
96 | void (*PostRomInitFunc) (void); |
97 | |
98 | bool8 Init (void); |
99 | void Deinit (void); |
100 | |
101 | int ScoreHiROM (bool8, int32 romoff = 0); |
102 | int ScoreLoROM (bool8, int32 romoff = 0); |
103 | int First512BytesCountZeroes() const; |
104 | uint32 (uint32, uint8 *); |
105 | uint32 FileLoader (uint8 *, const char *, uint32); |
106 | uint32 MemLoader (uint8 *, const char*, uint32); |
107 | bool8 LoadROMMem (const uint8 *, uint32); |
108 | bool8 LoadROM (const char *); |
109 | bool8 LoadROMInt (int32); |
110 | bool8 LoadMultiCartMem (const uint8 *, uint32, const uint8 *, uint32, const uint8 *, uint32); |
111 | bool8 LoadMultiCart (const char *, const char *); |
112 | bool8 LoadMultiCartInt (); |
113 | bool8 LoadSufamiTurbo (); |
114 | bool8 LoadBSCart (); |
115 | bool8 LoadGNEXT (); |
116 | bool8 LoadSRAM (const char *); |
117 | bool8 SaveSRAM (const char *); |
118 | void ClearSRAM (bool8 onlyNonSavedSRAM = 0); |
119 | bool8 LoadSRTC (void); |
120 | bool8 SaveSRTC (void); |
121 | bool8 SaveMPAK (const char *); |
122 | |
123 | char * Safe (const char *); |
124 | char * SafeANK (const char *); |
125 | void (uint8 *); |
126 | void InitROM (void); |
127 | |
128 | uint32 map_mirror (uint32, uint32); |
129 | void map_lorom (uint32, uint32, uint32, uint32, uint32); |
130 | void map_hirom (uint32, uint32, uint32, uint32, uint32); |
131 | void map_lorom_offset (uint32, uint32, uint32, uint32, uint32, uint32); |
132 | void map_hirom_offset (uint32, uint32, uint32, uint32, uint32, uint32); |
133 | void map_space (uint32, uint32, uint32, uint32, uint8 *); |
134 | void map_index (uint32, uint32, uint32, uint32, int, int); |
135 | void map_System (void); |
136 | void map_WRAM (void); |
137 | void map_LoROMSRAM (void); |
138 | void map_HiROMSRAM (void); |
139 | void map_DSP (void); |
140 | void map_C4 (void); |
141 | void map_OBC1 (void); |
142 | void map_SetaRISC (void); |
143 | void map_SetaDSP (void); |
144 | void map_WriteProtectROM (void); |
145 | void Map_Initialize (void); |
146 | void Map_LoROMMap (void); |
147 | void Map_NoMAD1LoROMMap (void); |
148 | void Map_JumboLoROMMap (void); |
149 | void Map_ROM24MBSLoROMMap (void); |
150 | void Map_SRAM512KLoROMMap (void); |
151 | void Map_SufamiTurboLoROMMap (void); |
152 | void Map_SufamiTurboPseudoLoROMMap (void); |
153 | void Map_SuperFXLoROMMap (void); |
154 | void Map_SetaDSPLoROMMap (void); |
155 | void Map_SDD1LoROMMap (void); |
156 | void Map_SA1LoROMMap (void); |
157 | void Map_BSSA1LoROMMap (void); |
158 | void Map_HiROMMap (void); |
159 | void Map_ExtendedHiROMMap (void); |
160 | void Map_SPC7110HiROMMap (void); |
161 | void Map_BSCartLoROMMap(uint8); |
162 | void Map_BSCartHiROMMap(void); |
163 | |
164 | uint16 checksum_calc_sum (uint8 *, uint32); |
165 | uint16 checksum_mirror_sum (uint8 *, uint32 &, uint32 mask = 0x800000); |
166 | void Checksum_Calculate (void); |
167 | |
168 | bool8 match_na (const char *); |
169 | bool8 match_nn (const char *); |
170 | bool8 match_nc (const char *); |
171 | bool8 match_id (const char *); |
172 | void ApplyROMFixes (void); |
173 | void CheckForAnyPatch (const char *, bool8, int32 &); |
174 | |
175 | void MakeRomInfoText (char *); |
176 | |
177 | const char * MapType (void); |
178 | const char * StaticRAMSize (void); |
179 | const char * Size (void); |
180 | const char * Revision (void); |
181 | const char * KartContents (void); |
182 | const char * Country (void); |
183 | const char * PublishingCompany (void); |
184 | }; |
185 | |
186 | struct SMulti |
187 | { |
188 | int cartType; |
189 | int32 cartSizeA, cartSizeB; |
190 | int32 sramSizeA, sramSizeB; |
191 | uint32 sramMaskA, sramMaskB; |
192 | uint32 cartOffsetA, cartOffsetB; |
193 | uint8 *sramA, *sramB; |
194 | char fileNameA[PATH_MAX + 1], fileNameB[PATH_MAX + 1]; |
195 | }; |
196 | |
197 | extern CMemory Memory; |
198 | extern SMulti Multi; |
199 | |
200 | void S9xAutoSaveSRAM (void); |
201 | bool8 LoadZip(const char *, uint32 *, uint8 *); |
202 | |
203 | enum s9xwrap_t |
204 | { |
205 | WRAP_NONE, |
206 | WRAP_BANK, |
207 | WRAP_PAGE |
208 | }; |
209 | |
210 | enum s9xwriteorder_t |
211 | { |
212 | WRITE_01, |
213 | WRITE_10 |
214 | }; |
215 | |
216 | #include "getset.h" |
217 | |
218 | #endif |
219 | |