Subversion Repositories Kolibri OS

Rev

Rev 2 | Go to most recent revision | Details | 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
 
16
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
173
 
174
 
175
;    imul  eax, [0x90000+bmp_header.width]
176
;    imul  eax, 3
177
;    add   eax, raw_data  ; now eax points to the last line of image
178
179
 
180
;    mov   [_coloroutborder], ecx
181
;    mov   [_colorborder], ecx
182
;    sub   eax, 2*3
183
;    mov   ecx, [eax]
184
;    mov   [_colorframe], ecx
185
186
 
187
 
188
    mov   [_skinh], eax
189
    popad
190
    ret
191
192
 
193
 
194
 
195
196
 
197
198
 
199
200
 
201
202
 
203
        shl   eax,16
204
        mov   ax,[edi+0]
205
        add   ax,[edi+8]
206
        mov   ebx,[edi+4]
207
        shl   ebx,16
208
        mov   bx,[edi+4]
209
        add   bx,[edi+12]
210
;        mov   esi,[edi+24]
211
;        shr   esi,1
212
;        and   esi,0x007f7f7f
213
        mov   esi,[_coloroutborder]
214
        call  draw_rectangle
215
        mov   ecx,3
216
      _dw3l:
217
        add   eax,1*65536-1
218
        add   ebx,1*65536-1
219
        test  ax,ax
220
        js    no_skin_add_button
221
        test  bx,bx
222
        js    no_skin_add_button
223
        mov   esi,[_colorframe] ;[edi+24]
224
        call  draw_rectangle
225
        dec   ecx
226
        jnz   _dw3l
227
        mov   esi,[_colorborder]
228
        add   eax,1*65536-1
229
        add   ebx,1*65536-1
230
        test  ax,ax
231
        js    no_skin_add_button
232
        test  bx,bx
233
        js    no_skin_add_button
234
        call  draw_rectangle
235
236
 
237
        mov   eax,[esi+8]    ; window width
238
        mov   edx,[_skinleft]
239
        shl   edx,16
240
        mov   ecx,[_skinleftw]
241
        shl   ecx,16
242
        add   ecx,[_skinh]
243
        mov   ebx,[_refleft]
244
        call  sys_putimage
245
246
 
247
        mov   eax,[esi+8]
248
        sub   eax,[_skinleftw]
249
        sub   eax,[_skinoperw]
250
        cmp   eax,[_skinbase]
251
        jng   non_base
252
        xor   edx,edx
253
        mov   ebx,[_skinbasew]
254
        div   ebx
255
256
 
257
258
 
259
        mov   ecx,[_skinbasew]
260
        shl   ecx,16
261
        add   ecx,[_skinh]
262
        mov   edx,[_skinbase]
263
        sub   edx,[_skinbasew]
264
        shl   edx,16
265
      baseskinloop:
266
        shr   edx,16
267
        add   edx,[_skinbasew]
268
        shl   edx,16
269
270
 
271
        call  sys_putimage
272
        pop   edx ecx ebx eax
273
274
 
275
        jnz   baseskinloop
276
      non_base:
277
278
 
279
        mov   edx,[esi+8]
280
        sub   edx,[_skinoperw]
281
        inc   edx
282
        shl   edx,16
283
        mov   ebx,[_refoper]
284
        mov   ecx,[_skinoperw]
285
        shl   ecx,16
286
        add   ecx,[_skinh]
287
        call  sys_putimage
288
289
 
290
291
 
292
        add   edx,21+5
293
        mov   ebx,[esi+04]
294
        add   ebx,[esi+12]
295
        cmp   edx,ebx
296
        jg    _noinside2
297
        mov   eax,5
298
        mov   ebx,[_skinh]
299
        mov   ecx,[esi+8]
300
        mov   edx,[esi+12]
301
        sub   ecx,4
302
        sub   edx,4
303
        mov   edi,[esi+16]
304
        call  [drawbar]
305
      _noinside2:
306
307
 
308
        movzx eax,word [edi]
309
        cmp   eax,1000
310
        jge   no_skin_add_button
311
        inc   eax
312
        mov   [edi],ax
313
314
 
315
        add   eax,edi
316
317
 
318
        mov   [eax],bx
319
320
 
321
        mov   bx,1
322
        mov   [eax],bx
323
        add   eax,2         ; x start
324
        mov   ebx,[esp]
325
        mov   ebx,[ebx+8]
326
        cmp   [_buttonCx],0
327
        jg    _bCx_at_right
328
        mov   ebx,[_buttonCw]    ; ebx will be 0 in next instruction
329
      _bCx_at_right:
330
        sub   ebx,[_buttonCw]
331
        sub   ebx,[_buttonCx]
332
        mov   [eax],bx
333
        add   eax,2         ; x size
334
        mov   ebx,[_buttonCw]
335
        mov   [eax],bx
336
        add   eax,2         ; y start
337
        mov   ebx,[_buttonCy]
338
        mov   [eax],bx
339
        add   eax,2         ; y size
340
        mov   ebx,[_buttonCh]
341
        mov   [eax],bx
342
343
 
344
        mov   edi,[0xfe88]
345
        movzx eax,word [edi]
346
        cmp   eax,1000
347
        jge   no_skin_add_button
348
        inc   eax
349
        mov   [edi],ax
350
351
 
352
        add   eax,edi
353
354
 
355
        mov   [eax],bx
356
357
 
358
        mov   bx,65535 ;999
359
        mov   [eax],bx
360
        add   eax,2         ; x start
361
        mov   ebx,[esp]
362
        mov   ebx,[ebx+8]
363
        cmp   [_buttonMx],0
364
        jg    _bMx_at_right
365
        mov   ebx,[_buttonMw]    ; ebx will be 0 in next instruction
366
      _bMx_at_right:
367
        sub   ebx,[_buttonMw]
368
        sub   ebx,[_buttonMx]
369
        mov   [eax],bx
370
        add   eax,2         ; x size
371
        mov   ebx,[_buttonMw]
372
        mov   [eax],bx
373
        add   eax,2         ; y start
374
        mov   ebx,[_buttonMy]
375
        mov   [eax],bx
376
        add   eax,2         ; y size
377
        mov   ebx,[_buttonMh]
378
        mov   [eax],bx
379
;* minimize button
380
381
 
382
383
 
384
        popa
385
        ret
386