-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathopenchanl.src
266 lines (234 loc) · 6.94 KB
/
openchanl.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
.page
.subttl 'openchannel'
;***************************************
;* chkin -- open channel for input *
;* *
;* the number of the logical file to be*
;* opened for input is passed in .x. *
;* chkin searches the logical file *
;* to look up device and command info. *
;* errors are reported if the device *
;* was not opened for input ,(e.g. *
;* cassette write file), or the logical*
;* file has no reference in the tables.*
;* device 0, (keyboard), and device 3 *
;* (screen), require no table entries *
;* and are handled separate. *
;***************************************
nchkin
jsr lookup ;see if file known
beq jx310 ;yup...
jmp error3 ;no...file not open
jx310
jsr jz100 ;extract file info (returns w/.a=fa & flags set)
beq jx320 ;is keyboard...done.
;
; could be screen, keyboard, or serial
;
cmp #3
beq jx320 ;is screen...done.
bcs jx330 ;is serial...address it
cmp #2
bne opcasi ;open cass for input
jsr aready ;open rs-232 for input
bcs excp1 ;carry set if acia not ready
lda fa
jx320
sta dfltn ;all input comes from here
clc ;good exit
excp1
rts
;
; a serial device has to be a talker
;
jx330
tax ;device # for dflto
jsr ttalk ;tell him to talk
bit status ;anybody home? (case of no devices on bus)
bmi dnpci ;no...
lda sa ;a second?
bpl jx340 ;yes...send it
jsr ttkatn ;no...let go
jmp jx350
jx340
jsr ttksa ;send second
jx350
txa ;restore dev#
bit status ;secondary address sent ok?
bpl jx320 ;yep, done
dnpci
jmp error5 ;input channel device not present
opcasi
ldx sa ;open cass for input
cpx #$60 ;is command a read?
beq jx320 ;yes
jmp error6
.page
;***************************************
;* chkout -- open channel for output *
;* *
;* the number of the logical file to be*
;* opened for output is passed in .x. *
;* chkout searches the logical file *
;* to look up device and command info. *
;* errors are reported if the device *
;* was not opened for input ,(e.g. *
;* keyboard), or the logical file has *
;* reference in the tables. *
;* device 0, (keyboard), and device 3 *
;* (screen), require no table entries *
;* and are handled separate. *
;***************************************
nckout
jsr lookup ;is file in table?
beq ck5 ;yes...
jmp error3 ;no...file not open
ck5
jsr jz100 ;extract table info (returns w/.a=fa & flags set)
bne ck10 ;no...something else.
ck20
jmp error7 ;yes...not output file
;
; could be screen, serial, or tape
;
ck10
cmp #3
beq ck30 ;is screen...done
bcs ck40 ;is serial...address it
cmp #2
bne optapo ;open tape for output
jsr aready ;open rs-232 for output
bcs excp2 ;carry set if acia not ready
lda fa
ck30
sta dflto ;all output goes here
clc ;good exit
excp2
rts
ck40
tax ;save device for dflto
jsr tlistn ;tell him to listen
bit status ;anybody home? (case of no devices on bus)
bmi dnpco ;no...
lda sa ;is there a second?
bpl ck50 ;yes...
jsr tscatn ;no...release lines
bne ck60 ;branch always
ck50
jsr tsecnd ;send second...
ck60
txa
bit status ;speaketh ye?
bpl ck30 ;yep, done
dnpco
jmp error5 ;device not present
optapo
ldx sa ;open tape for output
cpx #$60 ;read?
beq ck20 ;yes...bad!
bne ck30 ;always
.page
;***** tedisk support routines... {state transition} *****
tstkdy
pha ;save .a
stx wrbase ;save .x
ldx #$30 ;starting i/o offset
lda fa ;load file address
cmp #8 ;=8?
beq tstok
nok8 cmp #9 ;=9?
bne notprs
ldx #0 ;must be $fec0
tstok lda #$55 ;write a pattern to cmd channel
sta tedrva-48,x
eor tedrva-48,x ;is it the same
bne notprs
lda tedrvb-48,x ;i tied a status bit hi
and #2
bne notprs ;br, he is blown away
stx usekdy ;store offset into i/o slot
clc ;ok
.byte $24
notprs sec ;sorry not home
ldx wrbase ;restore .x
pla ;restore .a
rts ;45 bytes
patchb lda tedrvc-48,x ;wait for rdy ack to go hi
bpl patchb
bmi ptchbb ;bra
patcha lda #0
sta tedrva-48,x ;clear cmd channel
ptchbb lda #$40
sta tedrvc-48,x ;set dav hi
ldx wrbase ;restor .x
pla ;restore .a for ciout, data for acptr
clc ;ok
rts ;*
patchd sta tedrvc
sta drvc2-48
sta tedrvc-48
dex
stx drva2-48
jmp ptchdd
;this is in the patch area:
;ptchdd inx ;.x=0
; stx drvb2-48
; stx tedrva-48
; rts ;x must = 0 on rts !!!
ttalk
jsr tstkdy ;who do we talk to???
bcc kdy1 ;he's out there
jmp talk ;serial dev.
kdy1 pha ;save (a)data
lda #italk
sta kdycmd
lda usekdy
ora #$40 ;write to kdy
sta usekdy
lda #kcmd1
jmp kdy75 ;finish up
ttkatn
bit usekdy ;do an open in with no sa...
bvs kdy5 ;kdy is pres...do nothing
jmp tkatn ;serial
ttksa
bit usekdy ;do an open in with sa...
bvs kdy3 ;kdy is pres
jmp tksa
kdy3
pha ;save (a) data
; lda sa ; assumne SA in acc from call to TKSA by
NOP ; application. this is an 05 rev recommended
NOP ; by D. Siracusa for compatibility with LOGO, etc.
sta kdycmd
lda #kcmd2
jmp kdy75
tlistn
jsr tstkdy ;do an open out with fa...
bcc kdy4 ;he's out there...
jmp listn
kdy4
pha ;save (a) data
lda #ilstn
sta kdycmd
lda usekdy
ora #$80
sta usekdy
lda #kcmd1 ;tell tedisk to listen
jmp kdy75
tscatn
bit usekdy ;do an open out with no sa...
bmi kdy5
jmp scatn
kdy5
rts ;do nothing for kdy
tsecnd
bit usekdy ;do an open out with sa...
bmi kdy6
jmp secnd
kdy6
pha ;save (a) data
sta kdycmd
lda #kcmd2
jmp kdy75
;end