-
Notifications
You must be signed in to change notification settings - Fork 84
/
opnchnl.src
198 lines (198 loc) · 4.75 KB
/
opnchnl.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
.page 'open channel'
; opchnl
;
; open a read chanl with 2 buffers
; will insert sa in lintab
; and inits all pointers.
; relative ss and ptrs are set.
;
opnrch lda #1 ; get one data buffer
jsr getrch
jsr initp ; clear pointers
lda type
pha
asl a
ora drvnum
sta filtyp,x ; set file type
jsr strrd ; read 1st one or two blocks
ldx lindx
lda track
bne or10
;
lda sector
sta lstchr,x ; set last char ptr
or10
pla
cmp #reltyp
bne or30 ; must be sequential stuff
;
ldy sa
lda lintab,y ; set channel as r/w
ora #$40
sta lintab,y
;
;
lda rec
sta rs,x ; set record size
;
jsr getbuf ; get ss buffer
bpl or20
jmp gberr ; no buffer
or20
ldx lindx
sta ss,x
ldy trkss ; set ss track
sty track
ldy secss ; set ss sector
sty sector
jsr seth ; set ss header
jsr rdss ; read it in
jsr watjob
orow
;
ldx lindx
lda #2
sta nr,x ; set for nxtrec
;
lda #0
jsr setpnt ; set first data byte
;
jsr rd40 ; set up 1st record
jmp gethdr ; restore t&s
;
or30
jsr rdbyt ; sequential set up
ldx lindx
sta chndat,x
lda #rdytlk
sta chnrdy,x
rts
;
; initialize variables for open chanl
; lstjob,sets active buffer#,lstchr,
; buffer pointers in buftab=2
;
initp ldx lindx
lda buf0,x
asl a
tay
lda #2
sta buftab,y
lda buf1,x
ora #$80
sta buf1,x
asl a
tay
lda #2
sta buftab,y
lda #0
sta nbkl,x
sta nbkh,x
lda #0
sta lstchr,x
rts
;
;
; open a write chanl with 2 buffers
opnwch jsr intts ; get first track,sector
lda #1
jsr getwch ; get 1 buffers for writing
jsr sethdr ; set up buffer headers
jsr initp ; zropnt
ldx lindx
lda type
pha
asl a
ora drvnum
sta filtyp,x ; set filtyp=seq
pla
cmp #reltyp
beq ow10
lda #rdylst ; active listener
sta chnrdy,x
rts
;
ow10
ldy sa
lda lintab,y
and #$3f
ora #$40
sta lintab,y ; set channel as r/w
;
lda rec
sta rs,x ; set record size
;
jsr getbuf ; get ss buffer
bpl ow20
jmp gberr ; no buffer
ow20
ldx lindx
sta ss,x
jsr clrbuf
;
jsr nxtts
lda track
sta trkss ; save ss t&s
lda sector
sta secss
;
ldx lindx
lda ss,x
jsr seth ; set ss header
lda #0
jsr setssp
lda #0 ; set null link
jsr putss
lda #ssioff+1 ; set last char
jsr putss
lda #0 ; set this ss #
jsr putss
lda rec ; record size
jsr putss
lda track
jsr putss
lda sector
jsr putss
lda #ssioff
jsr setssp
jsr gethdr ; get first t&s
lda track
jsr putss
lda sector
jsr putss
;
jsr wrtss ; write it out
jsr watjob
lda #2
jsr setpnt
;
ldx lindx ; set nr for null buffer
sec
lda #0
sbc rs,x
sta nr,x
;
jsr nulbuf ; null records
jsr nullnk
jsr wrtout
jsr watjob
jsr mapout
jmp orow
;
;*
;*
;***********************
;*
;* putss
;*
;* put byte into side sector
;*
;***********************
;*
;*
putss pha
ldx lindx
lda ss,x
jmp putb1
;
;.end