annotate 3rdparty/utils/view/view_img.a @ 1706:6b23465701c0

Tim Kientzle's VIEW
author boisy
date Tue, 10 Aug 2004 23:46:24 +0000
parents
children b7fb6a9aead4
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 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
3 * SUBS for IMG picture formats
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
4 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
5 * IMGshowpic -- displays picture on screen
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
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
9 check macro
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
10 pshs b,cc This macro will print "ERROR #xxx", where xxx is the
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
11 ldb #\1 . number given as an argument. Very useful for
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
12 os9 F$PErr . checkpointing, to make sure certain routines are
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
13 puls b,cc . executed. Printed to StdErr path.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
14 endm
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
15
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
16 ifp1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
17 use /dd/defs/os9defs.a
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
18 endc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
19
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
20 StdOut equ 1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
21 StdErr equ 2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
22
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
23 psect view_img_a,0,0,0,0,0
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
24
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
25 vsect dp
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
26 nscreens rmb 1 Number of screens in this picture.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
27 endsect
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
28
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
29 IMGshowpic:
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
30 bsr header
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
31 *lbsr setscreen Unlike some formats, these are handled by "header".
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
32 *lbsr setpals
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
33 lbsr setbuffer
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
34
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
35 spscreens
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
36 lbsr flipscreen Select next screen
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
37 ldd <Skiplines First, skip any lines.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
38 beq skip01
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
39 skip00
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
40 lbsr getline
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
41 subd #1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
42 bne skip00
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
43 skip01
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
44
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
45 ldd #00
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
46 ldx #25
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
47 showpicloop
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
48 lbsr getline
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
49
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
50 tst <Size If we're displaying a "small" pic, skip every 25th line.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
51 bne showpic2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
52 leax -1,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
53 bne showpic2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
54 ldx #25
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
55 bra spnoput
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
56 showpic2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
57
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
58 lbsr putline
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
59 addd #1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
60 spnoput
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
61 cmpd #192
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
62 bne showpicloop
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
63 spfinish
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
64 lbsr getline Read rest of this screen.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
65 tst <endofpic
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
66 beq spfinish
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
67 clr <endofpic Clear for next screen.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
68 spendscreen
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
69 dec nscreens Any more?
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
70 bne spscreens Yes, get it.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
71 rts
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
72
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
73 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
74 * read header info from file, and set window type information
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
75 * Uses altbuff.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
76 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
77 vsect dp
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
78 count rmb 1 Count/value is used for compressed packets
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
79 value rmb 1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
80 straight rmb 1 Number of straight bytes.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
81 compressed fcb $ff T=we're in a compressed block.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
82 endoffile rmb 1 T= EOF reached, so always return linebuff all 0
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
83 endofpic rmb 1 T= end-of-picture seen.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
84 zeroflag rmb 1 T= We've seen one zero.. another will be end-of-pic
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
85 endsect
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
86
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
87 header
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
88 pshs a,b,x,y,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
89
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
90 * Set default Skiplines.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
91 ldd <Skiplines
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
92 cmpd #$ffff
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
93 bne headskip
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
94 ldd #0
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
95 std <Skiplines
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
96 headskip
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
97
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
98 * Set default Size
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
99 lda <Size
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
100 bpl headsize
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
101 lda #1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
102 sta <Size
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
103 headsize
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
104
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
105 * Cancel any color cycling or rotation
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
106 lda <cyclestart one-palette cycle is effectively none
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
107 sta <cycleend
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
108 clr <extranum no colors to rotate.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
109
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
110 * Now, read in header
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
111 leax altbuff,y read in type and palettes
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
112 pshs y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
113 ldy #18 Number of bytes in header.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
114 lbsr I_Read
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
115 lbcs _error
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
116 puls y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
117 leax altbuff,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
118 lda ,x+ This byte contains RGB/CMP bit and other useless info.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
119
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
120 lda ,x+ This specifies the picture format and palettes to be used.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
121
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
122 cmpa #0 Dithered grey
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
123 bne header0
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
124 lda #7
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
125 sta <type
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
126 lbsr setscreen
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
127 lda #1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
128 sta nscreens
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
129 lda #3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
130 lbsr setborder
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
131 leax greypals,pcr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
132 lbsr headpals
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
133 bra headend
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
134 header0
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
135
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
136 cmpa #1 false 16-color
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
137 bne header1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
138 lda #8
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
139 sta <type
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
140 lbsr setscreen
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
141 lda #1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
142 sta nscreens
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
143 lda #15
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
144 lbsr setborder
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
145 lbsr headpals Use palettes in header
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
146 bra headend
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
147 header1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
148
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
149 cmpa #2 Solid grey
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
150 bne header2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
151 leax greypals,pcr Set pals to grey palettes.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
152 lda #7 Use type 7 screen
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
153 sta <type
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
154 lbsr setscreen Set it.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
155 lda #1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
156 sta nscreens Only one screen for this format.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
157 lda #3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
158 lbsr setborder
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
159 lbsr headpals
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
160 bra headend
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
161 header2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
162
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
163 cmpa #3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
164 bne header3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
165 lda #7
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
166 sta <type
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
167 lda #3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
168 sta nscreens
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
169 lda #$ff
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
170 sta <flipping Turn on flipping.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
171 lbsr setscreen Set up red screen
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
172 lda #3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
173 lbsr setborder
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
174 leax redpals,pcr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
175 lbsr headpals
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
176 lbsr setscreen Set up green screen
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
177 lbsr setborder
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
178 leax greenpals,pcr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
179 lbsr headpals
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
180 lbsr setscreen Set up blue screen
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
181 lbsr setborder
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
182 leax bluepals,pcr
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
183 lbsr headpals
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
184 bra headend
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
185 header3
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
186
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
187 lbsr E$Format Illegal file format.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
188
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
189
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
190 headend
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
191 puls a,b,x,y,u,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
192
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
193 headpals
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
194 pshs a,b,x,u Set the palettes.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
195 leau palette,y
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
196 ldb #16
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
197 headloop
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
198 lda ,x+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
199 sta ,u+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
200 decb
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
201 bne headloop
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
202 lbsr setpals
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
203 puls a,b,x,u,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
204
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
205 greypals fcb $3f,$38,$07,$00 Only first four palettes matter here.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
206 redpals fcb $24,$20,$04,$00
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
207 greenpals fcb $12,$10,$02,$00
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
208 bluepals fcb $09,$08,$01,$00
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
209
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
210 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
211 * Getline
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
212 *
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
213 getline
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
214 pshs a,b,x,y,u
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
215 leau linebuff,y First, clear out line buffer to $ff, the background pattern.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
216 ldx #160
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
217 lda #$ff Since palette 3 is the background, use this for fill pattern.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
218 getl1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
219 sta ,u+
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
220 leax -1,x
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
221 bne getl1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
222
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
223 tst endoffile Are we at end-of-file?
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
224 lbne getline1 Yes, just leave buffer of zeros
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
225 tst endofpic
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
226 lbne getline1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
227
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
228 * Get a line from file
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
229 leau linebuff,y Where we'll put the line.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
230 ldx #160 Number of bytes in one line.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
231 * Check if we're in a compressed or uncompressed packet.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
232 tst count Did we reach the end of the line in a compressed packet?
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
233 bne uncompress Yes, finish uncompressing
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
234 tst straight Did we reach it in a straight packet?
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
235 bne copystraight Yes, finish the packet.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
236 tst compressed Did we just finish a straight packet?
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
237 beq getcomp Yes, we're just starting a compressed one.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
238 * Get a straight packet
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
239 getstraight
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
240 clr compressed Mark that we're in a straight packet
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
241 lbsr I_GetByte
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
242 bcs geteof
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
243 sta straight
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
244 bne copystraight non-zero count, handle it.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
245 tst zeroflag
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
246 bne geteop If already one zero, set endofpic
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
247 com zeroflag Otherwise, set zeroflag.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
248 bra getcomp If zero, next type of packet.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
249 * Read in straight data
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
250 copystraight
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
251 clr zeroflag
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
252 ldb straight Get number of bytes
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
253 getstr1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
254 lbsr I_GetByte Get the next byte
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
255 bcs geteof
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
256 sta ,u+ Store the byte.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
257 decb Count down number of reps
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
258 leax -1,x Count down size of line
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
259 beq getstr2 If end of line, finish.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
260 tstb
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
261 bne getstr1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
262 stb straight
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
263 bra getcomp Get a compressed packet.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
264 getstr2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
265 stb straight Hit end of line, store remaining count.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
266 bra getline1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
267 * Get a compressed packet
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
268 getcomp
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
269 com compressed Mark that we're in a compressed packet
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
270 lbsr I_GetByte
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
271 bcs geteof
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
272 sta count
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
273 bne getcomp1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
274 tst zeroflag
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
275 bne geteop If already one zero, set endofpic
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
276 com zeroflag Otherwise, set zeroflag.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
277 bra getstraight If zero, next type of packet.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
278 getcomp1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
279 lbsr I_GetByte
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
280 bcs geteof
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
281 sta value
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
282 * Expand compressed data
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
283 uncompress
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
284 clr zeroflag
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
285 ldd count Get count/value
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
286 getunc1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
287 stb ,u+ Store a copy of current value
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
288 deca Count down number of reps
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
289 leax -1,x Count down size of line
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
290 beq getunc2 If end of line, finish.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
291 tsta
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
292 bne getunc1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
293 std count
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
294 bra getstraight Get a straight packet.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
295 getunc2
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
296 std count Otherwise, store remaining count.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
297 bra getline1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
298
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
299 geteop
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
300 lda #$ff
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
301 sta endofpic Mark end of picture.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
302 sta compressed
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
303 clr straight
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
304 clr count
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
305 clr zeroflag Clear zeroflag.
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
306 bra getline1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
307 geteof
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
308 cmpb #E$EOF
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
309 lbne _error
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
310 lda #$ff
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
311 sta endoffile endoffile is also endofpic
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
312 sta endofpic
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
313 getline1
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
314 puls a,b,x,y,u,pc
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
315
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
316
6b23465701c0 Tim Kientzle's VIEW
boisy
parents:
diff changeset
317 endsect