-
Notifications
You must be signed in to change notification settings - Fork 82
/
lccgcrbn1.src
164 lines (117 loc) · 3.15 KB
/
lccgcrbn1.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
.page
.subttl 'lccgcrbn1.src'
; even faster gcr to binary conversion
jget4gb ldy gcrpnt
lda (bufpnt),y
sta gtab ; A
and #mask2
sta gtab+1
iny ; next byte
bne 1$ ; test for next buffer
lda nxtbf
sta bufpnt+1
ldy nxtpnt
1$ lda (bufpnt),y
sta gtab+2 ; C
and #mask2x
ora gtab+1
sta gtab+1 ; B
lda gtab+2
and #mask4
sta gtab+3
iny ; next
lda (bufpnt),y
tax
and #mask4x
ora gtab+3
sta gtab+3 ; D
txa
and #mask5
sta gtab+4
iny ; next byte
lda (bufpnt),y
sta gtab+5 ; F
and #mask5x
ora gtab+4
sta gtab+4 ; E
lda gtab+5
and #mask7
sta gtab+6
iny
; test for overflow during write to binary conversion
bne 2$
lda nxtbf
sta bufpnt+1
ldy nxtpnt
sty bufpnt
2$ lda (bufpnt),y
sta gtab+7 ; H
and #mask7x
ora gtab+6
sta gtab+6 ; G
iny
sty gcrpnt
ldx gtab
lda gcrtb1,x ; a
ldx gtab+1
ora gcrtba,x ; b
sta btab
ldx gtab+2
lda gcrtb2,x ; c
ldx gtab+3
ora gcrtbd,x ; d
sta btab+1
ldx gtab+4
lda gcrtbe,x ; e
ldx gtab+5
ora gcrtb3,x ; f
sta btab+2
ldx gtab+6
lda gcrtbg,x ; g
ldx gtab+7
ora gcrtb4,x ; h
sta btab+3
rts
jgcrbin lda #0 ; setup pointers
sta gcrpnt
sta savpnt
sta bytcnt
lda #>ovrbuf ; point to overflow first
sta nxtbf
lda #255-toprd ; overflow offset
sta nxtpnt
lda bufpnt+1
sta savpnt+1
jsr jget4gb
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
1$ sty bytcnt
jsr jget4gb
ldy bytcnt
lda btab
sta (savpnt),y
iny
beq 2$ ; 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 1$ ; jmp
2$ lda savpnt+1 ; restore buffer pointer
sta bufpnt+1
rts