Subversion Repositories Kolibri OS

Rev

Rev 316 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;
  2. ;   TRANSPARENT EXAMPLE
  3. ;
  4. ;   Compile with FASM for Menuet
  5. ;
  6.  
  7. use32
  8.  
  9.                org    0x0
  10.  
  11.                db     'MENUET01'              ; 8 byte id
  12.                dd     0x01                    ; header version
  13.                dd     START                   ; start of code
  14.                dd     I_END                   ; size of image
  15.                dd     0x30000                 ; memory for app
  16.                dd     0x30000                 ; esp
  17.                dd     0x0 , 0x0               ; I_Param , I_Icon
  18.  
  19. include 'lang.inc'
  20. include '..\..\..\macros.inc'
  21.  
  22. START:                          ; start of execution
  23.     mov  [procinfo.box.left], 100
  24.     mov  [procinfo.box.width],  200
  25.     mov  [procinfo.box.top], 80
  26.     mov  [procinfo.box.height],  300
  27.     call draw_window
  28. red:    
  29.     call get_transparent
  30.     call draw_window            ; at first, draw the window
  31.  
  32. still:
  33.  
  34.     mov  eax,10                 ; wait here for event
  35.     mcall
  36.  
  37.     cmp  eax,1                  ; redraw request ?
  38.     je   red
  39.     cmp  eax,2                  ; key in buffer ?
  40.     je   key
  41.     cmp  eax,3                  ; button in buffer ?
  42.     je   button
  43.     jmp  still
  44.  
  45.   key:                          ; key
  46.     mov  al,2                  ; just read it and ignore
  47.     mcall
  48.     jmp  still
  49.  
  50.   button:                       ; button
  51.     mov  al,17                 ; get id
  52.     mcall
  53.  
  54.     cmp  ah,1                   ; button id=1 ?
  55.     jne  noclose
  56.     or   eax,-1                 ; close this program
  57.     mcall
  58.   noclose:
  59.  
  60.     jmp  still
  61.  
  62.  
  63. ;   *********************************************
  64. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  65. ;   *********************************************
  66.  
  67.  
  68. draw_window:
  69.  
  70.     mov  eax,12                    ; function 12:tell os about windowdraw
  71.     mov  ebx,1                     ; 1, start of draw
  72.     mcall
  73.                                    ; DRAW WINDOW
  74.     xor  eax,eax                   ; function 0 : define and draw window
  75.     mov  ebx,[procinfo.box.left]
  76.     shl  ebx,16
  77.     add  ebx,[procinfo.box.width]
  78.     mov  ecx,[procinfo.box.top]
  79.     shl  ecx,16
  80.     add  ecx,[procinfo.box.height]
  81.     mov  edx,0x33000000            ; color of work area RRGGBB,8->color gl
  82.     mov  edi,title                ; WINDOW LABEL
  83.     mcall
  84.  
  85.     call draw_transparent
  86.                                    
  87.     mov  eax,12                    ; function 12:tell os about windowdraw
  88.     mov  ebx,2                     ; 2, end of draw
  89.     mcall
  90.  
  91.     ret
  92.  
  93.  
  94.  
  95.  
  96. draw_transparent:
  97.  
  98.     pusha
  99.  
  100.     mov  eax,7
  101.     mov  ebx,0x1000
  102.     mov  ecx,[procinfo.box.width]
  103.     shl  ecx,16
  104.     add  ecx,[procinfo.box.height]
  105.     xor  edx,edx
  106.     mcall
  107.  
  108.     popa
  109.     ret
  110.  
  111.  
  112. get_transparent:
  113.  
  114.     pusha
  115.  
  116.     mov  eax,9
  117.     mov  ebx,I_END
  118.     mov  ecx,-1
  119.     mcall
  120.  
  121.     mov  eax,14
  122.     mcall
  123.  
  124.     shr  eax,16
  125.     inc  eax
  126.     mov  [scx],eax
  127.  
  128.     add  [procinfo.box.left], 4
  129.     sub  [procinfo.box.width],  4+4
  130.     add  [procinfo.box.top], 22
  131.     sub  [procinfo.box.height],  22+4
  132.  
  133.     mov  eax,[procinfo.box.left]
  134.     add  eax,[procinfo.box.width]
  135.     mov  [x_end],eax
  136.     mov  eax,[procinfo.box.top]
  137.     add  eax,[procinfo.box.height]
  138.     mov  [y_end],eax
  139.  
  140.     mov  eax,[procinfo.box.left]
  141.     mov  ebx,[procinfo.box.top]
  142.  
  143.   dtpl1:
  144.  
  145.     push  eax
  146.     push  ebx
  147.  
  148.     imul  ebx,[scx]
  149.     add   ebx,eax
  150.     mov   eax,35
  151.     mcall
  152.  
  153.     or    eax, 0x4e4e4e
  154.  
  155.     mov   ebx,[esp+4]
  156.     mov   ecx,[esp]
  157.     sub   ebx,[procinfo.box.left]
  158.     sub   ecx,[procinfo.box.top]
  159.     imul  ecx,[procinfo.box.width]
  160.     imul  ebx,3
  161.     imul  ecx,3
  162.     add   ebx,ecx
  163.     mov   [0x1000+ebx],eax
  164.  
  165.     pop   ebx
  166.     pop   eax
  167.  
  168.     inc   eax
  169.     cmp   eax,[x_end]
  170.     jb    dtpl1
  171.     mov   eax,[procinfo.box.left]
  172.     inc   ebx
  173.     cmp   ebx,[y_end]
  174.     jb    dtpl1
  175.  
  176.     popa
  177.  
  178.     ret
  179.  
  180.  
  181.  
  182.  
  183. ; DATA AREA
  184.  
  185.  
  186. x_end    dd 0
  187. y_end    dd 0
  188.  
  189. scx      dd 640
  190.  
  191. title     db   'Transparent',0
  192.  
  193. I_END:
  194. procinfo process_information
  195.  
  196.