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