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