1706
|
1 *
|
|
2 *
|
|
3 * SUBS for Pmode 4 picture format
|
|
4 *
|
|
5 * MAXshowpic -- 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
|
1912
|
17 use os9defs.d
|
1706
|
18 endc
|
|
19
|
|
20 psect view_max_a,0,0,0,0,0
|
|
21
|
|
22 vsect dp
|
|
23 totlines rmb 2
|
|
24 fitcount rmb 2
|
|
25 linesize rmb 2
|
|
26 endsect
|
|
27
|
|
28 MAXshowpic:
|
|
29 bsr header Read header info, set palettes, etc.
|
|
30
|
|
31 pshs d
|
|
32 ldd <Skiplines
|
|
33 beq skip01
|
|
34 skip00
|
|
35 lbsr getline
|
|
36 subd #1
|
|
37 bne skip00
|
|
38 skip01
|
|
39
|
|
40 lbsr setscreen
|
|
41 lbsr setpals
|
|
42 lbsr setbuffer
|
|
43 lda <border
|
|
44 lbsr setborder Set the border appropriately.
|
|
45 lbsr getline
|
|
46
|
|
47 spscreens
|
|
48 lbsr nextline
|
|
49 ldd fitcount
|
|
50 addd totlines
|
|
51 spget
|
|
52 std fitcount
|
|
53 lbsr getline
|
|
54 tst <Size
|
|
55 bne spnofit
|
|
56 ldd fitcount
|
|
57 subd #192
|
|
58 bge spget
|
|
59 std fitcount
|
|
60 spnofit
|
|
61 tst <endoffile
|
|
62 beq spscreens
|
|
63
|
|
64 showpicend
|
|
65 lbsr flipscreens
|
|
66
|
|
67 lda <format
|
|
68 cmpa #MAXCMPFormat If it's MAXCMP or ARTCMP, return extra memory.
|
|
69 beq spspecial
|
|
70 cmpa #ARTCMPFormat
|
|
71 bne spnormal
|
|
72 spspecial
|
|
73 lbsr EndMAXCMP
|
|
74 spnormal
|
|
75
|
|
76 puls d,pc
|
|
77
|
|
78 *
|
|
79 * read header info from file, and set window type information
|
|
80 *
|
|
81 vsect dp
|
|
82 endoffile rmb 1
|
|
83 totsize rmb 2
|
|
84 double rmb 1 True: each line gets doubled.
|
|
85 doublef rmb 1 True: this is first time this line's been returned.
|
|
86 fillval rmb 1 Value to blank out lines with.
|
|
87 pmode rmb 1 Pmode 0,1,2,3,4,5=Art.
|
|
88 pformat rmb 1 Pseudo-format: maxcmpformat ->p41format, artcmp -> art
|
|
89 endsect
|
|
90
|
|
91 sizetable fcb 16,32,16,32,32,32 Bytes/line in PMode 0,1,2,3,4, ART
|
|
92
|
|
93 header
|
|
94 pshs a,b,x,y,u
|
|
95
|
|
96 lda <format
|
|
97 cmpa #MAXCMPFormat Handle MAXCMP specially
|
|
98 bne headmode1
|
|
99 lda #P41Format MAXCMP looks like PMode 4
|
|
100 bra headmode2
|
|
101 headmode1
|
|
102 cmpa #ARTCMPFormat Handle ARTCMP specially
|
|
103 bne headmode2
|
|
104 lda #ARTFormat ARTCMP looks like ART
|
|
105 headmode2
|
|
106 sta <pformat
|
|
107
|
|
108 lda <pformat
|
|
109 suba #P00Format
|
|
110 lsra Divide by two, so A holds the pmode
|
|
111 sta pmode
|
|
112 leax sizetable,pcr
|
|
113 ldb a,x
|
|
114 clra
|
|
115 std linesize Set number bytes/line
|
|
116
|
|
117 lda <pformat
|
|
118 cmpa #ARTFormat
|
|
119 beq headbord ART is _really_ a 2-color mode.
|
|
120 suba #P00Format 2-color modes need border set to 3, 4 color to 0
|
|
121 anda #2
|
|
122 bne headbord1
|
|
123 headbord
|
|
124 lda #3
|
|
125 sta <border
|
|
126 lda #$ff
|
|
127 sta fillval
|
|
128 headbord1
|
|
129
|
|
130 lda <pmode
|
|
131 cmpa #1 For PMode's 0 and 1, we double each line to simulate
|
|
132 bhi headdoub 96 line graphics screen
|
|
133 com double
|
|
134 headdoub
|
|
135
|
|
136 leax altbuff,y Read in header into altbuff
|
|
137 lda <format
|
|
138 cmpa #MAXCMPFormat First, is this MAXCMP or ARTCMP?
|
|
139 beq headspecial
|
|
140 cmpa #ARTCMPFormat
|
|
141 beq headspecial If so, go decode it, etc.
|
|
142 pshs y
|
|
143 ldy #5 Otherwise, just read the header.
|
|
144 lbsr I_Read
|
|
145 lbcs _error
|
|
146 puls y
|
|
147 bra headnormal
|
|
148 headspecial
|
|
149 lbsr MAXCMPdecode Decode MAXCMP picture, set up header info at ,X
|
|
150 headnormal
|
|
151
|
|
152 lda #6
|
|
153 sta <type Use screen type 6: 320x192 by 4 color
|
|
154
|
|
155 leax altbuff,y Now, interpret header.
|
|
156 lda ,x+
|
|
157 lbne E$Format This must be zero.
|
|
158 ldd ,x++
|
|
159 std totsize This gives total # bytes in file.
|
|
160 ldu linesize Calculate total number of lines in file.
|
|
161 pshs u
|
|
162 lsr 1,s
|
|
163 calclines
|
|
164 lsra Since linesize is always a power of two, this works.
|
|
165 rorb
|
|
166 lsr 1,s
|
|
167 bne calclines
|
|
168 puls u
|
|
169 tst double Are we doubling lines?
|
|
170 beq doubtot
|
|
171 lsla Yes, double the number of lines for proper scaling.
|
|
172 rolb
|
|
173 doubtot
|
|
174 std totlines
|
|
175
|
|
176 leax pals01,pcr First, handle artifacted stuff as a special case.
|
|
177 ldb <pmode
|
|
178 cmpb #5
|
|
179 beq headpals
|
|
180 leax pals00,pcr
|
|
181 ldb <pformat
|
|
182 subb #P00Format Formats alternate between the 4 palette choices.
|
|
183 andb #3 So, interpret mod 4.
|
|
184 lslb Times 4 to get the beginning of the palette
|
|
185 lslb
|
|
186 abx
|
|
187
|
|
188 headpals
|
|
189 leau palette,y
|
|
190 ldb #16
|
|
191 pshs b
|
|
192 headloop
|
|
193 lda ,x+
|
|
194 sta ,u+
|
|
195 dec ,s
|
|
196 bne headloop
|
|
197 puls b
|
|
198
|
|
199 * Set some miscellaneous variables
|
|
200 lda #1
|
|
201 sta <cyclestart Cycle palettes 1 and 2 to allow switching artifact modes
|
|
202 lda #2
|
|
203 sta <cycleend
|
|
204 clr <cycle
|
|
205 clr <extranum lda No color rotation
|
|
206
|
|
207 ldd <Skiplines
|
|
208 cmpd #$ffff Is Skiplines still default?
|
|
209 bne headskip No, don't change it.
|
|
210 ldd #0
|
|
211 std <Skiplines Set it to 0
|
|
212 headskip
|
|
213
|
|
214 lda <Size
|
|
215 bpl headsize
|
|
216 lda #1 Default to BIG size
|
|
217 sta <Size
|
|
218 headsize
|
|
219
|
|
220 puls a,b,x,y,u,pc
|
|
221
|
|
222 * Palettes for 2-color set 0, 2-color set 1, 4-color set 0, and 4-color set 1
|
|
223 pals00 fcb 0,0,0,18 Black and green.
|
|
224 pals01 fcb 0,9,36,63 Includes artifacted colors.
|
|
225 pals10 fcb 18,54,36,9
|
|
226 pals11 fcb 63,27,45,38
|
|
227
|
|
228
|
|
229 *
|
|
230 * Getline
|
|
231 *
|
|
232 getline
|
|
233 pshs a,b,x,y,u
|
|
234 * If doublef is set, return same line again
|
|
235 tst double Is double in effect?
|
|
236 beq nodoub No, just do normal thing.
|
|
237 tst doublef
|
|
238 bne getline1
|
|
239 nodoub
|
|
240 * First, clear out buffer
|
|
241 leau linebuff,y
|
|
242 lda fillval
|
|
243 ldb #160
|
|
244 getline3
|
|
245 sta ,u+
|
|
246 decb
|
|
247 bne getline3
|
|
248 * If at end of file, leave it that way
|
|
249 tst endoffile
|
|
250 lbne getline1
|
|
251 * Get a line from the file
|
|
252 leax linebuff+8,y read in one line of screen
|
|
253 ldd <totsize
|
|
254 cmpd linesize
|
|
255 bhs getlok
|
|
256 com endoffile If <1 line left, mark end of file and quit.
|
|
257 lbra getline1
|
|
258 getlok
|
|
259 pshs y
|
|
260 ldy linesize Get 1 line's worth
|
|
261 lbsr getmaxline
|
|
262 puls y
|
|
263 lbcs geteof Error through EOF check.
|
|
264 ldd <totsize
|
|
265 subd linesize Count down bytes in file.
|
|
266 std <totsize
|
|
267 * Now, we have to expand the bytes to get a good picture format.
|
|
268 ldb <pmode
|
|
269 bitb #1 Odd pmode's are 4-color
|
|
270 bne cnvcol
|
|
271 cnvbw
|
|
272 bsr oneexpand Everything else is 2-color.
|
|
273 bra cnvfinish
|
|
274 cnvcol
|
|
275 bsr twoexpand
|
|
276 cnvfinish
|
|
277 ldd linesize
|
|
278 lslb We already doubled the line size once.
|
|
279 cnfloop
|
|
280 cmpb #64
|
|
281 bhs getline7
|
|
282 bsr twoexpand Expand out line until it's 64 bytes long.
|
|
283 lslb
|
|
284 bra cnfloop
|
|
285
|
|
286 getline7
|
|
287 tst <Size
|
|
288 bne getline1 If Big or larger, don't do horizontal scaling
|
|
289 ldd <totlines
|
|
290 cmpd #300
|
|
291 blo getline1 If not double-page, don't do scaling.
|
|
292 bsr horscale Do the scaling
|
|
293 bra getline1 End.
|
|
294
|
|
295 geteof
|
|
296 cmpb #E$EOF
|
|
297 bne getline4
|
|
298 com endoffile
|
|
299 bra getline1
|
|
300 getline4
|
|
301 lbra _error If not EOF, just exit with error.
|
|
302 getline1
|
|
303 com doublef Complement double flag.
|
|
304 puls a,b,x,y,u,pc
|
|
305
|
|
306 * X points to location, Y holds needed count
|
|
307 getmaxline
|
|
308 pshs a
|
|
309 lda <format
|
|
310 cmpa #MAXCMPFormat
|
|
311 beq getlinespecial
|
|
312 cmpa #ARTCMPFormat
|
|
313 beq getlinespecial
|
|
314
|
|
315 lbsr I_Read Just Read line if normal file
|
|
316 bra getlinenormal
|
|
317 getlinespecial
|
|
318
|
|
319 lbsr MAXCMPline
|
|
320 getlinenormal
|
|
321 puls a,pc
|
|
322
|
|
323 arttable fcb $00,$05,$0A,$0F,$50,$55,$5A,$5F,$A0,$A5,$AA,$AF,$F0,$F5,$FA,$FF
|
|
324 pm4table fcb $00,$03,$0C,$0F,$30,$33,$3C,$3F,$C0,$C3,$CC,$CF,$F0,$F3,$FC,$FF
|
|
325
|
|
326 oneexpand
|
|
327 pshs a,b,x,y,u
|
|
328 leay pm4table,pcr Expand each 1 bit to 2 bits
|
|
329 bra cnvdo
|
|
330 twoexpand
|
|
331 pshs a,b,x,y,u
|
|
332 leay arttable,pcr Double each 2 bits
|
|
333 cnvdo
|
|
334 leau 64,x
|
|
335 leax 32,x Expand 32 bytes out to 64.
|
|
336 lda #32
|
|
337 pshs a
|
|
338 cnvloop
|
|
339 lda ,-x
|
|
340 tfr a,b
|
|
341 lsra
|
|
342 lsra
|
|
343 lsra
|
|
344 lsra
|
|
345 andb #$0f
|
|
346 lda a,y
|
|
347 ldb b,y
|
|
348 std ,--u
|
|
349 dec ,s
|
|
350 bne cnvloop
|
|
351 puls a
|
|
352 puls a,b,x,y,u,pc
|
|
353
|
|
354 *
|
|
355 * Take the picture line and squeeze it horizontally by half.
|
|
356 *
|
|
357 horscale
|
|
358 pshs a,b,x,u
|
|
359 leax linebuff+8,y
|
|
360 leau linebuff+8,y
|
|
361 bsr horsub1
|
|
362 leax linebuff+72,y
|
|
363 leau linebuff+40,y
|
|
364 bsr horsub2
|
|
365 puls a,b,x,u,pc
|
|
366
|
|
367 horsub0
|
|
368 bsr horsuba Do it twice.
|
|
369 horsuba
|
|
370 lslb Move 1 pixel over, skip one.
|
|
371 rola
|
|
372 lslb
|
|
373 rola
|
|
374 lslb
|
|
375 lslb
|
|
376 rts
|
|
377
|
|
378 * Compress the picture.
|
|
379 horsub1
|
|
380 ldb #32 We do two bytes at a time.
|
|
381 pshs b
|
|
382 horsloop
|
|
383 ldb ,x+
|
|
384 bsr horsub0
|
|
385 ldb ,x+
|
|
386 bsr horsub0
|
|
387 sta ,u+
|
|
388 dec ,s
|
|
389 bne horsloop
|
|
390 puls b
|
|
391 rts
|
|
392
|
|
393 * Center result data on line.
|
|
394 horsub2
|
|
395 bsr horsub3 Clear out last 16 bytes on line.
|
|
396 ldb #32
|
|
397 horsloop2
|
|
398 lda ,-u Move 32 bytes to center.
|
|
399 sta ,-x
|
|
400 decb
|
|
401 bne horsloop2
|
|
402 horsub3
|
|
403 lda linebuff,y
|
|
404 ldb #16
|
|
405 horsloop3
|
|
406 sta ,-x Clear out first 16 bytes.
|
|
407 decb
|
|
408 bne horsloop3
|
|
409 rts
|
|
410
|
|
411 endsect
|