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