Subversion Repositories Kolibri OS

Rev

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

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