-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathfastld.src
309 lines (255 loc) · 5.57 KB
/
fastld.src
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
.page
.subttl 'fastld.src'
fstload jsr spout ; output
jsr set_fil ; setup filename for parser
bcs 9$
jsr autoi ; init mechanism
lda nodrv ; chk status
bne 9$ ; no drive status
lda fastsr ; set error recovery flag on
ora #$81 ; & eoi flag
sta fastsr
jsr findbuf ; check for buffer availabilty
lda cmdbuf
cmp #'* ; load last ?
bne 7$
lda prgtrk ; any file ?
beq 7$
pha ; save track
lda prgsec
sta filsec ; update
pla
jmp 1$
7$ lda #0
tay
tax ; clear .a, .x, .y
sta lstdrv ; init drive number
sta filtbl ; set up for file name parser
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
lda fastsr
and #$7f ; clr error recovery flag
sta fastsr
bit switch ; seq flag set ?
bmi 8$
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
; lda pattyp ; is it a program file ?
; cmp #2
jsr ptch56 ; *** rom ds 07/15/85 ***
nop ; fill
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
bne 6$ ; not prg
8$ lda filtrk ; check if found. err if not
bne 1$ ; br, file found
6$ ldx #%00000010 ; file not found
.byte skip2
9$ ldx #%00001111 ; no drive
jmp sys_err
1$ sta prgtrk ; save for next
pha ; save track
jsr set_buf ; setup buffer allocation
pla ; get track
ldx channel ; get channel offset
sta hdrs,x ; setup track
lda filsec ; & sector
sta prgsec ; for next time
sta hdrs+1,x
lda #read ; read job
sta cmdbuf+2 ; save read cmd
sta ctl_cmd
2$ cli ; let controller run
ldx jobnum ; get job #
lda ctl_cmd ; get cmd
sta jobs,x ; send cmd
jsr stbctr ; whack the controller in the head
cpx #2 ; error ?
bcc 5$
jmp ctr_err
5$ sei
ldy #0
lda (dirbuf),y ; check status
beq end_of_file
lda fastsr ; clear flag
and #$fe
sta fastsr
jsr handsk ; handshake error to the host
ldy #2
3$ lda (dirbuf),y
tax ; save data in .x
jsr handsk ; handshake it to the host
iny
bne 3$
ldx channel ; jobnum * 2
lda (dirbuf),y ; .y = 0
cmp hdrs,x ; same as previous track ?
beq 4$
ldy #read
.byte skip2
4$ ldy #fread ; fast read
sty ctl_cmd ; command to seek then read
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
jsr handsk ; handshake it to the host
lda #1
bit fastsr ; first time through ?
beq 1$ ; br, nope
tay ; .y = 1
lda (dirbuf),y ; number of bytes
sec
sbc #3
sta ctl_dat ; save it
tax ; send it
jsr handsk ; handshake it to the host
iny ; next
lda (dirbuf),y ; address low
tax
jsr handsk ; handshake it to the host
iny
lda (dirbuf),y ; address high
tax
jsr handsk ; handshake it to the host
ldy #4 ; skip addresses
bne 3$ ; bra
1$ ldy #1
lda (dirbuf),y ; number of bytes
tax
dex
stx ctl_dat ; save here
jsr handsk ; handshake it to the host
ldy #2 ; start at data
3$ lda (dirbuf),y
tax
jsr handsk ; handshake it to the host
iny
dec ctl_dat ; use it as a temp
bne 3$
lda #0
sta sa
jsr close ; close channel (faux)
jmp endcmd
;
;
;
; *************************
; ***** ERROR HANDLER *****
; *************************
ctr_err sei ; no irq's
stx ctl_dat ; save status here
jsr handsk ; handshake it to the host
lda #0
sta sa
jsr close ; close channel (faux)
ldx jobnum
lda ctl_dat ; get error
jmp error ; error out.....
sys_err sei
stx ctl_dat ; save error
ldx #2 ; file not found
jsr handsk ; give it to him
lda #0
sta sa
jsr close ; close channel (faux)
lda ctl_dat ; get error back
cmp #2
beq 1$
lda #nodriv ; no active drive
.byte skip2
1$ lda #flntfd ; file not found
jmp cmderr ; never more...
;
;
;
; *************************************
; ***** FIND INTERNAL READ BUFFER *****
; *************************************
findbuf lda #0
sta sa ; psydo-load
lda #1 ; 1 buffer
jsr getrch ; find a read channel
tax
lda bufind,x ; get buffer
sta dirbuf+1 ; set it up indirect
rts
;
;
;
; **************************************
; ***** SETUP INTERNAL READ BUFFER *****
; **************************************
set_buf lda dirbuf+1 ; index to determine job
sec
sbc #3
sta jobnum ; save in jobnum
asl a
sta channel ; save channel off
lda #0
sta dirbuf ; even page boundary
rts
;
;
;
; *************************************
; ***** FAST LOAD FILENAME PARSER *****
; *************************************
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$
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
handsk ; .x contains data
1$ lda pb ; debounce
cmp pb
bne 1$
and #$ff ; set/clr neg flag
bmi 3$ ; br, attn low
eor fastsr ; wait for state chg
and #4
beq 1$
stx sdr ; send it
lda fastsr
eor #4 ; change state of clk
sta fastsr
lda #8
2$ bit icr ; wait transmission time
beq 2$
rts
3$ jmp ptch30 ; bye-bye the host wants us