Rev 6804 | Rev 7432 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5183 | hidnplayr | 1 | format binary as "" |
2 | |||
1004 | diamond | 3 | use32 |
4 | org 0x0 |
||
5 | |||
6 | db 'MENUET01' |
||
7421 | leency | 7 | dd 0x01, START, I_END, F_END, stacktop, @PARAMS, sys_path |
1004 | diamond | 8 | |
9 | ;----------------------------------------------------------------------------- |
||
10 | |||
3116 | dunkaist | 11 | include '../../../config.inc' |
1080 | diamond | 12 | include '../../../proc32.inc' |
13 | include '../../../macros.inc' |
||
3116 | dunkaist | 14 | include '../../../dll.inc' |
6801 | IgorA | 15 | include '../../../KOSfuncs.inc' |
3116 | dunkaist | 16 | ;include '../../../debug.inc' |
1004 | diamond | 17 | |
18 | include '../../../develop/libraries/libs-dev/libio/libio.inc' |
||
19 | include '../../../develop/libraries/libs-dev/libimg/libimg.inc' |
||
20 | |||
1511 | mario79 | 21 | ;include '../../../develop/libraries/box_lib/asm/trunk/opendial.mac' |
22 | ;use_OpenDialog |
||
1004 | diamond | 23 | ;----------------------------------------------------------------------------- |
24 | |||
25 | START: |
||
6801 | IgorA | 26 | mcall SF_SYS_MISC, SSF_HEAP_INIT |
1004 | diamond | 27 | |
1570 | dunkaist | 28 | stdcall dll.Load, @IMPORT |
29 | or eax, eax |
||
30 | jnz exit |
||
1004 | diamond | 31 | |
1570 | dunkaist | 32 | invoke sort.START, 1 |
1016 | diamond | 33 | |
1570 | dunkaist | 34 | mov ecx, 1 ; for 15.4: 1 = tile |
35 | cmp word [@PARAMS], '\T' |
||
36 | jz set_bgr |
||
37 | inc ecx ; for 15.4: 2 = stretch |
||
38 | cmp word [@PARAMS], '\S' |
||
39 | jz set_bgr |
||
1004 | diamond | 40 | |
1594 | mario79 | 41 | cmp byte [@PARAMS], 0 |
42 | jz @f |
||
43 | mov esi, @PARAMS |
||
44 | mov edi, path |
||
45 | mov ecx, 4096/4 |
||
46 | rep movsd |
||
47 | mov byte [edi-1], 0 |
||
48 | @@: |
||
49 | ; OpenDialog initialisation |
||
50 | push dword OpenDialog_data |
||
51 | call [OpenDialog_Init] |
||
52 | |||
1427 | diamond | 53 | ; initialize keyboard handling |
1570 | dunkaist | 54 | invoke ini_get_shortcut, inifilename, aShortcuts, aNext, -1, next_mod |
55 | mov [next_key], eax |
||
56 | invoke ini_get_shortcut, inifilename, aShortcuts, aPrev, -1, prev_mod |
||
57 | mov [prev_key], eax |
||
3116 | dunkaist | 58 | invoke ini_get_shortcut, inifilename, aShortcuts, aSlide, -1, slide_mod |
59 | mov [slide_key], eax |
||
60 | invoke ini_get_shortcut, inifilename, aShortcuts, aTglbar, -1, tglbar_mod |
||
61 | mov [tglbar_key], eax |
||
6801 | IgorA | 62 | mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1 ; set kbd mode to scancodes |
1427 | diamond | 63 | |
1570 | dunkaist | 64 | cmp byte [@PARAMS], 0 |
65 | jnz params_given |
||
1004 | diamond | 66 | |
1570 | dunkaist | 67 | mov [OpenDialog_data.draw_window],draw_window_fake |
68 | |||
1511 | mario79 | 69 | ; OpenDialog Open |
1570 | dunkaist | 70 | push dword OpenDialog_data |
71 | call [OpenDialog_Start] |
||
1470 | mario79 | 72 | |
1570 | dunkaist | 73 | cmp [OpenDialog_data.status],1 |
74 | jne exit |
||
1470 | mario79 | 75 | |
1570 | dunkaist | 76 | mov [OpenDialog_data.draw_window],draw_window |
1470 | mario79 | 77 | |
1570 | dunkaist | 78 | mov esi, path |
79 | mov edi, @PARAMS |
||
80 | mov ecx, 4096/4 |
||
81 | rep movsd |
||
82 | mov byte [edi-1], 0 |
||
83 | jmp params_given |
||
1004 | diamond | 84 | |
85 | set_bgr: |
||
6801 | IgorA | 86 | mcall SF_BACKGROUND_SET, SSF_MODE_BG |
1570 | dunkaist | 87 | mov eax, @PARAMS + 4 |
88 | call load_image |
||
89 | jc exit |
||
1004 | diamond | 90 | |
1570 | dunkaist | 91 | call set_as_bgr |
92 | jmp exit |
||
1004 | diamond | 93 | |
94 | params_given: |
||
95 | |||
1570 | dunkaist | 96 | mov esi, @PARAMS |
97 | push esi |
||
98 | call find_last_name_component |
||
1427 | diamond | 99 | |
1570 | dunkaist | 100 | pop eax |
101 | call load_image |
||
102 | jc exit |
||
103 | call generate_header |
||
1004 | diamond | 104 | |
105 | ;----------------------------------------------------------------------------- |
||
106 | |||
107 | red: |
||
1570 | dunkaist | 108 | call draw_window |
1004 | diamond | 109 | |
110 | still: |
||
1570 | dunkaist | 111 | mov eax, [image] |
112 | test byte [eax + Image.Flags], Image.IsAnimated |
||
6804 | IgorA | 113 | push SF_WAIT_EVENT |
1570 | dunkaist | 114 | pop eax |
115 | jz @f |
||
6801 | IgorA | 116 | mcall SF_SYSTEM_GET, SSF_TIME_COUNT |
1570 | dunkaist | 117 | mov edx, [cur_frame] |
118 | mov ebx, [cur_frame_time] |
||
119 | add ebx, [edx + Image.Delay] |
||
120 | sub ebx, eax |
||
121 | cmp ebx, [edx + Image.Delay] |
||
122 | ja red_update_frame |
||
123 | test ebx, ebx |
||
124 | jz red_update_frame |
||
6804 | IgorA | 125 | push SF_WAIT_EVENT_TIMEOUT |
1570 | dunkaist | 126 | pop eax |
1080 | diamond | 127 | @@: |
1570 | dunkaist | 128 | mcall |
129 | dec eax |
||
130 | js red_update_frame |
||
131 | jz red |
||
132 | dec eax |
||
133 | jnz button |
||
1004 | diamond | 134 | |
1080 | diamond | 135 | key: |
1570 | dunkaist | 136 | xor esi, esi |
1427 | diamond | 137 | keyloop: |
6801 | IgorA | 138 | mcall SF_GET_KEY |
1570 | dunkaist | 139 | test al, al |
140 | jnz keyloopdone |
||
141 | shr eax, 8 |
||
142 | mov ecx, eax |
||
6801 | IgorA | 143 | mcall SF_KEYBOARD, SSF_GET_CONTROL_KEYS |
1570 | dunkaist | 144 | mov edx, next_mod |
145 | call check_shortcut |
||
146 | jz .next |
||
147 | add edx, prev_mod - next_mod |
||
148 | call check_shortcut |
||
3116 | dunkaist | 149 | jz .prev |
150 | add edx, slide_mod - prev_mod |
||
151 | call check_shortcut |
||
152 | jz .slide |
||
153 | add edx, tglbar_mod - slide_mod |
||
154 | call check_shortcut |
||
155 | jz .tglbar |
||
156 | cmp cl, 1 ; Esc |
||
157 | jz .esc |
||
158 | jmp keyloop |
||
159 | .esc: |
||
160 | test byte [bSlideShow], 1 |
||
161 | jnz .slide |
||
162 | jmp keyloop |
||
163 | .tglbar: |
||
164 | mov byte [bTglbar], 1 |
||
165 | test byte[bSlideShow], 1 |
||
166 | jnz @f |
||
167 | xor [toolbar_height], 31 |
||
168 | @@: |
||
169 | jmp keyloop |
||
170 | .slide: |
||
171 | call slide_show |
||
172 | jmp keyloop |
||
1427 | diamond | 173 | .prev: |
1570 | dunkaist | 174 | dec esi |
175 | jmp keyloop |
||
1427 | diamond | 176 | .next: |
1570 | dunkaist | 177 | inc esi |
178 | jmp keyloop |
||
1427 | diamond | 179 | keyloopdone: |
3116 | dunkaist | 180 | test esi, esi |
181 | jnz next_or_prev_handler |
||
182 | test byte [bSlideShow], 2 |
||
183 | jnz red |
||
184 | test byte [bTglbar], 1 |
||
185 | jnz red |
||
186 | jmp still |
||
1427 | diamond | 187 | next_or_prev_handler: |
1570 | dunkaist | 188 | call next_or_prev_image |
189 | jmp red |
||
1004 | diamond | 190 | |
1080 | diamond | 191 | red_update_frame: |
1570 | dunkaist | 192 | mov eax, [cur_frame] |
193 | mov eax, [eax + Image.Next] |
||
194 | test eax, eax |
||
195 | jnz @f |
||
196 | mov eax, [image] |
||
1080 | diamond | 197 | @@: |
1570 | dunkaist | 198 | mov [cur_frame], eax |
6801 | IgorA | 199 | mcall SF_SYSTEM_GET, SSF_TIME_COUNT |
1570 | dunkaist | 200 | mov [cur_frame_time], eax |
6801 | IgorA | 201 | mcall SF_THREAD_INFO, procinfo, -1 |
1570 | dunkaist | 202 | call draw_cur_frame |
203 | jmp still |
||
1080 | diamond | 204 | |
205 | button: |
||
6801 | IgorA | 206 | mcall SF_GET_BUTTON |
1570 | dunkaist | 207 | shr eax, 8 |
1004 | diamond | 208 | |
1570 | dunkaist | 209 | ; flip horizontally |
210 | cmp eax, 'flh' |
||
211 | jne @f |
||
1004 | diamond | 212 | |
1570 | dunkaist | 213 | invoke img.flip, [image], FLIP_HORIZONTAL |
214 | jmp redraw_image |
||
1004 | diamond | 215 | |
1570 | dunkaist | 216 | ; flip vertically |
217 | @@: cmp eax, 'flv' |
||
218 | jne @f |
||
1004 | diamond | 219 | |
1570 | dunkaist | 220 | invoke img.flip, [image], FLIP_VERTICAL |
221 | jmp redraw_image |
||
1004 | diamond | 222 | |
1570 | dunkaist | 223 | ; flip both horizontally and vertically |
224 | @@: cmp eax, 'flb' |
||
225 | jne @f |
||
1004 | diamond | 226 | |
1570 | dunkaist | 227 | invoke img.flip, [image], FLIP_BOTH |
228 | jmp redraw_image |
||
1004 | diamond | 229 | |
1570 | dunkaist | 230 | ; rotate left |
231 | @@: cmp eax, 'rtl' |
||
232 | jne @f |
||
1004 | diamond | 233 | |
1570 | dunkaist | 234 | push ROTATE_90_CCW |
1004 | diamond | 235 | .rotate_common: |
1570 | dunkaist | 236 | invoke img.rotate, [image] |
237 | mov eax, [image] |
||
238 | test eax, eax ; clear ZF flag |
||
239 | call update_image_sizes |
||
240 | jmp redraw_image |
||
1004 | diamond | 241 | |
1570 | dunkaist | 242 | ; rotate right |
243 | @@: cmp eax, 'rtr' |
||
244 | jne @f |
||
1004 | diamond | 245 | |
1570 | dunkaist | 246 | push ROTATE_90_CW |
247 | jmp .rotate_common |
||
1004 | diamond | 248 | |
1570 | dunkaist | 249 | ; open new file |
250 | @@: cmp eax, 'opn' |
||
251 | jne @f |
||
252 | |||
1511 | mario79 | 253 | ; OpenDialog Open |
1570 | dunkaist | 254 | push dword OpenDialog_data |
255 | call [OpenDialog_Start] |
||
256 | |||
257 | cmp [OpenDialog_data.status],1 |
||
258 | jne still |
||
259 | |||
260 | mov esi, path |
||
261 | mov edi, @PARAMS |
||
262 | push edi |
||
263 | mov ecx, 4096/4 |
||
264 | rep movsd |
||
265 | mov byte [edi-1], 0 |
||
266 | |||
267 | pop esi |
||
268 | push esi |
||
269 | call find_last_name_component |
||
1475 | diamond | 270 | |
1570 | dunkaist | 271 | pop eax |
272 | push [image] |
||
273 | call load_image |
||
274 | jc .restore_old |
||
275 | call generate_header |
||
276 | |||
277 | invoke img.destroy |
||
278 | call free_directory |
||
279 | jmp red |
||
280 | |||
1004 | diamond | 281 | .restore_old: |
1570 | dunkaist | 282 | pop [image] |
283 | call init_frame |
||
284 | jmp still |
||
1004 | diamond | 285 | |
1570 | dunkaist | 286 | ; set background |
1016 | diamond | 287 | @@: |
1570 | dunkaist | 288 | cmp eax, 'bgr' |
289 | jne @f |
||
1016 | diamond | 290 | |
1570 | dunkaist | 291 | call set_as_bgr |
292 | jmp still |
||
1016 | diamond | 293 | |
294 | @@: |
||
3116 | dunkaist | 295 | cmp eax, 'sld' |
296 | jne @f |
||
1016 | diamond | 297 | |
3116 | dunkaist | 298 | call slide_show |
299 | jmp red |
||
300 | |||
301 | @@: |
||
302 | |||
1570 | dunkaist | 303 | or esi, -1 |
304 | cmp eax, 'bck' |
||
305 | jz next_or_prev_handler |
||
306 | neg esi |
||
307 | cmp eax, 'fwd' |
||
308 | jz next_or_prev_handler |
||
1016 | diamond | 309 | |
1570 | dunkaist | 310 | cmp eax, 1 |
311 | jne still |
||
1004 | diamond | 312 | |
313 | exit: |
||
6801 | IgorA | 314 | mcall SF_TERMINATE_PROCESS |
1004 | diamond | 315 | |
316 | redraw_image = red |
||
317 | |||
318 | load_image: |
||
1570 | dunkaist | 319 | and [img_data], 0 |
320 | push eax |
||
321 | invoke file.open, eax, O_READ |
||
322 | or eax, eax |
||
323 | jz .error_pop |
||
324 | mov [fh], eax |
||
325 | invoke file.size |
||
326 | mov [img_data_len], ebx |
||
327 | stdcall mem.Alloc, ebx |
||
328 | test eax, eax |
||
329 | jz .error_close |
||
330 | mov [img_data], eax |
||
331 | invoke file.read, [fh], eax, [img_data_len] |
||
332 | cmp eax, -1 |
||
333 | jz .error_close |
||
334 | cmp eax, [img_data_len] |
||
335 | jnz .error_close |
||
336 | invoke file.close, [fh] |
||
337 | inc eax |
||
338 | jz .error |
||
1004 | diamond | 339 | |
1570 | dunkaist | 340 | invoke img.decode, [img_data], [img_data_len], 0 |
341 | or eax, eax |
||
342 | jz .error |
||
343 | cmp [image], 0 |
||
344 | pushf |
||
345 | mov [image], eax |
||
6804 | IgorA | 346 | call img_resize_to_screen |
1570 | dunkaist | 347 | call init_frame |
348 | popf |
||
349 | call update_image_sizes |
||
350 | call free_img_data |
||
351 | clc |
||
352 | ret |
||
1004 | diamond | 353 | |
354 | .error_free: |
||
1570 | dunkaist | 355 | invoke img.destroy, [image] |
356 | jmp .error |
||
1004 | diamond | 357 | |
358 | .error_pop: |
||
1570 | dunkaist | 359 | pop eax |
360 | jmp .error |
||
1004 | diamond | 361 | .error_close: |
1570 | dunkaist | 362 | invoke file.close, [fh] |
1004 | diamond | 363 | .error: |
1570 | dunkaist | 364 | call free_img_data |
365 | stc |
||
366 | ret |
||
1004 | diamond | 367 | |
6804 | IgorA | 368 | align 4 |
369 | proc img_resize_to_screen uses eax ebx ecx edx |
||
370 | mov ebx, [image] |
||
371 | cmp [ebx+Image.Type],Image.bpp24 |
||
372 | jne .end_f |
||
373 | test [ebx+Image.Flags],Image.IsAnimated |
||
374 | jnz .end_f |
||
375 | mov eax, [ebx+Image.Data] |
||
376 | mov [buf_0],eax |
||
377 | mov eax, [ebx+Image.Width] |
||
378 | mov [buf_0.w],eax |
||
379 | mov eax, [ebx+Image.Height] |
||
380 | mov [buf_0.h],eax |
||
381 | |||
382 | mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT |
||
383 | mov edx, [image_padding] |
||
384 | shl edx, 1 |
||
385 | add edx, eax |
||
386 | mcall SF_GET_SCREEN_SIZE |
||
387 | mov ecx, eax |
||
388 | shr ecx, 17 |
||
389 | |||
390 | mov ebx, [image] |
||
391 | movzx eax,ax |
||
392 | sub eax, edx |
||
393 | sub eax, [toolbar_height] |
||
394 | sub eax, 5-1 ;5 px = border |
||
395 | cmp eax, 1 |
||
396 | jle .end0 |
||
397 | cmp eax, [ebx+Image.Height] |
||
398 | jl .end1 |
||
399 | .end0: |
||
400 | xor eax,eax |
||
401 | jmp .end2 |
||
402 | .end1: |
||
403 | mov [ebx+Image.Height],eax |
||
404 | .end2: |
||
405 | sub ecx, [image_padding] |
||
406 | shl ecx, 1 |
||
407 | sub ecx, 10-1 ;10 px = 2 borders |
||
408 | cmp ecx, 1 |
||
409 | jle .end3 |
||
410 | cmp ecx, [ebx+Image.Width] |
||
411 | jl .end4 |
||
412 | .end3: |
||
413 | xor ecx,ecx |
||
414 | jmp .end5 |
||
415 | .end4: |
||
416 | mov [ebx+Image.Width],ecx |
||
417 | .end5: |
||
418 | cmp eax,ecx |
||
419 | jne @f |
||
420 | test eax,eax |
||
421 | jz .end_f |
||
422 | @@: |
||
423 | stdcall [buf2d_resize], buf_0, ecx, eax, 2 |
||
424 | .end_f: |
||
425 | ret |
||
426 | endp |
||
427 | |||
428 | align 4 |
||
1004 | diamond | 429 | free_img_data: |
1570 | dunkaist | 430 | mov eax, [img_data] |
431 | test eax, eax |
||
432 | jz @f |
||
433 | stdcall mem.Free, eax |
||
1004 | diamond | 434 | @@: |
1570 | dunkaist | 435 | ret |
1004 | diamond | 436 | |
437 | update_image_sizes: |
||
1570 | dunkaist | 438 | pushf |
439 | mov edx, [eax + Image.Width] |
||
2036 | dunkaist | 440 | test [eax + Image.Flags], Image.IsAnimated |
441 | jnz .not_in_row |
||
442 | push eax |
||
443 | @@: cmp [eax + Image.Next], 0 |
||
444 | jz @f |
||
445 | mov eax, [eax + Image.Next] |
||
446 | add edx, [eax + Image.Width] |
||
447 | inc edx |
||
448 | jmp @b |
||
449 | @@: pop eax |
||
450 | .not_in_row: |
||
1570 | dunkaist | 451 | mov [draw_width], edx |
452 | add edx, 19 |
||
3116 | dunkaist | 453 | cmp edx, 50 + 25*numimages |
1570 | dunkaist | 454 | jae @f |
3116 | dunkaist | 455 | mov edx, 50 + 25*numimages |
1004 | diamond | 456 | @@: |
3116 | dunkaist | 457 | ; dec edx |
1570 | dunkaist | 458 | mov [wnd_width], edx |
459 | mov esi, [eax + Image.Height] |
||
2036 | dunkaist | 460 | test [eax + Image.Flags], Image.IsAnimated |
461 | jnz .max_equals_first |
||
462 | push eax |
||
463 | @@: cmp [eax + Image.Next], 0 |
||
464 | jz @f |
||
465 | mov eax, [eax + Image.Next] |
||
466 | cmp esi, [eax + Image.Height] |
||
467 | jae @b |
||
468 | mov esi, [eax + Image.Height] |
||
469 | jmp @b |
||
470 | @@: pop eax |
||
471 | .max_equals_first: |
||
1570 | dunkaist | 472 | mov [draw_height], esi |
3116 | dunkaist | 473 | add esi, [toolbar_height] |
474 | add esi, [image_padding] |
||
475 | add esi, [image_padding] |
||
476 | add esi, 5 ; window bottom frame height |
||
477 | dec esi |
||
1570 | dunkaist | 478 | mov [wnd_height], esi |
479 | popf |
||
480 | jz .no_resize |
||
3116 | dunkaist | 481 | test [wnd_style], 1 SHL 25 |
482 | jz .no_resize |
||
6801 | IgorA | 483 | mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT |
1570 | dunkaist | 484 | add esi, eax |
6801 | IgorA | 485 | mcall SF_CHANGE_WINDOW,-1,-1 |
1004 | diamond | 486 | .no_resize: |
1570 | dunkaist | 487 | ret |
1004 | diamond | 488 | |
1016 | diamond | 489 | set_as_bgr: |
1570 | dunkaist | 490 | mov esi, [image] |
491 | mov ecx, [esi + Image.Width] |
||
492 | mov edx, [esi + Image.Height] |
||
6801 | IgorA | 493 | mcall SF_BACKGROUND_SET, SSF_SIZE_BG |
1016 | diamond | 494 | |
6801 | IgorA | 495 | mcall SF_BACKGROUND_SET, SSF_MAP_BG |
1570 | dunkaist | 496 | test eax, eax |
497 | jz @f |
||
1016 | diamond | 498 | |
1570 | dunkaist | 499 | push eax |
500 | invoke img.to_rgb2, esi, eax |
||
501 | pop ecx |
||
6801 | IgorA | 502 | mcall SF_BACKGROUND_SET, SSF_UNMAP_BG |
1016 | diamond | 503 | |
504 | @@: |
||
6801 | IgorA | 505 | mcall SF_BACKGROUND_SET, SSF_REDRAW_BG |
7421 | leency | 506 | |
507 | ;save to file eskin.ini |
||
508 | xor al,al |
||
509 | mov ecx,1024 |
||
510 | mov edi,sys_path+2 |
||
511 | repne scasb |
||
512 | sub edi,sys_path+3 |
||
513 | invoke ini_set_str, inifileeskin, amain, aprogram, sys_path+2, edi |
||
514 | ;add param '\S__' |
||
515 | cmp word[@PARAMS],'\S' |
||
516 | je @f |
||
517 | mov esi, @PARAMS+4096-8 |
||
518 | mov edi, @PARAMS+4096-4 |
||
519 | mov ecx, 4096/4-1 |
||
520 | std |
||
521 | rep movsd |
||
522 | cld |
||
523 | mov dword[@PARAMS],'\S__' |
||
524 | @@: |
||
525 | ; |
||
526 | xor al,al |
||
527 | mov ecx,4096 |
||
528 | mov edi,@PARAMS |
||
529 | repne scasb |
||
530 | sub edi,@PARAMS+1 |
||
531 | invoke ini_set_str, inifileeskin, amain, aparam, @PARAMS, edi |
||
1570 | dunkaist | 532 | ret |
1016 | diamond | 533 | |
3116 | dunkaist | 534 | slide_show: |
535 | or byte [bSlideShow], 2 |
||
536 | xor byte [bSlideShow], 1 |
||
537 | btc dword [wnd_style], 25 |
||
538 | jc @f |
||
539 | mov eax, [toolbar_height_old] |
||
540 | mov [toolbar_height], eax |
||
541 | mov [image_padding], 5 |
||
542 | jmp .toolbar_height_done |
||
543 | @@: |
||
544 | mov eax, [toolbar_height] |
||
545 | mov [toolbar_height_old], eax |
||
546 | mov [toolbar_height], 0 |
||
547 | mov [image_padding], 0 |
||
548 | .toolbar_height_done: |
||
549 | ret |
||
550 | |||
1427 | diamond | 551 | ; seek to ESI image files |
552 | ; esi>0 means next file, esi<0 - prev file |
||
553 | next_or_prev_image: |
||
1570 | dunkaist | 554 | push esi |
555 | call load_directory |
||
556 | pop esi |
||
557 | mov ebx, [directory_ptr] |
||
558 | test ebx, ebx |
||
559 | jz .ret |
||
560 | cmp dword[ebx+4], 0 |
||
561 | jz .ret |
||
562 | mov eax, [cur_file_idx] |
||
563 | cmp eax, -1 |
||
564 | jnz @f |
||
565 | test esi, esi |
||
566 | jns @f |
||
567 | mov eax, [ebx+4] |
||
1016 | diamond | 568 | @@: |
1570 | dunkaist | 569 | push [image] |
570 | add eax, esi |
||
1427 | diamond | 571 | @@: |
1570 | dunkaist | 572 | test eax, eax |
573 | jns @f |
||
574 | add eax, [ebx+4] |
||
575 | jmp @b |
||
1016 | diamond | 576 | @@: |
1570 | dunkaist | 577 | cmp eax, [ebx+4] |
578 | jb @f |
||
579 | sub eax, [ebx+4] |
||
580 | jmp @b |
||
1427 | diamond | 581 | @@: |
1570 | dunkaist | 582 | push eax |
1427 | diamond | 583 | .scanloop: |
1570 | dunkaist | 584 | push eax ebx esi |
585 | imul esi, eax, 304 |
||
586 | add esi, [directory_ptr] |
||
587 | add esi, 32 + 40 |
||
588 | mov edi, curdir |
||
1016 | diamond | 589 | @@: |
1570 | dunkaist | 590 | inc edi |
591 | cmp byte [edi-1], 0 |
||
592 | jnz @b |
||
593 | mov byte [edi-1], '/' |
||
1016 | diamond | 594 | @@: |
1570 | dunkaist | 595 | lodsb |
596 | stosb |
||
597 | test al, al |
||
598 | jnz @b |
||
599 | mov eax, curdir |
||
600 | call load_image |
||
601 | pushf |
||
602 | mov esi, curdir |
||
603 | push esi |
||
604 | mov edi, @PARAMS |
||
605 | mov ecx, 4096/4 |
||
606 | rep movsd |
||
607 | mov byte [edi-1], 0 |
||
608 | pop esi |
||
1040 | diamond | 609 | @@: |
1570 | dunkaist | 610 | lodsb |
611 | test al, al |
||
612 | jnz @b |
||
1040 | diamond | 613 | @@: |
1570 | dunkaist | 614 | dec esi |
615 | cmp byte [esi], '/' |
||
616 | jnz @b |
||
617 | mov byte [esi], 0 |
||
618 | popf |
||
619 | pop esi ebx eax |
||
620 | jnc .loadedok |
||
621 | test esi, esi |
||
622 | js .try_prev |
||
1427 | diamond | 623 | .try_next: |
1570 | dunkaist | 624 | inc eax |
625 | cmp eax, [ebx+4] |
||
626 | jb @f |
||
627 | xor eax, eax |
||
1016 | diamond | 628 | @@: |
1427 | diamond | 629 | .try_common: |
1570 | dunkaist | 630 | cmp eax, [esp] |
631 | jz .notfound |
||
632 | jmp .scanloop |
||
1427 | diamond | 633 | .try_prev: |
1570 | dunkaist | 634 | dec eax |
635 | jns @f |
||
636 | mov eax, [ebx+4] |
||
637 | dec eax |
||
1016 | diamond | 638 | @@: |
1570 | dunkaist | 639 | jmp .try_common |
1427 | diamond | 640 | .loadedok: |
1570 | dunkaist | 641 | mov [cur_file_idx], eax |
642 | pop eax |
||
643 | invoke img.destroy |
||
644 | call generate_header |
||
1016 | diamond | 645 | .ret: |
1570 | dunkaist | 646 | ret |
1016 | diamond | 647 | .notfound: |
1570 | dunkaist | 648 | pop eax |
649 | pop [image] |
||
650 | call init_frame |
||
651 | ret |
||
1016 | diamond | 652 | |
653 | load_directory: |
||
1570 | dunkaist | 654 | cmp [directory_ptr], 0 |
655 | jnz .ret |
||
656 | mov esi, @PARAMS |
||
657 | mov edi, curdir |
||
658 | mov ecx, [last_name_component] |
||
659 | sub ecx, esi |
||
660 | dec ecx |
||
661 | js @f |
||
662 | rep movsb |
||
1427 | diamond | 663 | @@: |
1570 | dunkaist | 664 | mov byte [edi], 0 |
6801 | IgorA | 665 | mcall SF_SYS_MISC, SSF_MEM_ALLOC, 0x1000 |
1570 | dunkaist | 666 | test eax, eax |
667 | jz .ret |
||
668 | mov ebx, readdir_fileinfo |
||
669 | mov dword [ebx+12], (0x1000 - 32) / 304 |
||
670 | mov dword [ebx+16], eax |
||
6801 | IgorA | 671 | mcall SF_FILE |
1570 | dunkaist | 672 | cmp eax, 6 |
673 | jz .dirok |
||
674 | test eax, eax |
||
675 | jnz free_directory |
||
676 | mov edx, [directory_ptr] |
||
677 | mov ecx, [edx+8] |
||
678 | mov [readblocks], ecx |
||
679 | imul ecx, 304 |
||
680 | add ecx, 32 |
||
6801 | IgorA | 681 | mcall SF_SYS_MISC, SSF_MEM_REALLOC |
1570 | dunkaist | 682 | test eax, eax |
683 | jz free_directory |
||
684 | mov [directory_ptr], eax |
||
6801 | IgorA | 685 | mcall SF_FILE, readdir_fileinfo |
1016 | diamond | 686 | .dirok: |
1570 | dunkaist | 687 | cmp ebx, 0 |
688 | jle free_directory |
||
689 | mov eax, [directory_ptr] |
||
690 | add eax, 32 |
||
691 | mov edi, eax |
||
692 | push 0 |
||
1016 | diamond | 693 | .dirskip: |
1570 | dunkaist | 694 | push eax |
695 | test byte [eax], 18h |
||
696 | jnz .nocopy |
||
697 | lea esi, [eax+40] |
||
698 | mov ecx, esi |
||
1016 | diamond | 699 | @@: |
1570 | dunkaist | 700 | lodsb |
701 | test al, al |
||
702 | jnz @b |
||
1016 | diamond | 703 | @@: |
1570 | dunkaist | 704 | dec esi |
705 | cmp esi, ecx |
||
706 | jb .noext |
||
707 | cmp byte [esi], '.' |
||
708 | jnz @b |
||
709 | inc esi |
||
710 | mov ecx, [esi] |
||
5183 | hidnplayr | 711 | cmp byte[esi+3], 0 |
712 | jne .not_3 |
||
1570 | dunkaist | 713 | or ecx, 0x202020 |
714 | cmp ecx, 'jpg' |
||
715 | jz .copy |
||
716 | cmp ecx, 'bmp' |
||
717 | jz .copy |
||
718 | cmp ecx, 'gif' |
||
719 | jz .copy |
||
720 | cmp ecx, 'png' |
||
721 | jz .copy |
||
722 | cmp ecx, 'jpe' |
||
723 | jz .copy |
||
724 | cmp ecx, 'ico' |
||
725 | jz .copy |
||
726 | cmp ecx, 'cur' |
||
727 | jz .copy |
||
3116 | dunkaist | 728 | cmp ecx, 'tga' |
729 | jz .copy |
||
1575 | dunkaist | 730 | cmp ecx, 'pcx' |
731 | jz .copy |
||
1922 | dunkaist | 732 | cmp ecx, 'xcf' |
733 | jz .copy |
||
2389 | dunkaist | 734 | cmp ecx, 'pbm' |
735 | jz .copy |
||
736 | cmp ecx, 'pgm' |
||
737 | jz .copy |
||
738 | cmp ecx, 'pnm' |
||
739 | jz .copy |
||
740 | cmp ecx, 'tif' |
||
741 | jz .copy |
||
5183 | hidnplayr | 742 | .not_3: |
743 | cmp byte[esi+4], 0 |
||
744 | jne .nocopy |
||
745 | or ecx, 0x20202020 |
||
2389 | dunkaist | 746 | cmp ecx, 'tiff' |
747 | jz @f |
||
2394 | dunkaist | 748 | cmp ecx, 'wbmp' |
749 | jz @f |
||
1570 | dunkaist | 750 | cmp ecx, 'jpeg' |
751 | jnz .nocopy |
||
1016 | diamond | 752 | @@: |
1570 | dunkaist | 753 | cmp byte [esi+4], 0 |
754 | jnz .nocopy |
||
1016 | diamond | 755 | .copy: |
1570 | dunkaist | 756 | mov esi, [esp] |
757 | mov ecx, 304 / 4 |
||
758 | rep movsd |
||
759 | inc dword [esp+4] |
||
1016 | diamond | 760 | .nocopy: |
761 | .noext: |
||
1570 | dunkaist | 762 | pop eax |
763 | add eax, 304 |
||
764 | dec ebx |
||
765 | jnz .dirskip |
||
766 | mov eax, [directory_ptr] |
||
767 | pop ebx |
||
768 | mov [eax+4], ebx |
||
769 | test ebx, ebx |
||
770 | jz free_directory |
||
771 | push 0 ; sort mode |
||
772 | push ebx |
||
773 | add eax, 32 |
||
774 | push eax |
||
775 | call [SortDir] |
||
776 | xor eax, eax |
||
777 | mov edi, [directory_ptr] |
||
778 | add edi, 32 + 40 |
||
1016 | diamond | 779 | .scan: |
1570 | dunkaist | 780 | mov esi, [last_name_component] |
781 | push edi |
||
782 | invoke strcmpi |
||
783 | pop edi |
||
784 | jz .found |
||
785 | inc eax |
||
786 | add edi, 304 |
||
787 | dec ebx |
||
788 | jnz .scan |
||
789 | or eax, -1 |
||
1016 | diamond | 790 | .found: |
1570 | dunkaist | 791 | mov [cur_file_idx], eax |
1016 | diamond | 792 | .ret: |
1570 | dunkaist | 793 | ret |
1016 | diamond | 794 | |
795 | free_directory: |
||
6801 | IgorA | 796 | mcall SF_SYS_MISC, SSF_MEM_FREE, [directory_ptr] |
1570 | dunkaist | 797 | and [directory_ptr], 0 |
798 | ret |
||
1016 | diamond | 799 | |
1427 | diamond | 800 | ; in: esi->full name (e.g. /path/to/file.png) |
801 | ; out: [last_name_component]->last component (e.g. file.png) |
||
802 | find_last_name_component: |
||
1570 | dunkaist | 803 | mov ecx, esi |
1427 | diamond | 804 | @@: |
1570 | dunkaist | 805 | lodsb |
806 | test al, al |
||
807 | jnz @b |
||
1427 | diamond | 808 | @@: |
1570 | dunkaist | 809 | dec esi |
810 | cmp esi, ecx |
||
811 | jb @f |
||
812 | cmp byte [esi], '/' |
||
813 | jnz @b |
||
1427 | diamond | 814 | @@: |
1570 | dunkaist | 815 | inc esi |
816 | mov [last_name_component], esi |
||
817 | ret |
||
1427 | diamond | 818 | |
1080 | diamond | 819 | init_frame: |
1570 | dunkaist | 820 | push eax |
821 | mov eax, [image] |
||
822 | mov [cur_frame], eax |
||
823 | test byte [eax + Image.Flags], Image.IsAnimated |
||
824 | jz @f |
||
825 | push ebx |
||
6801 | IgorA | 826 | mcall SF_SYSTEM_GET, SSF_TIME_COUNT |
1570 | dunkaist | 827 | pop ebx |
828 | mov [cur_frame_time], eax |
||
1080 | diamond | 829 | @@: |
1570 | dunkaist | 830 | pop eax |
831 | ret |
||
1080 | diamond | 832 | |
1004 | diamond | 833 | draw_window: |
3116 | dunkaist | 834 | btr word [bSlideShow], 1 ; mode changed |
835 | jc .mode_changed |
||
836 | test byte [bTglbar], 1 |
||
837 | jz .mode_not_changed |
||
838 | .mode_changed: |
||
839 | test [wnd_style], 1 SHL 25 |
||
840 | jz .mode_slide |
||
841 | mov [bg_color], 0x00ffffff |
||
842 | mov eax, [image] |
||
843 | cmp eax, eax |
||
844 | call update_image_sizes |
||
6801 | IgorA | 845 | mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT |
3116 | dunkaist | 846 | mov esi, [wnd_height] |
847 | add esi, eax |
||
848 | test byte [bTglbar], 1 |
||
849 | jz @f |
||
6801 | IgorA | 850 | mcall SF_CHANGE_WINDOW, -1, -1, [wnd_width], |
3116 | dunkaist | 851 | jmp .mode_not_changed |
852 | @@: |
||
6801 | IgorA | 853 | mcall SF_CHANGE_WINDOW, [wnd_x], [wnd_y], [wnd_width], |
3116 | dunkaist | 854 | jmp .mode_not_changed |
855 | .mode_slide: |
||
856 | mov [bg_color], 0x00000000 |
||
857 | mov eax, [procinfo.box.left] |
||
858 | mov [wnd_x], eax |
||
859 | mov eax, [procinfo.box.top] |
||
860 | mov [wnd_y], eax |
||
6801 | IgorA | 861 | mcall SF_GET_SCREEN_SIZE |
3116 | dunkaist | 862 | mov edx, eax |
863 | shr edx, 16 |
||
864 | movzx eax, ax |
||
865 | mov esi, eax |
||
6801 | IgorA | 866 | mcall SF_CHANGE_WINDOW, 0, 0, , |
3116 | dunkaist | 867 | jmp .posok.slide_show |
868 | |||
869 | .mode_not_changed: |
||
1570 | dunkaist | 870 | cmp [bFirstDraw], 0 |
871 | jz .posok |
||
872 | or ecx, -1 |
||
6801 | IgorA | 873 | mcall SF_THREAD_INFO, procinfo |
1040 | diamond | 874 | |
3116 | dunkaist | 875 | test byte [procinfo.wnd_state], 0x04 |
876 | jnz .posok |
||
1040 | diamond | 877 | |
1570 | dunkaist | 878 | mov edx, ecx |
879 | mov esi, ecx |
||
3116 | dunkaist | 880 | cmp dword [procinfo.box.width], 50 + 25 * numimages |
1570 | dunkaist | 881 | jae @f |
3116 | dunkaist | 882 | mov edx, 50 + 25 * numimages |
1040 | diamond | 883 | @@: |
3116 | dunkaist | 884 | cmp dword [procinfo.box.height], 70 |
1570 | dunkaist | 885 | jae @f |
886 | mov esi, 70 |
||
1040 | diamond | 887 | @@: |
1570 | dunkaist | 888 | mov eax, edx |
889 | and eax, esi |
||
890 | cmp eax, -1 |
||
891 | jz @f |
||
892 | mov ebx, ecx |
||
6801 | IgorA | 893 | mcall SF_CHANGE_WINDOW |
1040 | diamond | 894 | @@: |
895 | |||
896 | .posok: |
||
3116 | dunkaist | 897 | test [wnd_style], 1 SHL 25 |
898 | jz .posok.slide_show |
||
6801 | IgorA | 899 | mcall SF_REDRAW, SSF_BEGIN_DRAW |
900 | mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT |
||
1570 | dunkaist | 901 | mov ebp, eax ; save skin height |
902 | add eax, [wnd_height] |
||
3116 | dunkaist | 903 | mov ebx, [wnd_x] |
904 | shl ebx, 16 |
||
1570 | dunkaist | 905 | add ebx, [wnd_width] |
3116 | dunkaist | 906 | mov ecx, [wnd_y] |
907 | shl ecx, 16 |
||
908 | add ecx, eax |
||
6801 | IgorA | 909 | mcall SF_CREATE_WINDOW, , , [wnd_style], 0, real_header |
3116 | dunkaist | 910 | jmp .posok.common |
911 | .posok.slide_show: |
||
6801 | IgorA | 912 | mcall SF_REDRAW, SSF_BEGIN_DRAW |
913 | mcall SF_GET_SCREEN_SIZE |
||
3116 | dunkaist | 914 | mov ebx, eax |
915 | shr ebx, 16 |
||
916 | movzx eax, ax |
||
917 | mov ecx, eax |
||
6801 | IgorA | 918 | mcall SF_CREATE_WINDOW, , , [wnd_style], 0, real_header |
3116 | dunkaist | 919 | .posok.common: |
6801 | IgorA | 920 | mcall SF_THREAD_INFO, procinfo, -1 |
3116 | dunkaist | 921 | mov eax, [procinfo.client_box.width] |
922 | sub eax, [image_padding] |
||
923 | sub eax, [image_padding] |
||
924 | sub eax, [draw_width] |
||
925 | sar eax, 1 |
||
926 | test eax, eax |
||
927 | jns @f |
||
928 | mov eax, 0 |
||
929 | @@: |
||
930 | add eax, [image_padding] |
||
931 | mov [draw_x], eax |
||
932 | mov eax, [procinfo.client_box.height] |
||
933 | sub eax, [toolbar_height] |
||
934 | sub eax, [image_padding] |
||
935 | sub eax, [image_padding] |
||
936 | sub eax, [draw_height] |
||
937 | sar eax, 1 |
||
938 | test eax, eax |
||
939 | jns @f |
||
940 | mov eax, 0 |
||
941 | @@: |
||
942 | add eax, [toolbar_height] |
||
943 | add eax, [image_padding] |
||
944 | mov [draw_y], eax |
||
1570 | dunkaist | 945 | mov [bFirstDraw], 1 |
3116 | dunkaist | 946 | cmp dword [procinfo.client_box.height], 0 |
1570 | dunkaist | 947 | jle .nodraw |
3116 | dunkaist | 948 | mov ebx, [procinfo.client_box.width] |
1570 | dunkaist | 949 | inc ebx |
3116 | dunkaist | 950 | mov ecx, [draw_y] |
6801 | IgorA | 951 | mcall SF_DRAW_RECT, , , [bg_color] |
3116 | dunkaist | 952 | mov ecx, [procinfo.client_box.height] |
1570 | dunkaist | 953 | inc ecx |
3116 | dunkaist | 954 | mov esi, [cur_frame] |
955 | mov esi, [esi + Image.Height] |
||
956 | add esi, [draw_y] |
||
1570 | dunkaist | 957 | sub ecx, esi |
958 | jbe @f |
||
959 | push esi |
||
960 | shl esi, 16 |
||
961 | add ecx, esi |
||
962 | pop esi |
||
963 | mcall |
||
964 | xor ecx, ecx |
||
1040 | diamond | 965 | @@: |
1570 | dunkaist | 966 | add ecx, esi |
3116 | dunkaist | 967 | mov ebx, [draw_y] |
968 | sub ecx, ebx |
||
969 | shl ebx, 16 |
||
970 | add ecx, ebx |
||
971 | mov ebx, [draw_x] |
||
1570 | dunkaist | 972 | mcall |
3116 | dunkaist | 973 | mov esi, [cur_frame] |
974 | mov esi, [esi + Image.Width] |
||
1570 | dunkaist | 975 | add esi, ebx |
3116 | dunkaist | 976 | mov ebx, [procinfo.client_box.width] |
1570 | dunkaist | 977 | inc ebx |
978 | sub ebx, esi |
||
979 | jbe @f |
||
980 | shl esi, 16 |
||
981 | add ebx, esi |
||
982 | mcall |
||
1040 | diamond | 983 | @@: |
1004 | diamond | 984 | |
3116 | dunkaist | 985 | test [wnd_style], 1 SHL 25 |
986 | jz .slide_show_mode |
||
987 | mov byte [bTglbar], 0 |
||
988 | cmp byte [toolbar_height], 0 |
||
989 | je .decorations_done |
||
990 | mov ebx, [procinfo.client_box.width] |
||
1570 | dunkaist | 991 | push ebx |
6801 | IgorA | 992 | mcall SF_DRAW_LINE, , <30, 30>, 0x007F7F7F |
1570 | dunkaist | 993 | mcall , <5 + 25 * 1, 5 + 25 * 1>, <0, 30> |
994 | mcall , <10 + 25 * 3, 10 + 25 * 3> |
||
3116 | dunkaist | 995 | mcall , <15 + 25 * 5, 15 + 25 * 5> |
1570 | dunkaist | 996 | pop ebx |
3116 | dunkaist | 997 | sub ebx, 25 * 5 + 10 |
1570 | dunkaist | 998 | push ebx |
999 | imul ebx, 10001h |
||
1000 | mcall |
||
1004 | diamond | 1001 | |
6801 | IgorA | 1002 | mcall SF_DEFINE_BUTTON, <5 + 25 * 0, 20>, <5, 20>, 'opn'+40000000h |
1570 | dunkaist | 1003 | mcall , <10 + 25 * 1, 20>, , 'bck'+40000000h |
1004 | mcall , <10 + 25 * 2, 20>, , 'fwd'+40000000h |
||
1005 | mcall , <15 + 25 * 3, 20>, , 'bgr'+40000000h |
||
3116 | dunkaist | 1006 | mcall , <15 + 25 * 4, 20>, , 'sld'+40000000h |
1570 | dunkaist | 1007 | pop ebx |
1008 | add ebx, 5 |
||
1009 | shl ebx, 16 |
||
1010 | mov bl, 20 |
||
1011 | mcall , , , 'flh'+40000000h |
||
1012 | add ebx, 25 * 65536 |
||
1013 | mcall , , , 'flv'+40000000h |
||
1014 | add ebx, 30 * 65536 |
||
1015 | mcall , , , 'rtr'+40000000h |
||
1016 | add ebx, 25 * 65536 |
||
1017 | mcall , , , 'rtl'+40000000h |
||
1018 | add ebx, 25 * 65536 |
||
1019 | mcall , , , 'flb'+40000000h |
||
1004 | diamond | 1020 | |
1570 | dunkaist | 1021 | mov ebp, (numimages-1)*20 |
1004 | diamond | 1022 | |
6801 | IgorA | 1023 | mcall SF_PUT_IMAGE_EXT, buttons+openbtn*20, <20, 20>, <5 + 25 * 0, 5>, 8, palette |
3116 | dunkaist | 1024 | mcall , buttons+backbtn*20, , <10 + 25 * 1, 5> |
1570 | dunkaist | 1025 | mcall , buttons+forwardbtn*20, , <10 + 25 * 2, 5> |
3116 | dunkaist | 1026 | mcall , buttons+bgrbtn*20, , <15 + 25 * 3, 5> |
1027 | mcall , buttons+slidebtn*20, , <15 + 25 * 4, 5> |
||
1028 | mov edx, [procinfo.client_box.width] |
||
1570 | dunkaist | 1029 | sub edx, 25 * 5 + 4 |
1030 | shl edx, 16 |
||
1031 | mov dl, 5 |
||
1032 | mcall , buttons+fliphorzbtn*20 |
||
1033 | add edx, 25 * 65536 |
||
1034 | mcall , buttons+flipvertbtn*20 |
||
1035 | add edx, 30 * 65536 |
||
1036 | mcall , buttons+rotcwbtn*20 |
||
1037 | add edx, 25 * 65536 |
||
1038 | mcall , buttons+rotccwbtn*20 |
||
1039 | add edx, 25 * 65536 |
||
1040 | mcall , buttons+rot180btn*20 |
||
3116 | dunkaist | 1041 | jmp .decorations_done |
1004 | diamond | 1042 | |
3116 | dunkaist | 1043 | .slide_show_mode: |
1044 | |||
1045 | .decorations_done: |
||
1570 | dunkaist | 1046 | call draw_cur_frame |
1004 | diamond | 1047 | |
1087 | diamond | 1048 | .nodraw: |
6801 | IgorA | 1049 | mcall SF_REDRAW, SSF_END_DRAW |
1040 | diamond | 1050 | |
1570 | dunkaist | 1051 | ret |
1004 | diamond | 1052 | |
1080 | diamond | 1053 | draw_cur_frame: |
1570 | dunkaist | 1054 | push 0 ; ypos |
1055 | push 0 ; xpos |
||
3116 | dunkaist | 1056 | mov eax, [procinfo.client_box.height] |
1057 | sub eax, [toolbar_height] |
||
1058 | sub eax, [image_padding] |
||
1059 | inc eax |
||
1570 | dunkaist | 1060 | push eax ; max height |
3116 | dunkaist | 1061 | mov eax, [procinfo.client_box.width] |
1062 | sub eax, [image_padding] |
||
1063 | inc eax |
||
1570 | dunkaist | 1064 | push eax ; max width |
3116 | dunkaist | 1065 | push [draw_y] |
1066 | push [draw_x] |
||
1570 | dunkaist | 1067 | push [cur_frame] |
1068 | call [img.draw] |
||
1069 | mov eax, [image] |
||
1070 | test [eax + Image.Flags], Image.IsAnimated |
||
1071 | jnz .done |
||
1072 | cmp [eax + Image.Next], 0 |
||
1073 | jnz .additional_frames |
||
1102 | diamond | 1074 | .done: |
1570 | dunkaist | 1075 | ret |
1102 | diamond | 1076 | .additional_frames: |
3116 | dunkaist | 1077 | mov ebx, [procinfo.client_box.width] |
1078 | sub ebx, [image_padding] |
||
1079 | inc ebx |
||
1570 | dunkaist | 1080 | jbe .done |
3116 | dunkaist | 1081 | mov esi, [draw_x] |
1102 | diamond | 1082 | .afloop: |
1570 | dunkaist | 1083 | sub ebx, [eax + Image.Width] |
1084 | jbe .done |
||
1085 | dec ebx |
||
1086 | jz .done |
||
1087 | add esi, [eax + Image.Width] |
||
1088 | mov eax, [eax + Image.Next] |
||
1089 | push eax |
||
1090 | inc esi |
||
1091 | push 0 ; ypos |
||
1092 | push 0 ; xpos |
||
3116 | dunkaist | 1093 | mov ecx, [procinfo.client_box.height] |
1094 | sub ecx, [toolbar_height] |
||
1095 | sub ecx, [image_padding] |
||
1096 | inc ecx |
||
1097 | ; inc ebx |
||
1570 | dunkaist | 1098 | push ecx ; max height |
1099 | push ebx ; max width |
||
3116 | dunkaist | 1100 | push [draw_y] ; y |
1570 | dunkaist | 1101 | push esi ; x |
1102 | push eax ; image |
||
1103 | call [img.draw] |
||
1104 | pop eax |
||
1105 | cmp [eax + Image.Next], 0 |
||
1106 | jnz .afloop |
||
1107 | ret |
||
1080 | diamond | 1108 | |
1004 | diamond | 1109 | |
1427 | diamond | 1110 | check_shortcut: |
1570 | dunkaist | 1111 | ; in: cl = scancode (from sysfn 2), |
1112 | ; eax = state of modifiers (from sysfn 66.3), |
||
1113 | ; edx -> shortcut descriptor |
||
1114 | ; out: ZF set <=> fail |
||
1115 | cmp cl, [edx+4] |
||
1116 | jnz .not |
||
1117 | push eax |
||
1118 | mov esi, [edx] |
||
1119 | and esi, 0xF |
||
1120 | and al, 3 |
||
1121 | call dword [check_modifier_table+esi*4] |
||
1122 | test al, al |
||
1123 | pop eax |
||
1124 | jnz .not |
||
1125 | push eax |
||
1126 | mov esi, [edx] |
||
1127 | shr esi, 4 |
||
1128 | and esi, 0xF |
||
1129 | shr al, 2 |
||
1130 | and al, 3 |
||
1131 | call dword [check_modifier_table+esi*4] |
||
1132 | test al, al |
||
1133 | pop eax |
||
1134 | jnz .not |
||
1135 | push eax |
||
1136 | mov esi, [edx] |
||
1137 | shr esi, 8 |
||
1138 | and esi, 0xF |
||
1139 | shr al, 4 |
||
1140 | and al, 3 |
||
1141 | call dword [check_modifier_table+esi*4] |
||
1142 | test al, al |
||
1143 | pop eax |
||
1144 | ; jnz .not |
||
1427 | diamond | 1145 | .not: |
1570 | dunkaist | 1146 | ret |
1427 | diamond | 1147 | |
1148 | check_modifier_0: |
||
1570 | dunkaist | 1149 | setnz al |
1150 | ret |
||
1427 | diamond | 1151 | check_modifier_1: |
1570 | dunkaist | 1152 | setp al |
1153 | ret |
||
1427 | diamond | 1154 | check_modifier_2: |
1570 | dunkaist | 1155 | cmp al, 3 |
1156 | setnz al |
||
1157 | ret |
||
1427 | diamond | 1158 | check_modifier_3: |
1570 | dunkaist | 1159 | cmp al, 1 |
1160 | setnz al |
||
1161 | ret |
||
1427 | diamond | 1162 | check_modifier_4: |
1570 | dunkaist | 1163 | cmp al, 2 |
1164 | setnz al |
||
1165 | ret |
||
1427 | diamond | 1166 | |
1167 | ; fills real_header with window title |
||
1168 | ; window title is generated as ' |
||
1169 | generate_header: |
||
1570 | dunkaist | 1170 | push eax |
1171 | mov esi, [last_name_component] |
||
1172 | mov edi, real_header |
||
1427 | diamond | 1173 | @@: |
1570 | dunkaist | 1174 | lodsb |
1175 | test al, al |
||
1176 | jz @f |
||
1177 | stosb |
||
1178 | cmp edi, real_header+256 |
||
1179 | jb @b |
||
1427 | diamond | 1180 | .overflow: |
1570 | dunkaist | 1181 | mov dword [edi-4], '...' |
1427 | diamond | 1182 | .ret: |
1570 | dunkaist | 1183 | pop eax |
1184 | ret |
||
1427 | diamond | 1185 | @@: |
1570 | dunkaist | 1186 | mov esi, s_header |
1427 | diamond | 1187 | @@: |
1570 | dunkaist | 1188 | lodsb |
1189 | stosb |
||
1190 | test al, al |
||
1191 | jz .ret |
||
1192 | cmp edi, real_header+256 |
||
1193 | jb @b |
||
1194 | jmp .overflow |
||
1004 | diamond | 1195 | ;----------------------------------------------------------------------------- |
1196 | |||
1427 | diamond | 1197 | s_header db ' - Kolibri Image Viewer', 0 |
3116 | dunkaist | 1198 | wnd_style dd 0x73FFFFFF |
1199 | wnd_x dd 100 |
||
1200 | wnd_y dd 100 |
||
1201 | image_padding dd 5 |
||
1202 | toolbar_height dd 31 |
||
1203 | bg_color dd 0x00ffffff |
||
1004 | diamond | 1204 | |
1205 | ;----------------------------------------------------------------------------- |
||
1206 | ;----------------------------------------------------------------------------- |
||
1207 | |||
1208 | align 4 |
||
1209 | @IMPORT: |
||
1210 | |||
1570 | dunkaist | 1211 | library \ |
1212 | libio , 'libio.obj' , \ |
||
1213 | libgfx , 'libgfx.obj' , \ |
||
1214 | libimg , 'libimg.obj' , \ |
||
1215 | libini , 'libini.obj' , \ |
||
1216 | sort , 'sort.obj' , \ |
||
6804 | IgorA | 1217 | proc_lib ,'proc_lib.obj',\ |
1218 | libbuf2d, 'buf2d.obj' |
||
1004 | diamond | 1219 | |
1511 | mario79 | 1220 | |
1570 | dunkaist | 1221 | import libio , \ |
1222 | libio.init , 'lib_init' , \ |
||
1223 | file.size , 'file_size' , \ |
||
1224 | file.open , 'file_open' , \ |
||
1225 | file.read , 'file_read' , \ |
||
1226 | file.close , 'file_close' |
||
1004 | diamond | 1227 | |
1570 | dunkaist | 1228 | import libgfx , \ |
1229 | libgfx.init , 'lib_init' , \ |
||
1230 | gfx.open , 'gfx_open' , \ |
||
1231 | gfx.close , 'gfx_close' , \ |
||
1232 | gfx.pen.color , 'gfx_pen_color' , \ |
||
1233 | gfx.line , 'gfx_line' |
||
1004 | diamond | 1234 | |
1570 | dunkaist | 1235 | import libimg , \ |
1236 | libimg.init , 'lib_init' , \ |
||
1237 | img.is_img , 'img_is_img' , \ |
||
1238 | img.to_rgb2 , 'img_to_rgb2', \ |
||
1239 | img.decode , 'img_decode' , \ |
||
1240 | img.flip , 'img_flip' , \ |
||
1241 | img.rotate , 'img_rotate' , \ |
||
1242 | img.destroy , 'img_destroy', \ |
||
1243 | img.draw , 'img_draw' |
||
1004 | diamond | 1244 | |
1570 | dunkaist | 1245 | import libini, \ |
7421 | leency | 1246 | ini_get_shortcut, 'ini_get_shortcut',\ |
1247 | ini_set_str, 'ini_set_str' |
||
1427 | diamond | 1248 | |
1144 | diamond | 1249 | import sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi' |
1016 | diamond | 1250 | |
1570 | dunkaist | 1251 | import proc_lib, \ |
1252 | OpenDialog_Init, 'OpenDialog_init', \ |
||
1253 | OpenDialog_Start,'OpenDialog_start' |
||
1511 | mario79 | 1254 | |
6804 | IgorA | 1255 | import libbuf2d, \ |
1256 | buf2d_init, 'lib_init', \ |
||
1257 | buf2d_resize, 'buf2d_resize' |
||
1258 | |||
1259 | align 4 |
||
1260 | buf_0: dd 0 |
||
1261 | dw 0,0 |
||
1262 | .w: dd 0 |
||
1263 | .h: dd 0,0 |
||
1264 | db 24 ;+20 bit in pixel |
||
1265 | |||
1570 | dunkaist | 1266 | bFirstDraw db 0 |
3116 | dunkaist | 1267 | bSlideShow db 0 |
1268 | bTglbar db 0 |
||
1004 | diamond | 1269 | ;----------------------------------------------------------------------------- |
1270 | |||
1016 | diamond | 1271 | virtual at 0 |
1272 | file 'kivicons.bmp':0xA,4 |
||
1273 | load offbits dword from 0 |
||
1274 | end virtual |
||
3116 | dunkaist | 1275 | numimages = 10 |
1016 | diamond | 1276 | openbtn = 0 |
1277 | backbtn = 1 |
||
1278 | forwardbtn = 2 |
||
1279 | bgrbtn = 3 |
||
1280 | fliphorzbtn = 4 |
||
1281 | flipvertbtn = 5 |
||
1282 | rotcwbtn = 6 |
||
1283 | rotccwbtn = 7 |
||
1284 | rot180btn = 8 |
||
3116 | dunkaist | 1285 | slidebtn = 9 |
1016 | diamond | 1286 | |
1004 | diamond | 1287 | palette: |
1570 | dunkaist | 1288 | file 'kivicons.bmp':0x36,offbits-0x36 |
1016 | diamond | 1289 | buttons: |
1570 | dunkaist | 1290 | file 'kivicons.bmp':offbits |
1004 | diamond | 1291 | repeat 10 |
1292 | y = % - 1 |
||
1293 | z = 20 - % |
||
1016 | diamond | 1294 | repeat numimages*5 |
1295 | load a dword from $ - numimages*20*20 + numimages*20*y + (%-1)*4 |
||
1296 | load b dword from $ - numimages*20*20 + numimages*20*z + (%-1)*4 |
||
1297 | store dword a at $ - numimages*20*20 + numimages*20*z + (%-1)*4 |
||
1298 | store dword b at $ - numimages*20*20 + numimages*20*y + (%-1)*4 |
||
1004 | diamond | 1299 | end repeat |
1300 | end repeat |
||
1301 | |||
1570 | dunkaist | 1302 | inifilename db '/sys/media/kiv.ini',0 |
1303 | aShortcuts db 'Shortcuts',0 |
||
1304 | aNext db 'Next',0 |
||
1305 | aPrev db 'Prev',0 |
||
3116 | dunkaist | 1306 | aSlide db 'SlideShow',0 |
1307 | aTglbar db 'ToggleBar',0 |
||
1427 | diamond | 1308 | |
7421 | leency | 1309 | inifileeskin db '/sys/settings/eskin.ini',0 |
1310 | amain db 'main',0 |
||
1311 | aprogram db 'program',0 |
||
1312 | aparam db 'param',0 |
||
1313 | |||
1427 | diamond | 1314 | align 4 |
1315 | check_modifier_table: |
||
1570 | dunkaist | 1316 | dd check_modifier_0 |
1317 | dd check_modifier_1 |
||
1318 | dd check_modifier_2 |
||
1319 | dd check_modifier_3 |
||
1320 | dd check_modifier_4 |
||
1427 | diamond | 1321 | |
1470 | mario79 | 1322 | ;--------------------------------------------------------------------- |
1323 | align 4 |
||
1324 | OpenDialog_data: |
||
1570 | dunkaist | 1325 | .type dd 0 |
1326 | .procinfo dd procinfo ;+4 |
||
1327 | .com_area_name dd communication_area_name ;+8 |
||
1328 | .com_area dd 0 ;+12 |
||
1329 | .opendir_pach dd temp_dir_pach ;+16 |
||
1330 | .dir_default_pach dd communication_area_default_pach ;+20 |
||
1331 | .start_path dd open_dialog_path ;+24 |
||
1332 | .draw_window dd draw_window ;+28 |
||
1333 | .status dd 0 ;+32 |
||
1334 | .openfile_pach dd path ;openfile_pach ;+36 |
||
1335 | .filename_area dd 0 ;+40 |
||
1336 | .filter_area dd Filter |
||
1582 | mario79 | 1337 | .x: |
5183 | hidnplayr | 1338 | .x_size dw 420 ;+48 ; Window X size |
1339 | .x_start dw 10 ;+50 ; Window X position |
||
1582 | mario79 | 1340 | .y: |
5183 | hidnplayr | 1341 | .y_size dw 320 ;+52 ; Window y size |
1342 | .y_start dw 10 ;+54 ; Window Y position |
||
1004 | diamond | 1343 | |
1470 | mario79 | 1344 | communication_area_name: |
1570 | dunkaist | 1345 | db 'FFFFFFFF_open_dialog',0 |
1701 | lrz | 1346 | |
1470 | mario79 | 1347 | open_dialog_path: |
1701 | lrz | 1348 | if __nightbuild eq yes |
1349 | db '/sys/MANAGERS/opendial',0 |
||
1350 | else |
||
1570 | dunkaist | 1351 | db '/sys/File Managers/opendial',0 |
1701 | lrz | 1352 | end if |
1470 | mario79 | 1353 | communication_area_default_pach: |
1570 | dunkaist | 1354 | db '/rd/1',0 |
1004 | diamond | 1355 | |
1470 | mario79 | 1356 | Filter: |
1357 | dd Filter.end - Filter |
||
1358 | .1: |
||
1359 | db 'BMP',0 |
||
1360 | db 'GIF',0 |
||
1361 | db 'JPG',0 |
||
1362 | db 'JPEG',0 |
||
1363 | db 'JPE',0 |
||
1364 | db 'PNG',0 |
||
1365 | db 'ICO',0 |
||
1366 | db 'CUR',0 |
||
3116 | dunkaist | 1367 | db 'TGA',0 |
1570 | dunkaist | 1368 | db 'PCX',0 |
1922 | dunkaist | 1369 | db 'XCF',0 |
2389 | dunkaist | 1370 | db 'PBM',0 |
1371 | db 'PGM',0 |
||
1372 | db 'PNM',0 |
||
1373 | db 'TIF',0 |
||
1374 | db 'TIFF',0 |
||
2394 | dunkaist | 1375 | db 'WBMP',0 |
1470 | mario79 | 1376 | .end: |
1377 | db 0 |
||
1004 | diamond | 1378 | |
1470 | mario79 | 1379 | draw_window_fake: |
1570 | dunkaist | 1380 | ret |
1470 | mario79 | 1381 | ;------------------------------------------------------------------------------ |
1016 | diamond | 1382 | readdir_fileinfo: |
1570 | dunkaist | 1383 | dd 1 |
1384 | dd 0 |
||
1385 | dd 0 |
||
1386 | readblocks dd 0 |
||
1387 | directory_ptr dd 0 |
||
1470 | mario79 | 1388 | ;------------------------------------------------------------------------------ |
1004 | diamond | 1389 | I_END: |
1570 | dunkaist | 1390 | curdir rb 1024 |
1016 | diamond | 1391 | |
1392 | align 4 |
||
1004 | diamond | 1393 | img_data dd ? |
1394 | img_data_len dd ? |
||
1570 | dunkaist | 1395 | fh dd ? |
1396 | image dd ? |
||
3116 | dunkaist | 1397 | wnd_width dd 100 |
1398 | wnd_height dd 100 |
||
1399 | draw_x dd ? |
||
1400 | draw_y dd ? |
||
1570 | dunkaist | 1401 | draw_width dd ? |
1402 | draw_height dd ? |
||
1403 | last_name_component dd ? |
||
1404 | cur_file_idx dd ? |
||
1405 | cur_frame_time dd ? |
||
1406 | cur_frame dd ? |
||
1004 | diamond | 1407 | |
1570 | dunkaist | 1408 | next_mod dd ? |
1409 | next_key dd ? |
||
1410 | prev_mod dd ? |
||
1411 | prev_key dd ? |
||
3116 | dunkaist | 1412 | slide_mod dd ? |
1413 | slide_key dd ? |
||
1414 | tglbar_mod dd ? |
||
1415 | tglbar_key dd ? |
||
1004 | diamond | 1416 | |
3116 | dunkaist | 1417 | toolbar_height_old rd 1 |
1418 | |||
1419 | procinfo process_information |
||
7421 | leency | 1420 | align 16 |
1570 | dunkaist | 1421 | path: rb 4096 ;1024+16 |
1422 | real_header rb 256 |
||
1470 | mario79 | 1423 | @PARAMS rb 4096 ;512 |
1424 | ;--------------------------------------------------------------------- |
||
7421 | leency | 1425 | sys_path rb 1024 |
1470 | mario79 | 1426 | temp_dir_pach: |
1427 | rb 4096 |
||
1428 | ;--------------------------------------------------------------------- |
||
1570 | dunkaist | 1429 | rb 4096 |
1470 | mario79 | 1430 | stacktop: |
1431 | ;--------------------------------------------------------------------- |
||
1922 | dunkaist | 1432 | F_END:=>15>15>10>10>5>20,>15>15>10>10>5,>5>15>10>0,>5>30,>0> |