Rev 2488 | Rev 2836 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2488 | Rev 2618 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;****************************************************************************** |
1 | ;****************************************************************************** |
2 | ; MAIN MENU |
2 | ; MAIN MENU |
3 | ;****************************************************************************** |
3 | ;****************************************************************************** |
- | 4 | ; last update: 17/04/2012 |
|
- | 5 | ; changed by: Marat Zakiyanov aka Mario79, aka Mario |
|
- | 6 | ; changes: Support for boot parameters. |
|
- | 7 | ;------------------------------------------------------------------------------ |
|
4 | ; last update: 22/03/2012 |
8 | ; last update: 22/03/2012 |
5 | ; changed by: Marat Zakiyanov aka Mario79, aka Mario |
9 | ; changed by: Marat Zakiyanov aka Mario79, aka Mario |
6 | ; changes: Global optimization! The program uses |
10 | ; changes: Global optimization! The program uses |
7 | ; only 32 KB of memory instead of 128 kb is now. |
11 | ; only 32 KB of memory instead of 128 kb is now. |
8 | ;------------------------------------------------------------------------------ |
12 | ;------------------------------------------------------------------------------ |
Line 14... | Line 18... | ||
14 | ; MAIN MENU by lisovin@26.ru |
18 | ; MAIN MENU by lisovin@26.ru |
15 | ; Some parts of code rewritten by Ivan Poddubny |
19 | ; Some parts of code rewritten by Ivan Poddubny |
16 | ; |
20 | ; |
17 | ; Compile with FASM for Menuet |
21 | ; Compile with FASM for Menuet |
18 | ;****************************************************************************** |
22 | ;****************************************************************************** |
19 | include "lang.inc" |
- | |
20 | include "..\..\..\macros.inc" |
- | |
21 | - | ||
22 | BTN_HEIGHT = 22 |
23 | BTN_HEIGHT = 22 |
23 | TXT_Y = (BTN_HEIGHT)/2-5 |
24 | TXT_Y = (BTN_HEIGHT)/2-5 |
Line 24... | Line 25... | ||
24 | 25 | ||
25 | PANEL_HEIGHT = 20 |
26 | PANEL_HEIGHT = 20 |
26 | MENU_BOTTON_X_POS = 10 |
27 | MENU_BOTTON_X_POS = 10 |
27 | MENU_BOTTON_X_SIZE = 60 |
28 | MENU_BOTTON_X_SIZE = 50 |
28 | ;------------------------------------------------------------------------------ |
29 | ;------------------------------------------------------------------------------ |
29 | use32 |
30 | use32 |
Line 30... | Line 31... | ||
30 | org 0x0 |
31 | org 0x0 |
31 | 32 | ||
32 | db 'MENUET01' ; 8 byte id |
33 | db 'MENUET01' ; 8 byte id |
33 | dd 0x01 ; header version |
34 | dd 0x01 ; header version |
34 | dd START ; start of code |
35 | dd START ; start of code |
35 | dd IM_END ; size of image |
36 | dd IM_END ; size of image |
36 | dd mem_end ; memory for app |
37 | dd mem_end ; memory for app |
37 | dd stack_area ; esp |
38 | dd stack_area ; esp |
38 | dd 0x0 ; boot parameters |
39 | dd bootparam ; boot parameters |
- | 40 | dd 0x0 ; path |
|
- | 41 | ;------------------------------------------------------------------------------ |
|
39 | dd 0x0 ; path |
42 | include "lang.inc" |
40 | ;------------------------------------------------------------------------------ |
43 | include "..\..\..\macros.inc" |
41 | ;include "DEBUG.INC" ; debug macros |
44 | ;include "DEBUG.INC" ; debug macros |
- | 45 | ;------------------------------------------------------------------------------ |
|
- | 46 | align 4 |
|
- | 47 | conversion_ASCII_to_HEX: |
|
- | 48 | xor ebx,ebx |
|
- | 49 | cld |
|
- | 50 | lodsd |
|
- | 51 | mov ecx,4 |
|
- | 52 | ;-------------------------------------- |
|
- | 53 | align 4 |
|
- | 54 | .loop: |
|
- | 55 | cmp al,0x60 ; check for ABCDEF |
|
- | 56 | ja @f |
|
- | 57 | sub al,0x30 ; 0-9 |
|
- | 58 | jmp .store |
|
- | 59 | ;-------------------------------------- |
|
- | 60 | align 4 |
|
- | 61 | @@: |
|
- | 62 | sub al,0x57 ; A-F |
|
- | 63 | ;-------------------------------------- |
|
- | 64 | align 4 |
|
- | 65 | .store: |
|
- | 66 | and al,0xf |
|
- | 67 | rol ebx,4 |
|
- | 68 | add bl,al |
|
- | 69 | ror eax,8 |
|
- | 70 | dec ecx |
|
- | 71 | jnz .loop |
|
- | 72 | ||
- | 73 | ret |
|
42 | ;------------------------------------------------------------------------------ |
74 | ;------------------------------------------------------------------------------ |
43 | align 4 |
75 | align 4 |
- | 76 | START: ; start of execution |
|
- | 77 | mcall 68,11 |
|
- | 78 | ||
- | 79 | mov esi,bootparam |
|
- | 80 | cmp [esi],byte 0 |
|
- | 81 | je .no_boot_parameters |
|
- | 82 | ; boot params - hex |
|
- | 83 | ; db '9999' ; +0 Menu button X |
|
- | 84 | ; db '9999' ; +4 Menu button X size |
|
- | 85 | ; db '9999' ; +8 Menu button Y |
|
- | 86 | ; db '9999' ; +12 Menu button Y size |
|
- | 87 | ; db '9999' ; +16 Panel height |
|
- | 88 | ; db '1000' ; +20 Panel attachment |
|
- | 89 | ||
- | 90 | ; mov edx,bootparam |
|
- | 91 | ; call debug_outstr |
|
- | 92 | ; newline |
|
- | 93 | ||
- | 94 | call conversion_ASCII_to_HEX |
|
- | 95 | mov [menu_button_x.start],ebx |
|
- | 96 | ||
- | 97 | ; dps "menu_button_x.start: " |
|
- | 98 | ; dpd ebx |
|
- | 99 | ; newline |
|
- | 100 | ||
- | 101 | call conversion_ASCII_to_HEX |
|
- | 102 | mov [menu_button_x.size],ebx |
|
- | 103 | ||
- | 104 | ; dps "menu_button_x.size: " |
|
- | 105 | ; dpd ebx |
|
- | 106 | ; newline |
|
- | 107 | ||
- | 108 | call conversion_ASCII_to_HEX |
|
- | 109 | mov [menu_button_y.start],ebx |
|
- | 110 | ||
- | 111 | ; dps "menu_button_y.start: " |
|
- | 112 | ; dpd ebx |
|
- | 113 | ; newline |
|
- | 114 | ||
- | 115 | call conversion_ASCII_to_HEX |
|
- | 116 | mov [menu_button_y.size],ebx |
|
- | 117 | ||
- | 118 | ; dps "menu_button_y.size: " |
|
- | 119 | ; dpd ebx |
|
- | 120 | ; newline |
|
- | 121 | ||
- | 122 | call conversion_ASCII_to_HEX |
|
- | 123 | mov [panel_height],ebx |
|
- | 124 | ||
- | 125 | ; dps "panel_height: " |
|
- | 126 | ; dpd ebx |
|
- | 127 | ; newline |
|
- | 128 | ||
- | 129 | call conversion_ASCII_to_HEX |
|
- | 130 | mov [panel_attachment],ebx |
|
- | 131 | ||
- | 132 | ; dps "panel_attachment: " |
|
- | 133 | ; dpd ebx |
|
- | 134 | ; newline |
|
- | 135 | ;-------------------------------------- |
|
44 | START: ; start of execution |
136 | align 4 |
45 | mcall 68,11 |
137 | .no_boot_parameters: |
46 | call program_exist |
138 | call program_exist |
Line 47... | Line 139... | ||
47 | mcall 14 |
139 | mcall 14 |
Line 130... | Line 222... | ||
130 | jmp newprocess |
222 | jmp newprocess |
131 | ;-------------------------------------- |
223 | ;-------------------------------------- |
132 | align 4 |
224 | align 4 |
133 | search_end1: |
225 | search_end1: |
134 | mcall 14 |
226 | mcall 14 |
- | 227 | cmp [panel_attachment],byte 1 |
|
- | 228 | je @f |
|
135 | sub ax,20 |
229 | xor ax,ax |
- | 230 | jmp .store |
|
- | 231 | ;-------------------------------------- |
|
- | 232 | align 4 |
|
- | 233 | @@: |
|
- | 234 | sub ax,[panel_height] ;20 |
|
- | 235 | .store: |
|
136 | mov ebx,[menu_data] |
236 | mov ebx,[menu_data] |
137 | mov [ebx + y_end],ax |
237 | mov [ebx + y_end],ax |
138 | mov [ebx + x_start],5 |
238 | mov [ebx + x_start],5 |
139 | mov al,[ebx + rows] |
239 | mov al,[ebx + rows] |
140 | mov [ebx + cur_sel],al ; clear selection |
240 | mov [ebx + cur_sel],al ; clear selection |
Line 416... | Line 516... | ||
416 | click: |
516 | click: |
417 | cmp [mousemask],0 ; not in a window (i.e. menu) |
517 | cmp [mousemask],0 ; not in a window (i.e. menu) |
418 | jne still |
518 | jne still |
419 | ; checking for pressing 'MENU' on the taskbar |
519 | ; checking for pressing 'MENU' on the taskbar |
420 | mov eax,[screen_mouse_position] |
520 | mov eax,[screen_mouse_position] |
- | 521 | ||
- | 522 | cmp [panel_attachment],byte 1 |
|
- | 523 | je @f |
|
- | 524 | ||
- | 525 | xor ebx,ebx |
|
- | 526 | jmp .check_y |
|
- | 527 | ;-------------------------------------- |
|
- | 528 | align 4 |
|
- | 529 | @@: |
|
421 | mov ebx,[screen_size] |
530 | mov ebx,[screen_size] |
422 | sub bx,PANEL_HEIGHT |
531 | sub bx,word [panel_height] ;PANEL_HEIGHT |
- | 532 | ;-------------------------------------- |
|
- | 533 | align 4 |
|
- | 534 | .check_y: |
|
- | 535 | add bx,word [menu_button_y.start] |
|
423 | cmp bx,ax |
536 | cmp bx,ax |
424 | ja close |
537 | ja close |
- | 538 | ||
- | 539 | add bx,word [menu_button_y.size] |
|
- | 540 | cmp bx,ax |
|
- | 541 | jb close |
|
- | 542 | ||
425 | shr eax,16 |
543 | shr eax,16 |
- | 544 | ||
- | 545 | mov ebx,[menu_button_x.start] |
|
426 | cmp ax,MENU_BOTTON_X_SIZE |
546 | cmp bx,ax ; MENU_BOTTON_X_SIZE |
427 | ja close |
547 | ja close |
- | 548 | ||
- | 549 | add bx,[menu_button_x.size] |
|
428 | cmp ax,MENU_BOTTON_X_POS |
550 | cmp bx,ax ; MENU_BOTTON_X_POS |
429 | ja still |
551 | ja still |
430 | ;------------------------------------------------------------------------------ |
552 | ;------------------------------------------------------------------------------ |
431 | align 4 |
553 | align 4 |
432 | close: |
554 | close: |
Line 576... | Line 698... | ||
576 | ; ********************************************* |
698 | ; ********************************************* |
577 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
699 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
578 | ; ********************************************* |
700 | ; ********************************************* |
579 | align 4 |
701 | align 4 |
580 | draw_window: |
702 | draw_window: |
- | 703 | mcall 48,5 |
|
- | 704 | mov [x_working_area],eax |
|
- | 705 | mov [y_working_area],ebx |
|
- | 706 | ||
581 | mcall 12,1 ; 1,start of draw |
707 | mcall 12,1 ; 1,start of draw |
582 | movzx ebx,[edi + rows] |
708 | movzx ebx,[edi + rows] |
583 | imul eax,ebx,BTN_HEIGHT ; eax = height of window |
709 | imul eax,ebx,BTN_HEIGHT ; eax = height of window |
584 | movzx ecx,[edi + y_end] |
710 | movzx ecx,[edi + y_end] |
- | 711 | cmp [panel_attachment],byte 1 |
|
- | 712 | je @f |
|
- | 713 | ; add ecx,eax |
|
- | 714 | ; sub ecx,BTN_HEIGHT |
|
- | 715 | jmp .1 |
|
- | 716 | ;-------------------------------------- |
|
- | 717 | align 4 |
|
- | 718 | @@: |
|
585 | sub ecx,eax ; ecx = Y_START |
719 | sub ecx,eax ; ecx = Y_START |
- | 720 | ;-------------------------------------- |
|
- | 721 | align 4 |
|
- | 722 | .1: |
|
586 | shl ecx,16 |
723 | shl ecx,16 |
587 | add ecx,eax ; ecx = [ Y_START | Y_SIZE ] |
724 | add ecx,eax ; ecx = [ Y_START | Y_SIZE ] |
588 | dec ecx |
725 | dec ecx |
- | 726 | ||
589 | movzx ebx,[edi + x_start] |
727 | movzx ebx,[edi + x_start] |
590 | shl ebx,16 |
728 | shl ebx,16 |
591 | mov bx,140 ; ebx = [ X_START | X_SIZE ] |
729 | mov bx,140 ; ebx = [ X_START | X_SIZE ] |
592 | mov edx,0x01000000 ; color of work area RRGGBB,8->color gl |
730 | mov edx,0x01000000 ; color of work area RRGGBB,8->color gl |
593 | mov esi,edx ; unmovable window |
731 | mov esi,edx ; unmovable window |
- | 732 | ||
- | 733 | mov eax,[y_working_area] |
|
- | 734 | shr eax,16 |
|
- | 735 | ror ecx,16 |
|
- | 736 | test cx,0x8000 |
|
- | 737 | jz @f |
|
- | 738 | mov cx,ax |
|
- | 739 | ;-------------------------------------- |
|
- | 740 | align 4 |
|
- | 741 | @@: |
|
- | 742 | cmp cx,ax |
|
- | 743 | ja @f |
|
- | 744 | mov cx,ax |
|
- | 745 | ;-------------------------------------- |
|
- | 746 | align 4 |
|
- | 747 | @@: |
|
- | 748 | rol ecx,16 |
|
594 | xor eax,eax ; function 0 : define and draw window |
749 | xor eax,eax ; function 0 : define and draw window |
595 | mcall |
750 | mcall |
Line -... | Line 751... | ||
- | 751 | ||
- | 752 | ; dps "[ Y_START | Y_SIZE ] : " |
|
- | 753 | ; dph ecx |
|
- | 754 | ; newline |
|
- | 755 | ||
- | 756 | ; dps "[ X_START | X_SIZE ] : " |
|
- | 757 | ; dph ebx |
|
- | 758 | ; newline |
|
596 | 759 | ||
597 | call draw_all_buttons |
760 | call draw_all_buttons |
598 | mcall 12,2 |
761 | mcall 12,2 |
599 | ret |
762 | ret |
600 | ;------------------------------------------------------------------------------ |
763 | ;------------------------------------------------------------------------------ |
Line 697... | Line 860... | ||
697 | free_my_area_lock dd 0 |
860 | free_my_area_lock dd 0 |
698 | free_my_area dd 0 |
861 | free_my_area dd 0 |
Line 699... | Line 862... | ||
699 | 862 | ||
700 | processes dd 0 |
863 | processes dd 0 |
- | 864 | ;-------------------------------------- |
|
- | 865 | menu_button_x: |
|
- | 866 | .start: dd MENU_BOTTON_X_POS |
|
- | 867 | .size: dd MENU_BOTTON_X_SIZE |
|
- | 868 | ;-------------------------------------- |
|
- | 869 | menu_button_y: |
|
- | 870 | .start: dd 2 |
|
- | 871 | .size: dd 18 |
|
- | 872 | ;-------------------------------------- |
|
- | 873 | panel_height: dd PANEL_HEIGHT |
|
- | 874 | panel_attachment: dd 1 |
|
701 | ;-------------------------------------- |
875 | ;-------------------------------------- |
702 | align 4 |
876 | align 4 |
703 | fileinfo: |
877 | fileinfo: |
704 | .subfunction dd 5 ; 5 - file info; 0 - file read |
878 | .subfunction dd 5 ; 5 - file info; 0 - file read |
705 | .start dd 0 ; start byte |
879 | .start dd 0 ; start byte |
Line 736... | Line 910... | ||
736 | ;-------------------------------------- |
910 | ;-------------------------------------- |
737 | screen_size: |
911 | screen_size: |
738 | .y dw ? |
912 | .y dw ? |
739 | .x dw ? |
913 | .x dw ? |
740 | ;-------------------------------------- |
914 | ;-------------------------------------- |
- | 915 | x_working_area: |
|
- | 916 | .right: dw ? |
|
- | 917 | .left: dw ? |
|
- | 918 | y_working_area: |
|
- | 919 | .bottom: dw ? |
|
- | 920 | .top: dw ? |
|
- | 921 | ;-------------------------------------- |
|
741 | sc system_colors |
922 | sc system_colors |
742 | ;-------------------------------------- |
923 | ;-------------------------------------- |
743 | last_key db ? |
924 | last_key db ? |
744 | ;------------------------------------------------------------------------------ |
925 | ;------------------------------------------------------------------------------ |
745 | align 4 |
926 | align 4 |
Line 756... | Line 937... | ||
756 | prev_sel db ? ; +12 previous selection |
937 | prev_sel db ? ; +12 previous selection |
757 | rb 16-$+1 ; [16 bytes per element] |
938 | rb 16-$+1 ; [16 bytes per element] |
758 | end virtual |
939 | end virtual |
759 | ;------------------------------------------------------------------------------ |
940 | ;------------------------------------------------------------------------------ |
760 | align 4 |
941 | align 4 |
- | 942 | bootparam: |
|
761 | procinfo: |
943 | procinfo: |
762 | rb 1024 |
944 | rb 1024 |
763 | ;------------------------------------------------------------------------------ |
945 | ;------------------------------------------------------------------------------ |
764 | align 4 |
946 | align 4 |
765 | rb 0x1000 |
947 | rb 0x1000 |