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