2 * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
4 * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
5 * Jerremy Koot (jkoot@snes9x.com)
7 * Super FX C emulator code
8 * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
10 * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
12 * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
13 * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
14 * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
16 * DOS port code contains the works of other authors. See headers in
19 * Snes9x homepage: http://www.snes9x.com
21 * Permission to use, copy, modify and distribute Snes9x in both binary and
22 * source form, for non-commercial purposes, is hereby granted without fee,
23 * providing that this license information and copyright notice appear with
24 * all copies and any derived work.
26 * This software is provided 'as-is', without any express or implied
27 * warranty. In no event shall the authors be held liable for any damages
28 * arising from the use of this software.
30 * Snes9x is freeware for PERSONAL USE only. Commercial users should
31 * seek permission of the copyright holders first. Commercial use includes
32 * charging money for Snes9x or software derived from Snes9x.
34 * The copyright holders request that bug fixes and improvements to the code
35 * should be forwarded to them so everyone can benefit from the modifications
38 * Super NES and Super Nintendo Entertainment System are trademarks of
39 * Nintendo Co., Limited and its subsidiary companies.
46 #ifdef FAST_LSB_WORD_ACCESS
47 #define READ_WORD(s) (*(uint16 *) (s))
48 #define READ_DWORD(s) (*(uint32 *) (s))
49 #define WRITE_WORD(s, d) (*(uint16 *) (s) = (d)
50 #define WRITE_DWORD(s, d) (*(uint32 *) (s) = (d)
52 #define READ_WORD(s) ( *(uint8 *) (s) |\
53 (*((uint8 *) (s) + 1) << 8))
54 #define READ_DWORD(s) ( *(uint8 *) (s) |\
55 (*((uint8 *) (s) + 1) << 8) |\
56 (*((uint8 *) (s) + 2) << 16) |\
57 (*((uint8 *) (s) + 3) << 24))
58 #define WRITE_WORD(s, d) *(uint8 *) (s) = (d), \
59 *((uint8 *) (s) + 1) = (d) >> 8
60 #define WRITE_DWORD(s, d) *(uint8 *) (s) = (uint8) (d), \
61 *((uint8 *) (s) + 1) = (uint8) ((d) >> 8),\
62 *((uint8 *) (s) + 2) = (uint8) ((d) >> 16),\
63 *((uint8 *) (s) + 3) = (uint8) ((d) >> 24)
64 #define WRITE_3WORD(s, d) *(uint8 *) (s) = (uint8) (d), \
65 *((uint8 *) (s) + 1) = (uint8) ((d) >> 8),\
66 *((uint8 *) (s) + 2) = (uint8) ((d) >> 16)
67 #define READ_3WORD(s) ( *(uint8 *) (s) |\
68 (*((uint8 *) (s) + 1) << 8) |\
69 (*((uint8 *) (s) + 2) << 16))
73 #define MEMMAP_BLOCK_SIZE (0x1000)
74 #define MEMMAP_NUM_BLOCKS (0x1000000 / MEMMAP_BLOCK_SIZE)
75 #define MEMMAP_BLOCKS_PER_BANK (0x10000 / MEMMAP_BLOCK_SIZE)
76 #define MEMMAP_SHIFT 12
77 #define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1)
78 #define MEMMAP_MAX_SDD1_LOGGED_ENTRIES (0x10000 / 8)
82 bool8_32 LoadROM (const char *);
83 void InitROM (bool8_32);
84 bool8_32 LoadSRAM (const char *);
85 bool8_32 SaveSRAM (const char *);
90 void WriteProtectROM ();
94 char *Safe (const char *);
97 void LoROM24MBSMap ();
98 void SRAM512KLoROMMap ();
99 void SRAM1024KLoROMMap ();
100 void SufamiTurboLoROMMap ();
102 void SuperFXROMMap ();
103 void TalesROMMap (bool8_32);
107 bool8_32 AllASCII (uint8 *b, int size);
108 int ScoreHiROM (bool8_32 skip_header);
109 int ScoreLoROM (bool8_32 skip_header);
110 void ApplyROMFixes ();
111 void CheckForIPSPatch (const char *rom_filename, bool8_32 header,
114 const char *TVStandard ();
115 const char *Speed ();
116 const char *StaticRAMSize ();
117 const char *MapType ();
118 const char *MapMode ();
119 const char *KartContents ();
121 const char *Headers ();
122 const char *ROMID ();
123 const char *CompanyID ();
126 MAP_PPU, MAP_CPU, MAP_DSP, MAP_LOROM_SRAM, MAP_HIROM_SRAM,
127 MAP_NONE, MAP_DEBUG, MAP_C4, MAP_BWRAM, MAP_BWRAM_BITMAP,
128 MAP_BWRAM_BITMAP2, MAP_SA1RAM, MAP_LAST
130 enum { MAX_ROM_SIZE = 0x600000 };
143 uint8 *Map [MEMMAP_NUM_BLOCKS];
144 uint8 *WriteMap [MEMMAP_NUM_BLOCKS];
145 uint8 MemorySpeed [MEMMAP_NUM_BLOCKS];
146 uint8 BlockIsRAM [MEMMAP_NUM_BLOCKS];
147 uint8 BlockIsROM [MEMMAP_NUM_BLOCKS];
148 char ROMName [ROM_NAME_LEN];
154 int32 ROMFramesPerSecond;
156 uint32 CalculatedSize;
157 uint32 CalculatedChecksum;
159 uint32 ROMComplementChecksum;
163 uint32 SDD1LoggedDataCountPrev;
164 uint32 SDD1LoggedDataCount;
165 uint8 SDD1LoggedData [MEMMAP_MAX_SDD1_LOGGED_ENTRIES];
167 char ROMFilename [_MAX_PATH];
169 char ROMFilename [1024];
174 extern CMemory Memory;
177 extern uint8 *RegRAM;
178 void S9xDeinterleaveMode2 ();
179 void S9xSaveSRAM(void);
180 void S9xAutoSaveSRAM();
183 #ifdef NO_INLINE_SET_GET
184 uint8 S9xGetByte (uint32 Address);
185 uint16 S9xGetWord (uint32 Address);
186 void S9xSetByte (uint8 Byte, uint32 Address);
187 void S9xSetWord (uint16 Byte, uint32 Address);
188 void S9xSetPCBase (uint32 Address);
189 uint8 *S9xGetMemPointer (uint32 Address);
190 uint8 *GetBasePointer (uint32 Address);