Rev 109 | Go to most recent revision | Details | Compare with Previous | 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 |
||
316 | heavyiron | 27 | call draw_window |
28 | red: |
||
29 | call get_transparent |
||
31 | halyavin | 30 | call draw_window ; at first, draw the window |
31 | |||
32 | still: |
||
33 | |||
34 | mov eax,10 ; wait here for event |
||
35 | int 0x40 |
||
36 | |||
37 | cmp eax,1 ; redraw request ? |
||
38 | je red |
||
39 | cmp eax,2 ; key in buffer ? |
||
40 | je key |
||
41 | cmp eax,3 ; button in buffer ? |
||
42 | je button |
||
43 | jmp still |
||
44 | |||
45 | key: ; key |
||
316 | heavyiron | 46 | mov al,2 ; just read it and ignore |
31 | halyavin | 47 | int 0x40 |
48 | jmp still |
||
49 | |||
50 | button: ; button |
||
316 | heavyiron | 51 | mov al,17 ; get id |
31 | halyavin | 52 | int 0x40 |
53 | |||
54 | cmp ah,1 ; button id=1 ? |
||
55 | jne noclose |
||
316 | heavyiron | 56 | or eax,-1 ; close this program |
31 | halyavin | 57 | int 0x40 |
58 | noclose: |
||
59 | |||
60 | jmp still |
||
61 | |||
62 | |||
63 | ; ********************************************* |
||
64 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
65 | ; ********************************************* |
||
66 | |||
67 | |||
68 | draw_window: |
||
69 | |||
70 | mov eax,12 ; function 12:tell os about windowdraw |
||
71 | mov ebx,1 ; 1, start of draw |
||
72 | int 0x40 |
||
73 | ; DRAW WINDOW |
||
316 | heavyiron | 74 | xor eax,eax ; function 0 : define and draw window |
31 | halyavin | 75 | mov ebx,[procinfo.x_start] |
76 | shl ebx,16 |
||
77 | add ebx,[procinfo.x_size] |
||
78 | mov ecx,[procinfo.y_start] |
||
79 | shl ecx,16 |
||
80 | add ecx,[procinfo.y_size] |
||
316 | heavyiron | 81 | mov edx,0x33000000 ; color of work area RRGGBB,8->color gl |
82 | mov edi,header ; WINDOW LABEL |
||
31 | halyavin | 83 | int 0x40 |
84 | |||
85 | call draw_transparent |
||
316 | heavyiron | 86 | |
31 | halyavin | 87 | mov eax,12 ; function 12:tell os about windowdraw |
88 | mov ebx,2 ; 2, end of draw |
||
89 | int 0x40 |
||
90 | |||
91 | ret |
||
92 | |||
93 | |||
94 | |||
95 | |||
96 | draw_transparent: |
||
97 | |||
98 | pusha |
||
99 | |||
100 | mov eax,7 |
||
101 | mov ebx,0x1000 |
||
102 | mov ecx,[procinfo.x_size] |
||
103 | shl ecx,16 |
||
104 | add ecx,[procinfo.y_size] |
||
316 | heavyiron | 105 | xor edx,edx |
31 | halyavin | 106 | int 0x40 |
107 | |||
108 | popa |
||
109 | ret |
||
110 | |||
111 | |||
112 | get_transparent: |
||
113 | |||
114 | pusha |
||
115 | |||
116 | mov eax,9 |
||
117 | mov ebx,I_END |
||
118 | mov ecx,-1 |
||
119 | int 0x40 |
||
120 | |||
121 | mov eax,14 |
||
122 | int 0x40 |
||
123 | |||
124 | shr eax,16 |
||
125 | inc eax |
||
126 | mov [scx],eax |
||
127 | |||
128 | add [procinfo.x_start], 4 |
||
129 | sub [procinfo.x_size], 4+4 |
||
130 | add [procinfo.y_start], 22 |
||
131 | sub [procinfo.y_size], 22+4 |
||
132 | |||
133 | mov eax,[procinfo.x_start] |
||
134 | add eax,[procinfo.x_size] |
||
135 | mov [x_end],eax |
||
136 | mov eax,[procinfo.y_start] |
||
137 | add eax,[procinfo.y_size] |
||
138 | mov [y_end],eax |
||
139 | |||
140 | mov eax,[procinfo.x_start] |
||
141 | mov ebx,[procinfo.y_start] |
||
142 | |||
143 | dtpl1: |
||
144 | |||
145 | push eax |
||
146 | push ebx |
||
147 | |||
148 | imul ebx,[scx] |
||
149 | add ebx,eax |
||
150 | mov eax,35 |
||
151 | int 0x40 |
||
152 | |||
153 | or eax, 0x4e4e4e |
||
154 | |||
155 | mov ebx,[esp+4] |
||
156 | mov ecx,[esp] |
||
157 | sub ebx,[procinfo.x_start] |
||
158 | sub ecx,[procinfo.y_start] |
||
159 | imul ecx,[procinfo.x_size] |
||
160 | imul ebx,3 |
||
161 | imul ecx,3 |
||
162 | add ebx,ecx |
||
163 | mov [0x1000+ebx],eax |
||
164 | |||
165 | pop ebx |
||
166 | pop eax |
||
167 | |||
168 | inc eax |
||
169 | cmp eax,[x_end] |
||
170 | jb dtpl1 |
||
171 | mov eax,[procinfo.x_start] |
||
172 | inc ebx |
||
173 | cmp ebx,[y_end] |
||
174 | jb dtpl1 |
||
175 | |||
176 | popa |
||
177 | |||
178 | ret |
||
179 | |||
180 | |||
181 | |||
182 | |||
183 | ; DATA AREA |
||
184 | |||
185 | ;x_start dd 100 |
||
186 | ;y_start dd 80 |
||
187 | |||
188 | ;x_size dd 160 |
||
189 | ;y_size dd 200 |
||
190 | |||
191 | x_end dd 0 |
||
192 | y_end dd 0 |
||
193 | |||
194 | scx dd 640 |
||
195 | |||
316 | heavyiron | 196 | header db 'Transparent',0 |
31 | halyavin | 197 | |
198 | I_END: |
||
199 | procinfo process_information |
||
200 |