Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;**************************************************************
  2. ; Path Show Macro for Kolibri OS
  3. ; Copyright (c) 2010, Marat Zakiyanov aka Mario79, aka Mario
  4. ; All rights reserved.
  5. ;
  6. ; Redistribution and use in source and binary forms, with or without
  7. ; modification, are permitted provided that the following conditions are met:
  8. ;     * Redistributions of source code must retain the above copyright
  9. ;       notice, this list of conditions and the following disclaimer.
  10. ;     * Redistributions in binary form must reproduce the above copyright
  11. ;       notice, this list of conditions and the following disclaimer in the
  12. ;       documentation and/or other materials provided with the distribution.
  13. ;     * Neither the name of the <organization> nor the
  14. ;       names of its contributors may be used to endorse or promote products
  15. ;       derived from this software without specific prior written permission.
  16. ;
  17. ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
  18. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  21. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ;*****************************************************************************
  28. macro path_show_start
  29. {
  30.         pusha
  31.         mov     edi,dword [esp+36]
  32. }
  33. ;*****************************************************************************
  34. macro path_show_exit
  35. {
  36. popa
  37. ret 4
  38. }
  39. ;*****************************************************************************
  40. align 16
  41. path_show:
  42. ps_type                 equ [edi]       ;dword
  43. ps_start_y              equ [edi+4]     ;word
  44. ps_start_x              equ [edi+6]     ;word
  45. ps_font_size_x          equ [edi+8]     ;word
  46. ps_area_size_x          equ [edi+10]    ;word
  47. ps_font_number          equ [edi+12]    ;dword
  48. ps_background_flag      equ [edi+16]    ;dword
  49. ps_font_color           equ [edi+20]    ;dword
  50. ps_background_color     equ [edi+24]    ;dword
  51. ps_text_pointer         equ [edi+28]    ;dword
  52. ps_work_area_pointer    equ [edi+32]    ;dword
  53. ps_temp_text_length     equ [edi+36]    ;dword
  54. ;*****************************************************************************
  55. ;*****************************************************************************
  56. ; draw event
  57. ;*****************************************************************************
  58. ;*****************************************************************************
  59. .prepare:
  60. path_show_start
  61. ;-------------------------------------
  62.         mov     esi,ps_text_pointer
  63.         xor     eax,eax
  64.         xor     ecx,ecx
  65.         dec     ecx
  66.         cld
  67. @@:
  68.         lodsb
  69.         inc     ecx
  70.         test    eax,eax
  71.         jnz     @b
  72.         mov     ps_temp_text_length,ecx
  73.         movzx   eax,word ps_font_size_x
  74.         imul    ecx,eax
  75.         movzx   eax,word ps_area_size_x
  76.         cmp     ecx,eax
  77.         jae     .cut
  78. ;-------------------------------------
  79.         mov     esi,ps_text_pointer
  80.         mov     edi,ps_work_area_pointer
  81.         xor     eax,eax
  82. @@:
  83.         lodsb
  84.         stosb
  85.         test    eax,eax
  86.         jnz     @b
  87.         jmp     .exit
  88. ;-------------------------------------
  89. .cut:
  90. ; copy the first 6 characters of path
  91.         mov     esi,ps_text_pointer
  92.         push    edi
  93.         mov     edi,ps_work_area_pointer
  94.         mov     ecx,6
  95.         rep     movsb
  96. ; insert a line break '...'    
  97.         mov     al,byte '.'
  98.         mov     ecx,3
  99.         rep     stosb
  100.         mov     ecx,edi
  101. ; calculate the display length, in characters
  102.         pop     edi
  103.         movzx   ebx,word ps_font_size_x
  104.         movzx   eax,word ps_area_size_x
  105.         xor     edx,edx
  106.         div     ebx
  107.         sub     eax,9
  108. ; eax - maximum length of display area, the number of characters       
  109.         mov     esi,ps_temp_text_length
  110.         add     esi,ps_text_pointer
  111.         sub     esi,eax
  112. ; esi - pointer of the last segment of the displayed text
  113.         mov     edi,ecx
  114.         mov     ecx,eax
  115.         rep     movsb
  116.         xor     eax,eax
  117.         stosb
  118. ;-------------------------------------
  119. .exit:
  120. path_show_exit
  121. ;*****************************************************************************
  122. ;*****************************************************************************
  123. ; draw event
  124. ;*****************************************************************************
  125. ;*****************************************************************************
  126. .draw:
  127. path_show_start
  128. ;-------------------------------------
  129.         mov     ebx,ps_start_y
  130.         xor     ecx,ecx
  131.         or      ecx,0x80000000
  132.         mov     eax,ps_background_flag
  133.         and     eax,1b
  134.         shl     eax,30
  135.         add     ecx,eax
  136.         mov     eax,ps_font_number
  137.         and     eax,11b
  138.         shl     eax,28
  139.         add     ecx,eax
  140.         mov     eax,ps_font_color
  141.         and     eax,0xffffff
  142.         add     ecx,eax
  143.         mov     edx,ps_work_area_pointer
  144.         mov     eax,ps_background_color
  145.         and     eax,0xffffff
  146.         xor     esi,esi
  147.         mov     edi,eax
  148.         mcall   SF_DRAW_TEXT
  149. path_show_exit
  150. ;*****************************************************************************
  151.