Subversion Repositories Kolibri OS

Rev

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

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