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