forked from bazz1tv/snestracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmusicUploader.s
141 lines (117 loc) · 1.71 KB
/
musicUploader.s
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
; SPC upload Routine
; You need to specify a Direct-Page (Zero Page) RAM variable (24-bits)
; to store the address of your Music payloads. Call it spx_binary_loc
; Example upload
.index 16
.accu 8
ldx.w #spx_binary
lda #:spx_binary
stx spx_binary_loc
sta spx_binary_loc+2
.SECTION "MusicUploader"
LoadMusic:
.index 16
; loop until spc is ready
scr_checkready:
lda #$AA
cmp $2140
bne scr_checkready
lda #$BB
cmp $2141
bne scr_checkready
ldy #0
scr_firstblock:
; load spx
lda #$01
sta $2141
lda [spx_binary_loc], y
iny
sta $2142
lda [spx_binary_loc], y
iny
sta $2143
lda #$CC
sta $2140
scr_check2:
cmp $2140
; check for $CC
bne scr_check2
; size bytes -> X
rep #$20
lda [spx_binary_loc], y
tax
sep #$20
iny
iny
lda #$FF
; byte to transfer
REDO:
scr_data_loop:
; switch counter to hi-byte
xba
; load a byte
lda [spx_binary_loc], y
iny
sta $2141
xba ; counter to lobyte
ina
sta $2140
;check port0
scr_check4:
cmp $2140
bne scr_check4
dex
bne scr_data_loop
pha
rep #$20
lda [spx_binary_loc], y
beq scr_terminate
iny
iny
sep #$20
sta $2142
xba
sta $2143
; X has starting address
lda #1 ; non-zero
sta $2141
pla
ina
scr_nz1:
ina
beq scr_nz1
sta $2140
scr_check5:
cmp $2140
bne scr_check5
rep #$20
lda [spx_binary_loc], y
tax
sep #$20
iny
iny
lda #$FF ; reset counter too
bra REDO
scr_terminate:
sep #$20
sta $2141
rep #$20
iny
iny
lda [spx_binary_loc], y
sep #$20
sta $2142
xba
sta $2143
pla
ina
scr_nz2:
ina
beq scr_nz2
sta $2140
scr_check6:
cmp $2140
bne scr_check6
; PROTOCOL COMPLETE.
RTS
.ENDS