Rev 8762 | Rev 9435 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8762 | Rev 9433 | ||
---|---|---|---|
Line 19... | Line 19... | ||
19 | ; Some parts of code rewritten by Ivan Poddubny |
19 | ; Some parts of code rewritten by Ivan Poddubny |
20 | ; |
20 | ; |
21 | ; Compile with FASM for Kolibri |
21 | ; Compile with FASM for Kolibri |
22 | ;****************************************************************************** |
22 | ;****************************************************************************** |
23 | BTN_HEIGHT = 26 |
23 | BTN_HEIGHT = 26 |
24 | BTN_WIDTH = 178 |
24 | BTN_WIDTH = 198 ; was 178 |
25 | TXT_Y = (BTN_HEIGHT)/2-7 |
25 | TXT_Y = (BTN_HEIGHT)/2-7 |
26 | FONT_TYPE = 0x90000000 |
26 | FONT_TYPE = 0x90000000 |
Line 27... | Line 27... | ||
27 | 27 | ||
28 | PANEL_HEIGHT = 20 |
28 | PANEL_HEIGHT = 20 |
Line 41... | Line 41... | ||
41 | dd bootparam ; boot parameters |
41 | dd bootparam ; boot parameters |
42 | dd 0x0 ; path |
42 | dd 0x0 ; path |
43 | ;------------------------------------------------------------------------------ |
43 | ;------------------------------------------------------------------------------ |
44 | include "..\..\..\macros.inc" |
44 | include "..\..\..\macros.inc" |
45 | include "..\..\..\gui_patterns.inc" |
45 | include "..\..\..\gui_patterns.inc" |
- | 46 | ; Formatted debug output: |
|
46 | ;include "../../../debug.inc" ; debug macros |
47 | include "..\..\..\debug-fdo.inc" |
- | 48 | __DEBUG__ = 1 ; 0 - disable debug output / 1 - enable debug output |
|
- | 49 | __DEBUG_LEVEL__ = DBG_ERR ; set the debug level |
|
- | 50 | DBG_ALL = 0 ; all messages |
|
- | 51 | DBG_INFO = 1 ; info and errors |
|
- | 52 | DBG_ERR = 2 ; only errors |
|
47 | ;------------------------------------------------------------------------------ |
53 | ;------------------------------------------------------------------------------ |
48 | align 4 |
54 | align 4 |
49 | conversion_ASCII_to_HEX: |
55 | conversion_ASCII_to_HEX: |
50 | xor ebx,ebx |
56 | xor ebx,ebx |
51 | cld |
57 | cld |
Line 78... | Line 84... | ||
78 | START: ; start of execution |
84 | START: ; start of execution |
79 | mcall 68,11 |
85 | mcall 68,11 |
Line 80... | Line 86... | ||
80 | 86 | ||
Line -... | Line 87... | ||
- | 87 | mcall 30, 1, default_dir |
|
- | 88 | ||
81 | mcall 30, 1, default_dir |
89 | ; DEBUGF DBG_INFO, "MENU START! sc.work = %x\n", [sc.work] |
82 | 90 | ||
83 | mov esi,bootparam |
91 | mov esi,bootparam |
84 | cmp [esi],byte 0 |
92 | cmp [esi],byte 0 |
85 | je .no_boot_parameters |
93 | je .no_boot_parameters |
Line 143... | Line 151... | ||
143 | mcall 14 |
151 | mcall 14 |
144 | mov [screen_size],eax |
152 | mov [screen_size],eax |
Line 145... | Line 153... | ||
145 | 153 | ||
Line -... | Line 154... | ||
- | 154 | mcall 48,3,sc,sizeof.system_colors ; load system colors |
|
- | 155 | ||
- | 156 | ; DEBUGF DBG_INFO, "sc.work = %x\n", [sc.work] |
|
- | 157 | ||
- | 158 | mov eax, 68 |
|
- | 159 | mov ebx, 22 |
|
- | 160 | mov ecx, icons_resname |
|
- | 161 | mov esi, 0 ; SHM_READ |
|
- | 162 | mcall |
|
- | 163 | test eax, eax |
|
- | 164 | jnz @f |
|
- | 165 | mov [no_shared_resources], 1 |
|
- | 166 | DEBUGF DBG_ERR, "Failed to get ICONS18W from @RESHARE.\nTry rerun @RESHARE.\n" |
|
- | 167 | jmp .no_res |
|
- | 168 | @@: |
|
- | 169 | mov [shared_icons_ptr], eax |
|
- | 170 | mov [shared_icons_size], edx |
|
- | 171 | ; copy shared icons to active icons |
|
- | 172 | mov esi, eax |
|
- | 173 | mov ecx, edx |
|
- | 174 | mcall 68, 12, edx |
|
- | 175 | mov edi, eax |
|
- | 176 | mov [shared_icons_active_ptr], eax |
|
- | 177 | shr ecx, 2 ; /= 4; ecx = how many dwords in shared icons |
|
- | 178 | cld |
|
- | 179 | rep movsd |
|
- | 180 | ; change work color to work_light color |
|
- | 181 | mov esi, [shared_icons_active_ptr] |
|
- | 182 | xor ecx, ecx |
|
- | 183 | .for1: |
|
- | 184 | cmp ecx, [shared_icons_size] |
|
- | 185 | jae .end_for1 |
|
- | 186 | ||
- | 187 | mov eax, esi |
|
- | 188 | add eax, ecx |
|
- | 189 | mov edx, [eax] |
|
- | 190 | cmp edx, [sc.work] |
|
- | 191 | ; DEBUGF DBG_INFO, "eax = %x, sc.work = %x\n", eax, [sc.work] |
|
- | 192 | jne @f |
|
- | 193 | mov ebx, [sc.work] ;[sc.work_light] |
|
- | 194 | add ebx, 0x1a1a1a ;; |
|
- | 195 | mov [eax], ebx |
|
- | 196 | @@: |
|
- | 197 | add ecx, 4 |
|
- | 198 | jmp .for1 |
|
- | 199 | .end_for1: |
|
146 | mcall 48,3,sc,sizeof.system_colors ; load system colors |
200 | .no_res: |
147 | 201 | ||
148 | ; get size of file MENU.DAT |
202 | ; get size of file MENU.DAT |
149 | mcall 70,fileinfo |
203 | mcall 70,fileinfo |
150 | test eax,eax |
204 | test eax,eax |
Line 166... | Line 220... | ||
166 | jz close |
220 | jz close |
167 | mov ecx,ebx |
221 | mov ecx,ebx |
168 | mov edi,[fileinfo.return] ;mem_end |
222 | mov edi,[fileinfo.return] ;mem_end |
169 | ;-------------------------------------- |
223 | ;-------------------------------------- |
170 | align 4 |
224 | align 4 |
171 | newsearch: |
225 | newsearch: ; search for next submenu in MENU.DAT |
172 | mov al,'#' |
226 | mov al,'#' |
173 | cld |
227 | cld |
174 | repne scasb |
228 | repne scasb |
175 | test ecx,ecx ; if not found |
229 | test ecx,ecx ; if not found |
176 | jz close |
230 | jz close |
177 | call get_number |
231 | call get_number ; get submenu number from char at edi position to ebx |
178 | test ebx,ebx |
232 | test ebx,ebx |
179 | jnz .number |
233 | jnz .number |
180 | cmp al,'#' |
234 | cmp al,'#' |
181 | je search_end |
235 | je search_end |
182 | ;-------------------------------------- |
236 | ;-------------------------------------- |
183 | align 4 |
237 | align 4 |
184 | .number: |
238 | .number: |
185 | shl ebx,4 |
239 | shl ebx,4 ; *= 16 . 16 is size of process table (see virtual at 0 ... stuff in the end of file) |
186 | add ebx,[menu_data] ; pointer to process table |
240 | add ebx,[menu_data] ; pointer to process table |
187 | mov [ebx],edi |
241 | mov [ebx],edi ; process_table->pointer = edi |
188 | inc [processes] |
242 | inc [processes] |
189 | jmp newsearch |
243 | jmp newsearch |
190 | ;-------------------------------------- |
244 | ;-------------------------------------- |
191 | align 4 |
245 | align 4 |
192 | search_end: |
246 | search_end: |
Line 244... | Line 298... | ||
244 | mov [ebx + cur_sel],al ; clear selection |
298 | mov [ebx + cur_sel],al ; clear selection |
245 | mov [ebx + prev_sel],al |
299 | mov [ebx + prev_sel],al |
246 | mov [buffer],0 |
300 | mov [buffer],0 |
247 | ;------------------------------------------------------------------------------ |
301 | ;------------------------------------------------------------------------------ |
248 | align 4 |
302 | align 4 |
- | 303 | thread: ; starts new thread. called when opening each menu |
|
249 | thread: |
304 | DEBUGF DBG_INFO, "start new THREAD\n" |
250 | mov ebp,esp |
305 | mov ebp,esp |
251 | sub ebp,0x1000 |
306 | sub ebp,0x1000 |
252 | cmp ebp,0x2000 ; if this is first started thread |
307 | cmp ebp,0x2000 ; if this is first started thread |
253 | ja @f |
308 | ja @f |
254 | xor ebp,ebp ; not free area |
309 | xor ebp,ebp ; not free area |
Line 264... | Line 319... | ||
264 | align 4 |
319 | align 4 |
265 | red: |
320 | red: |
266 | call draw_window ; redraw |
321 | call draw_window ; redraw |
267 | ;------------------------------------------------------------------------------ |
322 | ;------------------------------------------------------------------------------ |
268 | align 4 |
323 | align 4 |
269 | still: |
324 | still: ; event loop |
270 | call free_area_if_set_mutex |
325 | call free_area_if_set_mutex |
Line 271... | Line 326... | ||
271 | 326 | ||
272 | mcall 23,5 ; wait here for event |
327 | mcall 23,5 ; wait here for event |
273 | test [close_now],1 ; is close flag set? |
328 | test [close_now],1 ; is close flag set? |
Line 368... | Line 423... | ||
368 | pushad |
423 | pushad |
369 | mov edi,esi |
424 | mov edi,esi |
370 | ; dph eax |
425 | ; dph eax |
371 | call draw_only_needed_buttons |
426 | call draw_only_needed_buttons |
372 | popad |
427 | popad |
373 | ; look for the next line |
428 | ; look (.next_string) for the next line in MENU.DAT |
374 | push eax |
429 | push eax |
375 | ;-------------------------------------- |
430 | ;-------------------------------------- |
376 | align 4 |
431 | align 4 |
377 | .next_string: |
432 | .next_string: |
- | 433 | ; DEBUGF DBG_INFO, ".next_string called\n" |
|
378 | call searchstartstring |
434 | call searchstartstring |
379 | dec ah |
435 | dec ah |
380 | jnz .next_string |
436 | jnz .next_string |
381 | pop eax |
437 | pop eax |
Line 713... | Line 769... | ||
713 | ; ********************************************* |
769 | ; ********************************************* |
714 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
770 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
715 | ; ********************************************* |
771 | ; ********************************************* |
716 | align 4 |
772 | align 4 |
717 | draw_window: |
773 | draw_window: |
718 | mcall 48,5 |
774 | mcall 48,5 ; get working area |
719 | mov [x_working_area],eax |
775 | mov [x_working_area],eax |
720 | mov [y_working_area],ebx |
776 | mov [y_working_area],ebx |
Line 721... | Line 777... | ||
721 | 777 | ||
722 | mcall 12,1 ; 1,start of draw |
778 | mcall 12,1 ; 1,start of draw |
Line 840... | Line 896... | ||
840 | sub esi,0x1b1b1b |
896 | sub esi,0x1b1b1b |
Line 841... | Line 897... | ||
841 | 897 | ||
842 | ;-------------------------------------- |
898 | ;-------------------------------------- |
843 | align 4 |
899 | align 4 |
- | 900 | nocorrect: |
|
844 | nocorrect: |
901 | mov [is_icon_active], 0 |
845 | inc dl |
902 | inc dl |
846 | cmp [edi + cur_sel],dl |
903 | cmp [edi + cur_sel],dl |
- | 904 | jne .nohighlight |
|
847 | jne .nohighlight |
905 | mov [is_icon_active], 1 |
848 | cmp esi,0 |
906 | cmp esi,0 |
849 | jne @f |
907 | jne @f |
850 | mov esi,0x2a2a2a |
908 | mov esi,0x2a2a2a |
851 | @@: |
909 | @@: |
Line 860... | Line 918... | ||
860 | ; dunkaist] |
918 | ; dunkaist] |
861 | mcall |
919 | mcall |
862 | push edx |
920 | push edx |
Line 863... | Line 921... | ||
863 | 921 | ||
864 | mov edx, esi |
922 | mov edx, esi |
Line 865... | Line 923... | ||
865 | mcall 13 |
923 | mcall 13 ; draw rect |
866 | 924 | ||
867 | mcall , BTN_WIDTH,<[draw_y],1>,[sc.work_light] |
925 | mcall , BTN_WIDTH,<[draw_y],1>,[sc.work_light] |
868 | add ecx, BTN_HEIGHT-1 |
926 | add ecx, BTN_HEIGHT-1 |
Line 874... | Line 932... | ||
874 | 932 | ||
875 | pop edx |
933 | pop edx |
876 | movzx edx,dl |
934 | movzx edx,dl |
877 | dec dl |
935 | dec dl |
878 | imul ebx,edx,BTN_HEIGHT |
936 | imul ebx,edx,BTN_HEIGHT |
879 | add ebx,(4 shl 16) + TXT_Y |
937 | add ebx,((4 + 18) shl 16) + TXT_Y ; added + 18 (icon size) |
880 | movzx ecx,dl |
938 | movzx ecx,dl |
881 | inc ecx |
939 | inc ecx |
882 | mov edx,[edi + pointer] |
940 | mov edx,[edi + pointer] |
883 | ;-------------------------------------- |
941 | ;-------------------------------------- |
884 | align 4 |
942 | align 4 |
885 | .findline: |
943 | .findline: |
886 | cmp byte [edx],13 |
944 | cmp byte [edx],13 ; if \r encountered => line found |
887 | je .linefound |
945 | je .linefound |
888 | inc edx |
946 | inc edx ; go to next char |
889 | jmp .findline |
947 | jmp .findline |
890 | ;------------------------------------------------------------------------------ |
948 | ;------------------------------------------------------------------------------ |
891 | align 4 |
949 | align 4 |
892 | .linefound: |
950 | .linefound: |
893 | inc edx |
951 | inc edx ; go to next char after \r |
894 | cmp byte [edx],10 |
952 | cmp byte [edx],10 ; if it is not \n then again findline |
895 | jne .findline |
953 | jne .findline |
896 | dec ecx |
954 | dec ecx ; TODO what in ecx? button number? |
Line 897... | Line 955... | ||
897 | jnz .findline |
955 | jnz .findline |
898 | 956 | ||
- | 957 | mov ecx, [sc.work_text] |
|
- | 958 | add ecx, FONT_TYPE |
|
- | 959 | ||
- | 960 | push ecx esi edi ebp |
|
- | 961 | push ebx ; preserve ebx, it stores coordinates |
|
- | 962 | mov [tmp], edx |
|
- | 963 | mov [has_icon], 1 |
|
- | 964 | xor ebx, ebx |
|
- | 965 | @@: ; parse icon number |
|
- | 966 | inc edx |
|
- | 967 | mov al,[edx] |
|
- | 968 | ; DEBUGF DBG_INFO, "(%u)\n", al |
|
- | 969 | cmp al, '0' |
|
- | 970 | jb @f |
|
- | 971 | cmp al, '9' |
|
899 | mov ecx, [sc.work_text] |
972 | ja @f |
- | 973 | sub al, '0' |
|
- | 974 | imul ebx,10 |
|
- | 975 | add ebx,eax |
|
- | 976 | jmp @b |
|
- | 977 | @@: |
|
- | 978 | ; DEBUGF DBG_INFO, "icon_number = %x al = %u\n", ebx, al |
|
- | 979 | mov [icon_number], ebx |
|
- | 980 | cmp al, ' ' |
|
- | 981 | je @f |
|
- | 982 | ; if no space after number then consider that number is a part of caption |
|
- | 983 | mov edx, [tmp] ; restore edx |
|
- | 984 | mov [has_icon], 0 ; no icon |
|
- | 985 | @@: |
|
- | 986 | pop ebx |
|
- | 987 | ||
- | 988 | mcall 4,,,,21 ; draw menu element caption |
|
- | 989 | ||
- | 990 | cmp [no_shared_resources], 1 |
|
- | 991 | je @f |
|
- | 992 | cmp [has_icon], 1 |
|
- | 993 | jne @f |
|
- | 994 | ; draw icon: |
|
- | 995 | mov eax, ebx |
|
- | 996 | shr eax, 16 |
|
- | 997 | sub eax, 18 ; 18 - icon width |
|
- | 998 | movzx ebx, bx |
|
- | 999 | ||
- | 1000 | sub ebx, 2 |
|
- | 1001 | shl eax, 16 |
|
- | 1002 | add eax, ebx |
|
- | 1003 | mov [tmp], eax |
|
- | 1004 | mov ebx, [icon_number] |
|
- | 1005 | imul ebx, 18*18*4 |
|
- | 1006 | ||
- | 1007 | mov ecx, [shared_icons_ptr] |
|
- | 1008 | ; DEBUGF DBG_INFO, "is_icon_active = %x\n", [is_icon_active] |
|
- | 1009 | cmp [is_icon_active], 1 |
|
- | 1010 | jne .not_active_icon |
|
- | 1011 | mov ecx, [shared_icons_active_ptr] |
|
- | 1012 | .not_active_icon: |
|
- | 1013 | add ebx, ecx |
|
- | 1014 | mcall 65, ebx, (18 shl 16) + 18, [tmp], 32, 0, 0 |
|
- | 1015 | ||
- | 1016 | pop ebp edi esi ecx |
|
900 | add ecx, FONT_TYPE |
1017 | |
901 | mcall 4,,,,21 |
1018 | @@: |
902 | pop edx |
1019 | pop edx |
903 | ret |
1020 | ret |
904 | ;------------------------------------------------------------------------------ |
1021 | ;------------------------------------------------------------------------------ |
Line 1000... | Line 1117... | ||
1000 | parent db ? ; +10 id of parent menu |
1117 | parent db ? ; +10 id of parent menu |
1001 | cur_sel db ? ; +11 current selection |
1118 | cur_sel db ? ; +11 current selection |
1002 | prev_sel db ? ; +12 previous selection |
1119 | prev_sel db ? ; +12 previous selection |
1003 | rb 16-$+1 ; [16 bytes per element] |
1120 | rb 16-$+1 ; [16 bytes per element] |
1004 | end virtual |
1121 | end virtual |
- | 1122 | ||
- | 1123 | include_debug_strings ; for debug-fdo |
|
- | 1124 | ||
- | 1125 | icons_resname db 'ICONS18W', 0 |
|
- | 1126 | shared_icons_ptr dd ? |
|
- | 1127 | shared_icons_active_ptr dd ? |
|
- | 1128 | shared_icons_size dd ? |
|
- | 1129 | has_icon db ? |
|
- | 1130 | icon_number dd ? |
|
- | 1131 | is_icon_active dd ? |
|
- | 1132 | no_shared_resources dd 0 |
|
- | 1133 | tmp dd ? |
|
1005 | ;------------------------------------------------------------------------------ |
1134 | ;------------------------------------------------------------------------------ |
1006 | align 4 |
1135 | align 4 |
1007 | bootparam: |
1136 | bootparam: |
1008 | procinfo: |
1137 | procinfo: |
1009 | rb 1024 |
1138 | rb 1024 |