Subversion Repositories Kolibri OS

Rev

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

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