Subversion Repositories Kolibri OS

Rev

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

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