Subversion Repositories Kolibri OS

Rev

Rev 485 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. macro opendialog redproc,openoff,erroff,path
  2. {
  3. local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
  4. local run_fileinfo, param
  5. local getmesloop, loox, mred, mkey, mbutton, mgetmes
  6. local dlg_is_work, ready
  7. ;
  8. ; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
  9. ; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
  10. ;
  11.  
  12.     cld
  13. ;;    mov esi,path
  14.     mov edi,path
  15.     xor eax,eax
  16.     mov ecx,(1024+16)/4
  17.     rep stosb
  18.  
  19. ;mov [get_loops],0
  20.     mov [dlg_pid_get],0
  21.  
  22. ; Get my PID in dec format 4 bytes
  23. ;    mov eax,9
  24. ;    mov ebx,prcinfo
  25. ;    mov ecx,-1
  26. ;    mcall
  27.     mov eax,[parentPID]
  28. ; convert eax bin to param dec
  29. ;    mov eax,dword [prcinfo+30]  ;offset of myPID
  30.     mov edi,param+4-1            ;offset to 4 bytes
  31.     mov ecx,4
  32.     mov ebx,10
  33.     cld
  34. new_d:
  35.     xor edx,edx
  36.     div ebx
  37.     add dl,'0'
  38.     mov [edi],dl
  39.     dec edi
  40.     loop new_d
  41.  
  42. ; wirite 1 byte space to param
  43.     mov [param+4],byte 32    ;Space for next parametr
  44. ; and 1 byte type of dialog to param
  45.     mov [param+5],byte 'O'   ;Get Open dialog (Use 'S' for Save dialog)
  46.  
  47. ;
  48. ; STEP2 prepare IPC area for get messages
  49. ;
  50.  
  51. ; prepare IPC area
  52.     mov [path],dword 0
  53.     mov [path+4],dword 8
  54.  
  55. ; define IPC memory
  56.     mov eax,60
  57.     mov ebx,1        ; define IPC
  58.     mov ecx,path     ; offset of area
  59.     mov edx,1024+16  ; size
  60.     mcall
  61.  
  62. ; change wanted events list 7-bit IPC event
  63.     mov eax,40
  64.     mov ebx,01000111b
  65.     mcall
  66.  
  67. ;
  68. ; STEP 3 run SYSTEM XTREE with parameters
  69. ;
  70.  
  71.     mov eax,70
  72.     mov ebx,run_fileinfo
  73.     mcall
  74.  
  75.     call redproc
  76.  
  77.     mov [get_loops],0
  78. getmesloop:
  79.     mov eax,23
  80.     mov ebx,50     ;0.5 sec
  81.     mcall
  82.         dec     eax
  83.         jz      mred
  84.         dec     eax
  85.         jz      mkey
  86.         dec     eax
  87.         jz      mbutton
  88.         cmp     al, 7-3
  89.         jz      mgetmes
  90.  
  91. ; Get number of procces
  92.     mov ebx,prcinfo
  93.     mov ecx,-1
  94.     mov eax,9
  95.     mcall
  96.     mov ebp,eax
  97.  
  98. loox:
  99.     mov eax,9
  100.     mov ebx,prcinfo
  101.     mov ecx,ebp
  102.     mcall
  103.     mov eax,[DLGPID]
  104.     cmp [prcinfo+30],eax    ;IF Dialog find
  105.     je  dlg_is_work          ;jmp to dlg_is_work
  106.     dec ebp
  107.     jnz loox
  108.  
  109.     jmp erroff
  110.  
  111. dlg_is_work:
  112.     cmp [prcinfo+50],word 9 ;If slot state 9 - dialog is terminated
  113.     je  erroff                 ;TESTODP2 terminated too
  114.  
  115.     cmp [dlg_pid_get],dword 1
  116.     je  getmesloop
  117.     inc [get_loops]
  118.     cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
  119.     jae erroff
  120.     jmp getmesloop
  121.  
  122. mred:
  123.     call redproc
  124.     jmp  getmesloop
  125. mkey:
  126.     mov  eax,2
  127.     mcall                   ; read (eax=2)
  128.     jmp  getmesloop
  129. mbutton:
  130.     mov  eax,17                 ; get id
  131.     mcall
  132.     cmp  ah,1                   ; button id=1 ?
  133.     jne  getmesloop
  134.     or  eax,-1                 ; close this program
  135.     mcall
  136. mgetmes:
  137.  
  138. ; If dlg_pid_get then second message get jmp to still
  139.     cmp  [dlg_pid_get],dword 1
  140.     je   ready
  141.  
  142. ; First message is number of PID SYSXTREE dialog
  143.  
  144. ; convert PID dec to PID bin
  145.     movzx eax,byte [path+16]
  146.     sub eax,48
  147.     imul eax,10
  148.     movzx ebx,byte [path+16+1]
  149.     add eax,ebx
  150.     sub eax,48
  151.     imul eax,10
  152.     movzx ebx,byte [path+16+2]
  153.     add eax,ebx
  154.     sub eax,48
  155.     imul eax,10
  156.     movzx ebx,byte [path+16+3]
  157.     add eax,ebx
  158.     sub eax,48
  159.     mov [DLGPID],eax
  160.  
  161. ; Claear and prepare IPC area for next message
  162.     mov [path],dword 0
  163.     mov [path+4],dword 8
  164.     mov [path+8],dword 0
  165.     mov [path+12],dword 0
  166.     mov [path+16],dword 0
  167.  
  168. ; Set dlg_pid_get for get next message
  169.     mov [dlg_pid_get],dword 1
  170.     call redproc   ;show DLG_PID
  171.     jmp  getmesloop
  172.  
  173. ready:
  174. ;
  175. ; The second message get
  176. ; Second message is 1024 bytes path to SAVE/OPEN file
  177. ; shl path string on 16 bytes
  178. ;
  179.     cld
  180.     mov esi,path+16
  181.     mov edi,path
  182.     mov ecx,1024/4
  183.     rep movsd
  184.     mov [edi],byte 0
  185.  
  186.     jmp openoff
  187.  
  188.  
  189. ; DATA AREA
  190. get_loops   dd 0
  191. dlg_pid_get dd 0
  192. DLGPID      dd 0
  193.  
  194. param:
  195.    dd 0    ; My dec PID
  196.    dd 0,0  ; Type of dialog
  197.  
  198. run_fileinfo:
  199.  dd 7
  200.  dd 0
  201.  dd param
  202.  dd 0
  203.  dd 0
  204. ;run_filepath
  205.  db '/sys/SYSXTREE',0
  206.  
  207. ;prcinfo:
  208. ;times 256 db 0
  209. }
  210.