Rev 178 | 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 |
||
113 | virtual at 0 |
||
114 | db data |
||
115 | s = $ |
||
116 | end virtual |
||
117 | d#elsz s |
||
118 | if m < s |
||
119 | m = s |
||
120 | end if |
||
121 | db data |
||
122 | .size = $-name |
||
123 | .maxl = m |
||
124 | end if |
||
125 | } |
||
126 | |||
127 | macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
||
128 | common |
||
122 | diamond | 129 | local s,m,c |
31 | halyavin | 130 | m = 0 |
122 | diamond | 131 | c = 0 |
31 | halyavin | 132 | if used name |
133 | label name |
||
134 | forward |
||
135 | if lang eq lng |
||
136 | virtual at 0 |
||
137 | db data |
||
138 | s = $ |
||
139 | end virtual |
||
140 | d#elsz s |
||
141 | if m < s |
||
142 | m = s |
||
143 | end if |
||
144 | db data |
||
122 | diamond | 145 | c = c+1 |
31 | halyavin | 146 | end if |
147 | common |
||
122 | diamond | 148 | .size = $-name |
149 | .maxl = m |
||
150 | .count = c |
||
31 | halyavin | 151 | end if |
152 | } |
||
153 | |||
154 | |||
155 | ; easy system call macro |
||
156 | macro mpack dest, hsrc, lsrc |
||
157 | { |
||
158 | if (hsrc eqtype 0) & (lsrc eqtype 0) |
||
159 | mov dest, (hsrc) shl 16 + lsrc |
||
160 | else |
||
161 | if (hsrc eqtype 0) & (~lsrc eqtype 0) |
||
162 | mov dest, (hsrc) shl 16 |
||
163 | add dest, lsrc |
||
164 | else |
||
165 | mov dest, hsrc |
||
166 | shl dest, 16 |
||
167 | add dest, lsrc |
||
168 | end if |
||
169 | end if |
||
170 | } |
||
171 | |||
172 | ;macro __mov reg,a { ; mike.dld |
||
173 | ; if ~a eq |
||
174 | ; mov reg,a |
||
175 | ; end if |
||
176 | ;} |
||
177 | |||
178 | macro __mov reg,a,b { ; mike.dld |
||
179 | if (~a eq)&(~b eq) |
||
180 | mpack reg,a,b |
||
181 | else if (~a eq)&(b eq) |
||
182 | mov reg,a |
||
183 | end if |
||
184 | } |
||
185 | |||
186 | macro mcall a,b,c,d,e,f { ; mike.dld |
||
187 | __mov eax,a |
||
188 | __mov ebx,b |
||
189 | __mov ecx,c |
||
190 | __mov edx,d |
||
191 | __mov esi,e |
||
192 | __mov edi,f |
||
193 | int 0x40 |
||
194 | } |
||
195 | |||
196 | |||
197 | ; ------------------------- |
||
198 | macro header a,[b] { |
||
199 | common |
||
200 | use32 |
||
201 | org 0 |
||
202 | db 'MENUET',a |
||
203 | forward |
||
204 | if b eq |
||
205 | dd 0 |
||
206 | else |
||
207 | dd b |
||
208 | end if } |
||
209 | macro section name { align 16 |
||
210 | label name } |
||
211 | macro func name { |
||
212 | if ~used name |
||
259 | mikedld | 213 | ;display 'FUNC NOT USED: ',`name,13,10 |
31 | halyavin | 214 | else |
215 | align 4 |
||
216 | name: |
||
122 | diamond | 217 | ;diff16 `name,0,name |
31 | halyavin | 218 | ;pushad |
219 | ;pushfd |
||
220 | ;dps `name |
||
221 | ;newline |
||
222 | ;mcall 5,1 |
||
223 | ;popfd |
||
224 | ;popad |
||
225 | } |
||
226 | macro endf { end if } |
||
227 | |||
228 | macro diff16 title,l1,l2 |
||
229 | { |
||
230 | local s,d |
||
231 | s = l2-l1 |
||
232 | display title,': 0x' |
||
233 | repeat 8 |
||
234 | d = '0' + s shr ((8-%) shl 2) and $0F |
||
235 | if d > '9' |
||
236 | d = d + 'A'-'9'-1 |
||
237 | end if |
||
238 | display d |
||
239 | end repeat |
||
240 | display 13,10 |
||
241 | } |
||
242 | |||
243 | macro diff10 title,l1,l2 |
||
244 | { |
||
245 | local s,d,z,m |
||
246 | s = l2-l1 |
||
247 | z = 0 |
||
248 | m = 1000000000 |
||
249 | display title,': ' |
||
250 | repeat 10 |
||
251 | d = '0' + s / m |
||
252 | s = s - (s/m)*m |
||
253 | m = m / 10 |
||
254 | if d <> '0' |
||
255 | z = 1 |
||
256 | end if |
||
257 | if z <> 0 |
||
258 | display d |
||
259 | end if |
||
260 | end repeat |
||
261 | display 13,10 |
||
262 | } |
||
263 | |||
264 | ; optimize the code for size |
||
265 | __regs fix |
||
266 | |||
267 | macro add arg1,arg2 |
||
268 | { |
||
269 | if (arg2 eqtype 0) |
||
270 | if (arg2) = 1 |
||
271 | inc arg1 |
||
272 | else |
||
273 | add arg1,arg2 |
||
274 | end if |
||
275 | else |
||
276 | add arg1,arg2 |
||
277 | end if |
||
278 | } |
||
279 | |||
280 | macro sub arg1,arg2 |
||
281 | { |
||
282 | if (arg2 eqtype 0) |
||
283 | if (arg2) = 1 |
||
284 | dec arg1 |
||
285 | else |
||
286 | sub arg1,arg2 |
||
287 | end if |
||
288 | else |
||
289 | sub arg1,arg2 |
||
290 | end if |
||
291 | } |
||
292 | |||
293 | macro mov arg1,arg2 |
||
294 | { |
||
295 | if (arg1 in __regs) & (arg2 eqtype 0) |
||
296 | if (arg2) = 0 |
||
297 | xor arg1,arg1 |
||
298 | else if (arg2) = 1 |
||
299 | xor arg1,arg1 |
||
300 | inc arg1 |
||
301 | else if (arg2) = -1 |
||
302 | or arg1,-1 |
||
303 | else if (arg2) > -128 & (arg2) < 128 |
||
304 | push arg2 |
||
305 | pop arg1 |
||
306 | else |
||
307 | mov arg1,arg2 |
||
308 | end if |
||
309 | else |
||
310 | mov arg1,arg2 |
||
311 | end if |
||
312 | } |
||
313 | |||
314 | |||
122 | diamond | 315 | macro RGB [a] { |
316 | common |
||
317 | match (r=,g=,b),a \{ |
||
318 | \dd ((r) shl 16) or ((g) shl 8) or (b) |
||
319 | \} |
||
320 | } |
||
321 | |||
322 | |||
31 | halyavin | 323 | struc POINT _t,_dx,_dy { |
324 | .x _t _dx |
||
325 | .y _t _dy |
||
326 | } |
||
327 | |||
328 | ; structure definition helper |
||
122 | diamond | 329 | include 'struct.inc' |
31 | halyavin | 330 | |
178 | heavyiron | 331 | struct RECT |
332 | left dd ? |
||
333 | top dd ? |
||
334 | right dd ? |
||
335 | bottom dd ? |
||
336 | ends |
||
337 | |||
338 | struct BOX |
||
339 | left dd ? |
||
340 | top dd ? |
||
341 | width dd ? |
||
342 | height dd ? |
||
343 | ends |
||
344 | |||
31 | halyavin | 345 | ; structures used in MeOS |
122 | diamond | 346 | struct process_information |
347 | cpu_usage dd ? ; +0 |
||
348 | window_stack_position dw ? ; +4 |
||
349 | window_stack_value dw ? ; +6 |
||
178 | heavyiron | 350 | dw ? ; +8 |
122 | diamond | 351 | process_name rb 12 ; +10 |
352 | memory_start dd ? ; +22 |
||
353 | used_memory dd ? ; +26 |
||
354 | PID dd ? ; +30 |
||
178 | heavyiron | 355 | box BOX ; +34 |
122 | diamond | 356 | slot_state dw ? ; +50 |
178 | heavyiron | 357 | dw ? ; +52 |
358 | client_box BOX ; +54 |
||
31 | halyavin | 359 | rb (1024-52) |
122 | diamond | 360 | ends |
31 | halyavin | 361 | |
122 | diamond | 362 | struct system_colors |
363 | frame dd ? |
||
364 | grab dd ? |
||
365 | grab_button dd ? |
||
366 | grab_button_text dd ? |
||
367 | grab_text dd ? |
||
368 | work dd ? |
||
369 | work_button dd ? |
||
370 | work_button_text dd ? |
||
371 | work_text dd ? |
||
372 | work_graph dd ? |
||
373 | ends |
||
31 | halyavin | 374 | |
259 | mikedld | 375 | struct FILEDATE |
376 | Second db ? |
||
377 | Minute db ? |
||
378 | Hour db ? |
||
379 | db ? |
||
380 | Day db ? |
||
381 | Month db ? |
||
382 | Year dw ? |
||
383 | ends |
||
122 | diamond | 384 | |
259 | mikedld | 385 | struct FILEINFO |
386 | Attributes dd ? |
||
387 | IsUnicode db ? |
||
388 | db 3 dup(?) |
||
389 | DateCreate FILEDATE |
||
390 | DateAccess FILEDATE |
||
391 | DateModify FILEDATE |
||
392 | Size dq ? |
||
393 | ends |
||
394 | |||
31 | halyavin | 395 | ; constants |
396 | |||
397 | ; events |
||
398 | EV_IDLE = 0 |
||
399 | EV_TIMER = 0 |
||
400 | EV_REDRAW = 1 |
||
401 | EV_KEY = 2 |
||
402 | EV_BUTTON = 3 |
||
403 | EV_EXIT = 4 |
||
404 | EV_BACKGROUND = 5 |
||
405 | EV_MOUSE = 6 |
||
406 | EV_IPC = 7 |
||
407 | EV_STACK = 8 |
||
408 | |||
409 | ; event mask bits for function 40 |
||
410 | EVM_REDRAW = 1b |
||
411 | EVM_KEY = 10b |
||
412 | EVM_BUTTON = 100b |
||
413 | EVM_EXIT = 1000b |
||
414 | EVM_BACKGROUND = 10000b |
||
415 | EVM_MOUSE = 100000b |
||
416 | EVM_IPC = 1000000b |
||
417 | EVM_STACK = 10000000b>>>>> |