-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathfstloadnew.src
More file actions
209 lines (170 loc) · 3.38 KB
/
fstloadnew.src
File metadata and controls
209 lines (170 loc) · 3.38 KB
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
.page
.subttl 'fstloadnew.src'
fstload jsr spout ; output
lda fastsr ; set flag
ora #1
sta fastsr
jsr set_fil ; setup filename for parser
bcs 6$
lda cmdbuf
cmp #'* ; load last ?
bne 7$
lda prgtrk ; any file ?
bne 1$
7$ lda #0
tay
tax ; clear .x, .y
sta lstdrv ; init drive number
sta filtbl ; set up for file name parser
jsr autoi ; init mechanism
lda nodrv ; chk status
bne 6$ ; no drive status
jsr onedrv ; select drive
lda f2cnt
pha
lda #1
sta f2cnt
lda #$ff
sta r0 ; set flag
jsr lookup ; locate file
pla
sta f2cnt ; restore var
bit switch ; seq flag set ?
bmi 8$
lda pattyp ; is it a program file ?
cmp #2
bne 6$ ; not prg
8$ lda filtrk ; check if found. err if not
bne 1$
6$ ldx #%00000010 ; file not found
jmp fld_err
1$ pha ; save trk
lda #prgtyp
jsr opntyp ; open a internal channel
txa
lsr a ; a/2
sta channel ; save channel off
tax
pla ; restore track
sta hdrs,x ; setup track
lda filsec ; & sector
sta hdrs+1,x
lda #read ; read job
sta cmdbuf+2 ; save read cmd
sta ctl_cmd
2$ cli ; let controller run
ldx channel ; get channel #
lda ctl_cmd ; get cmd
sta jobs,x ; send cmd
jsr stbctr ; whack the controller in the head
cpx #2 ; error ?
bcc 5$
jmp fld_err
5$ sei
ldy #0
lda (dirbuf),y ; check status
beq end_of_file
lda fastsr ; clear flag
and #$fe
sta fastsr
stx ctl_dat ; .x = send status
jsr hskrd
ldy #2
3$ lda (dirbuf),y
sta ctl_dat ; save data
jsr hskrd ; send data to the host
iny
bne 3$
lda (dirbuf),y
cmp hdrs ; same as previous track ?
beq 4$
ldy #read
.byte skip2
4$ ldy #fread ; fast read
sty ctl_cmd ; command to seek then read
ldx channel
sta hdrs,x ; next track
ldy #1 ; sector entry
lda (dirbuf),y
sta hdrs+1,x ; next sector
jmp 2$
end_of_file
ldx #$1f ; eof
stx ctl_dat ; send status
jsr hskrd
lda #1
bit fastsr ; first time through ?
beq 1$
ldy #1
lda (dirbuf),y ; number of bytes
sec
sbc #3
sta ctl_dat ; send it
pha ; save it
jsr hskrd
iny ; next
lda (dirbuf),y ; address low
sta ctl_dat ; send status
jsr hskrd
iny
lda (dirbuf),y ; address high
sta ctl_dat ; send status
jsr hskrd
pla
tax ; # of bytes
ldy #4 ; skip addresses
bne 3$ ; bra
1$ ldy #1
lda (dirbuf),y ; number of bytes
tax
dex
stx ctl_dat ; send it
jsr hskrd
ldy #2 ; start at data
3$ lda (dirbuf),y
sta ctl_dat ; save data
jsr hskrd ; send data to the host
iny
dex
bne 3$
jmp endcmd
fld_err stx ctl_dat ; send error
jsr hskrd
jmp exbad
set_fil ldy #3 ; default .y
lda cmdsiz ; delete burst load command
sec
sbc #3
sta cmdsiz ; new command size
lda cmdbuf+4 ; drv # given ?
cmp #':
bne 1$
lda cmdbuf+3
tax ; save
and #'0
cmp #'0 ; 0:file ?
bne 1$
cpx #'1 ; chk for error
beq 4$
cpx #'0 ; chk for h:jsjsj ... etc
bne 1$
dec cmdsiz ; adjust ...
iny
dec cmdsiz
iny
1$ lda cmdbuf+3 ; drv # given ?
cmp #':
bne 2$
dec cmdsiz
iny
2$ ldx #0 ; start at cmdbuf+0
3$ lda cmdbuf,y ; extract file-name
sta cmdbuf,x
iny
inx
cpx cmdsiz ; done ?
bne 3$ ; delete cmd from buffer
clc
.byte skip1
4$ sec ; error
rts