Subversion Repositories Kolibri OS

Rev

Rev 33 | Rev 49 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ha 1
 
2
;;                                          ;;
3
;;   WINDOW SKIN for MenuetOS               ;;
4
;;                                          ;;
5
;;   entryway@bkg.lt                        ;;
6
;;                                          ;;
7
;;   Bugfixes & upgrades by                 ;;
8
;;             Samuel Rodriguez Perez       ;;
9
;;             Xeoda@ciberirmandade.org     ;;
10
;;                                          ;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
13
 
14
 
15
 
7 me_root 16
1 ha 17
 
18
  bmp_header:
19
    .type       rw  1  ; "BM" signature
20
    .filesize   rd  1  ; size of the file
21
    .reserved   rd  1  ; zero
22
    .offbits    rd  1  ; pointer to image data
23
    ;----------------
24
    .headsize   rd  1  ; usually 40 bytes for image header
25
    .width      rd  1
26
    .height     rd  1
27
    .planes     rw  1  ; usually 1
28
    .bitcount   rw  1  ; currently 24 bits/pixel (0x18)
29
    .compress   rd  1  ; zero
30
    .sizeimage  rd  1  ; x*y*(bitcount/8)
31
    .unused     rd  4  ; these bits aren't used by MeOS
32
  bmp_data:
33
end virtual
34
35
 
36
  _bmp_bpl dd ?        ; bytes per line
37
  _bmp_dpl dd ?        ; dwords per line
38
  _bmp_zb  dd ?        ; bytes filled by zeroes at the end of a scanline
39
 align 32
40
  raw_data:
41
end virtual
42
43
 
44
; esi = to bmp data (source)
45
; edi = to raw data (destination)
46
    cmp   [esi+bmp_header.type],'BM'     ; check if bmp file is really loaded
47
    jne   .finish
48
    mov   edx,esi
49
50
 
51
    imul  eax,3
52
    push  eax
53
    test  eax,11b
54
    jz    @f
55
    add   eax,4
56
  @@:
57
    shr   eax,2
58
    mov   [_bmp_dpl],eax
59
    shl   eax,2
60
    mov   [_bmp_bpl],eax
61
    pop   ebx
62
    sub   eax,ebx
63
    mov   [_bmp_zb],eax
64
65
 
66
    mov   eax,[_bmp_bpl]
67
    imul  eax,[edx+bmp_header.height]
68
    add   esi,eax
69
    mov   ebx,[edx+bmp_header.height]    ; ebx = y
70
    cld
71
    .y_begin:
72
       sub   esi,[_bmp_bpl]
73
       push  esi
74
       mov   ecx,[_bmp_dpl]
75
       rep   movsd
76
       pop   esi
77
       sub   edi,[_bmp_zb]
78
    dec   ebx
79
    jne   .y_begin
80
81
 
82
    ret
83
84
 
85
 
86
; 1) load LEFT.BMP
87
;   a) _skinleftw = bmp_width
88
;   b) _skinleft = 0
89
;   c) _refleft = 0x778000
90
;   d) convert
91
; 2) load BASE.BMP
92
;   a) _skinbasew = bmp_width
93
;   b) _skinbase = _skinleftw
94
;   c) _refbase = _refleft+sizeof(left_raw_converted)
95
;   d) convert
96
; 3) load OPER.BMP
97
;   a) _skinoper = minus width from bmp file
98
;   b) _skinoperw = width from bmp file
99
;   c) _refoper = _refbase+sizeof(oper_raw_converted)
100
;   d) convert
101
; 4) set height
102
103
 
104
; eax = pointer to filename
105
    mov   ebx, 1
106
    or    ecx, -1
107
    mov   edx, 0x90000
108
    mov   esi, 12
109
    call  fileread
110
    ret
111
112
 
113
 
114
    pushad
115
    mov   eax, _fileleft
116
    call  load_bmp_file
117
    mov   eax, [0x90000+bmp_header.width]
118
    mov   [_skinleftw], eax
119
    mov   [_skinleft], 0
120
    mov   edi, raw_data
121
    mov   [_refleft], edi
122
    mov   esi, 0x90000
123
    call  bmp2raw
124
    mov   eax, [_bmp_bpl]
125
    imul  eax, [0x90000+bmp_header.height]
126
    push  eax
127
128
 
129
    call  load_bmp_file
130
    mov   eax, [0x90000+bmp_header.width]
131
    mov   [_skinbasew], eax
132
    mov   eax, [_skinleftw]
133
    mov   [_skinbase], eax
134
    pop   eax
135
    add   eax, [_refleft]
136
    ; align to 32-byte boundary
137
    test  eax, 11111b
138
    jz    @f
139
    shr   eax, 5
140
    inc   eax
141
    shl   eax, 5
142
  @@:
143
    ; save base address
144
    mov   [_refbase], eax
145
    ; convert
146
    mov   edi, eax
147
    mov   esi, 0x90000
148
    call  bmp2raw
149
    mov   eax, [_bmp_bpl]
150
    imul  eax, [0x90000+bmp_header.height]
151
    push  eax
152
153
 
154
    call  load_bmp_file
155
    mov   eax, [0x90000+bmp_header.width]
156
    mov   [_skinoperw], eax
157
    neg   eax
158
    mov   [_skinoper], eax
159
    pop   eax
160
    add   eax, [_refbase]
161
    ; align to 32-byte boundary
162
    test  eax, 11111b
163
    jz    @f
164
    shr   eax, 5
165
    inc   eax
166
    shl   eax, 5
167
  @@:
168
    mov   [_refoper], eax
169
    mov   edi, eax
170
    mov   esi, 0x90000
171
    call  bmp2raw
172
    mov   eax, [0x90000+bmp_header.height]
33 mario79 173
    mov   [_skinh], eax
174
    popad
175
1 ha 176
 
33 mario79 177
1 ha 178
 
33 mario79 179
    pushad
180
    mov   eax, _fileleft_1
181
    call  load_bmp_file
182
    mov   eax, [0x90000+bmp_header.width]
183
    mov   [_skinleftw], eax
184
    mov   [_skinleft_1], 0
185
    mov   edi, raw_data+1000h
186
    mov   [_refleft_1], edi
187
    mov   esi, 0x90000
188
    call  bmp2raw
189
    mov   eax, [_bmp_bpl]
190
    imul  eax, [0x90000+bmp_header.height]
191
    push  eax
192
1 ha 193
 
33 mario79 194
    call  load_bmp_file
195
    mov   eax, [0x90000+bmp_header.width]
196
    mov   [_skinbasew], eax
197
    mov   eax, [_skinleftw]
198
    mov   [_skinbase], eax
199
    pop   eax
200
    add   eax, [_refleft_1]
201
    ; align to 32-byte boundary
202
    test  eax, 11111b
203
    jz    @f
204
    shr   eax, 5
205
    inc   eax
206
    shl   eax, 5
207
  @@:
208
    ; save base address
209
    mov   [_refbase_1], eax
210
    ; convert
211
    mov   edi, eax
212
    mov   esi, 0x90000
213
    call  bmp2raw
214
    mov   eax, [_bmp_bpl]
215
    imul  eax, [0x90000+bmp_header.height]
216
    push  eax
217
1 ha 218
 
33 mario79 219
    call  load_bmp_file
220
    mov   eax, [0x90000+bmp_header.width]
221
    mov   [_skinoperw], eax
222
    neg   eax
223
    mov   [_skinoper], eax
224
    pop   eax
225
    add   eax, [_refbase_1]
226
    ; align to 32-byte boundary
227
    test  eax, 11111b
228
    jz    @f
229
    shr   eax, 5
230
    inc   eax
231
    shl   eax, 5
232
  @@:
233
    mov   [_refoper_1], eax
234
    mov   edi, eax
235
    mov   esi, 0x90000
236
    call  bmp2raw
237
    mov   eax, [0x90000+bmp_header.height]
1 ha 238
    mov   [_skinh], eax
239
    popad
240
    ret
241
242
 
243
;param1 - aw_yes
35 halyavin 244
1 ha 245
 
246
247
 
248
249
 
250
251
 
252
        shl   eax,16
253
        mov   ax,[edi+0]
254
        add   ax,[edi+8]
255
        mov   ebx,[edi+4]
256
        shl   ebx,16
257
        mov   bx,[edi+4]
258
        add   bx,[edi+12]
259
;        mov   esi,[edi+24]
260
;        shr   esi,1
261
;        and   esi,0x007f7f7f
262
        mov   esi,[_coloroutborder]
263
        call  draw_rectangle
264
        mov   ecx,3
265
      _dw3l:
266
        add   eax,1*65536-1
267
        add   ebx,1*65536-1
268
        test  ax,ax
269
        js    no_skin_add_button
270
        test  bx,bx
271
        js    no_skin_add_button
272
        mov   esi,[_colorframe] ;[edi+24]
273
        call  draw_rectangle
274
        dec   ecx
275
        jnz   _dw3l
276
        mov   esi,[_colorborder]
277
        add   eax,1*65536-1
278
        add   ebx,1*65536-1
279
        test  ax,ax
280
        js    no_skin_add_button
281
        test  bx,bx
282
        js    no_skin_add_button
283
        call  draw_rectangle
284
285
 
286
        mov   eax,[esi+8]    ; window width
287
        mov   edx,[_skinleft]
288
        shl   edx,16
289
        mov   ecx,[_skinleftw]
290
        shl   ecx,16
291
        add   ecx,[_skinh]
292
33 mario79 293
 
35 halyavin 294
        mov   ebx, [_refleft_1]
295
        jne   @f
33 mario79 296
        mov   ebx,[_refleft]
1 ha 297
     @@:
33 mario79 298
        call  sys_putimage
1 ha 299
300
 
301
        mov   eax,[esi+8]
302
        sub   eax,[_skinleftw]
303
        sub   eax,[_skinoperw]
304
        cmp   eax,[_skinbase]
305
        jng   non_base
306
        xor   edx,edx
307
        mov   ebx,[_skinbasew]
308
        div   ebx
309
310
 
311
312
 
35 halyavin 313
        mov   ebx,[_refbase_1]
314
        jne   @f
33 mario79 315
        mov   ebx,[_refbase]
1 ha 316
     @@:
33 mario79 317
35 halyavin 318
 
1 ha 319
        shl   ecx,16
320
        add   ecx,[_skinh]
321
        mov   edx,[_skinbase]
322
        sub   edx,[_skinbasew]
323
        shl   edx,16
324
      baseskinloop:
325
        shr   edx,16
326
        add   edx,[_skinbasew]
327
        shl   edx,16
328
329
 
330
        call  sys_putimage
331
        pop   edx ecx ebx eax
332
333
 
334
        jnz   baseskinloop
335
      non_base:
336
337
 
338
        mov   edx,[esi+8]
339
        sub   edx,[_skinoperw]
340
        inc   edx
341
        shl   edx,16
342
        cmp   byte [esp+32+4+4], 1
35 halyavin 343
        mov   ebx,[_refoper_1]
344
        jne   @f
33 mario79 345
        mov   ebx,[_refoper]
1 ha 346
     @@:
33 mario79 347
35 halyavin 348
 
1 ha 349
        shl   ecx,16
350
        add   ecx,[_skinh]
351
        call  sys_putimage
352
353
 
354
355
 
356
        add   edx,21+5
357
        mov   ebx,[esi+04]
358
        add   ebx,[esi+12]
359
        cmp   edx,ebx
360
        jg    _noinside2
361
        mov   eax,5
362
        mov   ebx,[_skinh]
363
        mov   ecx,[esi+8]
364
        mov   edx,[esi+12]
365
        sub   ecx,4
366
        sub   edx,4
367
        mov   edi,[esi+16]
368
        call  [drawbar]
369
      _noinside2:
370
371
 
372
        movzx eax,word [edi]
373
        cmp   eax,1000
374
        jge   no_skin_add_button
375
        inc   eax
376
        mov   [edi],ax
377
378
 
379
        add   eax,edi
380
381
 
382
        mov   [eax],bx
383
384
 
385
        mov   bx,1
386
        mov   [eax],bx
387
        add   eax,2         ; x start
388
        mov   ebx,[esp]
389
        mov   ebx,[ebx+8]
390
        cmp   [_buttonCx],0
391
        jg    _bCx_at_right
392
        mov   ebx,[_buttonCw]    ; ebx will be 0 in next instruction
393
      _bCx_at_right:
394
        sub   ebx,[_buttonCw]
395
        sub   ebx,[_buttonCx]
396
        mov   [eax],bx
397
        add   eax,2         ; x size
398
        mov   ebx,[_buttonCw]
399
        mov   [eax],bx
400
        add   eax,2         ; y start
401
        mov   ebx,[_buttonCy]
402
        mov   [eax],bx
403
        add   eax,2         ; y size
404
        mov   ebx,[_buttonCh]
405
        mov   [eax],bx
406
407
 
408
        mov   edi,[0xfe88]
409
        movzx eax,word [edi]
410
        cmp   eax,1000
411
        jge   no_skin_add_button
412
        inc   eax
413
        mov   [edi],ax
414
415
 
416
        add   eax,edi
417
418
 
419
        mov   [eax],bx
420
421
 
422
        mov   bx,65535 ;999
423
        mov   [eax],bx
424
        add   eax,2         ; x start
425
        mov   ebx,[esp]
426
        mov   ebx,[ebx+8]
427
        cmp   [_buttonMx],0
428
        jg    _bMx_at_right
429
        mov   ebx,[_buttonMw]    ; ebx will be 0 in next instruction
430
      _bMx_at_right:
431
        sub   ebx,[_buttonMw]
432
        sub   ebx,[_buttonMx]
433
        mov   [eax],bx
434
        add   eax,2         ; x size
435
        mov   ebx,[_buttonMw]
436
        mov   [eax],bx
437
        add   eax,2         ; y start
438
        mov   ebx,[_buttonMy]
439
        mov   [eax],bx
440
        add   eax,2         ; y size
441
        mov   ebx,[_buttonMh]
442
        mov   [eax],bx
443
;* minimize button
444
445
 
446
447
 
448
        popa
449
33 mario79 450
 
35 halyavin 451