Menu - Global optimization! The program uses only 32 KB of memory instead of 128 kb is now.
git-svn-id: svn://kolibrios.org@2488 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a40a904d62
commit
a8e40b5de4
@ -1,11 +1,16 @@
|
|||||||
;******************************************************************************
|
;******************************************************************************
|
||||||
; MAIN MENU
|
; MAIN MENU
|
||||||
;******************************************************************************
|
;******************************************************************************
|
||||||
|
; last update: 22/03/2012
|
||||||
|
; changed by: Marat Zakiyanov aka Mario79, aka Mario
|
||||||
|
; changes: Global optimization! The program uses
|
||||||
|
; only 32 KB of memory instead of 128 kb is now.
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
; last update: 19/09/2011
|
; last update: 19/09/2011
|
||||||
; changed by: Marat Zakiyanov aka Mario79, aka Mario
|
; changed by: Marat Zakiyanov aka Mario79, aka Mario
|
||||||
; changes: Checking for program exist to memory
|
; changes: Checking for program exist to memory
|
||||||
; Added processing of keys: left and right arrow
|
; Added processing of keys: left and right arrow
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; MAIN MENU by lisovin@26.ru
|
; MAIN MENU by lisovin@26.ru
|
||||||
; Some parts of code rewritten by Ivan Poddubny <ivan-yar@bk.ru>
|
; Some parts of code rewritten by Ivan Poddubny <ivan-yar@bk.ru>
|
||||||
;
|
;
|
||||||
@ -20,34 +25,53 @@
|
|||||||
PANEL_HEIGHT = 20
|
PANEL_HEIGHT = 20
|
||||||
MENU_BOTTON_X_POS = 10
|
MENU_BOTTON_X_POS = 10
|
||||||
MENU_BOTTON_X_SIZE = 60
|
MENU_BOTTON_X_SIZE = 60
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
use32
|
use32
|
||||||
org 0x0
|
org 0x0
|
||||||
|
|
||||||
db 'MENUET01' ; 8 byte id
|
db 'MENUET01' ; 8 byte id
|
||||||
dd 0x01 ; header version
|
dd 0x01 ; header version
|
||||||
dd START ; start of code
|
dd START ; start of code
|
||||||
dd I_END ; size of image
|
dd IM_END ; size of image
|
||||||
dd 0x20000 ; memory for app
|
dd mem_end ; memory for app
|
||||||
dd 0x20000 ; esp
|
dd stack_area ; esp
|
||||||
dd 0x0,0x0 ; I_Param , I_Icon
|
dd 0x0 ; boot parameters
|
||||||
;******************************************************************************
|
dd 0x0 ; path
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
;include "DEBUG.INC" ; debug macros
|
;include "DEBUG.INC" ; debug macros
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
START: ; start of execution
|
START: ; start of execution
|
||||||
|
mcall 68,11
|
||||||
call program_exist
|
call program_exist
|
||||||
mcall 14
|
mcall 14
|
||||||
mov [screen_size],eax
|
mov [screen_size],eax
|
||||||
|
|
||||||
mcall 48,3,sc,sizeof.system_colors ; load system colors
|
mcall 48,3,sc,sizeof.system_colors ; load system colors
|
||||||
mcall 70,fileinfo ; load MENU.DAT
|
|
||||||
test eax,eax ; error ?
|
; get size of file MENU.DAT
|
||||||
jz @f
|
mcall 70,fileinfo
|
||||||
cmp eax,6
|
test eax,eax
|
||||||
jnz close
|
jnz close
|
||||||
@@:
|
; get memory for MENU.DAT
|
||||||
|
mov ecx,[procinfo+32]
|
||||||
|
mov [fileinfo.size],ecx
|
||||||
|
mcall 68,12
|
||||||
|
mov [fileinfo.return],eax
|
||||||
|
mcall 68
|
||||||
|
mov [menu_data],eax
|
||||||
|
; load MENU.DAT
|
||||||
|
mov [fileinfo],dword 0
|
||||||
|
mcall 70,fileinfo
|
||||||
|
test eax,eax
|
||||||
|
jnz close
|
||||||
|
|
||||||
test ebx,ebx ; length = 0 ?
|
test ebx,ebx ; length = 0 ?
|
||||||
jz close
|
jz close
|
||||||
mov ecx,ebx
|
mov ecx,ebx
|
||||||
mov edi,mem_end
|
mov edi,[fileinfo.return] ;mem_end
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
newsearch:
|
newsearch:
|
||||||
mov al,'#'
|
mov al,'#'
|
||||||
cld
|
cld
|
||||||
@ -59,24 +83,31 @@ newsearch:
|
|||||||
jnz .number
|
jnz .number
|
||||||
cmp al,'#'
|
cmp al,'#'
|
||||||
je search_end
|
je search_end
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
.number:
|
.number:
|
||||||
shl ebx,4
|
shl ebx,4
|
||||||
add ebx,menu_data ; pointer to process table
|
add ebx,[menu_data] ; pointer to process table
|
||||||
mov [ebx],edi
|
mov [ebx],edi
|
||||||
inc [processes]
|
inc [processes]
|
||||||
jmp newsearch
|
jmp newsearch
|
||||||
;---------------------------------------------------------------------
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
search_end:
|
search_end:
|
||||||
mov [end_pointer],edi
|
mov [end_pointer],edi
|
||||||
mov ebx,[processes]
|
mov ebx,[processes]
|
||||||
dec ebx
|
dec ebx
|
||||||
shl ebx,4
|
shl ebx,4
|
||||||
add ebx,menu_data
|
add ebx,[menu_data]
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
newprocess:
|
newprocess:
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
mov ecx,edi
|
mov ecx,edi
|
||||||
sub ecx,[ebx]
|
sub ecx,[ebx]
|
||||||
mov al,10
|
mov al,10
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
newsearch1:
|
newsearch1:
|
||||||
std
|
std
|
||||||
repne scasb
|
repne scasb
|
||||||
@ -86,35 +117,54 @@ newsearch1:
|
|||||||
jne newsearch1
|
jne newsearch1
|
||||||
inc edx
|
inc edx
|
||||||
jmp newsearch1
|
jmp newsearch1
|
||||||
;---------------------------------------------------------------------
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
endprocess:
|
endprocess:
|
||||||
mov esi,ebx
|
mov esi,ebx
|
||||||
add esi,4
|
add esi,4
|
||||||
dec edx
|
dec edx
|
||||||
mov [esi],dl
|
mov [esi],dl
|
||||||
cmp ebx,menu_data
|
cmp ebx,[menu_data]
|
||||||
jbe search_end1
|
jbe search_end1
|
||||||
sub ebx,16
|
sub ebx,16
|
||||||
jmp newprocess
|
jmp newprocess
|
||||||
;---------------------------------------------------------------------
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
search_end1:
|
search_end1:
|
||||||
mcall 14
|
mcall 14
|
||||||
sub ax,20
|
sub ax,20
|
||||||
mov [menu_data + y_end],ax
|
mov ebx,[menu_data]
|
||||||
mov [menu_data + x_start],5
|
mov [ebx + y_end],ax
|
||||||
mov al,[menu_data + rows]
|
mov [ebx + x_start],5
|
||||||
mov [menu_data + cur_sel],al ; clear selection
|
mov al,[ebx + rows]
|
||||||
mov [menu_data + prev_sel],al
|
mov [ebx + cur_sel],al ; clear selection
|
||||||
|
mov [ebx + prev_sel],al
|
||||||
mov [buffer],0
|
mov [buffer],0
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
thread:
|
thread:
|
||||||
|
mov ebp,esp
|
||||||
|
sub ebp,0x1000
|
||||||
|
cmp ebp,0x2000 ; if this is first started thread
|
||||||
|
ja @f
|
||||||
|
xor ebp,ebp ; not free area
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
|
@@:
|
||||||
mov eax,[buffer] ; identifier
|
mov eax,[buffer] ; identifier
|
||||||
shl eax,4
|
shl eax,4
|
||||||
add eax,menu_data
|
add eax,[menu_data]
|
||||||
mov edi,eax
|
mov edi,eax
|
||||||
mcall 40,100111b ; mouse + button + key + redraw
|
mcall 40,100111b ; mouse + button + key + redraw
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
red:
|
red:
|
||||||
call draw_window ; redraw
|
call draw_window ; redraw
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
still:
|
still:
|
||||||
|
call free_area_if_set_mutex
|
||||||
|
|
||||||
mcall 23,5 ; wait here for event
|
mcall 23,5 ; wait here for event
|
||||||
test [close_now],1 ; is close flag set?
|
test [close_now],1 ; is close flag set?
|
||||||
jnz close
|
jnz close
|
||||||
@ -127,21 +177,21 @@ still:
|
|||||||
je button
|
je button
|
||||||
cmp eax,6 ; mouse event ?
|
cmp eax,6 ; mouse event ?
|
||||||
je mouse
|
je mouse
|
||||||
cmp edi,menu_data
|
cmp edi,[menu_data]
|
||||||
je still ; if main process-ignored
|
je still ; if main process-ignored
|
||||||
|
|
||||||
movzx ebx,[edi + parent] ; parent id
|
movzx ebx,[edi + parent] ; parent id
|
||||||
shl ebx,4
|
shl ebx,4
|
||||||
add ebx,menu_data ; ebx = base of parent info
|
add ebx,[menu_data] ; ebx = base of parent info
|
||||||
call backconvert ; get my id in al
|
call backconvert ; get my id in al
|
||||||
cmp al,[ebx + child] ; if I'm not child of my parent, I shall die :)
|
cmp al,[ebx + child] ; if I'm not child of my parent, I shall die :)
|
||||||
jne close
|
jne close
|
||||||
|
|
||||||
jmp still
|
jmp still
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
key:
|
key:
|
||||||
; mov eax,2
|
mcall 2
|
||||||
mcall
|
|
||||||
mov [last_key],ah
|
mov [last_key],ah
|
||||||
mov al,[edi + rows] ; number of buttons
|
mov al,[edi + rows] ; number of buttons
|
||||||
cmp ah,178 ; KEY_UP
|
cmp ah,178 ; KEY_UP
|
||||||
@ -153,7 +203,8 @@ key:
|
|||||||
jnz redrawbut
|
jnz redrawbut
|
||||||
mov [edi+cur_sel],al
|
mov [edi+cur_sel],al
|
||||||
jmp redrawbut
|
jmp redrawbut
|
||||||
;---------------------------------------------------------------------
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
.noup:
|
.noup:
|
||||||
cmp ah,177 ; KEY_DOWN
|
cmp ah,177 ; KEY_DOWN
|
||||||
jne .nodn
|
jne .nodn
|
||||||
@ -165,7 +216,8 @@ key:
|
|||||||
jna redrawbut
|
jna redrawbut
|
||||||
mov [edi + cur_sel],1
|
mov [edi + cur_sel],1
|
||||||
jmp redrawbut
|
jmp redrawbut
|
||||||
;---------------------------------------------------------------------
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
.nodn:
|
.nodn:
|
||||||
cmp ah,179 ; KEY_LEFT
|
cmp ah,179 ; KEY_LEFT
|
||||||
je @f
|
je @f
|
||||||
@ -174,20 +226,23 @@ key:
|
|||||||
@@:
|
@@:
|
||||||
mov ah,[edi + cur_sel]
|
mov ah,[edi + cur_sel]
|
||||||
jmp button1
|
jmp button1
|
||||||
;---------------------------------------------------------------------
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
.noenter:
|
.noenter:
|
||||||
cmp ah,176 ; KEY_RIGHT
|
cmp ah,176 ; KEY_RIGHT
|
||||||
je @f
|
je @f
|
||||||
cmp ah,27 ; ESC
|
cmp ah,27 ; ESC
|
||||||
jne still
|
jne still
|
||||||
jmp close
|
jmp close
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
@@:
|
@@:
|
||||||
call get_process_ID
|
call get_process_ID
|
||||||
cmp [main_process_ID],ecx
|
cmp [main_process_ID],ecx
|
||||||
jne close
|
jne close
|
||||||
jmp still
|
jmp still
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; include "DEBUG.INC"
|
align 4
|
||||||
button: ; BUTTON HANDLER
|
button: ; BUTTON HANDLER
|
||||||
mcall 17 ; get id
|
mcall 17 ; get id
|
||||||
; dunkaist[
|
; dunkaist[
|
||||||
@ -195,6 +250,8 @@ button: ; BUTTON HANDLER
|
|||||||
setz byte[close_now] ; set (or not set) close_recursive flag
|
setz byte[close_now] ; set (or not set) close_recursive flag
|
||||||
jz close ; if so,close all menus
|
jz close ; if so,close all menus
|
||||||
; dunkaist]
|
; dunkaist]
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
button1:
|
button1:
|
||||||
mov esi,edi
|
mov esi,edi
|
||||||
push edi
|
push edi
|
||||||
@ -211,6 +268,8 @@ button1:
|
|||||||
popad
|
popad
|
||||||
; look for the next line <ah> times; <ah> = button_id
|
; look for the next line <ah> times; <ah> = button_id
|
||||||
push eax
|
push eax
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
.next_string:
|
.next_string:
|
||||||
call searchstartstring
|
call searchstartstring
|
||||||
dec ah
|
dec ah
|
||||||
@ -247,11 +306,13 @@ button1:
|
|||||||
pop edi
|
pop edi
|
||||||
mov [mousemask],0
|
mov [mousemask],0
|
||||||
jmp close
|
jmp close
|
||||||
;---------------------------------------------------------------------
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
searchexit:
|
searchexit:
|
||||||
pop edi
|
pop edi
|
||||||
jmp still
|
jmp still
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
runthread:
|
runthread:
|
||||||
inc edi
|
inc edi
|
||||||
|
|
||||||
@ -276,7 +337,7 @@ runthread:
|
|||||||
add cx,141 ; new x_start in cx
|
add cx,141 ; new x_start in cx
|
||||||
movzx edx,al
|
movzx edx,al
|
||||||
shl edx,4
|
shl edx,4
|
||||||
add edx,menu_data ; edx points to child's base address
|
add edx,[menu_data] ; edx points to child's base address
|
||||||
mov [edx + x_start],cx ; xstart for new thread
|
mov [edx + x_start],cx ; xstart for new thread
|
||||||
mov cx,[esi + y_end] ; y_end in cx
|
mov cx,[esi + y_end] ; y_end in cx
|
||||||
mov bl,[esi + rows] ; number of buttons in bl
|
mov bl,[esi + rows] ; number of buttons in bl
|
||||||
@ -298,14 +359,13 @@ runthread:
|
|||||||
mov [edx + prev_sel],al ; clear previous selected element
|
mov [edx + prev_sel],al ; clear previous selected element
|
||||||
mov [edx + child],0
|
mov [edx + child],0
|
||||||
|
|
||||||
cmp [thread_stack],0x1e000
|
mcall 68,12,0x1000 ; stack of each thread is allocated 4 KB
|
||||||
jne thread_stack_not_full
|
add eax,0x1000 ; set the stack pointer to the desired position
|
||||||
mov [thread_stack],0xE000
|
mov edx,eax
|
||||||
thread_stack_not_full:
|
mcall 51,1,thread ; Go ahead!
|
||||||
add [thread_stack],0x2000 ; start new thread
|
|
||||||
mcall 51,1,thread,[thread_stack]
|
|
||||||
jmp searchexit
|
jmp searchexit
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
mouse: ; MOUSE EVENT HANDLER
|
mouse: ; MOUSE EVENT HANDLER
|
||||||
mcall 37,0
|
mcall 37,0
|
||||||
mov [screen_mouse_position],eax ; eax = [ Y | X ] relative to screen
|
mov [screen_mouse_position],eax ; eax = [ Y | X ] relative to screen
|
||||||
@ -335,18 +395,24 @@ mouse: ; MOUSE EVENT HANDLER
|
|||||||
;;;;;;
|
;;;;;;
|
||||||
mov [edi + cur_sel],al
|
mov [edi + cur_sel],al
|
||||||
mov [edi + prev_sel],bl
|
mov [edi + prev_sel],bl
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
redrawbut:
|
redrawbut:
|
||||||
call draw_only_needed_buttons
|
call draw_only_needed_buttons
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
noredrawbut:
|
noredrawbut:
|
||||||
call backconvert
|
call backconvert
|
||||||
bts [mousemask],eax
|
bts [mousemask],eax
|
||||||
jmp still
|
jmp still
|
||||||
;---------------------------------------------------------------------
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
noinwindow:
|
noinwindow:
|
||||||
call backconvert
|
call backconvert
|
||||||
btr [mousemask],eax
|
btr [mousemask],eax
|
||||||
jmp still
|
jmp still
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
click:
|
click:
|
||||||
cmp [mousemask],0 ; not in a window (i.e. menu)
|
cmp [mousemask],0 ; not in a window (i.e. menu)
|
||||||
jne still
|
jne still
|
||||||
@ -361,34 +427,90 @@ click:
|
|||||||
ja close
|
ja close
|
||||||
cmp ax,MENU_BOTTON_X_POS
|
cmp ax,MENU_BOTTON_X_POS
|
||||||
ja still
|
ja still
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
close:
|
close:
|
||||||
|
|
||||||
movzx ebx,[edi+parent] ; parent id
|
movzx ebx,[edi+parent] ; parent id
|
||||||
shl ebx,4
|
shl ebx,4
|
||||||
add ebx,menu_data ; ebx = base of parent info
|
add ebx,[menu_data] ; ebx = base of parent info
|
||||||
call backconvert
|
call backconvert
|
||||||
cmp [ebx + child],al ; if i am the child of my parent...
|
cmp [ebx + child],al ; if i am the child of my parent...
|
||||||
jnz @f
|
jnz @f
|
||||||
mov [ebx + child],-1 ; ...my parent now has no children
|
mov [ebx + child],-1 ; ...my parent now has no children
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
@@:
|
@@:
|
||||||
or eax,-1 ; close this thread
|
or eax,-1 ; close this thread
|
||||||
mov [edi + child],al ; my child is not mine
|
mov [edi + child],al ; my child is not mine
|
||||||
|
|
||||||
|
call free_area_if_set_mutex
|
||||||
|
call set_mutex_for_free_area
|
||||||
|
|
||||||
mcall
|
mcall
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
backconvert: ; convert from pointer to process id
|
backconvert: ; convert from pointer to process id
|
||||||
mov eax,edi
|
mov eax,edi
|
||||||
sub eax,menu_data
|
sub eax,[menu_data]
|
||||||
shr eax,4
|
shr eax,4
|
||||||
ret
|
ret
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
|
set_mutex_for_free_area:
|
||||||
|
; set mutex for free thread stack area
|
||||||
|
push eax ebx
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
|
.wait_lock:
|
||||||
|
cmp [free_my_area_lock], 0
|
||||||
|
je .get_lock
|
||||||
|
mcall 68,1
|
||||||
|
jmp .wait_lock
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
|
.get_lock:
|
||||||
|
mov eax, 1
|
||||||
|
xchg eax, [free_my_area_lock]
|
||||||
|
test eax, eax
|
||||||
|
jnz .wait_lock
|
||||||
|
mov [free_my_area],ebp
|
||||||
|
pop ebx eax
|
||||||
|
ret
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
|
free_area_if_set_mutex:
|
||||||
|
cmp [free_my_area_lock],0
|
||||||
|
je .end
|
||||||
|
|
||||||
|
push eax ebx ecx
|
||||||
|
mov ecx,[free_my_area]
|
||||||
|
|
||||||
|
test ecx,ecx
|
||||||
|
jz @f
|
||||||
|
mcall 68,13
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
|
@@:
|
||||||
|
xor eax,eax
|
||||||
|
mov [free_my_area_lock],eax
|
||||||
|
pop ecx ebx eax
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
|
.end:
|
||||||
|
ret
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
;==================================
|
;==================================
|
||||||
; get_number
|
; get_number
|
||||||
; load number from [edi] to ebx
|
; load number from [edi] to ebx
|
||||||
;==================================
|
;==================================
|
||||||
|
align 4
|
||||||
get_number:
|
get_number:
|
||||||
push edi
|
push edi
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
xor ebx,ebx
|
xor ebx,ebx
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
.get_next_char:
|
.get_next_char:
|
||||||
mov al,[edi]
|
mov al,[edi]
|
||||||
inc edi
|
inc edi
|
||||||
@ -401,16 +523,19 @@ get_number:
|
|||||||
add ebx,eax
|
add ebx,eax
|
||||||
jmp .get_next_char
|
jmp .get_next_char
|
||||||
;-------------------------------------
|
;-------------------------------------
|
||||||
|
align 4
|
||||||
.finish:
|
.finish:
|
||||||
pop edi
|
pop edi
|
||||||
ret
|
ret
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
get_process_ID:
|
get_process_ID:
|
||||||
mcall 9,procinfo,-1
|
mcall 9,procinfo,-1
|
||||||
mov edx,eax
|
mov edx,eax
|
||||||
mov ecx,[ebx+30] ; PID
|
mov ecx,[ebx+30] ; PID
|
||||||
ret
|
ret
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
program_exist:
|
program_exist:
|
||||||
call get_process_ID
|
call get_process_ID
|
||||||
mov [main_process_ID],ecx
|
mov [main_process_ID],ecx
|
||||||
@ -419,6 +544,7 @@ program_exist:
|
|||||||
mov ecx,edx
|
mov ecx,edx
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
;-----------------------------------------
|
;-----------------------------------------
|
||||||
|
align 4
|
||||||
.loop:
|
.loop:
|
||||||
push ecx
|
push ecx
|
||||||
mcall 9,procinfo
|
mcall 9,procinfo
|
||||||
@ -433,19 +559,24 @@ program_exist:
|
|||||||
; dph ecx
|
; dph ecx
|
||||||
mcall 18,2
|
mcall 18,2
|
||||||
mov edx,1
|
mov edx,1
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
@@:
|
@@:
|
||||||
pop ecx
|
pop ecx
|
||||||
loop .loop
|
loop .loop
|
||||||
;-----------------------------------------
|
|
||||||
test edx,edx
|
test edx,edx
|
||||||
jz @f
|
jz @f
|
||||||
mcall -1
|
mcall -1
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; *********************************************
|
; *********************************************
|
||||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||||
; *********************************************
|
; *********************************************
|
||||||
|
align 4
|
||||||
draw_window:
|
draw_window:
|
||||||
mcall 12,1 ; 1,start of draw
|
mcall 12,1 ; 1,start of draw
|
||||||
movzx ebx,[edi + rows]
|
movzx ebx,[edi + rows]
|
||||||
@ -466,16 +597,20 @@ draw_window:
|
|||||||
call draw_all_buttons
|
call draw_all_buttons
|
||||||
mcall 12,2
|
mcall 12,2
|
||||||
ret
|
ret
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
draw_all_buttons:
|
draw_all_buttons:
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
.new_button:
|
.new_button:
|
||||||
call draw_one_button
|
call draw_one_button
|
||||||
inc edx
|
inc edx
|
||||||
cmp dl,[edi + rows]
|
cmp dl,[edi + rows]
|
||||||
jb .new_button
|
jb .new_button
|
||||||
ret
|
ret
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
draw_only_needed_buttons:
|
draw_only_needed_buttons:
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
mov dl,[edi + cur_sel]
|
mov dl,[edi + cur_sel]
|
||||||
@ -485,7 +620,8 @@ draw_only_needed_buttons:
|
|||||||
dec dl
|
dec dl
|
||||||
call draw_one_button
|
call draw_one_button
|
||||||
ret
|
ret
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
draw_one_button:
|
draw_one_button:
|
||||||
; receives number of button in dl
|
; receives number of button in dl
|
||||||
push edx
|
push edx
|
||||||
@ -500,11 +636,15 @@ draw_one_button:
|
|||||||
cmp esi,0xdfdfdf
|
cmp esi,0xdfdfdf
|
||||||
jb nocorrect
|
jb nocorrect
|
||||||
sub esi,0x1b1b1b
|
sub esi,0x1b1b1b
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
nocorrect:
|
nocorrect:
|
||||||
inc dl
|
inc dl
|
||||||
cmp [edi + cur_sel],dl
|
cmp [edi + cur_sel],dl
|
||||||
jne .nohighlight
|
jne .nohighlight
|
||||||
add esi,0x1a1a1a
|
add esi,0x1a1a1a
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
.nohighlight:
|
.nohighlight:
|
||||||
or edx,0x20000000
|
or edx,0x20000000
|
||||||
; dunkaist[
|
; dunkaist[
|
||||||
@ -519,12 +659,15 @@ nocorrect:
|
|||||||
movzx ecx,dl
|
movzx ecx,dl
|
||||||
inc ecx
|
inc ecx
|
||||||
mov edx,[edi + pointer]
|
mov edx,[edi + pointer]
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
.findline:
|
.findline:
|
||||||
cmp byte [edx],13
|
cmp byte [edx],13
|
||||||
je .linefound
|
je .linefound
|
||||||
inc edx
|
inc edx
|
||||||
jmp .findline
|
jmp .findline
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
.linefound:
|
.linefound:
|
||||||
inc edx
|
inc edx
|
||||||
cmp byte [edx],10
|
cmp byte [edx],10
|
||||||
@ -535,7 +678,8 @@ nocorrect:
|
|||||||
mcall 4,,[sc.work_text],,21
|
mcall 4,,[sc.work_text],,21
|
||||||
pop edx
|
pop edx
|
||||||
ret
|
ret
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
searchstartstring:
|
searchstartstring:
|
||||||
mov ecx,40
|
mov ecx,40
|
||||||
mov al,13
|
mov al,13
|
||||||
@ -544,34 +688,40 @@ searchstartstring:
|
|||||||
cmp byte [edi],10
|
cmp byte [edi],10
|
||||||
jne searchstartstring
|
jne searchstartstring
|
||||||
ret
|
ret
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
;*** DATA AREA ****************************************************************
|
;*** DATA AREA ****************************************************************
|
||||||
menu_mame:
|
menu_mame:
|
||||||
db '@MENU',0
|
db '@MENU',0
|
||||||
|
|
||||||
thread_stack dd 0xE000
|
align 4
|
||||||
processes dd 0
|
free_my_area_lock dd 0
|
||||||
|
free_my_area dd 0
|
||||||
|
|
||||||
|
processes dd 0
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
fileinfo:
|
fileinfo:
|
||||||
.subfunction dd 0 ; 0=READ
|
.subfunction dd 5 ; 5 - file info; 0 - file read
|
||||||
.start dd 0 ; start byte
|
.start dd 0 ; start byte
|
||||||
.size_high dd 0 ; rezerved
|
.size_high dd 0 ; rezerved
|
||||||
.size dd 0x10000-mem_end ; blocks to read
|
.size dd 0 ; bytes to read
|
||||||
.return dd mem_end ; return data pointer
|
.return dd procinfo ; return data pointer
|
||||||
.name:
|
.name:
|
||||||
db '/sys/MENU.DAT',0 ; ASCIIZ dir & filename
|
db '/sys/MENU.DAT',0 ; ASCIIZ dir & filename
|
||||||
|
;--------------------------------------
|
||||||
|
align 4
|
||||||
fileinfo_start:
|
fileinfo_start:
|
||||||
.subfunction dd 7 ; 7=START APPLICATION
|
.subfunction dd 7 ; 7=START APPLICATION
|
||||||
.flags dd 0 ; flags
|
.flags dd 0 ; flags
|
||||||
.params dd 0x0 ; nop
|
.params dd 0x0 ; nop
|
||||||
.rezerved dd 0x0 ; nop
|
.rezerved dd 0x0 ; nop
|
||||||
.rezerved_1 dd 0x0 ; nop
|
.rezerved_1 dd 0x0 ; nop
|
||||||
.name:
|
.name:
|
||||||
times 50 db ' '
|
times 50 db ' '
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
I_END:
|
IM_END:
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
close_now dd ? ; close all processes immediately
|
close_now dd ? ; close all processes immediately
|
||||||
end_pointer dd ?
|
end_pointer dd ?
|
||||||
buffer dd ?
|
buffer dd ?
|
||||||
@ -579,21 +729,22 @@ mousemask dd ? ; mask for mouse pointer location
|
|||||||
|
|
||||||
active_process dd ?
|
active_process dd ?
|
||||||
main_process_ID dd ?
|
main_process_ID dd ?
|
||||||
|
;--------------------------------------
|
||||||
screen_mouse_position:
|
screen_mouse_position:
|
||||||
.y dw ?
|
.y dw ?
|
||||||
.x dw ?
|
.x dw ?
|
||||||
|
;--------------------------------------
|
||||||
screen_size:
|
screen_size:
|
||||||
.y dw ?
|
.y dw ?
|
||||||
.x dw ?
|
.x dw ?
|
||||||
|
;--------------------------------------
|
||||||
|
|
||||||
sc system_colors
|
sc system_colors
|
||||||
|
;--------------------------------------
|
||||||
menu_data:
|
last_key db ?
|
||||||
rb 0x4000 ;x10000
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
|
menu_data dd ?
|
||||||
|
;--------------------------------------
|
||||||
virtual at 0 ; PROCESSES TABLE (located at menu_data)
|
virtual at 0 ; PROCESSES TABLE (located at menu_data)
|
||||||
pointer dd ? ; +0 pointer in file
|
pointer dd ? ; +0 pointer in file
|
||||||
rows db ? ; +4 numer of strings
|
rows db ? ; +4 numer of strings
|
||||||
@ -605,12 +756,14 @@ virtual at 0 ; PROCESSES TABLE (located at menu_data)
|
|||||||
prev_sel db ? ; +12 previous selection
|
prev_sel db ? ; +12 previous selection
|
||||||
rb 16-$+1 ; [16 bytes per element]
|
rb 16-$+1 ; [16 bytes per element]
|
||||||
end virtual
|
end virtual
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
last_key db ?
|
|
||||||
;---------------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
procinfo:
|
procinfo:
|
||||||
rb 1024
|
rb 1024
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
align 4
|
||||||
|
rb 0x1000
|
||||||
|
stack_area:
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
mem_end:
|
mem_end:
|
||||||
;---------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
Loading…
Reference in New Issue
Block a user