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