Subversion Repositories Kolibri OS

Rev

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

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