Subversion Repositories Kolibri OS

Rev

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

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