-
Notifications
You must be signed in to change notification settings - Fork 85
/
open
405 lines (405 loc) · 5.73 KB
/
open
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
.PAGE 'OPEN'
;
; OPEN CHANNEL FROM IEEE
; PARSES THE INPUT STRING THAT IS
; SENT AS AN OPEN DATA CHANNEL,
; LOAD, OR SAVE. CHANNELS ARE ALLOCATED
; AND THE DIRECTORY IS SEARCHED FOR
; THE FILENAME CONTAINED IN THE STRING.
;
OPEN
LDA SA
STA TEMPSA
JSR CMDSET ; INITIATE CMD PTRS
STX CMDNUM
LDX CMDBUF
LDA TEMPSA
BNE OP021
CPX #'* ; LOAD LAST?
BNE OP021
LDA PRGTRK
BEQ OP0415 ; NO LAST PROG, INIT 0
OP02
STA TRACK ; LOAD LAST PROGRAM
LDA PRGDRV
STA DRVNUM
STA FILDRV
LDA #PRGTYP
STA PATTYP
LDA PRGSEC
STA SECTOR
JSR OPNRCH
LDA #PRGTYP+PRGTYP
ORA DRVNUM
ENDRD
LDX LINDX
STA FILTYP,Y
JMP ENDCMD
OP021
CPX #'$
BNE OP041
LDA TEMPSA ; LOAD DIRECTORY
BNE OP04
JMP LOADIR
OP04
JSR SIMPRS ; OPEN DIR AS SEQ FILE
LDX DRVNUM
LDA DSTRK,X ; START OF DIRECTORY
STA TRACK
LDA DSSEC,X
STA SECTOR
JSR OPNRCH
LDA DRVNUM
ORA #SEQTYP+SEQTYP
JMP ENDRD
OP041
CPX #'# ; "#" IS DIRECT ACCESS
BNE OP042
JMP OPNBLK
OP0415
LDA #PRGTYP ; PROGRAM TYPE
STA TYPFLG
LDA #0
STA DRVNUM
STA LSTDRV
JSR INITDR
OP042
JSR PRSCLN ; LOOK FOR ":"
BNE OP049
LDX #0
BEQ OP20 ; JUMP
OP049
TXA
BEQ OP10
OP05
LDA #BADSYN ; SOMETHING AMISS
JMP CMDERR
OP10
DEY ; BACK UP TO ":"
BEQ OP20 ; 1ST CHAR IS ":"
DEY
OP20
STY FILTBL ; SAVE FILENAME PTR
LDA #$8D ; LOOK FOR CR-SHIFTED
JSR PARSE
INX
STX F2CNT
JSR ONEDRV
JSR OPTSCH
JSR FFST ; LOOK FOR FILE ENTRY
LDX #0
STX REC
STX MODE ; READ MODE
STX TYPE ; DELETED
INX
CPX F1CNT
BCS OP40 ; NO PARAMETERS
JSR CKTM ; CHECK FOR TYPE & MODE
INX
CPX F1CNT
BCS OP40 ; ONLY ONE PARAMETER
CPY #RELTYP
BEQ OP60 ; SET RECORD SIZE
JSR CKTM ; SET TYPE/MODE
OP40
LDX TEMPSA
STX SA ; SET SA BACK
CPX #2
BCS OP45 ; NOT LOAD OR SAVE
STX MODE ; MODE=SA
LDA TYPE
BNE OP50 ; TYPE FROM PARM
LDA #PRGTYP
STA TYPE ; USE PRG
OP45
LDA TYPE
BNE OP50 ; TYPE FROM PARM
LDA PATTYP
AND #TYPMSK
STA TYPE ; TYPE FROM FILE
LDA FILTRK
BNE OP50 ; YES, IT EXISTS
LDA #SEQTYP
STA TYPE ; DEFAULT IS SEQ
OP50
LDA MODE
CMP #WTMODE
BEQ OP75 ; GO WRITE
JMP OP90
OP60
LDY FILTBL,X ; GET RECORD SIZE
LDA CMDBUF,Y
STA REC
LDA FILTRK
BNE OP40 ; IT'S HERE, READ
LDA #WTMODE ; USE WRITE TO OPEN
STA MODE
BNE OP40 ; JUMP
OP75
LDA PATTYP
AND #$80
TAX
BNE OP81
OP77
LDA #$20 ; OPEN WRITE
BIT PATTYP
BEQ OP80
JSR DELDIR ;CREATED
JMP OPWRIT
OP80
LDA FILTRK
BNE OP81
JMP OPWRIT ; NOT FOUND, OK!
OP81
LDA CMDBUF
CMP #'@ ; CHECK FOR REPLACE
BEQ OP82
TXA
BNE OP815
LDA #FLEXST
JMP CMDERR
OP815
LDA #BADFN
JMP CMDERR
OP82
LDA PATTYP ; REPLACE
AND #TYPMSK
CMP TYPE
BNE OP115
CMP #RELTYP
BEQ OP115
JSR OPNWCH
LDA LINDX
STA WLINDX
LDA #IRSA ; INTERNAL CHAN
STA SA
JSR FNDRCH
LDA INDEX
JSR SETPNT
LDY #0
LDA (DIRBUF),Y
ORA #$20 ; SET REPLACE BIT
STA (DIRBUF),Y
LDY #26
LDA TRACK
STA (DIRBUF),Y
INY
LDA SECTOR
STA (DIRBUF),Y
LDX WLINDX
LDA ENTSEC
STA DSEC,X
LDA ENTTRK
STA DTRK,X
LDA ENTIND
STA DIND,X
JSR CURBLK
JSR DRTWRT
JMP OPFIN
OP90
LDA FILTRK ; OPEN READ (& LOAD)
BNE OP100
OP95
LDA #FLNTFD ; TRACK NOT RECORDED
JMP CMDERR ; NOT FOUND
OP100
LDA MODE
CMP #MDMODE
BEQ OP110
LDA #$20
BIT PATTYP
BEQ OP110
LDA #FILOPN
JMP CMDERR
OP110
LDA PATTYP
AND #TYPMSK ; TYPE IS IN INDEX TABLE
CMP TYPE
BEQ OP120
OP115
LDA #MISTYP ; TYPE MISMATCH
JMP CMDERR
OP120
LDY #0
STY F2PTR
LDX MODE
CPX #APMODE
BNE OP125
CMP #RELTYP
BEQ OP115
LDA (DIRBUF),Y
AND #$4F
STA (DIRBUF),Y
LDA SA
PHA
LDA #IRSA
STA SA
JSR CURBLK
JSR DRTWRT
PLA
STA SA
OP125
JSR OPREAD
LDA MODE
CMP #APMODE
BNE OPFIN
JSR APPEND
JMP ENDCMD
OPREAD
LDY #19
LDA (DIRBUF),Y
STA TRKSS
INY
LDA (DIRBUF),Y
STA SECSS
INY
LDA (DIRBUF),Y
LDX REC
STA REC
TXA
BEQ OP130
CMP REC
BEQ OP130
LDA #NOREC
JSR CMDERR
OP130
LDX F2PTR
LDA FILTRK,X
STA TRACK
LDA FILSEC,X
STA SECTOR
JSR OPNRCH
LDY LINDX ; OPEN A READ CHNL
LDX F2PTR
LDA ENTSEC,X
STA DSEC,Y
LDA ENTTRK,X
STA DTRK,Y
LDA ENTIND,X
STA DIND,Y
RTS
OPWRIT
LDA FILDRV
AND #1
STA DRVNUM
JSR OPNWCH
JSR ADDFIL ; ADD TO DIRECTORY
OPFIN
LDA SA
CMP #2
BCS OPF1
JSR GETHDR
LDA TRACK
STA PRGTRK
LDA DRVNUM
STA PRGDRV
LDA SECTOR
STA PRGSEC
OPF1
JMP ENDCMD
CKTM
LDY FILTBL,X ; GET PTR
LDA CMDBUF,Y ; GET CHAR
LDY #NMODES
CKM1
DEY
BMI CKM2 ; NO VALID MODE
CMP MODLST,Y
BNE CKM1
STY MODE ; MODE FOUND
CKM2
LDY #NTYPES
CKT1
DEY
BMI CKT2 ; NO VALID TYPE
CMP TPLST,Y
BNE CKT1
STY TYPE ; TYPE FOUND
CKT2
RTS
APPEND
JSR GCBYTE
LDA #LRF
JSR TSTFLG
BEQ APPEND
JSR RDLNK
LDX SECTOR
INX
TXA
BNE AP30
JSR WRT0 ;GET ANOTHER BLOCK
LDA #2
AP30
JSR SETPNT
LDX LINDX
LDA #RDYLST
STA CHNRDY,X
LDA #$80 ;CHNL BIT
ORA LINDX
LDX SA
STA LINTAB,X
RTS
;
; LOAD DIRECTORY
;
LOADIR
LDA #LDCMD
STA CMDNUM
LDX CMDSIZ
DEX
BNE LD01
LDA #'* ; LOAD BOTH DIRECTORIES
STA CMDBUF
LDA #$80
STA PATTYP
ORA LSTDRV
STA FILDRV
INC F1CNT
INC F2CNT
BNE LD10 ; JUMP
LD01
DEX ; LOAD BY NAME
BNE LD03
LDA CMDBUF+1
JSR TST0V1
BMI LD03
LD02
AND #1 ; LOAD ONE DIR
STA FILDRV
INC F1CNT
INC F2CNT
INC FILTBL
LDA #$80
STA PATTYP
LDA #'*
STA CMDBUF+1
BNE LD10 ; JUMP
LD03
JSR PRSCLN
BNE LD05 ; FOUND ":"
JSR CMDRST
LDY #3
LD05
DEY
DEY
STY FILTBL
JSR TC35 ; PARSE & SET TABLES
JSR FS1SET
JSR ALLDRS
LD10
JSR OPTSCH ; NEW DIRECTORY
JSR NEWDIR
JSR FFST
LD20
JSR STDIR ; START DIRECTORY
JSR GETBYT ; SET 1ST BYTE
LDX LINDX
STA CHNDAT,X
LDA DRVNUM
STA LSTDRV
ORA #4
STA FILTYP,X
LDA #0
STA BUFTAB+CBPTR
RTS
.END