Subversion Repositories Kolibri OS

Rev

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

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