Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | 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.     mov eax,0
  16.     mov ecx,200
  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,procinfo
  25.     mov ecx,-1
  26.     int 0x40
  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,150      ; size 150 bytes
  60.     int 0x40
  61.  
  62. ; change wanted events list 7-bit IPC event
  63.     mov eax,40
  64.     mov ebx,01000111b
  65.     int 0x40
  66.  
  67. ;
  68. ; STEP 3 run SYSTEM XTREE with parameters
  69. ;
  70.  
  71.     mov eax,58
  72.     mov ebx,run_fileinfo
  73.     int 0x40
  74.  
  75.     call redproc
  76.  
  77.     mov [get_loops],0
  78. getmesloop:
  79.     mov eax,23
  80.     mov ebx,50     ;0.5 sec
  81.     int 0x40
  82.  
  83.     cmp eax,1
  84.     je  mred
  85.     cmp eax,2
  86.     je  mkey
  87.     cmp eax,3
  88.     je  mbutton
  89.     cmp eax,7
  90.     je  mgetmes
  91.  
  92. ; Get number of procces
  93.     mov ebx,procinfo
  94.     mov ecx,-1
  95.     mov eax,9
  96.     int 0x40
  97.     mov ebp,eax
  98.  
  99. loox:
  100.     mov eax,9
  101.     mov ebx,procinfo
  102.     mov ecx,ebp
  103.     int 0x40
  104.     mov eax,[DLGPID]
  105.     cmp [procinfo+30],eax    ;IF Dialog find
  106.     je  dlg_is_work          ;jmp to dlg_is_work
  107.     dec ebp
  108.     jnz loox
  109.  
  110.     jmp erroff
  111.  
  112. dlg_is_work:
  113.     cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
  114.     je  erroff                 ;TESTODP2 terminated too
  115.  
  116.     cmp [dlg_pid_get],dword 1
  117.     je  getmesloop
  118.     inc [get_loops]
  119.     cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
  120.     jae erroff
  121.     jmp getmesloop
  122.  
  123. mred:
  124.     call redproc
  125.     jmp  getmesloop
  126. mkey:
  127.     mov  eax,2
  128.     int  0x40                   ; read (eax=2)
  129.     jmp  getmesloop
  130. mbutton:
  131.     mov  eax,17                 ; get id
  132.     int  0x40
  133.     cmp  ah,1                   ; button id=1 ?
  134.     jne  getmesloop
  135.     mov  eax,-1                 ; close this program
  136.     int  0x40
  137. mgetmes:
  138.  
  139. ; If dlg_pid_get then second message get jmp to still
  140.     cmp  [dlg_pid_get],dword 1
  141.     je   ready
  142.  
  143. ; First message is number of PID SYSXTREE dialog
  144.  
  145. ; convert PID dec to PID bin
  146.     movzx eax,byte [path+16]
  147.     sub eax,48
  148.     imul eax,10
  149.     movzx ebx,byte [path+16+1]
  150.     add eax,ebx
  151.     sub eax,48
  152.     imul eax,10
  153.     movzx ebx,byte [path+16+2]
  154.     add eax,ebx
  155.     sub eax,48
  156.     imul eax,10
  157.     movzx ebx,byte [path+16+3]
  158.     add eax,ebx
  159.     sub eax,48
  160.     mov [DLGPID],eax
  161.  
  162. ; Claear and prepare IPC area for next message
  163.     mov [path],dword 0
  164.     mov [path+4],dword 8
  165.     mov [path+8],dword 0
  166.     mov [path+12],dword 0
  167.     mov [path+16],dword 0
  168.  
  169. ; Set dlg_pid_get for get next message
  170.     mov [dlg_pid_get],dword 1
  171.     call redproc   ;show DLG_PID
  172.     jmp  getmesloop
  173.  
  174. ready:
  175. ;
  176. ; The second message get
  177. ; Second message is 100 bytes path to SAVE/OPEN file
  178. ; shl path string on 16 bytes
  179. ;
  180.     cld
  181.     mov esi,path+16
  182.     mov edi,path
  183.     mov ecx,200
  184.     rep movsb
  185.     mov [edi],byte 0
  186.  
  187.     jmp openoff
  188.  
  189.  
  190. ; DATA AREA
  191. get_loops   dd 0
  192. dlg_pid_get dd 0
  193. DLGPID      dd 0
  194.  
  195. param:
  196.    dd 0    ; My dec PID
  197.    dd 0,0  ; Type of dialog
  198.  
  199. run_fileinfo:
  200.  dd 16
  201.  dd 0
  202.  dd param
  203.  dd 0
  204.  dd procinfo ; 0x10000
  205. ;run_filepath
  206.  db '/RD/1/SYSXTREE',0
  207.  
  208. procinfo:
  209. times 1024 db 0
  210. }
  211.  
  212.  
  213. macro savedialog redproc,openoff,erroff,path
  214. {
  215. local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
  216. local run_fileinfo, run_filepath, param
  217. local getmesloop, loox, mred, mkey, mbutton, mgetmes
  218. local dlg_is_work, ready, procinfo
  219. ;
  220. ; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
  221. ; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
  222. ;
  223.  
  224.     cld
  225. ;;    mov esi,path
  226.     mov edi,path
  227.     mov eax,0
  228.     mov ecx,200
  229.     rep stosb
  230.  
  231. ;mov [get_loops],0
  232. mov [dlg_pid_get],0
  233.  
  234. ; Get my PID in dec format 4 bytes
  235.     mov eax,9
  236.     mov ebx,procinfo
  237.     mov ecx,-1
  238.     int 0x40
  239.  
  240. ; convert eax bin to param dec
  241.     mov eax,dword [procinfo+30]  ;offset of myPID
  242.     mov edi,param+4-1            ;offset to 4 bytes
  243.     mov ecx,4
  244.     mov ebx,10
  245.     cld
  246. new_d:
  247.     xor edx,edx
  248.     div ebx
  249.     add dl,'0'
  250.     mov [edi],dl
  251.     dec edi
  252.     loop new_d
  253.  
  254. ; wirite 1 byte space to param
  255.     mov [param+4],byte 32    ;Space for next parametr
  256. ; and 1 byte type of dialog to param
  257.     mov [param+5],byte 'S'   ;Get Open dialog (Use 'S' for Save dialog)
  258.  
  259. ;
  260. ; STEP2 prepare IPC area for get messages
  261. ;
  262.  
  263. ; prepare IPC area
  264.     mov [path],dword 0
  265.     mov [path+4],dword 8
  266.  
  267. ; define IPC memory
  268.     mov eax,60
  269.     mov ebx,1        ; define IPC
  270.     mov ecx,path ; offset of area
  271.     mov edx,150      ; size 150 bytes
  272.     int 0x40
  273.  
  274. ; change wanted events list 7-bit IPC event
  275.     mov eax,40
  276.     mov ebx,01000111b
  277.     int 0x40
  278.  
  279. ;
  280. ; STEP 3 run SYSTEM XTREE with parameters
  281. ;
  282.  
  283.     mov eax,58
  284.     mov ebx,run_fileinfo
  285.     int 0x40
  286.  
  287.     call redproc
  288.  
  289.     mov [get_loops],0
  290. getmesloop:
  291.     mov eax,23
  292.     mov ebx,50     ;0.5 sec
  293.     int 0x40
  294.  
  295.     cmp eax,1
  296.     je  mred
  297.     cmp eax,2
  298.     je  mkey
  299.     cmp eax,3
  300.     je  mbutton
  301.     cmp eax,7
  302.     je  mgetmes
  303.  
  304. ; Get number of procces
  305.     mov ebx,procinfo
  306.     mov ecx,-1
  307.     mov eax,9
  308.     int 0x40
  309.     mov ebp,eax
  310.  
  311. loox:
  312.     mov eax,9
  313.     mov ebx,procinfo
  314.     mov ecx,ebp
  315.     int 0x40
  316.     mov eax,[DLGPID]
  317.     cmp [procinfo+30],eax    ;IF Dialog find
  318.     je  dlg_is_work          ;jmp to dlg_is_work
  319.     dec ebp
  320.     jnz loox
  321.  
  322.     jmp erroff
  323.  
  324. dlg_is_work:
  325.     cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
  326.     je  erroff                 ;TESTODP2 terminated too
  327.  
  328.     cmp [dlg_pid_get],dword 1
  329.     je  getmesloop
  330.     inc [get_loops]
  331.     cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
  332.     jae erroff
  333.     jmp getmesloop
  334.  
  335. mred:
  336.     call redproc
  337.     jmp  getmesloop
  338. mkey:
  339.     mov  eax,2
  340.     int  0x40                   ; read (eax=2)
  341.     jmp  getmesloop
  342. mbutton:
  343.     mov  eax,17                 ; get id
  344.     int  0x40
  345.     cmp  ah,1                   ; button id=1 ?
  346.     jne  getmesloop
  347.     mov  eax,-1                 ; close this program
  348.     int  0x40
  349. mgetmes:
  350.  
  351. ; If dlg_pid_get then second message get jmp to still
  352.     cmp  [dlg_pid_get],dword 1
  353.     je   ready
  354.  
  355. ; First message is number of PID SYSXTREE dialog
  356.  
  357. ; convert PID dec to PID bin
  358.     movzx eax,byte [path+16]
  359.     sub eax,48
  360.     imul eax,10
  361.     movzx ebx,byte [path+16+1]
  362.     add eax,ebx
  363.     sub eax,48
  364.     imul eax,10
  365.     movzx ebx,byte [path+16+2]
  366.     add eax,ebx
  367.     sub eax,48
  368.     imul eax,10
  369.     movzx ebx,byte [path+16+3]
  370.     add eax,ebx
  371.     sub eax,48
  372.     mov [DLGPID],eax
  373.  
  374. ; Claear and prepare IPC area for next message
  375.     mov [path],dword 0
  376.     mov [path+4],dword 8
  377.     mov [path+8],dword 0
  378.     mov [path+12],dword 0
  379.     mov [path+16],dword 0
  380.  
  381. ; Set dlg_pid_get for get next message
  382.     mov [dlg_pid_get],dword 1
  383.     call redproc   ;show DLG_PID
  384.     jmp  getmesloop
  385.  
  386. ready:
  387. ;
  388. ; The second message get
  389. ; Second message is 100 bytes path to SAVE/OPEN file
  390. ; shl path string on 16 bytes
  391. ;
  392.     cld
  393.     mov esi,path+16
  394.     mov edi,path
  395.     mov ecx,200
  396.     rep movsb
  397.     mov [edi],byte 0
  398.  
  399.     jmp openoff
  400.  
  401.  
  402. ; DATA AREA
  403. get_loops   dd 0
  404. dlg_pid_get dd 0
  405. DLGPID      dd 0
  406.  
  407. param:
  408.    dd 0  ; My dec PID
  409.    dd 0,0  ; Type of dialog
  410.  
  411. run_fileinfo:
  412.  dd 16
  413.  dd 0
  414.  dd param
  415.  dd 0
  416.  dd procinfo
  417. ;run_filepath:
  418.  db '/RD/1/SYSXTREE',0
  419.  
  420. procinfo:
  421. times 1024 db 0
  422. }
  423. ;-----------------------------------------------------------
  424.