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.
44 #define ORIG_SNAPSHOT_MAGIC "#!snes96"
45 #define ORIG_SNAPSHOT_VERSION 4
47 EXTERN_C bool8_32 S9xLoadOrigSnapshot (const char *filename);
54 uint8 FastROMSpeed_old_old;
59 bool8_32 WaitingForInterrupt;
65 uint16 MemSpeedx2_old;
66 uint16 FastROMSpeed_old;
68 uint8 *PCAtOpcodeStart;
89 uint16 TimerTarget [3];
90 bool8_32 TimerEnabled [3];
91 bool8_32 TimerValueWritten [3];
97 struct { uint8 A, Y; } B;
99 struct { uint8 Y, A; } B;
104 struct SOrigAPURegisters{
112 #define ORIG_MAX_BUFFER_SIZE (1024 * 4)
113 #define NUM_CHANNELS 8
122 signed short wave [ORIG_MAX_BUFFER_SIZE];
125 short left_vol_level;
126 short right_vol_level;
128 unsigned long int env_error;
131 unsigned long attack_rate;
132 unsigned long decay_rate;
133 unsigned long sustain_rate;
134 unsigned long release_rate;
135 unsigned long sustain_level;
137 signed short decoded [16];
138 signed short previous [2];
139 uint16 sample_number;
141 bool8_32 needs_decode;
142 uint32 block_pointer;
143 uint32 sample_pointer;
151 short master_volume_left;
152 short master_volume_right;
153 short echo_volume_left;
154 short echo_volume_right;
158 int echo_buffer_size;
159 int echo_write_enabled;
160 int echo_channel_enable;
162 // Just incase they are needed in the future, for snapshot compatibility.
164 OrigChannel channels [NUM_CHANNELS];
191 uint16 FullGraphicCount;
203 bool8_32 ThroughMain;
215 struct SOrigOBJ OBJ [129];
216 uint8 OAMPriorityRotation;
220 uint16 OAMTileAddress;
223 uint16 VBeamPosLatched;
224 uint16 HBeamPosLatched;
228 uint8 HVBeamCounterLatched;
236 uint8 Joypad1ButtonReadPos;
237 uint8 Joypad2ButtonReadPos;
240 uint8 FixedColourRed;
241 uint8 FixedColourGreen;
242 uint8 FixedColourBlue;
247 bool8_32 ForcedBlanking;
248 bool8_32 OBJThroughMain;
249 bool8_32 OBJThroughSub;
251 uint8 OBJNameSelect_old;
253 bool8_32 OBJAddition;
255 uint8 OAMData [512 + 32];
256 bool8_32 VTimerEnabled;
257 bool8_32 HTimerEnabled;
258 short HTimerPosition;
260 bool8_32 BGMosaic [4];
268 uint8 ClipCounts [6];
269 uint8 ClipLeftEdges [3][6];
270 uint8 ClipRightEdges [3][6];
271 uint8 ClipWindowOverlapLogic [6];
272 uint8 ClipWindow1Enable [6];
273 uint8 ClipWindow2Enable [6];
274 bool8_32 ClipWindow1Inside [6];
275 bool8_32 ClipWindow2Inside [6];
276 bool8_32 RecomputeClipWindows;
278 uint16 OBJNameSelect;
279 bool8_32 Need16x8Mulitply;
280 uint8 Joypad3ButtonReadPos;
285 bool8_32 TransferDirection;
286 bool8_32 AAddressFixed;
287 bool8_32 AAddressDecrement;
296 uint16 TransferBytes;
299 bool8_32 HDMAIndirectAddressing;
300 uint16 IndirectAddress;
305 bool8_32 JustStarted;
311 struct { uint8 l,h; } B;
313 struct { uint8 h,l; } B;
318 struct SOrigRegisters{