Subversion Repositories Kolibri OS

Rev

Rev 2263 | Rev 2673 | 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
;--------------------------------------
2207 leency 74
edit_boxes_set_sys_color edit1,editboxes_end,color_table
2263 leency 75
check_boxes_set_sys_color check1,check1_end,color_table
2207 leency 76
;--------------------------------------
1688 mario79 77
	xor	eax,eax
78
	cmp	[params],al
79
	je	default
80
 
81
	mov	edi,path
1671 mario79 82
	mov	esi,params
1688 mario79 83
	call	copy_1
1681 mario79 84
 
1688 mario79 85
	sub	esi,2
86
	std
87
@@:
88
	lodsb
89
	dec	edi
90
	cmp	al,byte '/'
91
	jnz	@r
92
 
93
	mov	[edi-1],byte 0
1671 mario79 94
	mov	edi,inname
1688 mario79 95
	add	esi,2
96
	push	esi
97
	call	copy_1
98
	pop	esi
1671 mario79 99
	mov	edi,outname
1688 mario79 100
	call	copy_1
101
;---------------------------------------------------------------------
102
	call	set_editbox_position_all
103
;---------------------------------------------------------------------
1671 mario79 104
	call	draw_window
105
	call	pack
1688 mario79 106
	jmp	OD_initialization
107
;*********************************************************************
1671 mario79 108
default:
109
	mov	esi,definoutname
110
	mov	edi,esi
111
	xor	ecx,ecx
112
	xor	eax,eax
113
	dec	ecx
114
	repnz	scasb
115
	not	ecx
116
	dec	ecx
117
	mov	[innamelen],ecx
118
	push	ecx
119
	push	esi
120
	mov	edi,inname
121
	rep	movsb
122
	pop	esi
123
	pop	ecx
124
	mov	[outnamelen],ecx
125
	mov	edi,outname
126
	rep	movsb
127
;---------------------------------------------------------------------
1688 mario79 128
	call	set_editbox_position_all
129
;---------------------------------------------------------------------
130
OD_initialization:
1686 mario79 131
;OpenDialog	initialisation
132
	push    dword OpenDialog_data
133
	call    [OpenDialog_Init]
134
;---------------------------------------------------------------------
135
red:
1671 mario79 136
	call	draw_window
1681 mario79 137
;--------------------------------------
1686 mario79 138
still:
1681 mario79 139
	mcall	10
1671 mario79 140
	dec	eax
1686 mario79 141
	jz	red
1681 mario79 142
 
1671 mario79 143
	dec	eax
1686 mario79 144
	jz	key
1681 mario79 145
 
1671 mario79 146
	dec	eax
1686 mario79 147
	jz	button
148
 
149
	push	dword edit1
150
	call	[edit_box_mouse]
151
 
152
	push	dword edit2
153
	call	[edit_box_mouse]
154
 
155
	push	dword edit3
156
	call	[edit_box_mouse]
157
 
1713 mario79 158
	push	dword check1
159
	call	[check_box_mouse]
160
 
1686 mario79 161
	jmp	still
162
;*********************************************************************
1713 mario79 163
tell_compress_mess:
164
	push	compressing_len
165
	pop	ecx
166
	mov	esi,compressing_str
167
	call	write_string
168
	ret
169
;*********************************************************************
170
clear_mess_and_displogo:
171
	call	refresh_editbox_data
172
; clear messages
173
	call	clear_messages
174
; display logo
175
	mov	esi,info_str
176
	push	info_len
177
	pop	ecx
178
	call	write_string
179
	ret
180
;*********************************************************************
1688 mario79 181
clear_messages:
182
	xor	eax,eax
183
	mov	ecx,80*20/4+1
184
	mov	edi,message_mem
185
	rep	stosd
186
	ret
187
;*********************************************************************
188
exit:
189
	xor	eax,eax
190
	dec	eax
191
	mcall
192
;*********************************************************************
1686 mario79 193
button:
1671 mario79 194
; button pressed
1681 mario79 195
	mcall	17
1671 mario79 196
	xchg	al,ah
197
	cmp	al,7
198
	jz	but7
1681 mario79 199
 
1671 mario79 200
	dec	eax
201
	jz	exit
1681 mario79 202
 
1671 mario79 203
	dec	eax
204
	jnz	nopack
1681 mario79 205
 
1713 mario79 206
	mov	eax,[check1+32]
207
	test	eax,10b
208
	jnz	@f
209
 
1671 mario79 210
	call	pack
1686 mario79 211
	jmp	still
1713 mario79 212
;---------------------------------------------------------------------
213
@@:
214
	call	kerpack
215
	jmp	still
1671 mario79 216
;---------------------------------------------------------------------
217
nopack:
218
	dec	eax
219
	jnz	nounpack
1713 mario79 220
 
1671 mario79 221
	call	unpack
1686 mario79 222
	jmp	still
1713 mario79 223
;---------------------------------------------------------------------
1671 mario79 224
but7:
225
	call	clear_messages
226
; display logo
227
	mov	esi,info_str
228
	push	info_len
229
	pop	ecx
230
	call	write_string
231
; display info
232
	mov	esi,usage_str
233
	mov	ecx,usage_len
234
	call	write_string
1686 mario79 235
	jmp	still
1671 mario79 236
;---------------------------------------------------------------------
237
nounpack:
238
	dec	eax
1686 mario79 239
	jnz	still
1681 mario79 240
 
1686 mario79 241
	call	OpenDialog_start
242
	jmp	still
243
;*********************************************************************
244
OpenDialog_start:
1688 mario79 245
	mov	esi,path
246
	mov	edi,temp_dir_pach
247
	call	copy_1
248
 
1686 mario79 249
	push    dword OpenDialog_data
250
	call    [OpenDialog_Start]
251
	cmp	[OpenDialog_data.status],1
252
	jne	@f
1681 mario79 253
 
1686 mario79 254
	mov	esi,filename_area
255
	mov	edi,inname
256
	call	copy_1
1681 mario79 257
 
1686 mario79 258
	mov	esi,filename_area
259
	mov	edi,outname
260
	call	copy_1
261
 
262
	mov	esi,temp_dir_pach
263
	mov	edi,path
264
	call	copy_1
265
 
1688 mario79 266
	call	refresh_editbox_data
267
 
1686 mario79 268
	call	set_editbox_position_all
1681 mario79 269
 
1686 mario79 270
	call	draw_editbox
1671 mario79 271
@@:
1686 mario79 272
	ret
273
;*********************************************************************
274
copy_1:
1671 mario79 275
	xor	eax,eax
1686 mario79 276
	cld
1671 mario79 277
@@:
1686 mario79 278
	lodsb
279
	stosb
1671 mario79 280
	test	eax,eax
1686 mario79 281
	jnz	@r
1671 mario79 282
	ret
1686 mario79 283
;*********************************************************************
1688 mario79 284
refresh_editbox_data:
285
	mov	esi,inname
286
	mov	edi,innamelen
287
	call	refresh_data
288
 
289
	mov	esi,outname
290
	mov	edi,outnamelen
291
	call	refresh_data
292
 
293
	mov	esi,path
294
	mov	edi,pathlen
295
	call	refresh_data
296
 
297
	ret
298
;*********************************************************************
299
refresh_data:
300
	push	esi
301
	xor	eax,eax
302
	cld
303
@@:
304
	lodsb
305
	test	eax,eax
306
	jnz	@r
307
	pop	eax
308
	sub	esi,eax
309
	dec	esi
310
	mov	[edi],esi
311
	ret
312
;*********************************************************************
1686 mario79 313
set_editbox_position_all:
314
	mov	ebx,inname
315
	mov	edi,edit1
316
	call	set_editbox_position
1681 mario79 317
 
1686 mario79 318
	mov	ebx,outname
319
	mov	edi,edit2
320
	call	set_editbox_position
1681 mario79 321
 
1686 mario79 322
	mov	ebx,path
323
	mov	edi,edit3
324
	call	set_editbox_position
1671 mario79 325
	ret
1686 mario79 326
;*********************************************************************
327
key:
328
	mcall	2
1681 mario79 329
 
1686 mario79 330
	push	dword edit1
331
	call	[edit_box_key]
1681 mario79 332
 
1686 mario79 333
	push	dword edit2
334
	call	[edit_box_key]
1681 mario79 335
 
1686 mario79 336
	push	dword edit3
337
	call	[edit_box_key]
1681 mario79 338
 
1686 mario79 339
	jmp	still
340
;*********************************************************************
1671 mario79 341
get_full_name:
342
	push	esi
343
	mov	esi,path
344
	mov	ecx,[esi-4]
345
	mov	edi,fullname
346
	rep	movsb
347
	mov	al,'/'
348
	cmp	[edi-1],al
349
	jz	@f
1681 mario79 350
 
1671 mario79 351
	stosb
1681 mario79 352
;--------------------------------------
1671 mario79 353
@@:
354
	pop	esi
355
	cmp	[esi],al
356
	jnz	@f
1681 mario79 357
 
1671 mario79 358
	mov	edi,fullname
1681 mario79 359
;--------------------------------------
1671 mario79 360
@@:
361
	mov	ecx,[esi-4]
362
	rep	movsb
363
	xor	eax,eax
364
	stosb
365
	ret
1686 mario79 366
;*********************************************************************
1671 mario79 367
write_string:
368
; in: esi=pointer, ecx=length
369
	mov	edx,[message_cur_pos]
1681 mario79 370
;--------------------------------------
1671 mario79 371
x1:
372
	lea	edi,[message_mem+edx]
1681 mario79 373
;--------------------------------------
1671 mario79 374
do_write_char:
375
	lodsb
376
	cmp	al,10
377
	jz	newline
1681 mario79 378
 
1671 mario79 379
	stosb
380
	inc	edx
381
	loop	do_write_char
382
	jmp	x2
383
;---------------------------------------------------------------------
384
newline:
385
	xor	eax,eax
386
	stosb
387
	xchg	eax,edx
388
	push	ecx
389
	push	eax
390
	mov	ecx,80
391
	div	ecx
392
	pop	eax
393
	xchg	eax,edx
394
	sub	edx,eax
395
	add	edx,ecx
396
	pop	ecx
397
	loop	x1
1681 mario79 398
;--------------------------------------
1671 mario79 399
x2:
400
	mov	[message_cur_pos],edx
401
; update window
1688 mario79 402
	mcall	13,<6,414>,<54,222>,[color_table+20]
1681 mario79 403
;--------------------------------------
1671 mario79 404
draw_messages:
1688 mario79 405
	mov	ebx,12 shl 16+60
1671 mario79 406
	mov	edi,message_mem
1681 mario79 407
;--------------------------------------
1671 mario79 408
@@:
409
	push	edi
410
	xor	eax,eax
411
	push	80
412
	pop	ecx
413
	repnz	scasb
414
	sub	ecx,79
415
	neg	ecx
416
	mov	esi,ecx
417
	pop	edi
1681 mario79 418
	mcall	4,,[color_table+32],edi
1671 mario79 419
	add	ebx,10
420
	add	edi,80
421
	cmp	edi,message_cur_pos
422
	jb	@b
1681 mario79 423
 
1671 mario79 424
	ret
1686 mario79 425
;*********************************************************************
1671 mario79 426
draw_window:
427
; start redraw
1681 mario79 428
	mcall	12,1
1686 mario79 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
2262 mario79 508
	mcall	8,<351,72>,,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
1688 mario79 546
	mcall	,<367,7>,,aCompress
547
	mcall	,<359,25>,,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
;---------------------------------------------------------------------