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