Subversion Repositories Kolibri OS

Rev

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

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