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