Rev 109 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; |
2 | ; TRANSPARENT EXAMPLE |
||
3 | ; |
||
4 | ; Compile with FASM for Menuet |
||
5 | ; |
||
6 | |||
7 | use32 |
||
8 | |||
9 | org 0x0 |
||
10 | |||
11 | db 'MENUET01' ; 8 byte id |
||
12 | dd 0x01 ; header version |
||
13 | dd START ; start of code |
||
14 | dd I_END ; size of image |
||
15 | dd 0x30000 ; memory for app |
||
16 | dd 0x30000 ; esp |
||
17 | dd 0x0 , 0x0 ; I_Param , I_Icon |
||
18 | |||
19 | include 'lang.inc' |
||
20 | include 'macros.inc' |
||
21 | |||
22 | START: ; start of execution |
||
23 | mov [procinfo.x_start], 100 |
||
24 | mov [procinfo.x_size], 200 |
||
25 | mov [procinfo.y_start], 80 |
||
26 | mov [procinfo.y_size], 300 |
||
27 | |||
28 | call draw_window ; at first, draw the window |
||
29 | |||
30 | still: |
||
31 | |||
32 | mov eax,10 ; wait here for event |
||
33 | int 0x40 |
||
34 | |||
35 | cmp eax,1 ; redraw request ? |
||
36 | je red |
||
37 | cmp eax,2 ; key in buffer ? |
||
38 | je key |
||
39 | cmp eax,3 ; button in buffer ? |
||
40 | je button |
||
41 | |||
42 | jmp still |
||
43 | |||
44 | red: ; redraw |
||
45 | call get_transparent |
||
46 | call draw_window |
||
47 | jmp still |
||
48 | |||
49 | key: ; key |
||
50 | mov eax,2 ; just read it and ignore |
||
51 | int 0x40 |
||
52 | jmp still |
||
53 | |||
54 | button: ; button |
||
55 | mov eax,17 ; get id |
||
56 | int 0x40 |
||
57 | |||
58 | cmp ah,1 ; button id=1 ? |
||
59 | jne noclose |
||
60 | mov eax,-1 ; close this program |
||
61 | int 0x40 |
||
62 | noclose: |
||
63 | |||
64 | jmp still |
||
65 | |||
66 | |||
67 | ; ********************************************* |
||
68 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
69 | ; ********************************************* |
||
70 | |||
71 | |||
72 | draw_window: |
||
73 | |||
74 | mov eax,12 ; function 12:tell os about windowdraw |
||
75 | mov ebx,1 ; 1, start of draw |
||
76 | int 0x40 |
||
77 | ; DRAW WINDOW |
||
78 | mov eax,0 ; function 0 : define and draw window |
||
79 | mov ebx,[procinfo.x_start] |
||
80 | shl ebx,16 |
||
81 | add ebx,[procinfo.x_size] |
||
82 | dec ebx |
||
83 | mov ecx,[procinfo.y_start] |
||
84 | shl ecx,16 |
||
85 | add ecx,[procinfo.y_size] |
||
86 | dec ecx |
||
87 | mov edx,0x03000000 ; color of work area RRGGBB,8->color gl |
||
88 | int 0x40 |
||
89 | |||
90 | call draw_transparent |
||
91 | ; WINDOW LABEL |
||
92 | mov eax,4 ; function 4 : write text to window |
||
93 | mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
||
94 | mov ecx,0x10ddeeff ; color of text RRGGBB |
||
95 | mov edx,labelt ; pointer to text beginning |
||
96 | mov esi,labellen-labelt ; text length |
||
97 | int 0x40 |
||
98 | |||
99 | ; call draw_transparent |
||
100 | |||
101 | mov eax,12 ; function 12:tell os about windowdraw |
||
102 | mov ebx,2 ; 2, end of draw |
||
103 | int 0x40 |
||
104 | |||
105 | ret |
||
106 | |||
107 | |||
108 | |||
109 | |||
110 | draw_transparent: |
||
111 | |||
112 | pusha |
||
113 | |||
114 | mov eax,7 |
||
115 | mov ebx,0x1000 |
||
116 | mov ecx,[procinfo.x_size] |
||
117 | shl ecx,16 |
||
118 | add ecx,[procinfo.y_size] |
||
119 | mov edx,4*65536+22 |
||
120 | int 0x40 |
||
121 | |||
122 | popa |
||
123 | ret |
||
124 | |||
125 | |||
126 | get_transparent: |
||
127 | |||
128 | pusha |
||
129 | |||
130 | mov eax,9 |
||
131 | mov ebx,I_END |
||
132 | mov ecx,-1 |
||
133 | int 0x40 |
||
134 | ; mov eax,[I_END+34] |
||
135 | ; mov [x_start],eax |
||
136 | ; mov eax,[I_END+38] |
||
137 | ; mov [y_start],eax |
||
138 | |||
139 | mov eax,14 |
||
140 | int 0x40 |
||
141 | |||
142 | shr eax,16 |
||
143 | inc eax |
||
144 | mov [scx],eax |
||
145 | |||
146 | add [procinfo.x_start], 4 |
||
147 | sub [procinfo.x_size], 4+4 |
||
148 | add [procinfo.y_start], 22 |
||
149 | sub [procinfo.y_size], 22+4 |
||
150 | |||
151 | mov eax,[procinfo.x_start] |
||
152 | add eax,[procinfo.x_size] |
||
153 | mov [x_end],eax |
||
154 | mov eax,[procinfo.y_start] |
||
155 | add eax,[procinfo.y_size] |
||
156 | mov [y_end],eax |
||
157 | |||
158 | mov eax,[procinfo.x_start] |
||
159 | mov ebx,[procinfo.y_start] |
||
160 | |||
161 | dtpl1: |
||
162 | |||
163 | push eax |
||
164 | push ebx |
||
165 | |||
166 | imul ebx,[scx] |
||
167 | add ebx,eax |
||
168 | mov eax,35 |
||
169 | int 0x40 |
||
170 | |||
171 | ; shr eax,1 |
||
172 | ; and eax,0x7f7f7f |
||
173 | or eax, 0x4e4e4e |
||
174 | |||
175 | mov ebx,[esp+4] |
||
176 | mov ecx,[esp] |
||
177 | sub ebx,[procinfo.x_start] |
||
178 | sub ecx,[procinfo.y_start] |
||
179 | imul ecx,[procinfo.x_size] |
||
180 | imul ebx,3 |
||
181 | imul ecx,3 |
||
182 | add ebx,ecx |
||
183 | mov [0x1000+ebx],eax |
||
184 | |||
185 | pop ebx |
||
186 | pop eax |
||
187 | |||
188 | inc eax |
||
189 | cmp eax,[x_end] |
||
190 | jb dtpl1 |
||
191 | mov eax,[procinfo.x_start] |
||
192 | inc ebx |
||
193 | cmp ebx,[y_end] |
||
194 | jb dtpl1 |
||
195 | |||
196 | popa |
||
197 | |||
198 | ret |
||
199 | |||
200 | |||
201 | |||
202 | |||
203 | ; DATA AREA |
||
204 | |||
205 | ;x_start dd 100 |
||
206 | ;y_start dd 80 |
||
207 | |||
208 | ;x_size dd 160 |
||
209 | ;y_size dd 200 |
||
210 | |||
211 | x_end dd 0 |
||
212 | y_end dd 0 |
||
213 | |||
214 | scx dd 640 |
||
215 | |||
216 | labelt: |
||
217 | db 'EXAMPLE APPLICATION' |
||
218 | labellen: |
||
219 | |||
220 | I_END: |
||
221 | procinfo process_information |
||
222 |