1706
|
1 *****************************************************************************
|
|
2 * *
|
|
3 * SUBS for st picture format *
|
|
4 * *
|
|
5 * STshowpic -- 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
|
1777
|
17 use os9defs.a
|
1706
|
18 endc
|
|
19
|
|
20 psect view_st_a,0,0,0,0,0
|
|
21
|
|
22 vsect dp
|
|
23 linesize rmb 2 Bytes per line.
|
|
24 totlines rmb 2 total lines in picture.
|
|
25 curline rmb 2 Number of current screen line.
|
|
26 fitcount rmb 2 Used to decide what lines to skip.
|
|
27 linesleft rmb 2 Lines left in picture.
|
|
28 endsect
|
|
29
|
|
30 STshowpic:
|
|
31 bsr header Get header info
|
|
32
|
|
33 ldd <Skiplines
|
|
34 beq skip01
|
|
35 skip00
|
|
36 lbsr getline
|
|
37 subd #1
|
|
38 bne skip00
|
|
39 skip01
|
|
40
|
|
41 spscreens
|
|
42 lbsr getline
|
|
43
|
|
44 tst <endoffile
|
|
45 bne showpicend
|
|
46 lbsr setscreen Set up screen
|
|
47 lbsr setpals Set up palettes
|
|
48 lbsr setbuffer Set up Get/Put Buffer
|
|
49
|
|
50 ldd #00
|
|
51 std curline
|
|
52 showpicloop
|
|
53 lbsr putline
|
|
54 ldd fitcount
|
|
55 addd totlines
|
|
56 spget
|
|
57 std fitcount
|
|
58 lbsr getline
|
|
59 tst <Size
|
|
60 bne spnofit
|
|
61 ldd fitcount
|
|
62 subd #192
|
|
63 bge spget
|
|
64 std fitcount
|
|
65 spnofit
|
|
66 ldd curline
|
|
67 addd #1
|
|
68 std curline
|
|
69 cmpd #192
|
|
70 bne showpicloop
|
|
71 ldd linesleft
|
|
72 cmpd #16
|
|
73 bhi spscreens
|
|
74 showpicend
|
|
75 rts
|
|
76
|
|
77 *
|
|
78 * read header info from file, and set window type information
|
|
79 *
|
|
80 vsect dp
|
|
81 endoffile rmb 1
|
|
82 endsect
|
|
83
|
|
84 header
|
|
85 pshs a,b,x,y,u
|
|
86 leax altbuff,y read in type and palettes into altbuff
|
|
87 pshs y
|
|
88 ldy #34
|
|
89 lbsr I_Read
|
|
90 lbcs _error
|
|
91 puls y
|
|
92 leax altbuff,y
|
|
93 lda ,x+
|
|
94
|
|
95 lda ,x+ This byte is the screen type.
|
|
96
|
|
97 bne head0
|
|
98 lda #8
|
|
99 sta <type
|
|
100 ldd #200
|
|
101 std totlines
|
|
102 std linesleft
|
|
103 ldd #160
|
|
104 std linesize
|
|
105 bra headpals
|
|
106 head0
|
|
107
|
|
108 cmpa #1
|
|
109 bne head1
|
|
110 lda #7
|
|
111 sta <type
|
|
112 ldd #200
|
|
113 std totlines
|
|
114 std linesleft
|
|
115 ldd #160
|
|
116 std linesize
|
|
117 bra headpals
|
|
118 head1
|
|
119
|
|
120 cmpa #2
|
|
121 bne head2
|
|
122 lda #5 640 2-color screen.
|
|
123 sta <type
|
|
124 ldd #400
|
|
125 std totlines
|
|
126 std linesleft
|
|
127 ldd #80
|
|
128 std linesize
|
|
129 bra headpals
|
|
130 head2
|
|
131
|
|
132 headpals
|
|
133 leau palette,y Need to expand palettes out to 3 bytes/palette
|
|
134 ldb #16 16 palettes to expand out.
|
|
135 headexp
|
|
136 lda ,x+
|
|
137 anda #$0f Red is in lower nybble of first byte.
|
|
138 sta ,u+
|
|
139 lda ,x Second byte is: upper nybble green, lower nybble blue.
|
|
140 lsra
|
|
141 lsra
|
|
142 lsra
|
|
143 lsra
|
|
144 sta ,u+
|
|
145 lda ,x+
|
|
146 anda #$0f
|
|
147 sta ,u+
|
|
148 decb
|
|
149 bne headexp
|
|
150
|
|
151 lbsr palscale First, scale so largest is 255
|
|
152 lbsr palconv Convert palette values from ST to CoCo format
|
|
153
|
|
154 * Set some miscellaneous variables
|
|
155 lda <cyclestart No cycling
|
|
156 sta <cycleend
|
|
157 clr <extranum No color rotation
|
|
158
|
|
159 ldd <Skiplines
|
|
160 cmpd #$ffff Is Skiplines still default?
|
|
161 bne headskip No, don't change it.
|
|
162 ldd #0
|
|
163 std <Skiplines Set it to 0
|
|
164 headskip
|
|
165
|
|
166 lda <Size
|
|
167 bpl headsize Default size is BIG
|
|
168 lda #1
|
|
169 sta <Size
|
|
170 headsize
|
|
171
|
|
172 puls a,b,x,y,u,pc
|
|
173
|
|
174 *
|
|
175 * Getline
|
|
176 *
|
|
177 getline
|
|
178 pshs a,b,x,y,u
|
|
179 * First, fill buffers with all zeros
|
|
180 leau linebuff,y
|
|
181 leax altbuff,y
|
|
182 ldb #160
|
|
183 getline3
|
|
184 clr ,u+
|
|
185 clr ,x+
|
|
186 decb
|
|
187 bne getline3
|
|
188 * If at end of file, leave it that way
|
|
189 tst endoffile
|
|
190 beq getline5
|
|
191 ldd #0
|
|
192 std linesleft First, set number of lines remaining to zero.
|
|
193 lbra getline1
|
|
194 getline5
|
|
195 * Count down lines left
|
|
196 ldd linesleft
|
|
197 bne getline6
|
|
198 com endoffile If no lines left, force end of file condition.
|
|
199 lbra getline1
|
|
200 getline6
|
|
201 subd #1
|
|
202 std linesleft
|
|
203 * Get a line from the file
|
|
204 leax altbuff,y read in one line of screen
|
|
205 pshs y
|
|
206 ldy <linesize Warning: Mung Y!
|
|
207 lbsr I_Read
|
|
208 puls y
|
|
209 lbcs geteof Error through EOF check.
|
|
210 * Now, we have to interleave the bits to get CoCo screen format.
|
|
211 leax altbuff,y
|
|
212 leau linebuff,y
|
|
213 ldy <linesize Total number of bytes to convert.
|
|
214 lda <type
|
|
215
|
|
216 cmpa #5
|
|
217 bne conv5
|
|
218 cnv5loop
|
|
219 lda ,x+ This type screen, just copy the data.
|
|
220 sta ,u+
|
|
221 leay -1,y
|
|
222 bne cnv5loop
|
|
223 lbra getline1
|
|
224 conv5
|
|
225
|
|
226 cmpa #7 Type 7 screen requires 2-way interleaving.
|
|
227 bne conv7
|
|
228 cnv7loop
|
|
229 lbsr twolev
|
|
230 leax 1,x
|
|
231 lbsr twolev
|
|
232 leax 3,x
|
|
233 leay -4,y
|
|
234 bne cnv7loop
|
|
235 lbra getline1 Now we're done.
|
|
236 conv7
|
|
237
|
|
238 cmpa #8 Type 8 screen requires 4-way interleaving.
|
|
239 bne conv8
|
|
240 cnv8loop
|
|
241 lbsr fourlev Convert 4 bytes out of 8 -- X-X-X-X-
|
|
242 leax 1,x Offset to next 4
|
|
243 lbsr fourlev Convert 4 bytes out of 8 -- -X-X-X-X
|
|
244 leax 7,x Now, skip to next 8.
|
|
245 leay -8,y Count down number of bytes.
|
|
246 bne cnv8loop
|
|
247 bra getline1 Now exit.
|
|
248 conv8
|
|
249 bra getline1 Now exit.
|
|
250
|
|
251 geteof
|
|
252 cmpb #E$EOF
|
|
253 bne getline4
|
|
254 com endoffile
|
|
255 bra getline1
|
|
256 getline4
|
|
257 lbra _error If not EOF, just exit with error.
|
|
258 getline1
|
|
259 puls a,b,x,y,u,pc
|
|
260
|
|
261 * converts bytes 0,x 2,x 4,x and 6,x into 4 CoCo-format bytes
|
|
262 * at [u]. U is advanced by 4, other regs unchanged.
|
|
263
|
|
264 fourtab
|
|
265 fdb $0000,$0001,$0010,$0011,$0100,$0101,$0110,$0111
|
|
266 fdb $1000,$1001,$1010,$1011,$1100,$1101,$1110,$1111
|
|
267
|
|
268 fourlev
|
|
269 pshs a,b,x,y
|
|
270 leay fourtab,pcr
|
|
271 ldb #4
|
|
272 pshs b 4 bytes to worry about.
|
|
273 bra fourlev1
|
|
274 fourlev0
|
|
275 lsl 3,u
|
|
276 rol 2,u
|
|
277 rol 1,u
|
|
278 rol ,u
|
|
279 fourlev1
|
|
280 lda ,x Get high nybble of byte.
|
|
281 lsra
|
|
282 lsra
|
|
283 lsra
|
|
284 anda #$1e
|
|
285 ldd a,y Expand it out.
|
|
286 ora ,u Or it into stuff so far.
|
|
287 orb 1,u
|
|
288 std ,u
|
|
289 lda ,x++ Get low nybble, and advance to next byte.
|
|
290 anda #$0f
|
|
291 lsla
|
|
292 ldd a,y Expand it out.
|
|
293 ora 2,u Or into stuff so far.
|
|
294 orb 3,u
|
|
295 std 2,u
|
|
296 dec ,s Have we done all four bytes?
|
|
297 bne fourlev0
|
|
298 puls b Clean up stack.
|
|
299 leau 4,u
|
|
300 puls a,b,x,y,pc
|
|
301
|
|
302 twolev
|
|
303 bsr twolev1
|
|
304 twolev1
|
|
305 pshs a,b
|
|
306 ldb #4
|
|
307 twoloop
|
|
308 lsl ,x
|
|
309 rola
|
|
310 lsl 2,x
|
|
311 rola
|
|
312 decb
|
|
313 bne twoloop
|
|
314 sta ,u+
|
|
315 puls a,b,pc
|
|
316
|
|
317
|
|
318 endsect
|