-
Notifications
You must be signed in to change notification settings - Fork 82
/
blk.src
445 lines (372 loc) · 9.75 KB
/
blk.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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
.messg "blk"
.subttl "blk"
.page
; user commands
user ldy cmdbuf+1
cpy #'0
bne us10 ; 0 resets pntr
lda cmdsiz ; check command size
cmp #3
bcc usrint
sei
lda cmdbuf+2 ; get command
sta switch ; save info
and #$1f
tax ; command info
asl a
tay
lda cmdtbb,y
sta ip
lda cmdtbb+1,y
sta ip+1
jsr setlds ; set leds
lda fsflag ; clear clock bit
and #all-clkin
sta fsflag
jsr burst_doit
jmp endcmd
burst_doit
jmp (ip)
usrint
lda #<ublock ; set default block add
sta usrjmp
lda #>ublock
sta usrjmp+1
unused rts
us10
jsr usrexc ; execute code by table
jmp endcmd
usrexc
dey ; entry is (((index-1)and$f)*2)
tya
and #$f
asl a
tay
lda (usrjmp),y
sta ip
iny
lda (usrjmp),y
sta ip+1
jmp (ip)
.page
; open direct access buffer
; from open "#"
opnblk lda sa ; sa is destroyed by this patch
pha
jsr autoi ; init disk for proper channel assignment
pla ; restore sa
sta sa
ldx cmdsiz
dex
bne ob10
lda #1 ; get any buffer
jsr getrch
jmp ob30
ob05 lda #nochnl
jmp cmderr
ob10 ldy #1 ; buffer # is requested
jsr bp05
ldx filsec
cpx #bfcnt+1 ; must be less than or equal to buffer count
bcs ob05
lda #0
sta temp
sec
ob15 rol temp
dex
bpl ob15
lda temp
and bufuse
bne ob05 ; buffer is used
lda temp
ora bufuse ; set buffer as used
sta bufuse
lda #0 ; set up channel
jsr getrch
ldx lindx
lda filsec
sta buf0,x
tax
lda #0
sta jobs,x
sta lstjob,x
ob30 ldx sa
lda lintab,x ; set lindx table
ora #$40
sta lintab,x
ldy lindx
lda #$ff
sta lstchr,y
lda #rndrdy
sta chnrdy,y ; set channel ready
lda buf0,y
sta chndat,y ; buffer # as 1st char
asl a
tax
lda #1
sta buftab,x
lda #dirtyp+dirtyp
sta filtyp,y ; set direct file type
jmp endcmd
block ldy #0 ; block commands
ldx #0
lda #'- ; separates cmd from subcmd
jsr parse ; locate sub-cmd
bne blk40
blk10 lda #badcmd
jmp cmderr
blk30 lda #badsyn
jmp cmderr
blk40 txa
bne blk30
ldx #nbcmds-1 ; find command
lda cmdbuf,y
blk50 cmp bctab,x
beq blk60
dex
bpl blk50
bmi blk10
blk60 txa
ora #$80
sta cmdnum
jsr blkpar ; parse parms
lda cmdnum
asl a
tax
lda bcjmp+1,x
sta temp+1
lda bcjmp,x
sta temp
jmp (temp) ; goto command
blkpar ldy #0 ; parse block parms
ldx #0
lda #':
jsr parse
bne bp05 ; found ":"
ldy #3 ; else char #3 is beginning
bp05 lda cmdbuf,y
cmp #' '
beq bp10
cmp #29 ; skip character
beq bp10
cmp #',
bne bp20
bp10 iny
cpy cmdsiz
bcc bp05
rts ; that's all
bp20 jsr aschex
inc f1cnt
ldy f2ptr
cpx #mxfils-1
bcc bp10
bcs blk30 ; bad syntax
.pag
; convert ascii to hex (binary)
; & store conversion in tables
; .y= ptr into cmdbuf
aschex lda #0
sta temp
sta temp+1
sta temp+3
ldx #$ff
ah10 lda cmdbuf,y ; test for dec #
cmp #$40
bcs ah20 ; non-numeric terminates
cmp #$30
bcc ah20 ; non-numeric
and #$f
pha
lda temp+1 ; shift digits (*10)
sta temp+2
lda temp
sta temp+1
pla
sta temp
iny
cpy cmdsiz
bcc ah10 ; still in string
ah20 sty f2ptr ; convert digits to...
clc ; ...binary by dec table
lda #0
ah30 inx
cpx #3
bcs ah40
ldy temp,x
ah35 dey
bmi ah30
adc dectab,x
bcc ah35
clc
inc temp+3
bne ah35
ah40 pha
ldx f1cnt
lda temp+3
sta filtrk,x ; store result in table
pla
sta filsec,x
rts
.page
dectab .byte 1,10,100 ; decimal table
blkfre jsr autoi ; init if neccessary
jsr blktst ; block-free
jsr frets
jmp endsav
blkalc jsr autoi ; init if neccessary
jsr blktst
lda sector
pha
jsr getsec
beq ba15 ; none greater this trk
pla
cmp sector
bne ba30 ; requested sec not avail
jsr wused
jmp endsav
ba15 pla ; pop stack
ba20 lda #0
sta sector
inc track
lda track
cmp maxtrk
bcs ba40 ; gone all the way
jsr getsec
beq ba20
ba30 lda #noblk
jsr cmder2
ba40 lda #noblk
jsr cmderr ; t=0,s=0 :none left
; block read subs
blkrd2 jsr bkotst ; test parms
jmp drtrd
getsim jsr getpre ; get byte w/o inc
lda (buftab,x)
rts
.pag
; block read
blkrd3 jsr blkrd2
blkrd4 lda #0
jsr setpnt
jsr getsim ; y=lindx
sta lstchr,y
lda #rndrdy
sta chnrdy,y
rts
blkrd jsr blkrd3
jsr rnget1
jmp endcmd
;user direct read, lstchr=$ff
xublkrd jsr xbkotst
jsr drtrd
jsr blkrd4
jmp ublkrd1
ublkrd jsr blkpar
jsr blkrd3
ublkrd1 lda lstchr,y
sta chndat,y
lda #$ff
sta lstchr,y
jmp endcmd ; (rts)
;block-write
blkwt jsr bkotst
jsr getpnt
tay
dey
cmp #2
bcs bw10
ldy #1
bw10 lda #0 ; set record size
jsr setpnt
tya
jsr putbyt
txa
pha
jsr drtwrt ; write block
pla
tax
ldy lindx
jmp blkp4
;user dirct write, no lstchr, no ts check
xublkwt jsr xbkotst
jmp ublkwt1
;user dirct write, no lstchr
ublkwt jsr blkpar
jsr bkotst
ublkwt1 jsr drtwrt
jmp endcmd
.pag
;in .file vector:
blkexc jsr blkrd2 ; read block & execute
lda #0
sta temp
ldx jobnum
lda bufind,x
sta temp+1
jsr be10 ; indirect jsr
jmp endcmd
be10 jmp (temp)
blkptr jsr buftst ; set buffer pointer
lda jobnum
asl a
tax
lda filsec+1
sta buftab,x
jsr getpre
blkp4 jsr rnget2 ; set up get
jmp endcmd
buftst ldx f1ptr ; test allocated buf
inc f1ptr ; ...related to sa
lda filsec,x
tay
dey
dey
cpy #$d ; set limit to # of sas
bcc bt20
bt15 lda #nochnl
jmp cmderr
bt20 sta sa
jsr fndrch
bcs bt15
jsr getact
sta jobnum
rts
bkotst jsr buftst ; test parms
blktst ldx f1ptr ; test legal block and
lda filsec+2,x
sta sector
lda filsec+1,x
sta track
jsr tschk
jmp setlds ; (rts)
xbkotst jsr buftst ; test parms
ldx f1ptr ; set track and sector
lda filsec+2,x
sta sector
lda filsec+1,x
sta track
jsr setlds
lda #bit6
sta jobrtn
rts
allocbuf
ora bufuse
sta bufuse
rts
bctab .byt 'AFRWEP',$d2,$d7,'?','*'
nbcmds =*-bctab
bcjmp
.word blkalc ; block-allocate
.word blkfre ; block-free
.word blkrd ; block-read
.word blkwt ; block-write
.word blkexc ; block-execute
.word blkptr ; block-pointer
.word xublkrd ; user read no tschk
.word xublkwt ; user write no tschk
.word blkme
.word blkwif
blkme lda #$79
jmp errts0
blkwif lda #$7a
jmp errts0