CtrlDemo: code cleaning, library import optimization
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 21s
Build system / Build (pull_request) Successful in 4m29s

This commit is contained in:
2025-05-18 15:34:48 +03:00
parent c148987224
commit 95d7853a8e
5 changed files with 179 additions and 148 deletions

View File

@@ -49,9 +49,9 @@ include '../../../../../load_lib.mac'
;--- Start of program ---------------------------------------------- ;--- Start of program ----------------------------------------------
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
START: START:
mcall 68,11 mcall SF_SYS_MISC,SSF_HEAP_INIT
mcall 66,1,1 mcall SF_KEYBOARD,SSF_SET_INPUT_MODE,1
mcall 40,0x27 mcall SF_SET_EVENTS_MASK,0x27
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
load_libraries l_libs_start,end_l_libs load_libraries l_libs_start,end_l_libs
@@ -84,7 +84,7 @@ load_libraries l_libs_start,end_l_libs
copy_path icons_file_name,path,library_path,0 copy_path icons_file_name,path,library_path,0
mcall 70,fileinfo mcall SF_FILE,fileinfo
mov [fileinfo+0],dword 0 mov [fileinfo+0],dword 0
@@ -93,14 +93,14 @@ load_libraries l_libs_start,end_l_libs
mov [img_size],ecx mov [img_size],ecx
mcall 68,12 mcall SF_SYS_MISC,SSF_MEM_ALLOC
mov [fileinfo+16],eax mov [fileinfo+16],eax
mov [image_file],eax mov [image_file],eax
mcall 70,fileinfo mcall SF_FILE,fileinfo
xor eax,eax xor eax,eax
mov [return_code],eax mov [return_code],eax
@@ -108,8 +108,7 @@ load_libraries l_libs_start,end_l_libs
push image_file push image_file
call [cnv_png_import.Start] call [cnv_png_import.Start]
mov ecx,[image_file] mcall SF_SYS_MISC,SSF_MEM_FREE,[image_file]
mcall 68,13,
cmp [return_code],dword 0 cmp [return_code],dword 0
jne button.exit jne button.exit
@@ -151,28 +150,28 @@ load_libraries l_libs_start,end_l_libs
red: red:
call draw_window call draw_window
still: still:
mcall 10 mcall SF_WAIT_EVENT
cmp eax,1 cmp eax,EV_REDRAW
je red je red
cmp eax,2 cmp eax,EV_KEY
je key je key
cmp eax,3 cmp eax,EV_BUTTON
je button je button
cmp eax,6 cmp eax,EV_MOUSE
je mouse je mouse
jmp still jmp still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
key: key:
mcall 2 mcall SF_GET_KEY
jmp still jmp still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
button: button:
mcall 17 mcall SF_GET_BUTTON
cmp ah,1 cmp ah,1
jne still jne still
.exit: .exit:
mcall -1 mcall SF_TERMINATE_PROCESS
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
mouse: mouse:
;----------------------------------------------- ;-----------------------------------------------
@@ -184,7 +183,7 @@ mouse:
jbe .horizontal jbe .horizontal
; mouse event for Vertical ScrollBar ; mouse event for Vertical ScrollBar
push dword scroll_bar_data_vertical push dword scroll_bar_data_vertical
call [scrollbar_ver_mouse] call [scrollbar_v_mouse]
mov eax,scroll_bar_data_vertical.redraw mov eax,scroll_bar_data_vertical.redraw
xor ebx,ebx xor ebx,ebx
cmp [eax],ebx cmp [eax],ebx
@@ -200,7 +199,7 @@ mouse:
jbe .other jbe .other
; mouse event for Horizontal ScrollBar ; mouse event for Horizontal ScrollBar
push dword scroll_bar_data_horizontal push dword scroll_bar_data_horizontal
call [scrollbar_hor_mouse] call [scrollbar_h_mouse]
mov eax,scroll_bar_data_horizontal.redraw mov eax,scroll_bar_data_horizontal.redraw
xor ebx,ebx xor ebx,ebx
cmp [eax],ebx cmp [eax],ebx
@@ -240,7 +239,7 @@ mouse:
.mouse_dinamic_button: .mouse_dinamic_button:
; mouse event for Dinamic Button 1 ; mouse event for Dinamic Button 1
push dword dinamic_button_data_1 push dword dinamic_button_data_1
call [dinamic_button_mouse] call [dbutton_mouse]
mov eax,dinamic_button_data_1.click mov eax,dinamic_button_data_1.click
cmp [eax],dword 1 cmp [eax],dword 1
jne @f jne @f
@@ -249,7 +248,7 @@ mouse:
@@: @@:
; mouse event for Dinamic Button 2 ; mouse event for Dinamic Button 2
push dword dinamic_button_data_2 push dword dinamic_button_data_2
call [dinamic_button_mouse] call [dbutton_mouse]
mov eax,dinamic_button_data_2.click mov eax,dinamic_button_data_2.click
cmp [eax],dword 1 cmp [eax],dword 1
jne still ;@f jne still ;@f
@@ -283,7 +282,7 @@ analyse_out_menu_2:
jmp still jmp still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
about: about:
mcall 51,1,thread3,thread mcall SF_CREATE_THREAD,1,thread3,thread
jmp still jmp still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
OpenDialog_start_0: OpenDialog_start_0:
@@ -320,9 +319,9 @@ OpenDialog_start:
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
draw_window: draw_window:
mcall 12,1 mcall SF_REDRAW,SSF_BEGIN_DRAW
mcall 0,<0,400>,<0,400>,0x03AABBCC,0x805080D0,0x005080D0 mcall SF_CREATE_WINDOW,<0,400>,<0,400>,0x03AABBCC,0x805080D0,0x005080D0
mcall 71,1,header_1 mcall SF_SET_CAPTION,1,header_1
;--------------------------------------------- ;---------------------------------------------
; draw for Menu 1 ; draw for Menu 1
push dword menu_data_1 push dword menu_data_1
@@ -333,15 +332,15 @@ draw_window:
;--------------------------------------------- ;---------------------------------------------
; draw for Dinamic Button 1 ; draw for Dinamic Button 1
push dword dinamic_button_data_1 push dword dinamic_button_data_1
call [dinamic_button_draw] call [dbutton_draw]
; draw for Dinamic Button 2 ; draw for Dinamic Button 2
push dword dinamic_button_data_2 push dword dinamic_button_data_2
call [dinamic_button_draw] call [dbutton_draw]
;--------------------------------------------- ;---------------------------------------------
mcall 13,<170,200>,<25,15>,0xffffb0 mcall SF_DRAW_RECT,<170,200>,<25,15>,0xffffb0
; mov bx,28 ; mov bx,28
; add ebx,2 shl 16 ; add ebx,2 shl 16
; mcall 4,,0xC0000000,text_work_area,,0xffffb0 ; mcall SF_DRAW_TEXT,,0xC0000000,text_work_area,,0xffffb0
; draw for PathShow ; draw for PathShow
push dword PathShow_data_1 push dword PathShow_data_1
call [PathShow_draw] call [PathShow_draw]
@@ -357,21 +356,21 @@ draw_window:
; draw for Vertical ScrollBar ; draw for Vertical ScrollBar
push dword scroll_bar_data_vertical push dword scroll_bar_data_vertical
call [scrollbar_ver_draw] call [scrollbar_v_draw]
; draw for Horizontal ScrollBar ; draw for Horizontal ScrollBar
push dword scroll_bar_data_horizontal push dword scroll_bar_data_horizontal
call [scrollbar_hor_draw] call [scrollbar_h_draw]
; reset all_redraw flag ; reset all_redraw flag
xor eax,eax xor eax,eax
mov [scroll_bar_data_vertical.all_redraw],eax mov [scroll_bar_data_vertical.all_redraw],eax
mov [scroll_bar_data_horizontal.all_redraw],eax mov [scroll_bar_data_horizontal.all_redraw],eax
;--------------------------------------------- ;---------------------------------------------
call draw_cube call draw_cube
mcall 12,2 mcall SF_REDRAW,SSF_END_DRAW
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
draw_cube: draw_cube:
mcall 13,<30,301>,<50,301>,0xafafaf mcall SF_DRAW_RECT,<30,301>,<50,301>,0xafafaf
mov ecx,[scroll_bar_data_vertical.position] mov ecx,[scroll_bar_data_vertical.position]
add ecx,50 add ecx,50
shl ecx,16 shl ecx,16
@@ -380,7 +379,7 @@ draw_cube:
add ebx,30 add ebx,30
shl ebx,16 shl ebx,16
mov bx,30 mov bx,30
mcall 13,,,0x0 mcall SF_DRAW_RECT,,,0x0
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
include 'data.inc' include 'data.inc'

View File

@@ -30,7 +30,7 @@ system_dir_ProcLib db '/sys/lib/proc_lib.obj',0
align 4 align 4
l_libs_start: l_libs_start:
library01 l_libs system_dir_Boxlib+9, file_name, system_dir_Boxlib,\ library01 l_libs system_dir_Boxlib+9, file_name, system_dir_Boxlib,\
Box_lib_import, plugins_directory import_box_lib, plugins_directory
library02 l_libs system_dir_CnvPNG+9, file_name, system_dir_CnvPNG,\ library02 l_libs system_dir_CnvPNG+9, file_name, system_dir_CnvPNG,\
cnv_png_import, plugins_directory cnv_png_import, plugins_directory
@@ -126,90 +126,9 @@ deflate_unpack dd 0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 sz_lib_init db 'lib_init',0
Box_lib_import:
;init_lib dd a_init
;version_lib dd a_version
;edit_box_draw dd aEdit_box_draw
;edit_box_key dd aEdit_box_key
;edit_box_mouse dd aEdit_box_mouse
;version_ed dd aVersion_ed
;check_box_draw dd aCheck_box_draw
;check_box_mouse dd aCheck_box_mouse
;version_ch dd aVersion_ch
;option_box_draw dd aOption_box_draw
;option_box_mouse dd aOption_box_mouse
;version_op dd aVersion_op
scrollbar_ver_draw dd aScrollbar_ver_draw
scrollbar_ver_mouse dd aScrollbar_ver_mouse
scrollbar_hor_draw dd aScrollbar_hor_draw
scrollbar_hor_mouse dd aScrollbar_hor_mouse
;version_scrollbar dd aVersion_scrollbar
dinamic_button_draw dd aDbutton_draw
dinamic_button_mouse dd aDbutton_mouse
;version_dbutton dd aVersion_dbutton
menu_bar_draw dd aMenu_bar_draw
menu_bar_mouse dd aMenu_bar_mouse
menu_bar_activate dd aMenu_bar_activate
;version_menu_bar dd aVersion_menu_bar
;FileBrowser_draw dd aFileBrowser_draw
;FileBrowser_mouse dd aFileBrowser_mouse
;FileBrowser_key dd aFileBrowser_key
;Version_FileBrowser dd aVersion_FileBrowser
PathShow_prepare dd sz_PathShow_prepare
PathShow_draw dd sz_PathShow_draw
;Version_path_show dd szVersion_path_show
dd 0,0
;a_init db 'lib_init',0
;a_version db 'version',0
;aEdit_box_draw db 'edit_box_draw',0
;aEdit_box_key db 'edit_box_key',0
;aEdit_box_mouse db 'edit_box_mouse',0
;aVersion_ed db 'version_ed',0
;aCheck_box_draw db 'check_box_draw',0
;aCheck_box_mouse db 'check_box_mouse',0
;aVersion_ch db 'version_ch',0
;aOption_box_draw db 'option_box_draw',0
;aOption_box_mouse db 'option_box_mouse',0
;aVersion_op db 'version_op',0
aScrollbar_ver_draw db 'scrollbar_v_draw',0
aScrollbar_ver_mouse db 'scrollbar_v_mouse',0
aScrollbar_hor_draw db 'scrollbar_h_draw',0
aScrollbar_hor_mouse db 'scrollbar_h_mouse',0
;aVersion_scrollbar db 'version_scrollbar',0
aDbutton_draw db 'dbutton_draw',0
aDbutton_mouse db 'dbutton_mouse',0
;aVersion_dbutton db 'version_dbutton',0
aMenu_bar_draw db 'menu_bar_draw',0
aMenu_bar_mouse db 'menu_bar_mouse',0
aMenu_bar_activate db 'menu_bar_activate',0
;aVersion_menu_bar db 'version_menu_bar',0
;aFileBrowser_draw db 'FileBrowser_draw',0
;aFileBrowser_mouse db 'FileBrowser_mouse',0
;aFileBrowser_key db 'FileBrowser_key',0
;aVersion_FileBrowser db 'version_FileBrowser',0
sz_PathShow_prepare db 'PathShow_prepare',0
sz_PathShow_draw db 'PathShow_draw',0
;szVersion_path_show db 'version_PathShow',0
include '../../import.inc' ;import_box_lib
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
;--------------------------------------------------------------------- ;---------------------------------------------------------------------

View File

@@ -18,7 +18,7 @@ include '../../../../../load_lib.mac'
@use_library ;use load lib macros @use_library ;use load lib macros
start: start:
;universal load library/librarys ;universal load library/librarys
sys_load_library library_name, library_path, system_path, myimport sys_load_library library_name, library_path, system_path, import_box_lib
;if return code =-1 then exit, else nornary work ;if return code =-1 then exit, else nornary work
cmp eax,-1 cmp eax,-1
jz exit jz exit
@@ -116,37 +116,9 @@ library_name db 'box_lib.obj',0
;library_name db 'box_lib.obj',0 ;library_name db 'box_lib.obj',0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
myimport: sz_lib_init db 'lib_init',0
edit_box_draw dd aEdit_box_draw include '../../import.inc' ;creating a function import table
edit_box_key dd aEdit_box_key
edit_box_mouse dd aEdit_box_mouse
version_ed dd aVersion_ed
init_checkbox dd aInit_checkbox
check_box_draw dd aCheck_box_draw
check_box_mouse dd aCheck_box_mouse
version_ch dd aVersion_ch
option_box_draw dd aOption_box_draw
option_box_mouse dd aOption_box_mouse
version_op dd aVersion_op
dd 0,0
aEdit_box_draw db 'edit_box_draw',0
aEdit_box_key db 'edit_box_key',0
aEdit_box_mouse db 'edit_box_mouse',0
aVersion_ed db 'version_ed',0
aInit_checkbox db 'init_checkbox2',0
aCheck_box_draw db 'check_box_draw2',0
aCheck_box_mouse db 'check_box_mouse2',0
aVersion_ch db 'version_ch2',0
aOption_box_draw db 'option_box_draw',0
aOption_box_mouse db 'option_box_mouse',0
aVersion_op db 'version_op',0
check1 check_box2 (10 shl 16 + 12),(45 shl 16 + 12),5,0x80AABBCC,0,0,check_text1,ch_flag_en check1 check_box2 (10 shl 16 + 12),(45 shl 16 + 12),5,0x80AABBCC,0,0,check_text1,ch_flag_en

View File

@@ -0,0 +1,117 @@
;
; Export functions
;
E_LIB lib_init
E_LIB version
E_LIB edit_box_draw
E_LIB edit_box_key
E_LIB edit_box_key_safe
E_LIB edit_box_mouse
E_LIB edit_box_set_text
E_LIB version_ed
E_LIB init_checkbox, init_checkbox2
E_LIB check_box_draw, check_box_draw2
E_LIB check_box_mouse, check_box_mouse2
E_LIB version_ch, version_ch2
E_LIB option_box_draw
E_LIB option_box_mouse
E_LIB version_op
E_LIB scrollbar_v_draw
E_LIB scrollbar_v_mouse
E_LIB scrollbar_h_draw
E_LIB scrollbar_h_mouse
E_LIB version_scrollbar
E_LIB dbutton_draw
E_LIB dbutton_mouse
E_LIB version_dbutton
E_LIB menu_bar_draw
E_LIB menu_bar_mouse
E_LIB menu_bar_activate
E_LIB version_menu_bar
E_LIB FileBrowser_draw
E_LIB FileBrowser_mouse
E_LIB FileBrowser_key
E_LIB version_FileBrowser
E_LIB tl_data_init
E_LIB tl_data_clear
E_LIB tl_info_clear
E_LIB tl_key
E_LIB tl_mouse
E_LIB tl_draw
E_LIB tl_info_undo
E_LIB tl_info_redo
E_LIB tl_node_add
E_LIB tl_node_set_data
E_LIB tl_node_get_data
E_LIB tl_node_delete
E_LIB tl_cur_beg
E_LIB tl_cur_next
E_LIB tl_cur_perv
E_LIB tl_node_close_open
E_LIB tl_node_lev_inc
E_LIB tl_node_lev_dec
E_LIB tl_node_move_up
E_LIB tl_node_move_down
E_LIB tl_node_poi_get_info
E_LIB tl_node_poi_get_next_info
E_LIB tl_node_poi_get_data
E_LIB tl_save_mem
E_LIB tl_load_mem
E_LIB tl_get_mem_size
E_LIB version_tree_list
E_LIB PathShow_prepare
E_LIB PathShow_draw
E_LIB version_PathShow
E_LIB ted_but_sumb_upper
E_LIB ted_but_sumb_lover
E_LIB ted_but_convert_by_table
E_LIB ted_can_save
E_LIB ted_clear
E_LIB ted_delete
E_LIB ted_draw
E_LIB ted_init
E_LIB ted_init_scroll_bars
E_LIB ted_init_syntax_file
E_LIB ted_is_select
E_LIB ted_key
E_LIB ted_mouse
E_LIB ted_open_file
E_LIB ted_save_file
E_LIB ted_text_add
E_LIB ted_but_select_word
E_LIB ted_but_cut
E_LIB ted_but_copy
E_LIB ted_but_paste
E_LIB ted_but_undo
E_LIB ted_but_redo
E_LIB ted_but_reverse
E_LIB ted_but_find
E_LIB ted_but_replace
E_LIB ted_text_colored
E_LIB ted_go_to_position
E_LIB version_text_edit
E_LIB frame_draw
E_LIB version_frame
E_LIB progressbar_draw
E_LIB progressbar_progress
E_LIB tooltip_init
E_LIB tooltip_delete
E_LIB tooltip_test_show
E_LIB tooltip_mouse
E_LIB get_font_size
purge E_LIB

View File

@@ -0,0 +1,24 @@
align 4
import_box_lib:
macro E_LIB n, lfn
{
if n eq lib_init
dd sz_#n
else if defined sz_#n
n dd sz_#n
end if
}
include 'export.inc'
dd 0,0
macro E_LIB n, lfn
{
if used n
if lfn eq
sz_#n db `n,0
else
sz_#n db `lfn,0
end if
end if
}
include 'export.inc'