Rev 6276 | Rev 7134 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
485 | heavyiron | 1 | @^ fix macro comment { |
2 | ^@ fix } |
||
3 | |||
4795 | Akyltist | 4 | ; ------------------------- |
5 | macro library [lname,fname] |
||
6 | { |
||
7 | forward |
||
8 | dd __#lname#_library_table__,__#lname#_library_name__ |
||
9 | common |
||
10 | dd 0 |
||
11 | forward |
||
12 | align 4 |
||
13 | __#lname#_library_name__ db fname,0 |
||
14 | } |
||
485 | heavyiron | 15 | |
4795 | Akyltist | 16 | macro import lname,[name,sname] |
17 | { |
||
18 | common |
||
19 | align 4 |
||
20 | __#lname#_library_table__: |
||
21 | forward |
||
22 | if used name |
||
23 | name dd __#name#_import_name__ |
||
24 | end if |
||
25 | common |
||
26 | dd 0 |
||
27 | forward |
||
28 | if used name |
||
29 | align 4 |
||
30 | __#name#_import_name__ db sname,0 |
||
31 | end if |
||
32 | } |
||
33 | |||
34 | macro export [name,sname] |
||
35 | { |
||
36 | forward |
||
37 | dd __#name#_export_name__,name |
||
38 | common |
||
39 | dd 0 |
||
40 | forward |
||
41 | align 4 |
||
42 | __#name#_export_name__ db sname,0 |
||
43 | } |
||
44 | ; ------------------------- |
||
45 | |||
485 | heavyiron | 46 | macro m2m dest,src { |
47 | push src |
||
48 | pop dest |
||
49 | } |
||
50 | |||
51 | |||
52 | macro iglobal { |
||
53 | IGlobals equ IGlobals, |
||
54 | macro __IGlobalBlock { } |
||
55 | |||
56 | macro uglobal { |
||
57 | UGlobals equ UGlobals, |
||
58 | macro __UGlobalBlock { } |
||
59 | |||
60 | endg fix } ; Use endg for ending iglobal and uglobal blocks. |
||
61 | |||
62 | |||
63 | macro IncludeIGlobals{ |
||
64 | macro IGlobals dummy,[n] \{ __IGlobalBlock |
||
65 | purge __IGlobalBlock \} |
||
66 | match I, IGlobals \{ I \} } |
||
67 | |||
68 | macro IncludeUGlobals{ |
||
69 | macro UGlobals dummy,[n] \{ |
||
70 | \common |
||
71 | \local begin, size |
||
72 | begin = $ |
||
73 | virtual at $ |
||
74 | \forward |
||
75 | __UGlobalBlock |
||
76 | purge __UGlobalBlock |
||
77 | \common |
||
78 | size = $ - begin |
||
79 | end virtual |
||
80 | rb size |
||
81 | \} |
||
82 | match U, UGlobals \{ U \} } |
||
83 | |||
84 | uglobal |
||
85 | endg |
||
86 | |||
87 | iglobal |
||
88 | endg |
||
89 | |||
90 | |||
91 | ; new application structure |
||
92 | macro meos_app_start |
||
93 | { |
||
94 | use32 |
||
95 | org 0x0 |
||
96 | |||
97 | db 'MENUET01' |
||
98 | dd 0x01 |
||
99 | dd __start |
||
100 | dd __end |
||
101 | dd __memory |
||
102 | dd __stack |
||
103 | |||
104 | if used __params & ~defined __params |
||
105 | dd __params |
||
106 | else |
||
107 | dd 0x0 |
||
108 | end if |
||
109 | |||
110 | dd 0x0 |
||
111 | } |
||
112 | MEOS_APP_START fix meos_app_start |
||
113 | |||
114 | macro code |
||
115 | { |
||
116 | __start: |
||
117 | } |
||
118 | CODE fix code |
||
119 | |||
120 | macro data |
||
121 | { |
||
122 | __data: |
||
123 | IncludeIGlobals |
||
124 | } |
||
125 | DATA fix data |
||
126 | |||
127 | macro udata |
||
128 | { |
||
129 | if used __params & ~defined __params |
||
130 | __params: |
||
131 | db 0 |
||
132 | __end: |
||
133 | rb 255 |
||
134 | else |
||
135 | __end: |
||
136 | end if |
||
137 | __udata: |
||
138 | IncludeUGlobals |
||
139 | } |
||
140 | UDATA fix udata |
||
141 | |||
142 | macro meos_app_end |
||
143 | { |
||
144 | align 32 |
||
145 | rb 2048 |
||
146 | __stack: |
||
147 | __memory: |
||
148 | } |
||
149 | MEOS_APP_END fix meos_app_end |
||
150 | |||
151 | |||
152 | ; macro for defining multiline text data |
||
153 | struc mstr [sstring] |
||
154 | { |
||
155 | forward |
||
156 | local ssize |
||
157 | virtual at 0 |
||
158 | db sstring |
||
159 | ssize = $ |
||
160 | end virtual |
||
161 | dd ssize |
||
162 | db sstring |
||
163 | common |
||
164 | dd -1 |
||
165 | } |
||
166 | |||
167 | ; macro for defining multiline text data |
||
168 | struc mls [sstring] |
||
169 | { |
||
170 | forward |
||
171 | local ssize |
||
172 | virtual at 0 |
||
173 | db sstring ; mod |
||
174 | ssize = $ |
||
175 | end virtual |
||
176 | db ssize |
||
177 | db sstring |
||
178 | common |
||
179 | db -1 ; mod |
||
180 | } |
||
181 | |||
182 | |||
183 | |||
184 | ; strings |
||
1567 | dunkaist | 185 | macro sz name,[data] { ; from MFAR [mike.dld] |
485 | heavyiron | 186 | common |
187 | if used name |
||
188 | name db data |
||
189 | .size = $-name |
||
190 | end if |
||
191 | } |
||
192 | |||
5943 | pathoswith | 193 | macro szZ name,[data] { ; same as sz, but for zero terminated string [dunkaist] |
1567 | dunkaist | 194 | common |
195 | if used name |
||
196 | name db data,0 |
||
197 | .size = $-name-1 |
||
198 | end if |
||
199 | } |
||
200 | sz0 fix szZ |
||
201 | |||
485 | heavyiron | 202 | macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
203 | common |
||
204 | if used name |
||
205 | label name |
||
206 | forward |
||
207 | if lang eq lng |
||
208 | db data |
||
209 | end if |
||
210 | common |
||
211 | .size = $-name |
||
212 | end if |
||
213 | } |
||
214 | |||
1567 | dunkaist | 215 | macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
485 | heavyiron | 216 | common |
217 | local s,m |
||
218 | m = 0 |
||
219 | if used name |
||
220 | label name |
||
221 | forward |
||
222 | virtual at 0 |
||
223 | db data |
||
224 | s = $ |
||
225 | end virtual |
||
226 | d#elsz s |
||
227 | if m < s |
||
228 | m = s |
||
229 | end if |
||
230 | db data |
||
231 | common |
||
232 | .size = $-name |
||
233 | .maxl = m |
||
234 | end if |
||
235 | } |
||
236 | |||
237 | macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
||
238 | common |
||
239 | local s,m,c |
||
240 | m = 0 |
||
241 | c = 0 |
||
242 | if used name |
||
243 | label name |
||
244 | forward |
||
245 | if lang eq lng |
||
246 | virtual at 0 |
||
247 | db data |
||
248 | s = $ |
||
249 | end virtual |
||
250 | d#elsz s |
||
251 | if m < s |
||
252 | m = s |
||
253 | end if |
||
254 | db data |
||
255 | c = c+1 |
||
256 | end if |
||
257 | common |
||
258 | .size = $-name |
||
259 | .maxl = m |
||
260 | .count = c |
||
261 | end if |
||
262 | } |
||
263 | |||
264 | |||
265 | ; easy system call macro |
||
266 | macro mpack dest, hsrc, lsrc |
||
267 | { |
||
268 | if (hsrc eqtype 0) & (lsrc eqtype 0) |
||
269 | mov dest, (hsrc) shl 16 + lsrc |
||
270 | else |
||
271 | if (hsrc eqtype 0) & (~lsrc eqtype 0) |
||
272 | mov dest, (hsrc) shl 16 |
||
273 | add dest, lsrc |
||
274 | else |
||
5947 | pathoswith | 275 | mov dest, hsrc |
485 | heavyiron | 276 | shl dest, 16 |
277 | add dest, lsrc |
||
278 | end if |
||
279 | end if |
||
280 | } |
||
281 | |||
1567 | dunkaist | 282 | macro __mov reg,a,b { ; mike.dld |
485 | heavyiron | 283 | if (~a eq)&(~b eq) |
284 | mpack reg,a,b |
||
285 | else if (~a eq)&(b eq) |
||
5947 | pathoswith | 286 | mov reg,a |
485 | heavyiron | 287 | end if |
288 | } |
||
289 | |||
290 | |||
291 | include 'config.inc' |
||
1567 | dunkaist | 292 | ;__CPU_type equ p5 |
293 | SYSENTER_VAR equ 0 |
||
485 | heavyiron | 294 | |
3618 | hidnplayr | 295 | macro mcall a,b,c,d,e,f { ; mike.dld, updated by Ghost for Fast System Calls |
296 | local ..ret_point |
||
485 | heavyiron | 297 | __mov eax,a |
298 | __mov ebx,b |
||
299 | __mov ecx,c |
||
300 | __mov edx,d |
||
301 | __mov esi,e |
||
302 | __mov edi,f |
||
303 | |||
3618 | hidnplayr | 304 | if __CPU_type eq p5 |
305 | int 0x40 |
||
306 | else |
||
307 | if __CPU_type eq p6 |
||
308 | push ebp |
||
309 | mov ebp, esp |
||
310 | push ..ret_point ; it may be 2 or 5 byte |
||
311 | sysenter |
||
312 | ..ret_point: |
||
313 | pop edx |
||
314 | pop ecx |
||
315 | |||
316 | else |
||
317 | if __CPU_type eq k6 |
||
318 | push ecx |
||
319 | syscall |
||
320 | pop ecx |
||
321 | else |
||
322 | display 'ERROR : unknown CPU type (set to p5)', 10, 13 |
||
323 | __CPU_type equ p5 |
||
324 | int 0x40 |
||
325 | end if |
||
326 | end if |
||
327 | end if |
||
485 | heavyiron | 328 | } |
329 | |||
330 | |||
331 | ; ------------------------- |
||
332 | macro header a,[b] { |
||
333 | common |
||
334 | use32 |
||
335 | org 0 |
||
336 | db 'MENUET',a |
||
337 | forward |
||
338 | if b eq |
||
339 | dd 0 |
||
340 | else |
||
341 | dd b |
||
342 | end if } |
||
343 | macro section name { align 16 |
||
344 | label name } |
||
345 | macro func name { |
||
346 | if ~used name |
||
347 | display 'FUNC NOT USED: ',`name,13,10 |
||
348 | else |
||
349 | align 4 |
||
350 | name: |
||
351 | ;diff16 `name,0,name |
||
352 | ;pushad |
||
353 | ;pushfd |
||
354 | ;dps `name |
||
355 | ;newline |
||
356 | ;mcall 5,1 |
||
357 | ;popfd |
||
358 | ;popad |
||
359 | } |
||
360 | macro endf { end if } |
||
361 | |||
362 | macro diff16 title,l1,l2 |
||
363 | { |
||
364 | local s,d |
||
365 | s = l2-l1 |
||
366 | display title,': 0x' |
||
367 | repeat 8 |
||
368 | d = '0' + s shr ((8-%) shl 2) and $0F |
||
369 | if d > '9' |
||
370 | d = d + 'A'-'9'-1 |
||
371 | end if |
||
372 | display d |
||
373 | end repeat |
||
374 | display 13,10 |
||
375 | } |
||
376 | |||
377 | macro diff10 title,l1,l2 |
||
378 | { |
||
379 | local s,d,z,m |
||
380 | s = l2-l1 |
||
381 | z = 0 |
||
382 | m = 1000000000 |
||
383 | display title,': ' |
||
384 | repeat 10 |
||
385 | d = '0' + s / m |
||
386 | s = s - (s/m)*m |
||
387 | m = m / 10 |
||
388 | if d <> '0' |
||
389 | z = 1 |
||
390 | end if |
||
391 | if z <> 0 |
||
392 | display d |
||
393 | end if |
||
394 | end repeat |
||
395 | display 13,10 |
||
396 | } |
||
397 | |||
398 | |||
5943 | pathoswith | 399 | macro movi arg1,arg2 |
400 | { |
||
401 | if (arg1 in |
||
402 | if (arg2) = 0 |
||
403 | xor arg1,arg1 |
||
404 | else if (arg2) = 1 |
||
405 | xor arg1,arg1 |
||
406 | inc arg1 |
||
407 | else if (arg2) = -1 |
||
408 | or arg1,-1 |
||
409 | else if (arg2) >= -128 & (arg2) <= 127 |
||
410 | push arg2 |
||
411 | pop arg1 |
||
412 | else |
||
413 | mov arg1,arg2 |
||
414 | end if |
||
415 | else |
||
416 | mov arg1,arg2 |
||
417 | end if |
||
418 | } |
||
485 | heavyiron | 419 | |
420 | |||
421 | macro RGB [a] { |
||
422 | common |
||
423 | match (r=,g=,b),a \{ |
||
424 | \dd ((r) shl 16) or ((g) shl 8) or (b) |
||
425 | \} |
||
426 | } |
||
427 | |||
428 | |||
429 | struc POINT _t,_dx,_dy { |
||
430 | .x _t _dx |
||
431 | .y _t _dy |
||
432 | } |
||
433 | |||
434 | ; structure definition helper |
||
435 | include 'struct.inc' |
||
436 | |||
437 | struct RECT |
||
1567 | dunkaist | 438 | left dd ? |
439 | top dd ? |
||
485 | heavyiron | 440 | right dd ? |
441 | bottom dd ? |
||
442 | ends |
||
443 | |||
444 | struct BOX |
||
1567 | dunkaist | 445 | left dd ? |
446 | top dd ? |
||
485 | heavyiron | 447 | width dd ? |
448 | height dd ? |
||
449 | ends |
||
450 | |||
3032 | leency | 451 | ; structures used in KolibriOS |
485 | heavyiron | 452 | struct process_information |
3032 | leency | 453 | cpu_usage dd ? ; +0 |
1567 | dunkaist | 454 | window_stack_position dw ? ; +4 |
455 | window_stack_value dw ? ; +6 |
||
3032 | leency | 456 | dw ? ; +8 |
457 | process_name rb 12 ; +10 |
||
458 | memory_start dd ? ; +22 |
||
459 | used_memory dd ? ; +26 |
||
460 | PID dd ? ; +30 |
||
461 | box BOX ; +34 |
||
462 | slot_state dw ? ; +50 |
||
463 | dw ? ; +52 |
||
464 | client_box BOX ; +54 |
||
485 | heavyiron | 465 | wnd_state db ? ; +70 |
466 | rb (1024-71) |
||
467 | ends |
||
468 | |||
469 | struct system_colors |
||
6219 | leency | 470 | frame dd ? ;nonset1 |
471 | grab dd ? ;nonset2 |
||
6196 | leency | 472 | work_3d_dark dd ? |
473 | work_3d_light dd ? |
||
6276 | leency | 474 | grab_text dd ? ;window_title |
3032 | leency | 475 | work dd ? |
1567 | dunkaist | 476 | work_button dd ? |
485 | heavyiron | 477 | work_button_text dd ? |
3032 | leency | 478 | work_text dd ? |
1567 | dunkaist | 479 | work_graph dd ? |
485 | heavyiron | 480 | ends |
481 | |||
482 | struct FILEDATE |
||
483 | Second db ? |
||
484 | Minute db ? |
||
1567 | dunkaist | 485 | Hour db ? |
3032 | leency | 486 | db ? |
1567 | dunkaist | 487 | Day db ? |
485 | heavyiron | 488 | Month db ? |
1567 | dunkaist | 489 | Year dw ? |
485 | heavyiron | 490 | ends |
491 | |||
492 | struct FILEINFO |
||
493 | Attributes dd ? |
||
494 | IsUnicode db ? |
||
3032 | leency | 495 | db 3 dup(?) |
485 | heavyiron | 496 | DateCreate FILEDATE |
497 | DateAccess FILEDATE |
||
498 | DateModify FILEDATE |
||
1567 | dunkaist | 499 | Size dq ? |
485 | heavyiron | 500 | ends |
501 | |||
5383 | hidnplayr | 502 | cmove fix cmovz |
3618 | hidnplayr | 503 | |
504 | macro cmovz reg1, reg2 { |
||
505 | |||
5384 | hidnplayr | 506 | local ..jumpaddr |
507 | |||
5383 | hidnplayr | 508 | if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 |
509 | jnz ..jumpaddr |
||
510 | mov reg1, reg2 |
||
511 | ..jumpaddr: |
||
512 | else |
||
513 | cmovz reg1, reg2 |
||
514 | end if |
||
3618 | hidnplayr | 515 | |
516 | } |
||
517 | |||
518 | cmovne fix cmovnz |
||
5383 | hidnplayr | 519 | |
3618 | hidnplayr | 520 | macro cmovnz reg1, reg2 { |
521 | |||
5384 | hidnplayr | 522 | local ..jumpaddr |
523 | |||
5383 | hidnplayr | 524 | if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 |
525 | jz ..jumpaddr |
||
526 | mov reg1, reg2 |
||
527 | ..jumpaddr: |
||
528 | else |
||
529 | cmovnz reg1, reg2 |
||
530 | end if |
||
3618 | hidnplayr | 531 | |
532 | } |
||
533 | |||
534 | macro cmovg reg1, reg2 { |
||
535 | |||
5384 | hidnplayr | 536 | local ..jumpaddr |
537 | |||
5383 | hidnplayr | 538 | if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 |
539 | jle ..jumpaddr |
||
3618 | hidnplayr | 540 | mov reg1, reg2 |
5383 | hidnplayr | 541 | ..jumpaddr: |
542 | else |
||
543 | cmovg reg1, reg2 |
||
544 | end if |
||
3618 | hidnplayr | 545 | } |
546 | |||
547 | macro cmovl reg1, reg2 { |
||
548 | |||
5384 | hidnplayr | 549 | local ..jumpaddr |
550 | |||
5383 | hidnplayr | 551 | if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 |
552 | jge ..jumpaddr |
||
3618 | hidnplayr | 553 | mov reg1, reg2 |
5383 | hidnplayr | 554 | ..jumpaddr: |
555 | else |
||
556 | cmovl reg1, reg2 |
||
557 | end if |
||
3618 | hidnplayr | 558 | } |
559 | |||
6832 | dunkaist | 560 | ; replaces /programs/cmp.inc |
561 | irp cond, e, ne, g, ng, l, nl, ge, le { |
||
562 | macro cmp#cond a, b, c\{ |
||
563 | cmp a, b |
||
564 | j#cond c |
||
565 | \} |
||
566 | } |
||
567 | |||
485 | heavyiron | 568 | ; constants |
569 | |||
570 | ; events |
||
571 | EV_IDLE = 0 |
||
572 | EV_TIMER = 0 |
||
573 | EV_REDRAW = 1 |
||
1567 | dunkaist | 574 | EV_KEY = 2 |
485 | heavyiron | 575 | EV_BUTTON = 3 |
576 | EV_EXIT = 4 |
||
577 | EV_BACKGROUND = 5 |
||
578 | EV_MOUSE = 6 |
||
1567 | dunkaist | 579 | EV_IPC = 7 |
485 | heavyiron | 580 | EV_STACK = 8 |
581 | |||
582 | ; event mask bits for function 40 |
||
3618 | hidnplayr | 583 | EVM_REDRAW = 1b |
584 | EVM_KEY = 10b |
||
585 | EVM_BUTTON = 100b |
||
586 | EVM_EXIT = 1000b |
||
587 | EVM_BACKGROUND = 10000b |
||
588 | EVM_MOUSE = 100000b |
||
589 | EVM_IPC = 1000000b |
||
590 | EVM_STACK = 10000000b |
||
591 | EVM_DEBUG = 100000000b |
||
592 | EVM_STACK2 = 1000000000b |
||
3942 | mario79 | 593 | |
594 | EVM_MOUSE_FILTER = 0x80000000 |
||
595 | EVM_CURSOR_FILTER = 0x40000000=>>>>> |