Subversion Repositories Kolibri OS

Rev

Rev 485 | 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, procinfo
  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 stosd
  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,procinfo
  25.     or  ecx,-1
  26.     mcall
  27.  
  28. ; convert eax bin to param dec
  29.     mov eax,dword [procinfo+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,procinfo
  93.     mov ecx,-1
  94.     mov eax,9
  95.     mcall
  96.     mov ebp,eax
  97.  
  98. loox:
  99.     mov eax,9
  100.     mov ebx,procinfo
  101.     mov ecx,ebp
  102.     mcall
  103.     mov eax,[DLGPID]
  104.     cmp [procinfo+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 [procinfo+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.     mov  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 100 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. procinfo:
  208. times 1024 db 0
  209. }
  210.  
  211.  
  212. macro savedialog redproc,openoff,erroff,path
  213. {
  214. local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
  215. local run_fileinfo, run_filepath, param
  216. local getmesloop, loox, mred, mkey, mbutton, mgetmes
  217. local dlg_is_work, ready, procinfo
  218. ;
  219. ; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
  220. ; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
  221. ;
  222.  
  223.     cld
  224. ;;    mov esi,path
  225.     mov edi,path
  226.     xor eax,eax
  227.     mov ecx,(1024+16)/4
  228.     rep stosb
  229.  
  230. ;mov [get_loops],0
  231. mov [dlg_pid_get],0
  232.  
  233. ; Get my PID in dec format 4 bytes
  234.     mov eax,9
  235.     mov ebx,procinfo
  236.     mov ecx,-1
  237.     mcall
  238.  
  239. ; convert eax bin to param dec
  240.     mov eax,dword [procinfo+30]  ;offset of myPID
  241.     mov edi,param+4-1            ;offset to 4 bytes
  242.     mov ecx,4
  243.     mov ebx,10
  244.     cld
  245. new_d:
  246.     xor edx,edx
  247.     div ebx
  248.     add dl,'0'
  249.     mov [edi],dl
  250.     dec edi
  251.     loop new_d
  252.  
  253. ; wirite 1 byte space to param
  254.     mov [param+4],byte 32    ;Space for next parametr
  255. ; and 1 byte type of dialog to param
  256.     mov [param+5],byte 'S'   ;Get Open dialog (Use 'S' for Save dialog)
  257.  
  258. ;
  259. ; STEP2 prepare IPC area for get messages
  260. ;
  261.  
  262. ; prepare IPC area
  263.     mov [path],dword 0
  264.     mov [path+4],dword 8
  265.  
  266. ; define IPC memory
  267.     mov eax,60
  268.     mov ebx,1        ; define IPC
  269.     mov ecx,path     ; offset of area
  270.     mov edx,1024+16  ; size
  271.     mcall
  272.  
  273. ; change wanted events list 7-bit IPC event
  274.     mov eax,40
  275.     mov ebx,01000111b
  276.     mcall
  277.  
  278. ;
  279. ; STEP 3 run SYSTEM XTREE with parameters
  280. ;
  281.  
  282.     mov eax,70
  283.     mov ebx,run_fileinfo
  284.     mcall
  285.  
  286.     call redproc
  287.  
  288.     mov [get_loops],0
  289. getmesloop:
  290.     mov eax,23
  291.     mov ebx,50     ;0.5 sec
  292.     mcall
  293.         dec     eax
  294.         jz      mred
  295.         dec     eax
  296.         jz      mkey
  297.         dec     eax
  298.         jz      mbutton
  299.         cmp     al, 7-3
  300.         jz      mgetmes
  301.  
  302. ; Get number of procces
  303.     mov ebx,procinfo
  304.     mov ecx,-1
  305.     mov eax,9
  306.     mcall
  307.     mov ebp,eax
  308.  
  309. loox:
  310.     mov eax,9
  311.     mov ebx,procinfo
  312.     mov ecx,ebp
  313.     mcall
  314.     mov eax,[DLGPID]
  315.     cmp [procinfo+30],eax    ;IF Dialog find
  316.     je  dlg_is_work          ;jmp to dlg_is_work
  317.     dec ebp
  318.     jnz loox
  319.  
  320.     jmp erroff
  321.  
  322. dlg_is_work:
  323.     cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
  324.     je  erroff                 ;TESTODP2 terminated too
  325.  
  326.     cmp [dlg_pid_get],dword 1
  327.     je  getmesloop
  328.     inc [get_loops]
  329.     cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
  330.     jae erroff
  331.     jmp getmesloop
  332.  
  333. mred:
  334.     call redproc
  335.     jmp  getmesloop
  336. mkey:
  337.     mov  eax,2
  338.     mcall                       ; read (eax=2)
  339.     jmp  getmesloop
  340. mbutton:
  341.     mov  eax,17                 ; get id
  342.     mcall
  343.     cmp  ah,1                   ; button id=1 ?
  344.     jne  getmesloop
  345.     mov  eax,-1                 ; close this program
  346.     mcall
  347. mgetmes:
  348.  
  349. ; If dlg_pid_get then second message get jmp to still
  350.     cmp  [dlg_pid_get],dword 1
  351.     je   ready
  352.  
  353. ; First message is number of PID SYSXTREE dialog
  354.  
  355. ; convert PID dec to PID bin
  356.     movzx eax,byte [path+16]
  357.     sub eax,48
  358.     imul eax,10
  359.     movzx ebx,byte [path+16+1]
  360.     add eax,ebx
  361.     sub eax,48
  362.     imul eax,10
  363.     movzx ebx,byte [path+16+2]
  364.     add eax,ebx
  365.     sub eax,48
  366.     imul eax,10
  367.     movzx ebx,byte [path+16+3]
  368.     add eax,ebx
  369.     sub eax,48
  370.     mov [DLGPID],eax
  371.  
  372. ; Claear and prepare IPC area for next message
  373.     mov [path],dword 0
  374.     mov [path+4],dword 8
  375.     mov [path+8],dword 0
  376.     mov [path+12],dword 0
  377.     mov [path+16],dword 0
  378.  
  379. ; Set dlg_pid_get for get next message
  380.     mov [dlg_pid_get],dword 1
  381.     call redproc   ;show DLG_PID
  382.     jmp  getmesloop
  383.  
  384. ready:
  385. ;
  386. ; The second message get
  387. ; Second message is 100 bytes path to SAVE/OPEN file
  388. ; shl path string on 16 bytes
  389. ;
  390.     cld
  391.     mov esi,path+16
  392.     mov edi,path
  393.     mov ecx,1024/4
  394.     rep movsd
  395.     mov [edi],byte 0
  396.  
  397.     jmp openoff
  398.  
  399.  
  400. ; DATA AREA
  401. get_loops   dd 0
  402. dlg_pid_get dd 0
  403. DLGPID      dd 0
  404.  
  405. param:
  406.    dd 0  ; My dec PID
  407.    dd 0,0  ; Type of dialog
  408.  
  409. run_fileinfo:
  410.  dd 7
  411.  dd 0
  412.  dd param
  413.  dd 0
  414.  dd 0
  415. ;run_filepath:
  416.  db '/sys/SYSXTREE',0
  417.  
  418. procinfo:
  419. times 1024 db 0
  420. }
  421. ;-----------------------------------------------------------
  422.