-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsnes_init.asm
146 lines (116 loc) · 2.48 KB
/
snes_init.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
.macro init_snes
sei
clc
xce
rep #$38
jml clear_everything
.endmacro
; Put cold code in bank 2 to avoid cluttering PRGRAM
.segment "BANK2"
clear_everything:
.a16
.i16
lda #$1FFF
tcs
lda #$0000
tcd
sep #$20
phk
plb
lda #$80
sta $2100 ;Force blank
xba
ldx #$2101
: ;$2101-$210C
sta $00,X
inx
cpx #$210D
bne :-
: ;$210D-$2121
sta $00,X
sta $00,X
inx
cpx #$2121
bne :-
ldx #$2123
: ;$2123-$2133
sta $00,X
inx
cpx #$2134
bne :-
;stz $213E ; wut?
sta $4200 ;$4200 - disable timers, NMI and auto-joy
sta $4016
lda #$FF
sta $4201
lda #$00
ldx #$4207
: sta $00,X
inx
cpx #$420E
bne :-
;lda $4210 ; Who did this and why? NMI is cleared on power/reset, interrupts are also disabled at this point.
;OAM
sta $2102
sta $2103
ldx #$0080
lda #$E0
: sta $2104
sta $2104
stz $2104
stz $2104
dex
bne :-
ldx #$0020
: stz $2104
dex
bne :-
;VRAM
lda #$80
sta $2115 ; increment vram address on writes to $2119
ldx #$0000
stx $2116 ; begin at address $0000 in vram
stx $4305 ; transfer $10000 bytes
ldx #.loword(CONST_ZERO)
lda #^CONST_ZERO
stx $4302 ; source address
sta $4304 ; source bank
ldx #$1809 ; alternate byte writes to $2118/$2119 fixed source
stx $4300
lda #$01
sta $420B
;CGRAM
stz $2121
ldx #$200 ; 512 bytes
stx $4305
ldx #$2208 ; write a byte at a time to $2122 from fixed source
stx $4300
lda #$01
sta $420B
;WRAM
stz $2181 ;set WRAM address to $7E0000
stz $2182
stz $2183
ldx #$8008
stx $4300 ;Set DMA mode to fixed source, byte to $2180
sta $420B ;Begin transfer
;$2183 is incremented after 64KiB has been transfered
nop
sta $420B ;now set the next 64k
;Clear the framebuffer
;ldx #.loword(FRAMEBUFFER)
;lda #^FRAMEBUFFER
;ldy #FRAMEBUFFER_SIZE
ldx #$0000
lda #^FRAMEBUFFER
ldy #$0000
stx $4302
sta $4304
sty $4305
ldx #$8080
stx $4300
lda #$01
sta $420B
jml Entry
CONST_ZERO:
.word $0000