Mercurial > hg > Members > kono > nitros9-code
comparison 3rdparty/utils/view/view_pix.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 pix picture format | |
4 * | |
5 * PIXshowpic -- Displays picture, using putline routine | |
6 * | |
7 * | |
8 | |
9 check macro | |
10 pshs b,cc | |
11 ldb #\1 | |
12 os9 F$PErr | |
13 puls b,cc | |
14 endm | |
15 | |
16 ifp1 | |
17 use /dd/defs/os9defs.a | |
18 endc | |
19 | |
20 psect view_pix_a,0,0,0,0,0 | |
21 | |
22 vsect dp | |
23 pixfirstcol: rmb 2 | |
24 pictwidth rmb 2 | |
25 linesize rmb 2 | |
26 linecount rmb 2 | |
27 updown rmb 2 | |
28 pixsize rmb 2 | |
29 endsect | |
30 | |
31 PIXshowpic: | |
32 bsr header Get header info | |
33 lbsr setscreen Set up screen | |
34 lbsr setpals Set up palettes | |
35 lbsr setvert Set up Get/Put Buffer | |
36 std linesize Store size of line in bytes. | |
37 | |
38 lbsr getline | |
39 ldd #0 | |
40 std updown | |
41 showpicloop | |
42 std linecount | |
43 | |
44 ldd updown If necessary, get a new line | |
45 cmpd pictwidth | |
46 blo spl1 | |
47 lbsr getline | |
48 subd pictwidth Subtract 640. | |
49 std updown | |
50 spl1 | |
51 | |
52 * Now, dither it and put it on the screen | |
53 leax altbuff,y Read from altbuff | |
54 leau linebuff,y ... into linebuff. | |
55 ldd linesize | |
56 lbsr pixditherline | |
57 | |
58 ldd updown Add 256 to count. | |
59 addd pixsize | |
60 std updown | |
61 | |
62 ldd linecount | |
63 addd #1 | |
64 cmpd pictwidth | |
65 bne showpicloop | |
66 | |
67 lbsr endvert Trash Get/Put buffer. | |
68 | |
69 rts | |
70 | |
71 * | |
72 * read header info from file, and set window type information | |
73 * | |
74 vsect dp | |
75 endoffile fcb 0 | |
76 double fcb 0 T=128x128, so we need to double things | |
77 count rmb 1 Counts down lines | |
78 endsect | |
79 | |
80 | |
81 header | |
82 pshs a,b,x,y,u | |
83 lda <format | |
84 cmpa #PIX256Format Is this definitely 256x256? | |
85 beq headbig | |
86 cmpa #PIX128Format Is it definitely 128x128? | |
87 beq headsmall | |
88 lbsr I_Size If neither of those was specified, let's try to use file size | |
89 lbcs _error to determine the format. | |
90 cmpd #10000 If it's over 10000 bytes, we'll take it as 256x256 | |
91 bhi headbig Yes, treat it as a 256x256. | |
92 com double Otherwise, treat it as a 128x128 picture. | |
93 headsmall | |
94 ldd #128 | |
95 std pixsize | |
96 bra headend | |
97 headbig | |
98 ldd #256 | |
99 std pixsize | |
100 headend | |
101 * Set screen type | |
102 lda #7 | |
103 sta <type | |
104 * Set some miscellaneous variables | |
105 lda #0 | |
106 sta <cyclestart | |
107 sta <cycleend | |
108 * Set palettes | |
109 leax ourpals,pcr | |
110 leau palette,y | |
111 ldd ,x++ | |
112 std ,u++ | |
113 ldd ,x++ | |
114 std ,u++ | |
115 * Set Skiplines default | |
116 ldd <Skiplines | |
117 cmpd #$ffff | |
118 bne head27 | |
119 ldd #20 | |
120 std <Skiplines | |
121 head27 | |
122 cmpd #64 Is it too big? | |
123 blo head28 | |
124 ldd #64 | |
125 std <Skiplines | |
126 head28 | |
127 * Set Size default to BIG | |
128 lda <Size | |
129 bpl headsize | |
130 lda #1 | |
131 sta <Size | |
132 headsize | |
133 * Set picture width | |
134 ldd #600 Default picture width | |
135 tst <Size | |
136 bne head30 | |
137 ldd #450 width for fitted picture | |
138 head30 | |
139 std pictwidth | |
140 * Set the first column to (640-pictwidth)/2 | |
141 ldd #640 | |
142 subd pictwidth | |
143 lsra | |
144 rorb | |
145 andb #$fc Force it to a multiple of 4 for put speed | |
146 std pixfirstcol | |
147 | |
148 puls a,b,x,y,u,pc | |
149 | |
150 ourpals fcb 0,7,56,63 | |
151 | |
152 * | |
153 * Getline | |
154 * | |
155 getline | |
156 pshs a,b,x,y,u | |
157 * First, fill buffers with all zeros | |
158 leau alt2buff,y | |
159 leax altbuff,y | |
160 ldb #200 | |
161 getline3 | |
162 clr ,u+ | |
163 clr ,x+ | |
164 decb | |
165 bne getline3 | |
166 * If at end of file, leave it that way | |
167 tst endoffile | |
168 bne getline1 | |
169 * Get a line into alt2buff | |
170 leax alt2buff,y | |
171 pshs y | |
172 ldd pixsize | |
173 lsra | |
174 rorb | |
175 tfr d,y Number of bytes is 1/2 picture size | |
176 lbsr I_Read | |
177 puls y | |
178 lbcc getline2 | |
179 cmpb #E$EOF | |
180 bne getline4 | |
181 com endoffile | |
182 getline2 | |
183 * Now, expand it into altbuff | |
184 leax alt2buff,y | |
185 leau altbuff,y | |
186 ldd #128 Get number of bytes in altbuff to expand into D. | |
187 tst double If we're doubling, only expand half as many bytes. | |
188 beq getline21 | |
189 lsra | |
190 rorb | |
191 getline21 | |
192 bsr expandline | |
193 bsr scrunchline Scrunch it down to 192 pixels. | |
194 bra getline1 | |
195 * Error exit point | |
196 getline4 | |
197 lbra _error If not EOF, just exit with error. | |
198 getline1 | |
199 puls a,b,x,y,u,pc | |
200 | |
201 * | |
202 * Expand line by nybbles. | |
203 * | |
204 * Take buffer [X], copy each nybble to a separate byte in [U]. | |
205 * Number of bytes in [X] is in D. | |
206 * | |
207 expandline | |
208 pshs a,b,x,y,u | |
209 tfr d,y | |
210 expand1 | |
211 lda ,x+ | |
212 tfr a,b | |
213 andb #$0f | |
214 lsra | |
215 lsra | |
216 lsra | |
217 lsra | |
218 tst <double | |
219 beq expand2 | |
220 sta ,u+ | |
221 sta ,u+ | |
222 stb ,u+ | |
223 stb ,u+ | |
224 bra expand3 | |
225 expand2 | |
226 std ,u++ | |
227 expand3 | |
228 leay -1,y | |
229 bne expand1 | |
230 puls a,b,x,y,u,pc | |
231 | |
232 * | |
233 * Take data in altbuff, and either remove bytes to "fit" it down to | |
234 * 192 bytes, or remove "Skiplines" number from beginning. | |
235 scrunchline | |
236 pshs a,b,x,y,u | |
237 leax altbuff,y | |
238 tfr x,u | |
239 tst <Size | |
240 bne scrbegin | |
241 * Fit the data into 192 bytes | |
242 ldb #192 | |
243 scrloop | |
244 lda ,u+ Take 4 bytes, and copy 3 of them. | |
245 sta ,x+ | |
246 lda ,u+ | |
247 sta ,x+ | |
248 lda ,u+ | |
249 sta ,x+ | |
250 lda ,u+ | |
251 subb #3 | |
252 bne scrloop | |
253 bra scrend | |
254 * Remove bytes from beginning. | |
255 scrbegin | |
256 ldd <Skiplines | |
257 leau d,u | |
258 ldb #192 | |
259 scrloop2 | |
260 lda ,u+ | |
261 sta ,x+ | |
262 decb | |
263 bne scrloop2 | |
264 scrend | |
265 puls a,b,x,y,u,pc | |
266 | |
267 endsect |