Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
205 | heavyiron | 1 | ; language for programs |
2 | lang fix en ; ru en fr ge fi |
||
3 | |||
4 | @^ fix macro comment { |
||
5 | ^@ fix } |
||
6 | |||
223 | Ghost | 7 | nl equ 0x0d, 0x0a |
205 | heavyiron | 8 | ;~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- |
9 | macro uglobal { |
||
10 | UGlobals equ UGlobals, |
||
11 | macro __UGlobalBlock { } |
||
12 | |||
13 | endg fix } ; Use endg for ending iglobal and uglobal blocks. |
||
14 | |||
15 | macro IncludeUGlobals{ |
||
16 | macro UGlobals dummy,[n] \{ |
||
17 | \common |
||
18 | \local begin, size |
||
19 | begin = $ |
||
20 | virtual at $ |
||
21 | \forward |
||
22 | __UGlobalBlock |
||
23 | purge __UGlobalBlock |
||
24 | \common |
||
25 | size = $ - begin |
||
26 | end virtual |
||
27 | rb size |
||
28 | \} |
||
29 | match U, UGlobals \{ U \} } |
||
30 | |||
31 | uglobal |
||
32 | endg |
||
33 | ;~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- |
||
34 | |||
35 | ; new application structure |
||
36 | macro meos_app_start |
||
37 | { |
||
38 | use32 |
||
39 | org 0x0 |
||
40 | |||
41 | db 'MENUET01' |
||
42 | dd 0x01 |
||
43 | dd __start |
||
44 | dd __end |
||
45 | dd __memory |
||
46 | dd __stack |
||
47 | |||
48 | if used __params & ~defined __params |
||
49 | dd __params |
||
50 | else |
||
51 | dd 0x0 |
||
52 | end if |
||
53 | |||
54 | dd 0x0 |
||
55 | } |
||
56 | MEOS_APP_START fix meos_app_start |
||
57 | |||
58 | macro code |
||
59 | { |
||
60 | __start: |
||
61 | } |
||
62 | CODE fix code |
||
63 | |||
64 | macro data |
||
65 | { |
||
66 | __data: |
||
67 | } |
||
68 | DATA fix data |
||
69 | |||
70 | macro udata |
||
71 | { |
||
72 | if used __params & ~defined __params |
||
73 | __params: |
||
74 | db 0 |
||
75 | __end: |
||
76 | rb 255 |
||
77 | else |
||
78 | __end: |
||
79 | end if |
||
80 | __udata: |
||
81 | IncludeUGlobals |
||
82 | } |
||
83 | UDATA fix udata |
||
84 | |||
85 | macro meos_app_end |
||
86 | { |
||
87 | align 32 |
||
88 | rb 2048 |
||
89 | __stack: |
||
90 | __memory: |
||
91 | display nl, ' ' |
||
92 | } |
||
93 | MEOS_APP_END fix meos_app_end |
||
94 | |||
95 | ; macro for defining multiline text data |
||
96 | struc mls [sstring] { |
||
97 | forward |
||
98 | local ssize |
||
99 | virtual at 0 |
||
100 | db sstring ; mod |
||
101 | ssize = $ |
||
102 | end virtual |
||
103 | db ssize |
||
104 | db sstring |
||
105 | common |
||
106 | |||
107 | db -1 ; mod |
||
108 | } |
||
109 | |||
110 | |||
111 | |||
112 | ; strings |
||
113 | macro sz name,[data] { ; from MFAR [mike.dld] |
||
114 | common |
||
115 | if used name |
||
116 | name db data |
||
117 | .size = $-name |
||
118 | end if |
||
119 | } |
||
120 | |||
121 | macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
||
122 | common |
||
123 | if used name |
||
124 | label name |
||
125 | forward |
||
126 | if lang eq lng |
||
127 | db data |
||
128 | end if |
||
129 | common |
||
130 | .size = $-name |
||
131 | end if |
||
132 | } |
||
133 | |||
134 | macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
||
135 | common |
||
136 | local s,m |
||
137 | m = 0 |
||
138 | if used name |
||
139 | label name |
||
140 | virtual at 0 |
||
141 | db data |
||
142 | s = $ |
||
143 | end virtual |
||
144 | d#elsz s |
||
145 | if m < s |
||
146 | m = s |
||
147 | end if |
||
148 | db data |
||
149 | .size = $-name |
||
150 | .maxl = m |
||
151 | end if |
||
152 | } |
||
153 | |||
154 | macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
||
155 | common |
||
156 | local s,m |
||
157 | m = 0 |
||
158 | if used name |
||
159 | label name |
||
160 | forward |
||
161 | if lang eq lng |
||
162 | virtual at 0 |
||
163 | db data |
||
164 | s = $ |
||
165 | end virtual |
||
166 | d#elsz s |
||
167 | if m < s |
||
168 | m = s |
||
169 | end if |
||
170 | db data |
||
171 | end if |
||
172 | common |
||
173 | .size = $-name |
||
174 | .maxl = m |
||
175 | end if |
||
176 | } |
||
177 | |||
178 | |||
179 | ; easy system call macro |
||
180 | macro mpack dest, hsrc, lsrc |
||
181 | { |
||
182 | if (hsrc eqtype 0) & (lsrc eqtype 0) |
||
183 | mov dest, (hsrc) shl 16 + lsrc |
||
184 | else |
||
185 | if (hsrc eqtype 0) & (~lsrc eqtype 0) |
||
186 | mov dest, (hsrc) shl 16 |
||
187 | add dest, lsrc |
||
188 | else |
||
189 | mov dest, hsrc |
||
190 | shl dest, 16 |
||
191 | add dest, lsrc |
||
192 | end if |
||
193 | end if |
||
194 | } |
||
195 | |||
196 | ;macro __mov reg,a { ; mike.dld |
||
197 | ; if ~a eq |
||
198 | ; mov reg,a |
||
199 | ; end if |
||
200 | ;} |
||
201 | |||
202 | macro __mov reg,a,b { ; mike.dld |
||
203 | if (~a eq)&(~b eq) |
||
204 | mpack reg,a,b |
||
205 | else if (~a eq)&(b eq) |
||
206 | mov reg,a |
||
207 | end if |
||
208 | } |
||
209 | |||
210 | macro mcall a,b,c,d,e,f { ; mike.dld |
||
211 | __mov eax,a |
||
212 | __mov ebx,b |
||
213 | __mov ecx,c |
||
214 | __mov edx,d |
||
215 | __mov esi,e |
||
216 | __mov edi,f |
||
217 | int 0x40 |
||
218 | } |
||
219 | |||
220 | |||
221 | ; ------------------------- |
||
222 | macro header a,[b] { |
||
223 | common |
||
224 | use32 |
||
225 | org 0 |
||
226 | db 'MENUET',a |
||
227 | forward |
||
228 | if b eq |
||
229 | dd 0 |
||
230 | else |
||
231 | dd b |
||
232 | end if } |
||
233 | macro section name { align 16 |
||
234 | label name } |
||
235 | macro func name { |
||
236 | if ~used name |
||
237 | display 'FUNC NOT USED: ',`name,13,10 |
||
238 | else |
||
239 | align 4 |
||
240 | name: |
||
241 | ;pushad |
||
242 | ;pushfd |
||
243 | ;dps `name |
||
244 | ;newline |
||
245 | ;mcall 5,1 |
||
246 | ;popfd |
||
247 | ;popad |
||
248 | } |
||
249 | macro endf { end if } |
||
250 | |||
251 | macro diff16 title,l1,l2 |
||
252 | { |
||
253 | local s,d |
||
254 | s = l2-l1 |
||
255 | display title,': 0x' |
||
256 | repeat 8 |
||
257 | d = '0' + s shr ((8-%) shl 2) and $0F |
||
258 | if d > '9' |
||
259 | d = d + 'A'-'9'-1 |
||
260 | end if |
||
261 | display d |
||
262 | end repeat |
||
263 | display 13,10 |
||
264 | } |
||
265 | |||
266 | macro diff10 title,l1,l2 |
||
267 | { |
||
268 | local s,d,z,m |
||
269 | s = l2-l1 |
||
270 | z = 0 |
||
271 | m = 1000000000 |
||
272 | display title,': ' |
||
273 | repeat 10 |
||
274 | d = '0' + s / m |
||
275 | s = s - (s/m)*m |
||
276 | m = m / 10 |
||
277 | if d <> '0' |
||
278 | z = 1 |
||
279 | end if |
||
280 | if z <> 0 |
||
281 | display d |
||
282 | end if |
||
283 | end repeat |
||
284 | display 13,10 |
||
285 | } |
||
286 | |||
287 | ; optimize the code for size |
||
288 | __regs fix |
||
289 | |||
290 | macro add arg1,arg2 |
||
291 | { |
||
292 | if (arg2 eqtype 0) |
||
293 | if (arg2) = 1 |
||
294 | inc arg1 |
||
295 | else |
||
296 | add arg1,arg2 |
||
297 | end if |
||
298 | else |
||
299 | add arg1,arg2 |
||
300 | end if |
||
301 | } |
||
302 | |||
303 | macro sub arg1,arg2 |
||
304 | { |
||
305 | if (arg2 eqtype 0) |
||
306 | if (arg2) = 1 |
||
307 | dec arg1 |
||
308 | else |
||
309 | sub arg1,arg2 |
||
310 | end if |
||
311 | else |
||
312 | sub arg1,arg2 |
||
313 | end if |
||
314 | } |
||
315 | |||
316 | macro mov arg1,arg2 |
||
317 | { |
||
318 | if (arg1 in __regs) & (arg2 eqtype 0) |
||
319 | if (arg2) = 0 |
||
320 | xor arg1,arg1 |
||
321 | else if (arg2) = 1 |
||
322 | xor arg1,arg1 |
||
323 | inc arg1 |
||
324 | else if (arg2) = -1 |
||
325 | or arg1,-1 |
||
326 | else if (arg2) > -128 & (arg2) < 128 |
||
327 | push arg2 |
||
328 | pop arg1 |
||
329 | else |
||
330 | mov arg1,arg2 |
||
331 | end if |
||
332 | else |
||
333 | mov arg1,arg2 |
||
334 | end if |
||
335 | } |
||
336 | |||
337 | |||
338 | struc POINT _t,_dx,_dy { |
||
339 | .x _t _dx |
||
340 | .y _t _dy |
||
341 | } |
||
342 | |||
343 | |||
344 | ; constants |
||
345 | |||
346 | ; events |
||
347 | EV_IDLE = 0 |
||
348 | EV_TIMER = 0 |
||
349 | EV_REDRAW = 1 |
||
350 | EV_KEY = 2 |
||
351 | EV_BUTTON = 3 |
||
352 | EV_EXIT = 4 |
||
353 | EV_BACKGROUND = 5 |
||
354 | EV_MOUSE = 6 |
||
355 | EV_IPC = 7 |
||
356 | EV_STACK = 8 |
||
357 | |||
358 | ; event mask bits for function 40 |
||
359 | EVM_REDRAW = 1b |
||
360 | EVM_KEY = 10b |
||
361 | EVM_BUTTON = 100b |
||
362 | EVM_EXIT = 1000b |
||
363 | EVM_BACKGROUND = 10000b |
||
364 | EVM_MOUSE = 100000b |
||
365 | EVM_IPC = 1000000b |
||
366 | EVM_STACK = 10000000b>>>>> |