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