Mercurial > hg > Members > kono > nitros9-code
comparison 3rdparty/utils/view/view_cm3.a @ 1706:6b23465701c0
Tim Kientzle's VIEW
author | boisy |
---|---|
date | Tue, 10 Aug 2004 23:46:24 +0000 |
parents | |
children | b7fb6a9aead4 |
comparison
equal
deleted
inserted
replaced
1705:bd792517eea1 | 1706:6b23465701c0 |
---|---|
1 ******************************************************************************* | |
2 * | |
3 * SUBS for CM3 picture formats | |
4 * | |
5 * CM3showpic -- display picture, using putline routine | |
6 * | |
7 ******************************************************************************* | |
8 | |
9 ifp1 | |
10 use /dd/defs/os9defs.a | |
11 endc | |
12 | |
13 StdOut equ 1 | |
14 StdErr equ 2 | |
15 | |
16 psect view_cm3_a,0,0,0,0,0 | |
17 | |
18 vsect dp | |
19 endoffile rmb 1 T= EOF reached, so always return linebuff all 0 | |
20 patterns rmb 1 T= patterns must be skipped | |
21 totscreens fcb 1 Total number of screens in picture | |
22 numscreens fcb 1 Number of screens remaining in picture- for Getline sub. | |
23 lines rmb 1 Number of lines remaining on this screen | |
24 lastbyte rmb 1 | |
25 endsect | |
26 | |
27 | |
28 vsect | |
29 image rmb 20 | |
30 action rmb 25 | |
31 endsect | |
32 | |
33 * | |
34 * Main picture display function | |
35 * | |
36 CM3showpic: | |
37 bsr header | |
38 | |
39 pshs d | |
40 ldd <Skiplines | |
41 beq skip01 | |
42 skip00 | |
43 lbsr getline | |
44 subd #1 | |
45 bne skip00 | |
46 skip01 | |
47 | |
48 lbsr setscreen | |
49 lbsr setpals | |
50 lbsr setbuffer | |
51 lbsr getline | |
52 | |
53 spscreens | |
54 ldd #0 | |
55 showpicloop | |
56 lbsr putline | |
57 lbsr getline | |
58 tst <Size | |
59 bgt spnoskip Size >0, don't do skip. | |
60 pshs a | |
61 lda <totscreens | |
62 cmpa #2 Two screens? | |
63 puls a | |
64 blo spnoskip No, ignore this. | |
65 spskip | |
66 lbsr getline Yes, get another line. | |
67 spnoskip | |
68 addd #1 | |
69 cmpd #192 | |
70 bne showpicloop | |
71 tst <Size | |
72 beq showpicend Only do another screen if not small size. | |
73 lbsr getline | |
74 tst <endoffile | |
75 bne showpicend | |
76 lbsr setscreen | |
77 lbsr setpals | |
78 bra spscreens | |
79 showpicend | |
80 puls d,pc | |
81 | |
82 * | |
83 * read header info from file, and set window type information | |
84 * Uses altbuff to store header as it's read from disk. | |
85 * | |
86 header | |
87 pshs a,b,x,y,u | |
88 leax altbuff,y read in type and palettes | |
89 pshs y | |
90 ldy #29 | |
91 lbsr I_Read | |
92 puls y | |
93 lbcs _error | |
94 leax altbuff,y | |
95 lda ,x+ | |
96 cmpa #1 No patterns | |
97 beq head2 | |
98 cmpa #0 0 or $80 are types for screens with patterns | |
99 beq head0 | |
100 cmpa #$80 | |
101 lbne E$Format | |
102 lda #2 | |
103 sta numscreens | |
104 sta totscreens | |
105 head0 | |
106 com patterns | |
107 head2 | |
108 | |
109 leau palette,y Set palettes | |
110 ldb #16 | |
111 headloop | |
112 lda ,x+ | |
113 sta ,u+ | |
114 decb | |
115 bne headloop | |
116 | |
117 ldb ,x+ Store rate for palette rotation | |
118 clra | |
119 std <cyclerate | |
120 | |
121 ldd #$0b0e Palette cycling starts at palette 11, ends at 14 | |
122 sta <cyclestart | |
123 stb <cycleend | |
124 | |
125 ldb ,x+ Get rate for color cycling | |
126 clra | |
127 std <extrarate | |
128 | |
129 ldb #8 | |
130 leau extrapals,y Set palette values for color cycling | |
131 head2loop | |
132 lda ,x+ | |
133 sta ,u+ | |
134 decb | |
135 bne head2loop | |
136 | |
137 lda #10 | |
138 sta <extraslot | |
139 | |
140 lda ,x+ | |
141 bmi headanim If no animation, set cyclestart=cycleend | |
142 lda <cyclestart | |
143 sta <cycleend | |
144 headanim | |
145 | |
146 ldb #8 | |
147 lda ,x+ | |
148 bmi headrot Set number of values for color rotation. | |
149 clrb | |
150 headrot | |
151 stb <extranum | |
152 | |
153 lda <type | |
154 bne headtype | |
155 lda #8 Set screen type to 8 | |
156 sta <type | |
157 headtype | |
158 | |
159 lda #$ff | |
160 sta <cycle Turn cycling on. | |
161 | |
162 tst patterns Do we need to skip pattern info? | |
163 beq head3 | |
164 leax linebuff,y | |
165 pshs y | |
166 ldy #243 This many bytes of pattern info must be skipped. | |
167 lbsr I_Read | |
168 puls y | |
169 lbcs _error | |
170 head3 | |
171 | |
172 ldd <Skiplines Set lines to skip if not already set. | |
173 cmpd #$ffff | |
174 bne headskip | |
175 ldd #0 | |
176 std <Skiplines | |
177 headskip | |
178 | |
179 lda <Size | |
180 bpl headsize | |
181 lda #1 Default size is BIG. | |
182 sta <Size | |
183 headsize | |
184 | |
185 ldd #120 | |
186 std <fliprate Set to flip every 2 seconds. | |
187 | |
188 leax altbuff,y Clear out buffer with "last line" info. | |
189 clrb | |
190 headclear | |
191 clr ,x+ | |
192 decb | |
193 bne headclear | |
194 | |
195 puls a,b,x,y,u,pc | |
196 | |
197 | |
198 * | |
199 * Getline | |
200 * | |
201 getline | |
202 pshs a,b,x,y,u | |
203 * Clear line and check for end-of-file condition | |
204 leau linebuff,y | |
205 ldb #160 | |
206 getl1 | |
207 clr ,u+ | |
208 decb | |
209 bne getl1 | |
210 tst endoffile Are we at end-of-file? | |
211 lbne getline1 | |
212 * Check if we're at the beginning of a new screen. | |
213 tst lines | |
214 bne getl2 | |
215 * If so, and numscreens=0, then end-of-file | |
216 dec numscreens | |
217 bpl getl3 | |
218 com endoffile | |
219 lbra getline1 | |
220 getl3 | |
221 lbsr I_GetByte | |
222 sta lines | |
223 getl2 | |
224 * get header byte | |
225 lbsr I_GetByte | |
226 * Test for compressed/uncompressed line. | |
227 tsta | |
228 bpl getcomp | |
229 * | |
230 * Get uncompressed line. | |
231 * | |
232 getnormal | |
233 leax linebuff,y read in one line of screen | |
234 pshs y | |
235 ldy #160 | |
236 lbsr I_Read | |
237 puls y | |
238 lbcc getnor2 | |
239 geteof | |
240 cmpb #E$EOF watch for end-of-file | |
241 bne getnor1 | |
242 com endoffile Flag end-of-file condition | |
243 bra getnor2 Keep on going. | |
244 getnor1 | |
245 lbra _error If not EOF, just exit with error. | |
246 * | |
247 * Get compressed line. | |
248 * | |
249 getcomp | |
250 leax image,y Initialize counters for image and action bits. | |
251 stx <imptr | |
252 leax action,y | |
253 stx <actptr | |
254 ldb #8 | |
255 stb <imcnt | |
256 stb <actcnt | |
257 | |
258 tfr a,b | |
259 clra | |
260 cmpd #21 | |
261 lbhi E$Format if >21 action bytes, then error. | |
262 addd #20 Get total number of bytes for image + action. | |
263 tfr d,u | |
264 leax image,y | |
265 exg y,u | |
266 lbsr I_Read | |
267 exg y,u | |
268 lbcs geteof Test for end-of-file, etc. | |
269 | |
270 * decode a compressed packet | |
271 leax altbuff,y | |
272 leau linebuff,y | |
273 ldb #160 | |
274 lda lastbyte A always holds the last byte on the line. | |
275 getcomp0 | |
276 bsr tstimage | |
277 bcc getcomp9 image byte 0 -> repeat last byte | |
278 lda ,x | |
279 bsr tstaction 1 image & 0 action -> repeat from above | |
280 bcc getcomp9 | |
281 lbsr I_GetByte 1 image & 1 action -> get new value | |
282 getcomp9 | |
283 sta lastbyte | |
284 sta ,u+ | |
285 leax 1,x | |
286 decb | |
287 bne getcomp0 | |
288 * | |
289 * Now, put line where it belongs. | |
290 * | |
291 getnor2 | |
292 leax linebuff,y | |
293 leau altbuff,y Copy linebuff to altbuff, to save last line | |
294 ldb #160 | |
295 getnor3 | |
296 lda ,x+ | |
297 sta ,u+ | |
298 decb | |
299 bne getnor3 | |
300 sta lastbyte | |
301 * If small and double-screen, then do horizontal compression. | |
302 tst <Size | |
303 bne getline1 | |
304 lda <totscreens | |
305 cmpa #2 | |
306 bne getline1 | |
307 bsr squishline | |
308 * Exit getline | |
309 getline1 | |
310 dec lines | |
311 puls a,b,x,y,u,pc | |
312 | |
313 * | |
314 * These subs return consecutive bits from the appropriate bit arrays | |
315 * | |
316 vsect dp | |
317 actptr rmb 2 | |
318 actcnt rmb 1 | |
319 imptr rmb 2 | |
320 imcnt rmb 1 | |
321 endsect | |
322 | |
323 tstaction | |
324 rol [actptr] | |
325 dec actcnt | |
326 bne tstact1 | |
327 pshs a,x | |
328 ldx actptr | |
329 leax 1,x | |
330 stx actptr | |
331 lda #8 | |
332 sta actcnt | |
333 puls a,x | |
334 tstact1 | |
335 rts | |
336 | |
337 tstimage | |
338 rol [imptr] | |
339 dec imcnt | |
340 bne tstim1 | |
341 pshs a,x | |
342 ldx imptr | |
343 leax 1,x | |
344 stx imptr | |
345 lda #8 | |
346 sta imcnt | |
347 puls a,x | |
348 tstim1 | |
349 rts | |
350 | |
351 squishline | |
352 pshs a,b,x,y,u | |
353 leax linebuff,y | |
354 tfr x,u | |
355 ldy #80 Total # of pairs of bytes. | |
356 squish1 | |
357 ldd ,x++ | |
358 lsrb Top nybble of B to bottom. | |
359 lsrb | |
360 lsrb | |
361 lsrb | |
362 andb #$0f Mask off bottom nybble of B. | |
363 anda #$f0 .. and top of A. | |
364 pshs b Or them together. | |
365 ora ,s+ | |
366 sta ,u+ | |
367 leay -1,y | |
368 bne squish1 | |
369 | |
370 ldy #40 Clear out 40 bytes on right side. | |
371 squish2 | |
372 clr ,-x | |
373 leay -1,y | |
374 bne squish2 | |
375 | |
376 ldy #80 Move 80 bytes to center of screen. | |
377 squish3 | |
378 lda ,-u | |
379 sta ,-x | |
380 leay -1,y | |
381 bne squish3 | |
382 | |
383 ldy #40 Clear out 40 bytes on left side. | |
384 squish4 | |
385 clr ,-x | |
386 leay -1,y | |
387 bne squish4 | |
388 puls a,b,x,y,u,pc | |
389 | |
390 endsect |