Subversion Repositories Kolibri OS

Rev

Rev 485 | Rev 2063 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;    MAGNIFY SCREEN
3
;
4
;    Compile with FASM for Menuet
5
;
6
 
7
use32
8
 
9
                org     0x0
10
 
209 diamond 11
                db      'MENUET01'              ; 8 byte id
12
                dd      1                       ; header version
31 halyavin 13
                dd      START                   ; program start
14
                dd      I_END                   ; program image size
209 diamond 15
                dd      0x1000                  ; required amount of memory
16
                dd      0x1000                  ; esp
17
                dd      0, 0                    ; no parameters, no path
31 halyavin 18
 
485 heavyiron 19
include '..\..\..\macros.inc'
209 diamond 20
delay   equ     20
31 halyavin 21
 
209 diamond 22
magnify_width = 40
23
magnify_height = 30
31 halyavin 24
 
25
START:                          ; start of execution
209 diamond 26
redraw:
27
        call    draw_window
31 halyavin 28
still:
209 diamond 29
        call    draw_screen
30
wtevent:
31
        mov     eax, 23         ; wait here for event with timeout
32
        mov     ebx, delay
485 heavyiron 33
        mcall
209 diamond 34
        dec     eax
35
        js      still
36
        jz      redraw
37
        dec     eax
38
        jnz     button
39
; key in buffer
40
        mov     al, 2
485 heavyiron 41
        mcall
209 diamond 42
        jmp     wtevent
43
button:
44
; we have only one button, close
45
        or      eax, -1
485 heavyiron 46
        mcall
31 halyavin 47
 
48
;   *********************************************
49
;   *******  WINDOW DEFINITIONS AND DRAW ********
50
;   *********************************************
51
 
52
draw_window:
209 diamond 53
        mov     eax, 12         ; function 12:tell os about windowdraw
54
        mov     ebx, 1          ; 1, start of draw
485 heavyiron 55
        mcall
31 halyavin 56
 
209 diamond 57
        mov     al, 48          ; function 48 : graphics parameters
58
        mov     bl, 4           ; subfunction 4 : get skin height
485 heavyiron 59
        mcall
31 halyavin 60
 
209 diamond 61
                                        ; DRAW WINDOW
62
        mov     ebx, 100*65536 + 8*magnify_width + 8
63
        lea     ecx, [eax + 100*65536 + 8*magnify_height + 3]
551 spraid 64
        mov     edx, 0x34000000         ; color of work area RRGGBB
209 diamond 65
        mov     edi, labelt             ; header
66
        xor     eax, eax                ; function 0 : define and draw window
485 heavyiron 67
        mcall
31 halyavin 68
 
69
 
209 diamond 70
        mov     al, 12                  ; function 12:tell os about windowdraw
71
        mov     ebx, 2                  ; 2, end of draw
485 heavyiron 72
        mcall
31 halyavin 73
 
209 diamond 74
        ret
31 halyavin 75
 
76
draw_screen:
77
draw_magnify:
209 diamond 78
        mov     eax, 14
485 heavyiron 79
        mcall            ; get screen size
209 diamond 80
        movzx   ecx, ax
81
        inc     ecx
82
        mov     [size_y], ecx
83
        shr     eax, 16
84
        inc     eax
85
        mov     [size_x], eax
31 halyavin 86
 
209 diamond 87
        mov     eax, 37
88
        xor     ebx, ebx
485 heavyiron 89
        mcall            ; get mouse coordinates
209 diamond 90
        mov     ecx, eax
91
        shr     ecx, 16         ; ecx = x
92
        movzx   edx, ax         ; edx = y
93
        inc     ecx
94
        mov     [m_xe], ecx
95
        inc     edx
96
        mov     [m_ye], edx
97
        sub     ecx, magnify_width
98
        sub     edx, magnify_height
99
        mov     [m_x], ecx
100
        mov     [m_y], edx
101
.loop_y:
102
.loop_x:
103
        xor     eax, eax        ; assume black color for invalid pixels
104
        test    ecx, ecx
105
        js      .nopix
106
        cmp     ecx, [size_x]
107
        jge     .nopix
108
        test    edx, edx
109
        js      .nopix
110
        cmp     edx, [size_y]
111
        jge     .nopix
112
        mov     ebx, edx
113
        imul    ebx, [size_x]
114
        add     ebx, ecx
115
        mov     eax, 35
485 heavyiron 116
        mcall            ; read pixel
209 diamond 117
.nopix:
118
        push    ecx edx
119
        sub     ecx, [m_x]
120
        sub     edx, [m_y]
121
        mov     ebx, ecx
122
        shl     ebx, 3+16
123
        mov     bl, 7
124
        mov     ecx, edx
125
        shl     ecx, 3+16
126
        mov     cl, 7
127
        mov     edx, eax
128
        mov     eax, 13
485 heavyiron 129
        mcall
209 diamond 130
        pop     edx ecx
131
        inc     ecx
132
        cmp     ecx, [m_xe]
133
        jnz     .loop_x
134
        mov     ecx, [m_x]
135
        inc     edx
136
        cmp     edx, [m_ye]
137
        jnz     .loop_y
138
        ret
31 halyavin 139
 
140
; DATA AREA
141
 
142
labelt:
209 diamond 143
    db   'MAGNIFIER - MOVE MOUSE POINTER', 0
31 halyavin 144
 
145
I_END:
209 diamond 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      ?