-
Notifications
You must be signed in to change notification settings - Fork 5
/
fxinst.cpp
1864 lines (1727 loc) · 75.5 KB
/
fxinst.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
*
* (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
* Jerremy Koot (jkoot@snes9x.com)
*
* Super FX C emulator code
* (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
* Gary Henderson.
* Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
*
* DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
* C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
* C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
*
* DOS port code contains the works of other authors. See headers in
* individual files.
*
* Snes9x homepage: http://www.snes9x.com
*
* Permission to use, copy, modify and distribute Snes9x in both binary and
* source form, for non-commercial purposes, is hereby granted without fee,
* providing that this license information and copyright notice appear with
* all copies and any derived work.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event shall the authors be held liable for any damages
* arising from the use of this software.
*
* Snes9x is freeware for PERSONAL USE only. Commercial users should
* seek permission of the copyright holders first. Commercial use includes
* charging money for Snes9x or software derived from Snes9x.
*
* The copyright holders request that bug fixes and improvements to the code
* should be forwarded to them so everyone can benefit from the modifications
* in future versions.
*
* Super NES and Super Nintendo Entertainment System are trademarks of
* Nintendo Co., Limited and its subsidiary companies.
*/
#define FX_DO_ROMBUFFER
#include "fxemu.h"
#include "fxinst.h"
#include <string.h>
#include <stdio.h>
extern struct FxRegs_s GSU;
int gsu_bank [512] = {0};
/* Set this define if you wish the plot instruction to check for y-pos limits */
/* (I don't think it's nessecary) */
#define CHECK_LIMITS
/* Codes used:
*
* rn = a GSU register (r0-r15)
* #n = 4 bit immediate value
* #pp = 8 bit immediate value
* (yy) = 8 bit word address (0x0000 - 0x01fe)
* #xx = 16 bit immediate value
* (xx) = 16 bit address (0x0000 - 0xffff)
*
*/
/* 00 - stop - stop GSU execution (and maybe generate an IRQ) */
static void fx_stop(struct FxRegs_s * gsu)
{
CF(G);
gsu->vCounter = 0;
gsu->vInstCount = gsu->vCounter;
/* Check if we need to generate an IRQ */
if(!(gsu->pvRegisters[GSU_CFGR] & 0x80))
SF(IRQ);
gsu->vPlotOptionReg = 0;
gsu->vPipe = 1;
CLRFLAGS;
R15++;
}
/* 01 - nop - no operation */
static void fx_nop(struct FxRegs_s * gsu) { CLRFLAGS; R15++; }
extern void fx_flushCache(struct FxRegs_s * gsu);
/* 02 - cache - reintialize GSU cache */
static void fx_cache(struct FxRegs_s * gsu)
{
uint32 c = R15 & 0xfff0;
if(gsu->vCacheBaseReg != c || !gsu->bCacheActive)
{
fx_flushCache(gsu);
gsu->vCacheBaseReg = c;
gsu->bCacheActive = TRUE;
#if 0
if(c < (0x10000-512))
{
uint8 const* t = &ROM(c);
memcpy(gsu->pvCache,t,512);
}
else
{
uint8 const* t1;
uint8 const* t2;
uint32 i = 0x10000 - c;
t1 = &ROM(c);
t2 = &ROM(0);
memcpy(gsu->pvCache,t1,i);
memcpy(&gsu->pvCache[i],t2,512-i);
}
#endif
}
R15++;
CLRFLAGS;
}
/* 03 - lsr - logic shift right */
static void fx_lsr(struct FxRegs_s * gsu)
{
uint32 v;
gsu->vCarry = SREG & 1;
v = USEX16(SREG) >> 1;
R15++; DREG = v;
gsu->vSign = v;
gsu->vZero = v;
TESTR14;
CLRFLAGS;
}
/* 04 - rol - rotate left */
static void fx_rol(struct FxRegs_s * gsu)
{
uint32 v = (SREG << 1) + gsu->vCarry;
gsu->vCarry = (SREG >> 15) & 1;
R15++; DREG = v;
gsu->vSign = v;
gsu->vZero = v;
TESTR14;
CLRFLAGS;
}
/* 05 - bra - branch always */
static void fx_bra(struct FxRegs_s * gsu) { uint8 v = PIPE; R15++; FETCHPIPE; R15 += SEX8(v); }
/* Branch on condition */
#define BRA_COND(cond) uint8 v = PIPE; R15++; FETCHPIPE; if(cond) R15 += SEX8(v); else R15++;
#define TEST_S (gsu->vSign & 0x8000)
#define TEST_Z (USEX16(gsu->vZero) == 0)
#define TEST_OV (gsu->vOverflow >= 0x8000 || gsu->vOverflow < -0x8000)
#define TEST_CY (gsu->vCarry & 1)
/* 06 - blt - branch on less than */
static void fx_blt(struct FxRegs_s * gsu) { BRA_COND( (TEST_S!=0) != (TEST_OV!=0) ); }
/* 07 - bge - branch on greater or equals */
static void fx_bge(struct FxRegs_s * gsu) { BRA_COND( (TEST_S!=0) == (TEST_OV!=0)); }
/* 08 - bne - branch on not equal */
static void fx_bne(struct FxRegs_s * gsu) { BRA_COND( !TEST_Z ); }
/* 09 - beq - branch on equal */
static void fx_beq(struct FxRegs_s * gsu) { BRA_COND( TEST_Z ); }
/* 0a - bpl - branch on plus */
static void fx_bpl(struct FxRegs_s * gsu) { BRA_COND( !TEST_S ); }
/* 0b - bmi - branch on minus */
static void fx_bmi(struct FxRegs_s * gsu) { BRA_COND( TEST_S ); }
/* 0c - bcc - branch on carry clear */
static void fx_bcc(struct FxRegs_s * gsu) { BRA_COND( !TEST_CY ); }
/* 0d - bcs - branch on carry set */
static void fx_bcs(struct FxRegs_s * gsu) { BRA_COND( TEST_CY ); }
/* 0e - bvc - branch on overflow clear */
static void fx_bvc(struct FxRegs_s * gsu) { BRA_COND( !TEST_OV ); }
/* 0f - bvs - branch on overflow set */
static void fx_bvs(struct FxRegs_s * gsu) { BRA_COND( TEST_OV ); }
/* 10-1f - to rn - set register n as destination register */
/* 10-1f(B) - move rn - move one register to another (if B flag is set) */
#define FX_TO(reg) \
if(TF(B)) { gsu->avReg[(reg)] = SREG; CLRFLAGS; } \
else { gsu->pvDreg = &gsu->avReg[reg]; } R15++;
#define FX_TO_R14(reg) \
if(TF(B)) { gsu->avReg[(reg)] = SREG; CLRFLAGS; READR14; } \
else { gsu->pvDreg = &gsu->avReg[reg]; } R15++;
#define FX_TO_R15(reg) \
if(TF(B)) { gsu->avReg[(reg)] = SREG; CLRFLAGS; } \
else { gsu->pvDreg = &gsu->avReg[reg]; R15++; }
static void fx_to_r0(struct FxRegs_s * gsu) { FX_TO(0); }
static void fx_to_r1(struct FxRegs_s * gsu) { FX_TO(1); }
static void fx_to_r2(struct FxRegs_s * gsu) { FX_TO(2); }
static void fx_to_r3(struct FxRegs_s * gsu) { FX_TO(3); }
static void fx_to_r4(struct FxRegs_s * gsu) { FX_TO(4); }
static void fx_to_r5(struct FxRegs_s * gsu) { FX_TO(5); }
static void fx_to_r6(struct FxRegs_s * gsu) { FX_TO(6); }
static void fx_to_r7(struct FxRegs_s * gsu) { FX_TO(7); }
static void fx_to_r8(struct FxRegs_s * gsu) { FX_TO(8); }
static void fx_to_r9(struct FxRegs_s * gsu) { FX_TO(9); }
static void fx_to_r10(struct FxRegs_s * gsu) { FX_TO(10); }
static void fx_to_r11(struct FxRegs_s * gsu) { FX_TO(11); }
static void fx_to_r12(struct FxRegs_s * gsu) { FX_TO(12); }
static void fx_to_r13(struct FxRegs_s * gsu) { FX_TO(13); }
static void fx_to_r14(struct FxRegs_s * gsu) { FX_TO_R14(14); }
static void fx_to_r15(struct FxRegs_s * gsu) { FX_TO_R15(15); }
/* 20-2f - to rn - set register n as source and destination register */
#define FX_WITH(reg) SF(B); gsu->pvSreg = gsu->pvDreg = &gsu->avReg[reg]; R15++;
static void fx_with_r0(struct FxRegs_s * gsu) { FX_WITH(0); }
static void fx_with_r1(struct FxRegs_s * gsu) { FX_WITH(1); }
static void fx_with_r2(struct FxRegs_s * gsu) { FX_WITH(2); }
static void fx_with_r3(struct FxRegs_s * gsu) { FX_WITH(3); }
static void fx_with_r4(struct FxRegs_s * gsu) { FX_WITH(4); }
static void fx_with_r5(struct FxRegs_s * gsu) { FX_WITH(5); }
static void fx_with_r6(struct FxRegs_s * gsu) { FX_WITH(6); }
static void fx_with_r7(struct FxRegs_s * gsu) { FX_WITH(7); }
static void fx_with_r8(struct FxRegs_s * gsu) { FX_WITH(8); }
static void fx_with_r9(struct FxRegs_s * gsu) { FX_WITH(9); }
static void fx_with_r10(struct FxRegs_s * gsu) { FX_WITH(10); }
static void fx_with_r11(struct FxRegs_s * gsu) { FX_WITH(11); }
static void fx_with_r12(struct FxRegs_s * gsu) { FX_WITH(12); }
static void fx_with_r13(struct FxRegs_s * gsu) { FX_WITH(13); }
static void fx_with_r14(struct FxRegs_s * gsu) { FX_WITH(14); }
static void fx_with_r15(struct FxRegs_s * gsu) { FX_WITH(15); }
/* 30-3b - stw (rn) - store word */
#define FX_STW(reg) \
gsu->vLastRamAdr = gsu->avReg[reg]; \
RAM(gsu->avReg[reg]) = (uint8)SREG; \
RAM(gsu->avReg[reg]^1) = (uint8)(SREG>>8); \
CLRFLAGS; R15++
static void fx_stw_r0(struct FxRegs_s * gsu) { FX_STW(0); }
static void fx_stw_r1(struct FxRegs_s * gsu) { FX_STW(1); }
static void fx_stw_r2(struct FxRegs_s * gsu) { FX_STW(2); }
static void fx_stw_r3(struct FxRegs_s * gsu) { FX_STW(3); }
static void fx_stw_r4(struct FxRegs_s * gsu) { FX_STW(4); }
static void fx_stw_r5(struct FxRegs_s * gsu) { FX_STW(5); }
static void fx_stw_r6(struct FxRegs_s * gsu) { FX_STW(6); }
static void fx_stw_r7(struct FxRegs_s * gsu) { FX_STW(7); }
static void fx_stw_r8(struct FxRegs_s * gsu) { FX_STW(8); }
static void fx_stw_r9(struct FxRegs_s * gsu) { FX_STW(9); }
static void fx_stw_r10(struct FxRegs_s * gsu) { FX_STW(10); }
static void fx_stw_r11(struct FxRegs_s * gsu) { FX_STW(11); }
/* 30-3b(ALT1) - stb (rn) - store byte */
#define FX_STB(reg) \
gsu->vLastRamAdr = gsu->avReg[reg]; \
RAM(gsu->avReg[reg]) = (uint8)SREG; \
CLRFLAGS; R15++
static void fx_stb_r0(struct FxRegs_s * gsu) { FX_STB(0); }
static void fx_stb_r1(struct FxRegs_s * gsu) { FX_STB(1); }
static void fx_stb_r2(struct FxRegs_s * gsu) { FX_STB(2); }
static void fx_stb_r3(struct FxRegs_s * gsu) { FX_STB(3); }
static void fx_stb_r4(struct FxRegs_s * gsu) { FX_STB(4); }
static void fx_stb_r5(struct FxRegs_s * gsu) { FX_STB(5); }
static void fx_stb_r6(struct FxRegs_s * gsu) { FX_STB(6); }
static void fx_stb_r7(struct FxRegs_s * gsu) { FX_STB(7); }
static void fx_stb_r8(struct FxRegs_s * gsu) { FX_STB(8); }
static void fx_stb_r9(struct FxRegs_s * gsu) { FX_STB(9); }
static void fx_stb_r10(struct FxRegs_s * gsu) { FX_STB(10); }
static void fx_stb_r11(struct FxRegs_s * gsu) { FX_STB(11); }
/* 3c - loop - decrement loop counter, and branch on not zero */
static void fx_loop(struct FxRegs_s * gsu)
{
gsu->vSign = gsu->vZero = --R12;
if( (uint16) R12 != 0 )
R15 = R13;
else
R15++;
CLRFLAGS;
}
/* 3d - alt1 - set alt1 mode */
static void fx_alt1(struct FxRegs_s * gsu) { SF(ALT1); CF(B); R15++; }
/* 3e - alt2 - set alt2 mode */
static void fx_alt2(struct FxRegs_s * gsu) { SF(ALT2); CF(B); R15++; }
/* 3f - alt3 - set alt3 mode */
static void fx_alt3(struct FxRegs_s * gsu) { SF(ALT1); SF(ALT2); CF(B); R15++; }
/* 40-4b - ldw (rn) - load word from RAM */
#define FX_LDW(reg) uint32 v; \
gsu->vLastRamAdr = gsu->avReg[reg]; \
v = (uint32)RAM(gsu->avReg[reg]); \
v |= ((uint32)RAM(gsu->avReg[reg]^1))<<8; \
R15++; DREG = v; \
TESTR14; \
CLRFLAGS
static void fx_ldw_r0(struct FxRegs_s * gsu) { FX_LDW(0); }
static void fx_ldw_r1(struct FxRegs_s * gsu) { FX_LDW(1); }
static void fx_ldw_r2(struct FxRegs_s * gsu) { FX_LDW(2); }
static void fx_ldw_r3(struct FxRegs_s * gsu) { FX_LDW(3); }
static void fx_ldw_r4(struct FxRegs_s * gsu) { FX_LDW(4); }
static void fx_ldw_r5(struct FxRegs_s * gsu) { FX_LDW(5); }
static void fx_ldw_r6(struct FxRegs_s * gsu) { FX_LDW(6); }
static void fx_ldw_r7(struct FxRegs_s * gsu) { FX_LDW(7); }
static void fx_ldw_r8(struct FxRegs_s * gsu) { FX_LDW(8); }
static void fx_ldw_r9(struct FxRegs_s * gsu) { FX_LDW(9); }
static void fx_ldw_r10(struct FxRegs_s * gsu) { FX_LDW(10); }
static void fx_ldw_r11(struct FxRegs_s * gsu) { FX_LDW(11); }
/* 40-4b(ALT1) - ldb (rn) - load byte */
#define FX_LDB(reg) uint32 v; \
gsu->vLastRamAdr = gsu->avReg[reg]; \
v = (uint32)RAM(gsu->avReg[reg]); \
R15++; DREG = v; \
TESTR14; \
CLRFLAGS
static void fx_ldb_r0(struct FxRegs_s * gsu) { FX_LDB(0); }
static void fx_ldb_r1(struct FxRegs_s * gsu) { FX_LDB(1); }
static void fx_ldb_r2(struct FxRegs_s * gsu) { FX_LDB(2); }
static void fx_ldb_r3(struct FxRegs_s * gsu) { FX_LDB(3); }
static void fx_ldb_r4(struct FxRegs_s * gsu) { FX_LDB(4); }
static void fx_ldb_r5(struct FxRegs_s * gsu) { FX_LDB(5); }
static void fx_ldb_r6(struct FxRegs_s * gsu) { FX_LDB(6); }
static void fx_ldb_r7(struct FxRegs_s * gsu) { FX_LDB(7); }
static void fx_ldb_r8(struct FxRegs_s * gsu) { FX_LDB(8); }
static void fx_ldb_r9(struct FxRegs_s * gsu) { FX_LDB(9); }
static void fx_ldb_r10(struct FxRegs_s * gsu) { FX_LDB(10); }
static void fx_ldb_r11(struct FxRegs_s * gsu) { FX_LDB(11); }
/* 4c - plot - plot pixel with R1,R2 as x,y and the color register as the color */
static void fx_plot_2bit(struct FxRegs_s * gsu)
{
uint32 x = USEX8(R1);
uint32 y = USEX8(R2);
uint8 *a;
uint8 v,c;
R15++;
CLRFLAGS;
R1++;
#ifdef CHECK_LIMITS
if(y >= gsu->vScreenHeight) return;
#endif
if(gsu->vPlotOptionReg & 0x02)
c = (x^y)&1 ? (uint8)(gsu->vColorReg>>4) : (uint8)gsu->vColorReg;
else
c = (uint8)gsu->vColorReg;
if( !(gsu->vPlotOptionReg & 0x01) && !(c & 0xf)) return;
a = gsu->apvScreen[y >> 3] + gsu->x[x >> 3] + ((y & 7) << 1);
v = 128 >> (x&7);
if(c & 0x01) a[0] |= v;
else a[0] &= ~v;
if(c & 0x02) a[1] |= v;
else a[1] &= ~v;
}
/* 2c(ALT1) - rpix - read color of the pixel with R1,R2 as x,y */
static void fx_rpix_2bit(struct FxRegs_s * gsu)
{
uint32 x = USEX8(R1);
uint32 y = USEX8(R2);
uint8 *a;
uint8 v;
R15++;
CLRFLAGS;
#ifdef CHECK_LIMITS
if(y >= gsu->vScreenHeight) return;
#endif
a = gsu->apvScreen[y >> 3] + gsu->x[x >> 3] + ((y & 7) << 1);
v = 128 >> (x&7);
DREG = 0;
DREG |= ((uint32)((a[0] & v) != 0)) << 0;
DREG |= ((uint32)((a[1] & v) != 0)) << 1;
TESTR14;
}
/* 4c - plot - plot pixel with R1,R2 as x,y and the color register as the color */
static void fx_plot_4bit(struct FxRegs_s * gsu)
{
uint32 x = USEX8(R1);
uint32 y = USEX8(R2);
uint8 *a;
uint8 v,c;
R15++;
CLRFLAGS;
R1++;
#ifdef CHECK_LIMITS
if(y >= gsu->vScreenHeight) return;
#endif
if(gsu->vPlotOptionReg & 0x02)
c = (x^y)&1 ? (uint8)(gsu->vColorReg>>4) : (uint8)gsu->vColorReg;
else
c = (uint8)gsu->vColorReg;
if( !(gsu->vPlotOptionReg & 0x01) && !(c & 0xf)) return;
a = gsu->apvScreen[y >> 3] + gsu->x[x >> 3] + ((y & 7) << 1);
v = 128 >> (x&7);
if(c & 0x01) a[0x00] |= v;
else a[0x00] &= ~v;
if(c & 0x02) a[0x01] |= v;
else a[0x01] &= ~v;
if(c & 0x04) a[0x10] |= v;
else a[0x10] &= ~v;
if(c & 0x08) a[0x11] |= v;
else a[0x11] &= ~v;
}
/* 4c(ALT1) - rpix - read color of the pixel with R1,R2 as x,y */
static void fx_rpix_4bit(struct FxRegs_s * gsu)
{
uint32 x = USEX8(R1);
uint32 y = USEX8(R2);
uint8 *a;
uint8 v;
R15++;
CLRFLAGS;
#ifdef CHECK_LIMITS
if(y >= gsu->vScreenHeight) return;
#endif
a = gsu->apvScreen[y >> 3] + gsu->x[x >> 3] + ((y & 7) << 1);
v = 128 >> (x&7);
DREG = 0;
DREG |= ((uint32)((a[0x00] & v) != 0)) << 0;
DREG |= ((uint32)((a[0x01] & v) != 0)) << 1;
DREG |= ((uint32)((a[0x10] & v) != 0)) << 2;
DREG |= ((uint32)((a[0x11] & v) != 0)) << 3;
TESTR14;
}
/* 8c - plot - plot pixel with R1,R2 as x,y and the color register as the color */
static void fx_plot_8bit(struct FxRegs_s * gsu)
{
uint32 x = USEX8(R1);
uint32 y = USEX8(R2);
uint8 *a;
uint8 v,c;
R15++;
CLRFLAGS;
R1++;
#ifdef CHECK_LIMITS
if(y >= gsu->vScreenHeight) return;
#endif
c = (uint8)gsu->vColorReg;
if(gsu->vPlotOptionReg & 0x10)
if( !(gsu->vPlotOptionReg & 0x01) && !(c&0xf)) return;
else
if( !(gsu->vPlotOptionReg & 0x01) && !c) return;
a = gsu->apvScreen[y >> 3] + gsu->x[x >> 3] + ((y & 7) << 1);
v = 128 >> (x&7);
if(c & 0x01) a[0x00] |= v;
else a[0x00] &= ~v;
if(c & 0x02) a[0x01] |= v;
else a[0x01] &= ~v;
if(c & 0x04) a[0x10] |= v;
else a[0x10] &= ~v;
if(c & 0x08) a[0x11] |= v;
else a[0x11] &= ~v;
if(c & 0x10) a[0x20] |= v;
else a[0x20] &= ~v;
if(c & 0x20) a[0x21] |= v;
else a[0x21] &= ~v;
if(c & 0x40) a[0x30] |= v;
else a[0x30] &= ~v;
if(c & 0x80) a[0x31] |= v;
else a[0x31] &= ~v;
}
/* 4c(ALT1) - rpix - read color of the pixel with R1,R2 as x,y */
static void fx_rpix_8bit(struct FxRegs_s * gsu)
{
uint32 x = USEX8(R1);
uint32 y = USEX8(R2);
uint8 *a;
uint8 v;
R15++;
CLRFLAGS;
#ifdef CHECK_LIMITS
if(y >= gsu->vScreenHeight) return;
#endif
a = gsu->apvScreen[y >> 3] + gsu->x[x >> 3] + ((y & 7) << 1);
v = 128 >> (x&7);
DREG = 0;
DREG |= ((uint32)((a[0x00] & v) != 0)) << 0;
DREG |= ((uint32)((a[0x01] & v) != 0)) << 1;
DREG |= ((uint32)((a[0x10] & v) != 0)) << 2;
DREG |= ((uint32)((a[0x11] & v) != 0)) << 3;
DREG |= ((uint32)((a[0x20] & v) != 0)) << 4;
DREG |= ((uint32)((a[0x21] & v) != 0)) << 5;
DREG |= ((uint32)((a[0x30] & v) != 0)) << 6;
DREG |= ((uint32)((a[0x31] & v) != 0)) << 7;
TESTR14;
}
/* 4o - plot - plot pixel with R1,R2 as x,y and the color register as the color */
static void fx_plot_obj(struct FxRegs_s * gsu)
{
printf ("ERROR fx_plot_obj called\n");
}
/* 4c(ALT1) - rpix - read color of the pixel with R1,R2 as x,y */
static void fx_rpix_obj(struct FxRegs_s * gsu)
{
printf ("ERROR fx_rpix_obj called\n");
}
/* 4d - swap - swap upper and lower byte of a register */
static void fx_swap(struct FxRegs_s * gsu)
{
uint8 c = (uint8)SREG;
uint8 d = (uint8)(SREG>>8);
uint32 v = (((uint32)c)<<8)|((uint32)d);
R15++; DREG = v;
gsu->vSign = v;
gsu->vZero = v;
TESTR14;
CLRFLAGS;
}
/* 4e - color - copy source register to color register */
static void fx_color(struct FxRegs_s * gsu)
{
uint8 c = (uint8)SREG;
if(gsu->vPlotOptionReg & 0x04)
c = (c&0xf0) | (c>>4);
if(gsu->vPlotOptionReg & 0x08)
{
gsu->vColorReg &= 0xf0;
gsu->vColorReg |= c & 0x0f;
}
else
gsu->vColorReg = USEX8(c);
CLRFLAGS;
R15++;
}
/* 4e(ALT1) - cmode - set plot option register */
static void fx_cmode(struct FxRegs_s * gsu)
{
gsu->vPlotOptionReg = SREG;
if(gsu->vPlotOptionReg & 0x10)
{
/* OBJ Mode (for drawing into sprites) */
gsu->vScreenHeight = 256;
}
else
gsu->vScreenHeight = gsu->vScreenRealHeight;
fx_computeScreenPointers (gsu);
CLRFLAGS;
R15++;
}
/* 4f - not - perform exclusive exor with 1 on all bits */
static void fx_not(struct FxRegs_s * gsu)
{
uint32 v = ~SREG;
R15++; DREG = v;
gsu->vSign = v;
gsu->vZero = v;
TESTR14;
CLRFLAGS;
}
/* 50-5f - add rn - add, register + register */
#define FX_ADD(reg) \
int32 s = SUSEX16(SREG) + SUSEX16(gsu->avReg[reg]); \
gsu->vCarry = s >= 0x10000; \
gsu->vOverflow = ~(SREG ^ gsu->avReg[reg]) & (gsu->avReg[reg] ^ s) & 0x8000; \
gsu->vSign = s; \
gsu->vZero = s; \
R15++; DREG = s; \
TESTR14; \
CLRFLAGS
static void fx_add_r0(struct FxRegs_s * gsu) { FX_ADD(0); }
static void fx_add_r1(struct FxRegs_s * gsu) { FX_ADD(1); }
static void fx_add_r2(struct FxRegs_s * gsu) { FX_ADD(2); }
static void fx_add_r3(struct FxRegs_s * gsu) { FX_ADD(3); }
static void fx_add_r4(struct FxRegs_s * gsu) { FX_ADD(4); }
static void fx_add_r5(struct FxRegs_s * gsu) { FX_ADD(5); }
static void fx_add_r6(struct FxRegs_s * gsu) { FX_ADD(6); }
static void fx_add_r7(struct FxRegs_s * gsu) { FX_ADD(7); }
static void fx_add_r8(struct FxRegs_s * gsu) { FX_ADD(8); }
static void fx_add_r9(struct FxRegs_s * gsu) { FX_ADD(9); }
static void fx_add_r10(struct FxRegs_s * gsu) { FX_ADD(10); }
static void fx_add_r11(struct FxRegs_s * gsu) { FX_ADD(11); }
static void fx_add_r12(struct FxRegs_s * gsu) { FX_ADD(12); }
static void fx_add_r13(struct FxRegs_s * gsu) { FX_ADD(13); }
static void fx_add_r14(struct FxRegs_s * gsu) { FX_ADD(14); }
static void fx_add_r15(struct FxRegs_s * gsu) { FX_ADD(15); }
/* 50-5f(ALT1) - adc rn - add with carry, register + register */
#define FX_ADC(reg) \
int32 s = SUSEX16(SREG) + SUSEX16(gsu->avReg[reg]) + SEX16(gsu->vCarry); \
gsu->vCarry = s >= 0x10000; \
gsu->vOverflow = ~(SREG ^ gsu->avReg[reg]) & (gsu->avReg[reg] ^ s) & 0x8000; \
gsu->vSign = s; \
gsu->vZero = s; \
R15++; DREG = s; \
TESTR14; \
CLRFLAGS
static void fx_adc_r0(struct FxRegs_s * gsu) { FX_ADC(0); }
static void fx_adc_r1(struct FxRegs_s * gsu) { FX_ADC(1); }
static void fx_adc_r2(struct FxRegs_s * gsu) { FX_ADC(2); }
static void fx_adc_r3(struct FxRegs_s * gsu) { FX_ADC(3); }
static void fx_adc_r4(struct FxRegs_s * gsu) { FX_ADC(4); }
static void fx_adc_r5(struct FxRegs_s * gsu) { FX_ADC(5); }
static void fx_adc_r6(struct FxRegs_s * gsu) { FX_ADC(6); }
static void fx_adc_r7(struct FxRegs_s * gsu) { FX_ADC(7); }
static void fx_adc_r8(struct FxRegs_s * gsu) { FX_ADC(8); }
static void fx_adc_r9(struct FxRegs_s * gsu) { FX_ADC(9); }
static void fx_adc_r10(struct FxRegs_s * gsu) { FX_ADC(10); }
static void fx_adc_r11(struct FxRegs_s * gsu) { FX_ADC(11); }
static void fx_adc_r12(struct FxRegs_s * gsu) { FX_ADC(12); }
static void fx_adc_r13(struct FxRegs_s * gsu) { FX_ADC(13); }
static void fx_adc_r14(struct FxRegs_s * gsu) { FX_ADC(14); }
static void fx_adc_r15(struct FxRegs_s * gsu) { FX_ADC(15); }
/* 50-5f(ALT2) - add #n - add, register + immediate */
#define FX_ADD_I(imm) \
int32 s = SUSEX16(SREG) + imm; \
gsu->vCarry = s >= 0x10000; \
gsu->vOverflow = ~(SREG ^ imm) & (imm ^ s) & 0x8000; \
gsu->vSign = s; \
gsu->vZero = s; \
R15++; DREG = s; \
TESTR14; \
CLRFLAGS
static void fx_add_i0(struct FxRegs_s * gsu) { FX_ADD_I(0); }
static void fx_add_i1(struct FxRegs_s * gsu) { FX_ADD_I(1); }
static void fx_add_i2(struct FxRegs_s * gsu) { FX_ADD_I(2); }
static void fx_add_i3(struct FxRegs_s * gsu) { FX_ADD_I(3); }
static void fx_add_i4(struct FxRegs_s * gsu) { FX_ADD_I(4); }
static void fx_add_i5(struct FxRegs_s * gsu) { FX_ADD_I(5); }
static void fx_add_i6(struct FxRegs_s * gsu) { FX_ADD_I(6); }
static void fx_add_i7(struct FxRegs_s * gsu) { FX_ADD_I(7); }
static void fx_add_i8(struct FxRegs_s * gsu) { FX_ADD_I(8); }
static void fx_add_i9(struct FxRegs_s * gsu) { FX_ADD_I(9); }
static void fx_add_i10(struct FxRegs_s * gsu) { FX_ADD_I(10); }
static void fx_add_i11(struct FxRegs_s * gsu) { FX_ADD_I(11); }
static void fx_add_i12(struct FxRegs_s * gsu) { FX_ADD_I(12); }
static void fx_add_i13(struct FxRegs_s * gsu) { FX_ADD_I(13); }
static void fx_add_i14(struct FxRegs_s * gsu) { FX_ADD_I(14); }
static void fx_add_i15(struct FxRegs_s * gsu) { FX_ADD_I(15); }
/* 50-5f(ALT3) - adc #n - add with carry, register + immediate */
#define FX_ADC_I(imm) \
int32 s = SUSEX16(SREG) + imm + SUSEX16(gsu->vCarry); \
gsu->vCarry = s >= 0x10000; \
gsu->vOverflow = ~(SREG ^ imm) & (imm ^ s) & 0x8000; \
gsu->vSign = s; \
gsu->vZero = s; \
R15++; DREG = s; \
TESTR14; \
CLRFLAGS
static void fx_adc_i0(struct FxRegs_s * gsu) { FX_ADC_I(0); }
static void fx_adc_i1(struct FxRegs_s * gsu) { FX_ADC_I(1); }
static void fx_adc_i2(struct FxRegs_s * gsu) { FX_ADC_I(2); }
static void fx_adc_i3(struct FxRegs_s * gsu) { FX_ADC_I(3); }
static void fx_adc_i4(struct FxRegs_s * gsu) { FX_ADC_I(4); }
static void fx_adc_i5(struct FxRegs_s * gsu) { FX_ADC_I(5); }
static void fx_adc_i6(struct FxRegs_s * gsu) { FX_ADC_I(6); }
static void fx_adc_i7(struct FxRegs_s * gsu) { FX_ADC_I(7); }
static void fx_adc_i8(struct FxRegs_s * gsu) { FX_ADC_I(8); }
static void fx_adc_i9(struct FxRegs_s * gsu) { FX_ADC_I(9); }
static void fx_adc_i10(struct FxRegs_s * gsu) { FX_ADC_I(10); }
static void fx_adc_i11(struct FxRegs_s * gsu) { FX_ADC_I(11); }
static void fx_adc_i12(struct FxRegs_s * gsu) { FX_ADC_I(12); }
static void fx_adc_i13(struct FxRegs_s * gsu) { FX_ADC_I(13); }
static void fx_adc_i14(struct FxRegs_s * gsu) { FX_ADC_I(14); }
static void fx_adc_i15(struct FxRegs_s * gsu) { FX_ADC_I(15); }
/* 60-6f - sub rn - subtract, register - register */
#define FX_SUB(reg) \
int32 s = SUSEX16(SREG) - SUSEX16(gsu->avReg[reg]); \
gsu->vCarry = s >= 0; \
gsu->vOverflow = (SREG ^ gsu->avReg[reg]) & (SREG ^ s) & 0x8000; \
gsu->vSign = s; \
gsu->vZero = s; \
R15++; DREG = s; \
TESTR14; \
CLRFLAGS
static void fx_sub_r0(struct FxRegs_s * gsu) { FX_SUB(0); }
static void fx_sub_r1(struct FxRegs_s * gsu) { FX_SUB(1); }
static void fx_sub_r2(struct FxRegs_s * gsu) { FX_SUB(2); }
static void fx_sub_r3(struct FxRegs_s * gsu) { FX_SUB(3); }
static void fx_sub_r4(struct FxRegs_s * gsu) { FX_SUB(4); }
static void fx_sub_r5(struct FxRegs_s * gsu) { FX_SUB(5); }
static void fx_sub_r6(struct FxRegs_s * gsu) { FX_SUB(6); }
static void fx_sub_r7(struct FxRegs_s * gsu) { FX_SUB(7); }
static void fx_sub_r8(struct FxRegs_s * gsu) { FX_SUB(8); }
static void fx_sub_r9(struct FxRegs_s * gsu) { FX_SUB(9); }
static void fx_sub_r10(struct FxRegs_s * gsu) { FX_SUB(10); }
static void fx_sub_r11(struct FxRegs_s * gsu) { FX_SUB(11); }
static void fx_sub_r12(struct FxRegs_s * gsu) { FX_SUB(12); }
static void fx_sub_r13(struct FxRegs_s * gsu) { FX_SUB(13); }
static void fx_sub_r14(struct FxRegs_s * gsu) { FX_SUB(14); }
static void fx_sub_r15(struct FxRegs_s * gsu) { FX_SUB(15); }
/* 60-6f(ALT1) - sbc rn - subtract with carry, register - register */
#define FX_SBC(reg) \
int32 s = SUSEX16(SREG) - SUSEX16(gsu->avReg[reg]) - (SUSEX16(gsu->vCarry^1)); \
gsu->vCarry = s >= 0; \
gsu->vOverflow = (SREG ^ gsu->avReg[reg]) & (SREG ^ s) & 0x8000; \
gsu->vSign = s; \
gsu->vZero = s; \
R15++; DREG = s; \
TESTR14; \
CLRFLAGS
static void fx_sbc_r0(struct FxRegs_s * gsu) { FX_SBC(0); }
static void fx_sbc_r1(struct FxRegs_s * gsu) { FX_SBC(1); }
static void fx_sbc_r2(struct FxRegs_s * gsu) { FX_SBC(2); }
static void fx_sbc_r3(struct FxRegs_s * gsu) { FX_SBC(3); }
static void fx_sbc_r4(struct FxRegs_s * gsu) { FX_SBC(4); }
static void fx_sbc_r5(struct FxRegs_s * gsu) { FX_SBC(5); }
static void fx_sbc_r6(struct FxRegs_s * gsu) { FX_SBC(6); }
static void fx_sbc_r7(struct FxRegs_s * gsu) { FX_SBC(7); }
static void fx_sbc_r8(struct FxRegs_s * gsu) { FX_SBC(8); }
static void fx_sbc_r9(struct FxRegs_s * gsu) { FX_SBC(9); }
static void fx_sbc_r10(struct FxRegs_s * gsu) { FX_SBC(10); }
static void fx_sbc_r11(struct FxRegs_s * gsu) { FX_SBC(11); }
static void fx_sbc_r12(struct FxRegs_s * gsu) { FX_SBC(12); }
static void fx_sbc_r13(struct FxRegs_s * gsu) { FX_SBC(13); }
static void fx_sbc_r14(struct FxRegs_s * gsu) { FX_SBC(14); }
static void fx_sbc_r15(struct FxRegs_s * gsu) { FX_SBC(15); }
/* 60-6f(ALT2) - sub #n - subtract, register - immediate */
#define FX_SUB_I(imm) \
int32 s = SUSEX16(SREG) - imm; \
gsu->vCarry = s >= 0; \
gsu->vOverflow = (SREG ^ imm) & (SREG ^ s) & 0x8000; \
gsu->vSign = s; \
gsu->vZero = s; \
R15++; DREG = s; \
TESTR14; \
CLRFLAGS
static void fx_sub_i0(struct FxRegs_s * gsu) { FX_SUB_I(0); }
static void fx_sub_i1(struct FxRegs_s * gsu) { FX_SUB_I(1); }
static void fx_sub_i2(struct FxRegs_s * gsu) { FX_SUB_I(2); }
static void fx_sub_i3(struct FxRegs_s * gsu) { FX_SUB_I(3); }
static void fx_sub_i4(struct FxRegs_s * gsu) { FX_SUB_I(4); }
static void fx_sub_i5(struct FxRegs_s * gsu) { FX_SUB_I(5); }
static void fx_sub_i6(struct FxRegs_s * gsu) { FX_SUB_I(6); }
static void fx_sub_i7(struct FxRegs_s * gsu) { FX_SUB_I(7); }
static void fx_sub_i8(struct FxRegs_s * gsu) { FX_SUB_I(8); }
static void fx_sub_i9(struct FxRegs_s * gsu) { FX_SUB_I(9); }
static void fx_sub_i10(struct FxRegs_s * gsu) { FX_SUB_I(10); }
static void fx_sub_i11(struct FxRegs_s * gsu) { FX_SUB_I(11); }
static void fx_sub_i12(struct FxRegs_s * gsu) { FX_SUB_I(12); }
static void fx_sub_i13(struct FxRegs_s * gsu) { FX_SUB_I(13); }
static void fx_sub_i14(struct FxRegs_s * gsu) { FX_SUB_I(14); }
static void fx_sub_i15(struct FxRegs_s * gsu) { FX_SUB_I(15); }
/* 60-6f(ALT3) - cmp rn - compare, register, register */
#define FX_CMP(reg) \
int32 s = SUSEX16(SREG) - SUSEX16(gsu->avReg[reg]); \
gsu->vCarry = s >= 0; \
gsu->vOverflow = (SREG ^ gsu->avReg[reg]) & (SREG ^ s) & 0x8000; \
gsu->vSign = s; \
gsu->vZero = s; \
R15++; \
CLRFLAGS;
static void fx_cmp_r0(struct FxRegs_s * gsu) { FX_CMP(0); }
static void fx_cmp_r1(struct FxRegs_s * gsu) { FX_CMP(1); }
static void fx_cmp_r2(struct FxRegs_s * gsu) { FX_CMP(2); }
static void fx_cmp_r3(struct FxRegs_s * gsu) { FX_CMP(3); }
static void fx_cmp_r4(struct FxRegs_s * gsu) { FX_CMP(4); }
static void fx_cmp_r5(struct FxRegs_s * gsu) { FX_CMP(5); }
static void fx_cmp_r6(struct FxRegs_s * gsu) { FX_CMP(6); }
static void fx_cmp_r7(struct FxRegs_s * gsu) { FX_CMP(7); }
static void fx_cmp_r8(struct FxRegs_s * gsu) { FX_CMP(8); }
static void fx_cmp_r9(struct FxRegs_s * gsu) { FX_CMP(9); }
static void fx_cmp_r10(struct FxRegs_s * gsu) { FX_CMP(10); }
static void fx_cmp_r11(struct FxRegs_s * gsu) { FX_CMP(11); }
static void fx_cmp_r12(struct FxRegs_s * gsu) { FX_CMP(12); }
static void fx_cmp_r13(struct FxRegs_s * gsu) { FX_CMP(13); }
static void fx_cmp_r14(struct FxRegs_s * gsu) { FX_CMP(14); }
static void fx_cmp_r15(struct FxRegs_s * gsu) { FX_CMP(15); }
/* 70 - merge - R7 as upper byte, R8 as lower byte (used for texture-mapping) */
static void fx_merge(struct FxRegs_s * gsu)
{
uint32 v = (R7&0xff00) | ((R8&0xff00)>>8);
R15++; DREG = v;
gsu->vOverflow = (v & 0xc0c0) << 16;
gsu->vZero = !(v & 0xf0f0);
gsu->vSign = ((v | (v<<8)) & 0x8000);
gsu->vCarry = (v & 0xe0e0) != 0;
TESTR14;
CLRFLAGS;
}
/* 71-7f - and rn - reister & register */
#define FX_AND(reg) \
uint32 v = SREG & gsu->avReg[reg]; \
R15++; DREG = v; \
gsu->vSign = v; \
gsu->vZero = v; \
TESTR14; \
CLRFLAGS;
static void fx_and_r1(struct FxRegs_s * gsu) { FX_AND(1); }
static void fx_and_r2(struct FxRegs_s * gsu) { FX_AND(2); }
static void fx_and_r3(struct FxRegs_s * gsu) { FX_AND(3); }
static void fx_and_r4(struct FxRegs_s * gsu) { FX_AND(4); }
static void fx_and_r5(struct FxRegs_s * gsu) { FX_AND(5); }
static void fx_and_r6(struct FxRegs_s * gsu) { FX_AND(6); }
static void fx_and_r7(struct FxRegs_s * gsu) { FX_AND(7); }
static void fx_and_r8(struct FxRegs_s * gsu) { FX_AND(8); }
static void fx_and_r9(struct FxRegs_s * gsu) { FX_AND(9); }
static void fx_and_r10(struct FxRegs_s * gsu) { FX_AND(10); }
static void fx_and_r11(struct FxRegs_s * gsu) { FX_AND(11); }
static void fx_and_r12(struct FxRegs_s * gsu) { FX_AND(12); }
static void fx_and_r13(struct FxRegs_s * gsu) { FX_AND(13); }
static void fx_and_r14(struct FxRegs_s * gsu) { FX_AND(14); }
static void fx_and_r15(struct FxRegs_s * gsu) { FX_AND(15); }
/* 71-7f(ALT1) - bic rn - reister & ~register */
#define FX_BIC(reg) \
uint32 v = SREG & ~gsu->avReg[reg]; \
R15++; DREG = v; \
gsu->vSign = v; \
gsu->vZero = v; \
TESTR14; \
CLRFLAGS;
static void fx_bic_r1(struct FxRegs_s * gsu) { FX_AND(1); }
static void fx_bic_r2(struct FxRegs_s * gsu) { FX_AND(2); }
static void fx_bic_r3(struct FxRegs_s * gsu) { FX_AND(3); }
static void fx_bic_r4(struct FxRegs_s * gsu) { FX_AND(4); }
static void fx_bic_r5(struct FxRegs_s * gsu) { FX_AND(5); }
static void fx_bic_r6(struct FxRegs_s * gsu) { FX_AND(6); }
static void fx_bic_r7(struct FxRegs_s * gsu) { FX_AND(7); }
static void fx_bic_r8(struct FxRegs_s * gsu) { FX_AND(8); }
static void fx_bic_r9(struct FxRegs_s * gsu) { FX_AND(9); }
static void fx_bic_r10(struct FxRegs_s * gsu) { FX_AND(10); }
static void fx_bic_r11(struct FxRegs_s * gsu) { FX_AND(11); }
static void fx_bic_r12(struct FxRegs_s * gsu) { FX_AND(12); }
static void fx_bic_r13(struct FxRegs_s * gsu) { FX_AND(13); }
static void fx_bic_r14(struct FxRegs_s * gsu) { FX_AND(14); }
static void fx_bic_r15(struct FxRegs_s * gsu) { FX_AND(15); }
/* 71-7f(ALT2) - and #n - reister & immediate */
#define FX_AND_I(imm) \
uint32 v = SREG & imm; \
R15++; DREG = v; \
gsu->vSign = v; \
gsu->vZero = v; \
TESTR14; \
CLRFLAGS;
static void fx_and_i1(struct FxRegs_s * gsu) { FX_AND_I(1); }
static void fx_and_i2(struct FxRegs_s * gsu) { FX_AND_I(2); }
static void fx_and_i3(struct FxRegs_s * gsu) { FX_AND_I(3); }
static void fx_and_i4(struct FxRegs_s * gsu) { FX_AND_I(4); }
static void fx_and_i5(struct FxRegs_s * gsu) { FX_AND_I(5); }
static void fx_and_i6(struct FxRegs_s * gsu) { FX_AND_I(6); }
static void fx_and_i7(struct FxRegs_s * gsu) { FX_AND_I(7); }
static void fx_and_i8(struct FxRegs_s * gsu) { FX_AND_I(8); }
static void fx_and_i9(struct FxRegs_s * gsu) { FX_AND_I(9); }
static void fx_and_i10(struct FxRegs_s * gsu) { FX_AND_I(10); }
static void fx_and_i11(struct FxRegs_s * gsu) { FX_AND_I(11); }
static void fx_and_i12(struct FxRegs_s * gsu) { FX_AND_I(12); }
static void fx_and_i13(struct FxRegs_s * gsu) { FX_AND_I(13); }
static void fx_and_i14(struct FxRegs_s * gsu) { FX_AND_I(14); }
static void fx_and_i15(struct FxRegs_s * gsu) { FX_AND_I(15); }
/* 71-7f(ALT3) - bic #n - reister & ~immediate */
#define FX_BIC_I(imm) \
uint32 v = SREG & ~imm; \
R15++; DREG = v; \
gsu->vSign = v; \
gsu->vZero = v; \
TESTR14; \
CLRFLAGS;
static void fx_bic_i1(struct FxRegs_s * gsu) { FX_BIC_I(1); }
static void fx_bic_i2(struct FxRegs_s * gsu) { FX_BIC_I(2); }
static void fx_bic_i3(struct FxRegs_s * gsu) { FX_BIC_I(3); }
static void fx_bic_i4(struct FxRegs_s * gsu) { FX_BIC_I(4); }
static void fx_bic_i5(struct FxRegs_s * gsu) { FX_BIC_I(5); }
static void fx_bic_i6(struct FxRegs_s * gsu) { FX_BIC_I(6); }
static void fx_bic_i7(struct FxRegs_s * gsu) { FX_BIC_I(7); }
static void fx_bic_i8(struct FxRegs_s * gsu) { FX_BIC_I(8); }
static void fx_bic_i9(struct FxRegs_s * gsu) { FX_BIC_I(9); }
static void fx_bic_i10(struct FxRegs_s * gsu) { FX_BIC_I(10); }
static void fx_bic_i11(struct FxRegs_s * gsu) { FX_BIC_I(11); }
static void fx_bic_i12(struct FxRegs_s * gsu) { FX_BIC_I(12); }
static void fx_bic_i13(struct FxRegs_s * gsu) { FX_BIC_I(13); }
static void fx_bic_i14(struct FxRegs_s * gsu) { FX_BIC_I(14); }
static void fx_bic_i15(struct FxRegs_s * gsu) { FX_BIC_I(15); }
/* 80-8f - mult rn - 8 bit to 16 bit signed multiply, register * register */
#define FX_MULT(reg) \
uint32 v = (uint32)(SEX8(SREG) * SEX8(gsu->avReg[reg])); \
R15++; DREG = v; \
gsu->vSign = v; \
gsu->vZero = v; \
TESTR14; \
CLRFLAGS;
static void fx_mult_r0(struct FxRegs_s * gsu) { FX_MULT(0); }
static void fx_mult_r1(struct FxRegs_s * gsu) { FX_MULT(1); }
static void fx_mult_r2(struct FxRegs_s * gsu) { FX_MULT(2); }
static void fx_mult_r3(struct FxRegs_s * gsu) { FX_MULT(3); }
static void fx_mult_r4(struct FxRegs_s * gsu) { FX_MULT(4); }
static void fx_mult_r5(struct FxRegs_s * gsu) { FX_MULT(5); }
static void fx_mult_r6(struct FxRegs_s * gsu) { FX_MULT(6); }
static void fx_mult_r7(struct FxRegs_s * gsu) { FX_MULT(7); }
static void fx_mult_r8(struct FxRegs_s * gsu) { FX_MULT(8); }
static void fx_mult_r9(struct FxRegs_s * gsu) { FX_MULT(9); }
static void fx_mult_r10(struct FxRegs_s * gsu) { FX_MULT(10); }
static void fx_mult_r11(struct FxRegs_s * gsu) { FX_MULT(11); }
static void fx_mult_r12(struct FxRegs_s * gsu) { FX_MULT(12); }
static void fx_mult_r13(struct FxRegs_s * gsu) { FX_MULT(13); }
static void fx_mult_r14(struct FxRegs_s * gsu) { FX_MULT(14); }
static void fx_mult_r15(struct FxRegs_s * gsu) { FX_MULT(15); }
/* 80-8f(ALT1) - umult rn - 8 bit to 16 bit unsigned multiply, register * register */
#define FX_UMULT(reg) \
uint32 v = USEX8(SREG) * USEX8(gsu->avReg[reg]); \
R15++; DREG = v; \
gsu->vSign = v; \
gsu->vZero = v; \
TESTR14; \
CLRFLAGS;
static void fx_umult_r0(struct FxRegs_s * gsu) { FX_UMULT(0); }
static void fx_umult_r1(struct FxRegs_s * gsu) { FX_UMULT(1); }
static void fx_umult_r2(struct FxRegs_s * gsu) { FX_UMULT(2); }
static void fx_umult_r3(struct FxRegs_s * gsu) { FX_UMULT(3); }
static void fx_umult_r4(struct FxRegs_s * gsu) { FX_UMULT(4); }
static void fx_umult_r5(struct FxRegs_s * gsu) { FX_UMULT(5); }
static void fx_umult_r6(struct FxRegs_s * gsu) { FX_UMULT(6); }
static void fx_umult_r7(struct FxRegs_s * gsu) { FX_UMULT(7); }
static void fx_umult_r8(struct FxRegs_s * gsu) { FX_UMULT(8); }
static void fx_umult_r9(struct FxRegs_s * gsu) { FX_UMULT(9); }
static void fx_umult_r10(struct FxRegs_s * gsu) { FX_UMULT(10); }
static void fx_umult_r11(struct FxRegs_s * gsu) { FX_UMULT(11); }
static void fx_umult_r12(struct FxRegs_s * gsu) { FX_UMULT(12); }
static void fx_umult_r13(struct FxRegs_s * gsu) { FX_UMULT(13); }
static void fx_umult_r14(struct FxRegs_s * gsu) { FX_UMULT(14); }
static void fx_umult_r15(struct FxRegs_s * gsu) { FX_UMULT(15); }
/* 80-8f(ALT2) - mult #n - 8 bit to 16 bit signed multiply, register * immediate */
#define FX_MULT_I(imm) \
uint32 v = (uint32) (SEX8(SREG) * ((int32)imm)); \
R15++; DREG = v; \
gsu->vSign = v; \
gsu->vZero = v; \
TESTR14; \
CLRFLAGS;
static void fx_mult_i0(struct FxRegs_s * gsu) { FX_MULT_I(0); }
static void fx_mult_i1(struct FxRegs_s * gsu) { FX_MULT_I(1); }
static void fx_mult_i2(struct FxRegs_s * gsu) { FX_MULT_I(2); }
static void fx_mult_i3(struct FxRegs_s * gsu) { FX_MULT_I(3); }
static void fx_mult_i4(struct FxRegs_s * gsu) { FX_MULT_I(4); }
static void fx_mult_i5(struct FxRegs_s * gsu) { FX_MULT_I(5); }
static void fx_mult_i6(struct FxRegs_s * gsu) { FX_MULT_I(6); }
static void fx_mult_i7(struct FxRegs_s * gsu) { FX_MULT_I(7); }
static void fx_mult_i8(struct FxRegs_s * gsu) { FX_MULT_I(8); }
static void fx_mult_i9(struct FxRegs_s * gsu) { FX_MULT_I(9); }
static void fx_mult_i10(struct FxRegs_s * gsu) { FX_MULT_I(10); }
static void fx_mult_i11(struct FxRegs_s * gsu) { FX_MULT_I(11); }
static void fx_mult_i12(struct FxRegs_s * gsu) { FX_MULT_I(12); }
static void fx_mult_i13(struct FxRegs_s * gsu) { FX_MULT_I(13); }
static void fx_mult_i14(struct FxRegs_s * gsu) { FX_MULT_I(14); }
static void fx_mult_i15(struct FxRegs_s * gsu) { FX_MULT_I(15); }
/* 80-8f(ALT3) - umult #n - 8 bit to 16 bit unsigned multiply, register * immediate */
#define FX_UMULT_I(imm) \
uint32 v = USEX8(SREG) * ((uint32)imm); \
R15++; DREG = v; \
gsu->vSign = v; \
gsu->vZero = v; \
TESTR14; \
CLRFLAGS;
static void fx_umult_i0(struct FxRegs_s * gsu) { FX_UMULT_I(0); }
static void fx_umult_i1(struct FxRegs_s * gsu) { FX_UMULT_I(1); }
static void fx_umult_i2(struct FxRegs_s * gsu) { FX_UMULT_I(2); }
static void fx_umult_i3(struct FxRegs_s * gsu) { FX_UMULT_I(3); }
static void fx_umult_i4(struct FxRegs_s * gsu) { FX_UMULT_I(4); }
static void fx_umult_i5(struct FxRegs_s * gsu) { FX_UMULT_I(5); }
static void fx_umult_i6(struct FxRegs_s * gsu) { FX_UMULT_I(6); }