/[projet1]/public/atari/tools/rembrandt/DIVERS/GEM_INIT.S
Defence Force logotype

Contents of /public/atari/tools/rembrandt/DIVERS/GEM_INIT.S

Parent Directory Parent Directory | Revision Log Revision Log


Revision 67 - (show annotations)
Sat Apr 25 18:10:46 2009 UTC (10 years, 7 months ago) by dbug
File size: 7367 byte(s)
Added Rembrandt and Forgotten Bits
1
2 * a sample GEM program supplied with Devpac
3
4 * Source code Copyright (C) 1988,1992 HiSoft. All rights reserved.
5 * No part of this source may be reproduced, transmitted,
6 * transcribed, or stored in a retrieval system, or translated
7 * in any form or by any means without the prior written
8 * permission of HiSoft.
9
10 * HiSoft makes no representations or warranties with respect
11 * to the contents hereof and specifically disclaims any
12 * implied warranties or merchantability or fitness for any
13 * particular purpose.
14
15 * feel free to use any or all of the object code
16
17 * If you cannot assemble this exactly as supplied, tell us.
18 * If the object doesn't run after you have made any changes,
19 * please do not tell us, as you're on your own once you
20 * start messing with it!
21
22 * this is mainly to show the calling sequence for GEM
23 * from assembler - the program itself doesn't do much
24
25 * last changed:6.8.92
26 * updated to use Devpac3 style names & options
27
28 opt XDEBUG dump long labels for debugging
29
30 include gemmacro.i
31
32 * the program proper
33 start move.l 4(a7),a3 base page
34 move.l #mystack,a7
35 move.l $c(a3),d0 text len
36 add.l $14(a3),d0 data len
37 add.l $1c(a3),d0 BSS len
38 add.l #$100,d0 basepage
39 move.l d0,-(sp)
40 move.l a3,-(sp)
41 clr.w -(sp)
42 move.w #$4a,-(sp)
43 trap #1 shrink memory
44 lea 12(sp),sp
45
46 appl_init
47 move.w d0,ap_id store the application id
48
49 graf_handle
50 move.w d0,current_handle Desktop's VDI handle
51
52 * start by opening a virtual workstation
53 lea intin,a0
54 moveq #10-1,d0 -1 for DBF
55 .fill move.w #1,(a0)+ most params are 1
56 dbf d0,.fill
57 move.w #2,(a0)+ use RC system
58
59 v_opnvwk open it
60
61 * set the mouse to an arrow
62 graf_mouse #0 arrow please
63
64 * we want to open a window, so find the usable size of the screen
65 wind_get #0,#4 work area of Desktop
66
67 * the type of the window
68 wtype equ %000000101111 title, close, full, move, size
69
70 * the size lies in int_out(1..4), so calculate the window size
71 movem.w int_out+2,d0-d3
72 wind_calc #wtype,#1,d0,d1,d2,d3 want work area
73
74 * now remember its offsets
75 move.w int_out+2,xstart
76 move.w int_out+4,ystart
77 move.w int_out+6,xwidth
78 move.w int_out+8,ywidth
79
80 * and create the window
81 movem.w int_out+2,d0-d3
82 wind_create #wtype,d0,d1,d2,d3
83 move.w d0,w_handle save the handle (error checks?)
84
85 * now set its title
86 move.l #windowname,int_in+4
87 wind_set w_handle,#2 title string
88
89 * now actually show it by opening
90 movem.w xstart,d0-d3
91 add.w #10,d0 x start
92 add.w #10,d1 y start
93 sub.w #20,d2 width
94 sub.w #20,d3 height
95 wind_open w_handle,d0,d1,d2,d3
96
97 bsr recalcwindow
98 bsr setupmode
99
100 * the main loop of the application
101 * the only interesting events are messages
102 waitforevent
103 evnt_mesag #messagebuf
104 lea messagebuf,a0
105 move.w (a0),d0 message type
106 cmp.w #20,d0
107 beq updateit if Redraw
108 cmp.w #22,d0
109 beq quit if Close button
110 cmp.w #23,d0
111 beq fullit if Full button
112 cmp.w #27,d0
113 beq sizeit if re-size required
114 cmp.w #28,d0
115 beq moveit if window moved
116
117 * nothing I'm interested in so try again
118 bra waitforevent
119
120 * move the window around the screen
121 moveit move.w 6(a0),d0
122 cmp.w w_handle,d0
123 bne waitforevent if not my window then don't
124 changedwindow
125 move.w 8(a0),int_in+4 new x pos
126 move.w 10(a0),int_in+6 new y pos
127 move.w 12(a0),d0
128 cmp.w #40,d0
129 bcc.s .wok
130 moveq #40,d0 can't be too narrow
131 .wok move.w d0,int_in+8 width
132 move.w 14(a0),d0
133 cmp.w #50,d0
134 bcc.s .hok
135 moveq #50,d0 can't be too thin either
136 .hok move.w d0,int_in+10 height
137
138 wind_set w_handle,#5
139
140 movem.w xwidth,d4-d5 old size
141 bsr recalcwindow
142 cmp.w xwidth,d4
143 bcs waitforevent
144 cmp.w ywidth,d5
145 bcs waitforevent
146 bne.s forceupdate
147 cmp.w xwidth,d4
148 beq waitforevent not if exactly the same
149 * if the new size is smaller in both dimensions than the old size
150 * then an update event will not be posted, so the re-draw will
151 * have to be done manually
152 forceupdate
153 bsr drawwindow draw it
154 bra waitforevent and carry on
155
156 * re-size the window
157 sizeit move.w 6(a0),d0
158 cmp.w w_handle,d0
159 bne waitforevent if not my window
160 bra changedwindow
161
162 * there's an update
163 updateit
164 move.w 6(a0),d0
165 cmp.w w_handle,d0
166 bne waitforevent if not my window
167 * there are two ways of doing updates:
168 * (a) to support overlapping windows
169 * this takes a lot of code, and is very slow and tricky
170 * (b) to ignore the possibility of overlapping windows
171 * this takes little code and is easy
172 * Here method (b) is used! (method (a) is needed if you have a Desk
173 * menu or multi-windows in your program - this doesn't have either
174 * -that's my excuse and I'm sticking to it!)
175
176 * start by clipping the rectangle
177 movem.w 8(a0),d0-d3 the rectangle
178 add.w d0,d2
179 add.w d1,d3
180 vs_clip #1,d0,d1,d2,d3 clipping on
181
182 bsr drawwindow draw the window
183 bra waitforevent
184
185 * the full button has been clicked
186 * this puts up an alert box
187 fullit form_alert #1,#myalert
188 bra waitforevent
189
190 * to go away various things have to be tidied up
191 * starting with closing the window
192 quit wind_close w_handle close it
193 wind_delete w_handle and delete it
194
195 * then closing the virtual workstation
196 v_clsvwk close it
197
198 appl_exit tell GEM I've finished
199
200 * now quit to the desktop
201 clr.w -(a7) status code
202 move.w #$4c,-(a7) P_TERM
203 trap #1 and go away
204
205 * calculate the work area of the window
206 recalcwindow
207 wind_get w_handle,#4 get work area
208 movem.w int_out+2,d0-d3
209 movem.w d0-d3,xstart
210 rts
211
212 * this draws the picture in the window
213 * which is an oval on top of a rectangle
214
215 * before drawing anywhere you have to hide the mouse
216 drawwindow
217 v_hide_c hide the mouse
218 vsf_interior #2 pattern
219
220 movem.w xstart,d0-d3 AES rectangle
221 add.w d0,d2
222 subq.w #1,d2
223 add.w d1,d3
224 subq.w #1,d3 convert to VDI
225 vr_recfl d0,d1,d2,d3 filled rectangle
226 * the oval has to be drawn in the user defined pattern
227 vsf_interior #4
228
229 movem.w xstart,d0-d3
230 asr.w #1,d2 half width
231 asr.w #1,d3 half height
232 add.w d2,d0 x centre
233 add.w d3,d1 y centre
234 v_ellipse d0,d1,d2,d3
235
236 * we have finished drawing so get the mouse back
237 v_show_c #0 show the mouse
238 rts
239
240 * this prepares the drawing mode etc
241 setupmode
242 move.l #intin,a0
243 move.w #%0000100101000000,(a0)+
244 move.w #%0000100101000000,(a0)+
245 move.w #%0000111101000000,(a0)+
246 move.w #%0000100101000000,(a0)+
247 move.w #%0000100101000000,(a0)+
248 move.w #%0000000000000000,(a0)+
249 move.w #%0110010011011100,(a0)+
250 move.w #%1000101010001000,(a0)+
251 move.w #%1100101011001000,(a0)+
252 move.w #%0010101010001000,(a0)+
253 move.w #%1100010010001000,(a0)+
254 REPT 16-11
255 clr.w (a0)+
256 ENDR
257 move.w #16,contrl3 single plane
258 vsf_updat set user defined fill style
259 vsf_color #1
260 rts
261
262 SECTION DATA
263
264 * all C strings must end in a null
265 windowname dc.b ' An Example GEM Program by HiSoft ',0
266
267 myalert dc.b "[1][This is written in 68000|assembler using HiSoft's|"
268 dc.b 'Devpac Version 3][ OK ]',0
269
270 * global constants
271 SECTION BSS
272
273 * these have to remain together
274 xstart ds.w 1
275 ystart ds.w 1
276 xwidth ds.w 1
277 ywidth ds.w 1
278
279 w_handle ds.w 1
280 ws_handle ds.w 1
281 ap_id ds.w 1
282 messagebuf ds.b 16
283
284 ds.l 100 stack space
285 mystack ds.w 1 (stacks go backwards)
286
287
288 * if not linking then include the run-times
289
290 IFEQ __LK
291 include aeslib.s
292 include vdilib.s
293 ENDC

  ViewVC Help
Powered by ViewVC 1.1.26