Subversion Repositories Kolibri OS

Rev

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

Rev 9910 Rev 9911
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
6
;;                                                              ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
8
 
9
$Revision: 9910 $
9
$Revision: 9911 $
10
 
10
 
11
;==============================================================================
11
;==============================================================================
12
;     public functions 
12
;     public functions 
13
;==============================================================================
13
;==============================================================================
14
 
14
 
15
window.BORDER_SIZE = 5
15
window.BORDER_SIZE = 5
16
 
16
 
17
uglobal
17
uglobal
18
  common_colours rd 48
18
  common_colours rd 48
19
  draw_limits    RECT
19
  draw_limits    RECT
20
endg
20
endg
21
;------------------------------------------------------------------------------
21
;------------------------------------------------------------------------------
22
 
22
 
23
 
23
 
24
align 4
24
align 4
25
syscall_draw_window: ;     system function 0
25
syscall_draw_window: ;     system function 0
26
        mov     eax, edx
26
        mov     eax, edx
27
        shr     eax, 24
27
        shr     eax, 24
28
        and     al, 0x0f
28
        and     al, 0x0f
29
        cmp     al, 5
29
        cmp     al, 5
30
        jae     .exit
30
        jae     .exit
31
 
31
 
32
        push    eax
32
        push    eax
33
        call    window._.sys_set_window
33
        call    window._.sys_set_window
34
        pop     eax
34
        pop     eax
35
 
35
 
36
        or      al, al
36
        or      al, al
37
        jnz     @f
37
        jnz     @f
38
 
38
 
39
; type I - original style
39
; type I - original style
40
        call    drawwindow_I
40
        call    drawwindow_I
41
        jmp     window._.draw_window_caption.2
41
        jmp     window._.draw_window_caption.2
42
;--------------------------------------
42
;--------------------------------------
43
@@:
43
@@:
44
        dec     al
44
        dec     al
45
        jnz     @f
45
        jnz     @f
46
 
46
 
47
; type II - only reserve area, no draw
47
; type II - only reserve area, no draw
48
        call    __sys_draw_pointer
48
        call    __sys_draw_pointer
49
        jmp     .exit
49
        jmp     .exit
50
;--------------------------------------
50
;--------------------------------------
51
@@:
51
@@:
52
        dec     al
52
        dec     al
53
        jnz     @f
53
        jnz     @f
54
 
54
 
55
; type III  - new style
55
; type III  - new style
56
        call    drawwindow_III
56
        call    drawwindow_III
57
        jmp     window._.draw_window_caption.2
57
        jmp     window._.draw_window_caption.2
58
;--------------------------------------
58
;--------------------------------------
59
@@:
59
@@:
60
; type IV & V - skinned window (resizable & not)
60
; type IV & V - skinned window (resizable & not)
61
        mov     eax, [thread_count]
61
        mov     eax, [thread_count]
62
        movzx   eax, word[WIN_POS + eax * 2]
62
        movzx   eax, word[WIN_POS + eax * 2]
63
        cmp     eax, [current_slot_idx]
63
        cmp     eax, [current_slot_idx]
64
        setz    al
64
        setz    al
65
        movzx   eax, al
65
        movzx   eax, al
66
        push    eax
66
        push    eax
67
        call    drawwindow_IV
67
        call    drawwindow_IV
68
        jmp     window._.draw_window_caption.2
68
        jmp     window._.draw_window_caption.2
69
;--------------------------------------
69
;--------------------------------------
70
.exit:
70
.exit:
71
        ret
71
        ret
72
;------------------------------------------------------------------------------
72
;------------------------------------------------------------------------------
73
 
73
 
74
 
74
 
75
align 4
75
align 4
76
; system function 1
76
; system function 1
77
syscall_setpixel:  
77
syscall_setpixel:  
78
        mov     eax, ebx
78
        mov     eax, ebx
79
        mov     ebx, ecx
79
        mov     ebx, ecx
80
        mov     ecx, edx
80
        mov     ecx, edx
81
        mov     edx, [current_slot_idx]
81
        mov     edx, [current_slot_idx]
82
        shl     edx, BSF sizeof.WDATA
82
        shl     edx, BSF sizeof.WDATA
83
        add     eax, [edx + window_data + WDATA.box.left]
83
        add     eax, [edx + window_data + WDATA.box.left]
84
        add     ebx, [edx + window_data + WDATA.box.top]
84
        add     ebx, [edx + window_data + WDATA.box.top]
85
        mov     edi, [current_slot]
85
        mov     edi, [current_slot]
86
        add     eax, [edi+APPDATA.wnd_clientbox.left]
86
        add     eax, [edi+APPDATA.wnd_clientbox.left]
87
        add     ebx, [edi+APPDATA.wnd_clientbox.top]
87
        add     ebx, [edi+APPDATA.wnd_clientbox.top]
88
        xor     edi, edi ; no force
88
        xor     edi, edi ; no force
89
        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
89
        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
90
        jmp     __sys_putpixel
90
        jmp     __sys_putpixel
91
;------------------------------------------------------------------------------
91
;------------------------------------------------------------------------------
92
 
92
 
93
 
93
 
94
align 4
94
align 4
95
; system function 4
95
; system function 4
96
syscall_writetext: 
96
syscall_writetext: 
97
 
97
 
98
        push    esi    ;check pointer on kernel address.
98
        push    esi    ;check pointer on kernel address.
99
        test    ecx, 0x80000000
99
        test    ecx, 0x80000000
100
        jz      @f
100
        jz      @f
101
        xor     esi, esi
101
        xor     esi, esi
102
@@:
102
@@:
103
        stdcall is_region_userspace, edx, esi
103
        stdcall is_region_userspace, edx, esi
104
        pop     esi
104
        pop     esi
105
        jnz     .err
105
        jnz     .err
106
 
106
 
107
        mov     eax, [current_slot_idx]
107
        mov     eax, [current_slot_idx]
108
        shl     eax, BSF sizeof.WDATA
108
        shl     eax, BSF sizeof.WDATA
109
        mov     ebp, [eax + window_data + WDATA.box.left]
109
        mov     ebp, [eax + window_data + WDATA.box.left]
110
        push    esi
110
        push    esi
111
        mov     esi, [current_slot]
111
        mov     esi, [current_slot]
112
        add     ebp, [esi+APPDATA.wnd_clientbox.left]
112
        add     ebp, [esi+APPDATA.wnd_clientbox.left]
113
        shl     ebp, 16
113
        shl     ebp, 16
114
        add     ebp, [eax + window_data + WDATA.box.top]
114
        add     ebp, [eax + window_data + WDATA.box.top]
115
        add     bp, word[esi+APPDATA.wnd_clientbox.top]
115
        add     bp, word[esi+APPDATA.wnd_clientbox.top]
116
        pop     esi
116
        pop     esi
117
        test    ecx, 0x08000000  ; redirect the output to the user area
117
        test    ecx, 0x08000000  ; redirect the output to the user area
118
        jnz     @f
118
        jnz     @f
119
        add     ebx, ebp
119
        add     ebx, ebp
120
align 4
120
align 4
121
@@:
121
@@:
122
        mov     eax, edi
122
        mov     eax, edi
123
        test    ecx, 0x08000000  ; redirect the output to the user area
123
        test    ecx, 0x08000000  ; redirect the output to the user area
124
        jnz     @f
124
        jnz     @f
125
        xor     edi, edi
125
        xor     edi, edi
126
        jmp     dtext
126
        jmp     dtext
127
 
127
 
128
@@:     ;  check pointer
128
@@:     ;  check pointer
129
        stdcall is_region_userspace, edi, 0
129
        stdcall is_region_userspace, edi, 0
130
        jnz     .err
130
        jnz     .err
131
        jmp     dtext
131
        jmp     dtext
132
.err:
132
.err:
133
        ret
133
        ret
134
;------------------------------------------------------------------------------
134
;------------------------------------------------------------------------------
135
 
135
 
136
 
136
 
137
align 4
137
align 4
138
; system function 13
138
; system function 13
139
syscall_drawrect: 
139
syscall_drawrect: 
140
        mov     edi, edx ; color + gradient
140
        mov     edi, edx ; color + gradient
141
        and     edi, 0x80FFFFFF
141
        and     edi, 0x80FFFFFF
142
        test    bx, bx  ; x.size
142
        test    bx, bx  ; x.size
143
        je      .drectr
143
        je      .drectr
144
        test    cx, cx ; y.size
144
        test    cx, cx ; y.size
145
        je      .drectr
145
        je      .drectr
146
 
146
 
147
        mov     eax, ebx ; bad idea
147
        mov     eax, ebx ; bad idea
148
        mov     ebx, ecx
148
        mov     ebx, ecx
149
 
149
 
150
        movzx   ecx, ax ; ecx - x.size
150
        movzx   ecx, ax ; ecx - x.size
151
        shr     eax, 16 ; eax - x.coord
151
        shr     eax, 16 ; eax - x.coord
152
        movzx   edx, bx ; edx - y.size
152
        movzx   edx, bx ; edx - y.size
153
        shr     ebx, 16 ; ebx - y.coord
153
        shr     ebx, 16 ; ebx - y.coord
154
        mov     esi, [current_slot]
154
        mov     esi, [current_slot]
155
 
155
 
156
        add     eax, [esi + APPDATA.wnd_clientbox.left]
156
        add     eax, [esi + APPDATA.wnd_clientbox.left]
157
        add     ebx, [esi + APPDATA.wnd_clientbox.top]
157
        add     ebx, [esi + APPDATA.wnd_clientbox.top]
158
        add     ecx, eax
158
        add     ecx, eax
159
        add     edx, ebx
159
        add     edx, ebx
160
        jmp     vesa20_drawbar
160
        jmp     vesa20_drawbar
161
.drectr:
161
.drectr:
162
        ret
162
        ret
163
;------------------------------------------------------------------------------
163
;------------------------------------------------------------------------------
164
 
164
 
165
align 4
165
align 4
166
; system function 38
166
; system function 38
167
syscall_drawline:
167
syscall_drawline:
168
        mov     edi, [current_slot_idx]
168
        mov     edi, [current_slot_idx]
169
        shl     edi, BSF sizeof.WDATA
169
        shl     edi, BSF sizeof.WDATA
170
        movzx   eax, word[edi + window_data + WDATA.box.left]
170
        movzx   eax, word[edi + window_data + WDATA.box.left]
171
        mov     ebp, eax
171
        mov     ebp, eax
172
        mov     esi, [current_slot]
172
        mov     esi, [current_slot]
173
        add     ebp, [esi+APPDATA.wnd_clientbox.left]
173
        add     ebp, [esi+APPDATA.wnd_clientbox.left]
174
        add     ax, word[esi+APPDATA.wnd_clientbox.left]
174
        add     ax, word[esi+APPDATA.wnd_clientbox.left]
175
        add     ebp, ebx
175
        add     ebp, ebx
176
        shl     eax, 16
176
        shl     eax, 16
177
        movzx   ebx, word[edi + window_data + WDATA.box.top]
177
        movzx   ebx, word[edi + window_data + WDATA.box.top]
178
        add     eax, ebp
178
        add     eax, ebp
179
        mov     ebp, ebx
179
        mov     ebp, ebx
180
        add     ebp, [esi+APPDATA.wnd_clientbox.top]
180
        add     ebp, [esi+APPDATA.wnd_clientbox.top]
181
        add     bx, word[esi+APPDATA.wnd_clientbox.top]
181
        add     bx, word[esi+APPDATA.wnd_clientbox.top]
182
        add     ebp, ecx
182
        add     ebp, ecx
183
        shl     ebx, 16
183
        shl     ebx, 16
184
        xor     edi, edi
184
        xor     edi, edi
185
        add     ebx, ebp
185
        add     ebx, ebp
186
        mov     ecx, edx
186
        mov     ecx, edx
187
        jmp     __sys_draw_line
187
        jmp     __sys_draw_line
188
;------------------------------------------------------------------------------
188
;------------------------------------------------------------------------------
189
 
189
 
190
 
190
 
191
align 4
191
align 4
192
; system function 48 
192
; system function 48 
193
syscall_display_settings: 
193
syscall_display_settings: 
194
        cmp     ebx, 13
194
        cmp     ebx, 13
195
        ja      .ret
195
        ja      .ret
196
        jmp     dword[.ftable + ebx*4]
196
        jmp     dword[.ftable + ebx*4]
197
 
197
 
198
align 4
198
align 4
199
.ftable:
199
.ftable:
200
dd  .redrawWholeScreen
200
dd  .redrawWholeScreen
201
dd  .setButtonStyle
201
dd  .setButtonStyle
202
dd  .setSystemColors
202
dd  .setSystemColors
203
dd  .getSystemColors
203
dd  .getSystemColors
204
dd  .getCaptionHeight
204
dd  .getCaptionHeight
205
dd  .getScreenWorkingArea
205
dd  .getScreenWorkingArea
206
dd  .setScreenWorkingArea
206
dd  .setScreenWorkingArea
207
dd  .getSkinMargins
207
dd  .getSkinMargins
208
dd  .setSkin
208
dd  .setSkin
209
dd  .getFontSmoothing
209
dd  .getFontSmoothing
210
dd  .setFontSmoothing
210
dd  .setFontSmoothing
211
dd  .getFontSize
211
dd  .getFontSize
212
dd  .setFontSize
212
dd  .setFontSize
213
dd  .setSkinUnicode
213
dd  .setSkinUnicode
214
 
214
 
215
.redrawWholeScreen:
215
.redrawWholeScreen:
216
        xor     eax, eax
216
        xor     eax, eax
217
        inc     ebx
217
        inc     ebx
218
        cmp     [windowtypechanged], ebx
218
        cmp     [windowtypechanged], ebx
219
        jne     .ret
219
        jne     .ret
220
        mov     [windowtypechanged], eax
220
        mov     [windowtypechanged], eax
221
.redrawScreen:
221
.redrawScreen:
222
        xor     eax, eax
222
        xor     eax, eax
223
        mov     [draw_limits.left], eax
223
        mov     [draw_limits.left], eax
224
        mov     [draw_limits.top], eax
224
        mov     [draw_limits.top], eax
225
        mov     eax, [_display.width]
225
        mov     eax, [_display.width]
226
        dec     eax
226
        dec     eax
227
        mov     [draw_limits.right], eax
227
        mov     [draw_limits.right], eax
228
        mov     eax, [_display.height]
228
        mov     eax, [_display.height]
229
        dec     eax
229
        dec     eax
230
        mov     [draw_limits.bottom], eax
230
        mov     [draw_limits.bottom], eax
231
        mov     eax, window_data
231
        mov     eax, window_data
232
        jmp     redrawscreen
232
        jmp     redrawscreen
233
 
233
 
234
.setButtonStyle:
234
.setButtonStyle:
235
; in: ecx: 0 = flat, 1 = with gradient
235
; in: ecx: 0 = flat, 1 = with gradient
236
        and     ecx, 1
236
        and     ecx, 1
237
        cmp     ecx, [buttontype]
237
        cmp     ecx, [buttontype]
238
        je      .ret
238
        je      .ret
239
        mov     [buttontype], ecx
239
        mov     [buttontype], ecx
240
        mov     [windowtypechanged], ebx
240
        mov     [windowtypechanged], ebx
241
.ret:
241
.ret:
242
        ret
242
        ret
243
 
243
 
244
.setSystemColors:
244
.setSystemColors:
245
; in: ecx = pointer to color table, edx = size of color table
245
; in: ecx = pointer to color table, edx = size of color table
246
        dec     ebx
246
        dec     ebx
247
        mov     esi, ecx
247
        mov     esi, ecx
248
        cmp     edx, 192
248
        cmp     edx, 192
249
        jnae    @f
249
        jnae    @f
250
        mov     edx, 192 ; max size
250
        mov     edx, 192 ; max size
251
@@:
251
@@:
252
        stdcall is_region_userspace, esi, edx    ;
252
        stdcall is_region_userspace, esi, edx    ;
253
        jz      @f                               ;
253
        jz      @f                               ;
254
        ret                                      ;
254
        ret                                      ;
255
@@:
255
@@:
256
        mov     edi, common_colours
256
        mov     edi, common_colours
257
        mov     ecx, edx
257
        mov     ecx, edx
258
        rep movsb
258
        rep movsb
259
        mov     [windowtypechanged], ebx
259
        mov     [windowtypechanged], ebx
260
        ret
260
        ret
261
 
261
 
262
.getSystemColors:
262
.getSystemColors:
263
; in: ecx = pointer to color table, edx = size of color table
263
; in: ecx = pointer to color table, edx = size of color table
264
        mov     edi, ecx
264
        mov     edi, ecx
265
        cmp     edx, 192
265
        cmp     edx, 192
266
        jnae    @f
266
        jnae    @f
267
        mov     edx, 192 ; max size
267
        mov     edx, 192 ; max size
268
@@:
268
@@:
269
        stdcall is_region_userspace, edi, edx
269
        stdcall is_region_userspace, edi, edx
270
        jz      @f
270
        jz      @f
271
        ret
271
        ret
272
@@:
272
@@:
273
        mov     esi, common_colours
273
        mov     esi, common_colours
274
        mov     ecx, edx
274
        mov     ecx, edx
275
        rep movsb
275
        rep movsb
276
        ret
276
        ret
277
 
277
 
278
.getCaptionHeight:
278
.getCaptionHeight:
279
        mov     eax, [_skinh]
279
        mov     eax, [_skinh]
280
        mov     [esp + 32], eax
280
        mov     [esp + SYSCALL_STACK.eax], eax
281
        ret
281
        ret
282
 
282
 
283
.getScreenWorkingArea:
283
.getScreenWorkingArea:
284
; out: eax = pack[left, right], ebx = pack[top, bottom]
284
; out: eax = pack[left, right], ebx = pack[top, bottom]
285
        mov     eax, [screen_workarea.left - 2]
285
        mov     eax, [screen_workarea.left - 2]
286
        mov     ax, word[screen_workarea.right]
286
        mov     ax, word[screen_workarea.right]
287
        mov     [esp + SYSCALL_STACK.eax], eax
287
        mov     [esp + SYSCALL_STACK.eax], eax
288
        mov     eax, [screen_workarea.top - 2]
288
        mov     eax, [screen_workarea.top - 2]
289
        mov     ax, word[screen_workarea.bottom]
289
        mov     ax, word[screen_workarea.bottom]
290
        mov     [esp + SYSCALL_STACK.ebx], eax
290
        mov     [esp + SYSCALL_STACK.ebx], eax
291
        ret
291
        ret
292
 
292
 
293
.setScreenWorkingArea:
293
.setScreenWorkingArea:
294
; in: ecx = pack[left, right], edx = pack[top, bottom]
294
; in: ecx = pack[left, right], edx = pack[top, bottom]
295
        xor     esi, esi
295
        xor     esi, esi
296
        mov     edi, [_display.width]
296
        mov     edi, [_display.width]
297
        dec     edi
297
        dec     edi
298
        mov     eax, ecx
298
        mov     eax, ecx
299
        movsx   ebx, ax
299
        movsx   ebx, ax
300
        sar     eax, 16
300
        sar     eax, 16
301
        cmp     eax, ebx
301
        cmp     eax, ebx
302
        jge     .check_horizontal
302
        jge     .check_horizontal
303
        inc     esi
303
        inc     esi
304
        or      eax, eax
304
        or      eax, eax
305
        jge     @f
305
        jge     @f
306
        xor     eax, eax
306
        xor     eax, eax
307
@@:
307
@@:
308
        mov     [screen_workarea.left], eax
308
        mov     [screen_workarea.left], eax
309
        cmp     ebx, edi
309
        cmp     ebx, edi
310
        jle     @f
310
        jle     @f
311
        mov     ebx, edi
311
        mov     ebx, edi
312
@@:
312
@@:
313
        mov     [screen_workarea.right], ebx
313
        mov     [screen_workarea.right], ebx
314
.check_horizontal:
314
.check_horizontal:
315
        mov     edi, [_display.height]
315
        mov     edi, [_display.height]
316
        dec     edi
316
        dec     edi
317
        mov     eax, edx
317
        mov     eax, edx
318
        movsx   ebx, ax
318
        movsx   ebx, ax
319
        sar     eax, 16
319
        sar     eax, 16
320
        cmp     eax, ebx
320
        cmp     eax, ebx
321
        jge     .check_if_redraw_needed
321
        jge     .check_if_redraw_needed
322
        inc     esi
322
        inc     esi
323
        or      eax, eax
323
        or      eax, eax
324
        jge     @f
324
        jge     @f
325
        xor     eax, eax
325
        xor     eax, eax
326
@@:
326
@@:
327
        mov     [screen_workarea.top], eax
327
        mov     [screen_workarea.top], eax
328
        cmp     ebx, edi
328
        cmp     ebx, edi
329
        jle     @f
329
        jle     @f
330
        mov     ebx, edi
330
        mov     ebx, edi
331
@@:
331
@@:
332
        mov     [screen_workarea.bottom], ebx
332
        mov     [screen_workarea.bottom], ebx
333
.check_if_redraw_needed:
333
.check_if_redraw_needed:
334
        or      esi, esi
334
        or      esi, esi
335
        jz      @f
335
        jz      @f
336
        call    repos_windows
336
        call    repos_windows
337
.calculateScreen:
337
.calculateScreen:
338
        xor     eax, eax
338
        xor     eax, eax
339
        xor     ebx, ebx
339
        xor     ebx, ebx
340
        mov     ecx, [_display.width]
340
        mov     ecx, [_display.width]
341
        mov     edx, [_display.height]
341
        mov     edx, [_display.height]
342
        dec     ecx
342
        dec     ecx
343
        dec     edx
343
        dec     edx
344
        jmp     calculatescreen
344
        jmp     calculatescreen
345
 
345
 
346
.getSkinMargins:
346
.getSkinMargins:
347
; out: eax = pack[left, right], ebx = pack[top, bottom]
347
; out: eax = pack[left, right], ebx = pack[top, bottom]
348
        mov     eax, [_skinmargins + 0]
348
        mov     eax, [_skinmargins + 0]
349
        mov     [esp + SYSCALL_STACK.eax], eax
349
        mov     [esp + SYSCALL_STACK.eax], eax
350
        mov     eax, [_skinmargins + 4]
350
        mov     eax, [_skinmargins + 4]
351
        mov     [esp + SYSCALL_STACK.ebx], eax
351
        mov     [esp + SYSCALL_STACK.ebx], eax
352
        ret
352
        ret
353
 
353
 
354
.setSkin:
354
.setSkin:
355
; in: ecx -> file path string
355
; in: ecx -> file path string
356
        mov     ebx, ecx
356
        mov     ebx, ecx
357
        call    read_skin_file
357
        call    read_skin_file
358
        mov     [esp + SYSCALL_STACK.eax], eax
358
        mov     [esp + SYSCALL_STACK.eax], eax
359
        test    eax, eax
359
        test    eax, eax
360
        jnz     .ret
360
        jnz     .ret
361
        call    .calculateScreen
361
        call    .calculateScreen
362
        jmp     .redrawScreen
362
        jmp     .redrawScreen
363
 
363
 
364
.getFontSmoothing:
364
.getFontSmoothing:
365
        xor     eax, eax
365
        xor     eax, eax
366
        mov     al, [fontSmoothing]
366
        mov     al, [fontSmoothing]
367
        mov     [esp + SYSCALL_STACK.eax], eax
367
        mov     [esp + SYSCALL_STACK.eax], eax
368
        ret
368
        ret
369
 
369
 
370
.setFontSmoothing:
370
.setFontSmoothing:
371
        mov     [fontSmoothing], cl
371
        mov     [fontSmoothing], cl
372
        ret
372
        ret
373
 
373
 
374
.getFontSize:
374
.getFontSize:
375
        xor     eax, eax
375
        xor     eax, eax
376
        mov     al, [fontSize]
376
        mov     al, [fontSize]
377
        mov     [esp + SYSCALL_STACK.eax], eax
377
        mov     [esp + SYSCALL_STACK.eax], eax
378
        ret
378
        ret
379
 
379
 
380
.setFontSize:
380
.setFontSize:
381
        mov     [fontSize], cl
381
        mov     [fontSize], cl
382
        ret
382
        ret
383
 
383
 
384
.setSkinUnicode:
384
.setSkinUnicode:
385
; in: ecx -> file path string, edx = string encoding
385
; in: ecx -> file path string, edx = string encoding
386
        push    ecx edx
386
        push    ecx edx
387
        stdcall kernel_alloc, maxPathLength
387
        stdcall kernel_alloc, maxPathLength
388
        mov     edi, eax
388
        mov     edi, eax
389
        pop     eax esi
389
        pop     eax esi
390
        push    edi
390
        push    edi
391
        call    getFullPath
391
        call    getFullPath
392
        test    eax, eax
392
        test    eax, eax
393
        jz      @f
393
        jz      @f
394
        mov     ebx, [esp]
394
        mov     ebx, [esp]
395
        call    read_skin_file
395
        call    read_skin_file
396
        mov     [esp + SYSCALL_STACK.eax + 4], eax
396
        mov     [esp + SYSCALL_STACK.eax + 4], eax
397
@@:
397
@@:
398
        call    kernel_free
398
        call    kernel_free
399
        call    .calculateScreen
399
        call    .calculateScreen
400
        jmp     .redrawScreen
400
        jmp     .redrawScreen
401
 
401
 
402
;------------------------------------------------------------------------------
402
;------------------------------------------------------------------------------
403
 
403
 
404
align 4
404
align 4
405
; system function 50
405
; system function 50
406
;; Set window shape address:
406
;; Set window shape address:
407
;> ebx = 0
407
;> ebx = 0
408
;> ecx = shape data address
408
;> ecx = shape data address
409
; --------------------------
409
; --------------------------
410
;; Set window shape scale:
410
;; Set window shape scale:
411
;> ebx = 1
411
;> ebx = 1
412
;> ecx = scale power (resulting scale is 2^ebx)
412
;> ecx = scale power (resulting scale is 2^ebx)
413
syscall_set_window_shape: 
413
syscall_set_window_shape: 
414
        mov     edi, [current_slot]
414
        mov     edi, [current_slot]
415
 
415
 
416
        test    ebx, ebx
416
        test    ebx, ebx
417
        jne     .shape_scale
417
        jne     .shape_scale
418
        mov     [edi + APPDATA.wnd_shape], ecx
418
        mov     [edi + APPDATA.wnd_shape], ecx
419
;--------------------------------------
419
;--------------------------------------
420
align 4
420
align 4
421
.shape_scale:
421
.shape_scale:
422
        dec     ebx
422
        dec     ebx
423
        jnz     .exit
423
        jnz     .exit
424
        mov     [edi + APPDATA.wnd_shape_scale], ecx
424
        mov     [edi + APPDATA.wnd_shape_scale], ecx
425
;--------------------------------------
425
;--------------------------------------
426
align 4
426
align 4
427
.exit:
427
.exit:
428
        ret
428
        ret
429
;------------------------------------------------------------------------------
429
;------------------------------------------------------------------------------
430
 
430
 
431
align 4
431
align 4
432
;     system function 67 
432
;     system function 67 
433
syscall_move_window: 
433
syscall_move_window: 
434
        mov     edi, [current_slot_idx]
434
        mov     edi, [current_slot_idx]
435
        shl     edi, BSF sizeof.WDATA
435
        shl     edi, BSF sizeof.WDATA
436
        add     edi, window_data
436
        add     edi, window_data
437
 
437
 
438
        test    [edi + WDATA.fl_wdrawn], 1
438
        test    [edi + WDATA.fl_wdrawn], 1
439
        jz      .exit
439
        jz      .exit
440
 
440
 
441
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
441
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
442
        jnz     .exit
442
        jnz     .exit
443
 
443
 
444
        cmp     ebx, -1
444
        cmp     ebx, -1
445
        jne     @f
445
        jne     @f
446
        mov     ebx, [edi + WDATA.box.left]
446
        mov     ebx, [edi + WDATA.box.left]
447
;--------------------------------------
447
;--------------------------------------
448
align 4
448
align 4
449
@@:
449
@@:
450
        cmp     ecx, -1
450
        cmp     ecx, -1
451
        jne     @f
451
        jne     @f
452
        mov     ecx, [edi + WDATA.box.top]
452
        mov     ecx, [edi + WDATA.box.top]
453
;--------------------------------------
453
;--------------------------------------
454
align 4
454
align 4
455
@@:
455
@@:
456
        cmp     edx, -1
456
        cmp     edx, -1
457
        jne     @f
457
        jne     @f
458
        mov     edx, [edi + WDATA.box.width]
458
        mov     edx, [edi + WDATA.box.width]
459
;--------------------------------------
459
;--------------------------------------
460
align 4
460
align 4
461
@@:
461
@@:
462
        cmp     esi, -1
462
        cmp     esi, -1
463
        jne     @f
463
        jne     @f
464
        mov     esi, [edi + WDATA.box.height]
464
        mov     esi, [edi + WDATA.box.height]
465
;--------------------------------------
465
;--------------------------------------
466
align 4
466
align 4
467
@@:
467
@@:
468
        push    esi edx ecx ebx
468
        push    esi edx ecx ebx
469
        mov     eax, esp
469
        mov     eax, esp
470
        mov     bl, [edi + WDATA.fl_wstate]
470
        mov     bl, [edi + WDATA.fl_wstate]
471
;--------------------------------------
471
;--------------------------------------
472
align 4
472
align 4
473
@@:
473
@@:
474
        cmp     [REDRAW_BACKGROUND], byte 0
474
        cmp     [REDRAW_BACKGROUND], byte 0
475
        jz      @f
475
        jz      @f
476
        call    change_task
476
        call    change_task
477
        jmp     @b
477
        jmp     @b
478
;--------------------------------------
478
;--------------------------------------
479
align 4
479
align 4
480
@@:
480
@@:
481
        call    window._.set_window_box
481
        call    window._.set_window_box
482
        add     esp, sizeof.BOX
482
        add     esp, sizeof.BOX
483
 
483
 
484
.exit:
484
.exit:
485
        ret
485
        ret
486
;------------------------------------------------------------------------------
486
;------------------------------------------------------------------------------
487
 
487
 
488
; system function 71
488
; system function 71
489
syscall_window_settings: 
489
syscall_window_settings: 
490
        mov     edi, [current_slot_idx]
490
        mov     edi, [current_slot_idx]
491
        shl     edi, BSF sizeof.WDATA
491
        shl     edi, BSF sizeof.WDATA
492
        or      [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
492
        or      [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
493
        cmp     ebx, 2
493
        cmp     ebx, 2
494
        jz      @f
494
        jz      @f
495
        xor     edx, edx
495
        xor     edx, edx
496
@@:
496
@@:
497
        cmp     dl, 4
497
        cmp     dl, 4
498
        jc      @f
498
        jc      @f
499
        xor     edx, edx
499
        xor     edx, edx
500
@@:
500
@@:
501
        mov     [edi*8 + SLOT_BASE + APPDATA.wnd_caption], ecx
501
        mov     [edi*8 + SLOT_BASE + APPDATA.wnd_caption], ecx
502
        mov     [edi*8 + SLOT_BASE + APPDATA.captionEncoding], dl
502
        mov     [edi*8 + SLOT_BASE + APPDATA.captionEncoding], dl
503
        jmp     window._.draw_window_caption
503
        jmp     window._.draw_window_caption
504
;------------------------------------------------------------------------------
504
;------------------------------------------------------------------------------
505
 
505
 
506
align 4
506
align 4
507
set_window_defaults:
507
set_window_defaults:
508
        mov     byte [window_data + sizeof.WDATA + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
508
        mov     byte [window_data + sizeof.WDATA + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
509
        push    eax ecx
509
        push    eax ecx
510
        xor     eax, eax
510
        xor     eax, eax
511
        mov     ecx, WIN_STACK
511
        mov     ecx, WIN_STACK
512
;--------------------------------------
512
;--------------------------------------
513
align 4
513
align 4
514
@@:
514
@@:
515
        inc     eax
515
        inc     eax
516
        add     ecx, 2
516
        add     ecx, 2
517
        ; process no
517
        ; process no
518
        mov     [ecx + 0x000], ax
518
        mov     [ecx + 0x000], ax
519
        ; positions in stack
519
        ; positions in stack
520
        mov     [ecx + 0x400], ax
520
        mov     [ecx + 0x400], ax
521
        cmp     ecx, WIN_POS - 2
521
        cmp     ecx, WIN_POS - 2
522
        jne     @b
522
        jne     @b
523
        pop     ecx eax
523
        pop     ecx eax
524
        ret
524
        ret
525
;------------------------------------------------------------------------------
525
;------------------------------------------------------------------------------
526
 
526
 
527
align 4
527
align 4
528
;? Scan all windows from bottom to top, calling `setscreen` for each one
528
;? Scan all windows from bottom to top, calling `setscreen` for each one
529
;? intersecting given screen area
529
;? intersecting given screen area
530
;> eax = left
530
;> eax = left
531
;> ebx = top
531
;> ebx = top
532
;> ecx = right
532
;> ecx = right
533
;> edx = bottom
533
;> edx = bottom
534
calculatescreen:
534
calculatescreen:
535
        push    esi
535
        push    esi
536
        pushfd
536
        pushfd
537
        cli
537
        cli
538
 
538
 
539
        mov     esi, 1
539
        mov     esi, 1
540
        call    window._.set_screen
540
        call    window._.set_screen
541
 
541
 
542
        push    ebp
542
        push    ebp
543
 
543
 
544
        mov     ebp, [thread_count]
544
        mov     ebp, [thread_count]
545
        cmp     ebp, 1
545
        cmp     ebp, 1
546
        jbe     .exit
546
        jbe     .exit
547
 
547
 
548
        push    eax ;for num layout
548
        push    eax ;for num layout
549
 
549
 
550
        push    edx ecx ebx eax
550
        push    edx ecx ebx eax
551
 
551
 
552
        mov     dword[esp+10h], ZPOS_DESKTOP
552
        mov     dword[esp+10h], ZPOS_DESKTOP
553
;--------------------------------------
553
;--------------------------------------
554
align 4
554
align 4
555
.layout:
555
.layout:
556
        mov     esi, 1          ; = num in window stack
556
        mov     esi, 1          ; = num in window stack
557
        mov     ebp, [thread_count]
557
        mov     ebp, [thread_count]
558
;--------------------------------------
558
;--------------------------------------
559
align 4
559
align 4
560
.next_window:
560
.next_window:
561
        movzx   edi, word[WIN_POS + esi * 2]
561
        movzx   edi, word[WIN_POS + esi * 2]
562
        shl     edi, BSF sizeof.WDATA        ;size of TASKDATA and WDATA = 32 bytes
562
        shl     edi, BSF sizeof.WDATA        ;size of TASKDATA and WDATA = 32 bytes
563
 
563
 
564
        cmp     byte [SLOT_BASE + edi*8 + APPDATA.state], TSTATE_FREE
564
        cmp     byte [SLOT_BASE + edi*8 + APPDATA.state], TSTATE_FREE
565
        je      .skip_window
565
        je      .skip_window
566
 
566
 
567
        add     edi, window_data
567
        add     edi, window_data
568
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
568
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
569
        jnz     .skip_window
569
        jnz     .skip_window
570
 
570
 
571
        mov     eax, [esp+10h]
571
        mov     eax, [esp+10h]
572
        cmp     [edi + WDATA.z_modif], al
572
        cmp     [edi + WDATA.z_modif], al
573
        jne     .skip_window
573
        jne     .skip_window
574
 
574
 
575
        mov     eax, [edi + WDATA.box.left]
575
        mov     eax, [edi + WDATA.box.left]
576
        cmp     eax, [esp + RECT.right]
576
        cmp     eax, [esp + RECT.right]
577
        jg      .skip_window
577
        jg      .skip_window
578
        mov     ebx, [edi + WDATA.box.top]
578
        mov     ebx, [edi + WDATA.box.top]
579
        cmp     ebx, [esp + RECT.bottom]
579
        cmp     ebx, [esp + RECT.bottom]
580
        jg      .skip_window
580
        jg      .skip_window
581
        mov     ecx, [edi + WDATA.box.width]
581
        mov     ecx, [edi + WDATA.box.width]
582
        add     ecx, eax
582
        add     ecx, eax
583
        cmp     ecx, [esp + RECT.left]
583
        cmp     ecx, [esp + RECT.left]
584
        jl      .skip_window
584
        jl      .skip_window
585
        mov     edx, [edi + WDATA.box.height]
585
        mov     edx, [edi + WDATA.box.height]
586
        add     edx, ebx
586
        add     edx, ebx
587
        cmp     edx, [esp + RECT.top]
587
        cmp     edx, [esp + RECT.top]
588
        jl      .skip_window
588
        jl      .skip_window
589
 
589
 
590
        cmp     eax, [esp + RECT.left]
590
        cmp     eax, [esp + RECT.left]
591
        jae     @f
591
        jae     @f
592
        mov     eax, [esp + RECT.left]
592
        mov     eax, [esp + RECT.left]
593
;--------------------------------------
593
;--------------------------------------
594
align 4
594
align 4
595
@@:
595
@@:
596
        cmp     ebx, [esp + RECT.top]
596
        cmp     ebx, [esp + RECT.top]
597
        jae     @f
597
        jae     @f
598
        mov     ebx, [esp + RECT.top]
598
        mov     ebx, [esp + RECT.top]
599
;--------------------------------------
599
;--------------------------------------
600
align 4
600
align 4
601
@@:
601
@@:
602
        cmp     ecx, [esp + RECT.right]
602
        cmp     ecx, [esp + RECT.right]
603
        jbe     @f
603
        jbe     @f
604
        mov     ecx, [esp + RECT.right]
604
        mov     ecx, [esp + RECT.right]
605
;--------------------------------------
605
;--------------------------------------
606
align 4
606
align 4
607
@@:
607
@@:
608
        cmp     edx, [esp + RECT.bottom]
608
        cmp     edx, [esp + RECT.bottom]
609
        jbe     @f
609
        jbe     @f
610
        mov     edx, [esp + RECT.bottom]
610
        mov     edx, [esp + RECT.bottom]
611
;--------------------------------------
611
;--------------------------------------
612
align 4
612
align 4
613
@@:
613
@@:
614
        push    esi
614
        push    esi
615
        movzx   esi, word[WIN_POS + esi * 2]
615
        movzx   esi, word[WIN_POS + esi * 2]
616
        call    window._.set_screen
616
        call    window._.set_screen
617
        pop     esi
617
        pop     esi
618
;--------------------------------------
618
;--------------------------------------
619
align 4
619
align 4
620
.skip_window:
620
.skip_window:
621
        inc     esi
621
        inc     esi
622
        dec     ebp
622
        dec     ebp
623
        jnz     .next_window
623
        jnz     .next_window
624
;---------------------------------------------
624
;---------------------------------------------
625
        inc     dword[esp+10h]
625
        inc     dword[esp+10h]
626
        cmp     dword[esp+10h], ZPOS_ALWAYS_TOP
626
        cmp     dword[esp+10h], ZPOS_ALWAYS_TOP
627
        jle     .layout
627
        jle     .layout
628
;---------------------------------------------
628
;---------------------------------------------
629
        mov     esi, [thread_count]
629
        mov     esi, [thread_count]
630
        movzx   edi, word[WIN_POS + esi * 2]
630
        movzx   edi, word[WIN_POS + esi * 2]
631
        shl     edi, BSF sizeof.WDATA
631
        shl     edi, BSF sizeof.WDATA
632
        add     edi, window_data
632
        add     edi, window_data
633
 
633
 
634
        pop     eax ebx ecx edx
634
        pop     eax ebx ecx edx
635
        pop     ebp     ;del num layout
635
        pop     ebp     ;del num layout
636
;--------------------------------------
636
;--------------------------------------
637
align 4
637
align 4
638
.exit:
638
.exit:
639
        pop     ebp
639
        pop     ebp
640
        inc     [_display.mask_seqno]
640
        inc     [_display.mask_seqno]
641
        popfd
641
        popfd
642
        pop     esi
642
        pop     esi
643
        ret
643
        ret
644
;------------------------------------------------------------------------------
644
;------------------------------------------------------------------------------
645
 
645
 
646
 
646
 
647
align 4
647
align 4
648
repos_windows:
648
repos_windows:
649
        mov     ecx, [thread_count]
649
        mov     ecx, [thread_count]
650
        mov     edi, window_data + sizeof.WDATA * 2
650
        mov     edi, window_data + sizeof.WDATA * 2
651
        call    force_redraw_background
651
        call    force_redraw_background
652
        dec     ecx
652
        dec     ecx
653
        jle     .exit
653
        jle     .exit
654
;--------------------------------------
654
;--------------------------------------
655
align 4
655
align 4
656
.next_window:
656
.next_window:
657
        mov     [edi + WDATA.fl_redraw], 1
657
        mov     [edi + WDATA.fl_redraw], 1
658
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
658
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
659
        jnz     .fix_maximized
659
        jnz     .fix_maximized
660
 
660
 
661
        mov     eax, [edi + WDATA.box.left]
661
        mov     eax, [edi + WDATA.box.left]
662
        add     eax, [edi + WDATA.box.width]
662
        add     eax, [edi + WDATA.box.width]
663
        mov     ebx, [_display.width]
663
        mov     ebx, [_display.width]
664
        cmp     eax, ebx
664
        cmp     eax, ebx
665
        jl      .fix_vertical
665
        jl      .fix_vertical
666
        mov     eax, [edi + WDATA.box.width]
666
        mov     eax, [edi + WDATA.box.width]
667
        sub     eax, ebx
667
        sub     eax, ebx
668
        jl      @f
668
        jl      @f
669
        mov     [edi + WDATA.box.width], ebx
669
        mov     [edi + WDATA.box.width], ebx
670
;--------------------------------------
670
;--------------------------------------
671
align 4
671
align 4
672
@@:
672
@@:
673
        sub     ebx, [edi + WDATA.box.width]
673
        sub     ebx, [edi + WDATA.box.width]
674
        mov     [edi + WDATA.box.left], ebx
674
        mov     [edi + WDATA.box.left], ebx
675
;--------------------------------------
675
;--------------------------------------
676
align 4
676
align 4
677
.fix_vertical:
677
.fix_vertical:
678
        mov     eax, [edi + WDATA.box.top]
678
        mov     eax, [edi + WDATA.box.top]
679
        add     eax, [edi + WDATA.box.height]
679
        add     eax, [edi + WDATA.box.height]
680
        mov     ebx, [_display.height]
680
        mov     ebx, [_display.height]
681
        cmp     eax, ebx
681
        cmp     eax, ebx
682
        jl      .fix_client_box
682
        jl      .fix_client_box
683
        mov     eax, [edi + WDATA.box.height]
683
        mov     eax, [edi + WDATA.box.height]
684
        sub     eax, ebx
684
        sub     eax, ebx
685
        jl      @f
685
        jl      @f
686
        mov     [edi + WDATA.box.height], ebx
686
        mov     [edi + WDATA.box.height], ebx
687
;--------------------------------------
687
;--------------------------------------
688
align 4
688
align 4
689
@@:
689
@@:
690
        sub     ebx, [edi + WDATA.box.height]
690
        sub     ebx, [edi + WDATA.box.height]
691
        mov     [edi + WDATA.box.top], ebx
691
        mov     [edi + WDATA.box.top], ebx
692
;--------------------------------------
692
;--------------------------------------
693
align 4
693
align 4
694
.fix_client_box:
694
.fix_client_box:
695
        call    window._.set_window_clientbox
695
        call    window._.set_window_clientbox
696
        add     edi, sizeof.WDATA
696
        add     edi, sizeof.WDATA
697
        loop    .next_window
697
        loop    .next_window
698
;--------------------------------------
698
;--------------------------------------
699
align 4
699
align 4
700
.exit:
700
.exit:
701
        ret
701
        ret
702
;--------------------------------------
702
;--------------------------------------
703
align 4
703
align 4
704
.fix_maximized:
704
.fix_maximized:
705
        mov     eax, [screen_workarea.left]
705
        mov     eax, [screen_workarea.left]
706
        mov     [edi + WDATA.box.left], eax
706
        mov     [edi + WDATA.box.left], eax
707
        sub     eax, [screen_workarea.right]
707
        sub     eax, [screen_workarea.right]
708
        neg     eax
708
        neg     eax
709
        mov     [edi + WDATA.box.width], eax
709
        mov     [edi + WDATA.box.width], eax
710
        mov     eax, [screen_workarea.top]
710
        mov     eax, [screen_workarea.top]
711
        mov     [edi + WDATA.box.top], eax
711
        mov     [edi + WDATA.box.top], eax
712
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
712
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
713
        jnz     .fix_client_box
713
        jnz     .fix_client_box
714
        sub     eax, [screen_workarea.bottom]
714
        sub     eax, [screen_workarea.bottom]
715
        neg     eax
715
        neg     eax
716
        mov     [edi + WDATA.box.height], eax
716
        mov     [edi + WDATA.box.height], eax
717
        jmp     .fix_client_box
717
        jmp     .fix_client_box
718
;------------------------------------------------------------------------------
718
;------------------------------------------------------------------------------
719
 
719
 
720
 
720
 
721
align 4
721
align 4
722
;> eax = pack[16(left), 16(right)]
722
;> eax = pack[16(left), 16(right)]
723
;> ebx = pack[16(top), 16(bottom)]
723
;> ebx = pack[16(top), 16(bottom)]
724
;> esi = color
724
;> esi = color
725
;       ?? RR GG BB    ; 0x01000000 negation
725
;       ?? RR GG BB    ; 0x01000000 negation
726
;                      ; 0x02000000 used for draw_rectangle without top line
726
;                      ; 0x02000000 used for draw_rectangle without top line
727
;                      ;           for example drawwindow_III and drawwindow_IV
727
;                      ;           for example drawwindow_III and drawwindow_IV
728
draw_rectangle:
728
draw_rectangle:
729
        push    eax ebx ecx edi
729
        push    eax ebx ecx edi
730
 
730
 
731
        xor     edi, edi
731
        xor     edi, edi
732
;--------------------------------------
732
;--------------------------------------
733
align 4
733
align 4
734
.flags_set:
734
.flags_set:
735
        push    ebx
735
        push    ebx
736
 
736
 
737
        ; set line color
737
        ; set line color
738
        mov     ecx, esi
738
        mov     ecx, esi
739
        ; draw top border
739
        ; draw top border
740
        rol     ebx, 16
740
        rol     ebx, 16
741
        push    ebx
741
        push    ebx
742
        rol     ebx, 16
742
        rol     ebx, 16
743
        pop     bx
743
        pop     bx
744
        test    ecx, 1 shl 25
744
        test    ecx, 1 shl 25
745
        jnz     @f
745
        jnz     @f
746
        sub     ecx, 1 shl 25
746
        sub     ecx, 1 shl 25
747
;        call    [draw_line]
747
;        call    [draw_line]
748
        call    __sys_draw_line
748
        call    __sys_draw_line
749
;--------------------------------------
749
;--------------------------------------
750
align 4
750
align 4
751
@@:
751
@@:
752
        ; draw bottom border
752
        ; draw bottom border
753
        mov     ebx, [esp - 2]
753
        mov     ebx, [esp - 2]
754
        pop     bx
754
        pop     bx
755
;        call    [draw_line]
755
;        call    [draw_line]
756
        call    __sys_draw_line
756
        call    __sys_draw_line
757
 
757
 
758
        pop     ebx
758
        pop     ebx
759
        add     ebx, 1 * 65536 - 1
759
        add     ebx, 1 * 65536 - 1
760
 
760
 
761
        ; draw left border
761
        ; draw left border
762
        rol     eax, 16
762
        rol     eax, 16
763
        push    eax
763
        push    eax
764
        rol     eax, 16
764
        rol     eax, 16
765
        pop     ax
765
        pop     ax
766
;        call    [draw_line]
766
;        call    [draw_line]
767
        call    __sys_draw_line
767
        call    __sys_draw_line
768
 
768
 
769
        ; draw right border
769
        ; draw right border
770
        mov     eax, [esp - 2]
770
        mov     eax, [esp - 2]
771
        pop     ax
771
        pop     ax
772
;        call    [draw_line]
772
;        call    [draw_line]
773
        call    __sys_draw_line
773
        call    __sys_draw_line
774
 
774
 
775
        pop     edi ecx ebx eax
775
        pop     edi ecx ebx eax
776
        ret
776
        ret
777
;--------------------------------------
777
;--------------------------------------
778
align 4
778
align 4
779
.forced:
779
.forced:
780
        push    eax ebx ecx edi
780
        push    eax ebx ecx edi
781
        xor     edi, edi
781
        xor     edi, edi
782
        inc     edi
782
        inc     edi
783
        jmp     .flags_set
783
        jmp     .flags_set
784
;------------------------------------------------------------------------------
784
;------------------------------------------------------------------------------
785
 
785
 
786
 
786
 
787
align 4
787
align 4
788
drawwindow_I_caption:
788
drawwindow_I_caption:
789
        push    [edx + WDATA.cl_titlebar]
789
        push    [edx + WDATA.cl_titlebar]
790
        mov     esi, edx
790
        mov     esi, edx
791
 
791
 
792
        mov     edx, [esi + WDATA.box.top]
792
        mov     edx, [esi + WDATA.box.top]
793
        mov     eax, edx
793
        mov     eax, edx
794
        lea     ebx, [edx + 21]
794
        lea     ebx, [edx + 21]
795
        inc     edx
795
        inc     edx
796
        add     eax, [esi + WDATA.box.height]
796
        add     eax, [esi + WDATA.box.height]
797
 
797
 
798
        cmp     ebx, eax
798
        cmp     ebx, eax
799
        jbe     @f
799
        jbe     @f
800
        mov     ebx, eax
800
        mov     ebx, eax
801
;--------------------------------------
801
;--------------------------------------
802
align 4
802
align 4
803
@@:
803
@@:
804
        push    ebx
804
        push    ebx
805
 
805
 
806
        xor     edi, edi
806
        xor     edi, edi
807
;--------------------------------------
807
;--------------------------------------
808
align 4
808
align 4
809
.next_line:
809
.next_line:
810
        mov     ebx, edx
810
        mov     ebx, edx
811
        shl     ebx, 16
811
        shl     ebx, 16
812
        add     ebx, edx
812
        add     ebx, edx
813
        mov     eax, [esi + WDATA.box.left]
813
        mov     eax, [esi + WDATA.box.left]
814
        inc     eax
814
        inc     eax
815
        shl     eax, 16
815
        shl     eax, 16
816
        add     eax, [esi + WDATA.box.left]
816
        add     eax, [esi + WDATA.box.left]
817
        add     eax, [esi + WDATA.box.width]
817
        add     eax, [esi + WDATA.box.width]
818
        dec     eax
818
        dec     eax
819
        mov     ecx, [esi + WDATA.cl_titlebar]
819
        mov     ecx, [esi + WDATA.cl_titlebar]
820
        test    ecx, 0x80000000
820
        test    ecx, 0x80000000
821
        jz      @f
821
        jz      @f
822
        sub     ecx, 0x00040404
822
        sub     ecx, 0x00040404
823
        mov     [esi + WDATA.cl_titlebar], ecx
823
        mov     [esi + WDATA.cl_titlebar], ecx
824
;--------------------------------------
824
;--------------------------------------
825
align 4
825
align 4
826
@@:
826
@@:
827
        and     ecx, 0x00ffffff
827
        and     ecx, 0x00ffffff
828
;        call    [draw_line]
828
;        call    [draw_line]
829
        call    __sys_draw_line
829
        call    __sys_draw_line
830
        inc     edx
830
        inc     edx
831
        cmp     edx, [esp]
831
        cmp     edx, [esp]
832
        jb      .next_line
832
        jb      .next_line
833
 
833
 
834
        add     esp, 4
834
        add     esp, 4
835
        pop     [esi + WDATA.cl_titlebar]
835
        pop     [esi + WDATA.cl_titlebar]
836
        ret
836
        ret
837
;------------------------------------------------------------------------------
837
;------------------------------------------------------------------------------
838
 
838
 
839
 
839
 
840
align 4
840
align 4
841
drawwindow_I:
841
drawwindow_I:
842
        pushad
842
        pushad
843
 
843
 
844
        ; window border
844
        ; window border
845
 
845
 
846
        mov     eax, [edx + WDATA.box.left - 2]
846
        mov     eax, [edx + WDATA.box.left - 2]
847
        mov     ax, word[edx + WDATA.box.left]
847
        mov     ax, word[edx + WDATA.box.left]
848
        add     ax, word[edx + WDATA.box.width]
848
        add     ax, word[edx + WDATA.box.width]
849
        mov     ebx, [edx + WDATA.box.top - 2]
849
        mov     ebx, [edx + WDATA.box.top - 2]
850
        mov     bx, word[edx + WDATA.box.top]
850
        mov     bx, word[edx + WDATA.box.top]
851
        add     bx, word[edx + WDATA.box.height]
851
        add     bx, word[edx + WDATA.box.height]
852
 
852
 
853
        mov     esi, [edx + WDATA.cl_frames]
853
        mov     esi, [edx + WDATA.cl_frames]
854
        call    draw_rectangle
854
        call    draw_rectangle
855
 
855
 
856
        ; window caption
856
        ; window caption
857
 
857
 
858
        call    drawwindow_I_caption
858
        call    drawwindow_I_caption
859
 
859
 
860
        ; window client area
860
        ; window client area
861
 
861
 
862
        ; do we need to draw it?
862
        ; do we need to draw it?
863
        mov     edi, [esi + WDATA.cl_workarea]
863
        mov     edi, [esi + WDATA.cl_workarea]
864
        test    edi, 0x40000000
864
        test    edi, 0x40000000
865
        jnz     .exit
865
        jnz     .exit
866
 
866
 
867
        ; does client area have a positive size on screen?
867
        ; does client area have a positive size on screen?
868
        cmp     [esi + WDATA.box.height], 21
868
        cmp     [esi + WDATA.box.height], 21
869
        jle     .exit
869
        jle     .exit
870
 
870
 
871
        ; okay, let's draw it
871
        ; okay, let's draw it
872
        mov     eax, 1
872
        mov     eax, 1
873
        mov     ebx, 21
873
        mov     ebx, 21
874
        mov     ecx, [esi + WDATA.box.width]
874
        mov     ecx, [esi + WDATA.box.width]
875
        mov     edx, [esi + WDATA.box.height]
875
        mov     edx, [esi + WDATA.box.height]
876
;        call    [drawbar]
876
;        call    [drawbar]
877
        call    vesa20_drawbar
877
        call    vesa20_drawbar
878
;--------------------------------------
878
;--------------------------------------
879
align 4
879
align 4
880
.exit:
880
.exit:
881
        popad
881
        popad
882
        ret
882
        ret
883
;------------------------------------------------------------------------------
883
;------------------------------------------------------------------------------
884
 
884
 
885
 
885
 
886
align 4
886
align 4
887
drawwindow_III_caption:
887
drawwindow_III_caption:
888
        mov     ecx, [edx + WDATA.cl_titlebar]
888
        mov     ecx, [edx + WDATA.cl_titlebar]
889
        push    ecx
889
        push    ecx
890
        mov     esi, edx
890
        mov     esi, edx
891
        mov     edx, [esi + WDATA.box.top]
891
        mov     edx, [esi + WDATA.box.top]
892
        add     edx, 4
892
        add     edx, 4
893
        mov     ebx, [esi + WDATA.box.top]
893
        mov     ebx, [esi + WDATA.box.top]
894
        add     ebx, 20
894
        add     ebx, 20
895
        mov     eax, [esi + WDATA.box.top]
895
        mov     eax, [esi + WDATA.box.top]
896
        add     eax, [esi + WDATA.box.height]
896
        add     eax, [esi + WDATA.box.height]
897
 
897
 
898
        cmp     ebx, eax
898
        cmp     ebx, eax
899
        jb      @f
899
        jb      @f
900
        mov     ebx, eax
900
        mov     ebx, eax
901
;--------------------------------------
901
;--------------------------------------
902
align 4
902
align 4
903
@@:
903
@@:
904
        push    ebx
904
        push    ebx
905
 
905
 
906
        xor     edi, edi
906
        xor     edi, edi
907
;--------------------------------------
907
;--------------------------------------
908
align 4
908
align 4
909
.next_line:
909
.next_line:
910
        mov     ebx, edx
910
        mov     ebx, edx
911
        shl     ebx, 16
911
        shl     ebx, 16
912
        add     ebx, edx
912
        add     ebx, edx
913
        mov     eax, [esi + WDATA.box.left]
913
        mov     eax, [esi + WDATA.box.left]
914
        shl     eax, 16
914
        shl     eax, 16
915
        add     eax, [esi + WDATA.box.left]
915
        add     eax, [esi + WDATA.box.left]
916
        add     eax, [esi + WDATA.box.width]
916
        add     eax, [esi + WDATA.box.width]
917
        add     eax, 4 * 65536 - 4
917
        add     eax, 4 * 65536 - 4
918
        mov     ecx, [esi + WDATA.cl_titlebar]
918
        mov     ecx, [esi + WDATA.cl_titlebar]
919
        test    ecx, 0x40000000
919
        test    ecx, 0x40000000
920
        jz      @f
920
        jz      @f
921
        add     ecx, 0x00040404
921
        add     ecx, 0x00040404
922
;--------------------------------------
922
;--------------------------------------
923
align 4
923
align 4
924
@@:
924
@@:
925
        test    ecx, 0x80000000
925
        test    ecx, 0x80000000
926
        jz      @f
926
        jz      @f
927
        sub     ecx, 0x00040404
927
        sub     ecx, 0x00040404
928
;--------------------------------------
928
;--------------------------------------
929
align 4
929
align 4
930
@@:
930
@@:
931
        mov     [esi + WDATA.cl_titlebar], ecx
931
        mov     [esi + WDATA.cl_titlebar], ecx
932
        and     ecx, 0x00ffffff
932
        and     ecx, 0x00ffffff
933
;        call    [draw_line]
933
;        call    [draw_line]
934
        call    __sys_draw_line
934
        call    __sys_draw_line
935
        inc     edx
935
        inc     edx
936
        cmp     edx, [esp]
936
        cmp     edx, [esp]
937
        jb      .next_line
937
        jb      .next_line
938
 
938
 
939
        add     esp, 4
939
        add     esp, 4
940
        pop     [esi + WDATA.cl_titlebar]
940
        pop     [esi + WDATA.cl_titlebar]
941
        ret
941
        ret
942
;------------------------------------------------------------------------------
942
;------------------------------------------------------------------------------
943
 
943
 
944
 
944
 
945
align 4
945
align 4
946
drawwindow_III:
946
drawwindow_III:
947
        pushad
947
        pushad
948
 
948
 
949
        ; window border
949
        ; window border
950
 
950
 
951
        mov     eax, [edx + WDATA.box.left - 2]
951
        mov     eax, [edx + WDATA.box.left - 2]
952
        mov     ax, word[edx + WDATA.box.left]
952
        mov     ax, word[edx + WDATA.box.left]
953
        add     ax, word[edx + WDATA.box.width]
953
        add     ax, word[edx + WDATA.box.width]
954
        mov     ebx, [edx + WDATA.box.top - 2]
954
        mov     ebx, [edx + WDATA.box.top - 2]
955
        mov     bx, word[edx + WDATA.box.top]
955
        mov     bx, word[edx + WDATA.box.top]
956
        add     bx, word[edx + WDATA.box.height]
956
        add     bx, word[edx + WDATA.box.height]
957
 
957
 
958
        mov     esi, [edx + WDATA.cl_frames]
958
        mov     esi, [edx + WDATA.cl_frames]
959
        shr     esi, 1
959
        shr     esi, 1
960
        and     esi, 0x007f7f7f
960
        and     esi, 0x007f7f7f
961
        call    draw_rectangle
961
        call    draw_rectangle
962
 
962
 
963
        push    esi
963
        push    esi
964
        mov     ecx, 3
964
        mov     ecx, 3
965
        mov     esi, [edx + WDATA.cl_frames]
965
        mov     esi, [edx + WDATA.cl_frames]
966
;--------------------------------------
966
;--------------------------------------
967
align 4
967
align 4
968
.next_frame:
968
.next_frame:
969
        add     eax, 1 * 65536 - 1
969
        add     eax, 1 * 65536 - 1
970
        add     ebx, 1 * 65536 - 1
970
        add     ebx, 1 * 65536 - 1
971
        call    draw_rectangle
971
        call    draw_rectangle
972
        dec     ecx
972
        dec     ecx
973
        jnz     .next_frame
973
        jnz     .next_frame
974
 
974
 
975
        pop     esi
975
        pop     esi
976
        add     eax, 1 * 65536 - 1
976
        add     eax, 1 * 65536 - 1
977
        add     ebx, 1 * 65536 - 1
977
        add     ebx, 1 * 65536 - 1
978
        call    draw_rectangle
978
        call    draw_rectangle
979
 
979
 
980
        ; window caption
980
        ; window caption
981
 
981
 
982
        call    drawwindow_III_caption
982
        call    drawwindow_III_caption
983
 
983
 
984
        ; window client area
984
        ; window client area
985
 
985
 
986
        ; do we need to draw it?
986
        ; do we need to draw it?
987
        mov     edi, [esi + WDATA.cl_workarea]
987
        mov     edi, [esi + WDATA.cl_workarea]
988
        test    edi, 0x40000000
988
        test    edi, 0x40000000
989
        jnz     .exit
989
        jnz     .exit
990
 
990
 
991
        ; does client area have a positive size on screen?
991
        ; does client area have a positive size on screen?
992
        mov     edx, [esi + WDATA.box.top]
992
        mov     edx, [esi + WDATA.box.top]
993
        add     edx, 21 + 5
993
        add     edx, 21 + 5
994
        mov     ebx, [esi + WDATA.box.top]
994
        mov     ebx, [esi + WDATA.box.top]
995
        add     ebx, [esi + WDATA.box.height]
995
        add     ebx, [esi + WDATA.box.height]
996
        cmp     edx, ebx
996
        cmp     edx, ebx
997
        jg      .exit
997
        jg      .exit
998
 
998
 
999
        ; okay, let's draw it
999
        ; okay, let's draw it
1000
        mov     eax, 5
1000
        mov     eax, 5
1001
        mov     ebx, 20
1001
        mov     ebx, 20
1002
        mov     ecx, [esi + WDATA.box.width]
1002
        mov     ecx, [esi + WDATA.box.width]
1003
        mov     edx, [esi + WDATA.box.height]
1003
        mov     edx, [esi + WDATA.box.height]
1004
        sub     ecx, 4
1004
        sub     ecx, 4
1005
        sub     edx, 4
1005
        sub     edx, 4
1006
;        call    [drawbar]
1006
;        call    [drawbar]
1007
        call    vesa20_drawbar
1007
        call    vesa20_drawbar
1008
;--------------------------------------
1008
;--------------------------------------
1009
align 4
1009
align 4
1010
.exit:
1010
.exit:
1011
        popad
1011
        popad
1012
        ret
1012
        ret
1013
;------------------------------------------------------------------------------
1013
;------------------------------------------------------------------------------
1014
 
1014
 
1015
 
1015
 
1016
align 4
1016
align 4
1017
;? Activate window, redrawing if necessary
1017
;? Activate window, redrawing if necessary
1018
waredraw:
1018
waredraw:
1019
        push    -1
1019
        push    -1
1020
        mov     eax, [thread_count]
1020
        mov     eax, [thread_count]
1021
        lea     eax, [WIN_POS + eax * 2]
1021
        lea     eax, [WIN_POS + eax * 2]
1022
        cmp     eax, esi
1022
        cmp     eax, esi
1023
        pop     eax
1023
        pop     eax
1024
        je      .exit
1024
        je      .exit
1025
 
1025
 
1026
        ; is it overlapped by another window now?
1026
        ; is it overlapped by another window now?
1027
        push    ecx
1027
        push    ecx
1028
        call    window._.check_window_draw
1028
        call    window._.check_window_draw
1029
        test    ecx, ecx
1029
        test    ecx, ecx
1030
        pop     ecx
1030
        pop     ecx
1031
        jz      .do_not_draw
1031
        jz      .do_not_draw
1032
 
1032
 
1033
        ; yes it is, activate and update screen buffer
1033
        ; yes it is, activate and update screen buffer
1034
        call    window._.window_activate
1034
        call    window._.window_activate
1035
 
1035
 
1036
        pushad
1036
        pushad
1037
        mov     edi, [thread_count]
1037
        mov     edi, [thread_count]
1038
        movzx   esi, word[WIN_POS + edi * 2]
1038
        movzx   esi, word[WIN_POS + edi * 2]
1039
        shl     esi, BSF sizeof.WDATA
1039
        shl     esi, BSF sizeof.WDATA
1040
        add     esi, window_data
1040
        add     esi, window_data
1041
 
1041
 
1042
        mov     eax, [esi + WDATA.box.left]
1042
        mov     eax, [esi + WDATA.box.left]
1043
        mov     ebx, [esi + WDATA.box.top]
1043
        mov     ebx, [esi + WDATA.box.top]
1044
        mov     ecx, [esi + WDATA.box.width]
1044
        mov     ecx, [esi + WDATA.box.width]
1045
        mov     edx, [esi + WDATA.box.height]
1045
        mov     edx, [esi + WDATA.box.height]
1046
 
1046
 
1047
        add     ecx, eax
1047
        add     ecx, eax
1048
        add     edx, ebx
1048
        add     edx, ebx
1049
 
1049
 
1050
        mov     edi, [thread_count]
1050
        mov     edi, [thread_count]
1051
        movzx   esi, word[WIN_POS + edi * 2]
1051
        movzx   esi, word[WIN_POS + edi * 2]
1052
        call    window._.set_screen
1052
        call    window._.set_screen
1053
 
1053
 
1054
        call    window._.set_top_wnd
1054
        call    window._.set_top_wnd
1055
 
1055
 
1056
        inc     [_display.mask_seqno]
1056
        inc     [_display.mask_seqno]
1057
        popad
1057
        popad
1058
 
1058
 
1059
        ; tell application to redraw itself
1059
        ; tell application to redraw itself
1060
        mov     [edi + WDATA.fl_redraw], 1
1060
        mov     [edi + WDATA.fl_redraw], 1
1061
        xor     eax, eax
1061
        xor     eax, eax
1062
        jmp     .exit
1062
        jmp     .exit
1063
;--------------------------------------
1063
;--------------------------------------
1064
align 4
1064
align 4
1065
.do_not_draw:
1065
.do_not_draw:
1066
        ; no it's not, just activate the window
1066
        ; no it's not, just activate the window
1067
        call    window._.window_activate
1067
        call    window._.window_activate
1068
        xor     eax, eax
1068
        xor     eax, eax
1069
        ret
1069
        ret
1070
 
1070
 
1071
;--------------------------------------
1071
;--------------------------------------
1072
align 4
1072
align 4
1073
.exit:
1073
.exit:
1074
        inc     eax
1074
        inc     eax
1075
        ret
1075
        ret
1076
;------------------------------------------------------------------------------
1076
;------------------------------------------------------------------------------
1077
 
1077
 
1078
 
1078
 
1079
align 4
1079
align 4
1080
minimize_all_window:
1080
minimize_all_window:
1081
        push    ebx ecx edx esi edi
1081
        push    ebx ecx edx esi edi
1082
        pushfd
1082
        pushfd
1083
        cli
1083
        cli
1084
        xor     edx, edx
1084
        xor     edx, edx
1085
        mov     eax, 2  ; we do not minimize the kernel thread N1
1085
        mov     eax, 2  ; we do not minimize the kernel thread N1
1086
        mov     ebx, [thread_count]
1086
        mov     ebx, [thread_count]
1087
;--------------------------------------
1087
;--------------------------------------
1088
align 4
1088
align 4
1089
.loop:
1089
.loop:
1090
        movzx   edi, word[WIN_POS + eax * 2]
1090
        movzx   edi, word[WIN_POS + eax * 2]
1091
        shl     edi, BSF sizeof.WDATA
1091
        shl     edi, BSF sizeof.WDATA
1092
; it is a unused slot?
1092
; it is a unused slot?
1093
        cmp     byte [SLOT_BASE + edi*8 + APPDATA.state], TSTATE_FREE
1093
        cmp     byte [SLOT_BASE + edi*8 + APPDATA.state], TSTATE_FREE
1094
        je      @f
1094
        je      @f
1095
; it is a hidden thread?
1095
; it is a hidden thread?
1096
        lea     esi, [SLOT_BASE + edi*8 + APPDATA.app_name]
1096
        lea     esi, [SLOT_BASE + edi*8 + APPDATA.app_name]
1097
        cmp     [esi], byte '@'
1097
        cmp     [esi], byte '@'
1098
        je      @f
1098
        je      @f
1099
; is it already minimized?
1099
; is it already minimized?
1100
        test    [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED
1100
        test    [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED
1101
        jnz     @f
1101
        jnz     @f
1102
; no it's not, let's do that
1102
; no it's not, let's do that
1103
        or      [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED
1103
        or      [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED
1104
        inc     edx
1104
        inc     edx
1105
;--------------------------------------
1105
;--------------------------------------
1106
align 4
1106
align 4
1107
@@:
1107
@@:
1108
        inc     eax
1108
        inc     eax
1109
        cmp     eax, ebx
1109
        cmp     eax, ebx
1110
        jbe     .loop
1110
        jbe     .loop
1111
; If nothing has changed
1111
; If nothing has changed
1112
        test    edx, edx
1112
        test    edx, edx
1113
        jz      @f
1113
        jz      @f
1114
 
1114
 
1115
        push    edx
1115
        push    edx
1116
        call    syscall_display_settings.calculateScreen
1116
        call    syscall_display_settings.calculateScreen
1117
        call    syscall_display_settings.redrawScreen
1117
        call    syscall_display_settings.redrawScreen
1118
        pop     edx
1118
        pop     edx
1119
;--------------------------------------
1119
;--------------------------------------
1120
align 4
1120
align 4
1121
@@:
1121
@@:
1122
        mov     eax, edx
1122
        mov     eax, edx
1123
        popfd
1123
        popfd
1124
        pop     edi esi edx ecx ebx
1124
        pop     edi esi edx ecx ebx
1125
        ret
1125
        ret
1126
;------------------------------------------------------------------------------
1126
;------------------------------------------------------------------------------
1127
align 4
1127
align 4
1128
;------------------------------------------------------------------------------
1128
;------------------------------------------------------------------------------
1129
 
1129
 
1130
;> eax = window number on screen
1130
;> eax = window number on screen
1131
;# corrupts [dl*]
1131
;# corrupts [dl*]
1132
minimize_window:
1132
minimize_window:
1133
        push    edi
1133
        push    edi
1134
        pushfd
1134
        pushfd
1135
        cli
1135
        cli
1136
 
1136
 
1137
        ; is it already minimized?
1137
        ; is it already minimized?
1138
        movzx   edi, word[WIN_POS + eax * 2]
1138
        movzx   edi, word[WIN_POS + eax * 2]
1139
        shl     edi, BSF sizeof.WDATA
1139
        shl     edi, BSF sizeof.WDATA
1140
        add     edi, window_data
1140
        add     edi, window_data
1141
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1141
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1142
        jnz     .exit
1142
        jnz     .exit
1143
 
1143
 
1144
        push    eax ebx ecx edx esi
1144
        push    eax ebx ecx edx esi
1145
 
1145
 
1146
        ; no it's not, let's do that
1146
        ; no it's not, let's do that
1147
        or      [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1147
        or      [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1148
; If the window width is 0, then the action is not needed.
1148
; If the window width is 0, then the action is not needed.
1149
        cmp     [edi + WDATA.box.width], dword 0
1149
        cmp     [edi + WDATA.box.width], dword 0
1150
        je      @f
1150
        je      @f
1151
; If the window height is 0, then the action is not needed.
1151
; If the window height is 0, then the action is not needed.
1152
        cmp     [edi + WDATA.box.height], dword 0
1152
        cmp     [edi + WDATA.box.height], dword 0
1153
        je      @f
1153
        je      @f
1154
 
1154
 
1155
        mov     eax, [edi + WDATA.box.left]
1155
        mov     eax, [edi + WDATA.box.left]
1156
        mov     [draw_limits.left], eax
1156
        mov     [draw_limits.left], eax
1157
        mov     ecx, eax
1157
        mov     ecx, eax
1158
        add     ecx, [edi + WDATA.box.width]
1158
        add     ecx, [edi + WDATA.box.width]
1159
        mov     [draw_limits.right], ecx
1159
        mov     [draw_limits.right], ecx
1160
        mov     ebx, [edi + WDATA.box.top]
1160
        mov     ebx, [edi + WDATA.box.top]
1161
        mov     [draw_limits.top], ebx
1161
        mov     [draw_limits.top], ebx
1162
        mov     edx, ebx
1162
        mov     edx, ebx
1163
        add     edx, [edi + WDATA.box.height]
1163
        add     edx, [edi + WDATA.box.height]
1164
        mov     [draw_limits.bottom], edx
1164
        mov     [draw_limits.bottom], edx
1165
 
1165
 
1166
;        DEBUGF  1, "K : minimize_window\n"
1166
;        DEBUGF  1, "K : minimize_window\n"
1167
;        DEBUGF  1, "K : dl_left %x\n",[draw_limits.left]
1167
;        DEBUGF  1, "K : dl_left %x\n",[draw_limits.left]
1168
;        DEBUGF  1, "K : dl_right %x\n",[draw_limits.right]
1168
;        DEBUGF  1, "K : dl_right %x\n",[draw_limits.right]
1169
;        DEBUGF  1, "K : dl_top %x\n",[draw_limits.top]
1169
;        DEBUGF  1, "K : dl_top %x\n",[draw_limits.top]
1170
;        DEBUGF  1, "K : dl_bottom %x\n",[draw_limits.bottom]
1170
;        DEBUGF  1, "K : dl_bottom %x\n",[draw_limits.bottom]
1171
        call    calculatescreen
1171
        call    calculatescreen
1172
;        xor     esi, esi
1172
;        xor     esi, esi
1173
;        xor     eax, eax
1173
;        xor     eax, eax
1174
        mov     eax, edi
1174
        mov     eax, edi
1175
        call    redrawscreen
1175
        call    redrawscreen
1176
;--------------------------------------
1176
;--------------------------------------
1177
align 4
1177
align 4
1178
@@:
1178
@@:
1179
        pop     esi edx ecx ebx eax
1179
        pop     esi edx ecx ebx eax
1180
;--------------------------------------
1180
;--------------------------------------
1181
align 4
1181
align 4
1182
.exit:
1182
.exit:
1183
        popfd
1183
        popfd
1184
        pop     edi
1184
        pop     edi
1185
        ret
1185
        ret
1186
;------------------------------------------------------------------------------
1186
;------------------------------------------------------------------------------
1187
 
1187
 
1188
 
1188
 
1189
align 4
1189
align 4
1190
;> eax = window number on screen
1190
;> eax = window number on screen
1191
;# corrupts [dl*]
1191
;# corrupts [dl*]
1192
restore_minimized_window:
1192
restore_minimized_window:
1193
        pushad
1193
        pushad
1194
        pushfd
1194
        pushfd
1195
        cli
1195
        cli
1196
 
1196
 
1197
        ; is it already restored?
1197
        ; is it already restored?
1198
        movzx   esi, word[WIN_POS + eax * 2]
1198
        movzx   esi, word[WIN_POS + eax * 2]
1199
        mov     edi, esi
1199
        mov     edi, esi
1200
        shl     edi, BSF sizeof.WDATA
1200
        shl     edi, BSF sizeof.WDATA
1201
        add     edi, window_data
1201
        add     edi, window_data
1202
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1202
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1203
        jz      .exit
1203
        jz      .exit
1204
 
1204
 
1205
        ; no it's not, let's do that
1205
        ; no it's not, let's do that
1206
        mov     [edi + WDATA.fl_redraw], 1
1206
        mov     [edi + WDATA.fl_redraw], 1
1207
        and     [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED
1207
        and     [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED
1208
        mov     ebp, window._.set_screen
1208
        mov     ebp, window._.set_screen
1209
        cmp     eax, [thread_count]
1209
        cmp     eax, [thread_count]
1210
        jz      @f
1210
        jz      @f
1211
        mov     ebp, calculatescreen
1211
        mov     ebp, calculatescreen
1212
;--------------------------------------
1212
;--------------------------------------
1213
align 4
1213
align 4
1214
@@:
1214
@@:
1215
        mov     eax, [edi + WDATA.box.left]
1215
        mov     eax, [edi + WDATA.box.left]
1216
        mov     ebx, [edi + WDATA.box.top]
1216
        mov     ebx, [edi + WDATA.box.top]
1217
        mov     ecx, [edi + WDATA.box.width]
1217
        mov     ecx, [edi + WDATA.box.width]
1218
        mov     edx, [edi + WDATA.box.height]
1218
        mov     edx, [edi + WDATA.box.height]
1219
        add     ecx, eax
1219
        add     ecx, eax
1220
        add     edx, ebx
1220
        add     edx, ebx
1221
        call    ebp
1221
        call    ebp
1222
 
1222
 
1223
        cmp     ebp, window._.set_screen
1223
        cmp     ebp, window._.set_screen
1224
        jne     @f
1224
        jne     @f
1225
        call    window._.set_top_wnd
1225
        call    window._.set_top_wnd
1226
    @@:
1226
    @@:
1227
        inc     [_display.mask_seqno]
1227
        inc     [_display.mask_seqno]
1228
;--------------------------------------
1228
;--------------------------------------
1229
align 4
1229
align 4
1230
.exit:
1230
.exit:
1231
        popfd
1231
        popfd
1232
        popad
1232
        popad
1233
        ret
1233
        ret
1234
;------------------------------------------------------------------------------
1234
;------------------------------------------------------------------------------
1235
align 4
1235
align 4
1236
; TODO: remove this proc
1236
; TODO: remove this proc
1237
;------------------------------------------------------------------------------
1237
;------------------------------------------------------------------------------
1238
 
1238
 
1239
 
1239
 
1240
window_check_events:
1240
window_check_events:
1241
        ; do we have window minimize/restore request?
1241
        ; do we have window minimize/restore request?
1242
        cmp     [window_minimize], 0
1242
        cmp     [window_minimize], 0
1243
        je      .exit
1243
        je      .exit
1244
 
1244
 
1245
        ; okay, minimize or restore top-most window and exit
1245
        ; okay, minimize or restore top-most window and exit
1246
        mov     eax, [thread_count]
1246
        mov     eax, [thread_count]
1247
        mov     bl, 0
1247
        mov     bl, 0
1248
        xchg    [window_minimize], bl
1248
        xchg    [window_minimize], bl
1249
        dec     bl
1249
        dec     bl
1250
        jnz     @f
1250
        jnz     @f
1251
        call    minimize_window
1251
        call    minimize_window
1252
        jmp     .exit
1252
        jmp     .exit
1253
;--------------------------------------
1253
;--------------------------------------
1254
align 4
1254
align 4
1255
@@:
1255
@@:
1256
        call    restore_minimized_window
1256
        call    restore_minimized_window
1257
;--------------------------------------
1257
;--------------------------------------
1258
align 4
1258
align 4
1259
.exit:
1259
.exit:
1260
        ret
1260
        ret
1261
;------------------------------------------------------------------------------
1261
;------------------------------------------------------------------------------
1262
 
1262
 
1263
 
1263
 
1264
align 4
1264
align 4
1265
;> esi = process slot
1265
;> esi = process slot
1266
sys_window_maximize_handler:
1266
sys_window_maximize_handler:
1267
        mov     edi, esi
1267
        mov     edi, esi
1268
        shl     edi, BSF sizeof.WDATA
1268
        shl     edi, BSF sizeof.WDATA
1269
        add     edi, window_data
1269
        add     edi, window_data
1270
 
1270
 
1271
        ; can window change its height?
1271
        ; can window change its height?
1272
        ; only types 2 and 3 can be resized
1272
        ; only types 2 and 3 can be resized
1273
        mov     dl, [edi + WDATA.fl_wstyle]
1273
        mov     dl, [edi + WDATA.fl_wstyle]
1274
        test    dl, 2
1274
        test    dl, 2
1275
        jz      .exit
1275
        jz      .exit
1276
 
1276
 
1277
        ; toggle normal/maximized window state
1277
        ; toggle normal/maximized window state
1278
        mov     bl, [edi + WDATA.fl_wstate]
1278
        mov     bl, [edi + WDATA.fl_wstate]
1279
        xor     bl, WSTATE_MAXIMIZED
1279
        xor     bl, WSTATE_MAXIMIZED
1280
 
1280
 
1281
        ; calculate and set appropriate window bounds
1281
        ; calculate and set appropriate window bounds
1282
        test    bl, WSTATE_MAXIMIZED
1282
        test    bl, WSTATE_MAXIMIZED
1283
        jz      .restore_size
1283
        jz      .restore_size
1284
 
1284
 
1285
        mov     eax, [screen_workarea.left]
1285
        mov     eax, [screen_workarea.left]
1286
        mov     ecx, [screen_workarea.top]
1286
        mov     ecx, [screen_workarea.top]
1287
        push    [screen_workarea.bottom] \
1287
        push    [screen_workarea.bottom] \
1288
                [screen_workarea.right] \
1288
                [screen_workarea.right] \
1289
                ecx \
1289
                ecx \
1290
                eax
1290
                eax
1291
        sub     [esp + BOX.width], eax
1291
        sub     [esp + BOX.width], eax
1292
        sub     [esp + BOX.height], ecx
1292
        sub     [esp + BOX.height], ecx
1293
        mov     eax, esp
1293
        mov     eax, esp
1294
        jmp     .set_box
1294
        jmp     .set_box
1295
;--------------------------------------
1295
;--------------------------------------
1296
align 4
1296
align 4
1297
.restore_size:
1297
.restore_size:
1298
        mov     eax, esi
1298
        mov     eax, esi
1299
        shl     eax, BSF sizeof.APPDATA
1299
        shl     eax, BSF sizeof.APPDATA
1300
        add     eax, SLOT_BASE + APPDATA.saved_box
1300
        add     eax, SLOT_BASE + APPDATA.saved_box
1301
        push    [eax + BOX.height] \
1301
        push    [eax + BOX.height] \
1302
                [eax + BOX.width] \
1302
                [eax + BOX.width] \
1303
                [eax + BOX.top] \
1303
                [eax + BOX.top] \
1304
                [eax + BOX.left]
1304
                [eax + BOX.left]
1305
        mov     eax, esp
1305
        mov     eax, esp
1306
;--------------------------------------
1306
;--------------------------------------
1307
align 4
1307
align 4
1308
.set_box:
1308
.set_box:
1309
        test    bl, WSTATE_ROLLEDUP
1309
        test    bl, WSTATE_ROLLEDUP
1310
        jz      @f
1310
        jz      @f
1311
 
1311
 
1312
        xchg    eax, ecx
1312
        xchg    eax, ecx
1313
        call    window._.get_rolledup_height
1313
        call    window._.get_rolledup_height
1314
        mov     [ecx + BOX.height], eax
1314
        mov     [ecx + BOX.height], eax
1315
        xchg    eax, ecx
1315
        xchg    eax, ecx
1316
;--------------------------------------
1316
;--------------------------------------
1317
align 4
1317
align 4
1318
@@:
1318
@@:
1319
        call    window._.set_window_box
1319
        call    window._.set_window_box
1320
        add     esp, sizeof.BOX
1320
        add     esp, sizeof.BOX
1321
;--------------------------------------
1321
;--------------------------------------
1322
align 4
1322
align 4
1323
.exit:
1323
.exit:
1324
        inc     [_display.mask_seqno]
1324
        inc     [_display.mask_seqno]
1325
        ret
1325
        ret
1326
;------------------------------------------------------------------------------
1326
;------------------------------------------------------------------------------
1327
 
1327
 
1328
 
1328
 
1329
align 4
1329
align 4
1330
;> esi = process slot
1330
;> esi = process slot
1331
sys_window_rollup_handler:
1331
sys_window_rollup_handler:
1332
        mov     edx, esi
1332
        mov     edx, esi
1333
        shl     edx, BSF sizeof.APPDATA
1333
        shl     edx, BSF sizeof.APPDATA
1334
        add     edx, SLOT_BASE
1334
        add     edx, SLOT_BASE
1335
 
1335
 
1336
        ; toggle normal/rolled up window state
1336
        ; toggle normal/rolled up window state
1337
        mov     bl, [edi + WDATA.fl_wstate]
1337
        mov     bl, [edi + WDATA.fl_wstate]
1338
        xor     bl, WSTATE_ROLLEDUP
1338
        xor     bl, WSTATE_ROLLEDUP
1339
 
1339
 
1340
        ; calculate and set appropriate window bounds
1340
        ; calculate and set appropriate window bounds
1341
        test    bl, WSTATE_ROLLEDUP
1341
        test    bl, WSTATE_ROLLEDUP
1342
        jz      .restore_size
1342
        jz      .restore_size
1343
 
1343
 
1344
        call    window._.get_rolledup_height
1344
        call    window._.get_rolledup_height
1345
        push    eax \
1345
        push    eax \
1346
                [edi + WDATA.box.width] \
1346
                [edi + WDATA.box.width] \
1347
                [edi + WDATA.box.top] \
1347
                [edi + WDATA.box.top] \
1348
                [edi + WDATA.box.left]
1348
                [edi + WDATA.box.left]
1349
        mov     eax, esp
1349
        mov     eax, esp
1350
        jmp     .set_box
1350
        jmp     .set_box
1351
;--------------------------------------
1351
;--------------------------------------
1352
align 4
1352
align 4
1353
.restore_size:
1353
.restore_size:
1354
        test    bl, WSTATE_MAXIMIZED
1354
        test    bl, WSTATE_MAXIMIZED
1355
        jnz     @f
1355
        jnz     @f
1356
        add     esp, -sizeof.BOX
1356
        add     esp, -sizeof.BOX
1357
        lea     eax, [edx + APPDATA.saved_box]
1357
        lea     eax, [edx + APPDATA.saved_box]
1358
        jmp     .set_box
1358
        jmp     .set_box
1359
;--------------------------------------
1359
;--------------------------------------
1360
align 4
1360
align 4
1361
@@:
1361
@@:
1362
        mov     eax, [screen_workarea.top]
1362
        mov     eax, [screen_workarea.top]
1363
        push    [screen_workarea.bottom] \
1363
        push    [screen_workarea.bottom] \
1364
                [edi + WDATA.box.width] \
1364
                [edi + WDATA.box.width] \
1365
                eax \
1365
                eax \
1366
                [edi + WDATA.box.left]
1366
                [edi + WDATA.box.left]
1367
        sub     [esp + BOX.height], eax
1367
        sub     [esp + BOX.height], eax
1368
        mov     eax, esp
1368
        mov     eax, esp
1369
;--------------------------------------
1369
;--------------------------------------
1370
align 4
1370
align 4
1371
.set_box:
1371
.set_box:
1372
        call    window._.set_window_box
1372
        call    window._.set_window_box
1373
        add     esp, sizeof.BOX
1373
        add     esp, sizeof.BOX
1374
        ret
1374
        ret
1375
;------------------------------------------------------------------------------
1375
;------------------------------------------------------------------------------
1376
align 4
1376
align 4
1377
;------------------------------------------------------------------------------
1377
;------------------------------------------------------------------------------
1378
;sys_window_start_moving_handler:
1378
;sys_window_start_moving_handler:
1379
;------------------------------------------------------------------------------
1379
;------------------------------------------------------------------------------
1380
;? 
1380
;? 
1381
;------------------------------------------------------------------------------
1381
;------------------------------------------------------------------------------
1382
;> eax = old (original) window box
1382
;> eax = old (original) window box
1383
;> esi = process slot
1383
;> esi = process slot
1384
;------------------------------------------------------------------------------
1384
;------------------------------------------------------------------------------
1385
;        mov     edi, eax
1385
;        mov     edi, eax
1386
;        call    window._.draw_negative_box
1386
;        call    window._.draw_negative_box
1387
;        ret
1387
;        ret
1388
;------------------------------------------------------------------------------
1388
;------------------------------------------------------------------------------
1389
 
1389
 
1390
 
1390
 
1391
align 4
1391
align 4
1392
;> eax = old (original) window box
1392
;> eax = old (original) window box
1393
;> ebx = new (final) window box
1393
;> ebx = new (final) window box
1394
;> esi = process slot
1394
;> esi = process slot
1395
sys_window_end_moving_handler:
1395
sys_window_end_moving_handler:
1396
;        mov     edi, ebx
1396
;        mov     edi, ebx
1397
;        call    window._.end_moving__box
1397
;        call    window._.end_moving__box
1398
 
1398
 
1399
        mov     edi, esi
1399
        mov     edi, esi
1400
        shl     edi, BSF sizeof.WDATA
1400
        shl     edi, BSF sizeof.WDATA
1401
        add     edi, window_data
1401
        add     edi, window_data
1402
 
1402
 
1403
        test    [fl_moving], 1
1403
        test    [fl_moving], 1
1404
        jz      @f
1404
        jz      @f
1405
 
1405
 
1406
        push    edi
1406
        push    edi
1407
        mov     edi, ebx
1407
        mov     edi, ebx
1408
        call    window._.draw_negative_box
1408
        call    window._.draw_negative_box
1409
        pop     edi
1409
        pop     edi
1410
    @@:
1410
    @@:
1411
 
1411
 
1412
        mov     eax, ebx
1412
        mov     eax, ebx
1413
        mov     bl, [edi + WDATA.fl_wstate]
1413
        mov     bl, [edi + WDATA.fl_wstate]
1414
        call    window._.set_window_box
1414
        call    window._.set_window_box
1415
        ret
1415
        ret
1416
;------------------------------------------------------------------------------
1416
;------------------------------------------------------------------------------
1417
 
1417
 
1418
 
1418
 
1419
align 4
1419
align 4
1420
;> eax = old (from previous call) window box
1420
;> eax = old (from previous call) window box
1421
;> ebx = new (current) window box
1421
;> ebx = new (current) window box
1422
;> esi = process_slot
1422
;> esi = process_slot
1423
sys_window_moving_handler:
1423
sys_window_moving_handler:
1424
        mov     edi, eax
1424
        mov     edi, eax
1425
        call    window._.draw_negative_box
1425
        call    window._.draw_negative_box
1426
        mov     edi, ebx
1426
        mov     edi, ebx
1427
        call    window._.draw_negative_box
1427
        call    window._.draw_negative_box
1428
        ret
1428
        ret
1429
 
1429
 
1430
 
1430
 
1431
 
1431
 
1432
 
1432
 
1433
;==============================================================================
1433
;==============================================================================
1434
;      private functions
1434
;      private functions
1435
;==============================================================================
1435
;==============================================================================
1436
 
1436
 
1437
iglobal
1437
iglobal
1438
align 4
1438
align 4
1439
window_topleft  dd \
1439
window_topleft  dd \
1440
    1, 21, \ ;type 0
1440
    1, 21, \ ;type 0
1441
    0,  0, \ ;type 1
1441
    0,  0, \ ;type 1
1442
    5, 20, \ ;type 2
1442
    5, 20, \ ;type 2
1443
    5,  ?, \ ;type 3 {set by skin}
1443
    5,  ?, \ ;type 3 {set by skin}
1444
    5,  ?    ;type 4 {set by skin}
1444
    5,  ?    ;type 4 {set by skin}
1445
endg
1445
endg
1446
 
1446
 
1447
;------------------------------------------------------------------------------
1447
;------------------------------------------------------------------------------
1448
 
1448
 
1449
 
1449
 
1450
align 4
1450
align 4
1451
;> eax = old (original) window box
1451
;> eax = old (original) window box
1452
;> ebx = new (final) window box
1452
;> ebx = new (final) window box
1453
;> edi = pointer to WDATA struct
1453
;> edi = pointer to WDATA struct
1454
window._.invalidate_screen:
1454
window._.invalidate_screen:
1455
        push    eax ebx
1455
        push    eax ebx
1456
 
1456
 
1457
        ; TODO: do we really need `draw_limits`?
1457
        ; TODO: do we really need `draw_limits`?
1458
        ; Yes, they are used by background drawing code.
1458
        ; Yes, they are used by background drawing code.
1459
 
1459
 
1460
; we need only to restore the background windows at the old place!
1460
; we need only to restore the background windows at the old place!
1461
        mov     ecx, [ebx + BOX.left]
1461
        mov     ecx, [ebx + BOX.left]
1462
        mov     [draw_limits.left], ecx
1462
        mov     [draw_limits.left], ecx
1463
        add     ecx, [ebx + BOX.width]
1463
        add     ecx, [ebx + BOX.width]
1464
        mov     [draw_limits.right], ecx
1464
        mov     [draw_limits.right], ecx
1465
        mov     ecx, [ebx + BOX.top]
1465
        mov     ecx, [ebx + BOX.top]
1466
        mov     [draw_limits.top], ecx
1466
        mov     [draw_limits.top], ecx
1467
        add     ecx, [ebx + BOX.height]
1467
        add     ecx, [ebx + BOX.height]
1468
        mov     [draw_limits.bottom], ecx
1468
        mov     [draw_limits.bottom], ecx
1469
; recalculate screen buffer at old position
1469
; recalculate screen buffer at old position
1470
        push    ebx
1470
        push    ebx
1471
        mov     edx, [eax + BOX.height]
1471
        mov     edx, [eax + BOX.height]
1472
        mov     ecx, [eax + BOX.width]
1472
        mov     ecx, [eax + BOX.width]
1473
        mov     ebx, [eax + BOX.top]
1473
        mov     ebx, [eax + BOX.top]
1474
        mov     eax, [eax + BOX.left]
1474
        mov     eax, [eax + BOX.left]
1475
        add     ecx, eax
1475
        add     ecx, eax
1476
        add     edx, ebx
1476
        add     edx, ebx
1477
        call    calculatescreen
1477
        call    calculatescreen
1478
        pop     eax
1478
        pop     eax
1479
; recalculate screen buffer at new position
1479
; recalculate screen buffer at new position
1480
        mov     edx, [eax + BOX.height]
1480
        mov     edx, [eax + BOX.height]
1481
        mov     ecx, [eax + BOX.width]
1481
        mov     ecx, [eax + BOX.width]
1482
        mov     ebx, [eax + BOX.top]
1482
        mov     ebx, [eax + BOX.top]
1483
        mov     eax, [eax + BOX.left]
1483
        mov     eax, [eax + BOX.left]
1484
        add     ecx, eax
1484
        add     ecx, eax
1485
        add     edx, ebx
1485
        add     edx, ebx
1486
        call    calculatescreen
1486
        call    calculatescreen
1487
 
1487
 
1488
        mov     eax, edi
1488
        mov     eax, edi
1489
        call    redrawscreen
1489
        call    redrawscreen
1490
 
1490
 
1491
        ; tell window to redraw itself
1491
        ; tell window to redraw itself
1492
        mov     [edi + WDATA.fl_redraw], 1
1492
        mov     [edi + WDATA.fl_redraw], 1
1493
 
1493
 
1494
        pop     ebx eax
1494
        pop     ebx eax
1495
        ret
1495
        ret
1496
;------------------------------------------------------------------------------
1496
;------------------------------------------------------------------------------
1497
 
1497
 
1498
 
1498
 
1499
align 4
1499
align 4
1500
;> eax = pointer to BOX struct
1500
;> eax = pointer to BOX struct
1501
;> bl = new window state flags
1501
;> bl = new window state flags
1502
;> edi = pointer to WDATA struct
1502
;> edi = pointer to WDATA struct
1503
window._.set_window_box:
1503
window._.set_window_box:
1504
        push    eax ebx esi
1504
        push    eax ebx esi
1505
 
1505
 
1506
; don't do anything if the new box is identical to the old
1506
; don't do anything if the new box is identical to the old
1507
        cmp     bl, [edi + WDATA.fl_wstate]
1507
        cmp     bl, [edi + WDATA.fl_wstate]
1508
        jnz     @f
1508
        jnz     @f
1509
        mov     esi, eax
1509
        mov     esi, eax
1510
        push    edi
1510
        push    edi
1511
if WDATA.box
1511
if WDATA.box
1512
        add     edi, WDATA.box
1512
        add     edi, WDATA.box
1513
end if
1513
end if
1514
        mov     ecx, 4
1514
        mov     ecx, 4
1515
        repz cmpsd
1515
        repz cmpsd
1516
        pop     edi
1516
        pop     edi
1517
        jz      .exit
1517
        jz      .exit
1518
;--------------------------------------
1518
;--------------------------------------
1519
align 4
1519
align 4
1520
@@:
1520
@@:
1521
        add     esp, -sizeof.BOX
1521
        add     esp, -sizeof.BOX
1522
        mov     ebx, esp
1522
        mov     ebx, esp
1523
if WDATA.box
1523
if WDATA.box
1524
        lea     esi, [edi + WDATA.box]
1524
        lea     esi, [edi + WDATA.box]
1525
else
1525
else
1526
        mov     esi, edi ; optimization for WDATA.box = 0
1526
        mov     esi, edi ; optimization for WDATA.box = 0
1527
end if
1527
end if
1528
        xchg    eax, esi
1528
        xchg    eax, esi
1529
        mov     ecx, sizeof.BOX
1529
        mov     ecx, sizeof.BOX
1530
        call    memmove
1530
        call    memmove
1531
        xchg    eax, esi
1531
        xchg    eax, esi
1532
        xchg    ebx, esi
1532
        xchg    ebx, esi
1533
        call    memmove
1533
        call    memmove
1534
        mov     eax, ebx
1534
        mov     eax, ebx
1535
        mov     ebx, esi
1535
        mov     ebx, esi
1536
        call    window._.check_window_position
1536
        call    window._.check_window_position
1537
        call    window._.set_window_clientbox
1537
        call    window._.set_window_clientbox
1538
        call    window._.invalidate_screen
1538
        call    window._.invalidate_screen
1539
 
1539
 
1540
        add     esp, sizeof.BOX
1540
        add     esp, sizeof.BOX
1541
 
1541
 
1542
        mov     cl, [esp + 4]
1542
        mov     cl, [esp + 4]
1543
        mov     ch, cl
1543
        mov     ch, cl
1544
        xchg    cl, [edi + WDATA.fl_wstate]
1544
        xchg    cl, [edi + WDATA.fl_wstate]
1545
 
1545
 
1546
        or      cl, ch
1546
        or      cl, ch
1547
        test    cl, WSTATE_MAXIMIZED
1547
        test    cl, WSTATE_MAXIMIZED
1548
        jnz     .exit
1548
        jnz     .exit
1549
 
1549
 
1550
        mov     eax, edi
1550
        mov     eax, edi
1551
        sub     eax, window_data
1551
        sub     eax, window_data
1552
        shl     eax, 3
1552
        shl     eax, 3
1553
        add     eax, SLOT_BASE
1553
        add     eax, SLOT_BASE
1554
 
1554
 
1555
        lea     ebx, [edi + WDATA.box]
1555
        lea     ebx, [edi + WDATA.box]
1556
        xchg    esp, ebx
1556
        xchg    esp, ebx
1557
 
1557
 
1558
        pop     [eax + APPDATA.saved_box.left] \
1558
        pop     [eax + APPDATA.saved_box.left] \
1559
                [eax + APPDATA.saved_box.top] \
1559
                [eax + APPDATA.saved_box.top] \
1560
                [eax + APPDATA.saved_box.width] \
1560
                [eax + APPDATA.saved_box.width] \
1561
                edx
1561
                edx
1562
 
1562
 
1563
        xchg    esp, ebx
1563
        xchg    esp, ebx
1564
 
1564
 
1565
        test    ch, WSTATE_ROLLEDUP
1565
        test    ch, WSTATE_ROLLEDUP
1566
        jnz     .exit
1566
        jnz     .exit
1567
 
1567
 
1568
        mov     [eax + APPDATA.saved_box.height], edx
1568
        mov     [eax + APPDATA.saved_box.height], edx
1569
;--------------------------------------
1569
;--------------------------------------
1570
align 4
1570
align 4
1571
.exit:
1571
.exit:
1572
        pop     esi ebx eax
1572
        pop     esi ebx eax
1573
        ret
1573
        ret
1574
;------------------------------------------------------------------------------
1574
;------------------------------------------------------------------------------
1575
 
1575
 
1576
 
1576
 
1577
align 4
1577
align 4
1578
;> edi = pointer to WDATA struct
1578
;> edi = pointer to WDATA struct
1579
window._.set_window_clientbox:
1579
window._.set_window_clientbox:
1580
        push    eax ecx edi
1580
        push    eax ecx edi
1581
 
1581
 
1582
        mov     eax, [_skinh]
1582
        mov     eax, [_skinh]
1583
        mov     [window_topleft + 8 * 3 + 4], eax
1583
        mov     [window_topleft + 8 * 3 + 4], eax
1584
        mov     [window_topleft + 8 * 4 + 4], eax
1584
        mov     [window_topleft + 8 * 4 + 4], eax
1585
 
1585
 
1586
        mov     ecx, edi
1586
        mov     ecx, edi
1587
        sub     edi, window_data
1587
        sub     edi, window_data
1588
        shl     edi, 3
1588
        shl     edi, 3
1589
        test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
1589
        test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
1590
        jz      .whole_window
1590
        jz      .whole_window
1591
 
1591
 
1592
        movzx   eax, [ecx + WDATA.fl_wstyle]
1592
        movzx   eax, [ecx + WDATA.fl_wstyle]
1593
        and     eax, 0x0F
1593
        and     eax, 0x0F
1594
        mov     eax, [eax * 8 + window_topleft + 0]
1594
        mov     eax, [eax * 8 + window_topleft + 0]
1595
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1595
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1596
        shl     eax, 1
1596
        shl     eax, 1
1597
        neg     eax
1597
        neg     eax
1598
        add     eax, [ecx + WDATA.box.width]
1598
        add     eax, [ecx + WDATA.box.width]
1599
        inc     eax  ;Leency: as window is created width+1 so client the same
1599
        inc     eax  ;Leency: as window is created width+1 so client the same
1600
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1600
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1601
 
1601
 
1602
        movzx   eax, [ecx + WDATA.fl_wstyle]
1602
        movzx   eax, [ecx + WDATA.fl_wstyle]
1603
        and     eax, 0x0F
1603
        and     eax, 0x0F
1604
        push    [eax * 8 + window_topleft + 0]
1604
        push    [eax * 8 + window_topleft + 0]
1605
        mov     eax, [eax * 8 + window_topleft + 4]
1605
        mov     eax, [eax * 8 + window_topleft + 4]
1606
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1606
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1607
        neg     eax
1607
        neg     eax
1608
        sub     eax, [esp]
1608
        sub     eax, [esp]
1609
        add     eax, [ecx + WDATA.box.height]
1609
        add     eax, [ecx + WDATA.box.height]
1610
        inc     eax  ;Leency: as window is created height+1 so client the same
1610
        inc     eax  ;Leency: as window is created height+1 so client the same
1611
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1611
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1612
        add     esp, 4
1612
        add     esp, 4
1613
        jmp     .exit
1613
        jmp     .exit
1614
;--------------------------------------
1614
;--------------------------------------
1615
align 4
1615
align 4
1616
.whole_window:
1616
.whole_window:
1617
        xor     eax, eax
1617
        xor     eax, eax
1618
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1618
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1619
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1619
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1620
        mov     eax, [ecx + WDATA.box.width]
1620
        mov     eax, [ecx + WDATA.box.width]
1621
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1621
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1622
        mov     eax, [ecx + WDATA.box.height]
1622
        mov     eax, [ecx + WDATA.box.height]
1623
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1623
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1624
;--------------------------------------
1624
;--------------------------------------
1625
align 4
1625
align 4
1626
.exit:
1626
.exit:
1627
        pop     edi ecx eax
1627
        pop     edi ecx eax
1628
        ret
1628
        ret
1629
;------------------------------------------------------------------------------
1629
;------------------------------------------------------------------------------
1630
 
1630
 
1631
 
1631
 
1632
align 4
1632
align 4
1633
;< edx = pointer to WDATA struct
1633
;< edx = pointer to WDATA struct
1634
window._.sys_set_window:
1634
window._.sys_set_window:
1635
        mov     eax, [current_slot_idx]
1635
        mov     eax, [current_slot_idx]
1636
        shl     eax, BSF sizeof.WDATA
1636
        shl     eax, BSF sizeof.WDATA
1637
        add     eax, window_data
1637
        add     eax, window_data
1638
; save window colors
1638
; save window colors
1639
        mov     [eax + WDATA.cl_workarea], edx
1639
        mov     [eax + WDATA.cl_workarea], edx
1640
        mov     [eax + WDATA.cl_titlebar], esi
1640
        mov     [eax + WDATA.cl_titlebar], esi
1641
        mov     [eax + WDATA.cl_frames], edi
1641
        mov     [eax + WDATA.cl_frames], edi
1642
        mov     edi, eax
1642
        mov     edi, eax
1643
; Was it already defined before?
1643
; Was it already defined before?
1644
        test    [edi + WDATA.fl_wdrawn], 1
1644
        test    [edi + WDATA.fl_wdrawn], 1
1645
        jnz     .set_client_box
1645
        jnz     .set_client_box
1646
; No, it wasn't. After first draw_window we need redraw mouse necessarily!
1646
; No, it wasn't. After first draw_window we need redraw mouse necessarily!
1647
; Otherwise the user can see cursor specified by f.37.5 from another window.
1647
; Otherwise the user can see cursor specified by f.37.5 from another window.
1648
; He will be really unhappy! Usually, he will be enraged!
1648
; He will be really unhappy! Usually, he will be enraged!
1649
        or      [edi + WDATA.fl_wdrawn], 1
1649
        or      [edi + WDATA.fl_wdrawn], 1
1650
        mov     [redrawmouse_unconditional], 1
1650
        mov     [redrawmouse_unconditional], 1
1651
        call    wakeup_osloop
1651
        call    wakeup_osloop
1652
; performing initial window definition
1652
; performing initial window definition
1653
        movzx   eax, bx
1653
        movzx   eax, bx
1654
        mov     [edi + WDATA.box.width], eax
1654
        mov     [edi + WDATA.box.width], eax
1655
        movzx   eax, cx
1655
        movzx   eax, cx
1656
        mov     [edi + WDATA.box.height], eax
1656
        mov     [edi + WDATA.box.height], eax
1657
        sar     ebx, 16
1657
        sar     ebx, 16
1658
        sar     ecx, 16
1658
        sar     ecx, 16
1659
        mov     [edi + WDATA.box.left], ebx
1659
        mov     [edi + WDATA.box.left], ebx
1660
        mov     [edi + WDATA.box.top], ecx
1660
        mov     [edi + WDATA.box.top], ecx
1661
 
1661
 
1662
        call    window._.check_window_position
1662
        call    window._.check_window_position
1663
 
1663
 
1664
        push    ecx edi
1664
        push    ecx edi
1665
 
1665
 
1666
        mov     cl, [edi + WDATA.fl_wstyle]
1666
        mov     cl, [edi + WDATA.fl_wstyle]
1667
        mov     eax, [edi + WDATA.cl_frames]
1667
        mov     eax, [edi + WDATA.cl_frames]
1668
 
1668
 
1669
        sub     edi, window_data
1669
        sub     edi, window_data
1670
        shl     edi, 3
1670
        shl     edi, 3
1671
        add     edi, SLOT_BASE
1671
        add     edi, SLOT_BASE
1672
 
1672
 
1673
        and     cl, 0x0F
1673
        and     cl, 0x0F
1674
        cmp     cl, 3
1674
        cmp     cl, 3
1675
        je      @f
1675
        je      @f
1676
        cmp     cl, 4
1676
        cmp     cl, 4
1677
        je      @f
1677
        je      @f
1678
 
1678
 
1679
        xor     eax, eax
1679
        xor     eax, eax
1680
;--------------------------------------
1680
;--------------------------------------
1681
align 4
1681
align 4
1682
@@:
1682
@@:
1683
        mov     [edi + APPDATA.wnd_caption], eax
1683
        mov     [edi + APPDATA.wnd_caption], eax
1684
 
1684
 
1685
        mov     esi, [esp]
1685
        mov     esi, [esp]
1686
        add     edi, APPDATA.saved_box
1686
        add     edi, APPDATA.saved_box
1687
        movsd
1687
        movsd
1688
        movsd
1688
        movsd
1689
        movsd
1689
        movsd
1690
        movsd
1690
        movsd
1691
 
1691
 
1692
        pop     edi ecx
1692
        pop     edi ecx
1693
 
1693
 
1694
        mov     esi, [current_slot_idx]
1694
        mov     esi, [current_slot_idx]
1695
        movzx   esi, word[WIN_STACK + esi * 2]
1695
        movzx   esi, word[WIN_STACK + esi * 2]
1696
        lea     esi, [WIN_POS + esi * 2]
1696
        lea     esi, [WIN_POS + esi * 2]
1697
        call    waredraw
1697
        call    waredraw
1698
 
1698
 
1699
        mov     eax, [edi + WDATA.box.left]
1699
        mov     eax, [edi + WDATA.box.left]
1700
        mov     ebx, [edi + WDATA.box.top]
1700
        mov     ebx, [edi + WDATA.box.top]
1701
        mov     ecx, [edi + WDATA.box.width]
1701
        mov     ecx, [edi + WDATA.box.width]
1702
        mov     edx, [edi + WDATA.box.height]
1702
        mov     edx, [edi + WDATA.box.height]
1703
        add     ecx, eax
1703
        add     ecx, eax
1704
        add     edx, ebx
1704
        add     edx, ebx
1705
        call    calculatescreen
1705
        call    calculatescreen
1706
 
1706
 
1707
        mov     byte[KEY_COUNT], 0           ; empty keyboard buffer
1707
        mov     byte[KEY_COUNT], 0           ; empty keyboard buffer
1708
        mov     byte[BTN_COUNT], 0           ; empty button buffer
1708
        mov     byte[BTN_COUNT], 0           ; empty button buffer
1709
;--------------------------------------
1709
;--------------------------------------
1710
align 4
1710
align 4
1711
.set_client_box:
1711
.set_client_box:
1712
        ; update window client box coordinates
1712
        ; update window client box coordinates
1713
        call    window._.set_window_clientbox
1713
        call    window._.set_window_clientbox
1714
 
1714
 
1715
        ; reset window redraw flag and exit
1715
        ; reset window redraw flag and exit
1716
        mov     [edi + WDATA.fl_redraw], 0
1716
        mov     [edi + WDATA.fl_redraw], 0
1717
        mov     edx, edi
1717
        mov     edx, edi
1718
        ret
1718
        ret
1719
;------------------------------------------------------------------------------
1719
;------------------------------------------------------------------------------
1720
 
1720
 
1721
 
1721
 
1722
align 4
1722
align 4
1723
;? Check if window is inside screen area
1723
;? Check if window is inside screen area
1724
;> edi = pointer to WDATA
1724
;> edi = pointer to WDATA
1725
window._.check_window_position:
1725
window._.check_window_position:
1726
        push    eax ebx ecx edx esi
1726
        push    eax ebx ecx edx esi
1727
 
1727
 
1728
        mov     eax, [edi + WDATA.box.left]
1728
        mov     eax, [edi + WDATA.box.left]
1729
        mov     ebx, [edi + WDATA.box.top]
1729
        mov     ebx, [edi + WDATA.box.top]
1730
        mov     ecx, [edi + WDATA.box.width]
1730
        mov     ecx, [edi + WDATA.box.width]
1731
        mov     edx, [edi + WDATA.box.height]
1731
        mov     edx, [edi + WDATA.box.height]
1732
 
1732
 
1733
        mov     esi, [_display.width]
1733
        mov     esi, [_display.width]
1734
        cmp     ecx, esi
1734
        cmp     ecx, esi
1735
        jae     .fix_width_high
1735
        jae     .fix_width_high
1736
;--------------------------------------
1736
;--------------------------------------
1737
align 4
1737
align 4
1738
.check_left:
1738
.check_left:
1739
        or      eax, eax
1739
        or      eax, eax
1740
        jl      .fix_left_low
1740
        jl      .fix_left_low
1741
        add     eax, ecx
1741
        add     eax, ecx
1742
        cmp     eax, esi
1742
        cmp     eax, esi
1743
        jge     .fix_left_high
1743
        jge     .fix_left_high
1744
;--------------------------------------
1744
;--------------------------------------
1745
align 4
1745
align 4
1746
.check_height:
1746
.check_height:
1747
        mov     esi, [_display.height]
1747
        mov     esi, [_display.height]
1748
        cmp     edx, esi
1748
        cmp     edx, esi
1749
        jae     .fix_height_high
1749
        jae     .fix_height_high
1750
;--------------------------------------
1750
;--------------------------------------
1751
align 4
1751
align 4
1752
.check_top:
1752
.check_top:
1753
        or      ebx, ebx
1753
        or      ebx, ebx
1754
        jl      .fix_top_low
1754
        jl      .fix_top_low
1755
        add     ebx, edx
1755
        add     ebx, edx
1756
        cmp     ebx, esi
1756
        cmp     ebx, esi
1757
        jge     .fix_top_high
1757
        jge     .fix_top_high
1758
;--------------------------------------
1758
;--------------------------------------
1759
align 4
1759
align 4
1760
.exit:
1760
.exit:
1761
        pop     esi edx ecx ebx eax
1761
        pop     esi edx ecx ebx eax
1762
        ret
1762
        ret
1763
;--------------------------------------
1763
;--------------------------------------
1764
align 4
1764
align 4
1765
.fix_width_high:
1765
.fix_width_high:
1766
        mov     ecx, esi
1766
        mov     ecx, esi
1767
        dec     ecx
1767
        dec     ecx
1768
        mov     [edi + WDATA.box.width], ecx
1768
        mov     [edi + WDATA.box.width], ecx
1769
        jmp     .check_left
1769
        jmp     .check_left
1770
;--------------------------------------
1770
;--------------------------------------
1771
align 4
1771
align 4
1772
.fix_left_low:
1772
.fix_left_low:
1773
        xor     eax, eax
1773
        xor     eax, eax
1774
        mov     [edi + WDATA.box.left], eax
1774
        mov     [edi + WDATA.box.left], eax
1775
        jmp     .check_height
1775
        jmp     .check_height
1776
;--------------------------------------
1776
;--------------------------------------
1777
align 4
1777
align 4
1778
.fix_left_high:
1778
.fix_left_high:
1779
        mov     eax, esi
1779
        mov     eax, esi
1780
        sub     eax, ecx
1780
        sub     eax, ecx
1781
        dec     eax
1781
        dec     eax
1782
        mov     [edi + WDATA.box.left], eax
1782
        mov     [edi + WDATA.box.left], eax
1783
        jmp     .check_height
1783
        jmp     .check_height
1784
;--------------------------------------
1784
;--------------------------------------
1785
align 4
1785
align 4
1786
.fix_height_high:
1786
.fix_height_high:
1787
        mov     edx, esi
1787
        mov     edx, esi
1788
        dec     edx
1788
        dec     edx
1789
        mov     [edi + WDATA.box.height], edx
1789
        mov     [edi + WDATA.box.height], edx
1790
        jmp     .check_top
1790
        jmp     .check_top
1791
;--------------------------------------
1791
;--------------------------------------
1792
align 4
1792
align 4
1793
.fix_top_low:
1793
.fix_top_low:
1794
        xor     ebx, ebx
1794
        xor     ebx, ebx
1795
        mov     [edi + WDATA.box.top], ebx
1795
        mov     [edi + WDATA.box.top], ebx
1796
        jmp     .exit
1796
        jmp     .exit
1797
;--------------------------------------
1797
;--------------------------------------
1798
align 4
1798
align 4
1799
.fix_top_high:
1799
.fix_top_high:
1800
        mov     ebx, esi
1800
        mov     ebx, esi
1801
        sub     ebx, edx
1801
        sub     ebx, edx
1802
        dec     ebx
1802
        dec     ebx
1803
        mov     [edi + WDATA.box.top], ebx
1803
        mov     [edi + WDATA.box.top], ebx
1804
        jmp     .exit
1804
        jmp     .exit
1805
;------------------------------------------------------------------------------
1805
;------------------------------------------------------------------------------
1806
 
1806
 
1807
 
1807
 
1808
align 4
1808
align 4
1809
;> edi = pointer to WDATA
1809
;> edi = pointer to WDATA
1810
window._.get_titlebar_height:
1810
window._.get_titlebar_height:
1811
        mov     al, [edi + WDATA.fl_wstyle]
1811
        mov     al, [edi + WDATA.fl_wstyle]
1812
        and     al, 0x0f
1812
        and     al, 0x0f
1813
        cmp     al, 0x03
1813
        cmp     al, 0x03
1814
        jne     @f
1814
        jne     @f
1815
        mov     eax, [_skinh]
1815
        mov     eax, [_skinh]
1816
        ret
1816
        ret
1817
;--------------------------------------
1817
;--------------------------------------
1818
align 4
1818
align 4
1819
@@:
1819
@@:
1820
        mov     eax, 21
1820
        mov     eax, 21
1821
        ret
1821
        ret
1822
;------------------------------------------------------------------------------
1822
;------------------------------------------------------------------------------
1823
 
1823
 
1824
 
1824
 
1825
align 4
1825
align 4
1826
;> edi = pointer to WDATA
1826
;> edi = pointer to WDATA
1827
window._.get_rolledup_height:
1827
window._.get_rolledup_height:
1828
        mov     al, [edi + WDATA.fl_wstyle]
1828
        mov     al, [edi + WDATA.fl_wstyle]
1829
        and     al, 0x0f
1829
        and     al, 0x0f
1830
        cmp     al, 0x03
1830
        cmp     al, 0x03
1831
        jb      @f
1831
        jb      @f
1832
        mov     eax, [_skinh]
1832
        mov     eax, [_skinh]
1833
        add     eax, 3
1833
        add     eax, 3
1834
        ret
1834
        ret
1835
;--------------------------------------
1835
;--------------------------------------
1836
align 4
1836
align 4
1837
@@:
1837
@@:
1838
        or      al, al
1838
        or      al, al
1839
        jnz     @f
1839
        jnz     @f
1840
        mov     eax, 21
1840
        mov     eax, 21
1841
        ret
1841
        ret
1842
;--------------------------------------
1842
;--------------------------------------
1843
align 4
1843
align 4
1844
@@:
1844
@@:
1845
        mov     eax, 21 + 2
1845
        mov     eax, 21 + 2
1846
        ret
1846
        ret
1847
;------------------------------------------------------------------------------
1847
;------------------------------------------------------------------------------
1848
 
1848
 
1849
 
1849
 
1850
align 4
1850
align 4
1851
;? Reserve window area in screen buffer
1851
;? Reserve window area in screen buffer
1852
;> eax = left
1852
;> eax = left
1853
;> ebx = top
1853
;> ebx = top
1854
;> ecx = right
1854
;> ecx = right
1855
;> edx = bottom
1855
;> edx = bottom
1856
;> esi = process number
1856
;> esi = process number
1857
window._.set_screen:
1857
window._.set_screen:
1858
virtual at esp
1858
virtual at esp
1859
  ff_x     dd ?
1859
  ff_x     dd ?
1860
  ff_y     dd ?
1860
  ff_y     dd ?
1861
  ff_width dd ?
1861
  ff_width dd ?
1862
  ff_xsz   dd ?
1862
  ff_xsz   dd ?
1863
  ff_ysz   dd ?
1863
  ff_ysz   dd ?
1864
  ff_scale dd ?
1864
  ff_scale dd ?
1865
end virtual
1865
end virtual
1866
 
1866
 
1867
        pushad
1867
        pushad
1868
 
1868
 
1869
        cmp     esi, 1
1869
        cmp     esi, 1
1870
        jz      .check_for_shaped_window
1870
        jz      .check_for_shaped_window
1871
        mov     edi, esi
1871
        mov     edi, esi
1872
        shl     edi, BSF sizeof.WDATA
1872
        shl     edi, BSF sizeof.WDATA
1873
        cmp     [window_data + edi + WDATA.box.width], 0
1873
        cmp     [window_data + edi + WDATA.box.width], 0
1874
        jnz     .check_for_shaped_window
1874
        jnz     .check_for_shaped_window
1875
        cmp     [window_data + edi + WDATA.box.height], 0
1875
        cmp     [window_data + edi + WDATA.box.height], 0
1876
        jz      .exit
1876
        jz      .exit
1877
;--------------------------------------
1877
;--------------------------------------
1878
align 4
1878
align 4
1879
.check_for_shaped_window:
1879
.check_for_shaped_window:
1880
        mov     edi, esi
1880
        mov     edi, esi
1881
        shl     edi, BSF sizeof.APPDATA
1881
        shl     edi, BSF sizeof.APPDATA
1882
        add     edi, SLOT_BASE
1882
        add     edi, SLOT_BASE
1883
        cmp     [edi + APPDATA.wnd_shape], 0
1883
        cmp     [edi + APPDATA.wnd_shape], 0
1884
        jne     .shaped_window
1884
        jne     .shaped_window
1885
 
1885
 
1886
        ; get x&y size
1886
        ; get x&y size
1887
        sub     ecx, eax
1887
        sub     ecx, eax
1888
        sub     edx, ebx
1888
        sub     edx, ebx
1889
        inc     ecx
1889
        inc     ecx
1890
        inc     edx
1890
        inc     edx
1891
 
1891
 
1892
        ; get WinMap start
1892
        ; get WinMap start
1893
        push    esi
1893
        push    esi
1894
        mov     esi, [_display.width]
1894
        mov     esi, [_display.width]
1895
        mov     edi, [d_width_calc_area + ebx*4]
1895
        mov     edi, [d_width_calc_area + ebx*4]
1896
 
1896
 
1897
        add     edi, eax
1897
        add     edi, eax
1898
        add     edi, [_display.win_map]
1898
        add     edi, [_display.win_map]
1899
        pop     eax
1899
        pop     eax
1900
        mov     ah, al
1900
        mov     ah, al
1901
        push    ax
1901
        push    ax
1902
        shl     eax, 16
1902
        shl     eax, 16
1903
        pop     ax
1903
        pop     ax
1904
;--------------------------------------
1904
;--------------------------------------
1905
align 4
1905
align 4
1906
.next_line:
1906
.next_line:
1907
        push    ecx
1907
        push    ecx
1908
        shr     ecx, 2
1908
        shr     ecx, 2
1909
        rep stosd
1909
        rep stosd
1910
        mov     ecx, [esp]
1910
        mov     ecx, [esp]
1911
        and     ecx, 3
1911
        and     ecx, 3
1912
        rep stosb
1912
        rep stosb
1913
        pop     ecx
1913
        pop     ecx
1914
        add     edi, esi
1914
        add     edi, esi
1915
        sub     edi, ecx
1915
        sub     edi, ecx
1916
        dec     edx
1916
        dec     edx
1917
        jnz     .next_line
1917
        jnz     .next_line
1918
 
1918
 
1919
        jmp     .exit
1919
        jmp     .exit
1920
;--------------------------------------
1920
;--------------------------------------
1921
align 4
1921
align 4
1922
.shaped_window:
1922
.shaped_window:
1923
        ;  for (y=0; y <= x_size; y++)
1923
        ;  for (y=0; y <= x_size; y++)
1924
        ;      for (x=0; x <= x_size; x++)
1924
        ;      for (x=0; x <= x_size; x++)
1925
        ;          if (shape[coord(x,y,scale)]==1)
1925
        ;          if (shape[coord(x,y,scale)]==1)
1926
        ;             set_pixel(x, y, process_number);
1926
        ;             set_pixel(x, y, process_number);
1927
 
1927
 
1928
        sub     ecx, eax
1928
        sub     ecx, eax
1929
        sub     edx, ebx
1929
        sub     edx, ebx
1930
        inc     ecx
1930
        inc     ecx
1931
        inc     edx
1931
        inc     edx
1932
 
1932
 
1933
        push    [edi + APPDATA.wnd_shape_scale]  ; push scale first -> for loop
1933
        push    [edi + APPDATA.wnd_shape_scale]  ; push scale first -> for loop
1934
 
1934
 
1935
        ; get WinMap start  -> ebp
1935
        ; get WinMap start  -> ebp
1936
        push    eax
1936
        push    eax
1937
        mov     eax, [d_width_calc_area + ebx*4]
1937
        mov     eax, [d_width_calc_area + ebx*4]
1938
 
1938
 
1939
        add     eax, [esp]
1939
        add     eax, [esp]
1940
        add     eax, [_display.win_map]
1940
        add     eax, [_display.win_map]
1941
        mov     ebp, eax
1941
        mov     ebp, eax
1942
 
1942
 
1943
        mov     edi, [edi + APPDATA.wnd_shape]
1943
        mov     edi, [edi + APPDATA.wnd_shape]
1944
        pop     eax
1944
        pop     eax
1945
 
1945
 
1946
        ; eax = x_start
1946
        ; eax = x_start
1947
        ; ebx = y_start
1947
        ; ebx = y_start
1948
        ; ecx = x_size
1948
        ; ecx = x_size
1949
        ; edx = y_size
1949
        ; edx = y_size
1950
        ; esi = process_number
1950
        ; esi = process_number
1951
        ; edi = &shape
1951
        ; edi = &shape
1952
        ;       [scale]
1952
        ;       [scale]
1953
        push    edx ecx ; for loop - x,y size
1953
        push    edx ecx ; for loop - x,y size
1954
 
1954
 
1955
        mov     ecx, esi
1955
        mov     ecx, esi
1956
        shl     ecx, BSF sizeof.WDATA
1956
        shl     ecx, BSF sizeof.WDATA
1957
        mov     edx, [window_data + ecx + WDATA.box.top]
1957
        mov     edx, [window_data + ecx + WDATA.box.top]
1958
        push    [window_data + ecx + WDATA.box.width]           ; for loop - width
1958
        push    [window_data + ecx + WDATA.box.width]           ; for loop - width
1959
        mov     ecx, [window_data + ecx + WDATA.box.left]
1959
        mov     ecx, [window_data + ecx + WDATA.box.left]
1960
        sub     ebx, edx
1960
        sub     ebx, edx
1961
        sub     eax, ecx
1961
        sub     eax, ecx
1962
        push    ebx eax ; for loop - x,y
1962
        push    ebx eax ; for loop - x,y
1963
 
1963
 
1964
        add     [ff_xsz], eax
1964
        add     [ff_xsz], eax
1965
        add     [ff_ysz], ebx
1965
        add     [ff_ysz], ebx
1966
 
1966
 
1967
        mov     ebx, [ff_y]
1967
        mov     ebx, [ff_y]
1968
;--------------------------------------
1968
;--------------------------------------
1969
align 4
1969
align 4
1970
.ff_new_y:
1970
.ff_new_y:
1971
        mov     edx, [ff_x]
1971
        mov     edx, [ff_x]
1972
;--------------------------------------
1972
;--------------------------------------
1973
align 4
1973
align 4
1974
.ff_new_x:
1974
.ff_new_x:
1975
        ; -- body --
1975
        ; -- body --
1976
        mov     ecx, [ff_scale]
1976
        mov     ecx, [ff_scale]
1977
        mov     eax, [ff_width]
1977
        mov     eax, [ff_width]
1978
        inc     eax
1978
        inc     eax
1979
        shr     eax, cl
1979
        shr     eax, cl
1980
        push    ebx edx
1980
        push    ebx edx
1981
        shr     ebx, cl
1981
        shr     ebx, cl
1982
        shr     edx, cl
1982
        shr     edx, cl
1983
        imul    eax, ebx
1983
        imul    eax, ebx
1984
        add     eax, edx
1984
        add     eax, edx
1985
        pop     edx ebx
1985
        pop     edx ebx
1986
        add     eax, edi
1986
        add     eax, edi
1987
        call    .read_byte
1987
        call    .read_byte
1988
        test    al, al
1988
        test    al, al
1989
        jz      @f
1989
        jz      @f
1990
        mov     eax, esi
1990
        mov     eax, esi
1991
        mov     [ebp], al
1991
        mov     [ebp], al
1992
        ; -- end body --
1992
        ; -- end body --
1993
;--------------------------------------
1993
;--------------------------------------
1994
align 4
1994
align 4
1995
@@:
1995
@@:
1996
        inc     ebp
1996
        inc     ebp
1997
        inc     edx
1997
        inc     edx
1998
        cmp     edx, [ff_xsz]
1998
        cmp     edx, [ff_xsz]
1999
        jb      .ff_new_x
1999
        jb      .ff_new_x
2000
 
2000
 
2001
        sub     ebp, [ff_xsz]
2001
        sub     ebp, [ff_xsz]
2002
        add     ebp, [ff_x]
2002
        add     ebp, [ff_x]
2003
        add     ebp, [_display.width]  ; screen.x
2003
        add     ebp, [_display.width]  ; screen.x
2004
        inc     ebx
2004
        inc     ebx
2005
        cmp     ebx, [ff_ysz]
2005
        cmp     ebx, [ff_ysz]
2006
        jb      .ff_new_y
2006
        jb      .ff_new_y
2007
 
2007
 
2008
        add     esp, 24
2008
        add     esp, 24
2009
;--------------------------------------
2009
;--------------------------------------
2010
align 4
2010
align 4
2011
.exit:
2011
.exit:
2012
        popad
2012
        popad
2013
        inc     [_display.mask_seqno]
2013
        inc     [_display.mask_seqno]
2014
        ret
2014
        ret
2015
;--------------------------------------
2015
;--------------------------------------
2016
align 4
2016
align 4
2017
.read_byte:
2017
.read_byte:
2018
        ; eax - address
2018
        ; eax - address
2019
        ; esi - slot
2019
        ; esi - slot
2020
        push    eax ecx edx esi
2020
        push    eax ecx edx esi
2021
        xchg    eax, esi
2021
        xchg    eax, esi
2022
        lea     ecx, [esp + 12]
2022
        lea     ecx, [esp + 12]
2023
        mov     edx, 1
2023
        mov     edx, 1
2024
        call    read_process_memory
2024
        call    read_process_memory
2025
        pop     esi edx ecx eax
2025
        pop     esi edx ecx eax
2026
        ret
2026
        ret
2027
;------------------------------------------------------------------------------
2027
;------------------------------------------------------------------------------
2028
 
2028
 
2029
 
2029
 
2030
align 4
2030
align 4
2031
; Activate window
2031
; Activate window
2032
; esi = pointer to WIN_POS+ window data
2032
; esi = pointer to WIN_POS+ window data
2033
window._.window_activate:
2033
window._.window_activate:
2034
        push    eax ebx
2034
        push    eax ebx
2035
 
2035
 
2036
        ; if type of current active window is 3 or 4, it must be redrawn
2036
        ; if type of current active window is 3 or 4, it must be redrawn
2037
        mov     ebx, [thread_count]
2037
        mov     ebx, [thread_count]
2038
 
2038
 
2039
;       DEBUGF  1, "K : thread_count (0x%x)\n", ebx
2039
;       DEBUGF  1, "K : thread_count (0x%x)\n", ebx
2040
 
2040
 
2041
        movzx   ebx, word[WIN_POS + ebx * 2]
2041
        movzx   ebx, word[WIN_POS + ebx * 2]
2042
        shl     ebx, BSF sizeof.WDATA
2042
        shl     ebx, BSF sizeof.WDATA
2043
        add     eax, window_data
2043
        add     eax, window_data
2044
        mov     al, [window_data + ebx + WDATA.fl_wstyle]
2044
        mov     al, [window_data + ebx + WDATA.fl_wstyle]
2045
        and     al, 0x0f
2045
        and     al, 0x0f
2046
        cmp     al, 0x03
2046
        cmp     al, 0x03
2047
        je      .set_window_redraw_flag
2047
        je      .set_window_redraw_flag
2048
        cmp     al, 0x04
2048
        cmp     al, 0x04
2049
        jne     .move_others_down
2049
        jne     .move_others_down
2050
;--------------------------------------
2050
;--------------------------------------
2051
align 4
2051
align 4
2052
.set_window_redraw_flag:
2052
.set_window_redraw_flag:
2053
        mov     [window_data + ebx + WDATA.fl_redraw], 1
2053
        mov     [window_data + ebx + WDATA.fl_redraw], 1
2054
;--------------------------------------
2054
;--------------------------------------
2055
align 4
2055
align 4
2056
.move_others_down:
2056
.move_others_down:
2057
        ; bx <- process no
2057
        ; bx <- process no
2058
        movzx   ebx, word[esi]
2058
        movzx   ebx, word[esi]
2059
        ; bx <- position in window stack
2059
        ; bx <- position in window stack
2060
        movzx   ebx, word[WIN_STACK + ebx * 2]
2060
        movzx   ebx, word[WIN_STACK + ebx * 2]
2061
 
2061
 
2062
        ; drop others
2062
        ; drop others
2063
        xor     eax, eax
2063
        xor     eax, eax
2064
;--------------------------------------
2064
;--------------------------------------
2065
align 4
2065
align 4
2066
.next_stack_window:
2066
.next_stack_window:
2067
        cmp     eax, [thread_count]
2067
        cmp     eax, [thread_count]
2068
        jae     .move_self_up
2068
        jae     .move_self_up
2069
        inc     eax
2069
        inc     eax
2070
 
2070
 
2071
;       push    ebx
2071
;       push    ebx
2072
;       xor     ebx,ebx
2072
;       xor     ebx,ebx
2073
;       mov     bx,[WIN_STACK + eax * 2]
2073
;       mov     bx,[WIN_STACK + eax * 2]
2074
;       DEBUGF  1, "K : DEC WIN_STACK (0x%x)\n",ebx
2074
;       DEBUGF  1, "K : DEC WIN_STACK (0x%x)\n",ebx
2075
;       pop     ebx
2075
;       pop     ebx
2076
 
2076
 
2077
        cmp     [WIN_STACK + eax * 2], bx
2077
        cmp     [WIN_STACK + eax * 2], bx
2078
        jbe     .next_stack_window
2078
        jbe     .next_stack_window
2079
        dec     word[WIN_STACK + eax * 2]
2079
        dec     word[WIN_STACK + eax * 2]
2080
        jmp     .next_stack_window
2080
        jmp     .next_stack_window
2081
;--------------------------------------
2081
;--------------------------------------
2082
align 4
2082
align 4
2083
.move_self_up:
2083
.move_self_up:
2084
        movzx   ebx, word[esi]
2084
        movzx   ebx, word[esi]
2085
        ; number of thread
2085
        ; number of thread
2086
        mov     ax, word [thread_count]
2086
        mov     ax, word [thread_count]
2087
        ; this is the last (and the upper)
2087
        ; this is the last (and the upper)
2088
        mov     [WIN_STACK + ebx * 2], ax
2088
        mov     [WIN_STACK + ebx * 2], ax
2089
 
2089
 
2090
        ; update on screen - window stack
2090
        ; update on screen - window stack
2091
        xor     eax, eax
2091
        xor     eax, eax
2092
;--------------------------------------
2092
;--------------------------------------
2093
align 4
2093
align 4
2094
.next_window_pos:
2094
.next_window_pos:
2095
        cmp     eax, [thread_count]
2095
        cmp     eax, [thread_count]
2096
        jae     .reset_vars
2096
        jae     .reset_vars
2097
        inc     eax
2097
        inc     eax
2098
        movzx   ebx, word[WIN_STACK + eax * 2]
2098
        movzx   ebx, word[WIN_STACK + eax * 2]
2099
        mov     [WIN_POS + ebx * 2], ax
2099
        mov     [WIN_POS + ebx * 2], ax
2100
        jmp     .next_window_pos
2100
        jmp     .next_window_pos
2101
;--------------------------------------
2101
;--------------------------------------
2102
align 4
2102
align 4
2103
.reset_vars:
2103
.reset_vars:
2104
        mov     byte[KEY_COUNT], 0
2104
        mov     byte[KEY_COUNT], 0
2105
        mov     byte[BTN_COUNT], 0
2105
        mov     byte[BTN_COUNT], 0
2106
        mov     word[MOUSE_SCROLL_H], 0
2106
        mov     word[MOUSE_SCROLL_H], 0
2107
        mov     word[MOUSE_SCROLL_V], 0
2107
        mov     word[MOUSE_SCROLL_V], 0
2108
 
2108
 
2109
        pop     ebx eax
2109
        pop     ebx eax
2110
        ret
2110
        ret
2111
;------------------------------------------------------------------------------
2111
;------------------------------------------------------------------------------
2112
 
2112
 
2113
 
2113
 
2114
; Deactivate window
2114
; Deactivate window
2115
; esi = pointer to WIN_POS+ window data
2115
; esi = pointer to WIN_POS+ window data
2116
window._.window_deactivate:
2116
window._.window_deactivate:
2117
        push    eax ebx
2117
        push    eax ebx
2118
;--------------------------------------
2118
;--------------------------------------
2119
align 4
2119
align 4
2120
.move_others_up:
2120
.move_others_up:
2121
        ; ax <- process no
2121
        ; ax <- process no
2122
        movzx   ebx, word[esi]
2122
        movzx   ebx, word[esi]
2123
        ; ax <- position in window stack
2123
        ; ax <- position in window stack
2124
        movzx   ebx, word[WIN_STACK + ebx * 2]
2124
        movzx   ebx, word[WIN_STACK + ebx * 2]
2125
        ; up others
2125
        ; up others
2126
        xor     eax, eax
2126
        xor     eax, eax
2127
;--------------------------------------
2127
;--------------------------------------
2128
align 4
2128
align 4
2129
.next_stack_window:
2129
.next_stack_window:
2130
        cmp     eax, [thread_count]
2130
        cmp     eax, [thread_count]
2131
        jae     .move_self_down
2131
        jae     .move_self_down
2132
        inc     eax
2132
        inc     eax
2133
        cmp     [WIN_STACK + eax * 2], bx
2133
        cmp     [WIN_STACK + eax * 2], bx
2134
        jae     .next_stack_window
2134
        jae     .next_stack_window
2135
        inc     word[WIN_STACK + eax * 2]
2135
        inc     word[WIN_STACK + eax * 2]
2136
        jmp     .next_stack_window
2136
        jmp     .next_stack_window
2137
;--------------------------------------
2137
;--------------------------------------
2138
align 4
2138
align 4
2139
.move_self_down:
2139
.move_self_down:
2140
        movzx   ebx, word[esi]
2140
        movzx   ebx, word[esi]
2141
        ; this is the last (and the low)
2141
        ; this is the last (and the low)
2142
        mov     [WIN_STACK + ebx * 2], word 1
2142
        mov     [WIN_STACK + ebx * 2], word 1
2143
        ; update on screen - window stack
2143
        ; update on screen - window stack
2144
        xor     eax, eax
2144
        xor     eax, eax
2145
;--------------------------------------
2145
;--------------------------------------
2146
align 4
2146
align 4
2147
.next_window_pos:
2147
.next_window_pos:
2148
        cmp     eax, [thread_count]
2148
        cmp     eax, [thread_count]
2149
        jae     .reset_vars
2149
        jae     .reset_vars
2150
        inc     eax
2150
        inc     eax
2151
        movzx   ebx, word[WIN_STACK + eax * 2]
2151
        movzx   ebx, word[WIN_STACK + eax * 2]
2152
        mov     [WIN_POS + ebx * 2], ax
2152
        mov     [WIN_POS + ebx * 2], ax
2153
        jmp     .next_window_pos
2153
        jmp     .next_window_pos
2154
;--------------------------------------
2154
;--------------------------------------
2155
align 4
2155
align 4
2156
.reset_vars:
2156
.reset_vars:
2157
        mov     byte[KEY_COUNT], 0
2157
        mov     byte[KEY_COUNT], 0
2158
        mov     byte[BTN_COUNT], 0
2158
        mov     byte[BTN_COUNT], 0
2159
        mov     word[MOUSE_SCROLL_H], 0
2159
        mov     word[MOUSE_SCROLL_H], 0
2160
        mov     word[MOUSE_SCROLL_V], 0
2160
        mov     word[MOUSE_SCROLL_V], 0
2161
        pop     ebx eax
2161
        pop     ebx eax
2162
        ret
2162
        ret
2163
;------------------------------------------------------------------------------
2163
;------------------------------------------------------------------------------
2164
 
2164
 
2165
 
2165
 
2166
align 4
2166
align 4
2167
; Check if window is necessary to draw
2167
; Check if window is necessary to draw
2168
; edi = pointer to WDATA
2168
; edi = pointer to WDATA
2169
window._.check_window_draw:
2169
window._.check_window_draw:
2170
        mov     cl, [edi + WDATA.fl_wstyle]
2170
        mov     cl, [edi + WDATA.fl_wstyle]
2171
        and     cl, 0x0f
2171
        and     cl, 0x0f
2172
        cmp     cl, 3
2172
        cmp     cl, 3
2173
        je      .exit.redraw      ; window type 3
2173
        je      .exit.redraw      ; window type 3
2174
        cmp     cl, 4
2174
        cmp     cl, 4
2175
        je      .exit.redraw      ; window type 4
2175
        je      .exit.redraw      ; window type 4
2176
 
2176
 
2177
        push    eax ebx edx esi
2177
        push    eax ebx edx esi
2178
 
2178
 
2179
        mov     eax, edi
2179
        mov     eax, edi
2180
        sub     eax, window_data
2180
        sub     eax, window_data
2181
        shr     eax, 5
2181
        shr     eax, 5
2182
 
2182
 
2183
        movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
2183
        movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
2184
        lea     esi, [WIN_POS + eax * 2]        ; get address of this process at 0xC400
2184
        lea     esi, [WIN_POS + eax * 2]        ; get address of this process at 0xC400
2185
;--------------------------------------
2185
;--------------------------------------
2186
align 4
2186
align 4
2187
.next_window:
2187
.next_window:
2188
        add     esi, 2
2188
        add     esi, 2
2189
 
2189
 
2190
        mov     eax, [thread_count]
2190
        mov     eax, [thread_count]
2191
        lea     eax, word[WIN_POS + eax * 2] ; number of the upper window
2191
        lea     eax, word[WIN_POS + eax * 2] ; number of the upper window
2192
 
2192
 
2193
        cmp     esi, eax
2193
        cmp     esi, eax
2194
        ja      .exit.no_redraw
2194
        ja      .exit.no_redraw
2195
 
2195
 
2196
        movzx   edx, word[esi]
2196
        movzx   edx, word[esi]
2197
        shl     edx, BSF sizeof.WDATA ; size of TASKDATA and WDATA is 32 bytes
2197
        shl     edx, BSF sizeof.WDATA ; size of TASKDATA and WDATA is 32 bytes
2198
        cmp     byte [SLOT_BASE + edx*8 - sizeof.APPDATA + APPDATA.state], TSTATE_FREE
2198
        cmp     byte [SLOT_BASE + edx*8 - sizeof.APPDATA + APPDATA.state], TSTATE_FREE
2199
        je      .next_window
2199
        je      .next_window
2200
 
2200
 
2201
        mov     eax, [edi + WDATA.box.top]
2201
        mov     eax, [edi + WDATA.box.top]
2202
        mov     ebx, [edi + WDATA.box.height]
2202
        mov     ebx, [edi + WDATA.box.height]
2203
        add     ebx, eax
2203
        add     ebx, eax
2204
 
2204
 
2205
        mov     ecx, [window_data + edx + WDATA.box.top]
2205
        mov     ecx, [window_data + edx + WDATA.box.top]
2206
        cmp     ecx, ebx
2206
        cmp     ecx, ebx
2207
        jge     .next_window
2207
        jge     .next_window
2208
        add     ecx, [window_data + edx + WDATA.box.height]
2208
        add     ecx, [window_data + edx + WDATA.box.height]
2209
        cmp     eax, ecx
2209
        cmp     eax, ecx
2210
        jge     .next_window
2210
        jge     .next_window
2211
 
2211
 
2212
        mov     eax, [edi + WDATA.box.left]
2212
        mov     eax, [edi + WDATA.box.left]
2213
        mov     ebx, [edi + WDATA.box.width]
2213
        mov     ebx, [edi + WDATA.box.width]
2214
        add     ebx, eax
2214
        add     ebx, eax
2215
 
2215
 
2216
        mov     ecx, [window_data + edx + WDATA.box.left]
2216
        mov     ecx, [window_data + edx + WDATA.box.left]
2217
        cmp     ecx, ebx
2217
        cmp     ecx, ebx
2218
        jge     .next_window
2218
        jge     .next_window
2219
        add     ecx, [window_data + edx + WDATA.box.width]
2219
        add     ecx, [window_data + edx + WDATA.box.width]
2220
        cmp     eax, ecx
2220
        cmp     eax, ecx
2221
        jge     .next_window
2221
        jge     .next_window
2222
 
2222
 
2223
        pop     esi edx ebx eax
2223
        pop     esi edx ebx eax
2224
;--------------------------------------
2224
;--------------------------------------
2225
align 4
2225
align 4
2226
.exit.redraw:
2226
.exit.redraw:
2227
        xor     ecx, ecx
2227
        xor     ecx, ecx
2228
        inc     ecx
2228
        inc     ecx
2229
        ret
2229
        ret
2230
;--------------------------------------
2230
;--------------------------------------
2231
align 4
2231
align 4
2232
.exit.no_redraw:
2232
.exit.no_redraw:
2233
        pop     esi edx ebx eax
2233
        pop     esi edx ebx eax
2234
        xor     ecx, ecx
2234
        xor     ecx, ecx
2235
        ret
2235
        ret
2236
 
2236
 
2237
 
2237
 
2238
;------------------------------------------------------------------------------
2238
;------------------------------------------------------------------------------
2239
 
2239
 
2240
 
2240
 
2241
align 4
2241
align 4
2242
window._.draw_window_caption:
2242
window._.draw_window_caption:
2243
        xor     eax, eax
2243
        xor     eax, eax
2244
        mov     edx, [thread_count]
2244
        mov     edx, [thread_count]
2245
        movzx   edx, word[WIN_POS + edx * 2]
2245
        movzx   edx, word[WIN_POS + edx * 2]
2246
        cmp     edx, [current_slot_idx]
2246
        cmp     edx, [current_slot_idx]
2247
        jne     @f
2247
        jne     @f
2248
        inc     eax
2248
        inc     eax
2249
;--------------------------------------
2249
;--------------------------------------
2250
align 4
2250
align 4
2251
@@:
2251
@@:
2252
        mov     edx, [current_slot_idx]
2252
        mov     edx, [current_slot_idx]
2253
        shl     edx, 5
2253
        shl     edx, 5
2254
        add     edx, window_data
2254
        add     edx, window_data
2255
        movzx   ebx, [edx + WDATA.fl_wstyle]
2255
        movzx   ebx, [edx + WDATA.fl_wstyle]
2256
        and     bl, 0x0F
2256
        and     bl, 0x0F
2257
        cmp     bl, 3
2257
        cmp     bl, 3
2258
        je      .draw_caption_style_3
2258
        je      .draw_caption_style_3
2259
        cmp     bl, 4
2259
        cmp     bl, 4
2260
        je      .draw_caption_style_3
2260
        je      .draw_caption_style_3
2261
 
2261
 
2262
        jmp     .not_style_3
2262
        jmp     .not_style_3
2263
;--------------------------------------
2263
;--------------------------------------
2264
align 4
2264
align 4
2265
.draw_caption_style_3:
2265
.draw_caption_style_3:
2266
        push    edx
2266
        push    edx
2267
        call    drawwindow_IV_caption
2267
        call    drawwindow_IV_caption
2268
        add     esp, 4
2268
        add     esp, 4
2269
        jmp     .2
2269
        jmp     .2
2270
;--------------------------------------
2270
;--------------------------------------
2271
align 4
2271
align 4
2272
.not_style_3:
2272
.not_style_3:
2273
        cmp     bl, 2
2273
        cmp     bl, 2
2274
        jne     .not_style_2
2274
        jne     .not_style_2
2275
 
2275
 
2276
        call    drawwindow_III_caption
2276
        call    drawwindow_III_caption
2277
        jmp     .2
2277
        jmp     .2
2278
;--------------------------------------
2278
;--------------------------------------
2279
align 4
2279
align 4
2280
.not_style_2:
2280
.not_style_2:
2281
        cmp     bl, 0
2281
        cmp     bl, 0
2282
        jne     .2
2282
        jne     .2
2283
 
2283
 
2284
        call    drawwindow_I_caption
2284
        call    drawwindow_I_caption
2285
;--------------------------------------
2285
;--------------------------------------
2286
align 4
2286
align 4
2287
.2:
2287
.2:
2288
        mov     edi, [current_slot_idx]
2288
        mov     edi, [current_slot_idx]
2289
        shl     edi, BSF sizeof.WDATA
2289
        shl     edi, BSF sizeof.WDATA
2290
        test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
2290
        test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
2291
        jz      .exit
2291
        jz      .exit
2292
        mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
2292
        mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
2293
        or      edx, edx
2293
        or      edx, edx
2294
        jz      .exit
2294
        jz      .exit
2295
 
2295
 
2296
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2296
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2297
        mov     bp, word[edi + window_data + WDATA.box.top]
2297
        mov     bp, word[edi + window_data + WDATA.box.top]
2298
        movzx   eax, [edi + window_data + WDATA.fl_wstyle]
2298
        movzx   eax, [edi + window_data + WDATA.fl_wstyle]
2299
        and     al, 0x0F
2299
        and     al, 0x0F
2300
        cmp     al, 3
2300
        cmp     al, 3
2301
        je      .skinned
2301
        je      .skinned
2302
        cmp     al, 4
2302
        cmp     al, 4
2303
        je      .skinned
2303
        je      .skinned
2304
 
2304
 
2305
        jmp     .not_skinned
2305
        jmp     .not_skinned
2306
;--------------------------------------
2306
;--------------------------------------
2307
align 4
2307
align 4
2308
.skinned:
2308
.skinned:
2309
        movzx   eax, word[edi + window_data + WDATA.box.width]
2309
        movzx   eax, word[edi + window_data + WDATA.box.width]
2310
        sub     ax, [_skinmargins.left]
2310
        sub     ax, [_skinmargins.left]
2311
        sub     ax, [_skinmargins.right]
2311
        sub     ax, [_skinmargins.right]
2312
        js      .exit
2312
        js      .exit
2313
        mov     ebx, dword[_skinmargins.left - 2]
2313
        mov     ebx, dword[_skinmargins.left - 2]
2314
        mov     bx, word[_skinh]
2314
        mov     bx, word[_skinh]
2315
        sub     bx, [_skinmargins.bottom]
2315
        sub     bx, [_skinmargins.bottom]
2316
        sub     bx, [_skinmargins.top]
2316
        sub     bx, [_skinmargins.top]
2317
        sar     bx, 1
2317
        sar     bx, 1
2318
        add     bx, [_skinmargins.top]
2318
        add     bx, [_skinmargins.top]
2319
        sub     bx, 8
2319
        sub     bx, 8
2320
        jmp     .dodraw
2320
        jmp     .dodraw
2321
;--------------------------------------
2321
;--------------------------------------
2322
align 4
2322
align 4
2323
.not_skinned:
2323
.not_skinned:
2324
        cmp     al, 1
2324
        cmp     al, 1
2325
        je      .exit
2325
        je      .exit
2326
        movzx   eax, word[edi + window_data + WDATA.box.width]
2326
        movzx   eax, word[edi + window_data + WDATA.box.width]
2327
        sub     eax, 16
2327
        sub     eax, 16
2328
        js      .exit
2328
        js      .exit
2329
        mov     ebx, 80002h
2329
        mov     ebx, 80002h
2330
.dodraw:
2330
.dodraw:
2331
        shr     eax, 3
2331
        shr     eax, 3
2332
        mov     esi, eax
2332
        mov     esi, eax
2333
        add     ebx, ebp
2333
        add     ebx, ebp
2334
        mov     ecx, [common_colours + 16]
2334
        mov     ecx, [common_colours + 16]
2335
        mov     al, [edi*8 + SLOT_BASE + APPDATA.captionEncoding]
2335
        mov     al, [edi*8 + SLOT_BASE + APPDATA.captionEncoding]
2336
        test    al, al
2336
        test    al, al
2337
        jnz     @f
2337
        jnz     @f
2338
        mov     al, 1
2338
        mov     al, 1
2339
        cmp     byte [edx], 4
2339
        cmp     byte [edx], 4
2340
        jnc     @f
2340
        jnc     @f
2341
        mov     al, [edx]
2341
        mov     al, [edx]
2342
        test    al, al
2342
        test    al, al
2343
        jz      .exit
2343
        jz      .exit
2344
        inc     edx
2344
        inc     edx
2345
@@:
2345
@@:
2346
        shl     eax, 28
2346
        shl     eax, 28
2347
        or      ecx, eax        
2347
        or      ecx, eax        
2348
        xor     edi, edi
2348
        xor     edi, edi
2349
        stc
2349
        stc
2350
        call    dtext._
2350
        call    dtext._
2351
.exit:
2351
.exit:
2352
        jmp     __sys_draw_pointer
2352
        jmp     __sys_draw_pointer
2353
;------------------------------------------------------------------------------
2353
;------------------------------------------------------------------------------
2354
 
2354
 
2355
 
2355
 
2356
align 4
2356
align 4
2357
; Draw negative box
2357
; Draw negative box
2358
; edi = pointer to BOX struct
2358
; edi = pointer to BOX struct
2359
window._.draw_negative_box:
2359
window._.draw_negative_box:
2360
        push    eax ebx esi
2360
        push    eax ebx esi
2361
        mov     esi, 0x01000000
2361
        mov     esi, 0x01000000
2362
;--------------------------------------
2362
;--------------------------------------
2363
align 4
2363
align 4
2364
.1:
2364
.1:
2365
        mov     eax, [edi + BOX.left - 2]
2365
        mov     eax, [edi + BOX.left - 2]
2366
        mov     ax, word[edi + BOX.left]
2366
        mov     ax, word[edi + BOX.left]
2367
        add     ax, word[edi + BOX.width]
2367
        add     ax, word[edi + BOX.width]
2368
        mov     ebx, [edi + BOX.top - 2]
2368
        mov     ebx, [edi + BOX.top - 2]
2369
        mov     bx, word[edi + BOX.top]
2369
        mov     bx, word[edi + BOX.top]
2370
        add     bx, word[edi + BOX.height]
2370
        add     bx, word[edi + BOX.height]
2371
        call    draw_rectangle.forced
2371
        call    draw_rectangle.forced
2372
        pop     esi ebx eax
2372
        pop     esi ebx eax
2373
        ret
2373
        ret
2374
;------------------------------------------------------------------------------
2374
;------------------------------------------------------------------------------
2375
;align 4
2375
;align 4
2376
;------------------------------------------------------------------------------
2376
;------------------------------------------------------------------------------
2377
;window._.end_moving__box: ;//////////////////////////////////////////////////
2377
;window._.end_moving__box: ;//////////////////////////////////////////////////
2378
;------------------------------------------------------------------------------
2378
;------------------------------------------------------------------------------
2379
;? Draw positive box
2379
;? Draw positive box
2380
;------------------------------------------------------------------------------
2380
;------------------------------------------------------------------------------
2381
;> edi = pointer to BOX struct
2381
;> edi = pointer to BOX struct
2382
;------------------------------------------------------------------------------
2382
;------------------------------------------------------------------------------
2383
;        push    eax ebx esi
2383
;        push    eax ebx esi
2384
;        xor     esi, esi
2384
;        xor     esi, esi
2385
;        jmp     window._.draw_negative_box.1
2385
;        jmp     window._.draw_negative_box.1
2386
;------------------------------------------------------------------------------
2386
;------------------------------------------------------------------------------
2387
 
2387
 
2388
 
2388
 
2389
align 4
2389
align 4
2390
; void __fastcall get_window_rect(struct RECT* rc);
2390
; void __fastcall get_window_rect(struct RECT* rc);
2391
; ecx = pointer to RECT
2391
; ecx = pointer to RECT
2392
window._.get_rect:
2392
window._.get_rect:
2393
        mov     eax, [current_slot_idx]
2393
        mov     eax, [current_slot_idx]
2394
        shl     eax, BSF sizeof.WDATA
2394
        shl     eax, BSF sizeof.WDATA
2395
 
2395
 
2396
        mov     edx, [eax + window_data + WDATA.box.left]
2396
        mov     edx, [eax + window_data + WDATA.box.left]
2397
        mov     [ecx+RECT.left], edx
2397
        mov     [ecx+RECT.left], edx
2398
 
2398
 
2399
        add     edx, [eax + window_data + WDATA.box.width]
2399
        add     edx, [eax + window_data + WDATA.box.width]
2400
        mov     [ecx+RECT.right], edx
2400
        mov     [ecx+RECT.right], edx
2401
 
2401
 
2402
        mov     edx, [eax +window_data + WDATA.box.top]
2402
        mov     edx, [eax +window_data + WDATA.box.top]
2403
        mov     [ecx+RECT.top], edx
2403
        mov     [ecx+RECT.top], edx
2404
 
2404
 
2405
        add     edx, [eax + window_data + WDATA.box.height]
2405
        add     edx, [eax + window_data + WDATA.box.height]
2406
        mov     [ecx+RECT.bottom], edx
2406
        mov     [ecx+RECT.bottom], edx
2407
        ret
2407
        ret
2408
;------------------------------------------------------------------------------
2408
;------------------------------------------------------------------------------
2409
 
2409
 
2410
 
2410
 
2411
align 4
2411
align 4
2412
; redraw all windows one above the window
2412
; redraw all windows one above the window
2413
;> eax = left
2413
;> eax = left
2414
;> ebx = top
2414
;> ebx = top
2415
;> ecx = right
2415
;> ecx = right
2416
;> edx = bottom
2416
;> edx = bottom
2417
;> esi = process number
2417
;> esi = process number
2418
;! corrupted edi
2418
;! corrupted edi
2419
window._.redraw_top_wnd:
2419
window._.redraw_top_wnd:
2420
        push    0
2420
        push    0
2421
        jmp     window._.set_top_wnd.go
2421
        jmp     window._.set_top_wnd.go
2422
;------------------------------------------------------------------------------
2422
;------------------------------------------------------------------------------
2423
 
2423
 
2424
 
2424
 
2425
align 4
2425
align 4
2426
; call set_screen for all windows one above the window
2426
; call set_screen for all windows one above the window
2427
;> eax = left
2427
;> eax = left
2428
;> ebx = top
2428
;> ebx = top
2429
;> ecx = right
2429
;> ecx = right
2430
;> edx = bottom
2430
;> edx = bottom
2431
;> esi = process number
2431
;> esi = process number
2432
;! corrupted edi
2432
;! corrupted edi
2433
window._.set_top_wnd:
2433
window._.set_top_wnd:
2434
        push    1
2434
        push    1
2435
.go:
2435
.go:
2436
        push    esi
2436
        push    esi
2437
        pushfd
2437
        pushfd
2438
        cli
2438
        cli
2439
 
2439
 
2440
        push    ebp
2440
        push    ebp
2441
        mov     ebp, [thread_count]
2441
        mov     ebp, [thread_count]
2442
        cmp     ebp, 1
2442
        cmp     ebp, 1
2443
        jbe     .exit
2443
        jbe     .exit
2444
 
2444
 
2445
        shl     esi, BSF sizeof.WDATA
2445
        shl     esi, BSF sizeof.WDATA
2446
        cmp     [esi + window_data + WDATA.z_modif], ZPOS_ALWAYS_TOP
2446
        cmp     [esi + window_data + WDATA.z_modif], ZPOS_ALWAYS_TOP
2447
        je      .exit
2447
        je      .exit
2448
 
2448
 
2449
        push    eax ;for num layout
2449
        push    eax ;for num layout
2450
        push    edx ecx ebx eax
2450
        push    edx ecx ebx eax
2451
 
2451
 
2452
        movsx   eax, byte [esi + window_data + WDATA.z_modif]
2452
        movsx   eax, byte [esi + window_data + WDATA.z_modif]
2453
        inc     eax
2453
        inc     eax
2454
        mov     dword[esp+10h], eax
2454
        mov     dword[esp+10h], eax
2455
;--------------------------------------
2455
;--------------------------------------
2456
align 4
2456
align 4
2457
.layout:
2457
.layout:
2458
        mov     esi, 1        ; = num in window stack
2458
        mov     esi, 1        ; = num in window stack
2459
        mov     ebp, [thread_count]
2459
        mov     ebp, [thread_count]
2460
;--------------------------------------
2460
;--------------------------------------
2461
align 4
2461
align 4
2462
.next_window:
2462
.next_window:
2463
        movzx   edi, word[WIN_POS + esi * 2]
2463
        movzx   edi, word[WIN_POS + esi * 2]
2464
        shl     edi, BSF sizeof.WDATA         ;size of TASKDATA and WDATA = 32 bytes
2464
        shl     edi, BSF sizeof.WDATA         ;size of TASKDATA and WDATA = 32 bytes
2465
 
2465
 
2466
        cmp     byte [SLOT_BASE + edi*8 + APPDATA.state], TSTATE_FREE
2466
        cmp     byte [SLOT_BASE + edi*8 + APPDATA.state], TSTATE_FREE
2467
        je      .skip_window
2467
        je      .skip_window
2468
 
2468
 
2469
        add     edi, window_data
2469
        add     edi, window_data
2470
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
2470
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
2471
        jnz     .skip_window
2471
        jnz     .skip_window
2472
 
2472
 
2473
        mov     eax, [esp+10h]
2473
        mov     eax, [esp+10h]
2474
        cmp     [edi + WDATA.z_modif], al
2474
        cmp     [edi + WDATA.z_modif], al
2475
        jne     .skip_window
2475
        jne     .skip_window
2476
 
2476
 
2477
        mov     eax, [edi + WDATA.box.left]
2477
        mov     eax, [edi + WDATA.box.left]
2478
        cmp     eax, [esp + RECT.right]
2478
        cmp     eax, [esp + RECT.right]
2479
        jg      .skip_window
2479
        jg      .skip_window
2480
        mov     ebx, [edi + WDATA.box.top]
2480
        mov     ebx, [edi + WDATA.box.top]
2481
        cmp     ebx, [esp + RECT.bottom]
2481
        cmp     ebx, [esp + RECT.bottom]
2482
        jg      .skip_window
2482
        jg      .skip_window
2483
        mov     ecx, [edi + WDATA.box.width]
2483
        mov     ecx, [edi + WDATA.box.width]
2484
        add     ecx, eax
2484
        add     ecx, eax
2485
        cmp     ecx, [esp + RECT.left]
2485
        cmp     ecx, [esp + RECT.left]
2486
        jl      .skip_window
2486
        jl      .skip_window
2487
        mov     edx, [edi + WDATA.box.height]
2487
        mov     edx, [edi + WDATA.box.height]
2488
        add     edx, ebx
2488
        add     edx, ebx
2489
        cmp     edx, [esp + RECT.top]
2489
        cmp     edx, [esp + RECT.top]
2490
        jl      .skip_window
2490
        jl      .skip_window
2491
 
2491
 
2492
        cmp     eax, [esp + RECT.left]
2492
        cmp     eax, [esp + RECT.left]
2493
        jae     @f
2493
        jae     @f
2494
        mov     eax, [esp + RECT.left]
2494
        mov     eax, [esp + RECT.left]
2495
;--------------------------------------
2495
;--------------------------------------
2496
align 4
2496
align 4
2497
@@:
2497
@@:
2498
        cmp     ebx, [esp + RECT.top]
2498
        cmp     ebx, [esp + RECT.top]
2499
        jae     @f
2499
        jae     @f
2500
        mov     ebx, [esp + RECT.top]
2500
        mov     ebx, [esp + RECT.top]
2501
;--------------------------------------
2501
;--------------------------------------
2502
align 4
2502
align 4
2503
@@:
2503
@@:
2504
        cmp     ecx, [esp + RECT.right]
2504
        cmp     ecx, [esp + RECT.right]
2505
        jbe     @f
2505
        jbe     @f
2506
        mov     ecx, [esp + RECT.right]
2506
        mov     ecx, [esp + RECT.right]
2507
;--------------------------------------
2507
;--------------------------------------
2508
align 4
2508
align 4
2509
@@:
2509
@@:
2510
        cmp     edx, [esp + RECT.bottom]
2510
        cmp     edx, [esp + RECT.bottom]
2511
        jbe     @f
2511
        jbe     @f
2512
        mov     edx, [esp + RECT.bottom]
2512
        mov     edx, [esp + RECT.bottom]
2513
;--------------------------------------
2513
;--------------------------------------
2514
align 4
2514
align 4
2515
@@:
2515
@@:
2516
        cmp     dword[esp+32], 0
2516
        cmp     dword[esp+32], 0
2517
        je      .set_fl_redraw
2517
        je      .set_fl_redraw
2518
 
2518
 
2519
        push    esi
2519
        push    esi
2520
        movzx   esi, word[WIN_POS + esi * 2]
2520
        movzx   esi, word[WIN_POS + esi * 2]
2521
        call    window._.set_screen
2521
        call    window._.set_screen
2522
        pop     esi
2522
        pop     esi
2523
        jmp     @f
2523
        jmp     @f
2524
.set_fl_redraw:
2524
.set_fl_redraw:
2525
        mov     [edi + WDATA.fl_redraw], 1      ;set redraw flag
2525
        mov     [edi + WDATA.fl_redraw], 1      ;set redraw flag
2526
     @@:
2526
     @@:
2527
;--------------------------------------
2527
;--------------------------------------
2528
align 4
2528
align 4
2529
.skip_window:
2529
.skip_window:
2530
        inc     esi
2530
        inc     esi
2531
        dec     ebp
2531
        dec     ebp
2532
        jnz     .next_window
2532
        jnz     .next_window
2533
;--------------------------------------
2533
;--------------------------------------
2534
        inc     dword[esp+10h]
2534
        inc     dword[esp+10h]
2535
        cmp     byte[esp+10h], ZPOS_ALWAYS_TOP
2535
        cmp     byte[esp+10h], ZPOS_ALWAYS_TOP
2536
        jle     .layout
2536
        jle     .layout
2537
;-------------------------------------
2537
;-------------------------------------
2538
 
2538
 
2539
        pop     eax ebx ecx edx
2539
        pop     eax ebx ecx edx
2540
        pop     ebp     ;del num layout
2540
        pop     ebp     ;del num layout
2541
;-------------------------------------
2541
;-------------------------------------
2542
align 4
2542
align 4
2543
.exit:
2543
.exit:
2544
 
2544
 
2545
        pop     ebp
2545
        pop     ebp
2546
        popfd
2546
        popfd
2547
        pop     esi
2547
        pop     esi
2548
 
2548
 
2549
        add     esp, 4   ;dword for 0/1 - set_screen/fl_redraw
2549
        add     esp, 4   ;dword for 0/1 - set_screen/fl_redraw
2550
        ret
2550
        ret