Subversion Repositories Kolibri OS

Rev

Rev 1594 | Rev 1922 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1594 Rev 1701
1
use32
1
use32
2
org 0x0
2
org 0x0
3
 
3
 
4
db 'MENUET01'
4
db 'MENUET01'
5
dd 0x01, START, I_END, F_END, stacktop, @PARAMS, 0x0
5
dd 0x01, START, I_END, F_END, stacktop, @PARAMS, 0x0
6
 
6
 
7
;-----------------------------------------------------------------------------
7
;-----------------------------------------------------------------------------
8
 
8
 
9
FALSE = 0
9
FALSE = 0
10
TRUE  = 1
10
TRUE  = 1
11
 
-
 
-
 
11
include '../../../config.inc'		;for nightbuild
12
include '../../../proc32.inc'
12
include '../../../proc32.inc'
13
include '../../../macros.inc'
13
include '../../../macros.inc'
14
include 'dll.inc'
14
include 'dll.inc'
15
 
15
 
16
include '../../../develop/libraries/libs-dev/libio/libio.inc'
16
include '../../../develop/libraries/libs-dev/libio/libio.inc'
17
include '../../../develop/libraries/libs-dev/libimg/libimg.inc'
17
include '../../../develop/libraries/libs-dev/libimg/libimg.inc'
18
 
18
 
19
;include '../../../develop/libraries/box_lib/asm/trunk/opendial.mac'
19
;include '../../../develop/libraries/box_lib/asm/trunk/opendial.mac'
20
;use_OpenDialog
20
;use_OpenDialog
21
;-----------------------------------------------------------------------------
21
;-----------------------------------------------------------------------------
22
 
22
 
23
START:
23
START:
24
    mcall   68, 11
24
    mcall   68, 11
25
 
25
 
26
    stdcall dll.Load, @IMPORT
26
    stdcall dll.Load, @IMPORT
27
    or  eax, eax
27
    or  eax, eax
28
    jnz exit
28
    jnz exit
29
 
29
 
30
    invoke  sort.START, 1
30
    invoke  sort.START, 1
31
 
31
 
32
    mov ecx, 1  ; for 15.4: 1 = tile
32
    mov ecx, 1  ; for 15.4: 1 = tile
33
    cmp word [@PARAMS], '\T'
33
    cmp word [@PARAMS], '\T'
34
    jz  set_bgr
34
    jz  set_bgr
35
    inc ecx ; for 15.4: 2 = stretch
35
    inc ecx ; for 15.4: 2 = stretch
36
    cmp word [@PARAMS], '\S'
36
    cmp word [@PARAMS], '\S'
37
    jz  set_bgr
37
    jz  set_bgr
38
 
38
 
39
    cmp byte [@PARAMS], 0
39
    cmp byte [@PARAMS], 0
40
    jz @f
40
    jz @f
41
    mov esi, @PARAMS
41
    mov esi, @PARAMS
42
    mov edi, path
42
    mov edi, path
43
    mov ecx, 4096/4
43
    mov ecx, 4096/4
44
    rep movsd
44
    rep movsd
45
    mov byte [edi-1], 0
45
    mov byte [edi-1], 0
46
@@:
46
@@:
47
; OpenDialog initialisation
47
; OpenDialog initialisation
48
    push    dword OpenDialog_data
48
    push    dword OpenDialog_data
49
    call    [OpenDialog_Init]
49
    call    [OpenDialog_Init]
50
 
50
 
51
; initialize keyboard handling
51
; initialize keyboard handling
52
    invoke  ini_get_shortcut, inifilename, aShortcuts, aNext, -1, next_mod
52
    invoke  ini_get_shortcut, inifilename, aShortcuts, aNext, -1, next_mod
53
    mov [next_key], eax
53
    mov [next_key], eax
54
    invoke  ini_get_shortcut, inifilename, aShortcuts, aPrev, -1, prev_mod
54
    invoke  ini_get_shortcut, inifilename, aShortcuts, aPrev, -1, prev_mod
55
    mov [prev_key], eax
55
    mov [prev_key], eax
56
    mcall   66, 1, 1    ; set kbd mode to scancodes
56
    mcall   66, 1, 1    ; set kbd mode to scancodes
57
 
57
 
58
    cmp byte [@PARAMS], 0
58
    cmp byte [@PARAMS], 0
59
    jnz params_given
59
    jnz params_given
60
 
60
 
61
    mov [OpenDialog_data.draw_window],draw_window_fake
61
    mov [OpenDialog_data.draw_window],draw_window_fake
62
    
62
    
63
; OpenDialog Open
63
; OpenDialog Open
64
    push    dword OpenDialog_data
64
    push    dword OpenDialog_data
65
    call    [OpenDialog_Start]
65
    call    [OpenDialog_Start]
66
 
66
 
67
    cmp [OpenDialog_data.status],1
67
    cmp [OpenDialog_data.status],1
68
    jne exit
68
    jne exit
69
 
69
 
70
    mov [OpenDialog_data.draw_window],draw_window
70
    mov [OpenDialog_data.draw_window],draw_window
71
 
71
 
72
    mov esi, path
72
    mov esi, path
73
    mov edi, @PARAMS
73
    mov edi, @PARAMS
74
    mov ecx, 4096/4
74
    mov ecx, 4096/4
75
    rep movsd
75
    rep movsd
76
    mov byte [edi-1], 0
76
    mov byte [edi-1], 0
77
    jmp params_given
77
    jmp params_given
78
 
78
 
79
set_bgr:
79
set_bgr:
80
    mcall   15, 4
80
    mcall   15, 4
81
    mov eax, @PARAMS + 4
81
    mov eax, @PARAMS + 4
82
    call    load_image
82
    call    load_image
83
    jc  exit
83
    jc  exit
84
 
84
 
85
    call    set_as_bgr
85
    call    set_as_bgr
86
    jmp exit
86
    jmp exit
87
 
87
 
88
params_given:
88
params_given:
89
 
89
 
90
    mov esi, @PARAMS
90
    mov esi, @PARAMS
91
    push    esi
91
    push    esi
92
    call    find_last_name_component
92
    call    find_last_name_component
93
 
93
 
94
    pop eax
94
    pop eax
95
    call    load_image
95
    call    load_image
96
    jc  exit
96
    jc  exit
97
    call    generate_header
97
    call    generate_header
98
 
98
 
99
;-----------------------------------------------------------------------------
99
;-----------------------------------------------------------------------------
100
 
100
 
101
red:
101
red:
102
    call    draw_window
102
    call    draw_window
103
 
103
 
104
still:
104
still:
105
    mov eax, [image]
105
    mov eax, [image]
106
    test    byte [eax + Image.Flags], Image.IsAnimated
106
    test    byte [eax + Image.Flags], Image.IsAnimated
107
    push    10
107
    push    10
108
    pop eax
108
    pop eax
109
    jz  @f
109
    jz  @f
110
    mcall   26, 9
110
    mcall   26, 9
111
    mov edx, [cur_frame]
111
    mov edx, [cur_frame]
112
    mov ebx, [cur_frame_time]
112
    mov ebx, [cur_frame_time]
113
    add ebx, [edx + Image.Delay]
113
    add ebx, [edx + Image.Delay]
114
    sub ebx, eax
114
    sub ebx, eax
115
    cmp ebx, [edx + Image.Delay]
115
    cmp ebx, [edx + Image.Delay]
116
    ja  red_update_frame
116
    ja  red_update_frame
117
    test    ebx, ebx
117
    test    ebx, ebx
118
    jz  red_update_frame
118
    jz  red_update_frame
119
    push    23
119
    push    23
120
    pop eax
120
    pop eax
121
  @@:
121
  @@:
122
    mcall
122
    mcall
123
    dec eax
123
    dec eax
124
    js  red_update_frame
124
    js  red_update_frame
125
    jz  red
125
    jz  red
126
    dec eax
126
    dec eax
127
    jnz button
127
    jnz button
128
 
128
 
129
key:
129
key:
130
    xor esi, esi
130
    xor esi, esi
131
keyloop:
131
keyloop:
132
    mcall   2
132
    mcall   2
133
    test    al, al
133
    test    al, al
134
    jnz keyloopdone
134
    jnz keyloopdone
135
    shr eax, 8
135
    shr eax, 8
136
    mov ecx, eax
136
    mov ecx, eax
137
    mcall   66, 3
137
    mcall   66, 3
138
    mov edx, next_mod
138
    mov edx, next_mod
139
    call    check_shortcut
139
    call    check_shortcut
140
    jz  .next
140
    jz  .next
141
    add edx, prev_mod - next_mod
141
    add edx, prev_mod - next_mod
142
    call    check_shortcut
142
    call    check_shortcut
143
    jnz keyloop
143
    jnz keyloop
144
.prev:
144
.prev:
145
    dec esi
145
    dec esi
146
    jmp keyloop
146
    jmp keyloop
147
.next:
147
.next:
148
    inc esi
148
    inc esi
149
    jmp keyloop
149
    jmp keyloop
150
keyloopdone:
150
keyloopdone:
151
    test    esi, esi
151
    test    esi, esi
152
    jz  still
152
    jz  still
153
next_or_prev_handler:
153
next_or_prev_handler:
154
    call    next_or_prev_image
154
    call    next_or_prev_image
155
    jmp red
155
    jmp red
156
 
156
 
157
red_update_frame:
157
red_update_frame:
158
    mov eax, [cur_frame]
158
    mov eax, [cur_frame]
159
    mov eax, [eax + Image.Next]
159
    mov eax, [eax + Image.Next]
160
    test    eax, eax
160
    test    eax, eax
161
    jnz @f
161
    jnz @f
162
    mov eax, [image]
162
    mov eax, [image]
163
  @@:
163
  @@:
164
    mov [cur_frame], eax
164
    mov [cur_frame], eax
165
    mcall   26, 9
165
    mcall   26, 9
166
    mov [cur_frame_time], eax
166
    mov [cur_frame_time], eax
167
    mcall   9, procinfo, -1
167
    mcall   9, procinfo, -1
168
    call    draw_cur_frame
168
    call    draw_cur_frame
169
    jmp still
169
    jmp still
170
 
170
 
171
button:
171
button:
172
    mcall   17
172
    mcall   17
173
    shr eax, 8
173
    shr eax, 8
174
 
174
 
175
    ; flip horizontally
175
    ; flip horizontally
176
    cmp eax, 'flh'
176
    cmp eax, 'flh'
177
    jne @f
177
    jne @f
178
 
178
 
179
    invoke  img.flip, [image], FLIP_HORIZONTAL
179
    invoke  img.flip, [image], FLIP_HORIZONTAL
180
    jmp redraw_image
180
    jmp redraw_image
181
 
181
 
182
    ; flip vertically
182
    ; flip vertically
183
    @@: cmp eax, 'flv'
183
    @@: cmp eax, 'flv'
184
    jne @f
184
    jne @f
185
 
185
 
186
    invoke  img.flip, [image], FLIP_VERTICAL
186
    invoke  img.flip, [image], FLIP_VERTICAL
187
    jmp redraw_image
187
    jmp redraw_image
188
 
188
 
189
    ; flip both horizontally and vertically
189
    ; flip both horizontally and vertically
190
    @@: cmp eax, 'flb'
190
    @@: cmp eax, 'flb'
191
    jne @f
191
    jne @f
192
 
192
 
193
    invoke  img.flip, [image], FLIP_BOTH
193
    invoke  img.flip, [image], FLIP_BOTH
194
    jmp redraw_image
194
    jmp redraw_image
195
 
195
 
196
    ; rotate left
196
    ; rotate left
197
    @@: cmp eax, 'rtl'
197
    @@: cmp eax, 'rtl'
198
    jne @f
198
    jne @f
199
 
199
 
200
    push    ROTATE_90_CCW
200
    push    ROTATE_90_CCW
201
.rotate_common:
201
.rotate_common:
202
    invoke  img.rotate, [image]
202
    invoke  img.rotate, [image]
203
    mov eax, [image]
203
    mov eax, [image]
204
    test    eax, eax    ; clear ZF flag
204
    test    eax, eax    ; clear ZF flag
205
    call    update_image_sizes
205
    call    update_image_sizes
206
    jmp redraw_image
206
    jmp redraw_image
207
 
207
 
208
    ; rotate right
208
    ; rotate right
209
    @@: cmp eax, 'rtr'
209
    @@: cmp eax, 'rtr'
210
    jne @f
210
    jne @f
211
 
211
 
212
    push    ROTATE_90_CW
212
    push    ROTATE_90_CW
213
    jmp .rotate_common
213
    jmp .rotate_common
214
 
214
 
215
    ; open new file
215
    ; open new file
216
    @@: cmp eax, 'opn'
216
    @@: cmp eax, 'opn'
217
    jne @f
217
    jne @f
218
    
218
    
219
; OpenDialog Open
219
; OpenDialog Open
220
    push    dword OpenDialog_data
220
    push    dword OpenDialog_data
221
    call    [OpenDialog_Start]
221
    call    [OpenDialog_Start]
222
    
222
    
223
    cmp [OpenDialog_data.status],1
223
    cmp [OpenDialog_data.status],1
224
    jne still
224
    jne still
225
    
225
    
226
    mov esi, path
226
    mov esi, path
227
    mov edi, @PARAMS
227
    mov edi, @PARAMS
228
    push    edi
228
    push    edi
229
    mov ecx, 4096/4
229
    mov ecx, 4096/4
230
    rep movsd
230
    rep movsd
231
    mov byte [edi-1], 0
231
    mov byte [edi-1], 0
232
    
232
    
233
    pop esi
233
    pop esi
234
    push    esi
234
    push    esi
235
    call    find_last_name_component
235
    call    find_last_name_component
236
 
236
 
237
    pop eax 
237
    pop eax 
238
    push    [image]
238
    push    [image]
239
    call    load_image
239
    call    load_image
240
    jc  .restore_old
240
    jc  .restore_old
241
    call    generate_header
241
    call    generate_header
242
    
242
    
243
    invoke  img.destroy
243
    invoke  img.destroy
244
    call    free_directory
244
    call    free_directory
245
    jmp red
245
    jmp red
246
    
246
    
247
    .restore_old:
247
    .restore_old:
248
    pop [image]
248
    pop [image]
249
    call    init_frame
249
    call    init_frame
250
    jmp still
250
    jmp still
251
 
251
 
252
    ; set background
252
    ; set background
253
    @@:
253
    @@:
254
    cmp eax, 'bgr'
254
    cmp eax, 'bgr'
255
    jne @f
255
    jne @f
256
 
256
 
257
    call    set_as_bgr
257
    call    set_as_bgr
258
    jmp still
258
    jmp still
259
 
259
 
260
    @@:
260
    @@:
261
 
261
 
262
    or  esi, -1
262
    or  esi, -1
263
    cmp eax, 'bck'
263
    cmp eax, 'bck'
264
    jz  next_or_prev_handler
264
    jz  next_or_prev_handler
265
    neg esi
265
    neg esi
266
    cmp eax, 'fwd'
266
    cmp eax, 'fwd'
267
    jz  next_or_prev_handler
267
    jz  next_or_prev_handler
268
 
268
 
269
    cmp eax, 1
269
    cmp eax, 1
270
    jne still
270
    jne still
271
 
271
 
272
  exit:
272
  exit:
273
    mcall   -1
273
    mcall   -1
274
 
274
 
275
  redraw_image = red
275
  redraw_image = red
276
 
276
 
277
load_image:
277
load_image:
278
    and [img_data], 0
278
    and [img_data], 0
279
    push    eax
279
    push    eax
280
    invoke  file.open, eax, O_READ
280
    invoke  file.open, eax, O_READ
281
    or  eax, eax
281
    or  eax, eax
282
    jz  .error_pop
282
    jz  .error_pop
283
    mov [fh], eax
283
    mov [fh], eax
284
    invoke  file.size
284
    invoke  file.size
285
    mov [img_data_len], ebx
285
    mov [img_data_len], ebx
286
    stdcall mem.Alloc, ebx
286
    stdcall mem.Alloc, ebx
287
    test    eax, eax
287
    test    eax, eax
288
    jz  .error_close
288
    jz  .error_close
289
    mov [img_data], eax
289
    mov [img_data], eax
290
    invoke  file.read, [fh], eax, [img_data_len]
290
    invoke  file.read, [fh], eax, [img_data_len]
291
    cmp eax, -1
291
    cmp eax, -1
292
    jz  .error_close
292
    jz  .error_close
293
    cmp eax, [img_data_len]
293
    cmp eax, [img_data_len]
294
    jnz .error_close
294
    jnz .error_close
295
    invoke  file.close, [fh]
295
    invoke  file.close, [fh]
296
    inc eax
296
    inc eax
297
    jz  .error
297
    jz  .error
298
 
298
 
299
; img.decode checks for img.is_img
299
; img.decode checks for img.is_img
300
;   invoke  img.is_img, [img_data], [img_data_len]
300
;   invoke  img.is_img, [img_data], [img_data_len]
301
;   or  eax, eax
301
;   or  eax, eax
302
;   jz  exit
302
;   jz  exit
303
    invoke  img.decode, [img_data], [img_data_len], 0
303
    invoke  img.decode, [img_data], [img_data_len], 0
304
    or  eax, eax
304
    or  eax, eax
305
    jz  .error
305
    jz  .error
306
    cmp [image], 0
306
    cmp [image], 0
307
    pushf
307
    pushf
308
    mov [image], eax
308
    mov [image], eax
309
    call    init_frame
309
    call    init_frame
310
    popf
310
    popf
311
    call    update_image_sizes
311
    call    update_image_sizes
312
    call    free_img_data
312
    call    free_img_data
313
    clc
313
    clc
314
    ret
314
    ret
315
 
315
 
316
.error_free:
316
.error_free:
317
    invoke  img.destroy, [image]
317
    invoke  img.destroy, [image]
318
    jmp .error
318
    jmp .error
319
 
319
 
320
.error_pop:
320
.error_pop:
321
    pop eax
321
    pop eax
322
    jmp .error
322
    jmp .error
323
.error_close:
323
.error_close:
324
    invoke  file.close, [fh]
324
    invoke  file.close, [fh]
325
.error:
325
.error:
326
    call    free_img_data
326
    call    free_img_data
327
    stc
327
    stc
328
    ret
328
    ret
329
 
329
 
330
free_img_data:
330
free_img_data:
331
    mov eax, [img_data]
331
    mov eax, [img_data]
332
    test    eax, eax
332
    test    eax, eax
333
    jz  @f
333
    jz  @f
334
    stdcall mem.Free, eax
334
    stdcall mem.Free, eax
335
@@:
335
@@:
336
    ret
336
    ret
337
 
337
 
338
update_image_sizes:
338
update_image_sizes:
339
    pushf
339
    pushf
340
    mov edx, [eax + Image.Width]
340
    mov edx, [eax + Image.Width]
341
    mov [draw_width], edx
341
    mov [draw_width], edx
342
    add edx, 19
342
    add edx, 19
343
    cmp edx, 40 + 25*9
343
    cmp edx, 40 + 25*9
344
    jae @f
344
    jae @f
345
    mov edx, 40 + 25*9
345
    mov edx, 40 + 25*9
346
@@:
346
@@:
347
    mov [wnd_width], edx
347
    mov [wnd_width], edx
348
    mov esi, [eax + Image.Height]
348
    mov esi, [eax + Image.Height]
349
    mov [draw_height], esi
349
    mov [draw_height], esi
350
    add esi, 44
350
    add esi, 44
351
    mov [wnd_height], esi
351
    mov [wnd_height], esi
352
    popf
352
    popf
353
    jz  .no_resize
353
    jz  .no_resize
354
    mcall   48, 4
354
    mcall   48, 4
355
    add esi, eax
355
    add esi, eax
356
    mcall   67,-1,-1
356
    mcall   67,-1,-1
357
.no_resize:
357
.no_resize:
358
    ret
358
    ret
359
 
359
 
360
set_as_bgr:
360
set_as_bgr:
361
    mov esi, [image]
361
    mov esi, [image]
362
    mov ecx, [esi + Image.Width]
362
    mov ecx, [esi + Image.Width]
363
    mov edx, [esi + Image.Height]
363
    mov edx, [esi + Image.Height]
364
    mcall   15, 1
364
    mcall   15, 1
365
 
365
 
366
    mcall   15, 6
366
    mcall   15, 6
367
    test    eax, eax
367
    test    eax, eax
368
    jz  @f
368
    jz  @f
369
 
369
 
370
    push    eax
370
    push    eax
371
    invoke  img.to_rgb2, esi, eax
371
    invoke  img.to_rgb2, esi, eax
372
    pop ecx
372
    pop ecx
373
    mcall   15, 7
373
    mcall   15, 7
374
 
374
 
375
@@:
375
@@:
376
    mcall   15, 3
376
    mcall   15, 3
377
    ret
377
    ret
378
 
378
 
379
; seek to ESI image files
379
; seek to ESI image files
380
; esi>0 means next file, esi<0 - prev file
380
; esi>0 means next file, esi<0 - prev file
381
next_or_prev_image:
381
next_or_prev_image:
382
    push    esi
382
    push    esi
383
    call    load_directory
383
    call    load_directory
384
    pop esi
384
    pop esi
385
    mov ebx, [directory_ptr]
385
    mov ebx, [directory_ptr]
386
    test    ebx, ebx
386
    test    ebx, ebx
387
    jz  .ret
387
    jz  .ret
388
    cmp dword[ebx+4], 0
388
    cmp dword[ebx+4], 0
389
    jz  .ret
389
    jz  .ret
390
    mov eax, [cur_file_idx]
390
    mov eax, [cur_file_idx]
391
    cmp eax, -1
391
    cmp eax, -1
392
    jnz @f
392
    jnz @f
393
    test    esi, esi
393
    test    esi, esi
394
    jns @f
394
    jns @f
395
    mov eax, [ebx+4]
395
    mov eax, [ebx+4]
396
@@:
396
@@:
397
    push    [image]
397
    push    [image]
398
    add eax, esi
398
    add eax, esi
399
@@:
399
@@:
400
    test    eax, eax
400
    test    eax, eax
401
    jns @f
401
    jns @f
402
    add eax, [ebx+4]
402
    add eax, [ebx+4]
403
    jmp @b
403
    jmp @b
404
@@:
404
@@:
405
    cmp eax, [ebx+4]
405
    cmp eax, [ebx+4]
406
    jb  @f
406
    jb  @f
407
    sub eax, [ebx+4]
407
    sub eax, [ebx+4]
408
    jmp @b
408
    jmp @b
409
@@:
409
@@:
410
    push    eax
410
    push    eax
411
.scanloop:
411
.scanloop:
412
    push    eax ebx esi
412
    push    eax ebx esi
413
    imul    esi, eax, 304
413
    imul    esi, eax, 304
414
    add esi, [directory_ptr]
414
    add esi, [directory_ptr]
415
    add esi, 32 + 40
415
    add esi, 32 + 40
416
    mov edi, curdir
416
    mov edi, curdir
417
@@:
417
@@:
418
    inc edi
418
    inc edi
419
    cmp byte [edi-1], 0
419
    cmp byte [edi-1], 0
420
    jnz @b
420
    jnz @b
421
    mov byte [edi-1], '/'
421
    mov byte [edi-1], '/'
422
@@:
422
@@:
423
    lodsb
423
    lodsb
424
    stosb
424
    stosb
425
    test    al, al
425
    test    al, al
426
    jnz @b
426
    jnz @b
427
    mov eax, curdir
427
    mov eax, curdir
428
    call    load_image
428
    call    load_image
429
    pushf
429
    pushf
430
    mov esi, curdir
430
    mov esi, curdir
431
    push    esi
431
    push    esi
432
    mov edi, @PARAMS
432
    mov edi, @PARAMS
433
    mov ecx, 4096/4
433
    mov ecx, 4096/4
434
    rep movsd
434
    rep movsd
435
    mov byte [edi-1], 0
435
    mov byte [edi-1], 0
436
    pop esi
436
    pop esi
437
@@:
437
@@:
438
    lodsb
438
    lodsb
439
    test    al, al
439
    test    al, al
440
    jnz @b
440
    jnz @b
441
@@:
441
@@:
442
    dec esi
442
    dec esi
443
    cmp byte [esi], '/'
443
    cmp byte [esi], '/'
444
    jnz @b
444
    jnz @b
445
    mov byte [esi], 0
445
    mov byte [esi], 0
446
    popf
446
    popf
447
    pop esi ebx eax
447
    pop esi ebx eax
448
    jnc .loadedok
448
    jnc .loadedok
449
    test    esi, esi
449
    test    esi, esi
450
    js  .try_prev
450
    js  .try_prev
451
.try_next:
451
.try_next:
452
    inc eax
452
    inc eax
453
    cmp eax, [ebx+4]
453
    cmp eax, [ebx+4]
454
    jb  @f
454
    jb  @f
455
    xor eax, eax
455
    xor eax, eax
456
@@:
456
@@:
457
.try_common:
457
.try_common:
458
    cmp eax, [esp]
458
    cmp eax, [esp]
459
    jz  .notfound
459
    jz  .notfound
460
    jmp .scanloop
460
    jmp .scanloop
461
.try_prev:
461
.try_prev:
462
    dec eax
462
    dec eax
463
    jns @f
463
    jns @f
464
    mov eax, [ebx+4]
464
    mov eax, [ebx+4]
465
    dec eax
465
    dec eax
466
@@:
466
@@:
467
    jmp .try_common
467
    jmp .try_common
468
.loadedok:
468
.loadedok:
469
    mov [cur_file_idx], eax
469
    mov [cur_file_idx], eax
470
    pop eax
470
    pop eax
471
    invoke  img.destroy
471
    invoke  img.destroy
472
    call    generate_header
472
    call    generate_header
473
.ret:
473
.ret:
474
    ret
474
    ret
475
.notfound:
475
.notfound:
476
    pop eax
476
    pop eax
477
    pop [image]
477
    pop [image]
478
    call    init_frame
478
    call    init_frame
479
    ret
479
    ret
480
 
480
 
481
load_directory:
481
load_directory:
482
    cmp [directory_ptr], 0
482
    cmp [directory_ptr], 0
483
    jnz .ret
483
    jnz .ret
484
    mov esi, @PARAMS
484
    mov esi, @PARAMS
485
    mov edi, curdir
485
    mov edi, curdir
486
    mov ecx, [last_name_component]
486
    mov ecx, [last_name_component]
487
    sub ecx, esi
487
    sub ecx, esi
488
    dec ecx
488
    dec ecx
489
    js  @f
489
    js  @f
490
    rep movsb
490
    rep movsb
491
@@:
491
@@:
492
    mov byte [edi], 0
492
    mov byte [edi], 0
493
    mcall   68, 12, 0x1000
493
    mcall   68, 12, 0x1000
494
    test    eax, eax
494
    test    eax, eax
495
    jz  .ret
495
    jz  .ret
496
    mov ebx, readdir_fileinfo
496
    mov ebx, readdir_fileinfo
497
    mov dword [ebx+12], (0x1000 - 32) / 304
497
    mov dword [ebx+12], (0x1000 - 32) / 304
498
    mov dword [ebx+16], eax
498
    mov dword [ebx+16], eax
499
    mcall   70
499
    mcall   70
500
    cmp eax, 6
500
    cmp eax, 6
501
    jz  .dirok
501
    jz  .dirok
502
    test    eax, eax
502
    test    eax, eax
503
    jnz free_directory
503
    jnz free_directory
504
    mov edx, [directory_ptr]
504
    mov edx, [directory_ptr]
505
    mov ecx, [edx+8]
505
    mov ecx, [edx+8]
506
    mov [readblocks], ecx
506
    mov [readblocks], ecx
507
    imul    ecx, 304
507
    imul    ecx, 304
508
    add ecx, 32
508
    add ecx, 32
509
    mcall   68, 20
509
    mcall   68, 20
510
    test    eax, eax
510
    test    eax, eax
511
    jz  free_directory
511
    jz  free_directory
512
    mov [directory_ptr], eax
512
    mov [directory_ptr], eax
513
    mcall   70, readdir_fileinfo
513
    mcall   70, readdir_fileinfo
514
.dirok:
514
.dirok:
515
    cmp ebx, 0
515
    cmp ebx, 0
516
    jle free_directory
516
    jle free_directory
517
    mov eax, [directory_ptr]
517
    mov eax, [directory_ptr]
518
    add eax, 32
518
    add eax, 32
519
    mov edi, eax
519
    mov edi, eax
520
    push    0
520
    push    0
521
.dirskip:
521
.dirskip:
522
    push    eax
522
    push    eax
523
    test    byte [eax], 18h
523
    test    byte [eax], 18h
524
    jnz .nocopy
524
    jnz .nocopy
525
    lea esi, [eax+40]
525
    lea esi, [eax+40]
526
    mov ecx, esi
526
    mov ecx, esi
527
@@:
527
@@:
528
    lodsb
528
    lodsb
529
    test    al, al
529
    test    al, al
530
    jnz @b
530
    jnz @b
531
@@:
531
@@:
532
    dec esi
532
    dec esi
533
    cmp esi, ecx
533
    cmp esi, ecx
534
    jb  .noext
534
    jb  .noext
535
    cmp byte [esi], '.'
535
    cmp byte [esi], '.'
536
    jnz @b
536
    jnz @b
537
    inc esi
537
    inc esi
538
    mov ecx, [esi]
538
    mov ecx, [esi]
539
    or  ecx, 0x202020
539
    or  ecx, 0x202020
540
    cmp ecx, 'jpg'
540
    cmp ecx, 'jpg'
541
    jz  .copy
541
    jz  .copy
542
    cmp ecx, 'bmp'
542
    cmp ecx, 'bmp'
543
    jz  .copy
543
    jz  .copy
544
    cmp ecx, 'gif'
544
    cmp ecx, 'gif'
545
    jz  .copy
545
    jz  .copy
546
    cmp ecx, 'png'
546
    cmp ecx, 'png'
547
    jz  .copy
547
    jz  .copy
548
    cmp ecx, 'jpe'
548
    cmp ecx, 'jpe'
549
    jz  .copy
549
    jz  .copy
550
    cmp ecx, 'ico'
550
    cmp ecx, 'ico'
551
    jz  .copy
551
    jz  .copy
552
    cmp ecx, 'cur'
552
    cmp ecx, 'cur'
553
    jz  .copy
553
    jz  .copy
554
; dunkaist [
554
; dunkaist [
555
    cmp ecx, 'pcx'
555
    cmp ecx, 'pcx'
556
    jz  .copy
556
    jz  .copy
557
; dunkaist ]
557
; dunkaist ]
558
    cmp ecx, 'jpeg'
558
    cmp ecx, 'jpeg'
559
    jz  @f
559
    jz  @f
560
    cmp ecx, 'jpeG'
560
    cmp ecx, 'jpeG'
561
    jnz .nocopy
561
    jnz .nocopy
562
@@:
562
@@:
563
    cmp byte [esi+4], 0
563
    cmp byte [esi+4], 0
564
    jnz .nocopy
564
    jnz .nocopy
565
.copy:
565
.copy:
566
    mov esi, [esp]
566
    mov esi, [esp]
567
    mov ecx, 304 / 4
567
    mov ecx, 304 / 4
568
    rep movsd
568
    rep movsd
569
    inc dword [esp+4]
569
    inc dword [esp+4]
570
.nocopy:
570
.nocopy:
571
.noext:
571
.noext:
572
    pop eax
572
    pop eax
573
    add eax, 304
573
    add eax, 304
574
    dec ebx
574
    dec ebx
575
    jnz .dirskip
575
    jnz .dirskip
576
    mov eax, [directory_ptr]
576
    mov eax, [directory_ptr]
577
    pop ebx
577
    pop ebx
578
    mov [eax+4], ebx
578
    mov [eax+4], ebx
579
    test    ebx, ebx
579
    test    ebx, ebx
580
    jz  free_directory
580
    jz  free_directory
581
    push    0   ; sort mode
581
    push    0   ; sort mode
582
    push    ebx
582
    push    ebx
583
    add eax, 32
583
    add eax, 32
584
    push    eax
584
    push    eax
585
    call    [SortDir]
585
    call    [SortDir]
586
    xor eax, eax
586
    xor eax, eax
587
    mov edi, [directory_ptr]
587
    mov edi, [directory_ptr]
588
    add edi, 32 + 40
588
    add edi, 32 + 40
589
.scan:
589
.scan:
590
    mov esi, [last_name_component]
590
    mov esi, [last_name_component]
591
    push    edi
591
    push    edi
592
    invoke  strcmpi
592
    invoke  strcmpi
593
    pop edi
593
    pop edi
594
    jz  .found
594
    jz  .found
595
    inc eax
595
    inc eax
596
    add edi, 304
596
    add edi, 304
597
    dec ebx
597
    dec ebx
598
    jnz .scan
598
    jnz .scan
599
    or  eax, -1
599
    or  eax, -1
600
.found:
600
.found:
601
    mov [cur_file_idx], eax
601
    mov [cur_file_idx], eax
602
.ret:
602
.ret:
603
    ret
603
    ret
604
 
604
 
605
free_directory:
605
free_directory:
606
    mcall   68, 13, [directory_ptr]
606
    mcall   68, 13, [directory_ptr]
607
    and [directory_ptr], 0
607
    and [directory_ptr], 0
608
    ret
608
    ret
609
 
609
 
610
; in: esi->full name (e.g. /path/to/file.png)
610
; in: esi->full name (e.g. /path/to/file.png)
611
; out: [last_name_component]->last component (e.g. file.png)
611
; out: [last_name_component]->last component (e.g. file.png)
612
find_last_name_component:
612
find_last_name_component:
613
    mov ecx, esi
613
    mov ecx, esi
614
@@:
614
@@:
615
    lodsb
615
    lodsb
616
    test    al, al
616
    test    al, al
617
    jnz @b
617
    jnz @b
618
@@:
618
@@:
619
    dec esi
619
    dec esi
620
    cmp esi, ecx
620
    cmp esi, ecx
621
    jb  @f
621
    jb  @f
622
    cmp byte [esi], '/'
622
    cmp byte [esi], '/'
623
    jnz @b
623
    jnz @b
624
@@:
624
@@:
625
    inc esi
625
    inc esi
626
    mov [last_name_component], esi
626
    mov [last_name_component], esi
627
    ret
627
    ret
628
 
628
 
629
init_frame:
629
init_frame:
630
    push    eax
630
    push    eax
631
    mov eax, [image]
631
    mov eax, [image]
632
    mov [cur_frame], eax
632
    mov [cur_frame], eax
633
    test    byte [eax + Image.Flags], Image.IsAnimated
633
    test    byte [eax + Image.Flags], Image.IsAnimated
634
    jz  @f
634
    jz  @f
635
    push    ebx
635
    push    ebx
636
    mcall   26, 9
636
    mcall   26, 9
637
    pop ebx
637
    pop ebx
638
    mov [cur_frame_time], eax
638
    mov [cur_frame_time], eax
639
@@:
639
@@:
640
    pop eax
640
    pop eax
641
    ret
641
    ret
642
 
642
 
643
draw_window:
643
draw_window:
644
    cmp [bFirstDraw], 0
644
    cmp [bFirstDraw], 0
645
    jz  .posok
645
    jz  .posok
646
    or  ecx, -1
646
    or  ecx, -1
647
    mcall   9, procinfo
647
    mcall   9, procinfo
648
 
648
 
649
    cmp dword [ebx + 66], 0
649
    cmp dword [ebx + 66], 0
650
    jle .posok
650
    jle .posok
651
 
651
 
652
    mov edx, ecx
652
    mov edx, ecx
653
    mov esi, ecx
653
    mov esi, ecx
654
    cmp dword [ebx + 42], 40 + 25 * 9
654
    cmp dword [ebx + 42], 40 + 25 * 9
655
    jae @f
655
    jae @f
656
    mov edx, 40 + 25 * 9
656
    mov edx, 40 + 25 * 9
657
@@:
657
@@:
658
    cmp dword [ebx + 46], 70
658
    cmp dword [ebx + 46], 70
659
    jae @f
659
    jae @f
660
    mov esi, 70
660
    mov esi, 70
661
@@:
661
@@:
662
    mov eax, edx
662
    mov eax, edx
663
    and eax, esi
663
    and eax, esi
664
    cmp eax, -1
664
    cmp eax, -1
665
    jz  @f
665
    jz  @f
666
    mov ebx, ecx
666
    mov ebx, ecx
667
    mcall   67
667
    mcall   67
668
@@:
668
@@:
669
 
669
 
670
.posok:
670
.posok:
671
    mcall   12, 1
671
    mcall   12, 1
672
    mcall   48, 4
672
    mcall   48, 4
673
    mov ebp, eax    ; save skin height
673
    mov ebp, eax    ; save skin height
674
    add eax, [wnd_height]
674
    add eax, [wnd_height]
675
    __mov   ebx, 100, 0
675
    __mov   ebx, 100, 0
676
    add ebx, [wnd_width]
676
    add ebx, [wnd_width]
677
    lea ecx, [100*65536 + eax]
677
    lea ecx, [100*65536 + eax]
678
    mcall   0, , , 0x73FFFFFF, 0, real_header
678
    mcall   0, , , 0x73FFFFFF, 0, real_header
679
 
679
 
680
    mcall   9, procinfo, -1
680
    mcall   9, procinfo, -1
681
    mov [bFirstDraw], 1
681
    mov [bFirstDraw], 1
682
    cmp dword [ebx + 66], 0
682
    cmp dword [ebx + 66], 0
683
    jle .nodraw
683
    jle .nodraw
684
    mov ebx, [ebx + 62]
684
    mov ebx, [ebx + 62]
685
    inc ebx
685
    inc ebx
686
    mcall   13, , <0, 35>, 0xFFFFFF
686
    mcall   13, , <0, 35>, 0xFFFFFF
687
    mov ecx, [procinfo + 66]
687
    mov ecx, [procinfo + 66]
688
    inc ecx
688
    inc ecx
689
    mov esi, [draw_height]
689
    mov esi, [draw_height]
690
    add esi, 35
690
    add esi, 35
691
    sub ecx, esi
691
    sub ecx, esi
692
    jbe @f
692
    jbe @f
693
    push    esi
693
    push    esi
694
    shl esi, 16
694
    shl esi, 16
695
    add ecx, esi
695
    add ecx, esi
696
    pop esi
696
    pop esi
697
    mcall
697
    mcall
698
    xor ecx, ecx
698
    xor ecx, ecx
699
@@:
699
@@:
700
    add ecx, esi
700
    add ecx, esi
701
    add ecx, 35*10000h - 35
701
    add ecx, 35*10000h - 35
702
    __mov   ebx, 0, 5
702
    __mov   ebx, 0, 5
703
    mcall
703
    mcall
704
    mov esi, [draw_width]
704
    mov esi, [draw_width]
705
    add esi, ebx
705
    add esi, ebx
706
    mov ebx, [procinfo+62]
706
    mov ebx, [procinfo+62]
707
    inc ebx
707
    inc ebx
708
    sub ebx, esi
708
    sub ebx, esi
709
    jbe @f
709
    jbe @f
710
    shl esi, 16
710
    shl esi, 16
711
    add ebx, esi
711
    add ebx, esi
712
    mcall
712
    mcall
713
@@:
713
@@:
714
 
714
 
715
    mov ebx, [procinfo + 62]
715
    mov ebx, [procinfo + 62]
716
    push    ebx
716
    push    ebx
717
    mcall   38, , <30, 30>, 0x007F7F7F
717
    mcall   38, , <30, 30>, 0x007F7F7F
718
    mcall   , <5 + 25 * 1, 5 + 25 * 1>, <0, 30>
718
    mcall   , <5 + 25 * 1, 5 + 25 * 1>, <0, 30>
719
    mcall   , <10 + 25 * 3, 10 + 25 * 3>
719
    mcall   , <10 + 25 * 3, 10 + 25 * 3>
720
    mcall   , <15 + 25 * 4, 15 + 25 * 4>
720
    mcall   , <15 + 25 * 4, 15 + 25 * 4>
721
    pop ebx
721
    pop ebx
722
    sub ebx, 25 * 5 + 10
722
    sub ebx, 25 * 5 + 10
723
    push    ebx
723
    push    ebx
724
    imul    ebx, 10001h
724
    imul    ebx, 10001h
725
    mcall
725
    mcall
726
 
726
 
727
    mcall   8, <5 + 25 * 0, 20>, <5, 20>, 'opn'+40000000h
727
    mcall   8, <5 + 25 * 0, 20>, <5, 20>, 'opn'+40000000h
728
    mcall   , <10 + 25 * 1, 20>, , 'bck'+40000000h
728
    mcall   , <10 + 25 * 1, 20>, , 'bck'+40000000h
729
    mcall   , <10 + 25 * 2, 20>, , 'fwd'+40000000h
729
    mcall   , <10 + 25 * 2, 20>, , 'fwd'+40000000h
730
    mcall   , <15 + 25 * 3, 20>, , 'bgr'+40000000h
730
    mcall   , <15 + 25 * 3, 20>, , 'bgr'+40000000h
731
    pop ebx
731
    pop ebx
732
    add ebx, 5
732
    add ebx, 5
733
    shl ebx, 16
733
    shl ebx, 16
734
    mov bl, 20
734
    mov bl, 20
735
    mcall   , , , 'flh'+40000000h
735
    mcall   , , , 'flh'+40000000h
736
    add ebx, 25 * 65536
736
    add ebx, 25 * 65536
737
    mcall   , , , 'flv'+40000000h
737
    mcall   , , , 'flv'+40000000h
738
    add ebx, 30 * 65536
738
    add ebx, 30 * 65536
739
    mcall   , , , 'rtr'+40000000h
739
    mcall   , , , 'rtr'+40000000h
740
    add ebx, 25 * 65536
740
    add ebx, 25 * 65536
741
    mcall   , , , 'rtl'+40000000h
741
    mcall   , , , 'rtl'+40000000h
742
    add ebx, 25 * 65536
742
    add ebx, 25 * 65536
743
    mcall   , , , 'flb'+40000000h
743
    mcall   , , , 'flb'+40000000h
744
 
744
 
745
    mov ebp, (numimages-1)*20
745
    mov ebp, (numimages-1)*20
746
 
746
 
747
    mcall   65, buttons+openbtn*20, <20, 20>, <5 + 25 * 0, 5>, 8, palette
747
    mcall   65, buttons+openbtn*20, <20, 20>, <5 + 25 * 0, 5>, 8, palette
748
    mcall   , buttons+backbtn*20, , <10 + 25 * 1, 5>
748
    mcall   , buttons+backbtn*20, , <10 + 25 * 1, 5>
749
    mcall   , buttons+forwardbtn*20, , <10 + 25 * 2, 5>
749
    mcall   , buttons+forwardbtn*20, , <10 + 25 * 2, 5>
750
    mcall   , buttons+bgrbtn*20, , <15 + 25 * 3, 5>
750
    mcall   , buttons+bgrbtn*20, , <15 + 25 * 3, 5>
751
    mov edx, [procinfo + 62]
751
    mov edx, [procinfo + 62]
752
    sub edx, 25 * 5 + 4
752
    sub edx, 25 * 5 + 4
753
    shl edx, 16
753
    shl edx, 16
754
    mov dl, 5
754
    mov dl, 5
755
    mcall   , buttons+fliphorzbtn*20
755
    mcall   , buttons+fliphorzbtn*20
756
    add edx, 25 * 65536
756
    add edx, 25 * 65536
757
    mcall   , buttons+flipvertbtn*20
757
    mcall   , buttons+flipvertbtn*20
758
    add edx, 30 * 65536
758
    add edx, 30 * 65536
759
    mcall   , buttons+rotcwbtn*20
759
    mcall   , buttons+rotcwbtn*20
760
    add edx, 25 * 65536
760
    add edx, 25 * 65536
761
    mcall   , buttons+rotccwbtn*20
761
    mcall   , buttons+rotccwbtn*20
762
    add edx, 25 * 65536
762
    add edx, 25 * 65536
763
    mcall   , buttons+rot180btn*20
763
    mcall   , buttons+rot180btn*20
764
 
764
 
765
    call    draw_cur_frame
765
    call    draw_cur_frame
766
 
766
 
767
.nodraw:
767
.nodraw:
768
    mcall   12, 2
768
    mcall   12, 2
769
 
769
 
770
    ret
770
    ret
771
 
771
 
772
draw_cur_frame:
772
draw_cur_frame:
773
    push    0   ; ypos
773
    push    0   ; ypos
774
    push    0   ; xpos
774
    push    0   ; xpos
775
    mov eax, [procinfo+66]
775
    mov eax, [procinfo+66]
776
    sub eax, 34
776
    sub eax, 34
777
    push    eax ; max height
777
    push    eax ; max height
778
    mov eax, [procinfo+62]
778
    mov eax, [procinfo+62]
779
    sub eax, 4
779
    sub eax, 4
780
    push    eax ; max width
780
    push    eax ; max width
781
    push    35  ; y
781
    push    35  ; y
782
    push    5   ; x
782
    push    5   ; x
783
    push    [cur_frame]
783
    push    [cur_frame]
784
    call    [img.draw]
784
    call    [img.draw]
785
    mov eax, [image]
785
    mov eax, [image]
786
    test    [eax + Image.Flags], Image.IsAnimated
786
    test    [eax + Image.Flags], Image.IsAnimated
787
    jnz .done
787
    jnz .done
788
    cmp [eax + Image.Next], 0
788
    cmp [eax + Image.Next], 0
789
    jnz .additional_frames
789
    jnz .additional_frames
790
.done:
790
.done:
791
    ret
791
    ret
792
.additional_frames:
792
.additional_frames:
793
    mov ebx, [procinfo+62]
793
    mov ebx, [procinfo+62]
794
    sub ebx, 4
794
    sub ebx, 4
795
    jbe .done
795
    jbe .done
796
    push    5
796
    push    5
797
    pop esi
797
    pop esi
798
.afloop:
798
.afloop:
799
    sub ebx, [eax + Image.Width]
799
    sub ebx, [eax + Image.Width]
800
    jbe .done
800
    jbe .done
801
    dec ebx
801
    dec ebx
802
    jz  .done
802
    jz  .done
803
    add esi, [eax + Image.Width]
803
    add esi, [eax + Image.Width]
804
    mov eax, [eax + Image.Next]
804
    mov eax, [eax + Image.Next]
805
    push    eax
805
    push    eax
806
    inc esi
806
    inc esi
807
    push    0   ; ypos
807
    push    0   ; ypos
808
    push    0   ; xpos
808
    push    0   ; xpos
809
    mov ecx, [procinfo+66]
809
    mov ecx, [procinfo+66]
810
    sub ecx, 34
810
    sub ecx, 34
811
    push    ecx ; max height
811
    push    ecx ; max height
812
    push    ebx ; max width
812
    push    ebx ; max width
813
    push    35  ; y
813
    push    35  ; y
814
    push    esi ; x
814
    push    esi ; x
815
    push    eax ; image
815
    push    eax ; image
816
    call    [img.draw]
816
    call    [img.draw]
817
    pop eax
817
    pop eax
818
    cmp [eax + Image.Next], 0
818
    cmp [eax + Image.Next], 0
819
    jnz .afloop
819
    jnz .afloop
820
    ret
820
    ret
821
 
821
 
822
; void* __stdcall mem.Alloc(unsigned size);
822
; void* __stdcall mem.Alloc(unsigned size);
823
mem.Alloc:
823
mem.Alloc:
824
    push    ebx ecx
824
    push    ebx ecx
825
    mov ecx, [esp+12]
825
    mov ecx, [esp+12]
826
    mcall   68, 12
826
    mcall   68, 12
827
    pop ecx ebx
827
    pop ecx ebx
828
    ret 4
828
    ret 4
829
 
829
 
830
; void* __stdcall mem.ReAlloc(void* mptr, unsigned size);
830
; void* __stdcall mem.ReAlloc(void* mptr, unsigned size);
831
mem.ReAlloc:
831
mem.ReAlloc:
832
    push    ebx ecx edx
832
    push    ebx ecx edx
833
    mov edx, [esp+16]
833
    mov edx, [esp+16]
834
    mov ecx, [esp+20]
834
    mov ecx, [esp+20]
835
    mcall   68, 20
835
    mcall   68, 20
836
    pop edx ecx ebx
836
    pop edx ecx ebx
837
    ret 8
837
    ret 8
838
 
838
 
839
; void __stdcall mem.Free(void* mptr);
839
; void __stdcall mem.Free(void* mptr);
840
mem.Free:
840
mem.Free:
841
    push    ebx ecx
841
    push    ebx ecx
842
    mov ecx, [esp+12]
842
    mov ecx, [esp+12]
843
    mcall   68, 13
843
    mcall   68, 13
844
    pop ecx ebx
844
    pop ecx ebx
845
    ret 4
845
    ret 4
846
 
846
 
847
check_shortcut:
847
check_shortcut:
848
; in:   cl = scancode (from sysfn 2),
848
; in:   cl = scancode (from sysfn 2),
849
;   eax = state of modifiers (from sysfn 66.3),
849
;   eax = state of modifiers (from sysfn 66.3),
850
;   edx -> shortcut descriptor
850
;   edx -> shortcut descriptor
851
; out:  ZF set <=> fail
851
; out:  ZF set <=> fail
852
    cmp cl, [edx+4]
852
    cmp cl, [edx+4]
853
    jnz .not
853
    jnz .not
854
    push    eax
854
    push    eax
855
    mov esi, [edx]
855
    mov esi, [edx]
856
    and esi, 0xF
856
    and esi, 0xF
857
    and al, 3
857
    and al, 3
858
    call    dword [check_modifier_table+esi*4]
858
    call    dword [check_modifier_table+esi*4]
859
    test    al, al
859
    test    al, al
860
    pop eax
860
    pop eax
861
    jnz .not
861
    jnz .not
862
    push    eax
862
    push    eax
863
    mov esi, [edx]
863
    mov esi, [edx]
864
    shr esi, 4
864
    shr esi, 4
865
    and esi, 0xF
865
    and esi, 0xF
866
    shr al, 2
866
    shr al, 2
867
    and al, 3
867
    and al, 3
868
    call    dword [check_modifier_table+esi*4]
868
    call    dword [check_modifier_table+esi*4]
869
    test    al, al
869
    test    al, al
870
    pop eax
870
    pop eax
871
    jnz .not
871
    jnz .not
872
    push    eax
872
    push    eax
873
    mov esi, [edx]
873
    mov esi, [edx]
874
    shr esi, 8
874
    shr esi, 8
875
    and esi, 0xF
875
    and esi, 0xF
876
    shr al, 4
876
    shr al, 4
877
    and al, 3
877
    and al, 3
878
    call    dword [check_modifier_table+esi*4]
878
    call    dword [check_modifier_table+esi*4]
879
    test    al, al
879
    test    al, al
880
    pop eax
880
    pop eax
881
;   jnz .not
881
;   jnz .not
882
.not:
882
.not:
883
    ret
883
    ret
884
 
884
 
885
check_modifier_0:
885
check_modifier_0:
886
    setnz   al
886
    setnz   al
887
    ret
887
    ret
888
check_modifier_1:
888
check_modifier_1:
889
    setp    al
889
    setp    al
890
    ret
890
    ret
891
check_modifier_2:
891
check_modifier_2:
892
    cmp al, 3
892
    cmp al, 3
893
    setnz   al
893
    setnz   al
894
    ret
894
    ret
895
check_modifier_3:
895
check_modifier_3:
896
    cmp al, 1
896
    cmp al, 1
897
    setnz   al
897
    setnz   al
898
    ret
898
    ret
899
check_modifier_4:
899
check_modifier_4:
900
    cmp al, 2
900
    cmp al, 2
901
    setnz   al
901
    setnz   al
902
    ret
902
    ret
903
 
903
 
904
; fills real_header with window title
904
; fills real_header with window title
905
; window title is generated as ' - Kolibri Image Viewer'
905
; window title is generated as ' - Kolibri Image Viewer'
906
generate_header:
906
generate_header:
907
    push    eax
907
    push    eax
908
    mov esi, [last_name_component]
908
    mov esi, [last_name_component]
909
    mov edi, real_header
909
    mov edi, real_header
910
@@:
910
@@:
911
    lodsb
911
    lodsb
912
    test    al, al
912
    test    al, al
913
    jz  @f
913
    jz  @f
914
    stosb
914
    stosb
915
    cmp edi, real_header+256
915
    cmp edi, real_header+256
916
    jb  @b
916
    jb  @b
917
.overflow:
917
.overflow:
918
    mov dword [edi-4], '...'
918
    mov dword [edi-4], '...'
919
.ret:
919
.ret:
920
    pop eax
920
    pop eax
921
    ret
921
    ret
922
@@:
922
@@:
923
    mov esi, s_header
923
    mov esi, s_header
924
@@:
924
@@:
925
    lodsb
925
    lodsb
926
    stosb
926
    stosb
927
    test    al, al
927
    test    al, al
928
    jz  .ret
928
    jz  .ret
929
    cmp edi, real_header+256
929
    cmp edi, real_header+256
930
    jb  @b
930
    jb  @b
931
    jmp .overflow
931
    jmp .overflow
932
;-----------------------------------------------------------------------------
932
;-----------------------------------------------------------------------------
933
 
933
 
934
s_header db ' - Kolibri Image Viewer', 0
934
s_header db ' - Kolibri Image Viewer', 0
935
 
935
 
936
;-----------------------------------------------------------------------------
936
;-----------------------------------------------------------------------------
937
;-----------------------------------------------------------------------------
937
;-----------------------------------------------------------------------------
938
 
938
 
939
align 4
939
align 4
940
@IMPORT:
940
@IMPORT:
941
 
941
 
942
library             \
942
library             \
943
    libio  , 'libio.obj'  , \
943
    libio  , 'libio.obj'  , \
944
    libgfx , 'libgfx.obj' , \
944
    libgfx , 'libgfx.obj' , \
945
    libimg , 'libimg.obj' , \
945
    libimg , 'libimg.obj' , \
946
    libini , 'libini.obj' , \
946
    libini , 'libini.obj' , \
947
    sort   , 'sort.obj'   , \
947
    sort   , 'sort.obj'   , \
948
    proc_lib ,'proc_lib.obj'
948
    proc_lib ,'proc_lib.obj'
949
 
949
 
950
 
950
 
951
import  libio             , \
951
import  libio             , \
952
    libio.init , 'lib_init'   , \
952
    libio.init , 'lib_init'   , \
953
    file.size  , 'file_size'  , \
953
    file.size  , 'file_size'  , \
954
    file.open  , 'file_open'  , \
954
    file.open  , 'file_open'  , \
955
    file.read  , 'file_read'  , \
955
    file.read  , 'file_read'  , \
956
    file.close , 'file_close'
956
    file.close , 'file_close'
957
 
957
 
958
import  libgfx              , \
958
import  libgfx              , \
959
    libgfx.init   , 'lib_init'  , \
959
    libgfx.init   , 'lib_init'  , \
960
    gfx.open      , 'gfx_open'  , \
960
    gfx.open      , 'gfx_open'  , \
961
    gfx.close     , 'gfx_close' , \
961
    gfx.close     , 'gfx_close' , \
962
    gfx.pen.color , 'gfx_pen_color' , \
962
    gfx.pen.color , 'gfx_pen_color' , \
963
    gfx.line      , 'gfx_line'
963
    gfx.line      , 'gfx_line'
964
 
964
 
965
import  libimg             , \
965
import  libimg             , \
966
    libimg.init , 'lib_init'   , \
966
    libimg.init , 'lib_init'   , \
967
    img.is_img  , 'img_is_img' , \
967
    img.is_img  , 'img_is_img' , \
968
    img.to_rgb2 , 'img_to_rgb2', \
968
    img.to_rgb2 , 'img_to_rgb2', \
969
    img.decode  , 'img_decode' , \
969
    img.decode  , 'img_decode' , \
970
    img.flip    , 'img_flip'   , \
970
    img.flip    , 'img_flip'   , \
971
    img.rotate  , 'img_rotate' , \
971
    img.rotate  , 'img_rotate' , \
972
    img.destroy , 'img_destroy', \
972
    img.destroy , 'img_destroy', \
973
    img.draw    , 'img_draw'
973
    img.draw    , 'img_draw'
974
 
974
 
975
import  libini, \
975
import  libini, \
976
    ini_get_shortcut, 'ini_get_shortcut'
976
    ini_get_shortcut, 'ini_get_shortcut'
977
 
977
 
978
import  sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi'
978
import  sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi'
979
 
979
 
980
import  proc_lib, \
980
import  proc_lib, \
981
    OpenDialog_Init, 'OpenDialog_init', \
981
    OpenDialog_Init, 'OpenDialog_init', \
982
    OpenDialog_Start,'OpenDialog_start'
982
    OpenDialog_Start,'OpenDialog_start'
983
 
983
 
984
bFirstDraw  db  0
984
bFirstDraw  db  0
985
;-----------------------------------------------------------------------------
985
;-----------------------------------------------------------------------------
986
 
986
 
987
virtual at 0
987
virtual at 0
988
file 'kivicons.bmp':0xA,4
988
file 'kivicons.bmp':0xA,4
989
load offbits dword from 0
989
load offbits dword from 0
990
end virtual
990
end virtual
991
numimages = 9
991
numimages = 9
992
openbtn = 0
992
openbtn = 0
993
backbtn = 1
993
backbtn = 1
994
forwardbtn = 2
994
forwardbtn = 2
995
bgrbtn = 3
995
bgrbtn = 3
996
fliphorzbtn = 4
996
fliphorzbtn = 4
997
flipvertbtn = 5
997
flipvertbtn = 5
998
rotcwbtn = 6
998
rotcwbtn = 6
999
rotccwbtn = 7
999
rotccwbtn = 7
1000
rot180btn = 8
1000
rot180btn = 8
1001
 
1001
 
1002
palette:
1002
palette:
1003
    file 'kivicons.bmp':0x36,offbits-0x36
1003
    file 'kivicons.bmp':0x36,offbits-0x36
1004
buttons:
1004
buttons:
1005
    file 'kivicons.bmp':offbits
1005
    file 'kivicons.bmp':offbits
1006
repeat 10
1006
repeat 10
1007
y = % - 1
1007
y = % - 1
1008
z = 20 - %
1008
z = 20 - %
1009
repeat numimages*5
1009
repeat numimages*5
1010
load a dword from $ - numimages*20*20 + numimages*20*y + (%-1)*4
1010
load a dword from $ - numimages*20*20 + numimages*20*y + (%-1)*4
1011
load b dword from $ - numimages*20*20 + numimages*20*z + (%-1)*4
1011
load b dword from $ - numimages*20*20 + numimages*20*z + (%-1)*4
1012
store dword a at $ - numimages*20*20 + numimages*20*z + (%-1)*4
1012
store dword a at $ - numimages*20*20 + numimages*20*z + (%-1)*4
1013
store dword b at $ - numimages*20*20 + numimages*20*y + (%-1)*4
1013
store dword b at $ - numimages*20*20 + numimages*20*y + (%-1)*4
1014
end repeat
1014
end repeat
1015
end repeat
1015
end repeat
1016
 
1016
 
1017
inifilename db  '/sys/media/kiv.ini',0
1017
inifilename db  '/sys/media/kiv.ini',0
1018
aShortcuts  db  'Shortcuts',0
1018
aShortcuts  db  'Shortcuts',0
1019
aNext       db  'Next',0
1019
aNext       db  'Next',0
1020
aPrev       db  'Prev',0
1020
aPrev       db  'Prev',0
1021
 
1021
 
1022
align 4
1022
align 4
1023
check_modifier_table:
1023
check_modifier_table:
1024
    dd  check_modifier_0
1024
    dd  check_modifier_0
1025
    dd  check_modifier_1
1025
    dd  check_modifier_1
1026
    dd  check_modifier_2
1026
    dd  check_modifier_2
1027
    dd  check_modifier_3
1027
    dd  check_modifier_3
1028
    dd  check_modifier_4
1028
    dd  check_modifier_4
1029
 
1029
 
1030
;---------------------------------------------------------------------
1030
;---------------------------------------------------------------------
1031
align 4
1031
align 4
1032
OpenDialog_data:
1032
OpenDialog_data:
1033
.type           dd 0
1033
.type           dd 0
1034
.procinfo       dd procinfo ;+4
1034
.procinfo       dd procinfo ;+4
1035
.com_area_name      dd communication_area_name ;+8
1035
.com_area_name      dd communication_area_name ;+8
1036
.com_area       dd 0 ;+12
1036
.com_area       dd 0 ;+12
1037
.opendir_pach       dd temp_dir_pach ;+16
1037
.opendir_pach       dd temp_dir_pach ;+16
1038
.dir_default_pach   dd communication_area_default_pach ;+20
1038
.dir_default_pach   dd communication_area_default_pach ;+20
1039
.start_path     dd open_dialog_path ;+24
1039
.start_path     dd open_dialog_path ;+24
1040
.draw_window        dd draw_window ;+28
1040
.draw_window        dd draw_window ;+28
1041
.status         dd 0 ;+32
1041
.status         dd 0 ;+32
1042
.openfile_pach      dd path  ;openfile_pach ;+36
1042
.openfile_pach      dd path  ;openfile_pach ;+36
1043
.filename_area      dd 0    ;+40
1043
.filename_area      dd 0    ;+40
1044
.filter_area        dd Filter
1044
.filter_area        dd Filter
1045
.x:
1045
.x:
1046
.x_size			dw 420 ;+48 ; Window X size
1046
.x_size			dw 420 ;+48 ; Window X size
1047
.x_start		dw 10 ;+50 ; Window X position
1047
.x_start		dw 10 ;+50 ; Window X position
1048
.y:
1048
.y:
1049
.y_size			dw 320 ;+52 ; Window y size
1049
.y_size			dw 320 ;+52 ; Window y size
1050
.y_start		dw 10 ;+54 ; Window Y position
1050
.y_start		dw 10 ;+54 ; Window Y position
1051
 
1051
 
1052
communication_area_name:
1052
communication_area_name:
1053
    db 'FFFFFFFF_open_dialog',0
1053
    db 'FFFFFFFF_open_dialog',0
-
 
1054
 
1054
open_dialog_path:
1055
open_dialog_path:
-
 
1056
if __nightbuild eq yes
-
 
1057
    db '/sys/MANAGERS/opendial',0
-
 
1058
else
1055
    db '/sys/File Managers/opendial',0
1059
    db '/sys/File Managers/opendial',0
-
 
1060
end if
1056
communication_area_default_pach:
1061
communication_area_default_pach:
1057
    db '/rd/1',0
1062
    db '/rd/1',0
1058
 
1063
 
1059
Filter:
1064
Filter:
1060
dd Filter.end - Filter
1065
dd Filter.end - Filter
1061
.1:
1066
.1:
1062
db 'BMP',0
1067
db 'BMP',0
1063
db 'GIF',0
1068
db 'GIF',0
1064
db 'JPG',0
1069
db 'JPG',0
1065
db 'JPEG',0
1070
db 'JPEG',0
1066
db 'JPE',0
1071
db 'JPE',0
1067
db 'PNG',0
1072
db 'PNG',0
1068
db 'ICO',0
1073
db 'ICO',0
1069
db 'CUR',0
1074
db 'CUR',0
1070
; dunkaist [
1075
; dunkaist [
1071
db 'PCX',0
1076
db 'PCX',0
1072
; dunkaist ]
1077
; dunkaist ]
1073
.end:
1078
.end:
1074
db 0
1079
db 0
1075
 
1080
 
1076
draw_window_fake:
1081
draw_window_fake:
1077
    ret
1082
    ret
1078
;------------------------------------------------------------------------------
1083
;------------------------------------------------------------------------------
1079
readdir_fileinfo:
1084
readdir_fileinfo:
1080
    dd  1
1085
    dd  1
1081
    dd  0
1086
    dd  0
1082
    dd  0
1087
    dd  0
1083
readblocks dd   0
1088
readblocks dd   0
1084
directory_ptr   dd  0
1089
directory_ptr   dd  0
1085
;------------------------------------------------------------------------------
1090
;------------------------------------------------------------------------------
1086
I_END:
1091
I_END:
1087
curdir      rb  1024
1092
curdir      rb  1024
1088
 
1093
 
1089
align 4
1094
align 4
1090
img_data     dd ?
1095
img_data     dd ?
1091
img_data_len dd ?
1096
img_data_len dd ?
1092
fh       dd ?
1097
fh       dd ?
1093
image        dd ?
1098
image        dd ?
1094
wnd_width   dd  ?
1099
wnd_width   dd  ?
1095
wnd_height  dd  ?
1100
wnd_height  dd  ?
1096
draw_width  dd  ?
1101
draw_width  dd  ?
1097
draw_height dd  ?
1102
draw_height dd  ?
1098
last_name_component dd  ?
1103
last_name_component dd  ?
1099
cur_file_idx    dd  ?
1104
cur_file_idx    dd  ?
1100
cur_frame_time  dd  ?
1105
cur_frame_time  dd  ?
1101
cur_frame   dd  ?
1106
cur_frame   dd  ?
1102
 
1107
 
1103
next_mod    dd  ?
1108
next_mod    dd  ?
1104
next_key    dd  ?
1109
next_key    dd  ?
1105
prev_mod    dd  ?
1110
prev_mod    dd  ?
1106
prev_key    dd  ?
1111
prev_key    dd  ?
1107
 
1112
 
1108
procinfo:   rb  1024
1113
procinfo:   rb  1024
1109
path:       rb  4096  ;1024+16
1114
path:       rb  4096  ;1024+16
1110
real_header rb  256
1115
real_header rb  256
1111
@PARAMS rb 4096  ;512
1116
@PARAMS rb 4096  ;512
1112
;---------------------------------------------------------------------
1117
;---------------------------------------------------------------------
1113
temp_dir_pach:
1118
temp_dir_pach:
1114
        rb 4096
1119
        rb 4096
1115
;---------------------------------------------------------------------
1120
;---------------------------------------------------------------------
1116
    rb 4096
1121
    rb 4096
1117
stacktop:
1122
stacktop:
1118
;---------------------------------------------------------------------
1123
;---------------------------------------------------------------------
1119
F_END:
1124
F_END: