forked from KolibriOS/kolibrios
add macros for load library. See editbox_ex and load_lib.mac.
Alfa version git-svn-id: svn://kolibrios.org@1064 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
94ab6bf2f1
commit
5753a02a42
@ -9,94 +9,14 @@ use32 ;
|
||||
dd mem ; Ž¡ê¥¬ ¨á¯®«ì§ã¥¬®© ¯ ¬ïâ¨, ¤«ï á⥪ ®â¢¥¤¥¬ 0å100 ¡ ©â ¨ ¢ë஢¨¬ £à¨æã 4 ¡ ©â
|
||||
dd mem ; à ᯮ«®¦¨¬ ¯®§¨æ¨î á⥪ ¢ ®¡« á⨠¯ ¬ïâ¨, áà §ã § ⥫®¬ ¯à®£à ¬¬ë. ‚¥àè¨ á⥪ ¢ ¤¨ ¯ §®¥ ¯ ¬ïâ¨, 㪠§ ®¬ ¢ëè¥
|
||||
dd 0x0 ; 㪠§ ⥫ì áâபã á ¯ à ¬¥âà ¬¨.
|
||||
dd way_of_ini
|
||||
dd cur_dir_path
|
||||
include 'macros.inc'
|
||||
include 'editbox_ex.mac'
|
||||
include 'load_lib.mac'
|
||||
start:
|
||||
;Get way for ini file.
|
||||
mov edi,way_of_ini
|
||||
mov ecx,1024
|
||||
xor eax,eax
|
||||
cld
|
||||
repne scasb
|
||||
test ecx,ecx
|
||||
jz @f
|
||||
|
||||
mov esi,1024
|
||||
sub esi,ecx
|
||||
mov ecx,esi
|
||||
std
|
||||
mov al,'/'
|
||||
repne scasb
|
||||
test ecx,ecx
|
||||
jz next_way
|
||||
add edi,2
|
||||
@@:
|
||||
mov esi,ini_file
|
||||
cld
|
||||
|
||||
@@: lodsb
|
||||
test al,al
|
||||
jz @f
|
||||
stosb
|
||||
jmp @b
|
||||
|
||||
@@: xor eax,eax
|
||||
stosb
|
||||
|
||||
; load DLL
|
||||
mov ecx,way_of_ini
|
||||
mov eax, 68
|
||||
mov ebx, 19
|
||||
mcall
|
||||
test eax, eax
|
||||
jz next_way
|
||||
jmp import_init_
|
||||
next_way:
|
||||
mov ecx,ini_file
|
||||
mov eax, 68
|
||||
mov ebx, 19
|
||||
mcall
|
||||
test eax, eax
|
||||
jz exit
|
||||
|
||||
|
||||
|
||||
import_init_:
|
||||
; initialize import
|
||||
mov edx, eax
|
||||
mov esi,myimport
|
||||
import_loop:
|
||||
lodsd
|
||||
test eax, eax
|
||||
jz import_done
|
||||
push edx
|
||||
import_find:
|
||||
mov ebx, [edx]
|
||||
test ebx, ebx
|
||||
jz exit;import_not_found
|
||||
push eax
|
||||
@@:
|
||||
mov cl, [eax]
|
||||
cmp cl, [ebx]
|
||||
jnz import_find_next
|
||||
test cl, cl
|
||||
jz import_found
|
||||
inc eax
|
||||
inc ebx
|
||||
jmp @b
|
||||
import_find_next:
|
||||
pop eax
|
||||
add edx, 8
|
||||
jmp import_find
|
||||
import_found:
|
||||
pop eax
|
||||
mov eax, [edx+4]
|
||||
mov [esi-4], eax
|
||||
pop edx
|
||||
jmp import_loop
|
||||
import_done:
|
||||
|
||||
;universal load library/librarys
|
||||
load_library library_name, cur_dir_path, library_path, system_path, \
|
||||
err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
|
||||
mcall 40,0x27 ;ãáâ ®¢¨âì ¬ áªã ¤«ï ®¦¨¤ ¥¬ëå ᮡë⨩
|
||||
red_win:
|
||||
call draw_window ;¯¥à¢® ç «ì® ¥®¡å®¤¨¬® à¨á®¢ âì ®ª®
|
||||
@ -150,7 +70,7 @@ key:
|
||||
align 4
|
||||
draw_window: ;à¨á®¢ ¨¥ ®ª ¯à¨«®¦¥¨ï
|
||||
mcall 12,1
|
||||
mcall 0,(50*65536+390),(30*65536+200),0xb3AABBCC,0x805080DD,hed
|
||||
mcall 0,(50*65536+390),(30*65536+200),0x33AABBCC,0x805080DD,hed
|
||||
|
||||
push dword edit1
|
||||
call [edit_box_draw]
|
||||
@ -174,7 +94,13 @@ draw_window: ;
|
||||
ret
|
||||
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
;DATA ¤ ë¥
|
||||
ini_file db '/sys/lib/box_lib.obj',0
|
||||
system_path db '/sys/lib/box_lib.obj',0
|
||||
library_name db 'box_lib.obj',0
|
||||
err_message_found_lib db 'Sorry I cannot found library box_lib.obj',0
|
||||
head_f_i:
|
||||
head_f_l db 'System error',0
|
||||
err_message_import db 'Error on load import library box_lib.obj',0
|
||||
|
||||
myimport:
|
||||
|
||||
edit_box_draw dd aEdit_box_draw
|
||||
@ -239,7 +165,9 @@ op_text: ;
|
||||
.3 db 'Option_Box #3'
|
||||
.e3:
|
||||
ed_buffer rb 100
|
||||
way_of_ini rb 1024
|
||||
;-----------------------
|
||||
cur_dir_path rb 4096
|
||||
library_path rb 4096
|
||||
i_end:
|
||||
rb 1024
|
||||
mem:
|
Binary file not shown.
254
programs/develop/libraries/box_lib/trunk/load_lib.mac
Normal file
254
programs/develop/libraries/box_lib/trunk/load_lib.mac
Normal file
@ -0,0 +1,254 @@
|
||||
;14.04.2009 - a macros for code load library the box_lib.obj from '/sys/lib/' or current dirrectory.
|
||||
; The macros for load any library/libraries:
|
||||
; Copyright (c) 2009, <Lrz>
|
||||
; All rights reserved.
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
; * Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
; * Redistributions in binary form must reproduce the above copyright
|
||||
; notice, this list of conditions and the following disclaimer in the
|
||||
; documentation and/or other materials provided with the distribution.
|
||||
; * Neither the name of the <organization> nor the
|
||||
; names of its contributors may be used to endorse or promote products
|
||||
; derived from this software without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY Alexey Teplov aka <Lrz> ''AS IS'' AND ANY
|
||||
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;*****************************************************************************
|
||||
; This macros based on source code:
|
||||
; <Lrz> - Alexey Teplov / Àëåêñåé Òåïëîâ
|
||||
; Mario79, Mario - Marat Zakiyanov / Ìàðàò Çàêèÿíîâ
|
||||
; Diamondz - Evgeny Grechnikov / Åâãåíèé Ãðå÷íèêîâ
|
||||
;------------------------
|
||||
; DESCRIPTION
|
||||
; Macro load_library
|
||||
; Logick of work.
|
||||
; A first time we must to check system path, where I belive find a system library. System path is "/sys/lib/".
|
||||
; If I cannot found my library, i must to check second way. Second way is current dirrectory.
|
||||
; If we cannot load library, we must show the error message:
|
||||
; "I'm sorry,the programm cannot found system library box_lib.obj."
|
||||
; "The find was make on 2 ways: /sys/lib/ and current dirrectory."
|
||||
;
|
||||
; ebx,library_name
|
||||
; esi,cur_dir_path
|
||||
; edi,library_path
|
||||
;---------------------------------------------------------------------
|
||||
; Macro test_load_library
|
||||
; A first time we must to check own path in current dirrectory the program, where I belive find a system library.
|
||||
; If I cannot found my library, i must to check second way. Second way is system path a "/sys/lib/".
|
||||
; If we cannot load library, we must show the error message:
|
||||
; "I'm sorry,the programm cannot found system library box_lib.obj."
|
||||
; "The find was make on 2 ways: /sys/lib/ and current dirrectory."
|
||||
|
||||
macro load_library library_name, cur_dir_path, library_path, system_path, err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
|
||||
{
|
||||
local end_steep
|
||||
;---------------------------------------------------------------------
|
||||
; loading Box_Lib library
|
||||
|
||||
mcall 68,19,system_path ; load of sys directory
|
||||
test eax,eax
|
||||
jnz end_steep
|
||||
|
||||
mov ebx,library_name
|
||||
mov esi,cur_dir_path
|
||||
mov edi,library_path
|
||||
|
||||
copy_path ;the macros making way /current pach a program/+ name system library
|
||||
|
||||
mcall 68,19,library_path ; load of alternative
|
||||
test eax,eax
|
||||
jnz end_steep
|
||||
|
||||
show_error_window err_message_found_lib, head_f_l ;show error message /create window
|
||||
|
||||
end_steep:
|
||||
|
||||
import_boxlib myimport, err_message_import, head_f_i ;import
|
||||
;---------------------------------------------------------------------
|
||||
}
|
||||
|
||||
|
||||
macro test_load_library library_name, cur_dir_path, library_path, system_path, err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
|
||||
{
|
||||
local end_steep
|
||||
;---------------------------------------------------------------------
|
||||
; loading Box_Lib library
|
||||
mov ebx,library_name
|
||||
mov esi,cur_dir_path
|
||||
mov edi,library_path
|
||||
|
||||
copy_path ;the macros making way /current pach a program/+ name system library
|
||||
|
||||
mcall 68,19,library_path ; load of alternative
|
||||
test eax,eax
|
||||
jnz end_steep
|
||||
|
||||
mcall 68,19,system_path ; load of sys directory
|
||||
test eax,eax
|
||||
jnz end_steep
|
||||
|
||||
show_error_window err_message_found_lib, head_f_l ;show error message /create window
|
||||
|
||||
end_steep:
|
||||
|
||||
import_boxlib myimport, err_message_import, head_f_i ;import
|
||||
;---------------------------------------------------------------------
|
||||
}
|
||||
|
||||
macro load_libraries library_name, cur_dir_path, library_path, system_path, err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
|
||||
{
|
||||
local end_steep
|
||||
;---------------------------------------------------------------------
|
||||
; loading Box_Lib library
|
||||
|
||||
mcall 68,19,system_path ; load of sys directory
|
||||
test eax,eax
|
||||
jnz end_steep
|
||||
|
||||
mov ebx,library_name
|
||||
mov esi,cur_dir_path
|
||||
mov edi,library_path
|
||||
|
||||
copy_path ;the macros making way /current pach a program/+ name system library
|
||||
|
||||
mcall 68,19,library_path ; load of alternative
|
||||
test eax,eax
|
||||
jnz end_steep
|
||||
|
||||
show_error_window err_message_found_lib, head_f_l ;show error message /create window
|
||||
|
||||
end_steep:
|
||||
|
||||
import_boxlib myimport, err_message_import, head_f_i ;import
|
||||
;---------------------------------------------------------------------
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
macro copy_path
|
||||
{
|
||||
local copy_path
|
||||
;---------------------------------------------------------------------
|
||||
; mov ebx,library_name
|
||||
; mov esi,cur_dir_path
|
||||
; mov edi,library_path
|
||||
|
||||
copy_path:
|
||||
xor eax,eax
|
||||
cld
|
||||
.lp1:
|
||||
lodsb
|
||||
stosb
|
||||
test eax,eax
|
||||
jnz .lp1
|
||||
mov esi,edi
|
||||
|
||||
std
|
||||
.lp2:
|
||||
lodsb
|
||||
cmp al,'/'
|
||||
jnz .lp2
|
||||
mov edi,esi
|
||||
mov esi,ebx
|
||||
add edi,2
|
||||
|
||||
|
||||
cld
|
||||
.lp3:
|
||||
lodsb
|
||||
stosb
|
||||
test eax,eax
|
||||
jnz .lp3
|
||||
;---------------------------------------------------------------------
|
||||
}
|
||||
|
||||
macro show_error_window err_message, head
|
||||
{
|
||||
local red_win
|
||||
local still
|
||||
local button
|
||||
|
||||
mcall 40,0x5 ;set mask on events rewraw window and get id button.
|
||||
red_win:
|
||||
;draw_window:
|
||||
mcall 12, 1
|
||||
mcall 0, <0,300>, <0,100>, 0x33AABBCC, 0x805080D0, head
|
||||
mcall 4, <10,10>, 0x90000000, err_message; _found_lib
|
||||
mcall 12, 2
|
||||
align 4
|
||||
still: ;main loop
|
||||
mcall 10 ;wait event
|
||||
dec eax
|
||||
jz red_win
|
||||
|
||||
sub eax,2
|
||||
jnz still ;go to main loop
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
button:
|
||||
mcall 17 ;get id button
|
||||
test ah,ah ;if in ah 0, then go to still
|
||||
jz still
|
||||
mcall -1
|
||||
}
|
||||
|
||||
macro import_boxlib myimport, err_message_import, head_f_i
|
||||
{
|
||||
local import_loop
|
||||
local import_find
|
||||
local lp
|
||||
local import_find_next
|
||||
local import_found
|
||||
local import_done
|
||||
local exit
|
||||
; initialize import
|
||||
mov edx, eax
|
||||
mov esi,myimport
|
||||
import_loop:
|
||||
lodsd
|
||||
test eax, eax
|
||||
jz import_done
|
||||
push edx
|
||||
import_find:
|
||||
mov ebx, [ds:edx]
|
||||
test ebx, ebx
|
||||
jz exit ;import_not_found
|
||||
push eax
|
||||
lp:
|
||||
mov cl, [ds:eax]
|
||||
cmp cl, [ds:ebx]
|
||||
jnz import_find_next
|
||||
test cl, cl
|
||||
jz import_found
|
||||
inc eax
|
||||
inc ebx
|
||||
jmp lp
|
||||
import_find_next:
|
||||
pop eax
|
||||
add edx, 8
|
||||
jmp import_find
|
||||
import_found:
|
||||
pop eax
|
||||
mov eax, [ds:edx+4]
|
||||
mov [esi-4], eax
|
||||
pop edx
|
||||
jmp import_loop
|
||||
exit:
|
||||
add esp,4
|
||||
|
||||
show_error_window err_message_import, head_f_i ;show error message /create window
|
||||
|
||||
import_done:
|
||||
;---------------------------------------------------------------------
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<Lrz> Теплов Алексей, Челябинск.
|
||||
Пример простого испльзования editbox в библиотеке,
|
||||
Пример простого использования editbox в библиотеке,
|
||||
EditBox переписан для работы в библиотеке.
|
||||
Дата 25.06.2008
|
||||
сделана поддержка запуска ассемблерного примера при расположении текущей библиотеки по 2-м местам
|
||||
@ -10,5 +10,6 @@ EditBox
|
||||
На данный момент, носит эксперементальный, тестовый характер.
|
||||
Библиотеку box_lib.obj нужно поместить в папку с выполняющейся программой editbox_ex, или по адресу /sys/lib/? но тогда нужно подменить путь в файле ini_file на путь к библиотеке
|
||||
. Пример сам вычисляет путь к библиотеке, не зависимо от своего месторасположения
|
||||
15.04.2009 - добавлен макрос load_lib.mac - универсальный для загрузки любой библиотеки/библиотек.
|
||||
13.09.2009 - обработка клавишь NUM, Caps,Scroll Lock. При нажатии на них, не происходит отображение символа.
|
||||
24.09.2007 - сделал поддрежку checkbox. Добавил ошибки, программа глючит очень серьезно :(
|
Loading…
Reference in New Issue
Block a user