1706
|
1 ********************************************************************************
|
|
2 *
|
|
3 * SUBS for MGE picture formats
|
|
4 *
|
|
5 * MGEshowpic -- displays picture on screen
|
|
6 *
|
|
7 ********************************************************************************
|
|
8
|
|
9 ifp1
|
1912
|
10 use os9defs.d
|
1706
|
11 endc
|
|
12
|
|
13 StdOut equ 1
|
|
14 StdErr equ 2
|
|
15
|
|
16 psect view_mge_a,0,0,0,0,0
|
|
17
|
|
18 vsect
|
|
19 picname rmb 30
|
|
20 endsect
|
|
21
|
|
22 MGEshowpic:
|
|
23 bsr header
|
|
24 lbsr setscreen
|
|
25 lbsr setpals
|
|
26 lbsr setbuffer
|
|
27 lbsr showname
|
|
28
|
|
29 ldd <Skiplines
|
|
30 beq skip01
|
|
31 skip00
|
|
32 lbsr getline
|
|
33 subd #1
|
|
34 bne skip00
|
|
35 skip01
|
|
36
|
|
37 ldd #00
|
|
38 showpicouter
|
|
39 ldx #25
|
|
40 showpicloop
|
|
41 lbsr getline
|
|
42 tst <Size
|
|
43 bne showpic2
|
|
44 leax -1,x
|
|
45 beq showpicouter
|
|
46 showpic2
|
|
47
|
|
48 lbsr putline
|
|
49 addd #1
|
|
50 cmpd #192
|
|
51 bne showpicloop
|
|
52 rts
|
|
53
|
|
54 *
|
|
55 * read header info from file, and set window type information
|
|
56 * Uses altbuff to read header info into.
|
|
57 *
|
|
58 vsect dp
|
|
59 compressed rmb 1 0=Compressed format in use
|
|
60 count rmb 1 Count/value is used for compressed format
|
|
61 value rmb 1
|
|
62 endoffile fcb 0 T= EOF reached, so always return linebuff all 0
|
|
63 endsect
|
|
64
|
|
65 header
|
|
66 pshs a,b,x,y,u
|
|
67 leax altbuff,y read in type and palettes
|
|
68 pshs y
|
|
69 ldy #51
|
|
70 lbsr I_Read
|
|
71 lbcs _error
|
|
72 puls y
|
|
73 leax altbuff,y
|
|
74 lda ,x+ This byte must be zero.
|
|
75 lbne E$Format
|
|
76 leau palette,y
|
|
77 ldb #16
|
|
78 headloop
|
|
79 lda ,x+
|
|
80 sta ,u+
|
|
81 decb
|
|
82 bne headloop
|
|
83
|
|
84 lda ,x+
|
|
85 beq headrgb
|
|
86 lbsr cmpconv
|
|
87 headrgb
|
|
88
|
|
89 lda <type
|
|
90 bne headtype
|
|
91 lda #8 Std MGE defaults to type 8
|
|
92 sta <type
|
|
93 ldb <format
|
|
94 cmpb #MGE640Format 640 defaults to type 7
|
|
95 bne headtype
|
|
96 lda #7
|
|
97 sta <type
|
|
98 headtype
|
|
99
|
|
100 lda ,x+
|
|
101 sta compressed
|
|
102 clr count
|
|
103
|
|
104 ldb #30
|
|
105 leau picname,y
|
|
106 headname
|
|
107 lda ,x+
|
|
108 sta ,u+
|
|
109 decb
|
|
110 bne headname
|
|
111
|
|
112 * Set rotation speed
|
|
113 ldb ,x+
|
|
114 clra
|
|
115 std <cyclerate
|
|
116
|
|
117 * Set limits for palette rotation
|
|
118 lda ,x+
|
|
119 tfr a,b
|
|
120 lsra
|
|
121 lsra
|
|
122 lsra
|
|
123 lsra
|
|
124 sta <cyclestart
|
|
125 andb #$0f
|
|
126 stb <cycleend
|
|
127
|
|
128 * Set default Skiplines.
|
|
129 ldd <Skiplines
|
|
130 cmpd #$ffff
|
|
131 bne headskip
|
|
132 ldd #0
|
|
133 std <Skiplines
|
|
134 headskip
|
|
135
|
|
136 * Set default Size
|
|
137 lda <Size
|
|
138 bpl headsize Default to Small size
|
|
139 lda #0
|
|
140 sta <Size
|
|
141 headsize
|
|
142
|
|
143 puls a,b,x,y,u,pc
|
|
144
|
|
145 *
|
|
146 * Getpair
|
|
147 *
|
|
148 getpair
|
|
149 pshs x,y
|
|
150 leax count,y
|
|
151 ldy #2
|
|
152 lbsr I_Read
|
|
153 lbcc getpair1 No error, don't worry.
|
|
154 cmpb #E$EOF Was it EOF?
|
|
155 beq getpair2
|
|
156 lbra _error No, error.
|
|
157 getpair2
|
|
158 ldd #0 Yes, translate into compressed MGE 0,0 EOF marker
|
|
159 std count
|
|
160 getpair1
|
|
161 puls x,y
|
|
162 ldd count
|
|
163 rts
|
|
164
|
|
165 *
|
|
166 * Getline
|
|
167 *
|
|
168 getline
|
|
169 pshs a,b,x,y,u
|
|
170 leau linebuff,y
|
|
171 ldb #160
|
|
172 getl1
|
|
173 clr ,u+
|
|
174 decb
|
|
175 bne getl1
|
|
176
|
|
177 tst endoffile Are we at end-of-file?
|
|
178 bne getline1
|
|
179
|
|
180 tst compressed Is it compressed mode?
|
|
181 bne getnormal 0 -> compressed.
|
|
182 * Get a line from compressed file
|
|
183 leau linebuff,y Where we'll put the line.
|
|
184 ldx #160 Number of bytes in one line.
|
|
185 ldd count Get count/value
|
|
186 getl2
|
|
187 tsta Count non-zero?
|
|
188 bne getl3
|
|
189 lbsr getpair Yes, get another count/value pair.
|
|
190 cmpa #0 Zero count -> EOF
|
|
191 bne getl3
|
|
192 com endoffile Set end-of-file flag
|
|
193 bra getline1
|
|
194 getl3
|
|
195 stb ,u+ Store a copy of current value
|
|
196 deca Count down number of reps
|
|
197 leax -1,x Count down size of line
|
|
198 bne getl2 If not end of line, continue
|
|
199 std count Otherwise, store remaining count.
|
|
200 bra getline1
|
|
201 * Get a line from uncompressed file
|
|
202 getnormal
|
|
203 leax linebuff,y read in one line of screen
|
|
204 ldy #160 Warning! Y munged.
|
|
205 lbsr I_Read
|
|
206 lbcc getline1
|
|
207 cmpb #E$EOF We have a special message for premature EOF
|
|
208 bne getnor1
|
|
209 com endoffile Flag end-of-file condition
|
|
210 bra getline1 Keep on going.
|
|
211 getnor1
|
|
212 lbra _error If not EOF, just exit with error.
|
|
213 getline1
|
|
214 puls a,b,x,y,u,pc
|
|
215
|
|
216 CurPos fcb $1b,$32,$0f,$02,$25,$37 Set foreground to pal#15, position cursor
|
|
217 showname
|
|
218 pshs a,b,x,y,u
|
|
219 leau picname,y
|
|
220
|
|
221 tfr u,x
|
|
222 clr 29,x Just to make sure we do hit a null...
|
|
223 ldy #0
|
|
224 shownloop
|
|
225 leay 1,y
|
|
226 ldb ,x+
|
|
227 cmpb #$20
|
|
228 bge shownloop
|
|
229
|
|
230 pshs y
|
|
231
|
|
232 leax CurPos,pcr Position the cursor to the bottom of the screen.
|
|
233 tfr y,d
|
|
234 subb #40
|
|
235 negb
|
|
236 lsrb
|
|
237 addb #$20
|
|
238 stb 4,x
|
|
239 ldy #6
|
|
240 lda <outpath
|
|
241 os9 I$Write
|
|
242 lbcs _error
|
|
243
|
|
244 puls y
|
|
245 tfr u,x
|
|
246 lda <outpath
|
|
247 os9 I$Write
|
|
248 lbcs _error
|
|
249 puls a,b,x,y,u,pc
|
|
250
|
|
251 endsect
|