-
Notifications
You must be signed in to change notification settings - Fork 85
/
block.src
453 lines (344 loc) · 5.71 KB
/
block.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
446
447
448
449
450
451
452
453
.page
.subttl block
; rom 1.1 additions
; user commands
user ldy cmdbuf+1
cpy #'0'
bne us10 ;0 resets pntr
usrint lda #<ublock ;set default block add
sta usrjmp
lda #>ublock
sta usrjmp+1
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 lstdrv
sta drvnum
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 ;must be less than 13.
bcs ob05
lda #0
sta temp
sta temp+1
sec
ob15 rol temp
rol temp+1
dex
bpl ob15
lda temp
and bufuse
bne ob05 ;buffer is used
lda temp+1
and bufuse+1
bne ob05 ;buf is used
lda temp
ora bufuse ;set buffer as used
sta bufuse
lda temp+1
ora bufuse+1
sta bufuse+1
lda #0 ;set up channel
jsr getrch
ldx lindx
lda filsec
sta buf0,x
tax
lda drvnum
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
.page
; block commands
block ldy #0
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
bctab .byte 'AFRWEP'
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
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
; 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 #$0f
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
dectab .byte 1,10,100 ;decimal table
; block-free
blkfre jsr blktst
jsr frets
jmp endcmd
; block-allocate
lda #1
sta wbam
blkalc jsr blktst
ba10 lda sector
pha
jsr getsec
beq ba15 ;none greater on this track
pla
cmp sector
bne ba30 ;requested sector not avail
jsr wused
jmp endcmd
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
; block read
blkrd3 jsr blkrd2
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
ublkrd jsr blkpar
jsr blkrd3
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
bw20 jsr drtwrt ;write block
pla
tax
;##### GCB 11/20/86 Block Read fix ############################
; jsr rnget2
jsr ptch25 ;7/87 FAB fixed the fix
;###############################################################
jmp endcmd
; user dirct write, no lstchr
ublkwt jsr blkpar
jsr bkotst
jsr drtwrt
jmp endcmd
; in vector.src:
;
; * = $fffa-6 ;user direct access
;
;ublock .word ublkrd
; .word ublkwt
; block-execute
blkexc jsr killp ;kill protect
jsr blkrd2 ;read block & execute
lda #0
be05 sta temp
ldx jobnum
lda bufind,x
sta temp+1
jsr be10 ;indirect jsr
jmp endcmd
be10 jmp (temp)
; buffer-pointer, set buffer pointer
blkptr jsr buftst
lda jobnum
asl a
tax
lda filsec+1
sta buftab,x
jsr getpre
jsr rnget2 ;set up get
jmp endcmd
; test for allocated buffer related to sa
buftst ldx f1ptr
inc f1ptr
lda filsec,x
tay
dey
dey
cpy #$0c ;set limit to # of sas
bcc bt20
bt15 lda #nochnl
jmp cmderr
bt20 sta sa
jsr fndrch
bcs bt15
jsr getact
sta jobnum
rts
; test block operation parms
bkotst jsr buftst
; test for legal block & set up drv, trk, sec
blktst ldx f1ptr
lda filsec,x
and #1
sta drvnum
lda filsec+2,x
sta sector
lda filsec+1,x
sta track
bt05 jsr tschk
jmp setlds ;(rts)
; .end
; rsr 1/19/80 add autoi to #cmd