-
Notifications
You must be signed in to change notification settings - Fork 3
/
ch376_attic.asm
139 lines (122 loc) · 3.35 KB
/
ch376_attic.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
CH376_READ_FILE
.as
.xl
; check if the selection is a directory or file
LDA SDCARD_PRSNT_MNT
BNE LF_CARDPRESENT
BRL LF_DONE
LF_CARDPRESENT
LDA #0
XBA
LDA SDOS_LINE_SELECT
setal
ASL A ; multiply the line # by 16
ASL A
ASL A
ASL A
STA SDOS_FILE_REC_PTR
setas
; Append to the file path
; find the *
LDX #0
LF_FIND_STAR
INX ; the first character is always '/'
LDA sd_card_dir_string,X
CMP #'*'
BNE LF_FIND_STAR
STZ SDOS_LOOP
LDY #0
LF_COPY_DIR_NAME
LDA [SDOS_FILE_REC_PTR],Y
BEQ LF_NAME_DONE
STA sd_card_dir_string,X
INY
INX
LDA SDOS_LOOP
INC A
STA SDOS_LOOP
CMP #8
BEQ LF_NAME_DONE
BRA LF_COPY_DIR_NAME
LF_NAME_DONE
LDY #8
LDA [SDOS_FILE_REC_PTR],Y
BEQ LF_DIR_DONE
LDA #'.'
STA sd_card_dir_string,X
LF_COPY_EXT
INX
LDA [SDOS_FILE_REC_PTR],Y
STA sd_card_dir_string,X
INY
CPY #11
BNE LF_COPY_EXT
LF_DIR_DONE
LDY #11
LDA [SDOS_FILE_REC_PTR],Y
CMP #$20
BEQ LF_LOAD_FILE
; copy the dir name to sd_card_dir_string
; add slash star
LDA #'/'
STA sd_card_dir_string,X
INX
LDA #'*'
STA sd_card_dir_string,X
INX
LDA #0
STA sd_card_dir_string,X
JML LOAD_DIRECTORY
LF_LOAD_FILE
LDA #0
INX
STA sd_card_dir_string,X
; copy the file size
setal
LDY #12
LDA [SDOS_FILE_REC_PTR],Y
STA SDOS_FILE_SIZE
INY
INY
LDA [SDOS_FILE_REC_PTR],Y
STA SDOS_FILE_SIZE+2
; Copy the data from SD card to this memory location
LDA #<>RAD_FILE_TEMP
STA SDCARD_FILE_PTR
setas
LDA #`RAD_FILE_TEMP
STA SDCARD_FILE_PTR+2
; Load the file pointed to by SDOS_LINE_SELECT
JSL ISDOS_READ_FILE
; clear pattern memory
LDA #0
LDX #0
LF_CLEAR_MEM
STA @lPATTERNS,X
INX
BNE LF_CLEAR_MEM
; load the song
JSL RAD_INIT_PLAYER
; Close the load file display
LF_DONE
setxs
JSL EXIT_FILE
; Display the file name
setxl
LDX #0
LDY #SCREEN_WIDTH * 23 + 50
LF_DISPLAY_FILE_NAME
LDA @lSDOS_FILE_NAME,X
INX
INY
STA [SCREENBEGIN], Y
CMP #0
BNE LF_DISPLAY_FILE_NAME
LDA #0
LF_BLANK
INY
INX
STA [SCREENBEGIN], Y
CPX #20
BNE LF_BLANK
RTL