1706
|
1 *
|
|
2 * Save current picture to a file
|
|
3 * DoSave: - Save current screen to file in specified format
|
|
4 * Currently supports VEFFormat, VEFSqFormat, MGEFormat, CM3Format
|
|
5 * Note: Since SetSave does not clear a file (DoSave resets the filesize to
|
|
6 * zero when it starts), VIEW can be used to convert a file in place
|
|
7 * by just saving back to the original file.
|
|
8 *
|
|
9
|
|
10 ifp1
|
1777
|
11 use os9defs.a
|
1706
|
12 endc
|
|
13
|
|
14 check macro
|
|
15 pshs b,cc
|
|
16 ldb #\1
|
|
17 os9 F$PErr
|
|
18 puls b,cc
|
|
19 endm
|
|
20
|
|
21 StdIn equ 0
|
|
22 StdOut equ 1
|
|
23 StdErr equ 2
|
|
24
|
|
25 psect view_save_a,0,0,0,0,0
|
|
26
|
|
27 vsect dp
|
|
28 SaveFormat: rmb 1 Also used in view_setsave.a
|
|
29 SavePath: rmb 1
|
|
30 LineSize rmb 2
|
|
31 endsect
|
|
32
|
|
33
|
|
34 *
|
|
35 * Do the actual save.
|
|
36 *
|
|
37 DoSave:
|
|
38 pshs a,b,x,y,u
|
|
39 lda #$ff
|
|
40 sta <abort Set to abort on signal.
|
|
41
|
|
42 * Set up line buffer for screen I/O
|
|
43 lbsr setbuffer
|
|
44
|
|
45 * First, set file size to zero, in case it was pre-existing.
|
|
46 lda SavePath
|
|
47 lbeq DoSaveEnd
|
|
48
|
|
49 ldb #SS.Size
|
|
50 ldx #0
|
|
51 tfr x,u
|
|
52 os9 I$SetStt
|
|
53 lbcs _error
|
|
54
|
|
55
|
|
56 * We'll need to know the size in bytes of one line, so figure that out
|
|
57 lda <type
|
|
58 ldb #80 Types 5 and 6 are 80 bytes/line
|
|
59 cmpa #7
|
|
60 blo Dosize
|
|
61 ldb #160 Types 7 and 8 are 160 bytes/line
|
|
62 Dosize
|
|
63 clra
|
|
64 std LineSize
|
|
65
|
|
66 lda SaveFormat If MGE Format save, write an MGE format header.
|
|
67 cmpa #MGE640Format
|
|
68 beq DoMGE1
|
|
69 cmpa #MGEFormat
|
|
70 bne DoMGE
|
|
71 DoMGE1
|
|
72 lbsr MGEHeader
|
|
73 DoMGE
|
|
74
|
|
75 lda SaveFormat If VEF Format save, write a VEF format header.
|
|
76 cmpa #VEFFormat
|
|
77 beq DoVEF1
|
|
78 cmpa #VEFSqFormat
|
|
79 bne DoVEF
|
|
80 DoVEF1
|
|
81 lbsr VEFHeader
|
|
82 DoVEF
|
|
83
|
|
84 lda SaveFormat
|
|
85 cmpa #CM3Format
|
|
86 bne DoCM3
|
|
87 lbsr CM3Header
|
|
88 DoCM3
|
|
89
|
|
90 * Now output rest of file
|
|
91 ldd #0
|
|
92 DoOut
|
|
93 lbsr fetchline
|
|
94 lbsr comline
|
|
95 lbsr putline Copy the line back to the screen, for visual feedback.
|
|
96 lbsr comline
|
|
97 lbsr outline
|
|
98 lbsr putline
|
|
99 addd #1
|
|
100 cmpd #192
|
|
101 bne DoOut
|
|
102
|
|
103 lda SaveFormat For MGE format, add 8 blank lines to end of file.
|
|
104 cmpa #MGE640Format
|
|
105 beq DoMGE11
|
|
106 cmpa #MGEFormat
|
|
107 bne DoMGE10
|
|
108 DoMGE11
|
|
109 lbsr Save8
|
|
110 DoMGE10
|
|
111
|
|
112 * Now close the file
|
|
113 lda SavePath
|
|
114 os9 I$Close
|
|
115 lbcs _error
|
|
116
|
|
117 * Print message on successful completion
|
|
118 leax str1done,pcr Output first part of message
|
|
119 lbsr O_Write
|
|
120
|
|
121 ldb SaveFormat
|
|
122 leax strVEF,pcr
|
|
123 cmpb #VEFFormat Is it VEF?
|
|
124 beq DoneSave
|
|
125
|
|
126 leax strMGE,pcr
|
|
127 cmpb #MGEFormat Is it MGE?
|
|
128 bne DoneSave1
|
|
129 ldb <type
|
|
130 cmpb #6 Type 6/8 are MGE
|
|
131 beq DoneSave
|
|
132 cmpb #8
|
|
133 beq DoneSave
|
|
134 leax str640,pcr Types 5/7 are 640.
|
|
135 bra DoneSave
|
|
136 DoneSave1
|
|
137
|
|
138 leax str640,pcr
|
|
139 cmpb #MGE640Format Is it 640?
|
|
140 bne DoneSave2
|
|
141 ldb <type
|
|
142 cmpb #8 Type 8 is MGE
|
|
143 bne DoneSave
|
|
144 leax strMGE,pcr
|
|
145 bra DoneSave
|
|
146 DoneSave2
|
|
147
|
|
148 leax strVEFSq,pcr
|
|
149 cmpb #VEFSqFormat Is it VEF Squashed?
|
|
150 beq DoneSave
|
|
151
|
|
152 leax strCM3,pcr
|
|
153 cmpb #CM3Format CM3 format
|
|
154 bne DoneSave3
|
|
155 ldb <type
|
|
156 cmpb #6 Type 6/8 are normal CM3
|
|
157 beq DoneSave
|
|
158 cmpb #8
|
|
159 beq DoneSave
|
|
160 leax strCM3640,pcr Types 5/7 are 640 across CM3.
|
|
161 bra DoneSave
|
|
162 DoneSave3
|
|
163
|
|
164 * Add other formats here
|
|
165 DoneSave
|
|
166 lbsr O_Write
|
|
167
|
|
168 leax str2done,pcr Output second part.
|
|
169 lbsr O_Write
|
|
170
|
|
171 DoSaveEnd
|
|
172 puls a,b,x,y,u,pc
|
|
173
|
|
174 strVEF fcc "normal VEF"
|
|
175 fcb 0
|
|
176 strMGE fcc "MGE"
|
|
177 fcb 0
|
|
178 str640 fcc "640 (MGE 640x200)"
|
|
179 fcb 0
|
|
180 strVEFSq fcc "VEF Squashed"
|
|
181 fcb 0
|
|
182 strCM3 fcc "CM3"
|
|
183 fcb 0
|
|
184 strCM3640 fcc "CM3 (640x192)"
|
|
185 fcb 0
|
|
186 str1done fcc "Picture saved in "
|
|
187 fcb 0
|
|
188 str2done fcc " format."
|
|
189 fcb $0d,0
|
|
190
|
|
191 * Clear out linebuff
|
|
192 clrline
|
|
193 pshs a,b,x
|
|
194 leax linebuff,y
|
|
195 clra
|
|
196 ldb #200
|
|
197 DoClear
|
|
198 sta ,x+
|
|
199 decb
|
|
200 bne DoClear
|
|
201 puls a,b,x,pc
|
|
202
|
|
203 * Complement linebuff
|
|
204 comline
|
|
205 pshs b,x
|
|
206 ldb #160
|
|
207 leax linebuff,y
|
|
208 comline1
|
|
209 com ,x+
|
|
210 decb
|
|
211 bne comline1
|
|
212 puls b,x,pc
|
|
213
|
|
214 * Output an MGE header
|
|
215 MGEHeader
|
|
216 pshs a,b,x,y,u
|
|
217 leax altbuff,y
|
|
218 clr ,x+ Initial 0 byte.
|
|
219 lbsr copypals
|
|
220 clr ,x+ Mark RGB
|
|
221 lda #$ff
|
|
222 sta ,x+ We're not using MGE compression (blech!)
|
|
223 leau MGEname,pcr Give this a generic name.
|
|
224 ldb #30
|
|
225 MGEhead1
|
|
226 lda ,u+
|
|
227 sta ,x+
|
|
228 decb
|
|
229 bne MGEhead1
|
|
230 ldd <cyclerate
|
|
231 stb ,x+ Save cycle rate
|
|
232 lda <cyclestart
|
|
233 lsla
|
|
234 lsla
|
|
235 lsla
|
|
236 lsla
|
|
237 ora <cycleend
|
|
238 sta ,x+ Save first/last palette rotation values.
|
|
239
|
|
240 leax altbuff,y Write the actual header.
|
|
241 lda SavePath
|
|
242 ldy #51
|
|
243 os9 I$Write
|
|
244 puls a,b,x,y,u,pc
|
|
245
|
|
246 MGEname fcc "OS9 picture"
|
|
247 fcb 0
|
|
248
|
|
249 * Output a CM3 header
|
|
250 CM3Header
|
|
251 pshs a,b,x,y,u
|
|
252 leax altbuff,y
|
|
253 lda #1 Single screen w/o patterns
|
|
254 sta ,x+
|
|
255 lbsr copypals 16 palette values
|
|
256 ldd <cyclerate
|
|
257 bne CM3head0
|
|
258 ldb #1
|
|
259 CM3head0
|
|
260 stb ,x+ Cycle rate
|
|
261 ldd <extrarate
|
|
262 bne CM3head1
|
|
263 ldb #1
|
|
264 CM3head1
|
|
265 stb ,x+ Extra rate
|
|
266 leau extrapals,y
|
|
267 ldd ,u++
|
|
268 std ,x++ Copy extrapals to header
|
|
269 ldd ,u++
|
|
270 std ,x++
|
|
271 ldd ,u++
|
|
272 std ,x++
|
|
273 ldd ,u++
|
|
274 std ,x++
|
|
275 lda <cycle
|
|
276 beq CM3head2
|
|
277 lda #$80
|
|
278 CM3head2
|
|
279 sta ,x+ Cycle enable flag
|
|
280 lda <extranum
|
|
281 beq CM3head3
|
|
282 lda #$80
|
|
283 CM3head3
|
|
284 sta ,x+ Extra enable flag
|
|
285 lda #192
|
|
286 sta ,x+ Number lines in picture
|
|
287
|
|
288 pshs y
|
|
289 lda SavePath
|
|
290 leax altbuff,y Now, save the header.
|
|
291 ldy #30
|
|
292 os9 I$Write
|
|
293 lbcs _error
|
|
294 puls y
|
|
295
|
|
296 leax alt2buff,y CM3 uses alt2buff to store last line data
|
|
297 ldy #500
|
|
298 clra
|
|
299 clrb
|
|
300 CM3head4
|
|
301 std ,x++
|
|
302 leay -1,y
|
|
303 bne CM3head4
|
|
304
|
|
305 puls a,b,x,y,u,pc
|
|
306
|
|
307 * Output a VEF header
|
|
308 VEFHeader
|
|
309 pshs a,b,x,y,u
|
|
310 leax altbuff,y
|
|
311 clra For normal format
|
|
312 ldb SaveFormat
|
|
313 cmpb #VEFFormat Plain vanilla??
|
|
314 beq Do1
|
|
315 lda #$80 For Squashed format
|
|
316 Do1
|
|
317 sta ,x+
|
|
318 lda #9
|
|
319 suba <type Get VEF screen type
|
|
320 cmpa #2
|
|
321 bhi Do2
|
|
322 deca
|
|
323 Do2
|
|
324 sta ,x+
|
|
325
|
|
326 bsr copypals Now copy the palettes.
|
|
327
|
|
328 * Now save the header out to the file.
|
|
329 leax altbuff,y
|
|
330 lda SavePath
|
|
331 pshs y
|
|
332 ldy #18
|
|
333 os9 I$Write
|
|
334 lbcs _error
|
|
335 puls y
|
|
336 bsr Save8
|
|
337 puls a,b,x,y,u,pc
|
|
338
|
|
339 * Write out 8 blank lines to file.
|
|
340 Save8
|
|
341 pshs b
|
|
342 lbsr clrline
|
|
343 ldb #8
|
|
344 DoBlank
|
|
345 lbsr outline
|
|
346 decb
|
|
347 bne DoBlank
|
|
348 puls b,pc
|
|
349
|
|
350 *
|
|
351 * Copy palettes to X, advance X by 16 bytes.
|
|
352 *
|
|
353 copypals
|
|
354 pshs a,b
|
|
355 lda <outpath
|
|
356 ldb #SS.Palet
|
|
357 os9 I$GetStt
|
|
358 leax 16,x
|
|
359 puls a,b,pc
|
|
360
|
|
361 *
|
|
362 * Output linebuff to file
|
|
363 outline
|
|
364 pshs a
|
|
365 lda SaveFormat
|
|
366 cmpa #VEFSqFormat
|
|
367 bne outline1
|
|
368 puls a
|
|
369 lbra outsqline Only VEF Squashed format uses outsqline
|
|
370 outline1
|
|
371 cmpa #VEFFormat
|
|
372 bne outline2
|
|
373 puls a
|
|
374 lbra outVEFline Unsquashed VEF line.
|
|
375 outline2
|
|
376 cmpa #MGEFormat
|
|
377 bne outline3
|
|
378 puls a
|
|
379 bra outMGEline Unsquashed MGE line.
|
|
380 outline3
|
|
381 cmpa #MGE640Format
|
|
382 bne outline4
|
|
383 puls a
|
|
384 bra outMGEline Unsquashed MGE line.
|
|
385 outline4
|
|
386 cmpa #CM3Format
|
|
387 bne outline5
|
|
388 puls a
|
|
389 bra outCM3line Output CM3 line.
|
|
390 outline5
|
|
391 * Additional formats go here.
|
|
392 outlineend
|
|
393 puls a
|
|
394 rts
|
|
395
|
|
396 *
|
|
397 * Output linebuff to file in normal MGE format
|
|
398 *
|
|
399 outMGEline
|
|
400 pshs a,b,x,y,u
|
|
401 lbsr MGEsame
|
|
402 leax altbuff,y
|
|
403 lda <type
|
|
404 cmpa #5
|
|
405 bne outMGE1
|
|
406 lbsr MGE57 Convert type 5 to type 7.
|
|
407 bra outMGE3
|
|
408 outMGE1
|
|
409 cmpa #6
|
|
410 bne outMGE2
|
|
411 ldb SaveFormat
|
|
412 cmpb #MGE640Format
|
|
413 beq outMGE11
|
|
414 lbsr MGE68 For MGE, convert type 6 to type 8.
|
|
415 bra outMGE3
|
|
416 outMGE11
|
|
417 lbsr MGE67 For 640, convert type 6 to type 7.
|
|
418 bra outMGE3
|
|
419 outMGE2
|
|
420 * Other conversions here.
|
|
421 outMGE3
|
|
422 lda SavePath
|
|
423 leax altbuff,y
|
|
424 ldy #160 After conversion, we always have 160 bytes/line
|
|
425 os9 I$Write
|
|
426 lbcs _error
|
|
427 puls a,b,x,y,u,pc
|
|
428
|
|
429 *
|
|
430 * Output linebuff to file in CM3 format
|
|
431 *
|
|
432 outCM3line
|
|
433 pshs a,b,x,y,u
|
|
434 lbsr MGEsame copy data to altbuff
|
|
435 leax altbuff,y
|
|
436 lda <type
|
|
437 cmpa #5
|
|
438 bne outCM31
|
|
439 lbsr MGE57 Convert type 5 -> type 7
|
|
440 bra outCM33
|
|
441 outCM31
|
|
442 cmpa #6
|
|
443 bne outCM32
|
|
444 lbsr MGE68 Convert type 6 -> type 8
|
|
445 bra outCM33
|
|
446 outCM32
|
|
447 outCM33
|
|
448
|
|
449 lbsr CM3compress compress data from linebuff into altbuff
|
|
450
|
|
451 lda SavePath
|
|
452 leax altbuff,y Output line data.
|
|
453 ldy ,x++ Get size of data.
|
|
454 os9 I$Write
|
|
455 lbcs _error
|
|
456 puls a,b,x,y,u,pc
|
|
457
|
|
458 *
|
|
459 * Output linebuff to file in normal VEF format
|
|
460 *
|
|
461 outVEFline
|
|
462 pshs a,b,x,y,u
|
|
463 lda SavePath
|
|
464 leax linebuff,y
|
|
465 ldy LineSize
|
|
466 os9 I$Write
|
|
467 lbcs _error
|
|
468 puls a,b,x,y,u,pc
|
|
469
|
|
470 *
|
|
471 * Output linebuff to file in Squashed VEF format
|
|
472 *
|
|
473 outsqline
|
|
474 pshs a,b,x,y,u
|
|
475 ldd LineSize
|
|
476 lsrb
|
|
477 rora Divide by two.
|
|
478 leax linebuff,y
|
|
479 lbsr VEFSquash Squash the first half of the line
|
|
480 bsr sqoutline output the packet
|
|
481 leax d,x
|
|
482 lbsr VEFSquash Squash the second half
|
|
483 bsr sqoutline output it.
|
|
484 puls a,b,x,y,u,pc
|
|
485
|
|
486 *
|
|
487 * Output packet in Altbuff to SavePath
|
|
488 sqoutline
|
|
489 pshs a,b,x,y
|
|
490 leax altbuff,y
|
|
491 ldb ,x
|
|
492 incb
|
|
493 clra
|
|
494 tfr d,y
|
|
495 lda SavePath
|
|
496 os9 I$Write
|
|
497 lbcs _error
|
|
498 puls a,b,x,y,pc
|
|
499
|
|
500
|
|
501 endsect
|