1 /*********************************************************************************** 2 Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), 4 Jerremy Koot (jkoot@snes9x.com) 5 6 (c) Copyright 2002 - 2004 Matthew Kendora 7 8 (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) 9 10 (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) 11 12 (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) 13 14 (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), 15 Kris Bleakley (codeviolation@hotmail.com) 16 17 (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), 18 Nach (n-a-c-h@users.sourceforge.net), 19 zones (kasumitokoduck@yahoo.com) 20 21 (c) Copyright 2006 - 2007 nitsuja 22 23 (c) Copyright 2009 - 2010 BearOso, 24 OV2 25 26 27 BS-X C emulator code 28 (c) Copyright 2005 - 2006 Dreamer Nom, 29 zones 30 31 C4 x86 assembler and some C emulation code 32 (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), 33 Nach, 34 zsKnight (zsknight@zsnes.com) 35 36 C4 C++ code 37 (c) Copyright 2003 - 2006 Brad Jorsch, 38 Nach 39 40 DSP-1 emulator code 41 (c) Copyright 1998 - 2006 _Demo_, 42 Andreas Naive (andreasnaive@gmail.com), 43 Gary Henderson, 44 Ivar (ivar@snes9x.com), 45 John Weidman, 46 Kris Bleakley, 47 Matthew Kendora, 48 Nach, 49 neviksti (neviksti@hotmail.com) 50 51 DSP-2 emulator code 52 (c) Copyright 2003 John Weidman, 53 Kris Bleakley, 54 Lord Nightmare (lord_nightmare@users.sourceforge.net), 55 Matthew Kendora, 56 neviksti 57 58 DSP-3 emulator code 59 (c) Copyright 2003 - 2006 John Weidman, 60 Kris Bleakley, 61 Lancer, 62 z80 gaiden 63 64 DSP-4 emulator code 65 (c) Copyright 2004 - 2006 Dreamer Nom, 66 John Weidman, 67 Kris Bleakley, 68 Nach, 69 z80 gaiden 70 71 OBC1 emulator code 72 (c) Copyright 2001 - 2004 zsKnight, 73 pagefault (pagefault@zsnes.com), 74 Kris Bleakley 75 Ported from x86 assembler to C by sanmaiwashi 76 77 SPC7110 and RTC C++ emulator code used in 1.39-1.51 78 (c) Copyright 2002 Matthew Kendora with research by 79 zsKnight, 80 John Weidman, 81 Dark Force 82 83 SPC7110 and RTC C++ emulator code used in 1.52+ 84 (c) Copyright 2009 byuu, 85 neviksti 86 87 S-DD1 C emulator code 88 (c) Copyright 2003 Brad Jorsch with research by 89 Andreas Naive, 90 John Weidman 91 92 S-RTC C emulator code 93 (c) Copyright 2001 - 2006 byuu, 94 John Weidman 95 96 ST010 C++ emulator code 97 (c) Copyright 2003 Feather, 98 John Weidman, 99 Kris Bleakley, 100 Matthew Kendora 101 102 Super FX x86 assembler emulator code 103 (c) Copyright 1998 - 2003 _Demo_, 104 pagefault, 105 zsKnight 106 107 Super FX C emulator code 108 (c) Copyright 1997 - 1999 Ivar, 109 Gary Henderson, 110 John Weidman 111 112 Sound emulator code used in 1.5-1.51 113 (c) Copyright 1998 - 2003 Brad Martin 114 (c) Copyright 1998 - 2006 Charles Bilyue' 115 116 Sound emulator code used in 1.52+ 117 (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) 118 119 SH assembler code partly based on x86 assembler code 120 (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) 121 122 2xSaI filter 123 (c) Copyright 1999 - 2001 Derek Liauw Kie Fa 124 125 HQ2x, HQ3x, HQ4x filters 126 (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) 127 128 NTSC filter 129 (c) Copyright 2006 - 2007 Shay Green 130 131 GTK+ GUI code 132 (c) Copyright 2004 - 2010 BearOso 133 134 Win32 GUI code 135 (c) Copyright 2003 - 2006 blip, 136 funkyass, 137 Matthew Kendora, 138 Nach, 139 nitsuja 140 (c) Copyright 2009 - 2010 OV2 141 142 Mac OS GUI code 143 (c) Copyright 1998 - 2001 John Stiles 144 (c) Copyright 2001 - 2010 zones 145 146 (c) Copyright 2010 - 2016 Daniel De Matteis. (UNDER NO CIRCUMSTANCE 147 WILL COMMERCIAL RIGHTS EVER BE APPROPRIATED TO ANY PARTY) 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 ROM_NAME_LEN 23 183 184 #define MEMMAP_BLOCK_SIZE (0x1000) 185 #define MEMMAP_NUM_BLOCKS (0x1000000 / MEMMAP_BLOCK_SIZE) 186 #define MEMMAP_SHIFT (12) 187 #define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1) 188 189 #define MAP_CPU 0 190 #define MAP_PPU 1 191 #define MAP_LOROM_SRAM 2 192 #define MAP_LOROM_SRAM_B 3 193 #define MAP_HIROM_SRAM 4 194 #define MAP_DSP 5 195 #define MAP_SA1RAM 6 196 #define MAP_BWRAM 7 197 #define MAP_BWRAM_BITMAP 8 198 #define MAP_BWRAM_BITMAP2 9 199 #define MAP_SPC7110_ROM 10 200 #define MAP_SPC7110_DRAM 11 201 #define MAP_RONLY_SRAM 12 202 #define MAP_C4 13 203 #define MAP_OBC_RAM 14 204 #define MAP_SETA_DSP 15 205 #define MAP_SETA_RISC 16 206 #define MAP_BSX 17 207 #define MAP_NONE 18 208 #define MAP_LAST 19 209 210 #ifdef HW_DOL 211 #define MAX_ROM_SIZE 0x600000 212 #else 213 #define MAX_ROM_SIZE 0x800000 214 #endif 215 216 #define NOPE 0 217 #define YEAH 1 218 #define BIGFIRST 2 219 #define SMALLFIRST 3 220 221 #define MAP_TYPE_I_O 0 222 #define MAP_TYPE_ROM 1 223 #define MAP_TYPE_RAM 2 224 225 enum speedhacks 226 { 227 SPEEDHACK_NONE = 0, 228 SPEEDHACK_CT, 229 SPEEDHACK_DKC1, 230 SPEEDHACK_SUPER_METROID, 231 SPEEDHACK_KILLER_INSTINCT, 232 SPEEDHACK_FF6, 233 SPEEDHACK_STAR_FOX_1, 234 SPEEDHACK_SUPER_MARIO_WORLD, 235 }; 236 237 typedef struct 238 { 239 int32 HeaderCount; 240 241 uint8 *RAM; 242 uint8 *ROM; 243 uint8 *SRAM; 244 uint8 *VRAM; 245 uint8 *FillRAM; 246 uint8 *BWRAM; 247 uint8 *C4RAM; 248 uint8 *OBC1RAM; 249 uint8 *BSRAM; 250 uint8 *BIOSROM; 251 252 uint8 *Map[MEMMAP_NUM_BLOCKS]; 253 uint8 *WriteMap[MEMMAP_NUM_BLOCKS]; 254 uint8 BlockIsRAM[MEMMAP_NUM_BLOCKS]; 255 uint8 BlockIsROM[MEMMAP_NUM_BLOCKS]; 256 uint8 ExtendedFormat; 257 258 char ROMName[ROM_NAME_LEN]; 259 char RawROMName[ROM_NAME_LEN]; 260 char ROMId[5]; 261 int32 CompanyId; 262 uint8 ROMRegion; 263 uint8 ROMSpeed; 264 uint8 ROMType; 265 uint8 ROMSize; 266 uint32 ROMChecksum; 267 uint32 ROMComplementChecksum; 268 uint32 ROMCRC32; 269 270 bool8 HiROM; 271 bool8 LoROM; 272 uint8 SRAMSize; 273 uint32 SRAMMask; 274 uint32 CalculatedSize; 275 uint32 CalculatedChecksum; 276 277 } CMemory; 278 279 bool8 Init (void); 280 void Deinit (void); 281 282 bool8 LoadROM (void); 283 bool8 LoadMultiCart (const char *cartA, const char *cartB); 284 bool8 LoadSufamiTurbo (const char *cartA, const char *cartB); 285 bool8 LoadSameGame (const char *cartA, const char *cartB); 286 287 void map_WriteProtectROM (void); 288 289 struct SMulti 290 { 291 int cartType; 292 int32 cartSizeA; 293 int32 cartSizeB; 294 int32 sramSizeA; 295 int32 sramSizeB; 296 uint32 sramMaskA; 297 uint32 sramMaskB; 298 uint32 cartOffsetA; 299 uint32 cartOffsetB; 300 uint8 *sramA; 301 uint8 *sramB; 302 char fileNameA[PATH_MAX + 1]; 303 char fileNameB[PATH_MAX + 1]; 304 }; 305 306 extern CMemory Memory; 307 extern struct SMulti Multi; 308 309 #define WRAP_PAGE 0xFF 310 #define WRAP_BANK 0xFFFF 311 #define WRAP_NONE 0xFFFFFF 312 313 #ifndef max 314 #define max(a, b) (((a) > (b)) ? (a) : (b)) 315 #endif 316 317 #ifndef min 318 #define min(a, b) (((a) < (b)) ? (a) : (b)) 319 #endif 320 321 #endif 322