Browse code

* Fixes for gcc and clang (while they can compile the code, the DLLs made aren't functional, but oh well).

* [2SF] Used more up-to-date asmjit, despite the ugly looking code.

Naram Qashat authored on 2014/09/17 19:51:45
Showing 1 changed files
... ...
@@ -283,7 +283,7 @@ inline uint32_t AbsoluteIndexedIndirectSlow(AccessMode a) // (a,X)
283 283
 	return addr2;
284 284
 }
285 285
 
286
-inline uint32_t AbsoluteIndexedIndirect(AccessMode a) // (a,X)
286
+inline uint32_t AbsoluteIndexedIndirect(AccessMode) // (a,X)
287 287
 {
288 288
 	uint16_t addr = Immediate16Slow(READ);
289 289
 	addr += Registers.X.W;
... ...
@@ -295,7 +295,7 @@ inline uint32_t AbsoluteIndexedIndirect(AccessMode a) // (a,X)
295 295
 	return addr2;
296 296
 }
297 297
 
298
-template<typename F> inline uint32_t AbsoluteIndirectLongWrapper(F f, AccessMode a)
298
+template<typename F> inline uint32_t AbsoluteIndirectLongWrapper(F f, AccessMode)
299 299
 {
300 300
 	uint16_t addr = f(READ);
301 301
 
... ...
@@ -317,7 +317,7 @@ inline uint32_t AbsoluteIndirectLong(AccessMode a) // [a]
317 317
 	return AbsoluteIndirectLongWrapper(Immediate16, a);
318 318
 }
319 319
 
320
-template<typename F> inline uint32_t AbsoluteIndirectWrapper(F f, AccessMode a)
320
+template<typename F> inline uint32_t AbsoluteIndirectWrapper(F f, AccessMode)
321 321
 {
322 322
 	// No info on wrapping, but it doesn't matter anyway due to mirroring
323 323
 	uint16_t addr2 = S9xGetWord(f(READ));
... ...
@@ -460,7 +460,7 @@ inline uint32_t DirectIndirectIndexedE1(AccessMode a) // (d),Y
460 460
 	return addr + Registers.Y.W;
461 461
 }
462 462
 
463
-template<typename F> inline uint32_t DirectIndirectLongWrapper(F f, AccessMode a)
463
+template<typename F> inline uint32_t DirectIndirectLongWrapper(F f, AccessMode)
464 464
 {
465 465
 	uint16_t addr = f(READ);
466 466
 	uint32_t addr2 = S9xGetWord(addr);
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 _CPUADDR_H_
179
-#define _CPUADDR_H_
178
+#pragma once
180 179
 
181 180
 enum AccessMode
182 181
 {
... ...
@@ -702,5 +701,3 @@ inline uint32_t StackRelativeIndirectIndexed(AccessMode a) // (d,S),Y
702 701
 {
703 702
 	return StackRelativeIndirectIndexedWrapper(StackRelative, a);
704 703
 }
705
-
706
-#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,93 +175,92 @@
175 175
   Nintendo Co., Limited and its subsidiary companies.
176 176
  ***********************************************************************************/
177 177
 
178
-
179 178
 #ifndef _CPUADDR_H_
180 179
 #define _CPUADDR_H_
181 180
 
182
-typedef enum
181
+enum AccessMode
183 182
 {
184
-	NONE   = 0,
185
-	READ   = 1,
186
-	WRITE  = 2,
183
+	NONE = 0,
184
+	READ = 1,
185
+	WRITE = 2,
187 186
 	MODIFY = 3,
188
-	JUMP   = 5,
189
-	JSR    = 8
190
-}	AccessMode;
187
+	JUMP = 5,
188
+	JSR = 8
189
+};
191 190
 
192
-static inline uint8_t Immediate8Slow (AccessMode a)
191
+inline uint8_t Immediate8Slow(AccessMode a)
193 192
 {
194
-	uint8_t	val = S9xGetByte(Registers.PBPC);
193
+	uint8_t val = S9xGetByte(Registers.PC.xPBPC);
195 194
 	if (a & READ)
196 195
 		OpenBus = val;
197
-	Registers.PCw++;
196
+	++Registers.PC.W.xPC;
198 197
 
199 198
 	return val;
200 199
 }
201 200
 
202
-static inline uint8_t Immediate8 (AccessMode a)
201
+inline uint8_t Immediate8(AccessMode a)
203 202
 {
204
-	uint8_t	val = CPU.PCBase[Registers.PCw];
203
+	uint8_t val = CPU.PCBase[Registers.PC.W.xPC];
205 204
 	if (a & READ)
206 205
 		OpenBus = val;
207 206
 	AddCycles(CPU.MemSpeed);
208
-	Registers.PCw++;
207
+	++Registers.PC.W.xPC;
209 208
 
210 209
 	return val;
211 210
 }
212 211
 
213
-static inline uint16_t Immediate16Slow (AccessMode a)
212
+inline uint16_t Immediate16Slow(AccessMode a)
214 213
 {
215
-	uint16_t	val = S9xGetWord(Registers.PBPC, WRAP_BANK);
214
+	uint16_t val = S9xGetWord(Registers.PC.xPBPC, WRAP_BANK);
216 215
 	if (a & READ)
217
-		OpenBus = (uint8_t) (val >> 8);
218
-	Registers.PCw += 2;
216
+		OpenBus = static_cast<uint8_t>(val >> 8);
217
+	Registers.PC.W.xPC += 2;
219 218
 
220 219
 	return val;
221 220
 }
222 221
 
223
-static inline uint16_t Immediate16 (AccessMode a)
222
+inline uint16_t Immediate16(AccessMode a)
224 223
 {
225
-	uint16_t	val = READ_WORD(CPU.PCBase + Registers.PCw);
224
+	uint16_t val = READ_WORD(CPU.PCBase + Registers.PC.W.xPC);
226 225
 	if (a & READ)
227
-		OpenBus = (uint8_t) (val >> 8);
226
+		OpenBus = static_cast<uint8_t>(val >> 8);
228 227
 	AddCycles(CPU.MemSpeedx2);
229
-	Registers.PCw += 2;
228
+	Registers.PC.W.xPC += 2;
230 229
 
231 230
 	return val;
232 231
 }
233 232
 
234
-static inline uint32_t RelativeSlow (AccessMode a)						// branch $xx
233
+inline uint32_t RelativeSlow(AccessMode a) // branch $xx
235 234
 {
236
-	int8_t	offset = Immediate8Slow(a);
235
+	int8_t offset = Immediate8Slow(a);
237 236
 
238
-	return ((int16_t) Registers.PCw + offset) & 0xffff;
237
+	return (static_cast<int16_t>(Registers.PC.W.xPC) + offset) & 0xffff;
239 238
 }
240 239
 
241
-static inline uint32_t Relative (AccessMode a)							// branch $xx
240
+inline uint32_t Relative(AccessMode a) // branch $xx
242 241
 {
243
-	int8_t	offset = Immediate8(a);
242
+	int8_t offset = Immediate8(a);
244 243
 
245
-	return ((int16_t) Registers.PCw + offset) & 0xffff;
244
+	return (static_cast<int16_t>(Registers.PC.W.xPC) + offset) & 0xffff;
246 245
 }
247 246
 
248
-static inline uint32_t RelativeLongSlow (AccessMode a)					// BRL $xxxx
247
+inline uint32_t RelativeLongSlow(AccessMode a) // BRL $xxxx
249 248
 {
250
-	int16_t	offset = Immediate16Slow(a);
249
+	int16_t offset = Immediate16Slow(a);
251 250
 
252
-	return ((int32_t) Registers.PCw + offset) & 0xffff;
251
+	return (static_cast<int32_t>(Registers.PC.W.xPC) + offset) & 0xffff;
253 252
 }
254 253
 
255
-static inline uint32_t RelativeLong (AccessMode a)						// BRL $xxxx
254
+inline uint32_t RelativeLong(AccessMode a) // BRL $xxxx
256 255
 {
257
-	int16_t	offset = Immediate16(a);
256
+	int16_t offset = Immediate16(a);
258 257
 
259
-	return ((int32_t) Registers.PCw + offset) & 0xffff;
258
+	return (static_cast<int32_t>(Registers.PC.W.xPC) + offset) & 0xffff;
260 259
 }
261 260
 
262
-static inline uint32_t AbsoluteIndexedIndirectSlow (AccessMode a)			// (a,X)
261
+inline uint32_t AbsoluteIndexedIndirectSlow(AccessMode a) // (a,X)
263 262
 {
264
-	uint16_t	addr;
263
+	uint16_t addr;
265 264
 
266 265
 	if (a & JSR)
267 266
 	{
... ...
@@ -269,7 +268,7 @@ static inline uint32_t AbsoluteIndexedIndirectSlow (AccessMode a)			// (a,X)
269 268
 		// OpenBus needs to be set to account for this.
270 269
 		addr = Immediate8Slow(READ);
271 270
 		if (a == JSR)
272
-			OpenBus = Registers.PCl;
271
+			OpenBus = Registers.PC.B.xPCl;
273 272
 		addr |= Immediate8Slow(READ) << 8;
274 273
 	}
275 274
 	else
... ...
@@ -279,413 +278,429 @@ static inline uint32_t AbsoluteIndexedIndirectSlow (AccessMode a)			// (a,X)
279 278
 	addr += Registers.X.W;
280 279
 
281 280
 	// Address load wraps within the bank
282
-	uint16_t	addr2 = S9xGetWord(ICPU.ShiftedPB | addr, WRAP_BANK);
281
+	uint16_t addr2 = S9xGetWord(ICPU.ShiftedPB | addr, WRAP_BANK);
283 282
 	OpenBus = addr2 >> 8;
284 283
 
285 284
 	return addr2;
286 285
 }
287 286
 
288
-static inline uint32_t AbsoluteIndexedIndirect (AccessMode a)				// (a,X)
287
+inline uint32_t AbsoluteIndexedIndirect(AccessMode a) // (a,X)
289 288
 {
290
-	uint16_t	addr = Immediate16Slow(READ);
289
+	uint16_t addr = Immediate16Slow(READ);
291 290
 	addr += Registers.X.W;
292 291
 
293 292
 	// Address load wraps within the bank
294
-	uint16_t	addr2 = S9xGetWord(ICPU.ShiftedPB | addr, WRAP_BANK);
293
+	uint16_t addr2 = S9xGetWord(ICPU.ShiftedPB | addr, WRAP_BANK);
295 294
 	OpenBus = addr2 >> 8;
296 295
 
297 296
 	return addr2;
298 297
 }
299 298
 
300
-static inline uint32_t AbsoluteIndirectLongSlow (AccessMode a)			// [a]
299
+template<typename F> inline uint32_t AbsoluteIndirectLongWrapper(F f, AccessMode a)
301 300
 {
302
-	uint16_t	addr = Immediate16Slow(READ);
301
+	uint16_t addr = f(READ);
303 302
 
304 303
 	// No info on wrapping, but it doesn't matter anyway due to mirroring
305
-	uint32_t	addr2 = S9xGetWord(addr);
304
+	uint32_t addr2 = S9xGetWord(addr);
306 305
 	OpenBus = addr2 >> 8;
307 306
 	addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
308 307
 
309 308
 	return addr2;
310 309
 }
311 310
 
312
-static inline uint32_t AbsoluteIndirectLong (AccessMode a)				// [a]
311
+inline uint32_t AbsoluteIndirectLongSlow(AccessMode a) // [a]
313 312
 {
314
-	uint16_t	addr = Immediate16(READ);
315
-
316
-	// No info on wrapping, but it doesn't matter anyway due to mirroring
317
-	uint32_t	addr2 = S9xGetWord(addr);
318
-	OpenBus = addr2 >> 8;
319
-	addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
313
+	return AbsoluteIndirectLongWrapper(Immediate16Slow, a);
314
+}
320 315
 
321
-	return addr2;
316
+inline uint32_t AbsoluteIndirectLong(AccessMode a) // [a]
317
+{
318
+	return AbsoluteIndirectLongWrapper(Immediate16, a);
322 319
 }
323 320
 
324
-static inline uint32_t AbsoluteIndirectSlow (AccessMode a)				// (a)
321
+template<typename F> inline uint32_t AbsoluteIndirectWrapper(F f, AccessMode a)
325 322
 {
326 323
 	// No info on wrapping, but it doesn't matter anyway due to mirroring
327
-	uint16_t	addr2 = S9xGetWord(Immediate16Slow(READ));
324
+	uint16_t addr2 = S9xGetWord(f(READ));
328 325
 	OpenBus = addr2 >> 8;
329 326
 
330 327
 	return addr2;
331 328
 }
332 329
 
333
-static inline uint32_t AbsoluteIndirect (AccessMode a)					// (a)
330
+inline uint32_t AbsoluteIndirectSlow(AccessMode a) // (a)
334 331
 {
335
-	// No info on wrapping, but it doesn't matter anyway due to mirroring
336
-	uint16_t	addr2 = S9xGetWord(Immediate16(READ));
337
-	OpenBus = addr2 >> 8;
332
+	return AbsoluteIndirectWrapper(Immediate16Slow, a);
333
+}
338 334
 
339
-	return addr2;
335
+inline uint32_t AbsoluteIndirect(AccessMode a) // (a)
336
+{
337
+	return AbsoluteIndirectWrapper(Immediate16, a);
338
+}
339
+
340
+template<typename F> inline uint32_t AbsoluteWrapper(F f, AccessMode a)
341
+{
342
+	return ICPU.ShiftedDB | f(a);
340 343
 }
341 344
 
342
-static inline uint32_t AbsoluteSlow (AccessMode a)						// a
345
+inline uint32_t AbsoluteSlow(AccessMode a) // a
343 346
 {
344
-	return ICPU.ShiftedDB | Immediate16Slow(a);
347
+	return AbsoluteWrapper(Immediate16Slow, a);
345 348
 }
346 349
 
347
-static inline uint32_t Absolute (AccessMode a)							// a
350
+inline uint32_t Absolute(AccessMode a) // a
348 351
 {
349
-	return ICPU.ShiftedDB | Immediate16(a);
352
+	return AbsoluteWrapper(Immediate16, a);
350 353
 }
351 354
 
352
-static inline uint32_t AbsoluteLongSlow (AccessMode a)					// l
355
+inline uint32_t AbsoluteLongSlow(AccessMode a) // l
353 356
 {
354
-	uint32_t	addr = Immediate16Slow(READ);
357
+	uint32_t addr = Immediate16Slow(READ);
355 358
 
356 359
 	// JSR l pushes the old bank in the middle of loading the new.
357 360
 	// OpenBus needs to be set to account for this.
358 361
 	if (a == JSR)
359
-		OpenBus = Registers.PB;
362
+		OpenBus = Registers.PC.B.xPB;
360 363
 
361 364
 	addr |= Immediate8Slow(a) << 16;
362 365
 
363 366
 	return addr;
364 367
 }
365 368
 
366
-static inline uint32_t AbsoluteLong (AccessMode a)						// l
369
+inline uint32_t AbsoluteLong(AccessMode a) // l
367 370
 {
368
-	uint32_t	addr = READ_3WORD(CPU.PCBase + Registers.PCw);
371
+	uint32_t addr = READ_3WORD(CPU.PCBase + Registers.PC.W.xPC);
369 372
 	AddCycles(CPU.MemSpeedx2 + CPU.MemSpeed);
370 373
 	if (a & READ)
371 374
 		OpenBus = addr >> 16;
372
-	Registers.PCw += 3;
375
+	Registers.PC.W.xPC += 3;
373 376
 
374 377
 	return addr;
375 378
 }
376 379
 
377
-static inline uint32_t DirectSlow (AccessMode a)							// d
380
+template<typename F> inline uint32_t DirectWrapper(F f, AccessMode a)
378 381
 {
379
-	uint16_t	addr = Immediate8Slow(a) + Registers.D.W;
380
-	if (Registers.DL != 0)
382
+	uint16_t addr = f(a) + Registers.D.W;
383
+	if (Registers.D.B.l)
381 384
 		AddCycles(ONE_CYCLE);
382 385
 
383 386
 	return addr;
384 387
 }
385 388
 
386
-static inline uint32_t Direct (AccessMode a)								// d
389
+inline uint32_t DirectSlow(AccessMode a) // d
387 390
 {
388
-	uint16_t	addr = Immediate8(a) + Registers.D.W;
389
-	if (Registers.DL != 0)
390
-		AddCycles(ONE_CYCLE);
391
+	return DirectWrapper(Immediate8Slow, a);
392
+}
391 393
 
392
-	return addr;
394
+inline uint32_t Direct(AccessMode a) // d
395
+{
396
+	return DirectWrapper(Immediate8, a);
393 397
 }
394 398
 
395
-static inline uint32_t DirectIndirectSlow (AccessMode a)					// (d)
399
+inline uint32_t DirectIndirectSlow(AccessMode a) // (d)
396 400
 {
397
-	uint32_t	addr = S9xGetWord(DirectSlow(READ), (!CheckEmulation() || Registers.DL) ? WRAP_BANK : WRAP_PAGE);
401
+	uint32_t addr = S9xGetWord(DirectSlow(READ), !CheckEmulation() || Registers.D.B.l ? WRAP_BANK : WRAP_PAGE);
398 402
 	if (a & READ)
399
-		OpenBus = (uint8_t) (addr >> 8);
403
+		OpenBus = static_cast<uint8_t>(addr >> 8);
400 404
 	addr |= ICPU.ShiftedDB;
401 405
 
402 406
 	return addr;
403 407
 }
404 408
 
405
-static inline uint32_t DirectIndirectE0 (AccessMode a)					// (d)
409
+inline uint32_t DirectIndirectE0(AccessMode a) // (d)
406 410
 {
407
-	uint32_t	addr = S9xGetWord(Direct(READ));
411
+	uint32_t addr = S9xGetWord(Direct(READ));
408 412
 	if (a & READ)
409
-		OpenBus = (uint8_t) (addr >> 8);
413
+		OpenBus = static_cast<uint8_t>(addr >> 8);
410 414
 	addr |= ICPU.ShiftedDB;
411 415
 
412 416
 	return addr;
413 417
 }
414 418
 
415
-static inline uint32_t DirectIndirectE1 (AccessMode a)					// (d)
419
+inline uint32_t DirectIndirectE1(AccessMode a) // (d)
416 420
 {
417
-	uint32_t	addr = S9xGetWord(DirectSlow(READ), Registers.DL ? WRAP_BANK : WRAP_PAGE);
421
+	uint32_t addr = S9xGetWord(DirectSlow(READ), Registers.D.B.l ? WRAP_BANK : WRAP_PAGE);
418 422
 	if (a & READ)
419
-		OpenBus = (uint8_t) (addr >> 8);
423
+		OpenBus = static_cast<uint8_t>(addr >> 8);
420 424
 	addr |= ICPU.ShiftedDB;
421 425
 
422 426
 	return addr;
423 427
 }
424 428
 
425
-static inline uint32_t DirectIndirectIndexedSlow (AccessMode a)			// (d),Y
429
+inline uint32_t DirectIndirectIndexedSlow(AccessMode a) // (d),Y
426 430
 {
427
-	uint32_t	addr = DirectIndirectSlow(a);
428
-	if (a & WRITE || !CheckIndex() || (addr & 0xff) + Registers.YL >= 0x100)
431
+	uint32_t addr = DirectIndirectSlow(a);
432
+	if ((a & WRITE) || !CheckIndex() || (addr & 0xff) + Registers.Y.B.l >= 0x100)
429 433
 		AddCycles(ONE_CYCLE);
430 434
 
431 435
 	return addr + Registers.Y.W;
432 436
 }
433 437
 
434
-static inline uint32_t DirectIndirectIndexedE0X0 (AccessMode a)			// (d),Y
438
+inline uint32_t DirectIndirectIndexedE0X0(AccessMode a) // (d),Y
435 439
 {
436
-	uint32_t	addr = DirectIndirectE0(a);
440
+	uint32_t addr = DirectIndirectE0(a);
437 441
 	AddCycles(ONE_CYCLE);
438 442
 
439 443
 	return addr + Registers.Y.W;
440 444
 }
441 445
 
442
-static inline uint32_t DirectIndirectIndexedE0X1 (AccessMode a)			// (d),Y
446
+inline uint32_t DirectIndirectIndexedE0X1(AccessMode a) // (d),Y
443 447
 {
444
-	uint32_t	addr = DirectIndirectE0(a);
445
-	if (a & WRITE || (addr & 0xff) + Registers.YL >= 0x100)
448
+	uint32_t addr = DirectIndirectE0(a);
449
+	if ((a & WRITE) || (addr & 0xff) + Registers.Y.B.l >= 0x100)
446 450
 		AddCycles(ONE_CYCLE);
447 451
 
448 452
 	return addr + Registers.Y.W;
449 453
 }
450 454
 
451
-static inline uint32_t DirectIndirectIndexedE1 (AccessMode a)				// (d),Y
455
+inline uint32_t DirectIndirectIndexedE1(AccessMode a) // (d),Y
452 456
 {
453
-	uint32_t	addr = DirectIndirectE1(a);
454
-	if (a & WRITE || (addr & 0xff) + Registers.YL >= 0x100)
457
+	uint32_t addr = DirectIndirectE1(a);
458
+	if ((a & WRITE) || (addr & 0xff) + Registers.Y.B.l >= 0x100)
455 459
 		AddCycles(ONE_CYCLE);
456 460
 
457 461
 	return addr + Registers.Y.W;
458 462
 }
459 463
 
460
-static inline uint32_t DirectIndirectLongSlow (AccessMode a)				// [d]
464
+template<typename F> inline uint32_t DirectIndirectLongWrapper(F f, AccessMode a)
461 465
 {
462
-	uint16_t	addr = DirectSlow(READ);
463
-	uint32_t	addr2 = S9xGetWord(addr);
466
+	uint16_t addr = f(READ);
467
+	uint32_t addr2 = S9xGetWord(addr);
464 468
 	OpenBus = addr2 >> 8;
465 469
 	addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
466 470
 
467 471
 	return addr2;
468 472
 }
469 473
 
470
-static inline uint32_t DirectIndirectLong (AccessMode a)					// [d]
474
+inline uint32_t DirectIndirectLongSlow(AccessMode a) // [d]
471 475
 {
472
-	uint16_t	addr = Direct(READ);
473
-	uint32_t	addr2 = S9xGetWord(addr);
474
-	OpenBus = addr2 >> 8;
475
-	addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
476
+	return DirectIndirectLongWrapper(DirectSlow, a);
477
+}
476 478
 
477
-	return addr2;
479
+inline uint32_t DirectIndirectLong(AccessMode a) // [d]
480
+{
481
+	return DirectIndirectLongWrapper(Direct, a);
482
+}
483
+
484
+template<typename F> inline uint32_t DirectIndirectIndexedLongWrapper(F f, AccessMode a)
485
+{
486
+	return f(a) + Registers.Y.W;
478 487
 }
479 488
 
480
-static inline uint32_t DirectIndirectIndexedLongSlow (AccessMode a)		// [d],Y
489
+inline uint32_t DirectIndirectIndexedLongSlow(AccessMode a) // [d],Y
481 490
 {
482
-	return DirectIndirectLongSlow(a) + Registers.Y.W;
491
+	return DirectIndirectIndexedLongWrapper(DirectIndirectLongSlow, a);
483 492
 }
484 493
 
485
-static inline uint32_t DirectIndirectIndexedLong (AccessMode a)			// [d],Y
494
+inline uint32_t DirectIndirectIndexedLong(AccessMode a) // [d],Y
486 495
 {
487
-	return DirectIndirectLong(a) + Registers.Y.W;
496
+	return DirectIndirectIndexedLongWrapper(DirectIndirectLong, a);
488 497
 }
489 498
 
490
-static inline uint32_t DirectIndexedXSlow (AccessMode a)					// d,X
499
+inline uint32_t DirectIndexedXSlow(AccessMode a) // d,X
491 500
 {
492
-	pair	addr;
501
+	pair addr;
493 502
 	addr.W = DirectSlow(a);
494
-	if (!CheckEmulation() || Registers.DL)
503
+	if (!CheckEmulation() || Registers.D.B.l)
495 504
 		addr.W += Registers.X.W;
496 505
 	else
497
-		addr.B.l += Registers.XL;
506
+		addr.B.l += Registers.X.B.l;
498 507
 
499 508
 	AddCycles(ONE_CYCLE);
500 509
 
501 510
 	return addr.W;
502 511
 }
503 512
 
504
-static inline uint32_t DirectIndexedXE0 (AccessMode a)					// d,X
513
+inline uint32_t DirectIndexedXE0(AccessMode a) // d,X
505 514
 {
506
-	uint16_t	addr = Direct(a) + Registers.X.W;
515
+	uint16_t addr = Direct(a) + Registers.X.W;
507 516
 	AddCycles(ONE_CYCLE);
508 517
 
509 518
 	return addr;
510 519
 }
511 520
 
512
-static inline uint32_t DirectIndexedXE1 (AccessMode a)					// d,X
521
+inline uint32_t DirectIndexedXE1(AccessMode a) // d,X
513 522
 {
514
-	if (Registers.DL)
523
+	if (Registers.D.B.l)
515 524
 		return DirectIndexedXE0(a);
516 525
 	else
517 526
 	{
518
-		pair	addr;
527
+		pair addr;
519 528
 		addr.W = Direct(a);
520
-		addr.B.l += Registers.XL;
529
+		addr.B.l += Registers.X.B.l;
521 530
 		AddCycles(ONE_CYCLE);
522 531
 
523 532
 		return addr.W;
524 533
 	}
525 534
 }
526 535
 
527
-static inline uint32_t DirectIndexedYSlow (AccessMode a)					// d,Y
536
+inline uint32_t DirectIndexedYSlow(AccessMode a) // d,Y
528 537
 {
529
-	pair	addr;
538
+	pair addr;
530 539
 	addr.W = DirectSlow(a);
531
-	if (!CheckEmulation() || Registers.DL)
540
+	if (!CheckEmulation() || Registers.D.B.l)
532 541
 		addr.W += Registers.Y.W;
533 542
 	else
534
-		addr.B.l += Registers.YL;
543
+		addr.B.l += Registers.Y.B.l;
535 544
 
536 545
 	AddCycles(ONE_CYCLE);
537 546
 
538 547
 	return addr.W;
539 548
 }
540 549
 
541
-static inline uint32_t DirectIndexedYE0 (AccessMode a)					// d,Y
550
+inline uint32_t DirectIndexedYE0(AccessMode a) // d,Y
542 551
 {
543
-	uint16_t	addr = Direct(a) + Registers.Y.W;
552
+	uint16_t addr = Direct(a) + Registers.Y.W;
544 553
 	AddCycles(ONE_CYCLE);
545 554
 
546 555
 	return addr;
547 556
 }
548 557
 
549
-static inline uint32_t DirectIndexedYE1 (AccessMode a)					// d,Y
558
+inline uint32_t DirectIndexedYE1(AccessMode a) // d,Y
550 559
 {
551
-	if (Registers.DL)
560
+	if (Registers.D.B.l)
552 561
 		return DirectIndexedYE0(a);
553 562
 	else
554 563
 	{
555
-		pair	addr;
564
+		pair addr;
556 565
 		addr.W = Direct(a);
557
-		addr.B.l += Registers.YL;
566
+		addr.B.l += Registers.Y.B.l;
558 567
 		AddCycles(ONE_CYCLE);
559 568
 
560 569
 		return addr.W;
561 570
 	}
562 571
 }
563 572
 
564
-static inline uint32_t DirectIndexedIndirectSlow (AccessMode a)			// (d,X)
573
+inline uint32_t DirectIndexedIndirectSlow(AccessMode a) // (d,X)
565 574
 {
566
-	uint32_t	addr = S9xGetWord(DirectIndexedXSlow(READ), (!CheckEmulation() || Registers.DL) ? WRAP_BANK : WRAP_PAGE);
575
+	uint32_t addr = S9xGetWord(DirectIndexedXSlow(READ), !CheckEmulation() || Registers.D.B.l ? WRAP_BANK : WRAP_PAGE);
567 576
 	if (a & READ)
568
-		OpenBus = (uint8_t) (addr >> 8);
577
+		OpenBus = static_cast<uint8_t>(addr >> 8);
569 578
 
570 579
 	return ICPU.ShiftedDB | addr;
571 580
 }
572 581
 
573
-static inline uint32_t DirectIndexedIndirectE0 (AccessMode a)				// (d,X)
582
+inline uint32_t DirectIndexedIndirectE0(AccessMode a) // (d,X)
574 583
 {
575
-	uint32_t	addr = S9xGetWord(DirectIndexedXE0(READ));
584
+	uint32_t addr = S9xGetWord(DirectIndexedXE0(READ));
576 585
 	if (a & READ)
577
-		OpenBus = (uint8_t) (addr >> 8);
586
+		OpenBus = static_cast<uint8_t>(addr >> 8);
578 587
 
579 588
 	return ICPU.ShiftedDB | addr;
580 589
 }
581 590
 
582
-static inline uint32_t DirectIndexedIndirectE1 (AccessMode a)				// (d,X)
591
+inline uint32_t DirectIndexedIndirectE1(AccessMode a) // (d,X)
583 592
 {
584
-	uint32_t	addr = S9xGetWord(DirectIndexedXE1(READ), Registers.DL ? WRAP_BANK : WRAP_PAGE);
593
+	uint32_t addr = S9xGetWord(DirectIndexedXE1(READ), Registers.D.B.l ? WRAP_BANK : WRAP_PAGE);
585 594
 	if (a & READ)
586
-		OpenBus = (uint8_t) (addr >> 8);
595
+		OpenBus = static_cast<uint8_t>(addr >> 8);
587 596
 
588 597
 	return ICPU.ShiftedDB | addr;
589 598
 }
590 599
 
591
-static inline uint32_t AbsoluteIndexedXSlow (AccessMode a)				// a,X
600
+inline uint32_t AbsoluteIndexedXSlow(AccessMode a) // a,X
592 601
 {
593
-	uint32_t	addr = AbsoluteSlow(a);
594
-	if (a & WRITE || !CheckIndex() || (addr & 0xff) + Registers.XL >= 0x100)
602
+	uint32_t addr = AbsoluteSlow(a);
603
+	if ((a & WRITE) || !CheckIndex() || (addr & 0xff) + Registers.X.B.l >= 0x100)
595 604
 		AddCycles(ONE_CYCLE);
596 605
 
597 606
 	return addr + Registers.X.W;
598 607
 }
599 608
 
600
-static inline uint32_t AbsoluteIndexedXX0 (AccessMode a)					// a,X
609
+inline uint32_t AbsoluteIndexedXX0(AccessMode a) // a,X
601 610
 {
602
-	uint32_t	addr = Absolute(a);
611
+	uint32_t addr = Absolute(a);
603 612
 	AddCycles(ONE_CYCLE);
604 613
 
605 614
 	return addr + Registers.X.W;
606 615
 }
607 616
 
608
-static inline uint32_t AbsoluteIndexedXX1 (AccessMode a)					// a,X
617
+inline uint32_t AbsoluteIndexedXX1(AccessMode a) // a,X
609 618
 {
610
-	uint32_t	addr = Absolute(a);
611
-	if (a & WRITE || (addr & 0xff) + Registers.XL >= 0x100)
619
+	uint32_t addr = Absolute(a);
620
+	if ((a & WRITE) || (addr & 0xff) + Registers.X.B.l >= 0x100)
612 621
 		AddCycles(ONE_CYCLE);
613 622
 
614 623
 	return addr + Registers.X.W;
615 624
 }
616 625
 
617
-static inline uint32_t AbsoluteIndexedYSlow (AccessMode a)				// a,Y
626
+inline uint32_t AbsoluteIndexedYSlow(AccessMode a) // a,Y
618 627
 {
619
-	uint32_t	addr = AbsoluteSlow(a);
620
-	if (a & WRITE || !CheckIndex() || (addr & 0xff) + Registers.YL >= 0x100)
628
+	uint32_t addr = AbsoluteSlow(a);
629
+	if ((a & WRITE) || !CheckIndex() || (addr & 0xff) + Registers.Y.B.l >= 0x100)
621 630
 		AddCycles(ONE_CYCLE);
622 631
 
623 632
 	return addr + Registers.Y.W;
624 633
 }
625 634
 
626
-static inline uint32_t AbsoluteIndexedYX0 (AccessMode a)					// a,Y
635
+inline uint32_t AbsoluteIndexedYX0(AccessMode a) // a,Y
627 636
 {
628
-	uint32_t	addr = Absolute(a);
637
+	uint32_t addr = Absolute(a);
629 638
 	AddCycles(ONE_CYCLE);
630 639
 
631 640
 	return addr + Registers.Y.W;
632 641
 }
633 642
 
634
-static inline uint32_t AbsoluteIndexedYX1 (AccessMode a)					// a,Y
643
+inline uint32_t AbsoluteIndexedYX1(AccessMode a) // a,Y
635 644
 {
636
-	uint32_t	addr = Absolute(a);
637
-	if (a & WRITE || (addr & 0xff) + Registers.YL >= 0x100)
645
+	uint32_t addr = Absolute(a);
646
+	if ((a & WRITE) || (addr & 0xff) + Registers.Y.B.l >= 0x100)
638 647
 		AddCycles(ONE_CYCLE);
639 648
 
640 649
 	return addr + Registers.Y.W;
641 650
 }
642 651
 
643
-static inline uint32_t AbsoluteLongIndexedXSlow (AccessMode a)			// l,X
652
+template<typename F> inline uint32_t AbsoluteLongIndexedXWrapper(F f, AccessMode a)
653
+{
654
+	return f(a) + Registers.X.W;
655
+}
656
+
657
+inline uint32_t AbsoluteLongIndexedXSlow(AccessMode a) // l,X
644 658
 {
645
-	return AbsoluteLongSlow(a) + Registers.X.W;
659
+	return AbsoluteLongIndexedXWrapper(AbsoluteLongSlow, a);
646 660
 }
647 661
 
648
-static inline uint32_t AbsoluteLongIndexedX (AccessMode a)				// l,X
662
+inline uint32_t AbsoluteLongIndexedX(AccessMode a) // l,X
649 663
 {
650
-	return AbsoluteLong(a) + Registers.X.W;
664
+	return AbsoluteLongIndexedXWrapper(AbsoluteLong, a);
651 665
 }
652 666
 
653
-static inline uint32_t StackRelativeSlow (AccessMode a)					// d,S
667
+template<typename F> inline uint32_t StackRelativeWrapper(F f, AccessMode a)
654 668
 {
655
-	uint16_t	addr = Immediate8Slow(a) + Registers.S.W;
669
+	uint16_t addr = f(a) + Registers.S.W;
656 670
 	AddCycles(ONE_CYCLE);
657 671
 
658 672
 	return addr;
659 673
 }
660 674
 
661
-static inline uint32_t StackRelative (AccessMode a)						// d,S
675
+inline uint32_t StackRelativeSlow(AccessMode a) // d,S
662 676
 {
663
-	uint16_t	addr = Immediate8(a) + Registers.S.W;
664
-	AddCycles(ONE_CYCLE);
677
+	return StackRelativeWrapper(Immediate8Slow, a);
678
+}
665 679
 
666
-	return addr;
680
+inline uint32_t StackRelative(AccessMode a) // d,S
681
+{
682
+	return StackRelativeWrapper(Immediate8, a);
667 683
 }
668 684
 
669
-static inline uint32_t StackRelativeIndirectIndexedSlow (AccessMode a)	// (d,S),Y
685
+template<typename F> inline uint32_t StackRelativeIndirectIndexedWrapper(F f, AccessMode a)
670 686
 {
671
-	uint32_t	addr = S9xGetWord(StackRelativeSlow(READ));
687
+	uint32_t addr = S9xGetWord(f(READ));
672 688
 	if (a & READ)
673
-		OpenBus = (uint8_t) (addr >> 8);
689
+		OpenBus = static_cast<uint8_t>(addr >> 8);
674 690
 	addr = (addr + Registers.Y.W + ICPU.ShiftedDB) & 0xffffff;
675 691
 	AddCycles(ONE_CYCLE);
676 692
 
677 693
 	return addr;
678 694
 }
679 695
 
680
-static inline uint32_t StackRelativeIndirectIndexed (AccessMode a)		// (d,S),Y
696
+inline uint32_t StackRelativeIndirectIndexedSlow(AccessMode a) // (d,S),Y
681 697
 {
682
-	uint32_t	addr = S9xGetWord(StackRelative(READ));
683
-	if (a & READ)
684
-		OpenBus = (uint8_t) (addr >> 8);
685
-	addr = (addr + Registers.Y.W + ICPU.ShiftedDB) & 0xffffff;
686
-	AddCycles(ONE_CYCLE);
698
+	return StackRelativeIndirectIndexedWrapper(StackRelativeSlow, a);
699
+}
687 700
 
688
-	return addr;
701
+inline uint32_t StackRelativeIndirectIndexed(AccessMode a) // (d,S),Y
702
+{
703
+	return StackRelativeIndirectIndexedWrapper(StackRelative, a);
689 704
 }
690 705
 
691 706
 #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,691 @@
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 _CPUADDR_H_
180
+#define _CPUADDR_H_
181
+
182
+typedef enum
183
+{
184
+	NONE   = 0,
185
+	READ   = 1,
186
+	WRITE  = 2,
187
+	MODIFY = 3,
188
+	JUMP   = 5,
189
+	JSR    = 8
190
+}	AccessMode;
191
+
192
+static inline uint8_t Immediate8Slow (AccessMode a)
193
+{
194
+	uint8_t	val = S9xGetByte(Registers.PBPC);
195
+	if (a & READ)
196
+		OpenBus = val;
197
+	Registers.PCw++;
198
+
199
+	return val;
200
+}
201
+
202
+static inline uint8_t Immediate8 (AccessMode a)
203
+{
204
+	uint8_t	val = CPU.PCBase[Registers.PCw];
205
+	if (a & READ)
206
+		OpenBus = val;
207
+	AddCycles(CPU.MemSpeed);
208
+	Registers.PCw++;
209
+
210
+	return val;
211
+}
212
+
213
+static inline uint16_t Immediate16Slow (AccessMode a)
214
+{
215
+	uint16_t	val = S9xGetWord(Registers.PBPC, WRAP_BANK);
216
+	if (a & READ)
217
+		OpenBus = (uint8_t) (val >> 8);
218
+	Registers.PCw += 2;
219
+
220
+	return val;
221
+}
222
+
223
+static inline uint16_t Immediate16 (AccessMode a)
224
+{
225
+	uint16_t	val = READ_WORD(CPU.PCBase + Registers.PCw);
226
+	if (a & READ)
227
+		OpenBus = (uint8_t) (val >> 8);
228
+	AddCycles(CPU.MemSpeedx2);
229
+	Registers.PCw += 2;
230
+
231
+	return val;
232
+}
233
+
234
+static inline uint32_t RelativeSlow (AccessMode a)						// branch $xx
235
+{
236
+	int8_t	offset = Immediate8Slow(a);
237
+
238
+	return ((int16_t) Registers.PCw + offset) & 0xffff;
239
+}
240
+
241
+static inline uint32_t Relative (AccessMode a)							// branch $xx
242
+{
243
+	int8_t	offset = Immediate8(a);
244
+
245
+	return ((int16_t) Registers.PCw + offset) & 0xffff;
246
+}
247
+
248
+static inline uint32_t RelativeLongSlow (AccessMode a)					// BRL $xxxx
249
+{
250
+	int16_t	offset = Immediate16Slow(a);
251
+
252
+	return ((int32_t) Registers.PCw + offset) & 0xffff;
253
+}
254
+
255
+static inline uint32_t RelativeLong (AccessMode a)						// BRL $xxxx
256
+{
257
+	int16_t	offset = Immediate16(a);
258
+
259
+	return ((int32_t) Registers.PCw + offset) & 0xffff;
260
+}
261
+
262
+static inline uint32_t AbsoluteIndexedIndirectSlow (AccessMode a)			// (a,X)
263
+{
264
+	uint16_t	addr;
265
+
266
+	if (a & JSR)
267
+	{
268
+		// JSR (a,X) pushes the old address in the middle of loading the new.
269
+		// OpenBus needs to be set to account for this.
270
+		addr = Immediate8Slow(READ);
271
+		if (a == JSR)
272
+			OpenBus = Registers.PCl;
273
+		addr |= Immediate8Slow(READ) << 8;
274
+	}
275
+	else
276
+		addr = Immediate16Slow(READ);
277
+
278
+	AddCycles(ONE_CYCLE);
279
+	addr += Registers.X.W;
280
+
281
+	// Address load wraps within the bank
282
+	uint16_t	addr2 = S9xGetWord(ICPU.ShiftedPB | addr, WRAP_BANK);
283
+	OpenBus = addr2 >> 8;
284
+
285
+	return addr2;
286
+}
287
+
288
+static inline uint32_t AbsoluteIndexedIndirect (AccessMode a)				// (a,X)
289
+{
290
+	uint16_t	addr = Immediate16Slow(READ);
291
+	addr += Registers.X.W;
292
+
293
+	// Address load wraps within the bank
294
+	uint16_t	addr2 = S9xGetWord(ICPU.ShiftedPB | addr, WRAP_BANK);
295
+	OpenBus = addr2 >> 8;
296
+
297
+	return addr2;
298
+}
299
+
300
+static inline uint32_t AbsoluteIndirectLongSlow (AccessMode a)			// [a]
301
+{
302
+	uint16_t	addr = Immediate16Slow(READ);
303
+
304
+	// No info on wrapping, but it doesn't matter anyway due to mirroring
305
+	uint32_t	addr2 = S9xGetWord(addr);
306
+	OpenBus = addr2 >> 8;
307
+	addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
308
+
309
+	return addr2;
310
+}
311
+
312
+static inline uint32_t AbsoluteIndirectLong (AccessMode a)				// [a]
313
+{
314
+	uint16_t	addr = Immediate16(READ);
315
+
316
+	// No info on wrapping, but it doesn't matter anyway due to mirroring
317
+	uint32_t	addr2 = S9xGetWord(addr);
318
+	OpenBus = addr2 >> 8;
319
+	addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
320
+
321
+	return addr2;
322
+}
323
+
324
+static inline uint32_t AbsoluteIndirectSlow (AccessMode a)				// (a)
325
+{
326
+	// No info on wrapping, but it doesn't matter anyway due to mirroring
327
+	uint16_t	addr2 = S9xGetWord(Immediate16Slow(READ));
328
+	OpenBus = addr2 >> 8;
329
+
330
+	return addr2;
331
+}
332
+
333
+static inline uint32_t AbsoluteIndirect (AccessMode a)					// (a)
334
+{
335
+	// No info on wrapping, but it doesn't matter anyway due to mirroring
336
+	uint16_t	addr2 = S9xGetWord(Immediate16(READ));
337
+	OpenBus = addr2 >> 8;
338
+
339
+	return addr2;
340
+}
341
+
342
+static inline uint32_t AbsoluteSlow (AccessMode a)						// a
343
+{
344
+	return ICPU.ShiftedDB | Immediate16Slow(a);
345
+}
346
+
347
+static inline uint32_t Absolute (AccessMode a)							// a
348
+{
349
+	return ICPU.ShiftedDB | Immediate16(a);
350
+}
351
+
352
+static inline uint32_t AbsoluteLongSlow (AccessMode a)					// l
353
+{
354
+	uint32_t	addr = Immediate16Slow(READ);
355
+
356
+	// JSR l pushes the old bank in the middle of loading the new.
357
+	// OpenBus needs to be set to account for this.
358
+	if (a == JSR)
359
+		OpenBus = Registers.PB;
360
+
361
+	addr |= Immediate8Slow(a) << 16;
362
+
363
+	return addr;
364
+}
365
+
366
+static inline uint32_t AbsoluteLong (AccessMode a)						// l
367
+{
368
+	uint32_t	addr = READ_3WORD(CPU.PCBase + Registers.PCw);
369
+	AddCycles(CPU.MemSpeedx2 + CPU.MemSpeed);
370
+	if (a & READ)
371
+		OpenBus = addr >> 16;
372
+	Registers.PCw += 3;
373
+
374
+	return addr;
375
+}
376
+
377
+static inline uint32_t DirectSlow (AccessMode a)							// d
378
+{
379
+	uint16_t	addr = Immediate8Slow(a) + Registers.D.W;
380
+	if (Registers.DL != 0)
381
+		AddCycles(ONE_CYCLE);
382
+
383
+	return addr;
384
+}
385
+
386
+static inline uint32_t Direct (AccessMode a)								// d
387
+{
388
+	uint16_t	addr = Immediate8(a) + Registers.D.W;
389
+	if (Registers.DL != 0)
390
+		AddCycles(ONE_CYCLE);
391
+
392
+	return addr;
393
+}
394
+
395
+static inline uint32_t DirectIndirectSlow (AccessMode a)					// (d)
396
+{
397
+	uint32_t	addr = S9xGetWord(DirectSlow(READ), (!CheckEmulation() || Registers.DL) ? WRAP_BANK : WRAP_PAGE);
398
+	if (a & READ)
399
+		OpenBus = (uint8_t) (addr >> 8);
400
+	addr |= ICPU.ShiftedDB;
401
+
402
+	return addr;
403
+}
404
+
405
+static inline uint32_t DirectIndirectE0 (AccessMode a)					// (d)
406
+{
407
+	uint32_t	addr = S9xGetWord(Direct(READ));
408
+	if (a & READ)
409
+		OpenBus = (uint8_t) (addr >> 8);
410
+	addr |= ICPU.ShiftedDB;
411
+
412
+	return addr;
413
+}
414
+
415
+static inline uint32_t DirectIndirectE1 (AccessMode a)					// (d)
416
+{
417
+	uint32_t	addr = S9xGetWord(DirectSlow(READ), Registers.DL ? WRAP_BANK : WRAP_PAGE);
418
+	if (a & READ)
419
+		OpenBus = (uint8_t) (addr >> 8);
420
+	addr |= ICPU.ShiftedDB;
421
+
422
+	return addr;
423
+}
424
+
425
+static inline uint32_t DirectIndirectIndexedSlow (AccessMode a)			// (d),Y
426
+{
427
+	uint32_t	addr = DirectIndirectSlow(a);
428
+	if (a & WRITE || !CheckIndex() || (addr & 0xff) + Registers.YL >= 0x100)
429
+		AddCycles(ONE_CYCLE);
430
+
431
+	return addr + Registers.Y.W;
432
+}
433
+
434
+static inline uint32_t DirectIndirectIndexedE0X0 (AccessMode a)			// (d),Y
435
+{
436
+	uint32_t	addr = DirectIndirectE0(a);
437
+	AddCycles(ONE_CYCLE);
438
+
439
+	return addr + Registers.Y.W;
440
+}
441
+
442
+static inline uint32_t DirectIndirectIndexedE0X1 (AccessMode a)			// (d),Y
443
+{
444
+	uint32_t	addr = DirectIndirectE0(a);
445
+	if (a & WRITE || (addr & 0xff) + Registers.YL >= 0x100)
446
+		AddCycles(ONE_CYCLE);
447
+
448
+	return addr + Registers.Y.W;
449
+}
450
+
451
+static inline uint32_t DirectIndirectIndexedE1 (AccessMode a)				// (d),Y
452
+{
453
+	uint32_t	addr = DirectIndirectE1(a);
454
+	if (a & WRITE || (addr & 0xff) + Registers.YL >= 0x100)
455
+		AddCycles(ONE_CYCLE);
456
+
457
+	return addr + Registers.Y.W;
458
+}
459
+
460
+static inline uint32_t DirectIndirectLongSlow (AccessMode a)				// [d]
461
+{
462
+	uint16_t	addr = DirectSlow(READ);
463
+	uint32_t	addr2 = S9xGetWord(addr);
464
+	OpenBus = addr2 >> 8;
465
+	addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
466
+
467
+	return addr2;
468
+}
469
+
470
+static inline uint32_t DirectIndirectLong (AccessMode a)					// [d]
471
+{
472
+	uint16_t	addr = Direct(READ);
473
+	uint32_t	addr2 = S9xGetWord(addr);
474
+	OpenBus = addr2 >> 8;
475
+	addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
476
+
477
+	return addr2;
478
+}
479
+
480
+static inline uint32_t DirectIndirectIndexedLongSlow (AccessMode a)		// [d],Y
481
+{
482
+	return DirectIndirectLongSlow(a) + Registers.Y.W;
483
+}
484
+
485
+static inline uint32_t DirectIndirectIndexedLong (AccessMode a)			// [d],Y
486
+{
487
+	return DirectIndirectLong(a) + Registers.Y.W;
488
+}
489
+
490
+static inline uint32_t DirectIndexedXSlow (AccessMode a)					// d,X
491
+{
492
+	pair	addr;
493
+	addr.W = DirectSlow(a);
494
+	if (!CheckEmulation() || Registers.DL)
495
+		addr.W += Registers.X.W;
496
+	else
497
+		addr.B.l += Registers.XL;
498
+
499
+	AddCycles(ONE_CYCLE);
500
+
501
+	return addr.W;
502
+}
503
+
504
+static inline uint32_t DirectIndexedXE0 (AccessMode a)					// d,X
505
+{
506
+	uint16_t	addr = Direct(a) + Registers.X.W;
507
+	AddCycles(ONE_CYCLE);
508
+
509
+	return addr;
510
+}
511
+
512
+static inline uint32_t DirectIndexedXE1 (AccessMode a)					// d,X
513
+{
514
+	if (Registers.DL)
515
+		return DirectIndexedXE0(a);
516
+	else
517
+	{
518
+		pair	addr;
519
+		addr.W = Direct(a);
520
+		addr.B.l += Registers.XL;
521
+		AddCycles(ONE_CYCLE);
522
+
523
+		return addr.W;
524
+	}
525
+}
526
+
527
+static inline uint32_t DirectIndexedYSlow (AccessMode a)					// d,Y
528
+{
529
+	pair	addr;
530
+	addr.W = DirectSlow(a);
531
+	if (!CheckEmulation() || Registers.DL)
532
+		addr.W += Registers.Y.W;
533
+	else
534
+		addr.B.l += Registers.YL;
535
+
536
+	AddCycles(ONE_CYCLE);
537
+
538
+	return addr.W;
539
+}
540
+
541
+static inline uint32_t DirectIndexedYE0 (AccessMode a)					// d,Y
542
+{
543
+	uint16_t	addr = Direct(a) + Registers.Y.W;
544
+	AddCycles(ONE_CYCLE);
545
+
546
+	return addr;
547
+}
548
+
549
+static inline uint32_t DirectIndexedYE1 (AccessMode a)					// d,Y
550
+{
551
+	if (Registers.DL)
552
+		return DirectIndexedYE0(a);
553
+	else
554
+	{
555
+		pair	addr;
556
+		addr.W = Direct(a);
557
+		addr.B.l += Registers.YL;
558
+		AddCycles(ONE_CYCLE);
559
+
560
+		return addr.W;
561
+	}
562
+}
563
+
564
+static inline uint32_t DirectIndexedIndirectSlow (AccessMode a)			// (d,X)
565
+{
566
+	uint32_t	addr = S9xGetWord(DirectIndexedXSlow(READ), (!CheckEmulation() || Registers.DL) ? WRAP_BANK : WRAP_PAGE);
567
+	if (a & READ)
568
+		OpenBus = (uint8_t) (addr >> 8);
569
+
570
+	return ICPU.ShiftedDB | addr;
571
+}
572
+
573
+static inline uint32_t DirectIndexedIndirectE0 (AccessMode a)				// (d,X)
574
+{
575
+	uint32_t	addr = S9xGetWord(DirectIndexedXE0(READ));
576
+	if (a & READ)
577
+		OpenBus = (uint8_t) (addr >> 8);
578
+
579
+	return ICPU.ShiftedDB | addr;
580
+}
581
+
582
+static inline uint32_t DirectIndexedIndirectE1 (AccessMode a)				// (d,X)
583
+{
584
+	uint32_t	addr = S9xGetWord(DirectIndexedXE1(READ), Registers.DL ? WRAP_BANK : WRAP_PAGE);
585
+	if (a & READ)
586
+		OpenBus = (uint8_t) (addr >> 8);
587
+
588
+	return ICPU.ShiftedDB | addr;
589
+}
590
+
591
+static inline uint32_t AbsoluteIndexedXSlow (AccessMode a)				// a,X
592
+{
593
+	uint32_t	addr = AbsoluteSlow(a);
594
+	if (a & WRITE || !CheckIndex() || (addr & 0xff) + Registers.XL >= 0x100)
595
+		AddCycles(ONE_CYCLE);
596
+
597
+	return addr + Registers.X.W;
598
+}
599
+
600
+static inline uint32_t AbsoluteIndexedXX0 (AccessMode a)					// a,X
601
+{
602
+	uint32_t	addr = Absolute(a);
603
+	AddCycles(ONE_CYCLE);
604
+
605
+	return addr + Registers.X.W;
606
+}
607
+
608
+static inline uint32_t AbsoluteIndexedXX1 (AccessMode a)					// a,X
609
+{
610
+	uint32_t	addr = Absolute(a);
611
+	if (a & WRITE || (addr & 0xff) + Registers.XL >= 0x100)
612
+		AddCycles(ONE_CYCLE);
613
+
614
+	return addr + Registers.X.W;
615
+}
616
+
617
+static inline uint32_t AbsoluteIndexedYSlow (AccessMode a)				// a,Y
618
+{
619
+	uint32_t	addr = AbsoluteSlow(a);
620
+	if (a & WRITE || !CheckIndex() || (addr & 0xff) + Registers.YL >= 0x100)
621
+		AddCycles(ONE_CYCLE);
622
+
623
+	return addr + Registers.Y.W;
624
+}
625
+
626
+static inline uint32_t AbsoluteIndexedYX0 (AccessMode a)					// a,Y
627
+{
628
+	uint32_t	addr = Absolute(a);
629
+	AddCycles(ONE_CYCLE);
630
+
631
+	return addr + Registers.Y.W;
632
+}
633
+
634
+static inline uint32_t AbsoluteIndexedYX1 (AccessMode a)					// a,Y
635
+{
636
+	uint32_t	addr = Absolute(a);
637
+	if (a & WRITE || (addr & 0xff) + Registers.YL >= 0x100)
638
+		AddCycles(ONE_CYCLE);
639
+
640
+	return addr + Registers.Y.W;
641
+}
642
+
643
+static inline uint32_t AbsoluteLongIndexedXSlow (AccessMode a)			// l,X
644
+{
645
+	return AbsoluteLongSlow(a) + Registers.X.W;
646
+}
647
+
648
+static inline uint32_t AbsoluteLongIndexedX (AccessMode a)				// l,X
649
+{
650
+	return AbsoluteLong(a) + Registers.X.W;
651
+}
652
+
653
+static inline uint32_t StackRelativeSlow (AccessMode a)					// d,S
654
+{
655
+	uint16_t	addr = Immediate8Slow(a) + Registers.S.W;
656
+	AddCycles(ONE_CYCLE);
657
+
658
+	return addr;
659
+}
660
+
661
+static inline uint32_t StackRelative (AccessMode a)						// d,S
662
+{
663
+	uint16_t	addr = Immediate8(a) + Registers.S.W;
664
+	AddCycles(ONE_CYCLE);
665
+
666
+	return addr;
667
+}
668
+
669
+static inline uint32_t StackRelativeIndirectIndexedSlow (AccessMode a)	// (d,S),Y
670
+{
671
+	uint32_t	addr = S9xGetWord(StackRelativeSlow(READ));
672
+	if (a & READ)
673
+		OpenBus = (uint8_t) (addr >> 8);
674
+	addr = (addr + Registers.Y.W + ICPU.ShiftedDB) & 0xffffff;
675
+	AddCycles(ONE_CYCLE);
676
+
677
+	return addr;
678
+}
679
+
680
+static inline uint32_t StackRelativeIndirectIndexed (AccessMode a)		// (d,S),Y
681
+{
682
+	uint32_t	addr = S9xGetWord(StackRelative(READ));
683
+	if (a & READ)
684
+		OpenBus = (uint8_t) (addr >> 8);
685
+	addr = (addr + Registers.Y.W + ICPU.ShiftedDB) & 0xffffff;
686
+	AddCycles(ONE_CYCLE);
687
+
688
+	return addr;
689
+}
690
+
691
+#endif