annotate 3rdparty/utils/view/view_savecomp.a @ 2265:581d99904cc5

makefiles updated
author boisy
date Mon, 28 Dec 2009 01:29:05 +0000
parents 37fd74e6fad8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1706
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
1 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
2 * Save compression routines.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
3 * VEFSquash: Squashes data for VEF format.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
4 * CM3Compress: Compresses altbuff using CM3 compression
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
5 * MGEsame: copy linebuff to altbuff
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
6 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
7
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
8 ifp1
1912
37fd74e6fad8 Now assembles with rma, uses os9defs.d in c3
boisy
parents: 1777
diff changeset
9 use os9defs.d
1706
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
10 endc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
11
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
12 check macro
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
13 pshs b,cc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
14 ldb #\1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
15 os9 F$PErr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
16 puls b,cc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
17 endm
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
18
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
19 psect view_savecomp_a,0,0,0,0,0
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
20
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
21 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
22 * Compress one line with CM3 compression.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
23 * Expects: line data in altbuff
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
24 * Returns: compressed line in altbuff, preceded by 2-byte size
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
25 * Uses: alt2buff to store last line of data
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
26 Stash equ 160 Stash new line at end of old line
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
27 CM3compress:
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
28 pshs a,b
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
29 bsr CM3stash Stash line at alt2buff+Stash
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
30 lbsr CM3docomp Try to compress it
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
31 ldd altbuff,y Get the result size
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
32 cmpd #160
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
33 bls CM3comp0 If its small, use compressed line
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
34 bsr CM3nocomp Else don't compress it
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
35 CM3comp0
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
36 bsr CM3save Save old line
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
37 puls a,b,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
38
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
39 * Copy from altbuff to stash area
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
40 CM3stash
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
41 pshs a,b,x,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
42 leax altbuff,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
43 leau alt2buff+Stash,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
44 ldb #160
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
45 CM3st1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
46 lda ,x+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
47 sta ,u+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
48 decb
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
49 bne CM3st1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
50 puls a,b,x,u,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
51
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
52 * Copy from stash area to save area
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
53 CM3save
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
54 pshs a,b,x,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
55 leax alt2buff+Stash,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
56 leau alt2buff,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
57 ldb #160
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
58 CM3save1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
59 lda ,x+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
60 sta ,u+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
61 decb
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
62 bne CM3save1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
63 puls a,b,x,u,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
64
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
65 * No compression: from stash area to altbuff
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
66 CM3nocomp
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
67 pshs a,b,x,y,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
68 leax altbuff,y First try, no compression at all.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
69 ldd #161
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
70 std ,x++
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
71 ldb #160
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
72 stb ,x+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
73 leau alt2buff+Stash,y Get data from stash area.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
74 CM3noc1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
75 lda ,u+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
76 sta ,x+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
77 decb
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
78 bne CM3noc1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
79 puls a,b,x,y,u,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
80
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
81 vsect dp
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
82 ImagePtr rmb 2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
83 ImageBit rmb 1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
84 ActionPtr rmb 2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
85 ActionBit rmb 1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
86 endsect
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
87
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
88 SetAction
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
89 pshs a,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
90 lda ActionBit
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
91 ldx ActionPtr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
92 ora ,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
93 sta ,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
94 puls a,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
95 ClrAction
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
96 pshs a,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
97 lda ActionBit
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
98 lsra
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
99 bcc ClrAct1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
100 ldx ActionPtr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
101 leax 1,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
102 stx ActionPtr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
103 inc altbuff+2,y Increment count of Action bytes.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
104 rora
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
105 ClrAct1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
106 sta ActionBit
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
107 puls a,x,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
108
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
109 SetImage
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
110 pshs a,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
111 lda ImageBit
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
112 ldx ImagePtr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
113 ora ,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
114 sta ,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
115 puls a,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
116 ClrImage
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
117 pshs a,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
118 lda ImageBit
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
119 lsra
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
120 bcc ClrIm1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
121 ldx ImagePtr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
122 leax 1,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
123 stx ImagePtr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
124 rora
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
125 ClrIm1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
126 sta ImageBit
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
127 puls a,x,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
128
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
129 * Try doing CM3 compression
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
130 CM3docomp
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
131 pshs a,b,x,y,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
132
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
133 leax altbuff,y Clear out receiving area.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
134 clrb
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
135 CM3do1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
136 clr ,x+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
137 decb
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
138 bne CM3do1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
139
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
140 leax altbuff+2+1,y Set up Image and Action stuff
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
141 stx ImagePtr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
142 leax altbuff+2+1+20,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
143 stx ActionPtr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
144 lda #$80
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
145 sta ImageBit Start with MSBit
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
146 sta ActionBit
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
147 lda #1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
148 sta altbuff+2,y Set # Action bytes to 1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
149
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
150 leax alt2buff+Stash,y Point to line data
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
151 leau altbuff+2+1+20+20,y Point to space for extra bytes.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
152 ldb #160 Number of bytes.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
153 CM3do3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
154 lda ,x+ Get next byte
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
155 cmpa -2,x Same as previous?
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
156 bne CM3do4
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
157 bsr ClrImage Yes, mark it.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
158 bra CM3do6
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
159 CM3do4
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
160 bsr SetImage
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
161 cmpa -(Stash+1),x Same as above?
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
162 bne CM3do5
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
163 bsr ClrAction Mark as such
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
164 bra CM3do6
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
165 CM3do5
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
166 lbsr SetAction
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
167 sta ,u+ Store byte value
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
168 CM3do6
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
169 decb
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
170 bne CM3do3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
171
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
172 ldb altbuff+2,y Minimize this value.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
173 lda ActionBit
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
174 cmpa #$80 If this is true, then last action byte hasn't been used.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
175 bne CM3do7
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
176 decb so we can decrement it.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
177 beq CM3do7 ... but not to zero.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
178 stb altbuff+2,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
179 CM3do7
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
180
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
181 leax altbuff+2+1+20+20,y Point to start of extra bytes
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
182 ldb altbuff+2,y Get # of action bytes
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
183 subb #20 Number of unused action bytes
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
184 bne CM3do8 If none are unused, just leave extra bytes in place.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
185 tfr u,x Set X to end.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
186 bra CM3do11
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
187 CM3do8
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
188
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
189 pshs u Save end of extra bytes
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
190 CM3do9
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
191 cmpx ,s
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
192 beq CM3do10
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
193 lda ,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
194 sta b,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
195 leax 1,x Move extra bytes down
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
196 bra CM3do9
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
197 CM3do10
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
198
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
199 puls u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
200 leax b,x Point to new end of extra bytes.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
201 CM3do11
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
202
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
203 tfr x,d
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
204 leax altbuff+2,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
205 pshs x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
206 subd ,s D holds size of compressed data
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
207 puls x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
208 std altbuff,y store size.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
209 puls a,b,x,y,u,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
210
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
211 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
212 * Squash one packet worth of data
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
213 * Expects: Number of bytes to squash in D.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
214 * Bytes to squash pointed to by X.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
215 * Returns: Squashed packet in altbuff
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
216 VEFSquash:
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
217 pshs a,b,x,y,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
218 leau altbuff+1,y Data goes here
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
219 tfr d,y Size of data to compress
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
220 clrb This will count up size of compressed packet
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
221 Sq1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
222 lda ,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
223 cmpa 1,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
224 bne Sq2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
225 cmpa 2,x If three bytes are the same, then do compression.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
226 bne Sq2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
227 bsr sqcomprs Get a compressed subpacket.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
228 bra Sq3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
229 Sq2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
230 bsr sqstraight
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
231 Sq3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
232 sty -2,s Same as tsty
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
233 bne Sq1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
234 ldy 4,s Restore Y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
235 stb altbuff,y Store packet size.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
236 puls a,b,x,y,u,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
237
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
238 * Encode a sequence of straight data
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
239 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
240 sqstraight
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
241 pshs u Save address of subpacket size.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
242 clr ,u+ Set zero count.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
243 lda ,x+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
244 sqstr1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
245 sta ,u+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
246 incb Increment total bytes
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
247 inc [,s] Increment subpacket size
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
248 leay -1,y Count down bytes to compress
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
249 beq sqstr2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
250 lda ,x+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
251 cmpa ,x Three like bytes mean we stop here.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
252 bne sqstr1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
253 cmpa 1,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
254 bne sqstr1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
255 leax -1,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
256 sqstr2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
257 incb Include subpacket size in total count.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
258 leas 2,s Clean up stack.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
259 rts
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
260
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
261 * Encode a sequence of compressed data
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
262 * B is increased by 2, X points to byte after repeated data,
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
263 * U is increased by 2, Y is decreased by number of bytes compressed.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
264 sqcomprs
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
265 lda ,x+ Store the byte as the second byte.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
266 sta 1,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
267 clr ,u Clear our count
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
268 sqcomprs1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
269 inc ,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
270 leay -1,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
271 beq sqcomprs2 Abort the loop if Y goes to zero.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
272 cmpa ,x+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
273 beq sqcomprs1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
274 leax -1,x Backup to point to different byte
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
275 sqcomprs2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
276 lda ,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
277 ora #$80 Set high bit for compressed subpacket
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
278 sta ,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
279 leau 2,u Move past this subpacket
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
280 addb #2 and bump total packet size.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
281 rts
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
282
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
283 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
284 * MGEsame -- copy linebuff to altbuff
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
285 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
286 MGEsame:
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
287 pshs a,b,x,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
288 leax linebuff,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
289 leau altbuff,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
290 ldb #160
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
291 MGEsameloop
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
292 lda ,x+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
293 sta ,u+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
294 decb
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
295 bne MGEsameloop
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
296 puls a,b,x,u,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
297
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
298 endsect