Subversion Repositories Kolibri OS

Rev

Rev 2096 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;---------------------------------------------------------------------
  2. ;    MAGNIFY SCREEN v1.0
  3. ;
  4. ;    Version for KolibriOS 2005-2011
  5. ;
  6. ;    Version for Menuet to 2005
  7. ;---------------------------------------------------------------------
  8. ; last update:  08/18/2011
  9. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  10. ; changes:      Checking for "rolled up" window
  11. ;---------------------------------------------------------------------
  12.         use32
  13.         org     0x0
  14.         db      'MENUET01'              ; 8 byte id
  15.         dd      1                       ; header version
  16.         dd      START                   ; program start
  17.         dd      I_END                   ; program image size
  18.         dd      0x1000                  ; required amount of memory
  19.         dd      0x1000                  ; esp
  20.         dd      0, 0                    ; no parameters, no path
  21. ;---------------------------------------------------------------------
  22. include 'lang.inc'
  23. include '..\..\..\macros.inc'
  24. delay   equ     20
  25.  
  26. magnify_width = 40
  27. magnify_height = 30
  28. ;---------------------------------------------------------------------
  29. START:                          ; start of execution
  30. redraw:
  31.         call    draw_window
  32. still:
  33.         call    draw_magnify
  34. wtevent:
  35.         mcall   23,delay        ; wait here for event with timeout
  36.         dec     eax
  37.         js      still
  38.         jz      redraw
  39.         dec     eax
  40.         jnz     button
  41. ; key in buffer
  42.         mov     al, 2
  43.         mcall
  44.         jmp     wtevent
  45. ;---------------------------------------------------------------------
  46. button:
  47. ; we have only one button, close
  48.         or      eax, -1
  49.         mcall
  50. ;---------------------------------------------------------------------
  51. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  52. ;---------------------------------------------------------------------
  53. draw_window:
  54.         mcall   12,1
  55.        
  56.         mov     al, 48          ; function 48 : graphics parameters
  57.         mov     bl, 4           ; subfunction 4 : get skin height
  58.         mcall
  59.                                         ; DRAW WINDOW
  60.         mov     ebx, 100*65536 + 8*magnify_width + 8
  61.         lea     ecx, [eax + 100*65536 + 8*magnify_height + 3]
  62.         mov     edx, 0x34000000         ; color of work area RRGGBB
  63.         mov     edi, labelt             ; header
  64.         xor     eax, eax                ; function 0 : define and draw window
  65.         mcall
  66.        
  67.         mcall   12,2
  68.         ret
  69. ;---------------------------------------------------------------------
  70. draw_magnify:
  71.         mcall   9,procinfo,-1
  72.         mov     eax,[procinfo+70] ;status of window
  73.         test    eax,100b
  74.         jne     .end
  75.  
  76.         mcall   14      ; get screen size
  77.         movzx   ecx, ax
  78.         inc     ecx
  79.         mov     [size_y], ecx
  80.         shr     eax, 16
  81.         inc     eax
  82.         mov     [size_x], eax
  83.        
  84.         xor     ebx, ebx
  85.         mcall   37      ; get mouse coordinates
  86.         mov     ecx, eax
  87.         shr     ecx, 16         ; ecx = x
  88.         movzx   edx, ax         ; edx = y
  89.         inc     ecx
  90.         mov     [m_xe], ecx
  91.         inc     edx
  92.         mov     [m_ye], edx
  93.         sub     ecx, magnify_width
  94.         sub     edx, magnify_height
  95.         mov     [m_x], ecx
  96.         mov     [m_y], edx
  97. .loop_y:
  98. .loop_x:
  99.         xor     eax, eax        ; assume black color for invalid pixels
  100.         test    ecx, ecx
  101.         js      .nopix
  102.         cmp     ecx, [size_x]
  103.         jge     .nopix
  104.         test    edx, edx
  105.         js      .nopix
  106.         cmp     edx, [size_y]
  107.         jge     .nopix
  108.         mov     ebx, edx
  109.         imul    ebx, [size_x]
  110.         add     ebx, ecx
  111.         mcall   35      ; read pixel
  112. .nopix:
  113.         push    ecx edx
  114.         sub     ecx, [m_x]
  115.         sub     edx, [m_y]
  116.         mov     ebx, ecx
  117.         shl     ebx, 3+16
  118.         mov     bl, 8
  119.         mov     ecx, edx
  120.         shl     ecx, 3+16
  121.         mov     cl, 8
  122.         mov     edx, eax
  123.         mcall   13
  124.         pop     edx ecx
  125.         inc     ecx
  126.         cmp     ecx, [m_xe]
  127.         jnz     .loop_x
  128.         mov     ecx, [m_x]
  129.         inc     edx
  130.         cmp     edx, [m_ye]
  131.         jnz     .loop_y
  132. .end:
  133.         ret
  134. ;---------------------------------------------------------------------
  135. ; DATA AREA
  136. ;---------------------------------------------------------------------
  137. if lang eq ru
  138. labelt:
  139.     db   'Magnifier - ªà ­­ ï «ã¯ ', 0
  140. else
  141. labelt:
  142.     db   'Magnifier', 0
  143. end if
  144.  
  145. I_END:
  146. align 4
  147. m_x     dd      ?
  148. m_y     dd      ?
  149. m_xe    dd      ?
  150. m_ye    dd      ?
  151. size_x  dd      ?
  152. size_y  dd      ?
  153. ;---------------------------------------------------------------------
  154. procinfo:
  155.         rb 1024
  156. ;---------------------------------------------------------------------