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 | ; |
2 | ; |
3 | ; MENU / DIALOG EXAMPLE |
3 | ; MENU / DIALOG EXAMPLE |
4 | ; |
4 | ; |
5 | ; Compile with FASM for Menuet |
5 | ; Compile with FASM for Menuet |
6 | ; |
6 | ; |
7 | 7 | ||
8 | use32 |
8 | use32 |
9 | 9 | ||
10 | org 0x0 |
10 | org 0x0 |
11 | 11 | ||
12 | db 'MENUET01' ; 8 byte id |
12 | db 'MENUET01' ; 8 byte id |
13 | dd 0x01 ; header version |
13 | dd 0x01 ; header version |
14 | dd START ; start of code |
14 | dd START ; start of code |
15 | dd I_END ; size of image |
15 | dd I_END ; size of image |
16 | dd 0x10000 ; memory for app |
16 | dd 0x10000 ; memory for app |
17 | dd 0x10000 ; esp |
17 | dd 0x10000 ; esp |
18 | dd 0x0 , 0x0 ; I_Param , I_Icon |
18 | dd 0x0 , 0x0 ; I_Param , I_Icon |
19 | 19 | ||
20 | include 'lang.inc' |
20 | include 'lang.inc' |
21 | include 'macros.inc' |
21 | include '..\..\..\..\macros.inc' |
22 | include 'dialogs1.inc' |
22 | include 'dialogs1.inc' |
23 | 23 | ||
24 | menu_history dd 0x0 |
24 | menu_history dd 0x0 |
25 | 25 | ||
26 | START: ; start of execution |
26 | START: ; start of execution |
- | 27 | ||
27 | 28 | red: |
|
28 | call draw_window_main |
29 | call draw_window_main |
29 | 30 | ||
30 | still: ; wait here for event |
31 | still: ; wait here for event |
31 | 32 | ||
32 | mov eax,23 |
33 | mov eax,10 |
33 | mov ebx,2 |
- | |
34 | int 0x40 |
34 | mcall |
35 | 35 | ||
36 | cmp eax,1 ; process events |
36 | cmp eax,1 ; process events |
37 | je red |
37 | je red |
38 | cmp eax,2 |
38 | cmp eax,2 |
39 | je key |
39 | je key |
40 | cmp eax,3 |
40 | cmp eax,3 |
41 | je button |
41 | je button |
42 | 42 | ||
43 | call check_mouse ; DIALOG CHECK |
43 | call check_mouse ; DIALOG CHECK |
44 | 44 | ||
45 | mov eax,[menu_action] |
45 | mov eax,[menu_action] |
46 | cmp eax,[menu_history] |
46 | cmp eax,[menu_history] |
47 | je nodisplay |
47 | je nodisplay |
48 | 48 | ||
49 | mov [menu_history],eax |
49 | mov [menu_history],eax |
50 | 50 | ||
51 | mov eax,13 |
51 | mov eax,13 |
52 | mov ebx,220*65536+6*4 |
52 | mov ebx,220*65536+6*4 |
53 | mov ecx,70*65536+8 |
53 | mov ecx,70*65536+8 |
54 | mov edx,0xffffff |
54 | mov edx,0xffffff |
55 | int 0x40 |
55 | mcall |
56 | 56 | ||
57 | mov eax,4 ; show menu selections |
57 | mov eax,4 ; show menu selections |
58 | mov ebx,220*65536+70 |
58 | mov ebx,220*65536+70 |
59 | mov ecx,0x000000 |
59 | mov ecx,0x000000 |
60 | mov edx,menu_action |
60 | mov edx,menu_action |
61 | mov esi,4 |
61 | mov esi,4 |
62 | int 0x40 |
62 | mcall |
63 | 63 | ||
64 | nodisplay: |
64 | nodisplay: |
65 | 65 | ||
66 | cmp word [menu_action],word 'AD' ; user requests close |
66 | cmp word [menu_action],word 'AD' ; user requests close |
67 | jne no_menu_close |
67 | jne no_menu_close |
68 | mov eax,-1 |
68 | mov eax,-1 |
69 | int 0x40 |
69 | mcall |
70 | no_menu_close: |
70 | no_menu_close: |
71 | 71 | ||
72 | jmp still |
72 | jmp still |
73 | - | ||
74 | red: ; redraw |
- | |
75 | call draw_window_main |
- | |
76 | jmp still |
- | |
77 | 73 | ||
78 | key: |
74 | key: |
79 | mov eax,2 ; key in buffer |
75 | mov eax,2 ; key in buffer |
80 | int 0x40 |
76 | mcall |
81 | jmp still |
77 | jmp still |
82 | 78 | ||
83 | button: ; button in buffer |
79 | button: ; button in buffer |
84 | mov eax,17 |
80 | mov eax,17 |
85 | int 0x40 |
81 | mcall |
86 | 82 | ||
87 | cmp ah,1 ; close application |
83 | cmp ah,1 ; close application |
88 | jne noclose |
84 | jne noclose |
89 | mov eax,-1 |
85 | or eax,-1 |
90 | int 0x40 |
86 | mcall |
91 | noclose: |
87 | noclose: |
92 | 88 | ||
93 | cmp ah,2 |
89 | cmp ah,2 |
94 | jne no_alert_box ; ALERT BOX |
90 | jne no_alert_box ; ALERT BOX |
95 | mov eax,170 ; window width |
91 | mov eax,170 ; window width |
96 | mov ebx,alert_text ; asciiz string |
92 | mov ebx,alert_text ; asciiz string |
97 | mov ecx,1 ; OK button |
93 | mov ecx,1 ; OK button |
98 | call alert_box ; function call |
94 | call alert_box ; function call |
99 | jmp still |
95 | jmp still |
100 | no_alert_box: |
96 | no_alert_box: |
101 | 97 | ||
102 | cmp ah,3 |
98 | cmp ah,3 |
103 | jne no_choose_box ; CHOOSE BOX |
99 | jne no_choose_box ; CHOOSE BOX |
104 | mov eax,220 ; window width |
100 | mov eax,220 ; window width |
105 | mov ebx,choose_text ; asciiz string |
101 | mov ebx,choose_text ; asciiz string |
106 | mov ecx,2 ; YES/NO buttons |
102 | mov ecx,2 ; YES/NO buttons |
107 | call alert_box ; function call |
103 | call alert_box ; function call |
108 | jmp still |
104 | jmp still |
109 | no_choose_box: |
105 | no_choose_box: |
110 | 106 | ||
111 | 107 | ||
112 | jmp still |
108 | jmp still |
113 | 109 | ||
114 | 110 | ||
115 | 111 | ||
116 | 112 | ||
117 | ; ********************************************* |
113 | ; ********************************************* |
118 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
114 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
119 | ; ********************************************* |
115 | ; ********************************************* |
120 | 116 | ||
121 | draw_window_main: |
117 | draw_window_main: |
122 | 118 | ||
123 | mov eax,12 ; function 12:tell os about windowdraw |
119 | mov eax,12 ; function 12:tell os about windowdraw |
124 | mov ebx,1 ; 1, start of draw |
120 | mov ebx,1 ; 1, start of draw |
125 | int 0x40 |
121 | mcall |
126 | 122 | ||
127 | mov eax,0 ; open window |
123 | mov eax,0 ; open window |
128 | mov ebx,100*65536+300 |
124 | mov ebx,100*65536+300 |
129 | mov ecx,100*65536+120 |
125 | mov ecx,100*65536+120 |
130 | mov edx,0x02ffffff |
126 | mov edx,0x02ffffff |
131 | mov esi,0x805080d0 |
127 | mov esi,0x805080d0 |
132 | mov edi,0x005080d0 |
128 | mov edi,0x005080d0 |
133 | int 0x40 |
129 | mcall |
134 | 130 | ||
135 | call draw_menu ; DRAW MENU |
131 | call draw_menu ; DRAW MENU |
136 | 132 | ||
137 | mov eax,4 ; window label |
133 | mov eax,4 ; window label |
138 | mov ebx,8*65536+8 |
134 | mov ebx,8*65536+8 |
139 | mov ecx,0x10ddeeff |
135 | mov ecx,0x10ddeeff |
140 | mov edx,labelt |
136 | mov edx,labelt |
141 | mov esi,labellen-labelt |
137 | mov esi,labellen-labelt |
142 | int 0x40 |
138 | mcall |
143 | 139 | ||
144 | mov eax,8 ; close button |
140 | mov eax,8 ; close button |
145 | mov ebx,(300-17)*65536+10 |
141 | mov ebx,(300-17)*65536+10 |
146 | mov ecx,5*65536+10 |
142 | mov ecx,5*65536+10 |
147 | mov edx,1 |
143 | mov edx,1 |
148 | mov esi,0x4466bb |
144 | mov esi,0x4466bb |
149 | int 0x40 |
145 | mcall |
150 | 146 | ||
151 | mov eax,8 ; button : OPEN ALERT BOX |
147 | mov eax,8 ; button : OPEN ALERT BOX |
152 | mov ebx,25*65536+150 |
148 | mov ebx,25*65536+150 |
153 | mov ecx,61*65536+14 |
149 | mov ecx,61*65536+14 |
154 | mov edx,2 |
150 | mov edx,2 |
155 | mov esi,0x4466aa |
151 | mov esi,0x4466aa |
156 | int 0x40 |
152 | mcall |
157 | 153 | ||
158 | mov eax,8 ; button : OPEN CHOOSE BOX |
154 | mov eax,8 ; button : OPEN CHOOSE BOX |
159 | mov ebx,25*65536+150 |
155 | mov ebx,25*65536+150 |
160 | mov ecx,81*65536+14 |
156 | mov ecx,81*65536+14 |
161 | mov edx,3 |
157 | mov edx,3 |
162 | mov esi,0x4466aa |
158 | mov esi,0x4466aa |
163 | int 0x40 |
159 | mcall |
164 | 160 | ||
165 | mov ebx,20*65536+55 ; draw info text with function 4 |
161 | mov ebx,20*65536+55 ; draw info text with function 4 |
166 | mov ecx,0xffffff |
162 | mov ecx,0xffffff |
167 | mov edx,text |
163 | mov edx,text |
168 | mov esi,40 |
164 | mov esi,40 |
169 | newline: |
165 | newline: |
170 | mov eax,4 |
166 | mov eax,4 |
171 | int 0x40 |
167 | mcall |
172 | add ebx,10 |
168 | add ebx,10 |
173 | add edx,40 |
169 | add edx,40 |
174 | cmp [edx],byte 'x' |
170 | cmp [edx],byte 'x' |
175 | jne newline |
171 | jne newline |
176 | 172 | ||
177 | mov eax,12 ; function 12:tell os about windowdraw |
173 | mov eax,12 ; function 12:tell os about windowdraw |
178 | mov ebx,2 ; 2, end of draw |
174 | mov ebx,2 ; 2, end of draw |
179 | int 0x40 |
175 | mcall |
180 | 176 | ||
181 | ret |
177 | ret |
182 | 178 | ||
183 | 179 | ||
184 | ; DATA AREA |
180 | ; DATA AREA |
185 | 181 | ||
186 | text: |
182 | text: |
187 | db ' ' |
183 | db ' ' |
188 | db ' OPEN ALERT BOX ' |
184 | db ' OPEN ALERT BOX ' |
189 | db ' ' |
185 | db ' ' |
190 | db ' OPEN CHOOSE BOX ' |
186 | db ' OPEN CHOOSE BOX ' |
191 | 187 | ||
192 | db 'x <- END MARKER, DONT DELETE ' |
188 | db 'x <- END MARKER, DONT DELETE ' |
193 | 189 | ||
194 | labelt: |
190 | labelt: |
195 | db 'EXAMPLE APPLICATION' |
191 | db 'EXAMPLE APPLICATION' |
196 | labellen: |
192 | labellen: |
197 | 193 | ||
198 | alert_text db ' File not found !',0 |
194 | alert_text db ' File not found !',0 |
199 | choose_text db ' Save file before exit ? ',0 |
195 | choose_text db ' Save file before exit ? ',0 |
200 | 196 | ||
201 | I_END:-> |
197 | I_END:-> |