Subversion Repositories Kolibri OS

Rev

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