Subversion Repositories Kolibri OS

Rev

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

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