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/'
;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
info_len = $ - info_str
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 10
db 'Command-line usage:',10
db ' kpack infile [outfile]',10
db 'If no output file is specified,',10
db ' packed data will be written back to input file',10
db ' path_to_infile with zero',10
db 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
errload_str db 'Cannot load input file',10
errload_len = $ - errload_str
@ -125,8 +127,6 @@ system_dir_ProcLib db '/sys/lib/proc_lib.obj',0
;---------------------------------------------------------------------
align 4
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, \
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
edit1 edit_box 160, 62, 1+22, 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
edit3 edit_box 160, 62, 33+22, 0xffffff, 0xff, 0x80ff, 0, 0x8000,256, path, mouse_dd, 0, 6,6
edit1 edit_box 160, 60, 1, 0xffffff, 0xff, 0x80ff, 0, 0x8000, 256, inname, mouse_dd, 0, 11,11
edit2 edit_box 160, 60, 17, 0xffffff, 0xff, 0x80ff, 0, 0x8000,256, outname, mouse_dd, 0, 7,7
edit3 edit_box 160, 60, 33, 0xffffff, 0xff, 0x80ff, 0, 0x8000,256, path, mouse_dd, 0, 6,6
editboxes_end:
mouse_dd dd 0

View File

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

View File

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

View File

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

View File

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