SPANEL - Code optimizing and refactoring.

git-svn-id: svn://kolibrios.org@2592 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2012-04-09 00:39:44 +00:00
parent a612dc8dfb
commit 3624840f7d
2 changed files with 220 additions and 231 deletions

View File

@ -1 +1,3 @@
fasm spanel.asm spanel @fasm -m 16384 spanel.asm spanel
@kpack spanel
@pause

View File

@ -1,52 +1,54 @@
; ;
; PANEL SETUP ; PANEL SETUP
; ;
; Compile with FASM for Menuet ;------------------------------------------------------------------------------
; last update: 09/04/2012
; changed by: Marat Zakiyanov aka Mario79, aka Mario
; changes: Code optimizing and refactoring.
; ;
;------------------------------------------------------------------------------
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 0x8000 ; memory for app dd I_END ;0x8000 ; memory for app
dd 0x8000 ; esp dd stack_top ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon dd 0x0 ; boot parameters
dd 0x0 ; path
;------------------------------------------------------------------------------
include '../../../macros.inc' include '../../../macros.inc'
;------------------------------------------------------------------------------
START: ; start of execution START:
;------------------------------------------------------------------------------
align 4
red:
call draw_window call draw_window
;------------------------------------------------------------------------------
align 4
still: still:
mcall 10
mov eax,10 ; wait here for event
int 0x40
cmp eax,1 ; redraw request ? cmp eax,1 ; redraw request ?
je red je red
cmp eax,2 ; key in buffer ? cmp eax,2 ; key in buffer ?
je key je key
cmp eax,3 ; button in buffer ? cmp eax,3 ; button in buffer ?
je button je button
jmp still jmp still
;------------------------------------------------------------------------------
red: ; redraw align 4
call draw_window key:
jmp still mcall 2
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
shr eax,8 shr eax,8
cmp eax,'0' cmp eax,'0'
jb still jb still
cmp eax,'9' cmp eax,'9'
jg still jg still
@ -60,46 +62,43 @@ still:
mov [edi],al mov [edi],al
call draw_window jmp red
jmp still ;------------------------------------------------------------------------------
align 4
button: ; button button:
mov eax,17 ; get id mcall 17
int 0x40
cmp ah,1 ; button id=1 ? cmp ah,1 ; button id=1 ?
jne noclose jne noclose
mov eax,-1 ; close this program
int 0x40
noclose:
mcall -1 ; close this program
;--------------------------------------
align 4
noclose:
cmp ah,10 cmp ah,10
jne no_apply jne no_apply
mov esi,text+17 mov esi,text+17
mov edi,I_END+10 mov edi,panel_ini_data_area ;I_END+10
mov ecx,12 mov ecx,12
newfe: ;--------------------------------------
align 4
newfe:
mov ebx,[esi] mov ebx,[esi]
mov [edi],ebx mov [edi],ebx
mov [edi+4],byte ';' mov [edi+4],byte ';'
add edi,5 add edi,5
add esi,55 add esi,55
loop newfe loop newfe
mov [edi],byte 'x' mov [edi],byte 'x'
mcall 70,dat_write
mov eax,70
mov ebx,dat_write
int 0x40
mov esi,1 mov esi,1
newread: ;--------------------------------------
align 4
newread:
inc esi inc esi
mov eax,9 mcall 9,proc_info,esi
mov ebx,I_END
mov ecx,esi
int 0x40
cmp esi,eax cmp esi,eax
jg all_terminated jg all_terminated
@ -107,102 +106,59 @@ still:
and eax,not 0x20202000 and eax,not 0x20202000
cmp eax,'@PAN' cmp eax,'@PAN'
jne newread jne newread
mov eax,[ebx+14] mov eax,[ebx+14]
and eax,not 0x2020 and eax,not 0x2020
cmp eax,'EL ' cmp ax,'EL'
jne newread jne newread
mov eax,18 mcall 18,2,esi
mov ebx,2
mov ecx,esi
int 0x40
mov eax,5 mcall 5,5
mov ebx,5
int 0x40
mov esi,1 mov esi,1
jmp newread jmp newread
;--------------------------------------
align 4
all_terminated:
mcall 5,25
all_terminated: mcall 70,panel_start
;--------------------------------------
mov eax,5 align 4
mov ebx,25 no_apply:
int 0x40
mov eax, 70
mov ebx, panel_start
int 0x40
no_apply:
cmp ah,11 cmp ah,11
jb no_entry jb still
shr eax,8 shr eax,8
sub eax,11 sub eax,11
imul eax,55 imul eax,55
add eax,17 add eax,17
mov [ent],eax mov [ent],eax
mov [text+eax],dword '0000' mov [text+eax],dword '0000'
call draw_window jmp red
jmp still ;------------------------------------------------------------------------------
no_entry:
jmp still
ent dd 17
panel_start:
dd 7
dd 0
dd 0
dd 0
dd 0
db '/RD/1/@PANEL',0
dat_write:
dd 2
dq 0
dd 5*12+1
dd I_END+10
db 'PANEL.DAT',0
; ********************************************* ; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ******** ; ******* WINDOW DEFINITIONS AND DRAW ********
; ********************************************* ; *********************************************
;------------------------------------------------------------------------------
align 4
draw_window: draw_window:
mcall 12,1
; DRAW WINDOW
xor eax,eax
xor esi,esi
mcall ,<100,385>,<100,190>,0x14ffffff,,labelt
mcall 8,<25,335>,<162,12>,10,0x80a0c0 ;0x6677cc
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
mov ebx,100*65536+385 ; [x start] *65536 + [x size]
mov ecx,100*65536+190 ; [y start] *65536 + [y size]
mov edx,0x14ffffff ; color of work area RRGGBB,8->color gl
mov edi,labelt ; color of frames RRGGBB
int 0x40
mov eax,8
mov ebx,25*65536+335 ;160
mov ecx,162*65536+12
mov edx,10
mov esi,0x80a0c0 ;0x6677cc
int 0x40
mov eax,8
mov ebx,340*65536+20 mov ebx,340*65536+20
mov ecx,34*65536+10 mov ecx,34*65536+10
mov edx,11 inc edx ;11 - button
newb: ;--------------------------------------
int 0x40 align 4
newb:
mcall
add ecx,10*65536 add ecx,10*65536
inc edx inc edx
cmp edx,23 cmp edx,23
@ -212,45 +168,76 @@ draw_window:
mov ecx,0x224466 mov ecx,0x224466
mov edx,text mov edx,text
mov esi,55 mov esi,55
newline:
mov eax,4 mov eax,4
int 0x40 ;--------------------------------------
align 4
newline:
mcall
add ebx,10 add ebx,10
add edx,55 add edx,55
cmp [edx],byte 'x' cmp [edx],byte 'x'
jne newline jne newline
mov eax,12 ; function 12:tell os about windowdraw mcall 12,2
mov ebx,2 ; 2, end of draw
int 0x40
ret ret
;------------------------------------------------------------------------------
align 4
; DATA AREA ; DATA AREA
text: text:
db 'width 0000 : 0 for full screen width <'
db 'width 0000 : 0 for full screen width <' db 'buttons 0000 : 0 no frames , 1 frames <'
db 'buttons 0000 : 0 no frames , 1 frames <' db 'soften_up 0001 : 0 no , 1 yes <'
db 'soften_up 0001 : 0 no , 1 yes <' db 'soften_down 0001 : 0 no , 1 yes <'
db 'soften_down 0001 : 0 no , 1 yes <' db 'minimize_left 0001 : 0 no , 1 yes <'
db 'minimize_left 0001 : 0 no , 1 yes <' db 'minimize_right 0001 : 0 no , 1 yes <'
db 'minimize_right 0001 : 0 no , 1 yes <' db 'icons_position 0100 : position in pixels <'
db 'icons_position 0100 : position in pixels <' db 'menu_enable 0001 : 0 no , 1 yes <'
db 'menu_enable 0001 : 0 no , 1 yes <' db 'setup_enable 0001 : 0 no , 1 yes <'
db 'setup_enable 0001 : 0 no , 1 yes <' db 'graph_text 0001 : 0 graphics , 1 text <'
db 'graph_text 0001 : 0 graphics , 1 text <' db 'soften_middle 0001 : 0 no , 1 yes <'
db 'soften_middle 0001 : 0 no , 1 yes <' db 'icons 0001 : 0 start , 1 activate <'
db 'icons 0001 : 0 start , 1 activate <' db ' '
db ' ' db ' APPLY '
db ' APPLY ' db 'x'
db 'x' ;------------------------------------------------------------------------------
labelt: labelt:
db 'Panel setup' db 'Panel setup'
labellen: labellen:
;------------------------------------------------------------------------------
align 4
ent dd 17
;------------------------------------------------------------------------------
align 4
panel_start:
dd 7
dd 0
dd 0
dd 0
dd 0
db '/RD/1/@PANEL',0
;------------------------------------------------------------------------------
align 4
dat_write:
dd 2
dd 0
dd 0
dd 5*12+1
dd panel_ini_data_area ;I_END+10
db 'PANEL.DAT',0
;------------------------------------------------------------------------------
IM_END:
;------------------------------------------------------------------------------
align 4
proc_info:
rb 1024
;------------------------------------------------------------------------------
align 4
rb 1024
stack_top:
;------------------------------------------------------------------------------
align 4
panel_ini_data_area:
rb 61
;------------------------------------------------------------------------------
I_END: I_END:
;------------------------------------------------------------------------------