-
Notifications
You must be signed in to change notification settings - Fork 82
/
opchnl
198 lines (198 loc) · 2.85 KB
/
opchnl
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