Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 485 | 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
 
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
33
        int     0x40
34
        dec     eax
35
        js      still
36
        jz      redraw
37
        dec     eax
38
        jnz     button
39
; key in buffer
40
        mov     al, 2
41
        int     0x40
42
        jmp     wtevent
43
button:
44
; we have only one button, close
45
        or      eax, -1
46
        int     0x40
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
55
        int     0x40
31 halyavin 56
 
209 diamond 57
        mov     al, 48          ; function 48 : graphics parameters
58
        mov     bl, 4           ; subfunction 4 : get skin height
59
        int     0x40
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]
64
        mov     edx, 0x33000000         ; color of work area RRGGBB
65
        mov     edi, labelt             ; header
66
        xor     eax, eax                ; function 0 : define and draw window
67
        int     0x40
31 halyavin 68
 
69
 
209 diamond 70
        mov     al, 12                  ; function 12:tell os about windowdraw
71
        mov     ebx, 2                  ; 2, end of draw
72
        int     0x40
31 halyavin 73
 
209 diamond 74
        ret
31 halyavin 75
 
76
draw_screen:
77
draw_magnify:
209 diamond 78
        mov     eax, 14
79
        int     0x40            ; get screen size
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
89
        int     0x40            ; get mouse coordinates
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
116
        int     0x40            ; read pixel
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
129
        int     0x40
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      ?