Subversion Repositories Kolibri OS

Rev

Rev 996 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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