-
Notifications
You must be signed in to change notification settings - Fork 82
/
lccgcrbin.src
286 lines (232 loc) · 3.28 KB
/
lccgcrbin.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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
.page
.subttl lccgcrbin
mask1 = $f8
mask2 = $07
mask2x = $c0
mask3 = $3e
mask4 = $01
mask4x = $f0
mask5 = $0f
mask5x = $80
mask6 = $7c
mask7 = $03
mask7x = $e0
mask8 = $1f
; fast gcr to binary conversion
get4gb ldy gcrpnt
lda (bufpnt),y
and #mask1
lsr a
lsr a
lsr a
sta gtab ;hi nibble
lda (bufpnt),y
and #mask2
asl a
asl a
sta gtab+1
iny ;next byte
bne xx05 ;test for next buffer
lda nxtbf
sta bufpnt+1
ldy nxtpnt
xx05 lda (bufpnt),y
and #mask2x
rol a
rol a
rol a
ora gtab+1
sta gtab+1
lda (bufpnt),y
and #mask3
lsr a
sta gtab+2
lda (bufpnt),y
and #mask4
asl a
asl a
asl a
asl a
sta gtab+3
iny ;next
lda (bufpnt),y
and #mask4x
lsr a
lsr a
lsr a
lsr a
ora gtab+3
sta gtab+3
lda (bufpnt),y
and #mask5
asl a
sta gtab+4
iny ;next byte
lda (bufpnt),y
and #mask5x
clc
rol a
rol a
and #1
ora gtab+4
sta gtab+4
lda (bufpnt),y
and #mask6
lsr a
lsr a
sta gtab+5
lda (bufpnt),y
and #mask7
asl a
asl a
asl a
sta gtab+6
iny ;test for overflow during write to binary conversion
bne xx06
lda nxtbf
sta bufpnt+1
ldy nxtpnt
xx06 lda (bufpnt),y
and #mask7x
rol a
rol a
rol a
rol a
ora gtab+6
sta gtab+6
lda (bufpnt),y
and #mask8
sta gtab+7
iny
sty gcrpnt
ldx gtab
lda gcrhi,x
ldx gtab+1
ora gcrlo,x
sta btab
ldx gtab+2
lda gcrhi,x
ldx gtab+3
ora gcrlo,x
sta btab+1
ldx gtab+4
lda gcrhi,x
ldx gtab+5
ora gcrlo,x
sta btab+2
ldx gtab+6
lda gcrhi,x
ldx gtab+7
ora gcrlo,x
sta btab+3
rts
gcrhi .byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $80
.byte $00
.byte $10
.byte $ff ;error
.byte $c0
.byte $40
.byte $50
.byte $ff ;error
.byte $ff ;error
.byte $20
.byte $30
.byte $ff ;error
.byte $f0
.byte $60
.byte $70
.byte $ff ;error
.byte $90
.byte $a0
.byte $b0
.byte $ff ;error
.byte $d0
.byte $e0
.byte $ff ;error
gcrlo .byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte $ff ;error
.byte 8
.byte $00
.byte 1
.byte $ff ;error
.byte $c
.byte 4
.byte 5
.byte $ff ;error
.byte $ff ;error
.byte 2
.byte 3
.byte $ff ;error
.byte $f
.byte 6
.byte 7
.byte $ff ;error
.byte 9
.byte $a
.byte $b
.byte $ff ;error
.byte $d
.byte $e
.byte $ff ;error
gcrbin lda #0 ;setup pointers
sta gcrpnt
sta savpnt
sta bytcnt
lda #>ovrbuf
sta nxtbf
lda #255-toprd
sta nxtpnt
lda bufpnt+1
sta savpnt+1
jsr get4gb
lda btab
sta bid ;get header id
ldy bytcnt
lda btab+1
sta (savpnt),y
iny
lda btab+2
sta (savpnt),y
iny
lda btab+3
sta (savpnt),y
iny
gcrb10 sty bytcnt
jsr get4gb
ldy bytcnt
lda btab
sta (savpnt),y
iny
beq gcrb20 ;test if done yet
lda btab+1
sta (savpnt),y
iny
lda btab+2
sta (savpnt),y
iny
lda btab+3
sta (savpnt),y
iny
bne gcrb10 ;jmp
gcrb20 lda btab+1
sta chksum
lda savpnt+1 ;restore buffer pointer
sta bufpnt+1
rts
; .end