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