1706
|
1 *
|
|
2 * View: view a picture file on a window screen
|
|
3 *
|
|
4 * Global labels:
|
|
5 * main: Main entry point, called by root.a
|
|
6 * _exit: Exit with no error
|
|
7 * _error: Exit with error code in B
|
|
8 * _abort: Clean up and then exit with no error.
|
|
9 * E$Format: Exit with message about illegal file format.
|
|
10 *
|
|
11 check macro
|
|
12 pshs b,cc
|
|
13 ldb #\1
|
|
14 os9 F$PErr
|
|
15 puls b,cc
|
|
16 endm
|
|
17
|
|
18 ifp1
|
1912
|
19 use os9defs.d
|
1706
|
20 endc
|
|
21
|
|
22 StdOut equ 1
|
|
23 StdErr equ 2
|
|
24
|
|
25 psect View_a,0,0,0,0,0
|
|
26
|
|
27 main:
|
|
28 lbsr SetSig Install signal trap
|
|
29 com <abort Set for abort on signal.
|
|
30 lbsr select Send select code to current screen.
|
|
31
|
|
32 pshs a
|
|
33 pshs y
|
|
34 os9 F$ID Get our PID, for use with graphics
|
|
35 puls y
|
|
36 sta <PID
|
|
37 lbsr killbuffs Kill off buffers in our group before we start
|
|
38 lbsr saveopts Get StdOut options, and save them.
|
|
39 puls a
|
|
40
|
|
41 pshs d,x
|
|
42 leax end,y Set up free space pool.
|
|
43 stx <MemTop
|
|
44 pshs x
|
|
45 tfr s,d
|
|
46 subd #stacksize
|
|
47 subd ,s++
|
|
48 std <MemSiz
|
|
49 puls d,x
|
|
50
|
|
51 lbsr Parse Parse command line options, open input file
|
|
52
|
|
53 lda <format
|
|
54 pshs y
|
|
55 lbsr showpic Display the picture
|
|
56 puls y
|
|
57
|
|
58 lbsr bell
|
|
59 lbsr sendsig
|
|
60
|
|
61 lbsr keywait Wait for a keypress.
|
|
62 lbsr DoSave Save the picture.
|
|
63 _abort:
|
|
64 lbsr sendsig
|
|
65 lbsr cleanup Cleanup-- Select Stdout, turn on cursor, restore options.
|
|
66 lbsr killbuffs Kill any buffers we used.
|
|
67
|
|
68 * Exit with no error
|
|
69 _exit:
|
|
70 clrb
|
|
71 _error:
|
|
72 OS9 F$Exit
|
|
73
|
|
74 BEL fcb $07
|
|
75
|
|
76 bell
|
|
77 pshs a,b,x,y
|
|
78 tst <SigPID
|
|
79 bne bellend Don't bell if we should send a signal.
|
|
80 lda <outpath
|
|
81 leax BEL,pcr
|
|
82 ldy #1
|
|
83 os9 I$Write
|
|
84 bellend
|
|
85 puls a,b,x,y,pc
|
|
86
|
|
87 sendsig
|
|
88 pshs a,b
|
|
89 lda <SigPID
|
|
90 beq nosig
|
|
91 ldb <SigOut
|
|
92 os9 F$Send
|
|
93 lbcs _error
|
|
94 clr <SigPID
|
|
95 nosig
|
|
96 puls a,b,pc
|
|
97
|
|
98 E$Format:
|
|
99 leax ErrFmt,pcr
|
|
100 ldy #ErrFmt2-ErrFmt
|
|
101 bra DoError
|
|
102 ErrFmt fcc "Illegal file format."
|
|
103 fcb $0d
|
|
104 ErrFmt2
|
|
105 DoError
|
|
106 lda #StdErr
|
|
107 os9 I$WritLn
|
|
108 ldb #1
|
|
109 bra _error
|
|
110
|
|
111 *
|
|
112 * Expects allocation size requested in D,
|
|
113 * returns pointer in X. Error is generated if not enough mem.
|
|
114 malloc:
|
|
115 pshs a,b,y
|
|
116 clra
|
|
117 clrb
|
|
118 os9 F$Mem
|
|
119 lbcs _error
|
|
120 std <oldmemsize
|
|
121 pshs y
|
|
122
|
|
123 addd 2,s
|
|
124 os9 F$Mem
|
|
125 lbcs _error
|
|
126 std <newmemsize
|
|
127 puls x
|
|
128 puls a,b,y,pc
|
|
129
|
|
130 unmalloc:
|
|
131 pshs a,b,y
|
|
132 ldd #0
|
|
133 os9 F$Mem
|
|
134 lbcs _error
|
|
135 cmpd <newmemsize
|
|
136 bne unmalend
|
|
137 ldd <oldmemsize
|
|
138 os9 F$Mem
|
|
139 lbcs _error
|
|
140 unmalend
|
|
141 puls a,b,y,pc
|
|
142
|
|
143 ***************************************
|
|
144 * *
|
|
145 * Select according to picture format *
|
|
146 * *
|
|
147 ***************************************
|
|
148
|
|
149 SPTable
|
|
150 fcb MAXFormat
|
|
151 lbra MAXshowpic MAXshowpic also handles all the pmodes
|
|
152 fcb P00Format
|
|
153 lbra MAXshowpic
|
|
154 fcb P01Format
|
|
155 lbra MAXshowpic
|
|
156 fcb P10Format
|
|
157 lbra MAXshowpic
|
|
158 fcb P11Format
|
|
159 lbra MAXshowpic
|
|
160 fcb P20Format
|
|
161 lbra MAXshowpic
|
|
162 fcb P21Format
|
|
163 lbra MAXshowpic
|
|
164 fcb P30Format
|
|
165 lbra MAXshowpic
|
|
166 fcb P31Format
|
|
167 lbra MAXshowpic
|
|
168 fcb P40Format
|
|
169 lbra MAXshowpic
|
|
170 fcb P41Format
|
|
171 lbra MAXshowpic
|
|
172 fcb ARTFormat
|
|
173 lbra MAXshowpic
|
|
174 fcb MGEFormat
|
|
175 lbra MGEshowpic
|
|
176 fcb MGE640Format
|
|
177 lbra MGEshowpic
|
|
178 fcb CM3Format
|
|
179 lbra CM3showpic
|
|
180 fcb CLPFormat
|
|
181 lbra CLPshowpic
|
|
182 fcb PUBFormat
|
|
183 lbra CLPshowpic
|
|
184 fcb VEFFormat
|
|
185 lbra VEFshowpic
|
|
186 fcb PIX256Format
|
|
187 lbra PIXshowpic
|
|
188 fcb PIX128Format
|
|
189 lbra PIXshowpic
|
|
190 fcb PIXFormat
|
|
191 lbra PIXshowpic
|
|
192 fcb IMGFormat
|
|
193 lbra IMGshowpic
|
|
194 fcb RATFormat
|
|
195 lbra RATshowpic
|
|
196 fcb STFormat
|
|
197 lbra STshowpic
|
|
198 fcb MACFormat
|
|
199 lbra MACshowpic
|
|
200 fcb RLEFormat
|
|
201 lbra RLEshowpic
|
|
202 fcb GIFFormat
|
|
203 lbra GIFshowpic
|
|
204 fcb GIFBWFormat
|
|
205 lbra GIFshowpic
|
|
206 fcb MAXCMPFormat
|
|
207 lbra MAXshowpic
|
|
208 fcb ARTCMPFormat
|
|
209 lbra MAXshowpic
|
|
210
|
|
211 *
|
|
212 * Does a jump to the appropriate subr entry point.
|
|
213 * Expects picture format code in A.
|
|
214 *
|
|
215 showpic
|
|
216 pshs x Space to store jump destination
|
|
217 pshs x Save X register
|
|
218 leax SPTable-3,pcr
|
|
219 sploop
|
|
220 leax 3,x
|
|
221 cmpa ,x+ Does the format match?
|
|
222 bne sploop
|
|
223 stx 2,s Jump address is table entry
|
|
224 puls x,pc restore X and jump.
|
|
225
|
|
226 endsect
|