Rev 2211 | Rev 2618 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ;****************************************************************************** |
2211 | mario79 | 2 | ; MAIN MENU |
3 | ;****************************************************************************** |
||
2488 | mario79 | 4 | ; last update: 22/03/2012 |
5 | ; changed by: Marat Zakiyanov aka Mario79, aka Mario |
||
6 | ; changes: Global optimization! The program uses |
||
7 | ; only 32 KB of memory instead of 128 kb is now. |
||
8 | ;------------------------------------------------------------------------------ |
||
2211 | mario79 | 9 | ; last update: 19/09/2011 |
10 | ; changed by: Marat Zakiyanov aka Mario79, aka Mario |
||
11 | ; changes: Checking for program exist to memory |
||
12 | ; Added processing of keys: left and right arrow |
||
2488 | mario79 | 13 | ;------------------------------------------------------------------------------ |
31 | halyavin | 14 | ; MAIN MENU by lisovin@26.ru |
15 | ; Some parts of code rewritten by Ivan Poddubny |
||
16 | ; |
||
17 | ; Compile with FASM for Menuet |
||
18 | ;****************************************************************************** |
||
19 | include "lang.inc" |
||
485 | heavyiron | 20 | include "..\..\..\macros.inc" |
31 | halyavin | 21 | |
22 | BTN_HEIGHT = 22 |
||
23 | TXT_Y = (BTN_HEIGHT)/2-5 |
||
24 | |||
2211 | mario79 | 25 | PANEL_HEIGHT = 20 |
26 | MENU_BOTTON_X_POS = 10 |
||
27 | MENU_BOTTON_X_SIZE = 60 |
||
2488 | mario79 | 28 | ;------------------------------------------------------------------------------ |
2211 | mario79 | 29 | use32 |
30 | org 0x0 |
||
2488 | mario79 | 31 | |
2211 | mario79 | 32 | db 'MENUET01' ; 8 byte id |
33 | dd 0x01 ; header version |
||
34 | dd START ; start of code |
||
2488 | mario79 | 35 | dd IM_END ; size of image |
36 | dd mem_end ; memory for app |
||
37 | dd stack_area ; esp |
||
38 | dd 0x0 ; boot parameters |
||
39 | dd 0x0 ; path |
||
40 | ;------------------------------------------------------------------------------ |
||
31 | halyavin | 41 | ;include "DEBUG.INC" ; debug macros |
2488 | mario79 | 42 | ;------------------------------------------------------------------------------ |
43 | align 4 |
||
97 | mario79 | 44 | START: ; start of execution |
2488 | mario79 | 45 | mcall 68,11 |
2211 | mario79 | 46 | call program_exist |
47 | mcall 14 |
||
48 | mov [screen_size],eax |
||
49 | |||
50 | mcall 48,3,sc,sizeof.system_colors ; load system colors |
||
2488 | mario79 | 51 | |
52 | ; get size of file MENU.DAT |
||
53 | mcall 70,fileinfo |
||
54 | test eax,eax |
||
2211 | mario79 | 55 | jnz close |
2488 | mario79 | 56 | ; get memory for MENU.DAT |
57 | mov ecx,[procinfo+32] |
||
58 | mov [fileinfo.size],ecx |
||
59 | mcall 68,12 |
||
60 | mov [fileinfo.return],eax |
||
61 | mcall 68 |
||
62 | mov [menu_data],eax |
||
63 | ; load MENU.DAT |
||
64 | mov [fileinfo],dword 0 |
||
65 | mcall 70,fileinfo |
||
66 | test eax,eax |
||
67 | jnz close |
||
68 | |||
2211 | mario79 | 69 | test ebx,ebx ; length = 0 ? |
70 | jz close |
||
71 | mov ecx,ebx |
||
2488 | mario79 | 72 | mov edi,[fileinfo.return] ;mem_end |
73 | ;-------------------------------------- |
||
74 | align 4 |
||
2211 | mario79 | 75 | newsearch: |
76 | mov al,'#' |
||
77 | cld |
||
78 | repne scasb |
||
79 | test ecx,ecx ; if not found |
||
80 | jz close |
||
81 | call get_number |
||
82 | test ebx,ebx |
||
83 | jnz .number |
||
84 | cmp al,'#' |
||
85 | je search_end |
||
2488 | mario79 | 86 | ;-------------------------------------- |
87 | align 4 |
||
2211 | mario79 | 88 | .number: |
89 | shl ebx,4 |
||
2488 | mario79 | 90 | add ebx,[menu_data] ; pointer to process table |
2211 | mario79 | 91 | mov [ebx],edi |
92 | inc [processes] |
||
93 | jmp newsearch |
||
2488 | mario79 | 94 | ;-------------------------------------- |
95 | align 4 |
||
2211 | mario79 | 96 | search_end: |
97 | mov [end_pointer],edi |
||
98 | mov ebx,[processes] |
||
99 | dec ebx |
||
100 | shl ebx,4 |
||
2488 | mario79 | 101 | add ebx,[menu_data] |
102 | ;-------------------------------------- |
||
103 | align 4 |
||
2211 | mario79 | 104 | newprocess: |
105 | xor edx,edx |
||
106 | mov ecx,edi |
||
107 | sub ecx,[ebx] |
||
108 | mov al,10 |
||
2488 | mario79 | 109 | ;-------------------------------------- |
110 | align 4 |
||
2211 | mario79 | 111 | newsearch1: |
112 | std |
||
113 | repne scasb |
||
114 | test ecx,ecx |
||
115 | je endprocess |
||
116 | cmp [edi],byte 13 |
||
117 | jne newsearch1 |
||
118 | inc edx |
||
119 | jmp newsearch1 |
||
2488 | mario79 | 120 | ;-------------------------------------- |
121 | align 4 |
||
2211 | mario79 | 122 | endprocess: |
123 | mov esi,ebx |
||
124 | add esi,4 |
||
125 | dec edx |
||
126 | mov [esi],dl |
||
2488 | mario79 | 127 | cmp ebx,[menu_data] |
2211 | mario79 | 128 | jbe search_end1 |
129 | sub ebx,16 |
||
130 | jmp newprocess |
||
2488 | mario79 | 131 | ;-------------------------------------- |
132 | align 4 |
||
2211 | mario79 | 133 | search_end1: |
134 | mcall 14 |
||
135 | sub ax,20 |
||
2488 | mario79 | 136 | mov ebx,[menu_data] |
137 | mov [ebx + y_end],ax |
||
138 | mov [ebx + x_start],5 |
||
139 | mov al,[ebx + rows] |
||
140 | mov [ebx + cur_sel],al ; clear selection |
||
141 | mov [ebx + prev_sel],al |
||
2211 | mario79 | 142 | mov [buffer],0 |
2488 | mario79 | 143 | ;------------------------------------------------------------------------------ |
144 | align 4 |
||
2211 | mario79 | 145 | thread: |
2488 | mario79 | 146 | mov ebp,esp |
147 | sub ebp,0x1000 |
||
148 | cmp ebp,0x2000 ; if this is first started thread |
||
149 | ja @f |
||
150 | xor ebp,ebp ; not free area |
||
151 | ;-------------------------------------- |
||
152 | align 4 |
||
153 | @@: |
||
2211 | mario79 | 154 | mov eax,[buffer] ; identifier |
155 | shl eax,4 |
||
2488 | mario79 | 156 | add eax,[menu_data] |
2211 | mario79 | 157 | mov edi,eax |
158 | mcall 40,100111b ; mouse + button + key + redraw |
||
2488 | mario79 | 159 | ;------------------------------------------------------------------------------ |
160 | align 4 |
||
2211 | mario79 | 161 | red: |
162 | call draw_window ; redraw |
||
2488 | mario79 | 163 | ;------------------------------------------------------------------------------ |
164 | align 4 |
||
31 | halyavin | 165 | still: |
2488 | mario79 | 166 | call free_area_if_set_mutex |
167 | |||
2211 | mario79 | 168 | mcall 23,5 ; wait here for event |
169 | test [close_now],1 ; is close flag set? |
||
170 | jnz close |
||
171 | |||
172 | cmp eax,1 ; redraw request ? |
||
173 | je red |
||
174 | cmp eax,2 ; key pressed ? |
||
175 | je key |
||
176 | cmp eax,3 ; button in buffer ? |
||
177 | je button |
||
178 | cmp eax,6 ; mouse event ? |
||
179 | je mouse |
||
2488 | mario79 | 180 | cmp edi,[menu_data] |
2211 | mario79 | 181 | je still ; if main process-ignored |
182 | |||
183 | movzx ebx,[edi + parent] ; parent id |
||
184 | shl ebx,4 |
||
2488 | mario79 | 185 | add ebx,[menu_data] ; ebx = base of parent info |
2211 | mario79 | 186 | call backconvert ; get my id in al |
187 | cmp al,[ebx + child] ; if I'm not child of my parent, I shall die :) |
||
188 | jne close |
||
189 | |||
190 | jmp still |
||
2488 | mario79 | 191 | ;------------------------------------------------------------------------------ |
192 | align 4 |
||
2211 | mario79 | 193 | key: |
2488 | mario79 | 194 | mcall 2 |
2211 | mario79 | 195 | mov [last_key],ah |
196 | mov al,[edi + rows] ; number of buttons |
||
197 | cmp ah,178 ; KEY_UP |
||
198 | jne .noup |
||
199 | |||
200 | mov ah,[edi+cur_sel] |
||
201 | mov [edi+prev_sel],ah |
||
202 | dec byte [edi+cur_sel] |
||
203 | jnz redrawbut |
||
204 | mov [edi+cur_sel],al |
||
205 | jmp redrawbut |
||
2488 | mario79 | 206 | ;-------------------------------------- |
207 | align 4 |
||
2211 | mario79 | 208 | .noup: |
209 | cmp ah,177 ; KEY_DOWN |
||
210 | jne .nodn |
||
211 | |||
212 | mov ah,[edi + cur_sel] |
||
213 | mov [edi + prev_sel],ah |
||
214 | inc [edi + cur_sel] |
||
215 | cmp [edi + cur_sel],al |
||
216 | jna redrawbut |
||
217 | mov [edi + cur_sel],1 |
||
218 | jmp redrawbut |
||
2488 | mario79 | 219 | ;-------------------------------------- |
220 | align 4 |
||
2211 | mario79 | 221 | .nodn: |
222 | cmp ah,179 ; KEY_LEFT |
||
223 | je @f |
||
224 | cmp ah,13 ; ENTER |
||
225 | jne .noenter |
||
226 | @@: |
||
227 | mov ah,[edi + cur_sel] |
||
228 | jmp button1 |
||
2488 | mario79 | 229 | ;-------------------------------------- |
230 | align 4 |
||
2211 | mario79 | 231 | .noenter: |
232 | cmp ah,176 ; KEY_RIGHT |
||
233 | je @f |
||
234 | cmp ah,27 ; ESC |
||
235 | jne still |
||
236 | jmp close |
||
2488 | mario79 | 237 | ;-------------------------------------- |
238 | align 4 |
||
2211 | mario79 | 239 | @@: |
240 | call get_process_ID |
||
241 | cmp [main_process_ID],ecx |
||
242 | jne close |
||
243 | jmp still |
||
2488 | mario79 | 244 | ;------------------------------------------------------------------------------ |
245 | align 4 |
||
2211 | mario79 | 246 | button: ; BUTTON HANDLER |
247 | mcall 17 ; get id |
||
248 | ; dunkaist[ |
||
249 | test eax,0xfffffe00 ; is it system close button? (close signal from @panel) |
||
250 | setz byte[close_now] ; set (or not set) close_recursive flag |
||
251 | jz close ; if so,close all menus |
||
252 | ; dunkaist] |
||
2488 | mario79 | 253 | ;-------------------------------------- |
254 | align 4 |
||
2211 | mario79 | 255 | button1: |
256 | mov esi,edi |
||
257 | push edi |
||
258 | mov edi,[edi + pointer] |
||
31 | halyavin | 259 | ; print "hello" |
2211 | mario79 | 260 | mov al,[esi + cur_sel] |
261 | mov [esi + prev_sel],al |
||
262 | mov [esi + cur_sel],ah |
||
263 | |||
264 | pushad |
||
265 | mov edi,esi |
||
266 | ; dph eax |
||
267 | call draw_only_needed_buttons |
||
268 | popad |
||
269 | ; look for the next line |
||
270 | push eax |
||
2488 | mario79 | 271 | ;-------------------------------------- |
272 | align 4 |
||
2211 | mario79 | 273 | .next_string: |
274 | call searchstartstring |
||
275 | dec ah |
||
276 | jnz .next_string |
||
277 | pop eax |
||
278 | |||
279 | mov ecx,40 |
||
280 | mov al,'/' |
||
281 | cld |
||
282 | repne scasb |
||
283 | test ecx,ecx ; if '/' not found |
||
284 | je searchexit |
||
285 | |||
286 | cmp [edi],byte '@' ; check for submenu |
||
287 | je runthread |
||
288 | |||
289 | cmp [last_key],179 |
||
290 | je searchexit |
||
291 | |||
292 | dec edi |
||
293 | push edi ; pointer to start of filename |
||
294 | call searchstartstring ; search for next string |
||
295 | sub edi,2 ; to last byte of string |
||
296 | |||
297 | mov ecx,edi |
||
298 | pop esi |
||
299 | sub ecx,esi |
||
300 | inc ecx ; length of filename |
||
301 | mov edi, fileinfo_start.name |
||
302 | rep movsb ; copy string |
||
303 | mov [edi],byte 0 ; store terminator |
||
304 | mcall 70,fileinfo_start ; start program |
||
305 | or [close_now],1 ; set close flag |
||
306 | pop edi |
||
307 | mov [mousemask],0 |
||
308 | jmp close |
||
2488 | mario79 | 309 | ;-------------------------------------- |
310 | align 4 |
||
2211 | mario79 | 311 | searchexit: |
312 | pop edi |
||
313 | jmp still |
||
2488 | mario79 | 314 | ;------------------------------------------------------------------------------ |
315 | align 4 |
||
2211 | mario79 | 316 | runthread: |
317 | inc edi |
||
318 | |||
319 | push eax |
||
320 | call get_number ; get number of this process |
||
321 | pop eax |
||
322 | |||
323 | test ebx,ebx ; returned zero - main menu or not number |
||
324 | jz searchexit |
||
325 | |||
326 | mov al,bl |
||
327 | |||
328 | mov ebx,[processes] |
||
329 | dec bl |
||
330 | cmp al,bl |
||
331 | ja searchexit ; such process doesnt exist |
||
332 | cmp al,[esi + child] |
||
333 | je searchexit ; such process already exists |
||
334 | |||
335 | mov [esi + child],al ; this is my child |
||
336 | mov cx,[esi + x_start] |
||
337 | add cx,141 ; new x_start in cx |
||
338 | movzx edx,al |
||
339 | shl edx,4 |
||
2488 | mario79 | 340 | add edx,[menu_data] ; edx points to child's base address |
2211 | mario79 | 341 | mov [edx + x_start],cx ; xstart for new thread |
342 | mov cx,[esi + y_end] ; y_end in cx |
||
343 | mov bl,[esi + rows] ; number of buttons in bl |
||
344 | sub bl,ah ; number of btn from bottom |
||
345 | movzx eax,al |
||
346 | mov [buffer],eax ; thread id in buffer |
||
347 | movzx ebx,bl |
||
348 | push edx |
||
349 | mov eax,BTN_HEIGHT |
||
350 | mul ebx |
||
351 | sub cx,ax ; new y_end for new thread |
||
352 | pop edx |
||
353 | mov [edx + y_end],cx ; store y_end |
||
354 | mov edi,esi |
||
355 | call backconvert ; get number of this process (al) |
||
356 | mov [edx + parent],al ; store number of parent process |
||
357 | mov al,[edx + rows] |
||
358 | mov [edx + cur_sel],al ; clear current selected element |
||
359 | mov [edx + prev_sel],al ; clear previous selected element |
||
360 | mov [edx + child],0 |
||
361 | |||
2488 | mario79 | 362 | mcall 68,12,0x1000 ; stack of each thread is allocated 4 KB |
363 | add eax,0x1000 ; set the stack pointer to the desired position |
||
364 | mov edx,eax |
||
365 | mcall 51,1,thread ; Go ahead! |
||
2211 | mario79 | 366 | jmp searchexit |
2488 | mario79 | 367 | ;------------------------------------------------------------------------------ |
368 | align 4 |
||
2211 | mario79 | 369 | mouse: ; MOUSE EVENT HANDLER |
370 | mcall 37,0 |
||
371 | mov [screen_mouse_position],eax ; eax = [ Y | X ] relative to screen |
||
31 | halyavin | 372 | |
2211 | mario79 | 373 | mcall 37,2 |
374 | test eax,eax ; check buttons state |
||
375 | jnz click |
||
376 | mcall 37,1 |
||
377 | ror eax,16 ; eax = [ Y | X ] relative to window |
||
378 | cmp ax,140 ; pointer in window? |
||
379 | ja noinwindow |
||
380 | ; *** in window *** |
||
381 | shr eax,16 ; eax = [ 0 | Y ] |
||
382 | xor edx,edx |
||
383 | mov ebx,BTN_HEIGHT |
||
384 | div ebx |
||
385 | inc eax ; number of "button" in eax |
||
386 | movzx ebx,[edi + rows] ; total strings in ebx |
||
387 | cmp eax,ebx |
||
388 | ja noinwindow |
||
389 | cmp [edi + cur_sel],al |
||
390 | je noredrawbut |
||
391 | mov bl,[edi + cur_sel] |
||
392 | ;;;;;; |
||
393 | cmp [edi + child],0 |
||
394 | jne noredrawbut |
||
395 | ;;;;;; |
||
396 | mov [edi + cur_sel],al |
||
397 | mov [edi + prev_sel],bl |
||
2488 | mario79 | 398 | ;-------------------------------------- |
399 | align 4 |
||
2211 | mario79 | 400 | redrawbut: |
401 | call draw_only_needed_buttons |
||
2488 | mario79 | 402 | ;-------------------------------------- |
403 | align 4 |
||
2211 | mario79 | 404 | noredrawbut: |
405 | call backconvert |
||
406 | bts [mousemask],eax |
||
407 | jmp still |
||
2488 | mario79 | 408 | ;-------------------------------------- |
409 | align 4 |
||
2211 | mario79 | 410 | noinwindow: |
411 | call backconvert |
||
412 | btr [mousemask],eax |
||
413 | jmp still |
||
2488 | mario79 | 414 | ;------------------------------------------------------------------------------ |
415 | align 4 |
||
2211 | mario79 | 416 | click: |
417 | cmp [mousemask],0 ; not in a window (i.e. menu) |
||
418 | jne still |
||
419 | ; checking for pressing 'MENU' on the taskbar |
||
420 | mov eax,[screen_mouse_position] |
||
421 | mov ebx,[screen_size] |
||
422 | sub bx,PANEL_HEIGHT |
||
423 | cmp bx,ax |
||
424 | ja close |
||
425 | shr eax,16 |
||
426 | cmp ax,MENU_BOTTON_X_SIZE |
||
427 | ja close |
||
428 | cmp ax,MENU_BOTTON_X_POS |
||
429 | ja still |
||
2488 | mario79 | 430 | ;------------------------------------------------------------------------------ |
431 | align 4 |
||
2211 | mario79 | 432 | close: |
433 | |||
434 | movzx ebx,[edi+parent] ; parent id |
||
435 | shl ebx,4 |
||
2488 | mario79 | 436 | add ebx,[menu_data] ; ebx = base of parent info |
2211 | mario79 | 437 | call backconvert |
438 | cmp [ebx + child],al ; if i am the child of my parent... |
||
439 | jnz @f |
||
440 | mov [ebx + child],-1 ; ...my parent now has no children |
||
2488 | mario79 | 441 | ;-------------------------------------- |
442 | align 4 |
||
728 | diamond | 443 | @@: |
2211 | mario79 | 444 | or eax,-1 ; close this thread |
445 | mov [edi + child],al ; my child is not mine |
||
2488 | mario79 | 446 | |
447 | call free_area_if_set_mutex |
||
448 | call set_mutex_for_free_area |
||
449 | |||
2211 | mario79 | 450 | mcall |
2488 | mario79 | 451 | ;-------------------------------------- |
452 | align 4 |
||
2211 | mario79 | 453 | backconvert: ; convert from pointer to process id |
454 | mov eax,edi |
||
2488 | mario79 | 455 | sub eax,[menu_data] |
2211 | mario79 | 456 | shr eax,4 |
457 | ret |
||
2488 | mario79 | 458 | ;------------------------------------------------------------------------------ |
459 | align 4 |
||
460 | set_mutex_for_free_area: |
||
461 | ; set mutex for free thread stack area |
||
462 | push eax ebx |
||
463 | ;-------------------------------------- |
||
464 | align 4 |
||
465 | .wait_lock: |
||
466 | cmp [free_my_area_lock], 0 |
||
467 | je .get_lock |
||
468 | mcall 68,1 |
||
469 | jmp .wait_lock |
||
470 | ;-------------------------------------- |
||
471 | align 4 |
||
472 | .get_lock: |
||
473 | mov eax, 1 |
||
474 | xchg eax, [free_my_area_lock] |
||
475 | test eax, eax |
||
476 | jnz .wait_lock |
||
477 | mov [free_my_area],ebp |
||
478 | pop ebx eax |
||
479 | ret |
||
480 | ;------------------------------------------------------------------------------ |
||
481 | align 4 |
||
482 | free_area_if_set_mutex: |
||
483 | cmp [free_my_area_lock],0 |
||
484 | je .end |
||
485 | |||
486 | push eax ebx ecx |
||
487 | mov ecx,[free_my_area] |
||
488 | |||
489 | test ecx,ecx |
||
490 | jz @f |
||
491 | mcall 68,13 |
||
492 | ;-------------------------------------- |
||
493 | align 4 |
||
494 | @@: |
||
495 | xor eax,eax |
||
496 | mov [free_my_area_lock],eax |
||
497 | pop ecx ebx eax |
||
498 | ;-------------------------------------- |
||
499 | align 4 |
||
500 | .end: |
||
501 | ret |
||
502 | ;------------------------------------------------------------------------------ |
||
31 | halyavin | 503 | ;================================== |
504 | ; get_number |
||
505 | ; load number from [edi] to ebx |
||
506 | ;================================== |
||
2488 | mario79 | 507 | align 4 |
2211 | mario79 | 508 | get_number: |
509 | push edi |
||
510 | xor eax,eax |
||
511 | xor ebx,ebx |
||
2488 | mario79 | 512 | ;-------------------------------------- |
513 | align 4 |
||
2211 | mario79 | 514 | .get_next_char: |
515 | mov al,[edi] |
||
516 | inc edi |
||
517 | cmp al, '0' |
||
518 | jb .finish |
||
519 | cmp al, '9' |
||
520 | ja .finish |
||
521 | sub al, '0' |
||
522 | imul ebx,10 |
||
523 | add ebx,eax |
||
524 | jmp .get_next_char |
||
525 | ;------------------------------------- |
||
2488 | mario79 | 526 | align 4 |
2211 | mario79 | 527 | .finish: |
528 | pop edi |
||
529 | ret |
||
2488 | mario79 | 530 | ;------------------------------------------------------------------------------ |
531 | align 4 |
||
2211 | mario79 | 532 | get_process_ID: |
533 | mcall 9,procinfo,-1 |
||
534 | mov edx,eax |
||
535 | mov ecx,[ebx+30] ; PID |
||
536 | ret |
||
2488 | mario79 | 537 | ;------------------------------------------------------------------------------ |
538 | align 4 |
||
2211 | mario79 | 539 | program_exist: |
540 | call get_process_ID |
||
541 | mov [main_process_ID],ecx |
||
542 | mcall 18,21 |
||
543 | mov [active_process],eax ; WINDOW SLOT |
||
544 | mov ecx,edx |
||
545 | xor edx,edx |
||
546 | ;----------------------------------------- |
||
2488 | mario79 | 547 | align 4 |
2211 | mario79 | 548 | .loop: |
549 | push ecx |
||
550 | mcall 9,procinfo |
||
551 | mov eax,[menu_mame] |
||
552 | cmp [ebx+10],eax |
||
553 | jne @f |
||
554 | mov ax,[menu_mame+4] |
||
555 | cmp [ebx+14],ax |
||
556 | jne @f |
||
557 | cmp ecx,[active_process] |
||
558 | je @f |
||
559 | ; dph ecx |
||
560 | mcall 18,2 |
||
561 | mov edx,1 |
||
2488 | mario79 | 562 | ;-------------------------------------- |
563 | align 4 |
||
2211 | mario79 | 564 | @@: |
565 | pop ecx |
||
566 | loop .loop |
||
2488 | mario79 | 567 | |
2211 | mario79 | 568 | test edx,edx |
569 | jz @f |
||
570 | mcall -1 |
||
2488 | mario79 | 571 | ;-------------------------------------- |
572 | align 4 |
||
2211 | mario79 | 573 | @@: |
574 | ret |
||
2488 | mario79 | 575 | ;------------------------------------------------------------------------------ |
31 | halyavin | 576 | ; ********************************************* |
577 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
578 | ; ********************************************* |
||
2488 | mario79 | 579 | align 4 |
31 | halyavin | 580 | draw_window: |
2211 | mario79 | 581 | mcall 12,1 ; 1,start of draw |
582 | movzx ebx,[edi + rows] |
||
583 | imul eax,ebx,BTN_HEIGHT ; eax = height of window |
||
584 | movzx ecx,[edi + y_end] |
||
585 | sub ecx,eax ; ecx = Y_START |
||
586 | shl ecx,16 |
||
587 | add ecx,eax ; ecx = [ Y_START | Y_SIZE ] |
||
588 | dec ecx |
||
589 | movzx ebx,[edi + x_start] |
||
590 | shl ebx,16 |
||
591 | mov bx,140 ; ebx = [ X_START | X_SIZE ] |
||
592 | mov edx,0x01000000 ; color of work area RRGGBB,8->color gl |
||
593 | mov esi,edx ; unmovable window |
||
594 | xor eax,eax ; function 0 : define and draw window |
||
595 | mcall |
||
596 | |||
597 | call draw_all_buttons |
||
598 | mcall 12,2 |
||
599 | ret |
||
2488 | mario79 | 600 | ;------------------------------------------------------------------------------ |
601 | align 4 |
||
2211 | mario79 | 602 | draw_all_buttons: |
603 | xor edx,edx |
||
2488 | mario79 | 604 | ;-------------------------------------- |
605 | align 4 |
||
2211 | mario79 | 606 | .new_button: |
607 | call draw_one_button |
||
608 | inc edx |
||
609 | cmp dl,[edi + rows] |
||
610 | jb .new_button |
||
611 | ret |
||
2488 | mario79 | 612 | ;------------------------------------------------------------------------------ |
613 | align 4 |
||
2211 | mario79 | 614 | draw_only_needed_buttons: |
615 | xor edx,edx |
||
616 | mov dl,[edi + cur_sel] |
||
617 | dec dl |
||
618 | call draw_one_button |
||
619 | mov dl,[edi + prev_sel] |
||
620 | dec dl |
||
621 | call draw_one_button |
||
622 | ret |
||
2488 | mario79 | 623 | ;------------------------------------------------------------------------------ |
624 | align 4 |
||
2211 | mario79 | 625 | draw_one_button: |
626 | ; receives number of button in dl |
||
627 | push edx |
||
628 | mov eax,8 |
||
629 | mov ebx,140 |
||
630 | movzx ecx,dl |
||
631 | imul ecx,BTN_HEIGHT |
||
632 | shl ecx,16 |
||
633 | add ecx,BTN_HEIGHT-1 |
||
634 | ; edx = button identifier |
||
635 | mov esi,[sc.work] |
||
636 | cmp esi,0xdfdfdf |
||
637 | jb nocorrect |
||
638 | sub esi,0x1b1b1b |
||
2488 | mario79 | 639 | ;-------------------------------------- |
640 | align 4 |
||
2211 | mario79 | 641 | nocorrect: |
642 | inc dl |
||
643 | cmp [edi + cur_sel],dl |
||
644 | jne .nohighlight |
||
645 | add esi,0x1a1a1a |
||
2488 | mario79 | 646 | ;-------------------------------------- |
647 | align 4 |
||
2211 | mario79 | 648 | .nohighlight: |
649 | or edx,0x20000000 |
||
650 | ; dunkaist[ |
||
651 | add edx,0xd1ff00 ; This makes first menu buttons differ |
||
652 | ; from system close button with 0x000001 id |
||
653 | ; dunkaist] |
||
654 | mcall |
||
655 | movzx edx,dl |
||
656 | dec dl |
||
657 | imul ebx,edx,BTN_HEIGHT |
||
658 | add ebx,(4 shl 16) + TXT_Y |
||
659 | movzx ecx,dl |
||
660 | inc ecx |
||
661 | mov edx,[edi + pointer] |
||
2488 | mario79 | 662 | ;-------------------------------------- |
663 | align 4 |
||
2211 | mario79 | 664 | .findline: |
665 | cmp byte [edx],13 |
||
666 | je .linefound |
||
667 | inc edx |
||
668 | jmp .findline |
||
2488 | mario79 | 669 | ;------------------------------------------------------------------------------ |
670 | align 4 |
||
2211 | mario79 | 671 | .linefound: |
672 | inc edx |
||
673 | cmp byte [edx],10 |
||
674 | jne .findline |
||
675 | dec ecx |
||
676 | jnz .findline |
||
677 | |||
678 | mcall 4,,[sc.work_text],,21 |
||
679 | pop edx |
||
680 | ret |
||
2488 | mario79 | 681 | ;------------------------------------------------------------------------------ |
682 | align 4 |
||
2211 | mario79 | 683 | searchstartstring: |
684 | mov ecx,40 |
||
685 | mov al,13 |
||
686 | cld |
||
687 | repne scasb |
||
688 | cmp byte [edi],10 |
||
689 | jne searchstartstring |
||
690 | ret |
||
2488 | mario79 | 691 | ;------------------------------------------------------------------------------ |
31 | halyavin | 692 | ;*** DATA AREA **************************************************************** |
2211 | mario79 | 693 | menu_mame: |
694 | db '@MENU',0 |
||
31 | halyavin | 695 | |
2488 | mario79 | 696 | align 4 |
697 | free_my_area_lock dd 0 |
||
698 | free_my_area dd 0 |
||
699 | |||
2211 | mario79 | 700 | processes dd 0 |
2488 | mario79 | 701 | ;-------------------------------------- |
702 | align 4 |
||
31 | halyavin | 703 | fileinfo: |
2488 | mario79 | 704 | .subfunction dd 5 ; 5 - file info; 0 - file read |
705 | .start dd 0 ; start byte |
||
706 | .size_high dd 0 ; rezerved |
||
707 | .size dd 0 ; bytes to read |
||
708 | .return dd procinfo ; return data pointer |
||
31 | halyavin | 709 | .name: |
529 | spraid | 710 | db '/sys/MENU.DAT',0 ; ASCIIZ dir & filename |
2488 | mario79 | 711 | ;-------------------------------------- |
712 | align 4 |
||
31 | halyavin | 713 | fileinfo_start: |
2488 | mario79 | 714 | .subfunction dd 7 ; 7=START APPLICATION |
715 | .flags dd 0 ; flags |
||
716 | .params dd 0x0 ; nop |
||
717 | .rezerved dd 0x0 ; nop |
||
718 | .rezerved_1 dd 0x0 ; nop |
||
31 | halyavin | 719 | .name: |
720 | times 50 db ' ' |
||
2488 | mario79 | 721 | ;------------------------------------------------------------------------------ |
722 | IM_END: |
||
723 | ;------------------------------------------------------------------------------ |
||
724 | align 4 |
||
2211 | mario79 | 725 | close_now dd ? ; close all processes immediately |
726 | end_pointer dd ? |
||
727 | buffer dd ? |
||
728 | mousemask dd ? ; mask for mouse pointer location |
||
31 | halyavin | 729 | |
2211 | mario79 | 730 | active_process dd ? |
731 | main_process_ID dd ? |
||
2488 | mario79 | 732 | ;-------------------------------------- |
2211 | mario79 | 733 | screen_mouse_position: |
734 | .y dw ? |
||
735 | .x dw ? |
||
2488 | mario79 | 736 | ;-------------------------------------- |
2211 | mario79 | 737 | screen_size: |
738 | .y dw ? |
||
739 | .x dw ? |
||
2488 | mario79 | 740 | ;-------------------------------------- |
31 | halyavin | 741 | sc system_colors |
2488 | mario79 | 742 | ;-------------------------------------- |
743 | last_key db ? |
||
744 | ;------------------------------------------------------------------------------ |
||
745 | align 4 |
||
746 | menu_data dd ? |
||
747 | ;-------------------------------------- |
||
31 | halyavin | 748 | virtual at 0 ; PROCESSES TABLE (located at menu_data) |
2211 | mario79 | 749 | pointer dd ? ; +0 pointer in file |
750 | rows db ? ; +4 numer of strings |
||
751 | x_start dw ? ; +5 x start |
||
752 | y_end dw ? ; +7 y end |
||
753 | child db ? ; +9 id of child menu |
||
754 | parent db ? ; +10 id of parent menu |
||
755 | cur_sel db ? ; +11 current selection |
||
756 | prev_sel db ? ; +12 previous selection |
||
757 | rb 16-$+1 ; [16 bytes per element] |
||
31 | halyavin | 758 | end virtual |
2488 | mario79 | 759 | ;------------------------------------------------------------------------------ |
2211 | mario79 | 760 | align 4 |
761 | procinfo: |
||
762 | rb 1024 |
||
2488 | mario79 | 763 | ;------------------------------------------------------------------------------ |
764 | align 4 |
||
765 | rb 0x1000 |
||
766 | stack_area: |
||
767 | ;------------------------------------------------------------------------------ |
||
31 | halyavin | 768 | mem_end: |
2488 | mario79 | 769 | ;------------------------------------------------------------------------------ |