-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathlccread1.src
238 lines (190 loc) · 5.67 KB
/
lccread1.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
.page
.subttl 'lccread1.src'
;=============================================================
;= 8 = 8 = 8 = 8 = 8 =
;=============================================================
; (5) (3 + 2) (5) (1+ 4) (4 +1) (5) (2 + 3) (5)
; a b c d e f g h
;=============================================================
; read in track,sector specified
; in header
*=*+256-<* ; even page
jdstrt jsr jsrch ; find header
jmp jsync ; and then data block sync
jread cmp #0 ; test if read job
beq jread01 ; go test if write
jmp jwright
jread01 jsr jdstrt ; find header and start reading data
; sync routine sets y to 0
1$ bit pota1 ; 4
bmi 1$ ; 3 + 2
lda data2 ; 4
tax ; 2 reg x = xxxxx000
lda gcrtb1,x ; 4 nibble a
sta btab ; 3
txa ; 2
and #%00000111 ; 2
sta btab+1 ; 3 extract 3 bits nibble b
2$ bit pota1 ; 4
bmi 2$ ; 3 + 2
lda data2 ; 4
sta btab+2 ; 3
and #%11000000 ; 2 extract 2 bits nibble b
ora btab+1 ; 3
tax ; 2 reg x = xx000xxx
lda gcrtba,x ; 4 nibble b
ora btab ; 3
pha ; 3
jmp 5$ ; 3
;********************************************************************
3$ bit pota1 ; 4
bmi 3$ ; 3 + 2
lda data2 ; 4
tax ; 2 reg x = xxxxx000
lda gcrtb1,x ; 4 nibble a
sta btab ; 3
txa ; 2
and #%00000111 ; 2
sta btab+1 ; 3 extract 3 bits nibble b
4$ bit pota1 ; 4
bmi 4$ ; 3 + 2
lda data2 ; 4
sta btab+2 ; 3
and #%11000000 ; 2
ora btab+1 ; 3
tax ; 2 reg x = xx000xxx
lda gcrtba,x ; 4 nibble b
ora btab ; 3
sta (bufpnt),y ; 6
iny ; 2
beq 6$ ; 2
5$ lda btab+2 ; 3
tax ; 2 reg x = 00xxxxx0
lda gcrtb2,x ; 4 nibble c
sta btab ; 3
txa ; 2
and #%00000001 ; 2
sta btab+2 ; 3 extract 1 bits nibble d
7$ bit pota1 ; 4
bmi 7$ ; 3 + 2
lda data2 ; 4
sta btab+3 ; 3
and #%11110000 ; 2
ora btab+2 ; 3
tax ; 2 reg x = xxxx000x
lda gcrtbd,x ; 4 nibble d
ora btab ; 3
sta (bufpnt),y ; 6
iny ; 2
lda btab+3 ; 3
and #%00001111 ; 2
sta btab+3 ; 3 extract 4 bits nibble e
8$ bit pota1 ; 4
bmi 8$ ; 3 + 2
lda data2 ; 4
sta chksum ; 3
and #%10000000 ; 2
ora btab+3 ; 3
tax ; 2 reg x = x000xxxx
lda gcrtbe,x ; 4 nibble e
sta btab ; 3
lda chksum ; 3
tax ; 2 reg x = 0xxxxx00
lda gcrtb3,x ; 4 nibble f
ora btab ; 3
sta (bufpnt),y ; 6
iny ; 2
txa ; 2
and #%00000011 ; 2
sta chksum ; 3 extract 2 bits nibble g
9$ bit pota1 ; 4
bmi 9$ ; 3 + 2
lda data2 ; 4
sta btab+1 ; 3
and #%11100000 ; 2
ora chksum ; 3
tax ; 2 reg x = xxx000xx
lda gcrtbg,x ; 4 nibble g
sta btab ; 3
lda btab+1 ; 3
tax ; 2 reg x = 000xxxxx
lda gcrtb4,x ; 4 nibble h
ora btab ; 3
sta (bufpnt),y ; 6
iny ; 2
jmp 3$ ; 4
;*******************************************************************
6$ lda btab+2 ; 3
tax ; 2 reg x = 00xxxxx0
lda gcrtb2,x ; 4 nibble c
sta btab ; 3
txa ; 2
and #%00000001 ; 2
sta btab+2 ; 3
10$ bit pota1 ; 4
bmi 10$ ; 3 + 2
lda data2 ; 4
and #%11110000 ; 2
ora btab+2 ; 3
tax ; 2 reg x = xxxx000x
lda gcrtbd,x ; 4 nibble d
ora btab ; 3
sta btab+1 ; 3 store off cs byte
pla ; retrieve first byte off of disk
cmp dbid ; see if it is a 7
bne 12$ ; br, nope
jsr chkblk ; calc checksum
cmp btab+1
beq 11$
lda #5 ; data block checksum error
.byte skip2
12$ lda #4
.byte skip2
11$ lda #1 ; read data block ok
jmp jerrr
jsrch lda dskid ; get master id for the drive
sta header
lda dskid+1
sta header+1
ldy #0 ; get track,sectr
lda (hdrpnt),y
sta header+2
iny
lda (hdrpnt),y
sta header+3
lda #0
eor header
eor header+1
eor header+2
eor header+3
sta header+4 ; store the checksum
jsr conhdr ; convert header to gcr
lda #90 ; search 90 sync chars
sta tmp
1$ jsr jsync ; find sync
2$ lda stab,y ; what it should be
3$ bit pota1
bmi 3$
cmp data2 ; is it the same .cmp absolute
bne 4$ ; nope
iny
cpy #8
bne 2$
rts
4$ dec tmp ; try again
bne 1$
lda #2 ; cant find this header
jmp jerrr
jsync ldx #15
ldy #0 ; s/w timers ok
1$ bit dskcnt ; sync a synch ?
bpl 2$
dey
bne 1$
dex
bne 1$
lda #3
jmp jerrr ; sync error
2$ lda data2 ; clear pa latch
ldy #0 ; clear pointer
rts