-
Notifications
You must be signed in to change notification settings - Fork 15
/
hardware_registers.asm
1178 lines (1039 loc) · 27 KB
/
hardware_registers.asm
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
;--------------------;
; HARDWARE REGISTERS ;
;--------------------;
ORG $002100
; === $002100 ===
; 1 byte
; Screen brightness & F-blank control
; f---bbbb
; | ++++ screen brightness
; +------- forced blanking when set
HW_INIDISP: skip 1
; Valid values
!HW_DISP_FBlank = %10000000
!HW_DISP_NoBlank = %00001111
; === $002101 ===
; 1 byte
; Object size & object data location
; sssppbbb
; |||||+++ VRAM address where OBJ tile data is stored
; ||||| (bbb * w$2000) (upper bit redundant)
; |||++--- VRAM offset of second page of OBJ data
; ||| ((pp+1) * w$1000)
; +++----- OBJ size
HW_OBJSEL: skip 1
; Valid values
!HW_OBJ_Size_8_16 = %00000000
!HW_OBJ_Size_8_32 = %00100000
!HW_OBJ_Size_8_64 = %01000000
!HW_OBJ_Size_16_32 = %01100000
!HW_OBJ_Size_16_64 = %10000000
!HW_OBJ_Size_32_64 = %10100000
!HW_OBJ_Size_16R_32R = %11000000
!HW_OBJ_Size_16R_32 = %11100000
; === $002102 ===
; 2 bytes
; Word address for OAM access
; OAM priority rotation flag
; p------aAAAAAAAa
; | +++++++++ OAM word address
; | +++++++- 7 bit OBJ index to set highest priority
; +--------------- Set to specify highest priority object
HW_OAMADD: skip 2
; Valid values
!HW_OAM_SetPriority = %10000000
; === $002104 ===
; 1 byte
; OAM data for write only
; WRITE TWICE
; 1st write = lower 8 bits of the data
; 2nd write = upper 8 bits of the data
HW_OAMDATA: skip 1
; === $002105 ===
; 1 byte
; the background mode and layer character size settings
; 4321pmmm
; |||||+++ the background mode
; ||||+--- set if background layer 3 has high priority
; ++++---- set if background layer 1/2/3/4 has 16x16 characters, else 8x8
HW_BGMODE: skip 1
; Valid values
!HW_BG_Mode0 = %000
!HW_BG_Mode1 = %001
!HW_BG_Mode2 = %010
!HW_BG_Mode3 = %011
!HW_BG_Mode4 = %100
!HW_BG_Mode5 = %101
!HW_BG_Mode6 = %110
!HW_BG_Mode7 = %111
!HW_BG_BG3Pri = %1000
; === $002106 ===
; 1 byte
; enable mosaic effect and control its size
; ssss4321
; |||||||+ enable mosaic on BG1
; ||||||+- enable mosaic on BG2
; |||||+-- enable mosaic on BG3
; ||||+--- enable mosaic on BG4
; ++++---- size of mosaic blocks in pixels minus 1
HW_MOSAIC: skip 1
; === $002107 ===
; 1 byte
; BG1 tilemap data location in VRAM, and background size
; aaaaaass
; ||||||++ BG1 size
; ++++++-- VRAM address where BG1 tilemap is stored
; (aaaaaa * w$400) (upper bit redundant)
HW_BG1SC: skip 1
; Valid values
!HW_BGSC_Size_32x32 = %00000000
!HW_BGSC_Size_64x32 = %00000001
!HW_BGSC_Size_32x64 = %00000010
!HW_BGSC_Size_64x64 = %00000011
; === $002108 ===
; 1 byte
; BG2 tilemap data location in VRAM, and background size
; aaaaaass
; ||||||++ BG2 size
; ++++++-- VRAM address where BG2 tilemap is stored
; (aaaaaa * w$400) (upper bit redundant)
HW_BG2SC: skip 1
; Valid values
!HW_BGSC_Size_32x32 = %00000000
!HW_BGSC_Size_64x32 = %00000001
!HW_BGSC_Size_32x64 = %00000010
!HW_BGSC_Size_64x64 = %00000011
; === $002109 ===
; 1 byte
; BG3 tilemap data location in VRAM, and background size
; aaaaaass
; ||||||++ BG3 size
; ++++++-- VRAM address where BG3 tilemap is stored
; (aaaaaa * w$400) (upper bit redundant)
HW_BG3SC: skip 1
; Valid values
!HW_BGSC_Size_32x32 = %00000000
!HW_BGSC_Size_64x32 = %00000001
!HW_BGSC_Size_32x64 = %00000010
!HW_BGSC_Size_64x64 = %00000011
; === $00210A ===
; 1 byte
; BG4 tilemap data location in VRAM, and background size
; aaaaaass
; ||||||++ BG4 size
; ++++++-- VRAM address where BG4 tilemap is stored
; (aaaaaa * w$400) (upper bit redundant)
HW_BG4SC: skip 1
; Valid values
!HW_BGSC_Size_32x32 = %00000000
!HW_BGSC_Size_64x32 = %00000001
!HW_BGSC_Size_32x64 = %00000010
!HW_BGSC_Size_64x64 = %00000011
; === $00210B ===
; 1 byte
; BG1 & BG2 character data location in VRAM
; 22221111
; ||||++++ Location of character data for BG1
; |||| (1111 * w$1000) (upper bit redundant)
; ++++---- Location of character data for BG2
; (2222 * w$1000) (upper bit redundant)
HW_BG12NBA: skip 1
; === $00210C ===
; 1 byte
; BG3 & BG4 character data location in VRAM
; 44443333
; ||||++++ Location of character data for BG3
; |||| (3333 * w$1000) (upper bit redundant)
; ++++---- Location of character data for BG4
; (4444 * w$1000) (upper bit redundant)
HW_BG34NBA: skip 1
; === $00210D ===
; 1 byte
; horizontal scroll value of BG1
; WRITE TWICE
; 1st write = lower 8 bits of the scroll value
; 2nd write = upper 2 (or upper 5) bits of the scroll value
HW_BG1HOFS: skip 1
; === $00210E ===
; 1 byte
; vertical scroll value of BG1
; WRITE TWICE
; 1st write = lower 8 bits of the scroll value
; 2nd write = upper 2 (or upper 5) bits of the scroll value
HW_BG1VOFS: skip 1
; === $00210F ===
; 1 byte
; horizontal scroll value of BG2
; WRITE TWICE
; 1st write = lower 8 bits of the scroll value
; 2nd write = upper 2 bits of the scroll value
HW_BG2HOFS: skip 1
; === $002110 ===
; 1 byte
; vertical scroll value of BG2
; WRITE TWICE
; 1st write = lower 8 bits of the scroll value
; 2nd write = upper 2 bits of the scroll value
HW_BG2VOFS: skip 1
; === $002111 ===
; 1 byte
; horizontal scroll value of BG3
; WRITE TWICE
; 1st write = lower 8 bits of the scroll value
; 2nd write = upper 2 bits of the scroll value
HW_BG3HOFS: skip 1
; === $002112 ===
; 1 byte
; vertical scroll value of BG3
; WRITE TWICE
; 1st write = lower 8 bits of the scroll value
; 2nd write = upper 2 bits of the scroll value
HW_BG3VOFS: skip 1
; === $002113 ===
; 1 byte
; horizontal scroll value of BG4
; WRITE TWICE
; 1st write = lower 8 bits of the scroll value
; 2nd write = upper 2 bits of the scroll value
HW_BG4HOFS: skip 1
; === $002114 ===
; 1 byte
; vertical scroll value of BG4
; WRITE TWICE
; 1st write = lower 8 bits of the scroll value
; 2nd write = upper 2 bits of the scroll value
HW_BG4VOFS: skip 1
; === $002115 ===
; 1 byte
; VRAM address increment options
; controls how HW_VDADD changes as VRAM is accessed
; i---ggvv
; | ||++ how much to increment by each access
; | || (useful for tilemaps)
; | ++-- address remapping
; | (useful for character data)
; +------- 0 = increment on low byte access
; 1 = increment on high byte access
HW_VMAINC: skip 1
; Valid values
!HW_VINC_IncBy1 = %00000000
!HW_VINC_IncBy32 = %00000001
!HW_VINC_IncBy128 = %00000010
!HW_VINC_IncBy8_32 = %00000100
!HW_VINC_IncBy8_64 = %00001000
!HW_VINC_IncBy8_128 = %00001100
!HW_VINC_IncOnLo = %00000000
!HW_VINC_IncOnHi = %10000000
; === $002116 ===
; 2 bytes
; Word address for VRAM access
HW_VMADD: skip 2
; === $002118 ===
; 2 bytes
; VRAM data for write only
HW_VMDATA: skip 2
; === $00211A ===
; 1 byte
; Background mode 7 display options
; ss----vh
; || |+ flip the screen horizontally
; || +- flip the screen vertically
; ++------ how to process tilemap out of bounds
HW_M7SEL: skip 1
; Valid values
!HW_M7SEL_Repeat = %00000000
!HW_M7SEL_Color = %10000000
!HW_M7SEL_Tile0 = %11000000
; === $00211B ===
; 1 byte
; A 16-bit value to be multiplied with 8-bit value in MPYB
; this multiplication is very fast since it uses the mode 7 hardware
; WRITE TWICE
; 1st write = lower 8 bits of the value
; 2nd write = upper 8 bits of the value
HW_MPYA:
; === $00211B ===
; 1 byte
; the value of the A parameter for the mode 7 transformation matrix
; WRITE TWICE
; 1st write = lower 8 bits of the parameter value
; 2nd write = upper 8 bits of the parameter value
HW_M7A: skip 1
; === $00211C ===
; 1 byte
; An 8-bit value to be multiplied with 16-bit value in MPYA
; this multiplication is very fast since it uses the mode 7 hardware
HW_MPYB:
; === $00211C ===
; 1 byte
; the value of the B parameter for the mode 7 transformation matrix
; WRITE TWICE
; 1st write = lower 8 bits of the parameter value
; 2nd write = upper 8 bits of the parameter value
HW_M7B: skip 1
; === $00211D ===
; 1 byte
; the value of the C parameter for the mode 7 transformation matrix
; WRITE TWICE
; 1st write = lower 8 bits of the parameter value
; 2nd write = upper 8 bits of the parameter value
HW_M7C: skip 1
; === $00211E ===
; 1 byte
; the value of the D parameter for the mode 7 transformation matrix
; WRITE TWICE
; 1st write = lower 8 bits of the parameter value
; 2nd write = upper 8 bits of the parameter value
HW_M7D: skip 1
; === $00211F ===
; 1 byte
; the horizontal co-ordinate of the mode 7 fixed point
; WRITE TWICE
; 1st write = lower 8 bits of the parameter value
; 2nd write = upper 5 bits of the parameter value
HW_M7X: skip 1
; === $002120 ===
; 1 byte
; the vertical co-ordinate of the mode 7 fixed point
; WRITE TWICE
; 1st write = lower 8 bits of the parameter value
; 2nd write = upper 5 bits of the parameter value
HW_M7Y: skip 1
; === $002121 ===
; 1 byte
; Word address for CGRAM access
HW_CGADD: skip 1
; === $002122 ===
; 1 byte
; CGRAM data for write only
; WRITE TWICE
; 1st write = lower 8 bits of the data
; 2nd write = upper 7 bits of the data
HW_CGDATA: skip 1
; === $002123 ===
; 1 byte
; window selection settings for BG1 and BG2
; 2i1i2i1i
; |||||||+ BG1, in/out bit for window 1
; ||||||+- BG1, enable bit for window 1
; |||||+-- BG1, in/out bit for window 2
; ||||+--- BG1, enable bit for window 2
; |||+---- BG2, in/out bit for window 1
; ||+----- BG2, enable bit for window 1
; |+------ BG2, in/out bit for window 2
; +------- BG2, enable bit for window 2
HW_W12SEL: skip 1
; Valid values
!HW_WSEL_BG1_W1_IO = %00000001
!HW_WSEL_BG1_W1_En = %00000010
!HW_WSEL_BG1_W2_IO = %00000100
!HW_WSEL_BG1_W2_En = %00001000
!HW_WSEL_BG2_W1_IO = %00010000
!HW_WSEL_BG2_W1_En = %00100000
!HW_WSEL_BG2_W2_IO = %01000000
!HW_WSEL_BG2_W2_En = %10000000
; === $002124 ===
; 1 byte
; window selection settings for BG3 and BG4
; 2i1i2i1i
; |||||||+ BG3, in/out bit for window 1
; ||||||+- BG3, enable bit for window 1
; |||||+-- BG3, in/out bit for window 2
; ||||+--- BG3, enable bit for window 2
; |||+---- BG4, in/out bit for window 1
; ||+----- BG4, enable bit for window 1
; |+------ BG4, in/out bit for window 2
; +------- BG4, enable bit for window 2
HW_W34SEL: skip 1
; Valid values
!HW_WSEL_BG3_W1_IO = %00000001
!HW_WSEL_BG3_W1_En = %00000010
!HW_WSEL_BG3_W2_IO = %00000100
!HW_WSEL_BG3_W2_En = %00001000
!HW_WSEL_BG4_W1_IO = %00010000
!HW_WSEL_BG4_W1_En = %00100000
!HW_WSEL_BG4_W2_IO = %01000000
!HW_WSEL_BG4_W2_En = %10000000
; === $002125 ===
; 1 byte
; window selection settings for OBJ and color window
; 2i1i2i1i
; |||||||+ OBJ, in/out bit for window 1
; ||||||+- OBJ, enable bit for window 1
; |||||+-- OBJ, in/out bit for window 2
; ||||+--- OBJ, enable bit for window 2
; |||+---- color window, in/out bit for window 1
; ||+----- color window, enable bit for window 1
; |+------ color window, in/out bit for window 2
; +------- color window, enable bit for window 2
HW_WOBJSEL: skip 1
; Valid values
!HW_WSEL_OBJ_W1_IO = %00000001
!HW_WSEL_OBJ_W1_En = %00000010
!HW_WSEL_OBJ_W2_IO = %00000100
!HW_WSEL_OBJ_W2_En = %00001000
!HW_WSEL_Color_W1_IO = %00010000
!HW_WSEL_Color_W1_En = %00100000
!HW_WSEL_Color_W2_IO = %01000000
!HW_WSEL_Color_W2_En = %10000000
; === $002126 ===
; 1 byte
; horizontal position of the left side of window 1
HW_WH0: skip 1
; === $002127 ===
; 1 byte
; horizontal position of the right side of window 1
HW_WH1: skip 1
; === $002128 ===
; 1 byte
; horizontal position of the left side of window 2
HW_WH2: skip 1
; === $002129 ===
; 1 byte
; horizontal position of the right side of window 2
HW_WH3: skip 1
; === $00212A ===
; 1 byte
; window intersection logic for BG1, BG2, BG3, BG4
; 44332211
; ||||||++ intersection logic for BG1
; ||||++-- intersection logic for BG2
; ||++---- intersection logic for BG3
; ++------ intersection logic for BG4
HW_WBGLOG: skip 1
; Valid values
!HW_WLOG_OR = %00
!HW_WLOG_AND = %01
!HW_WLOG_XOR = %10
!HW_WLOG_XNOR = %11
; === $00212B ===
; 1 byte
; window intersection logic for OBJ and color window
; ----ccoo
; ||++ intersection logic for OBJ
; ++-- intersection logic for color window
HW_WOBJLOG: skip 1
; Valid values
!HW_WLOG_OR = %00
!HW_WLOG_AND = %01
!HW_WLOG_XOR = %10
!HW_WLOG_XNOR = %11
; === $00212C ===
; 1 byte
; background layers to enable on the main screen
; ----o4321
; ||||+ enable BG1
; |||+- enable BG2
; ||+-- enable BG3
; |+--- enable BG4
; +---- enable OBJ
HW_TM: skip 1
; Valid values
!HW_Through_None = %00000
!HW_Through_BG1 = %00001
!HW_Through_BG2 = %00010
!HW_Through_BG3 = %00100
!HW_Through_BG4 = %01000
!HW_Through_OBJ = %10000
; === $00212D ===
; 1 byte
; background layers to enable on the sub screen
; ----o4321
; ||||+ enable BG1
; |||+- enable BG2
; ||+-- enable BG3
; |+--- enable BG4
; +---- enable OBJ
HW_TS: skip 1
; Valid values
!HW_Through_None = %00000
!HW_Through_BG1 = %00001
!HW_Through_BG2 = %00010
!HW_Through_BG3 = %00100
!HW_Through_BG4 = %01000
!HW_Through_OBJ = %10000
; === $00212E ===
; 1 byte
; background layers to enable on the main screen window
; ----o4321
; ||||+ enable BG1
; |||+- enable BG2
; ||+-- enable BG3
; |+--- enable BG4
; +---- enable OBJ
HW_TMW: skip 1
; Valid values
!HW_Through_None = %00000
!HW_Through_BG1 = %00001
!HW_Through_BG2 = %00010
!HW_Through_BG3 = %00100
!HW_Through_BG4 = %01000
!HW_Through_OBJ = %10000
; === $00212F ===
; 1 byte
; background layers to enable on the sub screen window
; ----o4321
; ||||+ enable BG1
; |||+- enable BG2
; ||+-- enable BG3
; |+--- enable BG4
; +---- enable OBJ
HW_TSW: skip 1
; Valid values
!HW_Through_None = %00000
!HW_Through_BG1 = %00001
!HW_Through_BG2 = %00010
!HW_Through_BG3 = %00100
!HW_Through_BG4 = %01000
!HW_Through_OBJ = %10000
; === $002130 ===
; 1 byte
; color math enable and selection switch
; mmss--fd
; |||| |+ set if direct color is enabled
; |||| +- set for color math between subscreens, clear for fixed color math
; ||++---- color window sub screen
; ++------ color window main screen
HW_CGSWSEL: skip 1
; Valid values
!HW_CGSW_DirectColor = %00000001
!HW_CGSW_FixedColor = %00000010
!HW_CGSW_CW_On = %00
!HW_CGSW_CW_In = %01
!HW_CGSW_CW_Out = %10
!HW_CGSW_CW_Off = %11
; === $002131 ===
; 1 byte
; color math settings
; shbo4321
; ||++++++ set if BG1/BG2/BG3/BG4/OBJ/back color should participate in color math
; |+------ set if color math result should be halved (e.g. average)
; +------- set if subtract subscreens, else add
HW_CGADSUB: skip 1
; Valid values
!HW_CMath_BG1 = %00000001
!HW_CMath_BG2 = %00000010
!HW_CMath_BG3 = %00000100
!HW_CMath_BG4 = %00001000
!HW_CMath_OBJ = %00010000
!HW_CMath_Back = %00100000
!HW_CMath_Half = %01000000
!HW_CMath_Sub = %10000000
; === $002132 ===
; 1 byte
; the constant fixed color
; bgrvvvvv
; |||+++++ the value of the color component
; ||+----- write the value to the red component
; |+------ write the value to the green component
; +------- write the value to the blue component
HW_COLDATA: skip 1
; Valid values
!HW_COL_Red = %00100000
!HW_COL_Green = %01000000
!HW_COL_Blue = %10000000
; === $002133 ===
; 1 byte
; various technical screen options
; sx--hovi
; || |||+ enable interlace mode
; || ||+- interlace OBJ
; || |+-- enable overscan
; || +--- enable pseudo h512 mode
; |+------ external background via mode 7
; +------- external synchronization (not used)
HW_SETINI: skip 1
; Valid values
!HW_INI_Interlace = %00000001
!HW_INI_ObjVert = %00000010
!HW_INI_Overscan = %00000100
!HW_INI_PseudoH512 = %00001000
!HW_INI_ExtBG = %01000000
!HW_INI_ExtSync = %10000000
; === $002134 ===
; 3 bytes
; The 24-bit product of multiplication via MPYA and MPYB
; this multiplication is very fast since it uses the mode 7 hardware
HW_MPY: skip 3
; === $002137 ===
; 1 byte
; Register to latch the horizontal and vertical counter
; values OPHCT & OPVCT via software
; No data is read
HW_SLHV: skip 1
; === $002138 ===
; 1 byte
; OAM data for read only
; READ TWICE
; 1st read = lower 8 bits of the data
; 2nd read = upper 8 bits of the data
HW_ROAMDATA: skip 1
; === $002139 ===
; 2 bytes
; VRAM data for read only
HW_RVMDATA: skip 2
; === $00213B ===
; 1 byte
; CGRAM data for read only
; READ TWICE
; 1st read = lower 8 bits of the data
; 2nd read = upper 7 bits of the data
HW_RCGDATA: skip 1
; === $00213C ===
; 1 byte
; horizontal counter value
; latched via software at SLHV, or via hardware port 2 programmable I/O
; READ TWICE
; 1st read = lower 8 bits of the data
; 2nd read = upper 1 bit of the data
HW_OPHCT: skip 1
; === $00213D ===
; 1 byte
; vertical counter value
; latched via software at SLHV, or via hardware port 2 programmable I/O
; READ TWICE
; 1st read = lower 8 bits of the data
; 2nd read = upper 1 bit of the data
HW_OPVCT: skip 1
; === $00213E ===
; 1 byte
; PPU status and version number
; trp-vvvv
; ||| ++++ version number of 5C77 PPU chip
; ||+----- PPU primary/secondary flag
; |+------ set if more than 32 OBJ on one line
; +------- set if more than 34 8x8 OBJ pieces on one line
HW_STAT77: skip 1
; === $00213F ===
; 1 byte
; PPU status and version number
; read this register to clear latch flag and reset OPHCT/OPVCT flip flops
; fl-rvvvv
; || |++++ version number of 5C78 PPU chip
; || +---- region (0=NTSC, 1=PAL)
; |+------ external latch activated flag (OPVCT/OPHCT)
; +------- parity of interlace field
HW_STAT78: skip 1
; === $002140 ===
; 1 byte
; SPC700 I/O port 0
; Communicates with ARAM address $00F4
HW_APUIO0: skip 1
; === $002141 ===
; 1 byte
; SPC700 I/O port 1
; Communicates with ARAM address $00F5
HW_APUIO1: skip 1
; === $002142 ===
; 1 byte
; SPC700 I/O port 2
; Communicates with ARAM address $00F6
HW_APUIO2: skip 1
; === $002143 ===
; 1 byte
; SPC700 I/O port 3
; Communicates with ARAM address $00F7
HW_APUIO3: skip 1
ORG $002180
; === $002180 ===
; 1 byte
; WRAM data for read or write
HW_WMDATA: skip 1
; === $002181 ===
; 3 bytes
; 17-bit address for WRAM access
HW_WMADD: skip 3
ORG $004016
; === $004016 ===
; 1 byte
; Legacy controller port 1 I/O
; READ
; ------ba
; |+ Controller port 1, Data1 line (player 1)
; +- Controller port 1, Data2 line (player 3)
; WRITE
; -------s
; + Strobe both controller ports, latching Data1 and Data2
HW_JOY1: skip 1
; === $004017 ===
; 1 byte
; Legacy controller port 2 I/O
; ------ba
; |+ Controller port 2, Data1 line (player 2)
; +- Controller port 2, Data2 line (player 4)
HW_JOY2: skip 1
ORG $004200
; === $004200 ===
; 1 byte
; special timer enable switches
; n-vh---c
; | || + Enable standard joypad read
; | |+---- Enable IRQ horizontal timer
; | +----- Enable IRQ vertical timer
; +------- Enable NMI interrupt
HW_NMITIMEN: skip 1
; Valid values
!HW_TIMEN_JoyRead = %00000001
!HW_TIMEN_IRQH = %00010000
!HW_TIMEN_IRQV = %00100000
!HW_TIMEN_IRQHV = %00110000
!HW_TIMEN_NMI = %10000000
; === $004201 ===
; 1 byte
; used to write to the programmable I/O lines
; ba------
; |+------ Controller port 1 programmable I/O
; +------- Controller port 2 programmable I/O
; Also connected to external latch
HW_WRIO: skip 1
; === $004202 ===
; 1 byte
; An 8-bit value to be multiplied with 8-bit value in WRMPYB
HW_WRMPYA: skip 1
; === $004203 ===
; 1 byte
; An 8-bit value to be multiplied with 8-bit value in WRMPYA
; After writing, 16-bit product will be available in RDMPY after 8 cycles
HW_WRMPYB: skip 1
; === $004204 ===
; 2 bytes
; A 16-bit value to be divided by 8-bit value in WRDIVB
HW_WRDIV: skip 2
; === $004206 ===
; 1 byte
; An 8-bit value to divide 16-bit value in WRDIVA by
; After writing, 16-bit quotient will be available in RDDIV
; and 16-bit remainder will be available in RDMPY after 16 cycles
HW_WRDIVB: skip 1
; === $004207 ===
; 2 bytes
; horizontal timer value for IRQ interrupt
HW_HTIME: skip 2
; === $004209 ===
; 2 bytes
; vertical timer value for IRQ interrupt
HW_VTIME: skip 2
; === $00420B ===
; 1 byte
; Enable DMA on each of the 8 DMA channels
HW_MDMAEN: skip 1
; Valid values
!Ch0 = %00000001
!Ch1 = %00000010
!Ch2 = %00000100
!Ch3 = %00001000
!Ch4 = %00010000
!Ch5 = %00100000
!Ch6 = %01000000
!Ch7 = %10000000
; === $00420C ===
; 1 byte
; Enable HDMA on each of the 8 DMA channels
HW_HDMAEN: skip 1
; Valid values
!Ch0 = %00000001
!Ch1 = %00000010
!Ch2 = %00000100
!Ch3 = %00001000
!Ch4 = %00010000
!Ch5 = %00100000
!Ch6 = %01000000
!Ch7 = %10000000
; === $00420D ===
; 1 byte
; High speed switch for FastROM
; -------s
; + 0 = 2.68MHz, 1 = 3.58MHz
HW_MEMSEL: skip 1
ORG $004210
; === $004210 ===
; 1 byte
; NMI status and CPU version number
; this register must be read during V-blank
; n---vvvv
; | ++++ CPU version number
; +------- NMI has occurred flag
HW_RDNMI: skip 1
; === $004211 ===
; 1 byte
; IRQ status
; this register must be read during IRQ
; t-------
; +------- IRQ has occurred flag
HW_TIMEUP: skip 1
; === $004212 ===
; 1 byte
; blanking and joypad autoread statuses
; vh-----c
; || + joypad autoread is occurring flag
; |+------ H-blank is occurring flag
; +------- V-blank is occurring flag
HW_HVBJOY: skip 1
; === $004213 ===
; 1 byte
; used to read from the programmable I/O lines
; ba------
; |+------ Controller port 1 programmable I/O
; +------- Controller port 2 programmable I/O
; Also connected to external latch
HW_RDIO: skip 1
; === $004214 ===
; 2 bytes
; 16-bit quotient result from WRDIV and WRDIVB
HW_RDDIV: skip 2
; === $004216 ===
; 2 bytes
; 16-bit product result from WRMPYA and WRMPYB
; 16-bit remainder result from WRDIV and WRDIVB
HW_RDMPY: skip 2
; === $004218 ===
; 2 bytes
; controller data for player 1 (port 1, Data1)
; byetudlraxLRxxxx
; ||||||||||||++++ controller signature
; ||||||||||++---- L and R shoulder buttons
; ||||||||++------ A and X face buttons
; ||||++++-------- up, down, left, and right on dpad
; ||++------------ select and start face buttons
; ++-------------- B and Y face buttons
HW_CNTRL1: skip 2
; === $00421A ===
; 2 bytes
; controller data for player 2 (port 2, Data1)
; byetudlraxLRxxxx
; ||||||||||||++++ controller signature
; ||||||||||++---- L and R shoulder buttons
; ||||||||++------ A and X face buttons
; ||||++++-------- up, down, left, and right on dpad
; ||++------------ select and start face buttons
; ++-------------- B and Y face buttons
HW_CNTRL2: skip 2
; === $00421C ===
; 2 bytes
; controller data for player 3 (port 1, Data2)
; byetudlraxLRxxxx
; ||||||||||||++++ controller signature
; ||||||||||++---- L and R shoulder buttons
; ||||||||++------ A and X face buttons
; ||||++++-------- up, down, left, and right on dpad
; ||++------------ select and start face buttons
; ++-------------- B and Y face buttons
HW_CNTRL3: skip 2
; === $00421E ===
; 2 bytes
; controller data for player 2 (port 2, Data1)
; byetudlraxLRxxxx
; ||||||||||||++++ controller signature
; ||||||||||++---- L and R shoulder buttons
; ||||||||++------ A and X face buttons
; ||||++++-------- up, down, left, and right on dpad
; ||++------------ select and start face buttons
; ++-------------- B and Y face buttons
HW_CNTRL4: skip 2
ORG $004300
; === $004300 ===
; 1 byte
; DMA transfer parameters
; bi-ffmmm
; || ||+++ number of bytes to transfer where
; || ++--- how much to inc/dec A bus address
; |+------ use indirect addressing for HDMA
; +------- direction of transfer (0=A->B, 1=B->A)
HW_DMAPARAM: skip 1
; Valid values
!HW_DMA_1Byte1Addr = %000
!HW_DMA_2Byte2Addr = %001
!HW_DMA_2Byte1Addr = %010
!HW_DMA_4Byte2Addr = %011
!HW_DMA_4Byte4Addr = %100
!HW_DMA_ABusInc = %00000
!HW_DMA_ABusDec = %10000
!HW_DMA_ABusFix = %01000
!HW_DMA_HDMAIndirect = %01000000
!HW_DMA_AtoB = %00000000
!HW_DMA_BtoA = %10000000
; === $004301 ===
; 1 byte
; the register on the B bus to transfer to/from ($0021xx)
HW_DMAREG: skip 1
; === $004302 ===
; 3 bytes
; the 24-bit address on the A bus to transfer from/to
HW_DMAADDR: skip 3
; === $004305 ===
; 2 bytes
; DMA
; the number of bytes to transfer (0 means $10000)
; HDMA
; the effective address of indirect address HDMA table
; (written automatically during transfer)
HW_DMACNT: skip 2
; === $004307 ===
; 1 byte
; the bank of the effective address of indirect address HDMA table
HW_HDMABANK: skip 1
; === $004308 ===
; 2 bytes
; the intermediate address of an HDMA transfer
; (written automatically during transfer)
HW_DMAIDX: skip 2
; === $00430A ===
; 1 byte
; number of lines taken from HDMA table
; (written automatically during transfer)
HW_HDMALINES: skip 1
; DSP REGISTERS
ORG $00
; === $00 ===
; 1 byte
; signed 8-bit voice left channel volume
DSP_VOLL: skip 1