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