Browse code

[SNSF] Replaced most uses of fill/copy with fill_n/copy_n, and a few other minor code cleanups.

Naram Qashat authored on 2013/05/27 22:34:22
Showing 1 changed files
... ...
@@ -178,7 +178,6 @@
178 178
 #include "snes9x.h"
179 179
 #include "memmap.h"
180 180
 #include "dma.h"
181
-#include "apu/apu.h"
182 181
 
183 182
 SCPUState CPU;
184 183
 SICPU ICPU;
Browse code

[SNSF] Massive code cleanup, as well as removing as much unused code/variables as possible.

Naram Qashat authored on 2013/05/23 06:02:16
Showing 1 changed files
... ...
@@ -175,147 +175,40 @@
175 175
   Nintendo Co., Limited and its subsidiary companies.
176 176
  ***********************************************************************************/
177 177
 
178
-
179 178
 #include "snes9x.h"
180 179
 #include "memmap.h"
181 180
 #include "dma.h"
182 181
 #include "apu/apu.h"
183
-//#include "fxinst.h"
184
-//#include "fxemu.h"
185
-//#include "srtc.h"
186
-//#include "cheats.h"
187
-#ifdef NETPLAY_SUPPORT
188
-#include "netplay.h"
189
-#endif
190
-#ifdef DEBUGGER
191
-#include "debug.h"
192
-#include "missing.h"
193
-#endif
194
-
195
-struct SCPUState		CPU;
196
-struct SICPU			ICPU;
197
-struct SRegisters		Registers;
198
-struct SPPU				PPU;
199
-struct InternalPPU		IPPU;
200
-struct SDMA				DMA[8];
201
-struct STimings			Timings;
202
-/*struct SGFX				GFX;
203
-struct SBG				BG;
204
-struct SLineData		LineData[240];
205
-struct SLineMatrixData	LineMatrixData[240];
206
-struct SDSP0			DSP0;
207
-struct SDSP1			DSP1;
208
-struct SDSP2			DSP2;
209
-struct SDSP3			DSP3;
210
-struct SDSP4			DSP4;
211
-struct SSA1				SA1;
212
-struct SSA1Registers	SA1Registers;
213
-struct FxRegs_s			GSU;
214
-struct FxInfo_s			SuperFX;
215
-struct SST010			ST010;
216
-struct SST011			ST011;
217
-struct SST018			ST018;
218
-struct SOBC1			OBC1;
219
-struct SSPC7110Snapshot	s7snap;
220
-struct SSRTCSnapshot	srtcsnap;
221
-struct SRTCData			RTCData;
222
-struct SBSX				BSX;*/
223
-struct SMulti			Multi;
224
-struct SSettings		Settings;
225
-struct SSNESGameFixes	SNESGameFixes;
226
-#ifdef NETPLAY_SUPPORT
227
-struct SNetPlay			NetPlay;
228
-#endif
229
-#ifdef DEBUGGER
230
-struct Missing			missing;
231
-#endif
232
-/*struct SCheatData		Cheat;
233
-struct Watch			watches[16];*/
234
-CMemory					Memory;
235
-
236
-//char	String[513];
237
-uint8_t	OpenBus = 0;
238
-uint8_t	*HDMAMemPointers[8];
239
-uint16_t	BlackColourMap[256];
240
-uint16_t	DirectColourMaps[8][256];
241
-
242
-SnesModel	M1SNES = { 1, 3, 2 };
243
-//SnesModel	M2SNES = { 2, 4, 3 };
244
-SnesModel	*Model = &M1SNES;
245
-
246
-#ifdef GFX_MULTI_FORMAT
247
-uint32_t	RED_LOW_BIT_MASK           = RED_LOW_BIT_MASK_RGB565;
248
-uint32_t	GREEN_LOW_BIT_MASK         = GREEN_LOW_BIT_MASK_RGB565;
249
-uint32_t	BLUE_LOW_BIT_MASK          = BLUE_LOW_BIT_MASK_RGB565;
250
-uint32_t	RED_HI_BIT_MASK            = RED_HI_BIT_MASK_RGB565;
251
-uint32_t	GREEN_HI_BIT_MASK          = GREEN_HI_BIT_MASK_RGB565;
252
-uint32_t	BLUE_HI_BIT_MASK           = BLUE_HI_BIT_MASK_RGB565;
253
-uint32_t	MAX_RED                    = MAX_RED_RGB565;
254
-uint32_t	MAX_GREEN                  = MAX_GREEN_RGB565;
255
-uint32_t	MAX_BLUE                   = MAX_BLUE_RGB565;
256
-uint32_t	SPARE_RGB_BIT_MASK         = SPARE_RGB_BIT_MASK_RGB565;
257
-uint32_t	GREEN_HI_BIT               = (MAX_GREEN_RGB565 + 1) >> 1;
258
-uint32_t	RGB_LOW_BITS_MASK          = (RED_LOW_BIT_MASK_RGB565 | GREEN_LOW_BIT_MASK_RGB565 | BLUE_LOW_BIT_MASK_RGB565);
259
-uint32_t	RGB_HI_BITS_MASK           = (RED_HI_BIT_MASK_RGB565  | GREEN_HI_BIT_MASK_RGB565  | BLUE_HI_BIT_MASK_RGB565);
260
-uint32_t	RGB_HI_BITS_MASKx2         = (RED_HI_BIT_MASK_RGB565  | GREEN_HI_BIT_MASK_RGB565  | BLUE_HI_BIT_MASK_RGB565) << 1;
261
-uint32_t	RGB_REMOVE_LOW_BITS_MASK   = ~RGB_LOW_BITS_MASK;
262
-uint32_t	FIRST_COLOR_MASK           = FIRST_COLOR_MASK_RGB565;
263
-uint32_t	SECOND_COLOR_MASK          = SECOND_COLOR_MASK_RGB565;
264
-uint32_t	THIRD_COLOR_MASK           = THIRD_COLOR_MASK_RGB565;
265
-uint32_t	ALPHA_BITS_MASK            = ALPHA_BITS_MASK_RGB565;
266
-uint32_t	FIRST_THIRD_COLOR_MASK     = 0;
267
-uint32_t	TWO_LOW_BITS_MASK          = 0;
268
-uint32_t	HIGH_BITS_SHIFTED_TWO_MASK = 0;
269
-#endif
270
-
271
-uint16_t SignExtend[2] =
182
+
183
+SCPUState CPU;
184
+SICPU ICPU;
185
+SRegisters Registers;
186
+SPPU PPU;
187
+InternalPPU IPPU;
188
+SDMA DMA[8];
189
+STimings Timings;
190
+SSettings Settings;
191
+SSNESGameFixes SNESGameFixes;
192
+CMemory Memory;
193
+
194
+uint8_t OpenBus = 0;
195
+uint8_t *HDMAMemPointers[8];
196
+
197
+SnesModel M1SNES = { 1, 3, 2 };
198
+SnesModel *Model = &M1SNES;
199
+
200
+uint16_t SignExtend[] =
272 201
 {
273 202
 	0x0000,
274 203
 	0xff00
275 204
 };
276 205
 
277
-int HDMA_ModeByteCounts[8] =
206
+int HDMA_ModeByteCounts[] =
278 207
 {
279 208
 	1, 2, 2, 4, 4, 4, 2, 4
280 209
 };
281 210
 
282
-/*uint8_t mul_brightness[16][32] =
283
-{
284
-	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
285
-	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
286
-	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
287
-	  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 },
288
-	{ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
289
-	  0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04 },
290
-	{ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03,
291
-	  0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06 },
292
-	{ 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04,
293
-	  0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08 },
294
-	{ 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05,
295
-	  0x05, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a },
296
-	{ 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06,
297
-	  0x06, 0x07, 0x07, 0x08, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0c, 0x0c },
298
-	{ 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07,
299
-	  0x07, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e },
300
-	{ 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, 0x08,
301
-	  0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, 0x0f, 0x10, 0x11 },
302
-	{ 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x07, 0x07, 0x08, 0x08, 0x09,
303
-	  0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x11, 0x12, 0x13 },
304
-	{ 0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x05, 0x06, 0x07, 0x07, 0x08, 0x09, 0x09, 0x0a,
305
-	  0x0b, 0x0b, 0x0c, 0x0d, 0x0d, 0x0e, 0x0f, 0x0f, 0x10, 0x11, 0x11, 0x12, 0x13, 0x13, 0x14, 0x15 },
306
-	{ 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x04, 0x05, 0x06, 0x07, 0x07, 0x08, 0x09, 0x0a, 0x0a, 0x0b,
307
-	  0x0c, 0x0c, 0x0d, 0x0e, 0x0f, 0x0f, 0x10, 0x11, 0x12, 0x12, 0x13, 0x14, 0x15, 0x15, 0x16, 0x17 },
308
-	{ 0x00, 0x01, 0x02, 0x02, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c,
309
-	  0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x12, 0x13, 0x14, 0x15, 0x16, 0x16, 0x17, 0x18, 0x19 },
310
-	{ 0x00, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c, 0x0d,
311
-	  0x0e, 0x0f, 0x10, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x17, 0x18, 0x19, 0x1a, 0x1b },
312
-	{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
313
-	  0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d },
314
-	{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
315
-	  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }
316
-};*/
317
-
318
-uint8_t S9xOpLengthsM0X0[256] =
211
+uint8_t S9xOpLengthsM0X0[] =
319 212
 {
320 213
 //  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
321 214
 	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 0
... ...
@@ -336,7 +229,7 @@ uint8_t S9xOpLengthsM0X0[256] =
336 229
 	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4  // F
337 230
 };
338 231
 
339
-uint8_t S9xOpLengthsM0X1[256] =
232
+uint8_t S9xOpLengthsM0X1[] =
340 233
 {
341 234
 //  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
342 235
 	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 0
... ...
@@ -357,7 +250,7 @@ uint8_t S9xOpLengthsM0X1[256] =
357 250
 	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4  // F
358 251
 };
359 252
 
360
-uint8_t S9xOpLengthsM1X0[256] =
253
+uint8_t S9xOpLengthsM1X0[] =
361 254
 {
362 255
 //  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
363 256
 	2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 0
... ...
@@ -378,7 +271,7 @@ uint8_t S9xOpLengthsM1X0[256] =
378 271
 	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4  // F
379 272
 };
380 273
 
381
-uint8_t S9xOpLengthsM1X1[256] =
274
+uint8_t S9xOpLengthsM1X1[] =
382 275
 {
383 276
 //  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
384 277
 	2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 0
Browse code

Import actual code.

Naram Qashat authored on 2013/03/26 02:41:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,400 @@
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
+#include "snes9x.h"
180
+#include "memmap.h"
181
+#include "dma.h"
182
+#include "apu/apu.h"
183
+//#include "fxinst.h"
184
+//#include "fxemu.h"
185
+//#include "srtc.h"
186
+//#include "cheats.h"
187
+#ifdef NETPLAY_SUPPORT
188
+#include "netplay.h"
189
+#endif
190
+#ifdef DEBUGGER
191
+#include "debug.h"
192
+#include "missing.h"
193
+#endif
194
+
195
+struct SCPUState		CPU;
196
+struct SICPU			ICPU;
197
+struct SRegisters		Registers;
198
+struct SPPU				PPU;
199
+struct InternalPPU		IPPU;
200
+struct SDMA				DMA[8];
201
+struct STimings			Timings;
202
+/*struct SGFX				GFX;
203
+struct SBG				BG;
204
+struct SLineData		LineData[240];
205
+struct SLineMatrixData	LineMatrixData[240];
206
+struct SDSP0			DSP0;
207
+struct SDSP1			DSP1;
208
+struct SDSP2			DSP2;
209
+struct SDSP3			DSP3;
210
+struct SDSP4			DSP4;
211
+struct SSA1				SA1;
212
+struct SSA1Registers	SA1Registers;
213
+struct FxRegs_s			GSU;
214
+struct FxInfo_s			SuperFX;
215
+struct SST010			ST010;
216
+struct SST011			ST011;
217
+struct SST018			ST018;
218
+struct SOBC1			OBC1;
219
+struct SSPC7110Snapshot	s7snap;
220
+struct SSRTCSnapshot	srtcsnap;
221
+struct SRTCData			RTCData;
222
+struct SBSX				BSX;*/
223
+struct SMulti			Multi;
224
+struct SSettings		Settings;
225
+struct SSNESGameFixes	SNESGameFixes;
226
+#ifdef NETPLAY_SUPPORT
227
+struct SNetPlay			NetPlay;
228
+#endif
229
+#ifdef DEBUGGER
230
+struct Missing			missing;
231
+#endif
232
+/*struct SCheatData		Cheat;
233
+struct Watch			watches[16];*/
234
+CMemory					Memory;
235
+
236
+//char	String[513];
237
+uint8_t	OpenBus = 0;
238
+uint8_t	*HDMAMemPointers[8];
239
+uint16_t	BlackColourMap[256];
240
+uint16_t	DirectColourMaps[8][256];
241
+
242
+SnesModel	M1SNES = { 1, 3, 2 };
243
+//SnesModel	M2SNES = { 2, 4, 3 };
244
+SnesModel	*Model = &M1SNES;
245
+
246
+#ifdef GFX_MULTI_FORMAT
247
+uint32_t	RED_LOW_BIT_MASK           = RED_LOW_BIT_MASK_RGB565;
248
+uint32_t	GREEN_LOW_BIT_MASK         = GREEN_LOW_BIT_MASK_RGB565;
249
+uint32_t	BLUE_LOW_BIT_MASK          = BLUE_LOW_BIT_MASK_RGB565;
250
+uint32_t	RED_HI_BIT_MASK            = RED_HI_BIT_MASK_RGB565;
251
+uint32_t	GREEN_HI_BIT_MASK          = GREEN_HI_BIT_MASK_RGB565;
252
+uint32_t	BLUE_HI_BIT_MASK           = BLUE_HI_BIT_MASK_RGB565;
253
+uint32_t	MAX_RED                    = MAX_RED_RGB565;
254
+uint32_t	MAX_GREEN                  = MAX_GREEN_RGB565;
255
+uint32_t	MAX_BLUE                   = MAX_BLUE_RGB565;
256
+uint32_t	SPARE_RGB_BIT_MASK         = SPARE_RGB_BIT_MASK_RGB565;
257
+uint32_t	GREEN_HI_BIT               = (MAX_GREEN_RGB565 + 1) >> 1;
258
+uint32_t	RGB_LOW_BITS_MASK          = (RED_LOW_BIT_MASK_RGB565 | GREEN_LOW_BIT_MASK_RGB565 | BLUE_LOW_BIT_MASK_RGB565);
259
+uint32_t	RGB_HI_BITS_MASK           = (RED_HI_BIT_MASK_RGB565  | GREEN_HI_BIT_MASK_RGB565  | BLUE_HI_BIT_MASK_RGB565);
260
+uint32_t	RGB_HI_BITS_MASKx2         = (RED_HI_BIT_MASK_RGB565  | GREEN_HI_BIT_MASK_RGB565  | BLUE_HI_BIT_MASK_RGB565) << 1;
261
+uint32_t	RGB_REMOVE_LOW_BITS_MASK   = ~RGB_LOW_BITS_MASK;
262
+uint32_t	FIRST_COLOR_MASK           = FIRST_COLOR_MASK_RGB565;
263
+uint32_t	SECOND_COLOR_MASK          = SECOND_COLOR_MASK_RGB565;
264
+uint32_t	THIRD_COLOR_MASK           = THIRD_COLOR_MASK_RGB565;
265
+uint32_t	ALPHA_BITS_MASK            = ALPHA_BITS_MASK_RGB565;
266
+uint32_t	FIRST_THIRD_COLOR_MASK     = 0;
267
+uint32_t	TWO_LOW_BITS_MASK          = 0;
268
+uint32_t	HIGH_BITS_SHIFTED_TWO_MASK = 0;
269
+#endif
270
+
271
+uint16_t SignExtend[2] =
272
+{
273
+	0x0000,
274
+	0xff00
275
+};
276
+
277
+int HDMA_ModeByteCounts[8] =
278
+{
279
+	1, 2, 2, 4, 4, 4, 2, 4
280
+};
281
+
282
+/*uint8_t mul_brightness[16][32] =
283
+{
284
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
285
+	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
286
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
287
+	  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 },
288
+	{ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
289
+	  0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04 },
290
+	{ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03,
291
+	  0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06 },
292
+	{ 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04,
293
+	  0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08 },
294
+	{ 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05,
295
+	  0x05, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a },
296
+	{ 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06,
297
+	  0x06, 0x07, 0x07, 0x08, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0c, 0x0c },
298
+	{ 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07,
299
+	  0x07, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e },
300
+	{ 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, 0x08,
301
+	  0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, 0x0f, 0x10, 0x11 },
302
+	{ 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x07, 0x07, 0x08, 0x08, 0x09,
303
+	  0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x11, 0x12, 0x13 },
304
+	{ 0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x05, 0x06, 0x07, 0x07, 0x08, 0x09, 0x09, 0x0a,
305
+	  0x0b, 0x0b, 0x0c, 0x0d, 0x0d, 0x0e, 0x0f, 0x0f, 0x10, 0x11, 0x11, 0x12, 0x13, 0x13, 0x14, 0x15 },
306
+	{ 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x04, 0x05, 0x06, 0x07, 0x07, 0x08, 0x09, 0x0a, 0x0a, 0x0b,
307
+	  0x0c, 0x0c, 0x0d, 0x0e, 0x0f, 0x0f, 0x10, 0x11, 0x12, 0x12, 0x13, 0x14, 0x15, 0x15, 0x16, 0x17 },
308
+	{ 0x00, 0x01, 0x02, 0x02, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c,
309
+	  0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x12, 0x13, 0x14, 0x15, 0x16, 0x16, 0x17, 0x18, 0x19 },
310
+	{ 0x00, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c, 0x0d,
311
+	  0x0e, 0x0f, 0x10, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x17, 0x18, 0x19, 0x1a, 0x1b },
312
+	{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
313
+	  0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d },
314
+	{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
315
+	  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }
316
+};*/
317
+
318
+uint8_t S9xOpLengthsM0X0[256] =
319
+{
320
+//  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
321
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 0
322
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
323
+	3, 2, 4, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 2
324
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
325
+	1, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 4
326
+	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
327
+	1, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 6
328
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
329
+	2, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 8
330
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
331
+	3, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // A
332
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
333
+	3, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // C
334
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
335
+	3, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // E
336
+	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4  // F
337
+};
338
+
339
+uint8_t S9xOpLengthsM0X1[256] =
340
+{
341
+//  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
342
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 0
343
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
344
+	3, 2, 4, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 2
345
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
346
+	1, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 4
347
+	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
348
+	1, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 6
349
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
350
+	2, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 8
351
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
352
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // A
353
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
354
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // C
355
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
356
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // E
357
+	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4  // F
358
+};
359
+
360
+uint8_t S9xOpLengthsM1X0[256] =
361
+{
362
+//  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
363
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 0
364
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
365
+	3, 2, 4, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 2
366
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
367
+	1, 2, 2, 2, 3, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 4
368
+	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
369
+	1, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 6
370
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
371
+	2, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 8
372
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
373
+	3, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // A
374
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
375
+	3, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // C
376
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
377
+	3, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // E
378
+	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4  // F
379
+};
380
+
381
+uint8_t S9xOpLengthsM1X1[256] =
382
+{
383
+//  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
384
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 0
385
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
386
+	3, 2, 4, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 2
387
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
388
+	1, 2, 2, 2, 3, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 4
389
+	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
390
+	1, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 6
391
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
392
+	2, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 8
393
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
394
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // A
395
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
396
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // C
397
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
398
+	2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // E
399
+	2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4  // F
400
+};