Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
RishiRecon
GitHub Repository: RishiRecon/exploits
Path: blob/main/misc/emulator/xnes/snes9x/fxinst.cpp
28515 views
1
/***********************************************************************************
2
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
3
4
(c) Copyright 1996 - 2002 Gary Henderson ([email protected]),
5
Jerremy Koot ([email protected])
6
7
(c) Copyright 2002 - 2004 Matthew Kendora
8
9
(c) Copyright 2002 - 2005 Peter Bortas ([email protected])
10
11
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
12
13
(c) Copyright 2001 - 2006 John Weidman ([email protected])
14
15
(c) Copyright 2002 - 2006 funkyass ([email protected]),
16
Kris Bleakley ([email protected])
17
18
(c) Copyright 2002 - 2010 Brad Jorsch ([email protected]),
19
Nach ([email protected]),
20
21
(c) Copyright 2002 - 2011 zones ([email protected])
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_ ([email protected]),
35
Nach,
36
zsKnight ([email protected])
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 ([email protected]),
45
Gary Henderson,
46
Ivar ([email protected]),
47
John Weidman,
48
Kris Bleakley,
49
Matthew Kendora,
50
Nach,
51
neviksti ([email protected])
52
53
DSP-2 emulator code
54
(c) Copyright 2003 John Weidman,
55
Kris Bleakley,
56
Lord Nightmare ([email protected]),
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 ([email protected]),
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 ([email protected])
120
121
SH assembler code partly based on x86 assembler code
122
(c) Copyright 2002 - 2004 Marcus Comstedt ([email protected])
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 ([email protected])
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 "fxinst.h"
181
#include "fxemu.h"
182
183
// Set this define if you wish the plot instruction to check for y-pos limits (I don't think it's nessecary)
184
#define CHECK_LIMITS
185
186
187
/*
188
Codes used:
189
rn = a GSU register (r0 - r15)
190
#n = 4 bit immediate value
191
#pp = 8 bit immediate value
192
(yy) = 8 bit word address (0x0000 - 0x01fe)
193
#xx = 16 bit immediate value
194
(xx) = 16 bit address (0x0000 - 0xffff)
195
*/
196
197
// 00 - stop - stop GSU execution (and maybe generate an IRQ)
198
static void fx_stop (void)
199
{
200
CF(G);
201
GSU.vCounter = 0;
202
GSU.vInstCount = GSU.vCounter;
203
204
// Check if we need to generate an IRQ
205
if (!(GSU.pvRegisters[GSU_CFGR] & 0x80))
206
SF(IRQ);
207
208
GSU.vPlotOptionReg = 0;
209
GSU.vPipe = 1;
210
CLRFLAGS;
211
R15++;
212
}
213
214
// 01 - nop - no operation
215
static void fx_nop (void)
216
{
217
CLRFLAGS;
218
R15++;
219
}
220
221
// 02 - cache - reintialize GSU cache
222
static void fx_cache (void)
223
{
224
uint32 c = R15 & 0xfff0;
225
226
if (GSU.vCacheBaseReg != c || !GSU.bCacheActive)
227
{
228
fx_flushCache();
229
GSU.vCacheBaseReg = c;
230
GSU.bCacheActive = TRUE;
231
232
#if 0
233
if (c < (0x10000 - 512))
234
{
235
const uint8 *t = &ROM(c);
236
memcpy(GSU.pvCache, t, 512);
237
}
238
else
239
{
240
const uint8 *t1, t2;
241
uint32 i = 0x10000 - c;
242
t1 = &ROM(c);
243
t2 = &ROM(0);
244
memcpy(GSU.pvCache, t1, i);
245
memcpy(&GSU.pvCache[i], t2, 512 - i);
246
}
247
#endif
248
}
249
250
CLRFLAGS;
251
R15++;
252
}
253
254
// 03 - lsr - logic shift right
255
static void fx_lsr (void)
256
{
257
uint32 v;
258
GSU.vCarry = SREG & 1;
259
v = USEX16(SREG) >> 1;
260
R15++;
261
DREG = v;
262
GSU.vSign = v;
263
GSU.vZero = v;
264
TESTR14;
265
CLRFLAGS;
266
}
267
268
// 04 - rol - rotate left
269
static void fx_rol (void)
270
{
271
uint32 v = USEX16((SREG << 1) + GSU.vCarry);
272
GSU.vCarry = (SREG >> 15) & 1;
273
R15++;
274
DREG = v;
275
GSU.vSign = v;
276
GSU.vZero = v;
277
TESTR14;
278
CLRFLAGS;
279
}
280
281
// 05 - bra - branch always
282
static void fx_bra (void)
283
{
284
uint8 v = PIPE;
285
R15++;
286
FETCHPIPE;
287
R15 += SEX8(v);
288
}
289
290
// Branch on condition
291
#define BRA_COND(cond) \
292
uint8 v = PIPE; \
293
R15++; \
294
FETCHPIPE; \
295
if (cond) \
296
R15 += SEX8(v); \
297
else \
298
R15++
299
300
#define TEST_S (GSU.vSign & 0x8000)
301
#define TEST_Z (USEX16(GSU.vZero) == 0)
302
#define TEST_OV (GSU.vOverflow >= 0x8000 || GSU.vOverflow < -0x8000)
303
#define TEST_CY (GSU.vCarry & 1)
304
305
// 06 - blt - branch on less than
306
static void fx_blt (void)
307
{
308
BRA_COND((TEST_S != 0) != (TEST_OV != 0));
309
}
310
311
// 07 - bge - branch on greater or equals
312
static void fx_bge (void)
313
{
314
BRA_COND((TEST_S != 0) == (TEST_OV != 0));
315
}
316
317
// 08 - bne - branch on not equal
318
static void fx_bne (void)
319
{
320
BRA_COND(!TEST_Z);
321
}
322
323
// 09 - beq - branch on equal
324
static void fx_beq (void)
325
{
326
BRA_COND(TEST_Z);
327
}
328
329
// 0a - bpl - branch on plus
330
static void fx_bpl (void)
331
{
332
BRA_COND(!TEST_S);
333
}
334
335
// 0b - bmi - branch on minus
336
static void fx_bmi (void)
337
{
338
BRA_COND(TEST_S);
339
}
340
341
// 0c - bcc - branch on carry clear
342
static void fx_bcc (void)
343
{
344
BRA_COND(!TEST_CY);
345
}
346
347
// 0d - bcs - branch on carry set
348
static void fx_bcs (void)
349
{
350
BRA_COND(TEST_CY);
351
}
352
353
// 0e - bvc - branch on overflow clear
354
static void fx_bvc (void)
355
{
356
BRA_COND(!TEST_OV);
357
}
358
359
// 0f - bvs - branch on overflow set
360
static void fx_bvs (void)
361
{
362
BRA_COND(TEST_OV);
363
}
364
365
// 10-1f - to rn - set register n as destination register
366
// 10-1f (B) - move rn - move one register to another (if B flag is set)
367
#define FX_TO(reg) \
368
if (TF(B)) \
369
{ \
370
GSU.avReg[(reg)] = SREG; \
371
CLRFLAGS; \
372
} \
373
else \
374
GSU.pvDreg = &GSU.avReg[reg]; \
375
R15++
376
377
#define FX_TO_R14(reg) \
378
if (TF(B)) \
379
{ \
380
GSU.avReg[(reg)] = SREG; \
381
CLRFLAGS; \
382
READR14; \
383
} \
384
else \
385
GSU.pvDreg = &GSU.avReg[reg]; \
386
R15++
387
388
#define FX_TO_R15(reg) \
389
if (TF(B)) \
390
{ \
391
GSU.avReg[(reg)] = SREG; \
392
CLRFLAGS; \
393
} \
394
else \
395
{ \
396
GSU.pvDreg = &GSU.avReg[reg]; \
397
R15++; \
398
}
399
400
static void fx_to_r0 (void)
401
{
402
FX_TO(0);
403
}
404
405
static void fx_to_r1 (void)
406
{
407
FX_TO(1);
408
}
409
410
static void fx_to_r2 (void)
411
{
412
FX_TO(2);
413
}
414
415
static void fx_to_r3 (void)
416
{
417
FX_TO(3);
418
}
419
420
static void fx_to_r4 (void)
421
{
422
FX_TO(4);
423
}
424
425
static void fx_to_r5 (void)
426
{
427
FX_TO(5);
428
}
429
430
static void fx_to_r6 (void)
431
{
432
FX_TO(6);
433
}
434
435
static void fx_to_r7 (void)
436
{
437
FX_TO(7);
438
}
439
440
static void fx_to_r8 (void)
441
{
442
FX_TO(8);
443
}
444
445
static void fx_to_r9 (void)
446
{
447
FX_TO(9);
448
}
449
450
static void fx_to_r10 (void)
451
{
452
FX_TO(10);
453
}
454
455
static void fx_to_r11 (void)
456
{
457
FX_TO(11);
458
}
459
460
static void fx_to_r12 (void)
461
{
462
FX_TO(12);
463
}
464
465
static void fx_to_r13 (void)
466
{
467
FX_TO(13);
468
}
469
470
static void fx_to_r14 (void)
471
{
472
FX_TO_R14(14);
473
}
474
475
static void fx_to_r15 (void)
476
{
477
FX_TO_R15(15);
478
}
479
480
// 20-2f - to rn - set register n as source and destination register
481
#define FX_WITH(reg) \
482
SF(B); \
483
GSU.pvSreg = GSU.pvDreg = &GSU.avReg[reg]; \
484
R15++
485
486
static void fx_with_r0 (void)
487
{
488
FX_WITH(0);
489
}
490
491
static void fx_with_r1 (void)
492
{
493
FX_WITH(1);
494
}
495
496
static void fx_with_r2 (void)
497
{
498
FX_WITH(2);
499
}
500
501
static void fx_with_r3 (void)
502
{
503
FX_WITH(3);
504
}
505
506
static void fx_with_r4 (void)
507
{
508
FX_WITH(4);
509
}
510
511
static void fx_with_r5 (void)
512
{
513
FX_WITH(5);
514
}
515
516
static void fx_with_r6 (void)
517
{
518
FX_WITH(6);
519
}
520
521
static void fx_with_r7 (void)
522
{
523
FX_WITH(7);
524
}
525
526
static void fx_with_r8 (void)
527
{
528
FX_WITH(8);
529
}
530
531
static void fx_with_r9 (void)
532
{
533
FX_WITH(9);
534
}
535
536
static void fx_with_r10 (void)
537
{
538
FX_WITH(10);
539
}
540
541
static void fx_with_r11 (void)
542
{
543
FX_WITH(11);
544
}
545
546
static void fx_with_r12 (void)
547
{
548
FX_WITH(12);
549
}
550
551
static void fx_with_r13 (void)
552
{
553
FX_WITH(13);
554
}
555
556
static void fx_with_r14 (void)
557
{
558
FX_WITH(14);
559
}
560
561
static void fx_with_r15 (void)
562
{
563
FX_WITH(15);
564
}
565
566
// 30-3b - stw (rn) - store word
567
#define FX_STW(reg) \
568
GSU.vLastRamAdr = GSU.avReg[reg]; \
569
RAM(GSU.avReg[reg]) = (uint8) SREG; \
570
RAM(GSU.avReg[reg] ^ 1) = (uint8) (SREG >> 8); \
571
CLRFLAGS; \
572
R15++
573
574
static void fx_stw_r0 (void)
575
{
576
FX_STW(0);
577
}
578
579
static void fx_stw_r1 (void)
580
{
581
FX_STW(1);
582
}
583
584
static void fx_stw_r2 (void)
585
{
586
FX_STW(2);
587
}
588
589
static void fx_stw_r3 (void)
590
{
591
FX_STW(3);
592
}
593
594
static void fx_stw_r4 (void)
595
{
596
FX_STW(4);
597
}
598
599
static void fx_stw_r5 (void)
600
{
601
FX_STW(5);
602
}
603
604
static void fx_stw_r6 (void)
605
{
606
FX_STW(6);
607
}
608
609
static void fx_stw_r7 (void)
610
{
611
FX_STW(7);
612
}
613
614
static void fx_stw_r8 (void)
615
{
616
FX_STW(8);
617
}
618
619
static void fx_stw_r9 (void)
620
{
621
FX_STW(9);
622
}
623
624
static void fx_stw_r10 (void)
625
{
626
FX_STW(10);
627
}
628
629
static void fx_stw_r11 (void)
630
{
631
FX_STW(11);
632
}
633
634
// 30-3b (ALT1) - stb (rn) - store byte
635
#define FX_STB(reg) \
636
GSU.vLastRamAdr = GSU.avReg[reg]; \
637
RAM(GSU.avReg[reg]) = (uint8) SREG; \
638
CLRFLAGS; \
639
R15++
640
641
static void fx_stb_r0 (void)
642
{
643
FX_STB(0);
644
}
645
646
static void fx_stb_r1 (void)
647
{
648
FX_STB(1);
649
}
650
651
static void fx_stb_r2 (void)
652
{
653
FX_STB(2);
654
}
655
656
static void fx_stb_r3 (void)
657
{
658
FX_STB(3);
659
}
660
661
static void fx_stb_r4 (void)
662
{
663
FX_STB(4);
664
}
665
666
static void fx_stb_r5 (void)
667
{
668
FX_STB(5);
669
}
670
671
static void fx_stb_r6 (void)
672
{
673
FX_STB(6);
674
}
675
676
static void fx_stb_r7 (void)
677
{
678
FX_STB(7);
679
}
680
681
static void fx_stb_r8 (void)
682
{
683
FX_STB(8);
684
}
685
686
static void fx_stb_r9 (void)
687
{
688
FX_STB(9);
689
}
690
691
static void fx_stb_r10 (void)
692
{
693
FX_STB(10);
694
}
695
696
static void fx_stb_r11 (void)
697
{
698
FX_STB(11);
699
}
700
701
// 3c - loop - decrement loop counter, and branch on not zero
702
static void fx_loop (void)
703
{
704
GSU.vSign = GSU.vZero = --R12;
705
if ((uint16) R12 != 0)
706
R15 = R13;
707
else
708
R15++;
709
CLRFLAGS;
710
}
711
712
// 3d - alt1 - set alt1 mode
713
static void fx_alt1 (void)
714
{
715
SF(ALT1);
716
CF(B);
717
R15++;
718
}
719
720
// 3e - alt2 - set alt2 mode
721
static void fx_alt2 (void)
722
{
723
SF(ALT2);
724
CF(B);
725
R15++;
726
}
727
728
// 3f - alt3 - set alt3 mode
729
static void fx_alt3 (void)
730
{
731
SF(ALT1);
732
SF(ALT2);
733
CF(B);
734
R15++;
735
}
736
737
// 40-4b - ldw (rn) - load word from RAM
738
#define FX_LDW(reg) \
739
uint32 v; \
740
GSU.vLastRamAdr = GSU.avReg[reg]; \
741
v = (uint32) RAM(GSU.avReg[reg]); \
742
v |= ((uint32) RAM(GSU.avReg[reg] ^ 1)) << 8; \
743
R15++; \
744
DREG = v; \
745
TESTR14; \
746
CLRFLAGS
747
748
static void fx_ldw_r0 (void)
749
{
750
FX_LDW(0);
751
}
752
753
static void fx_ldw_r1 (void)
754
{
755
FX_LDW(1);
756
}
757
758
static void fx_ldw_r2 (void)
759
{
760
FX_LDW(2);
761
}
762
763
static void fx_ldw_r3 (void)
764
{
765
FX_LDW(3);
766
}
767
768
static void fx_ldw_r4 (void)
769
{
770
FX_LDW(4);
771
}
772
773
static void fx_ldw_r5 (void)
774
{
775
FX_LDW(5);
776
}
777
778
static void fx_ldw_r6 (void)
779
{
780
FX_LDW(6);
781
}
782
783
static void fx_ldw_r7 (void)
784
{
785
FX_LDW(7);
786
}
787
788
static void fx_ldw_r8 (void)
789
{
790
FX_LDW(8);
791
}
792
793
static void fx_ldw_r9 (void)
794
{
795
FX_LDW(9);
796
}
797
798
static void fx_ldw_r10 (void)
799
{
800
FX_LDW(10);
801
}
802
803
static void fx_ldw_r11 (void)
804
{
805
FX_LDW(11);
806
}
807
808
// 40-4b (ALT1) - ldb (rn) - load byte
809
#define FX_LDB(reg) \
810
uint32 v; \
811
GSU.vLastRamAdr = GSU.avReg[reg]; \
812
v = (uint32) RAM(GSU.avReg[reg]); \
813
R15++; \
814
DREG = v; \
815
TESTR14; \
816
CLRFLAGS
817
818
static void fx_ldb_r0 (void)
819
{
820
FX_LDB(0);
821
}
822
823
static void fx_ldb_r1 (void)
824
{
825
FX_LDB(1);
826
}
827
828
static void fx_ldb_r2 (void)
829
{
830
FX_LDB(2);
831
}
832
833
static void fx_ldb_r3 (void)
834
{
835
FX_LDB(3);
836
}
837
838
static void fx_ldb_r4 (void)
839
{
840
FX_LDB(4);
841
}
842
843
static void fx_ldb_r5 (void)
844
{
845
FX_LDB(5);
846
}
847
848
static void fx_ldb_r6 (void)
849
{
850
FX_LDB(6);
851
}
852
853
static void fx_ldb_r7 (void)
854
{
855
FX_LDB(7);
856
}
857
858
static void fx_ldb_r8 (void)
859
{
860
FX_LDB(8);
861
}
862
863
static void fx_ldb_r9 (void)
864
{
865
FX_LDB(9);
866
}
867
868
static void fx_ldb_r10 (void)
869
{
870
FX_LDB(10);
871
}
872
873
static void fx_ldb_r11 (void)
874
{
875
FX_LDB(11);
876
}
877
878
// 4c - plot - plot pixel with R1, R2 as x, y and the color register as the color
879
static void fx_plot_2bit (void)
880
{
881
uint32 x = USEX8(R1);
882
uint32 y = USEX8(R2);
883
uint8 *a;
884
uint8 v, c;
885
886
R15++;
887
CLRFLAGS;
888
R1++;
889
890
#ifdef CHECK_LIMITS
891
if (y >= GSU.vScreenHeight)
892
return;
893
#endif
894
895
if (GSU.vPlotOptionReg & 0x02)
896
c = (x ^ y) & 1 ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg;
897
else
898
c = (uint8) GSU.vColorReg;
899
900
if (!(GSU.vPlotOptionReg & 0x01) && !(c & 0xf))
901
return;
902
903
a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);
904
v = 128 >> (x & 7);
905
906
if (c & 0x01)
907
a[0] |= v;
908
else
909
a[0] &= ~v;
910
911
if (c & 0x02)
912
a[1] |= v;
913
else
914
a[1] &= ~v;
915
}
916
917
// 4c (ALT1) - rpix - read color of the pixel with R1, R2 as x, y
918
static void fx_rpix_2bit (void)
919
{
920
uint32 x = USEX8(R1);
921
uint32 y = USEX8(R2);
922
uint8 *a;
923
uint8 v;
924
925
R15++;
926
CLRFLAGS;
927
928
#ifdef CHECK_LIMITS
929
if (y >= GSU.vScreenHeight)
930
return;
931
#endif
932
933
a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);
934
v = 128 >> (x & 7);
935
936
DREG = 0;
937
DREG |= ((uint32) ((a[0] & v) != 0)) << 0;
938
DREG |= ((uint32) ((a[1] & v) != 0)) << 1;
939
TESTR14;
940
}
941
942
// 4c - plot - plot pixel with R1, R2 as x, y and the color register as the color
943
static void fx_plot_4bit (void)
944
{
945
uint32 x = USEX8(R1);
946
uint32 y = USEX8(R2);
947
uint8 *a;
948
uint8 v, c;
949
950
R15++;
951
CLRFLAGS;
952
R1++;
953
954
#ifdef CHECK_LIMITS
955
if (y >= GSU.vScreenHeight)
956
return;
957
#endif
958
959
if (GSU.vPlotOptionReg & 0x02)
960
c = (x ^ y) & 1 ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg;
961
else
962
c = (uint8) GSU.vColorReg;
963
964
if (!(GSU.vPlotOptionReg & 0x01) && !(c & 0xf))
965
return;
966
967
a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);
968
v = 128 >> (x & 7);
969
970
if (c & 0x01)
971
a[0x00] |= v;
972
else
973
a[0x00] &= ~v;
974
975
if (c & 0x02)
976
a[0x01] |= v;
977
else
978
a[0x01] &= ~v;
979
980
if (c & 0x04)
981
a[0x10] |= v;
982
else
983
a[0x10] &= ~v;
984
985
if (c & 0x08)
986
a[0x11] |= v;
987
else
988
a[0x11] &= ~v;
989
}
990
991
// 4c (ALT1) - rpix - read color of the pixel with R1, R2 as x, y
992
static void fx_rpix_4bit (void)
993
{
994
uint32 x = USEX8(R1);
995
uint32 y = USEX8(R2);
996
uint8 *a;
997
uint8 v;
998
999
R15++;
1000
CLRFLAGS;
1001
1002
#ifdef CHECK_LIMITS
1003
if (y >= GSU.vScreenHeight)
1004
return;
1005
#endif
1006
1007
a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);
1008
v = 128 >> (x & 7);
1009
1010
DREG = 0;
1011
DREG |= ((uint32) ((a[0x00] & v) != 0)) << 0;
1012
DREG |= ((uint32) ((a[0x01] & v) != 0)) << 1;
1013
DREG |= ((uint32) ((a[0x10] & v) != 0)) << 2;
1014
DREG |= ((uint32) ((a[0x11] & v) != 0)) << 3;
1015
TESTR14;
1016
}
1017
1018
// 4c - plot - plot pixel with R1, R2 as x, y and the color register as the color
1019
static void fx_plot_8bit (void)
1020
{
1021
uint32 x = USEX8(R1);
1022
uint32 y = USEX8(R2);
1023
uint8 *a;
1024
uint8 v, c;
1025
1026
R15++;
1027
CLRFLAGS;
1028
R1++;
1029
1030
#ifdef CHECK_LIMITS
1031
if (y >= GSU.vScreenHeight)
1032
return;
1033
#endif
1034
1035
c = (uint8) GSU.vColorReg;
1036
if (!(GSU.vPlotOptionReg & 0x10))
1037
{
1038
if (!(GSU.vPlotOptionReg & 0x01) && !(c & 0xf))
1039
return;
1040
}
1041
else
1042
if (!(GSU.vPlotOptionReg & 0x01) && !c)
1043
return;
1044
1045
a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);
1046
v = 128 >> (x & 7);
1047
1048
if (c & 0x01)
1049
a[0x00] |= v;
1050
else
1051
a[0x00] &= ~v;
1052
1053
if (c & 0x02)
1054
a[0x01] |= v;
1055
else
1056
a[0x01] &= ~v;
1057
1058
if (c & 0x04)
1059
a[0x10] |= v;
1060
else
1061
a[0x10] &= ~v;
1062
1063
if (c & 0x08)
1064
a[0x11] |= v;
1065
else
1066
a[0x11] &= ~v;
1067
1068
if (c & 0x10)
1069
a[0x20] |= v;
1070
else
1071
a[0x20] &= ~v;
1072
1073
if (c & 0x20)
1074
a[0x21] |= v;
1075
else
1076
a[0x21] &= ~v;
1077
1078
if (c & 0x40)
1079
a[0x30] |= v;
1080
else
1081
a[0x30] &= ~v;
1082
1083
if (c & 0x80)
1084
a[0x31] |= v;
1085
else
1086
a[0x31] &= ~v;
1087
}
1088
1089
// 4c (ALT1) - rpix - read color of the pixel with R1, R2 as x, y
1090
static void fx_rpix_8bit (void)
1091
{
1092
uint32 x = USEX8(R1);
1093
uint32 y = USEX8(R2);
1094
uint8 *a;
1095
uint8 v;
1096
1097
R15++;
1098
CLRFLAGS;
1099
1100
#ifdef CHECK_LIMITS
1101
if (y >= GSU.vScreenHeight)
1102
return;
1103
#endif
1104
1105
a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);
1106
v = 128 >> (x & 7);
1107
1108
DREG = 0;
1109
DREG |= ((uint32) ((a[0x00] & v) != 0)) << 0;
1110
DREG |= ((uint32) ((a[0x01] & v) != 0)) << 1;
1111
DREG |= ((uint32) ((a[0x10] & v) != 0)) << 2;
1112
DREG |= ((uint32) ((a[0x11] & v) != 0)) << 3;
1113
DREG |= ((uint32) ((a[0x20] & v) != 0)) << 4;
1114
DREG |= ((uint32) ((a[0x21] & v) != 0)) << 5;
1115
DREG |= ((uint32) ((a[0x30] & v) != 0)) << 6;
1116
DREG |= ((uint32) ((a[0x31] & v) != 0)) << 7;
1117
GSU.vZero = DREG;
1118
TESTR14;
1119
}
1120
1121
// 4c - plot - plot pixel with R1, R2 as x, y and the color register as the color
1122
static void fx_plot_obj (void)
1123
{
1124
#ifdef DEBUGGER
1125
fprintf(stderr, "ERROR fx_plot_obj called\n");
1126
#endif
1127
}
1128
1129
// 4c (ALT1) - rpix - read color of the pixel with R1, R2 as x, y
1130
static void fx_rpix_obj (void)
1131
{
1132
#ifdef DEBUGGER
1133
fprintf(stderr, "ERROR fx_rpix_obj called\n");
1134
#endif
1135
}
1136
1137
// 4d - swap - swap upper and lower byte of a register
1138
static void fx_swap (void)
1139
{
1140
uint8 c = (uint8) SREG;
1141
uint8 d = (uint8) (SREG >> 8);
1142
uint32 v = (((uint32) c) << 8) | ((uint32) d);
1143
R15++;
1144
DREG = v;
1145
GSU.vSign = v;
1146
GSU.vZero = v;
1147
TESTR14;
1148
CLRFLAGS;
1149
}
1150
1151
// 4e - color - copy source register to color register
1152
static void fx_color (void)
1153
{
1154
uint8 c = (uint8) SREG;
1155
1156
if (GSU.vPlotOptionReg & 0x04)
1157
c = (c & 0xf0) | (c >> 4);
1158
if (GSU.vPlotOptionReg & 0x08)
1159
{
1160
GSU.vColorReg &= 0xf0;
1161
GSU.vColorReg |= c & 0x0f;
1162
}
1163
else
1164
GSU.vColorReg = USEX8(c);
1165
1166
CLRFLAGS;
1167
R15++;
1168
}
1169
1170
// 4e (ALT1) - cmode - set plot option register
1171
static void fx_cmode (void)
1172
{
1173
GSU.vPlotOptionReg = SREG;
1174
1175
if (GSU.vPlotOptionReg & 0x10)
1176
GSU.vScreenHeight = 256; // OBJ Mode (for drawing into sprites)
1177
else
1178
GSU.vScreenHeight = GSU.vScreenRealHeight;
1179
1180
fx_computeScreenPointers();
1181
CLRFLAGS;
1182
R15++;
1183
}
1184
1185
// 4f - not - perform exclusive exor with 1 on all bits
1186
static void fx_not (void)
1187
{
1188
uint32 v = ~SREG;
1189
R15++;
1190
DREG = v;
1191
GSU.vSign = v;
1192
GSU.vZero = v;
1193
TESTR14;
1194
CLRFLAGS;
1195
}
1196
1197
// 50-5f - add rn - add, register + register
1198
#define FX_ADD(reg) \
1199
int32 s = SUSEX16(SREG) + SUSEX16(GSU.avReg[reg]); \
1200
GSU.vCarry = s >= 0x10000; \
1201
GSU.vOverflow = ~(SREG ^ GSU.avReg[reg]) & (GSU.avReg[reg] ^ s) & 0x8000; \
1202
GSU.vSign = s; \
1203
GSU.vZero = s; \
1204
R15++; \
1205
DREG = s; \
1206
TESTR14; \
1207
CLRFLAGS
1208
1209
static void fx_add_r0 (void)
1210
{
1211
FX_ADD(0);
1212
}
1213
1214
static void fx_add_r1 (void)
1215
{
1216
FX_ADD(1);
1217
}
1218
1219
static void fx_add_r2 (void)
1220
{
1221
FX_ADD(2);
1222
}
1223
1224
static void fx_add_r3 (void)
1225
{
1226
FX_ADD(3);
1227
}
1228
1229
static void fx_add_r4 (void)
1230
{
1231
FX_ADD(4);
1232
}
1233
1234
static void fx_add_r5 (void)
1235
{
1236
FX_ADD(5);
1237
}
1238
1239
static void fx_add_r6 (void)
1240
{
1241
FX_ADD(6);
1242
}
1243
1244
static void fx_add_r7 (void)
1245
{
1246
FX_ADD(7);
1247
}
1248
1249
static void fx_add_r8 (void)
1250
{
1251
FX_ADD(8);
1252
}
1253
1254
static void fx_add_r9 (void)
1255
{
1256
FX_ADD(9);
1257
}
1258
1259
static void fx_add_r10 (void)
1260
{
1261
FX_ADD(10);
1262
}
1263
1264
static void fx_add_r11 (void)
1265
{
1266
FX_ADD(11);
1267
}
1268
1269
static void fx_add_r12 (void)
1270
{
1271
FX_ADD(12);
1272
}
1273
1274
static void fx_add_r13 (void)
1275
{
1276
FX_ADD(13);
1277
}
1278
1279
static void fx_add_r14 (void)
1280
{
1281
FX_ADD(14);
1282
}
1283
1284
static void fx_add_r15 (void)
1285
{
1286
FX_ADD(15);
1287
}
1288
1289
// 50-5f (ALT1) - adc rn - add with carry, register + register
1290
#define FX_ADC(reg) \
1291
int32 s = SUSEX16(SREG) + SUSEX16(GSU.avReg[reg]) + SEX16(GSU.vCarry); \
1292
GSU.vCarry = s >= 0x10000; \
1293
GSU.vOverflow = ~(SREG ^ GSU.avReg[reg]) & (GSU.avReg[reg] ^ s) & 0x8000; \
1294
GSU.vSign = s; \
1295
GSU.vZero = s; \
1296
R15++; \
1297
DREG = s; \
1298
TESTR14; \
1299
CLRFLAGS
1300
1301
static void fx_adc_r0 (void)
1302
{
1303
FX_ADC(0);
1304
}
1305
1306
static void fx_adc_r1 (void)
1307
{
1308
FX_ADC(1);
1309
}
1310
1311
static void fx_adc_r2 (void)
1312
{
1313
FX_ADC(2);
1314
}
1315
1316
static void fx_adc_r3 (void)
1317
{
1318
FX_ADC(3);
1319
}
1320
1321
static void fx_adc_r4 (void)
1322
{
1323
FX_ADC(4);
1324
}
1325
1326
static void fx_adc_r5 (void)
1327
{
1328
FX_ADC(5);
1329
}
1330
1331
static void fx_adc_r6 (void)
1332
{
1333
FX_ADC(6);
1334
}
1335
1336
static void fx_adc_r7 (void)
1337
{
1338
FX_ADC(7);
1339
}
1340
1341
static void fx_adc_r8 (void)
1342
{
1343
FX_ADC(8);
1344
}
1345
1346
static void fx_adc_r9 (void)
1347
{
1348
FX_ADC(9);
1349
}
1350
1351
static void fx_adc_r10 (void)
1352
{
1353
FX_ADC(10);
1354
}
1355
1356
static void fx_adc_r11 (void)
1357
{
1358
FX_ADC(11);
1359
}
1360
1361
static void fx_adc_r12 (void)
1362
{
1363
FX_ADC(12);
1364
}
1365
1366
static void fx_adc_r13 (void)
1367
{
1368
FX_ADC(13);
1369
}
1370
1371
static void fx_adc_r14 (void)
1372
{
1373
FX_ADC(14);
1374
}
1375
1376
static void fx_adc_r15 (void)
1377
{
1378
FX_ADC(15);
1379
}
1380
1381
// 50-5f (ALT2) - add #n - add, register + immediate
1382
#define FX_ADD_I(imm) \
1383
int32 s = SUSEX16(SREG) + imm; \
1384
GSU.vCarry = s >= 0x10000; \
1385
GSU.vOverflow = ~(SREG ^ imm) & (imm ^ s) & 0x8000; \
1386
GSU.vSign = s; \
1387
GSU.vZero = s; \
1388
R15++; \
1389
DREG = s; \
1390
TESTR14; \
1391
CLRFLAGS
1392
1393
static void fx_add_i0 (void)
1394
{
1395
FX_ADD_I(0);
1396
}
1397
1398
static void fx_add_i1 (void)
1399
{
1400
FX_ADD_I(1);
1401
}
1402
1403
static void fx_add_i2 (void)
1404
{
1405
FX_ADD_I(2);
1406
}
1407
1408
static void fx_add_i3 (void)
1409
{
1410
FX_ADD_I(3);
1411
}
1412
1413
static void fx_add_i4 (void)
1414
{
1415
FX_ADD_I(4);
1416
}
1417
1418
static void fx_add_i5 (void)
1419
{
1420
FX_ADD_I(5);
1421
}
1422
1423
static void fx_add_i6 (void)
1424
{
1425
FX_ADD_I(6);
1426
}
1427
1428
static void fx_add_i7 (void)
1429
{
1430
FX_ADD_I(7);
1431
}
1432
1433
static void fx_add_i8 (void)
1434
{
1435
FX_ADD_I(8);
1436
}
1437
1438
static void fx_add_i9 (void)
1439
{
1440
FX_ADD_I(9);
1441
}
1442
1443
static void fx_add_i10 (void)
1444
{
1445
FX_ADD_I(10);
1446
}
1447
1448
static void fx_add_i11 (void)
1449
{
1450
FX_ADD_I(11);
1451
}
1452
1453
static void fx_add_i12 (void)
1454
{
1455
FX_ADD_I(12);
1456
}
1457
1458
static void fx_add_i13 (void)
1459
{
1460
FX_ADD_I(13);
1461
}
1462
1463
static void fx_add_i14 (void)
1464
{
1465
FX_ADD_I(14);
1466
}
1467
1468
static void fx_add_i15 (void)
1469
{
1470
FX_ADD_I(15);
1471
}
1472
1473
// 50-5f (ALT3) - adc #n - add with carry, register + immediate
1474
#define FX_ADC_I(imm) \
1475
int32 s = SUSEX16(SREG) + imm + SUSEX16(GSU.vCarry); \
1476
GSU.vCarry = s >= 0x10000; \
1477
GSU.vOverflow = ~(SREG ^ imm) & (imm ^ s) & 0x8000; \
1478
GSU.vSign = s; \
1479
GSU.vZero = s; \
1480
R15++; \
1481
DREG = s; \
1482
TESTR14; \
1483
CLRFLAGS
1484
1485
static void fx_adc_i0 (void)
1486
{
1487
FX_ADC_I(0);
1488
}
1489
1490
static void fx_adc_i1 (void)
1491
{
1492
FX_ADC_I(1);
1493
}
1494
1495
static void fx_adc_i2 (void)
1496
{
1497
FX_ADC_I(2);
1498
}
1499
1500
static void fx_adc_i3 (void)
1501
{
1502
FX_ADC_I(3);
1503
}
1504
1505
static void fx_adc_i4 (void)
1506
{
1507
FX_ADC_I(4);
1508
}
1509
1510
static void fx_adc_i5 (void)
1511
{
1512
FX_ADC_I(5);
1513
}
1514
1515
static void fx_adc_i6 (void)
1516
{
1517
FX_ADC_I(6);
1518
}
1519
1520
static void fx_adc_i7 (void)
1521
{
1522
FX_ADC_I(7);
1523
}
1524
1525
static void fx_adc_i8 (void)
1526
{
1527
FX_ADC_I(8);
1528
}
1529
1530
static void fx_adc_i9 (void)
1531
{
1532
FX_ADC_I(9);
1533
}
1534
1535
static void fx_adc_i10 (void)
1536
{
1537
FX_ADC_I(10);
1538
}
1539
1540
static void fx_adc_i11 (void)
1541
{
1542
FX_ADC_I(11);
1543
}
1544
1545
static void fx_adc_i12 (void)
1546
{
1547
FX_ADC_I(12);
1548
}
1549
1550
static void fx_adc_i13 (void)
1551
{
1552
FX_ADC_I(13);
1553
}
1554
1555
static void fx_adc_i14 (void)
1556
{
1557
FX_ADC_I(14);
1558
}
1559
1560
static void fx_adc_i15 (void)
1561
{
1562
FX_ADC_I(15);
1563
}
1564
1565
// 60-6f - sub rn - subtract, register - register
1566
#define FX_SUB(reg) \
1567
int32 s = SUSEX16(SREG) - SUSEX16(GSU.avReg[reg]); \
1568
GSU.vCarry = s >= 0; \
1569
GSU.vOverflow = (SREG ^ GSU.avReg[reg]) & (SREG ^ s) & 0x8000; \
1570
GSU.vSign = s; \
1571
GSU.vZero = s; \
1572
R15++; \
1573
DREG = s; \
1574
TESTR14; \
1575
CLRFLAGS
1576
1577
static void fx_sub_r0 (void)
1578
{
1579
FX_SUB(0);
1580
}
1581
1582
static void fx_sub_r1 (void)
1583
{
1584
FX_SUB(1);
1585
}
1586
1587
static void fx_sub_r2 (void)
1588
{
1589
FX_SUB(2);
1590
}
1591
1592
static void fx_sub_r3 (void)
1593
{
1594
FX_SUB(3);
1595
}
1596
1597
static void fx_sub_r4 (void)
1598
{
1599
FX_SUB(4);
1600
}
1601
1602
static void fx_sub_r5 (void)
1603
{
1604
FX_SUB(5);
1605
}
1606
1607
static void fx_sub_r6 (void)
1608
{
1609
FX_SUB(6);
1610
}
1611
1612
static void fx_sub_r7 (void)
1613
{
1614
FX_SUB(7);
1615
}
1616
1617
static void fx_sub_r8 (void)
1618
{
1619
FX_SUB(8);
1620
}
1621
1622
static void fx_sub_r9 (void)
1623
{
1624
FX_SUB(9);
1625
}
1626
1627
static void fx_sub_r10 (void)
1628
{
1629
FX_SUB(10);
1630
}
1631
1632
static void fx_sub_r11 (void)
1633
{
1634
FX_SUB(11);
1635
}
1636
1637
static void fx_sub_r12 (void)
1638
{
1639
FX_SUB(12);
1640
}
1641
1642
static void fx_sub_r13 (void)
1643
{
1644
FX_SUB(13);
1645
}
1646
1647
static void fx_sub_r14 (void)
1648
{
1649
FX_SUB(14);
1650
}
1651
1652
static void fx_sub_r15 (void)
1653
{
1654
FX_SUB(15);
1655
}
1656
1657
// 60-6f (ALT1) - sbc rn - subtract with carry, register - register
1658
#define FX_SBC(reg) \
1659
int32 s = SUSEX16(SREG) - SUSEX16(GSU.avReg[reg]) - (SUSEX16(GSU.vCarry ^ 1)); \
1660
GSU.vCarry = s >= 0; \
1661
GSU.vOverflow = (SREG ^ GSU.avReg[reg]) & (SREG ^ s) & 0x8000; \
1662
GSU.vSign = s; \
1663
GSU.vZero = s; \
1664
R15++; \
1665
DREG = s; \
1666
TESTR14; \
1667
CLRFLAGS
1668
1669
static void fx_sbc_r0 (void)
1670
{
1671
FX_SBC(0);
1672
}
1673
1674
static void fx_sbc_r1 (void)
1675
{
1676
FX_SBC(1);
1677
}
1678
1679
static void fx_sbc_r2 (void)
1680
{
1681
FX_SBC(2);
1682
}
1683
1684
static void fx_sbc_r3 (void)
1685
{
1686
FX_SBC(3);
1687
}
1688
1689
static void fx_sbc_r4 (void)
1690
{
1691
FX_SBC(4);
1692
}
1693
1694
static void fx_sbc_r5 (void)
1695
{
1696
FX_SBC(5);
1697
}
1698
1699
static void fx_sbc_r6 (void)
1700
{
1701
FX_SBC(6);
1702
}
1703
1704
static void fx_sbc_r7 (void)
1705
{
1706
FX_SBC(7);
1707
}
1708
1709
static void fx_sbc_r8 (void)
1710
{
1711
FX_SBC(8);
1712
}
1713
1714
static void fx_sbc_r9 (void)
1715
{
1716
FX_SBC(9);
1717
}
1718
1719
static void fx_sbc_r10 (void)
1720
{
1721
FX_SBC(10);
1722
}
1723
1724
static void fx_sbc_r11 (void)
1725
{
1726
FX_SBC(11);
1727
}
1728
1729
static void fx_sbc_r12 (void)
1730
{
1731
FX_SBC(12);
1732
}
1733
1734
static void fx_sbc_r13 (void)
1735
{
1736
FX_SBC(13);
1737
}
1738
1739
static void fx_sbc_r14 (void)
1740
{
1741
FX_SBC(14);
1742
}
1743
1744
static void fx_sbc_r15 (void)
1745
{
1746
FX_SBC(15);
1747
}
1748
1749
// 60-6f (ALT2) - sub #n - subtract, register - immediate
1750
#define FX_SUB_I(imm) \
1751
int32 s = SUSEX16(SREG) - imm; \
1752
GSU.vCarry = s >= 0; \
1753
GSU.vOverflow = (SREG ^ imm) & (SREG ^ s) & 0x8000; \
1754
GSU.vSign = s; \
1755
GSU.vZero = s; \
1756
R15++; \
1757
DREG = s; \
1758
TESTR14; \
1759
CLRFLAGS
1760
1761
static void fx_sub_i0 (void)
1762
{
1763
FX_SUB_I(0);
1764
}
1765
1766
static void fx_sub_i1 (void)
1767
{
1768
FX_SUB_I(1);
1769
}
1770
1771
static void fx_sub_i2 (void)
1772
{
1773
FX_SUB_I(2);
1774
}
1775
1776
static void fx_sub_i3 (void)
1777
{
1778
FX_SUB_I(3);
1779
}
1780
1781
static void fx_sub_i4 (void)
1782
{
1783
FX_SUB_I(4);
1784
}
1785
1786
static void fx_sub_i5 (void)
1787
{
1788
FX_SUB_I(5);
1789
}
1790
1791
static void fx_sub_i6 (void)
1792
{
1793
FX_SUB_I(6);
1794
}
1795
1796
static void fx_sub_i7 (void)
1797
{
1798
FX_SUB_I(7);
1799
}
1800
1801
static void fx_sub_i8 (void)
1802
{
1803
FX_SUB_I(8);
1804
}
1805
1806
static void fx_sub_i9 (void)
1807
{
1808
FX_SUB_I(9);
1809
}
1810
1811
static void fx_sub_i10 (void)
1812
{
1813
FX_SUB_I(10);
1814
}
1815
1816
static void fx_sub_i11 (void)
1817
{
1818
FX_SUB_I(11);
1819
}
1820
1821
static void fx_sub_i12 (void)
1822
{
1823
FX_SUB_I(12);
1824
}
1825
1826
static void fx_sub_i13 (void)
1827
{
1828
FX_SUB_I(13);
1829
}
1830
1831
static void fx_sub_i14 (void)
1832
{
1833
FX_SUB_I(14);
1834
}
1835
1836
static void fx_sub_i15 (void)
1837
{
1838
FX_SUB_I(15);
1839
}
1840
1841
// 60-6f (ALT3) - cmp rn - compare, register, register
1842
#define FX_CMP(reg) \
1843
int32 s = SUSEX16(SREG) - SUSEX16(GSU.avReg[reg]); \
1844
GSU.vCarry = s >= 0; \
1845
GSU.vOverflow = (SREG ^ GSU.avReg[reg]) & (SREG ^ s) & 0x8000; \
1846
GSU.vSign = s; \
1847
GSU.vZero = s; \
1848
R15++; \
1849
CLRFLAGS
1850
1851
static void fx_cmp_r0 (void)
1852
{
1853
FX_CMP(0);
1854
}
1855
1856
static void fx_cmp_r1 (void)
1857
{
1858
FX_CMP(1);
1859
}
1860
1861
static void fx_cmp_r2 (void)
1862
{
1863
FX_CMP(2);
1864
}
1865
1866
static void fx_cmp_r3 (void)
1867
{
1868
FX_CMP(3);
1869
}
1870
1871
static void fx_cmp_r4 (void)
1872
{
1873
FX_CMP(4);
1874
}
1875
1876
static void fx_cmp_r5 (void)
1877
{
1878
FX_CMP(5);
1879
}
1880
1881
static void fx_cmp_r6 (void)
1882
{
1883
FX_CMP(6);
1884
}
1885
1886
static void fx_cmp_r7 (void)
1887
{
1888
FX_CMP(7);
1889
}
1890
1891
static void fx_cmp_r8 (void)
1892
{
1893
FX_CMP(8);
1894
}
1895
1896
static void fx_cmp_r9 (void)
1897
{
1898
FX_CMP(9);
1899
}
1900
1901
static void fx_cmp_r10 (void)
1902
{
1903
FX_CMP(10);
1904
}
1905
1906
static void fx_cmp_r11 (void)
1907
{
1908
FX_CMP(11);
1909
}
1910
1911
static void fx_cmp_r12 (void)
1912
{
1913
FX_CMP(12);
1914
}
1915
1916
static void fx_cmp_r13 (void)
1917
{
1918
FX_CMP(13);
1919
}
1920
1921
static void fx_cmp_r14 (void)
1922
{
1923
FX_CMP(14);
1924
}
1925
1926
static void fx_cmp_r15 (void)
1927
{
1928
FX_CMP(15);
1929
}
1930
1931
// 70 - merge - R7 as upper byte, R8 as lower byte (used for texture-mapping)
1932
static void fx_merge (void)
1933
{
1934
uint32 v = (R7 & 0xff00) | ((R8 & 0xff00) >> 8);
1935
R15++;
1936
DREG = v;
1937
GSU.vOverflow = (v & 0xc0c0) << 16;
1938
GSU.vZero = !(v & 0xf0f0);
1939
GSU.vSign = ((v | (v << 8)) & 0x8000);
1940
GSU.vCarry = (v & 0xe0e0) != 0;
1941
TESTR14;
1942
CLRFLAGS;
1943
}
1944
1945
// 71-7f - and rn - reister & register
1946
#define FX_AND(reg) \
1947
uint32 v = SREG & GSU.avReg[reg]; \
1948
R15++; \
1949
DREG = v; \
1950
GSU.vSign = v; \
1951
GSU.vZero = v; \
1952
TESTR14; \
1953
CLRFLAGS
1954
1955
static void fx_and_r1 (void)
1956
{
1957
FX_AND(1);
1958
}
1959
1960
static void fx_and_r2 (void)
1961
{
1962
FX_AND(2);
1963
}
1964
1965
static void fx_and_r3 (void)
1966
{
1967
FX_AND(3);
1968
}
1969
1970
static void fx_and_r4 (void)
1971
{
1972
FX_AND(4);
1973
}
1974
1975
static void fx_and_r5 (void)
1976
{
1977
FX_AND(5);
1978
}
1979
1980
static void fx_and_r6 (void)
1981
{
1982
FX_AND(6);
1983
}
1984
1985
static void fx_and_r7 (void)
1986
{
1987
FX_AND(7);
1988
}
1989
1990
static void fx_and_r8 (void)
1991
{
1992
FX_AND(8);
1993
}
1994
1995
static void fx_and_r9 (void)
1996
{
1997
FX_AND(9);
1998
}
1999
2000
static void fx_and_r10 (void)
2001
{
2002
FX_AND(10);
2003
}
2004
2005
static void fx_and_r11 (void)
2006
{
2007
FX_AND(11);
2008
}
2009
2010
static void fx_and_r12 (void)
2011
{
2012
FX_AND(12);
2013
}
2014
2015
static void fx_and_r13 (void)
2016
{
2017
FX_AND(13);
2018
}
2019
2020
static void fx_and_r14 (void)
2021
{
2022
FX_AND(14);
2023
}
2024
2025
static void fx_and_r15 (void)
2026
{
2027
FX_AND(15);
2028
}
2029
2030
// 71-7f (ALT1) - bic rn - reister & ~register
2031
#define FX_BIC(reg) \
2032
uint32 v = SREG & ~GSU.avReg[reg]; \
2033
R15++; \
2034
DREG = v; \
2035
GSU.vSign = v; \
2036
GSU.vZero = v; \
2037
TESTR14; \
2038
CLRFLAGS
2039
2040
static void fx_bic_r1 (void)
2041
{
2042
FX_BIC(1);
2043
}
2044
2045
static void fx_bic_r2 (void)
2046
{
2047
FX_BIC(2);
2048
}
2049
2050
static void fx_bic_r3 (void)
2051
{
2052
FX_BIC(3);
2053
}
2054
2055
static void fx_bic_r4 (void)
2056
{
2057
FX_BIC(4);
2058
}
2059
2060
static void fx_bic_r5 (void)
2061
{
2062
FX_BIC(5);
2063
}
2064
2065
static void fx_bic_r6 (void)
2066
{
2067
FX_BIC(6);
2068
}
2069
2070
static void fx_bic_r7 (void)
2071
{
2072
FX_BIC(7);
2073
}
2074
2075
static void fx_bic_r8 (void)
2076
{
2077
FX_BIC(8);
2078
}
2079
2080
static void fx_bic_r9 (void)
2081
{
2082
FX_BIC(9);
2083
}
2084
2085
static void fx_bic_r10 (void)
2086
{
2087
FX_BIC(10);
2088
}
2089
2090
static void fx_bic_r11 (void)
2091
{
2092
FX_BIC(11);
2093
}
2094
2095
static void fx_bic_r12 (void)
2096
{
2097
FX_BIC(12);
2098
}
2099
2100
static void fx_bic_r13 (void)
2101
{
2102
FX_BIC(13);
2103
}
2104
2105
static void fx_bic_r14 (void)
2106
{
2107
FX_BIC(14);
2108
}
2109
2110
static void fx_bic_r15 (void)
2111
{
2112
FX_BIC(15);
2113
}
2114
2115
// 71-7f (ALT2) - and #n - reister & immediate
2116
#define FX_AND_I(imm) \
2117
uint32 v = SREG & imm; \
2118
R15++; \
2119
DREG = v; \
2120
GSU.vSign = v; \
2121
GSU.vZero = v; \
2122
TESTR14; \
2123
CLRFLAGS
2124
2125
static void fx_and_i1 (void)
2126
{
2127
FX_AND_I(1);
2128
}
2129
2130
static void fx_and_i2 (void)
2131
{
2132
FX_AND_I(2);
2133
}
2134
2135
static void fx_and_i3 (void)
2136
{
2137
FX_AND_I(3);
2138
}
2139
2140
static void fx_and_i4 (void)
2141
{
2142
FX_AND_I(4);
2143
}
2144
2145
static void fx_and_i5 (void)
2146
{
2147
FX_AND_I(5);
2148
}
2149
2150
static void fx_and_i6 (void)
2151
{
2152
FX_AND_I(6);
2153
}
2154
2155
static void fx_and_i7 (void)
2156
{
2157
FX_AND_I(7);
2158
}
2159
2160
static void fx_and_i8 (void)
2161
{
2162
FX_AND_I(8);
2163
}
2164
2165
static void fx_and_i9 (void)
2166
{
2167
FX_AND_I(9);
2168
}
2169
2170
static void fx_and_i10 (void)
2171
{
2172
FX_AND_I(10);
2173
}
2174
2175
static void fx_and_i11 (void)
2176
{
2177
FX_AND_I(11);
2178
}
2179
2180
static void fx_and_i12 (void)
2181
{
2182
FX_AND_I(12);
2183
}
2184
2185
static void fx_and_i13 (void)
2186
{
2187
FX_AND_I(13);
2188
}
2189
2190
static void fx_and_i14 (void)
2191
{
2192
FX_AND_I(14);
2193
}
2194
2195
static void fx_and_i15 (void)
2196
{
2197
FX_AND_I(15);
2198
}
2199
2200
// 71-7f (ALT3) - bic #n - reister & ~immediate
2201
#define FX_BIC_I(imm) \
2202
uint32 v = SREG & ~imm; \
2203
R15++; \
2204
DREG = v; \
2205
GSU.vSign = v; \
2206
GSU.vZero = v; \
2207
TESTR14; \
2208
CLRFLAGS
2209
2210
static void fx_bic_i1 (void)
2211
{
2212
FX_BIC_I(1);
2213
}
2214
2215
static void fx_bic_i2 (void)
2216
{
2217
FX_BIC_I(2);
2218
}
2219
2220
static void fx_bic_i3 (void)
2221
{
2222
FX_BIC_I(3);
2223
}
2224
2225
static void fx_bic_i4 (void)
2226
{
2227
FX_BIC_I(4);
2228
}
2229
2230
static void fx_bic_i5 (void)
2231
{
2232
FX_BIC_I(5);
2233
}
2234
2235
static void fx_bic_i6 (void)
2236
{
2237
FX_BIC_I(6);
2238
}
2239
2240
static void fx_bic_i7 (void)
2241
{
2242
FX_BIC_I(7);
2243
}
2244
2245
static void fx_bic_i8 (void)
2246
{
2247
FX_BIC_I(8);
2248
}
2249
2250
static void fx_bic_i9 (void)
2251
{
2252
FX_BIC_I(9);
2253
}
2254
2255
static void fx_bic_i10 (void)
2256
{
2257
FX_BIC_I(10);
2258
}
2259
2260
static void fx_bic_i11 (void)
2261
{
2262
FX_BIC_I(11);
2263
}
2264
2265
static void fx_bic_i12 (void)
2266
{
2267
FX_BIC_I(12);
2268
}
2269
2270
static void fx_bic_i13 (void)
2271
{
2272
FX_BIC_I(13);
2273
}
2274
2275
static void fx_bic_i14 (void)
2276
{
2277
FX_BIC_I(14);
2278
}
2279
2280
static void fx_bic_i15 (void)
2281
{
2282
FX_BIC_I(15);
2283
}
2284
2285
// 80-8f - mult rn - 8 bit to 16 bit signed multiply, register * register
2286
#define FX_MULT(reg) \
2287
uint32 v = (uint32) (SEX8(SREG) * SEX8(GSU.avReg[reg])); \
2288
R15++; \
2289
DREG = v; \
2290
GSU.vSign = v; \
2291
GSU.vZero = v; \
2292
TESTR14; \
2293
CLRFLAGS
2294
2295
static void fx_mult_r0 (void)
2296
{
2297
FX_MULT(0);
2298
}
2299
2300
static void fx_mult_r1 (void)
2301
{
2302
FX_MULT(1);
2303
}
2304
2305
static void fx_mult_r2 (void)
2306
{
2307
FX_MULT(2);
2308
}
2309
2310
static void fx_mult_r3 (void)
2311
{
2312
FX_MULT(3);
2313
}
2314
2315
static void fx_mult_r4 (void)
2316
{
2317
FX_MULT(4);
2318
}
2319
2320
static void fx_mult_r5 (void)
2321
{
2322
FX_MULT(5);
2323
}
2324
2325
static void fx_mult_r6 (void)
2326
{
2327
FX_MULT(6);
2328
}
2329
2330
static void fx_mult_r7 (void)
2331
{
2332
FX_MULT(7);
2333
}
2334
2335
static void fx_mult_r8 (void)
2336
{
2337
FX_MULT(8);
2338
}
2339
2340
static void fx_mult_r9 (void)
2341
{
2342
FX_MULT(9);
2343
}
2344
2345
static void fx_mult_r10 (void)
2346
{
2347
FX_MULT(10);
2348
}
2349
2350
static void fx_mult_r11 (void)
2351
{
2352
FX_MULT(11);
2353
}
2354
2355
static void fx_mult_r12 (void)
2356
{
2357
FX_MULT(12);
2358
}
2359
2360
static void fx_mult_r13 (void)
2361
{
2362
FX_MULT(13);
2363
}
2364
2365
static void fx_mult_r14 (void)
2366
{
2367
FX_MULT(14);
2368
}
2369
2370
static void fx_mult_r15 (void)
2371
{
2372
FX_MULT(15);
2373
}
2374
2375
// 80-8f (ALT1) - umult rn - 8 bit to 16 bit unsigned multiply, register * register
2376
#define FX_UMULT(reg) \
2377
uint32 v = USEX8(SREG) * USEX8(GSU.avReg[reg]); \
2378
R15++; \
2379
DREG = v; \
2380
GSU.vSign = v; \
2381
GSU.vZero = v; \
2382
TESTR14; \
2383
CLRFLAGS
2384
2385
static void fx_umult_r0 (void)
2386
{
2387
FX_UMULT(0);
2388
}
2389
2390
static void fx_umult_r1 (void)
2391
{
2392
FX_UMULT(1);
2393
}
2394
2395
static void fx_umult_r2 (void)
2396
{
2397
FX_UMULT(2);
2398
}
2399
2400
static void fx_umult_r3 (void)
2401
{
2402
FX_UMULT(3);
2403
}
2404
2405
static void fx_umult_r4 (void)
2406
{
2407
FX_UMULT(4);
2408
}
2409
2410
static void fx_umult_r5 (void)
2411
{
2412
FX_UMULT(5);
2413
}
2414
2415
static void fx_umult_r6 (void)
2416
{
2417
FX_UMULT(6);
2418
}
2419
2420
static void fx_umult_r7 (void)
2421
{
2422
FX_UMULT(7);
2423
}
2424
2425
static void fx_umult_r8 (void)
2426
{
2427
FX_UMULT(8);
2428
}
2429
2430
static void fx_umult_r9 (void)
2431
{
2432
FX_UMULT(9);
2433
}
2434
2435
static void fx_umult_r10 (void)
2436
{
2437
FX_UMULT(10);
2438
}
2439
2440
static void fx_umult_r11 (void)
2441
{
2442
FX_UMULT(11);
2443
}
2444
2445
static void fx_umult_r12 (void)
2446
{
2447
FX_UMULT(12);
2448
}
2449
2450
static void fx_umult_r13 (void)
2451
{
2452
FX_UMULT(13);
2453
}
2454
2455
static void fx_umult_r14 (void)
2456
{
2457
FX_UMULT(14);
2458
}
2459
2460
static void fx_umult_r15 (void)
2461
{
2462
FX_UMULT(15);
2463
}
2464
2465
// 80-8f (ALT2) - mult #n - 8 bit to 16 bit signed multiply, register * immediate
2466
#define FX_MULT_I(imm) \
2467
uint32 v = (uint32) (SEX8(SREG) * ((int32) imm)); \
2468
R15++; \
2469
DREG = v; \
2470
GSU.vSign = v; \
2471
GSU.vZero = v; \
2472
TESTR14; \
2473
CLRFLAGS
2474
2475
static void fx_mult_i0 (void)
2476
{
2477
FX_MULT_I(0);
2478
}
2479
2480
static void fx_mult_i1 (void)
2481
{
2482
FX_MULT_I(1);
2483
}
2484
2485
static void fx_mult_i2 (void)
2486
{
2487
FX_MULT_I(2);
2488
}
2489
2490
static void fx_mult_i3 (void)
2491
{
2492
FX_MULT_I(3);
2493
}
2494
2495
static void fx_mult_i4 (void)
2496
{
2497
FX_MULT_I(4);
2498
}
2499
2500
static void fx_mult_i5 (void)
2501
{
2502
FX_MULT_I(5);
2503
}
2504
2505
static void fx_mult_i6 (void)
2506
{
2507
FX_MULT_I(6);
2508
}
2509
2510
static void fx_mult_i7 (void)
2511
{
2512
FX_MULT_I(7);
2513
}
2514
2515
static void fx_mult_i8 (void)
2516
{
2517
FX_MULT_I(8);
2518
}
2519
2520
static void fx_mult_i9 (void)
2521
{
2522
FX_MULT_I(9);
2523
}
2524
2525
static void fx_mult_i10 (void)
2526
{
2527
FX_MULT_I(10);
2528
}
2529
2530
static void fx_mult_i11 (void)
2531
{
2532
FX_MULT_I(11);
2533
}
2534
2535
static void fx_mult_i12 (void)
2536
{
2537
FX_MULT_I(12);
2538
}
2539
2540
static void fx_mult_i13 (void)
2541
{
2542
FX_MULT_I(13);
2543
}
2544
2545
static void fx_mult_i14 (void)
2546
{
2547
FX_MULT_I(14);
2548
}
2549
2550
static void fx_mult_i15 (void)
2551
{
2552
FX_MULT_I(15);
2553
}
2554
2555
// 80-8f (ALT3) - umult #n - 8 bit to 16 bit unsigned multiply, register * immediate
2556
#define FX_UMULT_I(imm) \
2557
uint32 v = USEX8(SREG) * ((uint32) imm); \
2558
R15++; \
2559
DREG = v; \
2560
GSU.vSign = v; \
2561
GSU.vZero = v; \
2562
TESTR14; \
2563
CLRFLAGS
2564
2565
static void fx_umult_i0 (void)
2566
{
2567
FX_UMULT_I(0);
2568
}
2569
2570
static void fx_umult_i1 (void)
2571
{
2572
FX_UMULT_I(1);
2573
}
2574
2575
static void fx_umult_i2 (void)
2576
{
2577
FX_UMULT_I(2);
2578
}
2579
2580
static void fx_umult_i3 (void)
2581
{
2582
FX_UMULT_I(3);
2583
}
2584
2585
static void fx_umult_i4 (void)
2586
{
2587
FX_UMULT_I(4);
2588
}
2589
2590
static void fx_umult_i5 (void)
2591
{
2592
FX_UMULT_I(5);
2593
}
2594
2595
static void fx_umult_i6 (void)
2596
{
2597
FX_UMULT_I(6);
2598
}
2599
2600
static void fx_umult_i7 (void)
2601
{
2602
FX_UMULT_I(7);
2603
}
2604
2605
static void fx_umult_i8 (void)
2606
{
2607
FX_UMULT_I(8);
2608
}
2609
2610
static void fx_umult_i9 (void)
2611
{
2612
FX_UMULT_I(9);
2613
}
2614
2615
static void fx_umult_i10 (void)
2616
{
2617
FX_UMULT_I(10);
2618
}
2619
2620
static void fx_umult_i11 (void)
2621
{
2622
FX_UMULT_I(11);
2623
}
2624
2625
static void fx_umult_i12 (void)
2626
{
2627
FX_UMULT_I(12);
2628
}
2629
2630
static void fx_umult_i13 (void)
2631
{
2632
FX_UMULT_I(13);
2633
}
2634
2635
static void fx_umult_i14 (void)
2636
{
2637
FX_UMULT_I(14);
2638
}
2639
2640
static void fx_umult_i15 (void)
2641
{
2642
FX_UMULT_I(15);
2643
}
2644
2645
// 90 - sbk - store word to last accessed RAM address
2646
static void fx_sbk (void)
2647
{
2648
RAM(GSU.vLastRamAdr) = (uint8) SREG;
2649
RAM(GSU.vLastRamAdr ^ 1) = (uint8) (SREG >> 8);
2650
CLRFLAGS;
2651
R15++;
2652
}
2653
2654
// 91-94 - link #n - R11 = R15 + immediate
2655
#define FX_LINK_I(lkn) \
2656
R11 = R15 + lkn; \
2657
CLRFLAGS; \
2658
R15++
2659
2660
static void fx_link_i1 (void)
2661
{
2662
FX_LINK_I(1);
2663
}
2664
2665
static void fx_link_i2 (void)
2666
{
2667
FX_LINK_I(2);
2668
}
2669
2670
static void fx_link_i3 (void)
2671
{
2672
FX_LINK_I(3);
2673
}
2674
2675
static void fx_link_i4 (void)
2676
{
2677
FX_LINK_I(4);
2678
}
2679
2680
// 95 - sex - sign extend 8 bit to 16 bit
2681
static void fx_sex (void)
2682
{
2683
uint32 v = (uint32) SEX8(SREG);
2684
R15++;
2685
DREG = v;
2686
GSU.vSign = v;
2687
GSU.vZero = v;
2688
TESTR14;
2689
CLRFLAGS;
2690
}
2691
2692
// 96 - asr - aritmetric shift right by one
2693
static void fx_asr (void)
2694
{
2695
uint32 v;
2696
GSU.vCarry = SREG & 1;
2697
v = (uint32) (SEX16(SREG) >> 1);
2698
R15++;
2699
DREG = v;
2700
GSU.vSign = v;
2701
GSU.vZero = v;
2702
TESTR14;
2703
CLRFLAGS;
2704
}
2705
2706
// 96 (ALT1) - div2 - aritmetric shift right by one
2707
static void fx_div2 (void)
2708
{
2709
uint32 v;
2710
int32 s = SEX16(SREG);
2711
GSU.vCarry = s & 1;
2712
if (s == -1)
2713
v = 0;
2714
else
2715
v = (uint32) (s >> 1);
2716
R15++;
2717
DREG = v;
2718
GSU.vSign = v;
2719
GSU.vZero = v;
2720
TESTR14;
2721
CLRFLAGS;
2722
}
2723
2724
// 97 - ror - rotate right by one
2725
static void fx_ror (void)
2726
{
2727
uint32 v = (USEX16(SREG) >> 1) | (GSU.vCarry << 15);
2728
GSU.vCarry = SREG & 1;
2729
R15++;
2730
DREG = v;
2731
GSU.vSign = v;
2732
GSU.vZero = v;
2733
TESTR14;
2734
CLRFLAGS;
2735
}
2736
2737
// 98-9d - jmp rn - jump to address of register
2738
#define FX_JMP(reg) \
2739
R15 = GSU.avReg[reg]; \
2740
CLRFLAGS
2741
2742
static void fx_jmp_r8 (void)
2743
{
2744
FX_JMP(8);
2745
}
2746
2747
static void fx_jmp_r9 (void)
2748
{
2749
FX_JMP(9);
2750
}
2751
2752
static void fx_jmp_r10 (void)
2753
{
2754
FX_JMP(10);
2755
}
2756
2757
static void fx_jmp_r11 (void)
2758
{
2759
FX_JMP(11);
2760
}
2761
2762
static void fx_jmp_r12 (void)
2763
{
2764
FX_JMP(12);
2765
}
2766
2767
static void fx_jmp_r13 (void)
2768
{
2769
FX_JMP(13);
2770
}
2771
2772
// 98-9d (ALT1) - ljmp rn - set program bank to source register and jump to address of register
2773
#define FX_LJMP(reg) \
2774
GSU.vPrgBankReg = GSU.avReg[reg] & 0x7f; \
2775
GSU.pvPrgBank = GSU.apvRomBank[GSU.vPrgBankReg]; \
2776
R15 = SREG; \
2777
GSU.bCacheActive = FALSE; \
2778
fx_cache(); \
2779
R15--
2780
2781
static void fx_ljmp_r8 (void)
2782
{
2783
FX_LJMP(8);
2784
}
2785
2786
static void fx_ljmp_r9 (void)
2787
{
2788
FX_LJMP(9);
2789
}
2790
2791
static void fx_ljmp_r10 (void)
2792
{
2793
FX_LJMP(10);
2794
}
2795
2796
static void fx_ljmp_r11 (void)
2797
{
2798
FX_LJMP(11);
2799
}
2800
2801
static void fx_ljmp_r12 (void)
2802
{
2803
FX_LJMP(12);
2804
}
2805
2806
static void fx_ljmp_r13 (void)
2807
{
2808
FX_LJMP(13);
2809
}
2810
2811
// 9e - lob - set upper byte to zero (keep low byte)
2812
static void fx_lob (void)
2813
{
2814
uint32 v = USEX8(SREG);
2815
R15++;
2816
DREG = v;
2817
GSU.vSign = v << 8;
2818
GSU.vZero = v << 8;
2819
TESTR14;
2820
CLRFLAGS;
2821
}
2822
2823
// 9f - fmult - 16 bit to 32 bit signed multiplication, upper 16 bits only
2824
static void fx_fmult (void)
2825
{
2826
uint32 v;
2827
uint32 c = (uint32) (SEX16(SREG) * SEX16(R6));
2828
v = c >> 16;
2829
R15++;
2830
DREG = v;
2831
GSU.vSign = v;
2832
GSU.vZero = v;
2833
GSU.vCarry = (c >> 15) & 1;
2834
TESTR14;
2835
CLRFLAGS;
2836
}
2837
2838
// 9f (ALT1) - lmult - 16 bit to 32 bit signed multiplication
2839
static void fx_lmult (void)
2840
{
2841
uint32 v;
2842
uint32 c = (uint32) (SEX16(SREG) * SEX16(R6));
2843
R4 = c;
2844
v = c >> 16;
2845
R15++;
2846
DREG = v;
2847
GSU.vSign = v;
2848
GSU.vZero = v;
2849
// XXX: R6 or R4?
2850
GSU.vCarry = (R4 >> 15) & 1; // should it be bit 15 of R4 instead ?
2851
TESTR14;
2852
CLRFLAGS;
2853
}
2854
2855
// a0-af - ibt rn, #pp - immediate byte transfer
2856
#define FX_IBT(reg) \
2857
uint8 v = PIPE; \
2858
R15++; \
2859
FETCHPIPE; \
2860
R15++; \
2861
GSU.avReg[reg] = SEX8(v); \
2862
CLRFLAGS
2863
2864
static void fx_ibt_r0 (void)
2865
{
2866
FX_IBT(0);
2867
}
2868
2869
static void fx_ibt_r1 (void)
2870
{
2871
FX_IBT(1);
2872
}
2873
2874
static void fx_ibt_r2 (void)
2875
{
2876
FX_IBT(2);
2877
}
2878
2879
static void fx_ibt_r3 (void)
2880
{
2881
FX_IBT(3);
2882
}
2883
2884
static void fx_ibt_r4 (void)
2885
{
2886
FX_IBT(4);
2887
}
2888
2889
static void fx_ibt_r5 (void)
2890
{
2891
FX_IBT(5);
2892
}
2893
2894
static void fx_ibt_r6 (void)
2895
{
2896
FX_IBT(6);
2897
}
2898
2899
static void fx_ibt_r7 (void)
2900
{
2901
FX_IBT(7);
2902
}
2903
2904
static void fx_ibt_r8 (void)
2905
{
2906
FX_IBT(8);
2907
}
2908
2909
static void fx_ibt_r9 (void)
2910
{
2911
FX_IBT(9);
2912
}
2913
2914
static void fx_ibt_r10 (void)
2915
{
2916
FX_IBT(10);
2917
}
2918
2919
static void fx_ibt_r11 (void)
2920
{
2921
FX_IBT(11);
2922
}
2923
2924
static void fx_ibt_r12 (void)
2925
{
2926
FX_IBT(12);
2927
}
2928
2929
static void fx_ibt_r13 (void)
2930
{
2931
FX_IBT(13);
2932
}
2933
2934
static void fx_ibt_r14 (void)
2935
{
2936
FX_IBT(14);
2937
READR14;
2938
}
2939
2940
static void fx_ibt_r15 (void)
2941
{
2942
FX_IBT(15);
2943
}
2944
2945
// a0-af (ALT1) - lms rn, (yy) - load word from RAM (short address)
2946
#define FX_LMS(reg) \
2947
GSU.vLastRamAdr = ((uint32) PIPE) << 1; \
2948
R15++; \
2949
FETCHPIPE; \
2950
R15++; \
2951
GSU.avReg[reg] = (uint32) RAM(GSU.vLastRamAdr); \
2952
GSU.avReg[reg] |= ((uint32) RAM(GSU.vLastRamAdr + 1)) << 8; \
2953
CLRFLAGS
2954
2955
static void fx_lms_r0 (void)
2956
{
2957
FX_LMS(0);
2958
}
2959
2960
static void fx_lms_r1 (void)
2961
{
2962
FX_LMS(1);
2963
}
2964
2965
static void fx_lms_r2 (void)
2966
{
2967
FX_LMS(2);
2968
}
2969
2970
static void fx_lms_r3 (void)
2971
{
2972
FX_LMS(3);
2973
}
2974
2975
static void fx_lms_r4 (void)
2976
{
2977
FX_LMS(4);
2978
}
2979
2980
static void fx_lms_r5 (void)
2981
{
2982
FX_LMS(5);
2983
}
2984
2985
static void fx_lms_r6 (void)
2986
{
2987
FX_LMS(6);
2988
}
2989
2990
static void fx_lms_r7 (void)
2991
{
2992
FX_LMS(7);
2993
}
2994
2995
static void fx_lms_r8 (void)
2996
{
2997
FX_LMS(8);
2998
}
2999
3000
static void fx_lms_r9 (void)
3001
{
3002
FX_LMS(9);
3003
}
3004
3005
static void fx_lms_r10 (void)
3006
{
3007
FX_LMS(10);
3008
}
3009
3010
static void fx_lms_r11 (void)
3011
{
3012
FX_LMS(11);
3013
}
3014
3015
static void fx_lms_r12 (void)
3016
{
3017
FX_LMS(12);
3018
}
3019
3020
static void fx_lms_r13 (void)
3021
{
3022
FX_LMS(13);
3023
}
3024
3025
static void fx_lms_r14 (void)
3026
{
3027
FX_LMS(14);
3028
READR14;
3029
}
3030
3031
static void fx_lms_r15 (void)
3032
{
3033
FX_LMS(15);
3034
}
3035
3036
// a0-af (ALT2) - sms (yy), rn - store word in RAM (short address)
3037
// XXX: If rn == r15, is the value of r15 before or after the extra byte is read ?
3038
#define FX_SMS(reg) \
3039
uint32 v = GSU.avReg[reg]; \
3040
GSU.vLastRamAdr = ((uint32) PIPE) << 1; \
3041
R15++; \
3042
FETCHPIPE; \
3043
RAM(GSU.vLastRamAdr) = (uint8) v; \
3044
RAM(GSU.vLastRamAdr + 1) = (uint8) (v >> 8); \
3045
CLRFLAGS; \
3046
R15++
3047
3048
static void fx_sms_r0 (void)
3049
{
3050
FX_SMS(0);
3051
}
3052
3053
static void fx_sms_r1 (void)
3054
{
3055
FX_SMS(1);
3056
}
3057
3058
static void fx_sms_r2 (void)
3059
{
3060
FX_SMS(2);
3061
}
3062
3063
static void fx_sms_r3 (void)
3064
{
3065
FX_SMS(3);
3066
}
3067
3068
static void fx_sms_r4 (void)
3069
{
3070
FX_SMS(4);
3071
}
3072
3073
static void fx_sms_r5 (void)
3074
{
3075
FX_SMS(5);
3076
}
3077
3078
static void fx_sms_r6 (void)
3079
{
3080
FX_SMS(6);
3081
}
3082
3083
static void fx_sms_r7 (void)
3084
{
3085
FX_SMS(7);
3086
}
3087
3088
static void fx_sms_r8 (void)
3089
{
3090
FX_SMS(8);
3091
}
3092
3093
static void fx_sms_r9 (void)
3094
{
3095
FX_SMS(9);
3096
}
3097
3098
static void fx_sms_r10 (void)
3099
{
3100
FX_SMS(10);
3101
}
3102
3103
static void fx_sms_r11 (void)
3104
{
3105
FX_SMS(11);
3106
}
3107
3108
static void fx_sms_r12 (void)
3109
{
3110
FX_SMS(12);
3111
}
3112
3113
static void fx_sms_r13 (void)
3114
{
3115
FX_SMS(13);
3116
}
3117
3118
static void fx_sms_r14 (void)
3119
{
3120
FX_SMS(14);
3121
}
3122
3123
static void fx_sms_r15 (void)
3124
{
3125
FX_SMS(15);
3126
}
3127
3128
// b0-bf - from rn - set source register
3129
// b0-bf (B) - moves rn - move register to register, and set flags, (if B flag is set)
3130
#define FX_FROM(reg) \
3131
if (TF(B)) \
3132
{ \
3133
uint32 v = GSU.avReg[reg]; \
3134
R15++; \
3135
DREG = v; \
3136
GSU.vOverflow = (v & 0x80) << 16; \
3137
GSU.vSign = v; \
3138
GSU.vZero = v; \
3139
TESTR14; \
3140
CLRFLAGS; \
3141
} \
3142
else \
3143
{ \
3144
GSU.pvSreg = &GSU.avReg[reg]; \
3145
R15++; \
3146
}
3147
3148
static void fx_from_r0 (void)
3149
{
3150
FX_FROM(0);
3151
}
3152
3153
static void fx_from_r1 (void)
3154
{
3155
FX_FROM(1);
3156
}
3157
3158
static void fx_from_r2 (void)
3159
{
3160
FX_FROM(2);
3161
}
3162
3163
static void fx_from_r3 (void)
3164
{
3165
FX_FROM(3);
3166
}
3167
3168
static void fx_from_r4 (void)
3169
{
3170
FX_FROM(4);
3171
}
3172
3173
static void fx_from_r5 (void)
3174
{
3175
FX_FROM(5);
3176
}
3177
3178
static void fx_from_r6 (void)
3179
{
3180
FX_FROM(6);
3181
}
3182
3183
static void fx_from_r7 (void)
3184
{
3185
FX_FROM(7);
3186
}
3187
3188
static void fx_from_r8 (void)
3189
{
3190
FX_FROM(8);
3191
}
3192
3193
static void fx_from_r9 (void)
3194
{
3195
FX_FROM(9);
3196
}
3197
3198
static void fx_from_r10 (void)
3199
{
3200
FX_FROM(10);
3201
}
3202
3203
static void fx_from_r11 (void)
3204
{
3205
FX_FROM(11);
3206
}
3207
3208
static void fx_from_r12 (void)
3209
{
3210
FX_FROM(12);
3211
}
3212
3213
static void fx_from_r13 (void)
3214
{
3215
FX_FROM(13);
3216
}
3217
3218
static void fx_from_r14 (void)
3219
{
3220
FX_FROM(14);
3221
}
3222
3223
static void fx_from_r15 (void)
3224
{
3225
FX_FROM(15);
3226
}
3227
3228
// c0 - hib - move high-byte to low-byte
3229
static void fx_hib (void)
3230
{
3231
uint32 v = USEX8(SREG >> 8);
3232
R15++;
3233
DREG = v;
3234
GSU.vSign = v << 8;
3235
GSU.vZero = v << 8;
3236
TESTR14;
3237
CLRFLAGS;
3238
}
3239
3240
// c1-cf - or rn
3241
#define FX_OR(reg) \
3242
uint32 v = SREG | GSU.avReg[reg]; \
3243
R15++; \
3244
DREG = v; \
3245
GSU.vSign = v; \
3246
GSU.vZero = v; \
3247
TESTR14; \
3248
CLRFLAGS
3249
3250
static void fx_or_r1 (void)
3251
{
3252
FX_OR(1);
3253
}
3254
3255
static void fx_or_r2 (void)
3256
{
3257
FX_OR(2);
3258
}
3259
3260
static void fx_or_r3 (void)
3261
{
3262
FX_OR(3);
3263
}
3264
3265
static void fx_or_r4 (void)
3266
{
3267
FX_OR(4);
3268
}
3269
3270
static void fx_or_r5 (void)
3271
{
3272
FX_OR(5);
3273
}
3274
3275
static void fx_or_r6 (void)
3276
{
3277
FX_OR(6);
3278
}
3279
3280
static void fx_or_r7 (void)
3281
{
3282
FX_OR(7);
3283
}
3284
3285
static void fx_or_r8 (void)
3286
{
3287
FX_OR(8);
3288
}
3289
3290
static void fx_or_r9 (void)
3291
{
3292
FX_OR(9);
3293
}
3294
3295
static void fx_or_r10 (void)
3296
{
3297
FX_OR(10);
3298
}
3299
3300
static void fx_or_r11 (void)
3301
{
3302
FX_OR(11);
3303
}
3304
3305
static void fx_or_r12 (void)
3306
{
3307
FX_OR(12);
3308
}
3309
3310
static void fx_or_r13 (void)
3311
{
3312
FX_OR(13);
3313
}
3314
3315
static void fx_or_r14 (void)
3316
{
3317
FX_OR(14);
3318
}
3319
3320
static void fx_or_r15 (void)
3321
{
3322
FX_OR(15);
3323
}
3324
3325
// c1-cf (ALT1) - xor rn
3326
#define FX_XOR(reg) \
3327
uint32 v = SREG ^ GSU.avReg[reg]; \
3328
R15++; \
3329
DREG = v; \
3330
GSU.vSign = v; \
3331
GSU.vZero = v; \
3332
TESTR14; \
3333
CLRFLAGS
3334
3335
static void fx_xor_r1 (void)
3336
{
3337
FX_XOR(1);
3338
}
3339
3340
static void fx_xor_r2 (void)
3341
{
3342
FX_XOR(2);
3343
}
3344
3345
static void fx_xor_r3 (void)
3346
{
3347
FX_XOR(3);
3348
}
3349
3350
static void fx_xor_r4 (void)
3351
{
3352
FX_XOR(4);
3353
}
3354
3355
static void fx_xor_r5 (void)
3356
{
3357
FX_XOR(5);
3358
}
3359
3360
static void fx_xor_r6 (void)
3361
{
3362
FX_XOR(6);
3363
}
3364
3365
static void fx_xor_r7 (void)
3366
{
3367
FX_XOR(7);
3368
}
3369
3370
static void fx_xor_r8 (void)
3371
{
3372
FX_XOR(8);
3373
}
3374
3375
static void fx_xor_r9 (void)
3376
{
3377
FX_XOR(9);
3378
}
3379
3380
static void fx_xor_r10 (void)
3381
{
3382
FX_XOR(10);
3383
}
3384
3385
static void fx_xor_r11 (void)
3386
{
3387
FX_XOR(11);
3388
}
3389
3390
static void fx_xor_r12 (void)
3391
{
3392
FX_XOR(12);
3393
}
3394
3395
static void fx_xor_r13 (void)
3396
{
3397
FX_XOR(13);
3398
}
3399
3400
static void fx_xor_r14 (void)
3401
{
3402
FX_XOR(14);
3403
}
3404
3405
static void fx_xor_r15 (void)
3406
{
3407
FX_XOR(15);
3408
}
3409
3410
// c1-cf (ALT2) - or #n
3411
#define FX_OR_I(imm) \
3412
uint32 v = SREG | imm; \
3413
R15++; \
3414
DREG = v; \
3415
GSU.vSign = v; \
3416
GSU.vZero = v; \
3417
TESTR14; \
3418
CLRFLAGS
3419
3420
static void fx_or_i1 (void)
3421
{
3422
FX_OR_I(1);
3423
}
3424
3425
static void fx_or_i2 (void)
3426
{
3427
FX_OR_I(2);
3428
}
3429
3430
static void fx_or_i3 (void)
3431
{
3432
FX_OR_I(3);
3433
}
3434
3435
static void fx_or_i4 (void)
3436
{
3437
FX_OR_I(4);
3438
}
3439
3440
static void fx_or_i5 (void)
3441
{
3442
FX_OR_I(5);
3443
}
3444
3445
static void fx_or_i6 (void)
3446
{
3447
FX_OR_I(6);
3448
}
3449
3450
static void fx_or_i7 (void)
3451
{
3452
FX_OR_I(7);
3453
}
3454
3455
static void fx_or_i8 (void)
3456
{
3457
FX_OR_I(8);
3458
}
3459
3460
static void fx_or_i9 (void)
3461
{
3462
FX_OR_I(9);
3463
}
3464
3465
static void fx_or_i10 (void)
3466
{
3467
FX_OR_I(10);
3468
}
3469
3470
static void fx_or_i11 (void)
3471
{
3472
FX_OR_I(11);
3473
}
3474
3475
static void fx_or_i12 (void)
3476
{
3477
FX_OR_I(12);
3478
}
3479
3480
static void fx_or_i13 (void)
3481
{
3482
FX_OR_I(13);
3483
}
3484
3485
static void fx_or_i14 (void)
3486
{
3487
FX_OR_I(14);
3488
}
3489
3490
static void fx_or_i15 (void)
3491
{
3492
FX_OR_I(15);
3493
}
3494
3495
// c1-cf (ALT3) - xor #n
3496
#define FX_XOR_I(imm) \
3497
uint32 v = SREG ^ imm; \
3498
R15++; \
3499
DREG = v; \
3500
GSU.vSign = v; \
3501
GSU.vZero = v; \
3502
TESTR14; \
3503
CLRFLAGS
3504
3505
static void fx_xor_i1 (void)
3506
{
3507
FX_XOR_I(1);
3508
}
3509
3510
static void fx_xor_i2 (void)
3511
{
3512
FX_XOR_I(2);
3513
}
3514
3515
static void fx_xor_i3 (void)
3516
{
3517
FX_XOR_I(3);
3518
}
3519
3520
static void fx_xor_i4 (void)
3521
{
3522
FX_XOR_I(4);
3523
}
3524
3525
static void fx_xor_i5 (void)
3526
{
3527
FX_XOR_I(5);
3528
}
3529
3530
static void fx_xor_i6 (void)
3531
{
3532
FX_XOR_I(6);
3533
}
3534
3535
static void fx_xor_i7 (void)
3536
{
3537
FX_XOR_I(7);
3538
}
3539
3540
static void fx_xor_i8 (void)
3541
{
3542
FX_XOR_I(8);
3543
}
3544
3545
static void fx_xor_i9 (void)
3546
{
3547
FX_XOR_I(9);
3548
}
3549
3550
static void fx_xor_i10 (void)
3551
{
3552
FX_XOR_I(10);
3553
}
3554
3555
static void fx_xor_i11 (void)
3556
{
3557
FX_XOR_I(11);
3558
}
3559
3560
static void fx_xor_i12 (void)
3561
{
3562
FX_XOR_I(12);
3563
}
3564
3565
static void fx_xor_i13 (void)
3566
{
3567
FX_XOR_I(13);
3568
}
3569
3570
static void fx_xor_i14 (void)
3571
{
3572
FX_XOR_I(14);
3573
}
3574
3575
static void fx_xor_i15 (void)
3576
{
3577
FX_XOR_I(15);
3578
}
3579
3580
// d0-de - inc rn - increase by one
3581
#define FX_INC(reg) \
3582
GSU.avReg[reg] += 1; \
3583
GSU.vSign = GSU.avReg[reg]; \
3584
GSU.vZero = GSU.avReg[reg]; \
3585
CLRFLAGS; \
3586
R15++
3587
3588
static void fx_inc_r0 (void)
3589
{
3590
FX_INC(0);
3591
}
3592
3593
static void fx_inc_r1 (void)
3594
{
3595
FX_INC(1);
3596
}
3597
3598
static void fx_inc_r2 (void)
3599
{
3600
FX_INC(2);
3601
}
3602
3603
static void fx_inc_r3 (void)
3604
{
3605
FX_INC(3);
3606
}
3607
3608
static void fx_inc_r4 (void)
3609
{
3610
FX_INC(4);
3611
}
3612
3613
static void fx_inc_r5 (void)
3614
{
3615
FX_INC(5);
3616
}
3617
3618
static void fx_inc_r6 (void)
3619
{
3620
FX_INC(6);
3621
}
3622
3623
static void fx_inc_r7 (void)
3624
{
3625
FX_INC(7);
3626
}
3627
3628
static void fx_inc_r8 (void)
3629
{
3630
FX_INC(8);
3631
}
3632
3633
static void fx_inc_r9 (void)
3634
{
3635
FX_INC(9);
3636
}
3637
3638
static void fx_inc_r10 (void)
3639
{
3640
FX_INC(10);
3641
}
3642
3643
static void fx_inc_r11 (void)
3644
{
3645
FX_INC(11);
3646
}
3647
3648
static void fx_inc_r12 (void)
3649
{
3650
FX_INC(12);
3651
}
3652
3653
static void fx_inc_r13 (void)
3654
{
3655
FX_INC(13);
3656
}
3657
3658
static void fx_inc_r14 (void)
3659
{
3660
FX_INC(14);
3661
READR14;
3662
}
3663
3664
// df - getc - transfer ROM buffer to color register
3665
static void fx_getc (void)
3666
{
3667
#ifndef FX_DO_ROMBUFFER
3668
uint8 c = ROM(R14);
3669
#else
3670
uint8 c = GSU.vRomBuffer;
3671
#endif
3672
3673
if (GSU.vPlotOptionReg & 0x04)
3674
c = (c & 0xf0) | (c >> 4);
3675
3676
if (GSU.vPlotOptionReg & 0x08)
3677
{
3678
GSU.vColorReg &= 0xf0;
3679
GSU.vColorReg |= c & 0x0f;
3680
}
3681
else
3682
GSU.vColorReg = USEX8(c);
3683
3684
CLRFLAGS;
3685
R15++;
3686
}
3687
3688
// df (ALT2) - ramb - set current RAM bank
3689
static void fx_ramb (void)
3690
{
3691
GSU.vRamBankReg = SREG & (FX_RAM_BANKS - 1);
3692
GSU.pvRamBank = GSU.apvRamBank[GSU.vRamBankReg & 0x3];
3693
CLRFLAGS;
3694
R15++;
3695
}
3696
3697
// df (ALT3) - romb - set current ROM bank
3698
static void fx_romb (void)
3699
{
3700
GSU.vRomBankReg = USEX8(SREG) & 0x7f;
3701
GSU.pvRomBank = GSU.apvRomBank[GSU.vRomBankReg];
3702
CLRFLAGS;
3703
R15++;
3704
}
3705
3706
// e0-ee - dec rn - decrement by one
3707
#define FX_DEC(reg) \
3708
GSU.avReg[reg] -= 1; \
3709
GSU.vSign = GSU.avReg[reg]; \
3710
GSU.vZero = GSU.avReg[reg]; \
3711
CLRFLAGS; \
3712
R15++
3713
3714
static void fx_dec_r0 (void)
3715
{
3716
FX_DEC(0);
3717
}
3718
3719
static void fx_dec_r1 (void)
3720
{
3721
FX_DEC(1);
3722
}
3723
3724
static void fx_dec_r2 (void)
3725
{
3726
FX_DEC(2);
3727
}
3728
3729
static void fx_dec_r3 (void)
3730
{
3731
FX_DEC(3);
3732
}
3733
3734
static void fx_dec_r4 (void)
3735
{
3736
FX_DEC(4);
3737
}
3738
3739
static void fx_dec_r5 (void)
3740
{
3741
FX_DEC(5);
3742
}
3743
3744
static void fx_dec_r6 (void)
3745
{
3746
FX_DEC(6);
3747
}
3748
3749
static void fx_dec_r7 (void)
3750
{
3751
FX_DEC(7);
3752
}
3753
3754
static void fx_dec_r8 (void)
3755
{
3756
FX_DEC(8);
3757
}
3758
3759
static void fx_dec_r9 (void)
3760
{
3761
FX_DEC(9);
3762
}
3763
3764
static void fx_dec_r10 (void)
3765
{
3766
FX_DEC(10);
3767
}
3768
3769
static void fx_dec_r11 (void)
3770
{
3771
FX_DEC(11);
3772
}
3773
3774
static void fx_dec_r12 (void)
3775
{
3776
FX_DEC(12);
3777
}
3778
3779
static void fx_dec_r13 (void)
3780
{
3781
FX_DEC(13);
3782
}
3783
3784
static void fx_dec_r14 (void)
3785
{
3786
FX_DEC(14);
3787
READR14;
3788
}
3789
3790
// ef - getb - get byte from ROM at address R14
3791
static void fx_getb (void)
3792
{
3793
uint32 v;
3794
#ifndef FX_DO_ROMBUFFER
3795
v = (uint32) ROM(R14);
3796
#else
3797
v = (uint32) GSU.vRomBuffer;
3798
#endif
3799
R15++;
3800
DREG = v;
3801
TESTR14;
3802
CLRFLAGS;
3803
}
3804
3805
// ef (ALT1) - getbh - get high-byte from ROM at address R14
3806
static void fx_getbh (void)
3807
{
3808
uint32 v;
3809
#ifndef FX_DO_ROMBUFFER
3810
uint32 c = (uint32) ROM(R14);
3811
#else
3812
uint32 c = USEX8(GSU.vRomBuffer);
3813
#endif
3814
v = USEX8(SREG) | (c << 8);
3815
R15++;
3816
DREG = v;
3817
TESTR14;
3818
CLRFLAGS;
3819
}
3820
3821
// ef (ALT2) - getbl - get low-byte from ROM at address R14
3822
static void fx_getbl (void)
3823
{
3824
uint32 v;
3825
#ifndef FX_DO_ROMBUFFER
3826
uint32 c = (uint32) ROM(R14);
3827
#else
3828
uint32 c = USEX8(GSU.vRomBuffer);
3829
#endif
3830
v = (SREG & 0xff00) | c;
3831
R15++;
3832
DREG = v;
3833
TESTR14;
3834
CLRFLAGS;
3835
}
3836
3837
// ef (ALT3) - getbs - get sign extended byte from ROM at address R14
3838
static void fx_getbs (void)
3839
{
3840
uint32 v;
3841
#ifndef FX_DO_ROMBUFFER
3842
int8 c;
3843
c = ROM(R14);
3844
v = SEX8(c);
3845
#else
3846
v = SEX8(GSU.vRomBuffer);
3847
#endif
3848
R15++;
3849
DREG = v;
3850
TESTR14;
3851
CLRFLAGS;
3852
}
3853
3854
// f0-ff - iwt rn, #xx - immediate word transfer to register
3855
#define FX_IWT(reg) \
3856
uint32 v = PIPE; \
3857
R15++; \
3858
FETCHPIPE; \
3859
R15++; \
3860
v |= USEX8(PIPE) << 8; \
3861
FETCHPIPE; \
3862
R15++; \
3863
GSU.avReg[reg] = v; \
3864
CLRFLAGS
3865
3866
static void fx_iwt_r0 (void)
3867
{
3868
FX_IWT(0);
3869
}
3870
3871
static void fx_iwt_r1 (void)
3872
{
3873
FX_IWT(1);
3874
}
3875
3876
static void fx_iwt_r2 (void)
3877
{
3878
FX_IWT(2);
3879
}
3880
3881
static void fx_iwt_r3 (void)
3882
{
3883
FX_IWT(3);
3884
}
3885
3886
static void fx_iwt_r4 (void)
3887
{
3888
FX_IWT(4);
3889
}
3890
3891
static void fx_iwt_r5 (void)
3892
{
3893
FX_IWT(5);
3894
}
3895
3896
static void fx_iwt_r6 (void)
3897
{
3898
FX_IWT(6);
3899
}
3900
3901
static void fx_iwt_r7 (void)
3902
{
3903
FX_IWT(7);
3904
}
3905
3906
static void fx_iwt_r8 (void)
3907
{
3908
FX_IWT(8);
3909
}
3910
3911
static void fx_iwt_r9 (void)
3912
{
3913
FX_IWT(9);
3914
}
3915
3916
static void fx_iwt_r10 (void)
3917
{
3918
FX_IWT(10);
3919
}
3920
3921
static void fx_iwt_r11 (void)
3922
{
3923
FX_IWT(11);
3924
}
3925
3926
static void fx_iwt_r12 (void)
3927
{
3928
FX_IWT(12);
3929
}
3930
3931
static void fx_iwt_r13 (void)
3932
{
3933
FX_IWT(13);
3934
}
3935
3936
static void fx_iwt_r14 (void)
3937
{
3938
FX_IWT(14);
3939
READR14;
3940
}
3941
3942
static void fx_iwt_r15 (void)
3943
{
3944
FX_IWT(15);
3945
}
3946
3947
// f0-ff (ALT1) - lm rn, (xx) - load word from RAM
3948
#define FX_LM(reg) \
3949
GSU.vLastRamAdr = PIPE; \
3950
R15++; \
3951
FETCHPIPE; \
3952
R15++; \
3953
GSU.vLastRamAdr |= USEX8(PIPE) << 8; \
3954
FETCHPIPE; \
3955
R15++; \
3956
GSU.avReg[reg] = RAM(GSU.vLastRamAdr); \
3957
GSU.avReg[reg] |= USEX8(RAM(GSU.vLastRamAdr ^ 1)) << 8; \
3958
CLRFLAGS
3959
3960
static void fx_lm_r0 (void)
3961
{
3962
FX_LM(0);
3963
}
3964
3965
static void fx_lm_r1 (void)
3966
{
3967
FX_LM(1);
3968
}
3969
3970
static void fx_lm_r2 (void)
3971
{
3972
FX_LM(2);
3973
}
3974
3975
static void fx_lm_r3 (void)
3976
{
3977
FX_LM(3);
3978
}
3979
3980
static void fx_lm_r4 (void)
3981
{
3982
FX_LM(4);
3983
}
3984
3985
static void fx_lm_r5 (void)
3986
{
3987
FX_LM(5);
3988
}
3989
3990
static void fx_lm_r6 (void)
3991
{
3992
FX_LM(6);
3993
}
3994
3995
static void fx_lm_r7 (void)
3996
{
3997
FX_LM(7);
3998
}
3999
4000
static void fx_lm_r8 (void)
4001
{
4002
FX_LM(8);
4003
}
4004
4005
static void fx_lm_r9 (void)
4006
{
4007
FX_LM(9);
4008
}
4009
4010
static void fx_lm_r10 (void)
4011
{
4012
FX_LM(10);
4013
}
4014
4015
static void fx_lm_r11 (void)
4016
{
4017
FX_LM(11);
4018
}
4019
4020
static void fx_lm_r12 (void)
4021
{
4022
FX_LM(12);
4023
}
4024
4025
static void fx_lm_r13 (void)
4026
{
4027
FX_LM(13);
4028
}
4029
4030
static void fx_lm_r14 (void)
4031
{
4032
FX_LM(14);
4033
READR14;
4034
}
4035
4036
static void fx_lm_r15 (void)
4037
{
4038
FX_LM(15);
4039
}
4040
4041
// f0-ff (ALT2) - sm (xx), rn - store word in RAM
4042
// XXX: If rn == r15, is the value of r15 before or after the extra bytes are read ?
4043
#define FX_SM(reg) \
4044
uint32 v = GSU.avReg[reg]; \
4045
GSU.vLastRamAdr = PIPE; \
4046
R15++; \
4047
FETCHPIPE; \
4048
R15++; \
4049
GSU.vLastRamAdr |= USEX8(PIPE) << 8; \
4050
FETCHPIPE; \
4051
RAM(GSU.vLastRamAdr) = (uint8) v; \
4052
RAM(GSU.vLastRamAdr ^ 1) = (uint8) (v >> 8); \
4053
CLRFLAGS; \
4054
R15++
4055
4056
static void fx_sm_r0 (void)
4057
{
4058
FX_SM(0);
4059
}
4060
4061
static void fx_sm_r1 (void)
4062
{
4063
FX_SM(1);
4064
}
4065
4066
static void fx_sm_r2 (void)
4067
{
4068
FX_SM(2);
4069
}
4070
4071
static void fx_sm_r3 (void)
4072
{
4073
FX_SM(3);
4074
}
4075
4076
static void fx_sm_r4 (void)
4077
{
4078
FX_SM(4);
4079
}
4080
4081
static void fx_sm_r5 (void)
4082
{
4083
FX_SM(5);
4084
}
4085
4086
static void fx_sm_r6 (void)
4087
{
4088
FX_SM(6);
4089
}
4090
4091
static void fx_sm_r7 (void)
4092
{
4093
FX_SM(7);
4094
}
4095
4096
static void fx_sm_r8 (void)
4097
{
4098
FX_SM(8);
4099
}
4100
4101
static void fx_sm_r9 (void)
4102
{
4103
FX_SM(9);
4104
}
4105
4106
static void fx_sm_r10 (void)
4107
{
4108
FX_SM(10);
4109
}
4110
4111
static void fx_sm_r11 (void)
4112
{
4113
FX_SM(11);
4114
}
4115
4116
static void fx_sm_r12 (void)
4117
{
4118
FX_SM(12);
4119
}
4120
4121
static void fx_sm_r13 (void)
4122
{
4123
FX_SM(13);
4124
}
4125
4126
static void fx_sm_r14 (void)
4127
{
4128
FX_SM(14);
4129
}
4130
4131
static void fx_sm_r15 (void)
4132
{
4133
FX_SM(15);
4134
}
4135
4136
// GSU executions functions
4137
4138
uint32 fx_run (uint32 nInstructions)
4139
{
4140
GSU.vCounter = nInstructions;
4141
READR14;
4142
while (TF(G) && (GSU.vCounter-- > 0))
4143
FX_STEP;
4144
#if 0
4145
#ifndef FX_ADDRESS_CHECK
4146
GSU.vPipeAdr = USEX16(R15 - 1) | (USEX8(GSU.vPrgBankReg) << 16);
4147
#endif
4148
#endif
4149
4150
return (nInstructions - GSU.vInstCount);
4151
}
4152
4153
/*
4154
uint32 fx_run_to_breakpoint (uint32 nInstructions)
4155
{
4156
uint32 vCounter = 0;
4157
4158
while (TF(G) && vCounter < nInstructions)
4159
{
4160
vCounter++;
4161
FX_STEP;
4162
4163
if (USEX16(R15) == GSU.vBreakPoint)
4164
{
4165
GSU.vErrorCode = FX_BREAKPOINT;
4166
break;
4167
}
4168
}
4169
4170
#if 0
4171
#ifndef FX_ADDRESS_CHECK
4172
GSU.vPipeAdr = USEX16(R15 - 1) | (USEX8(GSU.vPrgBankReg) << 16);
4173
#endif
4174
#endif
4175
4176
return (vCounter);
4177
}
4178
*/
4179
4180
/*
4181
uint32 fx_step_over (uint32 nInstructions)
4182
{
4183
uint32 vCounter = 0;
4184
4185
while (TF(G) && vCounter < nInstructions)
4186
{
4187
vCounter++;
4188
FX_STEP;
4189
4190
if (USEX16(R15) == GSU.vBreakPoint)
4191
{
4192
GSU.vErrorCode = FX_BREAKPOINT;
4193
break;
4194
}
4195
4196
if (USEX16(R15) == GSU.vStepPoint)
4197
break;
4198
}
4199
4200
#if 0
4201
#ifndef FX_ADDRESS_CHECK
4202
GSU.vPipeAdr = USEX16(R15 - 1) | (USEX8(GSU.vPrgBankReg) << 16);
4203
#endif
4204
#endif
4205
4206
return (vCounter);
4207
}
4208
*/
4209
4210
// Special table for the different plot configurations
4211
4212
void (*fx_PlotTable[]) (void) =
4213
{
4214
&fx_plot_2bit, &fx_plot_4bit, &fx_plot_4bit, &fx_plot_8bit, &fx_plot_obj,
4215
&fx_rpix_2bit, &fx_rpix_4bit, &fx_rpix_4bit, &fx_rpix_8bit, &fx_rpix_obj
4216
};
4217
4218
// Opcode table
4219
4220
void (*fx_OpcodeTable[]) (void) =
4221
{
4222
// ALT0 Table
4223
4224
// 00 - 0f
4225
&fx_stop, &fx_nop, &fx_cache, &fx_lsr, &fx_rol, &fx_bra, &fx_bge, &fx_blt,
4226
&fx_bne, &fx_beq, &fx_bpl, &fx_bmi, &fx_bcc, &fx_bcs, &fx_bvc, &fx_bvs,
4227
// 10 - 1f
4228
&fx_to_r0, &fx_to_r1, &fx_to_r2, &fx_to_r3, &fx_to_r4, &fx_to_r5, &fx_to_r6, &fx_to_r7,
4229
&fx_to_r8, &fx_to_r9, &fx_to_r10, &fx_to_r11, &fx_to_r12, &fx_to_r13, &fx_to_r14, &fx_to_r15,
4230
// 20 - 2f
4231
&fx_with_r0, &fx_with_r1, &fx_with_r2, &fx_with_r3, &fx_with_r4, &fx_with_r5, &fx_with_r6, &fx_with_r7,
4232
&fx_with_r8, &fx_with_r9, &fx_with_r10, &fx_with_r11, &fx_with_r12, &fx_with_r13, &fx_with_r14, &fx_with_r15,
4233
// 30 - 3f
4234
&fx_stw_r0, &fx_stw_r1, &fx_stw_r2, &fx_stw_r3, &fx_stw_r4, &fx_stw_r5, &fx_stw_r6, &fx_stw_r7,
4235
&fx_stw_r8, &fx_stw_r9, &fx_stw_r10, &fx_stw_r11, &fx_loop, &fx_alt1, &fx_alt2, &fx_alt3,
4236
// 40 - 4f
4237
&fx_ldw_r0, &fx_ldw_r1, &fx_ldw_r2, &fx_ldw_r3, &fx_ldw_r4, &fx_ldw_r5, &fx_ldw_r6, &fx_ldw_r7,
4238
&fx_ldw_r8, &fx_ldw_r9, &fx_ldw_r10, &fx_ldw_r11, &fx_plot_2bit, &fx_swap, &fx_color, &fx_not,
4239
// 50 - 5f
4240
&fx_add_r0, &fx_add_r1, &fx_add_r2, &fx_add_r3, &fx_add_r4, &fx_add_r5, &fx_add_r6, &fx_add_r7,
4241
&fx_add_r8, &fx_add_r9, &fx_add_r10, &fx_add_r11, &fx_add_r12, &fx_add_r13, &fx_add_r14, &fx_add_r15,
4242
// 60 - 6f
4243
&fx_sub_r0, &fx_sub_r1, &fx_sub_r2, &fx_sub_r3, &fx_sub_r4, &fx_sub_r5, &fx_sub_r6, &fx_sub_r7,
4244
&fx_sub_r8, &fx_sub_r9, &fx_sub_r10, &fx_sub_r11, &fx_sub_r12, &fx_sub_r13, &fx_sub_r14, &fx_sub_r15,
4245
// 70 - 7f
4246
&fx_merge, &fx_and_r1, &fx_and_r2, &fx_and_r3, &fx_and_r4, &fx_and_r5, &fx_and_r6, &fx_and_r7,
4247
&fx_and_r8, &fx_and_r9, &fx_and_r10, &fx_and_r11, &fx_and_r12, &fx_and_r13, &fx_and_r14, &fx_and_r15,
4248
// 80 - 8f
4249
&fx_mult_r0, &fx_mult_r1, &fx_mult_r2, &fx_mult_r3, &fx_mult_r4, &fx_mult_r5, &fx_mult_r6, &fx_mult_r7,
4250
&fx_mult_r8, &fx_mult_r9, &fx_mult_r10, &fx_mult_r11, &fx_mult_r12, &fx_mult_r13, &fx_mult_r14, &fx_mult_r15,
4251
// 90 - 9f
4252
&fx_sbk, &fx_link_i1, &fx_link_i2, &fx_link_i3, &fx_link_i4, &fx_sex, &fx_asr, &fx_ror,
4253
&fx_jmp_r8, &fx_jmp_r9, &fx_jmp_r10, &fx_jmp_r11, &fx_jmp_r12, &fx_jmp_r13, &fx_lob, &fx_fmult,
4254
// a0 - af
4255
&fx_ibt_r0, &fx_ibt_r1, &fx_ibt_r2, &fx_ibt_r3, &fx_ibt_r4, &fx_ibt_r5, &fx_ibt_r6, &fx_ibt_r7,
4256
&fx_ibt_r8, &fx_ibt_r9, &fx_ibt_r10, &fx_ibt_r11, &fx_ibt_r12, &fx_ibt_r13, &fx_ibt_r14, &fx_ibt_r15,
4257
// b0 - bf
4258
&fx_from_r0, &fx_from_r1, &fx_from_r2, &fx_from_r3, &fx_from_r4, &fx_from_r5, &fx_from_r6, &fx_from_r7,
4259
&fx_from_r8, &fx_from_r9, &fx_from_r10, &fx_from_r11, &fx_from_r12, &fx_from_r13, &fx_from_r14, &fx_from_r15,
4260
// c0 - cf
4261
&fx_hib, &fx_or_r1, &fx_or_r2, &fx_or_r3, &fx_or_r4, &fx_or_r5, &fx_or_r6, &fx_or_r7,
4262
&fx_or_r8, &fx_or_r9, &fx_or_r10, &fx_or_r11, &fx_or_r12, &fx_or_r13, &fx_or_r14, &fx_or_r15,
4263
// d0 - df
4264
&fx_inc_r0, &fx_inc_r1, &fx_inc_r2, &fx_inc_r3, &fx_inc_r4, &fx_inc_r5, &fx_inc_r6, &fx_inc_r7,
4265
&fx_inc_r8, &fx_inc_r9, &fx_inc_r10, &fx_inc_r11, &fx_inc_r12, &fx_inc_r13, &fx_inc_r14, &fx_getc,
4266
// e0 - ef
4267
&fx_dec_r0, &fx_dec_r1, &fx_dec_r2, &fx_dec_r3, &fx_dec_r4, &fx_dec_r5, &fx_dec_r6, &fx_dec_r7,
4268
&fx_dec_r8, &fx_dec_r9, &fx_dec_r10, &fx_dec_r11, &fx_dec_r12, &fx_dec_r13, &fx_dec_r14, &fx_getb,
4269
// f0 - ff
4270
&fx_iwt_r0, &fx_iwt_r1, &fx_iwt_r2, &fx_iwt_r3, &fx_iwt_r4, &fx_iwt_r5, &fx_iwt_r6, &fx_iwt_r7,
4271
&fx_iwt_r8, &fx_iwt_r9, &fx_iwt_r10, &fx_iwt_r11, &fx_iwt_r12, &fx_iwt_r13, &fx_iwt_r14, &fx_iwt_r15,
4272
4273
// ALT1 Table
4274
4275
// 00 - 0f
4276
&fx_stop, &fx_nop, &fx_cache, &fx_lsr, &fx_rol, &fx_bra, &fx_bge, &fx_blt,
4277
&fx_bne, &fx_beq, &fx_bpl, &fx_bmi, &fx_bcc, &fx_bcs, &fx_bvc, &fx_bvs,
4278
// 10 - 1f
4279
&fx_to_r0, &fx_to_r1, &fx_to_r2, &fx_to_r3, &fx_to_r4, &fx_to_r5, &fx_to_r6, &fx_to_r7,
4280
&fx_to_r8, &fx_to_r9, &fx_to_r10, &fx_to_r11, &fx_to_r12, &fx_to_r13, &fx_to_r14, &fx_to_r15,
4281
// 20 - 2f
4282
&fx_with_r0, &fx_with_r1, &fx_with_r2, &fx_with_r3, &fx_with_r4, &fx_with_r5, &fx_with_r6, &fx_with_r7,
4283
&fx_with_r8, &fx_with_r9, &fx_with_r10, &fx_with_r11, &fx_with_r12, &fx_with_r13, &fx_with_r14, &fx_with_r15,
4284
// 30 - 3f
4285
&fx_stb_r0, &fx_stb_r1, &fx_stb_r2, &fx_stb_r3, &fx_stb_r4, &fx_stb_r5, &fx_stb_r6, &fx_stb_r7,
4286
&fx_stb_r8, &fx_stb_r9, &fx_stb_r10, &fx_stb_r11, &fx_loop, &fx_alt1, &fx_alt2, &fx_alt3,
4287
// 40 - 4f
4288
&fx_ldb_r0, &fx_ldb_r1, &fx_ldb_r2, &fx_ldb_r3, &fx_ldb_r4, &fx_ldb_r5, &fx_ldb_r6, &fx_ldb_r7,
4289
&fx_ldb_r8, &fx_ldb_r9, &fx_ldb_r10, &fx_ldb_r11, &fx_rpix_2bit, &fx_swap, &fx_cmode, &fx_not,
4290
// 50 - 5f
4291
&fx_adc_r0, &fx_adc_r1, &fx_adc_r2, &fx_adc_r3, &fx_adc_r4, &fx_adc_r5, &fx_adc_r6, &fx_adc_r7,
4292
&fx_adc_r8, &fx_adc_r9, &fx_adc_r10, &fx_adc_r11, &fx_adc_r12, &fx_adc_r13, &fx_adc_r14, &fx_adc_r15,
4293
// 60 - 6f
4294
&fx_sbc_r0, &fx_sbc_r1, &fx_sbc_r2, &fx_sbc_r3, &fx_sbc_r4, &fx_sbc_r5, &fx_sbc_r6, &fx_sbc_r7,
4295
&fx_sbc_r8, &fx_sbc_r9, &fx_sbc_r10, &fx_sbc_r11, &fx_sbc_r12, &fx_sbc_r13, &fx_sbc_r14, &fx_sbc_r15,
4296
// 70 - 7f
4297
&fx_merge, &fx_bic_r1, &fx_bic_r2, &fx_bic_r3, &fx_bic_r4, &fx_bic_r5, &fx_bic_r6, &fx_bic_r7,
4298
&fx_bic_r8, &fx_bic_r9, &fx_bic_r10, &fx_bic_r11, &fx_bic_r12, &fx_bic_r13, &fx_bic_r14, &fx_bic_r15,
4299
// 80 - 8f
4300
&fx_umult_r0, &fx_umult_r1, &fx_umult_r2, &fx_umult_r3, &fx_umult_r4, &fx_umult_r5, &fx_umult_r6, &fx_umult_r7,
4301
&fx_umult_r8, &fx_umult_r9, &fx_umult_r10, &fx_umult_r11, &fx_umult_r12, &fx_umult_r13, &fx_umult_r14, &fx_umult_r15,
4302
// 90 - 9f
4303
&fx_sbk, &fx_link_i1, &fx_link_i2, &fx_link_i3, &fx_link_i4, &fx_sex, &fx_div2, &fx_ror,
4304
&fx_ljmp_r8, &fx_ljmp_r9, &fx_ljmp_r10, &fx_ljmp_r11, &fx_ljmp_r12, &fx_ljmp_r13, &fx_lob, &fx_lmult,
4305
// a0 - af
4306
&fx_lms_r0, &fx_lms_r1, &fx_lms_r2, &fx_lms_r3, &fx_lms_r4, &fx_lms_r5, &fx_lms_r6, &fx_lms_r7,
4307
&fx_lms_r8, &fx_lms_r9, &fx_lms_r10, &fx_lms_r11, &fx_lms_r12, &fx_lms_r13, &fx_lms_r14, &fx_lms_r15,
4308
// b0 - bf
4309
&fx_from_r0, &fx_from_r1, &fx_from_r2, &fx_from_r3, &fx_from_r4, &fx_from_r5, &fx_from_r6, &fx_from_r7,
4310
&fx_from_r8, &fx_from_r9, &fx_from_r10, &fx_from_r11, &fx_from_r12, &fx_from_r13, &fx_from_r14, &fx_from_r15,
4311
// c0 - cf
4312
&fx_hib, &fx_xor_r1, &fx_xor_r2, &fx_xor_r3, &fx_xor_r4, &fx_xor_r5, &fx_xor_r6, &fx_xor_r7,
4313
&fx_xor_r8, &fx_xor_r9, &fx_xor_r10, &fx_xor_r11, &fx_xor_r12, &fx_xor_r13, &fx_xor_r14, &fx_xor_r15,
4314
// d0 - df
4315
&fx_inc_r0, &fx_inc_r1, &fx_inc_r2, &fx_inc_r3, &fx_inc_r4, &fx_inc_r5, &fx_inc_r6, &fx_inc_r7,
4316
&fx_inc_r8, &fx_inc_r9, &fx_inc_r10, &fx_inc_r11, &fx_inc_r12, &fx_inc_r13, &fx_inc_r14, &fx_getc,
4317
// e0 - ef
4318
&fx_dec_r0, &fx_dec_r1, &fx_dec_r2, &fx_dec_r3, &fx_dec_r4, &fx_dec_r5, &fx_dec_r6, &fx_dec_r7,
4319
&fx_dec_r8, &fx_dec_r9, &fx_dec_r10, &fx_dec_r11, &fx_dec_r12, &fx_dec_r13, &fx_dec_r14, &fx_getbh,
4320
// f0 - ff
4321
&fx_lm_r0, &fx_lm_r1, &fx_lm_r2, &fx_lm_r3, &fx_lm_r4, &fx_lm_r5, &fx_lm_r6, &fx_lm_r7,
4322
&fx_lm_r8, &fx_lm_r9, &fx_lm_r10, &fx_lm_r11, &fx_lm_r12, &fx_lm_r13, &fx_lm_r14, &fx_lm_r15,
4323
4324
// ALT2 Table
4325
4326
// 00 - 0f
4327
&fx_stop, &fx_nop, &fx_cache, &fx_lsr, &fx_rol, &fx_bra, &fx_bge, &fx_blt,
4328
&fx_bne, &fx_beq, &fx_bpl, &fx_bmi, &fx_bcc, &fx_bcs, &fx_bvc, &fx_bvs,
4329
// 10 - 1f
4330
&fx_to_r0, &fx_to_r1, &fx_to_r2, &fx_to_r3, &fx_to_r4, &fx_to_r5, &fx_to_r6, &fx_to_r7,
4331
&fx_to_r8, &fx_to_r9, &fx_to_r10, &fx_to_r11, &fx_to_r12, &fx_to_r13, &fx_to_r14, &fx_to_r15,
4332
// 20 - 2f
4333
&fx_with_r0, &fx_with_r1, &fx_with_r2, &fx_with_r3, &fx_with_r4, &fx_with_r5, &fx_with_r6, &fx_with_r7,
4334
&fx_with_r8, &fx_with_r9, &fx_with_r10, &fx_with_r11, &fx_with_r12, &fx_with_r13, &fx_with_r14, &fx_with_r15,
4335
// 30 - 3f
4336
&fx_stw_r0, &fx_stw_r1, &fx_stw_r2, &fx_stw_r3, &fx_stw_r4, &fx_stw_r5, &fx_stw_r6, &fx_stw_r7,
4337
&fx_stw_r8, &fx_stw_r9, &fx_stw_r10, &fx_stw_r11, &fx_loop, &fx_alt1, &fx_alt2, &fx_alt3,
4338
// 40 - 4f
4339
&fx_ldw_r0, &fx_ldw_r1, &fx_ldw_r2, &fx_ldw_r3, &fx_ldw_r4, &fx_ldw_r5, &fx_ldw_r6, &fx_ldw_r7,
4340
&fx_ldw_r8, &fx_ldw_r9, &fx_ldw_r10, &fx_ldw_r11, &fx_plot_2bit, &fx_swap, &fx_color, &fx_not,
4341
// 50 - 5f
4342
&fx_add_i0, &fx_add_i1, &fx_add_i2, &fx_add_i3, &fx_add_i4, &fx_add_i5, &fx_add_i6, &fx_add_i7,
4343
&fx_add_i8, &fx_add_i9, &fx_add_i10, &fx_add_i11, &fx_add_i12, &fx_add_i13, &fx_add_i14, &fx_add_i15,
4344
// 60 - 6f
4345
&fx_sub_i0, &fx_sub_i1, &fx_sub_i2, &fx_sub_i3, &fx_sub_i4, &fx_sub_i5, &fx_sub_i6, &fx_sub_i7,
4346
&fx_sub_i8, &fx_sub_i9, &fx_sub_i10, &fx_sub_i11, &fx_sub_i12, &fx_sub_i13, &fx_sub_i14, &fx_sub_i15,
4347
// 70 - 7f
4348
&fx_merge, &fx_and_i1, &fx_and_i2, &fx_and_i3, &fx_and_i4, &fx_and_i5, &fx_and_i6, &fx_and_i7,
4349
&fx_and_i8, &fx_and_i9, &fx_and_i10, &fx_and_i11, &fx_and_i12, &fx_and_i13, &fx_and_i14, &fx_and_i15,
4350
// 80 - 8f
4351
&fx_mult_i0, &fx_mult_i1, &fx_mult_i2, &fx_mult_i3, &fx_mult_i4, &fx_mult_i5, &fx_mult_i6, &fx_mult_i7,
4352
&fx_mult_i8, &fx_mult_i9, &fx_mult_i10, &fx_mult_i11, &fx_mult_i12, &fx_mult_i13, &fx_mult_i14, &fx_mult_i15,
4353
// 90 - 9f
4354
&fx_sbk, &fx_link_i1, &fx_link_i2, &fx_link_i3, &fx_link_i4, &fx_sex, &fx_asr, &fx_ror,
4355
&fx_jmp_r8, &fx_jmp_r9, &fx_jmp_r10, &fx_jmp_r11, &fx_jmp_r12, &fx_jmp_r13, &fx_lob, &fx_fmult,
4356
// a0 - af
4357
&fx_sms_r0, &fx_sms_r1, &fx_sms_r2, &fx_sms_r3, &fx_sms_r4, &fx_sms_r5, &fx_sms_r6, &fx_sms_r7,
4358
&fx_sms_r8, &fx_sms_r9, &fx_sms_r10, &fx_sms_r11, &fx_sms_r12, &fx_sms_r13, &fx_sms_r14, &fx_sms_r15,
4359
// b0 - bf
4360
&fx_from_r0, &fx_from_r1, &fx_from_r2, &fx_from_r3, &fx_from_r4, &fx_from_r5, &fx_from_r6, &fx_from_r7,
4361
&fx_from_r8, &fx_from_r9, &fx_from_r10, &fx_from_r11, &fx_from_r12, &fx_from_r13, &fx_from_r14, &fx_from_r15,
4362
// c0 - cf
4363
&fx_hib, &fx_or_i1, &fx_or_i2, &fx_or_i3, &fx_or_i4, &fx_or_i5, &fx_or_i6, &fx_or_i7,
4364
&fx_or_i8, &fx_or_i9, &fx_or_i10, &fx_or_i11, &fx_or_i12, &fx_or_i13, &fx_or_i14, &fx_or_i15,
4365
// d0 - df
4366
&fx_inc_r0, &fx_inc_r1, &fx_inc_r2, &fx_inc_r3, &fx_inc_r4, &fx_inc_r5, &fx_inc_r6, &fx_inc_r7,
4367
&fx_inc_r8, &fx_inc_r9, &fx_inc_r10, &fx_inc_r11, &fx_inc_r12, &fx_inc_r13, &fx_inc_r14, &fx_ramb,
4368
// e0 - ef
4369
&fx_dec_r0, &fx_dec_r1, &fx_dec_r2, &fx_dec_r3, &fx_dec_r4, &fx_dec_r5, &fx_dec_r6, &fx_dec_r7,
4370
&fx_dec_r8, &fx_dec_r9, &fx_dec_r10, &fx_dec_r11, &fx_dec_r12, &fx_dec_r13, &fx_dec_r14, &fx_getbl,
4371
// f0 - ff
4372
&fx_sm_r0, &fx_sm_r1, &fx_sm_r2, &fx_sm_r3, &fx_sm_r4, &fx_sm_r5, &fx_sm_r6, &fx_sm_r7,
4373
&fx_sm_r8, &fx_sm_r9, &fx_sm_r10, &fx_sm_r11, &fx_sm_r12, &fx_sm_r13, &fx_sm_r14, &fx_sm_r15,
4374
4375
// ALT3 Table
4376
4377
// 00 - 0f
4378
&fx_stop, &fx_nop, &fx_cache, &fx_lsr, &fx_rol, &fx_bra, &fx_bge, &fx_blt,
4379
&fx_bne, &fx_beq, &fx_bpl, &fx_bmi, &fx_bcc, &fx_bcs, &fx_bvc, &fx_bvs,
4380
// 10 - 1f
4381
&fx_to_r0, &fx_to_r1, &fx_to_r2, &fx_to_r3, &fx_to_r4, &fx_to_r5, &fx_to_r6, &fx_to_r7,
4382
&fx_to_r8, &fx_to_r9, &fx_to_r10, &fx_to_r11, &fx_to_r12, &fx_to_r13, &fx_to_r14, &fx_to_r15,
4383
// 20 - 2f
4384
&fx_with_r0, &fx_with_r1, &fx_with_r2, &fx_with_r3, &fx_with_r4, &fx_with_r5, &fx_with_r6, &fx_with_r7,
4385
&fx_with_r8, &fx_with_r9, &fx_with_r10, &fx_with_r11, &fx_with_r12, &fx_with_r13, &fx_with_r14, &fx_with_r15,
4386
// 30 - 3f
4387
&fx_stb_r0, &fx_stb_r1, &fx_stb_r2, &fx_stb_r3, &fx_stb_r4, &fx_stb_r5, &fx_stb_r6, &fx_stb_r7,
4388
&fx_stb_r8, &fx_stb_r9, &fx_stb_r10, &fx_stb_r11, &fx_loop, &fx_alt1, &fx_alt2, &fx_alt3,
4389
// 40 - 4f
4390
&fx_ldb_r0, &fx_ldb_r1, &fx_ldb_r2, &fx_ldb_r3, &fx_ldb_r4, &fx_ldb_r5, &fx_ldb_r6, &fx_ldb_r7,
4391
&fx_ldb_r8, &fx_ldb_r9, &fx_ldb_r10, &fx_ldb_r11, &fx_rpix_2bit, &fx_swap, &fx_cmode, &fx_not,
4392
// 50 - 5f
4393
&fx_adc_i0, &fx_adc_i1, &fx_adc_i2, &fx_adc_i3, &fx_adc_i4, &fx_adc_i5, &fx_adc_i6, &fx_adc_i7,
4394
&fx_adc_i8, &fx_adc_i9, &fx_adc_i10, &fx_adc_i11, &fx_adc_i12, &fx_adc_i13, &fx_adc_i14, &fx_adc_i15,
4395
// 60 - 6f
4396
&fx_cmp_r0, &fx_cmp_r1, &fx_cmp_r2, &fx_cmp_r3, &fx_cmp_r4, &fx_cmp_r5, &fx_cmp_r6, &fx_cmp_r7,
4397
&fx_cmp_r8, &fx_cmp_r9, &fx_cmp_r10, &fx_cmp_r11, &fx_cmp_r12, &fx_cmp_r13, &fx_cmp_r14, &fx_cmp_r15,
4398
// 70 - 7f
4399
&fx_merge, &fx_bic_i1, &fx_bic_i2, &fx_bic_i3, &fx_bic_i4, &fx_bic_i5, &fx_bic_i6, &fx_bic_i7,
4400
&fx_bic_i8, &fx_bic_i9, &fx_bic_i10, &fx_bic_i11, &fx_bic_i12, &fx_bic_i13, &fx_bic_i14, &fx_bic_i15,
4401
// 80 - 8f
4402
&fx_umult_i0, &fx_umult_i1, &fx_umult_i2, &fx_umult_i3, &fx_umult_i4, &fx_umult_i5, &fx_umult_i6, &fx_umult_i7,
4403
&fx_umult_i8, &fx_umult_i9, &fx_umult_i10, &fx_umult_i11, &fx_umult_i12, &fx_umult_i13, &fx_umult_i14, &fx_umult_i15,
4404
// 90 - 9f
4405
&fx_sbk, &fx_link_i1, &fx_link_i2, &fx_link_i3, &fx_link_i4, &fx_sex, &fx_div2, &fx_ror,
4406
&fx_ljmp_r8, &fx_ljmp_r9, &fx_ljmp_r10, &fx_ljmp_r11, &fx_ljmp_r12, &fx_ljmp_r13, &fx_lob, &fx_lmult,
4407
// a0 - af
4408
&fx_lms_r0, &fx_lms_r1, &fx_lms_r2, &fx_lms_r3, &fx_lms_r4, &fx_lms_r5, &fx_lms_r6, &fx_lms_r7,
4409
&fx_lms_r8, &fx_lms_r9, &fx_lms_r10, &fx_lms_r11, &fx_lms_r12, &fx_lms_r13, &fx_lms_r14, &fx_lms_r15,
4410
// b0 - bf
4411
&fx_from_r0, &fx_from_r1, &fx_from_r2, &fx_from_r3, &fx_from_r4, &fx_from_r5, &fx_from_r6, &fx_from_r7,
4412
&fx_from_r8, &fx_from_r9, &fx_from_r10, &fx_from_r11, &fx_from_r12, &fx_from_r13, &fx_from_r14, &fx_from_r15,
4413
// c0 - cf
4414
&fx_hib, &fx_xor_i1, &fx_xor_i2, &fx_xor_i3, &fx_xor_i4, &fx_xor_i5, &fx_xor_i6, &fx_xor_i7,
4415
&fx_xor_i8, &fx_xor_i9, &fx_xor_i10, &fx_xor_i11, &fx_xor_i12, &fx_xor_i13, &fx_xor_i14, &fx_xor_i15,
4416
// d0 - df
4417
&fx_inc_r0, &fx_inc_r1, &fx_inc_r2, &fx_inc_r3, &fx_inc_r4, &fx_inc_r5, &fx_inc_r6, &fx_inc_r7,
4418
&fx_inc_r8, &fx_inc_r9, &fx_inc_r10, &fx_inc_r11, &fx_inc_r12, &fx_inc_r13, &fx_inc_r14, &fx_romb,
4419
// e0 - ef
4420
&fx_dec_r0, &fx_dec_r1, &fx_dec_r2, &fx_dec_r3, &fx_dec_r4, &fx_dec_r5, &fx_dec_r6, &fx_dec_r7,
4421
&fx_dec_r8, &fx_dec_r9, &fx_dec_r10, &fx_dec_r11, &fx_dec_r12, &fx_dec_r13, &fx_dec_r14, &fx_getbs,
4422
// f0 - ff
4423
&fx_lm_r0, &fx_lm_r1, &fx_lm_r2, &fx_lm_r3, &fx_lm_r4, &fx_lm_r5, &fx_lm_r6, &fx_lm_r7,
4424
&fx_lm_r8, &fx_lm_r9, &fx_lm_r10, &fx_lm_r11, &fx_lm_r12, &fx_lm_r13, &fx_lm_r14, &fx_lm_r15
4425
};
4426
4427