Subversion Repositories Kolibri OS

Rev

Rev 1713 | Rev 2207 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1671 mario79 1
; kpack = Kolibri Packer
1688 mario79 2
;---------------------------------------------------------------------
1713 mario79 3
; version:	0.20
2058 mario79 4
; last update:  08/18/2011
5
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
6
; changes:      Checking for "rolled up" window
7
;---------------------------------------------------------------------
8
; version:	0.20
1713 mario79 9
; last update:  07/12/2010
10
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
11
; changes:      Added code for packing the kernel.mnt
12
;---------------------------------------------------------------------
1688 mario79 13
; version:	0.15
14
; last update:  06/11/2010
15
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
16
; changes:      1) Window Y=4, B=1
17
;               2) Refresh lenght of data after Editbox editing
18
;               3) Changed format of start parameter -
19
;                    longer path (total length 255 + zero).
20
;---------------------------------------------------------------------
21
; version:	0.14
22
; last update:  03/11/2010
23
; changed by:   Marat Zakiyanov aka Mario79, aka Mario
24
; changes:      select path with OpenDialog,
25
;               using Box_Lib and Proc_Lib
26
;---------------------------------------------------------------------
27
; Kpack - Kolibri Packer
1671 mario79 28
; Kolibri version
29
; Written by diamond in 2006, 2007 specially for KolibriOS
30
;
31
; Disassemled and corrected in 2010 specially for FASM
32
;            by Marat Zakiyanov aka Mario79, aka Mario
33
;
34
; Uses LZMA compression library by Igor Pavlov
35
; (for more information on LZMA and 7-Zip visit http://www.7-zip.org)
36
; (plain-C packer and ASM unpacker are ported by diamond)
37
;---------------------------------------------------------------------
38
use32
39
	org	0
40
 
41
	db 'MENUET01'
42
	dd 1
1681 mario79 43
	dd START
44
	dd IM_END
1688 mario79 45
	dd I_END
1681 mario79 46
	dd stacktop
47
	dd params
1686 mario79 48
	dd cur_dir_path
1671 mario79 49
;---------------------------------------------------------------------
1702 Lrz 50
include '../../../config.inc'		;for nightbuild
1688 mario79 51
include '../../../macros.inc'
1686 mario79 52
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
53
include '../../../develop/libraries/box_lib/load_lib.mac'
54
  @use_library
1681 mario79 55
 
1671 mario79 56
START:
1686 mario79 57
	mcall	68,11
58
	mcall	40,100111b
59
 
1688 mario79 60
load_libraries l_libs_start,load_lib_end
61
	cmp eax,-1
62
	je exit
63
 
1671 mario79 64
	call	clear_messages
65
; set default path = /RD/1/
66
	mov	esi,defpath
67
	mov	edi,path
68
	mov	[edi-4],dword 6
69
	movsw
70
	movsd
71
; get system window info
1681 mario79 72
	mcall	48,3,color_table,40
1688 mario79 73
;--------------------------------------
74
	xor	eax,eax
75
	cmp	[params],al
76
	je	default
77
 
78
	mov	edi,path
1671 mario79 79
	mov	esi,params
1688 mario79 80
	call	copy_1
1681 mario79 81
 
1688 mario79 82
	sub	esi,2
83
	std
84
@@:
85
	lodsb
86
	dec	edi
87
	cmp	al,byte '/'
88
	jnz	@r
89
 
90
	mov	[edi-1],byte 0
1671 mario79 91
	mov	edi,inname
1688 mario79 92
	add	esi,2
93
	push	esi
94
	call	copy_1
95
	pop	esi
1671 mario79 96
	mov	edi,outname
1688 mario79 97
	call	copy_1
98
;---------------------------------------------------------------------
99
	call	set_editbox_position_all
100
;---------------------------------------------------------------------
1671 mario79 101
	call	draw_window
102
	call	pack
1688 mario79 103
	jmp	OD_initialization
104
;*********************************************************************
1671 mario79 105
default:
106
	mov	esi,definoutname
107
	mov	edi,esi
108
	xor	ecx,ecx
109
	xor	eax,eax
110
	dec	ecx
111
	repnz	scasb
112
	not	ecx
113
	dec	ecx
114
	mov	[innamelen],ecx
115
	push	ecx
116
	push	esi
117
	mov	edi,inname
118
	rep	movsb
119
	pop	esi
120
	pop	ecx
121
	mov	[outnamelen],ecx
122
	mov	edi,outname
123
	rep	movsb
124
;---------------------------------------------------------------------
1688 mario79 125
	call	set_editbox_position_all
126
;---------------------------------------------------------------------
127
OD_initialization:
1686 mario79 128
;OpenDialog	initialisation
129
	push    dword OpenDialog_data
130
	call    [OpenDialog_Init]
131
;---------------------------------------------------------------------
132
red:
1671 mario79 133
	call	draw_window
1681 mario79 134
;--------------------------------------
1686 mario79 135
still:
1681 mario79 136
	mcall	10
1671 mario79 137
	dec	eax
1686 mario79 138
	jz	red
1681 mario79 139
 
1671 mario79 140
	dec	eax
1686 mario79 141
	jz	key
1681 mario79 142
 
1671 mario79 143
	dec	eax
1686 mario79 144
	jz	button
145
 
146
	push	dword edit1
147
	call	[edit_box_mouse]
148
 
149
	push	dword edit2
150
	call	[edit_box_mouse]
151
 
152
	push	dword edit3
153
	call	[edit_box_mouse]
154
 
1713 mario79 155
	push	dword check1
156
	call	[check_box_mouse]
157
 
1686 mario79 158
	jmp	still
159
;*********************************************************************
1713 mario79 160
tell_compress_mess:
161
	push	compressing_len
162
	pop	ecx
163
	mov	esi,compressing_str
164
	call	write_string
165
	ret
166
;*********************************************************************
167
clear_mess_and_displogo:
168
	call	refresh_editbox_data
169
; clear messages
170
	call	clear_messages
171
; display logo
172
	mov	esi,info_str
173
	push	info_len
174
	pop	ecx
175
	call	write_string
176
	ret
177
;*********************************************************************
1688 mario79 178
clear_messages:
179
	xor	eax,eax
180
	mov	ecx,80*20/4+1
181
	mov	edi,message_mem
182
	rep	stosd
183
	ret
184
;*********************************************************************
185
exit:
186
	xor	eax,eax
187
	dec	eax
188
	mcall
189
;*********************************************************************
1686 mario79 190
button:
1671 mario79 191
; button pressed
1681 mario79 192
	mcall	17
1671 mario79 193
	xchg	al,ah
194
	cmp	al,7
195
	jz	but7
1681 mario79 196
 
1671 mario79 197
	dec	eax
198
	jz	exit
1681 mario79 199
 
1671 mario79 200
	dec	eax
201
	jnz	nopack
1681 mario79 202
 
1713 mario79 203
	mov	eax,[check1+32]
204
	test	eax,10b
205
	jnz	@f
206
 
1671 mario79 207
	call	pack
1686 mario79 208
	jmp	still
1713 mario79 209
;---------------------------------------------------------------------
210
@@:
211
	call	kerpack
212
	jmp	still
1671 mario79 213
;---------------------------------------------------------------------
214
nopack:
215
	dec	eax
216
	jnz	nounpack
1713 mario79 217
 
1671 mario79 218
	call	unpack
1686 mario79 219
	jmp	still
1713 mario79 220
;---------------------------------------------------------------------
1671 mario79 221
but7:
222
	call	clear_messages
223
; display logo
224
	mov	esi,info_str
225
	push	info_len
226
	pop	ecx
227
	call	write_string
228
; display info
229
	mov	esi,usage_str
230
	mov	ecx,usage_len
231
	call	write_string
1686 mario79 232
	jmp	still
1671 mario79 233
;---------------------------------------------------------------------
234
nounpack:
235
	dec	eax
1686 mario79 236
	jnz	still
1681 mario79 237
 
1686 mario79 238
	call	OpenDialog_start
239
	jmp	still
240
;*********************************************************************
241
OpenDialog_start:
1688 mario79 242
	mov	esi,path
243
	mov	edi,temp_dir_pach
244
	call	copy_1
245
 
1686 mario79 246
	push    dword OpenDialog_data
247
	call    [OpenDialog_Start]
248
	cmp	[OpenDialog_data.status],1
249
	jne	@f
1681 mario79 250
 
1686 mario79 251
	mov	esi,filename_area
252
	mov	edi,inname
253
	call	copy_1
1681 mario79 254
 
1686 mario79 255
	mov	esi,filename_area
256
	mov	edi,outname
257
	call	copy_1
258
 
259
	mov	esi,temp_dir_pach
260
	mov	edi,path
261
	call	copy_1
262
 
1688 mario79 263
	call	refresh_editbox_data
264
 
1686 mario79 265
	call	set_editbox_position_all
1681 mario79 266
 
1686 mario79 267
	call	draw_editbox
1671 mario79 268
@@:
1686 mario79 269
	ret
270
;*********************************************************************
271
copy_1:
1671 mario79 272
	xor	eax,eax
1686 mario79 273
	cld
1671 mario79 274
@@:
1686 mario79 275
	lodsb
276
	stosb
1671 mario79 277
	test	eax,eax
1686 mario79 278
	jnz	@r
1671 mario79 279
	ret
1686 mario79 280
;*********************************************************************
1688 mario79 281
refresh_editbox_data:
282
	mov	esi,inname
283
	mov	edi,innamelen
284
	call	refresh_data
285
 
286
	mov	esi,outname
287
	mov	edi,outnamelen
288
	call	refresh_data
289
 
290
	mov	esi,path
291
	mov	edi,pathlen
292
	call	refresh_data
293
 
294
	ret
295
;*********************************************************************
296
refresh_data:
297
	push	esi
298
	xor	eax,eax
299
	cld
300
@@:
301
	lodsb
302
	test	eax,eax
303
	jnz	@r
304
	pop	eax
305
	sub	esi,eax
306
	dec	esi
307
	mov	[edi],esi
308
	ret
309
;*********************************************************************
1686 mario79 310
set_editbox_position_all:
311
	mov	ebx,inname
312
	mov	edi,edit1
313
	call	set_editbox_position
1681 mario79 314
 
1686 mario79 315
	mov	ebx,outname
316
	mov	edi,edit2
317
	call	set_editbox_position
1681 mario79 318
 
1686 mario79 319
	mov	ebx,path
320
	mov	edi,edit3
321
	call	set_editbox_position
1671 mario79 322
	ret
1686 mario79 323
;*********************************************************************
324
key:
325
	mcall	2
1681 mario79 326
 
1686 mario79 327
	push	dword edit1
328
	call	[edit_box_key]
1681 mario79 329
 
1686 mario79 330
	push	dword edit2
331
	call	[edit_box_key]
1681 mario79 332
 
1686 mario79 333
	push	dword edit3
334
	call	[edit_box_key]
1681 mario79 335
 
1686 mario79 336
	jmp	still
337
;*********************************************************************
1671 mario79 338
get_full_name:
339
	push	esi
340
	mov	esi,path
341
	mov	ecx,[esi-4]
342
	mov	edi,fullname
343
	rep	movsb
344
	mov	al,'/'
345
	cmp	[edi-1],al
346
	jz	@f
1681 mario79 347
 
1671 mario79 348
	stosb
1681 mario79 349
;--------------------------------------
1671 mario79 350
@@:
351
	pop	esi
352
	cmp	[esi],al
353
	jnz	@f
1681 mario79 354
 
1671 mario79 355
	mov	edi,fullname
1681 mario79 356
;--------------------------------------
1671 mario79 357
@@:
358
	mov	ecx,[esi-4]
359
	rep	movsb
360
	xor	eax,eax
361
	stosb
362
	ret
1686 mario79 363
;*********************************************************************
1671 mario79 364
write_string:
365
; in: esi=pointer, ecx=length
366
	mov	edx,[message_cur_pos]
1681 mario79 367
;--------------------------------------
1671 mario79 368
x1:
369
	lea	edi,[message_mem+edx]
1681 mario79 370
;--------------------------------------
1671 mario79 371
do_write_char:
372
	lodsb
373
	cmp	al,10
374
	jz	newline
1681 mario79 375
 
1671 mario79 376
	stosb
377
	inc	edx
378
	loop	do_write_char
379
	jmp	x2
380
;---------------------------------------------------------------------
381
newline:
382
	xor	eax,eax
383
	stosb
384
	xchg	eax,edx
385
	push	ecx
386
	push	eax
387
	mov	ecx,80
388
	div	ecx
389
	pop	eax
390
	xchg	eax,edx
391
	sub	edx,eax
392
	add	edx,ecx
393
	pop	ecx
394
	loop	x1
1681 mario79 395
;--------------------------------------
1671 mario79 396
x2:
397
	mov	[message_cur_pos],edx
398
; update window
1688 mario79 399
	mcall	13,<6,414>,<54,222>,[color_table+20]
1681 mario79 400
;--------------------------------------
1671 mario79 401
draw_messages:
1688 mario79 402
	mov	ebx,12 shl 16+60
1671 mario79 403
	mov	edi,message_mem
1681 mario79 404
;--------------------------------------
1671 mario79 405
@@:
406
	push	edi
407
	xor	eax,eax
408
	push	80
409
	pop	ecx
410
	repnz	scasb
411
	sub	ecx,79
412
	neg	ecx
413
	mov	esi,ecx
414
	pop	edi
1681 mario79 415
	mcall	4,,[color_table+32],edi
1671 mario79 416
	add	ebx,10
417
	add	edi,80
418
	cmp	edi,message_cur_pos
419
	jb	@b
1681 mario79 420
 
1671 mario79 421
	ret
1686 mario79 422
;*********************************************************************
1671 mario79 423
draw_window:
424
; start redraw
1681 mario79 425
	mcall	12,1
1686 mario79 426
;--------------------------------------
1671 mario79 427
; define window
428
	xor	eax,eax
1688 mario79 429
	mov	ecx,100 shl 16+306
1671 mario79 430
	mov	edx,[color_table+20]
1688 mario79 431
	add	edx,34000000h
1681 mario79 432
	xor	esi,esi
1688 mario79 433
	xor	edi,edi
434
	mcall	,<100,436>,,,,caption_str
1686 mario79 435
	mcall	9,procinfo,-1
2058 mario79 436
 
437
	mov	eax,[procinfo+70] ;status of window
438
	test	eax,100b
439
	jne	.end
1686 mario79 440
;--------------------------------------
441
; draw lines and frame
442
	call	draw_lines
443
; draw buttons
444
	call	draw_bittons
445
; draw messages
446
	call	draw_messages
447
; draw editbox's
448
	mov	eax,[procinfo+42]
449
	sub	eax,65+72+10
1688 mario79 450
	mov	[edit1.width],eax
1686 mario79 451
	mov	[edit2.width],eax
452
	mov	[edit3.width],eax
453
 
454
	call	draw_editbox
455
; end redraw
2058 mario79 456
.end:
1686 mario79 457
	mcall	12,2
458
	ret
459
;*********************************************************************
460
draw_editbox:
461
	push	dword edit1
462
	call	[edit_box_draw]
1713 mario79 463
 
1686 mario79 464
	push	dword edit2
465
	call	[edit_box_draw]
1713 mario79 466
 
1686 mario79 467
	push	dword edit3
468
	call	[edit_box_draw]
1713 mario79 469
 
470
	push	dword check1
471
	call	[check_box_draw]
1686 mario79 472
	ret
473
;*********************************************************************
474
set_editbox_position:
475
	mov	esi,ebx
476
	cld
477
@@:
478
	lodsb
479
	test	al,al
480
	jne	@r
481
	sub	esi,ebx
482
	mov	eax,esi
483
	dec	eax
484
	mov	[edi+48], eax  ;ed_size
485
	mov	[edi+52], eax  ;ed_pos
486
	ret
487
;*********************************************************************
488
draw_lines:
1688 mario79 489
	mov	ecx,2 shl 16+12*3
1671 mario79 490
; draw frame for messages data
491
	push	ecx
1688 mario79 492
	add	ecx,50 shl 16+16
493
	mcall	38,<3,423>,,[color_table+36]
1681 mario79 494
	add	ecx,224*(1 shl 16+1)
495
	mcall
496
	sub	cx,224
1688 mario79 497
	mcall	,<3,3>
498
	mcall	,<423,423>
1671 mario79 499
	pop	ecx
1686 mario79 500
	ret
501
;*********************************************************************
502
draw_bittons:
1671 mario79 503
; define compress button
1681 mario79 504
	mov	cx,18
1688 mario79 505
	mcall	8,<351,72>,,2,[color_table+36]
1671 mario79 506
; uncompress button
1681 mario79 507
	add	ecx,18 shl 16
1671 mario79 508
	inc	edx
1681 mario79 509
	mcall
1671 mario79 510
	add	ecx,-12h+0Ah+140000h
511
; question button
512
	push	esi
513
	mov	dl,7
1688 mario79 514
	mcall	,<414,9>
1671 mario79 515
	shr	ecx,16
1688 mario79 516
	lea	ebx,[ecx+1A10002h]
1681 mario79 517
	mcall	4,,[color_table+28],aQuestion,1
1671 mario79 518
	pop	esi
519
; define settings buttons
1688 mario79 520
	mov	ecx,16*2+2
1671 mario79 521
	shl	ecx,16
1686 mario79 522
	mov	cx,13
1688 mario79 523
	mcall	8,<6,50>,,4
1671 mario79 524
; text on settings buttons
1688 mario79 525
	mov	ebx,9 shl 16+5
1671 mario79 526
	mov	al,4
527
	mov	ecx,[color_table+28]
528
	push	buttons1names
529
	pop	edx
530
	push	8
531
	pop	esi
1681 mario79 532
;--------------------------------------
1671 mario79 533
@@:
1681 mario79 534
	mcall
1671 mario79 535
	add	edx,esi
1686 mario79 536
	add	ebx,16
1671 mario79 537
	cmp	[edx-6],byte ' '
538
	jnz	@b
539
; text on compress and decompress buttons
540
	or	ecx,80000000h
1688 mario79 541
	mcall	,<367,7>,,aCompress
542
	mcall	,<359,25>,,aDecompress
1671 mario79 543
	ret
1686 mario79 544
;*********************************************************************
545
;Pack procedures
546
include 'packpoc.inc'
1671 mario79 547
;---------------------------------------------------------------------
1686 mario79 548
;UnPack procedures
549
include 'upacproc.inc'
1671 mario79 550
;---------------------------------------------------------------------
551
;lzma_compress:
552
include 'lzma_compress.inc'
553
;---------------------------------------------------------------------
554
;lzma_set_dict_size:
555
include 'lzma_set_dict_size.inc'
556
;---------------------------------------------------------------------
557
;lzma_decompress:
558
include	'lzma_decompress.inc'
559
;---------------------------------------------------------------------
1713 mario79 560
;kerpack code:
561
include	'kerpack.inc'
562
;---------------------------------------------------------------------
1681 mario79 563
;initialized variables and constants
564
include 'const_var.inc'
1671 mario79 565
;---------------------------------------------------------------------
566
IM_END:
567
;---------------------------------------------------------------------
1681 mario79 568
;uninitialized data
569
include 'data.inc'
1671 mario79 570
;---------------------------------------------------------------------
571
I_END:
572
;---------------------------------------------------------------------