Subversion Repositories Kolibri OS

Rev

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