Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1433 | mario79 | 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 |
||
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 |
||
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 | macro use_path_show |
||
41 | { |
||
42 | path_show: |
||
43 | ps_type equ [edi] ;dword |
||
44 | ps_start_y equ [edi+4] ;word |
||
45 | ps_start_x equ [edi+6] ;word |
||
46 | ps_font_size_x equ [edi+8] ;word |
||
47 | ps_area_size_x equ [edi+10] ;word |
||
48 | ps_font_number equ [edi+12] ;dword |
||
49 | ps_background_flag equ [edi+16] ;dword |
||
50 | ps_font_color equ [edi+20] ;dword |
||
51 | ps_background_color equ [edi+24] ;dword |
||
52 | ps_text_pointer equ [edi+28] ;dword |
||
53 | ps_work_area_pointer equ [edi+32] ;dword |
||
54 | ps_temp_text_length equ [edi+36] ;dword |
||
55 | ;***************************************************************************** |
||
56 | ;***************************************************************************** |
||
57 | ; draw event |
||
58 | ;***************************************************************************** |
||
59 | ;***************************************************************************** |
||
60 | .prepare: |
||
61 | path_show_start |
||
62 | ;------------------------------------- |
||
63 | mov esi,ps_text_pointer |
||
64 | xor eax,eax |
||
65 | xor ecx,ecx |
||
66 | dec ecx |
||
67 | cld |
||
68 | @@: |
||
69 | lodsb |
||
70 | inc ecx |
||
71 | test eax,eax |
||
72 | jnz @b |
||
73 | mov ps_temp_text_length,ecx |
||
74 | movzx eax,word ps_font_size_x |
||
75 | imul ecx,eax |
||
76 | movzx eax,word ps_area_size_x |
||
77 | cmp ecx,eax |
||
78 | jae .cut |
||
79 | ;------------------------------------- |
||
80 | mov esi,ps_text_pointer |
||
81 | mov edi,ps_work_area_pointer |
||
82 | xor eax,eax |
||
83 | @@: |
||
84 | lodsb |
||
85 | stosb |
||
86 | test eax,eax |
||
87 | jnz @b |
||
88 | jmp .exit |
||
89 | ;------------------------------------- |
||
90 | .cut: |
||
91 | ; copy the first 6 characters of path |
||
92 | mov esi,ps_text_pointer |
||
93 | push edi |
||
94 | mov edi,ps_work_area_pointer |
||
95 | mov ecx,6 |
||
96 | rep movsb |
||
97 | ; insert a line break '...' |
||
98 | mov al,byte '.' |
||
99 | mov ecx,3 |
||
100 | rep stosb |
||
101 | mov ecx,edi |
||
102 | ; calculate the display length, in characters |
||
103 | pop edi |
||
104 | movzx ebx,word ps_font_size_x |
||
105 | movzx eax,word ps_area_size_x |
||
106 | xor edx,edx |
||
107 | div ebx |
||
108 | sub eax,9 |
||
109 | ; eax - maximum length of display area, the number of characters |
||
110 | mov esi,ps_temp_text_length |
||
111 | add esi,ps_text_pointer |
||
112 | sub esi,eax |
||
113 | ; esi - pointer of the last segment of the displayed text |
||
114 | mov edi,ecx |
||
115 | mov ecx,eax |
||
116 | rep movsb |
||
117 | xor eax,eax |
||
118 | stosb |
||
119 | ;------------------------------------- |
||
120 | .exit: |
||
121 | path_show_exit |
||
122 | ;***************************************************************************** |
||
123 | ;***************************************************************************** |
||
124 | ; draw event |
||
125 | ;***************************************************************************** |
||
126 | ;***************************************************************************** |
||
127 | .draw: |
||
128 | path_show_start |
||
129 | ;------------------------------------- |
||
130 | mov ebx,ps_start_y |
||
131 | xor ecx,ecx |
||
132 | or ecx,0x80000000 |
||
133 | mov eax,ps_background_flag |
||
134 | and eax,1b |
||
135 | shl eax,30 |
||
136 | add ecx,eax |
||
137 | mov eax,ps_font_number |
||
138 | and eax,11b |
||
139 | shl eax,28 |
||
140 | add ecx,eax |
||
141 | mov eax,ps_font_color |
||
142 | and eax,0xffffff |
||
143 | add ecx,eax |
||
144 | mov edx,ps_work_area_pointer |
||
145 | mov eax,ps_background_color |
||
146 | and eax,0xffffff |
||
147 | xor esi,esi |
||
148 | mov edi,eax |
||
149 | mcall 4 |
||
150 | path_show_exit |
||
151 | } |
||
152 | ;***************************************************************************** |