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