Subversion Repositories Kolibri OS

Rev

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

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