Rev 109 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 109 | Rev 485 | ||
---|---|---|---|
1 | ; |
1 | ; |
2 | ; MENU EXAMPLE |
2 | ; MENU EXAMPLE |
3 | ; |
3 | ; |
4 | ; Compile with FASM for Menuet |
4 | ; Compile with FASM for Menuet |
5 | ; |
5 | ; |
6 | 6 | ||
7 | use32 |
7 | use32 |
8 | org 0x0 |
8 | org 0x0 |
9 | 9 | ||
10 | db 'MENUET01' ; 8 byte id |
10 | db 'MENUET01' ; 8 byte id |
11 | dd 0x01 ; header version |
11 | dd 0x01 ; header version |
12 | dd START ; start of code |
12 | dd START ; start of code |
13 | dd I_END ; size of image |
13 | dd I_END ; size of image |
14 | dd 0x1000 ; memory for app |
14 | dd 0x1000 ; memory for app |
15 | dd 0x1000 ; esp |
15 | dd 0x1000 ; esp |
16 | dd 0x0 , 0x0 ; I_Param , I_Icon |
16 | dd 0x0 , 0x0 ; I_Param , I_Icon |
17 | 17 | ||
18 | include 'lang.inc' |
18 | include 'lang.inc' |
19 | include 'macros.inc' |
19 | include '..\..\..\..\macros.inc' |
20 | 20 | ||
21 | START: ; start of execution |
21 | START: ; start of execution |
- | 22 | ||
22 | 23 | red: |
|
23 | call draw_window ; draw window |
24 | call draw_window ; draw window |
24 | call clear_data ; clear status bar |
25 | call clear_data ; clear status bar |
25 | 26 | ||
26 | still: |
27 | still: |
27 | 28 | ||
28 | mov eax,10 ; wait here for event |
29 | mov eax,10 ; wait here for event |
29 | int 0x40 ; do it |
30 | mcall ; do it |
30 | 31 | ||
31 | cmp eax,1 ; redraw request ? |
32 | cmp eax,1 ; redraw request ? |
32 | je red ; yes jump to it |
33 | jz red ; yes jump to it |
33 | cmp eax,2 ; key in buffer ? |
- | |
34 | je key ; yes jump to it |
- | |
35 | cmp eax,3 ; button in buffer ? |
34 | cmp eax,2 ; key in buffer ? |
36 | je button ; yes jump to it |
- | |
37 | jmp still ; start again |
- | |
38 | - | ||
39 | red: ; redraw |
- | |
40 | call draw_window ; redraw window |
- | |
41 | call clear_data ; clear status info |
- | |
42 | jmp still ; start again |
35 | jnz button |
43 | 36 | ||
44 | key: ; key |
37 | key: ; key |
45 | mov eax,2 ; just read it and ignore |
38 | mov eax,2 ; just read it and ignore |
46 | int 0x40 ; do it |
39 | mcall ; do it |
47 | jmp still ; start again |
40 | jmp still ; start again |
48 | 41 | ||
49 | button: ; button |
42 | button: ; button |
50 | mov eax,17 ; get id |
43 | mov eax,17 ; get id |
51 | int 0x40 ; do it |
44 | mcall ; do it |
52 | 45 | ||
53 | cmp ah,1 ; is it the close button |
46 | cmp ah,1 ; is it the close button |
54 | jne noclose ; no then jump code |
47 | jne noclose ; no then jump code |
55 | mov eax,-1 ; close this program |
48 | or eax,-1 ; close this program |
56 | int 0x40 ; do it |
49 | mcall ; do it |
57 | noclose: |
50 | noclose: |
58 | 51 | ||
59 | cmp ah,100 ; is it main menu |
52 | cmp ah,100 ; is it main menu |
60 | jb not_menu ; no then jump code |
53 | jb not_menu ; no then jump code |
61 | cmp ah,104 ; is it main menu |
54 | cmp ah,104 ; is it main menu |
62 | ja not_menu ; no then jump code |
55 | ja not_menu ; no then jump code |
63 | call draw_window ; redraw window |
56 | call draw_window ; redraw window |
64 | call clear_data ; clear status info |
57 | call clear_data ; clear status info |
65 | call draw_data ; update status info |
58 | call draw_data ; update status info |
66 | call write_sub ; draw a sub menu |
59 | call write_sub ; draw a sub menu |
67 | jmp still ; start again |
60 | jmp still ; start again |
68 | not_menu: |
61 | not_menu: |
69 | 62 | ||
70 | cmp ah,110 ; is it a sub menu |
63 | cmp ah,110 ; is it a sub menu |
71 | jb not_sub ; no then jump code |
64 | jb not_sub ; no then jump code |
72 | cmp ah,145 ; is it a sub menu |
65 | cmp ah,145 ; is it a sub menu |
73 | ja not_sub ; no then jump code |
66 | ja not_sub ; no then jump code |
74 | call draw_window ; redraw window |
67 | call draw_window ; redraw window |
75 | call clear_data ; clear status info |
68 | call clear_data ; clear status info |
76 | mov [button_press],1 ; sub button pressed |
69 | mov [button_press],1 ; sub button pressed |
77 | call draw_data ; update status info |
70 | call draw_data ; update status info |
78 | mov [button_press],0 ; clear pressed |
71 | mov [button_press],0 ; clear pressed |
79 | jmp still ; start again |
72 | jmp still ; start again |
80 | not_sub: |
73 | not_sub: |
81 | 74 | ||
82 | jmp still ; start again |
75 | jmp still ; start again |
83 | 76 | ||
84 | 77 | ||
85 | ; ********************************************* |
78 | ; ********************************************* |
86 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
79 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
87 | ; ********************************************* |
80 | ; ********************************************* |
88 | 81 | ||
89 | draw_window: |
82 | draw_window: |
90 | 83 | ||
91 | push eax ; save register |
84 | push eax ; save register |
92 | 85 | ||
93 | mov eax,12 ; function 12: tell os about windowdraw |
86 | mov eax,12 ; function 12: tell os about windowdraw |
94 | mov ebx,1 ; 1, start of draw |
87 | mov ebx,1 ; 1, start of draw |
95 | int 0x40 ; do it |
88 | mcall ; do it |
96 | 89 | ||
97 | mov eax,0 ; function 0: define and draw window |
90 | mov eax,0 ; function 0: define and draw window |
98 | mov ebx,50*65536 ; [x start] *65536 |
91 | mov ebx,50*65536 ; [x start] *65536 |
99 | add ebx,[x_size] ; add [x size] |
92 | add ebx,[x_size] ; add [x size] |
100 | mov ecx,50*65536 ; [y start] *65536 |
93 | mov ecx,50*65536 ; [y start] *65536 |
101 | add ecx,[y_size] ; add [y size] |
94 | add ecx,[y_size] ; add [y size] |
102 | mov edx,0x80ffffff ; colour of work area RRGGBB |
95 | mov edx,0x80ffffff ; colour of work area RRGGBB |
103 | mov esi,0x806688dd ; grab bar colour. negative glide |
96 | mov esi,0x806688dd ; grab bar colour. negative glide |
104 | int 0x40 ; do it |
97 | mcall ; do it |
105 | 98 | ||
106 | mov eax,4 ; function 4: write text to window |
99 | mov eax,4 ; function 4: write text to window |
107 | mov ebx,6*65536+7 ; [x start] *65536 + [y start] |
100 | mov ebx,6*65536+7 ; [x start] *65536 + [y start] |
108 | mov ecx,0x00ffffff ; text colour |
101 | mov ecx,0x00ffffff ; text colour |
109 | mov edx,window_text ; pointer to text beginning |
102 | mov edx,window_text ; pointer to text beginning |
110 | mov esi,12 ; text length |
103 | mov esi,12 ; text length |
111 | int 0x40 ; do it |
104 | mcall ; do it |
112 | 105 | ||
113 | mov eax,8 ; function 8: define and draw button |
106 | mov eax,8 ; function 8: define and draw button |
114 | mov ebx,(381-18)*65536+13 ; [x start] *65536 + [x size] |
107 | mov ebx,(381-18)*65536+13 ; [x start] *65536 + [x size] |
115 | mov ecx,4*65536+13 ; [y start] *65536 + [y size] |
108 | mov ecx,4*65536+13 ; [y start] *65536 + [y size] |
116 | mov edx,1 ; button id |
109 | mov edx,1 ; button id |
117 | mov esi,0x6688dd ; button color RRGGBB |
110 | mov esi,0x6688dd ; button color RRGGBB |
118 | int 0x40 ; do it |
111 | mcall ; do it |
119 | 112 | ||
120 | mov eax,13 ; function 13: draw bar |
113 | mov eax,13 ; function 13: draw bar |
121 | mov ebx,1*65536 ; [x start] *65536 |
114 | mov ebx,1*65536 ; [x start] *65536 |
122 | add ebx,[x_size] ; add [x size] |
115 | add ebx,[x_size] ; add [x size] |
123 | dec ebx ; x size - 1 |
116 | dec ebx ; x size - 1 |
124 | mov ecx,[y_size] ; [y start] *65536 |
117 | mov ecx,[y_size] ; [y start] *65536 |
125 | sub ecx,17 ; minus height |
118 | sub ecx,17 ; minus height |
126 | shl ecx,16 ; *65536 |
119 | shl ecx,16 ; *65536 |
127 | add ecx,17 ; add height |
120 | add ecx,17 ; add height |
128 | mov edx,0x006688dd ; bar colour |
121 | mov edx,0x006688dd ; bar colour |
129 | int 0x40 ; do it |
122 | mcall ; do it |
130 | 123 | ||
131 | mov eax,4 ; function 4 : write text to window |
124 | mov eax,4 ; function 4 : write text to window |
132 | mov ebx,5*65536 ; [x start] *65536 |
125 | mov ebx,5*65536 ; [x start] *65536 |
133 | add ebx,[y_size] ; add [y start] |
126 | add ebx,[y_size] ; add [y start] |
134 | sub ebx,12 ; move up |
127 | sub ebx,12 ; move up |
135 | xor ecx,ecx ; text colour |
128 | xor ecx,ecx ; text colour |
136 | mov edx,button_no ; pointer to text beginning |
129 | mov edx,button_no ; pointer to text beginning |
137 | mov esi,14 ; text length |
130 | mov esi,14 ; text length |
138 | int 0x40 ; do it |
131 | mcall ; do it |
139 | 132 | ||
140 | add ebx,95*65536 ; move xy position |
133 | add ebx,95*65536 ; move xy position |
141 | mov edx,menu_text ; pointer to text beginning |
134 | mov edx,menu_text ; pointer to text beginning |
142 | int 0x40 ; do it |
135 | mcall ; do it |
143 | 136 | ||
144 | call write_main ; draw menu |
137 | call write_main ; draw menu |
145 | 138 | ||
146 | mov eax,12 ; function 12: tell os about windowdraw |
139 | mov eax,12 ; function 12: tell os about windowdraw |
147 | mov ebx,2 ; 2, end of draw |
140 | mov ebx,2 ; 2, end of draw |
148 | int 0x40 ; do it |
141 | mcall ; do it |
149 | 142 | ||
150 | pop eax ; restore register |
143 | pop eax ; restore register |
151 | ret ; return |
144 | ret ; return |
152 | 145 | ||
153 | ; ************* WRITE MAIN ************* |
146 | ; ************* WRITE MAIN ************* |
154 | 147 | ||
155 | write_main: |
148 | write_main: |
156 | 149 | ||
157 | mov eax,13 ; function 13: draw bar |
150 | mov eax,13 ; function 13: draw bar |
158 | mov ebx,1*65536 ; [x start] *65536 |
151 | mov ebx,1*65536 ; [x start] *65536 |
159 | add ebx,[x_size] ; +[x_size] |
152 | add ebx,[x_size] ; +[x_size] |
160 | dec ebx ; x size - 1 |
153 | dec ebx ; x size - 1 |
161 | mov ecx,21*65536+17 ; [y start] *65536 +[y size] |
154 | mov ecx,21*65536+17 ; [y start] *65536 +[y size] |
162 | mov edx,[menu_colour] ; menu colour |
155 | mov edx,[menu_colour] ; menu colour |
163 | int 0x40 ; do it |
156 | mcall ; do it |
164 | 157 | ||
165 | mov [main_pos],1 ; start position first button |
158 | mov [main_pos],1 ; start position first button |
166 | xor edi,edi ; data offset = 0 |
159 | xor edi,edi ; data offset = 0 |
167 | 160 | ||
168 | next_main_item: |
161 | next_main_item: |
169 | mov al,[MENU_DATA+edi] ; get byte at menu_data + offset |
162 | mov al,[MENU_DATA+edi] ; get byte at menu_data + offset |
170 | cmp al,'E' ; is it the END |
163 | cmp al,'E' ; is it the END |
171 | je main_get_out ; yes then exit |
164 | je main_get_out ; yes then exit |
172 | cmp al,'0' ; is it a main menu item |
165 | cmp al,'0' ; is it a main menu item |
173 | jne not_main_menu ; no then jump code |
166 | jne not_main_menu ; no then jump code |
174 | 167 | ||
175 | main_menu: |
168 | main_menu: |
176 | mov al,[MENU_DATA+edi+1] ; get byte at menu_data + offset + 1 |
169 | mov al,[MENU_DATA+edi+1] ; get byte at menu_data + offset + 1 |
177 | cmp al,'0' ; is it a divider |
170 | cmp al,'0' ; is it a divider |
178 | je is_main_bar ; yes then jump code |
171 | je is_main_bar ; yes then jump code |
179 | mov eax,8 ; function 8: define button |
172 | mov eax,8 ; function 8: define button |
180 | mov ebx,[main_pos] ; [x start] |
173 | mov ebx,[main_pos] ; [x start] |
181 | shl ebx,16 ; *65536 |
174 | shl ebx,16 ; *65536 |
182 | add bl,75 ; +[x size] |
175 | add bl,75 ; +[x size] |
183 | mov ecx,21*65536+16 ; [y start] *65536 +[y size] |
176 | mov ecx,21*65536+16 ; [y start] *65536 +[y size] |
184 | xor edx,edx ; clear register |
177 | xor edx,edx ; clear register |
185 | mov dl,[MENU_DATA+edi+2] ; get byte button id number |
178 | mov dl,[MENU_DATA+edi+2] ; get byte button id number |
186 | mov esi,[menu_colour] ; button colour |
179 | mov esi,[menu_colour] ; button colour |
187 | int 0x40 ; do it |
180 | mcall ; do it |
188 | mov eax,4 ; function 4: write text to window |
181 | mov eax,4 ; function 4: write text to window |
189 | add ebx,6*65536-49 ; move xy position |
182 | add ebx,6*65536-49 ; move xy position |
190 | xor ecx,ecx ; text colour |
183 | xor ecx,ecx ; text colour |
191 | mov edx,MENU_DATA+3 ; point at menu text |
184 | mov edx,MENU_DATA+3 ; point at menu text |
192 | add edx,edi ; add our offset |
185 | add edx,edi ; add our offset |
193 | mov esi,11 ; number of characters |
186 | mov esi,11 ; number of characters |
194 | int 0x40 ; do it |
187 | mcall ; do it |
195 | 188 | ||
196 | is_main_bar: |
189 | is_main_bar: |
197 | add [main_pos],76 ; update button position |
190 | add [main_pos],76 ; update button position |
198 | 191 | ||
199 | not_main_menu: |
192 | not_main_menu: |
200 | add edi,14 ; update offset |
193 | add edi,14 ; update offset |
201 | jmp next_main_item ; do next menu item |
194 | jmp next_main_item ; do next menu item |
202 | 195 | ||
203 | main_get_out: |
196 | main_get_out: |
204 | 197 | ||
205 | ret ; return |
198 | ret ; return |
206 | 199 | ||
207 | ; *********** DRAW DATA *********** |
200 | ; *********** DRAW DATA *********** |
208 | 201 | ||
209 | draw_data: |
202 | draw_data: |
210 | 203 | ||
211 | push eax ; save register |
204 | push eax ; save register |
212 | mov ebx,0x00030000 ; display 3 decimal characters |
205 | mov ebx,0x00030000 ; display 3 decimal characters |
213 | xor ecx,ecx ; clear register |
206 | xor ecx,ecx ; clear register |
214 | mov cl,ah ; swap data |
207 | mov cl,ah ; swap data |
215 | mov eax,47 ; function 47: display number to window |
208 | mov eax,47 ; function 47: display number to window |
216 | mov edx,70*65536 ; [x start] *65536 |
209 | mov edx,70*65536 ; [x start] *65536 |
217 | add edx,[y_size] ; +[y start] |
210 | add edx,[y_size] ; +[y start] |
218 | sub edx,12 ; move position |
211 | sub edx,12 ; move position |
219 | xor esi,esi ; text colour |
212 | xor esi,esi ; text colour |
220 | int 0x40 ; do it |
213 | mcall ; do it |
221 | pop eax ; restore register |
214 | pop eax ; restore register |
222 | 215 | ||
223 | cmp [button_press],1 ; has a sub button been pressed |
216 | cmp [button_press],1 ; has a sub button been pressed |
224 | je draw_get_out ; then jump code |
217 | je draw_get_out ; then jump code |
225 | 218 | ||
226 | push eax ; save register |
219 | push eax ; save register |
227 | xor edx,edx ; clear register |
220 | xor edx,edx ; clear register |
228 | shr ax,8 ; move button id into al |
221 | shr ax,8 ; move button id into al |
229 | sub eax,100 ; subtract 100 |
222 | sub eax,100 ; subtract 100 |
230 | mov dx,14 ; use record length as multiplier |
223 | mov dx,14 ; use record length as multiplier |
231 | mul dx ; multiply |
224 | mul dx ; multiply |
232 | mov edx,eax ; swap registers |
225 | mov edx,eax ; swap registers |
233 | add edx,MENU_DATA ; add offset |
226 | add edx,MENU_DATA ; add offset |
234 | inc edx ; add 1 |
227 | inc edx ; add 1 |
235 | mov ebx,188*65536 ; [x start] *65536 |
228 | mov ebx,188*65536 ; [x start] *65536 |
236 | add ebx,[y_size] ; +[y start] |
229 | add ebx,[y_size] ; +[y start] |
237 | sub ebx,12 ; move position |
230 | sub ebx,12 ; move position |
238 | mov esi,1 ; 1 character |
231 | mov esi,1 ; 1 character |
239 | mov eax,4 ; function 4: write text to window |
232 | mov eax,4 ; function 4: write text to window |
240 | xor ecx,ecx ; text colour |
233 | xor ecx,ecx ; text colour |
241 | int 0x40 ; do it |
234 | mcall ; do it |
242 | pop eax ; restore register |
235 | pop eax ; restore register |
243 | 236 | ||
244 | draw_get_out: |
237 | draw_get_out: |
245 | ret ; return |
238 | ret ; return |
246 | 239 | ||
247 | ; **************** CLEAR DATA ****************** |
240 | ; **************** CLEAR DATA ****************** |
248 | 241 | ||
249 | clear_data: |
242 | clear_data: |
250 | 243 | ||
251 | push eax ; save register |
244 | push eax ; save register |
252 | mov eax,13 ; function 13: draw bar |
245 | mov eax,13 ; function 13: draw bar |
253 | mov ebx,67*65536+23 ; [x start] *65536 +[x size] |
246 | mov ebx,67*65536+23 ; [x start] *65536 +[x size] |
254 | mov ecx,[y_size] ; [y start] |
247 | mov ecx,[y_size] ; [y start] |
255 | sub ecx,15 ; move position |
248 | sub ecx,15 ; move position |
256 | shl ecx,16 ; *65536 |
249 | shl ecx,16 ; *65536 |
257 | add ecx,13 ; [y size] |
250 | add ecx,13 ; [y size] |
258 | mov edx,0x00aaaaaa ; bar colour |
251 | mov edx,0x00aaaaaa ; bar colour |
259 | int 0x40 ; do it |
252 | mcall ; do it |
260 | mov ebx,185*65536+11 ; move position |
253 | mov ebx,185*65536+11 ; move position |
261 | int 0x40 ; do it again |
254 | mcall ; do it again |
262 | 255 | ||
263 | pop eax ; restore register |
256 | pop eax ; restore register |
264 | ret ; return |
257 | ret ; return |
265 | 258 | ||
266 | ; ************* WRITE SUB ************* |
259 | ; ************* WRITE SUB ************* |
267 | 260 | ||
268 | write_sub: |
261 | write_sub: |
269 | 262 | ||
270 | push eax ; save register |
263 | push eax ; save register |
271 | mov [but_pos],38 ; y start position offset |
264 | mov [but_pos],38 ; y start position offset |
272 | mov [sub_pos],1 ; x start position offset |
265 | mov [sub_pos],1 ; x start position offset |
273 | xor edx,edx ; clear register |
266 | xor edx,edx ; clear register |
274 | shr ax,8 ; move button id into al |
267 | shr ax,8 ; move button id into al |
275 | sub eax,100 ; subtract 100 |
268 | sub eax,100 ; subtract 100 |
276 | mov dx,76 ; menu width + 1 |
269 | mov dx,76 ; menu width + 1 |
277 | mul dx ; multiply |
270 | mul dx ; multiply |
278 | add [sub_pos],eax ; add menu position to offset |
271 | add [sub_pos],eax ; add menu position to offset |
279 | pop eax ; restore register |
272 | pop eax ; restore register |
280 | 273 | ||
281 | xor edx,edx ; clear register |
274 | xor edx,edx ; clear register |
282 | shr ax,8 ; move button id into al |
275 | shr ax,8 ; move button id into al |
283 | sub eax,100 ; subtract 100 |
276 | sub eax,100 ; subtract 100 |
284 | mov dx,14 ; use record length as multiplier |
277 | mov dx,14 ; use record length as multiplier |
285 | mul dx ; multiply |
278 | mul dx ; multiply |
286 | add eax,MENU_DATA ; add offset |
279 | add eax,MENU_DATA ; add offset |
287 | inc eax ; plus 1 |
280 | inc eax ; plus 1 |
288 | mov al,[eax] ; get menu number byte |
281 | mov al,[eax] ; get menu number byte |
289 | mov [menu_number],al ; save it |
282 | mov [menu_number],al ; save it |
290 | 283 | ||
291 | xor edi,edi ; clear offset |
284 | xor edi,edi ; clear offset |
292 | 285 | ||
293 | next_sub_item: |
286 | next_sub_item: |
294 | mov al,[MENU_DATA+edi] ; get byte at menu_data + offset |
287 | mov al,[MENU_DATA+edi] ; get byte at menu_data + offset |
295 | cmp al,'E' ; is it the END |
288 | cmp al,'E' ; is it the END |
296 | je sub_get_out ; yes then exit |
289 | je sub_get_out ; yes then exit |
297 | cmp al,[menu_number] ; is it sub menu item |
290 | cmp al,[menu_number] ; is it sub menu item |
298 | jne not_sub_menu ; no then jump code |
291 | jne not_sub_menu ; no then jump code |
299 | 292 | ||
300 | sub_menu: |
293 | sub_menu: |
301 | mov al,[MENU_DATA+edi+1] ; get byte at menu_data + offset + 1 |
294 | mov al,[MENU_DATA+edi+1] ; get byte at menu_data + offset + 1 |
302 | cmp al,'0' ; is it a divider |
295 | cmp al,'0' ; is it a divider |
303 | jne is_sub_button ; no then jump code |
296 | jne is_sub_button ; no then jump code |
304 | mov eax,13 ; function 13: draw bar |
297 | mov eax,13 ; function 13: draw bar |
305 | mov edx,[menu_colour] ; bar colour |
298 | mov edx,[menu_colour] ; bar colour |
306 | mov ebx,[sub_pos] ; [x start] |
299 | mov ebx,[sub_pos] ; [x start] |
307 | shl ebx,16 ; *65536 |
300 | shl ebx,16 ; *65536 |
308 | add ebx,76 ; [x size] |
301 | add ebx,76 ; [x size] |
309 | mov ecx,[but_pos] ; [y start] |
302 | mov ecx,[but_pos] ; [y start] |
310 | shl ecx,16 ; *65536 |
303 | shl ecx,16 ; *65536 |
311 | add ecx,17 ; [y size] |
304 | add ecx,17 ; [y size] |
312 | int 0x40 ; do it |
305 | mcall ; do it |
313 | jmp is_sub_bar ; jump button code |
306 | jmp is_sub_bar ; jump button code |
314 | 307 | ||
315 | is_sub_button: |
308 | is_sub_button: |
316 | mov eax,8 ; function 8: define and draw button |
309 | mov eax,8 ; function 8: define and draw button |
317 | xor edx,edx ; clear register |
310 | xor edx,edx ; clear register |
318 | mov dl,[MENU_DATA+edi+2] ; get byte button id number |
311 | mov dl,[MENU_DATA+edi+2] ; get byte button id number |
319 | mov ebx,[sub_pos] ; [x start] |
312 | mov ebx,[sub_pos] ; [x start] |
320 | shl ebx,16 ; *65536 |
313 | shl ebx,16 ; *65536 |
321 | add ebx,75 ; [x size] |
314 | add ebx,75 ; [x size] |
322 | mov ecx,[but_pos] ; [y start] |
315 | mov ecx,[but_pos] ; [y start] |
323 | shl ecx,16 ; *65536 |
316 | shl ecx,16 ; *65536 |
324 | add ecx,16 ; [y size] |
317 | add ecx,16 ; [y size] |
325 | mov esi,[menu_colour] ; button colour |
318 | mov esi,[menu_colour] ; button colour |
326 | int 0x40 ; do it |
319 | mcall ; do it |
327 | 320 | ||
328 | mov ebx,[sub_pos] ; [x start] |
321 | mov ebx,[sub_pos] ; [x start] |
329 | shl ebx,16 ; *65536 |
322 | shl ebx,16 ; *65536 |
330 | add ebx,6*65536 ; move position |
323 | add ebx,6*65536 ; move position |
331 | add ebx,[but_pos] ; [y start] |
324 | add ebx,[but_pos] ; [y start] |
332 | add bl,5 ; move position |
325 | add bl,5 ; move position |
333 | xor ecx,ecx ; clear register |
326 | xor ecx,ecx ; clear register |
334 | mov edx,MENU_DATA+3 ; point to button text |
327 | mov edx,MENU_DATA+3 ; point to button text |
335 | add edx,edi ; add offset |
328 | add edx,edi ; add offset |
336 | mov esi,11 ; number of characters |
329 | mov esi,11 ; number of characters |
337 | mov eax,4 ; function 4: write text to window |
330 | mov eax,4 ; function 4: write text to window |
338 | int 0x40 ; do it |
331 | mcall ; do it |
339 | is_sub_bar: |
332 | is_sub_bar: |
340 | add [but_pos],17 ; move y position |
333 | add [but_pos],17 ; move y position |
341 | 334 | ||
342 | not_sub_menu: |
335 | not_sub_menu: |
343 | add edi,14 ; move offset |
336 | add edi,14 ; move offset |
344 | jmp next_sub_item ; do next button |
337 | jmp next_sub_item ; do next button |
345 | 338 | ||
346 | sub_get_out: |
339 | sub_get_out: |
347 | 340 | ||
348 | ret ; return |
341 | ret ; return |
349 | 342 | ||
350 | ; ***************** DATA AREA ****************** |
343 | ; ***************** DATA AREA ****************** |
351 | 344 | ||
352 | x_size: dd 381 ; window x size |
345 | x_size: dd 381 ; window x size |
353 | y_size: dd 200 ; window y size |
346 | y_size: dd 200 ; window y size |
354 | 347 | ||
355 | window_text db 'MENU EXAMPLE' ; grab bar text |
348 | window_text db 'MENU EXAMPLE' ; grab bar text |
356 | button_no db 'BUTTON No: ' ; status bar text |
349 | button_no db 'BUTTON No: ' ; status bar text |
357 | menu_text db 'MENU SELECTED:' ; status bar text |
350 | menu_text db 'MENU SELECTED:' ; status bar text |
358 | 351 | ||
359 | button_press dd 0 |
352 | button_press dd 0 |
360 | 353 | ||
361 | menu_colour dd 0x00aaaaaa ; menu & button colour |
354 | menu_colour dd 0x00aaaaaa ; menu & button colour |
362 | 355 | ||
363 | menu_number db '0' ; menu selection |
356 | menu_number db '0' ; menu selection |
364 | 357 | ||
365 | sub_pos dd 1 ; sub menu x position |
358 | sub_pos dd 1 ; sub menu x position |
366 | but_pos dd 38 ; sub menu y position |
359 | but_pos dd 38 ; sub menu y position |
367 | 360 | ||
368 | main_pos dd 1 ; main menu x position |
361 | main_pos dd 1 ; main menu x position |
369 | 362 | ||
370 | MENU_DATA: db '01' ; MAIN MENU = 0 - 1 = menu |
363 | MENU_DATA: db '01' ; MAIN MENU = 0 - 1 = menu |
371 | db 100 ; button id |
364 | db 100 ; button id |
372 | db 'FILE ' ; button text |
365 | db 'FILE ' ; button text |
373 | db '02' ; MAIN MENU = 0 - 2 = menu |
366 | db '02' ; MAIN MENU = 0 - 2 = menu |
374 | db 101 ; button id |
367 | db 101 ; button id |
375 | db 'EDIT ' ; button text |
368 | db 'EDIT ' ; button text |
376 | db '04' ; MAIN MENU = 0 - 3 = menu |
369 | db '04' ; MAIN MENU = 0 - 3 = menu |
377 | db 102 ; button id |
370 | db 102 ; button id |
378 | db 'TEST ' ; button text |
371 | db 'TEST ' ; button text |
379 | db '00' ; MAIN MENU = 0 - 0 = divider |
372 | db '00' ; MAIN MENU = 0 - 0 = divider |
380 | db 103 ; SPACER ID |
373 | db 103 ; SPACER ID |
381 | db ' ' ; SPACER TEXT padding |
374 | db ' ' ; SPACER TEXT padding |
382 | db '03' ; MAIN MENU = 0 - 4 = menu |
375 | db '03' ; MAIN MENU = 0 - 4 = menu |
383 | db 104 ; button id |
376 | db 104 ; button id |
384 | db 'HELP ' ; button text |
377 | db 'HELP ' ; button text |
385 | 378 | ||
386 | db '11' ; menu level = 1 - 1 = button |
379 | db '11' ; menu level = 1 - 1 = button |
387 | db 110 ; button id |
380 | db 110 ; button id |
388 | db 'LOAD ' ; button text |
381 | db 'LOAD ' ; button text |
389 | db '11' ; menu level = 1 - 1 = button |
382 | db '11' ; menu level = 1 - 1 = button |
390 | db 111 ; button id |
383 | db 111 ; button id |
391 | db 'SAVE ' ; button text |
384 | db 'SAVE ' ; button text |
392 | db '10' ; menu level = 1 - 0 = divider |
385 | db '10' ; menu level = 1 - 0 = divider |
393 | db 112 ; SPACER ID |
386 | db 112 ; SPACER ID |
394 | db ' ' ; SPACER TEXT padding |
387 | db ' ' ; SPACER TEXT padding |
395 | db '11' ; menu level = 1 - 1 = button |
388 | db '11' ; menu level = 1 - 1 = button |
396 | db 113 ; button id |
389 | db 113 ; button id |
397 | db 'QUIT ' ; button text |
390 | db 'QUIT ' ; button text |
398 | 391 | ||
399 | db '21' ; menu level = 2 - 1 = button |
392 | db '21' ; menu level = 2 - 1 = button |
400 | db 120 ; button id |
393 | db 120 ; button id |
401 | db 'COPY ' ; button text |
394 | db 'COPY ' ; button text |
402 | db '21' ; menu level = 2 - 1 = button |
395 | db '21' ; menu level = 2 - 1 = button |
403 | db 121 ; button id |
396 | db 121 ; button id |
404 | db 'PASTE ' ; button text |
397 | db 'PASTE ' ; button text |
405 | 398 | ||
406 | db '31' ; menu level = 3 - 1 = button |
399 | db '31' ; menu level = 3 - 1 = button |
407 | db 130 ; button id |
400 | db 130 ; button id |
408 | db 'SETUP ' ; button text |
401 | db 'SETUP ' ; button text |
409 | db '31' ; menu level = 3 - 1 = button |
402 | db '31' ; menu level = 3 - 1 = button |
410 | db 131 ; button id |
403 | db 131 ; button id |
411 | db 'ABOUT.. ' ; button text |
404 | db 'ABOUT.. ' ; button text |
412 | 405 | ||
413 | db '41' ; menu level = 3 - 1 = button |
406 | db '41' ; menu level = 3 - 1 = button |
414 | db 140 ; button id |
407 | db 140 ; button id |
415 | db 'TEST 1 ' ; button text |
408 | db 'TEST 1 ' ; button text |
416 | db '41' ; menu level = 3 - 1 = button |
409 | db '41' ; menu level = 3 - 1 = button |
417 | db 141 ; button id |
410 | db 141 ; button id |
418 | db 'TEST 2 ' ; button text |
411 | db 'TEST 2 ' ; button text |
419 | db '41' ; menu level = 3 - 1 = button |
412 | db '41' ; menu level = 3 - 1 = button |
420 | db 142 ; button id |
413 | db 142 ; button id |
421 | db 'TEST 3 ' ; button text |
414 | db 'TEST 3 ' ; button text |
422 | db '41' ; menu level = 3 - 1 = button |
415 | db '41' ; menu level = 3 - 1 = button |
423 | db 143 ; button id |
416 | db 143 ; button id |
424 | db 'TEST 4 ' ; button text |
417 | db 'TEST 4 ' ; button text |
425 | db '41' ; menu level = 3 - 1 = button |
418 | db '41' ; menu level = 3 - 1 = button |
426 | db 144 ; button id |
419 | db 144 ; button id |
427 | db 'TEST 5 ' ; button text |
420 | db 'TEST 5 ' ; button text |
428 | db '41' ; menu level = 3 - 1 = button |
421 | db '41' ; menu level = 3 - 1 = button |
429 | db 145 ; button id |
422 | db 145 ; button id |
430 | db 'TEST 6 ' ; button text |
423 | db 'TEST 6 ' ; button text |
431 | 424 | ||
432 | db 'END' ; IMPORTANT need an END |
425 | db 'END' ; IMPORTANT need an END |
433 | I_END: |
426 | I_END: |