Rev 647 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
215 | victor | 1 | ; language for programs |
2 | lang fix en ; ru en fr ge fi |
||
3 | |||
4 | @^ fix macro comment { |
||
5 | ^@ fix } |
||
6 | |||
7 | ; strings |
||
8 | macro sz name,[data] { ; from MFAR [mike.dld] |
||
9 | common |
||
10 | if used name |
||
11 | name db data |
||
12 | .size = $-name |
||
13 | end if |
||
14 | } |
||
15 | |||
16 | macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
||
17 | common |
||
18 | if used name |
||
19 | label name |
||
20 | forward |
||
21 | if lang eq lng |
||
22 | db data |
||
23 | end if |
||
24 | common |
||
25 | .size = $-name |
||
26 | end if |
||
27 | } |
||
28 | |||
29 | macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
||
30 | common |
||
31 | local s,m |
||
32 | m = 0 |
||
33 | if used name |
||
34 | label name |
||
35 | virtual at 0 |
||
36 | db data |
||
37 | s = $ |
||
38 | end virtual |
||
39 | d#elsz s |
||
40 | if m < s |
||
41 | m = s |
||
42 | end if |
||
43 | db data |
||
44 | .size = $-name |
||
45 | .maxl = m |
||
46 | end if |
||
47 | } |
||
48 | |||
49 | macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
||
50 | common |
||
51 | local s,m |
||
52 | m = 0 |
||
53 | if used name |
||
54 | label name |
||
55 | forward |
||
56 | if lang eq lng |
||
57 | virtual at 0 |
||
58 | db data |
||
59 | s = $ |
||
60 | end virtual |
||
61 | d#elsz s |
||
62 | if m < s |
||
63 | m = s |
||
64 | end if |
||
65 | db data |
||
66 | end if |
||
67 | common |
||
68 | .size = $-name |
||
69 | .maxl = m |
||
70 | end if |
||
71 | } |
||
72 | |||
73 | |||
74 | ; easy system call macro |
||
75 | macro mpack dest, hsrc, lsrc |
||
76 | { |
||
77 | if (hsrc eqtype 0) & (lsrc eqtype 0) |
||
78 | mov dest, (hsrc) shl 16 + lsrc |
||
79 | else |
||
80 | if (hsrc eqtype 0) & (~lsrc eqtype 0) |
||
81 | mov dest, (hsrc) shl 16 |
||
82 | add dest, lsrc |
||
83 | else |
||
84 | mov dest, hsrc |
||
85 | shl dest, 16 |
||
86 | add dest, lsrc |
||
87 | end if |
||
88 | end if |
||
89 | } |
||
90 | |||
91 | macro __mov reg,a,b { ; mike.dld |
||
92 | if (~a eq)&(~b eq) |
||
93 | mpack reg,a,b |
||
94 | else if (~a eq)&(b eq) |
||
95 | mov reg,a |
||
96 | end if |
||
97 | } |
||
98 | |||
99 | macro mcall a,b,c,d,e,f { ; mike.dld |
||
100 | __mov eax,a |
||
101 | __mov ebx,b |
||
102 | __mov ecx,c |
||
103 | __mov edx,d |
||
104 | __mov esi,e |
||
105 | __mov edi,f |
||
106 | int 0x40 |
||
107 | } |
||
108 | |||
109 | ; ------------------------- |
||
110 | macro header a,[b] { |
||
111 | common |
||
112 | use32 |
||
113 | org 0 |
||
114 | db 'MENUET',a |
||
115 | forward |
||
116 | if b eq |
||
117 | dd 0 |
||
118 | else |
||
119 | dd b |
||
120 | end if } |
||
121 | macro section name,algn |
||
122 | { |
||
123 | local boundary |
||
124 | boundary = 16 |
||
125 | if ~algn eq |
||
126 | boundary = algn |
||
127 | end if |
||
128 | align boundary |
||
129 | label name |
||
130 | } |
||
131 | macro func name { |
||
132 | if ~used name |
||
133 | display 'FUNC NOT USED: ',`name,13,10 |
||
134 | else |
||
135 | align 4 |
||
136 | name: |
||
137 | ;pushad |
||
138 | ;pushfd |
||
139 | ;dps `name |
||
140 | ;newline |
||
141 | ;mcall 5,1 |
||
142 | ;popfd |
||
143 | ;popad |
||
144 | } |
||
145 | macro endf { end if } |
||
146 | |||
147 | macro jif _op1,_cond,_op2,_label,_op |
||
148 | { |
||
149 | if _op eq |
||
150 | cmp _op1,_op2 |
||
151 | else |
||
152 | _op _op1,_op2 |
||
153 | end if |
||
154 | j#_cond _label |
||
155 | } |
||
156 | |||
157 | macro diff16 title,l1,l2 |
||
158 | { |
||
159 | local s,d |
||
160 | s = l2-l1 |
||
161 | display title,': 0x' |
||
162 | repeat 8 |
||
163 | d = '0' + s shr ((8-%) shl 2) and $0F |
||
164 | if d > '9' |
||
165 | d = d + 'A'-'9'-1 |
||
166 | end if |
||
167 | display d |
||
168 | end repeat |
||
169 | display 13,10 |
||
170 | } |
||
171 | |||
172 | macro diff10 title,l1,l2 |
||
173 | { |
||
174 | local s,d,z,m |
||
175 | s = l2-l1 |
||
176 | z = 0 |
||
177 | m = 1000000000 |
||
178 | display title,': ' |
||
179 | repeat 10 |
||
180 | d = '0' + s / m |
||
181 | s = s - (s/m)*m |
||
182 | m = m / 10 |
||
183 | if d <> '0' |
||
184 | z = 1 |
||
185 | end if |
||
186 | if z <> 0 |
||
187 | display d |
||
188 | end if |
||
189 | end repeat |
||
190 | display 13,10 |
||
191 | } |
||
192 | |||
193 | ; optimize the code for size |
||
194 | __regs fix |
||
195 | |||
196 | macro add arg1,arg2 |
||
197 | { |
||
198 | if (arg2 eqtype 0) |
||
199 | if (arg2) = 1 |
||
200 | inc arg1 |
||
201 | else |
||
202 | add arg1,arg2 |
||
203 | end if |
||
204 | else |
||
205 | add arg1,arg2 |
||
206 | end if |
||
207 | } |
||
208 | |||
209 | macro sub arg1,arg2 |
||
210 | { |
||
211 | if (arg2 eqtype 0) |
||
212 | if (arg2) = 1 |
||
213 | dec arg1 |
||
214 | else |
||
215 | sub arg1,arg2 |
||
216 | end if |
||
217 | else |
||
218 | sub arg1,arg2 |
||
219 | end if |
||
220 | } |
||
221 | |||
222 | macro mov arg1,arg2 |
||
223 | { |
||
224 | if (arg1 in __regs) & (arg2 eqtype 0) |
||
225 | if (arg2) = 0 |
||
226 | xor arg1,arg1 |
||
227 | else if (arg2) = 1 |
||
228 | xor arg1,arg1 |
||
229 | inc arg1 |
||
230 | else if (arg2) = -1 |
||
231 | or arg1,-1 |
||
232 | else if (arg2) > -128 & (arg2) < 128 |
||
233 | push arg2 |
||
234 | pop arg1 |
||
235 | else |
||
236 | mov arg1,arg2 |
||
237 | end if |
||
238 | else |
||
239 | mov arg1,arg2 |
||
240 | end if |
||
241 | } |
||
242 | |||
243 | |||
244 | struc POINT _t,_dx,_dy { |
||
245 | .x _t _dx |
||
246 | .y _t _dy |
||
247 | } |
||
248 | |||
249 | ; structure definition helper |
||
250 | macro struct name, [arg] |
||
251 | { |
||
252 | common |
||
253 | name@struct fix name |
||
254 | struc name arg { |
||
255 | } |
||
256 | |||
257 | macro struct_helper name |
||
258 | { |
||
259 | virtual at 0 |
||
260 | name name |
||
261 | sizeof.#name = $ - name |
||
262 | name equ sizeof.#name |
||
263 | end virtual |
||
264 | } |
||
265 | |||
266 | ends fix } struct_helper name@struct |
||
267 | |||
268 | macro union [def] |
||
269 | { |
||
270 | common size@union = 0 |
||
271 | origin@union = $ |
||
272 | forward virtual |
||
273 | def |
||
274 | if $-origin@union > size@union |
||
275 | size@union = $-origin@union |
||
276 | end if |
||
277 | end virtual |
||
278 | common rb size@union |
||
279 | } |
||
280 | |||
281 | ; structures used in MeOS |
||
282 | struc process_information |
||
283 | { |
||
284 | .cpu_usage dd ? ; +0 |
||
285 | .window_stack_position dw ? ; +4 |
||
286 | .window_stack_value dw ? ; +6 |
||
287 | .not_used1 dw ? ; +8 |
||
288 | .process_name rb 12 ; +10 |
||
289 | .memory_start dd ? ; +22 |
||
290 | .used_memory dd ? ; +26 |
||
291 | .PID dd ? ; +30 |
||
292 | .x_start dd ? ; +34 |
||
293 | .y_start dd ? ; +38 |
||
294 | .x_size dd ? ; +42 |
||
295 | .y_size dd ? ; +46 |
||
296 | .slot_state dw ? ; +50 |
||
297 | rb (1024-52) |
||
298 | } |
||
299 | |||
300 | struc system_colors |
||
301 | { |
||
302 | .frame dd ? |
||
303 | .grab dd ? |
||
6196 | leency | 304 | .work_3d_dark dd ? |
305 | .work_3d_light dd ? |
||
215 | victor | 306 | .grab_text dd ? |
307 | .work dd ? |
||
308 | .work_button dd ? |
||
309 | .work_button_text dd ? |
||
310 | .work_text dd ? |
||
311 | .work_graph dd ? |
||
312 | } |
||
313 | |||
314 | |||
315 | ; constants |
||
316 | |||
317 | ; events |
||
318 | EV_IDLE = 0 |
||
319 | EV_TIMER = 0 |
||
320 | EV_REDRAW = 1 |
||
321 | EV_KEY = 2 |
||
322 | EV_BUTTON = 3 |
||
323 | EV_EXIT = 4 |
||
324 | EV_BACKGROUND = 5 |
||
325 | EV_MOUSE = 6 |
||
326 | EV_IPC = 7 |
||
327 | EV_STACK = 8 |
||
328 | |||
329 | ; event mask bits for function 40 |
||
330 | EVM_REDRAW = 1b |
||
331 | EVM_KEY = 10b |
||
332 | EVM_BUTTON = 100b |
||
333 | EVM_EXIT = 1000b |
||
334 | EVM_BACKGROUND = 10000b |
||
335 | EVM_MOUSE = 100000b |
||
336 | EVM_IPC = 1000000b |
||
337 | EVM_STACK = 10000000b>>>>> |