Subversion Repositories Kolibri OS

Rev

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

Rev 425 Rev 431
1
$Revision: 425 $
1
$Revision: 431 $
-
 
2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
3
;;                                                              ;;
-
 
4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
-
 
5
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
-
 
6
;; Distributed under terms of the GNU General Public License    ;;
-
 
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
8
 
2
get_titlebar_height: ; edi = window draw_data pointer
9
get_titlebar_height: ; edi = window draw_data pointer
3
	mov	al,[edi+WDATA.fl_wstyle]
10
	mov	al,[edi+WDATA.fl_wstyle]
4
	and	al,0x0F
11
	and	al,0x0F
5
	cmp	al,0x03
12
	cmp	al,0x03
6
	jne	@f
13
	jne	@f
7
	mov	eax,[_skinh]
14
	mov	eax,[_skinh]
8
	ret
15
	ret
9
    @@: mov	eax,21
16
    @@: mov	eax,21
10
	ret
17
	ret
11
 
18
 
12
get_rolledup_height: ; edi = window draw_data pointer
19
get_rolledup_height: ; edi = window draw_data pointer
13
	mov	al,[edi+WDATA.fl_wstyle]
20
	mov	al,[edi+WDATA.fl_wstyle]
14
	and	al,0x0F
21
	and	al,0x0F
15
	cmp	al,0x03
22
	cmp	al,0x03
16
	jne	@f
23
	jne	@f
17
	mov	eax,[_skinh]
24
	mov	eax,[_skinh]
18
	add	eax,3
25
	add	eax,3
19
	ret
26
	ret
20
    @@: or	al,al
27
    @@: or	al,al
21
	jnz	@f
28
	jnz	@f
22
	mov	eax,21
29
	mov	eax,21
23
	ret
30
	ret
24
    @@: mov	eax,21+2
31
    @@: mov	eax,21+2
25
	ret
32
	ret
26
 
33
 
27
 
34
 
28
setwindowdefaults:
35
setwindowdefaults:
29
	pushad
36
	pushad
30
 
37
 
31
	xor   eax,eax
38
	xor   eax,eax
32
	mov   ecx,WIN_STACK
39
	mov   ecx,WIN_STACK
33
       @@:
40
       @@:
34
	inc   eax
41
	inc   eax
35
	add   ecx,2
42
	add   ecx,2
36
	mov   [ecx+0x000],ax	      ; process no
43
	mov   [ecx+0x000],ax	      ; process no
37
	mov   [ecx+0x400],ax	      ; positions in stack
44
	mov   [ecx+0x400],ax	      ; positions in stack
38
	cmp   ecx,WIN_POS-2	       ; the more high, the more surface
45
	cmp   ecx,WIN_POS-2	       ; the more high, the more surface
39
	jnz   @b
46
	jnz   @b
40
 
47
 
41
	popad
48
	popad
42
	ret
49
	ret
43
 
50
 
44
 
51
 
45
 
52
 
46
; eax = cx
53
; eax = cx
47
; ebx = cy
54
; ebx = cy
48
; ecx = ex
55
; ecx = ex
49
; edx = ey
56
; edx = ey
50
; èäåÿ: ïåðåáðàòü âñå îêíà, íà÷èíàÿ ñ ñàìîãî íèæíåãî,
57
; èäåÿ: ïåðåáðàòü âñå îêíà, íà÷èíàÿ ñ ñàìîãî íèæíåãî,
51
;       è äëÿ ïîïàâøèõ â çàäàííóþ îáëàñòü
58
;       è äëÿ ïîïàâøèõ â çàäàííóþ îáëàñòü
52
;       ÷àñòåé îêîí âûçâàòü setscreen
59
;       ÷àñòåé îêîí âûçâàòü setscreen
53
align 4
60
align 4
54
calculatescreen:
61
calculatescreen:
55
	pushad
62
	pushad
56
	pushfd
63
	pushfd
57
	cli
64
	cli
58
 
65
 
59
	push	edx ecx ebx eax
66
	push	edx ecx ebx eax
60
 
67
 
61
	mov	esi, 1
68
	mov	esi, 1
62
	call	setscreen
69
	call	setscreen
63
 
70
 
64
	mov	ebp, [TASK_COUNT]	 ; number of processes
71
	mov	ebp, [TASK_COUNT]	 ; number of processes
65
	cmp	ebp, 1
72
	cmp	ebp, 1
66
	jbe	.finish
73
	jbe	.finish
67
	align 4
74
	align 4
68
      .new_wnd:
75
      .new_wnd:
69
	movzx	edi, word [WIN_POS + esi * 2]
76
	movzx	edi, word [WIN_POS + esi * 2]
70
	shl	edi, 5
77
	shl	edi, 5
71
 
78
 
72
	cmp	[CURRENT_TASK+edi+TASKDATA.state], byte 9
79
	cmp	[CURRENT_TASK+edi+TASKDATA.state], byte 9
73
	je	.not_wnd
80
	je	.not_wnd
74
 
81
 
75
	add	edi, window_data
82
	add	edi, window_data
76
	test	[edi+WDATA.fl_wstate], WSTATE_MINIMIZED
83
	test	[edi+WDATA.fl_wstate], WSTATE_MINIMIZED
77
	jnz	.not_wnd
84
	jnz	.not_wnd
78
 
85
 
79
	mov	eax,[edi+WDATA.box.left]
86
	mov	eax,[edi+WDATA.box.left]
80
	cmp	eax, [esp+RECT.right]
87
	cmp	eax, [esp+RECT.right]
81
	ja	.out_of_bounds
88
	ja	.out_of_bounds
82
	mov	ebx,[edi+WDATA.box.top]
89
	mov	ebx,[edi+WDATA.box.top]
83
	cmp	ebx, [esp+RECT.bottom]
90
	cmp	ebx, [esp+RECT.bottom]
84
	ja	.out_of_bounds
91
	ja	.out_of_bounds
85
	mov	ecx,[edi+WDATA.box.width]
92
	mov	ecx,[edi+WDATA.box.width]
86
	add	ecx, eax
93
	add	ecx, eax
87
	cmp	ecx, [esp+RECT.left]
94
	cmp	ecx, [esp+RECT.left]
88
	jb	.out_of_bounds
95
	jb	.out_of_bounds
89
	mov	edx,[edi+WDATA.box.height]
96
	mov	edx,[edi+WDATA.box.height]
90
	add	edx, ebx
97
	add	edx, ebx
91
	cmp	edx, [esp+RECT.top]
98
	cmp	edx, [esp+RECT.top]
92
	jb	.out_of_bounds
99
	jb	.out_of_bounds
93
 
100
 
94
    cmp     eax, [esp+RECT.left]
101
    cmp     eax, [esp+RECT.left]
95
	jae	@f
102
	jae	@f
96
	mov	eax, [esp+RECT.left]
103
	mov	eax, [esp+RECT.left]
97
     @@:
104
     @@:
98
    cmp     ebx, [esp+RECT.top]
105
    cmp     ebx, [esp+RECT.top]
99
	jae	@f
106
	jae	@f
100
	mov	ebx, [esp+RECT.top]
107
	mov	ebx, [esp+RECT.top]
101
     @@:
108
     @@:
102
    cmp     ecx, [esp+RECT.right]
109
    cmp     ecx, [esp+RECT.right]
103
	jbe	@f
110
	jbe	@f
104
	mov	ecx, [esp+RECT.right]
111
	mov	ecx, [esp+RECT.right]
105
     @@:
112
     @@:
106
    cmp     edx, [esp+RECT.bottom]
113
    cmp     edx, [esp+RECT.bottom]
107
	jbe	@f
114
	jbe	@f
108
	mov	edx, [esp+RECT.bottom]
115
	mov	edx, [esp+RECT.bottom]
109
     @@:
116
     @@:
110
 
117
 
111
	push	esi
118
	push	esi
112
	movzx	esi, word [WIN_POS + esi * 2]
119
	movzx	esi, word [WIN_POS + esi * 2]
113
	call	setscreen
120
	call	setscreen
114
	pop	esi
121
	pop	esi
115
 
122
 
116
      .not_wnd:
123
      .not_wnd:
117
      .out_of_bounds:
124
      .out_of_bounds:
118
	inc	esi
125
	inc	esi
119
	dec	ebp
126
	dec	ebp
120
	jnz	.new_wnd
127
	jnz	.new_wnd
121
      .finish:
128
      .finish:
122
 
129
 
123
    pop     eax ebx ecx edx
130
    pop     eax ebx ecx edx
124
 
131
 
125
	popfd
132
	popfd
126
	popad
133
	popad
127
ret
134
ret
128
 
135
 
129
 
136
 
130
 
137
 
131
virtual at esp
138
virtual at esp
132
  ff_x	   dd ?
139
  ff_x	   dd ?
133
  ff_y	   dd ?
140
  ff_y	   dd ?
134
  ff_width dd ?
141
  ff_width dd ?
135
  ff_xsz   dd ?
142
  ff_xsz   dd ?
136
  ff_ysz   dd ?
143
  ff_ysz   dd ?
137
  ff_scale dd ?
144
  ff_scale dd ?
138
end virtual
145
end virtual
139
 
146
 
140
align 4
147
align 4
141
; ðåçåðâèðóåò ìåñòî ïîä îêíî çàäàííîãî ïðîöåññà
148
; ðåçåðâèðóåò ìåñòî ïîä îêíî çàäàííîãî ïðîöåññà
142
setscreen:
149
setscreen:
143
;  eax  x start
150
;  eax  x start
144
;  ebx  y start
151
;  ebx  y start
145
;  ecx  x end
152
;  ecx  x end
146
;  edx  y end
153
;  edx  y end
147
;  esi  process number
154
;  esi  process number
148
pushad
155
pushad
149
; \begin{diamond}[29.08.2006]
156
; \begin{diamond}[29.08.2006]
150
	cmp	esi, 1
157
	cmp	esi, 1
151
	jz	@f
158
	jz	@f
152
	mov	edi, esi
159
	mov	edi, esi
153
	shl	edi, 5
160
	shl	edi, 5
154
	cmp	[edi+window_data+WDATA.box.width], 0
161
	cmp	[edi+window_data+WDATA.box.width], 0
155
	jnz	@f
162
	jnz	@f
156
	cmp	[edi+window_data+WDATA.box.height], 0
163
	cmp	[edi+window_data+WDATA.box.height], 0
157
	jz	.ret
164
	jz	.ret
158
@@:
165
@@:
159
; \end{diamond}[29.08.2006]
166
; \end{diamond}[29.08.2006]
160
	mov edi, esi ;;;word [esi*2+WIN_POS]
167
	mov edi, esi ;;;word [esi*2+WIN_POS]
161
	shl   edi, 8
168
	shl   edi, 8
162
	add   edi, SLOT_BASE  ; address of random shaped window area
169
	add   edi, SLOT_BASE  ; address of random shaped window area
163
	cmp   [edi+APPDATA.wnd_shape], dword 0
170
	cmp   [edi+APPDATA.wnd_shape], dword 0
164
	jne   .free_form
171
	jne   .free_form
165
 
172
 
166
	; get x&y size
173
	; get x&y size
167
	sub   ecx, eax
174
	sub   ecx, eax
168
	sub   edx, ebx
175
	sub   edx, ebx
169
	inc   ecx
176
	inc   ecx
170
	inc   edx
177
	inc   edx
171
 
178
 
172
	; get WinMap start
179
	; get WinMap start
173
	mov   edi, [ScreenWidth] ; screen_sx
180
	mov   edi, [ScreenWidth] ; screen_sx
174
	inc   edi
181
	inc   edi
175
	imul  edi, ebx
182
	imul  edi, ebx
176
	add   edi, eax
183
	add   edi, eax
177
	add   edi, WinMapAddress
184
	add   edi, WinMapAddress
178
 
185
 
179
  .new_y:
186
  .new_y:
180
	push  ecx ; sx
187
	push  ecx ; sx
181
	push  edx
188
	push  edx
182
 
189
 
183
	mov   edx, esi
190
	mov   edx, esi
184
	align 4
191
	align 4
185
  .new_x:
192
  .new_x:
186
	mov   byte [edi], dl
193
	mov   byte [edi], dl
187
	inc   edi
194
	inc   edi
188
	dec   ecx
195
	dec   ecx
189
	jnz   .new_x
196
	jnz   .new_x
190
 
197
 
191
	pop   edx
198
	pop   edx
192
	pop   ecx
199
	pop   ecx
193
	add   edi, [ScreenWidth]
200
	add   edi, [ScreenWidth]
194
	inc   edi
201
	inc   edi
195
	sub   edi, ecx
202
	sub   edi, ecx
196
	dec   edx
203
	dec   edx
197
	jnz   .new_y
204
	jnz   .new_y
198
.ret:
205
.ret:
199
 popad
206
 popad
200
 ret
207
 ret
201
  .read_byte:
208
  .read_byte:
202
   ;eax - address
209
   ;eax - address
203
   ;esi - slot
210
   ;esi - slot
204
	push  eax
211
	push  eax
205
	push  ebx
212
	push  ebx
206
	push  ecx
213
	push  ecx
207
	push  edx
214
	push  edx
208
	mov   edx,eax
215
	mov   edx,eax
209
	mov   eax,esi
216
	mov   eax,esi
210
	lea   ebx,[esp+12]
217
	lea   ebx,[esp+12]
211
	mov   ecx,1
218
	mov   ecx,1
212
	call  read_process_memory
219
	call  read_process_memory
213
	pop   edx
220
	pop   edx
214
	pop   ecx
221
	pop   ecx
215
	pop   ebx
222
	pop   ebx
216
	pop   eax
223
	pop   eax
217
	ret
224
	ret
218
  .free_form:
225
  .free_form:
219
 
226
 
220
	;  for (y=0; y <= x_size; y++)
227
	;  for (y=0; y <= x_size; y++)
221
	;      for (x=0; x <= x_size; x++)
228
	;      for (x=0; x <= x_size; x++)
222
	;          if (shape[coord(x,y,scale)]==1)
229
	;          if (shape[coord(x,y,scale)]==1)
223
	;             set_pixel(x, y, process_number);
230
	;             set_pixel(x, y, process_number);
224
 
231
 
225
	sub  ecx, eax
232
	sub  ecx, eax
226
	sub  edx, ebx
233
	sub  edx, ebx
227
	inc  ecx
234
	inc  ecx
228
	inc  edx
235
	inc  edx
229
 
236
 
230
	push  dword [edi+APPDATA.wnd_shape_scale]  ; push scale first -> for loop
237
	push  dword [edi+APPDATA.wnd_shape_scale]  ; push scale first -> for loop
231
 
238
 
232
	; get WinMap start  -> ebp
239
	; get WinMap start  -> ebp
233
	push  eax
240
	push  eax
234
	mov   eax, [ScreenWidth] ; screen_sx
241
	mov   eax, [ScreenWidth] ; screen_sx
235
	inc   eax
242
	inc   eax
236
	imul  eax, ebx
243
	imul  eax, ebx
237
	add   eax, [esp]
244
	add   eax, [esp]
238
	add   eax, WinMapAddress
245
	add   eax, WinMapAddress
239
	mov   ebp, eax
246
	mov   ebp, eax
240
 
247
 
241
	mov   edi, [edi+APPDATA.wnd_shape]
248
	mov   edi, [edi+APPDATA.wnd_shape]
242
	pop   eax
249
	pop   eax
243
 
250
 
244
	; eax = x_start
251
	; eax = x_start
245
	; ebx = y_start
252
	; ebx = y_start
246
	; ecx = x_size
253
	; ecx = x_size
247
	; edx = y_size
254
	; edx = y_size
248
	; esi = process_number
255
	; esi = process_number
249
	; edi = &shape
256
	; edi = &shape
250
	;       [scale]
257
	;       [scale]
251
	push edx ecx ; for loop - x,y size
258
	push edx ecx ; for loop - x,y size
252
 
259
 
253
	mov  ecx, esi
260
	mov  ecx, esi
254
	shl  ecx, 5
261
	shl  ecx, 5
255
	mov  edx, [window_data+ecx+WDATA.box.top]
262
	mov  edx, [window_data+ecx+WDATA.box.top]
256
	push [window_data+ecx+WDATA.box.width]	    ; for loop - width
263
	push [window_data+ecx+WDATA.box.width]	    ; for loop - width
257
	mov  ecx, [window_data+ecx+WDATA.box.left]
264
	mov  ecx, [window_data+ecx+WDATA.box.left]
258
	sub  ebx, edx
265
	sub  ebx, edx
259
	sub  eax, ecx
266
	sub  eax, ecx
260
	push ebx eax ; for loop - x,y
267
	push ebx eax ; for loop - x,y
261
 
268
 
262
	add  [ff_xsz], eax
269
	add  [ff_xsz], eax
263
	add  [ff_ysz], ebx
270
	add  [ff_ysz], ebx
264
 
271
 
265
	mov  ebx, [ff_y]
272
	mov  ebx, [ff_y]
266
 
273
 
267
      .ff_new_y:
274
      .ff_new_y:
268
	mov  edx, [ff_x]
275
	mov  edx, [ff_x]
269
 
276
 
270
      .ff_new_x:
277
      .ff_new_x:
271
	; -- body --
278
	; -- body --
272
	mov  ecx, [ff_scale]
279
	mov  ecx, [ff_scale]
273
	mov  eax, [ff_width]
280
	mov  eax, [ff_width]
274
	inc  eax
281
	inc  eax
275
	shr  eax, cl
282
	shr  eax, cl
276
	push ebx edx
283
	push ebx edx
277
	shr  ebx, cl
284
	shr  ebx, cl
278
	shr  edx, cl
285
	shr  edx, cl
279
	imul eax, ebx
286
	imul eax, ebx
280
	add  eax, edx
287
	add  eax, edx
281
	pop  edx ebx
288
	pop  edx ebx
282
	add  eax, edi
289
	add  eax, edi
283
	call .read_byte
290
	call .read_byte
284
	test al,al
291
	test al,al
285
	jz   @f
292
	jz   @f
286
	mov  eax, esi
293
	mov  eax, esi
287
	mov  [ebp], al
294
	mov  [ebp], al
288
       @@:
295
       @@:
289
	; -- end body --
296
	; -- end body --
290
	inc  ebp
297
	inc  ebp
291
	inc  edx
298
	inc  edx
292
	cmp  edx, [ff_xsz]
299
	cmp  edx, [ff_xsz]
293
	jb   .ff_new_x
300
	jb   .ff_new_x
294
	sub  ebp, [ff_xsz]
301
	sub  ebp, [ff_xsz]
295
	add  ebp, [ff_x]
302
	add  ebp, [ff_x]
296
	add  ebp, [ScreenWidth]  ; screen.x
303
	add  ebp, [ScreenWidth]  ; screen.x
297
	inc  ebp
304
	inc  ebp
298
	inc  ebx
305
	inc  ebx
299
	cmp  ebx, [ff_ysz]
306
	cmp  ebx, [ff_ysz]
300
	jb   .ff_new_y
307
	jb   .ff_new_y
301
 
308
 
302
	add  esp, 24
309
	add  esp, 24
303
popad
310
popad
304
ret
311
ret
305
 
312
 
306
 
313
 
307
display_settings:
314
display_settings:
308
 
315
 
309
;    eax = 0         ; DISPLAY redraw
316
;    eax = 0         ; DISPLAY redraw
310
;          ebx = 0   ; all
317
;          ebx = 0   ; all
311
;
318
;
312
;    eax = 1         ; BUTTON type
319
;    eax = 1         ; BUTTON type
313
;          ebx = 0   ; flat
320
;          ebx = 0   ; flat
314
;          ebx = 1   ; 3D
321
;          ebx = 1   ; 3D
315
;    eax = 2         ; set WINDOW colours
322
;    eax = 2         ; set WINDOW colours
316
;          ebx = pointer to table
323
;          ebx = pointer to table
317
;          ecx = number of bytes define
324
;          ecx = number of bytes define
318
;    eax = 3         ; get WINDOW colours
325
;    eax = 3         ; get WINDOW colours
319
;          ebx = pointer to table
326
;          ebx = pointer to table
320
;          ecx = number of bytes wanted
327
;          ecx = number of bytes wanted
321
;    eax = 4         ; get skin height
328
;    eax = 4         ; get skin height
322
;          input  : nothing
329
;          input  : nothing
323
;          output : eax = skin height in pixel
330
;          output : eax = skin height in pixel
324
;    eax = 5         ; get screen workarea
331
;    eax = 5         ; get screen workarea
325
;          input  : nothing
332
;          input  : nothing
326
;          output : eax = [left]*65536+[right]
333
;          output : eax = [left]*65536+[right]
327
;                   ebx = [top]*65536+[bottom]
334
;                   ebx = [top]*65536+[bottom]
328
;    eax = 6         ; set screen workarea
335
;    eax = 6         ; set screen workarea
329
;          input  : ecx = [left]*65536+[right]
336
;          input  : ecx = [left]*65536+[right]
330
;                   edx = [top]*65536+[bottom]
337
;                   edx = [top]*65536+[bottom]
331
;          output : nothing
338
;          output : nothing
332
;    eax = 7         ; get skin margins
339
;    eax = 7         ; get skin margins
333
;          input  : nothing
340
;          input  : nothing
334
;          output : eax = [left]*65536+[right]
341
;          output : eax = [left]*65536+[right]
335
;                   ebx = [top]*65536+[bottom]
342
;                   ebx = [top]*65536+[bottom]
336
;    eax = 8         ; set window skin
343
;    eax = 8         ; set window skin
337
;          input  : ecx = pointer to file info block
344
;          input  : ecx = pointer to file info block
338
;          output : eax = FS error code
345
;          output : eax = FS error code
339
 
346
 
340
 
347
 
341
     pushad
348
     pushad
342
 
349
 
343
     test eax, eax	; redraw display
350
     test eax, eax	; redraw display
344
     jnz  dspl0
351
     jnz  dspl0
345
     test ebx, ebx
352
     test ebx, ebx
346
     jnz  dspl0
353
     jnz  dspl0
347
     cmp  [windowtypechanged],dword 1
354
     cmp  [windowtypechanged],dword 1
348
     jne  dspl00
355
     jne  dspl00
349
     mov  [windowtypechanged],dword 0
356
     mov  [windowtypechanged],dword 0
350
  redraw_screen_direct:
357
  redraw_screen_direct:
351
     mov  [dlx],dword 0
358
     mov  [dlx],dword 0
352
     mov  [dly],dword 0
359
     mov  [dly],dword 0
353
     mov  eax,[ScreenWidth]
360
     mov  eax,[ScreenWidth]
354
     mov  [dlxe],eax
361
     mov  [dlxe],eax
355
     mov  eax,[ScreenHeight]
362
     mov  eax,[ScreenHeight]
356
     mov  [dlye],eax
363
     mov  [dlye],eax
357
     mov  eax,window_data
364
     mov  eax,window_data
358
     call redrawscreen
365
     call redrawscreen
359
   dspl00:
366
   dspl00:
360
     popad
367
     popad
361
     ret
368
     ret
362
   dspl0:
369
   dspl0:
363
 
370
 
364
     cmp  eax,1       ; button type
371
     cmp  eax,1       ; button type
365
     jne  dspl1
372
     jne  dspl1
366
     and  ebx,1
373
     and  ebx,1
367
     cmp  ebx,[buttontype]
374
     cmp  ebx,[buttontype]
368
     je   dspl9
375
     je   dspl9
369
     mov  [buttontype],ebx
376
     mov  [buttontype],ebx
370
     mov  [windowtypechanged],dword 1
377
     mov  [windowtypechanged],dword 1
371
    dspl9:
378
    dspl9:
372
     popad
379
     popad
373
     ret
380
     ret
374
   dspl1:
381
   dspl1:
375
 
382
 
376
     cmp  eax,2       ; set common window colours
383
     cmp  eax,2       ; set common window colours
377
     jne  no_com_colours
384
     jne  no_com_colours
378
     mov  [windowtypechanged],dword 1
385
     mov  [windowtypechanged],dword 1
379
     mov  esi,[TASK_BASE]
386
     mov  esi,[TASK_BASE]
380
     add  esi,TASKDATA.mem_start
387
     add  esi,TASKDATA.mem_start
381
     add  ebx,[esi]
388
     add  ebx,[esi]
382
     mov  esi,ebx
389
     mov  esi,ebx
383
     mov  edi,common_colours
390
     mov  edi,common_colours
384
     and  ecx,127
391
     and  ecx,127
385
     cld
392
     cld
386
     rep  movsb
393
     rep  movsb
387
     popad
394
     popad
388
     ret
395
     ret
389
   no_com_colours:
396
   no_com_colours:
390
 
397
 
391
     cmp  eax,3       ; get common window colours
398
     cmp  eax,3       ; get common window colours
392
     jne  no_get_com
399
     jne  no_get_com
393
     mov  esi,[TASK_BASE]
400
     mov  esi,[TASK_BASE]
394
     add  esi,TASKDATA.mem_start
401
     add  esi,TASKDATA.mem_start
395
     add  ebx,[esi]
402
     add  ebx,[esi]
396
     mov  edi,ebx
403
     mov  edi,ebx
397
     mov  esi,common_colours
404
     mov  esi,common_colours
398
     and  ecx,127
405
     and  ecx,127
399
     cld
406
     cld
400
     rep  movsb
407
     rep  movsb
401
     popad
408
     popad
402
     ret
409
     ret
403
   no_get_com:
410
   no_get_com:
404
 
411
 
405
     cmp  eax,4       ; get skin height
412
     cmp  eax,4       ; get skin height
406
     jne  no_skin_height
413
     jne  no_skin_height
407
     popad
414
     popad
408
     mov  eax,[_skinh]
415
     mov  eax,[_skinh]
409
     mov  [esp+36],eax
416
     mov  [esp+36],eax
410
     ret
417
     ret
411
   no_skin_height:
418
   no_skin_height:
412
 
419
 
413
	cmp	eax,5	    ; get screen workarea
420
	cmp	eax,5	    ; get screen workarea
414
	jne	no_get_workarea
421
	jne	no_get_workarea
415
	popad
422
	popad
416
	mov	eax,[screen_workarea.left-2]
423
	mov	eax,[screen_workarea.left-2]
417
	mov	ax,word[screen_workarea.right]
424
	mov	ax,word[screen_workarea.right]
418
	mov	[esp+36],eax
425
	mov	[esp+36],eax
419
	mov	eax,[screen_workarea.top-2]
426
	mov	eax,[screen_workarea.top-2]
420
	mov	ax,word[screen_workarea.bottom]
427
	mov	ax,word[screen_workarea.bottom]
421
	mov	[esp+24],eax
428
	mov	[esp+24],eax
422
	ret
429
	ret
423
   no_get_workarea:
430
   no_get_workarea:
424
 
431
 
425
	cmp	eax,6	    ; set screen workarea
432
	cmp	eax,6	    ; set screen workarea
426
	jne	no_set_workarea
433
	jne	no_set_workarea
427
	movsx	eax,word[esp+16+2]
434
	movsx	eax,word[esp+16+2]
428
	movsx	ebx,word[esp+16]
435
	movsx	ebx,word[esp+16]
429
	cmp	eax,ebx
436
	cmp	eax,ebx
430
	jge	.lp1
437
	jge	.lp1
431
	or	eax,eax;[ScreenWidth]
438
	or	eax,eax;[ScreenWidth]
432
	jl	@f
439
	jl	@f
433
	mov	[screen_workarea.left],eax
440
	mov	[screen_workarea.left],eax
434
    @@: cmp	ebx,[ScreenWidth]
441
    @@: cmp	ebx,[ScreenWidth]
435
	jg	.lp1
442
	jg	.lp1
436
	mov	[screen_workarea.right],ebx
443
	mov	[screen_workarea.right],ebx
437
  .lp1: movsx	eax,word[esp+24+2]
444
  .lp1: movsx	eax,word[esp+24+2]
438
	movsx	ebx,word[esp+24]
445
	movsx	ebx,word[esp+24]
439
	cmp	eax,ebx
446
	cmp	eax,ebx
440
	jge	.lp2
447
	jge	.lp2
441
	or	eax,eax;[0xFE04]
448
	or	eax,eax;[0xFE04]
442
	jl	@f
449
	jl	@f
443
	mov	[screen_workarea.top],eax
450
	mov	[screen_workarea.top],eax
444
    @@: cmp	ebx,[ScreenHeight]
451
    @@: cmp	ebx,[ScreenHeight]
445
	jg	.lp2
452
	jg	.lp2
446
	mov	[screen_workarea.bottom],ebx
453
	mov	[screen_workarea.bottom],ebx
447
  .lp2: call	repos_windows
454
  .lp2: call	repos_windows
448
	mov	eax, 0
455
	mov	eax, 0
449
	mov	ebx, 0
456
	mov	ebx, 0
450
	mov	ecx, [ScreenWidth]
457
	mov	ecx, [ScreenWidth]
451
	mov	edx, [ScreenHeight]
458
	mov	edx, [ScreenHeight]
452
    call    calculatescreen
459
    call    calculatescreen
453
;    jmp    redraw_screen_direct
460
;    jmp    redraw_screen_direct
454
    .exit:
461
    .exit:
455
	popad
462
	popad
456
	ret
463
	ret
457
   no_set_workarea:
464
   no_set_workarea:
458
 
465
 
459
	cmp	eax,7	    ; get skin margins
466
	cmp	eax,7	    ; get skin margins
460
	jne	no_get_skinmargins
467
	jne	no_get_skinmargins
461
	popad
468
	popad
462
	mov	eax,dword[_skinmargins+0]
469
	mov	eax,dword[_skinmargins+0]
463
	mov	[esp+36],eax
470
	mov	[esp+36],eax
464
	mov	eax,dword[_skinmargins+4]
471
	mov	eax,dword[_skinmargins+4]
465
	mov	[esp+24],eax
472
	mov	[esp+24],eax
466
	ret
473
	ret
467
   no_get_skinmargins:
474
   no_get_skinmargins:
468
 
475
 
469
	cmp	eax,8	    ; set window skin
476
	cmp	eax,8	    ; set window skin
470
	jne	no_set_skin
477
	jne	no_set_skin
471
	mov	eax,ebx
478
	mov	eax,ebx
472
	mov	edi,[TASK_BASE]
479
	mov	edi,[TASK_BASE]
473
	add	ebx,[edi+TASKDATA.mem_start]	    ; abs start of info block
480
	add	ebx,[edi+TASKDATA.mem_start]	    ; abs start of info block
474
	pushd	[ebx+0] [ebx+4] [ebx+8] [ebx+12]
481
	pushd	[ebx+0] [ebx+4] [ebx+8] [ebx+12]
475
	mov	dword[ebx+0],0	      ; read
482
	mov	dword[ebx+0],0	      ; read
476
	mov	dword[ebx+4],0	      ; from the beginning
483
	mov	dword[ebx+4],0	      ; from the beginning
477
	mov	dword[ebx+8],64       ; 32 KBytes maximum
484
	mov	dword[ebx+8],64       ; 32 KBytes maximum
478
	mov	ecx,skin_data+64*512
485
	mov	ecx,skin_data+64*512
479
	sub	ecx,[edi+0x10]
486
	sub	ecx,[edi+0x10]
480
	mov	dword[ebx+12],ecx     ; destination
487
	mov	dword[ebx+12],ecx     ; destination
481
	push	eax
488
	push	eax
482
	pushad
489
	pushad
483
	call	file_system
490
	call	file_system
484
	popad
491
	popad
485
	pop    eax
492
	pop    eax
486
	popd	[ebx+12] [ebx+8] [ebx+4] [ebx+0]
493
	popd	[ebx+12] [ebx+8] [ebx+4] [ebx+0]
487
	cmp	eax,ERROR_SUCCESS
494
	cmp	eax,ERROR_SUCCESS
488
	je	@f
495
	je	@f
489
	cmp	eax,ERROR_END_OF_FILE
496
	cmp	eax,ERROR_END_OF_FILE
490
	jne	.exit
497
	jne	.exit
491
    @@: cmp	[skin_data+64*512+SKIN_HEADER.ident],'SKIN'
498
    @@: cmp	[skin_data+64*512+SKIN_HEADER.ident],'SKIN'
492
	mov	eax,ERROR_UNKNOWN_FS
499
	mov	eax,ERROR_UNKNOWN_FS
493
	jne	.exit
500
	jne	.exit
494
	mov	esi,skin_data+64*512
501
	mov	esi,skin_data+64*512
495
	mov	edi,skin_data
502
	mov	edi,skin_data
496
	mov	ecx,(64*512)/4
503
	mov	ecx,(64*512)/4
497
	rep	movsd
504
	rep	movsd
498
	call	parse_skin_data
505
	call	parse_skin_data
499
    pushad
506
    pushad
500
	mov	eax, 0
507
	mov	eax, 0
501
	mov	ebx, 0
508
	mov	ebx, 0
502
	mov	ecx, [ScreenWidth]
509
	mov	ecx, [ScreenWidth]
503
	mov	edx, [ScreenHeight]
510
	mov	edx, [ScreenHeight]
504
	call	calculatescreen
511
	call	calculatescreen
505
    popad
512
    popad
506
	mov	dword[esp+32+36],0
513
	mov	dword[esp+32+36],0
507
	jmp	redraw_screen_direct
514
	jmp	redraw_screen_direct
508
  .exit:
515
  .exit:
509
	mov	[esp+32+36],eax
516
	mov	[esp+32+36],eax
510
	popad
517
	popad
511
	ret
518
	ret
512
   no_set_skin:
519
   no_set_skin:
513
 
520
 
514
     popad
521
     popad
515
     ret
522
     ret
516
 
523
 
517
 
524
 
518
repos_windows:
525
repos_windows:
519
	mov	ecx,[TASK_COUNT]
526
	mov	ecx,[TASK_COUNT]
520
	mov	edi, OS_BASE+0x20*2
527
	mov	edi, OS_BASE+0x20*2
521
    mov    byte[REDRAW_BACKGROUND],1
528
    mov    byte[REDRAW_BACKGROUND],1
522
	dec	ecx
529
	dec	ecx
523
	jge    @f
530
	jge    @f
524
	ret
531
	ret
525
    @@: mov	[edi+WDATA.fl_redraw],1
532
    @@: mov	[edi+WDATA.fl_redraw],1
526
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
533
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
527
	jz	.lp2
534
	jz	.lp2
528
	mov	eax,[screen_workarea.left]
535
	mov	eax,[screen_workarea.left]
529
	mov	[edi+WDATA.box.left],eax
536
	mov	[edi+WDATA.box.left],eax
530
	sub	eax,[screen_workarea.right]
537
	sub	eax,[screen_workarea.right]
531
	neg	eax
538
	neg	eax
532
	mov	[edi+WDATA.box.width],eax
539
	mov	[edi+WDATA.box.width],eax
533
	mov	eax,[screen_workarea.top]
540
	mov	eax,[screen_workarea.top]
534
	mov	[edi+WDATA.box.top],eax
541
	mov	[edi+WDATA.box.top],eax
535
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
542
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
536
	jnz	.lp1
543
	jnz	.lp1
537
	sub	eax,[screen_workarea.bottom]
544
	sub	eax,[screen_workarea.bottom]
538
	neg	eax
545
	neg	eax
539
	mov	[edi+WDATA.box.height],eax
546
	mov	[edi+WDATA.box.height],eax
540
  .lp1:
547
  .lp1:
541
 
548
 
542
	call	set_window_clientbox
549
	call	set_window_clientbox
543
	add	edi,0x20
550
	add	edi,0x20
544
	loop	@b
551
	loop	@b
545
	ret
552
	ret
546
  .lp2: mov	eax,[edi+WDATA.box.left]
553
  .lp2: mov	eax,[edi+WDATA.box.left]
547
	add	eax,[edi+WDATA.box.width]
554
	add	eax,[edi+WDATA.box.width]
548
    mov    ebx,[ScreenWidth]
555
    mov    ebx,[ScreenWidth]
549
;    inc    ebx
556
;    inc    ebx
550
    cmp    eax,ebx
557
    cmp    eax,ebx
551
    jle    .lp4
558
    jle    .lp4
552
	mov	eax,[edi+WDATA.box.width]
559
	mov	eax,[edi+WDATA.box.width]
553
    sub    eax,ebx
560
    sub    eax,ebx
554
    jle    .lp3
561
    jle    .lp3
555
	mov	[edi+WDATA.box.width],ebx
562
	mov	[edi+WDATA.box.width],ebx
556
  .lp3: sub	ebx,[edi+WDATA.box.width]
563
  .lp3: sub	ebx,[edi+WDATA.box.width]
557
	mov	[edi+WDATA.box.left],ebx
564
	mov	[edi+WDATA.box.left],ebx
558
  .lp4: mov	eax,[edi+WDATA.box.top]
565
  .lp4: mov	eax,[edi+WDATA.box.top]
559
	add	eax,[edi+WDATA.box.height]
566
	add	eax,[edi+WDATA.box.height]
560
    mov    ebx,[ScreenHeight]
567
    mov    ebx,[ScreenHeight]
561
;    inc    ebx
568
;    inc    ebx
562
    cmp    eax,ebx
569
    cmp    eax,ebx
563
    jle    .lp6
570
    jle    .lp6
564
	mov	eax,[edi+WDATA.box.height]
571
	mov	eax,[edi+WDATA.box.height]
565
    sub    eax,ebx
572
    sub    eax,ebx
566
    jle    .lp5
573
    jle    .lp5
567
	mov	[edi+WDATA.box.height],ebx
574
	mov	[edi+WDATA.box.height],ebx
568
  .lp5: sub	ebx,[edi+WDATA.box.height]
575
  .lp5: sub	ebx,[edi+WDATA.box.height]
569
	mov	[edi+WDATA.box.top],ebx
576
	mov	[edi+WDATA.box.top],ebx
570
  .lp6: jmp	.lp1
577
  .lp6: jmp	.lp1
571
 
578
 
572
uglobal
579
uglobal
573
  common_colours:
580
  common_colours:
574
     times 128 db 0x0
581
     times 128 db 0x0
575
endg
582
endg
576
 
583
 
577
 
584
 
578
 
585
 
579
 
586
 
580
check_window_position:
587
check_window_position:
581
 
588
 
582
    pushad			     ; window inside screen ?
589
    pushad			     ; window inside screen ?
583
 
590
 
584
    movzx eax,word [edi+WDATA.box.left]
591
    movzx eax,word [edi+WDATA.box.left]
585
    movzx ebx,word [edi+WDATA.box.top]
592
    movzx ebx,word [edi+WDATA.box.top]
586
    movzx ecx,word [edi+WDATA.box.width]
593
    movzx ecx,word [edi+WDATA.box.width]
587
    movzx edx,word [edi+WDATA.box.height]
594
    movzx edx,word [edi+WDATA.box.height]
588
 
595
 
589
    mov   esi,ecx	      ; check x pos
596
    mov   esi,ecx	      ; check x pos
590
    add   esi,eax
597
    add   esi,eax
591
    cmp   esi,[ScreenWidth]
598
    cmp   esi,[ScreenWidth]
592
    jbe   x_pos_ok
599
    jbe   x_pos_ok
593
    mov   [edi+WDATA.box.left],dword 0
600
    mov   [edi+WDATA.box.left],dword 0
594
    xor   eax, eax
601
    xor   eax, eax
595
  x_pos_ok:
602
  x_pos_ok:
596
 
603
 
597
    mov   esi,edx	      ; check y pos
604
    mov   esi,edx	      ; check y pos
598
    add   esi,ebx
605
    add   esi,ebx
599
    cmp   esi,[ScreenHeight]
606
    cmp   esi,[ScreenHeight]
600
    jbe   y_pos_ok
607
    jbe   y_pos_ok
601
    mov   [edi+WDATA.box.top],dword 0
608
    mov   [edi+WDATA.box.top],dword 0
602
    mov   ebx,0
609
    mov   ebx,0
603
  y_pos_ok:
610
  y_pos_ok:
604
 
611
 
605
    mov   esi,ecx	      ; check x size
612
    mov   esi,ecx	      ; check x size
606
    add   esi,eax
613
    add   esi,eax
607
    cmp   esi,[ScreenWidth]
614
    cmp   esi,[ScreenWidth]
608
    jbe   x_size_ok
615
    jbe   x_size_ok
609
    mov   ecx,[ScreenWidth]
616
    mov   ecx,[ScreenWidth]
610
    mov   [edi+WDATA.box.width],ecx
617
    mov   [edi+WDATA.box.width],ecx
611
  x_size_ok:
618
  x_size_ok:
612
 
619
 
613
    mov   esi,edx	      ; check y size
620
    mov   esi,edx	      ; check y size
614
    add   esi,ebx
621
    add   esi,ebx
615
    cmp   esi,[ScreenHeight]
622
    cmp   esi,[ScreenHeight]
616
    jbe   y_size_ok
623
    jbe   y_size_ok
617
    mov   edx,[ScreenHeight]
624
    mov   edx,[ScreenHeight]
618
    mov   [edi+WDATA.box.height],edx
625
    mov   [edi+WDATA.box.height],edx
619
  y_size_ok:
626
  y_size_ok:
620
 
627
 
621
    popad
628
    popad
622
 
629
 
623
    ret
630
    ret
624
 
631
 
625
 
632
 
626
uglobal
633
uglobal
627
  new_window_starting dd 0
634
  new_window_starting dd 0
628
endg
635
endg
629
 
636
 
630
 
637
 
631
sys_window_mouse:
638
sys_window_mouse:
632
 
639
 
633
    push  eax
640
    push  eax
634
 
641
 
635
    mov   eax,[timer_ticks]
642
    mov   eax,[timer_ticks]
636
    cmp   [new_window_starting],eax
643
    cmp   [new_window_starting],eax
637
    jb	  swml1
644
    jb	  swml1
638
 
645
 
639
    mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
646
    mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
640
    mov   [DONT_DRAW_MOUSE],byte 0  ; draw mouse
647
    mov   [DONT_DRAW_MOUSE],byte 0  ; draw mouse
641
 
648
 
642
    mov   [new_window_starting],eax
649
    mov   [new_window_starting],eax
643
 
650
 
644
  swml1:
651
  swml1:
645
 
652
 
646
    pop   eax
653
    pop   eax
647
 
654
 
648
    ret
655
    ret
649
 
656
 
650
 
657
 
651
 
658
 
652
 
659
 
653
drawwindow_I_caption:
660
drawwindow_I_caption:
654
 
661
 
655
	mov   ecx,[edx+WDATA.cl_titlebar]   ; grab bar
662
	mov   ecx,[edx+WDATA.cl_titlebar]   ; grab bar
656
	push  ecx
663
	push  ecx
657
	mov   esi,edx
664
	mov   esi,edx
658
	mov   edx,[esi+WDATA.box.top]
665
	mov   edx,[esi+WDATA.box.top]
659
	add   edx,1
666
	add   edx,1
660
	mov   ebx,[esi+WDATA.box.top]
667
	mov   ebx,[esi+WDATA.box.top]
661
	add   ebx,21
668
	add   ebx,21
662
	mov   eax,[esi+WDATA.box.top]
669
	mov   eax,[esi+WDATA.box.top]
663
	add   eax,[esi+WDATA.box.height]
670
	add   eax,[esi+WDATA.box.height]
664
	cmp   ebx,eax
671
	cmp   ebx,eax
665
	jb    .wdsizeok
672
	jb    .wdsizeok
666
	mov   ebx,eax
673
	mov   ebx,eax
667
  .wdsizeok:
674
  .wdsizeok:
668
	push  ebx
675
	push  ebx
669
  .drwi:
676
  .drwi:
670
	mov   ebx,edx
677
	mov   ebx,edx
671
	shl   ebx,16
678
	shl   ebx,16
672
	add   ebx,edx
679
	add   ebx,edx
673
	mov   eax,[esi+WDATA.box.left]
680
	mov   eax,[esi+WDATA.box.left]
674
	inc   eax
681
	inc   eax
675
	shl   eax,16
682
	shl   eax,16
676
	add   eax,[esi+WDATA.box.left]
683
	add   eax,[esi+WDATA.box.left]
677
	add   eax,[esi+WDATA.box.width]
684
	add   eax,[esi+WDATA.box.width]
678
	sub   eax,1
685
	sub   eax,1
679
	push  edx
686
	push  edx
680
	mov   edx,0x80000000
687
	mov   edx,0x80000000
681
	mov   ecx,[esi+WDATA.cl_titlebar]
688
	mov   ecx,[esi+WDATA.cl_titlebar]
682
	and   ecx,edx
689
	and   ecx,edx
683
	cmp   ecx,edx
690
	cmp   ecx,edx
684
	jnz   .nofa
691
	jnz   .nofa
685
	mov   ecx,[esi+WDATA.cl_titlebar]
692
	mov   ecx,[esi+WDATA.cl_titlebar]
686
	sub   ecx,0x00040404
693
	sub   ecx,0x00040404
687
	mov   [esi+WDATA.cl_titlebar],ecx
694
	mov   [esi+WDATA.cl_titlebar],ecx
688
	and   ecx,0x00ffffff
695
	and   ecx,0x00ffffff
689
	jmp   .faj
696
	jmp   .faj
690
  .nofa:
697
  .nofa:
691
	mov   ecx,[esi+WDATA.cl_titlebar]
698
	mov   ecx,[esi+WDATA.cl_titlebar]
692
	and   ecx,0x00ffffff
699
	and   ecx,0x00ffffff
693
  .faj:
700
  .faj:
694
	pop   edx
701
	pop   edx
695
	mov   edi,0
702
	mov   edi,0
696
	call  [draw_line]
703
	call  [draw_line]
697
	inc   edx
704
	inc   edx
698
	cmp   edx,[esp]
705
	cmp   edx,[esp]
699
	jb    .drwi
706
	jb    .drwi
700
	add   esp,4
707
	add   esp,4
701
	pop   ecx
708
	pop   ecx
702
	mov   [esi+WDATA.cl_titlebar],ecx
709
	mov   [esi+WDATA.cl_titlebar],ecx
703
 
710
 
704
	ret
711
	ret
705
 
712
 
706
 
713
 
707
drawwindow_I:
714
drawwindow_I:
708
 
715
 
709
	pushad
716
	pushad
710
	or	[edx+WDATA.fl_wdrawn], 4
717
	or	[edx+WDATA.fl_wdrawn], 4
711
 
718
 
712
	mov   esi,[edx+WDATA.cl_frames]   ; rectangle
719
	mov   esi,[edx+WDATA.cl_frames]   ; rectangle
713
	mov   eax,[edx+WDATA.box.left]
720
	mov   eax,[edx+WDATA.box.left]
714
	shl   eax,16
721
	shl   eax,16
715
	add   eax,[edx+WDATA.box.left]
722
	add   eax,[edx+WDATA.box.left]
716
	add   eax,[edx+WDATA.box.width]
723
	add   eax,[edx+WDATA.box.width]
717
	mov   ebx,[edx+WDATA.box.top]
724
	mov   ebx,[edx+WDATA.box.top]
718
	shl   ebx,16
725
	shl   ebx,16
719
	add   ebx,[edx+WDATA.box.top]
726
	add   ebx,[edx+WDATA.box.top]
720
	add   ebx,[edx+WDATA.box.height]
727
	add   ebx,[edx+WDATA.box.height]
721
	call  draw_rectangle
728
	call  draw_rectangle
722
 
729
 
723
	and	[edx+WDATA.fl_wdrawn], not 4
730
	and	[edx+WDATA.fl_wdrawn], not 4
724
	test	[edx+WDATA.fl_wdrawn], 2
731
	test	[edx+WDATA.fl_wdrawn], 2
725
	jz	@f
732
	jz	@f
726
	call	drawwindowframes2
733
	call	drawwindowframes2
727
@@:
734
@@:
728
 
735
 
729
	call	drawwindow_I_caption
736
	call	drawwindow_I_caption
730
 
737
 
731
	mov   edx,[esi+WDATA.box.top]	   ; inside work area
738
	mov   edx,[esi+WDATA.box.top]	   ; inside work area
732
	add   edx,21+5
739
	add   edx,21+5
733
	mov   ebx,[esi+WDATA.box.top]
740
	mov   ebx,[esi+WDATA.box.top]
734
	add   ebx,[esi+WDATA.box.height]
741
	add   ebx,[esi+WDATA.box.height]
735
	cmp   edx,ebx
742
	cmp   edx,ebx
736
	jg    noinside
743
	jg    noinside
737
	mov   eax,1
744
	mov   eax,1
738
	mov   ebx,21
745
	mov   ebx,21
739
	mov   ecx,[esi+WDATA.box.width]
746
	mov   ecx,[esi+WDATA.box.width]
740
	mov   edx,[esi+WDATA.box.height]
747
	mov   edx,[esi+WDATA.box.height]
741
	mov   edi,[esi+WDATA.cl_workarea]
748
	mov   edi,[esi+WDATA.cl_workarea]
742
	test  edi,0x40000000
749
	test  edi,0x40000000
743
	jnz   noinside
750
	jnz   noinside
744
	call  [drawbar]
751
	call  [drawbar]
745
      noinside:
752
      noinside:
746
 
753
 
747
	popad
754
	popad
748
 
755
 
749
	ret
756
	ret
750
 
757
 
751
 
758
 
752
draw_rectangle:
759
draw_rectangle:
753
 
760
 
754
r_eax equ [esp+28]   ; x start
761
r_eax equ [esp+28]   ; x start
755
r_ax  equ [esp+30]   ; x end
762
r_ax  equ [esp+30]   ; x end
756
r_ebx equ [esp+16]   ; y start
763
r_ebx equ [esp+16]   ; y start
757
r_bx  equ [esp+18]   ; y end
764
r_bx  equ [esp+18]   ; y end
758
;esi                 ; color
765
;esi                 ; color
759
 
766
 
760
	pushad
767
	pushad
761
 
768
 
762
	mov   ecx,esi	       ; yb,xb -> yb,xe
769
	mov   ecx,esi	       ; yb,xb -> yb,xe
763
	mov   eax, r_eax
770
	mov   eax, r_eax
764
	rol   eax, 16
771
	rol   eax, 16
765
	mov   ebx,r_ebx
772
	mov   ebx,r_ebx
766
	shl   ebx,16
773
	shl   ebx,16
767
	mov   bx,r_ebx
774
	mov   bx,r_ebx
768
	xor   edi, edi
775
	xor   edi, edi
769
	call  [draw_line]
776
	call  [draw_line]
770
 
777
 
771
	mov   ebx,r_bx	       ; ye,xb -> ye,xe
778
	mov   ebx,r_bx	       ; ye,xb -> ye,xe
772
	shl   ebx,16
779
	shl   ebx,16
773
	mov   bx,r_bx
780
	mov   bx,r_bx
774
	call  [draw_line]
781
	call  [draw_line]
775
 
782
 
776
	mov   ecx,esi	       ; ya,xa -> ye,xa
783
	mov   ecx,esi	       ; ya,xa -> ye,xa
777
	mov   eax,r_eax
784
	mov   eax,r_eax
778
	shl   eax,16
785
	shl   eax,16
779
	mov   ax,r_eax
786
	mov   ax,r_eax
780
	mov   ebx,r_ebx
787
	mov   ebx,r_ebx
781
	shl   ebx,16
788
	shl   ebx,16
782
	mov   bx,r_bx
789
	mov   bx,r_bx
783
	mov   edi,0
790
	mov   edi,0
784
	call  [draw_line]
791
	call  [draw_line]
785
 
792
 
786
	mov   eax,r_ax	     ; ya,xe -> ye,xe
793
	mov   eax,r_ax	     ; ya,xe -> ye,xe
787
	shl   eax,16
794
	shl   eax,16
788
	mov   ax,r_ax
795
	mov   ax,r_ax
789
	call  [draw_line]
796
	call  [draw_line]
790
 
797
 
791
	popad
798
	popad
792
	ret
799
	ret
793
 
800
 
794
 
801
 
795
drawwindow_III_caption:
802
drawwindow_III_caption:
796
 
803
 
797
	mov   ecx,[edx+WDATA.cl_titlebar]			; GRAB BAR
804
	mov   ecx,[edx+WDATA.cl_titlebar]			; GRAB BAR
798
	push  ecx
805
	push  ecx
799
	mov   esi,edx
806
	mov   esi,edx
800
	mov   edx,[esi+WDATA.box.top]
807
	mov   edx,[esi+WDATA.box.top]
801
	add   edx,4
808
	add   edx,4
802
	mov   ebx,[esi+WDATA.box.top]
809
	mov   ebx,[esi+WDATA.box.top]
803
	add   ebx,20
810
	add   ebx,20
804
	mov   eax,[esi+WDATA.box.top]
811
	mov   eax,[esi+WDATA.box.top]
805
	add   eax,[esi+WDATA.box.height]
812
	add   eax,[esi+WDATA.box.height]
806
	cmp   ebx,eax
813
	cmp   ebx,eax
807
	jb    .wdsizeok
814
	jb    .wdsizeok
808
	mov   ebx,eax
815
	mov   ebx,eax
809
  .wdsizeok:
816
  .wdsizeok:
810
	push  ebx
817
	push  ebx
811
  .drwi:
818
  .drwi:
812
	mov   ebx,edx
819
	mov   ebx,edx
813
	shl   ebx,16
820
	shl   ebx,16
814
	add   ebx,edx
821
	add   ebx,edx
815
	mov   eax,[esi+WDATA.box.left]
822
	mov   eax,[esi+WDATA.box.left]
816
	shl   eax,16
823
	shl   eax,16
817
	add   eax,[esi+WDATA.box.left]
824
	add   eax,[esi+WDATA.box.left]
818
	add   eax,[esi+WDATA.box.width]
825
	add   eax,[esi+WDATA.box.width]
819
	add   eax,4*65536-4
826
	add   eax,4*65536-4
820
	mov   ecx,[esi+WDATA.cl_titlebar]
827
	mov   ecx,[esi+WDATA.cl_titlebar]
821
	test  ecx,0x40000000
828
	test  ecx,0x40000000
822
	jz    .nofa
829
	jz    .nofa
823
	add   ecx,0x040404
830
	add   ecx,0x040404
824
  .nofa:
831
  .nofa:
825
	test  ecx,0x80000000
832
	test  ecx,0x80000000
826
	jz    .nofa2
833
	jz    .nofa2
827
	sub   ecx,0x040404
834
	sub   ecx,0x040404
828
  .nofa2:
835
  .nofa2:
829
	mov   [esi+WDATA.cl_titlebar],ecx
836
	mov   [esi+WDATA.cl_titlebar],ecx
830
	and   ecx,0xffffff
837
	and   ecx,0xffffff
831
	xor   edi, edi
838
	xor   edi, edi
832
	call  [draw_line]
839
	call  [draw_line]
833
	inc   edx
840
	inc   edx
834
	cmp   edx,[esp]
841
	cmp   edx,[esp]
835
	jb    .drwi
842
	jb    .drwi
836
	add   esp,4
843
	add   esp,4
837
	pop   ecx
844
	pop   ecx
838
	mov   [esi+WDATA.cl_titlebar],ecx
845
	mov   [esi+WDATA.cl_titlebar],ecx
839
 
846
 
840
	ret
847
	ret
841
 
848
 
842
 
849
 
843
drawwindow_III:
850
drawwindow_III:
844
 
851
 
845
	pushad
852
	pushad
846
 
853
 
847
	mov   edi,edx				   ; RECTANGLE
854
	mov   edi,edx				   ; RECTANGLE
848
	mov   eax,[edi+WDATA.box.left]
855
	mov   eax,[edi+WDATA.box.left]
849
	shl   eax,16
856
	shl   eax,16
850
    mov   ax, word [edi+WDATA.box.left]
857
    mov   ax, word [edi+WDATA.box.left]
851
    add   ax, word [edi+WDATA.box.width]
858
    add   ax, word [edi+WDATA.box.width]
852
	mov   ebx,[edi+WDATA.box.top]
859
	mov   ebx,[edi+WDATA.box.top]
853
	shl   ebx,16
860
	shl   ebx,16
854
    mov   bx, word [edi+WDATA.box.top]
861
    mov   bx, word [edi+WDATA.box.top]
855
    add   bx, word [edi+WDATA.box.height]
862
    add   bx, word [edi+WDATA.box.height]
856
	mov   esi,[edi+WDATA.cl_frames]
863
	mov   esi,[edi+WDATA.cl_frames]
857
	shr   esi,1
864
	shr   esi,1
858
	and   esi,0x007f7f7f
865
	and   esi,0x007f7f7f
859
	push  esi
866
	push  esi
860
	or	[edi+WDATA.fl_wdrawn], 4
867
	or	[edi+WDATA.fl_wdrawn], 4
861
	call  draw_rectangle
868
	call  draw_rectangle
862
	and	[edi+WDATA.fl_wdrawn], not 4
869
	and	[edi+WDATA.fl_wdrawn], not 4
863
	test	[edi+WDATA.fl_wdrawn], 2
870
	test	[edi+WDATA.fl_wdrawn], 2
864
	jz	@f
871
	jz	@f
865
	call	drawwindowframes2
872
	call	drawwindowframes2
866
@@:
873
@@:
867
	mov   ecx,3
874
	mov   ecx,3
868
      dw3l:
875
      dw3l:
869
	add   eax,1*65536-1
876
	add   eax,1*65536-1
870
	add   ebx,1*65536-1
877
	add   ebx,1*65536-1
871
	mov   esi,[edi+WDATA.cl_frames]
878
	mov   esi,[edi+WDATA.cl_frames]
872
	call  draw_rectangle
879
	call  draw_rectangle
873
	dec   ecx
880
	dec   ecx
874
	jnz   dw3l
881
	jnz   dw3l
875
	pop   esi
882
	pop   esi
876
	add   eax,1*65536-1
883
	add   eax,1*65536-1
877
	add   ebx,1*65536-1
884
	add   ebx,1*65536-1
878
	call  draw_rectangle
885
	call  draw_rectangle
879
 
886
 
880
	call	drawwindow_III_caption
887
	call	drawwindow_III_caption
881
 
888
 
882
	mov   edx,[esi+WDATA.box.top]			    ; WORK AREA
889
	mov   edx,[esi+WDATA.box.top]			    ; WORK AREA
883
	add   edx,21+5
890
	add   edx,21+5
884
	mov   ebx,[esi+WDATA.box.top]
891
	mov   ebx,[esi+WDATA.box.top]
885
	add   ebx,[esi+WDATA.box.height]
892
	add   ebx,[esi+WDATA.box.height]
886
	cmp   edx,ebx
893
	cmp   edx,ebx
887
	jg    noinside2
894
	jg    noinside2
888
	mov   eax,5
895
	mov   eax,5
889
	mov   ebx,20
896
	mov   ebx,20
890
	mov   ecx,[esi+WDATA.box.width]
897
	mov   ecx,[esi+WDATA.box.width]
891
	mov   edx,[esi+WDATA.box.height]
898
	mov   edx,[esi+WDATA.box.height]
892
	sub   ecx,4
899
	sub   ecx,4
893
	sub   edx,4
900
	sub   edx,4
894
	mov   edi,[esi+WDATA.cl_workarea]
901
	mov   edi,[esi+WDATA.cl_workarea]
895
	test  edi,0x40000000
902
	test  edi,0x40000000
896
	jnz   noinside2
903
	jnz   noinside2
897
	call  [drawbar]
904
	call  [drawbar]
898
      noinside2:
905
      noinside2:
899
 
906
 
900
	popad
907
	popad
901
 
908
 
902
	ret
909
	ret
903
 
910
 
904
 
911
 
905
 
912
 
906
; activate window
913
; activate window
907
align 4
914
align 4
908
windowactivate:
915
windowactivate:
909
 
916
 
910
	; esi = abs mem position in stack 0xC400+
917
	; esi = abs mem position in stack 0xC400+
911
 
918
 
912
	pushad
919
	pushad
913
 
920
 
914
     ; if type of current active window is 3,
921
     ; if type of current active window is 3,
915
     ; it must be redrawn
922
     ; it must be redrawn
916
	mov   eax, [TASK_COUNT]
923
	mov   eax, [TASK_COUNT]
917
	movzx eax, word [WIN_POS + eax*2]
924
	movzx eax, word [WIN_POS + eax*2]
918
	shl   eax, 5
925
	shl   eax, 5
919
	add   eax, window_data
926
	add   eax, window_data
920
	mov   ebx, [eax + WDATA.cl_workarea]
927
	mov   ebx, [eax + WDATA.cl_workarea]
921
	and   ebx, 0x0f000000
928
	and   ebx, 0x0f000000
922
	cmp   ebx, 0x03000000
929
	cmp   ebx, 0x03000000
923
	jne   @f
930
	jne   @f
924
	mov   [eax + WDATA.fl_redraw], byte 1
931
	mov   [eax + WDATA.fl_redraw], byte 1
925
     @@:
932
     @@:
926
 
933
 
927
	push   esi
934
	push   esi
928
      movzx   eax, word [esi] ; ax <- process no
935
      movzx   eax, word [esi] ; ax <- process no
929
      movzx   eax, word [WIN_STACK+eax*2] ; ax <- position in window stack
936
      movzx   eax, word [WIN_STACK+eax*2] ; ax <- position in window stack
930
 
937
 
931
	xor   esi, esi	      ; drop others
938
	xor   esi, esi	      ; drop others
932
      waloop:
939
      waloop:
933
	cmp   esi, dword [TASK_COUNT]
940
	cmp   esi, dword [TASK_COUNT]
934
	jae   wacont
941
	jae   wacont
935
	inc   esi
942
	inc   esi
936
	lea   edi, [WIN_STACK + esi*2]
943
	lea   edi, [WIN_STACK + esi*2]
937
	mov   bx, [edi] ; position of the current process
944
	mov   bx, [edi] ; position of the current process
938
	cmp   bx, ax
945
	cmp   bx, ax
939
	jbe   @f
946
	jbe   @f
940
	dec   bx       ; upper? => drop!
947
	dec   bx       ; upper? => drop!
941
	mov   [edi], bx
948
	mov   [edi], bx
942
      @@:
949
      @@:
943
	jmp   waloop
950
	jmp   waloop
944
      wacont:
951
      wacont:
945
			    ; set to no 1
952
			    ; set to no 1
946
	pop   esi	    ;   esi = pointer at 0xC400
953
	pop   esi	    ;   esi = pointer at 0xC400
947
 
954
 
948
      movzx   eax, word [esi]
955
      movzx   eax, word [esi]
949
	mov   bx, [TASK_COUNT]	; number of processes
956
	mov   bx, [TASK_COUNT]	; number of processes
950
	mov   [WIN_STACK+eax*2], bx	; this is the last (and the upper)
957
	mov   [WIN_STACK+eax*2], bx	; this is the last (and the upper)
951
 
958
 
952
	; update on screen -window stack
959
	; update on screen -window stack
953
	xor   esi, esi
960
	xor   esi, esi
954
      waloop2:
961
      waloop2:
955
	mov   edi, [TASK_COUNT]
962
	mov   edi, [TASK_COUNT]
956
	cmp   esi, edi
963
	cmp   esi, edi
957
	jae   wacont2
964
	jae   wacont2
958
	inc   esi
965
	inc   esi
959
	movzx ebx, word [esi*2 + WIN_STACK]
966
	movzx ebx, word [esi*2 + WIN_STACK]
960
	mov   [ebx*2 + WIN_POS], si
967
	mov   [ebx*2 + WIN_POS], si
961
	jmp   waloop2
968
	jmp   waloop2
962
      wacont2:
969
      wacont2:
963
	mov   [KEY_COUNT], byte 0	    ; empty keyboard buffer
970
	mov   [KEY_COUNT], byte 0	    ; empty keyboard buffer
964
	mov   [BTN_COUNT], byte 0	    ; empty button buffer
971
	mov   [BTN_COUNT], byte 0	    ; empty button buffer
965
	popad
972
	popad
966
	ret
973
	ret
967
 
974
 
968
 
975
 
969
; check if window is necessary to draw
976
; check if window is necessary to draw
970
 
977
 
971
checkwindowdraw:
978
checkwindowdraw:
972
 
979
 
973
	; edi = position in window_data+
980
	; edi = position in window_data+
974
 
981
 
975
	mov   eax, [edi + WDATA.cl_workarea]
982
	mov   eax, [edi + WDATA.cl_workarea]
976
	and   eax, 0x0f000000
983
	and   eax, 0x0f000000
977
	cmp   eax, 0x03000000
984
	cmp   eax, 0x03000000
978
	je    .return_yes      ; window type 3
985
	je    .return_yes      ; window type 3
979
 
986
 
980
	mov   esi, edi
987
	mov   esi, edi
981
	sub   esi, window_data
988
	sub   esi, window_data
982
	shr   esi, 5
989
	shr   esi, 5
983
 
990
 
984
	; esi = process number
991
	; esi = process number
985
 
992
 
986
	movzx eax, word [WIN_STACK + esi * 2] ; get value of the curr process
993
	movzx eax, word [WIN_STACK + esi * 2] ; get value of the curr process
987
	lea   esi, [WIN_POS + eax * 2]	    ; get address of this process at 0xC400
994
	lea   esi, [WIN_POS + eax * 2]	    ; get address of this process at 0xC400
988
 
995
 
989
	push  esi
996
	push  esi
990
 
997
 
991
      .new_check:
998
      .new_check:
992
 
999
 
993
	pop   esi
1000
	pop   esi
994
	add   esi, 2
1001
	add   esi, 2
995
	push  esi
1002
	push  esi
996
 
1003
 
997
	mov   eax, [TASK_COUNT]
1004
	mov   eax, [TASK_COUNT]
998
	lea   eax, word [WIN_POS + eax * 2] ; number of the upper window
1005
	lea   eax, word [WIN_POS + eax * 2] ; number of the upper window
999
 
1006
 
1000
	cmp   esi, eax
1007
	cmp   esi, eax
1001
	ja    .all_wnds_to_top
1008
	ja    .all_wnds_to_top
1002
 
1009
 
1003
	movzx eax, word [esi]
1010
	movzx eax, word [esi]
1004
	shl   eax, 5
1011
	shl   eax, 5
1005
	cmp   [CURRENT_TASK + eax + TASKDATA.state], byte 9
1012
	cmp   [CURRENT_TASK + eax + TASKDATA.state], byte 9
1006
	je    .new_check		    ; skip dead windows
1013
	je    .new_check		    ; skip dead windows
1007
 
1014
 
1008
	lea   esi, [eax+window_data]
1015
	lea   esi, [eax+window_data]
1009
 
1016
 
1010
	mov   ebx, [edi+WDATA.box.top]	; y0
1017
	mov   ebx, [edi+WDATA.box.top]	; y0
1011
	mov   edx, [edi+WDATA.box.height]
1018
	mov   edx, [edi+WDATA.box.height]
1012
	add   edx, ebx	    ; y0e
1019
	add   edx, ebx	    ; y0e
1013
 
1020
 
1014
	mov   ecx, [esi+WDATA.box.top]	; y  ; y check
1021
	mov   ecx, [esi+WDATA.box.top]	; y  ; y check
1015
	cmp   ecx, edx
1022
	cmp   ecx, edx
1016
	jae   .new_check     ; y < y0e
1023
	jae   .new_check     ; y < y0e
1017
	mov   eax, [esi+WDATA.box.height]
1024
	mov   eax, [esi+WDATA.box.height]
1018
	add   ecx, eax	     ; ye
1025
	add   ecx, eax	     ; ye
1019
	cmp   ebx, ecx	     ; y0 >= ye
1026
	cmp   ebx, ecx	     ; y0 >= ye
1020
	ja    .new_check
1027
	ja    .new_check
1021
 
1028
 
1022
	mov   eax, [edi+WDATA.box.left]   ; x0
1029
	mov   eax, [edi+WDATA.box.left]   ; x0
1023
	mov   ecx, [edi+WDATA.box.width]
1030
	mov   ecx, [edi+WDATA.box.width]
1024
	add   ecx, eax	     ; x0e
1031
	add   ecx, eax	     ; x0e
1025
 
1032
 
1026
	mov   edx, [esi+WDATA.box.left]   ; x ; x check
1033
	mov   edx, [esi+WDATA.box.left]   ; x ; x check
1027
	cmp   edx, ecx
1034
	cmp   edx, ecx
1028
	jae   .new_check     ; x < x0e
1035
	jae   .new_check     ; x < x0e
1029
	mov   ecx, [esi+WDATA.box.width]
1036
	mov   ecx, [esi+WDATA.box.width]
1030
	add   edx, ecx
1037
	add   edx, ecx
1031
	cmp   eax, edx
1038
	cmp   eax, edx
1032
	ja    .new_check
1039
	ja    .new_check
1033
 
1040
 
1034
	pop   esi
1041
	pop   esi
1035
  .return_yes:
1042
  .return_yes:
1036
	mov   ecx,1   ; overlap some window
1043
	mov   ecx,1   ; overlap some window
1037
	ret
1044
	ret
1038
 
1045
 
1039
  .all_wnds_to_top:
1046
  .all_wnds_to_top:
1040
 
1047
 
1041
	pop   esi
1048
	pop   esi
1042
 
1049
 
1043
	xor   ecx, ecx	     ; passed all windows to top
1050
	xor   ecx, ecx	     ; passed all windows to top
1044
	ret
1051
	ret
1045
 
1052
 
1046
 
1053
 
1047
 
1054
 
1048
 
1055
 
1049
waredraw:     ; if redraw necessary at activate
1056
waredraw:     ; if redraw necessary at activate
1050
 
1057
 
1051
	pushad
1058
	pushad
1052
 
1059
 
1053
	call  checkwindowdraw	   ; draw window on activation ?
1060
	call  checkwindowdraw	   ; draw window on activation ?
1054
	test  ecx, ecx
1061
	test  ecx, ecx
1055
	jz    .do_not_draw
1062
	jz    .do_not_draw
1056
 
1063
 
1057
	popad
1064
	popad
1058
	mov   [MOUSE_DOWN], byte 1     ; do draw mouse
1065
	mov   [MOUSE_DOWN], byte 1     ; do draw mouse
1059
	call  windowactivate
1066
	call  windowactivate
1060
 
1067
 
1061
	; update screen info
1068
	; update screen info
1062
	pushad
1069
	pushad
1063
	mov   edi, [TASK_COUNT] ; the last process (number)
1070
	mov   edi, [TASK_COUNT] ; the last process (number)
1064
	movzx esi, word [WIN_POS + edi * 2]
1071
	movzx esi, word [WIN_POS + edi * 2]
1065
	shl   esi, 5
1072
	shl   esi, 5
1066
	add   esi, window_data
1073
	add   esi, window_data
1067
 
1074
 
1068
	; coordinates of the upper window
1075
	; coordinates of the upper window
1069
    mov   eax, [esi + WDATA.box.left]	; cx
1076
    mov   eax, [esi + WDATA.box.left]	; cx
1070
    mov   ebx, [esi + WDATA.box.top]	; cy
1077
    mov   ebx, [esi + WDATA.box.top]	; cy
1071
    mov   ecx, [esi + WDATA.box.width]	; sx
1078
    mov   ecx, [esi + WDATA.box.width]	; sx
1072
    mov   edx, [esi + WDATA.box.height] ; sy
1079
    mov   edx, [esi + WDATA.box.height] ; sy
1073
 
1080
 
1074
	add   ecx, eax	     ; ecx = x_end
1081
	add   ecx, eax	     ; ecx = x_end
1075
	add   edx, ebx	     ; edx = y_end
1082
	add   edx, ebx	     ; edx = y_end
1076
 
1083
 
1077
	mov   edi, [TASK_COUNT]
1084
	mov   edi, [TASK_COUNT]
1078
	movzx esi, word [WIN_POS + edi * 2]
1085
	movzx esi, word [WIN_POS + edi * 2]
1079
	call  setscreen
1086
	call  setscreen
1080
	popad
1087
	popad
1081
 
1088
 
1082
    mov   [edi + WDATA.fl_redraw], 1  ; redraw flag for app
1089
    mov   [edi + WDATA.fl_redraw], 1  ; redraw flag for app
1083
    mov   [MOUSE_DOWN],byte 0		  ; mouse down checks
1090
    mov   [MOUSE_DOWN],byte 0		  ; mouse down checks
1084
 
1091
 
1085
	ret
1092
	ret
1086
 
1093
 
1087
     .do_not_draw:
1094
     .do_not_draw:
1088
 
1095
 
1089
	popad
1096
	popad
1090
 
1097
 
1091
	call  windowactivate
1098
	call  windowactivate
1092
	mov   [MOUSE_DOWN],byte 0  ; mouse down checks
1099
	mov   [MOUSE_DOWN],byte 0  ; mouse down checks
1093
	mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
1100
	mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
1094
	mov   [DONT_DRAW_MOUSE],byte 0	; draw mouse
1101
	mov   [DONT_DRAW_MOUSE],byte 0	; draw mouse
1095
	ret
1102
	ret
1096
 
1103
 
1097
 
1104
 
1098
; eax = window number on screen
1105
; eax = window number on screen
1099
; corrupts registers and [dl*]
1106
; corrupts registers and [dl*]
1100
minimize_window:
1107
minimize_window:
1101
	movzx eax, word [WIN_POS+eax*2]
1108
	movzx eax, word [WIN_POS+eax*2]
1102
	shl   eax, 5
1109
	shl   eax, 5
1103
	add   eax, window_data
1110
	add   eax, window_data
1104
	test  [eax+WDATA.fl_wstate], WSTATE_MINIMIZED
1111
	test  [eax+WDATA.fl_wstate], WSTATE_MINIMIZED
1105
	jnz   .skip_redrawings
1112
	jnz   .skip_redrawings
1106
	pushfd
1113
	pushfd
1107
	cli
1114
	cli
1108
	or    [eax+WDATA.fl_wstate], WSTATE_MINIMIZED
1115
	or    [eax+WDATA.fl_wstate], WSTATE_MINIMIZED
1109
	mov   edi, eax
1116
	mov   edi, eax
1110
	;call  calculatescreen
1117
	;call  calculatescreen
1111
	mov   eax, [edi+WDATA.box.left]
1118
	mov   eax, [edi+WDATA.box.left]
1112
	mov   [dlx], eax
1119
	mov   [dlx], eax
1113
	mov   ecx, eax
1120
	mov   ecx, eax
1114
	add   ecx, [edi+WDATA.box.width]
1121
	add   ecx, [edi+WDATA.box.width]
1115
	mov   [dlxe], ecx
1122
	mov   [dlxe], ecx
1116
	mov   ebx, [edi+WDATA.box.top]
1123
	mov   ebx, [edi+WDATA.box.top]
1117
	mov   [dly], ebx
1124
	mov   [dly], ebx
1118
	mov   edx, ebx
1125
	mov   edx, ebx
1119
	add   edx, [edi+WDATA.box.height]
1126
	add   edx, [edi+WDATA.box.height]
1120
	mov   [dlye], edx
1127
	mov   [dlye], edx
1121
	call  calculatescreen
1128
	call  calculatescreen
1122
	xor   esi, esi
1129
	xor   esi, esi
1123
	xor   eax, eax
1130
	xor   eax, eax
1124
	call  redrawscreen
1131
	call  redrawscreen
1125
	popfd
1132
	popfd
1126
.skip_redrawings:
1133
.skip_redrawings:
1127
	ret
1134
	ret
1128
 
1135
 
1129
; eax = window number on screen
1136
; eax = window number on screen
1130
; corrupts registers and [dl*]
1137
; corrupts registers and [dl*]
1131
restore_minimized_window:
1138
restore_minimized_window:
1132
	pushfd
1139
	pushfd
1133
	cli
1140
	cli
1134
	movzx esi, word [WIN_POS+eax*2]
1141
	movzx esi, word [WIN_POS+eax*2]
1135
	mov   edi, esi
1142
	mov   edi, esi
1136
	shl   edi, 5
1143
	shl   edi, 5
1137
	add   edi, window_data
1144
	add   edi, window_data
1138
	test  [edi+WDATA.fl_wstate], WSTATE_MINIMIZED
1145
	test  [edi+WDATA.fl_wstate], WSTATE_MINIMIZED
1139
	jz    .skip_redrawings
1146
	jz    .skip_redrawings
1140
	mov   [edi+WDATA.fl_redraw], 1
1147
	mov   [edi+WDATA.fl_redraw], 1
1141
	and   [edi+WDATA.fl_wstate], not WSTATE_MINIMIZED
1148
	and   [edi+WDATA.fl_wstate], not WSTATE_MINIMIZED
1142
	cmp   eax, [TASK_COUNT] ; the uppermost window
1149
	cmp   eax, [TASK_COUNT] ; the uppermost window
1143
	jnz   .no_uppermost
1150
	jnz   .no_uppermost
1144
	mov   eax, [edi+WDATA.box.left]
1151
	mov   eax, [edi+WDATA.box.left]
1145
	mov   ebx, [edi+WDATA.box.top]
1152
	mov   ebx, [edi+WDATA.box.top]
1146
	mov   ecx, eax
1153
	mov   ecx, eax
1147
	mov   edx, ebx
1154
	mov   edx, ebx
1148
	add   ecx, [edi+WDATA.box.width]
1155
	add   ecx, [edi+WDATA.box.width]
1149
	add   edx, [edi+WDATA.box.height]
1156
	add   edx, [edi+WDATA.box.height]
1150
	call  setscreen
1157
	call  setscreen
1151
	jmp   .done
1158
	jmp   .done
1152
.no_uppermost:
1159
.no_uppermost:
1153
	mov   eax, [edi+WDATA.box.left]
1160
	mov   eax, [edi+WDATA.box.left]
1154
	mov   ebx, [edi+WDATA.box.top]
1161
	mov   ebx, [edi+WDATA.box.top]
1155
	mov   ecx, eax
1162
	mov   ecx, eax
1156
	mov   edx, ebx
1163
	mov   edx, ebx
1157
	add   ecx, [edi+WDATA.box.width]
1164
	add   ecx, [edi+WDATA.box.width]
1158
	add   edx, [edi+WDATA.box.height]
1165
	add   edx, [edi+WDATA.box.height]
1159
	call  calculatescreen
1166
	call  calculatescreen
1160
.done:
1167
.done:
1161
	mov   [MOUSE_BACKGROUND],byte 0 ; no mouse under
1168
	mov   [MOUSE_BACKGROUND],byte 0 ; no mouse under
1162
.skip_redrawings:
1169
.skip_redrawings:
1163
	popfd
1170
	popfd
1164
	ret
1171
	ret
1165
 
1172
 
1166
 
1173
 
1167
iglobal
1174
iglobal
1168
  window_moving   db 'K : Window - move/resize',13,10,0
1175
  window_moving   db 'K : Window - move/resize',13,10,0
1169
  window_moved	  db 'K : Window - done',13,10,0
1176
  window_moved	  db 'K : Window - done',13,10,0
1170
endg
1177
endg
1171
 
1178
 
1172
; check window touch
1179
; check window touch
1173
align 4
1180
align 4
1174
checkwindows:
1181
checkwindows:
1175
	pushad
1182
	pushad
1176
 
1183
 
1177
	cmp   [window_minimize], 0
1184
	cmp   [window_minimize], 0
1178
	je    .no_minimizing
1185
	je    .no_minimizing
1179
	mov   eax, [TASK_COUNT]       ; the uppermost window
1186
	mov   eax, [TASK_COUNT]       ; the uppermost window
1180
	mov   bl, 0
1187
	mov   bl, 0
1181
	xchg  [window_minimize], bl
1188
	xchg  [window_minimize], bl
1182
	cmp   bl, 1
1189
	cmp   bl, 1
1183
	jne   .restore
1190
	jne   .restore
1184
	call  minimize_window
1191
	call  minimize_window
1185
	jmp   .continue
1192
	jmp   .continue
1186
  .restore:
1193
  .restore:
1187
	call  restore_minimized_window
1194
	call  restore_minimized_window
1188
  .continue:
1195
  .continue:
1189
  .no_minimizing:
1196
  .no_minimizing:
1190
 
1197
 
1191
	cmp   [BTN_DOWN],byte 0    ; mouse buttons pressed ?
1198
	cmp   [BTN_DOWN],byte 0    ; mouse buttons pressed ?
1192
	jne  .mouse_buttons_pressed
1199
	jne  .mouse_buttons_pressed
1193
;..................................... start 1/4 : modified by vhanla .................
1200
;..................................... start 1/4 : modified by vhanla .................
1194
	mov [bPressedMouseXY_W],0
1201
	mov [bPressedMouseXY_W],0
1195
;..................................... end 1/4 : modified by vhanla ...................
1202
;..................................... end 1/4 : modified by vhanla ...................
1196
	popad
1203
	popad
1197
	ret
1204
	ret
1198
    .mouse_buttons_pressed:
1205
    .mouse_buttons_pressed:
1199
;..................................... start 2/4 : modified by vhanla .................
1206
;..................................... start 2/4 : modified by vhanla .................
1200
	jmp @f
1207
	jmp @f
1201
	bPressedMouseXY_W db 0x0
1208
	bPressedMouseXY_W db 0x0
1202
	@@:
1209
	@@:
1203
;..................................... end 2/4 : modified by vhanla ...................
1210
;..................................... end 2/4 : modified by vhanla ...................
1204
	mov   esi,[TASK_COUNT]
1211
	mov   esi,[TASK_COUNT]
1205
	inc   esi
1212
	inc   esi
1206
 
1213
 
1207
;..................................... start 3/4 : modified by vhanla .................
1214
;..................................... start 3/4 : modified by vhanla .................
1208
	push ax
1215
	push ax
1209
	cmp [bPressedMouseXY_W],0
1216
	cmp [bPressedMouseXY_W],0
1210
	jnz @f
1217
	jnz @f
1211
	mov [bPressedMouseXY_W],1
1218
	mov [bPressedMouseXY_W],1
1212
	mov ax,[MOUSE_X]
1219
	mov ax,[MOUSE_X]
1213
	mov [mx],ax
1220
	mov [mx],ax
1214
	mov ax,[MOUSE_Y]
1221
	mov ax,[MOUSE_Y]
1215
	mov [my],ax
1222
	mov [my],ax
1216
	@@:
1223
	@@:
1217
	pop ax
1224
	pop ax
1218
;..................................... end 3/4 : modified by vhanla ...................
1225
;..................................... end 3/4 : modified by vhanla ...................
1219
 
1226
 
1220
      cwloop:
1227
      cwloop:
1221
	cmp   esi,2
1228
	cmp   esi,2
1222
	jb   .exit
1229
	jb   .exit
1223
 
1230
 
1224
	dec   esi
1231
	dec   esi
1225
	movzx edi, word [WIN_POS + esi * 2] ; ebx
1232
	movzx edi, word [WIN_POS + esi * 2] ; ebx
1226
	shl   edi, 5
1233
	shl   edi, 5
1227
	add   edi, window_data
1234
	add   edi, window_data
1228
;        mov   edi, ebx
1235
;        mov   edi, ebx
1229
    mov   ecx, [edi + WDATA.box.left]
1236
    mov   ecx, [edi + WDATA.box.left]
1230
    mov   edx, [edi + WDATA.box.top]
1237
    mov   edx, [edi + WDATA.box.top]
1231
 
1238
 
1232
	mov   eax,ecx
1239
	mov   eax,ecx
1233
	mov   ebx,edx
1240
	mov   ebx,edx
1234
	test	[edi+WDATA.fl_wstate],WSTATE_MINIMIZED
1241
	test	[edi+WDATA.fl_wstate],WSTATE_MINIMIZED
1235
	jnz	cwloop
1242
	jnz	cwloop
1236
 
1243
 
1237
;..................................... start 4/4 : modified by vhanla .................
1244
;..................................... start 4/4 : modified by vhanla .................
1238
       movzx  eax, word [mx]; movzx eax,word[MOUSE_X]
1245
       movzx  eax, word [mx]; movzx eax,word[MOUSE_X]
1239
       movzx  ebx, word [my]; movzx ebx,word[MOUSE_Y]
1246
       movzx  ebx, word [my]; movzx ebx,word[MOUSE_Y]
1240
;..................................... endt 4/4 : modified by vhanla ..................
1247
;..................................... endt 4/4 : modified by vhanla ..................
1241
	cmp   ecx, eax
1248
	cmp   ecx, eax
1242
	jae   cwloop
1249
	jae   cwloop
1243
	cmp   edx, ebx
1250
	cmp   edx, ebx
1244
	jae   cwloop
1251
	jae   cwloop
1245
    add   ecx, [edi + WDATA.box.width]
1252
    add   ecx, [edi + WDATA.box.width]
1246
    add   edx, [edi + WDATA.box.height]
1253
    add   edx, [edi + WDATA.box.height]
1247
	cmp   eax, ecx
1254
	cmp   eax, ecx
1248
	jae   cwloop
1255
	jae   cwloop
1249
	cmp   ebx, edx
1256
	cmp   ebx, edx
1250
	jae   cwloop
1257
	jae   cwloop
1251
 
1258
 
1252
	pushad
1259
	pushad
1253
	mov   eax, esi
1260
	mov   eax, esi
1254
	mov   ebx, [TASK_COUNT]
1261
	mov   ebx, [TASK_COUNT]
1255
	cmp   eax, ebx	    ; is this window active?
1262
	cmp   eax, ebx	    ; is this window active?
1256
	jz    .move_resize_window
1263
	jz    .move_resize_window
1257
 
1264
 
1258
	; eax = position in windowing stack
1265
	; eax = position in windowing stack
1259
	; redraw must ?
1266
	; redraw must ?
1260
	lea   esi, [WIN_POS + esi * 2]
1267
	lea   esi, [WIN_POS + esi * 2]
1261
	call  waredraw
1268
	call  waredraw
1262
	add   esp, 32
1269
	add   esp, 32
1263
 
1270
 
1264
      .exit:
1271
      .exit:
1265
	popad
1272
	popad
1266
	ret
1273
	ret
1267
 
1274
 
1268
   .move_resize_window:    ; MOVE OR RESIZE WINDOW
1275
   .move_resize_window:    ; MOVE OR RESIZE WINDOW
1269
	popad
1276
	popad
1270
 
1277
 
1271
	; Check for user enabled fixed window
1278
	; Check for user enabled fixed window
1272
    mov   edx, [edi + WDATA.cl_titlebar]
1279
    mov   edx, [edi + WDATA.cl_titlebar]
1273
	and   edx, 0x0f000000
1280
	and   edx, 0x0f000000
1274
	cmp   edx, 0x01000000
1281
	cmp   edx, 0x01000000
1275
	jne   .window_move_enabled_for_user
1282
	jne   .window_move_enabled_for_user
1276
	popad
1283
	popad
1277
	ret
1284
	ret
1278
      .window_move_enabled_for_user:
1285
      .window_move_enabled_for_user:
1279
 
1286
 
1280
    test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1287
    test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1281
	jnz	.no_resize_2
1288
	jnz	.no_resize_2
1282
 
1289
 
1283
	mov   [do_resize_from_corner],byte 0   ; resize for skinned window
1290
	mov   [do_resize_from_corner],byte 0   ; resize for skinned window
1284
    mov   edx, [edi + WDATA.cl_workarea]
1291
    mov   edx, [edi + WDATA.cl_workarea]
1285
	and   edx, 0x0f000000
1292
	and   edx, 0x0f000000
1286
	cmp   edx, 0x02000000
1293
	cmp   edx, 0x02000000
1287
	jb    .no_resize_2 ; not type 2 wnd
1294
	jb    .no_resize_2 ; not type 2 wnd
1288
 
1295
 
1289
    mov   edx, [edi + WDATA.box.top]
1296
    mov   edx, [edi + WDATA.box.top]
1290
    add   edx, [edi + WDATA.box.height]
1297
    add   edx, [edi + WDATA.box.height]
1291
	sub   edx, 6	   ; edx = y_end - 6
1298
	sub   edx, 6	   ; edx = y_end - 6
1292
	cmp   ebx, edx	   ; ebx = mouse_y
1299
	cmp   ebx, edx	   ; ebx = mouse_y
1293
	jb    .no_resize_2
1300
	jb    .no_resize_2
1294
	mov   [do_resize_from_corner],byte 1
1301
	mov   [do_resize_from_corner],byte 1
1295
	jmp   .continue
1302
	jmp   .continue
1296
      .no_resize_2:
1303
      .no_resize_2:
1297
 
1304
 
1298
	push	eax
1305
	push	eax
1299
	call	get_titlebar_height
1306
	call	get_titlebar_height
1300
    add     eax,[edi + WDATA.box.top]
1307
    add     eax,[edi + WDATA.box.top]
1301
	cmp	ebx,eax
1308
	cmp	ebx,eax
1302
	pop	eax
1309
	pop	eax
1303
	jae	.exit
1310
	jae	.exit
1304
 
1311
 
1305
     .continue:
1312
     .continue:
1306
 
1313
 
1307
	push  esi
1314
	push  esi
1308
	mov   esi, window_moving
1315
	mov   esi, window_moving
1309
	call  sys_msg_board_str
1316
	call  sys_msg_board_str
1310
	pop   esi
1317
	pop   esi
1311
 
1318
 
1312
	mov   ecx, [timer_ticks]     ; double-click ?
1319
	mov   ecx, [timer_ticks]     ; double-click ?
1313
	mov   edx, ecx
1320
	mov   edx, ecx
1314
	sub   edx, [latest_window_touch]
1321
	sub   edx, [latest_window_touch]
1315
	mov   [latest_window_touch], ecx
1322
	mov   [latest_window_touch], ecx
1316
	mov   [latest_window_touch_delta], edx
1323
	mov   [latest_window_touch_delta], edx
1317
 
1324
 
1318
	mov   cl, [BTN_DOWN]	 ; save for shade check
1325
	mov   cl, [BTN_DOWN]	 ; save for shade check
1319
	mov   [do_resize], cl
1326
	mov   [do_resize], cl
1320
     no_emulation_righ_button:
1327
     no_emulation_righ_button:
1321
    mov   ecx, [edi + WDATA.box.left]
1328
    mov   ecx, [edi + WDATA.box.left]
1322
    mov   edx, [edi + WDATA.box.top]
1329
    mov   edx, [edi + WDATA.box.top]
1323
 
1330
 
1324
	push  eax ecx edx
1331
	push  eax ecx edx
1325
	mov   [dlx], ecx      ; save for drawlimits
1332
	mov   [dlx], ecx      ; save for drawlimits
1326
	mov   [dly], edx
1333
	mov   [dly], edx
1327
    mov   eax, [edi + WDATA.box.width]
1334
    mov   eax, [edi + WDATA.box.width]
1328
	add   ecx, eax
1335
	add   ecx, eax
1329
    mov   eax, [edi + WDATA.box.height]
1336
    mov   eax, [edi + WDATA.box.height]
1330
	add   edx, eax
1337
	add   edx, eax
1331
	mov   [dlxe], ecx
1338
	mov   [dlxe], ecx
1332
	mov   [dlye], edx
1339
	mov   [dlye], edx
1333
	pop   edx ecx eax
1340
	pop   edx ecx eax
1334
 
1341
 
1335
	sub   eax, ecx
1342
	sub   eax, ecx
1336
	sub   ebx, edx
1343
	sub   ebx, edx
1337
 
1344
 
1338
	mov   esi, [MOUSE_X]
1345
	mov   esi, [MOUSE_X]
1339
	mov   [WIN_TEMP_XY], esi
1346
	mov   [WIN_TEMP_XY], esi
1340
 
1347
 
1341
	pushad		 ; wait for putimages to finish
1348
	pushad		 ; wait for putimages to finish
1342
;        mov   eax,5
1349
;        mov   eax,5
1343
;        call  delay_hs
1350
;        call  delay_hs
1344
    mov   eax,[edi + WDATA.box.left]
1351
    mov   eax,[edi + WDATA.box.left]
1345
	mov   [npx],eax
1352
	mov   [npx],eax
1346
    mov   eax,[edi + WDATA.box.top]
1353
    mov   eax,[edi + WDATA.box.top]
1347
	mov   [npy],eax
1354
	mov   [npy],eax
1348
	popad
1355
	popad
1349
 
1356
 
1350
	push eax		  ; save old coordinates
1357
	push eax		  ; save old coordinates
1351
    mov   ax, word [edi + WDATA.box.left]
1358
    mov   ax, word [edi + WDATA.box.left]
1352
	mov   word [oldc+BOX.left],ax
1359
	mov   word [oldc+BOX.left],ax
1353
    mov   ax, word [edi + WDATA.box.top]
1360
    mov   ax, word [edi + WDATA.box.top]
1354
	mov   word [oldc+BOX.top],ax
1361
	mov   word [oldc+BOX.top],ax
1355
    mov   ax, word [edi + WDATA.box.width]
1362
    mov   ax, word [edi + WDATA.box.width]
1356
	mov   word [oldc+BOX.width],ax
1363
	mov   word [oldc+BOX.width],ax
1357
	mov   word [npxe],ax
1364
	mov   word [npxe],ax
1358
    mov   ax, word [edi + WDATA.box.height]
1365
    mov   ax, word [edi + WDATA.box.height]
1359
	mov   word [oldc+BOX.height],ax
1366
	mov   word [oldc+BOX.height],ax
1360
	mov   word [npye],ax
1367
	mov   word [npye],ax
1361
	pop eax
1368
	pop eax
1362
 
1369
 
1363
	call  drawwindowframes
1370
	call  drawwindowframes
1364
 
1371
 
1365
	mov   [reposition],0
1372
	mov   [reposition],0
1366
	mov   [MOUSE_DOWN],byte 1   ; no reaction to mouse up/down
1373
	mov   [MOUSE_DOWN],byte 1   ; no reaction to mouse up/down
1367
 
1374
 
1368
	; move window
1375
	; move window
1369
 
1376
 
1370
      newchm:
1377
      newchm:
1371
 
1378
 
1372
	mov   [DONT_DRAW_MOUSE],byte 1
1379
	mov   [DONT_DRAW_MOUSE],byte 1
1373
 
1380
 
1374
	call  checkidle
1381
	call  checkidle
1375
 
1382
 
1376
	call  checkVga_N13
1383
	call  checkVga_N13
1377
 
1384
 
1378
	mov   [MOUSE_BACKGROUND],byte 0
1385
	mov   [MOUSE_BACKGROUND],byte 0
1379
 
1386
 
1380
	call  [draw_pointer]
1387
	call  [draw_pointer]
1381
 
1388
 
1382
	pushad
1389
	pushad
1383
	call   stack_handler
1390
	call   stack_handler
1384
	popad
1391
	popad
1385
 
1392
 
1386
	mov   esi,[WIN_TEMP_XY]
1393
	mov   esi,[WIN_TEMP_XY]
1387
	cmp   esi,[MOUSE_X]
1394
	cmp   esi,[MOUSE_X]
1388
	je    cwb
1395
	je    cwb
1389
 
1396
 
1390
	mov   cx,[MOUSE_X]
1397
	mov   cx,[MOUSE_X]
1391
	mov   dx,[MOUSE_Y]
1398
	mov   dx,[MOUSE_Y]
1392
	sub   cx,ax
1399
	sub   cx,ax
1393
	sub   dx,bx
1400
	sub   dx,bx
1394
 
1401
 
1395
	push  ax
1402
	push  ax
1396
	push  bx
1403
	push  bx
1397
 
1404
 
1398
	call  drawwindowframes
1405
	call  drawwindowframes
1399
 
1406
 
1400
	mov   ax,[ScreenWidth]
1407
	mov   ax,[ScreenWidth]
1401
	mov   bx,[ScreenHeight]
1408
	mov   bx,[ScreenHeight]
1402
 
1409
 
1403
	cmp   [do_resize_from_corner],1
1410
	cmp   [do_resize_from_corner],1
1404
	je    no_new_position
1411
	je    no_new_position
1405
 
1412
 
1406
	mov   word [npx],word 0     ; x repos ?
1413
	mov   word [npx],word 0     ; x repos ?
1407
	cmp   ax,cx
1414
	cmp   ax,cx
1408
	jb    noreposx
1415
	jb    noreposx
1409
	mov   [reposition],1
1416
	mov   [reposition],1
1410
	sub   ax,word [npxe]
1417
	sub   ax,word [npxe]
1411
	mov   word [npx],ax
1418
	mov   word [npx],ax
1412
	cmp   ax,cx
1419
	cmp   ax,cx
1413
	jb    noreposx
1420
	jb    noreposx
1414
	mov   word [npx],cx
1421
	mov   word [npx],cx
1415
      noreposx:
1422
      noreposx:
1416
 
1423
 
1417
	mov   word [npy],word 0     ; y repos ?
1424
	mov   word [npy],word 0     ; y repos ?
1418
	cmp   bx,dx
1425
	cmp   bx,dx
1419
	jb    noreposy
1426
	jb    noreposy
1420
	mov   [reposition],1
1427
	mov   [reposition],1
1421
	sub   bx,word [npye]
1428
	sub   bx,word [npye]
1422
	mov   word [npy],bx
1429
	mov   word [npy],bx
1423
	cmp   bx,dx
1430
	cmp   bx,dx
1424
	jb    noreposy
1431
	jb    noreposy
1425
	mov   word [npy],dx
1432
	mov   word [npy],dx
1426
      noreposy:
1433
      noreposy:
1427
 
1434
 
1428
      no_new_position:
1435
      no_new_position:
1429
 
1436
 
1430
	cmp   [do_resize_from_corner],0    ; resize from right corner
1437
	cmp   [do_resize_from_corner],0    ; resize from right corner
1431
	je    norepos_size
1438
	je    norepos_size
1432
	pushad
1439
	pushad
1433
 
1440
 
1434
	mov   edx,edi
1441
	mov   edx,edi
1435
	sub   edx,window_data
1442
	sub   edx,window_data
1436
	;shr   edx,5
1443
	;shr   edx,5
1437
	;shl   edx,8
1444
	;shl   edx,8
1438
	;add   edx,0x80000                 ; process base at 0x80000+
1445
	;add   edx,0x80000                 ; process base at 0x80000+
1439
    lea   edx, [SLOT_BASE + edx*8]
1446
    lea   edx, [SLOT_BASE + edx*8]
1440
 
1447
 
1441
	movzx eax,word [MOUSE_X]
1448
	movzx eax,word [MOUSE_X]
1442
    cmp   eax,[edi + WDATA.box.left]
1449
    cmp   eax,[edi + WDATA.box.left]
1443
	jb    nnepx
1450
	jb    nnepx
1444
    sub   eax,[edi + WDATA.box.left]
1451
    sub   eax,[edi + WDATA.box.left]
1445
	cmp   eax,32 ; [edx+0x90+8]
1452
	cmp   eax,32 ; [edx+0x90+8]
1446
	jge   nnepx2
1453
	jge   nnepx2
1447
	mov   eax,32 ; [edx+0x90+8]
1454
	mov   eax,32 ; [edx+0x90+8]
1448
      nnepx2:
1455
      nnepx2:
1449
	mov   [npxe],eax
1456
	mov   [npxe],eax
1450
      nnepx:
1457
      nnepx:
1451
 
1458
 
1452
	call	get_rolledup_height
1459
	call	get_rolledup_height
1453
	mov	ebx,eax
1460
	mov	ebx,eax
1454
	movzx eax,word [MOUSE_Y]
1461
	movzx eax,word [MOUSE_Y]
1455
    cmp   eax,[edi + WDATA.box.top]
1462
    cmp   eax,[edi + WDATA.box.top]
1456
	jb    nnepy
1463
	jb    nnepy
1457
    sub   eax,[edi + WDATA.box.top]
1464
    sub   eax,[edi + WDATA.box.top]
1458
	cmp	eax,ebx ; [edx+0x90+12]
1465
	cmp	eax,ebx ; [edx+0x90+12]
1459
	jge	nnepy2
1466
	jge	nnepy2
1460
	mov	eax,ebx ; [edx+0x90+12]
1467
	mov	eax,ebx ; [edx+0x90+12]
1461
      nnepy2:
1468
      nnepy2:
1462
	mov   [npye],eax
1469
	mov   [npye],eax
1463
      nnepy:
1470
      nnepy:
1464
 
1471
 
1465
	mov   [reposition],1
1472
	mov   [reposition],1
1466
 
1473
 
1467
	popad
1474
	popad
1468
      norepos_size:
1475
      norepos_size:
1469
 
1476
 
1470
	pop   bx
1477
	pop   bx
1471
	pop   ax
1478
	pop   ax
1472
	call  drawwindowframes
1479
	call  drawwindowframes
1473
 
1480
 
1474
	mov   esi,[MOUSE_X]
1481
	mov   esi,[MOUSE_X]
1475
	mov   [WIN_TEMP_XY],esi
1482
	mov   [WIN_TEMP_XY],esi
1476
 
1483
 
1477
      cwb:
1484
      cwb:
1478
	cmp   [BTN_DOWN],byte 0
1485
	cmp   [BTN_DOWN],byte 0
1479
	jne   newchm
1486
	jne   newchm
1480
				     ; new position done
1487
				     ; new position done
1481
	mov	[DONT_DRAW_MOUSE],byte 1
1488
	mov	[DONT_DRAW_MOUSE],byte 1
1482
	mov	cl,0
1489
	mov	cl,0
1483
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1490
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1484
	jnz	@f
1491
	jnz	@f
1485
	mov	cl,[reposition]
1492
	mov	cl,[reposition]
1486
	call	drawwindowframes
1493
	call	drawwindowframes
1487
 
1494
 
1488
	mov   eax,[npx]
1495
	mov   eax,[npx]
1489
    mov   [edi + WDATA.box.left],eax
1496
    mov   [edi + WDATA.box.left],eax
1490
	mov   eax,[npy]
1497
	mov   eax,[npy]
1491
    mov   [edi + WDATA.box.top],eax
1498
    mov   [edi + WDATA.box.top],eax
1492
	mov   eax,[npxe]
1499
	mov   eax,[npxe]
1493
    mov   [edi + WDATA.box.width],eax
1500
    mov   [edi + WDATA.box.width],eax
1494
	mov   eax,[npye]
1501
	mov   eax,[npye]
1495
    mov   [edi + WDATA.box.height],eax
1502
    mov   [edi + WDATA.box.height],eax
1496
	call	set_window_clientbox
1503
	call	set_window_clientbox
1497
 
1504
 
1498
    @@: mov	[reposition],cl
1505
    @@: mov	[reposition],cl
1499
 
1506
 
1500
	cmp   [reposition],1	     ; save new position and size
1507
	cmp   [reposition],1	     ; save new position and size
1501
	jne   no_bounds_save
1508
	jne   no_bounds_save
1502
	push  esi edi ecx
1509
	push  esi edi ecx
1503
	mov   esi,edi
1510
	mov   esi,edi
1504
	mov   ecx,2
1511
	mov   ecx,2
1505
	test  [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP or WSTATE_MAXIMIZED
1512
	test  [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP or WSTATE_MAXIMIZED
1506
	jnz   @f
1513
	jnz   @f
1507
	add   ecx,2
1514
	add   ecx,2
1508
    @@: sub   edi,window_data
1515
    @@: sub   edi,window_data
1509
	shr   edi,5
1516
	shr   edi,5
1510
	shl   edi,8
1517
	shl   edi,8
1511
	add   edi,SLOT_BASE+APPDATA.saved_box
1518
	add   edi,SLOT_BASE+APPDATA.saved_box
1512
	cld
1519
	cld
1513
	rep   movsd
1520
	rep   movsd
1514
	pop   ecx edi esi
1521
	pop   ecx edi esi
1515
      no_bounds_save:
1522
      no_bounds_save:
1516
 
1523
 
1517
	pushad				   ; WINDOW SHADE/FULLSCREEN
1524
	pushad				   ; WINDOW SHADE/FULLSCREEN
1518
 
1525
 
1519
	cmp   [reposition],1
1526
	cmp   [reposition],1
1520
	je    no_window_sizing
1527
	je    no_window_sizing
1521
	mov   edx,edi
1528
	mov   edx,edi
1522
	sub   edx,window_data
1529
	sub   edx,window_data
1523
	shr   edx,5
1530
	shr   edx,5
1524
	shl   edx,8
1531
	shl   edx,8
1525
	add   edx,SLOT_BASE		    ; process base at 0x80000+
1532
	add   edx,SLOT_BASE		    ; process base at 0x80000+
1526
 
1533
 
1527
	cmp   [do_resize],2		  ; window shade ?
1534
	cmp   [do_resize],2		  ; window shade ?
1528
	jne   no_window_shade
1535
	jne   no_window_shade
1529
	mov   [reposition],1
1536
	mov   [reposition],1
1530
 
1537
 
1531
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1538
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1532
	jnz	wnd_rolldown
1539
	jnz	wnd_rolldown
1533
  wnd_rollup:
1540
  wnd_rollup:
1534
	or	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1541
	or	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1535
	call	get_rolledup_height
1542
	call	get_rolledup_height
1536
	jmp	@f
1543
	jmp	@f
1537
  wnd_rolldown:
1544
  wnd_rolldown:
1538
	and	[edi+WDATA.fl_wstate],not WSTATE_ROLLEDUP
1545
	and	[edi+WDATA.fl_wstate],not WSTATE_ROLLEDUP
1539
    mov     eax,[edx + APPDATA.saved_box.height] ; 0x90+BOX.height
1546
    mov     eax,[edx + APPDATA.saved_box.height] ; 0x90+BOX.height
1540
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1547
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1541
	jz	@f
1548
	jz	@f
1542
	mov	eax,[screen_workarea.bottom]
1549
	mov	eax,[screen_workarea.bottom]
1543
	sub	eax,[screen_workarea.top]
1550
	sub	eax,[screen_workarea.top]
1544
    @@: mov	[edi+WDATA.box.height],eax
1551
    @@: mov	[edi+WDATA.box.height],eax
1545
	call	set_window_clientbox
1552
	call	set_window_clientbox
1546
 
1553
 
1547
      no_window_shade:
1554
      no_window_shade:
1548
 
1555
 
1549
	cmp   [do_resize],1		  ; fullscreen/restore ?
1556
	cmp   [do_resize],1		  ; fullscreen/restore ?
1550
	jne   no_fullscreen_restore
1557
	jne   no_fullscreen_restore
1551
	cmp   [latest_window_touch_delta],dword 50
1558
	cmp   [latest_window_touch_delta],dword 50
1552
	jg    no_fullscreen_restore
1559
	jg    no_fullscreen_restore
1553
	mov   [reposition],1
1560
	mov   [reposition],1
1554
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1561
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1555
	jnz	restore_from_fullscreen
1562
	jnz	restore_from_fullscreen
1556
	or	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1563
	or	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1557
	mov	eax,[screen_workarea.left]
1564
	mov	eax,[screen_workarea.left]
1558
	mov	[edi+WDATA.box.left],eax
1565
	mov	[edi+WDATA.box.left],eax
1559
	sub	eax,[screen_workarea.right]
1566
	sub	eax,[screen_workarea.right]
1560
	neg	eax
1567
	neg	eax
1561
	mov	[edi+WDATA.box.width],eax
1568
	mov	[edi+WDATA.box.width],eax
1562
	mov	eax,[screen_workarea.top]
1569
	mov	eax,[screen_workarea.top]
1563
	mov	[edi+WDATA.box.top],eax
1570
	mov	[edi+WDATA.box.top],eax
1564
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1571
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1565
	jnz	@f
1572
	jnz	@f
1566
	sub	eax,[screen_workarea.bottom]
1573
	sub	eax,[screen_workarea.bottom]
1567
	neg	eax
1574
	neg	eax
1568
	mov	[edi+WDATA.box.height],eax
1575
	mov	[edi+WDATA.box.height],eax
1569
    @@:
1576
    @@:
1570
	jmp	restore_from_fullscreen.clientbox
1577
	jmp	restore_from_fullscreen.clientbox
1571
      restore_from_fullscreen:
1578
      restore_from_fullscreen:
1572
	and	[edi+WDATA.fl_wstate],not WSTATE_MAXIMIZED
1579
	and	[edi+WDATA.fl_wstate],not WSTATE_MAXIMIZED
1573
	push	[edi+WDATA.box.height]
1580
	push	[edi+WDATA.box.height]
1574
	push  edi			  ; restore
1581
	push  edi			  ; restore
1575
	lea   esi, [edx + APPDATA.saved_box]
1582
	lea   esi, [edx + APPDATA.saved_box]
1576
	mov   ecx,4
1583
	mov   ecx,4
1577
	cld
1584
	cld
1578
	rep   movsd
1585
	rep   movsd
1579
	pop   edi
1586
	pop   edi
1580
	pop	eax
1587
	pop	eax
1581
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1588
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1582
	jz	@f
1589
	jz	@f
1583
	mov	[edi+WDATA.box.height],eax
1590
	mov	[edi+WDATA.box.height],eax
1584
    @@:
1591
    @@:
1585
    .clientbox:
1592
    .clientbox:
1586
	call	set_window_clientbox
1593
	call	set_window_clientbox
1587
 
1594
 
1588
      no_fullscreen_restore:
1595
      no_fullscreen_restore:
1589
 
1596
 
1590
	mov   eax,[edi+WDATA.box.top]		      ; check Y inside screen
1597
	mov   eax,[edi+WDATA.box.top]		      ; check Y inside screen
1591
	add   eax,[edi+WDATA.box.height]
1598
	add   eax,[edi+WDATA.box.height]
1592
	cmp   eax,[ScreenHeight]
1599
	cmp   eax,[ScreenHeight]
1593
	jbe   no_window_sizing
1600
	jbe   no_window_sizing
1594
	mov   eax,[edi+WDATA.box.left]		       ; check X inside screen
1601
	mov   eax,[edi+WDATA.box.left]		       ; check X inside screen
1595
	add   eax,[edi+WDATA.box.width]
1602
	add   eax,[edi+WDATA.box.width]
1596
	cmp   eax,[ScreenWidth]
1603
	cmp   eax,[ScreenWidth]
1597
	jbe   no_window_sizing
1604
	jbe   no_window_sizing
1598
	mov   eax,[ScreenWidth]
1605
	mov   eax,[ScreenWidth]
1599
	sub   eax,[edi+WDATA.box.width]
1606
	sub   eax,[edi+WDATA.box.width]
1600
	mov   [edi+WDATA.box.left],eax
1607
	mov   [edi+WDATA.box.left],eax
1601
	mov   eax,[ScreenHeight]
1608
	mov   eax,[ScreenHeight]
1602
	sub   eax,[edi+WDATA.box.height]
1609
	sub   eax,[edi+WDATA.box.height]
1603
	mov   [edi+WDATA.box.top],eax
1610
	mov   [edi+WDATA.box.top],eax
1604
	call  set_window_clientbox
1611
	call  set_window_clientbox
1605
      no_window_sizing:
1612
      no_window_sizing:
1606
 
1613
 
1607
	popad
1614
	popad
1608
 
1615
 
1609
	cmp   [reposition],0
1616
	cmp   [reposition],0
1610
	je    retwm
1617
	je    retwm
1611
 
1618
 
1612
	mov   [DONT_DRAW_MOUSE],byte 1 ; no mouse
1619
	mov   [DONT_DRAW_MOUSE],byte 1 ; no mouse
1613
 
1620
 
1614
 
1621
 
1615
	push  eax ebx ecx edx
1622
	push  eax ebx ecx edx
1616
	mov   eax,[edi+WDATA.box.left]
1623
	mov   eax,[edi+WDATA.box.left]
1617
	mov   ebx,[edi+WDATA.box.top]
1624
	mov   ebx,[edi+WDATA.box.top]
1618
	mov   ecx,[edi+WDATA.box.width]
1625
	mov   ecx,[edi+WDATA.box.width]
1619
	mov   edx,[edi+WDATA.box.height]
1626
	mov   edx,[edi+WDATA.box.height]
1620
	add   ecx,eax
1627
	add   ecx,eax
1621
	add   edx,ebx
1628
	add   edx,ebx
1622
	call  calculatescreen
1629
	call  calculatescreen
1623
 
1630
 
1624
	mov   eax,[oldc+BOX.left]
1631
	mov   eax,[oldc+BOX.left]
1625
	mov   ebx,[oldc+BOX.top]
1632
	mov   ebx,[oldc+BOX.top]
1626
	mov   ecx,[oldc+BOX.width]
1633
	mov   ecx,[oldc+BOX.width]
1627
	mov   edx,[oldc+BOX.height]
1634
	mov   edx,[oldc+BOX.height]
1628
	add   ecx,eax
1635
	add   ecx,eax
1629
	add   edx,ebx
1636
	add   edx,ebx
1630
	call  calculatescreen
1637
	call  calculatescreen
1631
	pop   edx ecx ebx eax
1638
	pop   edx ecx ebx eax
1632
 
1639
 
1633
	mov   eax,edi
1640
	mov   eax,edi
1634
	call  redrawscreen
1641
	call  redrawscreen
1635
 
1642
 
1636
 
1643
 
1637
	mov	[edi+WDATA.fl_redraw],1
1644
	mov	[edi+WDATA.fl_redraw],1
1638
 
1645
 
1639
	mov   ecx,100	      ; wait to avoid mouse residuals
1646
	mov   ecx,100	      ; wait to avoid mouse residuals
1640
      waitre2:
1647
      waitre2:
1641
	mov   [DONT_DRAW_MOUSE],byte 1
1648
	mov   [DONT_DRAW_MOUSE],byte 1
1642
	call  checkidle
1649
	call  checkidle
1643
	cmp	[edi+WDATA.fl_redraw],0
1650
	cmp	[edi+WDATA.fl_redraw],0
1644
	jz    retwm
1651
	jz    retwm
1645
	loop  waitre2
1652
	loop  waitre2
1646
 
1653
 
1647
      retwm:
1654
      retwm:
1648
 
1655
 
1649
	mov   [DONT_DRAW_MOUSE],byte 0 ; mouse pointer
1656
	mov   [DONT_DRAW_MOUSE],byte 0 ; mouse pointer
1650
	mov   [MOUSE_BACKGROUND],byte 0 ; no mouse under
1657
	mov   [MOUSE_BACKGROUND],byte 0 ; no mouse under
1651
	mov   [MOUSE_DOWN],byte 0 ; react to mouse up/down
1658
	mov   [MOUSE_DOWN],byte 0 ; react to mouse up/down
1652
 
1659
 
1653
	mov    esi,window_moved
1660
	mov    esi,window_moved
1654
	call   sys_msg_board_str
1661
	call   sys_msg_board_str
1655
 
1662
 
1656
	popad
1663
	popad
1657
 
1664
 
1658
	ret
1665
	ret
1659
 
1666
 
1660
 
1667
 
1661
uglobal
1668
uglobal
1662
  add_window_data	     dd  0
1669
  add_window_data	     dd  0
1663
  do_resize_from_corner      db  0x0
1670
  do_resize_from_corner      db  0x0
1664
  reposition		     db  0x0
1671
  reposition		     db  0x0
1665
  latest_window_touch	     dd  0x0
1672
  latest_window_touch	     dd  0x0
1666
  latest_window_touch_delta  dd  0x0
1673
  latest_window_touch_delta  dd  0x0
1667
 
1674
 
1668
  do_resize db 0x0
1675
  do_resize db 0x0
1669
 
1676
 
1670
  oldc	  dd 0x0,0x0,0x0,0x0
1677
  oldc	  dd 0x0,0x0,0x0,0x0
1671
 
1678
 
1672
  dlx	  dd 0x0
1679
  dlx	  dd 0x0
1673
  dly	  dd 0x0
1680
  dly	  dd 0x0
1674
  dlxe	  dd 0x0
1681
  dlxe	  dd 0x0
1675
  dlye	  dd 0x0
1682
  dlye	  dd 0x0
1676
 
1683
 
1677
  npx	  dd 0x0
1684
  npx	  dd 0x0
1678
  npy	  dd 0x0
1685
  npy	  dd 0x0
1679
  npxe	  dd 0x0
1686
  npxe	  dd 0x0
1680
  npye	  dd 0x0
1687
  npye	  dd 0x0
1681
 
1688
 
1682
  mpx	  dd 0x0
1689
  mpx	  dd 0x0
1683
  mpy	  dd 0x0
1690
  mpy	  dd 0x0
1684
endg
1691
endg
1685
 
1692
 
1686
 
1693
 
1687
; draw negative window frames
1694
; draw negative window frames
1688
drawwindowframes2:
1695
drawwindowframes2:
1689
	pushad
1696
	pushad
1690
	cli
1697
	cli
1691
	jmp	drawwindowframes.do
1698
	jmp	drawwindowframes.do
1692
drawwindowframes:
1699
drawwindowframes:
1693
	pushad
1700
	pushad
1694
	cli
1701
	cli
1695
 
1702
 
1696
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1703
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1697
	jnz	.ret
1704
	jnz	.ret
1698
	mov	eax, [npx]
1705
	mov	eax, [npx]
1699
	cmp	eax, [edi+WDATA.box.left]
1706
	cmp	eax, [edi+WDATA.box.left]
1700
	jnz	.nowndframe
1707
	jnz	.nowndframe
1701
	mov	eax, [npxe]
1708
	mov	eax, [npxe]
1702
	cmp	eax, [edi+WDATA.box.width]
1709
	cmp	eax, [edi+WDATA.box.width]
1703
	jnz	.nowndframe
1710
	jnz	.nowndframe
1704
	mov	eax, [npy]
1711
	mov	eax, [npy]
1705
	cmp	eax, [edi+WDATA.box.top]
1712
	cmp	eax, [edi+WDATA.box.top]
1706
	jnz	.nowndframe
1713
	jnz	.nowndframe
1707
	mov	eax, [npye]
1714
	mov	eax, [npye]
1708
	cmp	eax, [edi+WDATA.box.height]
1715
	cmp	eax, [edi+WDATA.box.height]
1709
	jnz	.nowndframe
1716
	jnz	.nowndframe
1710
	xor	[edi+WDATA.fl_wdrawn], 2
1717
	xor	[edi+WDATA.fl_wdrawn], 2
1711
	test	[edi+WDATA.fl_wdrawn], 4
1718
	test	[edi+WDATA.fl_wdrawn], 4
1712
	jnz	.ret
1719
	jnz	.ret
1713
 
1720
 
1714
.nowndframe:
1721
.nowndframe:
1715
.do:
1722
.do:
1716
	mov	edi, 1
1723
	mov	edi, 1
1717
	mov	ecx, 0x01000000
1724
	mov	ecx, 0x01000000
1718
	mov   eax,[npx]
1725
	mov   eax,[npx]
1719
	shl   eax,16
1726
	shl   eax,16
1720
	add   eax,[npx]
1727
	add   eax,[npx]
1721
	add   eax,[npxe]
1728
	add   eax,[npxe]
1722
	add   eax,65536*1-1
1729
	add   eax,65536*1-1
1723
	mov   ebx,[npy]
1730
	mov   ebx,[npy]
1724
	shl   ebx,16
1731
	shl   ebx,16
1725
	add   ebx,[npy]
1732
	add   ebx,[npy]
1726
	call  [draw_line]
1733
	call  [draw_line]
1727
 
1734
 
1728
	mov   eax,[npx]
1735
	mov   eax,[npx]
1729
	shl   eax,16
1736
	shl   eax,16
1730
	add   eax,[npx]
1737
	add   eax,[npx]
1731
	add   eax,[npxe]
1738
	add   eax,[npxe]
1732
	add   eax,65536*1-1
1739
	add   eax,65536*1-1
1733
	mov   ebx,[npy]
1740
	mov   ebx,[npy]
1734
	add   ebx,[npye]
1741
	add   ebx,[npye]
1735
	shl   ebx,16
1742
	shl   ebx,16
1736
	add   ebx,[npy]
1743
	add   ebx,[npy]
1737
	add   ebx,[npye]
1744
	add   ebx,[npye]
1738
	call  [draw_line]
1745
	call  [draw_line]
1739
 
1746
 
1740
	mov   eax,[npx]
1747
	mov   eax,[npx]
1741
	shl   eax,16
1748
	shl   eax,16
1742
	add   eax,[npx]
1749
	add   eax,[npx]
1743
	mov   ebx,[npy]
1750
	mov   ebx,[npy]
1744
	shl   ebx,16
1751
	shl   ebx,16
1745
	add   ebx,[npy]
1752
	add   ebx,[npy]
1746
	add   ebx,[npye]
1753
	add   ebx,[npye]
1747
	call  [draw_line]
1754
	call  [draw_line]
1748
 
1755
 
1749
	mov   eax,[npx]
1756
	mov   eax,[npx]
1750
	add   eax,[npxe]
1757
	add   eax,[npxe]
1751
	shl   eax,16
1758
	shl   eax,16
1752
	add   eax,[npx]
1759
	add   eax,[npx]
1753
	add   eax,[npxe]
1760
	add   eax,[npxe]
1754
	mov   ebx,[npy]
1761
	mov   ebx,[npy]
1755
	shl   ebx,16
1762
	shl   ebx,16
1756
	add   ebx,[npy]
1763
	add   ebx,[npy]
1757
	add   ebx,[npye]
1764
	add   ebx,[npye]
1758
	call  [draw_line]
1765
	call  [draw_line]
1759
 
1766
 
1760
.ret:
1767
.ret:
1761
	sti
1768
	sti
1762
	popad
1769
	popad
1763
	ret
1770
	ret
1764
 
1771
 
1765
 
1772
 
1766
 
1773
 
1767
random_shaped_window:
1774
random_shaped_window:
1768
 
1775
 
1769
;
1776
;
1770
;  eax = 0    giving address of data area
1777
;  eax = 0    giving address of data area
1771
;      ebx    address
1778
;      ebx    address
1772
;  eax = 1    shape area scale
1779
;  eax = 1    shape area scale
1773
;      ebx    2^ebx scale
1780
;      ebx    2^ebx scale
1774
 
1781
 
1775
     test eax, eax
1782
     test eax, eax
1776
     jne  rsw_no_address
1783
     jne  rsw_no_address
1777
     mov  eax,[CURRENT_TASK]
1784
     mov  eax,[CURRENT_TASK]
1778
     shl  eax,8
1785
     shl  eax,8
1779
 
1786
 
1780
     mov  [eax+SLOT_BASE+APPDATA.wnd_shape],ebx
1787
     mov  [eax+SLOT_BASE+APPDATA.wnd_shape],ebx
1781
   rsw_no_address:
1788
   rsw_no_address:
1782
 
1789
 
1783
     cmp  eax,1
1790
     cmp  eax,1
1784
     jne  rsw_no_scale
1791
     jne  rsw_no_scale
1785
     mov  eax,[CURRENT_TASK]
1792
     mov  eax,[CURRENT_TASK]
1786
     shl  eax,8
1793
     shl  eax,8
1787
     mov  byte [eax+SLOT_BASE+APPDATA.wnd_shape_scale], bl
1794
     mov  byte [eax+SLOT_BASE+APPDATA.wnd_shape_scale], bl
1788
   rsw_no_scale:
1795
   rsw_no_scale:
1789
 
1796
 
1790
     ret
1797
     ret