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