Notable differences from upstream:
* Did not use the same #include setup for the new byuu apu and instead chose to do things more traditionally, as the latter is also much easier to deal with in Visual Studio than just including .cpp files into other .cpp files...
* MSU1 support not included (I see no need for this in a plugin meant to be used for original SNES music).
* The dynamic rate control on the APU not included (I also see no need for it in this plugin).
* The extra resamplers I added in were removed as the original hermite resampler was folded into a single non-inhertiable resampler.
* Bits of cleanup.
| ... | ... |
@@ -1,219 +1,51 @@ |
| 1 |
-/*********************************************************************************** |
|
| 1 |
+/*****************************************************************************\ |
|
| 2 | 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 |
- ***********************************************************************************/ |
|
| 3 |
+ This file is licensed under the Snes9x License. |
|
| 4 |
+ For further information, consult the LICENSE file in the root directory. |
|
| 5 |
+\*****************************************************************************/ |
|
| 177 | 6 |
|
| 178 | 7 |
#pragma once |
| 179 | 8 |
|
| 180 | 9 |
#ifndef VERSION |
| 181 |
-#define VERSION "1.53" |
|
| 10 |
+#define VERSION "1.60" |
|
| 182 | 11 |
#endif |
| 183 | 12 |
|
| 184 | 13 |
#include "port.h" |
| 185 | 14 |
|
| 186 |
-const int SNES_WIDTH = 256; |
|
| 187 |
-const int SNES_HEIGHT = 224; |
|
| 188 |
-const uint16_t SNES_HEIGHT_EXTENDED = 239; |
|
| 15 |
+inline constexpr int SNES_WIDTH = 256; |
|
| 16 |
+inline constexpr int SNES_HEIGHT = 224; |
|
| 17 |
+inline constexpr uint16_t SNES_HEIGHT_EXTENDED = 239; |
|
| 189 | 18 |
|
| 190 |
-const int32_t SNES_MAX_NTSC_VCOUNTER = 262; |
|
| 191 |
-const int32_t SNES_MAX_PAL_VCOUNTER = 312; |
|
| 192 |
-const int32_t SNES_HCOUNTER_MAX = 341; |
|
| 19 |
+inline constexpr double NTSC_MASTER_CLOCK = 21477272.727272; // 21477272 + 8/11 exact |
|
| 20 |
+inline constexpr double PAL_MASTER_CLOCK = 21281370.0; |
|
| 193 | 21 |
|
| 194 |
-const int32_t ONE_CYCLE = 6; |
|
| 195 |
-const int32_t SLOW_ONE_CYCLE = 8; |
|
| 196 |
-const int32_t TWO_CYCLES = 12; |
|
| 197 |
-const int32_t ONE_DOT_CYCLE = 4; |
|
| 22 |
+inline constexpr int32_t SNES_MAX_NTSC_VCOUNTER = 262; |
|
| 23 |
+inline constexpr int32_t SNES_MAX_PAL_VCOUNTER = 312; |
|
| 24 |
+inline constexpr int32_t SNES_HCOUNTER_MAX = 341; |
|
| 198 | 25 |
|
| 199 |
-const int32_t SNES_CYCLES_PER_SCANLINE = SNES_HCOUNTER_MAX * ONE_DOT_CYCLE; |
|
| 26 |
+inline constexpr int32_t ONE_CYCLE = 6; |
|
| 27 |
+inline constexpr int32_t SLOW_ONE_CYCLE = 8; |
|
| 28 |
+inline constexpr int32_t TWO_CYCLES = 12; |
|
| 29 |
+inline constexpr int32_t ONE_DOT_CYCLE = 4; |
|
| 200 | 30 |
|
| 201 |
-const int32_t SNES_WRAM_REFRESH_HC_v1 = 530; |
|
| 202 |
-const int32_t SNES_WRAM_REFRESH_HC_v2 = 538; |
|
| 203 |
-const int32_t SNES_WRAM_REFRESH_CYCLES = 40; |
|
| 31 |
+inline constexpr int32_t SNES_CYCLES_PER_SCANLINE = SNES_HCOUNTER_MAX * ONE_DOT_CYCLE; |
|
| 204 | 32 |
|
| 205 |
-const int32_t SNES_HBLANK_START_HC = 1096; // H=274 |
|
| 206 |
-const int32_t SNES_HDMA_START_HC = 1106; // FIXME: not true |
|
| 207 |
-const int32_t SNES_HBLANK_END_HC = 4; // H=1 |
|
| 208 |
-const int32_t SNES_HDMA_INIT_HC = 20; // FIXME: not true |
|
| 209 |
-const int32_t SNES_RENDER_START_HC = 48 * ONE_DOT_CYCLE; // FIXME: Snes9x renders a line at a time. |
|
| 33 |
+inline constexpr int32_t SNES_WRAM_REFRESH_HC_v1 = 530; |
|
| 34 |
+inline constexpr int32_t SNES_WRAM_REFRESH_HC_v2 = 538; |
|
| 35 |
+inline constexpr int32_t SNES_WRAM_REFRESH_CYCLES = 40; |
|
| 210 | 36 |
|
| 211 |
-const uint32_t DEBUG_MODE_FLAG = 1; // debugger |
|
| 212 |
-const uint32_t TRACE_FLAG = 1 << 1; // debugger |
|
| 213 |
-const uint32_t SCAN_KEYS_FLAG = 1 << 4; // CPU |
|
| 214 |
-const uint32_t HALTED_FLAG = 1 << 12; // APU |
|
| 37 |
+inline constexpr int32_t SNES_HBLANK_START_HC = 1096; // H=274 |
|
| 38 |
+inline constexpr int32_t SNES_HDMA_START_HC = 1106; // FIXME: not true |
|
| 39 |
+inline constexpr int32_t SNES_HBLANK_END_HC = 4; // H=1 |
|
| 40 |
+inline constexpr int32_t SNES_HDMA_INIT_HC = 20; // FIXME: not true |
|
| 41 |
+inline constexpr int32_t SNES_RENDER_START_HC = 128 * ONE_DOT_CYCLE; // FIXME: Snes9x renders a line at a time. |
|
| 215 | 42 |
|
| 216 |
-const size_t ROM_NAME_LEN = 23; |
|
| 43 |
+inline constexpr uint32_t DEBUG_MODE_FLAG = 1; // debugger |
|
| 44 |
+inline constexpr uint32_t TRACE_FLAG = 1 << 1; // debugger |
|
| 45 |
+inline constexpr uint32_t SCAN_KEYS_FLAG = 1 << 4; // CPU |
|
| 46 |
+inline constexpr uint32_t HALTED_FLAG = 1 << 12; // APU |
|
| 47 |
+ |
|
| 48 |
+inline constexpr size_t ROM_NAME_LEN = 23; |
|
| 217 | 49 |
|
| 218 | 50 |
struct SCPUState |
| 219 | 51 |
{
|
| ... | ... |
@@ -222,7 +54,7 @@ struct SCPUState |
| 222 | 54 |
int32_t PrevCycles; |
| 223 | 55 |
int32_t V_Counter; |
| 224 | 56 |
uint8_t *PCBase; |
| 225 |
- bool NMILine; |
|
| 57 |
+ bool NMIPending; |
|
| 226 | 58 |
bool IRQLine; |
| 227 | 59 |
bool IRQTransition; |
| 228 | 60 |
bool IRQLastState; |
| ... | ... |
@@ -251,6 +83,14 @@ enum |
| 251 | 83 |
HC_WRAM_REFRESH_EVENT = 6 |
| 252 | 84 |
}; |
| 253 | 85 |
|
| 86 |
+enum |
|
| 87 |
+{
|
|
| 88 |
+ IRQ_NONE = 0x0, |
|
| 89 |
+ IRQ_SET_FLAG = 0x1, |
|
| 90 |
+ IRQ_CLEAR_FLAG = 0x2, |
|
| 91 |
+ IRQ_TRIGGER_NMI = 0x4 |
|
| 92 |
+}; |
|
| 93 |
+ |
|
| 254 | 94 |
struct STimings |
| 255 | 95 |
{
|
| 256 | 96 |
int32_t H_Max_Master; |
| ... | ... |
@@ -262,13 +102,14 @@ struct STimings |
| 262 | 102 |
int32_t HDMAInit; |
| 263 | 103 |
int32_t HDMAStart; |
| 264 | 104 |
int32_t NMITriggerPos; |
| 105 |
+ int32_t NextIRQTimer; |
|
| 265 | 106 |
int32_t IRQTriggerCycles; |
| 266 | 107 |
int32_t WRAMRefreshPos; |
| 267 | 108 |
int32_t RenderPos; |
| 268 | 109 |
bool InterlaceField; |
| 269 | 110 |
int32_t DMACPUSync; // The cycles to synchronize DMA and CPU. Snes9x cannot emulate correctly. |
| 270 | 111 |
int32_t NMIDMADelay; // The delay of NMI trigger after DMA transfers. Snes9x cannot emulate correctly. |
| 271 |
- int32_t IRQPendCount; // This value is just a hack. |
|
| 112 |
+ int32_t IRQFlagChanging; // This value is just a hack. |
|
| 272 | 113 |
int32_t APUSpeedup; |
| 273 | 114 |
bool APUAllowTimeOverflow; |
| 274 | 115 |
}; |
| ... | ... |
@@ -281,12 +122,11 @@ struct SSettings |
| 281 | 122 |
bool PAL; |
| 282 | 123 |
|
| 283 | 124 |
bool SoundSync; |
| 284 |
- bool SixteenBitSound; |
|
| 285 | 125 |
uint32_t SoundPlaybackRate; |
| 286 | 126 |
uint32_t SoundInputRate; |
| 287 | 127 |
bool Stereo; |
| 288 |
- bool ReverseStereo; |
|
| 289 | 128 |
bool Mute; |
| 129 |
+ int32_t InterpolationMethod; |
|
| 290 | 130 |
|
| 291 | 131 |
bool DisableGameSpecificHacks; |
| 292 | 132 |
bool BlockInvalidVRAMAccessMaster; |
| ... | ... |
@@ -294,6 +134,8 @@ struct SSettings |
| 294 | 134 |
int32_t HDMATimingHack; |
| 295 | 135 |
|
| 296 | 136 |
bool TurboMode; |
| 137 |
+ |
|
| 138 |
+ bool SeparateEchoBuffer; |
|
| 297 | 139 |
}; |
| 298 | 140 |
|
| 299 | 141 |
struct SSNESGameFixes |
| ... | ... |
@@ -175,8 +175,7 @@ |
| 175 | 175 |
Nintendo Co., Limited and its subsidiary companies. |
| 176 | 176 |
***********************************************************************************/ |
| 177 | 177 |
|
| 178 |
-#ifndef _SNES9X_H_ |
|
| 179 |
-#define _SNES9X_H_ |
|
| 178 |
+#pragma once |
|
| 180 | 179 |
|
| 181 | 180 |
#ifndef VERSION |
| 182 | 181 |
#define VERSION "1.53" |
| ... | ... |
@@ -306,5 +305,3 @@ extern SSettings Settings; |
| 306 | 305 |
extern SCPUState CPU; |
| 307 | 306 |
extern STimings Timings; |
| 308 | 307 |
extern SSNESGameFixes SNESGameFixes; |
| 309 |
- |
|
| 310 |
-#endif |
| ... | ... |
@@ -175,295 +175,137 @@ |
| 175 | 175 |
Nintendo Co., Limited and its subsidiary companies. |
| 176 | 176 |
***********************************************************************************/ |
| 177 | 177 |
|
| 178 |
- |
|
| 179 | 178 |
#ifndef _SNES9X_H_ |
| 180 | 179 |
#define _SNES9X_H_ |
| 181 | 180 |
|
| 182 | 181 |
#ifndef VERSION |
| 183 |
-#define VERSION "1.53" |
|
| 182 |
+#define VERSION "1.53" |
|
| 184 | 183 |
#endif |
| 185 | 184 |
|
| 186 | 185 |
#include "port.h" |
| 187 |
-#include "65c816.h" |
|
| 188 |
-//#include "messages.h" |
|
| 189 |
- |
|
| 190 |
-#ifdef ZLIB |
|
| 191 |
-#include <zlib.h> |
|
| 192 |
-#define STREAM gzFile |
|
| 193 |
-#define READ_STREAM(p, l, s) gzread(s, p, l) |
|
| 194 |
-#define WRITE_STREAM(p, l, s) gzwrite(s, p, l) |
|
| 195 |
-#define GETS_STREAM(p, l, s) gzgets(s, p, l) |
|
| 196 |
-#define GETC_STREAM(s) gzgetc(s) |
|
| 197 |
-#define OPEN_STREAM(f, m) gzopen(f, m) |
|
| 198 |
-#define REOPEN_STREAM(f, m) gzdopen(f, m) |
|
| 199 |
-#define FIND_STREAM(f) gztell(f) |
|
| 200 |
-#define REVERT_STREAM(f, o, s) gzseek(f, o, s) |
|
| 201 |
-#define CLOSE_STREAM(s) gzclose(s) |
|
| 202 |
-#else |
|
| 203 |
-#define STREAM FILE * |
|
| 204 |
-#define READ_STREAM(p, l, s) fread(p, 1, l, s) |
|
| 205 |
-#define WRITE_STREAM(p, l, s) fwrite(p, 1, l, s) |
|
| 206 |
-#define GETS_STREAM(p, l, s) fgets(p, l, s) |
|
| 207 |
-#define GETC_STREAM(s) fgetc(s) |
|
| 208 |
-#define OPEN_STREAM(f, m) fopen(f, m) |
|
| 209 |
-#define REOPEN_STREAM(f, m) fdopen(f, m) |
|
| 210 |
-#define FIND_STREAM(f) ftell(f) |
|
| 211 |
-#define REVERT_STREAM(f, o, s) fseek(f, o, s) |
|
| 212 |
-#define CLOSE_STREAM(s) fclose(s) |
|
| 213 |
-#endif |
|
| 214 | 186 |
|
| 215 |
-#define SNES_WIDTH 256 |
|
| 216 |
-#define SNES_HEIGHT 224 |
|
| 217 |
-#define SNES_HEIGHT_EXTENDED 239 |
|
| 218 |
-#define MAX_SNES_WIDTH (SNES_WIDTH * 2) |
|
| 219 |
-#define MAX_SNES_HEIGHT (SNES_HEIGHT_EXTENDED * 2) |
|
| 220 |
-#define IMAGE_WIDTH (Settings.SupportHiRes ? MAX_SNES_WIDTH : SNES_WIDTH) |
|
| 221 |
-#define IMAGE_HEIGHT (Settings.SupportHiRes ? MAX_SNES_HEIGHT : SNES_HEIGHT_EXTENDED) |
|
| 222 |
- |
|
| 223 |
-#define NTSC_MASTER_CLOCK 21477272.0 |
|
| 224 |
-#define PAL_MASTER_CLOCK 21281370.0 |
|
| 225 |
- |
|
| 226 |
-#define SNES_MAX_NTSC_VCOUNTER 262 |
|
| 227 |
-#define SNES_MAX_PAL_VCOUNTER 312 |
|
| 228 |
-#define SNES_HCOUNTER_MAX 341 |
|
| 229 |
- |
|
| 230 |
-#define ONE_CYCLE 6 |
|
| 231 |
-#define SLOW_ONE_CYCLE 8 |
|
| 232 |
-#define TWO_CYCLES 12 |
|
| 233 |
-#define ONE_DOT_CYCLE 4 |
|
| 234 |
- |
|
| 235 |
-#define SNES_CYCLES_PER_SCANLINE (SNES_HCOUNTER_MAX * ONE_DOT_CYCLE) |
|
| 236 |
-#define SNES_SCANLINE_TIME (SNES_CYCLES_PER_SCANLINE / NTSC_MASTER_CLOCK) |
|
| 237 |
- |
|
| 238 |
-#define SNES_WRAM_REFRESH_HC_v1 530 |
|
| 239 |
-#define SNES_WRAM_REFRESH_HC_v2 538 |
|
| 240 |
-#define SNES_WRAM_REFRESH_CYCLES 40 |
|
| 241 |
- |
|
| 242 |
-#define SNES_HBLANK_START_HC 1096 // H=274 |
|
| 243 |
-#define SNES_HDMA_START_HC 1106 // FIXME: not true |
|
| 244 |
-#define SNES_HBLANK_END_HC 4 // H=1 |
|
| 245 |
-#define SNES_HDMA_INIT_HC 20 // FIXME: not true |
|
| 246 |
-#define SNES_RENDER_START_HC (48 * ONE_DOT_CYCLE) // FIXME: Snes9x renders a line at a time. |
|
| 247 |
- |
|
| 248 |
-#define SNES_TR_MASK (1 << 4) |
|
| 249 |
-#define SNES_TL_MASK (1 << 5) |
|
| 250 |
-#define SNES_X_MASK (1 << 6) |
|
| 251 |
-#define SNES_A_MASK (1 << 7) |
|
| 252 |
-#define SNES_RIGHT_MASK (1 << 8) |
|
| 253 |
-#define SNES_LEFT_MASK (1 << 9) |
|
| 254 |
-#define SNES_DOWN_MASK (1 << 10) |
|
| 255 |
-#define SNES_UP_MASK (1 << 11) |
|
| 256 |
-#define SNES_START_MASK (1 << 12) |
|
| 257 |
-#define SNES_SELECT_MASK (1 << 13) |
|
| 258 |
-#define SNES_Y_MASK (1 << 14) |
|
| 259 |
-#define SNES_B_MASK (1 << 15) |
|
| 260 |
- |
|
| 261 |
-#define DEBUG_MODE_FLAG (1 << 0) // debugger |
|
| 262 |
-#define TRACE_FLAG (1 << 1) // debugger |
|
| 263 |
-#define SINGLE_STEP_FLAG (1 << 2) // debugger |
|
| 264 |
-#define BREAK_FLAG (1 << 3) // debugger |
|
| 265 |
-#define SCAN_KEYS_FLAG (1 << 4) // CPU |
|
| 266 |
-#define HALTED_FLAG (1 << 12) // APU |
|
| 267 |
-#define FRAME_ADVANCE_FLAG (1 << 9) |
|
| 268 |
- |
|
| 269 |
-#define ROM_NAME_LEN 23 |
|
| 270 |
-#define AUTO_FRAMERATE 200 |
|
| 187 |
+const int SNES_WIDTH = 256; |
|
| 188 |
+const int SNES_HEIGHT = 224; |
|
| 189 |
+const uint16_t SNES_HEIGHT_EXTENDED = 239; |
|
| 190 |
+ |
|
| 191 |
+const int32_t SNES_MAX_NTSC_VCOUNTER = 262; |
|
| 192 |
+const int32_t SNES_MAX_PAL_VCOUNTER = 312; |
|
| 193 |
+const int32_t SNES_HCOUNTER_MAX = 341; |
|
| 194 |
+ |
|
| 195 |
+const int32_t ONE_CYCLE = 6; |
|
| 196 |
+const int32_t SLOW_ONE_CYCLE = 8; |
|
| 197 |
+const int32_t TWO_CYCLES = 12; |
|
| 198 |
+const int32_t ONE_DOT_CYCLE = 4; |
|
| 199 |
+ |
|
| 200 |
+const int32_t SNES_CYCLES_PER_SCANLINE = SNES_HCOUNTER_MAX * ONE_DOT_CYCLE; |
|
| 201 |
+ |
|
| 202 |
+const int32_t SNES_WRAM_REFRESH_HC_v1 = 530; |
|
| 203 |
+const int32_t SNES_WRAM_REFRESH_HC_v2 = 538; |
|
| 204 |
+const int32_t SNES_WRAM_REFRESH_CYCLES = 40; |
|
| 205 |
+ |
|
| 206 |
+const int32_t SNES_HBLANK_START_HC = 1096; // H=274 |
|
| 207 |
+const int32_t SNES_HDMA_START_HC = 1106; // FIXME: not true |
|
| 208 |
+const int32_t SNES_HBLANK_END_HC = 4; // H=1 |
|
| 209 |
+const int32_t SNES_HDMA_INIT_HC = 20; // FIXME: not true |
|
| 210 |
+const int32_t SNES_RENDER_START_HC = 48 * ONE_DOT_CYCLE; // FIXME: Snes9x renders a line at a time. |
|
| 211 |
+ |
|
| 212 |
+const uint32_t DEBUG_MODE_FLAG = 1; // debugger |
|
| 213 |
+const uint32_t TRACE_FLAG = 1 << 1; // debugger |
|
| 214 |
+const uint32_t SCAN_KEYS_FLAG = 1 << 4; // CPU |
|
| 215 |
+const uint32_t HALTED_FLAG = 1 << 12; // APU |
|
| 216 |
+ |
|
| 217 |
+const size_t ROM_NAME_LEN = 23; |
|
| 271 | 218 |
|
| 272 | 219 |
struct SCPUState |
| 273 | 220 |
{
|
| 274 |
- uint32_t Flags; |
|
| 275 |
- int32_t Cycles; |
|
| 276 |
- int32_t PrevCycles; |
|
| 277 |
- int32_t V_Counter; |
|
| 278 |
- uint8_t *PCBase; |
|
| 279 |
- bool NMILine; |
|
| 280 |
- bool IRQLine; |
|
| 281 |
- bool IRQTransition; |
|
| 282 |
- bool IRQLastState; |
|
| 283 |
- bool IRQExternal; |
|
| 284 |
- int32_t IRQPending; |
|
| 285 |
- int32_t MemSpeed; |
|
| 286 |
- int32_t MemSpeedx2; |
|
| 287 |
- int32_t FastROMSpeed; |
|
| 288 |
- bool InDMA; |
|
| 289 |
- bool InHDMA; |
|
| 290 |
- bool InDMAorHDMA; |
|
| 291 |
- bool InWRAMDMAorHDMA; |
|
| 292 |
- uint8_t HDMARanInDMA; |
|
| 293 |
- int32_t CurrentDMAorHDMAChannel; |
|
| 294 |
- uint8_t WhichEvent; |
|
| 295 |
- int32_t NextEvent; |
|
| 296 |
- bool WaitingForInterrupt; |
|
| 297 |
- uint32_t AutoSaveTimer; |
|
| 298 |
- bool SRAMModified; |
|
| 221 |
+ uint32_t Flags; |
|
| 222 |
+ int32_t Cycles; |
|
| 223 |
+ int32_t PrevCycles; |
|
| 224 |
+ int32_t V_Counter; |
|
| 225 |
+ uint8_t *PCBase; |
|
| 226 |
+ bool NMILine; |
|
| 227 |
+ bool IRQLine; |
|
| 228 |
+ bool IRQTransition; |
|
| 229 |
+ bool IRQLastState; |
|
| 230 |
+ int32_t IRQPending; |
|
| 231 |
+ int32_t MemSpeed; |
|
| 232 |
+ int32_t MemSpeedx2; |
|
| 233 |
+ int32_t FastROMSpeed; |
|
| 234 |
+ bool InDMA; |
|
| 235 |
+ bool InHDMA; |
|
| 236 |
+ bool InDMAorHDMA; |
|
| 237 |
+ bool InWRAMDMAorHDMA; |
|
| 238 |
+ uint8_t HDMARanInDMA; |
|
| 239 |
+ int32_t CurrentDMAorHDMAChannel; |
|
| 240 |
+ uint8_t WhichEvent; |
|
| 241 |
+ int32_t NextEvent; |
|
| 242 |
+ bool WaitingForInterrupt; |
|
| 299 | 243 |
}; |
| 300 | 244 |
|
| 301 | 245 |
enum |
| 302 | 246 |
{
|
| 303 | 247 |
HC_HBLANK_START_EVENT = 1, |
| 304 |
- HC_HDMA_START_EVENT = 2, |
|
| 248 |
+ HC_HDMA_START_EVENT = 2, |
|
| 305 | 249 |
HC_HCOUNTER_MAX_EVENT = 3, |
| 306 |
- HC_HDMA_INIT_EVENT = 4, |
|
| 307 |
- HC_RENDER_EVENT = 5, |
|
| 250 |
+ HC_HDMA_INIT_EVENT = 4, |
|
| 251 |
+ HC_RENDER_EVENT = 5, |
|
| 308 | 252 |
HC_WRAM_REFRESH_EVENT = 6 |
| 309 | 253 |
}; |
| 310 | 254 |
|
| 311 | 255 |
struct STimings |
| 312 | 256 |
{
|
| 313 |
- int32_t H_Max_Master; |
|
| 314 |
- int32_t H_Max; |
|
| 315 |
- int32_t V_Max_Master; |
|
| 316 |
- int32_t V_Max; |
|
| 317 |
- int32_t HBlankStart; |
|
| 318 |
- int32_t HBlankEnd; |
|
| 319 |
- int32_t HDMAInit; |
|
| 320 |
- int32_t HDMAStart; |
|
| 321 |
- int32_t NMITriggerPos; |
|
| 322 |
- int32_t IRQTriggerCycles; |
|
| 323 |
- int32_t WRAMRefreshPos; |
|
| 324 |
- int32_t RenderPos; |
|
| 325 |
- bool InterlaceField; |
|
| 326 |
- int32_t DMACPUSync; // The cycles to synchronize DMA and CPU. Snes9x cannot emulate correctly. |
|
| 327 |
- int32_t NMIDMADelay; // The delay of NMI trigger after DMA transfers. Snes9x cannot emulate correctly. |
|
| 328 |
- int32_t IRQPendCount; // This value is just a hack. |
|
| 329 |
- int32_t APUSpeedup; |
|
| 330 |
- bool APUAllowTimeOverflow; |
|
| 257 |
+ int32_t H_Max_Master; |
|
| 258 |
+ int32_t H_Max; |
|
| 259 |
+ int32_t V_Max_Master; |
|
| 260 |
+ int32_t V_Max; |
|
| 261 |
+ int32_t HBlankStart; |
|
| 262 |
+ int32_t HBlankEnd; |
|
| 263 |
+ int32_t HDMAInit; |
|
| 264 |
+ int32_t HDMAStart; |
|
| 265 |
+ int32_t NMITriggerPos; |
|
| 266 |
+ int32_t IRQTriggerCycles; |
|
| 267 |
+ int32_t WRAMRefreshPos; |
|
| 268 |
+ int32_t RenderPos; |
|
| 269 |
+ bool InterlaceField; |
|
| 270 |
+ int32_t DMACPUSync; // The cycles to synchronize DMA and CPU. Snes9x cannot emulate correctly. |
|
| 271 |
+ int32_t NMIDMADelay; // The delay of NMI trigger after DMA transfers. Snes9x cannot emulate correctly. |
|
| 272 |
+ int32_t IRQPendCount; // This value is just a hack. |
|
| 273 |
+ int32_t APUSpeedup; |
|
| 274 |
+ bool APUAllowTimeOverflow; |
|
| 331 | 275 |
}; |
| 332 | 276 |
|
| 333 | 277 |
struct SSettings |
| 334 | 278 |
{
|
| 335 |
- bool TraceDMA; |
|
| 336 |
- bool TraceHDMA; |
|
| 337 |
- bool TraceVRAM; |
|
| 338 |
- bool TraceUnknownRegisters; |
|
| 339 |
- bool TraceDSP; |
|
| 340 |
- bool TraceHCEvent; |
|
| 341 |
- |
|
| 342 |
- bool SuperFX; |
|
| 343 |
- uint8_t DSP; |
|
| 344 |
- bool SA1; |
|
| 345 |
- bool C4; |
|
| 346 |
- bool SDD1; |
|
| 347 |
- bool SPC7110; |
|
| 348 |
- bool SPC7110RTC; |
|
| 349 |
- bool OBC1; |
|
| 350 |
- uint8_t SETA; |
|
| 351 |
- bool SRTC; |
|
| 352 |
- bool BS; |
|
| 353 |
- bool BSXItself; |
|
| 354 |
- bool BSXBootup; |
|
| 355 |
- bool MouseMaster; |
|
| 356 |
- bool SuperScopeMaster; |
|
| 357 |
- bool JustifierMaster; |
|
| 358 |
- bool MultiPlayer5Master; |
|
| 359 |
- |
|
| 360 |
- bool ForceLoROM; |
|
| 361 |
- bool ForceHiROM; |
|
| 362 |
- bool ForceHeader; |
|
| 363 |
- bool ForceNoHeader; |
|
| 364 |
- bool ForceInterleaved; |
|
| 365 |
- bool ForceInterleaved2; |
|
| 366 |
- bool ForceInterleaveGD24; |
|
| 367 |
- bool ForceNotInterleaved; |
|
| 368 |
- bool ForcePAL; |
|
| 369 |
- bool ForceNTSC; |
|
| 370 |
- bool PAL; |
|
| 371 |
- uint32_t FrameTimePAL; |
|
| 372 |
- uint32_t FrameTimeNTSC; |
|
| 373 |
- uint32_t FrameTime; |
|
| 374 |
- |
|
| 375 |
- bool SoundSync; |
|
| 376 |
- bool SixteenBitSound; |
|
| 377 |
- uint32_t SoundPlaybackRate; |
|
| 378 |
- uint32_t SoundInputRate; |
|
| 379 |
- bool Stereo; |
|
| 380 |
- bool ReverseStereo; |
|
| 381 |
- bool Mute; |
|
| 382 |
- |
|
| 383 |
- bool SupportHiRes; |
|
| 384 |
- bool Transparency; |
|
| 385 |
- uint8_t BG_Forced; |
|
| 386 |
- bool DisableGraphicWindows; |
|
| 387 |
- |
|
| 388 |
- bool DisplayFrameRate; |
|
| 389 |
- bool DisplayWatchedAddresses; |
|
| 390 |
- bool DisplayPressedKeys; |
|
| 391 |
- bool DisplayMovieFrame; |
|
| 392 |
- bool AutoDisplayMessages; |
|
| 393 |
- uint32_t InitialInfoStringTimeout; |
|
| 394 |
- uint16_t DisplayColor; |
|
| 395 |
- |
|
| 396 |
- bool Multi; |
|
| 397 |
- char CartAName[PATH_MAX + 1]; |
|
| 398 |
- char CartBName[PATH_MAX + 1]; |
|
| 399 |
- |
|
| 400 |
- bool DisableGameSpecificHacks; |
|
| 401 |
- bool BlockInvalidVRAMAccessMaster; |
|
| 402 |
- bool BlockInvalidVRAMAccess; |
|
| 403 |
- int32_t HDMATimingHack; |
|
| 404 |
- |
|
| 405 |
- bool ForcedPause; |
|
| 406 |
- bool Paused; |
|
| 407 |
- bool StopEmulation; |
|
| 408 |
- |
|
| 409 |
- uint32_t SkipFrames; |
|
| 410 |
- uint32_t TurboSkipFrames; |
|
| 411 |
- uint32_t AutoMaxSkipFrames; |
|
| 412 |
- bool TurboMode; |
|
| 413 |
- uint32_t HighSpeedSeek; |
|
| 414 |
- bool FrameAdvance; |
|
| 415 |
- |
|
| 416 |
- bool NetPlay; |
|
| 417 |
- bool NetPlayServer; |
|
| 418 |
- char ServerName[128]; |
|
| 419 |
- int Port; |
|
| 420 |
- |
|
| 421 |
- bool MovieTruncate; |
|
| 422 |
- bool MovieNotifyIgnored; |
|
| 423 |
- bool WrongMovieStateProtection; |
|
| 424 |
- bool DumpStreams; |
|
| 425 |
- int DumpStreamsMaxFrames; |
|
| 426 |
- |
|
| 427 |
- bool TakeScreenshot; |
|
| 428 |
- int8_t StretchScreenshots; |
|
| 429 |
- bool SnapshotScreenshots; |
|
| 430 |
- |
|
| 431 |
- bool ApplyCheats; |
|
| 432 |
- bool NoPatch; |
|
| 433 |
- int32_t AutoSaveDelay; |
|
| 434 |
- bool DontSaveOopsSnapshot; |
|
| 435 |
- bool UpAndDown; |
|
| 436 |
- |
|
| 437 |
- bool OpenGLEnable; |
|
| 438 |
-}; |
|
| 279 |
+ bool SDD1; |
|
| 439 | 280 |
|
| 440 |
-struct SSNESGameFixes |
|
| 441 |
-{
|
|
| 442 |
- uint8_t SRAMInitialValue; |
|
| 443 |
- uint8_t Uniracers; |
|
| 281 |
+ bool ForceNotInterleaved; |
|
| 282 |
+ bool PAL; |
|
| 283 |
+ |
|
| 284 |
+ bool SoundSync; |
|
| 285 |
+ bool SixteenBitSound; |
|
| 286 |
+ uint32_t SoundPlaybackRate; |
|
| 287 |
+ uint32_t SoundInputRate; |
|
| 288 |
+ bool Stereo; |
|
| 289 |
+ bool ReverseStereo; |
|
| 290 |
+ bool Mute; |
|
| 291 |
+ |
|
| 292 |
+ bool DisableGameSpecificHacks; |
|
| 293 |
+ bool BlockInvalidVRAMAccessMaster; |
|
| 294 |
+ bool BlockInvalidVRAMAccess; |
|
| 295 |
+ int32_t HDMATimingHack; |
|
| 296 |
+ |
|
| 297 |
+ bool TurboMode; |
|
| 444 | 298 |
}; |
| 445 | 299 |
|
| 446 |
-enum |
|
| 300 |
+struct SSNESGameFixes |
|
| 447 | 301 |
{
|
| 448 |
- PAUSE_NETPLAY_CONNECT = (1 << 0), |
|
| 449 |
- PAUSE_TOGGLE_FULL_SCREEN = (1 << 1), |
|
| 450 |
- PAUSE_EXIT = (1 << 2), |
|
| 451 |
- PAUSE_MENU = (1 << 3), |
|
| 452 |
- PAUSE_INACTIVE_WINDOW = (1 << 4), |
|
| 453 |
- PAUSE_WINDOW_ICONISED = (1 << 5), |
|
| 454 |
- PAUSE_RESTORE_GUI = (1 << 6), |
|
| 455 |
- PAUSE_FREEZE_FILE = (1 << 7) |
|
| 302 |
+ uint8_t SRAMInitialValue; |
|
| 303 |
+ bool Uniracers; |
|
| 456 | 304 |
}; |
| 457 | 305 |
|
| 458 |
-void S9xSetPause(uint32_t); |
|
| 459 |
-void S9xClearPause(uint32_t); |
|
| 460 |
-void S9xExi(); |
|
| 461 |
-void S9xMessage(int, int, const char *); |
|
| 462 |
- |
|
| 463 |
-extern struct SSettings Settings; |
|
| 464 |
-extern struct SCPUState CPU; |
|
| 465 |
-extern struct STimings Timings; |
|
| 466 |
-extern struct SSNESGameFixes SNESGameFixes; |
|
| 467 |
-//extern char String[513]; |
|
| 306 |
+extern SSettings Settings; |
|
| 307 |
+extern SCPUState CPU; |
|
| 308 |
+extern STimings Timings; |
|
| 309 |
+extern SSNESGameFixes SNESGameFixes; |
|
| 468 | 310 |
|
| 469 | 311 |
#endif |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,469 @@ |
| 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 _SNES9X_H_ |
|
| 180 |
+#define _SNES9X_H_ |
|
| 181 |
+ |
|
| 182 |
+#ifndef VERSION |
|
| 183 |
+#define VERSION "1.53" |
|
| 184 |
+#endif |
|
| 185 |
+ |
|
| 186 |
+#include "port.h" |
|
| 187 |
+#include "65c816.h" |
|
| 188 |
+//#include "messages.h" |
|
| 189 |
+ |
|
| 190 |
+#ifdef ZLIB |
|
| 191 |
+#include <zlib.h> |
|
| 192 |
+#define STREAM gzFile |
|
| 193 |
+#define READ_STREAM(p, l, s) gzread(s, p, l) |
|
| 194 |
+#define WRITE_STREAM(p, l, s) gzwrite(s, p, l) |
|
| 195 |
+#define GETS_STREAM(p, l, s) gzgets(s, p, l) |
|
| 196 |
+#define GETC_STREAM(s) gzgetc(s) |
|
| 197 |
+#define OPEN_STREAM(f, m) gzopen(f, m) |
|
| 198 |
+#define REOPEN_STREAM(f, m) gzdopen(f, m) |
|
| 199 |
+#define FIND_STREAM(f) gztell(f) |
|
| 200 |
+#define REVERT_STREAM(f, o, s) gzseek(f, o, s) |
|
| 201 |
+#define CLOSE_STREAM(s) gzclose(s) |
|
| 202 |
+#else |
|
| 203 |
+#define STREAM FILE * |
|
| 204 |
+#define READ_STREAM(p, l, s) fread(p, 1, l, s) |
|
| 205 |
+#define WRITE_STREAM(p, l, s) fwrite(p, 1, l, s) |
|
| 206 |
+#define GETS_STREAM(p, l, s) fgets(p, l, s) |
|
| 207 |
+#define GETC_STREAM(s) fgetc(s) |
|
| 208 |
+#define OPEN_STREAM(f, m) fopen(f, m) |
|
| 209 |
+#define REOPEN_STREAM(f, m) fdopen(f, m) |
|
| 210 |
+#define FIND_STREAM(f) ftell(f) |
|
| 211 |
+#define REVERT_STREAM(f, o, s) fseek(f, o, s) |
|
| 212 |
+#define CLOSE_STREAM(s) fclose(s) |
|
| 213 |
+#endif |
|
| 214 |
+ |
|
| 215 |
+#define SNES_WIDTH 256 |
|
| 216 |
+#define SNES_HEIGHT 224 |
|
| 217 |
+#define SNES_HEIGHT_EXTENDED 239 |
|
| 218 |
+#define MAX_SNES_WIDTH (SNES_WIDTH * 2) |
|
| 219 |
+#define MAX_SNES_HEIGHT (SNES_HEIGHT_EXTENDED * 2) |
|
| 220 |
+#define IMAGE_WIDTH (Settings.SupportHiRes ? MAX_SNES_WIDTH : SNES_WIDTH) |
|
| 221 |
+#define IMAGE_HEIGHT (Settings.SupportHiRes ? MAX_SNES_HEIGHT : SNES_HEIGHT_EXTENDED) |
|
| 222 |
+ |
|
| 223 |
+#define NTSC_MASTER_CLOCK 21477272.0 |
|
| 224 |
+#define PAL_MASTER_CLOCK 21281370.0 |
|
| 225 |
+ |
|
| 226 |
+#define SNES_MAX_NTSC_VCOUNTER 262 |
|
| 227 |
+#define SNES_MAX_PAL_VCOUNTER 312 |
|
| 228 |
+#define SNES_HCOUNTER_MAX 341 |
|
| 229 |
+ |
|
| 230 |
+#define ONE_CYCLE 6 |
|
| 231 |
+#define SLOW_ONE_CYCLE 8 |
|
| 232 |
+#define TWO_CYCLES 12 |
|
| 233 |
+#define ONE_DOT_CYCLE 4 |
|
| 234 |
+ |
|
| 235 |
+#define SNES_CYCLES_PER_SCANLINE (SNES_HCOUNTER_MAX * ONE_DOT_CYCLE) |
|
| 236 |
+#define SNES_SCANLINE_TIME (SNES_CYCLES_PER_SCANLINE / NTSC_MASTER_CLOCK) |
|
| 237 |
+ |
|
| 238 |
+#define SNES_WRAM_REFRESH_HC_v1 530 |
|
| 239 |
+#define SNES_WRAM_REFRESH_HC_v2 538 |
|
| 240 |
+#define SNES_WRAM_REFRESH_CYCLES 40 |
|
| 241 |
+ |
|
| 242 |
+#define SNES_HBLANK_START_HC 1096 // H=274 |
|
| 243 |
+#define SNES_HDMA_START_HC 1106 // FIXME: not true |
|
| 244 |
+#define SNES_HBLANK_END_HC 4 // H=1 |
|
| 245 |
+#define SNES_HDMA_INIT_HC 20 // FIXME: not true |
|
| 246 |
+#define SNES_RENDER_START_HC (48 * ONE_DOT_CYCLE) // FIXME: Snes9x renders a line at a time. |
|
| 247 |
+ |
|
| 248 |
+#define SNES_TR_MASK (1 << 4) |
|
| 249 |
+#define SNES_TL_MASK (1 << 5) |
|
| 250 |
+#define SNES_X_MASK (1 << 6) |
|
| 251 |
+#define SNES_A_MASK (1 << 7) |
|
| 252 |
+#define SNES_RIGHT_MASK (1 << 8) |
|
| 253 |
+#define SNES_LEFT_MASK (1 << 9) |
|
| 254 |
+#define SNES_DOWN_MASK (1 << 10) |
|
| 255 |
+#define SNES_UP_MASK (1 << 11) |
|
| 256 |
+#define SNES_START_MASK (1 << 12) |
|
| 257 |
+#define SNES_SELECT_MASK (1 << 13) |
|
| 258 |
+#define SNES_Y_MASK (1 << 14) |
|
| 259 |
+#define SNES_B_MASK (1 << 15) |
|
| 260 |
+ |
|
| 261 |
+#define DEBUG_MODE_FLAG (1 << 0) // debugger |
|
| 262 |
+#define TRACE_FLAG (1 << 1) // debugger |
|
| 263 |
+#define SINGLE_STEP_FLAG (1 << 2) // debugger |
|
| 264 |
+#define BREAK_FLAG (1 << 3) // debugger |
|
| 265 |
+#define SCAN_KEYS_FLAG (1 << 4) // CPU |
|
| 266 |
+#define HALTED_FLAG (1 << 12) // APU |
|
| 267 |
+#define FRAME_ADVANCE_FLAG (1 << 9) |
|
| 268 |
+ |
|
| 269 |
+#define ROM_NAME_LEN 23 |
|
| 270 |
+#define AUTO_FRAMERATE 200 |
|
| 271 |
+ |
|
| 272 |
+struct SCPUState |
|
| 273 |
+{
|
|
| 274 |
+ uint32_t Flags; |
|
| 275 |
+ int32_t Cycles; |
|
| 276 |
+ int32_t PrevCycles; |
|
| 277 |
+ int32_t V_Counter; |
|
| 278 |
+ uint8_t *PCBase; |
|
| 279 |
+ bool NMILine; |
|
| 280 |
+ bool IRQLine; |
|
| 281 |
+ bool IRQTransition; |
|
| 282 |
+ bool IRQLastState; |
|
| 283 |
+ bool IRQExternal; |
|
| 284 |
+ int32_t IRQPending; |
|
| 285 |
+ int32_t MemSpeed; |
|
| 286 |
+ int32_t MemSpeedx2; |
|
| 287 |
+ int32_t FastROMSpeed; |
|
| 288 |
+ bool InDMA; |
|
| 289 |
+ bool InHDMA; |
|
| 290 |
+ bool InDMAorHDMA; |
|
| 291 |
+ bool InWRAMDMAorHDMA; |
|
| 292 |
+ uint8_t HDMARanInDMA; |
|
| 293 |
+ int32_t CurrentDMAorHDMAChannel; |
|
| 294 |
+ uint8_t WhichEvent; |
|
| 295 |
+ int32_t NextEvent; |
|
| 296 |
+ bool WaitingForInterrupt; |
|
| 297 |
+ uint32_t AutoSaveTimer; |
|
| 298 |
+ bool SRAMModified; |
|
| 299 |
+}; |
|
| 300 |
+ |
|
| 301 |
+enum |
|
| 302 |
+{
|
|
| 303 |
+ HC_HBLANK_START_EVENT = 1, |
|
| 304 |
+ HC_HDMA_START_EVENT = 2, |
|
| 305 |
+ HC_HCOUNTER_MAX_EVENT = 3, |
|
| 306 |
+ HC_HDMA_INIT_EVENT = 4, |
|
| 307 |
+ HC_RENDER_EVENT = 5, |
|
| 308 |
+ HC_WRAM_REFRESH_EVENT = 6 |
|
| 309 |
+}; |
|
| 310 |
+ |
|
| 311 |
+struct STimings |
|
| 312 |
+{
|
|
| 313 |
+ int32_t H_Max_Master; |
|
| 314 |
+ int32_t H_Max; |
|
| 315 |
+ int32_t V_Max_Master; |
|
| 316 |
+ int32_t V_Max; |
|
| 317 |
+ int32_t HBlankStart; |
|
| 318 |
+ int32_t HBlankEnd; |
|
| 319 |
+ int32_t HDMAInit; |
|
| 320 |
+ int32_t HDMAStart; |
|
| 321 |
+ int32_t NMITriggerPos; |
|
| 322 |
+ int32_t IRQTriggerCycles; |
|
| 323 |
+ int32_t WRAMRefreshPos; |
|
| 324 |
+ int32_t RenderPos; |
|
| 325 |
+ bool InterlaceField; |
|
| 326 |
+ int32_t DMACPUSync; // The cycles to synchronize DMA and CPU. Snes9x cannot emulate correctly. |
|
| 327 |
+ int32_t NMIDMADelay; // The delay of NMI trigger after DMA transfers. Snes9x cannot emulate correctly. |
|
| 328 |
+ int32_t IRQPendCount; // This value is just a hack. |
|
| 329 |
+ int32_t APUSpeedup; |
|
| 330 |
+ bool APUAllowTimeOverflow; |
|
| 331 |
+}; |
|
| 332 |
+ |
|
| 333 |
+struct SSettings |
|
| 334 |
+{
|
|
| 335 |
+ bool TraceDMA; |
|
| 336 |
+ bool TraceHDMA; |
|
| 337 |
+ bool TraceVRAM; |
|
| 338 |
+ bool TraceUnknownRegisters; |
|
| 339 |
+ bool TraceDSP; |
|
| 340 |
+ bool TraceHCEvent; |
|
| 341 |
+ |
|
| 342 |
+ bool SuperFX; |
|
| 343 |
+ uint8_t DSP; |
|
| 344 |
+ bool SA1; |
|
| 345 |
+ bool C4; |
|
| 346 |
+ bool SDD1; |
|
| 347 |
+ bool SPC7110; |
|
| 348 |
+ bool SPC7110RTC; |
|
| 349 |
+ bool OBC1; |
|
| 350 |
+ uint8_t SETA; |
|
| 351 |
+ bool SRTC; |
|
| 352 |
+ bool BS; |
|
| 353 |
+ bool BSXItself; |
|
| 354 |
+ bool BSXBootup; |
|
| 355 |
+ bool MouseMaster; |
|
| 356 |
+ bool SuperScopeMaster; |
|
| 357 |
+ bool JustifierMaster; |
|
| 358 |
+ bool MultiPlayer5Master; |
|
| 359 |
+ |
|
| 360 |
+ bool ForceLoROM; |
|
| 361 |
+ bool ForceHiROM; |
|
| 362 |
+ bool ForceHeader; |
|
| 363 |
+ bool ForceNoHeader; |
|
| 364 |
+ bool ForceInterleaved; |
|
| 365 |
+ bool ForceInterleaved2; |
|
| 366 |
+ bool ForceInterleaveGD24; |
|
| 367 |
+ bool ForceNotInterleaved; |
|
| 368 |
+ bool ForcePAL; |
|
| 369 |
+ bool ForceNTSC; |
|
| 370 |
+ bool PAL; |
|
| 371 |
+ uint32_t FrameTimePAL; |
|
| 372 |
+ uint32_t FrameTimeNTSC; |
|
| 373 |
+ uint32_t FrameTime; |
|
| 374 |
+ |
|
| 375 |
+ bool SoundSync; |
|
| 376 |
+ bool SixteenBitSound; |
|
| 377 |
+ uint32_t SoundPlaybackRate; |
|
| 378 |
+ uint32_t SoundInputRate; |
|
| 379 |
+ bool Stereo; |
|
| 380 |
+ bool ReverseStereo; |
|
| 381 |
+ bool Mute; |
|
| 382 |
+ |
|
| 383 |
+ bool SupportHiRes; |
|
| 384 |
+ bool Transparency; |
|
| 385 |
+ uint8_t BG_Forced; |
|
| 386 |
+ bool DisableGraphicWindows; |
|
| 387 |
+ |
|
| 388 |
+ bool DisplayFrameRate; |
|
| 389 |
+ bool DisplayWatchedAddresses; |
|
| 390 |
+ bool DisplayPressedKeys; |
|
| 391 |
+ bool DisplayMovieFrame; |
|
| 392 |
+ bool AutoDisplayMessages; |
|
| 393 |
+ uint32_t InitialInfoStringTimeout; |
|
| 394 |
+ uint16_t DisplayColor; |
|
| 395 |
+ |
|
| 396 |
+ bool Multi; |
|
| 397 |
+ char CartAName[PATH_MAX + 1]; |
|
| 398 |
+ char CartBName[PATH_MAX + 1]; |
|
| 399 |
+ |
|
| 400 |
+ bool DisableGameSpecificHacks; |
|
| 401 |
+ bool BlockInvalidVRAMAccessMaster; |
|
| 402 |
+ bool BlockInvalidVRAMAccess; |
|
| 403 |
+ int32_t HDMATimingHack; |
|
| 404 |
+ |
|
| 405 |
+ bool ForcedPause; |
|
| 406 |
+ bool Paused; |
|
| 407 |
+ bool StopEmulation; |
|
| 408 |
+ |
|
| 409 |
+ uint32_t SkipFrames; |
|
| 410 |
+ uint32_t TurboSkipFrames; |
|
| 411 |
+ uint32_t AutoMaxSkipFrames; |
|
| 412 |
+ bool TurboMode; |
|
| 413 |
+ uint32_t HighSpeedSeek; |
|
| 414 |
+ bool FrameAdvance; |
|
| 415 |
+ |
|
| 416 |
+ bool NetPlay; |
|
| 417 |
+ bool NetPlayServer; |
|
| 418 |
+ char ServerName[128]; |
|
| 419 |
+ int Port; |
|
| 420 |
+ |
|
| 421 |
+ bool MovieTruncate; |
|
| 422 |
+ bool MovieNotifyIgnored; |
|
| 423 |
+ bool WrongMovieStateProtection; |
|
| 424 |
+ bool DumpStreams; |
|
| 425 |
+ int DumpStreamsMaxFrames; |
|
| 426 |
+ |
|
| 427 |
+ bool TakeScreenshot; |
|
| 428 |
+ int8_t StretchScreenshots; |
|
| 429 |
+ bool SnapshotScreenshots; |
|
| 430 |
+ |
|
| 431 |
+ bool ApplyCheats; |
|
| 432 |
+ bool NoPatch; |
|
| 433 |
+ int32_t AutoSaveDelay; |
|
| 434 |
+ bool DontSaveOopsSnapshot; |
|
| 435 |
+ bool UpAndDown; |
|
| 436 |
+ |
|
| 437 |
+ bool OpenGLEnable; |
|
| 438 |
+}; |
|
| 439 |
+ |
|
| 440 |
+struct SSNESGameFixes |
|
| 441 |
+{
|
|
| 442 |
+ uint8_t SRAMInitialValue; |
|
| 443 |
+ uint8_t Uniracers; |
|
| 444 |
+}; |
|
| 445 |
+ |
|
| 446 |
+enum |
|
| 447 |
+{
|
|
| 448 |
+ PAUSE_NETPLAY_CONNECT = (1 << 0), |
|
| 449 |
+ PAUSE_TOGGLE_FULL_SCREEN = (1 << 1), |
|
| 450 |
+ PAUSE_EXIT = (1 << 2), |
|
| 451 |
+ PAUSE_MENU = (1 << 3), |
|
| 452 |
+ PAUSE_INACTIVE_WINDOW = (1 << 4), |
|
| 453 |
+ PAUSE_WINDOW_ICONISED = (1 << 5), |
|
| 454 |
+ PAUSE_RESTORE_GUI = (1 << 6), |
|
| 455 |
+ PAUSE_FREEZE_FILE = (1 << 7) |
|
| 456 |
+}; |
|
| 457 |
+ |
|
| 458 |
+void S9xSetPause(uint32_t); |
|
| 459 |
+void S9xClearPause(uint32_t); |
|
| 460 |
+void S9xExi(); |
|
| 461 |
+void S9xMessage(int, int, const char *); |
|
| 462 |
+ |
|
| 463 |
+extern struct SSettings Settings; |
|
| 464 |
+extern struct SCPUState CPU; |
|
| 465 |
+extern struct STimings Timings; |
|
| 466 |
+extern struct SSNESGameFixes SNESGameFixes; |
|
| 467 |
+//extern char String[513]; |
|
| 468 |
+ |
|
| 469 |
+#endif |