Subversion Repositories Kolibri OS

Rev

Rev 1427 | Rev 1471 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1427 Rev 1470
Line 1... Line 1...
1
use32
1
use32
2
org 0x0
2
org 0x0
Line 3... Line 3...
3
 
3
 
4
db 'MENUET01'
4
db 'MENUET01'
Line 5... Line 5...
5
dd 0x01, START, I_END, 0x4000, 0x4000, @PARAMS, 0x0
5
dd 0x01, START, I_END, F_END, stacktop, @PARAMS, 0x0
Line 6... Line 6...
6
 
6
 
7
;-----------------------------------------------------------------------------
7
;-----------------------------------------------------------------------------
Line 14... Line 14...
14
include 'dll.inc'
14
include 'dll.inc'
Line 15... Line 15...
15
 
15
 
16
include '../../../develop/libraries/libs-dev/libio/libio.inc'
16
include '../../../develop/libraries/libs-dev/libio/libio.inc'
Line -... Line 17...
-
 
17
include '../../../develop/libraries/libs-dev/libimg/libimg.inc'
-
 
18
 
17
include '../../../develop/libraries/libs-dev/libimg/libimg.inc'
19
include '../../../develop/libraries/box_lib/asm/trunk/opendial.mac'
Line 18... Line 20...
18
 
20
use_OpenDialog
19
;-----------------------------------------------------------------------------
21
;-----------------------------------------------------------------------------
Line -... Line 22...
-
 
22
 
-
 
23
START:
-
 
24
	mcall	68, 11
20
 
25
 
21
START:
26
; OpenDialog initialisation
22
	mcall	68, 11
27
init_OpenDialog	OpenDialog_data
Line 23... Line 28...
23
 
28
	
Line 42... Line 47...
42
	mcall	66, 1, 1	; set kbd mode to scancodes
47
	mcall	66, 1, 1	; set kbd mode to scancodes
Line 43... Line 48...
43
 
48
 
44
	cmp	byte [@PARAMS], 0
49
	cmp	byte [@PARAMS], 0
Line -... Line 50...
-
 
50
	jnz	params_given
-
 
51
 
45
	jnz	params_given
52
	mov	[OpenDialog_data.draw_window],draw_window_fake
-
 
53
	
-
 
54
	start_OpenDialog	OpenDialog_data
46
 
55
 
-
 
56
	cmp	[OpenDialog_data.status],1
-
 
57
	jne	exit
-
 
58
 
47
	call	opendialog
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
Line 191... Line 203...
191
 
203
 
192
	; open new file
204
	; open new file
193
    @@: cmp	eax, 'opn'
205
    @@: cmp	eax, 'opn'
Line 194... Line 206...
194
	jne	@f
206
	jne	@f
195
	
207
	
196
	call	opendialog
-
 
197
	jc	still
-
 
198
	push	[image]
208
	start_OpenDialog	OpenDialog_data
199
	mov	eax, path
209
	
-
 
210
	cmp	[OpenDialog_data.status],1
200
	call	load_image
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
-
 
216
	rep	movsd
-
 
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
205
	rep	movsd
227
	call	generate_header
206
	mov	byte [edi-1], 0
228
	
-
 
229
	invoke	img.destroy
207
	invoke	img.destroy
230
	call	free_directory
-
 
231
	pop	eax ; pop for [image]
208
	call	free_directory
232
	jmp	red
209
	jmp	red
233
	
210
    .restore_old:
234
    .restore_old:
211
	pop	[image]
235
	pop	[image]
Line 886... Line 910...
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
;-----------------------------------------------------------------------------
Line 893... Line 916...
893
 
916
 
Line 894... Line 917...
894
s_header db ' - Kolibri Image Viewer', 0
917
s_header db ' - Kolibri Image Viewer', 0
895
 
-
 
896
;-----------------------------------------------------------------------------
-
 
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
918
 
Line 1090... Line 919...
1090
 
919
;-----------------------------------------------------------------------------
1091
;-----------------------------------------------------------------------------
920
;-----------------------------------------------------------------------------
Line 1173... Line 1002...
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
Line -... Line 1006...
-
 
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:
Line -... Line 1042...
-
 
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
-
 
1201
directory_ptr	dd	0
1051
readblocks dd	0
1202
 
-
 
1203
;-----------------------------------------------------------------------------
1052
directory_ptr	dd	0
1204
 
-
 
1205
I_END:
1053
;------------------------------------------------------------------------------
Line 1206... Line 1054...
1206
 
1054
I_END:
1207
curdir		rb	1024
1055
curdir		rb	1024
1208
 
1056
 
Line 1224... Line 1072...
1224
next_key	dd	?
1072
next_key	dd	?
1225
prev_mod	dd	?
1073
prev_mod	dd	?
1226
prev_key	dd	?
1074
prev_key	dd	?
Line 1227... Line 1075...
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
-
 
1231
 
1078
real_header	rb	256
-
 
1079
@PARAMS rb 4096  ;512
-
 
1080
;---------------------------------------------------------------------
-
 
1081
temp_dir_pach:
-
 
1082
        rb 4096
-
 
1083
;---------------------------------------------------------------------
-
 
1084
	rb 4096
-
 
1085
stacktop:
-
 
1086
;---------------------------------------------------------------------
1232
@PARAMS rb 512
1087
F_END: