Subversion Repositories Kolibri OS

Rev

Rev 7 | Rev 35 | 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
244
 
245
246
 
247
248
 
249
250
 
251
        shl   eax,16
252
        mov   ax,[edi+0]
253
        add   ax,[edi+8]
254
        mov   ebx,[edi+4]
255
        shl   ebx,16
256
        mov   bx,[edi+4]
257
        add   bx,[edi+12]
258
;        mov   esi,[edi+24]
259
;        shr   esi,1
260
;        and   esi,0x007f7f7f
261
        mov   esi,[_coloroutborder]
262
        call  draw_rectangle
263
        mov   ecx,3
264
      _dw3l:
265
        add   eax,1*65536-1
266
        add   ebx,1*65536-1
267
        test  ax,ax
268
        js    no_skin_add_button
269
        test  bx,bx
270
        js    no_skin_add_button
271
        mov   esi,[_colorframe] ;[edi+24]
272
        call  draw_rectangle
273
        dec   ecx
274
        jnz   _dw3l
275
        mov   esi,[_colorborder]
276
        add   eax,1*65536-1
277
        add   ebx,1*65536-1
278
        test  ax,ax
279
        js    no_skin_add_button
280
        test  bx,bx
281
        js    no_skin_add_button
282
        call  draw_rectangle
283
284
 
285
        mov   eax,[esi+8]    ; window width
286
        mov   edx,[_skinleft]
287
        shl   edx,16
288
        mov   ecx,[_skinleftw]
289
        shl   ecx,16
290
        add   ecx,[_skinh]
291
33 mario79 292
 
293
;        cmp   [esp+32+4+2], word 1
294
        jne   @f
295
        mov   ebx,[_refleft]
1 ha 296
        jmp   no_aw_3
33 mario79 297
     @@:
298
        mov   ebx,[_refleft_1]
299
      no_aw_3:
300
        call  sys_putimage
1 ha 301
302
 
303
        mov   eax,[esi+8]
304
        sub   eax,[_skinleftw]
305
        sub   eax,[_skinoperw]
306
        cmp   eax,[_skinbase]
307
        jng   non_base
308
        xor   edx,edx
309
        mov   ebx,[_skinbasew]
310
        div   ebx
311
312
 
313
314
 
33 mario79 315
;        cmp   [esp+32+4+2], word 1
316
        jne   @f
317
        mov   ebx,[_refbase]
1 ha 318
        jmp   no_aw_2
33 mario79 319
     @@:
320
        mov   ebx,[_refbase_1]
321
      no_aw_2:
322
        mov   ecx,[_skinbasew]
1 ha 323
        shl   ecx,16
324
        add   ecx,[_skinh]
325
        mov   edx,[_skinbase]
326
        sub   edx,[_skinbasew]
327
        shl   edx,16
328
      baseskinloop:
329
        shr   edx,16
330
        add   edx,[_skinbasew]
331
        shl   edx,16
332
333
 
334
        call  sys_putimage
335
        pop   edx ecx ebx eax
336
337
 
338
        jnz   baseskinloop
339
      non_base:
340
341
 
342
        mov   edx,[esi+8]
343
        sub   edx,[_skinoperw]
344
        inc   edx
345
        shl   edx,16
346
        cmp   [aw_yes],1
33 mario79 347
;        cmp   [esp+32+4+2], word 1
348
        jne   @f
349
        mov   ebx,[_refoper]
1 ha 350
        jmp   no_aw_1
33 mario79 351
     @@:
352
        mov   ebx,[_refoper_1]
353
      no_aw_1:
354
        mov   ecx,[_skinoperw]
1 ha 355
        shl   ecx,16
356
        add   ecx,[_skinh]
357
        call  sys_putimage
358
359
 
360
361
 
362
        add   edx,21+5
363
        mov   ebx,[esi+04]
364
        add   ebx,[esi+12]
365
        cmp   edx,ebx
366
        jg    _noinside2
367
        mov   eax,5
368
        mov   ebx,[_skinh]
369
        mov   ecx,[esi+8]
370
        mov   edx,[esi+12]
371
        sub   ecx,4
372
        sub   edx,4
373
        mov   edi,[esi+16]
374
        call  [drawbar]
375
      _noinside2:
376
377
 
378
        movzx eax,word [edi]
379
        cmp   eax,1000
380
        jge   no_skin_add_button
381
        inc   eax
382
        mov   [edi],ax
383
384
 
385
        add   eax,edi
386
387
 
388
        mov   [eax],bx
389
390
 
391
        mov   bx,1
392
        mov   [eax],bx
393
        add   eax,2         ; x start
394
        mov   ebx,[esp]
395
        mov   ebx,[ebx+8]
396
        cmp   [_buttonCx],0
397
        jg    _bCx_at_right
398
        mov   ebx,[_buttonCw]    ; ebx will be 0 in next instruction
399
      _bCx_at_right:
400
        sub   ebx,[_buttonCw]
401
        sub   ebx,[_buttonCx]
402
        mov   [eax],bx
403
        add   eax,2         ; x size
404
        mov   ebx,[_buttonCw]
405
        mov   [eax],bx
406
        add   eax,2         ; y start
407
        mov   ebx,[_buttonCy]
408
        mov   [eax],bx
409
        add   eax,2         ; y size
410
        mov   ebx,[_buttonCh]
411
        mov   [eax],bx
412
413
 
414
        mov   edi,[0xfe88]
415
        movzx eax,word [edi]
416
        cmp   eax,1000
417
        jge   no_skin_add_button
418
        inc   eax
419
        mov   [edi],ax
420
421
 
422
        add   eax,edi
423
424
 
425
        mov   [eax],bx
426
427
 
428
        mov   bx,65535 ;999
429
        mov   [eax],bx
430
        add   eax,2         ; x start
431
        mov   ebx,[esp]
432
        mov   ebx,[ebx+8]
433
        cmp   [_buttonMx],0
434
        jg    _bMx_at_right
435
        mov   ebx,[_buttonMw]    ; ebx will be 0 in next instruction
436
      _bMx_at_right:
437
        sub   ebx,[_buttonMw]
438
        sub   ebx,[_buttonMx]
439
        mov   [eax],bx
440
        add   eax,2         ; x size
441
        mov   ebx,[_buttonMw]
442
        mov   [eax],bx
443
        add   eax,2         ; y start
444
        mov   ebx,[_buttonMy]
445
        mov   [eax],bx
446
        add   eax,2         ; y size
447
        mov   ebx,[_buttonMh]
448
        mov   [eax],bx
449
;* minimize button
450
451
 
452
453
 
454
        popa
455
33 mario79 456
 
1 ha 457