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