-
Notifications
You must be signed in to change notification settings - Fork 84
/
block
414 lines (413 loc) · 5.73 KB
/
block
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
.PAGE 'BLOCK COMMAND'
; ROM 1.1 ADDITIONS
; USER COMMANDS
.SKIP
USER LDY CMDBUF+1
CPY #'0
BNE US10 ;0 RESETS PNTR
.SKIP
USRINT LDA #<UBLOCK ;SET DEFAULT BLOCK ADD
STA USRJMP
LDA #>UBLOCK
STA USRJMP+1
RTS
.SKIP
US10 JSR USREXC ;EXECUTE CODE BY TABLE
JMP ENDCMD
.SKIP
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 'BLOCK COMMANDS'
; OPEN DIRECT ACCESS BUFFER
; FROM OPEN "#"
.SKIP
OPNBLK LDX CMDSIZ
DEX
BNE OB10
.SKI
LDA #1 ;GET ANY BUFFER
JSR GETRCH
JMP OB30
.SKIP
OB05 LDA #NOCHNL
JMP CMDERR
.SKIP
OB10 LDY #1 ;BUFFER # IS REQUESTED
JSR BP05
LDX FILSEC
CPX #BAMJOB ;MUST BE LESS THAN 13.
BCS OB05
.SKI
LDA #0
STA TEMP
STA TEMP+1
SEC
.SKI
OB15
ROL TEMP
ROL TEMP+1
DEX
BPL OB15
.SKI
LDA TEMP
AND BUFUSE
BNE OB05 ;BUFFER IS USED
LDA TEMP+1
AND BUFUSE+1
BNE OB05 ;BUF IS USED
.SKI
LDA TEMP
ORA BUFUSE ;SET BUFFER AS USED
STA BUFUSE
LDA TEMP+1
ORA BUFUSE+1
STA BUFUSE+1
.SKI
LDA #0 ;SET UP CHANNEL
JSR GETRCH
LDX LINDX
LDA FILSEC
STA BUF0,X
.SKI
OB30 LDX SA
LDA LINTAB,X ;SET LINDX TABLE
ORA #$40
STA LINTAB,X
.SKI
LDY LINDX
LDA #$FF
STA LSTCHR,Y
.SKIP
LDA #RNDRDY
STA CHNRDY,Y ;SET CHANNEL READY
.SKIP
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
.SKI
BLK10 LDA #BADCMD
JMP CMDERR
.SKI
BLK30 LDA #BADSYN
JMP CMDERR
.SKI
BLK40 TXA
BNE BLK30
.SKI
LDX #NBCMDS-1 ;FIND COMMAND
LDA CMDBUF,Y
BLK50 CMP BCTAB,X
BEQ BLK60
DEX
BPL BLK50
BMI BLK10
.SKI
BLK60
TXA
ORA #$80
STA CMDNUM
JSR BLKPAR ;PARSE PARMS
.SKI
LDA CMDNUM
ASL A
TAX
LDA BCJMP+1,X
STA TEMP+1
LDA BCJMP,X
STA TEMP
.SKI
JMP (TEMP) ;GOTO COMMAND
.SKI
BCTAB .BYT 'AFRWEP'
NBCMDS =*-BCTAB
.SKIP
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
.SKIP
BLKPAR LDY #0 ;PARSE BLOCK PARMS
LDX #0
LDA #':
JSR PARSE
BNE BP05 ;FOUND ":"
.SKIP
LDY #3 ;ELSE CHAR #3 IS BEGINNING
BP05 LDA CMDBUF,Y
CMP #'
BEQ BP10
.SKI
CMP #29 ;SKIP CHARACTER
BEQ BP10
.SKI
CMP #',
BNE BP20
.SKIP
BP10 INY
CPY CMDSIZ
BCC BP05
.SKIP
RTS ;THAT'S ALL
.SKIP
BP20 JSR ASCHEX
INC F1CNT
LDY F2PTR
CPX #MXFILS-1
BCC BP10
.SKIP
BCS BLK30 ;BAD SYNTAX
.SKIP
; CONVERT ASCII TO HEX (BINARY)
; & STORE CONVERSION IN TABLES
; .Y= PTR INTO CMDBUF
ASCHEX LDA #0
STA TEMP
STA TEMP+1
STA TEMP+3
.SKIP
LDX #$FF
AH10 LDA CMDBUF,Y ;TEST FOR DEC #
CMP #$40
BCS AH20 ;NON-NUMERIC TERMINATES
CMP #$30
BCC AH20 ;NON-NUMERIC
.SKIP
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
.SKIP
AH20 STY F2PTR ;CONVERT DIGITS TO...
CLC ;...BINARY BY DEC TABLE
LDA #0
.SKIP
AH30 INX
CPX #3
BCS AH40
.SKIP
LDY TEMP,X
AH35 DEY
BMI AH30
.SKIP
ADC DECTAB,X
BCC AH35
.SKIP
CLC
INC TEMP+3
BNE AH35
.SKIP
AH40 PHA
LDX F1CNT
LDA TEMP+3
STA FILTRK,X ;STORE RESULT IN TABLE
PLA
STA FILSEC,X
RTS
.SKIP
DECTAB .BYT 1,10,100 ;DECIMAL TABLE
.SKIP
;BLOCK-FREE
BLKFRE JSR BLKTST
JSR FRETS
JMP ENDCMD
.SKIP
;BLOCK-ALLOCATE
BLKALC JSR BLKTST
LDX DRVNUM
LDA IPBM,X
STA BMPNT+1
.SKIP
BA10 JSR AVAIL
BA20 JSR AV2
BCS BA40 ;SEARCH FOR NEXT AVAIL SECTOR
.SKIP
LDX SECTOR
INX
STX SECTOR
STX ERWORD ;SET NOT AVAIL FLAG
CPX R0
BCC BA20
.SKIP
LDA #0
STA SECTOR
LDX TRACK
INX
STX TRACK
CPX #36
BCS BA30
.SKIP
JSR BT05
JMP BA10
.SKIP
BA30 STA TRACK
BA35 LDA #NOBLK
JMP CMDER2
.SKIP
BA40 LDX ERWORD ;FINISHED SEARCH
BNE BA35 ;BLOCK WAS'NT AVAILABLE
.SKIP
JSR USEDTS ;BLOCK AVAIL, SET AS USED
JMP ENDCMD
.SKIP
; BLOCK READ SUBS
BLKRD2 JSR BKOTST ;TEST PARMS
JMP DRTRD
.SKIP
GETSIM JSR GETPRE ;GET BYTE W/O INC
LDA (BUFTAB,X)
RTS
.SKIP
; BLOCK READ
BLKRD3 JSR BLKRD2
LDA #0
JSR SETPNT
JSR GETSIM ;Y=LINDX
.SKIP
STA LSTCHR,Y
LDA #RNDRDY
STA CHNRDY,Y
RTS
BLKRD
JSR BLKRD3
JSR RNGET1
JMP ENDCMD
.SKIP
;USER DIRECT READ, LSTCHR=$FF
UBLKRD
JSR BLKPAR
JSR BLKRD3
LDA LSTCHR,Y
STA CHNDAT,Y
LDA #$FF
STA LSTCHR,Y
JMP ENDCMD ;(RTS)
.SKIP 2
;BLOCK-WRITE
BLKWT JSR BKOTST
.SKIP
JSR GETPNT
TAY
DEY
CMP #2
BCS BW10
LDY #1
.SKIP
BW10 LDA #0 ;SET RECORD SIZE
JSR SETPNT
TYA
JSR PUTBYT
TXA
PHA
.SKIP
BW20 JSR DRTWRT ;WRITE BLOCK
PLA
TAX
JSR RNGET2
JMP ENDCMD
.SKIP
;USER DIRCT WRITE, NO LSTCHR
UBLKWT JSR BLKPAR
JSR BKOTST
JSR DRTWRT
JMP ENDCMD
.SKIP
;IN .FILE VECTOR:
;*=$FFFA-6 ;USER DIRECT ACCESS
;UBLOCK .WORD UBLKRD
; .WORD UBLKWT
.SKIP 2
;BLOCK-EXECUTE
BLKEXC JSR BLKRD2 ;READ BLOCK & EXECUTE
LDA #0
.SKIP
BE05 STA TEMP
LDX JOBNUM
LDA BUFIND,X
STA TEMP+1
JSR BE10 ;INDIRECT JSR
JMP ENDCMD
.SKIP
BE10 JMP (TEMP)
.SKIP 2
;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
.SKIP
;TEST FOR ALLOCATED BUFFER..
; ..RELATED TO SA
BUFTST LDX F1PTR
INC F1PTR
LDA FILSEC,X
TAY
DEY
DEY
CPY #BAMJOB
BCC BT20
.SKIP
BT15 LDA #NOCHNL
JMP CMDERR
.SKIP
BT20 STA SA
JSR FNDRCH
BCS BT15
JSR GETACT
STA JOBNUM
RTS
.SKIP
;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
STA R0
JMP SETLDS ;(RTS)
.SKIP
.END