Kpack v0.15

1) Window Y=4, B = 1
2) Refresh lenght of data after Editbox editing
3) Changed format of start parameter - longer path (total length 255 + zero).


git-svn-id: svn://kolibrios.org@1688 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2010-11-06 18:12:33 +00:00
parent 309387e070
commit fb9f6b3fef
5 changed files with 140 additions and 215 deletions

View File

@ -10,19 +10,21 @@ definoutname db 0
defpath db '/RD/1/' defpath db '/RD/1/'
;curedit dd 0 ;curedit dd 0
info_str db 'KPack - Kolibri Packer, version 0.13',10 info_str db 'KPack - Kolibri Packer, version 0.15',10
db 'Uses LZMA v4.32 compression library',10,10 db 'Uses LZMA v4.32 compression library',10,10
info_len = $ - info_str info_len = $ - info_str
usage_str db 'Written by diamond in 2006, 2007, 2009 specially for KolibriOS',10 usage_str db 'Written by diamond in 2006, 2007, 2009 specially for KolibriOS',10
db 'Disassembled code, using Box_Lib, Proc_Lib and OpenDialog',10
db ' by Mario79, 2010',10
db 'LZMA is copyright (c) 1999-2005 by Igor Pavlov',10 db 'LZMA is copyright (c) 1999-2005 by Igor Pavlov',10
db 10 db 10
db 'Command-line usage:',10 db 'Command-line usage:',10
db ' kpack infile [outfile]',10 db ' path_to_infile with zero',10
db 'If no output file is specified,',10
db ' packed data will be written back to input file',10
db 10 db 10
db 'Window usage:',10 db 'Window usage:',10
db " enter input file name, output file name and press needed button",10 db 'Select file with PATH-button and press needed button',10
db ' or enter input and output file name,',10
db ' enter path and press needed button',10
usage_len = $ - usage_str usage_len = $ - usage_str
errload_str db 'Cannot load input file',10 errload_str db 'Cannot load input file',10
errload_len = $ - errload_str errload_len = $ - errload_str
@ -125,8 +127,6 @@ system_dir_ProcLib db '/sys/lib/proc_lib.obj',0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
l_libs_start: l_libs_start:
; load_library boxlib_name,cur_dir_path,buf_cmd_lin,system_path,\
; err_message_found_lib,head_f_l,myimport,err_message_import,head_f_i
library01 l_libs system_dir_Boxlib+9, cur_dir_path, library_path, system_dir_Boxlib, \ library01 l_libs system_dir_Boxlib+9, cur_dir_path, library_path, system_dir_Boxlib, \
err_message_found_lib1, head_f_l, Box_lib_import, err_message_import1, head_f_i err_message_found_lib1, head_f_l, Box_lib_import, err_message_import1, head_f_i
@ -178,9 +178,9 @@ start_temp_file_name: db 'temp.bin',0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
edit1 edit_box 160, 62, 1+22, 0xffffff, 0xff, 0x80ff, 0, 0x8000, 256, inname, mouse_dd, 0, 11,11 edit1 edit_box 160, 60, 1, 0xffffff, 0xff, 0x80ff, 0, 0x8000, 256, inname, mouse_dd, 0, 11,11
edit2 edit_box 160, 62, 17+22, 0xffffff, 0xff, 0x80ff, 0, 0x8000,256, outname, mouse_dd, 0, 7,7 edit2 edit_box 160, 60, 17, 0xffffff, 0xff, 0x80ff, 0, 0x8000,256, outname, mouse_dd, 0, 7,7
edit3 edit_box 160, 62, 33+22, 0xffffff, 0xff, 0x80ff, 0, 0x8000,256, path, mouse_dd, 0, 6,6 edit3 edit_box 160, 60, 33, 0xffffff, 0xff, 0x80ff, 0, 0x8000,256, path, mouse_dd, 0, 6,6
editboxes_end: editboxes_end:
mouse_dd dd 0 mouse_dd dd 0

View File

@ -3,7 +3,6 @@ params:
rb 256 rb 256
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
color_table rd 10 color_table rd 10
skinheight rd 1
innamelen rd 1 innamelen rd 1
inname rb 256 ;48 inname rb 256 ;48
@ -73,7 +72,8 @@ filename_area:
procinfo: procinfo:
rb 1024 rb 1024
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; Deconpress area ; Deconpress data area start
;---------------------------------------------------------------------
align 4 align 4
unpack.p rb 0x1F36*4 unpack.p rb 0x1F36*4
unpack.code_: unpack.code_:
@ -86,7 +86,11 @@ unpack.rep2 rd 1
unpack.rep3 rd 1 unpack.rep3 rd 1
unpack.previousByte rb 1 unpack.previousByte rb 1
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; Compress area ; Deconpress data area end
;---------------------------------------------------------------------
;---------------------------------------------------------------------
; Compress data area start
;---------------------------------------------------------------------
align 4 align 4
_lenEncoder: _lenEncoder:
rd 8451 rd 8451
@ -218,3 +222,5 @@ _pos: rd 1
_streamPos: rd 1 _streamPos: rd 1
pack_length: rd 1 pack_length: rd 1
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; Compress data area end
;---------------------------------------------------------------------

View File

@ -1,4 +1,20 @@
; kpack = Kolibri Packer ; kpack = Kolibri Packer
;---------------------------------------------------------------------
; version: 0.15
; last update: 06/11/2010
; changed by: Marat Zakiyanov aka Mario79, aka Mario
; changes: 1) Window Y=4, B=1
; 2) Refresh lenght of data after Editbox editing
; 3) Changed format of start parameter -
; longer path (total length 255 + zero).
;---------------------------------------------------------------------
; version: 0.14
; last update: 03/11/2010
; changed by: Marat Zakiyanov aka Mario79, aka Mario
; changes: select path with OpenDialog,
; using Box_Lib and Proc_Lib
;---------------------------------------------------------------------
; Kpack - Kolibri Packer
; Kolibri version ; Kolibri version
; Written by diamond in 2006, 2007 specially for KolibriOS ; Written by diamond in 2006, 2007 specially for KolibriOS
; ;
@ -16,12 +32,12 @@ use32
dd 1 dd 1
dd START dd START
dd IM_END dd IM_END
dd I_END ;memf dd I_END
dd stacktop dd stacktop
dd params dd params
dd cur_dir_path dd cur_dir_path
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
include '..\..\..\macros.inc' include '../../../macros.inc'
include '../../../develop/libraries/box_lib/trunk/box_lib.mac' include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
include '../../../develop/libraries/box_lib/load_lib.mac' include '../../../develop/libraries/box_lib/load_lib.mac'
@use_library @use_library
@ -30,6 +46,10 @@ START:
mcall 68,11 mcall 68,11
mcall 40,100111b mcall 40,100111b
load_libraries l_libs_start,load_lib_end
cmp eax,-1
je exit
call clear_messages call clear_messages
; set default path = /RD/1/ ; set default path = /RD/1/
mov esi,defpath mov esi,defpath
@ -39,59 +59,39 @@ START:
movsd movsd
; get system window info ; get system window info
mcall 48,3,color_table,40 mcall 48,3,color_table,40
inc ebx ;--------------------------------------
mcall xor eax,eax
mov [skinheight],eax cmp [params],al
jmp default je default
; check command line
mov edi,path
mov esi,params mov esi,params
mov [esi+100h],byte 0 call copy_1
;--------------------------------------
parse_opt:
call skip_spaces
test al,al
jz default
sub esi,2
std
@@:
lodsb
dec edi
cmp al,byte '/'
jnz @r
mov [edi-1],byte 0
mov edi,inname mov edi,inname
call copy_name add esi,2
test al,al push esi
jz outeqin call copy_1
pop esi
mov edi,outname mov edi,outname
call copy_name call copy_1
test al,al ;---------------------------------------------------------------------
jnz default call set_editbox_position_all
;-------------------------------------- ;---------------------------------------------------------------------
doit:
call draw_window call draw_window
call pack call pack
jmp still jmp OD_initialization
;--------------------------------------------------------------------- ;*********************************************************************
clear_messages:
xor eax,eax
mov ecx,80*20/4+1
mov edi,message_mem
rep stosd
ret
;---------------------------------------------------------------------
exit:
xor eax,eax
dec eax
mcall
;--------------------------------------
outeqin:
mov ecx,256/4+1
mov esi,inname-4
mov edi,outname-4
rep movsd
jmp doit
;---------------------------------------------------------------------
default: default:
load_libraries l_libs_start,load_lib_end
cmp eax,-1
je exit
mov esi,definoutname mov esi,definoutname
mov edi,esi mov edi,esi
xor ecx,ecx xor ecx,ecx
@ -111,15 +111,12 @@ load_libraries l_libs_start,load_lib_end
mov edi,outname mov edi,outname
rep movsb rep movsb
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; mov edi,fname_buf call set_editbox_position_all
; mov esi,path4 ;---------------------------------------------------------------------
; call copy_1 OD_initialization:
;OpenDialog initialisation ;OpenDialog initialisation
push dword OpenDialog_data push dword OpenDialog_data
call [OpenDialog_Init] call [OpenDialog_Init]
;---------------------------------------------------------------------
call set_editbox_position_all
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
red: red:
call draw_window call draw_window
@ -146,6 +143,18 @@ still:
jmp still jmp still
;********************************************************************* ;*********************************************************************
clear_messages:
xor eax,eax
mov ecx,80*20/4+1
mov edi,message_mem
rep stosd
ret
;*********************************************************************
exit:
xor eax,eax
dec eax
mcall
;*********************************************************************
button: button:
; button pressed ; button pressed
mcall 17 mcall 17
@ -190,6 +199,10 @@ nounpack:
jmp still jmp still
;********************************************************************* ;*********************************************************************
OpenDialog_start: OpenDialog_start:
mov esi,path
mov edi,temp_dir_pach
call copy_1
push dword OpenDialog_data push dword OpenDialog_data
call [OpenDialog_Start] call [OpenDialog_Start]
cmp [OpenDialog_data.status],1 cmp [OpenDialog_data.status],1
@ -198,22 +211,17 @@ OpenDialog_start:
mov esi,filename_area mov esi,filename_area
mov edi,inname mov edi,inname
call copy_1 call copy_1
sub edi,inname
mov [innamelen],edi
mov esi,filename_area mov esi,filename_area
mov edi,outname mov edi,outname
call copy_1 call copy_1
sub edi,outname
mov [outnamelen],edi
mov esi,temp_dir_pach mov esi,temp_dir_pach
mov edi,path mov edi,path
call copy_1 call copy_1
sub edi,path
dec edi
mov [pathlen],edi
call refresh_editbox_data
call set_editbox_position_all call set_editbox_position_all
call draw_editbox call draw_editbox
@ -230,6 +238,35 @@ copy_1:
jnz @r jnz @r
ret ret
;********************************************************************* ;*********************************************************************
refresh_editbox_data:
mov esi,inname
mov edi,innamelen
call refresh_data
mov esi,outname
mov edi,outnamelen
call refresh_data
mov esi,path
mov edi,pathlen
call refresh_data
ret
;*********************************************************************
refresh_data:
push esi
xor eax,eax
cld
@@:
lodsb
test eax,eax
jnz @r
pop eax
sub esi,eax
dec esi
mov [edi],esi
ret
;*********************************************************************
set_editbox_position_all: set_editbox_position_all:
mov ebx,inname mov ebx,inname
mov edi,edit1 mov edi,edit1
@ -258,14 +295,6 @@ key:
jmp still jmp still
;********************************************************************* ;*********************************************************************
onenter:
; cmp [curedit],inname
; jnz @f
push 2
pop eax
jmp nounpack
;*********************************************************************
get_full_name: get_full_name:
push esi push esi
mov esi,path mov esi,path
@ -327,14 +356,10 @@ newline:
x2: x2:
mov [message_cur_pos],edx mov [message_cur_pos],edx
; update window ; update window
mov ecx,[skinheight] mcall 13,<6,414>,<54,222>,[color_table+20]
shl ecx,16
add ecx,3700DEh
mcall 13,<9,417>,,[color_table+20]
;-------------------------------------- ;--------------------------------------
draw_messages: draw_messages:
mov ebx,[skinheight] mov ebx,12 shl 16+60
add ebx,3Ch+12*10000h
mov edi,message_mem mov edi,message_mem
;-------------------------------------- ;--------------------------------------
@@: @@:
@ -358,32 +383,27 @@ draw_messages:
draw_window: draw_window:
; start redraw ; start redraw
mcall 12,1 mcall 12,1
mov edi,[skinheight]
;-------------------------------------- ;--------------------------------------
; define window ; define window
xor eax,eax xor eax,eax
mov ecx,100 shl 16+286 mov ecx,100 shl 16+306
add ecx,edi
mov edx,[color_table+20] mov edx,[color_table+20]
add edx,13000000h add edx,34000000h
; push edi
xor esi,esi xor esi,esi
mcall ,<100,435>,,,,fullname ;temp_dir_pach ;caption_str xor edi,edi
; pop edi mcall ,<100,436>,,,,caption_str
mcall 9,procinfo,-1 mcall 9,procinfo,-1
;-------------------------------------- ;--------------------------------------
; draw lines and frame ; draw lines and frame
call draw_lines call draw_lines
; draw buttons ; draw buttons
call draw_bittons call draw_bittons
; infile, outfile, path strings
; call draw_strings
; draw messages ; draw messages
call draw_messages call draw_messages
; draw editbox's ; draw editbox's
mov eax,[procinfo+42] mov eax,[procinfo+42]
sub eax,65+72+10 sub eax,65+72+10
mov [edit1.width],eax ; óñòàíàâëèâàåì øèðèíó òåêñòîâûõ ïîëåé mov [edit1.width],eax
mov [edit2.width],eax mov [edit2.width],eax
mov [edit3.width],eax mov [edit3.width],eax
@ -416,51 +436,23 @@ set_editbox_position:
ret ret
;********************************************************************* ;*********************************************************************
draw_lines: draw_lines:
; mov edi,[skinheight] mov ecx,2 shl 16+12*3
; lines - horizontal
; mov ebx,8 shl 16+352
; mov ecx,edi
; shl ecx,16
; or ecx,edi
; add ecx,2 shl 16+2
; mcall 38,,,[color_table+36]
; mov esi,3
;@@:
; add ecx,12 shl 16+12
; mcall
; dec esi
; jnz @r
;--------------------------------------
; lines - vertical
; sub ecx,36 shl 16
; mcall ,<8,8>
; add ebx,52 shl 16+52
; mcall
; add ebx,292 shl 16+292
; mcall
;--------------------------------------
mov edi,[skinheight]
mov ecx,edi
shl ecx,16
or ecx,edi
add ecx,2 shl 16+2+12*3
; add ecx,12*3
; draw frame for messages data ; draw frame for messages data
push ecx push ecx
add ecx,52 shl 16+16 add ecx,50 shl 16+16
mcall 38,<8,425>,,[color_table+36] mcall 38,<3,423>,,[color_table+36]
add ecx,224*(1 shl 16+1) add ecx,224*(1 shl 16+1)
mcall mcall
sub cx,224 sub cx,224
mcall ,<8,8> mcall ,<3,3>
mcall ,<426,426> mcall ,<423,423>
pop ecx pop ecx
ret ret
;********************************************************************* ;*********************************************************************
draw_bittons: draw_bittons:
; define compress button ; define compress button
mov cx,18 mov cx,18
mcall 8,<354,72>,,2,[color_table+36] mcall 8,<351,72>,,2,[color_table+36]
; uncompress button ; uncompress button
add ecx,18 shl 16 add ecx,18 shl 16
inc edx inc edx
@ -469,30 +461,18 @@ draw_bittons:
; question button ; question button
push esi push esi
mov dl,7 mov dl,7
mcall ,<417,9> mcall ,<414,9>
shr ecx,16 shr ecx,16
lea ebx,[ecx+1A40002h] lea ebx,[ecx+1A10002h]
mcall 4,,[color_table+28],aQuestion,1 mcall 4,,[color_table+28],aQuestion,1
; mov al,8
pop esi pop esi
; define settings buttons ; define settings buttons
; mov ebx,9 shl 16+50 mov ecx,16*2+2
lea ecx,[edi+2]
add ecx,16*2
shl ecx,16 shl ecx,16
mov cx,13 mov cx,13
; push 4 mcall 8,<6,50>,,4
; pop edx
;--------------------------------------
;@@:
; mcall
; add ecx,12 shl 16
; inc edx
; cmp edx,6
; jbe @b
mcall 8,<9,50>,,4
; text on settings buttons ; text on settings buttons
lea ebx,[edi+5+0C0000h] mov ebx,9 shl 16+5
mov al,4 mov al,4
mov ecx,[color_table+28] mov ecx,[color_table+28]
push buttons1names push buttons1names
@ -507,46 +487,9 @@ draw_bittons:
cmp [edx-6],byte ' ' cmp [edx-6],byte ' '
jnz @b jnz @b
; text on compress and decompress buttons ; text on compress and decompress buttons
lea ebx,[edi+8+1720000h]
or ecx,80000000h or ecx,80000000h
mcall ,,,aCompress mcall ,<367,7>,,aCompress
lea ebx,[edi+1Ah+16A0000h] mcall ,<359,25>,,aDecompress
mcall ,,,aDecompress
ret
;*********************************************************************
copy_name:
lea edx,[edi+256]
;--------------------------------------
@@:
lodsb
cmp al,' '
jbe copy_name_done
stosb
cmp edi,edx
jb @b
;--------------------------------------
@@:
lodsb
cmp al,' '
ja @b
;--------------------------------------
copy_name_done:
dec esi
sub edx,256
sub edi,edx
mov [edx-4],edi
;--------------------------------------
skip_spaces:
lodsb
cmp al,0
jz @f
cmp al,' '
jbe skip_spaces
;--------------------------------------
@@:
dec esi
ret ret
;********************************************************************* ;*********************************************************************
;Pack procedures ;Pack procedures

View File

@ -1,7 +1,6 @@
;********************************************************************* ;*********************************************************************
pack: pack:
; call clear_edit_points call refresh_editbox_data
; and [curedit],0
; clear messages ; clear messages
call clear_messages call clear_messages
; display logo ; display logo
@ -34,9 +33,7 @@ inopened:
test ebx,ebx test ebx,ebx
jz infileerr jz infileerr
; maximum memory requests: 2*insize + 2*(maxoutsize+400h) + worksize ; maximum memory requests: 2*insize + 2*(maxoutsize+400h) + worksize
; mov esi,[memf]
xor esi,esi xor esi,esi
; mov [infile],esi
add esi,ebx add esi,ebx
mov [inbuftmp],esi mov [inbuftmp],esi
add esi,ebx add esi,ebx
@ -54,7 +51,6 @@ inopened:
mov [workmem],esi mov [workmem],esi
add ecx,ebx add ecx,ebx
add ecx,ecx add ecx,ecx
; add ecx,[memf]
; LZMA requires 0x448000 + dictsize*9.5 bytes for workmem, ; LZMA requires 0x448000 + dictsize*9.5 bytes for workmem,
and [lzma_dictsize],0 and [lzma_dictsize],0
push ecx push ecx
@ -77,10 +73,6 @@ inopened:
add eax,448000h add eax,448000h
pop ecx pop ecx
add ecx,eax add ecx,eax
; mcall 64,1
; test eax,eax
; jz mem_ok
mcall 68,12 mcall 68,12
@ -138,7 +130,7 @@ mem_ok:
jnz infileerr jnz infileerr
mov eax,[outfile] mov eax,[outfile]
mov [eax],dword 'KPCK' ;'KCPK' mov [eax],dword 'KPCK'
mov ecx,[insize] mov ecx,[insize]
mov [eax+4],dword ecx mov [eax+4],dword ecx
mov edi,eax mov edi,eax

View File

@ -1,7 +1,6 @@
;********************************************************************* ;*********************************************************************
unpack: unpack:
; call clear_edit_points call refresh_editbox_data
; and [curedit],0
; clear messages ; clear messages
call clear_messages call clear_messages
; display logo ; display logo
@ -27,15 +26,6 @@ unpack:
test ecx,ecx test ecx,ecx
jz infileerr jz infileerr
; mov ecx,[memf]
; mov [infile],ecx
; add ecx,eax
; mov [outfile],ecx
; mov [outfilebest],ecx
; mcall 64,1
; test eax,eax
; jnz memf1
mcall 68,12 mcall 68,12
mov [infile],eax mov [infile],eax
@ -62,12 +52,6 @@ unpack_err:
jmp write_string jmp write_string
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
@@: @@:
; mov ecx,[outfile]
; add ecx,dword [eax+4]
; mcall 64,1
; test eax,eax
; jnz memf1
mov ecx,[eax+4] mov ecx,[eax+4]
add ecx,[insize] add ecx,[insize]