Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2210 → Rev 2211

/programs/system/menu/trunk/build.sh
0,0 → 1,14
#!/bin/bash
# This script does for linux the same as build.bat for DOS,
# it compiles the KoOS kernel, hopefully ;-)
 
echo "lang fix en"
echo "lang fix en" > lang.inc
fasm -m 16384 menu.asm @menu
kpack @menu
rm -f lang.inc
exit 0
 
 
 
 
/programs/system/menu/trunk/build_en.bat
1,5 → 1,6
@erase lang.inc
@echo lang fix en >lang.inc
@fasm menu.asm @menu
@fasm -m 16384 menu.asm @menu
@kpack @menu
@erase lang.inc
@pause
/programs/system/menu/trunk/build_ru.bat
1,5 → 1,6
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm menu.asm @menu
@fasm -m 16384 menu.asm @menu
@kpack @menu
@erase lang.inc
@pause
/programs/system/menu/trunk/menu.asm
1,4 → 1,11
;******************************************************************************
; MAIN MENU
;******************************************************************************
; last update: 19/09/2011
; changed by: Marat Zakiyanov aka Mario79, aka Mario
; changes: Checking for program exist to memory
; Added processing of keys: left and right arrow
;---------------------------------------------------------------------
; MAIN MENU by lisovin@26.ru
; Some parts of code rewritten by Ivan Poddubny <ivan-yar@bk.ru>
;
10,6 → 17,10
BTN_HEIGHT = 22
TXT_Y = (BTN_HEIGHT)/2-5
 
PANEL_HEIGHT = 20
MENU_BOTTON_X_POS = 10
MENU_BOTTON_X_SIZE = 60
use32
org 0x0
db 'MENUET01' ; 8 byte id
17,21 → 28,17
dd START ; start of code
dd I_END ; size of image
dd 0x20000 ; memory for app
dd 0x20000-1 ; esp
dd 0x20000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
;******************************************************************************
;include "DEBUG.INC" ; debug macros
START: ; start of execution
call program_exist
mcall 14
mov [screen_size],eax
 
mov eax, 48 ; load system colors
mov ebx, 3
mov ecx, sc
mov edx, sizeof.system_colors
mcall
 
mov eax, 70 ; load MENU.DAT
mov ebx, fileinfo
mcall
mcall 48,3,sc,sizeof.system_colors ; load system colors
mcall 70,fileinfo ; load MENU.DAT
test eax, eax ; error ?
jz @f
cmp eax,6
58,6 → 65,7
mov [ebx], edi
inc [processes]
jmp newsearch
;---------------------------------------------------------------------
search_end:
mov [end_pointer], edi
mov ebx, [processes]
78,6 → 86,7
jne newsearch1
inc edx
jmp newsearch1
;---------------------------------------------------------------------
endprocess:
mov esi, ebx
add esi, 4
87,9 → 96,9
jbe search_end1
sub ebx, 16
jmp newprocess
;---------------------------------------------------------------------
search_end1:
mov eax, 14
mcall
mcall 14
sub ax, 20
mov [menu_data + y_end], ax
mov [menu_data + x_start], 5
96,7 → 105,6
mov al, [menu_data + rows]
mov [menu_data + cur_sel], al ; clear selection
mov [menu_data + prev_sel], al
 
mov [buffer], 0
thread:
mov eax, [buffer] ; identifier
103,18 → 111,11
shl eax, 4
add eax, menu_data
mov edi, eax
 
mov eax, 40 ; set event mask
mov ebx, 100111b ; mouse + button + key + redraw
mcall
 
call draw_window
 
mcall 40,100111b ; mouse + button + key + redraw
red:
call draw_window ; redraw
still:
mov eax, 23 ; wait here for event
mov ebx, 5
mcall
 
mcall 23,5 ; wait here for event
test [close_now], 1 ; is close flag set?
jnz close
 
126,7 → 127,6
je button
cmp eax, 6 ; mouse event ?
je mouse
 
cmp edi, menu_data
je still ; if main process-ignored
 
138,19 → 138,12
jne close
 
jmp still
 
 
red: ; redraw
call draw_window
jmp still
 
 
;---------------------------------------------------------------------
key:
; mov eax, 2
mcall
 
mov [last_key],ah
mov al, [edi + rows] ; number of buttons
 
cmp ah, 178 ; KEY_UP
jne .noup
 
160,8 → 153,7
jnz redrawbut
mov [edi+cur_sel], al
jmp redrawbut
 
 
;---------------------------------------------------------------------
.noup:
cmp ah, 177 ; KEY_DOWN
jne .nodn
173,23 → 165,31
jna redrawbut
mov [edi + cur_sel], 1
jmp redrawbut
 
;---------------------------------------------------------------------
.nodn:
cmp ah,179 ; KEY_LEFT
je @f
cmp ah, 13 ; ENTER
jne .noenter
@@:
mov ah, [edi + cur_sel]
jmp button1
 
;---------------------------------------------------------------------
.noenter:
cmp ah,176 ; KEY_RIGHT
je @f
cmp ah, 27 ; ESC
jne still
jmp close
 
@@:
call get_process_ID
cmp [main_process_ID],ecx
jne close
jmp still
;---------------------------------------------------------------------
; include "DEBUG.INC"
 
button: ; BUTTON HANDLER
mov eax, 17 ; get id
mcall
mcall 17 ; get id
; dunkaist[
test eax,0xfffffe00 ; is it system close button? (close signal from @panel)
setz byte[close_now]; set (or not set) close_recursive flag
199,17 → 199,16
mov esi, edi
push edi
mov edi, [edi + pointer]
 
; print "hello"
mov al, [esi + cur_sel]
mov [esi + prev_sel], al
mov [esi + cur_sel], ah
pushad
mov edi, esi
; dph eax
call draw_only_needed_buttons
popad
 
; look for the next line <ah> times; <ah> = button_id
push eax
.next_string:
228,6 → 227,9
cmp [edi], byte '@' ; check for submenu
je runthread
 
cmp [last_key],179
je searchexit
dec edi
push edi ; pointer to start of filename
call searchstartstring ; search for next string
239,21 → 241,17
inc ecx ; length of filename
mov edi, fileinfo_start.name
rep movsb ; copy string
mov byte [edi], 0 ; store terminator
mov eax, 70 ; start program
mov ebx, fileinfo_start
mcall
; mcall 5,100
mov [edi],byte 0 ; store terminator
mcall 70,fileinfo_start ; start program
or [close_now], 1 ; set close flag
pop edi
mov [mousemask], 0
jmp close
 
;---------------------------------------------------------------------
searchexit:
pop edi
jmp still
 
 
;---------------------------------------------------------------------
runthread:
inc edi
 
303,32 → 301,23
cmp [thread_stack], 0x1e000
jne thread_stack_not_full
mov [thread_stack], 0xE000
 
thread_stack_not_full:
add [thread_stack], 0x2000 ; start new thread
mov eax, 51
mov ebx, 1
mov ecx, thread
mov edx, [thread_stack]
mcall
 
mcall 51,1,thread,[thread_stack]
jmp searchexit
;---------------------------------------------------------------------
mouse: ; MOUSE EVENT HANDLER
mcall 37,0
mov [screen_mouse_position],eax ; eax = [ Y | X ] relative to screen
 
 
mouse: ; MOUSE EVENT HANDLER
mov eax, 37
mov ebx, 2
mcall
mcall 37,2
test eax, eax ; check buttons state
jnz click
mov eax, 37
mov ebx, 1
mcall
mcall 37,1
ror eax, 16 ; eax = [ Y | X ] relative to window
cmp ax, 140 ; pointer in window?
ja noinwindow
;  in window 
 
; *** in window ***
shr eax, 16 ; eax = [ 0 | Y ]
xor edx, edx
mov ebx, BTN_HEIGHT
340,12 → 329,10
cmp [edi + cur_sel], al
je noredrawbut
mov bl, [edi + cur_sel]
 
;;;;;;
cmp [edi + child], 0
jne noredrawbut
;;;;;;
 
mov [edi + cur_sel], al
mov [edi + prev_sel], bl
redrawbut:
354,17 → 341,29
call backconvert
bts [mousemask], eax
jmp still
;---------------------------------------------------------------------
noinwindow:
call backconvert
btr [mousemask], eax
jmp still
;---------------------------------------------------------------------
click:
cmp [mousemask], 0 ; not in a window (i.e. menu)
je close
jmp still
jne still
; checking for pressing 'MENU' on the taskbar
mov eax,[screen_mouse_position]
mov ebx,[screen_size]
sub bx,PANEL_HEIGHT
cmp bx,ax
ja close
shr eax,16
cmp ax,MENU_BOTTON_X_SIZE
ja close
cmp ax,MENU_BOTTON_X_POS
ja still
;---------------------------------------------------------------------
close:
 
 
close:
movzx ebx, [edi+parent] ; parent id
shl ebx, 4
add ebx, menu_data ; ebx = base of parent info
376,14 → 375,12
or eax, -1 ; close this thread
mov [edi + child], al ; my child is not mine
mcall
 
backconvert: ; convert from pointer to process id
mov eax, edi
sub eax, menu_data
shr eax, 4
ret
 
 
;---------------------------------------------------------------------
;==================================
; get_number
; load number from [edi] to ebx
390,10 → 387,8
;==================================
get_number:
push edi
 
xor eax, eax
xor ebx, ebx
 
.get_next_char:
mov al, [edi]
inc edi
405,23 → 400,54
imul ebx, 10
add ebx, eax
jmp .get_next_char
 
;-------------------------------------
.finish:
pop edi
ret
 
 
;---------------------------------------------------------------------
get_process_ID:
mcall 9,procinfo,-1
mov edx,eax
mov ecx,[ebx+30] ; PID
ret
;---------------------------------------------------------------------
program_exist:
call get_process_ID
mov [main_process_ID],ecx
mcall 18,21
mov [active_process],eax ; WINDOW SLOT
mov ecx,edx
xor edx,edx
;-----------------------------------------
.loop:
push ecx
mcall 9,procinfo
mov eax,[menu_mame]
cmp [ebx+10],eax
jne @f
mov ax,[menu_mame+4]
cmp [ebx+14],ax
jne @f
cmp ecx,[active_process]
je @f
; dph ecx
mcall 18,2
mov edx,1
@@:
pop ecx
loop .loop
;-----------------------------------------
test edx,edx
jz @f
mcall -1
@@:
ret
;---------------------------------------------------------------------
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
mov eax, 12 ; function 12:tell os about windowdraw
mov ebx, 1 ; 1, start of draw
mcall
 
mcall 12,1 ; 1,start of draw
movzx ebx, [edi + rows]
imul eax, ebx, BTN_HEIGHT ; eax = height of window
movzx ecx, [edi + y_end]
432,20 → 458,15
movzx ebx, [edi + x_start]
shl ebx, 16
mov bx, 140 ; ebx = [ X_START | X_SIZE ]
xor eax, eax ; function 0 : define and draw window
mov edx, 0x01000000 ; color of work area RRGGBB,8->color gl
mov esi, edx ; unmovable window
xor eax,eax ; function 0 : define and draw window
mcall
 
call draw_all_buttons
 
mov eax,12
mov ebx,2
mcall
 
mcall 12,2
ret
 
 
;---------------------------------------------------------------------
draw_all_buttons:
xor edx, edx
.new_button:
453,10 → 474,8
inc edx
cmp dl, [edi + rows]
jb .new_button
 
ret
 
 
;---------------------------------------------------------------------
draw_only_needed_buttons:
xor edx, edx
mov dl, [edi + cur_sel]
466,12 → 485,10
dec dl
call draw_one_button
ret
 
 
;---------------------------------------------------------------------
draw_one_button:
; receives number of button in dl
push edx;ad
 
push edx
mov eax, 8
mov ebx, 140
movzx ecx, dl
491,15 → 508,14
.nohighlight:
or edx, 0x20000000
; dunkaist[
add edx, 0xd1ff00 ; This makes first menu buttons differ from system close button with 0x000001 id
add edx,0xd1ff00 ; This makes first menu buttons differ
; from system close button with 0x000001 id
; dunkaist]
mcall
movzx edx, dl
 
dec dl
imul ebx, edx, BTN_HEIGHT
add ebx, (4 shl 16) + TXT_Y
 
movzx ecx, dl
inc ecx
mov edx, [edi + pointer]
508,6 → 524,7
je .linefound
inc edx
jmp .findline
;---------------------------------------------------------------------
.linefound:
inc edx
cmp byte [edx], 10
515,15 → 532,10
dec ecx
jnz .findline
 
mov ecx, [sc.work_text]
mov eax, 4
mov esi, 21
mcall
 
pop edx;ad
mcall 4,,[sc.work_text],,21
pop edx
ret
 
 
;---------------------------------------------------------------------
searchstartstring:
mov ecx, 40
mov al, 13
532,9 → 544,10
cmp byte [edi], 10
jne searchstartstring
ret
 
 
;---------------------------------------------------------------------
;*** DATA AREA ****************************************************************
menu_mame:
db '@MENU',0
 
thread_stack dd 0xE000
processes dd 0
556,14 → 569,26
.rezerved_1 dd 0x0 ; nop
.name:
times 50 db ' '
 
;---------------------------------------------------------------------
I_END:
 
;---------------------------------------------------------------------
close_now dd ? ; close all processes immediately
end_pointer dd ?
buffer dd ?
mousemask dd ? ; mask for mouse pointer location
 
active_process dd ?
main_process_ID dd ?
 
screen_mouse_position:
.y dw ?
.x dw ?
 
screen_size:
.y dw ?
.x dw ?
 
 
sc system_colors
 
menu_data:
581,4 → 606,11
rb 16-$+1 ; [16 bytes per element]
end virtual
 
last_key db ?
;---------------------------------------------------------------------
align 4
procinfo:
rb 1024
;---------------------------------------------------------------------
mem_end:
;---------------------------------------------------------------------