Subversion Repositories Kolibri OS

Rev

Rev 1671 | Rev 1686 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1671 Rev 1681
Line 12... Line 12...
12
use32
12
use32
13
	org	0
13
	org	0
Line 14... Line 14...
14
 
14
 
15
	db 'MENUET01'
15
	db 'MENUET01'
16
	dd 1
16
	dd 1
17
	dd START	;_start		;0x239F	;0x23A4
17
	dd START
18
	dd IM_END	;bss_start	;0x32C9 i_end ;0x32C4
18
	dd IM_END
19
memf	dd 0x53000 	;I_END	;bss_end	;memory;
19
memf	dd I_END
20
	dd stacktop	;bss_end	;0x59DC esp ;0x4ÑA0
20
	dd stacktop
21
	dd params	;params		;0x4000	;0x32C4
21
	dd params
22
	dd 0		;cur_dir_path
22
	dd 0		;cur_dir_path
-
 
23
;---------------------------------------------------------------------
-
 
24
include '..\..\..\macros.inc'
23
;---------------------------------------------------------------------
25
 
24
START:
26
START:
25
	call	clear_messages
27
	call	clear_messages
26
; set default path = /RD/1/
28
; set default path = /RD/1/
27
	mov	esi,defpath
29
	mov	esi,defpath
28
	mov	edi,path
30
	mov	edi,path
29
	mov	[edi-4],dword 6
31
	mov	[edi-4],dword 6
30
	movsw
32
	movsw
31
	movsd
33
	movsd
32
; get system window info
-
 
33
	mov	al,48
-
 
34
	push	3
-
 
35
	pop	ebx
34
; get system window info
36
	mov	ecx,color_table
-
 
37
	push	40
-
 
38
	pop	edx
-
 
39
	int	40h
35
	mcall	48,3,color_table,40
40
	inc	ebx
36
	inc	ebx
41
	int	40h
37
	mcall
42
	mov	[skinheight],eax
38
	mov	[skinheight],eax
43
; check command line
39
; check command line
44
	mov	esi,params
40
	mov	esi,params
-
 
41
	mov	[esi+100h],byte 0
45
	mov	[esi+100h],byte 0
42
;--------------------------------------
46
parse_opt:
43
parse_opt:
47
	call	skip_spaces
44
	call	skip_spaces
48
	test	al,al
45
	test	al,al
-
 
46
	jz	default
49
	jz	default
47
 
50
	mov	edi,inname
48
	mov	edi,inname
51
	call	copy_name
49
	call	copy_name
52
	test	al,al
50
	test	al,al
-
 
51
	jz	outeqin
53
	jz	outeqin
52
 
54
	mov	edi,outname
53
	mov	edi,outname
55
	call	copy_name
54
	call	copy_name
56
	test	al,al
55
	test	al,al
-
 
56
	jnz	default
57
	jnz	default
57
;--------------------------------------
58
doit:
58
doit:
59
	call	draw_window
59
	call	draw_window
60
	call	pack
60
	call	pack
61
	jmp	waitevent
61
	jmp	waitevent
Line 68... Line 68...
68
	ret
68
	ret
69
;---------------------------------------------------------------------
69
;---------------------------------------------------------------------
70
exit:
70
exit:
71
	xor	eax,eax
71
	xor	eax,eax
72
	dec	eax
72
	dec	eax
73
	int	40h
73
	mcall
-
 
74
;--------------------------------------
74
outeqin:
75
outeqin:
75
	mov	ecx,48/4+1
76
	mov	ecx,48/4+1
76
	mov	esi,inname-4
77
	mov	esi,inname-4
77
	mov	edi,outname-4
78
	mov	edi,outname-4
78
	rep	movsd
79
	rep	movsd
Line 102... Line 103...
102
	mov	edi,outname
103
	mov	edi,outname
103
	rep	movsb
104
	rep	movsb
104
;---------------------------------------------------------------------
105
;---------------------------------------------------------------------
105
dodraw:
106
dodraw:
106
	call	draw_window
107
	call	draw_window
-
 
108
;--------------------------------------
107
waitevent:
109
waitevent:
108
	push	10
110
	mcall	10
109
	pop	eax
-
 
110
	int	40h
-
 
111
	dec	eax
111
	dec	eax
112
	jz	dodraw
112
	jz	dodraw
-
 
113
 
113
	dec	eax
114
	dec	eax
114
	jz	keypressed
115
	jz	keypressed
-
 
116
 
115
	dec	eax
117
	dec	eax
116
	jnz	waitevent
118
	jnz	waitevent
117
; button pressed
119
; button pressed
118
	mov	al,17
120
	mcall	17
119
	int	40h
-
 
120
	xchg	al,ah
121
	xchg	al,ah
121
	cmp	al,7
122
	cmp	al,7
122
	jz	but7
123
	jz	but7
-
 
124
 
123
	dec	eax
125
	dec	eax
124
	jz	exit
126
	jz	exit
-
 
127
 
125
	dec	eax
128
	dec	eax
126
	jnz	nopack
129
	jnz	nopack
-
 
130
 
127
	call	pack
131
	call	pack
128
	jmp	waitevent
132
	jmp	waitevent
129
;---------------------------------------------------------------------
133
;---------------------------------------------------------------------
130
nopack:
134
nopack:
131
	dec	eax
135
	dec	eax
132
	jnz	nounpack
136
	jnz	nounpack
-
 
137
 
133
	call	unpack
138
	call	unpack
134
	jmp	waitevent
139
	jmp	waitevent
135
;---------------------------------------------------------------------
140
;---------------------------------------------------------------------
136
but7:
141
but7:
137
	call	clear_messages
142
	call	clear_messages
Line 152... Line 157...
152
	mov	esi,inname
157
	mov	esi,inname
153
	mov	ecx,[skinheight]
158
	mov	ecx,[skinheight]
154
	add	ecx,5
159
	add	ecx,5
155
	dec	eax
160
	dec	eax
156
	jz	edit
161
	jz	edit
-
 
162
 
157
	mov	esi,outname
163
	mov	esi,outname
158
	add	ecx,0Ch
164
	add	ecx,0Ch
159
	dec	eax
165
	dec	eax
160
	jz	edit
166
	jz	edit
-
 
167
 
161
	mov	esi,path
168
	mov	esi,path
162
	add	ecx,0Ch
169
	add	ecx,0Ch
-
 
170
;--------------------------------------
163
edit:
171
edit:
164
	cmp	esi,[curedit]
172
	cmp	esi,[curedit]
165
	mov	[curedit],0
173
	mov	[curedit],0
166
	jz	waitevent
174
	jz	waitevent
-
 
175
 
167
	mov	[curedit],esi
176
	mov	[curedit],esi
168
	mov	[curedit_y],ecx
177
	mov	[curedit_y],ecx
169
	mov	al,1
178
	mov	al,1
170
	mov	ebx,[esi-4]
179
	mov	ebx,[esi-4]
171
	mov	edi,ebx
180
	mov	edi,ebx
172
	imul	ebx,6
181
	imul	ebx,6
173
	add	ebx,42h
182
	add	ebx,42h
174
	add	ecx,4
183
	add	ecx,4
175
	xor	edx,edx
184
	xor	edx,edx
-
 
185
;--------------------------------------
176
@@:
186
@@:
177
	cmp	edi,48
187
	cmp	edi,48
178
	jz	waitevent
188
	jz	waitevent
-
 
189
 
179
	int	40h
190
	mcall
180
	add	ebx,6
191
	add	ebx,6
181
	inc	edi
192
	inc	edi
182
	jmp	@b
193
	jmp	@b
183
;---------------------------------------------------------------------
194
;---------------------------------------------------------------------
184
keypressed:
195
keypressed:
185
	mov	al,2
196
	mcall	2
186
	int	40h
-
 
187
	xchg	al,ah
197
	xchg	al,ah
188
	mov	edi,[curedit]
198
	mov	edi,[curedit]
189
	test	edi,edi
199
	test	edi,edi
190
	jz	waitevent
200
	jz	waitevent
-
 
201
 
191
	mov	ebx,[edi-4]
202
	mov	ebx,[edi-4]
192
	cmp	al,8
203
	cmp	al,8
193
	jz	backspace
204
	jz	backspace
-
 
205
 
194
	cmp	al,13
206
	cmp	al,13
195
	jz	onenter
207
	jz	onenter
-
 
208
 
196
	cmp	al,20h
209
	cmp	al,20h
197
	jb	waitevent
210
	jb	waitevent
-
 
211
 
198
	cmp	ebx,48
212
	cmp	ebx,48
199
	jz	waitevent
213
	jz	waitevent
-
 
214
 
200
	mov	[edi+ebx],al
215
	mov	[edi+ebx],al
201
	inc	ebx
216
	inc	ebx
202
	mov	[edi-4],ebx
217
	mov	[edi-4],ebx
203
; clear point and draw symbol
218
; clear point and draw symbol
204
	lea	edi,[edi+ebx-1]
219
	lea	edi,[edi+ebx-1]
205
	imul	ebx,6
220
	imul	ebx,6
206
	add	ebx,40h-6
221
	add	ebx,40h-6
207
	shl	ebx,16
222
	shl	ebx,16
208
	mov	al,13
-
 
209
	mov	bl,6
223
	mov	bl,6
210
	mov	ecx,[curedit_y]
224
	mov	ecx,[curedit_y]
211
	push	ecx
225
	push	ecx
212
	shl	ecx,16
226
	shl	ecx,16
213
	mov	cl,9
227
	mov	cl,9
214
	mov	edx,[color_table+20]
228
	mcall	13,,,[color_table+20]
215
	int	40h
-
 
216
	pop	ecx
229
	pop	ecx
217
	mov	bx,cx
230
	mov	bx,cx
218
	mov	edx,edi
-
 
219
	push	1
-
 
220
	pop	esi
-
 
221
	mov	ecx,[color_table+32]
231
	mcall	4,,[color_table+32],edi,1
222
	mov	al,4
-
 
223
	int	40h
-
 
224
	jmp	waitevent
232
	jmp	waitevent
225
;---------------------------------------------------------------------
233
;---------------------------------------------------------------------
226
backspace:
234
backspace:
227
	test	ebx,ebx
235
	test	ebx,ebx
228
	jz	waitevent
236
	jz	waitevent
-
 
237
 
229
	dec	ebx
238
	dec	ebx
230
	mov	[edi-4],ebx
239
	mov	[edi-4],ebx
231
; clear symbol and set point
240
; clear symbol and set point
232
	imul	ebx,6
241
	imul	ebx,6
233
	add	ebx,40h
242
	add	ebx,40h
234
	shl	ebx,16
243
	shl	ebx,16
235
	mov	al,13
-
 
236
	mov	bl,6
244
	mov	bl,6
237
	mov	ecx,[curedit_y]
245
	mov	ecx,[curedit_y]
238
	push	ecx
246
	push	ecx
239
	shl	ecx,16
247
	shl	ecx,16
240
	mov	cl,9
248
	mov	cl,9
241
	mov	edx,[color_table+20]
249
	mcall	13,,,[color_table+20]
242
	int	40h
-
 
243
	xor	edx,edx
250
	xor	edx,edx
244
	shr	ebx,16
251
	shr	ebx,16
245
	inc	ebx
252
	inc	ebx
246
	inc	ebx
253
	inc	ebx
247
	pop	ecx
254
	pop	ecx
248
	add	ecx,4
255
	add	ecx,4
249
	mov	al,1
256
	mcall	1
250
	int	40h
-
 
251
	jmp	waitevent
257
	jmp	waitevent
252
;---------------------------------------------------------------------
258
;---------------------------------------------------------------------
253
onenter:
259
onenter:
254
	cmp	[curedit],inname
260
	cmp	[curedit],inname
255
	jnz	@f
261
	jnz	@f
-
 
262
 
256
	push	2
263
	push	2
257
	pop	eax
264
	pop	eax
258
	jmp	nounpack
265
	jmp	nounpack
259
;---------------------------------------------------------------------
266
;---------------------------------------------------------------------
260
@@:
267
@@:
261
	cmp	[curedit],outname
268
	cmp	[curedit],outname
262
	jnz	@f
269
	jnz	@f
-
 
270
 
263
	call	pack
271
	call	pack
264
	jmp	waitevent
272
	jmp	waitevent
265
;---------------------------------------------------------------------
273
;---------------------------------------------------------------------
266
@@:
274
@@:
267
	call	clear_edit_points
275
	call	clear_edit_points
Line 284... Line 292...
284
	mov	[ebx],dword 5
292
	mov	[ebx],dword 5
285
	and	[ebx+4],dword 0
293
	and	[ebx+4],dword 0
286
	and	[ebx+8],dword 0
294
	and	[ebx+8],dword 0
287
	and     [ebx+12],dword 0
295
	and     [ebx+12],dword 0
288
	mov	[ebx+16],dword  file_attr
296
	mov	[ebx+16],dword  file_attr
289
	push	70
297
	mcall	70
290
	pop	eax
-
 
291
	int	40h
-
 
292
	test	eax,eax
298
	test	eax,eax
293
	jz	inopened
299
	jz	inopened
294
;---------------------------------------------------------------------
300
;---------------------------------------------------------------------
295
infileerr:
301
infileerr:
296
	mov	esi,errload_str
302
	mov	esi,errload_str
Line 329... Line 335...
329
	dec	eax
335
	dec	eax
330
	bsr	ecx,eax
336
	bsr	ecx,eax
331
	inc	ecx
337
	inc	ecx
332
	cmp	ecx,28
338
	cmp	ecx,28
333
	jb	@f
339
	jb	@f
-
 
340
 
334
	mov	cl,28
341
	mov	cl,28
-
 
342
;--------------------------------------
335
@@:
343
@@:
336
	mov	edx,ecx
344
	mov	edx,ecx
337
	xor	eax,eax
345
	xor	eax,eax
338
	inc	eax
346
	inc	eax
339
	shl	eax,cl
347
	shl	eax,cl
340
	imul	eax,19
348
	imul	eax,19
341
	shr	eax,1
349
	shr	eax,1
342
	add	eax,448000h
350
	add	eax,448000h
343
	pop	ecx
351
	pop	ecx
344
	add	ecx,eax
352
	add	ecx,eax
345
	push	64
353
	mcall	64,1
346
	pop	eax
-
 
347
	push	1
-
 
348
	pop	ebx
-
 
349
	int	40h
-
 
350
	test	eax,eax
354
	test	eax,eax
351
	jz	mem_ok
355
	jz	mem_ok
-
 
356
;--------------------------------------
352
; try to use smaller dictionary
357
; try to use smaller dictionary
353
meml0:
358
meml0:
354
	cmp	edx,4
359
	cmp	edx,4
355
	jbe	memf1
360
	jbe	memf1
-
 
361
 
356
	dec	edx
362
	dec	edx
357
	xor	eax,eax
363
	xor	eax,eax
358
	inc	eax
364
	inc	eax
359
	mov	ecx,edx
365
	mov	ecx,edx
360
	shl	eax,cl
366
	shl	eax,cl
Line 362... Line 368...
362
	shr	eax,1
368
	shr	eax,1
363
	add	eax,509000h
369
	add	eax,509000h
364
	pop	ecx
370
	pop	ecx
365
	push	ecx
371
	push	ecx
366
	add	ecx,eax
372
	add	ecx,eax
367
	push	64
373
	mcall	64
368
	pop	eax
-
 
369
	int	40h
-
 
370
	test	eax,eax
374
	test	eax,eax
371
	jnz	meml0
375
	jnz	meml0
-
 
376
;--------------------------------------
372
; ok, say warning and continue
377
; ok, say warning and continue
373
	mov	[lzma_dictsize],edx
378
	mov	[lzma_dictsize],edx
374
	mov	esi,lzma_memsmall_str
379
	mov	esi,lzma_memsmall_str
375
	push	lzma_memsmall_len
380
	push	lzma_memsmall_len
376
	pop	ecx
381
	pop	ecx
Line 388... Line 393...
388
	mov	ebx,fn70block
393
	mov	ebx,fn70block
389
	mov	[ebx],byte 0
394
	mov	[ebx],byte 0
390
	mov	[ebx+12],eax
395
	mov	[ebx+12],eax
391
	mov	esi,[infile]
396
	mov	esi,[infile]
392
	mov	[ebx+16],esi
397
	mov	[ebx+16],esi
393
	push	70
398
	mcall	70
394
	pop	eax
-
 
395
	int	40h
-
 
396
	test	eax,eax
399
	test	eax,eax
397
	jnz	infileerr
400
	jnz	infileerr
-
 
401
 
398
	mov	eax,[outfile]
402
	mov	eax,[outfile]
399
	mov	[eax],dword 'KPCK'	;'KCPK'
403
	mov	[eax],dword 'KPCK'	;'KCPK'
400
	mov     ecx,[insize]
404
	mov     ecx,[insize]
401
	mov	[eax+4],dword ecx
405
	mov	[eax+4],dword ecx
402
	mov	edi,eax
406
	mov	edi,eax
403
; set LZMA dictionary size
407
; set LZMA dictionary size
404
	mov	eax,[lzma_dictsize]
408
	mov	eax,[lzma_dictsize]
405
	test	eax,eax
409
	test	eax,eax
406
	js	no_lzma_setds
410
	js	no_lzma_setds
407
	jnz	lzma_setds
411
	jnz	lzma_setds
-
 
412
 
408
	mov	ecx,[insize]
413
	mov	ecx,[insize]
409
	dec	ecx
414
	dec	ecx
410
	bsr	eax,ecx
415
	bsr	eax,ecx
411
	inc	eax
416
	inc	eax
412
	cmp	eax,28
417
	cmp	eax,28
413
	jb	lzma_setds
418
	jb	lzma_setds
-
 
419
 
414
	mov	eax,28
420
	mov	eax,28
-
 
421
;--------------------------------------
415
lzma_setds:
422
lzma_setds:
416
	push	eax
423
	push	eax
417
	call	lzma_set_dict_size
424
	call	lzma_set_dict_size
-
 
425
;--------------------------------------
418
no_lzma_setds:
426
no_lzma_setds:
419
	push	compressing_len
427
	push	compressing_len
420
	pop	ecx
428
	pop	ecx
421
	mov	esi,compressing_str
429
	mov	esi,compressing_str
422
	call	write_string
430
	call	write_string
Line 428... Line 436...
428
	call	pack_lzma
436
	call	pack_lzma
429
	mov	[outsize],eax
437
	mov	[outsize],eax
430
	mov	eax,[outfile]
438
	mov	eax,[outfile]
431
	mov	[outfilebest],eax
439
	mov	[outfilebest],eax
432
	mov	[method],use_lzma
440
	mov	[method],use_lzma
-
 
441
;--------------------------------------
433
@@:
442
@@:
434
	call	preprocess_calltrick
443
	call	preprocess_calltrick
435
	test	eax,eax
444
	test	eax,eax
436
	jz	noct1
445
	jz	noct1
-
 
446
 
437
	call	set_outfile
447
	call	set_outfile
438
	call	pack_lzma
448
	call	pack_lzma
439
	add	eax,5
449
	add	eax,5
440
	cmp	eax,[outsize]
450
	cmp	eax,[outsize]
441
	jae	@f
451
	jae	@f
-
 
452
 
442
	mov	[outsize],eax
453
	mov	[outsize],eax
443
	mov	eax,[outfile]
454
	mov	eax,[outfile]
444
	mov	[outfilebest],eax
455
	mov	[outfilebest],eax
445
	mov	[method],use_lzma or use_calltrick1
456
	mov	[method],use_lzma or use_calltrick1
-
 
457
;--------------------------------------
446
@@:
458
@@:
447
noct1:
459
noct1:
448
	call	set_outfile
460
	call	set_outfile
449
	push	[ctn]
461
	push	[ctn]
450
	mov	al,[cti]
462
	mov	al,[cti]
451
	push	eax
463
	push	eax
452
	call	preprocess_calltrick2
464
	call	preprocess_calltrick2
453
	test	eax,eax
465
	test	eax,eax
454
	jz	noct2
466
	jz	noct2
-
 
467
 
455
	call	set_outfile
468
	call	set_outfile
456
	call	pack_lzma
469
	call	pack_lzma
457
	add	eax,5
470
	add	eax,5
458
	cmp	eax,[outsize]
471
	cmp	eax,[outsize]
459
	jae	@f
472
	jae	@f
-
 
473
 
460
	mov	[outsize],eax
474
	mov	[outsize],eax
461
	mov	eax,[outfile]
475
	mov	eax,[outfile]
462
	mov	[outfilebest],eax
476
	mov	[outfilebest],eax
463
	mov	[method],use_lzma or use_calltrick2
477
	mov	[method],use_lzma or use_calltrick2
464
	pop	ecx
478
	pop	ecx
465
	pop	ecx
479
	pop	ecx
466
	push	[ctn]
480
	push	[ctn]
467
	mov	al,[cti]
481
	mov	al,[cti]
468
	push	eax
482
	push	eax
-
 
483
;--------------------------------------
469
@@:
484
@@:
470
noct2:
485
noct2:
471
	pop	eax
486
	pop	eax
472
	mov	[cti],al
487
	mov	[cti],al
473
	pop	[ctn]
488
	pop	[ctn]
474
	add     [outsize],12
489
	add     [outsize],12
475
	mov	eax,[outsize]
490
	mov	eax,[outsize]
476
	cmp	eax,[insize]
491
	cmp	eax,[insize]
477
	jb	packed_ok
492
	jb	packed_ok
-
 
493
 
478
	mov	esi,too_big_str
494
	mov	esi,too_big_str
479
	push	too_big_len
495
	push	too_big_len
480
	pop	ecx
496
	pop	ecx
481
	jmp	write_string
497
	jmp	write_string
482
;---------------------------------------------------------------------
498
;---------------------------------------------------------------------
Line 485... Line 501...
485
        movzx	eax,[method]
501
        movzx	eax,[method]
486
	mov	edi,[outfilebest]
502
	mov	edi,[outfilebest]
487
	mov     [edi+8],eax
503
	mov     [edi+8],eax
488
	test	al,use_calltrick1 or use_calltrick2
504
	test	al,use_calltrick1 or use_calltrick2
489
	jz	@f
505
	jz	@f
-
 
506
 
490
	mov	ecx,[outsize]
507
	mov	ecx,[outsize]
491
	add	ecx,edi
508
	add	ecx,edi
492
	mov	eax,[ctn]
509
	mov	eax,[ctn]
493
	mov     [ecx-5],eax
510
	mov     [ecx-5],eax
494
	mov	al,[cti]
511
	mov	al,[cti]
495
	mov     [ecx-1],al
512
	mov     [ecx-1],al
-
 
513
;--------------------------------------
496
@@:
514
@@:
497
	mov	eax,[outsize]
515
	mov	eax,[outsize]
498
	mov	ecx,100
516
	mov	ecx,100
499
	mul	ecx
517
	mul	ecx
500
	div	[insize]
518
	div	[insize]
Line 504... Line 522...
504
	mov	[ratio],ax
522
	mov	[ratio],ax
505
	mov	esi,done_str
523
	mov	esi,done_str
506
	push	done_len
524
	push	done_len
507
	pop	ecx
525
	pop	ecx
508
	call	write_string
526
	call	write_string
-
 
527
;--------------------------------------
509
; save output file
528
; save output file
510
saveout:
529
saveout:
511
	mov	esi,outname
530
	mov	esi,outname
512
	call	get_full_name
531
	call	get_full_name
513
	mov	ebx,fn70block
532
	mov	ebx,fn70block
514
	mov	[ebx],byte 2
533
	mov	[ebx],byte 2
515
	mov	eax,[outfilebest]
534
	mov	eax,[outfilebest]
516
	mov	ecx,[outsize]
535
	mov	ecx,[outsize]
517
	mov	[ebx+12],ecx
536
	mov	[ebx+12],ecx
518
	mov	[ebx+16],eax
537
	mov	[ebx+16],eax
519
	push	70
538
	mcall	70
520
	pop	eax
-
 
521
	int	40h
-
 
522
	test	eax,eax
539
	test	eax,eax
523
	jz	@f
540
	jz	@f
-
 
541
;--------------------------------------
524
outerr:
542
outerr:
525
	mov	esi,outfileerr_str
543
	mov	esi,outfileerr_str
526
	push	outfileerr_len
544
	push	outfileerr_len
527
	pop	ecx
545
	pop	ecx
528
	jmp	write_string
546
	jmp	write_string
Line 533... Line 551...
533
	mov	[ebx],byte 6
551
	mov	[ebx],byte 6
534
	mov	[ebx+4],eax
552
	mov	[ebx+4],eax
535
	mov	[ebx+8],eax
553
	mov	[ebx+8],eax
536
	mov	[ebx+12],eax
554
	mov	[ebx+12],eax
537
	mov	[ebx+16],dword file_attr
555
	mov	[ebx+16],dword file_attr
538
	mov	al,70
556
	mcall	70
539
	int	40h
-
 
540
	ret
557
	ret
541
;---------------------------------------------------------------------
558
;---------------------------------------------------------------------
542
set_outfile:
559
set_outfile:
543
	mov	eax,[outfilebest]
560
	mov	eax,[outfilebest]
544
	xor	eax,[outfile1]
561
	xor	eax,[outfile1]
Line 561... Line 578...
561
	pop	edi
578
	pop	edi
562
	mov	ecx,[insize]
579
	mov	ecx,[insize]
563
	mov	esi,[infile]
580
	mov	esi,[infile]
564
	xchg	eax,edx
581
	xchg	eax,edx
565
	mov	ebx,[inbuftmp]
582
	mov	ebx,[inbuftmp]
-
 
583
;--------------------------------------
566
input_pre:
584
input_pre:
567
	lodsb
585
	lodsb
568
	sub	al,0E8h
586
	sub	al,0E8h
569
	cmp	al,1
587
	cmp	al,1
570
	ja	input_pre_cont
588
	ja	input_pre_cont
-
 
589
 
571
	cmp	ecx,5
590
	cmp	ecx,5
572
	jb	input_pre_done
591
	jb	input_pre_done
-
 
592
 
573
	lodsd
593
	lodsd
574
	add	eax,esi
594
	add	eax,esi
575
	sub	eax,[infile]
595
	sub	eax,[infile]
576
	cmp	eax,[insize]
596
	cmp	eax,[insize]
577
	jae	xxx
597
	jae	xxx
-
 
598
 
578
	cmp	eax,1000000h
599
	cmp	eax,1000000h
579
	jae	xxx
600
	jae	xxx
-
 
601
 
580
	sub	ecx,4
602
	sub	ecx,4
581
; bswap is not supported on i386
603
; bswap is not supported on i386
582
	xchg	al,ah
604
	xchg	al,ah
583
	ror	eax,16
605
	ror	eax,16
584
	xchg	al,ah
606
	xchg	al,ah
Line 590... Line 612...
590
;---------------------------------------------------------------------
612
;---------------------------------------------------------------------
591
xxx:
613
xxx:
592
	sub	esi,4
614
	sub	esi,4
593
	movzx	eax,byte [esi]
615
	movzx	eax,byte [esi]
594
	mov	[eax+edi],byte 1
616
	mov	[eax+edi],byte 1
-
 
617
;--------------------------------------
595
input_pre_cont:
618
input_pre_cont:
596
	loop	input_pre
619
	loop	input_pre
-
 
620
;--------------------------------------
597
input_pre_done:
621
input_pre_done:
598
	mov	[ctn],edx
622
	mov	[ctn],edx
599
	xor	eax,eax
623
	xor	eax,eax
600
	mov	ecx,256
624
	mov	ecx,256
601
	repnz	scasb
625
	repnz	scasb
602
	jnz	pack_calltrick_fail
626
	jnz	pack_calltrick_fail
-
 
627
 
603
	not	cl
628
	not	cl
604
	mov	[cti],cl
629
	mov	[cti],cl
605
@@:
630
@@:
606
	cmp	ebx,[inbuftmp]
631
	cmp	ebx,[inbuftmp]
607
	jz	@f
632
	jz	@f
-
 
633
 
608
	sub	ebx,4
634
	sub	ebx,4
609
	mov	eax,[ebx]
635
	mov	eax,[ebx]
610
	mov	[eax-4],cl
636
	mov	[eax-4],cl
611
	jmp	@b
637
	jmp	@b
612
;---------------------------------------------------------------------
638
;---------------------------------------------------------------------
Line 634... Line 660...
634
preprocess_calltrick2:
660
preprocess_calltrick2:
635
; restore input
661
; restore input
636
	mov	esi,[infile]
662
	mov	esi,[infile]
637
	mov	ecx,[ctn]
663
	mov	ecx,[ctn]
638
	jecxz	pc2l2
664
	jecxz	pc2l2
-
 
665
;--------------------------------------
639
pc2l1:
666
pc2l1:
640
	lodsb
667
	lodsb
641
	sub	al,0E8h
668
	sub	al,0E8h
642
	cmp	al,1
669
	cmp	al,1
643
	ja	pc2l1
670
	ja	pc2l1
-
 
671
 
644
	mov	al,[cti]
672
	mov	al,[cti]
645
	cmp	[esi],al
673
	cmp	[esi],al
646
	jnz	pc2l1
674
	jnz	pc2l1
-
 
675
 
647
	lodsd
676
	lodsd
648
	shr	ax,8
677
	shr	ax,8
649
	ror	eax,16
678
	ror	eax,16
650
	xchg	al,ah
679
	xchg	al,ah
651
	sub	eax,esi
680
	sub	eax,esi
652
	add	eax,[infile]
681
	add	eax,[infile]
653
	mov	[esi-4],eax
682
	mov	[esi-4],eax
654
	loop	pc2l1
683
	loop	pc2l1
-
 
684
;--------------------------------------
655
pc2l2:
685
pc2l2:
656
; input preprocessing
686
; input preprocessing
657
	mov	edi,ct1
687
	mov	edi,ct1
658
	xor	eax,eax
688
	xor	eax,eax
659
	push	edi
689
	push	edi
Line 662... Line 692...
662
	pop	edi
692
	pop	edi
663
	mov	ecx,[insize]
693
	mov	ecx,[insize]
664
	mov	esi,[infile]
694
	mov	esi,[infile]
665
	mov	ebx,[inbuftmp]
695
	mov	ebx,[inbuftmp]
666
	xchg	eax,edx
696
	xchg	eax,edx
-
 
697
;--------------------------------------
667
input_pre2:
698
input_pre2:
668
	lodsb
699
	lodsb
-
 
700
;--------------------------------------
669
@@:
701
@@:
670
	cmp	al,0Fh
702
	cmp	al,0Fh
671
	jnz	ip1
703
	jnz	ip1
-
 
704
 
672
	dec	ecx
705
	dec	ecx
673
	jz	input_pre_done2
706
	jz	input_pre_done2
-
 
707
 
674
	lodsb
708
	lodsb
675
	cmp	al,80h
709
	cmp	al,80h
676
	jb	@b
710
	jb	@b
-
 
711
 
677
	cmp	al,90h
712
	cmp	al,90h
678
	jb	@f
713
	jb	@f
-
 
714
;--------------------------------------
679
ip1:
715
ip1:
680
	sub	al,0E8h
716
	sub	al,0E8h
681
	cmp	al,1
717
	cmp	al,1
682
	ja	input_pre_cont2
718
	ja	input_pre_cont2
-
 
719
;--------------------------------------
683
@@:
720
@@:
684
	cmp	ecx,5
721
	cmp	ecx,5
685
	jb	input_pre_done2
722
	jb	input_pre_done2
-
 
723
 
686
	lodsd
724
	lodsd
687
	add	eax,esi
725
	add	eax,esi
688
	sub	eax,[infile]
726
	sub	eax,[infile]
689
	cmp	eax,[insize]
727
	cmp	eax,[insize]
690
	jae	xxx2
728
	jae	xxx2
-
 
729
 
691
	cmp	eax,1000000h
730
	cmp	eax,1000000h
692
	jae	xxx2
731
	jae	xxx2
-
 
732
 
693
	sub	ecx,4
733
	sub	ecx,4
694
	xchg	al,ah
734
	xchg	al,ah
695
	rol	eax,16
735
	rol	eax,16
696
	xchg	al,ah
736
	xchg	al,ah
697
	mov	[esi-4],eax
737
	mov	[esi-4],eax
Line 701... Line 741...
701
	jmp	input_pre_cont2
741
	jmp	input_pre_cont2
702
;---------------------------------------------------------------------
742
;---------------------------------------------------------------------
703
xxx2:	sub	esi,4
743
xxx2:	sub	esi,4
704
	movzx	eax,byte [esi]
744
	movzx	eax,byte [esi]
705
	mov	[eax+edi],byte 1
745
	mov	[eax+edi],byte 1
-
 
746
;--------------------------------------
706
input_pre_cont2:
747
input_pre_cont2:
707
	loop	input_pre2
748
	loop	input_pre2
-
 
749
;--------------------------------------
708
input_pre_done2:
750
input_pre_done2:
709
	mov	[ctn],edx
751
	mov	[ctn],edx
710
	xor	eax,eax
752
	xor	eax,eax
711
	mov	ecx,256
753
	mov	ecx,256
712
	repnz	scasb
754
	repnz	scasb
713
	jnz	pack_calltrick_fail
755
	jnz	pack_calltrick_fail
-
 
756
 
714
	not	cl
757
	not	cl
715
	mov	[cti],cl
758
	mov	[cti],cl
-
 
759
;--------------------------------------
716
@@:
760
@@:
717
	cmp	ebx,[inbuftmp]
761
	cmp	ebx,[inbuftmp]
718
	jz	@f
762
	jz	@f
-
 
763
 
719
	sub	ebx,4
764
	sub	ebx,4
720
	mov	eax,[ebx]
765
	mov	eax,[ebx]
721
	mov	[eax-4],cl
766
	mov	[eax-4],cl
722
	jmp	@b
767
	jmp	@b
723
;---------------------------------------------------------------------
768
;---------------------------------------------------------------------
Line 742... Line 787...
742
	mov	[ebx],dword 5
787
	mov	[ebx],dword 5
743
	and	[ebx+4],dword 0
788
	and	[ebx+4],dword 0
744
	and	[ebx+8],dword 0
789
	and	[ebx+8],dword 0
745
	and	[ebx+12],dword 0
790
	and	[ebx+12],dword 0
746
	mov	[ebx+16],dword file_attr
791
	mov	[ebx+16],dword file_attr
747
	push	70
792
	mcall	70
748
	pop	eax
-
 
749
	int	40h
-
 
750
	test	eax,eax
793
	test	eax,eax
751
	jnz	infileerr
794
	jnz	infileerr
-
 
795
 
752
	mov	eax,[insize]
796
	mov	eax,[insize]
753
	test	eax,eax
797
	test	eax,eax
754
	jz      infileerr
798
	jz      infileerr
-
 
799
 
755
	mov	ecx,[memf]
800
	mov	ecx,[memf]
756
	mov	[infile],ecx
801
	mov	[infile],ecx
757
	add	ecx,eax
802
	add	ecx,eax
758
	mov	[outfile],ecx
803
	mov	[outfile],ecx
759
	mov	[outfilebest],ecx
804
	mov	[outfilebest],ecx
760
	push	64
805
	mcall	64,1
761
	pop	eax
-
 
762
	push	1
-
 
763
	pop	ebx
-
 
764
	int	40h
-
 
765
	test	eax,eax
806
	test	eax,eax
766
	jnz	memf1
807
	jnz	memf1
-
 
808
 
767
	mov	ebx,fn70block
809
	mov	ebx,fn70block
768
	mov	[ebx],byte 0
810
	mov	[ebx],byte 0
769
	mov	eax,[insize]
811
	mov	eax,[insize]
770
	mov	[ebx+12],eax
812
	mov	[ebx+12],eax
771
	mov	esi,[infile]
813
	mov	esi,[infile]
772
	mov	[ebx+16],esi
814
	mov	[ebx+16],esi
773
	push	70
815
	mcall	70
774
	pop	eax
-
 
775
	int	40h
-
 
776
	test	eax,eax
816
	test	eax,eax
777
	jnz	infileerr
817
	jnz	infileerr
-
 
818
 
778
	mov	eax,[infile]
819
	mov	eax,[infile]
779
	cmp	[eax],dword 'KPCK'	;'KCPK'
820
	cmp	[eax],dword 'KPCK'
780
	jz	@f
821
	jz	@f
-
 
822
;--------------------------------------
781
unpack_err:
823
unpack_err:
782
	mov	esi,notpacked_str
824
	mov	esi,notpacked_str
783
	push	notpacked_len
825
	push	notpacked_len
784
	pop	ecx
826
	pop	ecx
785
	jmp	write_string
827
	jmp	write_string
786
;---------------------------------------------------------------------
828
;---------------------------------------------------------------------
787
@@:
829
@@:
788
	mov	ecx,[outfile]
830
	mov	ecx,[outfile]
789
	add	ecx,dword [eax+4]
831
	add	ecx,dword [eax+4]
790
	push	64
832
	mcall	64,1
791
	pop	eax
-
 
792
	push	1
-
 
793
	pop	ebx
-
 
794
	int	40h
-
 
795
	test	eax,eax
833
	test	eax,eax
796
	jnz	memf1
834
	jnz	memf1
-
 
835
 
797
	mov	esi,[infile]
836
	mov	esi,[infile]
798
	mov	eax,[esi+8]
837
	mov	eax,[esi+8]
799
	push	eax
838
	push	eax
800
	and	al,0C0h
839
	and	al,0C0h
801
	cmp	al,0C0h
840
	cmp	al,0C0h
802
	pop	eax
841
	pop	eax
803
	jz	unpack_err
842
	jz	unpack_err
-
 
843
 
804
	and	al,not 0C0h
844
	and	al,not 0C0h
805
	dec	eax
845
	dec	eax
806
	jnz	unpack_err
846
	jnz	unpack_err
-
 
847
 
807
	mov	eax,[esi+4]
848
	mov	eax,[esi+4]
808
	mov	[outsize],eax
849
	mov	[outsize],eax
809
	push	eax
850
	push	eax
810
	push	[outfile]
851
	push	[outfile]
811
	add	esi,11
852
	add	esi,11
Line 817... Line 858...
817
	mov	[esi+1],eax
858
	mov	[esi+1],eax
818
	call	lzma_decompress
859
	call	lzma_decompress
819
	mov	esi,[infile]
860
	mov	esi,[infile]
820
	test	[esi+8],byte 80h
861
	test	[esi+8],byte 80h
821
	jnz	uctr1
862
	jnz	uctr1
-
 
863
 
822
	test	[esi+8],byte 40h
864
	test	[esi+8],byte 40h
823
	jz	udone
865
	jz	udone
-
 
866
 
824
	add	esi,[insize]
867
	add	esi,[insize]
825
	sub	esi,5
868
	sub	esi,5
826
	lodsd
869
	lodsd
827
	mov	ecx,eax
870
	mov	ecx,eax
828
	jecxz	udone
871
	jecxz	udone
-
 
872
 
829
	mov	dl,[esi]
873
	mov	dl,[esi]
830
	mov	esi,[outfile]
874
	mov	esi,[outfile]
-
 
875
;--------------------------------------
831
uc1:
876
uc1:
832
	lodsb
877
	lodsb
833
	sub	al,0E8h
878
	sub	al,0E8h
834
	cmp	al,1
879
	cmp	al,1
835
	ja	uc1
880
	ja	uc1
-
 
881
 
836
	cmp	[esi],dl
882
	cmp	[esi],dl
837
	jnz	uc1
883
	jnz	uc1
-
 
884
 
838
	lodsd
885
	lodsd
839
	shr	ax,8
886
	shr	ax,8
840
	ror	eax,16
887
	ror	eax,16
841
	xchg	al,ah
888
	xchg	al,ah
842
	sub	eax,esi
889
	sub	eax,esi
Line 849... Line 896...
849
	add	esi,[insize]
896
	add	esi,[insize]
850
	sub	esi,5
897
	sub	esi,5
851
	lodsd
898
	lodsd
852
	mov	ecx,eax
899
	mov	ecx,eax
853
	jecxz	udone
900
	jecxz	udone
-
 
901
 
854
	mov	dl,[esi]
902
	mov	dl,[esi]
855
	mov	esi,[outfile]
903
	mov	esi,[outfile]
-
 
904
;--------------------------------------
856
uc2:
905
uc2:
857
	lodsb
906
	lodsb
-
 
907
;--------------------------------------
858
@@:
908
@@:
859
	cmp	al,15
909
	cmp	al,15
860
	jnz	uf
910
	jnz	uf
-
 
911
 
861
	lodsb
912
	lodsb
862
	cmp	al,80h
913
	cmp	al,80h
863
	jb	@b
914
	jb	@b
-
 
915
 
864
	cmp	al,90h
916
	cmp	al,90h
865
	jb	@f
917
	jb	@f
-
 
918
;--------------------------------------
866
uf:
919
uf:
867
	sub	al,0E8h
920
	sub	al,0E8h
868
	cmp	al,1
921
	cmp	al,1
869
	ja	uc2
922
	ja	uc2
-
 
923
;--------------------------------------
870
@@:
924
@@:
871
	cmp	[esi],dl
925
	cmp	[esi],dl
872
	jnz	uc2
926
	jnz	uc2
-
 
927
 
873
	lodsd
928
	lodsd
874
	shr	ax,8
929
	shr	ax,8
875
	ror	eax,16
930
	ror	eax,16
876
	xchg	al,ah
931
	xchg	al,ah
877
	sub	eax,esi
932
	sub	eax,esi
878
	add	eax,[outfile]
933
	add	eax,[outfile]
879
	mov	[esi-4],eax
934
	mov	[esi-4],eax
880
	loop	uc2
935
	loop	uc2
-
 
936
;--------------------------------------
881
udone:
937
udone:
882
	mov	esi,unpacked_ok
938
	mov	esi,unpacked_ok
883
	push	unpacked_len
939
	push	unpacked_len
884
	pop	ecx
940
	pop	ecx
885
	call	write_string
941
	call	write_string
886
	jmp	saveout
942
	jmp	saveout
-
 
943
 
887
;---------------------------------------------------------------------
944
;---------------------------------------------------------------------
888
get_full_name:
945
get_full_name:
889
	push	esi
946
	push	esi
890
	mov	esi,path
947
	mov	esi,path
891
	mov	ecx,[esi-4]
948
	mov	ecx,[esi-4]
892
	mov	edi,fullname
949
	mov	edi,fullname
893
	rep	movsb
950
	rep	movsb
894
	mov	al,'/'
951
	mov	al,'/'
895
	cmp	[edi-1],al
952
	cmp	[edi-1],al
896
	jz	@f
953
	jz	@f
-
 
954
 
897
	stosb
955
	stosb
-
 
956
;--------------------------------------
898
@@:
957
@@:
899
	pop	esi
958
	pop	esi
900
	cmp	[esi],al
959
	cmp	[esi],al
901
	jnz	@f
960
	jnz	@f
-
 
961
 
902
	mov	edi,fullname
962
	mov	edi,fullname
-
 
963
;--------------------------------------
903
@@:
964
@@:
904
	mov	ecx,[esi-4]
965
	mov	ecx,[esi-4]
905
	rep	movsb
966
	rep	movsb
906
	xor	eax,eax
967
	xor	eax,eax
907
	stosb
968
	stosb
908
	ret
969
	ret
909
;---------------------------------------------------------------------
970
;---------------------------------------------------------------------
910
wsret:
971
wsret:
911
	ret
972
	ret
-
 
973
;---------------------------------------------------------------------
912
write_string:
974
write_string:
913
; in: esi=pointer, ecx=length
975
; in: esi=pointer, ecx=length
914
	mov	edx,[message_cur_pos]
976
	mov	edx,[message_cur_pos]
-
 
977
;--------------------------------------
915
x1:
978
x1:
916
	lea	edi,[message_mem+edx]
979
	lea	edi,[message_mem+edx]
-
 
980
;--------------------------------------
917
do_write_char:
981
do_write_char:
918
	lodsb
982
	lodsb
919
	cmp	al,10
983
	cmp	al,10
920
	jz	newline
984
	jz	newline
-
 
985
 
921
	stosb
986
	stosb
922
	inc	edx
987
	inc	edx
923
	loop	do_write_char
988
	loop	do_write_char
924
	jmp	x2
989
	jmp	x2
925
;---------------------------------------------------------------------
990
;---------------------------------------------------------------------
Line 935... Line 1000...
935
	xchg	eax,edx
1000
	xchg	eax,edx
936
	sub	edx,eax
1001
	sub	edx,eax
937
	add	edx,ecx
1002
	add	edx,ecx
938
	pop	ecx
1003
	pop	ecx
939
	loop	x1
1004
	loop	x1
-
 
1005
;--------------------------------------
940
x2:
1006
x2:
941
	mov	[message_cur_pos],edx
1007
	mov	[message_cur_pos],edx
942
; update window
1008
; update window
943
	push	13
-
 
944
	pop	eax
-
 
945
	mov	ebx,901A1h
-
 
946
	mov	ecx,[skinheight]
1009
	mov	ecx,[skinheight]
947
	shl	ecx,16
1010
	shl	ecx,16
948
	add	ecx,3700DEh
1011
	add	ecx,3700DEh
949
	mov	edx,[color_table+20]
1012
	mcall	13,<9,417>,,[color_table+20]
950
	int	40h
1013
;--------------------------------------
951
draw_messages:
1014
draw_messages:
952
	mov	ebx,[skinheight]
1015
	mov	ebx,[skinheight]
953
	add	ebx,3Ch+12*10000h
1016
	add	ebx,3Ch+12*10000h
954
	mov	edi,message_mem
1017
	mov	edi,message_mem
-
 
1018
;--------------------------------------
955
@@:
1019
@@:
956
	push	edi
1020
	push	edi
957
	xor	eax,eax
1021
	xor	eax,eax
958
	push	80
1022
	push	80
959
	pop	ecx
1023
	pop	ecx
960
	repnz	scasb
1024
	repnz	scasb
961
	sub	ecx,79
1025
	sub	ecx,79
962
	neg	ecx
1026
	neg	ecx
963
	mov	esi,ecx
1027
	mov	esi,ecx
964
	mov	al,4
-
 
965
	pop	edi
1028
	pop	edi
966
	mov	edx,edi
-
 
967
	mov	ecx,[color_table+32]
1029
	mcall	4,,[color_table+32],edi
968
	int	40h
-
 
969
	add	ebx,10
1030
	add	ebx,10
970
	add	edi,80
1031
	add	edi,80
971
	cmp	edi,message_cur_pos
1032
	cmp	edi,message_cur_pos
972
	jb	@b
1033
	jb	@b
-
 
1034
 
973
	ret
1035
	ret
974
;---------------------------------------------------------------------
1036
;---------------------------------------------------------------------
975
draw_window:
1037
draw_window:
976
; start redraw
1038
; start redraw
977
	push	12
1039
	mcall	12,1
978
	pop	eax
-
 
979
	xor	ebx,ebx
-
 
980
	inc	ebx
-
 
981
	int	40h
-
 
982
	mov	edi,[skinheight]
1040
	mov	edi,[skinheight]
983
; define window
1041
; define window
984
	xor	eax,eax
1042
	xor	eax,eax
985
	mov	ebx,6401B3h
-
 
986
	mov	ecx,64011Eh
1043
	mov	ecx,100 shl 16+286
987
	add	ecx,edi
1044
	add	ecx,edi
988
	mov	edx,[color_table+20]
1045
	mov	edx,[color_table+20]
989
	add	edx,13000000h
1046
	add	edx,13000000h
990
	push	edi
1047
	push	edi
991
	mov	edi,caption_str
1048
	xor	esi,esi
992
	int	40h
1049
	mcall	,<100,435>,,,,caption_str
993
	pop	edi
1050
	pop	edi
994
; lines - horizontal
1051
; lines - horizontal
995
	mov	edx,[color_table+36]
-
 
996
	mov	ebx,80160h
1052
	mov	ebx,8 shl 16+352
997
	mov	ecx,edi
1053
	mov	ecx,edi
998
	shl	ecx,16
1054
	shl	ecx,16
999
	or	ecx,edi
1055
	or	ecx,edi
1000
	add	ecx,20002h
1056
	add	ecx,2 shl 16+2
1001
	mov	al,38
1057
	mcall	38,,,[color_table+36]
1002
	int	40h
-
 
1003
	add	ecx,0C000Ch
1058
	add	ecx,12 shl 16+12
1004
	int	40h
1059
	mcall
1005
	add	ecx,0C000Ch
1060
	add	ecx,12 shl 16+12
1006
	int	40h
1061
	mcall
1007
	add	ecx,0C000Ch
1062
	add	ecx,12 shl 16+12
1008
	int	40h
1063
	mcall
1009
; lines - vertical
1064
; lines - vertical
1010
	mov	ebx,80008h
-
 
1011
	sub	ecx,240000h
1065
	sub	ecx,36 shl 16
1012
	int	40h
1066
	mcall	,<8,8>
1013
	add	ebx,340034h
1067
	add	ebx,52 shl 16+52
1014
	int	40h
1068
	mcall
1015
	add	ebx,1240124h
1069
	add	ebx,292 shl 16+292
1016
	int	40h
1070
	mcall
1017
; draw frame for messages data
1071
; draw frame for messages data
1018
	push	ecx
1072
	push	ecx
1019
	mov	ebx,801AAh
-
 
1020
	add	ecx,340010h
1073
	add	ecx,52 shl 16+16
1021
	int	40h
1074
	mcall	,<8,425>
1022
	add	ecx,0E0h*10001h
1075
	add	ecx,224*(1 shl 16+1)
1023
	int	40h
1076
	mcall
1024
	mov	ebx,80008h
-
 
1025
	sub	cx,0E0h
1077
	sub	cx,224
1026
	int	40h
1078
	mcall	,<8,8>
1027
	mov	ebx,1AA01AAh
1079
	mcall	,<426,426>
1028
	int	40h
-
 
1029
	pop	ecx
1080
	pop	ecx
1030
; define compress button
1081
; define compress button
1031
	mov	al,8
-
 
1032
	mov	cx,12h
1082
	mov	cx,18
1033
	mov	ebx,1620048h
-
 
1034
	push	2
-
 
1035
	pop	edx
-
 
1036
	mov	esi,[color_table+36]
1083
	mcall	8,<354,72>,,2,[color_table+36]
1037
	int	40h
-
 
1038
; uncompress button
1084
; uncompress button
1039
	add	ecx,120000h
1085
	add	ecx,18 shl 16
1040
	inc	edx
1086
	inc	edx
1041
	int	40h
1087
	mcall
1042
	add	ecx,-12h+0Ah+140000h
1088
	add	ecx,-12h+0Ah+140000h
1043
; question button
1089
; question button
1044
	push	esi
1090
	push	esi
1045
	mov	ebx,1A10009h
-
 
1046
	mov	dl,7
1091
	mov	dl,7
1047
	int	40h
-
 
1048
	mov	al,4
1092
	mcall	,<417,9>
1049
	mov	edx,aQuestion
-
 
1050
	push	1
-
 
1051
	pop	esi
-
 
1052
	shr	ecx,16
1093
	shr	ecx,16
1053
	lea	ebx,[ecx+1A40002h]
1094
	lea	ebx,[ecx+1A40002h]
1054
	mov	ecx,[color_table+28]
1095
	mcall	4,,[color_table+28],aQuestion,1
1055
	int	40h
-
 
1056
	mov	al,8
1096
	mov	al,8
1057
	pop	esi
1097
	pop	esi
1058
; define settings buttons
1098
; define settings buttons
1059
	mov	ebx,90032h
1099
	mov	ebx,9 shl 16+50
1060
	lea	ecx,[edi+2]
1100
	lea	ecx,[edi+2]
1061
	shl	ecx,16
1101
	shl	ecx,16
1062
	mov	cx,0Bh
1102
	mov	cx,11
1063
	push	4
1103
	push	4
1064
	pop	edx
1104
	pop	edx
-
 
1105
;--------------------------------------
1065
@@:
1106
@@:
1066
	int	40h
1107
	mcall
1067
	add	ecx,0C0000h
1108
	add	ecx,12 shl 16
1068
	inc	edx
1109
	inc	edx
1069
	cmp	edx,6
1110
	cmp	edx,6
1070
	jbe	@b
1111
	jbe	@b
1071
; text on settings buttons
1112
; text on settings buttons
1072
	lea	ebx,[edi+5+0C0000h]
1113
	lea	ebx,[edi+5+0C0000h]
Line 1074... Line 1115...
1074
	mov	ecx,[color_table+28]
1115
	mov	ecx,[color_table+28]
1075
	push	buttons1names
1116
	push	buttons1names
1076
	pop	edx
1117
	pop	edx
1077
	push	8
1118
	push	8
1078
	pop	esi
1119
	pop	esi
-
 
1120
;--------------------------------------
1079
@@:
1121
@@:
1080
	int	40h
1122
	mcall
1081
	add	edx,esi
1123
	add	edx,esi
1082
	add	ebx,0Ch
1124
	add	ebx,12
1083
	cmp	[edx-6],byte ' '
1125
	cmp	[edx-6],byte ' '
1084
	jnz	@b
1126
	jnz	@b
1085
; text on compress and decompress buttons
1127
; text on compress and decompress buttons
1086
	lea	ebx,[edi+8+1720000h]
1128
	lea	ebx,[edi+8+1720000h]
1087
	push	aCompress
-
 
1088
	pop	edx
-
 
1089
	or	ecx,80000000h
1129
	or	ecx,80000000h
1090
	int	40h
1130
	mcall	,,,aCompress
1091
	lea	ebx,[edi+1Ah+16A0000h]
1131
	lea	ebx,[edi+1Ah+16A0000h]
1092
	push	aDecompress
1132
	mcall	,,,aDecompress
1093
	pop	edx
-
 
1094
	int	40h
-
 
1095
; infile, outfile, path strings
1133
; infile, outfile, path strings
1096
	mov	edx,inname
1134
	mov	edx,inname
1097
	lea	ebx,[edi+400005h]
1135
	lea	ebx,[edi+400005h]
-
 
1136
;--------------------------------------
1098
editdraw:
1137
editdraw:
1099
	mov	esi,[edx-4]
-
 
1100
	mov	al,4
-
 
1101
	mov	ecx,[color_table+32]
1138
	mcall	4,,[color_table+32],,[edx-4]
1102
	int	40h
-
 
1103
	cmp	edx,[curedit]
1139
	cmp	edx,[curedit]
1104
	jnz	cont
1140
	jnz	cont
-
 
1141
 
1105
	mov	al,1
1142
	mov	al,1
1106
	push	ebx
1143
	push	ebx
1107
	push	edx
1144
	push	edx
1108
	movzx	ecx,bx
1145
	movzx	ecx,bx
1109
	shr	ebx,16
1146
	shr	ebx,16
1110
	lea	edx,[esi*2]
1147
	lea	edx,[esi*2]
1111
	lea	edx,[edx+edx*2]
1148
	lea	edx,[edx+edx*2]
1112
	lea	ebx,[ebx+edx+2]
1149
	lea	ebx,[ebx+edx+2]
1113
	add	ecx,4
1150
	add	ecx,4
1114
	xor	edx,edx
1151
	xor	edx,edx
-
 
1152
;--------------------------------------
1115
@@:
1153
@@:
1116
	cmp	esi,48
1154
	cmp	esi,48
1117
	jz	@f
1155
	jz	@f
-
 
1156
 
1118
	int	40h
1157
	mcall
1119
	add	ebx,6
1158
	add	ebx,6
1120
	inc	esi
1159
	inc	esi
1121
	jmp	@b
1160
	jmp	@b
1122
;---------------------------------------------------------------------
1161
;---------------------------------------------------------------------
1123
@@:
1162
@@:
1124
	pop	edx
1163
	pop	edx
1125
	pop	ebx
1164
	pop	ebx
-
 
1165
;--------------------------------------
1126
cont:
1166
cont:
1127
	add	edx,52
1167
	add	edx,52
1128
	add	ebx,0Ch
1168
	add	ebx,0Ch
1129
	cmp	edx,path+52
1169
	cmp	edx,path+52
1130
	jb	editdraw
1170
	jb	editdraw
1131
; draw messages
1171
; draw messages
1132
	call	draw_messages
1172
	call	draw_messages
1133
; end redraw
1173
; end redraw
1134
	push	12
1174
	mcall	12,2
1135
	pop	eax
-
 
1136
	push	2
-
 
1137
	pop	ebx
-
 
1138
	int	40h
-
 
1139
	ret
1175
	ret
1140
;---------------------------------------------------------------------
1176
;---------------------------------------------------------------------
1141
copy_name:
1177
copy_name:
1142
	lea	edx,[edi+48]
1178
	lea	edx,[edi+48]
-
 
1179
;--------------------------------------
1143
@@:
1180
@@:
1144
	lodsb
1181
	lodsb
1145
	cmp	al,' '
1182
	cmp	al,' '
1146
	jbe	copy_name_done
1183
	jbe	copy_name_done
-
 
1184
 
1147
	stosb
1185
	stosb
1148
	cmp	edi,edx
1186
	cmp	edi,edx
1149
	jb	@b
1187
	jb	@b
-
 
1188
;--------------------------------------
1150
@@:
1189
@@:
1151
	lodsb
1190
	lodsb
1152
	cmp	al,' '
1191
	cmp	al,' '
1153
	ja	@b
1192
	ja	@b
-
 
1193
;--------------------------------------
1154
copy_name_done:
1194
copy_name_done:
1155
	dec	esi
1195
	dec	esi
1156
	sub	edx,48
1196
	sub	edx,48
1157
	sub	edi,edx
1197
	sub	edi,edx
1158
	mov	[edx-4],edi
1198
	mov	[edx-4],edi
1159
 
-
 
-
 
1199
;--------------------------------------
1160
skip_spaces:
1200
skip_spaces:
1161
	lodsb
1201
	lodsb
1162
	cmp	al,0
1202
	cmp	al,0
1163
	jz	@f
1203
	jz	@f
-
 
1204
 
1164
	cmp	al,' '
1205
	cmp	al,' '
1165
	jbe	skip_spaces
1206
	jbe	skip_spaces
-
 
1207
;--------------------------------------
1166
@@:
1208
@@:
1167
	dec	esi
1209
	dec	esi
1168
	ret
1210
	ret
1169
;---------------------------------------------------------------------
1211
;---------------------------------------------------------------------
1170
clear_edit_points:
1212
clear_edit_points:
1171
; clear edit points (if is)
1213
; clear edit points (if is)
1172
	mov	esi,[curedit]
1214
	mov	esi,[curedit]
1173
	test	esi,esi
1215
	test	esi,esi
1174
	jz	cleared_edit_points
1216
	jz	cleared_edit_points
-
 
1217
 
1175
	push	eax
1218
	push	eax
1176
	mov	al,13
-
 
1177
	mov	ebx,[esi-4]
1219
	mov	ebx,[esi-4]
1178
	imul	ebx,6
1220
	imul	ebx,6
1179
	mov	edi,ebx
1221
	mov	edi,ebx
1180
	add	ebx,40h
1222
	add	ebx,40h
1181
	shl	ebx,16
1223
	shl	ebx,16
1182
	add	ebx,48*6
1224
	add	ebx,48*6
1183
	sub	bx,di
1225
	sub	bx,di
1184
	mov	ecx,[curedit_y]
1226
	mov	ecx,[curedit_y]
1185
	shl	ecx,16
1227
	shl	ecx,16
1186
	or	cx,9
1228
	or	cx,9
1187
	mov	edx,[color_table+20]
1229
	mcall	13,,,[color_table+20]
1188
	int	40h
-
 
1189
	pop	eax
1230
	pop	eax
-
 
1231
;--------------------------------------
1190
cleared_edit_points:
1232
cleared_edit_points:
1191
	ret
1233
	ret
1192
;---------------------------------------------------------------------
1234
;---------------------------------------------------------------------
1193
;lzma_compress:
1235
;lzma_compress:
1194
include 'lzma_compress.inc'
1236
include 'lzma_compress.inc'
Line 1197... Line 1239...
1197
include 'lzma_set_dict_size.inc'
1239
include 'lzma_set_dict_size.inc'
1198
;---------------------------------------------------------------------
1240
;---------------------------------------------------------------------
1199
;lzma_decompress:
1241
;lzma_decompress:
1200
include	'lzma_decompress.inc'
1242
include	'lzma_decompress.inc'
1201
;---------------------------------------------------------------------
1243
;---------------------------------------------------------------------
1202
aQuestion	db '?'
-
 
1203
caption_str	db 'KPack',0
-
 
1204
buttons1names	db ' InFile:'
-
 
1205
		db 'OutFile:'
-
 
1206
		db '   Path:'
-
 
1207
aCompress	db 'COMPRESS',0
-
 
1208
aDecompress	db 'DECOMPRESS',0
-
 
1209
definoutname	db 0
-
 
1210
defpath		db '/RD/1/'
-
 
1211
curedit		dd 0
-
 
1212
 
-
 
1213
info_str	db 'KPack - Kolibri Packer, version 0.13',10
-
 
1214
		db 'Uses LZMA v4.32 compression library',10,10
-
 
1215
info_len	= $ - info_str
-
 
1216
usage_str	db 'Written by diamond in 2006, 2007, 2009 specially for KolibriOS',10
-
 
1217
		db 'LZMA  is copyright (c) 1999-2005 by Igor Pavlov',10
-
 
1218
		db 10
-
 
1219
		db 'Command-line usage:',10
-
 
1220
		db ' kpack infile [outfile]',10
-
 
1221
		db 'If no output file is specified,',10
-
 
1222
		db '    packed data will be written back to input file',10
-
 
1223
		db 10
-
 
1224
		db 'Window usage:',10
-
 
1225
		db " enter input file name, output file name and press needed button",10
-
 
1226
usage_len	= $ - usage_str
-
 
1227
errload_str	db 'Cannot load input file',10
-
 
1228
errload_len	= $ - errload_str
-
 
1229
outfileerr_str	db 'Cannot save output file',10
-
 
1230
outfileerr_len	= $ - outfileerr_str
-
 
1231
nomem_str	db 'No memory',10
-
 
1232
nomem_len	= $ - nomem_str
-
 
1233
too_big_str	db 'failed, output is greater than input.',10
-
 
1234
too_big_len	= $ - too_big_str
-
 
1235
compressing_str	db 'Compressing ... '
-
 
1236
compressing_len = $ - compressing_str
-
 
1237
lzma_memsmall_str db	'Warning: not enough memory for default LZMA settings,',10
-
 
1238
		db '         will use less dictionary size',10
-
 
1239
lzma_memsmall_len = $ - lzma_memsmall_str
-
 
1240
notpacked_str	db 'Input file is not packed with KPack!',10
-
 
1241
notpacked_len	= $ - notpacked_str
1244
;initialized variables and constants
1242
unpacked_ok	db 'Unpacked successful',10
-
 
1243
unpacked_len	= $ - unpacked_ok
-
 
1244
 
-
 
1245
done_str	db 'OK! Compression ratio: '
1245
include 'const_var.inc'
1246
ratio		dw	'00'
-
 
1247
		db '%',10
-
 
1248
done_len	= $ - done_str
-
 
1249
;---------------------------------------------------------------------
-
 
1250
align 4
-
 
1251
LiteralNextStates:	;0x30C: ;Binary tree
-
 
1252
db 0,0,0,0,1,2,3,4,5,6,4,5
-
 
1253
MatchNextStates:	;0x318:
-
 
1254
db 7,7,7,7,7,7,7,10,10,10,10,10
-
 
1255
RepNextStates:	;0x324:
-
 
1256
db 8,8,8,8,8,8,8,11,11,11,11,11
-
 
1257
ShortRepNextStates:	;0x330:
-
 
1258
db 9,9,9,9,9,9,9,11,11,11,11,11
-
 
1259
;0x33C:
-
 
1260
;---------------------------------------------------------------------
1246
;---------------------------------------------------------------------
1261
IM_END:
1247
IM_END:
1262
;---------------------------------------------------------------------
1248
;---------------------------------------------------------------------
1263
;rb	0xD3C  ;unknown space area
-
 
1264
params:
-
 
1265
	rb 256
-
 
1266
;---------------------------------------------------------------------	
-
 
1267
color_table	rd 10
-
 
1268
skinheight	rd 1
1249
;uninitialized data
1269
 
-
 
1270
innamelen	rd 1
-
 
1271
inname		rb 48
-
 
1272
outnamelen	rd 1
-
 
1273
outname		rb 48
-
 
1274
pathlen		rd 1
-
 
1275
path		rb 48
-
 
1276
curedit_y	rd 1
1250
include 'data.inc'
1277
 
-
 
1278
message_mem	rb 80*20
-
 
1279
message_cur_pos	rd 1
-
 
1280
 
-
 
1281
outsize		rd 1
-
 
1282
infile		rd 1
-
 
1283
outfile		rd 1
-
 
1284
outfile1	rd 1
-
 
1285
outfile2	rd 1
-
 
1286
outfilebest	rd 1
-
 
1287
inbuftmp	rd 1
-
 
1288
workmem		rd 1
-
 
1289
lzma_dictsize	rd 1
-
 
1290
ct1		rb 256
-
 
1291
ctn		rd 1
-
 
1292
cti		rb 1
-
 
1293
use_lzma	= 1
-
 
1294
 
-
 
1295
use_no_calltrick = 0
-
 
1296
use_calltrick1	= 40h
-
 
1297
use_calltrick2	= 80h
-
 
1298
 
-
 
1299
method		rb 1
-
 
1300
 
-
 
1301
;---------------------------------------------------------------------
-
 
1302
align 4
-
 
1303
fn70block:
-
 
1304
fn70op		rd 1
-
 
1305
fn70start	rd 1
-
 
1306
fn70size	rd 1
-
 
1307
fn70zero	rd 1
-
 
1308
fn70dest	rd 1
-
 
1309
fullname	rb 100
-
 
1310
 
-
 
1311
;---------------------------------------------------------------------
-
 
1312
align 4
-
 
1313
file_attr	rd 8
-
 
1314
insize		rd 1       ; last qword in file_attr
-
 
1315
		rd 1
-
 
1316
;---------------------------------------------------------------------
-
 
1317
align 4
-
 
1318
	rb 4096
-
 
1319
stacktop:
-
 
1320
;---------------------------------------------------------------------
1251
;---------------------------------------------------------------------
1321
I_END:
1252
I_END:
1322
;---------------------------------------------------------------------
1253
;---------------------------------------------------------------------
1323
1254