Subversion Repositories Kolibri OS

Rev

Rev 7 | Rev 35 | 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.     mov   eax, [0x90000+bmp_header.height]
  174.     mov   [_skinh], eax
  175.     popad
  176.  
  177.     ret
  178.  
  179. load_default_skin_1:          
  180.     pushad
  181.     mov   eax, _fileleft_1
  182.     call  load_bmp_file
  183.     mov   eax, [0x90000+bmp_header.width]
  184.     mov   [_skinleftw], eax
  185.     mov   [_skinleft_1], 0
  186.     mov   edi, raw_data+1000h
  187.     mov   [_refleft_1], edi
  188.     mov   esi, 0x90000
  189.     call  bmp2raw
  190.     mov   eax, [_bmp_bpl]
  191.     imul  eax, [0x90000+bmp_header.height]
  192.     push  eax
  193.  
  194.     mov   eax, _filebase_1
  195.     call  load_bmp_file
  196.     mov   eax, [0x90000+bmp_header.width]
  197.     mov   [_skinbasew], eax
  198.     mov   eax, [_skinleftw]
  199.     mov   [_skinbase], eax
  200.     pop   eax
  201.     add   eax, [_refleft_1]
  202.     ; align to 32-byte boundary
  203.     test  eax, 11111b
  204.     jz    @f
  205.     shr   eax, 5
  206.     inc   eax
  207.     shl   eax, 5
  208.   @@:
  209.     ; save base address
  210.     mov   [_refbase_1], eax
  211.     ; convert
  212.     mov   edi, eax
  213.     mov   esi, 0x90000
  214.     call  bmp2raw
  215.     mov   eax, [_bmp_bpl]
  216.     imul  eax, [0x90000+bmp_header.height]
  217.     push  eax
  218.  
  219.     mov   eax, _fileoper_1
  220.     call  load_bmp_file
  221.     mov   eax, [0x90000+bmp_header.width]
  222.     mov   [_skinoperw], eax
  223.     neg   eax
  224.     mov   [_skinoper], eax
  225.     pop   eax
  226.     add   eax, [_refbase_1]
  227.     ; align to 32-byte boundary
  228.     test  eax, 11111b
  229.     jz    @f
  230.     shr   eax, 5
  231.     inc   eax
  232.     shl   eax, 5
  233.   @@:
  234.     mov   [_refoper_1], eax
  235.     mov   edi, eax
  236.     mov   esi, 0x90000
  237.     call  bmp2raw
  238.     mov   eax, [0x90000+bmp_header.height]
  239.     mov   [_skinh], eax
  240.     popad
  241.     ret
  242.  
  243. drawwindow_IV:
  244.  
  245.         pusha
  246.  
  247.         push  edx
  248.  
  249.         mov   edi,[esp]                              ; RECTANGLE
  250.  
  251.         mov   eax,[edi+0]
  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.         mov   esi,[esp]
  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.  
  293.         cmp   [aw_yes],1
  294. ;        cmp   [esp+32+4+2], word 1
  295.         jne   @f
  296.         mov   ebx,[_refleft]
  297.         jmp   no_aw_3
  298.      @@:
  299.         mov   ebx,[_refleft_1]
  300.       no_aw_3:
  301.         call  sys_putimage
  302.  
  303.         mov   esi,[esp]
  304.         mov   eax,[esi+8]
  305.         sub   eax,[_skinleftw]
  306.         sub   eax,[_skinoperw]
  307.         cmp   eax,[_skinbase]
  308.         jng   non_base
  309.         xor   edx,edx
  310.         mov   ebx,[_skinbasew]
  311.         div   ebx
  312.  
  313.         inc   eax
  314.  
  315.         cmp   [aw_yes],1
  316. ;        cmp   [esp+32+4+2], word 1
  317.         jne   @f
  318.         mov   ebx,[_refbase]
  319.         jmp   no_aw_2
  320.      @@:
  321.         mov   ebx,[_refbase_1]
  322.       no_aw_2:
  323.         mov   ecx,[_skinbasew]
  324.         shl   ecx,16
  325.         add   ecx,[_skinh]
  326.         mov   edx,[_skinbase]
  327.         sub   edx,[_skinbasew]
  328.         shl   edx,16
  329.       baseskinloop:
  330.         shr   edx,16
  331.         add   edx,[_skinbasew]
  332.         shl   edx,16
  333.  
  334.         push  eax ebx ecx edx
  335.         call  sys_putimage
  336.         pop   edx ecx ebx eax
  337.  
  338.         dec   eax
  339.         jnz   baseskinloop
  340.       non_base:
  341.  
  342.         mov   esi,[esp]
  343.         mov   edx,[esi+8]
  344.         sub   edx,[_skinoperw]
  345.         inc   edx
  346.         shl   edx,16
  347.         cmp   [aw_yes],1
  348. ;        cmp   [esp+32+4+2], word 1
  349.         jne   @f
  350.         mov   ebx,[_refoper]
  351.         jmp   no_aw_1
  352.      @@:
  353.         mov   ebx,[_refoper_1]
  354.       no_aw_1:
  355.         mov   ecx,[_skinoperw]
  356.         shl   ecx,16
  357.         add   ecx,[_skinh]
  358.         call  sys_putimage
  359.  
  360.         mov   esi,[esp]
  361.  
  362.         mov   edx,[esi+04]                       ; WORK AREA
  363.         add   edx,21+5
  364.         mov   ebx,[esi+04]
  365.         add   ebx,[esi+12]
  366.         cmp   edx,ebx
  367.         jg    _noinside2
  368.         mov   eax,5
  369.         mov   ebx,[_skinh]
  370.         mov   ecx,[esi+8]
  371.         mov   edx,[esi+12]
  372.         sub   ecx,4
  373.         sub   edx,4
  374.         mov   edi,[esi+16]
  375.         call  [drawbar]
  376.       _noinside2:
  377.  
  378.         mov   edi,[0xfe88]
  379.         movzx eax,word [edi]
  380.         cmp   eax,1000
  381.         jge   no_skin_add_button
  382.         inc   eax
  383.         mov   [edi],ax
  384.  
  385.         shl   eax,4
  386.         add   eax,edi
  387.  
  388.         mov   bx,[0x3000]
  389.         mov   [eax],bx
  390.  
  391.         add   eax,2         ; save button id number
  392.         mov   bx,1
  393.         mov   [eax],bx
  394.         add   eax,2         ; x start
  395.         mov   ebx,[esp]
  396.         mov   ebx,[ebx+8]
  397.         cmp   [_buttonCx],0
  398.         jg    _bCx_at_right
  399.         mov   ebx,[_buttonCw]    ; ebx will be 0 in next instruction
  400.       _bCx_at_right:
  401.         sub   ebx,[_buttonCw]
  402.         sub   ebx,[_buttonCx]
  403.         mov   [eax],bx
  404.         add   eax,2         ; x size
  405.         mov   ebx,[_buttonCw]
  406.         mov   [eax],bx
  407.         add   eax,2         ; y start
  408.         mov   ebx,[_buttonCy]
  409.         mov   [eax],bx
  410.         add   eax,2         ; y size
  411.         mov   ebx,[_buttonCh]
  412.         mov   [eax],bx
  413.  
  414. ;* minimize button
  415.         mov   edi,[0xfe88]
  416.         movzx eax,word [edi]
  417.         cmp   eax,1000
  418.         jge   no_skin_add_button
  419.         inc   eax
  420.         mov   [edi],ax
  421.  
  422.         shl   eax,4
  423.         add   eax,edi
  424.  
  425.         mov   bx,[0x3000]
  426.         mov   [eax],bx
  427.  
  428.         add   eax,2         ; save button id number
  429.         mov   bx,65535 ;999
  430.         mov   [eax],bx
  431.         add   eax,2         ; x start
  432.         mov   ebx,[esp]
  433.         mov   ebx,[ebx+8]
  434.         cmp   [_buttonMx],0
  435.         jg    _bMx_at_right
  436.         mov   ebx,[_buttonMw]    ; ebx will be 0 in next instruction
  437.       _bMx_at_right:
  438.         sub   ebx,[_buttonMw]
  439.         sub   ebx,[_buttonMx]
  440.         mov   [eax],bx
  441.         add   eax,2         ; x size
  442.         mov   ebx,[_buttonMw]
  443.         mov   [eax],bx
  444.         add   eax,2         ; y start
  445.         mov   ebx,[_buttonMy]
  446.         mov   [eax],bx
  447.         add   eax,2         ; y size
  448.         mov   ebx,[_buttonMh]
  449.         mov   [eax],bx
  450. ;* minimize button
  451.  
  452.       no_skin_add_button:
  453.  
  454.         add   esp,4
  455.         popa
  456.  
  457.         ret
  458.  
  459.  
  460.