Rev 5383 | Rev 5942 | 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 | |||
1567 | dunkaist | 193 | macro szZ name,[data] { ; same as sz, but with 0 at the end of line (ASCIIZ string) [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 |
||
275 | mov dest, hsrc |
||
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) |
||
286 | mov reg,a |
||
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 | ; optimize the code for size |
||
399 | __regs fix |
||
400 | |||
401 | macro add arg1,arg2 |
||
402 | { |
||
403 | if (arg2 eqtype 0) |
||
404 | if (arg2) = 1 |
||
1567 | dunkaist | 405 | inc arg1 |
485 | heavyiron | 406 | else |
1567 | dunkaist | 407 | add arg1,arg2 |
485 | heavyiron | 408 | end if |
409 | else |
||
410 | add arg1,arg2 |
||
411 | end if |
||
412 | } |
||
413 | |||
414 | macro sub arg1,arg2 |
||
415 | { |
||
416 | if (arg2 eqtype 0) |
||
417 | if (arg2) = 1 |
||
1567 | dunkaist | 418 | dec arg1 |
485 | heavyiron | 419 | else |
1567 | dunkaist | 420 | sub arg1,arg2 |
485 | heavyiron | 421 | end if |
422 | else |
||
423 | sub arg1,arg2 |
||
424 | end if |
||
425 | } |
||
426 | |||
427 | macro mov arg1,arg2 |
||
428 | { |
||
429 | if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
||
430 | if (arg2) = 0 |
||
1567 | dunkaist | 431 | xor arg1,arg1 |
485 | heavyiron | 432 | else if (arg2) = 1 |
1567 | dunkaist | 433 | xor arg1,arg1 |
434 | inc arg1 |
||
485 | heavyiron | 435 | else if (arg2) = -1 |
1567 | dunkaist | 436 | or arg1,-1 |
485 | heavyiron | 437 | else if (arg2) > -128 & (arg2) < 128 |
1567 | dunkaist | 438 | push arg2 |
439 | pop arg1 |
||
485 | heavyiron | 440 | else |
1567 | dunkaist | 441 | mov arg1,arg2 |
485 | heavyiron | 442 | end if |
443 | else |
||
444 | mov arg1,arg2 |
||
445 | end if |
||
446 | } |
||
447 | |||
448 | |||
449 | macro RGB [a] { |
||
450 | common |
||
451 | match (r=,g=,b),a \{ |
||
452 | \dd ((r) shl 16) or ((g) shl 8) or (b) |
||
453 | \} |
||
454 | } |
||
455 | |||
456 | |||
457 | struc POINT _t,_dx,_dy { |
||
458 | .x _t _dx |
||
459 | .y _t _dy |
||
460 | } |
||
461 | |||
462 | ; structure definition helper |
||
463 | include 'struct.inc' |
||
464 | |||
465 | struct RECT |
||
1567 | dunkaist | 466 | left dd ? |
467 | top dd ? |
||
485 | heavyiron | 468 | right dd ? |
469 | bottom dd ? |
||
470 | ends |
||
471 | |||
472 | struct BOX |
||
1567 | dunkaist | 473 | left dd ? |
474 | top dd ? |
||
485 | heavyiron | 475 | width dd ? |
476 | height dd ? |
||
477 | ends |
||
478 | |||
3032 | leency | 479 | ; structures used in KolibriOS |
485 | heavyiron | 480 | struct process_information |
3032 | leency | 481 | cpu_usage dd ? ; +0 |
1567 | dunkaist | 482 | window_stack_position dw ? ; +4 |
483 | window_stack_value dw ? ; +6 |
||
3032 | leency | 484 | dw ? ; +8 |
485 | process_name rb 12 ; +10 |
||
486 | memory_start dd ? ; +22 |
||
487 | used_memory dd ? ; +26 |
||
488 | PID dd ? ; +30 |
||
489 | box BOX ; +34 |
||
490 | slot_state dw ? ; +50 |
||
491 | dw ? ; +52 |
||
492 | client_box BOX ; +54 |
||
485 | heavyiron | 493 | wnd_state db ? ; +70 |
494 | rb (1024-71) |
||
495 | ends |
||
496 | |||
497 | struct system_colors |
||
3032 | leency | 498 | frame dd ? |
499 | grab dd ? |
||
1567 | dunkaist | 500 | grab_button dd ? |
485 | heavyiron | 501 | grab_button_text dd ? |
3032 | leency | 502 | grab_text dd ? |
503 | work dd ? |
||
1567 | dunkaist | 504 | work_button dd ? |
485 | heavyiron | 505 | work_button_text dd ? |
3032 | leency | 506 | work_text dd ? |
1567 | dunkaist | 507 | work_graph dd ? |
485 | heavyiron | 508 | ends |
509 | |||
4817 | yogev_ezra | 510 | struct sys_colors_new |
4795 | Akyltist | 511 | menu_body dd ? |
512 | 3d_face dd ? |
||
513 | 3d_dark dd ? |
||
514 | 3d_light dd ? |
||
515 | win_title dd ? |
||
516 | win_body dd ? |
||
517 | btn_face dd ? |
||
518 | btn_text dd ? |
||
519 | win_text dd ? |
||
520 | panel_frame dd ? |
||
521 | win_face dd ? |
||
522 | win_inface dd ? |
||
523 | win_frame dd ? |
||
524 | win_inframe dd ? |
||
525 | win_border dd ? |
||
526 | win_inborder dd ? |
||
527 | win_graytext dd ? |
||
528 | menu_frame dd ? |
||
529 | menu_text dd ? |
||
530 | panel_body dd ? |
||
531 | panel_text dd ? |
||
532 | hint_frame dd ? |
||
533 | hint_body dd ? |
||
534 | hint_text dd ? |
||
535 | btn_inface dd ? |
||
536 | btn_fcface dd ? |
||
537 | btn_frame dd ? |
||
538 | btn_inframe dd ? |
||
539 | btn_fcframe dd ? |
||
540 | btn_intext dd ? |
||
541 | btn_fctext dd ? |
||
542 | gui_shadow dd ? |
||
543 | gui_face dd ? |
||
544 | gui_inface dd ? |
||
545 | gui_fcface dd ? |
||
546 | gui_frame dd ? |
||
547 | gui_inframe dd ? |
||
548 | gui_fcframe dd ? |
||
549 | gui_text dd ? |
||
550 | gui_intext dd ? |
||
551 | gui_fctext dd ? |
||
552 | gui_select dd ? |
||
553 | res_var_a dd ? |
||
554 | res_var_b dd ? |
||
555 | res_var_c dd ? |
||
556 | res_var_d dd ? |
||
557 | res_var_e dd ? |
||
558 | res_var_f dd ? |
||
559 | ends |
||
560 | |||
485 | heavyiron | 561 | struct FILEDATE |
562 | Second db ? |
||
563 | Minute db ? |
||
1567 | dunkaist | 564 | Hour db ? |
3032 | leency | 565 | db ? |
1567 | dunkaist | 566 | Day db ? |
485 | heavyiron | 567 | Month db ? |
1567 | dunkaist | 568 | Year dw ? |
485 | heavyiron | 569 | ends |
570 | |||
571 | struct FILEINFO |
||
572 | Attributes dd ? |
||
573 | IsUnicode db ? |
||
3032 | leency | 574 | db 3 dup(?) |
485 | heavyiron | 575 | DateCreate FILEDATE |
576 | DateAccess FILEDATE |
||
577 | DateModify FILEDATE |
||
1567 | dunkaist | 578 | Size dq ? |
485 | heavyiron | 579 | ends |
580 | |||
5383 | hidnplayr | 581 | cmove fix cmovz |
3618 | hidnplayr | 582 | |
583 | macro cmovz reg1, reg2 { |
||
584 | |||
5384 | hidnplayr | 585 | local ..jumpaddr |
586 | |||
5383 | hidnplayr | 587 | if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 |
588 | jnz ..jumpaddr |
||
589 | mov reg1, reg2 |
||
590 | ..jumpaddr: |
||
591 | else |
||
592 | cmovz reg1, reg2 |
||
593 | end if |
||
3618 | hidnplayr | 594 | |
595 | } |
||
596 | |||
597 | cmovne fix cmovnz |
||
5383 | hidnplayr | 598 | |
3618 | hidnplayr | 599 | macro cmovnz reg1, reg2 { |
600 | |||
5384 | hidnplayr | 601 | local ..jumpaddr |
602 | |||
5383 | hidnplayr | 603 | if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 |
604 | jz ..jumpaddr |
||
605 | mov reg1, reg2 |
||
606 | ..jumpaddr: |
||
607 | else |
||
608 | cmovnz reg1, reg2 |
||
609 | end if |
||
3618 | hidnplayr | 610 | |
611 | } |
||
612 | |||
613 | macro cmovg reg1, reg2 { |
||
614 | |||
5384 | hidnplayr | 615 | local ..jumpaddr |
616 | |||
5383 | hidnplayr | 617 | if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 |
618 | jle ..jumpaddr |
||
3618 | hidnplayr | 619 | mov reg1, reg2 |
5383 | hidnplayr | 620 | ..jumpaddr: |
621 | else |
||
622 | cmovg reg1, reg2 |
||
623 | end if |
||
3618 | hidnplayr | 624 | } |
625 | |||
626 | macro cmovl reg1, reg2 { |
||
627 | |||
5384 | hidnplayr | 628 | local ..jumpaddr |
629 | |||
5383 | hidnplayr | 630 | if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 |
631 | jge ..jumpaddr |
||
3618 | hidnplayr | 632 | mov reg1, reg2 |
5383 | hidnplayr | 633 | ..jumpaddr: |
634 | else |
||
635 | cmovl reg1, reg2 |
||
636 | end if |
||
3618 | hidnplayr | 637 | } |
638 | |||
485 | heavyiron | 639 | ; constants |
640 | |||
641 | ; events |
||
642 | EV_IDLE = 0 |
||
643 | EV_TIMER = 0 |
||
644 | EV_REDRAW = 1 |
||
1567 | dunkaist | 645 | EV_KEY = 2 |
485 | heavyiron | 646 | EV_BUTTON = 3 |
647 | EV_EXIT = 4 |
||
648 | EV_BACKGROUND = 5 |
||
649 | EV_MOUSE = 6 |
||
1567 | dunkaist | 650 | EV_IPC = 7 |
485 | heavyiron | 651 | EV_STACK = 8 |
652 | |||
653 | ; event mask bits for function 40 |
||
3618 | hidnplayr | 654 | EVM_REDRAW = 1b |
655 | EVM_KEY = 10b |
||
656 | EVM_BUTTON = 100b |
||
657 | EVM_EXIT = 1000b |
||
658 | EVM_BACKGROUND = 10000b |
||
659 | EVM_MOUSE = 100000b |
||
660 | EVM_IPC = 1000000b |
||
661 | EVM_STACK = 10000000b |
||
662 | EVM_DEBUG = 100000000b |
||
663 | EVM_STACK2 = 1000000000b |
||
3942 | mario79 | 664 | |
665 | EVM_MOUSE_FILTER = 0x80000000 |
||
666 | EVM_CURSOR_FILTER = 0x40000000>>>>> |