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