Rev 259 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 259 | Rev 297 | ||
---|---|---|---|
1 | @^ fix macro comment { |
1 | @^ fix macro comment { |
2 | ^@ fix } |
2 | ^@ fix } |
3 | 3 | ||
4 | 4 | ||
5 | macro m2m dest,src { |
5 | macro m2m dest,src { |
6 | push src |
6 | push src |
7 | pop dest |
7 | pop dest |
8 | } |
8 | } |
9 | 9 | ||
10 | ; new application structure |
10 | ; new application structure |
11 | macro meos_app_start |
11 | macro meos_app_start |
12 | { |
12 | { |
13 | use32 |
13 | use32 |
14 | org 0x0 |
14 | org 0x0 |
15 | 15 | ||
16 | db 'MENUET01' |
16 | db 'MENUET01' |
17 | dd 0x01 |
17 | dd 0x01 |
18 | dd __start |
18 | dd __start |
19 | dd __end |
19 | dd __end |
20 | dd __memory |
20 | dd __memory |
21 | dd __stack |
21 | dd __stack |
22 | 22 | ||
23 | if used __params & ~defined __params |
23 | if used __params & ~defined __params |
24 | dd __params |
24 | dd __params |
25 | else |
25 | else |
26 | dd 0x0 |
26 | dd 0x0 |
27 | end if |
27 | end if |
28 | 28 | ||
29 | dd 0x0 |
29 | dd 0x0 |
30 | } |
30 | } |
31 | MEOS_APP_START fix meos_app_start |
31 | MEOS_APP_START fix meos_app_start |
32 | 32 | ||
33 | macro code |
33 | macro code |
34 | { |
34 | { |
35 | __start: |
35 | __start: |
36 | } |
36 | } |
37 | CODE fix code |
37 | CODE fix code |
38 | 38 | ||
39 | macro data |
39 | macro data |
40 | { |
40 | { |
41 | __data: |
41 | __data: |
42 | } |
42 | } |
43 | DATA fix data |
43 | DATA fix data |
44 | 44 | ||
45 | macro udata |
45 | macro udata |
46 | { |
46 | { |
47 | if used __params & ~defined __params |
47 | if used __params & ~defined __params |
48 | __params: |
48 | __params: |
49 | db 0 |
49 | db 0 |
50 | __end: |
50 | __end: |
51 | rb 255 |
51 | rb 255 |
52 | else |
52 | else |
53 | __end: |
53 | __end: |
54 | end if |
54 | end if |
55 | __udata: |
55 | __udata: |
56 | } |
56 | } |
57 | UDATA fix udata |
57 | UDATA fix udata |
58 | 58 | ||
59 | macro meos_app_end |
59 | macro meos_app_end |
60 | { |
60 | { |
61 | align 32 |
61 | align 32 |
62 | rb 2048 |
62 | rb 2048 |
63 | __stack: |
63 | __stack: |
64 | __memory: |
64 | __memory: |
65 | } |
65 | } |
66 | MEOS_APP_END fix meos_app_end |
66 | MEOS_APP_END fix meos_app_end |
67 | 67 | ||
68 | 68 | ||
69 | ; macro for defining multiline text data |
69 | ; macro for defining multiline text data |
70 | struc mstr [sstring] |
70 | struc mstr [sstring] |
71 | { |
71 | { |
72 | forward |
72 | forward |
73 | local ssize |
73 | local ssize |
74 | virtual at 0 |
74 | virtual at 0 |
75 | db sstring |
75 | db sstring |
76 | ssize = $ |
76 | ssize = $ |
77 | end virtual |
77 | end virtual |
78 | dd ssize |
78 | dd ssize |
79 | db sstring |
79 | db sstring |
80 | common |
80 | common |
81 | dd -1 |
81 | dd -1 |
82 | } |
82 | } |
83 | 83 | ||
84 | 84 | ||
85 | ; strings |
85 | ; strings |
86 | macro sz name,[data] { ; from MFAR [mike.dld] |
86 | macro sz name,[data] { ; from MFAR [mike.dld] |
87 | common |
87 | common |
88 | if used name |
88 | if used name |
89 | name db data |
89 | name db data |
90 | .size = $-name |
90 | .size = $-name |
91 | end if |
91 | end if |
92 | } |
92 | } |
93 | 93 | ||
94 | macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
94 | macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
95 | common |
95 | common |
96 | if used name |
96 | if used name |
97 | label name |
97 | label name |
98 | forward |
98 | forward |
99 | if lang eq lng |
99 | if lang eq lng |
100 | db data |
100 | db data |
101 | end if |
101 | end if |
102 | common |
102 | common |
103 | .size = $-name |
103 | .size = $-name |
104 | end if |
104 | end if |
105 | } |
105 | } |
106 | 106 | ||
107 | macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
107 | macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
108 | common |
108 | common |
109 | local s,m |
109 | local s,m |
110 | m = 0 |
110 | m = 0 |
111 | if used name |
111 | if used name |
112 | label name |
112 | label name |
- | 113 | forward |
|
113 | virtual at 0 |
114 | virtual at 0 |
114 | db data |
115 | db data |
115 | s = $ |
116 | s = $ |
116 | end virtual |
117 | end virtual |
117 | d#elsz s |
118 | d#elsz s |
118 | if m < s |
119 | if m < s |
119 | m = s |
120 | m = s |
120 | end if |
121 | end if |
121 | db data |
122 | db data |
- | 123 | common |
|
122 | .size = $-name |
124 | .size = $-name |
123 | .maxl = m |
125 | .maxl = m |
124 | end if |
126 | end if |
125 | } |
127 | } |
126 | 128 | ||
127 | macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
129 | macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
128 | common |
130 | common |
129 | local s,m,c |
131 | local s,m,c |
130 | m = 0 |
132 | m = 0 |
131 | c = 0 |
133 | c = 0 |
132 | if used name |
134 | if used name |
133 | label name |
135 | label name |
134 | forward |
136 | forward |
135 | if lang eq lng |
137 | if lang eq lng |
136 | virtual at 0 |
138 | virtual at 0 |
137 | db data |
139 | db data |
138 | s = $ |
140 | s = $ |
139 | end virtual |
141 | end virtual |
140 | d#elsz s |
142 | d#elsz s |
141 | if m < s |
143 | if m < s |
142 | m = s |
144 | m = s |
143 | end if |
145 | end if |
144 | db data |
146 | db data |
145 | c = c+1 |
147 | c = c+1 |
146 | end if |
148 | end if |
147 | common |
149 | common |
148 | .size = $-name |
150 | .size = $-name |
149 | .maxl = m |
151 | .maxl = m |
150 | .count = c |
152 | .count = c |
151 | end if |
153 | end if |
152 | } |
154 | } |
153 | 155 | ||
154 | 156 | ||
155 | ; easy system call macro |
157 | ; easy system call macro |
156 | macro mpack dest, hsrc, lsrc |
158 | macro mpack dest, hsrc, lsrc |
157 | { |
159 | { |
158 | if (hsrc eqtype 0) & (lsrc eqtype 0) |
160 | if (hsrc eqtype 0) & (lsrc eqtype 0) |
159 | mov dest, (hsrc) shl 16 + lsrc |
161 | mov dest, (hsrc) shl 16 + lsrc |
160 | else |
162 | else |
161 | if (hsrc eqtype 0) & (~lsrc eqtype 0) |
163 | if (hsrc eqtype 0) & (~lsrc eqtype 0) |
162 | mov dest, (hsrc) shl 16 |
164 | mov dest, (hsrc) shl 16 |
163 | add dest, lsrc |
165 | add dest, lsrc |
164 | else |
166 | else |
165 | mov dest, hsrc |
167 | mov dest, hsrc |
166 | shl dest, 16 |
168 | shl dest, 16 |
167 | add dest, lsrc |
169 | add dest, lsrc |
168 | end if |
170 | end if |
169 | end if |
171 | end if |
170 | } |
172 | } |
171 | 173 | ||
172 | ;macro __mov reg,a { ; mike.dld |
174 | ;macro __mov reg,a { ; mike.dld |
173 | ; if ~a eq |
175 | ; if ~a eq |
174 | ; mov reg,a |
176 | ; mov reg,a |
175 | ; end if |
177 | ; end if |
176 | ;} |
178 | ;} |
177 | 179 | ||
178 | macro __mov reg,a,b { ; mike.dld |
180 | macro __mov reg,a,b { ; mike.dld |
179 | if (~a eq)&(~b eq) |
181 | if (~a eq)&(~b eq) |
180 | mpack reg,a,b |
182 | mpack reg,a,b |
181 | else if (~a eq)&(b eq) |
183 | else if (~a eq)&(b eq) |
182 | mov reg,a |
184 | mov reg,a |
183 | end if |
185 | end if |
184 | } |
186 | } |
185 | 187 | ||
186 | macro mcall a,b,c,d,e,f { ; mike.dld |
188 | macro mcall a,b,c,d,e,f { ; mike.dld |
187 | __mov eax,a |
189 | __mov eax,a |
188 | __mov ebx,b |
190 | __mov ebx,b |
189 | __mov ecx,c |
191 | __mov ecx,c |
190 | __mov edx,d |
192 | __mov edx,d |
191 | __mov esi,e |
193 | __mov esi,e |
192 | __mov edi,f |
194 | __mov edi,f |
193 | int 0x40 |
195 | int 0x40 |
194 | } |
196 | } |
195 | 197 | ||
196 | 198 | ||
197 | ; ------------------------- |
199 | ; ------------------------- |
198 | macro header a,[b] { |
200 | macro header a,[b] { |
199 | common |
201 | common |
200 | use32 |
202 | use32 |
201 | org 0 |
203 | org 0 |
202 | db 'MENUET',a |
204 | db 'MENUET',a |
203 | forward |
205 | forward |
204 | if b eq |
206 | if b eq |
205 | dd 0 |
207 | dd 0 |
206 | else |
208 | else |
207 | dd b |
209 | dd b |
208 | end if } |
210 | end if } |
209 | macro section name { align 16 |
211 | macro section name { align 16 |
210 | label name } |
212 | label name } |
211 | macro func name { |
213 | macro func name { |
212 | if ~used name |
214 | if ~used name |
213 | ;display 'FUNC NOT USED: ',`name,13,10 |
215 | display 'FUNC NOT USED: ',`name,13,10 |
214 | else |
216 | else |
215 | align 4 |
217 | align 4 |
216 | name: |
218 | name: |
217 | ;diff16 `name,0,name |
219 | ;diff16 `name,0,name |
218 | ;pushad |
220 | ;pushad |
219 | ;pushfd |
221 | ;pushfd |
220 | ;dps `name |
222 | ;dps `name |
221 | ;newline |
223 | ;newline |
222 | ;mcall 5,1 |
224 | ;mcall 5,1 |
223 | ;popfd |
225 | ;popfd |
224 | ;popad |
226 | ;popad |
225 | } |
227 | } |
226 | macro endf { end if } |
228 | macro endf { end if } |
227 | 229 | ||
228 | macro diff16 title,l1,l2 |
230 | macro diff16 title,l1,l2 |
229 | { |
231 | { |
230 | local s,d |
232 | local s,d |
231 | s = l2-l1 |
233 | s = l2-l1 |
232 | display title,': 0x' |
234 | display title,': 0x' |
233 | repeat 8 |
235 | repeat 8 |
234 | d = '0' + s shr ((8-%) shl 2) and $0F |
236 | d = '0' + s shr ((8-%) shl 2) and $0F |
235 | if d > '9' |
237 | if d > '9' |
236 | d = d + 'A'-'9'-1 |
238 | d = d + 'A'-'9'-1 |
237 | end if |
239 | end if |
238 | display d |
240 | display d |
239 | end repeat |
241 | end repeat |
240 | display 13,10 |
242 | display 13,10 |
241 | } |
243 | } |
242 | 244 | ||
243 | macro diff10 title,l1,l2 |
245 | macro diff10 title,l1,l2 |
244 | { |
246 | { |
245 | local s,d,z,m |
247 | local s,d,z,m |
246 | s = l2-l1 |
248 | s = l2-l1 |
247 | z = 0 |
249 | z = 0 |
248 | m = 1000000000 |
250 | m = 1000000000 |
249 | display title,': ' |
251 | display title,': ' |
250 | repeat 10 |
252 | repeat 10 |
251 | d = '0' + s / m |
253 | d = '0' + s / m |
252 | s = s - (s/m)*m |
254 | s = s - (s/m)*m |
253 | m = m / 10 |
255 | m = m / 10 |
254 | if d <> '0' |
256 | if d <> '0' |
255 | z = 1 |
257 | z = 1 |
256 | end if |
258 | end if |
257 | if z <> 0 |
259 | if z <> 0 |
258 | display d |
260 | display d |
259 | end if |
261 | end if |
260 | end repeat |
262 | end repeat |
261 | display 13,10 |
263 | display 13,10 |
262 | } |
264 | } |
263 | 265 | ||
264 | ; optimize the code for size |
266 | ; optimize the code for size |
265 | __regs fix |
267 | __regs fix |
266 | 268 | ||
267 | macro add arg1,arg2 |
269 | macro add arg1,arg2 |
268 | { |
270 | { |
269 | if (arg2 eqtype 0) |
271 | if (arg2 eqtype 0) |
270 | if (arg2) = 1 |
272 | if (arg2) = 1 |
271 | inc arg1 |
273 | inc arg1 |
272 | else |
274 | else |
273 | add arg1,arg2 |
275 | add arg1,arg2 |
274 | end if |
276 | end if |
275 | else |
277 | else |
276 | add arg1,arg2 |
278 | add arg1,arg2 |
277 | end if |
279 | end if |
278 | } |
280 | } |
279 | 281 | ||
280 | macro sub arg1,arg2 |
282 | macro sub arg1,arg2 |
281 | { |
283 | { |
282 | if (arg2 eqtype 0) |
284 | if (arg2 eqtype 0) |
283 | if (arg2) = 1 |
285 | if (arg2) = 1 |
284 | dec arg1 |
286 | dec arg1 |
285 | else |
287 | else |
286 | sub arg1,arg2 |
288 | sub arg1,arg2 |
287 | end if |
289 | end if |
288 | else |
290 | else |
289 | sub arg1,arg2 |
291 | sub arg1,arg2 |
290 | end if |
292 | end if |
291 | } |
293 | } |
292 | 294 | ||
293 | macro mov arg1,arg2 |
295 | macro mov arg1,arg2 |
294 | { |
296 | { |
295 | if (arg1 in __regs) & (arg2 eqtype 0) |
297 | if (arg1 in __regs) & (arg2 eqtype 0) |
296 | if (arg2) = 0 |
298 | if (arg2) = 0 |
297 | xor arg1,arg1 |
299 | xor arg1,arg1 |
298 | else if (arg2) = 1 |
300 | else if (arg2) = 1 |
299 | xor arg1,arg1 |
301 | xor arg1,arg1 |
300 | inc arg1 |
302 | inc arg1 |
301 | else if (arg2) = -1 |
303 | else if (arg2) = -1 |
302 | or arg1,-1 |
304 | or arg1,-1 |
303 | else if (arg2) > -128 & (arg2) < 128 |
305 | else if (arg2) > -128 & (arg2) < 128 |
304 | push arg2 |
306 | push arg2 |
305 | pop arg1 |
307 | pop arg1 |
306 | else |
308 | else |
307 | mov arg1,arg2 |
309 | mov arg1,arg2 |
308 | end if |
310 | end if |
309 | else |
311 | else |
310 | mov arg1,arg2 |
312 | mov arg1,arg2 |
311 | end if |
313 | end if |
312 | } |
314 | } |
313 | 315 | ||
314 | 316 | ||
315 | macro RGB [a] { |
317 | macro RGB [a] { |
316 | common |
318 | common |
317 | match (r=,g=,b),a \{ |
319 | match (r=,g=,b),a \{ |
318 | \dd ((r) shl 16) or ((g) shl 8) or (b) |
320 | \dd ((r) shl 16) or ((g) shl 8) or (b) |
319 | \} |
321 | \} |
320 | } |
322 | } |
321 | 323 | ||
322 | 324 | ||
323 | struc POINT _t,_dx,_dy { |
325 | struc POINT _t,_dx,_dy { |
324 | .x _t _dx |
326 | .x _t _dx |
325 | .y _t _dy |
327 | .y _t _dy |
326 | } |
328 | } |
327 | 329 | ||
328 | ; structure definition helper |
330 | ; structure definition helper |
329 | include 'struct.inc' |
331 | include 'struct.inc' |
330 | 332 | ||
331 | struct RECT |
333 | struct RECT |
332 | left dd ? |
334 | left dd ? |
333 | top dd ? |
335 | top dd ? |
334 | right dd ? |
336 | right dd ? |
335 | bottom dd ? |
337 | bottom dd ? |
336 | ends |
338 | ends |
337 | 339 | ||
338 | struct BOX |
340 | struct BOX |
339 | left dd ? |
341 | left dd ? |
340 | top dd ? |
342 | top dd ? |
341 | width dd ? |
343 | width dd ? |
342 | height dd ? |
344 | height dd ? |
343 | ends |
345 | ends |
344 | 346 | ||
345 | ; structures used in MeOS |
347 | ; structures used in MeOS |
346 | struct process_information |
348 | struct process_information |
347 | cpu_usage dd ? ; +0 |
349 | cpu_usage dd ? ; +0 |
348 | window_stack_position dw ? ; +4 |
350 | window_stack_position dw ? ; +4 |
349 | window_stack_value dw ? ; +6 |
351 | window_stack_value dw ? ; +6 |
350 | dw ? ; +8 |
352 | dw ? ; +8 |
351 | process_name rb 12 ; +10 |
353 | process_name rb 12 ; +10 |
352 | memory_start dd ? ; +22 |
354 | memory_start dd ? ; +22 |
353 | used_memory dd ? ; +26 |
355 | used_memory dd ? ; +26 |
354 | PID dd ? ; +30 |
356 | PID dd ? ; +30 |
355 | box BOX ; +34 |
357 | box BOX ; +34 |
356 | slot_state dw ? ; +50 |
358 | slot_state dw ? ; +50 |
357 | dw ? ; +52 |
359 | dw ? ; +52 |
358 | client_box BOX ; +54 |
360 | client_box BOX ; +54 |
359 | rb (1024-52) |
361 | rb (1024-52) |
360 | ends |
362 | ends |
361 | 363 | ||
362 | struct system_colors |
364 | struct system_colors |
363 | frame dd ? |
365 | frame dd ? |
364 | grab dd ? |
366 | grab dd ? |
365 | grab_button dd ? |
367 | grab_button dd ? |
366 | grab_button_text dd ? |
368 | grab_button_text dd ? |
367 | grab_text dd ? |
369 | grab_text dd ? |
368 | work dd ? |
370 | work dd ? |
369 | work_button dd ? |
371 | work_button dd ? |
370 | work_button_text dd ? |
372 | work_button_text dd ? |
371 | work_text dd ? |
373 | work_text dd ? |
372 | work_graph dd ? |
374 | work_graph dd ? |
373 | ends |
375 | ends |
374 | 376 | ||
375 | struct FILEDATE |
377 | struct FILEDATE |
376 | Second db ? |
378 | Second db ? |
377 | Minute db ? |
379 | Minute db ? |
378 | Hour db ? |
380 | Hour db ? |
379 | db ? |
381 | db ? |
380 | Day db ? |
382 | Day db ? |
381 | Month db ? |
383 | Month db ? |
382 | Year dw ? |
384 | Year dw ? |
383 | ends |
385 | ends |
384 | 386 | ||
385 | struct FILEINFO |
387 | struct FILEINFO |
386 | Attributes dd ? |
388 | Attributes dd ? |
387 | IsUnicode db ? |
389 | IsUnicode db ? |
388 | db 3 dup(?) |
390 | db 3 dup(?) |
389 | DateCreate FILEDATE |
391 | DateCreate FILEDATE |
390 | DateAccess FILEDATE |
392 | DateAccess FILEDATE |
391 | DateModify FILEDATE |
393 | DateModify FILEDATE |
392 | Size dq ? |
394 | Size dq ? |
393 | ends |
395 | ends |
394 | 396 | ||
395 | ; constants |
397 | ; constants |
396 | 398 | ||
397 | ; events |
399 | ; events |
398 | EV_IDLE = 0 |
400 | EV_IDLE = 0 |
399 | EV_TIMER = 0 |
401 | EV_TIMER = 0 |
400 | EV_REDRAW = 1 |
402 | EV_REDRAW = 1 |
401 | EV_KEY = 2 |
403 | EV_KEY = 2 |
402 | EV_BUTTON = 3 |
404 | EV_BUTTON = 3 |
403 | EV_EXIT = 4 |
405 | EV_EXIT = 4 |
404 | EV_BACKGROUND = 5 |
406 | EV_BACKGROUND = 5 |
405 | EV_MOUSE = 6 |
407 | EV_MOUSE = 6 |
406 | EV_IPC = 7 |
408 | EV_IPC = 7 |
407 | EV_STACK = 8 |
409 | EV_STACK = 8 |
408 | 410 | ||
409 | ; event mask bits for function 40 |
411 | ; event mask bits for function 40 |
410 | EVM_REDRAW = 1b |
412 | EVM_REDRAW = 1b |
411 | EVM_KEY = 10b |
413 | EVM_KEY = 10b |
412 | EVM_BUTTON = 100b |
414 | EVM_BUTTON = 100b |
413 | EVM_EXIT = 1000b |
415 | EVM_EXIT = 1000b |
414 | EVM_BACKGROUND = 10000b |
416 | EVM_BACKGROUND = 10000b |
415 | EVM_MOUSE = 100000b |
417 | EVM_MOUSE = 100000b |
416 | EVM_IPC = 1000000b |
418 | EVM_IPC = 1000000b |
417 | EVM_STACK = 10000000b>>>>> |
419 | EVM_STACK = 10000000b>>>>> |