| ... | ... |
@@ -175,8 +175,7 @@ |
| 175 | 175 |
Nintendo Co., Limited and its subsidiary companies. |
| 176 | 176 |
***********************************************************************************/ |
| 177 | 177 |
|
| 178 |
-#ifndef _MEMMAP_H_ |
|
| 179 |
-#define _MEMMAP_H_ |
|
| 178 |
+#pragma once |
|
| 180 | 179 |
|
| 181 | 180 |
#include <memory> |
| 182 | 181 |
#include <cstdint> |
| ... | ... |
@@ -296,5 +295,3 @@ enum s9xwriteorder_t |
| 296 | 295 |
}; |
| 297 | 296 |
|
| 298 | 297 |
#include "getset.h" |
| 299 |
- |
|
| 300 |
-#endif |
| ... | ... |
@@ -175,192 +175,112 @@ |
| 175 | 175 |
Nintendo Co., Limited and its subsidiary companies. |
| 176 | 176 |
***********************************************************************************/ |
| 177 | 177 |
|
| 178 |
- |
|
| 179 | 178 |
#ifndef _MEMMAP_H_ |
| 180 | 179 |
#define _MEMMAP_H_ |
| 181 | 180 |
|
| 182 |
-#define MEMMAP_BLOCK_SIZE (0x1000) |
|
| 183 |
-#define MEMMAP_NUM_BLOCKS (0x1000000 / MEMMAP_BLOCK_SIZE) |
|
| 184 |
-#define MEMMAP_SHIFT (12) |
|
| 185 |
-#define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1) |
|
| 181 |
+#include <memory> |
|
| 182 |
+#include <cstdint> |
|
| 183 |
+ |
|
| 184 |
+const int32_t MEMMAP_BLOCK_SIZE = 0x1000; |
|
| 185 |
+const size_t MEMMAP_NUM_BLOCKS = 0x1000000 / MEMMAP_BLOCK_SIZE; |
|
| 186 |
+const uint32_t MEMMAP_SHIFT = 12; |
|
| 187 |
+const uint32_t MEMMAP_MASK = MEMMAP_BLOCK_SIZE - 1; |
|
| 186 | 188 |
|
| 187 | 189 |
struct CMemory |
| 188 | 190 |
{
|
| 189 |
- enum |
|
| 190 |
- { MAX_ROM_SIZE = 0x800000 };
|
|
| 191 |
- |
|
| 192 |
- enum file_formats |
|
| 193 |
- { FILE_ZIP, FILE_JMA, FILE_DEFAULT };
|
|
| 191 |
+ enum { MAX_ROM_SIZE = 0x800000 };
|
|
| 194 | 192 |
|
| 195 | 193 |
enum |
| 196 |
- { NOPE, YEAH, BIGFIRST, SMALLFIRST };
|
|
| 194 |
+ {
|
|
| 195 |
+ NOPE, |
|
| 196 |
+ YEAH, |
|
| 197 |
+ BIGFIRST, |
|
| 198 |
+ SMALLFIRST |
|
| 199 |
+ }; |
|
| 197 | 200 |
|
| 198 | 201 |
enum |
| 199 |
- { MAP_TYPE_I_O, MAP_TYPE_ROM, MAP_TYPE_RAM };
|
|
| 202 |
+ {
|
|
| 203 |
+ MAP_TYPE_I_O, |
|
| 204 |
+ MAP_TYPE_RAM |
|
| 205 |
+ }; |
|
| 200 | 206 |
|
| 201 | 207 |
enum |
| 202 | 208 |
{
|
| 203 | 209 |
MAP_CPU, |
| 204 | 210 |
MAP_PPU, |
| 205 | 211 |
MAP_LOROM_SRAM, |
| 206 |
- MAP_LOROM_SRAM_B, |
|
| 207 | 212 |
MAP_HIROM_SRAM, |
| 208 |
- MAP_DSP, |
|
| 209 | 213 |
MAP_SA1RAM, |
| 210 |
- MAP_BWRAM, |
|
| 211 |
- MAP_BWRAM_BITMAP, |
|
| 212 |
- MAP_BWRAM_BITMAP2, |
|
| 213 |
- MAP_SPC7110_ROM, |
|
| 214 |
- MAP_SPC7110_DRAM, |
|
| 215 | 214 |
MAP_RONLY_SRAM, |
| 216 |
- MAP_C4, |
|
| 217 |
- MAP_OBC_RAM, |
|
| 218 |
- MAP_SETA_DSP, |
|
| 219 |
- MAP_SETA_RISC, |
|
| 220 |
- MAP_BSX, |
|
| 221 | 215 |
MAP_NONE, |
| 222 | 216 |
MAP_LAST |
| 223 | 217 |
}; |
| 224 | 218 |
|
| 225 |
- uint8_t NSRTHeader[32]; |
|
| 226 |
- int32_t HeaderCount; |
|
| 227 |
- |
|
| 228 |
- uint8_t *RAM; |
|
| 229 |
- uint8_t *ROM; |
|
| 230 |
- uint8_t *SRAM; |
|
| 231 |
- uint8_t *VRAM; |
|
| 232 |
- uint8_t *FillRAM; |
|
| 233 |
- uint8_t *BWRAM; |
|
| 234 |
- uint8_t *C4RAM; |
|
| 235 |
- uint8_t *OBC1RAM; |
|
| 236 |
- uint8_t *BSRAM; |
|
| 237 |
- uint8_t *BIOSROM; |
|
| 238 |
- |
|
| 239 |
- uint8_t *Map[MEMMAP_NUM_BLOCKS]; |
|
| 240 |
- uint8_t *WriteMap[MEMMAP_NUM_BLOCKS]; |
|
| 241 |
- uint8_t BlockIsRAM[MEMMAP_NUM_BLOCKS]; |
|
| 242 |
- uint8_t BlockIsROM[MEMMAP_NUM_BLOCKS]; |
|
| 243 |
- uint8_t ExtendedFormat; |
|
| 244 |
- |
|
| 245 |
- char ROMFilename[PATH_MAX + 1]; |
|
| 246 |
- char ROMName[ROM_NAME_LEN]; |
|
| 247 |
- char RawROMName[ROM_NAME_LEN]; |
|
| 248 |
- char ROMId[5]; |
|
| 249 |
- int32_t CompanyId; |
|
| 250 |
- uint8_t ROMRegion; |
|
| 251 |
- uint8_t ROMSpeed; |
|
| 252 |
- uint8_t ROMType; |
|
| 253 |
- uint8_t ROMSize; |
|
| 254 |
- uint32_t ROMChecksum; |
|
| 255 |
- uint32_t ROMComplementChecksum; |
|
| 256 |
- uint32_t ROMCRC32; |
|
| 257 |
- int32_t ROMFramesPerSecond; |
|
| 258 |
- |
|
| 259 |
- bool HiROM; |
|
| 260 |
- bool LoROM; |
|
| 261 |
- uint8_t SRAMSize; |
|
| 262 |
- uint32_t SRAMMask; |
|
| 263 |
- uint32_t CalculatedSize; |
|
| 264 |
- uint32_t CalculatedChecksum; |
|
| 265 |
- |
|
| 266 |
- // ports can assign this to perform some custom action upon loading a ROM (such as adjusting controls) |
|
| 267 |
- void (*PostRomInitFunc)(); |
|
| 268 |
- |
|
| 269 |
- bool Init(); |
|
| 270 |
- void Deinit(); |
|
| 271 |
- |
|
| 272 |
- int ScoreHiROM (bool, int32_t romoff = 0); |
|
| 273 |
- int ScoreLoROM (bool, int32_t romoff = 0); |
|
| 274 |
- //uint32_t HeaderRemove (uint32_t, int32_t &, uint8_t *); |
|
| 275 |
- //uint32_t FileLoader (uint8_t *, const char *, int32_t); |
|
| 276 |
- /*bool LoadROM (const char *); |
|
| 277 |
- bool LoadMultiCart (const char *, const char *); |
|
| 278 |
- bool LoadSufamiTurbo (const char *, const char *); |
|
| 279 |
- bool LoadSameGame (const char *, const char *); |
|
| 280 |
- bool LoadSRAM (const char *); |
|
| 281 |
- bool SaveSRAM (const char *); |
|
| 282 |
- void ClearSRAM (bool onlyNonSavedSRAM = 0); |
|
| 283 |
- bool LoadSRTC(); |
|
| 284 |
- bool SaveSRTC();*/ |
|
| 285 |
- bool LoadROMSNSF(const unsigned char *, int32_t, const unsigned char *, int32_t); |
|
| 286 |
- |
|
| 287 |
- char * Safe (const char *); |
|
| 288 |
- char * SafeANK (const char *); |
|
| 289 |
- void ParseSNESHeader (uint8_t *); |
|
| 290 |
- void InitROM(); |
|
| 291 |
- |
|
| 292 |
- uint32_t map_mirror (uint32_t, uint32_t); |
|
| 293 |
- void map_lorom (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 294 |
- void map_hirom (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 295 |
- void map_lorom_offset (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 296 |
- void map_hirom_offset (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 297 |
- void map_space (uint32_t, uint32_t, uint32_t, uint32_t, uint8_t *); |
|
| 298 |
- void map_index (uint32_t, uint32_t, uint32_t, uint32_t, int, int); |
|
| 299 |
- void map_System(); |
|
| 300 |
- void map_WRAM(); |
|
| 301 |
- void map_LoROMSRAM(); |
|
| 302 |
- void map_HiROMSRAM(); |
|
| 303 |
- //void map_DSP(); |
|
| 304 |
- //void map_C4(); |
|
| 305 |
- //void map_OBC1(); |
|
| 306 |
- //void map_SetaRISC(); |
|
| 307 |
- //void map_SetaDSP(); |
|
| 308 |
- void map_WriteProtectROM(); |
|
| 309 |
- void Map_Initialize(); |
|
| 310 |
- void Map_LoROMMap(); |
|
| 311 |
- void Map_NoMAD1LoROMMap(); |
|
| 312 |
- void Map_JumboLoROMMap(); |
|
| 313 |
- void Map_ROM24MBSLoROMMap(); |
|
| 314 |
- void Map_SRAM512KLoROMMap(); |
|
| 315 |
- //void Map_SufamiTurboLoROMMap(); |
|
| 316 |
- //void Map_SufamiTurboPseudoLoROMMap(); |
|
| 317 |
- //void Map_SuperFXLoROMMap(); |
|
| 318 |
- //void Map_SetaDSPLoROMMap(); |
|
| 319 |
- void Map_SDD1LoROMMap(); |
|
| 320 |
- //void Map_SA1LoROMMap(); |
|
| 321 |
- void Map_HiROMMap(); |
|
| 322 |
- void Map_ExtendedHiROMMap(); |
|
| 323 |
- //void Map_SameGameHiROMMap(); |
|
| 324 |
- //void Map_SPC7110HiROMMap(); |
|
| 325 |
- |
|
| 326 |
- uint16_t checksum_calc_sum (uint8_t *, uint32_t); |
|
| 327 |
- uint16_t checksum_mirror_sum (uint8_t *, uint32_t &, uint32_t mask = 0x800000); |
|
| 328 |
- void Checksum_Calculate(); |
|
| 329 |
- |
|
| 330 |
- bool match_na (const char *); |
|
| 331 |
- bool match_nn (const char *); |
|
| 332 |
- //bool match_nc (const char *); |
|
| 333 |
- bool match_id (const char *); |
|
| 334 |
- void ApplyROMFixes(); |
|
| 335 |
- //void CheckForAnyPatch (const char *, bool, int32_t &); |
|
| 336 |
- |
|
| 337 |
- //void MakeRomInfoText (char *); |
|
| 338 |
- |
|
| 339 |
- //const char * MapType(); |
|
| 340 |
- //const char * StaticRAMSize(); |
|
| 341 |
- //const char * Size(); |
|
| 342 |
- //const char * Revision(); |
|
| 343 |
- //const char * KartContents(); |
|
| 344 |
- //const char * Country(); |
|
| 345 |
- //const char * PublishingCompany(); |
|
| 346 |
-}; |
|
| 347 |
- |
|
| 348 |
-struct SMulti |
|
| 349 |
-{
|
|
| 350 |
- int cartType; |
|
| 351 |
- int32_t cartSizeA, cartSizeB; |
|
| 352 |
- int32_t sramSizeA, sramSizeB; |
|
| 353 |
- uint32_t sramMaskA, sramMaskB; |
|
| 354 |
- uint32_t cartOffsetA, cartOffsetB; |
|
| 355 |
- uint8_t *sramA, *sramB; |
|
| 356 |
- char fileNameA[PATH_MAX + 1], fileNameB[PATH_MAX + 1]; |
|
| 219 |
+ std::unique_ptr<uint8_t[]> RAM; |
|
| 220 |
+ std::unique_ptr<uint8_t[]> RealROM; |
|
| 221 |
+ uint8_t *ROM; |
|
| 222 |
+ std::unique_ptr<uint8_t[]> SRAM; |
|
| 223 |
+ std::unique_ptr<uint8_t[]> VRAM; |
|
| 224 |
+ uint8_t *FillRAM; |
|
| 225 |
+ |
|
| 226 |
+ uint8_t *Map[MEMMAP_NUM_BLOCKS]; |
|
| 227 |
+ uint8_t *WriteMap[MEMMAP_NUM_BLOCKS]; |
|
| 228 |
+ uint8_t BlockIsRAM[MEMMAP_NUM_BLOCKS]; |
|
| 229 |
+ uint8_t BlockIsROM[MEMMAP_NUM_BLOCKS]; |
|
| 230 |
+ uint8_t ExtendedFormat; |
|
| 231 |
+ |
|
| 232 |
+ char ROMName[ROM_NAME_LEN]; |
|
| 233 |
+ char ROMId[5]; |
|
| 234 |
+ uint8_t ROMRegion; |
|
| 235 |
+ uint8_t ROMSpeed; |
|
| 236 |
+ uint8_t ROMType; |
|
| 237 |
+ |
|
| 238 |
+ bool HiROM; |
|
| 239 |
+ bool LoROM; |
|
| 240 |
+ uint8_t SRAMSize; |
|
| 241 |
+ uint32_t SRAMMask; |
|
| 242 |
+ uint32_t CalculatedSize; |
|
| 243 |
+ |
|
| 244 |
+ bool Init(); |
|
| 245 |
+ void Deinit(); |
|
| 246 |
+ |
|
| 247 |
+ int ScoreHiROM(bool, int32_t romoff = 0); |
|
| 248 |
+ int ScoreLoROM(bool, int32_t romoff = 0); |
|
| 249 |
+ bool LoadROMSNSF(const uint8_t *, int32_t, const uint8_t *, int32_t); |
|
| 250 |
+ |
|
| 251 |
+ char *Safe(const char *); |
|
| 252 |
+ void ParseSNESHeader(uint8_t *); |
|
| 253 |
+ void InitROM(); |
|
| 254 |
+ |
|
| 255 |
+ uint32_t map_mirror(uint32_t, uint32_t); |
|
| 256 |
+ void map_lorom(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 257 |
+ void map_hirom(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 258 |
+ void map_lorom_offset(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 259 |
+ void map_hirom_offset(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 260 |
+ void map_space(uint32_t, uint32_t, uint32_t, uint32_t, uint8_t *); |
|
| 261 |
+ void map_index(uint32_t, uint32_t, uint32_t, uint32_t, int, int); |
|
| 262 |
+ void map_System(); |
|
| 263 |
+ void map_WRAM(); |
|
| 264 |
+ void map_LoROMSRAM(); |
|
| 265 |
+ void map_HiROMSRAM(); |
|
| 266 |
+ void map_WriteProtectROM(); |
|
| 267 |
+ void Map_Initialize(); |
|
| 268 |
+ void Map_LoROMMap(); |
|
| 269 |
+ void Map_NoMAD1LoROMMap(); |
|
| 270 |
+ void Map_JumboLoROMMap(); |
|
| 271 |
+ void Map_ROM24MBSLoROMMap(); |
|
| 272 |
+ void Map_SRAM512KLoROMMap(); |
|
| 273 |
+ void Map_SDD1LoROMMap(); |
|
| 274 |
+ void Map_HiROMMap(); |
|
| 275 |
+ void Map_ExtendedHiROMMap(); |
|
| 276 |
+ |
|
| 277 |
+ bool match_na(const char *); |
|
| 278 |
+ bool match_nn(const char *); |
|
| 279 |
+ bool match_id(const char *); |
|
| 280 |
+ void ApplyROMFixes(); |
|
| 357 | 281 |
}; |
| 358 | 282 |
|
| 359 |
-extern CMemory Memory; |
|
| 360 |
-extern SMulti Multi; |
|
| 361 |
- |
|
| 362 |
-void S9xAutoSaveSRAM(); |
|
| 363 |
-bool LoadZip(const char *, int32_t *, int32_t *, uint8_t *); |
|
| 283 |
+extern CMemory Memory; |
|
| 364 | 284 |
|
| 365 | 285 |
enum s9xwrap_t |
| 366 | 286 |
{
|
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,380 @@ |
| 1 |
+/*********************************************************************************** |
|
| 2 |
+ Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. |
|
| 3 |
+ |
|
| 4 |
+ (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), |
|
| 5 |
+ Jerremy Koot (jkoot@snes9x.com) |
|
| 6 |
+ |
|
| 7 |
+ (c) Copyright 2002 - 2004 Matthew Kendora |
|
| 8 |
+ |
|
| 9 |
+ (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) |
|
| 10 |
+ |
|
| 11 |
+ (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) |
|
| 12 |
+ |
|
| 13 |
+ (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) |
|
| 14 |
+ |
|
| 15 |
+ (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), |
|
| 16 |
+ Kris Bleakley (codeviolation@hotmail.com) |
|
| 17 |
+ |
|
| 18 |
+ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), |
|
| 19 |
+ Nach (n-a-c-h@users.sourceforge.net), |
|
| 20 |
+ |
|
| 21 |
+ (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) |
|
| 22 |
+ |
|
| 23 |
+ (c) Copyright 2006 - 2007 nitsuja |
|
| 24 |
+ |
|
| 25 |
+ (c) Copyright 2009 - 2011 BearOso, |
|
| 26 |
+ OV2 |
|
| 27 |
+ |
|
| 28 |
+ |
|
| 29 |
+ BS-X C emulator code |
|
| 30 |
+ (c) Copyright 2005 - 2006 Dreamer Nom, |
|
| 31 |
+ zones |
|
| 32 |
+ |
|
| 33 |
+ C4 x86 assembler and some C emulation code |
|
| 34 |
+ (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), |
|
| 35 |
+ Nach, |
|
| 36 |
+ zsKnight (zsknight@zsnes.com) |
|
| 37 |
+ |
|
| 38 |
+ C4 C++ code |
|
| 39 |
+ (c) Copyright 2003 - 2006 Brad Jorsch, |
|
| 40 |
+ Nach |
|
| 41 |
+ |
|
| 42 |
+ DSP-1 emulator code |
|
| 43 |
+ (c) Copyright 1998 - 2006 _Demo_, |
|
| 44 |
+ Andreas Naive (andreasnaive@gmail.com), |
|
| 45 |
+ Gary Henderson, |
|
| 46 |
+ Ivar (ivar@snes9x.com), |
|
| 47 |
+ John Weidman, |
|
| 48 |
+ Kris Bleakley, |
|
| 49 |
+ Matthew Kendora, |
|
| 50 |
+ Nach, |
|
| 51 |
+ neviksti (neviksti@hotmail.com) |
|
| 52 |
+ |
|
| 53 |
+ DSP-2 emulator code |
|
| 54 |
+ (c) Copyright 2003 John Weidman, |
|
| 55 |
+ Kris Bleakley, |
|
| 56 |
+ Lord Nightmare (lord_nightmare@users.sourceforge.net), |
|
| 57 |
+ Matthew Kendora, |
|
| 58 |
+ neviksti |
|
| 59 |
+ |
|
| 60 |
+ DSP-3 emulator code |
|
| 61 |
+ (c) Copyright 2003 - 2006 John Weidman, |
|
| 62 |
+ Kris Bleakley, |
|
| 63 |
+ Lancer, |
|
| 64 |
+ z80 gaiden |
|
| 65 |
+ |
|
| 66 |
+ DSP-4 emulator code |
|
| 67 |
+ (c) Copyright 2004 - 2006 Dreamer Nom, |
|
| 68 |
+ John Weidman, |
|
| 69 |
+ Kris Bleakley, |
|
| 70 |
+ Nach, |
|
| 71 |
+ z80 gaiden |
|
| 72 |
+ |
|
| 73 |
+ OBC1 emulator code |
|
| 74 |
+ (c) Copyright 2001 - 2004 zsKnight, |
|
| 75 |
+ pagefault (pagefault@zsnes.com), |
|
| 76 |
+ Kris Bleakley |
|
| 77 |
+ Ported from x86 assembler to C by sanmaiwashi |
|
| 78 |
+ |
|
| 79 |
+ SPC7110 and RTC C++ emulator code used in 1.39-1.51 |
|
| 80 |
+ (c) Copyright 2002 Matthew Kendora with research by |
|
| 81 |
+ zsKnight, |
|
| 82 |
+ John Weidman, |
|
| 83 |
+ Dark Force |
|
| 84 |
+ |
|
| 85 |
+ SPC7110 and RTC C++ emulator code used in 1.52+ |
|
| 86 |
+ (c) Copyright 2009 byuu, |
|
| 87 |
+ neviksti |
|
| 88 |
+ |
|
| 89 |
+ S-DD1 C emulator code |
|
| 90 |
+ (c) Copyright 2003 Brad Jorsch with research by |
|
| 91 |
+ Andreas Naive, |
|
| 92 |
+ John Weidman |
|
| 93 |
+ |
|
| 94 |
+ S-RTC C emulator code |
|
| 95 |
+ (c) Copyright 2001 - 2006 byuu, |
|
| 96 |
+ John Weidman |
|
| 97 |
+ |
|
| 98 |
+ ST010 C++ emulator code |
|
| 99 |
+ (c) Copyright 2003 Feather, |
|
| 100 |
+ John Weidman, |
|
| 101 |
+ Kris Bleakley, |
|
| 102 |
+ Matthew Kendora |
|
| 103 |
+ |
|
| 104 |
+ Super FX x86 assembler emulator code |
|
| 105 |
+ (c) Copyright 1998 - 2003 _Demo_, |
|
| 106 |
+ pagefault, |
|
| 107 |
+ zsKnight |
|
| 108 |
+ |
|
| 109 |
+ Super FX C emulator code |
|
| 110 |
+ (c) Copyright 1997 - 1999 Ivar, |
|
| 111 |
+ Gary Henderson, |
|
| 112 |
+ John Weidman |
|
| 113 |
+ |
|
| 114 |
+ Sound emulator code used in 1.5-1.51 |
|
| 115 |
+ (c) Copyright 1998 - 2003 Brad Martin |
|
| 116 |
+ (c) Copyright 1998 - 2006 Charles Bilyue' |
|
| 117 |
+ |
|
| 118 |
+ Sound emulator code used in 1.52+ |
|
| 119 |
+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) |
|
| 120 |
+ |
|
| 121 |
+ SH assembler code partly based on x86 assembler code |
|
| 122 |
+ (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) |
|
| 123 |
+ |
|
| 124 |
+ 2xSaI filter |
|
| 125 |
+ (c) Copyright 1999 - 2001 Derek Liauw Kie Fa |
|
| 126 |
+ |
|
| 127 |
+ HQ2x, HQ3x, HQ4x filters |
|
| 128 |
+ (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) |
|
| 129 |
+ |
|
| 130 |
+ NTSC filter |
|
| 131 |
+ (c) Copyright 2006 - 2007 Shay Green |
|
| 132 |
+ |
|
| 133 |
+ GTK+ GUI code |
|
| 134 |
+ (c) Copyright 2004 - 2011 BearOso |
|
| 135 |
+ |
|
| 136 |
+ Win32 GUI code |
|
| 137 |
+ (c) Copyright 2003 - 2006 blip, |
|
| 138 |
+ funkyass, |
|
| 139 |
+ Matthew Kendora, |
|
| 140 |
+ Nach, |
|
| 141 |
+ nitsuja |
|
| 142 |
+ (c) Copyright 2009 - 2011 OV2 |
|
| 143 |
+ |
|
| 144 |
+ Mac OS GUI code |
|
| 145 |
+ (c) Copyright 1998 - 2001 John Stiles |
|
| 146 |
+ (c) Copyright 2001 - 2011 zones |
|
| 147 |
+ |
|
| 148 |
+ |
|
| 149 |
+ Specific ports contains the works of other authors. See headers in |
|
| 150 |
+ individual files. |
|
| 151 |
+ |
|
| 152 |
+ |
|
| 153 |
+ Snes9x homepage: http://www.snes9x.com/ |
|
| 154 |
+ |
|
| 155 |
+ Permission to use, copy, modify and/or distribute Snes9x in both binary |
|
| 156 |
+ and source form, for non-commercial purposes, is hereby granted without |
|
| 157 |
+ fee, providing that this license information and copyright notice appear |
|
| 158 |
+ with all copies and any derived work. |
|
| 159 |
+ |
|
| 160 |
+ This software is provided 'as-is', without any express or implied |
|
| 161 |
+ warranty. In no event shall the authors be held liable for any damages |
|
| 162 |
+ arising from the use of this software or it's derivatives. |
|
| 163 |
+ |
|
| 164 |
+ Snes9x is freeware for PERSONAL USE only. Commercial users should |
|
| 165 |
+ seek permission of the copyright holders first. Commercial use includes, |
|
| 166 |
+ but is not limited to, charging money for Snes9x or software derived from |
|
| 167 |
+ Snes9x, including Snes9x or derivatives in commercial game bundles, and/or |
|
| 168 |
+ using Snes9x as a promotion for your commercial product. |
|
| 169 |
+ |
|
| 170 |
+ The copyright holders request that bug fixes and improvements to the code |
|
| 171 |
+ should be forwarded to them so everyone can benefit from the modifications |
|
| 172 |
+ in future versions. |
|
| 173 |
+ |
|
| 174 |
+ Super NES and Super Nintendo Entertainment System are trademarks of |
|
| 175 |
+ Nintendo Co., Limited and its subsidiary companies. |
|
| 176 |
+ ***********************************************************************************/ |
|
| 177 |
+ |
|
| 178 |
+ |
|
| 179 |
+#ifndef _MEMMAP_H_ |
|
| 180 |
+#define _MEMMAP_H_ |
|
| 181 |
+ |
|
| 182 |
+#define MEMMAP_BLOCK_SIZE (0x1000) |
|
| 183 |
+#define MEMMAP_NUM_BLOCKS (0x1000000 / MEMMAP_BLOCK_SIZE) |
|
| 184 |
+#define MEMMAP_SHIFT (12) |
|
| 185 |
+#define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1) |
|
| 186 |
+ |
|
| 187 |
+struct CMemory |
|
| 188 |
+{
|
|
| 189 |
+ enum |
|
| 190 |
+ { MAX_ROM_SIZE = 0x800000 };
|
|
| 191 |
+ |
|
| 192 |
+ enum file_formats |
|
| 193 |
+ { FILE_ZIP, FILE_JMA, FILE_DEFAULT };
|
|
| 194 |
+ |
|
| 195 |
+ enum |
|
| 196 |
+ { NOPE, YEAH, BIGFIRST, SMALLFIRST };
|
|
| 197 |
+ |
|
| 198 |
+ enum |
|
| 199 |
+ { MAP_TYPE_I_O, MAP_TYPE_ROM, MAP_TYPE_RAM };
|
|
| 200 |
+ |
|
| 201 |
+ enum |
|
| 202 |
+ {
|
|
| 203 |
+ MAP_CPU, |
|
| 204 |
+ MAP_PPU, |
|
| 205 |
+ MAP_LOROM_SRAM, |
|
| 206 |
+ MAP_LOROM_SRAM_B, |
|
| 207 |
+ MAP_HIROM_SRAM, |
|
| 208 |
+ MAP_DSP, |
|
| 209 |
+ MAP_SA1RAM, |
|
| 210 |
+ MAP_BWRAM, |
|
| 211 |
+ MAP_BWRAM_BITMAP, |
|
| 212 |
+ MAP_BWRAM_BITMAP2, |
|
| 213 |
+ MAP_SPC7110_ROM, |
|
| 214 |
+ MAP_SPC7110_DRAM, |
|
| 215 |
+ MAP_RONLY_SRAM, |
|
| 216 |
+ MAP_C4, |
|
| 217 |
+ MAP_OBC_RAM, |
|
| 218 |
+ MAP_SETA_DSP, |
|
| 219 |
+ MAP_SETA_RISC, |
|
| 220 |
+ MAP_BSX, |
|
| 221 |
+ MAP_NONE, |
|
| 222 |
+ MAP_LAST |
|
| 223 |
+ }; |
|
| 224 |
+ |
|
| 225 |
+ uint8_t NSRTHeader[32]; |
|
| 226 |
+ int32_t HeaderCount; |
|
| 227 |
+ |
|
| 228 |
+ uint8_t *RAM; |
|
| 229 |
+ uint8_t *ROM; |
|
| 230 |
+ uint8_t *SRAM; |
|
| 231 |
+ uint8_t *VRAM; |
|
| 232 |
+ uint8_t *FillRAM; |
|
| 233 |
+ uint8_t *BWRAM; |
|
| 234 |
+ uint8_t *C4RAM; |
|
| 235 |
+ uint8_t *OBC1RAM; |
|
| 236 |
+ uint8_t *BSRAM; |
|
| 237 |
+ uint8_t *BIOSROM; |
|
| 238 |
+ |
|
| 239 |
+ uint8_t *Map[MEMMAP_NUM_BLOCKS]; |
|
| 240 |
+ uint8_t *WriteMap[MEMMAP_NUM_BLOCKS]; |
|
| 241 |
+ uint8_t BlockIsRAM[MEMMAP_NUM_BLOCKS]; |
|
| 242 |
+ uint8_t BlockIsROM[MEMMAP_NUM_BLOCKS]; |
|
| 243 |
+ uint8_t ExtendedFormat; |
|
| 244 |
+ |
|
| 245 |
+ char ROMFilename[PATH_MAX + 1]; |
|
| 246 |
+ char ROMName[ROM_NAME_LEN]; |
|
| 247 |
+ char RawROMName[ROM_NAME_LEN]; |
|
| 248 |
+ char ROMId[5]; |
|
| 249 |
+ int32_t CompanyId; |
|
| 250 |
+ uint8_t ROMRegion; |
|
| 251 |
+ uint8_t ROMSpeed; |
|
| 252 |
+ uint8_t ROMType; |
|
| 253 |
+ uint8_t ROMSize; |
|
| 254 |
+ uint32_t ROMChecksum; |
|
| 255 |
+ uint32_t ROMComplementChecksum; |
|
| 256 |
+ uint32_t ROMCRC32; |
|
| 257 |
+ int32_t ROMFramesPerSecond; |
|
| 258 |
+ |
|
| 259 |
+ bool HiROM; |
|
| 260 |
+ bool LoROM; |
|
| 261 |
+ uint8_t SRAMSize; |
|
| 262 |
+ uint32_t SRAMMask; |
|
| 263 |
+ uint32_t CalculatedSize; |
|
| 264 |
+ uint32_t CalculatedChecksum; |
|
| 265 |
+ |
|
| 266 |
+ // ports can assign this to perform some custom action upon loading a ROM (such as adjusting controls) |
|
| 267 |
+ void (*PostRomInitFunc)(); |
|
| 268 |
+ |
|
| 269 |
+ bool Init(); |
|
| 270 |
+ void Deinit(); |
|
| 271 |
+ |
|
| 272 |
+ int ScoreHiROM (bool, int32_t romoff = 0); |
|
| 273 |
+ int ScoreLoROM (bool, int32_t romoff = 0); |
|
| 274 |
+ //uint32_t HeaderRemove (uint32_t, int32_t &, uint8_t *); |
|
| 275 |
+ //uint32_t FileLoader (uint8_t *, const char *, int32_t); |
|
| 276 |
+ /*bool LoadROM (const char *); |
|
| 277 |
+ bool LoadMultiCart (const char *, const char *); |
|
| 278 |
+ bool LoadSufamiTurbo (const char *, const char *); |
|
| 279 |
+ bool LoadSameGame (const char *, const char *); |
|
| 280 |
+ bool LoadSRAM (const char *); |
|
| 281 |
+ bool SaveSRAM (const char *); |
|
| 282 |
+ void ClearSRAM (bool onlyNonSavedSRAM = 0); |
|
| 283 |
+ bool LoadSRTC(); |
|
| 284 |
+ bool SaveSRTC();*/ |
|
| 285 |
+ bool LoadROMSNSF(const unsigned char *, int32_t, const unsigned char *, int32_t); |
|
| 286 |
+ |
|
| 287 |
+ char * Safe (const char *); |
|
| 288 |
+ char * SafeANK (const char *); |
|
| 289 |
+ void ParseSNESHeader (uint8_t *); |
|
| 290 |
+ void InitROM(); |
|
| 291 |
+ |
|
| 292 |
+ uint32_t map_mirror (uint32_t, uint32_t); |
|
| 293 |
+ void map_lorom (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 294 |
+ void map_hirom (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 295 |
+ void map_lorom_offset (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 296 |
+ void map_hirom_offset (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); |
|
| 297 |
+ void map_space (uint32_t, uint32_t, uint32_t, uint32_t, uint8_t *); |
|
| 298 |
+ void map_index (uint32_t, uint32_t, uint32_t, uint32_t, int, int); |
|
| 299 |
+ void map_System(); |
|
| 300 |
+ void map_WRAM(); |
|
| 301 |
+ void map_LoROMSRAM(); |
|
| 302 |
+ void map_HiROMSRAM(); |
|
| 303 |
+ //void map_DSP(); |
|
| 304 |
+ //void map_C4(); |
|
| 305 |
+ //void map_OBC1(); |
|
| 306 |
+ //void map_SetaRISC(); |
|
| 307 |
+ //void map_SetaDSP(); |
|
| 308 |
+ void map_WriteProtectROM(); |
|
| 309 |
+ void Map_Initialize(); |
|
| 310 |
+ void Map_LoROMMap(); |
|
| 311 |
+ void Map_NoMAD1LoROMMap(); |
|
| 312 |
+ void Map_JumboLoROMMap(); |
|
| 313 |
+ void Map_ROM24MBSLoROMMap(); |
|
| 314 |
+ void Map_SRAM512KLoROMMap(); |
|
| 315 |
+ //void Map_SufamiTurboLoROMMap(); |
|
| 316 |
+ //void Map_SufamiTurboPseudoLoROMMap(); |
|
| 317 |
+ //void Map_SuperFXLoROMMap(); |
|
| 318 |
+ //void Map_SetaDSPLoROMMap(); |
|
| 319 |
+ void Map_SDD1LoROMMap(); |
|
| 320 |
+ //void Map_SA1LoROMMap(); |
|
| 321 |
+ void Map_HiROMMap(); |
|
| 322 |
+ void Map_ExtendedHiROMMap(); |
|
| 323 |
+ //void Map_SameGameHiROMMap(); |
|
| 324 |
+ //void Map_SPC7110HiROMMap(); |
|
| 325 |
+ |
|
| 326 |
+ uint16_t checksum_calc_sum (uint8_t *, uint32_t); |
|
| 327 |
+ uint16_t checksum_mirror_sum (uint8_t *, uint32_t &, uint32_t mask = 0x800000); |
|
| 328 |
+ void Checksum_Calculate(); |
|
| 329 |
+ |
|
| 330 |
+ bool match_na (const char *); |
|
| 331 |
+ bool match_nn (const char *); |
|
| 332 |
+ //bool match_nc (const char *); |
|
| 333 |
+ bool match_id (const char *); |
|
| 334 |
+ void ApplyROMFixes(); |
|
| 335 |
+ //void CheckForAnyPatch (const char *, bool, int32_t &); |
|
| 336 |
+ |
|
| 337 |
+ //void MakeRomInfoText (char *); |
|
| 338 |
+ |
|
| 339 |
+ //const char * MapType(); |
|
| 340 |
+ //const char * StaticRAMSize(); |
|
| 341 |
+ //const char * Size(); |
|
| 342 |
+ //const char * Revision(); |
|
| 343 |
+ //const char * KartContents(); |
|
| 344 |
+ //const char * Country(); |
|
| 345 |
+ //const char * PublishingCompany(); |
|
| 346 |
+}; |
|
| 347 |
+ |
|
| 348 |
+struct SMulti |
|
| 349 |
+{
|
|
| 350 |
+ int cartType; |
|
| 351 |
+ int32_t cartSizeA, cartSizeB; |
|
| 352 |
+ int32_t sramSizeA, sramSizeB; |
|
| 353 |
+ uint32_t sramMaskA, sramMaskB; |
|
| 354 |
+ uint32_t cartOffsetA, cartOffsetB; |
|
| 355 |
+ uint8_t *sramA, *sramB; |
|
| 356 |
+ char fileNameA[PATH_MAX + 1], fileNameB[PATH_MAX + 1]; |
|
| 357 |
+}; |
|
| 358 |
+ |
|
| 359 |
+extern CMemory Memory; |
|
| 360 |
+extern SMulti Multi; |
|
| 361 |
+ |
|
| 362 |
+void S9xAutoSaveSRAM(); |
|
| 363 |
+bool LoadZip(const char *, int32_t *, int32_t *, uint8_t *); |
|
| 364 |
+ |
|
| 365 |
+enum s9xwrap_t |
|
| 366 |
+{
|
|
| 367 |
+ WRAP_NONE, |
|
| 368 |
+ WRAP_BANK, |
|
| 369 |
+ WRAP_PAGE |
|
| 370 |
+}; |
|
| 371 |
+ |
|
| 372 |
+enum s9xwriteorder_t |
|
| 373 |
+{
|
|
| 374 |
+ WRITE_01, |
|
| 375 |
+ WRITE_10 |
|
| 376 |
+}; |
|
| 377 |
+ |
|
| 378 |
+#include "getset.h" |
|
| 379 |
+ |
|
| 380 |
+#endif |