Rev 485 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | lang equ ru ; ru en fr ge fi |
2 | |||
3 | ; |
||
4 | ; Assembler |
||
5 | ; SMALL |
||
6 | ; CODE |
||
7 | ; Libary |
||
8 | ; |
||
9 | ; Ver 0.14 By Pavlushin Evgeni (RUSSIA) |
||
10 | ; www.waptap@mail.ru |
||
11 | |||
12 | ;Please compile aplications on FASM ver1.54 or higer!!! |
||
13 | |||
14 | ;InfoList |
||
15 | ;0.01 scank,putpix,puttxt |
||
16 | ;0.02 label,random,colors |
||
17 | ;0.03 window,startwd,endwd,attributes |
||
18 | ;0.04 close,delay,scevent ~30.04.2004 |
||
19 | ;0.05 small random, ~04.05.2004 |
||
20 | ;0.06 wtevent ~09.05.2004 |
||
21 | ;0.07 timeevent ~23.05.2004 |
||
22 | ;0.08 txtput ~14.06.2004 |
||
23 | ;0.09 opendialog,savedialog ~20.06.2004 |
||
24 | ;0.10 wordstoreg by halyavin, add at ~30.08.2004 |
||
25 | ; random bug deleted eax is use. |
||
26 | ;0.11 loadfile from me +puttxt bug del ~07.09.2004 |
||
27 | ;0.12 open/save dialog ~13.09.2004 |
||
28 | ;0.13 dialogs bugs deleted |
||
29 | ;0.14 drawlbut ~03.10.2004 |
||
30 | |||
31 | ; LOADFILE |
||
32 | ; (SYNTAX) LOADFILE 'full_path_to_file',file_load_area,file_temp_area |
||
33 | ; (SAMPLE) LOADFILE '/rd/1/clock.bmp',load_area,temp_area |
||
34 | |||
35 | macro loadfile file_name,file_load_area,file_temp_area |
||
36 | { |
||
37 | local open,fileinfo,string |
||
38 | jmp open |
||
39 | fileinfo: |
||
40 | dd 0 |
||
41 | dd 0 |
||
42 | dd 1 |
||
43 | dd file_load_area |
||
44 | dd file_temp_area |
||
45 | string: |
||
46 | db file_name,0 |
||
47 | open: |
||
48 | mov dword [fileinfo+8],1 ; how many blocks to read (1) |
||
49 | mov eax,58 |
||
50 | mov ebx,fileinfo |
||
485 | heavyiron | 51 | mcall |
31 | halyavin | 52 | mov eax,[file_load_area+2] |
53 | shr eax,9 ; поделим на 512 и прибавим 1 - получим число блоков |
||
54 | inc eax |
||
55 | mov dword [fileinfo+8],eax |
||
56 | mov eax,58 |
||
57 | mov ebx,fileinfo |
||
485 | heavyiron | 58 | mcall |
31 | halyavin | 59 | } |
60 | |||
61 | |||
485 | heavyiron | 62 | macro wordstoreg reg,hiword,loword |
31 | halyavin | 63 | { |
485 | heavyiron | 64 | if hiword eqtype 0 & loword eqtype 0 |
65 | mov reg,(hiword)*65536+(loword) |
||
66 | else if hiword eqtype 12 & loword eqtype eax |
||
67 | mov reg,(hiword)*65536 |
||
68 | add reg,loword |
||
69 | else if hiword eqtype 0 & loword eqtype [123] |
||
70 | mov reg,(hiword)*65536 |
||
71 | add reg,loword |
||
72 | else if (hiword eq ) & (loword eq ) |
||
31 | halyavin | 73 | else |
485 | heavyiron | 74 | mov reg,hiword |
75 | shl reg,16 |
||
76 | add reg,loword |
||
31 | halyavin | 77 | end if |
78 | } |
||
79 | |||
80 | |||
81 | ; DRAW BUTTON with label |
||
82 | |||
83 | macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor |
||
84 | { |
||
85 | local asd,lab |
||
86 | jmp asd |
||
87 | lab db text ;arg label |
||
88 | asd: |
||
485 | heavyiron | 89 | wordstoreg ebx,x,xs |
90 | wordstoreg ecx,y,ys |
||
31 | halyavin | 91 | mov edx,id |
92 | mov esi,bcolor |
||
93 | mov eax,8 |
||
485 | heavyiron | 94 | mcall |
31 | halyavin | 95 | |
96 | mov eax,asd-lab ;calc size |
||
97 | mov ebx,6 |
||
98 | mul ebx |
||
99 | mov esi,eax |
||
100 | |||
101 | mov eax,xs |
||
102 | sub eax,esi |
||
103 | shr eax,1 |
||
104 | add eax,x |
||
105 | |||
106 | mov edx,ys |
||
107 | sub edx,7 |
||
108 | shr edx,1 |
||
109 | add edx,y |
||
110 | |||
111 | mov ebx,eax |
||
112 | shl ebx,16 |
||
113 | add ebx,edx |
||
114 | |||
115 | mov ecx,tcolor ;arg4 color |
||
116 | mov edx,lab |
||
117 | mov esi,asd-lab ;calc size |
||
118 | mov eax,4 |
||
485 | heavyiron | 119 | mcall |
31 | halyavin | 120 | } |
121 | |||
122 | |||
123 | macro opendialog redproc,openoff,erroff,path |
||
124 | { |
||
125 | local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
||
126 | local run_fileinfo, param |
||
127 | local getmesloop, loox, mred, mkey, mbutton, mgetmes |
||
128 | local dlg_is_work, ready, procinfo |
||
129 | ; |
||
130 | ; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
||
131 | ; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
||
132 | ; |
||
133 | |||
134 | cld |
||
135 | ;; mov esi,path |
||
136 | mov edi,path |
||
137 | mov eax,0 |
||
138 | mov ecx,200 |
||
139 | rep stosb |
||
140 | |||
141 | ;mov [get_loops],0 |
||
142 | mov [dlg_pid_get],0 |
||
143 | |||
144 | ; Get my PID in dec format 4 bytes |
||
145 | mov eax,9 |
||
146 | mov ebx,procinfo |
||
147 | mov ecx,-1 |
||
485 | heavyiron | 148 | mcall |
31 | halyavin | 149 | |
150 | ; convert eax bin to param dec |
||
151 | mov eax,dword [procinfo+30] ;offset of myPID |
||
152 | mov edi,param+4-1 ;offset to 4 bytes |
||
153 | mov ecx,4 |
||
154 | mov ebx,10 |
||
155 | cld |
||
156 | new_d: |
||
157 | xor edx,edx |
||
158 | div ebx |
||
159 | add dl,'0' |
||
160 | mov [edi],dl |
||
161 | dec edi |
||
162 | loop new_d |
||
163 | |||
164 | ; wirite 1 byte space to param |
||
165 | mov [param+4],byte 32 ;Space for next parametr |
||
166 | ; and 1 byte type of dialog to param |
||
167 | mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog) |
||
168 | |||
169 | ; |
||
170 | ; STEP2 prepare IPC area for get messages |
||
171 | ; |
||
172 | |||
173 | ; prepare IPC area |
||
174 | mov [path],dword 0 |
||
175 | mov [path+4],dword 8 |
||
176 | |||
177 | ; define IPC memory |
||
178 | mov eax,60 |
||
179 | mov ebx,1 ; define IPC |
||
180 | mov ecx,path ; offset of area |
||
181 | mov edx,150 ; size 150 bytes |
||
485 | heavyiron | 182 | mcall |
31 | halyavin | 183 | |
184 | ; change wanted events list 7-bit IPC event |
||
185 | mov eax,40 |
||
186 | mov ebx,01000111b |
||
485 | heavyiron | 187 | mcall |
31 | halyavin | 188 | |
189 | ; |
||
190 | ; STEP 3 run SYSTEM XTREE with parameters |
||
191 | ; |
||
192 | |||
193 | mov eax,58 |
||
194 | mov ebx,run_fileinfo |
||
485 | heavyiron | 195 | mcall |
31 | halyavin | 196 | |
197 | call redproc |
||
198 | |||
199 | mov [get_loops],0 |
||
200 | getmesloop: |
||
201 | mov eax,23 |
||
202 | mov ebx,50 ;0.5 sec |
||
485 | heavyiron | 203 | mcall |
31 | halyavin | 204 | |
205 | cmp eax,1 |
||
206 | je mred |
||
207 | cmp eax,2 |
||
208 | je mkey |
||
209 | cmp eax,3 |
||
210 | je mbutton |
||
211 | cmp eax,7 |
||
212 | je mgetmes |
||
213 | |||
214 | ; Get number of procces |
||
215 | mov ebx,procinfo |
||
216 | mov ecx,-1 |
||
217 | mov eax,9 |
||
485 | heavyiron | 218 | mcall |
31 | halyavin | 219 | mov ebp,eax |
220 | |||
221 | loox: |
||
222 | mov eax,9 |
||
223 | mov ebx,procinfo |
||
224 | mov ecx,ebp |
||
485 | heavyiron | 225 | mcall |
31 | halyavin | 226 | mov eax,[DLGPID] |
227 | cmp [procinfo+30],eax ;IF Dialog find |
||
228 | je dlg_is_work ;jmp to dlg_is_work |
||
229 | dec ebp |
||
230 | jnz loox |
||
231 | |||
232 | jmp erroff |
||
233 | |||
234 | dlg_is_work: |
||
235 | cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated |
||
236 | je erroff ;TESTODP2 terminated too |
||
237 | |||
238 | cmp [dlg_pid_get],dword 1 |
||
239 | je getmesloop |
||
240 | inc [get_loops] |
||
241 | cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
||
242 | jae erroff |
||
243 | jmp getmesloop |
||
244 | |||
245 | mred: |
||
246 | call redproc |
||
247 | jmp getmesloop |
||
248 | mkey: |
||
249 | mov eax,2 |
||
485 | heavyiron | 250 | mcall ; read (eax=2) |
31 | halyavin | 251 | jmp getmesloop |
252 | mbutton: |
||
253 | mov eax,17 ; get id |
||
485 | heavyiron | 254 | mcall |
31 | halyavin | 255 | cmp ah,1 ; button id=1 ? |
256 | jne getmesloop |
||
257 | mov eax,-1 ; close this program |
||
485 | heavyiron | 258 | mcall |
31 | halyavin | 259 | mgetmes: |
260 | |||
261 | ; If dlg_pid_get then second message get jmp to still |
||
262 | cmp [dlg_pid_get],dword 1 |
||
263 | je ready |
||
264 | |||
265 | ; First message is number of PID SYSXTREE dialog |
||
266 | |||
267 | ; convert PID dec to PID bin |
||
268 | movzx eax,byte [path+16] |
||
269 | sub eax,48 |
||
270 | imul eax,10 |
||
271 | movzx ebx,byte [path+16+1] |
||
272 | add eax,ebx |
||
273 | sub eax,48 |
||
274 | imul eax,10 |
||
275 | movzx ebx,byte [path+16+2] |
||
276 | add eax,ebx |
||
277 | sub eax,48 |
||
278 | imul eax,10 |
||
279 | movzx ebx,byte [path+16+3] |
||
280 | add eax,ebx |
||
281 | sub eax,48 |
||
282 | mov [DLGPID],eax |
||
283 | |||
284 | ; Claear and prepare IPC area for next message |
||
285 | mov [path],dword 0 |
||
286 | mov [path+4],dword 8 |
||
287 | mov [path+8],dword 0 |
||
288 | mov [path+12],dword 0 |
||
289 | mov [path+16],dword 0 |
||
290 | |||
291 | ; Set dlg_pid_get for get next message |
||
292 | mov [dlg_pid_get],dword 1 |
||
293 | call redproc ;show DLG_PID |
||
294 | jmp getmesloop |
||
295 | |||
296 | ready: |
||
297 | ; |
||
298 | ; The second message get |
||
299 | ; Second message is 100 bytes path to SAVE/OPEN file |
||
300 | ; shl path string on 16 bytes |
||
301 | ; |
||
302 | cld |
||
303 | mov esi,path+16 |
||
304 | mov edi,path |
||
305 | mov ecx,200 |
||
306 | rep movsb |
||
307 | mov [edi],byte 0 |
||
308 | |||
309 | jmp openoff |
||
310 | |||
311 | |||
312 | ; DATA AREA |
||
313 | get_loops dd 0 |
||
314 | dlg_pid_get dd 0 |
||
315 | DLGPID dd 0 |
||
316 | |||
317 | param: |
||
318 | dd 0 ; My dec PID |
||
319 | dd 0,0 ; Type of dialog |
||
320 | |||
321 | run_fileinfo: |
||
322 | dd 16 |
||
323 | dd 0 |
||
324 | dd param |
||
325 | dd 0 |
||
326 | dd procinfo ; 0x10000 |
||
327 | ;run_filepath |
||
539 | spraid | 328 | db '/sys/SYSXTREE',0 |
31 | halyavin | 329 | |
330 | procinfo: |
||
485 | heavyiron | 331 | times 256 db 0 |
31 | halyavin | 332 | } |
333 | |||
334 | |||
335 | macro savedialog redproc,openoff,erroff,path |
||
336 | { |
||
337 | local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
||
338 | local run_fileinfo, run_filepath, param |
||
339 | local getmesloop, loox, mred, mkey, mbutton, mgetmes |
||
340 | local dlg_is_work, ready, procinfo |
||
341 | ; |
||
342 | ; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
||
343 | ; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
||
344 | ; |
||
345 | |||
346 | cld |
||
347 | ;; mov esi,path |
||
348 | mov edi,path |
||
349 | mov eax,0 |
||
350 | mov ecx,200 |
||
351 | rep stosb |
||
352 | |||
353 | ;mov [get_loops],0 |
||
354 | mov [dlg_pid_get],0 |
||
355 | |||
356 | ; Get my PID in dec format 4 bytes |
||
357 | mov eax,9 |
||
358 | mov ebx,procinfo |
||
359 | mov ecx,-1 |
||
485 | heavyiron | 360 | mcall |
31 | halyavin | 361 | |
362 | ; convert eax bin to param dec |
||
363 | mov eax,dword [procinfo+30] ;offset of myPID |
||
364 | mov edi,param+4-1 ;offset to 4 bytes |
||
365 | mov ecx,4 |
||
366 | mov ebx,10 |
||
367 | cld |
||
368 | new_d: |
||
369 | xor edx,edx |
||
370 | div ebx |
||
371 | add dl,'0' |
||
372 | mov [edi],dl |
||
373 | dec edi |
||
374 | loop new_d |
||
375 | |||
376 | ; wirite 1 byte space to param |
||
377 | mov [param+4],byte 32 ;Space for next parametr |
||
378 | ; and 1 byte type of dialog to param |
||
379 | mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog) |
||
380 | |||
381 | ; |
||
382 | ; STEP2 prepare IPC area for get messages |
||
383 | ; |
||
384 | |||
385 | ; prepare IPC area |
||
386 | mov [path],dword 0 |
||
387 | mov [path+4],dword 8 |
||
388 | |||
389 | ; define IPC memory |
||
390 | mov eax,60 |
||
391 | mov ebx,1 ; define IPC |
||
392 | mov ecx,path ; offset of area |
||
485 | heavyiron | 393 | mov edx,120 ; size 150 bytes |
394 | mcall |
||
31 | halyavin | 395 | |
396 | ; change wanted events list 7-bit IPC event |
||
397 | mov eax,40 |
||
398 | mov ebx,01000111b |
||
485 | heavyiron | 399 | mcall |
31 | halyavin | 400 | |
401 | ; |
||
402 | ; STEP 3 run SYSTEM XTREE with parameters |
||
403 | ; |
||
404 | |||
405 | mov eax,58 |
||
406 | mov ebx,run_fileinfo |
||
485 | heavyiron | 407 | mcall |
31 | halyavin | 408 | |
409 | call redproc |
||
410 | |||
411 | mov [get_loops],0 |
||
412 | getmesloop: |
||
413 | mov eax,23 |
||
414 | mov ebx,50 ;0.5 sec |
||
485 | heavyiron | 415 | mcall |
31 | halyavin | 416 | |
417 | cmp eax,1 |
||
418 | je mred |
||
419 | cmp eax,2 |
||
420 | je mkey |
||
421 | cmp eax,3 |
||
422 | je mbutton |
||
423 | cmp eax,7 |
||
424 | je mgetmes |
||
425 | |||
426 | ; Get number of procces |
||
427 | mov ebx,procinfo |
||
428 | mov ecx,-1 |
||
429 | mov eax,9 |
||
485 | heavyiron | 430 | mcall |
31 | halyavin | 431 | mov ebp,eax |
432 | |||
433 | loox: |
||
434 | mov eax,9 |
||
435 | mov ebx,procinfo |
||
436 | mov ecx,ebp |
||
485 | heavyiron | 437 | mcall |
31 | halyavin | 438 | mov eax,[DLGPID] |
439 | cmp [procinfo+30],eax ;IF Dialog find |
||
440 | je dlg_is_work ;jmp to dlg_is_work |
||
441 | dec ebp |
||
442 | jnz loox |
||
443 | |||
444 | jmp erroff |
||
445 | |||
446 | dlg_is_work: |
||
447 | cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated |
||
448 | je erroff ;TESTODP2 terminated too |
||
449 | |||
450 | cmp [dlg_pid_get],dword 1 |
||
451 | je getmesloop |
||
452 | inc [get_loops] |
||
453 | cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
||
454 | jae erroff |
||
455 | jmp getmesloop |
||
456 | |||
457 | mred: |
||
458 | call redproc |
||
459 | jmp getmesloop |
||
460 | mkey: |
||
485 | heavyiron | 461 | mcall ; read (eax=2) |
31 | halyavin | 462 | jmp getmesloop |
463 | mbutton: |
||
464 | mov eax,17 ; get id |
||
485 | heavyiron | 465 | mcall |
31 | halyavin | 466 | cmp ah,1 ; button id=1 ? |
467 | jne getmesloop |
||
468 | mov eax,-1 ; close this program |
||
485 | heavyiron | 469 | mcall |
31 | halyavin | 470 | mgetmes: |
471 | |||
472 | ; If dlg_pid_get then second message get jmp to still |
||
473 | cmp [dlg_pid_get],dword 1 |
||
474 | je ready |
||
475 | |||
476 | ; First message is number of PID SYSXTREE dialog |
||
477 | |||
478 | ; convert PID dec to PID bin |
||
479 | movzx eax,byte [path+16] |
||
480 | sub eax,48 |
||
481 | imul eax,10 |
||
482 | movzx ebx,byte [path+16+1] |
||
483 | add eax,ebx |
||
484 | sub eax,48 |
||
485 | imul eax,10 |
||
486 | movzx ebx,byte [path+16+2] |
||
487 | add eax,ebx |
||
488 | sub eax,48 |
||
489 | imul eax,10 |
||
490 | movzx ebx,byte [path+16+3] |
||
491 | add eax,ebx |
||
492 | sub eax,48 |
||
493 | mov [DLGPID],eax |
||
494 | |||
495 | ; Claear and prepare IPC area for next message |
||
496 | mov [path],dword 0 |
||
497 | mov [path+4],dword 8 |
||
498 | mov [path+8],dword 0 |
||
499 | mov [path+12],dword 0 |
||
500 | mov [path+16],dword 0 |
||
501 | |||
502 | ; Set dlg_pid_get for get next message |
||
503 | mov [dlg_pid_get],dword 1 |
||
504 | call redproc ;show DLG_PID |
||
505 | jmp getmesloop |
||
506 | |||
507 | ready: |
||
508 | ; |
||
509 | ; The second message get |
||
510 | ; Second message is 100 bytes path to SAVE/OPEN file |
||
511 | ; shl path string on 16 bytes |
||
512 | ; |
||
513 | cld |
||
514 | mov esi,path+16 |
||
515 | mov edi,path |
||
516 | mov ecx,200 |
||
517 | rep movsb |
||
518 | mov [edi],byte 0 |
||
519 | |||
520 | jmp openoff |
||
521 | |||
522 | |||
523 | ; DATA AREA |
||
524 | get_loops dd 0 |
||
525 | dlg_pid_get dd 0 |
||
526 | DLGPID dd 0 |
||
527 | |||
528 | param: |
||
485 | heavyiron | 529 | rb 4 ; My dec PID |
530 | rb 6 ; Type of dialog |
||
31 | halyavin | 531 | |
532 | run_fileinfo: |
||
533 | dd 16 |
||
534 | dd 0 |
||
535 | dd param |
||
536 | dd 0 |
||
537 | dd procinfo |
||
485 | heavyiron | 538 | run_filepath: |
539 | spraid | 539 | db '/sys/SYSXTREE',0 |
31 | halyavin | 540 | |
541 | procinfo: |
||
485 | heavyiron | 542 | times 256 db 0 |
31 | halyavin | 543 | } |
544 | |||
545 | |||
546 | |||
547 | |||
548 | ; RANDOM - generate random count (small) |
||
549 | ; (SYNTAX) RANDOM MaxCount,OutArgument |
||
550 | ; (SAMPLE) RANDOM 10000,eax |
||
551 | ; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations |
||
552 | |||
553 | randomuse = 0 |
||
554 | |||
555 | macro random arg1,arg2 |
||
556 | { |
||
557 | local rxproc |
||
558 | randomuse = randomuse + 1 |
||
559 | |||
560 | jmp rxproc |
||
561 | |||
562 | if defined randomuse & randomuse = 1 |
||
563 | randomproc: |
||
564 | jmp rnj |
||
565 | rsx1 dw 0x4321 |
||
566 | rsx2 dw 0x1234 |
||
567 | rnj: |
||
568 | ; mov eax,arg1 |
||
569 | push bx |
||
570 | push cx |
||
571 | push dx |
||
572 | push si |
||
573 | push di |
||
574 | mov cx,ax |
||
575 | mov ax,word ptr rsx1 |
||
576 | mov bx,word ptr rsx2 |
||
577 | mov si,ax |
||
578 | mov di,bx |
||
579 | mov dl,ah |
||
580 | mov ah,al |
||
581 | mov al,bh |
||
582 | mov bh,bl |
||
583 | xor bl,bl |
||
584 | rcr dl,1 |
||
585 | rcr ax,1 |
||
586 | rcr bx,1 |
||
587 | add bx,di |
||
588 | adc ax,si |
||
589 | add bx,0x62e9 |
||
590 | adc ax,0x3619 |
||
591 | mov word ptr rsx1,bx |
||
592 | mov word ptr rsx2,ax |
||
593 | xor dx,dx |
||
594 | cmp ax,0 |
||
595 | je nodiv |
||
596 | cmp cx,0 |
||
597 | je nodiv |
||
598 | div cx |
||
599 | nodiv: |
||
600 | mov ax,dx |
||
601 | pop di |
||
602 | pop si |
||
603 | pop dx |
||
604 | pop cx |
||
605 | pop bx |
||
606 | and eax,0000ffffh |
||
607 | ; mov arg2,0 |
||
608 | ; mov arg2,eax |
||
609 | ret |
||
610 | end if |
||
611 | |||
612 | rxproc: |
||
613 | mov eax,arg1 |
||
614 | call randomproc |
||
615 | mov arg2,eax |
||
616 | } |
||
617 | |||
618 | macro scank |
||
619 | { |
||
620 | mov eax,10 |
||
485 | heavyiron | 621 | mcall |
31 | halyavin | 622 | } |
623 | |||
624 | macro putpix x,y,color |
||
625 | { |
||
626 | mov ebx,x |
||
627 | mov ecx,y |
||
628 | mov edx,color |
||
629 | mov eax,1 |
||
485 | heavyiron | 630 | mcall |
31 | halyavin | 631 | } |
632 | |||
633 | macro puttxt x,y,offs,size,color |
||
634 | { |
||
635 | ; mov ebx,x |
||
636 | ; shl ebx,16 |
||
637 | ; add ebx,y |
||
485 | heavyiron | 638 | wordstoreg ebx,x,y |
639 | mov ecx,color |
||
640 | mov edx,offs |
||
641 | mov esi,size |
||
31 | halyavin | 642 | mov eax,4 |
485 | heavyiron | 643 | mcall |
31 | halyavin | 644 | } |
645 | |||
646 | macro outcount data, x, y, color, numtype |
||
647 | { |
||
648 | mov ecx,data |
||
649 | mov ebx,numtype |
||
650 | mov bl,0 |
||
651 | ; mov edx,x*65536+y |
||
485 | heavyiron | 652 | wordstoreg edx,x,y |
31 | halyavin | 653 | mov esi,color |
654 | mov eax,47 |
||
485 | heavyiron | 655 | mcall |
31 | halyavin | 656 | } |
657 | |||
658 | ; SCEVENT - Scan event |
||
659 | |||
660 | macro scevent red,key,but |
||
661 | { |
||
662 | mov eax,11 |
||
485 | heavyiron | 663 | mcall |
31 | halyavin | 664 | dec eax |
665 | jz red |
||
666 | dec eax |
||
667 | jz key |
||
668 | dec eax |
||
669 | jz but |
||
670 | } |
||
671 | |||
672 | ; WTEVENT - Wait event |
||
673 | |||
674 | macro wtevent red,key,but |
||
675 | { |
||
676 | mov eax,10 |
||
485 | heavyiron | 677 | mcall |
31 | halyavin | 678 | dec eax |
679 | jz red |
||
680 | dec eax |
||
681 | jz key |
||
682 | dec eax |
||
683 | jz but |
||
684 | } |
||
685 | |||
686 | ; TIMEEVENT - Wite for event with timeout |
||
687 | |||
688 | macro timeevent xfps,noevent,red,key,but |
||
689 | { |
||
690 | mov eax,23 |
||
691 | mov ebx,xfps |
||
485 | heavyiron | 692 | mcall |
31 | halyavin | 693 | cmp eax,0 |
694 | je noevent |
||
695 | dec eax |
||
696 | jz red |
||
697 | dec eax |
||
698 | jz key |
||
699 | dec eax |
||
700 | jz but |
||
701 | } |
||
702 | |||
703 | |||
704 | ; CLOSE - Close program |
||
705 | |||
706 | macro close |
||
707 | { |
||
708 | mov eax,-1 |
||
485 | heavyiron | 709 | mcall |
31 | halyavin | 710 | } |
711 | |||
712 | ; DELAY - Create delay 1/100 sec |
||
713 | ; (SYNTAX) Delay time |
||
714 | ; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec |
||
715 | |||
716 | macro delay arg1 |
||
717 | { |
||
718 | mov eax,5 |
||
719 | mov ebx,arg1 |
||
485 | heavyiron | 720 | mcall |
31 | halyavin | 721 | } |
722 | |||
723 | ; WINDOW - Draw window |
||
724 | ; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color |
||
725 | ; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned |
||
726 | |||
727 | macro window arg1,arg2,arg3,arg4,arg5 |
||
728 | { |
||
729 | ; mov ebx,arg1*65536+arg3 |
||
730 | ; mov ecx,arg2*65536+arg4 |
||
485 | heavyiron | 731 | wordstoreg ebx,arg1,arg3 |
732 | wordstoreg ecx,arg2,arg4 |
||
31 | halyavin | 733 | mov edx,arg5 |
734 | mov eax,0 |
||
485 | heavyiron | 735 | mcall |
31 | halyavin | 736 | } |
737 | |||
738 | macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7 |
||
739 | { |
||
740 | mov ebx,arg1*65536+arg3 |
||
741 | mov ecx,arg2*65536+arg4 |
||
742 | mov edx,arg5 |
||
743 | mov esi,arg6 |
||
744 | mov edi,arg7 |
||
745 | mov eax,0 |
||
485 | heavyiron | 746 | mcall |
31 | halyavin | 747 | } |
748 | |||
749 | |||
750 | ; STARTWD - Start of window draw |
||
751 | |||
752 | macro startwd |
||
753 | { |
||
754 | mov eax,12 |
||
755 | mov ebx,1 |
||
485 | heavyiron | 756 | mcall |
31 | halyavin | 757 | } |
758 | |||
759 | ; ENDWD - End window draw |
||
760 | |||
761 | macro endwd |
||
762 | { |
||
763 | mov eax,12 |
||
764 | mov ebx,2 |
||
485 | heavyiron | 765 | mcall |
31 | halyavin | 766 | } |
767 | |||
768 | ; LABEL - Put text to frame |
||
769 | ; (SYNTAX) LABEL Xstart,Ystart,'Text',Color |
||
770 | ; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big |
||
771 | |||
772 | macro label arg1,arg2,arg3,arg4 |
||
773 | { |
||
774 | local asd,lab |
||
775 | jmp asd |
||
776 | lab db arg3 ;arg label |
||
777 | asd: |
||
778 | ; mov ebx,arg1 ;arg1=y arg2=x |
||
779 | ; shl ebx,16 |
||
780 | ; add ebx,arg2 |
||
485 | heavyiron | 781 | wordstoreg ebx,arg1,arg2 |
782 | if ~(arg4 eq ) |
||
783 | mov ecx,arg4 ;arg4 color |
||
784 | end if |
||
31 | halyavin | 785 | mov edx,lab |
786 | mov esi,asd-lab ;calc size |
||
787 | mov eax,4 |
||
485 | heavyiron | 788 | mcall |
31 | halyavin | 789 | } |
790 | |||
791 | ;Key's |
||
792 | key_Up equ 178 |
||
793 | key_Down equ 177 |
||
794 | key_Right equ 179 |
||
795 | key_Left equ 176 |
||
796 | key_Esc equ 27 |
||
797 | key_Space equ 32 |
||
798 | key_Enter equ 13 |
||
799 | key_Bspace equ 8 |
||
800 | key_F1 equ 50 |
||
801 | key_F2 equ 51 |
||
802 | key_F3 equ 52 |
||
803 | key_F4 equ 53 |
||
804 | key_F5 equ 54 |
||
805 | key_F6 equ 55 |
||
806 | key_F7 equ 56 |
||
807 | key_F8 equ 57 |
||
808 | key_F9 equ 48 |
||
809 | key_F10 equ 49 |
||
810 | key_F11 equ 68 |
||
811 | key_F12 equ 255 |
||
812 | key_Home equ 180 |
||
813 | key_End equ 181 |
||
814 | key_PgUp equ 184 |
||
815 | key_PgDown equ 183 |
||
816 | |||
817 | ;Attributes |
||
818 | |||
819 | ;Window Attributes |
||
820 | window_Skinned equ 0x03000000 |
||
821 | window_Type2 equ 0x02000000 |
||
822 | window_Type1 equ 0x00000000 |
||
823 | window_Reserve equ 0x01000000 |
||
824 | |||
825 | ;Font Attributes |
||
826 | font_Big equ 0x10000000 |
||
827 | |||
828 | ;Colors |
||
829 | cl_White equ 0x00ffffff |
||
830 | cl_Black equ 0x00000000 |
||
831 | cl_Grey equ 0x00888888 |
||
832 | cl_Red equ 0x00ff0000 |
||
833 | cl_Lime equ 0x0000ff00 |
||
834 | cl_Green equ 0x0000af00 |
||
835 | cl_Blue equ 0x000000ff |
||
836 | cl_Purple equ 0x008080ff |
||
837 | cl_Violet equ 0x008040ff |
||
838 | cl_Cyan equ 0x0040e0ff65536> |