-
Notifications
You must be signed in to change notification settings - Fork 85
/
tst4
250 lines (250 loc) · 3.53 KB
/
tst4
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
.PAGE 'TST4'
;
; GET NEXT CHAR FROM A CHANNEL
;
GBYTE
JSR FNDRCH
JSR SETLDS
JSR GET
LDX LINDX
LDA CHNDAT,X
RTS
GET
LDX LINDX
JSR TYPFIL ; GET FILE TYPE
BNE GET00 ; NOT A RELATIVE FILE
JMP RDREL
GET00
LDA SA
CMP #$F
BEQ GETERC
LDA CHNRDY,X ; WAS LAST CHAR JUST SENT
AND #EOISND ; JUST SENT EOI
BNE GET1 ; NOPE NOT THIS TIME
JSR TYPFIL
CMP #DIRTYP
BNE GET0 ; NOT DIRECT TYPE
LDA #RNDRDY ; DIRECT FILE REMAINS ACTIVE
STA CHNRDY,X ; TALKER LISTENER NOEOI
JMP RNDGET ; PREPARE THE NEXT CHAR
GET0
LDA #NOTRDY ; LST CHAR SENT, NOT READY
STA CHNRDY,X
RTS
GET1
LDA SA ; TEST IF A LOAD
BEQ GET6 ; IT'S A LOAD SA OF 0
GET2
JSR TYPFIL ; TEST FOR REL FILE
BCC SEQGET ; SEQ FILE CHAR GET
RNDGET
JSR GETPRE ; DIRECT FILE GET
LDA BUFTAB,X
CMP LSTCHR,Y ; UP TO LST CHAR YET
BNE RNGET1 ; NOT YET
LDA #0 ; READ THE WHOLE THING
STA BUFTAB,X ; WRAP PNTR TO 0
RNGET1
INC BUFTAB,X ; GET THE NEXT CHAR
RNGET2
LDA (BUFTAB,X)
RNGET4
STA CHNDAT,Y ; SAVE CHAR IN
LDA BUFTAB,X
CMP LSTCHR,Y
BNE RNGET3
LDA #RNDEOI
STA CHNRDY,Y ; THIS IS LAST CHAR
RNGET3
RTS ; SEND EOI WITH IT
SEQGET
JSR RDBYT ; READ THE NEXT BYTE
GET3
LDX LINDX
STA CHNDAT,X ; STORE IN CHNDAT
RTS
GET6
LDA DIRLST ; TEST IF DIR LSTING
BEQ SEQGET ; NO, ITS NOT
JSR GETDIR ; YES IT IS,GET DIR CHAR
JMP GET3
GETERC
JSR GETPNT
CMP #<ERRBUF-1
BNE GE10
LDA DIRBUF+1
CMP #>ERRBUF
BNE GE10
LDA #CR
STA DATA
JSR ERROFF
LDA #0
JSR ERRTS0
DEC CB+2
LDA #EOIOUT
BNE GE30 ; JUMP
GE10
JSR GETBYT
STA DATA
BNE GE20
GE15
LDA #<ERRBUF-1
JSR SETPNT
LDA #>ERRBUF
STA BUFTAB+1,X
GE20
LDA #RDYTLK
GE30
STA CHNRDY+ERRCHN
LDA DATA
STA CHNDAT+ERRCHN
RTS
;
; READ NEXT BUFFER OF A FILE
; FOLLOW LINKS IN FIRST TWO BYTES
; END OF FILE IF 1ST BYTE = 0
; 2ND CHAR LENGTH
;
NXTBUF
JSR GETACT
ASL A
TAX
LDA #0
STA BUFTAB,X
LDA (BUFTAB,X)
BEQ NXTB1
DEC BUFTAB,X
JMP RDBYT
NXTB1
RTS
;
; DIRECT BLOCK READ
;
DRTRD
LDA #READ
BNE DRT
;
; DIRECT BLOCK WRITE
;
DRTWRT
LDA #WRITE
DRT
ORA DRVNUM
STA CMD
LDA JOBNUM
JSR SETH
LDX JOBNUM
JMP DOIT2
;
; OPEN INTERNAL READ CHANL (SA = 16)
;
OPNIRD
LDA #1
OPNTYP
STA TYPE
LDA #IRSA
STA SA
JSR OPNRCH
LDA #2
JMP SETPNT
;
; OPEN INTERNAL WRITE CHANL (SA = 16)
;
OPNIWR
LDA #IWSA
STA SA
JMP OPNWCH
;
; ALLOCATE NEXT DIRECTORY BLOCK ON 18
; AND MARK AS USED IN BAM
;
NXDRBK
JSR CURBLK
LDA #3
STA TEMP
LDA SECINC
PHA
LDA #3 ; INCR SECTOR BY 3 IN DIRECTORY
STA SECINC
JSR GETHED ; EXTRACT THE HEAD NUMBER
STA TMPHED ; SAVE THE HEAD NUMBER
JSR NXTDS
PLA
STA SECINC
LDA #0
JSR SETPNT
LDA TRACK
JSR PUTBYT
LDA SECTOR
JSR PUTBYT
JSR WRTBUF
JSR WATJOB
LDA #0
JSR SETPNT
NXDB1
JSR PUTBYT
BNE NXDB1 ; CLEAR THE NEW SECTOR
JSR PUTBYT ; TRACK = 0
LDA #$FF
JMP PUTBYT ; SECTOR = 255
;
; .A = NEW PNTR VALUE
;
SETPNT
STA TEMP
JSR GETACT
ASL A
TAX
LDA BUFTAB+1,X
STA DIRBUF+1
LDA TEMP
STA BUFTAB,X
STA DIRBUF
RTS
;
;
; FREE THE INTERNAL CHANL (SA = 16)
;
FREICH
LDA #IRSA
STA SA
JSR FRECHN
LDA #IWSA
STA SA
JMP FRECHN
;
; READ THE ACTIVE BUFFER POINTER
;
GETPNT
JSR GETACT
SETDIR
GP1
ASL A
TAX
LDA BUFTAB+1,X
STA DIRBUF+1
LDA BUFTAB,X
STA DIRBUF
RTS
;
; DIRECT READ BYTE, .A = BYTE # TO READ
;
DRDBYT
STA TEMP+2
JSR GETACT
TAX
LDA BUFIND,X
STA TEMP+3
LDY #0
LDA (TEMP+2),Y
RTS
;
; INDEX TABLE CONTAINING HIGH
; BYTE ADDRESS OF BUFFERS
;
BUFIND
.BYTE $11,$12,$13
.BYTE $20,$21,$22,$23
.BYTE $30,$31,$32,$33
.BYTE $40,$41,$42,$43
.END