Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 485 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 109 Rev 209
Line 6... Line 6...
6
 
6
 
Line 7... Line 7...
7
use32
7
use32
Line 8... Line 8...
8
 
8
 
9
                org     0x0
9
                org     0x0
10
 
10
 
11
                db      'MENUET00'              ; 8 byte id
11
                db      'MENUET01'              ; 8 byte id
12
                dd      38                      ; required os
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
Line 15... Line -...
15
                dd      0x10000                ; required amount of memory
-
 
16
                dd      0x10000
15
                dd      0x1000                  ; required amount of memory
17
                dd      0x00000000              ; reserved=no extended header
16
                dd      0x1000                  ; esp
Line -... Line 17...
-
 
17
                dd      0, 0                    ; no parameters, no path
-
 
18
 
Line 18... Line 19...
18
 
19
include 'macros.inc'
19
include 'lang.inc'
-
 
20
include 'macros.inc'
-
 
21
scr     equ     0x1000
-
 
22
 
-
 
23
 
-
 
24
START:                          ; start of execution
-
 
25
 
-
 
26
    mov  esp,0xfff0
20
delay   equ     20
27
 
-
 
28
    mov  eax,14                 ; get screen size
-
 
29
    int  0x40
-
 
30
    push eax
-
 
31
    and  eax,0x0000ffff
-
 
32
    add  eax,1
-
 
33
    mov  [size_y],eax
-
 
34
    pop  eax
-
 
35
    shr  eax,16
-
 
36
    add  eax,1
-
 
37
    mov  [size_x],eax
-
 
38
 
-
 
39
    mov  eax,[size_x]
-
 
40
    shr  eax,2
-
 
41
    mov  [cmp_ecx],eax
21
 
42
 
-
 
43
    mov  eax,[size_x]
-
 
44
    xor  edx,edx
-
 
45
    mov  ebx,3
-
 
46
    mul  ebx
-
 
47
    mov  [add_esi],eax
-
 
48
 
-
 
49
    mov  eax,[size_y]
-
 
50
    shr  eax,2
-
 
51
    mov  [cmp_edx],eax
22
magnify_width = 40
52
 
-
 
53
 
23
magnify_height = 30
54
 
24
 
55
    call draw_window            ; at first, draw the window
25
START:                          ; start of execution
56
 
26
redraw:
57
still:
27
        call    draw_window
58
 
-
 
59
    call draw_screen
-
 
60
 
28
still:
61
    mov  eax,23                 ; wait here for event with timeout
-
 
62
    mov  ebx,[delay]
29
        call    draw_screen
63
    int  0x40
-
 
64
 
30
wtevent:
65
    cmp  eax,1                  ; redraw request ?
-
 
66
    jz   red
31
        mov     eax, 23         ; wait here for event with timeout
67
    cmp  eax,2                  ; key in buffer ?
-
 
68
    jz   key
-
 
69
    cmp  eax,3                  ; button in buffer ?
32
        mov     ebx, delay
70
    jz   button
33
        int     0x40
71
 
-
 
72
    jmp  still
34
        dec     eax
73
 
-
 
74
  red:                          ; redraw
35
        js      still
75
    call draw_window
36
        jz      redraw
76
    jmp  still
37
        dec     eax
77
 
38
        jnz     button
78
  key:                          ; key
39
; key in buffer
79
    mov  eax,2                  ; just read it and ignore
40
        mov     al, 2
Line 80... Line -...
80
    int  0x40
-
 
81
    jmp  still
-
 
82
 
-
 
83
  button:                       ; button
-
 
84
    mov  eax,17                 ; get id
-
 
85
    int  0x40
-
 
86
 
-
 
87
    cmp  ah,1                   ; button id=1 ?
-
 
88
    jnz  noclose
-
 
89
    mov  eax,0xffffffff         ; close this program
-
 
90
    int  0x40
-
 
91
  noclose:
-
 
92
 
-
 
93
    cmp  ah,2
-
 
94
    jnz  nosave
-
 
95
    call save_screen
-
 
96
  nosave:
-
 
97
 
-
 
98
    jmp  still
-
 
99
 
-
 
100
 
-
 
101
 
-
 
102
save_screen:
-
 
103
 
-
 
104
     pusha
-
 
105
 
-
 
106
     mov  ebx,0
-
 
107
     mov  edi,0x10000
-
 
108
 
-
 
109
   ss1:
-
 
110
 
-
 
111
     mov  eax,35
-
 
112
     int  0x40
-
 
113
 
-
 
114
     add  ebx,1
-
 
115
 
-
 
116
     mov  [edi],eax
-
 
117
     add  edi,3
-
 
118
 
-
 
119
     cmp  edi,0xFFFF0
-
 
120
     jb   ss1
-
 
121
 
-
 
122
     mov  eax,33
-
 
123
     mov  ebx,filename
-
 
124
     mov  ecx,0x10000
-
 
125
     mov  edx,0xEFFF0
-
 
126
     mov  esi,0
-
 
127
     int  0x40
-
 
128
 
-
 
129
     popa
41
        int     0x40
130
 
42
        jmp     wtevent
131
     ret
43
button:
Line 132... Line -...
132
 
-
 
133
 
44
; we have only one button, close
134
filename  db  'SCREEN  RAW'
-
 
135
 
45
        or      eax, -1
136
;   *********************************************
46
        int     0x40
137
;   *******  WINDOW DEFINITIONS AND DRAW ********
47
 
Line 138... Line -...
138
;   *********************************************
-
 
139
 
48
;   *********************************************
140
 
-
 
141
draw_window:
-
 
142
 
-
 
143
    mov  eax,12                    ; function 12:tell os about windowdraw
-
 
144
    mov  ebx,1                     ; 1, start of draw
-
 
145
    int  0x40
-
 
146
 
-
 
147
                                   ; DRAW WINDOW
-
 
148
    mov  eax,0                     ; function 0 : define and draw window
-
 
149
    mov  ebx,100*65536             ; [x start] *65536 + [x size]
49
;   *******  WINDOW DEFINITIONS AND DRAW ********
150
    mov  ebx,100*65536+322
-
 
151
    mov  ecx,100*65536+262         ; [y start] *65536 + [y size]
-
 
152
    mov  edx,0x0;01111cc            ; color of work area RRGGBB
-
 
153
    mov  esi,0x809977ff            ; color of grab bar  RRGGBB,8->color glide
-
 
154
    mov  edi,0x00ffff00            ; color of frames    RRGGBB
50
;   *********************************************
Line 155... Line 51...
155
    int  0x40
51
 
156
 
52
draw_window:
157
                                   ; WINDOW LABEL
53
        mov     eax, 12         ; function 12:tell os about windowdraw
158
    mov  eax,4                     ; function 4 : write text to window
-
 
159
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
54
        mov     ebx, 1          ; 1, start of draw
160
    mov  ecx,0x00ffffff            ; color of text RRGGBB
55
        int     0x40
161
    mov  edx,labelt                ; pointer to text beginning
56
 
162
    mov  esi,labellen-labelt       ; text length
57
        mov     al, 48          ; function 48 : graphics parameters
Line 163... Line -...
163
    int  0x40
-
 
Line 164... Line 58...
164
 
58
        mov     bl, 4           ; subfunction 4 : get skin height
165
                                   ; CLOSE BUTTON
59
        int     0x40
166
    mov  eax,8                     ; function 8 : define and draw button
60
 
Line 167... Line 61...
167
    mov  bx,12                     ; [x start] *65536 + [x size]
61
                                        ; DRAW WINDOW
Line 168... Line -...
168
    mov  ebx,(322-19)*65536+12
-
 
169
    mov  ecx,5*65536+12            ; [y start] *65536 + [y size]
62
        mov     ebx, 100*65536 + 8*magnify_width + 8
170
    mov  edx,1                     ; button id
-
 
171
    mov  esi,0x22aacc              ; button color RRGGBB
-
 
172
    int  0x40
-
 
173
 
-
 
174
    call draw_screen
-
 
175
 
-
 
176
    mov  eax,12                    ; function 12:tell os about windowdraw
-
 
177
    mov  ebx,2                     ; 2, end of draw
-
 
178
    int  0x40
-
 
179
 
-
 
180
    ret
-
 
181
 
-
 
182
 
-
 
183
draw_screen:
-
 
184
 
-
 
185
    call draw_magnify
-
 
186
 
-
 
187
    ret
-
 
188
 
-
 
189
    pusha
-
 
190
 
-
 
191
    mov  edi,scr
-
 
192
 
-
 
193
    mov  ecx,0
-
 
194
    mov  edx,0
-
 
195
 
-
 
196
    mov  esi,0
-
 
197
 
-
 
198
  ds1:
-
 
199
 
-
 
200
    mov  eax,35
-
 
201
    mov  ebx,esi
-
 
202
    int  0x40
-
 
203
    stosd
-
 
204
    sub  edi,1
-
 
205
 
-
 
206
    add  esi,4
-
 
207
    add  ecx,1
-
 
208
    cmp  ecx,[cmp_ecx] ; 800/4
-
 
209
    jb   ds1
-
 
210
 
-
 
211
    add  esi,[add_esi] ; 800*3
-
 
212
    mov  ecx,0
-
 
213
    add  edx,1
-
 
214
    cmp  edx,[cmp_edx] ; 600/4
-
 
215
    jb   ds1
-
 
216
 
-
 
217
    mov  eax,7
-
 
218
    mov  ebx,scr
-
 
219
    mov  ecx,200*65536+160
-
 
220
    mov  ecx,[size_x]
-
 
221
    shr  ecx,2
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
-
 
68
 
-
 
69
 
222
    shl  ecx,16
-
 
223
    mov  cx,word [size_y]
70
        mov     al, 12                  ; function 12:tell os about windowdraw
-
 
71
        mov     ebx, 2                  ; 2, end of draw
Line 224... Line 72...
224
    shr  cx,2
72
        int     0x40
225
    mov  edx,20*65536+35
73
 
226
    int  0x40
74
        ret
227
 
-
 
228
    popa
75
 
229
 
-
 
230
    call draw_magnify
76
draw_screen:
231
 
-
 
232
    ret
-
 
233
 
-
 
234
 
-
 
235
draw_magnify:
-
 
236
 
-
 
237
    pusha
-
 
238
 
-
 
239
    mov  eax,37
-
 
240
    mov  ebx,0
-
 
241
    int  0x40
77
draw_magnify:
242
 
-
 
243
    mov  ecx,eax
-
 
244
    mov  edx,eax
-
 
245
    shr  ecx,16
-
 
246
    and  edx,65535
-
 
247
 
-
 
248
    sub  ecx,39
-
 
249
    sub  edx,29
-
 
250
 
-
 
251
    cmp  ecx,3000
78
        mov     eax, 14
252
    jb   co1
-
 
253
    popa
-
 
254
    ret
-
 
255
  co1:
-
 
256
    cmp  edx,3000
-
 
257
    jb   co2
79
        int     0x40            ; get screen size
-
 
80
        movzx   ecx, ax
258
    popa
81
        inc     ecx
259
    ret
-
 
-
 
82
        mov     [size_y], ecx
-
 
83
        shr     eax, 16
260
 
84
        inc     eax
261
  co2:
85
        mov     [size_x], eax
262
 
-
 
263
    and  ecx,2047
86
 
264
    and  edx,2047
87
        mov     eax, 37
-
 
88
        xor     ebx, ebx
-
 
89
        int     0x40            ; get mouse coordinates
265
 
90
        mov     ecx, eax
-
 
91
        shr     ecx, 16         ; ecx = x
-
 
92
        movzx   edx, ax         ; edx = y
266
    mov  [m_x],ecx
93
        inc     ecx
-
 
94
        mov     [m_xe], ecx
267
    mov  [m_y],edx
95
        inc     edx
268
 
96
        mov     [m_ye], edx
269
    add  ecx,40
97
        sub     ecx, magnify_width
270
    add  edx,30
-
 
-
 
98
        sub     edx, magnify_height
271
 
99
        mov     [m_x], ecx
272
    mov  [m_xe],ecx
100
        mov     [m_y], edx
273
    mov  [m_ye],edx
101
.loop_y:
274
 
102
.loop_x:
275
    mov  ecx,[m_x]
103
        xor     eax, eax        ; assume black color for invalid pixels
-
 
104
        test    ecx, ecx
-
 
105
        js      .nopix
276
    mov  edx,[m_y]
106
        cmp     ecx, [size_x]
277
 
107
        jge     .nopix
-
 
108
        test    edx, edx
278
  dm1:
109
        js      .nopix
279
 
-
 
280
    push edx
-
 
281
    mov  eax,edx
-
 
282
    mul  [size_x]
-
 
283
    pop  edx
-
 
284
    add  eax,ecx
-
 
285
 
-
 
286
    mov  ebx,eax
110
        cmp     edx, [size_y]
287
    mov  eax,35
111
        jge     .nopix
288
    int  0x40
-
 
289
 
112
        mov     ebx, edx
290
    pusha
113
        imul    ebx, [size_x]
291
    mov  ebx,ecx
114
        add     ebx, ecx
292
    sub  ebx,[m_x]
115
        mov     eax, 35
293
    mov  ecx,edx
-
 
294
    sub  ecx,[m_y]
116
        int     0x40            ; read pixel
295
    shl  ebx,3
117
.nopix:
296
    add  ebx,2
118
        push    ecx edx
297
    shl  ebx,16
119
        sub     ecx, [m_x]
298
    mov  bx,7
120
        sub     edx, [m_y]
299
    shl  ecx,3
121
        mov     ebx, ecx
300
    add  ecx,22
122
        shl     ebx, 3+16
301
    shl  ecx,16
-
 
302
    mov  cx,7
-
 
303
 
-
 
304
    mov  edx,eax
123
        mov     bl, 7
Line 305... Line -...
305
    mov  eax,13
-
 
306
    int  0x40
-
 
307
    popa
124
        mov     ecx, edx
Line 308... Line -...
308
 
-
 
309
    add  ecx,1
-
 
310
    cmp  ecx,[m_xe]
-
 
311
    jnz  dm1
-
 
312
    mov  ecx,[m_x]
-
 
313
    add  edx,1
-
 
314
    cmp  edx,[m_ye]
-
 
315
    jnz  dm1
-
 
316
 
-
 
317
    popa
-
 
318
 
-
 
319
    ret
-
 
320
 
-
 
321
 
-
 
322
 
-
 
323
; DATA AREA
125
        shl     ecx, 3+16
324
 
126
        mov     cl, 7
325
m_x      dd  100
-
 
326
m_y      dd  100
-
 
Line 327... Line 127...
327
 
127
        mov     edx, eax
328
m_xe     dd  110
-
 
329
m_ye     dd  110
-
 
330
 
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]