Subversion Repositories Kolibri OS

Rev

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