Rev 3340 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1166 | hidnplayr | 1 | @^ fix macro comment { |
2 | ^@ fix } |
||
3 | |||
1528 | hidnplayr | 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 | } |
||
1166 | hidnplayr | 15 | |
1528 | hidnplayr | 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 | |||
1166 | hidnplayr | 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 | |||
3340 | hidnplayr | 60 | endg fix } ; Use endg for ending iglobal and uglobal blocks. |
1166 | hidnplayr | 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 |
||
3340 | hidnplayr | 179 | db -1 ; mod |
1166 | hidnplayr | 180 | } |
181 | |||
182 | |||
183 | |||
184 | ; strings |
||
3340 | hidnplayr | 185 | macro sz name,[data] { ; from MFAR [mike.dld] |
1166 | hidnplayr | 186 | common |
187 | if used name |
||
188 | name db data |
||
189 | .size = $-name |
||
190 | end if |
||
191 | } |
||
192 | |||
193 | macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
||
194 | common |
||
195 | if used name |
||
196 | label name |
||
197 | forward |
||
198 | if lang eq lng |
||
199 | db data |
||
200 | end if |
||
201 | common |
||
202 | .size = $-name |
||
203 | end if |
||
204 | } |
||
205 | |||
3340 | hidnplayr | 206 | macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
1166 | hidnplayr | 207 | common |
208 | local s,m |
||
209 | m = 0 |
||
210 | if used name |
||
211 | label name |
||
212 | forward |
||
213 | virtual at 0 |
||
214 | db data |
||
215 | s = $ |
||
216 | end virtual |
||
217 | d#elsz s |
||
218 | if m < s |
||
219 | m = s |
||
220 | end if |
||
221 | db data |
||
222 | common |
||
223 | .size = $-name |
||
224 | .maxl = m |
||
225 | end if |
||
226 | } |
||
227 | |||
228 | macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
||
229 | common |
||
230 | local s,m,c |
||
231 | m = 0 |
||
232 | c = 0 |
||
233 | if used name |
||
234 | label name |
||
235 | forward |
||
236 | if lang eq lng |
||
237 | virtual at 0 |
||
238 | db data |
||
239 | s = $ |
||
240 | end virtual |
||
241 | d#elsz s |
||
242 | if m < s |
||
243 | m = s |
||
244 | end if |
||
245 | db data |
||
246 | c = c+1 |
||
247 | end if |
||
248 | common |
||
249 | .size = $-name |
||
250 | .maxl = m |
||
251 | .count = c |
||
252 | end if |
||
253 | } |
||
254 | |||
255 | |||
256 | ; easy system call macro |
||
257 | macro mpack dest, hsrc, lsrc |
||
258 | { |
||
259 | if (hsrc eqtype 0) & (lsrc eqtype 0) |
||
260 | mov dest, (hsrc) shl 16 + lsrc |
||
261 | else |
||
262 | if (hsrc eqtype 0) & (~lsrc eqtype 0) |
||
263 | mov dest, (hsrc) shl 16 |
||
264 | add dest, lsrc |
||
265 | else |
||
266 | mov dest, hsrc |
||
267 | shl dest, 16 |
||
268 | add dest, lsrc |
||
269 | end if |
||
270 | end if |
||
271 | } |
||
272 | |||
3340 | hidnplayr | 273 | macro __mov reg,a,b { ; mike.dld |
1166 | hidnplayr | 274 | if (~a eq)&(~b eq) |
275 | mpack reg,a,b |
||
276 | else if (~a eq)&(b eq) |
||
277 | mov reg,a |
||
278 | end if |
||
279 | } |
||
280 | |||
281 | |||
282 | include 'config.inc' |
||
1528 | hidnplayr | 283 | ;__CPU_type equ p5 |
3340 | hidnplayr | 284 | SYSENTER_VAR equ 0 |
1166 | hidnplayr | 285 | |
286 | macro mcall a,b,c,d,e,f { ; mike.dld, updated by Ghost for Fast System Calls |
||
3340 | hidnplayr | 287 | local ..ret_point |
1166 | hidnplayr | 288 | __mov eax,a |
289 | __mov ebx,b |
||
290 | __mov ecx,c |
||
291 | __mov edx,d |
||
292 | __mov esi,e |
||
293 | __mov edi,f |
||
294 | |||
295 | if __CPU_type eq p5 |
||
3340 | hidnplayr | 296 | int 0x40 |
1166 | hidnplayr | 297 | else |
298 | if __CPU_type eq p6 |
||
3340 | hidnplayr | 299 | push ebp |
300 | mov ebp, esp |
||
301 | push ..ret_point ; it may be 2 or 5 byte |
||
302 | sysenter |
||
1166 | hidnplayr | 303 | ..ret_point: |
3340 | hidnplayr | 304 | pop edx |
305 | pop ecx |
||
1166 | hidnplayr | 306 | |
307 | else |
||
308 | if __CPU_type eq k6 |
||
3340 | hidnplayr | 309 | push ecx |
310 | syscall |
||
311 | pop ecx |
||
1166 | hidnplayr | 312 | else |
3340 | hidnplayr | 313 | display 'ERROR : unknown CPU type (set to p5)', 10, 13 |
314 | __CPU_type equ p5 |
||
315 | int 0x40 |
||
1166 | hidnplayr | 316 | end if |
317 | end if |
||
318 | end if |
||
319 | } |
||
320 | |||
321 | |||
322 | ; ------------------------- |
||
323 | macro header a,[b] { |
||
324 | common |
||
325 | use32 |
||
326 | org 0 |
||
327 | db 'MENUET',a |
||
328 | forward |
||
329 | if b eq |
||
330 | dd 0 |
||
331 | else |
||
332 | dd b |
||
333 | end if } |
||
334 | macro section name { align 16 |
||
335 | label name } |
||
336 | macro func name { |
||
337 | if ~used name |
||
338 | display 'FUNC NOT USED: ',`name,13,10 |
||
339 | else |
||
340 | align 4 |
||
341 | name: |
||
342 | ;diff16 `name,0,name |
||
343 | ;pushad |
||
344 | ;pushfd |
||
345 | ;dps `name |
||
346 | ;newline |
||
347 | ;mcall 5,1 |
||
348 | ;popfd |
||
349 | ;popad |
||
350 | } |
||
351 | macro endf { end if } |
||
352 | |||
353 | macro diff16 title,l1,l2 |
||
354 | { |
||
355 | local s,d |
||
356 | s = l2-l1 |
||
357 | display title,': 0x' |
||
358 | repeat 8 |
||
359 | d = '0' + s shr ((8-%) shl 2) and $0F |
||
360 | if d > '9' |
||
361 | d = d + 'A'-'9'-1 |
||
362 | end if |
||
363 | display d |
||
364 | end repeat |
||
365 | display 13,10 |
||
366 | } |
||
367 | |||
368 | macro diff10 title,l1,l2 |
||
369 | { |
||
370 | local s,d,z,m |
||
371 | s = l2-l1 |
||
372 | z = 0 |
||
373 | m = 1000000000 |
||
374 | display title,': ' |
||
375 | repeat 10 |
||
376 | d = '0' + s / m |
||
377 | s = s - (s/m)*m |
||
378 | m = m / 10 |
||
379 | if d <> '0' |
||
380 | z = 1 |
||
381 | end if |
||
382 | if z <> 0 |
||
383 | display d |
||
384 | end if |
||
385 | end repeat |
||
386 | display 13,10 |
||
387 | } |
||
388 | |||
389 | ; optimize the code for size |
||
390 | __regs fix |
||
391 | |||
392 | macro add arg1,arg2 |
||
393 | { |
||
394 | if (arg2 eqtype 0) |
||
395 | if (arg2) = 1 |
||
3340 | hidnplayr | 396 | inc arg1 |
1166 | hidnplayr | 397 | else |
3340 | hidnplayr | 398 | add arg1,arg2 |
1166 | hidnplayr | 399 | end if |
400 | else |
||
401 | add arg1,arg2 |
||
402 | end if |
||
403 | } |
||
404 | |||
405 | macro sub arg1,arg2 |
||
406 | { |
||
407 | if (arg2 eqtype 0) |
||
408 | if (arg2) = 1 |
||
3340 | hidnplayr | 409 | dec arg1 |
1166 | hidnplayr | 410 | else |
3340 | hidnplayr | 411 | sub arg1,arg2 |
1166 | hidnplayr | 412 | end if |
413 | else |
||
414 | sub arg1,arg2 |
||
415 | end if |
||
416 | } |
||
417 | |||
418 | macro mov arg1,arg2 |
||
419 | { |
||
420 | if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
||
421 | if (arg2) = 0 |
||
3340 | hidnplayr | 422 | xor arg1,arg1 |
1166 | hidnplayr | 423 | else if (arg2) = 1 |
3340 | hidnplayr | 424 | xor arg1,arg1 |
425 | inc arg1 |
||
1166 | hidnplayr | 426 | else if (arg2) = -1 |
3340 | hidnplayr | 427 | or arg1,-1 |
1166 | hidnplayr | 428 | else if (arg2) > -128 & (arg2) < 128 |
3340 | hidnplayr | 429 | push arg2 |
430 | pop arg1 |
||
1166 | hidnplayr | 431 | else |
3340 | hidnplayr | 432 | mov arg1,arg2 |
1166 | hidnplayr | 433 | end if |
434 | else |
||
435 | mov arg1,arg2 |
||
436 | end if |
||
437 | } |
||
438 | |||
439 | |||
440 | macro RGB [a] { |
||
441 | common |
||
442 | match (r=,g=,b),a \{ |
||
443 | \dd ((r) shl 16) or ((g) shl 8) or (b) |
||
444 | \} |
||
445 | } |
||
446 | |||
447 | |||
448 | struc POINT _t,_dx,_dy { |
||
449 | .x _t _dx |
||
450 | .y _t _dy |
||
451 | } |
||
452 | |||
453 | ; structure definition helper |
||
454 | include 'struct.inc' |
||
455 | |||
456 | struct RECT |
||
3340 | hidnplayr | 457 | left dd ? |
458 | top dd ? |
||
1166 | hidnplayr | 459 | right dd ? |
460 | bottom dd ? |
||
461 | ends |
||
462 | |||
463 | struct BOX |
||
3340 | hidnplayr | 464 | left dd ? |
465 | top dd ? |
||
1166 | hidnplayr | 466 | width dd ? |
467 | height dd ? |
||
468 | ends |
||
469 | |||
470 | ; structures used in MeOS |
||
471 | struct process_information |
||
3340 | hidnplayr | 472 | cpu_usage dd ? ; +0 |
473 | window_stack_position dw ? ; +4 |
||
474 | window_stack_value dw ? ; +6 |
||
475 | dw ? ; +8 |
||
476 | process_name rb 12 ; +10 |
||
477 | memory_start dd ? ; +22 |
||
478 | used_memory dd ? ; +26 |
||
479 | PID dd ? ; +30 |
||
480 | box BOX ; +34 |
||
481 | slot_state dw ? ; +50 |
||
482 | dw ? ; +52 |
||
483 | client_box BOX ; +54 |
||
484 | wnd_state db ? ; +70 |
||
1166 | hidnplayr | 485 | rb (1024-71) |
486 | ends |
||
487 | |||
488 | struct system_colors |
||
3340 | hidnplayr | 489 | frame dd ? |
490 | grab dd ? |
||
491 | grab_button dd ? |
||
1166 | hidnplayr | 492 | grab_button_text dd ? |
3340 | hidnplayr | 493 | grab_text dd ? |
494 | work dd ? |
||
495 | work_button dd ? |
||
1166 | hidnplayr | 496 | work_button_text dd ? |
3340 | hidnplayr | 497 | work_text dd ? |
498 | work_graph dd ? |
||
1166 | hidnplayr | 499 | ends |
500 | |||
501 | struct FILEDATE |
||
502 | Second db ? |
||
503 | Minute db ? |
||
3340 | hidnplayr | 504 | Hour db ? |
505 | db ? |
||
506 | Day db ? |
||
1166 | hidnplayr | 507 | Month db ? |
3340 | hidnplayr | 508 | Year dw ? |
1166 | hidnplayr | 509 | ends |
510 | |||
511 | struct FILEINFO |
||
512 | Attributes dd ? |
||
513 | IsUnicode db ? |
||
3340 | hidnplayr | 514 | db 3 dup(?) |
1166 | hidnplayr | 515 | DateCreate FILEDATE |
516 | DateAccess FILEDATE |
||
517 | DateModify FILEDATE |
||
3340 | hidnplayr | 518 | Size dq ? |
1166 | hidnplayr | 519 | ends |
520 | |||
1528 | hidnplayr | 521 | |
3340 | hidnplayr | 522 | if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 |
1528 | hidnplayr | 523 | |
3340 | hidnplayr | 524 | cmove fix cmovz |
1528 | hidnplayr | 525 | macro cmovz reg1, reg2 { |
526 | |||
3340 | hidnplayr | 527 | local .jumpaddr |
1528 | hidnplayr | 528 | |
3340 | hidnplayr | 529 | jnz .jumpaddr |
530 | mov reg1, reg2 |
||
1528 | hidnplayr | 531 | .jumpaddr: |
532 | } |
||
533 | |||
3340 | hidnplayr | 534 | cmovne fix cmovnz |
1528 | hidnplayr | 535 | macro cmovnz reg1, reg2 { |
536 | |||
3340 | hidnplayr | 537 | local .jumpaddr |
1528 | hidnplayr | 538 | |
3340 | hidnplayr | 539 | jz .jumpaddr |
540 | mov reg1, reg2 |
||
1528 | hidnplayr | 541 | .jumpaddr: |
542 | } |
||
543 | |||
1857 | hidnplayr | 544 | macro cmovg reg1, reg2 { |
545 | |||
3340 | hidnplayr | 546 | local .jumpaddr |
1857 | hidnplayr | 547 | |
3340 | hidnplayr | 548 | jle .jumpaddr |
549 | mov reg1, reg2 |
||
1857 | hidnplayr | 550 | .jumpaddr: |
551 | } |
||
552 | |||
553 | macro cmovl reg1, reg2 { |
||
554 | |||
3340 | hidnplayr | 555 | local .jumpaddr |
1857 | hidnplayr | 556 | |
3340 | hidnplayr | 557 | jge .jumpaddr |
558 | mov reg1, reg2 |
||
1857 | hidnplayr | 559 | .jumpaddr: |
560 | } |
||
561 | |||
1528 | hidnplayr | 562 | end if |
563 | |||
1166 | hidnplayr | 564 | ; constants |
565 | |||
566 | ; events |
||
567 | EV_IDLE = 0 |
||
568 | EV_TIMER = 0 |
||
569 | EV_REDRAW = 1 |
||
3340 | hidnplayr | 570 | EV_KEY = 2 |
1166 | hidnplayr | 571 | EV_BUTTON = 3 |
572 | EV_EXIT = 4 |
||
573 | EV_BACKGROUND = 5 |
||
574 | EV_MOUSE = 6 |
||
3340 | hidnplayr | 575 | EV_IPC = 7 |
1166 | hidnplayr | 576 | EV_STACK = 8 |
577 | |||
578 | ; event mask bits for function 40 |
||
3518 | hidnplayr | 579 | EVM_REDRAW = 1b |
580 | EVM_KEY = 10b |
||
581 | EVM_BUTTON = 100b |
||
582 | EVM_EXIT = 1000b |
||
583 | EVM_BACKGROUND = 10000b |
||
584 | EVM_MOUSE = 100000b |
||
585 | EVM_IPC = 1000000b |
||
586 | EVM_STACK = 10000000b |
||
587 | EVM_DEBUG = 100000000b |
||
588 | EVM_STACK2 = 1000000000b>>>>> |