Browse code

Use #pragma once instead of include guards.

Naram Qashat authored on 2014/09/08 14:47:36
Showing 1 changed files
... ...
@@ -175,8 +175,7 @@
175 175
   Nintendo Co., Limited and its subsidiary companies.
176 176
  ***********************************************************************************/
177 177
 
178
-#ifndef _65C816_H_
179
-#define _65C816_H_
178
+#pragma once
180 179
 
181 180
 const uint16_t Carry = 1;
182 181
 const uint16_t Zero = 2;
... ...
@@ -245,5 +244,3 @@ inline bool CheckEmulation() { return !!(Registers.P.W & Emulation); }
245 244
 inline void SetFlags(uint16_t f) { Registers.P.W |= f; }
246 245
 inline void ClearFlags(uint16_t f) { Registers.P.W &= ~f; }
247 246
 inline bool CheckFlag(uint16_t f) { return !!(Registers.P.W & f); }
248
-
249
-#endif
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,103 +175,75 @@
175 175
   Nintendo Co., Limited and its subsidiary companies.
176 176
  ***********************************************************************************/
177 177
 
178
-
179 178
 #ifndef _65C816_H_
180 179
 #define _65C816_H_
181 180
 
182
-#define Carry		1
183
-#define Zero		2
184
-#define IRQ			4
185
-#define Decimal		8
186
-#define IndexFlag	16
187
-#define MemoryFlag	32
188
-#define Overflow	64
189
-#define Negative	128
190
-#define Emulation	256
191
-
192
-#define SetCarry()			(ICPU._Carry = 1)
193
-#define ClearCarry()		(ICPU._Carry = 0)
194
-#define SetZero()			(ICPU._Zero = 0)
195
-#define ClearZero()			(ICPU._Zero = 1)
196
-#define SetIRQ()			(Registers.PL |= IRQ)
197
-#define ClearIRQ()			(Registers.PL &= ~IRQ)
198
-#define SetDecimal()		(Registers.PL |= Decimal)
199
-#define ClearDecimal()		(Registers.PL &= ~Decimal)
200
-#define SetIndex()			(Registers.PL |= IndexFlag)
201
-#define ClearIndex()		(Registers.PL &= ~IndexFlag)
202
-#define SetMemory()			(Registers.PL |= MemoryFlag)
203
-#define ClearMemory()		(Registers.PL &= ~MemoryFlag)
204
-#define SetOverflow()		(ICPU._Overflow = 1)
205
-#define ClearOverflow()		(ICPU._Overflow = 0)
206
-#define SetNegative()		(ICPU._Negative = 0x80)
207
-#define ClearNegative()		(ICPU._Negative = 0)
208
-
209
-#define CheckCarry()		(ICPU._Carry)
210
-#define CheckZero()			(ICPU._Zero == 0)
211
-#define CheckIRQ()			(Registers.PL & IRQ)
212
-#define CheckDecimal()		(Registers.PL & Decimal)
213
-#define CheckIndex()		(Registers.PL & IndexFlag)
214
-#define CheckMemory()		(Registers.PL & MemoryFlag)
215
-#define CheckOverflow()		(ICPU._Overflow)
216
-#define CheckNegative()		(ICPU._Negative & 0x80)
217
-#define CheckEmulation()	(Registers.P.W & Emulation)
218
-
219
-#define SetFlags(f)			(Registers.P.W |= (f))
220
-#define ClearFlags(f)		(Registers.P.W &= ~(f))
221
-#define CheckFlag(f)		(Registers.PL & (f))
222
-
223
-typedef union
181
+const uint16_t Carry = 1;
182
+const uint16_t Zero = 2;
183
+const uint16_t IRQ = 4;
184
+const uint16_t Decimal = 8;
185
+const uint16_t IndexFlag = 16;
186
+const uint16_t MemoryFlag = 32;
187
+const uint16_t Overflow = 64;
188
+const uint16_t Negative = 128;
189
+const uint16_t Emulation = 256;
190
+
191
+union pair
224 192
 {
225 193
 #ifdef LSB_FIRST
226
-	struct { uint8_t	l, h; } B;
194
+	struct { uint8_t l, h; } B;
227 195
 #else
228
-	struct { uint8_t	h, l; } B;
196
+	struct { uint8_t h, l; } B;
229 197
 #endif
230
-	uint16_t	W;
231
-}	pair;
198
+	uint16_t W;
199
+};
232 200
 
233
-typedef union
201
+union PC_t
234 202
 {
235 203
 #ifdef LSB_FIRST
236
-	struct { uint8_t	xPCl, xPCh, xPB, z; } B;
237
-	struct { uint16_t	xPC, d; } W;
204
+	struct { uint8_t xPCl, xPCh, xPB, z; } B;
205
+	struct { uint16_t xPC, d; } W;
238 206
 #else
239
-	struct { uint8_t	z, xPB, xPCh, xPCl; } B;
240
-	struct { uint16_t	d, xPC; } W;
207
+	struct { uint8_t z, xPB, xPCh, xPCl; } B;
208
+	struct { uint16_t d, xPC; } W;
241 209
 #endif
242
-    uint32_t	xPBPC;
243
-}	PC_t;
210
+	uint32_t xPBPC;
211
+};
244 212
 
245 213
 struct SRegisters
246 214
 {
247
-	uint8_t	DB;
248
-	pair	P;
249
-	pair	A;
250
-	pair	D;
251
-	pair	S;
252
-	pair	X;
253
-	pair	Y;
254
-	PC_t	PC;
215
+	uint8_t DB;
216
+	pair P;
217
+	pair A;
218
+	pair D;
219
+	pair S;
220
+	pair X;
221
+	pair Y;
222
+	PC_t PC;
255 223
 };
256 224
 
257
-#define AL		A.B.l
258
-#define AH		A.B.h
259
-#define XL		X.B.l
260
-#define XH		X.B.h
261
-#define YL		Y.B.l
262
-#define YH		Y.B.h
263
-#define SL		S.B.l
264
-#define SH		S.B.h
265
-#define DL		D.B.l
266
-#define DH		D.B.h
267
-#define PL		P.B.l
268
-#define PH		P.B.h
269
-#define PBPC	PC.xPBPC
270
-#define PCw		PC.W.xPC
271
-#define PCh		PC.B.xPCh
272
-#define PCl		PC.B.xPCl
273
-#define PB		PC.B.xPB
274
-
275
-extern struct SRegisters	Registers;
225
+extern SRegisters Registers;
226
+
227
+inline void SetCarry() { ICPU._Carry = 1; }
228
+inline void ClearCarry() { ICPU._Carry = 0; }
229
+inline void SetIRQ() { Registers.P.B.l |= IRQ; }
230
+inline void ClearIRQ() { Registers.P.B.l &= ~IRQ; }
231
+inline void SetDecimal() { Registers.P.B.l |= Decimal; }
232
+inline void ClearDecimal() { Registers.P.B.l &= ~Decimal; }
233
+inline void SetOverflow() { ICPU._Overflow = 1; }
234
+inline void ClearOverflow() { ICPU._Overflow = 0; }
235
+
236
+inline bool CheckCarry() { return !!ICPU._Carry; }
237
+inline bool CheckZero() { return !ICPU._Zero; }
238
+inline bool CheckDecimal() { return !!(Registers.P.B.l & Decimal); }
239
+inline bool CheckIndex() { return !!(Registers.P.B.l & IndexFlag); }
240
+inline bool CheckMemory() { return !!(Registers.P.B.l & MemoryFlag); }
241
+inline bool CheckOverflow() { return !!(ICPU._Overflow); }
242
+inline bool CheckNegative() { return !!(ICPU._Negative & 0x80); }
243
+inline bool CheckEmulation() { return !!(Registers.P.W & Emulation); }
244
+
245
+inline void SetFlags(uint16_t f) { Registers.P.W |= f; }
246
+inline void ClearFlags(uint16_t f) { Registers.P.W &= ~f; }
247
+inline bool CheckFlag(uint16_t f) { return !!(Registers.P.W & f); }
276 248
 
277 249
 #endif
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,277 @@
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 _65C816_H_
180
+#define _65C816_H_
181
+
182
+#define Carry		1
183
+#define Zero		2
184
+#define IRQ			4
185
+#define Decimal		8
186
+#define IndexFlag	16
187
+#define MemoryFlag	32
188
+#define Overflow	64
189
+#define Negative	128
190
+#define Emulation	256
191
+
192
+#define SetCarry()			(ICPU._Carry = 1)
193
+#define ClearCarry()		(ICPU._Carry = 0)
194
+#define SetZero()			(ICPU._Zero = 0)
195
+#define ClearZero()			(ICPU._Zero = 1)
196
+#define SetIRQ()			(Registers.PL |= IRQ)
197
+#define ClearIRQ()			(Registers.PL &= ~IRQ)
198
+#define SetDecimal()		(Registers.PL |= Decimal)
199
+#define ClearDecimal()		(Registers.PL &= ~Decimal)
200
+#define SetIndex()			(Registers.PL |= IndexFlag)
201
+#define ClearIndex()		(Registers.PL &= ~IndexFlag)
202
+#define SetMemory()			(Registers.PL |= MemoryFlag)
203
+#define ClearMemory()		(Registers.PL &= ~MemoryFlag)
204
+#define SetOverflow()		(ICPU._Overflow = 1)
205
+#define ClearOverflow()		(ICPU._Overflow = 0)
206
+#define SetNegative()		(ICPU._Negative = 0x80)
207
+#define ClearNegative()		(ICPU._Negative = 0)
208
+
209
+#define CheckCarry()		(ICPU._Carry)
210
+#define CheckZero()			(ICPU._Zero == 0)
211
+#define CheckIRQ()			(Registers.PL & IRQ)
212
+#define CheckDecimal()		(Registers.PL & Decimal)
213
+#define CheckIndex()		(Registers.PL & IndexFlag)
214
+#define CheckMemory()		(Registers.PL & MemoryFlag)
215
+#define CheckOverflow()		(ICPU._Overflow)
216
+#define CheckNegative()		(ICPU._Negative & 0x80)
217
+#define CheckEmulation()	(Registers.P.W & Emulation)
218
+
219
+#define SetFlags(f)			(Registers.P.W |= (f))
220
+#define ClearFlags(f)		(Registers.P.W &= ~(f))
221
+#define CheckFlag(f)		(Registers.PL & (f))
222
+
223
+typedef union
224
+{
225
+#ifdef LSB_FIRST
226
+	struct { uint8_t	l, h; } B;
227
+#else
228
+	struct { uint8_t	h, l; } B;
229
+#endif
230
+	uint16_t	W;
231
+}	pair;
232
+
233
+typedef union
234
+{
235
+#ifdef LSB_FIRST
236
+	struct { uint8_t	xPCl, xPCh, xPB, z; } B;
237
+	struct { uint16_t	xPC, d; } W;
238
+#else
239
+	struct { uint8_t	z, xPB, xPCh, xPCl; } B;
240
+	struct { uint16_t	d, xPC; } W;
241
+#endif
242
+    uint32_t	xPBPC;
243
+}	PC_t;
244
+
245
+struct SRegisters
246
+{
247
+	uint8_t	DB;
248
+	pair	P;
249
+	pair	A;
250
+	pair	D;
251
+	pair	S;
252
+	pair	X;
253
+	pair	Y;
254
+	PC_t	PC;
255
+};
256
+
257
+#define AL		A.B.l
258
+#define AH		A.B.h
259
+#define XL		X.B.l
260
+#define XH		X.B.h
261
+#define YL		Y.B.l
262
+#define YH		Y.B.h
263
+#define SL		S.B.l
264
+#define SH		S.B.h
265
+#define DL		D.B.l
266
+#define DH		D.B.h
267
+#define PL		P.B.l
268
+#define PH		P.B.h
269
+#define PBPC	PC.xPBPC
270
+#define PCw		PC.W.xPC
271
+#define PCh		PC.B.xPCh
272
+#define PCl		PC.B.xPCl
273
+#define PB		PC.B.xPB
274
+
275
+extern struct SRegisters	Registers;
276
+
277
+#endif