Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  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. ;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
  146.     int 0x40
  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
  171.     int 0x40
  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
  200.     int 0x40
  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
  234.     int 0x40
  235.  
  236. ; change wanted events list 7-bit IPC event
  237.     mov eax,40
  238.     mov ebx,01000111b
  239.     int 0x40
  240.  
  241. ;
  242. ; STEP 3 run SYSTEM XTREE with parameters
  243. ;
  244.  
  245.     mov eax,58
  246.     mov ebx,run_fileinfo
  247.     int 0x40
  248.  
  249.     call redproc
  250.  
  251.     mov [get_loops],0
  252. getmesloop:
  253.     mov eax,23
  254.     mov ebx,50     ;0.5 sec
  255.     int 0x40
  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
  270.     int 0x40
  271.     mov ebp,eax
  272.  
  273. loox:
  274.     mov eax,9
  275.     mov ebx,procinfo
  276.     mov ecx,ebp
  277.     int 0x40
  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
  302.     int  0x40                   ; read (eax=2)
  303.     jmp  getmesloop
  304. mbutton:
  305.     mov  eax,17                 ; get id
  306.     int  0x40
  307.     cmp  ah,1                   ; button id=1 ?
  308.     jne  getmesloop
  309.     mov  eax,-1                 ; close this program
  310.     int  0x40
  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
  380.  db '/RD/1/SYSXTREE',0
  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
  412.     int 0x40
  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
  446.     int 0x40
  447.  
  448. ; change wanted events list 7-bit IPC event
  449.     mov eax,40
  450.     mov ebx,01000111b
  451.     int 0x40
  452.  
  453. ;
  454. ; STEP 3 run SYSTEM XTREE with parameters
  455. ;
  456.  
  457.     mov eax,58
  458.     mov ebx,run_fileinfo
  459.     int 0x40
  460.  
  461.     call redproc
  462.  
  463.     mov [get_loops],0
  464. getmesloop:
  465.     mov eax,23
  466.     mov ebx,50     ;0.5 sec
  467.     int 0x40
  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
  482.     int 0x40
  483.     mov ebp,eax
  484.  
  485. loox:
  486.     mov eax,9
  487.     mov ebx,procinfo
  488.     mov ecx,ebp
  489.     int 0x40
  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
  514.     int  0x40                   ; read (eax=2)
  515.     jmp  getmesloop
  516. mbutton:
  517.     mov  eax,17                 ; get id
  518.     int  0x40
  519.     cmp  ah,1                   ; button id=1 ?
  520.     jne  getmesloop
  521.     mov  eax,-1                 ; close this program
  522.     int  0x40
  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:
  592.  db '/RD/1/SYSXTREE',0
  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
  674.     int 0x40
  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
  683.     int 0x40
  684. }
  685.  
  686. macro puttxt x,y,offs,size,color
  687. {
  688. ;    mov ebx,x
  689. ;    shl ebx,16
  690. ;    add ebx,y
  691.     words2reg ebx,x,y
  692.  
  693.     dword2reg ecx,color
  694.     dword2reg edx,offs
  695.     dword2reg esi,size
  696.  
  697. ;    mov ecx,color
  698. ;    mov edx,offs
  699. ;    mov esi,size
  700.     mov eax,4
  701.     int 0x40
  702. }
  703.  
  704. macro outcount data, x, y, color, numtype
  705. {
  706.     mov ecx,data
  707.     mov ebx,numtype
  708.     mov bl,0
  709. ;    mov edx,x*65536+y
  710.     words2reg edx,x,y
  711.     mov esi,color
  712.     mov eax,47
  713.     int 0x40
  714. }
  715.  
  716. ; SCEVENT - Scan event
  717.  
  718. macro scevent red,key,but
  719. {
  720.     mov eax,11
  721.     int 0x40
  722.     dec eax
  723.     jz  red
  724.     dec eax
  725.     jz  key
  726.     dec eax
  727.     jz  but
  728. }
  729.  
  730. ; WTEVENT - Wait event
  731.  
  732. macro wtevent red,key,but
  733. {
  734.     mov eax,10
  735.     int 0x40
  736.     dec eax
  737.     jz  red
  738.     dec eax
  739.     jz  key
  740.     dec eax
  741.     jz  but
  742. }
  743.  
  744. ; TIMEEVENT - Wite for event with timeout
  745.  
  746. macro timeevent xfps,noevent,red,key,but
  747. {
  748.     mov eax,23
  749.     mov ebx,xfps
  750.     int 0x40
  751.     cmp eax,0
  752.     je  noevent
  753.     dec eax
  754.     jz  red
  755.     dec eax
  756.     jz  key
  757.     dec eax
  758.     jz  but
  759. }
  760.  
  761.  
  762. ; CLOSE - Close program
  763.  
  764. macro close
  765. {
  766.     mov eax,-1
  767.     int 0x40
  768. }
  769.  
  770. ; DELAY - Create delay 1/100 sec
  771. ; (SYNTAX)  Delay time
  772. ; (SAMPLE)  Delay 100   ;delay 2 sec 1/100*200=2 sec
  773.  
  774. macro delay arg1
  775. {
  776.     mov eax,5
  777.     mov ebx,arg1
  778.     int 0x40
  779. }
  780.  
  781. ; WINDOW - Draw window
  782. ; (SYNTAX)  WINDOW Xstart,Ystart,'Text',Color
  783. ; (SAMPLE)  WINDOW 10,10,640+8,480+24,window_Skinned
  784.  
  785. macro window arg1,arg2,arg3,arg4,arg5
  786. {
  787. ;    mov ebx,arg1*65536+arg3
  788. ;    mov ecx,arg2*65536+arg4
  789.     words2reg ebx,arg1,arg3
  790.     words2reg ecx,arg2,arg4
  791.     mov edx,arg5
  792.     mov eax,0
  793.     int 0x40
  794. }
  795.  
  796. macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7
  797. {
  798.     mov ebx,arg1*65536+arg3
  799.     mov ecx,arg2*65536+arg4
  800.     mov edx,arg5
  801.     mov esi,arg6
  802.     mov edi,arg7
  803.     mov eax,0
  804.     int 0x40
  805. }
  806.  
  807.  
  808. ; STARTWD - Start of window draw
  809.  
  810. macro startwd
  811. {
  812.     mov eax,12
  813.     mov ebx,1
  814.     int 0x40
  815. }
  816.  
  817. ; ENDWD - End window draw
  818.  
  819. macro endwd
  820. {
  821.     mov eax,12
  822.     mov ebx,2
  823.     int 0x40
  824. }
  825.  
  826. ; LABEL - Put text to frame
  827. ; (SYNTAX)  LABEL Xstart,Ystart,'Text',Color
  828. ; (SAMPLE)  LABEL 10,12,'Hello World!',cl_Green+font_Big
  829.  
  830. macro label arg1,arg2,arg3,arg4
  831. {
  832. local asd,lab
  833.     jmp asd
  834. lab db  arg3                 ;arg label
  835. asd:
  836. ;    mov ebx,arg1             ;arg1=y arg2=x
  837. ;    shl ebx,16
  838. ;    add ebx,arg2
  839.  
  840.    words2reg ebx,arg1,arg2
  841.  
  842.    dword2reg ecx,arg4
  843.  
  844.     mov edx,lab
  845.     mov esi,asd-lab          ;calc size
  846.     mov eax,4
  847.     int 0x40
  848. }
  849.  
  850. ;Key's
  851. key_Up     equ 178
  852. key_Down   equ 177
  853. key_Right  equ 179
  854. key_Left   equ 176
  855. key_Esc    equ 27
  856. key_Space  equ 32
  857. key_Enter  equ 13
  858. key_Bspace equ 8
  859. key_F1     equ 50
  860. key_F2     equ 51
  861. key_F3     equ 52
  862. key_F4     equ 53
  863. key_F5     equ 54
  864. key_F6     equ 55
  865. key_F7     equ 56
  866. key_F8     equ 57
  867. key_F9     equ 48
  868. key_F10    equ 49
  869. key_F11    equ 68
  870. key_F12    equ 255
  871. key_Home   equ 180
  872. key_End    equ 181
  873. key_PgUp   equ 184
  874. key_PgDown equ 183
  875.  
  876. ;Attributes
  877.  
  878. ;Window Attributes
  879. window_Skinned equ 0x03000000
  880. window_Type2   equ 0x02000000
  881. window_Type1   equ 0x00000000
  882. window_Reserve equ 0x01000000
  883.  
  884. ;Font Attributes
  885. font_Big  equ 0x10000000
  886.  
  887. ;Colors
  888. cl_White  equ 0x00ffffff
  889. cl_Black  equ 0x00000000
  890. cl_Grey   equ 0x00888888
  891. cl_Red    equ 0x00ff0000
  892. cl_Lime   equ 0x0000ff00
  893. cl_Green  equ 0x0000af00
  894. cl_Blue   equ 0x000000ff
  895. cl_Purple equ 0x008080ff
  896. cl_Violet equ 0x008040ff
  897. cl_Cyan   equ 0x0040e0ff
  898.