Subversion Repositories Kolibri OS

Rev

Rev 2 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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