Subversion Repositories Kolibri OS

Rev

Rev 485 | Rev 2096 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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