Subversion Repositories Kolibri OS

Rev

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

  1. use32
  2.         org 0
  3.         db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
  4.         dd 1,start,i_end,mem,stacktop,openfile_path,sys_path
  5.  
  6. include '../../../../programs/macros.inc'
  7. include '../../../../programs/proc32.inc'
  8. include '../../../../programs/KOSfuncs.inc'
  9. include '../../../../programs/load_img.inc'
  10. include '../trunk/str.inc'
  11.  
  12. vox_offs_tree_table equ 4
  13. vox_offs_data equ 12
  14. txt_buf rb 8
  15. include '../trunk/vox_rotate.inc'
  16.  
  17. @use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
  18. caption db 'Voxel creator 22.03.18',0 ;¯®¤¯¨áì ®ª­ 
  19.  
  20. BUF_STRUCT_SIZE equ 21
  21. buf2d_data equ dword[edi] ;¤ ­­ë¥ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  22. buf2d_w equ dword[edi+8] ;è¨à¨­  ¡ãä¥à 
  23. buf2d_h equ dword[edi+12] ;¢ëá®â  ¡ãä¥à 
  24. buf2d_l equ word[edi+4]
  25. buf2d_t equ word[edi+6] ;®âáâ㯠ᢥàåã
  26. buf2d_size_lt equ dword[edi+4] ;®âáâ㯠᫥¢  ¨ á¯à ¢  ¤«ï ¡ãä¥à 
  27. buf2d_color equ dword[edi+16] ;梥â ä®­  ¡ãä¥à 
  28. buf2d_bits equ byte[edi+20] ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
  29.  
  30. vox_offs_tree_table equ 4
  31. vox_offs_data equ 12
  32.  
  33. run_file_70 FileInfoBlock
  34. vox_obj_size dd 0 ;à §¬¥à ¢®ªá¥«ì­®£® ®¡ê¥ªâ  (¤«ï ã᪮७¨ï ¢áâ ¢ª¨)
  35. txt_space db ' ',0
  36. txt_pref db ' ¡ ',0,' Š¡',0,' Œ¡',0,' ƒ¡',0 ;¯à¨áâ ¢ª¨: ª¨«®, ¬¥£ , £¨£ 
  37. txt_f_size: db ' §¬¥à: '
  38. .size: rb 16
  39.  
  40. IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3
  41. image_data_toolbar dd 0
  42.  
  43. max_open_file_size equ 1024*1024 ;1 Mb
  44.  
  45. align 4
  46. start:
  47.         load_libraries l_libs_start,l_libs_end
  48.         ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ¡¨¡«¨®â¥ª 
  49.         mov     ebp,lib_0
  50.         cmp     dword [ebp+ll_struc_size-4],0
  51.         jz      @f
  52.                 mcall SF_TERMINATE_PROCESS
  53.         @@:
  54.         mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
  55.         mcall SF_SET_EVENTS_MASK,0x27
  56.         stdcall [OpenDialog_Init],OpenDialog_data ;¯®¤£®â®¢ª  ¤¨ «®£ 
  57.  
  58.         stdcall [buf2d_create], buf_0 ;ᮧ¤ ­¨¥ ¡ãä¥à 
  59.         stdcall [buf2d_create], buf_0z
  60.         stdcall [buf2d_vox_brush_create], buf_vox, vox_6_7_z
  61.  
  62.         include_image_file 'toolbar.png', image_data_toolbar
  63.  
  64.         stdcall mem.Alloc,max_open_file_size
  65.         mov dword[open_file_vox],eax
  66.         stdcall mem.Alloc,max_open_file_size
  67.         mov dword[open_file_img],eax
  68.  
  69.         mcall SF_SYSTEM_GET,SSF_TIME_COUNT
  70.         mov [last_time],eax
  71.         ;¯à®¢¥àª  ª®¬ ­¤­®© áâப¨
  72.         cmp dword[openfile_path],0
  73.         je @f
  74.                 call but_open_file_cmd_lin
  75.         @@:
  76.  
  77. align 4
  78. red_win:
  79.         call draw_window
  80.  
  81. align 4
  82. still:
  83.         mcall SF_SYSTEM_GET,SSF_TIME_COUNT
  84.         mov ebx,[last_time]
  85.         add ebx,10 ;§ ¤¥à¦ª 
  86.         cmp ebx,eax
  87.         jge @f
  88.                 mov ebx,eax
  89.         @@:
  90.         sub ebx,eax
  91.         mcall SF_WAIT_EVENT_TIMEOUT
  92.         cmp eax,0
  93.         je timer_funct
  94.  
  95.         cmp al,1
  96.         jz red_win
  97.         cmp al,2
  98.         jz key
  99.         cmp al,3
  100.         jz button
  101.  
  102.         jmp still
  103.  
  104. align 4
  105. timer_funct:
  106.         cmp byte[calc],0
  107.         je still
  108.  
  109.         pushad
  110.         mcall SF_SYSTEM_GET,SSF_TIME_COUNT
  111.         mov [last_time],eax
  112.  
  113.         ; ᪨¤ë¢ ¥¬ 㪠§ â¥«¨ ¡ãä¥à®¢ buf_npl_p, buf_npl, buf_npl_n
  114.         mov edi,buf_npl_p
  115.         mov eax,buf2d_data
  116.         mov edi,buf_npl
  117.         mov ebx,buf2d_data
  118.         mov edi,buf_npl_n
  119.         mov ecx,buf2d_data
  120.         ; change buffer data pointers
  121.         mov buf2d_data,eax
  122.         mov edi,buf_npl_p
  123.         mov buf2d_data,ebx
  124.         mov edi,buf_npl
  125.         mov buf2d_data,ecx
  126.  
  127.         mov eax,[n_plane]
  128.         mov ebx,buf2d_w
  129.         dec ebx
  130.  
  131.         cmp ebx,eax
  132.         jg @f
  133.                 stdcall create_obj_from_plane,buf_npl,eax ;ᮧ¤ ¥¬ § ¢¥àè î饥 á¥ç¥­¨¥
  134.                 ;¢ë¢®¤ ª®­¥ç­®£® १ã«ìâ â 
  135.                 call draw_object
  136.                 mov byte[calc],0
  137.                 jmp .end_f
  138.         @@:
  139.  
  140.         inc eax
  141.         stdcall create_plane, buf_npl_n,eax
  142.  
  143.         ; ᮧ¤ ­¨¥ ¢®áª¥«ì­®£® á¥ç¥­¨ï ­  ®á­®¢¥ ¡ãä¥à  buf_npl
  144.         mov edi,buf_npl
  145.         mov edx,[bby_min] ;0
  146.         .cycle_0:
  147.         mov ecx,[btx_min] ;0
  148.         .cycle_1:
  149.                 stdcall [buf2d_get_pixel], edi,ecx,edx
  150.                 cmp eax,buf2d_color
  151.                 je @f
  152.                         mov esi,eax
  153.                         call need_node
  154.                         cmp eax,buf2d_color
  155.                         jne @f ;®âᥨ¢ ¥¬ ¢­ãâ७­¨¥ ¢®ªá¥«¨, ¤«ï ®¯â¨¬¨§ æ¨¨ ¬®¤¥«¨
  156.                         mov eax,ebx
  157.                         sub eax,edx
  158.                         stdcall buf2d_vox_obj_create_node, [open_file_vox],ecx,[n_plane],\
  159.                                 eax,[k_scale],esi
  160.                 @@:
  161.                 inc ecx
  162.                 cmp ecx,ebx
  163.                 jle .cycle_1
  164.                 inc edx
  165.                 cmp edx,ebx
  166.                 jle .cycle_0
  167.  
  168.         stdcall [buf2d_draw], buf_npl
  169.         inc dword[n_plane] ;¯¥à¥¬¥é ¥¬ ¯«®áª®áâì á¥ç¥­¨ï
  170.         call draw_pok
  171.         .end_f:
  172.         popad
  173.         jmp still
  174.  
  175. align 4
  176. proc create_plane, buf_img:dword, n_plane:dword
  177.         pushad
  178.         ; ª®¯¨à㥬 «¨æ¥¢®¥ ¨§®¡à ¦¥­¨¥ ¢ ¡ãä¥à buf_img
  179.         ; bby_min - ¨á¯®«ì§ã¥¬ ¤«ï ®¯â¨¬¨§ æ¨¨ (¥á«¨ ᢥàåã ¨§®¡à ¦¥­¨¥ ¯ãá⮥)
  180.         mov eax,[bby_min]
  181.         mov esi,buf_i2
  182.         mov esi,[esi] ;buf2d_data
  183.         mov edi,[buf_img]
  184.         mov ecx,buf2d_w
  185.         imul eax,ecx
  186.         mov ebx,ecx
  187.         imul ecx,ebx
  188.         sub ecx,eax
  189.         lea ecx,[ecx+ecx*2]
  190.         mov edi,buf2d_data
  191.         lea eax,[eax+eax*2]
  192.         add edi,eax
  193.         add esi,eax
  194.         cld
  195.         rep movsb
  196.  
  197.         mov ecx,ebx
  198.         dec ebx
  199.         mov edi,buf_i0
  200.         .cycle_0:
  201.                 mov eax,ebx
  202.                 sub eax,[n_plane] ;eax - ¯¥à¥¢¥à­ãâ ï ª®®à¤¨­ â  n_plane
  203.                 stdcall [buf2d_get_pixel], edi,ecx,eax ;[n_plane]
  204.                 cmp eax,buf2d_color
  205.                 jne @f
  206.                         ;¢ëç¥àª¨¢ ­¨¥ ¢¥à⨪ «ì­®© «¨­¨¨ ¨§ á¥ç¥­¨ï buf_img
  207.                         stdcall [buf2d_line], [buf_img],ecx,[bby_min],ecx,ebx, buf2d_color
  208.                         jmp .end_1
  209.                 @@:
  210.                         mov edx,[bby_min] ;xor edx,edx
  211.                         mov esi,eax
  212.                         .cycle_1: ;横« ¤«ï ­ «®¦¥­¨ï ¢¥àå­¥© ⥪áâãàë
  213.                         stdcall [buf2d_get_pixel], [buf_img],ecx,edx
  214.                         cmp eax, buf2d_color
  215.                         je .end_0
  216.                                 stdcall [buf2d_set_pixel], [buf_img],ecx,edx, esi ;­ «®¦¥­¨¥ ¢¥àå­¥© ⥪áâãàë
  217.                                 jmp .end_1
  218.                         .end_0:
  219.                         inc edx
  220.                         cmp edx,ebx
  221.                         jle .cycle_1
  222.                 .end_1:
  223.                 loop .cycle_0
  224.  
  225.         ;£®à¨§®­â «ì­ë¥ «¨­¨¨ ­  ®á­®¢¥ ¡®ª®¢®© £à ­¨
  226.         mov ecx,[bby_min]
  227.         mov edi,buf_i1
  228.         .cycle_2:
  229.                 stdcall [buf2d_get_pixel], edi,[n_plane],ecx
  230.                 cmp eax,buf2d_color
  231.                 jne @f
  232.                         ;¢ëç¥àª¨¢ ­¨¥ £®à¨§®­â «ì­®© «¨­¨¨ ¨§ á¥ç¥­¨ï buf_img
  233.                         stdcall [buf2d_line], [buf_img],[btx_min],ecx,[btx_max],ecx, buf2d_color
  234.                         jmp .end_3
  235.                 @@:
  236.                         mov edx,[btx_max] ;ebx
  237.                         mov esi,eax
  238.                         .cycle_3: ;横« ¤«ï ­ «®¦¥­¨ï ¡®ª®¢®© ⥪áâãàë
  239.                         stdcall [buf2d_get_pixel], [buf_img],edx,ecx
  240.                         cmp eax, buf2d_color
  241.                         je .end_2
  242.                                 stdcall [buf2d_set_pixel], [buf_img],edx,ecx, esi ;­ «®¦¥­¨¥ ¡®ª®¢®© ⥪áâãàë
  243.                                 jmp .end_3
  244.                         .end_2:
  245.                         dec edx
  246.                         cmp edx,[btx_min]
  247.                         jge .cycle_3
  248.                 .end_3:
  249.                 inc ecx
  250.                 cmp ecx,ebx
  251.                 jle .cycle_2
  252.         popad
  253.         ret
  254. endp
  255.  
  256. align 4
  257. proc create_obj_from_plane, buf_img:dword, n_plane:dword
  258. pushad
  259.         ; ᮧ¤ ­¨¥ ¢®áª¥«ì­®£® á¥ç¥­¨ï ­  ®á­®¢¥ ¡ãä¥à  buf_img
  260.         mov edi,[buf_img]
  261.         mov ebx,buf2d_w
  262.         dec ebx
  263.         mov edx,[bby_min] ;0
  264.         .cycle_0:
  265.         mov ecx,[btx_min] ;0
  266.         .cycle_1:
  267.                 stdcall [buf2d_get_pixel], edi,ecx,edx
  268.                 cmp eax,buf2d_color
  269.                 je @f
  270.                         mov esi,eax
  271.                         ;call need_node
  272.                         ;cmp eax,buf2d_color
  273.                         ;jne @f ;®âᥨ¢ ¥¬ ¢­ãâ७­¨¥ ¢®ªá¥«¨, ¤«ï ®¯â¨¬¨§ æ¨¨ ¬®¤¥«¨
  274.                         mov eax,ebx
  275.                         sub eax,edx
  276.                         stdcall buf2d_vox_obj_create_node, [open_file_vox],ecx,[n_plane],\
  277.                                 eax,[k_scale],esi
  278.                 @@:
  279.                 inc ecx
  280.                 cmp ecx,ebx
  281.                 jle .cycle_1
  282.                 inc edx
  283.                 cmp edx,ebx
  284.                 jle .cycle_0
  285.         ret
  286. popad
  287. endp
  288.  
  289. ;description:
  290. ; äã­ªæ¨ï ¯à®¢¥àï¥â ­ã¦­® «¨ ®âᥨ¢ âì ¢®ªá¥«ì á ª®®à¤¨­ â ¬¨ [n_plane],ecx,edx
  291. ;input:
  292. ; ebx = max size y - 1
  293. ;output:
  294. ; eax = buf2d_color if node need
  295. align 4
  296. need_node:
  297.         mov eax,buf2d_color
  298.         cmp ecx,[btx_min] ;0
  299.         jle .end_f
  300.         cmp ecx,[btx_max] ;0
  301.         jge .end_f
  302.         cmp edx,[bby_min] ;0
  303.         jle .end_f
  304.         cmp edx,ebx ;max-1
  305.         jge .end_f
  306.                 push ecx edx
  307.                 stdcall [buf2d_get_pixel], buf_npl_p,ecx,edx ;¯à®¢¥àª  ¯à¥¤ë¤ã饣® á¥ç¥­¨ï
  308.                 cmp eax,buf2d_color
  309.                 je @f
  310.                 stdcall [buf2d_get_pixel], buf_npl_n,ecx,edx ;¯à®¢¥àª  ¯®á«¥¤ãî饣® á¥ç¥­¨ï
  311.                 cmp eax,buf2d_color
  312.                 je @f
  313.                 dec ecx
  314.                 stdcall [buf2d_get_pixel], edi,ecx,edx
  315.                 cmp eax,buf2d_color
  316.                 je @f
  317.                 add ecx,2
  318.                 stdcall [buf2d_get_pixel], edi,ecx,edx
  319.                 cmp eax,buf2d_color
  320.                 je @f
  321.                 dec ecx
  322.                 dec edx
  323.                 stdcall [buf2d_get_pixel], edi,ecx,edx
  324.                 cmp eax,buf2d_color
  325.                 je @f
  326.                 add edx,2
  327.                 stdcall [buf2d_get_pixel], edi,ecx,edx
  328.                 ;cmp eax,buf2d_color
  329.                 ;je @f
  330.                 @@:
  331.                 pop edx ecx
  332.         .end_f:
  333.         ret
  334.  
  335. align 4
  336. draw_window:
  337. pushad
  338.         mcall SF_REDRAW,SSF_BEGIN_DRAW
  339.  
  340.         ; *** à¨á®¢ ­¨¥ £« ¢­®£® ®ª­  (¢ë¯®«­ï¥âáï 1 à § ¯à¨ § ¯ã᪥) ***
  341.         mov edx,[sc.work]
  342.         or  edx,(3 shl 24)+0x30000000
  343.         mcall SF_CREATE_WINDOW,(20 shl 16)+410,(20 shl 16)+520,,,caption
  344.  
  345.         ; *** ᮧ¤ ­¨¥ ª­®¯®ª ­  ¯ ­¥«ì ***
  346.         mov esi,[sc.work_button]
  347.         mcall SF_DEFINE_BUTTON,(5 shl 16)+20,(5 shl 16)+20,3
  348.  
  349.         mov ebx,(30 shl 16)+20
  350.         mov edx,4
  351.         int 0x40
  352.  
  353.         mov ebx,(55 shl 16)+20
  354.         mov edx,5
  355.         int 0x40
  356.  
  357.         mov ebx,(85 shl 16)+20
  358.         mov edx,6
  359.         int 0x40
  360.  
  361.         add ebx,25 shl 16
  362.         mov edx,7
  363.         int 0x40
  364.  
  365.         add ebx,25 shl 16
  366.         mov edx,8
  367.         int 0x40
  368.  
  369.         add ebx,25 shl 16
  370.         mov edx,9
  371.         int 0x40
  372.  
  373.         add ebx,25 shl 16
  374.         mov edx,10
  375.         int 0x40
  376.  
  377.         add ebx,25 shl 16
  378.         mov edx,11
  379.         int 0x40
  380.  
  381.         add ebx,25 shl 16
  382.         mov edx,12
  383.         int 0x40
  384.  
  385.         ; *** à¨á®¢ ­¨¥ ¨ª®­®ª ­  ª­®¯ª å ***
  386.         mov edx,(7 shl 16)+7 ;icon new
  387.         mcall SF_PUT_IMAGE,[image_data_toolbar],(16 shl 16)+16
  388.  
  389.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  390.         add edx,(25 shl 16) ;icon open
  391.         int 0x40
  392.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  393.         add edx,(25 shl 16) ;icon save
  394.         int 0x40
  395.  
  396.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  397.         add edx,(30 shl 16) ;
  398.         int 0x40
  399.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  400.         add edx,(25 shl 16) ;
  401.         int 0x40
  402.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  403.         add edx,(25 shl 16) ;
  404.         int 0x40
  405.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  406.         add edx,(25 shl 16) ;
  407.         int 0x40
  408.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  409.         add edx,(25 shl 16) ;
  410.         int 0x40
  411.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  412.         add edx,(25 shl 16) ;
  413.         int 0x40
  414.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  415.         add edx,(25 shl 16) ;
  416.         int 0x40
  417.  
  418.         call draw_buffers
  419.         call draw_pok
  420.  
  421.         mcall SF_REDRAW,SSF_END_DRAW
  422. popad
  423.         ret
  424.  
  425. align 4
  426. draw_buffers:
  427.         ; *** à¨á®¢ ­¨¥ ¡ãä¥à  ***
  428.         stdcall [buf2d_draw], buf_0
  429.         stdcall [buf2d_draw], buf_i0
  430.         stdcall [buf2d_draw], buf_i1
  431.         stdcall [buf2d_draw], buf_i2
  432.         ret
  433.  
  434. align 4
  435. draw_pok:
  436.         ;®¡­®¢«¥­¨¥ ¯®¤¯¨á¨ à §¬¥à  ä ©« 
  437.         mov edi,txt_f_size.size
  438.         mov eax,dword[vox_obj_size]
  439.         mov ebx,txt_pref
  440.         .cycle:
  441.                 cmp eax,1024
  442.                 jl @f
  443.                 shr eax,10
  444.                 add ebx,4
  445.                 jmp .cycle
  446.         @@:
  447.  
  448.         stdcall convert_int_to_str, 16
  449.         stdcall str_cat, edi,ebx
  450.         stdcall str_cat, edi,txt_space ;§ ¢¥àè î騩 ¯à®¡¥«
  451.  
  452.         ;à¨á®¢ ­¨¥ ⥪áâ 
  453.         mov ecx,[sc.work_text]
  454.         or  ecx,0x80000000 or (1 shl 30)
  455.         mov edi,[sc.work] ;梥â ä®­  ®ª­ 
  456.         mcall SF_DRAW_TEXT,(275 shl 16)+7,,txt_f_size
  457.  
  458.         ret
  459.  
  460. align 4
  461. key:
  462.         mcall SF_GET_KEY
  463.         jmp still
  464.  
  465.  
  466. align 4
  467. button:
  468.         mcall SF_GET_BUTTON
  469.         cmp ah,3
  470.         jne @f
  471.                 call but_new_file
  472.         @@:
  473.         cmp ah,4
  474.         jne @f
  475.                 call but_open_file
  476.         @@:
  477.         cmp ah,5
  478.         jne @f
  479.                 call but_save_file
  480.         @@:
  481.         cmp ah,6
  482.         jne @f
  483.                 call but_1
  484.         @@:
  485.         cmp ah,7
  486.         jne @f
  487.                 call but_2
  488.         @@:
  489.         cmp ah,8
  490.         jne @f
  491.                 call but_3
  492.         @@:
  493.         cmp ah,9
  494.         jne @f
  495.                 stdcall but_run, 0
  496.         @@:
  497.         cmp ah,10
  498.         jne @f
  499.                 stdcall but_run, 1
  500.         @@:
  501.         cmp ah,11
  502.         jne @f
  503.                 call but_5
  504.         @@:
  505.         cmp ah,12
  506.         jne @f
  507.                 call but_rot_z
  508.         @@:
  509.         cmp ah,1
  510.         jne still
  511. .exit:
  512.         stdcall [buf2d_delete],buf_0
  513.         stdcall [buf2d_delete],buf_0z
  514.         stdcall [buf2d_vox_brush_delete],buf_vox
  515.         stdcall [buf2d_delete],buf_i0
  516.         stdcall [buf2d_delete],buf_i1
  517.         stdcall [buf2d_delete],buf_i2
  518.         stdcall [buf2d_delete],buf_npl_p
  519.         stdcall [buf2d_delete],buf_npl
  520.         stdcall [buf2d_delete],buf_npl_n
  521.         stdcall mem.Free,[image_data_toolbar]
  522.         stdcall mem.Free,[open_file_vox]
  523.         stdcall mem.Free,[open_file_img]
  524.         mcall SF_TERMINATE_PROCESS
  525.  
  526.  
  527. align 4
  528. vox_new_data:
  529.         db 2,0,0,0
  530.         db 000b,001b,010b,011b, 100b,101b,110b,111b ;default table
  531.         dd 0 ;null node
  532.  
  533. align 4
  534. proc but_new_file uses ecx edi esi
  535.         mov ecx,vox_offs_data+4
  536.         mov [vox_obj_size],ecx
  537.         mov esi,vox_new_data
  538.         mov edi,[open_file_vox]
  539.         cld
  540.         rep movsb
  541.         ret
  542. endp
  543.  
  544. align 4
  545. open_file_vox dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï ®âªàëâ¨ï ä ©«®¢
  546. open_file_img dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï ®âªàëâ¨ï ⥪áâãà
  547.  
  548. align 4
  549. but_open_file:
  550.         pushad
  551.         copy_path open_dialog_name,communication_area_default_path,file_name,0
  552.         mov [OpenDialog_data.type],0
  553.         stdcall [OpenDialog_Start],OpenDialog_data
  554.         cmp [OpenDialog_data.status],2
  555.         je @f
  556.                 ;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
  557.                 call but_open_file_cmd_lin
  558.         @@:
  559. popad
  560.         ret
  561.  
  562. align 4
  563. but_open_file_cmd_lin:
  564. pushad
  565.         mov [run_file_70.Function], SSF_READ_FILE
  566.         mov [run_file_70.Position], 0
  567.         mov [run_file_70.Flags], 0
  568.         mov [run_file_70.Count], dword max_open_file_size
  569.         m2m [run_file_70.Buffer],dword[open_file_vox]
  570.         mov byte[run_file_70+20], 0
  571.         mov dword[run_file_70.FileName], openfile_path
  572.         mcall SF_FILE,run_file_70
  573.         cmp ebx,0xffffffff
  574.         je .end_open_file
  575.                 ; ¯à®¢¥àª  ­  ¯à ¢¨«ì­®áâì ¢®ªá¥«ì­®£® ä®à¬ â 
  576.                 mov edi,[open_file_vox]
  577.                 add edi,vox_offs_tree_table
  578.                 xor bx,bx
  579.                 mov ecx,8
  580.                 cld
  581.                 @@:
  582.                         movzx ax,byte[edi]
  583.                         add bx,ax
  584.                         inc edi
  585.                         loop @b
  586.                 cmp bx,28 ;28=0+1+2+...+7
  587.                 jne .err_open
  588.  
  589.                 mcall SF_SET_CAPTION,1,openfile_path
  590.                 stdcall buf2d_vox_obj_get_size,[open_file_vox]
  591.                 mov [vox_obj_size],eax
  592.                 call draw_object
  593.                
  594.                 jmp .end_open_file
  595.         .err_open:
  596.                 call but_new_file
  597.                 stdcall [mb_create],msgbox_4,thread
  598.         .end_open_file:
  599.         popad
  600.         ret
  601.  
  602. align 4
  603. but_save_file:
  604.         pushad
  605.                 copy_path open_dialog_name,communication_area_default_path,file_name,0
  606.                 mov [OpenDialog_data.type],1
  607.                 stdcall [OpenDialog_Start],OpenDialog_data
  608.                 cmp [OpenDialog_data.status],2
  609.                 je .end_save_file
  610.                 ;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
  611.  
  612.                 mov eax,6 ;dword[v_zoom] ;§ ¤ ¥¬ ¬ áèâ ¡ ¯® 㬮«ç ­¨î
  613.                 mov ebx,[open_file_vox]
  614.                 mov byte[ebx],al
  615.  
  616.                 stdcall buf2d_vox_obj_get_size, ebx
  617.                 mov dword[run_file_70.Count], eax ;à §¬¥à ä ©« 
  618.                 mov [run_file_70.Function], SSF_CREATE_FILE
  619.                 mov [run_file_70.Position], 0
  620.                 mov [run_file_70.Flags], 0
  621.                 mov ebx, dword[open_file_vox]
  622.                 mov [run_file_70.Buffer], ebx
  623.                 mov byte[run_file_70+20], 0
  624.                 mov dword[run_file_70.FileName], openfile_path
  625.                 mcall SF_FILE,run_file_70
  626.                 cmp ebx,0xffffffff
  627.                 je .end_save_file
  628.  
  629.                 .end_save_file:
  630.         popad
  631.         ret
  632.  
  633. align 4
  634. but_1:
  635.         stdcall open_image_in_buf, buf_i0
  636.         ret
  637.  
  638. align 4
  639. but_2:
  640.         stdcall open_image_in_buf, buf_i1
  641.         call set_buf_tabs
  642.         ret
  643.  
  644. align 4
  645. but_3:
  646.         stdcall open_image_in_buf, buf_i2
  647.         call set_buf_tabs
  648.         ret
  649.  
  650. ;description:
  651. ; ¢ § ¢¨á¨¬®á⨠®â è¨à¨­ë 1-£® ¡ãä¥à  ãáâ ­ ¢«¨¢ ¥¬ ®âáâã¯ë ¤«ï 2-£® ¨ 3-£® ¡ãä¥à®¢
  652. align 4
  653. set_buf_tabs:
  654. push eax ebx edi
  655.         mov edi,buf_i0
  656.         cmp buf2d_data,0
  657.         je @f
  658.                 movzx eax,buf2d_l
  659.                 mov ebx,buf2d_w
  660.                 cmp ebx,128
  661.                 jle .end_0
  662.                         mov ebx,128
  663.                 .end_0:
  664.                 mov edi,buf_i1
  665.                 mov buf2d_l,ax
  666.                 add buf2d_l,bx
  667.                 add buf2d_l,2
  668.                 shl ebx,1
  669.                 mov edi,buf_i2
  670.                 mov buf2d_l,ax
  671.                 add buf2d_l,bx
  672.                 add buf2d_l,4
  673.         @@:    
  674. pop edi ebx eax
  675.         ret
  676.  
  677. align 4
  678. get_scale:
  679. push eax edi
  680.         mov edi,buf_i0
  681.         mov eax,buf2d_w
  682.  
  683.         mov dword[k_scale],-1
  684.         .cycle_s:
  685.         cmp eax,0
  686.         je @f
  687.                 shr eax,1
  688.                 inc dword[k_scale]
  689.                 jmp .cycle_s
  690.         @@:
  691. pop edi eax
  692.         ret
  693.  
  694. align 4
  695. proc set_borders uses eax ebx ecx edx edi
  696.         mov ecx,dword[k_scale]
  697.         mov edx,1
  698.         shl edx,cl
  699.  
  700.         ;®¯à¥¤¥«ï¥¬ ¬¨­¨¬ «ì­ãî ª®®à¤¨­ âã y ­  «¨æ¥¢®© £à ­¨
  701.         mov edi,buf_i2
  702.         mov dword[bby_min],0
  703.         xor ecx,ecx
  704.         .cycle_0:
  705.         xor ebx,ebx
  706.         .cycle_1:
  707.                 stdcall [buf2d_get_pixel],edi,ebx,ecx
  708.                 cmp eax,buf2d_color
  709.                 jne @f
  710.                 inc ebx
  711.                 cmp ebx,edx
  712.                 jl .cycle_1
  713.                 inc dword[bby_min]
  714.                 inc ecx
  715.                 cmp ecx,edx
  716.                 jl .cycle_0
  717.         @@:
  718.  
  719.         ;®¯à¥¤¥«ï¥¬ ¬¨­¨¬ «ì­ãî ª®®à¤¨­ âã x ­  «¨æ¥¢®© £à ­¨
  720.         mov dword[btx_min],0
  721.         xor ebx,ebx
  722.         .cycle_2:
  723.         mov ecx,[bby_min]
  724.         .cycle_3:
  725.                 stdcall [buf2d_get_pixel],edi,ebx,ecx
  726.                 cmp eax,buf2d_color
  727.                 jne @f
  728.                 inc ecx
  729.                 cmp ecx,edx
  730.                 jl .cycle_3
  731.                 inc dword[btx_min]
  732.                 inc ebx
  733.                 cmp ebx,edx
  734.                 jl .cycle_2
  735.         @@:
  736.  
  737.         ;®¯à¥¤¥«ï¥¬ ¬ ªá¨¬ «ì­ãî ª®®à¤¨­ âã x ­  «¨æ¥¢®© £à ­¨
  738.         mov [btx_max],edx
  739.         dec dword[btx_max]
  740.         mov ebx,[btx_max]
  741.         .cycle_4:
  742.         mov ecx,[bby_min]
  743.         .cycle_5:
  744.                 stdcall [buf2d_get_pixel],edi,ebx,ecx
  745.                 cmp eax,buf2d_color
  746.                 jne @f
  747.                 inc ecx
  748.                 cmp ecx,edx
  749.                 jl .cycle_5
  750.                 dec dword[btx_max]
  751.                 dec ebx
  752.                 cmp ebx,[btx_min]
  753.                 jg .cycle_4
  754.         @@:
  755.        
  756.         ;stdcall [buf2d_line], edi, 0,[bby_min],50,[bby_min],255
  757.         ret
  758. endp
  759.  
  760. align 4
  761. btx_min dd 0 ;¡ãä¥à ¢¥àå­¨© ¬¨­. x
  762. btx_max dd 0
  763. bty_min dd 0 ;¡ãä¥à ¢¥àå­¨© ¬¨­. y
  764. bty_max dd 0
  765. ;bbx_min dd 0
  766. ;bbx_max dd 0
  767. bby_min dd 0 ;¡ãä¥à ¡®ª®¢®© ¬¨­. y
  768. bby_max dd 0
  769. k_scale dd 0
  770. n_plane dd 0
  771.  
  772. calc db 0
  773.  
  774. ; ᮧ¤ ­¨¥ ¢®ªá¥«ï ¢ 3 íâ ¯ :
  775. ; 1) ¨é¥¬ ¬¥áâ® ¢ áâàãªâãॠ¤¥à¥¢ , ªã¤  ­ ¤® ¢áâ ¢¨âì (¥á«¨ ¢¥â¢ì áãé¥áâ¢ã¥â, 2-© íâ ¯ ¯à®¯ã᪠¥¬)
  776. ; 2) ¢áâ ¢«ï¥¬ ­®¢ãî ¢¥â¢ì á ¢®ªá¥«¥¬ (3-© íâ ¯ 㦥 ­¥ ¤¥« ¥¬)
  777. ; 3) ¬¥­ï¥¬ 梥⠢®ªá¥«ï
  778. align 4
  779. proc buf2d_vox_obj_create_node, v_obj:dword,coord_x:dword,coord_y:dword,\
  780. coord_z:dword,k_scale:dword,color:dword
  781. pushad
  782. locals
  783.         p_node dd 0 ;த¨â¥«ì᪨© 㧥«
  784. endl
  785.  
  786.         mov edi,[v_obj]
  787.         add edi,vox_offs_data
  788.         mov esi,[k_scale]
  789.         cmp esi,1
  790.         jl .change
  791.         ; *** (1) ***
  792.         .found:
  793.         stdcall vox_obj_get_node_position, [v_obj],[coord_x],[coord_y],[coord_z],esi
  794.         movzx bx,byte[edi+3]
  795.         mov [p_node],edi
  796.         add edi,4
  797.  
  798.         cmp eax,0
  799.         je .end_1
  800.         mov ecx,eax
  801.         cld
  802.         @@: ;横« ¤«ï ¯à®¯ã᪠ ¯à¥¤ë¤ãé¨å ¯®¤¤¥à¥¢ì¥¢ ¢ 㧫¥
  803.                 bt bx,0 ;¯à®¢¥à塞 ¥áâì «¨ ¤®ç¥à­¨¥ 㧫ë
  804.                 jnc .end_0
  805.                         xor eax,eax
  806.                         stdcall vox_obj_rec0 ;¢ eax ¢ëç¨á«ï¥âáï ç¨á«® ¤®ç¥à­¨å 㧫®¢, ¢ ¤ ­­®© ¢¥â¢¨
  807.                 .end_0:
  808.                 shr bx,1
  809.                 loop @b
  810.         .end_1:
  811.         bt bx,0
  812.         jnc .creat ;¥á«¨ ¯®¤¤¥à¥¢  ­¥ áãé¥áâ¢ã¥â, ¯¥à¥å®¤¨¬ ª ᮧ¤ ­¨î
  813.         dec esi
  814.         cmp esi,0
  815.         jg .found
  816.         jmp .change
  817.  
  818.         ; *** (2) ***
  819.         .creat:
  820.         mov edx,[color] ;¬¥­ï¥¬ 梥â
  821.         and edx,0xffffff ;¤«ï ¯à®ä¨« ªâ¨ª¨
  822.         mov ecx,esi
  823.         stdcall vox_obj_add_nodes_mem, [v_obj],edi,ecx ;à áè¨à塞 ¬¥áâ® § ­¨¬ ¥¬®¥ ®¡ê¥ªâ®¬, ¤«ï ¤®¡ ¢«¥­¨ï ­®¢ëå 㧫®¢
  824.         mov ebx,[p_node]
  825.         cld
  826.         @@:
  827.                 mov dword[edi],edx
  828.                 stdcall vox_obj_get_node_bit_mask, [v_obj],[coord_x],[coord_y],[coord_z],esi
  829.                 or byte[ebx+3],al
  830.  
  831.                 mov ebx,edi
  832.                 add edi,4
  833.                 dec esi
  834.                 loop @b
  835.         jmp .end_2
  836.  
  837.         ; *** (3) ***
  838.         .change:
  839.         mov eax,[color] ;¬¥­ï¥¬ 梥â
  840.         mov word[edi],ax
  841.         shr eax,16
  842.         mov byte[edi+2],al
  843.  
  844.         .end_2:
  845. popad
  846.         ret
  847. endp
  848.  
  849. ; ᤢ¨£ ¥â ã§«ë ¤«ï ¤®¡ ¢«¥­¨ï ­®¢ëå 㧫®¢
  850. ;input:
  851. ; p_insert - ¯®§¨æ¨ï ¤«ï ¢áâ ¢ª¨
  852. ; count - ª®««¨ç¥á⢮ ¢áâ ¢«ï¥¬ëå 㧫®¢
  853. align 4
  854. proc vox_obj_add_nodes_mem uses eax ecx edi esi, v_obj:dword,p_insert:dword,count:dword
  855.         mov esi,[v_obj]
  856.         ;stdcall buf2d_vox_obj_get_size,esi
  857.         add esi,[vox_obj_size] ;esi - 㪠§ â¥«ì ­  ª®­¥æ ä ©« 
  858.         mov edi,[count]
  859.         shl edi,2
  860.         add [vox_obj_size],edi
  861.         add edi,esi ;edi - 㪠§ â¥«ì ­  ¡ã¤ã騩 ª®­¥æ ä ©« 
  862.         mov ecx,esi
  863.         sub ecx,[p_insert]
  864.         shr ecx,2 ;ecx - ç¨á«® 横«®¢ ¤«ï ª®¯¨à®¢ ­¨ï
  865.         sub esi,4 ;esi - 㪠§ â¥«ì ­  ¯®á«¥¤­¨© 㧥«
  866.         sub edi,4 ;edi - 㪠§ â¥«ì ­  ¡ã¤ã騩 ¯®á«¥¤­¨© 㧥«
  867.         std
  868.         rep movsd ;ᤢ¨£ ¥¬ ¯ ¬ïâì
  869.         ret
  870. endp
  871.  
  872. ;???
  873. ; ®¯à¥¤¥«¥­¨¥ ¯®§¨æ¨¨ 㧫  ¢ ¤¥à¥¢¥ (®â 0 ¤® 7)
  874. align 4
  875. proc vox_obj_get_node_position uses ebx ecx edi, v_obj:dword,\
  876. coord_x:dword,coord_y:dword,coord_z:dword,k_scale:dword
  877.         mov ecx,[k_scale]
  878.         dec ecx
  879.         mov eax,[coord_x]
  880.         mov ebx,[coord_y]
  881.         mov edi,[coord_z]
  882.         cmp ecx,1
  883.         jl .end_0
  884.                 shr eax,cl
  885.                 shr ebx,cl
  886.                 shr edi,cl
  887.         .end_0:
  888.         and eax,1
  889.         bt ebx,0
  890.         jnc @f
  891.                 bts eax,1
  892.         @@:
  893.         bt edi,0
  894.         jnc @f
  895.                 bts eax,2
  896.         @@:
  897.  
  898.         mov edi,[v_obj]
  899.         add edi,vox_offs_tree_table
  900.         @@:
  901.                 cmp al,byte[edi]
  902.                 je @f
  903.                 inc edi
  904.                 jmp @b
  905.         @@:
  906.         sub edi,[v_obj]
  907.         sub edi,vox_offs_tree_table
  908.         mov eax,edi
  909.        
  910.         ret
  911. endp
  912.  
  913. ;???
  914. ;input:
  915. ; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
  916. ;output:
  917. ; eax - eax + ç¨á«® 㧫®¢ ¢ ¤ ­­ëå ¢®ªá. ®¡ê¥ªâ 
  918. ; edi - 㪠§ â¥«ì ­  ᬥ饭­ë¥ ¤ ­­ë¥ ¢®ªá. ®¡ê¥ªâ 
  919. align 4
  920. proc vox_obj_rec0
  921.         inc eax
  922.         cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
  923.         je .sub_trees
  924.  
  925.                 ;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
  926.                 push ebx ecx
  927.                 mov bh,byte[edi+3]
  928.                 add edi,4
  929.                 mov bl,8
  930.                 .cycle:
  931.                         bt bx,8 ;â¥áâ¨à㥬 ⮫쪮 bh
  932.                         jnc .c_next
  933.                                 stdcall vox_obj_rec0
  934.                         .c_next:
  935.                         shr bh,1
  936.                         dec bl
  937.                         jnz .cycle
  938.                 pop ecx ebx
  939.  
  940.                 jmp .end_f
  941.         .sub_trees:
  942.                 add edi,4
  943.         .end_f:
  944.         ret
  945. endp
  946.  
  947. ;output:
  948. ; eax - 1,2,4,8,16, ... ,128
  949. align 4
  950. proc vox_obj_get_node_bit_mask uses ebx ecx edi, v_obj:dword,\
  951. coord_x:dword,coord_y:dword,coord_z:dword,k_scale:dword
  952.         mov ecx,[k_scale]
  953.         dec ecx
  954.         mov eax,[coord_x]
  955.         mov ebx,[coord_y]
  956.         mov edi,[coord_z]
  957.         cmp ecx,1
  958.         jl .end_0
  959.                 shr eax,cl
  960.                 shr ebx,cl
  961.                 shr edi,cl
  962.         .end_0:
  963.         and eax,1
  964.         bt ebx,0
  965.         jnc @f
  966.                 bts eax,1
  967.         @@:
  968.         bt edi,0
  969.         jnc @f
  970.                 bts eax,2
  971.         @@:
  972.  
  973.         mov ecx,[v_obj]
  974.         add ecx,vox_offs_tree_table
  975.         @@:
  976.                 cmp al,byte[ecx]
  977.                 je @f
  978.                 inc ecx
  979.                 jmp @b
  980.         @@:
  981.         mov eax,1 ;ãáâ ­ ¢«¨¢ ¥¬ ¯¥à¢®­ ç «ì­®¥ §­ ç¥­¨¥ ¡¨â 
  982.         sub ecx,[v_obj]
  983.         sub ecx,vox_offs_tree_table
  984.         jz @f
  985.                 shl eax,cl ;ᤢ¨£ ¥¬ ¡¨â
  986.         @@:
  987.        
  988.         ret
  989. endp
  990.  
  991. ;
  992. ;output:
  993. ; eax - à §¬¥à ¢ ¡ ©â å § ­¨¬ ¥¬ë© ®¡ê¥ªâ®¬ v_obj
  994. align 4
  995. proc buf2d_vox_obj_get_size uses edi, v_obj:dword
  996.         mov edi,[v_obj]
  997.         add edi,vox_offs_data
  998.         xor eax,eax
  999.         stdcall vox_obj_rec0 ;eax - ç¨á«® 㧫®¢ ¢ ®¡ê¥ªâ¥ v_obj
  1000.         shl eax,2
  1001.         add eax,vox_offs_data
  1002.         ret
  1003. endp
  1004.  
  1005. ;input:
  1006. ; mode_add - ¥á«¨ ­¥ à ¢­® 0 ⮣¤  ᮧ¤ ­¨¥ ¢ ०¨¬¥ ¤®¡ ¢«¥­¨ï ¢®ªá¥«¥©
  1007. align 4
  1008. proc but_run uses eax ebx edi, mode_add:dword
  1009.         ; ¯à®¢¥àª  à §¬¥à®¢ ¨§®¡à ¦¥­¨© (⥪áâãà)
  1010.         mov edi,buf_i0
  1011.         mov ebx,buf2d_h
  1012.         cmp ebx,2
  1013.         jle .err_size_t
  1014.         cmp buf2d_w,ebx
  1015.         jne .err_size_t
  1016.         ;
  1017.         mov edi,buf_i1
  1018.         cmp ebx,buf2d_h
  1019.         jne .err_size_tb
  1020.         mov ebx,buf2d_h
  1021.         cmp ebx,2
  1022.         jle .err_size_b
  1023.         cmp buf2d_w,ebx
  1024.         jne .err_size_b
  1025.  
  1026.                 cmp dword[vox_obj_size],vox_offs_data
  1027.                 jl .n_file ;¥á«¨ à ­ìè¥ ­¥ ¡ë«® ®âªàëâëå ä ©«®¢
  1028.                 cmp dword[mode_add],0
  1029.                 jne @f
  1030.                 .n_file:
  1031.                         call but_new_file
  1032.                 @@:
  1033.  
  1034.                 mov edi,buf_i0
  1035.                 mov eax,buf2d_w
  1036.                 mov edi,buf_npl
  1037.                 cmp buf2d_data,0
  1038.                 jne @f
  1039.                         ; *** ᮧ¤ ¥¬ ¡ãä¥à 
  1040.                         m2m buf2d_w,eax
  1041.                         m2m buf2d_h,eax
  1042.                         stdcall [buf2d_create],edi
  1043.                         mov edi,buf_npl_p
  1044.                         m2m buf2d_w,eax
  1045.                         m2m buf2d_h,eax
  1046.                         stdcall [buf2d_create],edi
  1047.                         mov edi,buf_npl_n
  1048.                         m2m buf2d_w,eax
  1049.                         m2m buf2d_h,eax
  1050.                         stdcall [buf2d_create],edi
  1051.                         jmp .end_0
  1052.                 @@:
  1053.                         ; *** ¨§¬¥­ï¥¬ à §¬¥àë ¡ãä¥à®¢
  1054.                         stdcall [buf2d_resize], edi, eax,eax,1
  1055.                         mov edi,buf_npl_p
  1056.                         stdcall [buf2d_resize], edi, eax,eax,1
  1057.                         mov edi,buf_npl_n
  1058.                         stdcall [buf2d_resize], edi, eax,eax,1
  1059.                 .end_0:
  1060.                 mov dword[n_plane],1
  1061.                 mov byte[calc],1
  1062.                 call get_scale
  1063.                 call set_borders
  1064.  
  1065.                 stdcall create_plane,buf_npl,0
  1066.                 stdcall create_plane,buf_npl_n,1
  1067.                 stdcall create_obj_from_plane,buf_npl,0 ;ᮧ¤ ¥¬ ­ ç «ì­®¥ á¥ç¥­¨¥
  1068.  
  1069.                 jmp @f
  1070.         .err_size_t:
  1071.                 stdcall [mb_create],msgbox_0,thread
  1072.                 jmp @f
  1073.         .err_size_b:
  1074.                 stdcall [mb_create],msgbox_1,thread
  1075.                 jmp @f
  1076.         .err_size_tb:
  1077.                 stdcall [mb_create],msgbox_3,thread
  1078.                 ;jmp @f
  1079.         @@:
  1080.         ret
  1081. endp
  1082.  
  1083. align 4
  1084. but_5:
  1085.         cmp byte[calc],0
  1086.         je @f
  1087.                 call draw_object
  1088.                 mov byte[calc],0
  1089.         @@:
  1090.         ret
  1091.  
  1092. align 4
  1093. but_rot_z:
  1094.         stdcall vox_obj_rot_z, [open_file_vox]
  1095.         call draw_object
  1096.         ret
  1097.  
  1098. align 4
  1099. draw_object:
  1100.         ;¢ë¢®¤ १ã«ìâ â  ­  íªà ­
  1101.         stdcall [buf2d_clear], buf_0, [buf_0.color] ;ç¨á⨬ ¡ãä¥à
  1102.         stdcall [buf2d_clear], buf_0z, 0 ;ç¨á⨬ ¡ãä¥à
  1103.         stdcall [buf2d_vox_obj_draw_3g], buf_0, buf_0z, buf_vox,\
  1104.                 [open_file_vox], 0,0, 0, 6 ;[k_scale]
  1105.         stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
  1106.         ret
  1107.  
  1108. align 4
  1109. proc open_image_in_buf, buf:dword
  1110.         pushad
  1111.         copy_path open_dialog_name,communication_area_default_path,file_name,0
  1112.         mov [OpenDialog_data.type],0
  1113.         stdcall [OpenDialog_Start],OpenDialog_data
  1114.         cmp [OpenDialog_data.status],2
  1115.         je .end_open_file
  1116.  
  1117.         ;stdcall mem.Alloc, dword size ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
  1118.         ;mov [buf],eax
  1119.  
  1120.         mov [run_file_70.Function], SSF_READ_FILE
  1121.         mov [run_file_70.Position], 0
  1122.         mov [run_file_70.Flags], 0
  1123.         mov [run_file_70.Count], dword max_open_file_size
  1124.         m2m [run_file_70.Buffer],dword[open_file_img]
  1125.         mov byte[run_file_70+20], 0
  1126.         mov [run_file_70.FileName], openfile_path
  1127.         mcall SF_FILE,run_file_70
  1128.         cmp ebx,0xffffffff
  1129.         je .end_0
  1130.                 ;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï
  1131.                 stdcall dword[img_decode], dword[open_file_img],ebx,0
  1132.                 or eax,eax
  1133.                 jz .end_0 ;¥á«¨ ­ àã襭 ä®à¬ â ä ©« 
  1134.                 mov ebx,eax
  1135.                 ;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
  1136.                 stdcall dword[img_to_rgb2], ebx,dword[open_file_img]
  1137.  
  1138.                 mov edi,[buf]
  1139.                 cmp buf2d_data,0
  1140.                 jne @f
  1141.                         m2m buf2d_w,dword[ebx+4] ;+4 = image width
  1142.                         m2m buf2d_h,dword[ebx+8] ;+8 = image heihht
  1143.                         stdcall [buf2d_create_f_img], edi,[open_file_img]
  1144.                         jmp .end_1
  1145.                 @@:
  1146.                         mov ecx,dword[ebx+8]
  1147.                         stdcall [buf2d_resize], edi, [ebx+4],ecx,1 ;¨§¬¥­ï¥¬ à §¬¥àë ¡ãä¥à 
  1148.                         imul ecx,[ebx+4]
  1149.                         lea ecx,[ecx+ecx*2]
  1150.                         mov edi,buf2d_data
  1151.                         mov esi,[open_file_img]
  1152.                         cld
  1153.                         rep movsb ;copy image
  1154.                 .end_1:
  1155.  
  1156.                 ;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à ¢ ebx
  1157.                 stdcall dword[img_destroy], ebx
  1158.         .end_0:
  1159.  
  1160.         call draw_buffers
  1161.         .end_open_file:
  1162.         popad
  1163.         ret
  1164. endp
  1165.  
  1166. msgbox_0:
  1167.         db 1,0
  1168.         db '‚­¨¬ ­¨¥',0
  1169.         db ' §¬¥à ¢¥àå­¥£® ¨§®¡à ¦¥­¨ï ­¥ ª®à¥ªâ­ë©',0
  1170.         db '‡ ªàëâì',0
  1171.         db 0
  1172.  
  1173. msgbox_1:
  1174.         db 1,0
  1175.         db '‚­¨¬ ­¨¥',0
  1176.         db ' §¬¥à ¡®ª®¢®£® ¨§®¡à ¦¥­¨ï ­¥ ª®à¥ªâ­ë©',0
  1177.         db '‡ ªàëâì',0
  1178.         db 0
  1179.  
  1180. msgbox_2:
  1181.         db 1,0
  1182.         db '‚­¨¬ ­¨¥',0
  1183.         db ' §¬¥à ¯¥à¥¤­¥£® ¨§®¡à ¦¥­¨ï ­¥ ª®à¥ªâ­ë©',0
  1184.         db '‡ ªàëâì',0
  1185.         db 0
  1186.  
  1187. msgbox_3:
  1188.         db 1,0
  1189.         db '‚­¨¬ ­¨¥',0
  1190.         db ' §¬¥àë ¢¥àå­¥£® ¨ ¡®ª®¢®£® ¨§®¡à ¦¥­¨© ­¥ ᮢ¯ ¤ îâ',13,\
  1191.                 'Žâªà®©â¥ ¨§®¡à ¦¥­¨ï ®¤¨­ ª®¢ëå à §¬¥à®¢',0
  1192.         db '‡ ªàëâì',0
  1193.         db 0
  1194.  
  1195. msgbox_4:
  1196.         db 1,0
  1197.         db '‚­¨¬ ­¨¥',0
  1198.         db 'Žâªà뢠¥¬ë© ä ©« ᮤ¥à¦¨â ­¥ ¢®ªá¥«ì­ë© ä®à¬ â',0
  1199.         db '‡ ªàëâì',0
  1200.         db 0
  1201.  
  1202. ;¤ ­­ë¥ ¤«ï ¤¨ «®£  ®âªàëâ¨ï ä ©«®¢
  1203. align 4
  1204. OpenDialog_data:
  1205. .type                   dd 0 ;0 - ®âªàëâì, 1 - á®åà ­¨âì, 2 - ¢ë¡à âì ¤â४â®à¨î
  1206. .procinfo               dd procinfo     ;+4
  1207. .com_area_name          dd communication_area_name      ;+8
  1208. .com_area               dd 0    ;+12
  1209. .opendir_path           dd plugin_path  ;+16
  1210. .dir_default_path       dd default_dir ;+20
  1211. .start_path             dd file_name ;+24 ¯ãâì ª ¤¨ «®£ã ®âªàëâ¨ï ä ©«®¢
  1212. .draw_window            dd draw_window  ;+28
  1213. .status                 dd 0    ;+32
  1214. .openfile_path          dd openfile_path        ;+36 ¯ãâì ª ®âªà뢠¥¬®¬ã ä ©«ã
  1215. .filename_area          dd filename_area        ;+40
  1216. .filter_area            dd Filter
  1217. .x:
  1218. .x_size                 dw 420 ;+48 ; Window X size
  1219. .x_start                dw 10 ;+50 ; Window X position
  1220. .y:
  1221. .y_size                 dw 320 ;+52 ; Window y size
  1222. .y_start                dw 10 ;+54 ; Window Y position
  1223.  
  1224. default_dir db '/rd/1',0
  1225.  
  1226. communication_area_name:
  1227.         db 'FFFFFFFF_open_dialog',0
  1228. open_dialog_name:
  1229.         db 'opendial',0
  1230. communication_area_default_path:
  1231.         db '/rd/1/File managers/',0
  1232.  
  1233. Filter:
  1234. dd Filter.end - Filter ;.1
  1235. .1:
  1236. db 'PNG',0
  1237. db 'JPG',0
  1238. db 'JPEG',0
  1239. db 'BMP',0
  1240. db 'GIF',0
  1241. db 'VOX',0
  1242. .end:
  1243. db 0
  1244.  
  1245.  
  1246.  
  1247. head_f_i:
  1248. head_f_l db '‘¨á⥬­ ï ®è¨¡ª ',0
  1249.  
  1250. system_dir_0 db '/sys/lib/'
  1251. lib_name_0 db 'proc_lib.obj',0
  1252. err_message_found_lib_0 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,0
  1253. err_message_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,0
  1254.  
  1255. system_dir_1 db '/sys/lib/'
  1256. lib_name_1 db 'libimg.obj',0
  1257. err_message_found_lib_1 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'libimg.obj',39,0
  1258. err_message_import_1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libimg.obj',39,0
  1259.  
  1260. system_dir_2 db '/sys/lib/'
  1261. lib_name_2 db 'buf2d.obj',0
  1262. err_msg_found_lib_2 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'buf2d.obj',39,0
  1263. err_msg_import_2 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'buf2d',39,0
  1264.  
  1265. system_dir_3 db '/sys/lib/'
  1266. lib_name_3 db 'msgbox.obj',0
  1267. err_msg_found_lib_3 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'msgbox.obj',39,0
  1268. err_msg_import_3 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'msgbox',39,0
  1269.  
  1270. l_libs_start:
  1271.         lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
  1272.                 err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i
  1273.         lib_1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\
  1274.                 err_message_found_lib_1, head_f_l, import_libimg, err_message_import_1, head_f_i
  1275.         lib_2 l_libs lib_name_2, sys_path, library_path, system_dir_2,\
  1276.                 err_msg_found_lib_2,head_f_l,import_buf2d,err_msg_import_2,head_f_i
  1277.         lib_3 l_libs lib_name_3, sys_path, library_path, system_dir_3,\
  1278.                 err_msg_found_lib_3,head_f_l,import_msgbox_lib,err_msg_import_3,head_f_i
  1279. l_libs_end:
  1280.  
  1281. align 4
  1282. import_libimg:
  1283.         dd alib_init1
  1284.         img_is_img  dd aimg_is_img
  1285.         img_info    dd aimg_info
  1286.         img_from_file dd aimg_from_file
  1287.         img_to_file dd aimg_to_file
  1288.         img_from_rgb dd aimg_from_rgb
  1289.         img_to_rgb  dd aimg_to_rgb
  1290.         img_to_rgb2 dd aimg_to_rgb2
  1291.         img_decode  dd aimg_decode
  1292.         img_encode  dd aimg_encode
  1293.         img_create  dd aimg_create
  1294.         img_destroy dd aimg_destroy
  1295.         img_destroy_layer dd aimg_destroy_layer
  1296.         img_count   dd aimg_count
  1297.         img_lock_bits dd aimg_lock_bits
  1298.         img_unlock_bits dd aimg_unlock_bits
  1299.         img_flip    dd aimg_flip
  1300.         img_flip_layer dd aimg_flip_layer
  1301.         img_rotate  dd aimg_rotate
  1302.         img_rotate_layer dd aimg_rotate_layer
  1303.         img_draw    dd aimg_draw
  1304.  
  1305.         dd 0,0
  1306.         alib_init1   db 'lib_init',0
  1307.         aimg_is_img  db 'img_is_img',0 ;®¯à¥¤¥«ï¥â ¯® ¤ ­­ë¬, ¬®¦¥â «¨ ¡¨¡«¨®â¥ª  ᤥ« âì ¨§ ­¨å ¨§®¡à ¦¥­¨¥
  1308.         aimg_info    db 'img_info',0
  1309.         aimg_from_file db 'img_from_file',0
  1310.         aimg_to_file db 'img_to_file',0
  1311.         aimg_from_rgb db 'img_from_rgb',0
  1312.         aimg_to_rgb  db 'img_to_rgb',0 ;¯à¥®¡à §®¢ ­¨¥ ¨§®¡à ¦¥­¨ï ¢ ¤ ­­ë¥ RGB
  1313.         aimg_to_rgb2 db 'img_to_rgb2',0
  1314.         aimg_decode  db 'img_decode',0 ; ¢â®¬ â¨ç¥áª¨ ®¯à¥¤¥«ï¥â ä®à¬ â £à ä¨ç¥áª¨å ¤ ­­ëå
  1315.         aimg_encode  db 'img_encode',0
  1316.         aimg_create  db 'img_create',0
  1317.         aimg_destroy db 'img_destroy',0
  1318.         aimg_destroy_layer db 'img_destroy_layer',0
  1319.         aimg_count   db 'img_count',0
  1320.         aimg_lock_bits db 'img_lock_bits',0
  1321.         aimg_unlock_bits db 'img_unlock_bits',0
  1322.         aimg_flip    db 'img_flip',0
  1323.         aimg_flip_layer db 'img_flip_layer',0
  1324.         aimg_rotate  db 'img_rotate',0
  1325.         aimg_rotate_layer db 'img_rotate_layer',0
  1326.         aimg_draw    db 'img_draw',0
  1327.  
  1328. align 4
  1329. proclib_import: ;®¯¨á ­¨¥ íªá¯®àâ¨à㥬ëå ä㭪権
  1330.         OpenDialog_Init dd aOpenDialog_Init
  1331.         OpenDialog_Start dd aOpenDialog_Start
  1332. dd 0,0
  1333.         aOpenDialog_Init db 'OpenDialog_init',0
  1334.         aOpenDialog_Start db 'OpenDialog_start',0
  1335.  
  1336. align 4
  1337. import_buf2d:
  1338.         init dd sz_init
  1339.         buf2d_create dd sz_buf2d_create
  1340.         buf2d_create_f_img dd sz_buf2d_create_f_img
  1341.         buf2d_clear dd sz_buf2d_clear
  1342.         buf2d_draw dd sz_buf2d_draw
  1343.         buf2d_delete dd sz_buf2d_delete
  1344.         buf2d_resize dd sz_buf2d_resize
  1345.         buf2d_line dd sz_buf2d_line
  1346.         buf2d_rect_by_size dd sz_buf2d_rect_by_size
  1347.         buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size
  1348.         buf2d_circle dd sz_buf2d_circle
  1349.         buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
  1350.         buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
  1351.         buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
  1352.         buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
  1353.         buf2d_bit_blt dd sz_buf2d_bit_blt
  1354.         buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
  1355.         buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
  1356.         buf2d_curve_bezier dd sz_buf2d_curve_bezier
  1357.         buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
  1358.         buf2d_draw_text dd sz_buf2d_draw_text
  1359.         buf2d_crop_color dd sz_buf2d_crop_color
  1360.         buf2d_offset_h dd sz_buf2d_offset_h
  1361.         buf2d_flood_fill dd sz_buf2d_flood_fill
  1362.         buf2d_set_pixel dd sz_buf2d_set_pixel
  1363.         buf2d_get_pixel dd sz_buf2d_get_pixel
  1364.         buf2d_vox_brush_create dd sz_buf2d_vox_brush_create
  1365.         buf2d_vox_brush_delete dd sz_buf2d_vox_brush_delete
  1366.         buf2d_vox_obj_get_img_w_3g dd sz_buf2d_vox_obj_get_img_w_3g
  1367.         buf2d_vox_obj_get_img_h_3g dd sz_buf2d_vox_obj_get_img_h_3g
  1368.         buf2d_vox_obj_draw_1g dd sz_buf2d_vox_obj_draw_1g
  1369.         buf2d_vox_obj_draw_3g dd sz_buf2d_vox_obj_draw_3g
  1370.         buf2d_vox_obj_draw_3g_scaled dd sz_buf2d_vox_obj_draw_3g_scaled
  1371.         buf2d_vox_obj_draw_3g_shadows dd sz_buf2d_vox_obj_draw_3g_shadows
  1372.         buf2d_vox_obj_draw_pl dd sz_buf2d_vox_obj_draw_pl
  1373.         buf2d_vox_obj_draw_pl_scaled dd sz_buf2d_vox_obj_draw_pl_scaled
  1374.         dd 0,0
  1375.         sz_init db 'lib_init',0
  1376.         sz_buf2d_create db 'buf2d_create',0
  1377.         sz_buf2d_create_f_img db 'buf2d_create_f_img',0
  1378.         sz_buf2d_clear db 'buf2d_clear',0
  1379.         sz_buf2d_draw db 'buf2d_draw',0
  1380.         sz_buf2d_delete db 'buf2d_delete',0
  1381.         sz_buf2d_resize db 'buf2d_resize',0
  1382.         sz_buf2d_line db 'buf2d_line',0
  1383.         sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0
  1384.         sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0
  1385.         sz_buf2d_circle db 'buf2d_circle',0
  1386.         sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
  1387.         sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
  1388.         sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
  1389.         sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
  1390.         sz_buf2d_bit_blt db 'buf2d_bit_blt',0
  1391.         sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
  1392.         sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
  1393.         sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
  1394.         sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
  1395.         sz_buf2d_draw_text db 'buf2d_draw_text',0
  1396.         sz_buf2d_crop_color db 'buf2d_crop_color',0
  1397.         sz_buf2d_offset_h db 'buf2d_offset_h',0
  1398.         sz_buf2d_flood_fill db 'buf2d_flood_fill',0
  1399.         sz_buf2d_set_pixel db 'buf2d_set_pixel',0
  1400.         sz_buf2d_get_pixel db 'buf2d_get_pixel',0
  1401.         sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
  1402.         sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
  1403.         sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
  1404.         sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
  1405.         sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
  1406.         sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0
  1407.         sz_buf2d_vox_obj_draw_3g_scaled db 'buf2d_vox_obj_draw_3g_scaled',0
  1408.         sz_buf2d_vox_obj_draw_3g_shadows db 'buf2d_vox_obj_draw_3g_shadows',0
  1409.         sz_buf2d_vox_obj_draw_pl db 'buf2d_vox_obj_draw_pl',0
  1410.         sz_buf2d_vox_obj_draw_pl_scaled db 'buf2d_vox_obj_draw_pl_scaled',0
  1411.  
  1412. align 4
  1413. import_msgbox_lib:
  1414.         mb_create dd amb_create
  1415. ;       mb_reinit dd amb_reinit
  1416. ;       mb_setfunctions dd amb_setfunctions
  1417. dd 0,0
  1418.         amb_create db 'mb_create',0
  1419. ;       amb_reinit db 'mb_reinit',0
  1420. ;       amb_setfunctions db 'mb_setfunctions',0
  1421.  
  1422. mouse_dd dd 0x0
  1423. sc system_colors
  1424. last_time dd 0
  1425.  
  1426. align 16
  1427. procinfo process_information
  1428.  
  1429. align 4
  1430. buf_0: dd 0
  1431.         dw 5 ;+4 left
  1432.         dw 35 ;+6 top
  1433. .w: dd 6*64 ;+8 w
  1434. .h: dd 7*64 ;+12 h
  1435. .color: dd 0xffffff ;+16 color
  1436.         db 24 ;+20 bit in pixel
  1437.  
  1438. align 4
  1439. buf_0z: dd 0
  1440.         dw 5 ;+4 left
  1441.         dw 35 ;+6 top
  1442. .w: dd 6*64 ;+8 w
  1443. .h: dd 7*64 ;+12 h
  1444. .color: dd 0 ;+16 color
  1445.         db 32 ;+20 bit in pixel
  1446.  
  1447. align 4
  1448. buf_i0: dd 0
  1449.         dw 5 ;+4 left
  1450.         dw 35 ;+6 top
  1451. .w: dd 0 ;+8 w
  1452. .h: dd 0 ;+12 h
  1453. .color: dd 0 ;+16 color
  1454.         db 24 ;+20 bit in pixel
  1455.  
  1456. align 4
  1457. buf_i1: dd 0
  1458.         dw 105 ;+4 left
  1459.         dw 35 ;+6 top
  1460. .w: dd 0 ;+8 w
  1461. .h: dd 0 ;+12 h
  1462. .color: dd 0 ;+16 color
  1463.         db 24 ;+20 bit in pixel
  1464.  
  1465. align 4
  1466. buf_i2: dd 0
  1467.         dw 205 ;+4 left
  1468.         dw 35 ;+6 top
  1469. .w: dd 0 ;+8 w
  1470. .h: dd 0 ;+12 h
  1471. .color: dd 0 ;+16 color
  1472.         db 24 ;+20 bit in pixel
  1473.  
  1474. align 4
  1475. buf_npl_p: dd 0
  1476.         dw 0 ;+4 left
  1477.         dw 0 ;+6 top
  1478. .w: dd 0 ;+8 w
  1479. .h: dd 0 ;+12 h
  1480. .color: dd 0 ;+16 color
  1481.         db 24 ;+20 bit in pixel
  1482.  
  1483. align 4
  1484. buf_npl: dd 0
  1485.         dw 5 ;+4 left
  1486.         dw 35 ;+6 top
  1487. .w: dd 0 ;+8 w
  1488. .h: dd 0 ;+12 h
  1489. .color: dd 0 ;+16 color
  1490.         db 24 ;+20 bit in pixel
  1491.  
  1492. align 4
  1493. buf_npl_n: dd 0
  1494.         dw 0 ;+4 left
  1495.         dw 0 ;+6 top
  1496. .w: dd 0 ;+8 w
  1497. .h: dd 0 ;+12 h
  1498. .color: dd 0 ;+16 color
  1499.         db 24 ;+20 bit in pixel
  1500.  
  1501. ;¤ ­­ë¥ ¤«ï ᮧ¤ ­¨ï ¬¨­¨¬ «ì­®£® ¥¤¨­¨ç­®£® ¢®ªá¥«ï
  1502. align 4
  1503. vox_6_7_z:
  1504. dd 0,0,1,1,0,0,\
  1505.    0,2,2,2,2,0,\
  1506.    2,2,2,2,2,2,\
  1507.    2,3,2,2,3,2,\
  1508.    2,3,3,3,3,2,\
  1509.    0,3,3,3,3,0,\
  1510.    0,0,3,3,0,0
  1511.  
  1512. align 4
  1513. buf_vox:
  1514.         db 6,7,4,3 ;w,h,h_osn,n
  1515.         rb BUF_STRUCT_SIZE*(2+1)
  1516.  
  1517.  
  1518. align 16
  1519. i_end:
  1520.                 rb 2048
  1521.         thread:
  1522.                 rb 2048
  1523. stacktop:
  1524.         sys_path rb 1024
  1525.         file_name:
  1526.                 rb 1024 ;4096
  1527.         library_path rb 1024
  1528.         plugin_path rb 4096
  1529.         openfile_path rb 4096
  1530.         filename_area rb 256
  1531. mem:
  1532.