Rev 259 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | @^ fix macro comment { |
2 | ^@ fix } |
||
3 | |||
4 | |||
122 | diamond | 5 | macro m2m dest,src { |
6 | push src |
||
7 | pop dest |
||
8 | } |
||
9 | |||
31 | halyavin | 10 | ; new application structure |
11 | macro meos_app_start |
||
12 | { |
||
13 | use32 |
||
14 | org 0x0 |
||
15 | |||
16 | db 'MENUET01' |
||
17 | dd 0x01 |
||
18 | dd __start |
||
19 | dd __end |
||
20 | dd __memory |
||
21 | dd __stack |
||
22 | |||
23 | if used __params & ~defined __params |
||
24 | dd __params |
||
25 | else |
||
26 | dd 0x0 |
||
27 | end if |
||
28 | |||
29 | dd 0x0 |
||
30 | } |
||
31 | MEOS_APP_START fix meos_app_start |
||
32 | |||
33 | macro code |
||
34 | { |
||
35 | __start: |
||
36 | } |
||
37 | CODE fix code |
||
38 | |||
39 | macro data |
||
40 | { |
||
41 | __data: |
||
42 | } |
||
43 | DATA fix data |
||
44 | |||
45 | macro udata |
||
46 | { |
||
47 | if used __params & ~defined __params |
||
48 | __params: |
||
49 | db 0 |
||
50 | __end: |
||
51 | rb 255 |
||
52 | else |
||
53 | __end: |
||
54 | end if |
||
55 | __udata: |
||
56 | } |
||
57 | UDATA fix udata |
||
58 | |||
59 | macro meos_app_end |
||
60 | { |
||
61 | align 32 |
||
62 | rb 2048 |
||
63 | __stack: |
||
64 | __memory: |
||
65 | } |
||
66 | MEOS_APP_END fix meos_app_end |
||
67 | |||
68 | |||
69 | ; macro for defining multiline text data |
||
70 | struc mstr [sstring] |
||
71 | { |
||
72 | forward |
||
73 | local ssize |
||
74 | virtual at 0 |
||
75 | db sstring |
||
76 | ssize = $ |
||
77 | end virtual |
||
78 | dd ssize |
||
79 | db sstring |
||
80 | common |
||
81 | dd -1 |
||
82 | } |
||
83 | |||
84 | |||
85 | ; strings |
||
86 | macro sz name,[data] { ; from MFAR [mike.dld] |
||
87 | common |
||
88 | if used name |
||
122 | diamond | 89 | name db data |
31 | halyavin | 90 | .size = $-name |
91 | end if |
||
92 | } |
||
93 | |||
94 | macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
||
95 | common |
||
96 | if used name |
||
97 | label name |
||
98 | forward |
||
99 | if lang eq lng |
||
100 | db data |
||
101 | end if |
||
102 | common |
||
103 | .size = $-name |
||
104 | end if |
||
105 | } |
||
106 | |||
107 | macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
||
108 | common |
||
109 | local s,m |
||
110 | m = 0 |
||
111 | if used name |
||
112 | label name |
||
297 | mikedld | 113 | forward |
31 | halyavin | 114 | virtual at 0 |
115 | db data |
||
116 | s = $ |
||
117 | end virtual |
||
118 | d#elsz s |
||
119 | if m < s |
||
120 | m = s |
||
121 | end if |
||
122 | db data |
||
297 | mikedld | 123 | common |
31 | halyavin | 124 | .size = $-name |
125 | .maxl = m |
||
126 | end if |
||
127 | } |
||
128 | |||
129 | macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
||
130 | common |
||
122 | diamond | 131 | local s,m,c |
31 | halyavin | 132 | m = 0 |
122 | diamond | 133 | c = 0 |
31 | halyavin | 134 | if used name |
135 | label name |
||
136 | forward |
||
137 | if lang eq lng |
||
138 | virtual at 0 |
||
139 | db data |
||
140 | s = $ |
||
141 | end virtual |
||
142 | d#elsz s |
||
143 | if m < s |
||
144 | m = s |
||
145 | end if |
||
146 | db data |
||
122 | diamond | 147 | c = c+1 |
31 | halyavin | 148 | end if |
149 | common |
||
122 | diamond | 150 | .size = $-name |
151 | .maxl = m |
||
152 | .count = c |
||
31 | halyavin | 153 | end if |
154 | } |
||
155 | |||
156 | |||
157 | ; easy system call macro |
||
158 | macro mpack dest, hsrc, lsrc |
||
159 | { |
||
160 | if (hsrc eqtype 0) & (lsrc eqtype 0) |
||
161 | mov dest, (hsrc) shl 16 + lsrc |
||
162 | else |
||
163 | if (hsrc eqtype 0) & (~lsrc eqtype 0) |
||
164 | mov dest, (hsrc) shl 16 |
||
165 | add dest, lsrc |
||
166 | else |
||
167 | mov dest, hsrc |
||
168 | shl dest, 16 |
||
169 | add dest, lsrc |
||
170 | end if |
||
171 | end if |
||
172 | } |
||
173 | |||
174 | ;macro __mov reg,a { ; mike.dld |
||
175 | ; if ~a eq |
||
176 | ; mov reg,a |
||
177 | ; end if |
||
178 | ;} |
||
179 | |||
180 | macro __mov reg,a,b { ; mike.dld |
||
181 | if (~a eq)&(~b eq) |
||
182 | mpack reg,a,b |
||
183 | else if (~a eq)&(b eq) |
||
184 | mov reg,a |
||
185 | end if |
||
186 | } |
||
187 | |||
188 | macro mcall a,b,c,d,e,f { ; mike.dld |
||
189 | __mov eax,a |
||
190 | __mov ebx,b |
||
191 | __mov ecx,c |
||
192 | __mov edx,d |
||
193 | __mov esi,e |
||
194 | __mov edi,f |
||
195 | int 0x40 |
||
196 | } |
||
197 | |||
198 | |||
199 | ; ------------------------- |
||
200 | macro header a,[b] { |
||
201 | common |
||
202 | use32 |
||
203 | org 0 |
||
204 | db 'MENUET',a |
||
205 | forward |
||
206 | if b eq |
||
207 | dd 0 |
||
208 | else |
||
209 | dd b |
||
210 | end if } |
||
211 | macro section name { align 16 |
||
212 | label name } |
||
213 | macro func name { |
||
214 | if ~used name |
||
297 | mikedld | 215 | display 'FUNC NOT USED: ',`name,13,10 |
31 | halyavin | 216 | else |
217 | align 4 |
||
218 | name: |
||
122 | diamond | 219 | ;diff16 `name,0,name |
31 | halyavin | 220 | ;pushad |
221 | ;pushfd |
||
222 | ;dps `name |
||
223 | ;newline |
||
224 | ;mcall 5,1 |
||
225 | ;popfd |
||
226 | ;popad |
||
227 | } |
||
228 | macro endf { end if } |
||
229 | |||
230 | macro diff16 title,l1,l2 |
||
231 | { |
||
232 | local s,d |
||
233 | s = l2-l1 |
||
234 | display title,': 0x' |
||
235 | repeat 8 |
||
236 | d = '0' + s shr ((8-%) shl 2) and $0F |
||
237 | if d > '9' |
||
238 | d = d + 'A'-'9'-1 |
||
239 | end if |
||
240 | display d |
||
241 | end repeat |
||
242 | display 13,10 |
||
243 | } |
||
244 | |||
245 | macro diff10 title,l1,l2 |
||
246 | { |
||
247 | local s,d,z,m |
||
248 | s = l2-l1 |
||
249 | z = 0 |
||
250 | m = 1000000000 |
||
251 | display title,': ' |
||
252 | repeat 10 |
||
253 | d = '0' + s / m |
||
254 | s = s - (s/m)*m |
||
255 | m = m / 10 |
||
256 | if d <> '0' |
||
257 | z = 1 |
||
258 | end if |
||
259 | if z <> 0 |
||
260 | display d |
||
261 | end if |
||
262 | end repeat |
||
263 | display 13,10 |
||
264 | } |
||
265 | |||
266 | ; optimize the code for size |
||
267 | __regs fix |
||
268 | |||
269 | macro add arg1,arg2 |
||
270 | { |
||
271 | if (arg2 eqtype 0) |
||
272 | if (arg2) = 1 |
||
273 | inc arg1 |
||
274 | else |
||
275 | add arg1,arg2 |
||
276 | end if |
||
277 | else |
||
278 | add arg1,arg2 |
||
279 | end if |
||
280 | } |
||
281 | |||
282 | macro sub arg1,arg2 |
||
283 | { |
||
284 | if (arg2 eqtype 0) |
||
285 | if (arg2) = 1 |
||
286 | dec arg1 |
||
287 | else |
||
288 | sub arg1,arg2 |
||
289 | end if |
||
290 | else |
||
291 | sub arg1,arg2 |
||
292 | end if |
||
293 | } |
||
294 | |||
295 | macro mov arg1,arg2 |
||
296 | { |
||
297 | if (arg1 in __regs) & (arg2 eqtype 0) |
||
298 | if (arg2) = 0 |
||
299 | xor arg1,arg1 |
||
300 | else if (arg2) = 1 |
||
301 | xor arg1,arg1 |
||
302 | inc arg1 |
||
303 | else if (arg2) = -1 |
||
304 | or arg1,-1 |
||
305 | else if (arg2) > -128 & (arg2) < 128 |
||
306 | push arg2 |
||
307 | pop arg1 |
||
308 | else |
||
309 | mov arg1,arg2 |
||
310 | end if |
||
311 | else |
||
312 | mov arg1,arg2 |
||
313 | end if |
||
314 | } |
||
315 | |||
316 | |||
122 | diamond | 317 | macro RGB [a] { |
318 | common |
||
319 | match (r=,g=,b),a \{ |
||
320 | \dd ((r) shl 16) or ((g) shl 8) or (b) |
||
321 | \} |
||
322 | } |
||
323 | |||
324 | |||
31 | halyavin | 325 | struc POINT _t,_dx,_dy { |
326 | .x _t _dx |
||
327 | .y _t _dy |
||
328 | } |
||
329 | |||
330 | ; structure definition helper |
||
122 | diamond | 331 | include 'struct.inc' |
31 | halyavin | 332 | |
178 | heavyiron | 333 | struct RECT |
334 | left dd ? |
||
335 | top dd ? |
||
336 | right dd ? |
||
337 | bottom dd ? |
||
338 | ends |
||
339 | |||
340 | struct BOX |
||
341 | left dd ? |
||
342 | top dd ? |
||
343 | width dd ? |
||
344 | height dd ? |
||
345 | ends |
||
346 | |||
31 | halyavin | 347 | ; structures used in MeOS |
122 | diamond | 348 | struct process_information |
349 | cpu_usage dd ? ; +0 |
||
350 | window_stack_position dw ? ; +4 |
||
351 | window_stack_value dw ? ; +6 |
||
178 | heavyiron | 352 | dw ? ; +8 |
122 | diamond | 353 | process_name rb 12 ; +10 |
354 | memory_start dd ? ; +22 |
||
355 | used_memory dd ? ; +26 |
||
356 | PID dd ? ; +30 |
||
178 | heavyiron | 357 | box BOX ; +34 |
122 | diamond | 358 | slot_state dw ? ; +50 |
178 | heavyiron | 359 | dw ? ; +52 |
360 | client_box BOX ; +54 |
||
31 | halyavin | 361 | rb (1024-52) |
122 | diamond | 362 | ends |
31 | halyavin | 363 | |
122 | diamond | 364 | struct system_colors |
365 | frame dd ? |
||
366 | grab dd ? |
||
367 | grab_button dd ? |
||
368 | grab_button_text dd ? |
||
369 | grab_text dd ? |
||
370 | work dd ? |
||
371 | work_button dd ? |
||
372 | work_button_text dd ? |
||
373 | work_text dd ? |
||
374 | work_graph dd ? |
||
375 | ends |
||
31 | halyavin | 376 | |
259 | mikedld | 377 | struct FILEDATE |
378 | Second db ? |
||
379 | Minute db ? |
||
380 | Hour db ? |
||
381 | db ? |
||
382 | Day db ? |
||
383 | Month db ? |
||
384 | Year dw ? |
||
385 | ends |
||
122 | diamond | 386 | |
259 | mikedld | 387 | struct FILEINFO |
388 | Attributes dd ? |
||
389 | IsUnicode db ? |
||
390 | db 3 dup(?) |
||
391 | DateCreate FILEDATE |
||
392 | DateAccess FILEDATE |
||
393 | DateModify FILEDATE |
||
394 | Size dq ? |
||
395 | ends |
||
396 | |||
31 | halyavin | 397 | ; constants |
398 | |||
399 | ; events |
||
400 | EV_IDLE = 0 |
||
401 | EV_TIMER = 0 |
||
402 | EV_REDRAW = 1 |
||
403 | EV_KEY = 2 |
||
404 | EV_BUTTON = 3 |
||
405 | EV_EXIT = 4 |
||
406 | EV_BACKGROUND = 5 |
||
407 | EV_MOUSE = 6 |
||
408 | EV_IPC = 7 |
||
409 | EV_STACK = 8 |
||
410 | |||
411 | ; event mask bits for function 40 |
||
412 | EVM_REDRAW = 1b |
||
413 | EVM_KEY = 10b |
||
414 | EVM_BUTTON = 100b |
||
415 | EVM_EXIT = 1000b |
||
416 | EVM_BACKGROUND = 10000b |
||
417 | EVM_MOUSE = 100000b |
||
418 | EVM_IPC = 1000000b |
||
419 | EVM_STACK = 10000000b>>>>> |