-
Notifications
You must be signed in to change notification settings - Fork 462
/
fxdbg.cpp
1254 lines (1174 loc) · 16.7 KB
/
fxdbg.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.
This file is licensed under the Snes9x License.
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#ifdef DEBUGGER
#include "snes9x.h"
#include "fxinst.h"
#include "fxemu.h"
/*
When printing a line from the pipe, it could look like this:
01:8006 f4 fb 86 iwt r4, #$86fb
The values are:
program bank : 01
adress : 8006
values at memory address 8006 : f4 fb 86
instruction in the pipe : iwt r4, #$86fb
Note! If the instruction has more than one byte (like in 'iwt') and the instruction is in a delay slot,
the second and third byte displayed will not be the same as those used.
Since the instrction is in a delay slot,
the first byte of the instruction will be taken from the pipe at the address after the branch instruction,
and the next one or two bytes will be taken from the address that the branch points to.
This is a bit complicated, but I've taken this into account, in this debug function.
(See the diffrence of how the values vPipe1 and vPipe2 are read, compared to the values vByte1 and vByte2)
*/
/*
static const char *fx_apvMnemonicTable[] =
{
// ALT0 Table
// 00 - 0f
"stop",
"nop",
"cache",
"lsr",
"rol",
"bra $%04x",
"blt $%04x",
"bge $%04x",
"bne $%04x",
"beq $%04x",
"bpl $%04x",
"bmi $%04x",
"bcc $%04x",
"bcs $%04x",
"bvc $%04x",
"bvs $%04x",
// 10 - 1f
"to r0",
"to r1",
"to r2",
"to r3",
"to r4",
"to r5",
"to r6",
"to r7",
"to r8",
"to r9",
"to r10",
"to r11",
"to r12",
"to r13",
"to r14",
"to r15",
// 20 - 2f
"with r0",
"with r1",
"with r2",
"with r3",
"with r4",
"with r5",
"with r6",
"with r7",
"with r8",
"with r9",
"with r10",
"with r11",
"with r12",
"with r13",
"with r14",
"with r15",
// 30 - 3f
"stw (r0)",
"stw (r1)",
"stw (r2)",
"stw (r3)",
"stw (r4)",
"stw (r5)",
"stw (r6)",
"stw (r7)",
"stw (r8)",
"stw (r9)",
"stw (r10)",
"stw (r11)",
"loop",
"alt1",
"alt2",
"alt3",
// 40 - 4f
"ldw (r0)",
"ldw (r1)",
"ldw (r2)",
"ldw (r3)",
"ldw (r4)",
"ldw (r5)",
"ldw (r6)",
"ldw (r7)",
"ldw (r8)",
"ldw (r9)",
"ldw (r10)",
"ldw (r11)",
"plot",
"swap",
"color",
"not",
// 50 - 5f
"add r0",
"add r1",
"add r2",
"add r3",
"add r4",
"add r5",
"add r6",
"add r7",
"add r8",
"add r9",
"add r10",
"add r11",
"add r12",
"add r13",
"add r14",
"add r15",
// 60 - 6f
"sub r0",
"sub r1",
"sub r2",
"sub r3",
"sub r4",
"sub r5",
"sub r6",
"sub r7",
"sub r8",
"sub r9",
"sub r10",
"sub r11",
"sub r12",
"sub r13",
"sub r14",
"sub r15",
// 70 - 7f
"merge",
"and r1",
"and r2",
"and r3",
"and r4",
"and r5",
"and r6",
"and r7",
"and r8",
"and r9",
"and r10",
"and r11",
"and r12",
"and r13",
"and r14",
"and r15",
// 80 - 8f
"mult r0",
"mult r1",
"mult r2",
"mult r3",
"mult r4",
"mult r5",
"mult r6",
"mult r7",
"mult r8",
"mult r9",
"mult r10",
"mult r11",
"mult r12",
"mult r13",
"mult r14",
"mult r15",
// 90 - 9f
"sbk",
"link #1",
"link #2",
"link #3",
"link #4",
"sex",
"asr",
"ror",
"jmp (r8)",
"jmp (r9)",
"jmp (r10)",
"jmp (r11)",
"jmp (r12)",
"jmp (r13)",
"lob",
"fmult",
// a0 - af
"ibt r0, #$%02x",
"ibt r1, #$%02x",
"ibt r2, #$%02x",
"ibt r3, #$%02x",
"ibt r4, #$%02x",
"ibt r5, #$%02x",
"ibt r6, #$%02x",
"ibt r7, #$%02x",
"ibt r8, #$%02x",
"ibt r9, #$%02x",
"ibt r10, #$%02x",
"ibt r11, #$%02x",
"ibt r12, #$%02x",
"ibt r13, #$%02x",
"ibt r14, #$%02x",
"ibt r15, #$%02x",
// b0 - bf
"from r0",
"from r1",
"from r2",
"from r3",
"from r4",
"from r5",
"from r6",
"from r7",
"from r8",
"from r9",
"from r10",
"from r11",
"from r12",
"from r13",
"from r14",
"from r15",
// c0 - cf
"hib",
"or r1",
"or r2",
"or r3",
"or r4",
"or r5",
"or r6",
"or r7",
"or r8",
"or r9",
"or r10",
"or r11",
"or r12",
"or r13",
"or r14",
"or r15",
// d0 - df
"inc r0",
"inc r1",
"inc r2",
"inc r3",
"inc r4",
"inc r5",
"inc r6",
"inc r7",
"inc r8",
"inc r9",
"inc r10",
"inc r11",
"inc r12",
"inc r13",
"inc r14",
"getc",
// e0 - ef
"dec r0",
"dec r1",
"dec r2",
"dec r3",
"dec r4",
"dec r5",
"dec r6",
"dec r7",
"dec r8",
"dec r9",
"dec r10",
"dec r11",
"dec r12",
"dec r13",
"dec r14",
"getb",
// f0 - ff
"iwt r0, #$%04x",
"iwt r1, #$%04x",
"iwt r2, #$%04x",
"iwt r3, #$%04x",
"iwt r4, #$%04x",
"iwt r5, #$%04x",
"iwt r6, #$%04x",
"iwt r7, #$%04x",
"iwt r8, #$%04x",
"iwt r9, #$%04x",
"iwt r10, #$%04x",
"iwt r11, #$%04x",
"iwt r12, #$%04x",
"iwt r13, #$%04x",
"iwt r14, #$%04x",
"iwt r15, #$%04x",
// ALT1 Table
// 00 - 0f
"stop",
"nop",
"cache",
"lsr",
"rol",
"bra $%04x",
"blt $%04x",
"bge $%04x",
"bne $%04x",
"beq $%04x",
"bpl $%04x",
"bmi $%04x",
"bcc $%04x",
"bcs $%04x",
"bvc $%04x",
"bvs $%04x",
// 10 - 1f
"to r0",
"to r1",
"to r2",
"to r3",
"to r4",
"to r5",
"to r6",
"to r7",
"to r8",
"to r9",
"to r10",
"to r11",
"to r12",
"to r13",
"to r14",
"to r15",
// 20 - 2f
"with r0",
"with r1",
"with r2",
"with r3",
"with r4",
"with r5",
"with r6",
"with r7",
"with r8",
"with r9",
"with r10",
"with r11",
"with r12",
"with r13",
"with r14",
"with r15",
// 30 - 3f
"stb (r0)",
"stb (r1)",
"stb (r2)",
"stb (r3)",
"stb (r4)",
"stb (r5)",
"stb (r6)",
"stb (r7)",
"stb (r8)",
"stb (r9)",
"stb (r10)",
"stb (r11)",
"loop",
"alt1",
"alt2",
"alt3",
// 40 - 4f
"ldb (r0)",
"ldb (r1)",
"ldb (r2)",
"ldb (r3)",
"ldb (r4)",
"ldb (r5)",
"ldb (r6)",
"ldb (r7)",
"ldb (r8)",
"ldb (r9)",
"ldb (r10)",
"ldb (r11)",
"rpix",
"swap",
"cmode",
"not",
// 50 - 5f
"adc r0",
"adc r1",
"adc r2",
"adc r3",
"adc r4",
"adc r5",
"adc r6",
"adc r7",
"adc r8",
"adc r9",
"adc r10",
"adc r11",
"adc r12",
"adc r13",
"adc r14",
"adc r15",
// 60 - 6f
"sbc r0",
"sbc r1",
"sbc r2",
"sbc r3",
"sbc r4",
"sbc r5",
"sbc r6",
"sbc r7",
"sbc r8",
"sbc r9",
"sbc r10",
"sbc r11",
"sbc r12",
"sbc r13",
"sbc r14",
"sbc r15",
// 70 - 7f
"merge",
"bic r1",
"bic r2",
"bic r3",
"bic r4",
"bic r5",
"bic r6",
"bic r7",
"bic r8",
"bic r9",
"bic r10",
"bic r11",
"bic r12",
"bic r13",
"bic r14",
"bic r15",
// 80 - 8f
"umult r0",
"umult r1",
"umult r2",
"umult r3",
"umult r4",
"umult r5",
"umult r6",
"umult r7",
"umult r8",
"umult r9",
"umult r10",
"umult r11",
"umult r12",
"umult r13",
"umult r14",
"umult r15",
// 90 - 9f
"sbk",
"link #1",
"link #2",
"link #3",
"link #4",
"sex",
"div2",
"ror",
"ljmp (r8)",
"ljmp (r9)",
"ljmp (r10)",
"ljmp (r11)",
"ljmp (r12)",
"ljmp (r13)",
"lob",
"lmult",
// a0 - af
"lms r0, ($%04x)",
"lms r1, ($%04x)",
"lms r2, ($%04x)",
"lms r3, ($%04x)",
"lms r4, ($%04x)",
"lms r5, ($%04x)",
"lms r6, ($%04x)",
"lms r7, ($%04x)",
"lms r8, ($%04x)",
"lms r9, ($%04x)",
"lms r10, ($%04x)",
"lms r11, ($%04x)",
"lms r12, ($%04x)",
"lms r13, ($%04x)",
"lms r14, ($%04x)",
"lms r15, ($%04x)",
// b0 - bf
"from r0",
"from r1",
"from r2",
"from r3",
"from r4",
"from r5",
"from r6",
"from r7",
"from r8",
"from r9",
"from r10",
"from r11",
"from r12",
"from r13",
"from r14",
"from r15",
// c0 - cf
"hib",
"xor r1",
"xor r2",
"xor r3",
"xor r4",
"xor r5",
"xor r6",
"xor r7",
"xor r8",
"xor r9",
"xor r10",
"xor r11",
"xor r12",
"xor r13",
"xor r14",
"xor r15",
// d0 - df
"inc r0",
"inc r1",
"inc r2",
"inc r3",
"inc r4",
"inc r5",
"inc r6",
"inc r7",
"inc r8",
"inc r9",
"inc r10",
"inc r11",
"inc r12",
"inc r13",
"inc r14",
"getc",
// e0 - ef
"dec r0",
"dec r1",
"dec r2",
"dec r3",
"dec r4",
"dec r5",
"dec r6",
"dec r7",
"dec r8",
"dec r9",
"dec r10",
"dec r11",
"dec r12",
"dec r13",
"dec r14",
"getbh",
// f0 - ff
"lm r0, ($%04x)",
"lm r1, ($%04x)",
"lm r2, ($%04x)",
"lm r3, ($%04x)",
"lm r4, ($%04x)",
"lm r5, ($%04x)",
"lm r6, ($%04x)",
"lm r7, ($%04x)",
"lm r8, ($%04x)",
"lm r9, ($%04x)",
"lm r10, ($%04x)",
"lm r11, ($%04x)",
"lm r12, ($%04x)",
"lm r13, ($%04x)",
"lm r14, ($%04x)",
"lm r15, ($%04x)",
// ALT2 Table
// 00 - 0f
"stop",
"nop",
"cache",
"lsr",
"rol",
"bra $%04x",
"blt $%04x",
"bge $%04x",
"bne $%04x",
"beq $%04x",
"bpl $%04x",
"bmi $%04x",
"bcc $%04x",
"bcs $%04x",
"bvc $%04x",
"bvs $%04x",
// 10 - 1f
"to r0",
"to r1",
"to r2",
"to r3",
"to r4",
"to r5",
"to r6",
"to r7",
"to r8",
"to r9",
"to r10",
"to r11",
"to r12",
"to r13",
"to r14",
"to r15",
// 20 - 2f
"with r0",
"with r1",
"with r2",
"with r3",
"with r4",
"with r5",
"with r6",
"with r7",
"with r8",
"with r9",
"with r10",
"with r11",
"with r12",
"with r13",
"with r14",
"with r15",
// 30 - 3f
"stw (r0)",
"stw (r1)",
"stw (r2)",
"stw (r3)",
"stw (r4)",
"stw (r5)",
"stw (r6)",
"stw (r7)",
"stw (r8)",
"stw (r9)",
"stw (r10)",
"stw (r11)",
"loop",
"alt1",
"alt2",
"alt3",
// 40 - 4f
"ldw (r0)",
"ldw (r1)",
"ldw (r2)",
"ldw (r3)",
"ldw (r4)",
"ldw (r5)",
"ldw (r6)",
"ldw (r7)",
"ldw (r8)",
"ldw (r9)",
"ldw (r10)",
"ldw (r11)",
"plot",
"swap",
"color",
"not",
// 50 - 5f
"add #0",
"add #1",
"add #2",
"add #3",
"add #4",
"add #5",
"add #6",
"add #7",
"add #8",
"add #9",
"add #10",
"add #11",
"add #12",
"add #13",
"add #14",
"add #15",
// 60 - 6f
"sub #0",
"sub #1",
"sub #2",
"sub #3",
"sub #4",
"sub #5",
"sub #6",
"sub #7",
"sub #8",
"sub #9",
"sub #10",
"sub #11",
"sub #12",
"sub #13",
"sub #14",
"sub #15",
// 70 - 7f
"merge",
"and #1",
"and #2",
"and #3",
"and #4",
"and #5",
"and #6",
"and #7",
"and #8",
"and #9",
"and #10",
"and #11",
"and #12",
"and #13",
"and #14",
"and #15",
// 80 - 8f
"mult #0",
"mult #1",
"mult #2",
"mult #3",
"mult #4",
"mult #5",
"mult #6",
"mult #7",
"mult #8",
"mult #9",
"mult #10",
"mult #11",
"mult #12",
"mult #13",
"mult #14",
"mult #15",
// 90 - 9f
"sbk",
"link #1",
"link #2",
"link #3",
"link #4",
"sex",
"asr",
"ror",
"jmp (r8)",
"jmp (r9)",
"jmp (r10)",
"jmp (r11)",
"jmp (r12)",
"jmp (r13)",
"lob",
"fmult",
// a0 - af
"sms ($%04x), r0",
"sms ($%04x), r1",
"sms ($%04x), r2",
"sms ($%04x), r3",
"sms ($%04x), r4",
"sms ($%04x), r5",
"sms ($%04x), r6",
"sms ($%04x), r7",
"sms ($%04x), r8",
"sms ($%04x), r9",
"sms ($%04x), r10",
"sms ($%04x), r11",
"sms ($%04x), r12",
"sms ($%04x), r13",
"sms ($%04x), r14",
"sms ($%04x), r15",
// b0 - bf
"from r0",
"from r1",
"from r2",
"from r3",
"from r4",
"from r5",
"from r6",
"from r7",
"from r8",
"from r9",
"from r10",
"from r11",
"from r12",
"from r13",
"from r14",
"from r15",
// c0 - cf
"hib",
"or #1",
"or #2",
"or #3",
"or #4",
"or #5",
"or #6",
"or #7",
"or #8",
"or #9",
"or #10",
"or #11",
"or #12",
"or #13",
"or #14",
"or #15",
// d0 - df
"inc r0",
"inc r1",
"inc r2",
"inc r3",
"inc r4",
"inc r5",
"inc r6",
"inc r7",
"inc r8",
"inc r9",
"inc r10",
"inc r11",
"inc r12",
"inc r13",
"inc r14",
"ramb",
// e0 - ef
"dec r0",
"dec r1",
"dec r2",
"dec r3",
"dec r4",
"dec r5",
"dec r6",
"dec r7",
"dec r8",
"dec r9",
"dec r10",
"dec r11",
"dec r12",
"dec r13",
"dec r14",
"getbl",
// f0 - ff
"sm ($%04x), r0",
"sm ($%04x), r1",
"sm ($%04x), r2",
"sm ($%04x), r3",
"sm ($%04x), r4",
"sm ($%04x), r5",
"sm ($%04x), r6",
"sm ($%04x), r7",
"sm ($%04x), r8",
"sm ($%04x), r9",
"sm ($%04x), r10",
"sm ($%04x), r11",
"sm ($%04x), r12",
"sm ($%04x), r13",
"sm ($%04x), r14",
"sm ($%04x), r15",
// ALT3 Table
// 00 - 0f
"stop",
"nop",
"cache",
"lsr",
"rol",
"bra $%04x",
"blt $%04x",
"bge $%04x",
"bne $%04x",
"beq $%04x",
"bpl $%04x",
"bmi $%04x",
"bcc $%04x",
"bcs $%04x",
"bvc $%04x",
"bvs $%04x",
// 10 - 1f
"to r0",
"to r1",
"to r2",
"to r3",
"to r4",
"to r5",
"to r6",
"to r7",
"to r8",
"to r9",
"to r10",
"to r11",
"to r12",
"to r13",
"to r14",
"to r15",
// 20 - 2f
"with r0",
"with r1",
"with r2",
"with r3",
"with r4",
"with r5",
"with r6",
"with r7",
"with r8",
"with r9",
"with r10",
"with r11",
"with r12",
"with r13",
"with r14",
"with r15",
// 30 - 3f
"stb (r0)",
"stb (r1)",
"stb (r2)",
"stb (r3)",
"stb (r4)",
"stb (r5)",
"stb (r6)",
"stb (r7)",
"stb (r8)",
"stb (r9)",
"stb (r10)",
"stb (r11)",
"loop",
"alt1",
"alt2",
"alt3",
// 40 - 4f
"ldb (r0)",
"ldb (r1)",
"ldb (r2)",
"ldb (r3)",
"ldb (r4)",
"ldb (r5)",
"ldb (r6)",
"ldb (r7)",
"ldb (r8)",
"ldb (r9)",
"ldb (r10)",
"ldb (r11)",
"rpix",
"swap",
"cmode",
"not",
// 50 - 5f
"adc #0",
"adc #1",