forked from mist64/cbmsrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tst4.src
244 lines (244 loc) · 5.53 KB
/
tst4.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
.page 'tst4'
;
; get next char from a chanl
;
gbyte ; get through internal channel
jsr fndrch
jsr setlds
jsr get
ldx lindx
lda chndat,x
rts
;
;
get ldx lindx
jsr typfil ; get file type
bne get00
;
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 ; its a load sa of 0
;
get2 jsr typfil ; tst for rnd file
cmp #4
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
;
; 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 #1
sta temp
lda secinc
pha
lda #3 ; incr sector by 3 in directory
sta secinc
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
jsr putbyt
lda #$ff
jmp putbyt
;
;
; .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
;
; .end