Rev 4919 | Rev 4943 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4939 | eAndrew | 1 | VERSION equ "0.4Å" |
2 | |||
4865 | eAndrew | 3 | use32 |
4 | org 0 |
||
5 | db 'MENUET01' |
||
6 | dd 1, main, dataend, memory, stacktop, 0, 0 |
||
7 | |||
8 | include "../../proc32.inc" |
||
9 | include "../../macros.inc" |
||
10 | include "../../dll.inc" |
||
11 | include "../../develop/libraries/box_lib/trunk/box_lib.mac" |
||
4939 | eAndrew | 12 | ; include "../../debug.inc" |
4865 | eAndrew | 13 | include "parser.inc" |
14 | |||
15 | ;=============================== |
||
16 | |||
4939 | eAndrew | 17 | sz_cont db "?#" |
4865 | eAndrew | 18 | sz_head db "Calc+ [v", VERSION, "]", 0 |
4939 | eAndrew | 19 | ; buttons db "789456123()%^-+/*0" |
4865 | eAndrew | 20 | edb1 edit_box 184, 8, 12, 0, 0, 0, 0, 0, 500, \ |
21 | exp, group, ed_always_focus + ed_focus, 0, 0 |
||
22 | |||
23 | imports: |
||
24 | library gui, "box_lib.obj" |
||
25 | import gui, editbox.draw, "edit_box", \ |
||
26 | editbox.key, "edit_box_key", \ |
||
27 | editbox.mouse, "edit_box_mouse" |
||
28 | |||
29 | ;=============================== |
||
30 | |||
31 | main: |
||
4939 | eAndrew | 32 | mov [ans.buffer], dword "= 0" |
33 | mov [ans.size], 3 * 6 + 9 |
||
4865 | eAndrew | 34 | |
35 | mcall 40, 100111b |
||
36 | mcall 48, 3, scn, 192 |
||
37 | |||
4939 | eAndrew | 38 | |
4865 | eAndrew | 39 | m2m [edb1.color], [scn.gui_face] |
40 | m2m [edb1.shift_color], [scn.gui_select] |
||
41 | m2m [edb1.focus_border_color], [scn.gui_face] |
||
4939 | eAndrew | 42 | m2m [edb1.text_color], [scn.gui_text] |
4865 | eAndrew | 43 | |
44 | mcall 68, 11 |
||
45 | stdcall dll.Load, imports |
||
46 | |||
47 | ;---------------------- |
||
48 | |||
49 | update: |
||
4875 | eAndrew | 50 | mcall 23, 5 |
4865 | eAndrew | 51 | |
52 | cmp eax, EV_REDRAW |
||
53 | je ev_redraw |
||
54 | cmp eax, EV_KEY |
||
55 | je ev_key |
||
56 | cmp eax, EV_BUTTON |
||
57 | je ev_button |
||
58 | cmp eax, EV_MOUSE |
||
59 | je ev_mouse |
||
60 | |||
61 | dec [timer] |
||
62 | cmp [timer], 0 |
||
63 | je calc |
||
64 | |||
65 | jmp update |
||
66 | |||
67 | ;---------------------- |
||
68 | |||
69 | ev_redraw: |
||
70 | mov edx, [scn.win_body] |
||
71 | or edx, 0x34 shl 24 |
||
4939 | eAndrew | 72 | mcall 0, <100, 236 + 100>, <100, 164 - 102>, , , sz_head |
4865 | eAndrew | 73 | |
4939 | eAndrew | 74 | mcall 8, <275, 12>, <-17, 12>, 2 + 1 shl 30 |
75 | sub ebx, 12 shl 16 |
||
76 | inc edx |
||
77 | mcall |
||
78 | |||
79 | mcall 4, <279, -14>, [scn.win_title], sz_cont, 1 |
||
80 | add ebx, 1 shl 16 |
||
81 | mcall |
||
82 | |||
83 | sub ebx, 13 shl 16 |
||
84 | inc edx |
||
85 | mcall |
||
86 | |||
4875 | eAndrew | 87 | call draw_textbox |
4865 | eAndrew | 88 | |
4939 | eAndrew | 89 | ; mov [but_id], 0x0000000A |
90 | ; mov [txt_id], buttons |
||
91 | ; mov [txt_x], 16 |
||
92 | ; mov [but_w], 38 |
||
93 | ; stdcall draw_button, 4, 42 |
||
94 | ; stdcall draw_button, 46, 42 |
||
95 | ; stdcall draw_button, 88, 42 |
||
96 | ; stdcall draw_button, 4, 66 |
||
97 | ; stdcall draw_button, 46, 66 |
||
98 | ; stdcall draw_button, 88, 66 |
||
99 | ; stdcall draw_button, 4, 90 |
||
100 | ; stdcall draw_button, 46, 90 |
||
101 | ; stdcall draw_button, 88, 90 |
||
102 | ; stdcall draw_button, 88, 114 |
||
103 | ; |
||
104 | ; stdcall draw_button, 144, 42 |
||
105 | ; stdcall draw_button, 186, 42 |
||
106 | ; stdcall draw_button, 144, 66 |
||
107 | ; stdcall draw_button, 186, 66 |
||
108 | ; stdcall draw_button, 144, 90 |
||
109 | ; stdcall draw_button, 186, 90 |
||
110 | ; stdcall draw_button, 144, 114 |
||
111 | ; stdcall draw_button, 186, 114 |
||
4865 | eAndrew | 112 | |
4939 | eAndrew | 113 | ; mov [txt_x], 37 |
114 | ; mov [but_w], 80 |
||
115 | ; stdcall draw_button, 4, 114 |
||
4865 | eAndrew | 116 | |
117 | jmp update |
||
118 | |||
119 | ;---------------------- |
||
120 | |||
121 | ev_key: |
||
4875 | eAndrew | 122 | mov [timer], 10 |
4865 | eAndrew | 123 | |
124 | mcall 2 |
||
125 | cmp ah, 27 |
||
126 | je exit |
||
4939 | eAndrew | 127 | cmp ah, 13 |
128 | je calc |
||
4865 | eAndrew | 129 | invoke editbox.key, edb1 |
130 | jmp update |
||
131 | |||
132 | ;---------------------- |
||
133 | |||
134 | ev_button: |
||
4875 | eAndrew | 135 | mov [timer], 10 |
4865 | eAndrew | 136 | |
137 | mcall 17 |
||
138 | |||
139 | cmp ah, 1 |
||
140 | je exit |
||
141 | |||
4875 | eAndrew | 142 | cmp ah, 19 |
4865 | eAndrew | 143 | jne .not_del |
4875 | eAndrew | 144 | .del: |
4865 | eAndrew | 145 | cmp [edb1.pos], 0 |
146 | je update |
||
147 | mov eax, exp |
||
148 | add eax, [edb1.pos] |
||
149 | dec eax |
||
150 | mov ebx, exp |
||
151 | add ebx, [edb1.size] |
||
152 | inc ebx |
||
153 | @@: |
||
154 | cmp eax, ebx |
||
155 | je @f |
||
156 | mov cl, [eax + 1] |
||
157 | mov [eax], cl |
||
158 | inc eax |
||
159 | jmp @b |
||
160 | @@: |
||
161 | dec [edb1.pos] |
||
162 | dec [edb1.size] |
||
163 | m2m [edb1.shift], [edb1.pos] |
||
4875 | eAndrew | 164 | jmp .redraw |
4865 | eAndrew | 165 | .not_del: |
166 | |||
4939 | eAndrew | 167 | ; cmp ah, 10 |
168 | ; jl update |
||
169 | ; cmp ah, 50 |
||
170 | ; jg update |
||
171 | ; |
||
172 | ; movzx eax, ah |
||
173 | ; add eax, buttons |
||
174 | ; sub eax, 10 |
||
175 | ; mov al, [eax] |
||
176 | ; |
||
177 | ; mov ebx, exp |
||
178 | ; add ebx, [edb1.size] |
||
179 | ; mov ecx, exp |
||
180 | ; add ecx, [edb1.pos] |
||
181 | ; @@: |
||
182 | ; cmp ebx, ecx |
||
183 | ; je @f |
||
184 | ; mov dl, [ebx - 1] |
||
185 | ; mov [ebx], dl |
||
186 | ; dec ebx |
||
187 | ; jmp @b |
||
188 | ; @@: |
||
189 | ; |
||
190 | ; mov [ebx], al |
||
191 | ; inc [edb1.size] |
||
192 | ; inc [edb1.pos] |
||
4865 | eAndrew | 193 | |
4875 | eAndrew | 194 | .redraw: |
195 | call draw_textbox |
||
196 | jmp update |
||
4865 | eAndrew | 197 | |
198 | ;---------------------- |
||
199 | |||
200 | ev_mouse: |
||
201 | mcall 2 |
||
202 | |||
203 | invoke editbox.mouse, edb1 |
||
204 | jmp update |
||
205 | |||
206 | ;---------------------- |
||
207 | |||
208 | exit: |
||
209 | mcall -1 |
||
210 | |||
211 | ;---------------------- |
||
212 | |||
213 | calc: |
||
214 | stdcall parse |
||
215 | cmp [error_n], 0 |
||
216 | jne .error |
||
217 | |||
4939 | eAndrew | 218 | mov [ans.buffer], word "= " |
219 | |||
220 | stdcall convert_to_str, eax, ans.buffer + 2 |
||
221 | add eax, 2 |
||
4865 | eAndrew | 222 | imul eax, 6 |
223 | add eax, 9 |
||
224 | mov [ans.size], eax |
||
4875 | eAndrew | 225 | jmp .redraw |
4865 | eAndrew | 226 | |
227 | .error: |
||
228 | cmp [error_n], 1 |
||
229 | je .err_1 |
||
4875 | eAndrew | 230 | cmp [error_n], 4 |
231 | je .err_4 |
||
232 | |||
233 | mov [ans.buffer + 0], dword "Expe" |
||
234 | mov [ans.buffer + 4], dword "cted" |
||
235 | mov [ans.buffer + 8], dword " ')'" |
||
236 | mov [ans.buffer + 12], byte 0 |
||
237 | mov [ans.size], 81 |
||
238 | |||
239 | cmp [error_n], 2 |
||
240 | je .redraw |
||
241 | cmp [error_n], 3 |
||
242 | je .err_3 |
||
4865 | eAndrew | 243 | .err_1: |
244 | mov [ans.buffer + 0], dword "Div." |
||
245 | mov [ans.buffer + 4], dword " by " |
||
4875 | eAndrew | 246 | mov [ans.buffer + 8], byte "0" |
247 | mov [ans.buffer + 9], byte 0 |
||
248 | mov [ans.size], 63 |
||
249 | jmp .redraw |
||
250 | .err_4: |
||
251 | mov [ans.buffer + 0], dword "Inpu" |
||
252 | mov [ans.buffer + 4], dword "t er" |
||
253 | mov [ans.buffer + 8], dword "rror" |
||
4865 | eAndrew | 254 | mov [ans.buffer + 12], byte 0 |
255 | mov [ans.size], 81 |
||
4875 | eAndrew | 256 | jmp .redraw |
257 | .err_3: |
||
258 | mov [ans.buffer + 10], byte "(" |
||
259 | jmp .redraw |
||
4865 | eAndrew | 260 | |
4875 | eAndrew | 261 | .redraw: |
262 | call draw_textbox |
||
263 | jmp update |
||
264 | |||
4865 | eAndrew | 265 | ;---------------------- |
266 | |||
4939 | eAndrew | 267 | ; proc draw_button, x, y |
268 | ; mcall 8, <[x], [but_w]>, <[y], 20>, [but_id], [scn.btn_face] |
||
269 | ; |
||
270 | ; mcall 1, [x], [y], [scn.win_face] |
||
271 | ; add ebx, [but_w] |
||
272 | ; mcall |
||
273 | ; add ecx, 20 |
||
274 | ; mcall |
||
275 | ; sub ebx, [but_w] |
||
276 | ; mcall |
||
277 | ; |
||
278 | ; mov ebx, [x] |
||
279 | ; add ebx, [txt_x] |
||
280 | ; shl ebx, 16 |
||
281 | ; add ebx, [y] |
||
282 | ; add ebx, 7 |
||
283 | ; mcall 4, , [scn.win_text], [txt_id], 1 |
||
284 | ; |
||
285 | ; inc dword [txt_id] |
||
286 | ; inc dword [but_id] |
||
287 | ; |
||
288 | ; ret |
||
289 | ; endp |
||
4865 | eAndrew | 290 | |
291 | ;---------------------- |
||
292 | |||
4875 | eAndrew | 293 | proc draw_textbox |
4939 | eAndrew | 294 | mcall 13, <4, 320>, < 8, 23>, [scn.gui_frame] |
4875 | eAndrew | 295 | mov edx, [scn.gui_face] |
296 | cmp [error_n], 0 |
||
297 | je @f |
||
298 | mov edx, 0xFFAAAA |
||
299 | @@: |
||
4939 | eAndrew | 300 | mcall 13, < 5, 318>, < 9, 21> |
301 | mcall , < 5, 318>, < 9, 1>, [scn.3d_face] |
||
4875 | eAndrew | 302 | mcall , < 5, 1>, < 10, 20> |
4939 | eAndrew | 303 | mcall , < 5, 318>, < 31, 1>, [scn.3d_light] |
4875 | eAndrew | 304 | |
4939 | eAndrew | 305 | mov ebx, 328 |
306 | sub ebx, [ans.size] |
||
307 | shl ebx, 16 |
||
308 | add ebx, 16 |
||
309 | mov ecx, [scn.gui_intext] |
||
310 | or ecx, 1 shl 31 |
||
311 | mcall 4, , , ans.buffer |
||
4875 | eAndrew | 312 | |
313 | mcall 1, 4, 8, [scn.win_body] |
||
4939 | eAndrew | 314 | mcall , 323 |
4875 | eAndrew | 315 | mcall , , 30, [scn.3d_light] |
316 | mcall , 4 |
||
317 | |||
4939 | eAndrew | 318 | mov ebx, 318 |
4875 | eAndrew | 319 | sub ebx, [ans.size] |
320 | cmp ebx, 24 |
||
321 | jg @f |
||
322 | mov ebx, 24 |
||
323 | @@: |
||
324 | mov [edb1.width], ebx |
||
325 | m2m [edb1.color], [scn.gui_face] |
||
326 | m2m [edb1.focus_border_color], [scn.gui_face] |
||
327 | cmp [error_n], 0 |
||
328 | je @f |
||
329 | mov [edb1.color], 0xFFAAAA |
||
330 | mov [edb1.focus_border_color], 0xFFAAAA |
||
331 | @@: |
||
332 | invoke editbox.draw, edb1 |
||
333 | |||
334 | ret |
||
335 | endp |
||
336 | |||
337 | ;---------------------- |
||
338 | |||
4865 | eAndrew | 339 | dataend: |
340 | |||
341 | ;=============================== |
||
342 | |||
343 | rb 2048 |
||
344 | stacktop: |
||
345 | |||
346 | exp rb 512 |
||
347 | exp_pos rd 1 |
||
348 | exp_lvl rd 1 |
||
349 | group rd 1 |
||
350 | |||
351 | ans.buffer:rb 512 |
||
352 | ans.size rd 1 |
||
353 | error_n rd 1 |
||
354 | |||
355 | scn sys_colors_new |
||
356 | timer rd 1 |
||
357 | but_id rd 1 |
||
4875 | eAndrew | 358 | but_w rd 1 |
359 | txt_id rd 1 |
||
360 | txt_x rd 1 |
||
4865 | eAndrew | 361 | |
4939 | eAndrew | 362 | memory:>>>>>>>>>4,>[y],>[x],>279,>-17,>275,>100,>100,> |