Subversion Repositories Kolibri OS

Rev

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

  1. use32
  2.         org 0x0
  3.         db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
  4.         dd 0x1
  5.         dd start
  6.         dd i_end ;à §¬¥à ¯à¨«®¦¥­¨ï
  7.         dd mem
  8.         dd stacktop
  9.         dd 0
  10.         dd sys_path
  11.  
  12. include '../../../../programs/macros.inc'
  13. include '../../../../programs/proc32.inc'
  14. include '../../../../programs/develop/libraries/box_lib/load_lib.mac'
  15. include 'mem.inc'
  16. include 'dll.inc'
  17. include 'vox_draw.inc'
  18.  
  19. @use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
  20. caption db 'Voxel editor 23.08.12',0 ;¯®¤¯¨áì ®ª­ 
  21.  
  22. struct FileInfoBlock
  23.         Function dd ?
  24.         Position dd ?
  25.         Flags    dd ?
  26.         Count    dd ?
  27.         Buffer   dd ?
  28.                 db ?
  29.         FileName dd ?
  30. ends
  31.  
  32. run_file_70 FileInfoBlock
  33. image_data dd 0 ;㪠§ â¥«ì ­  ¢à¥¬¥­­ãî ¯ ¬ïâì. ¤«ï ­ã¦¥­ ¯à¥®¡à §®¢ ­¨ï ¨§®¡à ¦¥­¨ï
  34.  
  35. fn_toolbar db 'toolbar.png',0
  36. IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3
  37. IMAGE_TOOLBAR_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*21
  38. image_data_toolbar dd 0
  39. cursors_count equ 4
  40. IMAGE_CURSORS_SIZE equ 4096*cursors_count ;à §¬¥à ª à⨭ª¨ á ªãàá®à ¬¨
  41.  
  42. ;§­ ç¥­¨ï § ¤ ¢ ¥¬ë¥ ¯® 㬮«ç ­¨î, ¡¥§ ini ä ©« 
  43. ini_def_window_t equ 10
  44. ini_def_window_l equ 10
  45. ini_def_window_w equ 550
  46. ini_def_window_h equ 415
  47. ini_def_buf_w equ 198 ;=192+6
  48. ini_def_buf_h equ 231 ;=224+7
  49. ini_def_s_zoom equ 5
  50. ini_def_t_size equ 10
  51. ini_def_color_b equ 0xffffff
  52. ;®¯¨á ­¨¥ ¯ à ¬ â஢ ¤«ï ini ä ©« 
  53. ini_name db 'vox_editor.ini',0
  54. ini_sec_window db 'Window',0
  55. key_window_t db 't',0
  56. key_window_l db 'l',0
  57. key_window_w db 'w',0
  58. key_window_h db 'h',0
  59. key_buf_w db 'buf_w',0
  60. key_buf_h db 'buf_h',0
  61. ini_sec_options db 'Options',0
  62. key_s_zoom db 's_zoom',0
  63. key_t_size db 'tile_size',0
  64. key_f_size db 'file_size',0
  65. key_col_b db 'c_background',0
  66.  
  67. macro load_image_file path,buf,size { ;¬ ªà®á ¤«ï § £à㧪¨ ¨§®¡à ¦¥­¨©
  68.         ;path - ¬®¦¥â ¡ëâì ¯¥à¥¬¥­­®© ¨«¨ áâப®¢ë¬ ¯ à ¬¥â஬
  69.         if path eqtype '' ;¯à®¢¥à塞 § ¤ ­ «¨ áâப®© ¯ à ¬¥âà path
  70.                 jmp @f
  71.                         local .path_str
  72.                         .path_str db path ;ä®à¬¨à㥬 «®ª «ì­ãî ¯¥à¥¬¥­­ãî
  73.                         db 0
  74.                 @@:
  75.                 ;32 - áâ ­¤ àâ­ë©  ¤à¥á ¯® ª®â®à®¬ã ¤®«¦¥­ ¡ëâì ¡ãä¥à á á¨á⥬­ë¬ ¯ã⥬
  76.                 copy_path .path_str,[32],file_name,0x0
  77.         else
  78.                 copy_path path,[32],file_name,0x0 ;ä®à¬¨à㥬 ¯®«­ë© ¯ãâì ª ä ©«ã ¨§®¡à ¦¥­¨ï, ¯®¤à §ã¬¥¢ ¥¬ çâ® ®­ ¢ ®¤­®© ¯ ¯ª¥ á ¯à®£à ¬¬®©
  79.         end if
  80.  
  81.         stdcall mem.Alloc, dword size ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
  82.         mov [buf],eax
  83.  
  84.         mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
  85.         mov [run_file_70.Function], 0
  86.         mov [run_file_70.Position], 0
  87.         mov [run_file_70.Flags], 0
  88.         mov [run_file_70.Count], dword size
  89.         m2m [run_file_70.Buffer], [buf]
  90.         mov byte[run_file_70+20], 0
  91.         mov [run_file_70.FileName], file_name
  92.         mov ebx,run_file_70
  93.         int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
  94.         cmp ebx,0xffffffff
  95.         je @f
  96.                 ;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï ¨ ¯¥à¥¢®¤¨¬ ¥£® ¢® ¢à¥¬¥­­ë© ¡ãä¥à image_data
  97.                 stdcall dword[img_decode], dword[buf],ebx,0
  98.                 mov dword[image_data],eax
  99.                 ;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
  100.                 stdcall dword[img_to_rgb2], dword[image_data],dword[buf]
  101.                 ;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à image_data
  102.                 stdcall dword[img_destroy], dword[image_data]
  103.         @@:
  104. }
  105.  
  106. OT_MAP_X  equ  0
  107. OT_MAP_Y  equ  0
  108. OT_CAPT_X_COLOR equ  5 ;®âáâ㯠¤«ï ¯®¤¯¨á¨ 梥â 
  109. OT_CAPT_Y_COLOR equ 30
  110. PEN_MODE_NONE equ -1
  111. PEN_MODE_CLEAR equ 0 ;०¨¬ áâ¨à ­¨ï
  112. PEN_MODE_SELECT_COLOR equ 2 ;०¨¬ ¢ë¡®à  梥â 
  113.  
  114. align 4
  115. start:
  116.         load_libraries l_libs_start,l_libs_end
  117.         ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ¡¨¡«¨®â¥ª 
  118.         mov     ebp,lib_2
  119.         cmp     dword [ebp+ll_struc_size-4],0
  120.         jz      @f
  121.                 mcall -1 ;exit not correct
  122.         @@:
  123.         mcall 48,3,sc,sizeof.system_colors
  124.         mcall 40,0x27
  125.         stdcall [OpenDialog_Init],OpenDialog_data ;¯®¤£®â®¢ª  ¤¨ «®£ 
  126.  
  127. ;--- load ini file ---
  128.         copy_path ini_name,sys_path,file_name,0
  129.         ;window startup pozition
  130.         stdcall dword[ini_get_int],file_name,ini_sec_window,key_window_l,ini_def_window_l
  131.         mov word[wnd_s_pos+2],ax
  132.         stdcall dword[ini_get_int],file_name,ini_sec_window,key_window_w,ini_def_window_w
  133.         mov word[wnd_s_pos],ax
  134.         stdcall dword[ini_get_int],file_name,ini_sec_window,key_window_t,ini_def_window_t
  135.         mov word[wnd_s_pos+6],ax
  136.         stdcall dword[ini_get_int],file_name,ini_sec_window,key_window_h,ini_def_window_h
  137.         mov word[wnd_s_pos+4],ax
  138.         ;image buffer size
  139.         stdcall dword[ini_get_int],file_name,ini_sec_window,key_buf_w,ini_def_buf_w
  140.         mov [buf_0.w],eax
  141.         mov [buf_0z.w],eax
  142.         add ax,15
  143.         mov [buf_pl.l],ax ;®âáâ㯠¤«ï ¯à ¢®£® ®ª­ 
  144.         stdcall dword[ini_get_int],file_name,ini_sec_window,key_buf_h,ini_def_buf_h
  145.         mov [buf_0.h],eax
  146.         mov [buf_0z.h],eax
  147.         ;梥â ä®­ 
  148.         stdcall dword[ini_get_color],file_name,ini_sec_window,key_col_b,ini_def_color_b
  149.         mov [buf_0.color],eax
  150.         mov [buf_pl.color],eax
  151.  
  152.         ;¬ áâ ¡, ¯®á«¥ ª®â®à®£® ¡ã¤¥â 㢥«¨ç¥­¨¥
  153.         stdcall dword[ini_get_int],file_name,ini_sec_options,key_s_zoom,ini_def_s_zoom
  154.         mov [scaled_zoom],eax
  155.         ;à §¬¥à ª¢ ¤à â¨ª  ­  ¯«®áª®á⨠á¥ç¥­¨ï
  156.         stdcall dword[ini_get_int],file_name,ini_sec_options,key_t_size,ini_def_t_size
  157.         mov [tile_size],eax
  158.  
  159.         stdcall dword[ini_get_int],file_name,ini_sec_options,key_f_size,64
  160.         shl eax,10
  161.         mov [max_open_file_size],eax
  162.  
  163.         mov ecx,[scaled_zoom]
  164.         xor eax,eax
  165.         inc eax
  166.         shl eax,cl
  167.         imul eax,[tile_size]
  168.         mov [buf_pl.w],eax
  169.         add eax,[tile_size]
  170.         mov [buf_pl.h],eax
  171.  
  172.         ;*** § £à㧪  ªãàá®à®¢
  173.         load_image_file 'cursors_gr.png',image_data_toolbar,IMAGE_CURSORS_SIZE
  174.         stdcall [buf2d_create_f_img], buf_curs_8,[image_data_toolbar] ;ᮧ¤ ¥¬ ¡ãä¥à
  175.         stdcall mem.Free,[image_data_toolbar] ;®á¢®¡®¦¤ ¥¬ ¯ ¬ïâì
  176.  
  177.         load_image_file 'cursors.png',image_data_toolbar, IMAGE_CURSORS_SIZE
  178.         stdcall [buf2d_create_f_img], buf_curs,[image_data_toolbar] ;ᮧ¤ ¥¬ ¡ãä¥à
  179.         stdcall mem.Free,[image_data_toolbar] ;®á¢®¡®¦¤ ¥¬ ¯ ¬ïâì
  180.  
  181.         stdcall [buf2d_conv_24_to_8], buf_curs_8,1 ;¤¥« ¥¬ ¡ãä¥à ¯à®§à ç­®á⨠8¡¨â
  182.         stdcall [buf2d_conv_24_to_32],buf_curs,buf_curs_8 ;¤¥« ¥¬ ¡ãä¥à rgba 32¡¨â
  183.  
  184.  
  185.         stdcall [buf2d_create], buf_0 ;ᮧ¤ ­¨¥ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  186.         stdcall [buf2d_create], buf_0z ;ᮧ¤ ­¨¥ ¡ãä¥à  £«ã¡¨­ë
  187.         stdcall [buf2d_create], buf_pl ;ᮧ¤ ­¨¥ ¡ãä¥à  ¤«ï á¥ç¥­¨ï
  188.  
  189.         stdcall [buf2d_vox_brush_create], buf_vox, vox_6_7_z
  190.  
  191.         load_image_file fn_toolbar, image_data_toolbar,IMAGE_TOOLBAR_SIZE
  192.  
  193.         stdcall mem.Alloc,[max_open_file_size]
  194.         mov dword[open_file_vox],eax
  195.  
  196.         call but_new_file
  197.  
  198.         ;¯¥à¢®­ ç «ì­ ï ãáâ ­®¢ª  ªãàá®à 
  199.         stdcall set_pen_mode,1,0,((9 shl 8)+9) shl 16 ;pen
  200.  
  201. align 4
  202. red_win:
  203.         call draw_window
  204.  
  205. align 4
  206. still:
  207.         mcall 10
  208.  
  209.         cmp al,1
  210.         jz red_win
  211.         cmp al,2
  212.         jz key
  213.         cmp al,3
  214.         jz button
  215.         cmp al,6
  216.         jne @f
  217.                 mcall 9,procinfo,-1
  218.                 cmp ax,word[procinfo+4]
  219.                 jne @f ;®ª­® ­¥  ªâ¨¢­®
  220.                 call mouse
  221.         @@:
  222.         jmp still
  223.  
  224. align 4
  225. mouse:
  226.         pushad
  227.         mcall 37,2
  228.         bt eax,1 ;right button
  229.         jnc @f
  230.                 mcall 37,1 ;get mouse coords
  231.                 mov ebx,eax
  232.                 shr ebx,16
  233.                 and eax,0xffff
  234.                 stdcall get_buf_color, buf_0
  235.                 stdcall get_buf_color, buf_pl
  236.                 jmp .end_f
  237.         @@:
  238.         bt eax,0 ;left button
  239.         jnc .end_f
  240.                 mcall 37,1 ;get mouse coords
  241.                 mov ebx,eax
  242.                 shr ebx,16
  243.                 and eax,0xffff
  244.  
  245.                 cmp dword[v_pen_mode],PEN_MODE_SELECT_COLOR
  246.                 jne .end_2
  247.                         stdcall get_buf_color, buf_0
  248.                         stdcall get_buf_color, buf_pl
  249.                         jmp .end_f
  250.                 .end_2:
  251.  
  252.  
  253.                 push eax ebx
  254.                 mov edx,[v_zoom]
  255.                 cmp edx,[scaled_zoom]
  256.                 jle @f
  257.                 ;०¨¬ ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
  258.                 sub edx,[scaled_zoom]
  259.                 sub ax,word[buf_0.t]
  260.                 sub bx,word[buf_0.l]
  261.                 stdcall get_mouse_ev_scale, buf_vox, ebx, eax, [scaled_zoom],edx
  262.                 cmp eax,0
  263.                 je @f
  264.                         mov ebx,eax
  265.                         and eax,0x3fffffff
  266.                         rol ebx,2
  267.                         and ebx,3
  268.                         dec ebx
  269.  
  270.                         shl ebx,2
  271.                         add ebx,cam_x
  272.                         mov dword[ebx],eax ;change [cam_x] or [cam_y] or [cam_z]
  273.                         call draw_objects
  274.  
  275.                         pop ebx eax
  276.                         jmp .end_f
  277.                 @@:
  278.                 pop ebx eax
  279.  
  280.  
  281.                 ;eax - mouse coord y
  282.                 ;ebx - mouse coord x
  283.                 movzx edx,word[buf_pl.t]
  284.                 add edx,OT_MAP_Y
  285.                 cmp eax,edx
  286.                 jl .end_f
  287.                         sub eax,edx
  288.                         xor edx,edx
  289.                         mov ecx,[tile_size] ;H
  290.                         div ecx
  291.                 movzx edx,word[buf_pl.l]
  292.                 add edx,OT_MAP_X
  293.                 cmp ebx,edx
  294.                 jl .end_f
  295.                         call convert_y ;¯à¥®¡à §®¢ ­¨¥ ª®®à¤¨­ âë y
  296.                         cmp eax,0
  297.                         jge .end_0 ;®£à ­¨ç¥­¨¥ ¯® ­¨¦­¥© ª®®à¤¨­ â¥ y
  298.                                 cmp eax,-1
  299.                                 jne .end_f
  300.                                 ;¬¥­ï¥¬ á¥ç¥­¨¥, ¯®¯ «¨ ­  ª¢ ¤à â¨ª
  301.                                 sub ebx,edx
  302.                                 mov eax,ebx
  303.                                 xor edx,edx
  304.                                 mov ecx,[tile_size] ;W
  305.                                 div ecx
  306.                                 mov [n_plane],eax
  307.                                 jmp .end_1
  308.                         .end_0:
  309.                         mov [v_cur_y],eax ;Y-coord
  310.                         sub ebx,edx
  311.                         mov eax,ebx
  312.                         xor edx,edx
  313.                         mov ecx,[tile_size] ;W
  314.                         div ecx
  315.                         mov [v_cur_x],eax ;X-coord
  316.  
  317.                         cmp dword[v_pen_mode],PEN_MODE_CLEAR
  318.                         jl .end_1
  319.                         cmp dword[v_pen_mode],1
  320.                         jg .end_1
  321.                                 mov eax,[v_cur_x]
  322.                                 mov ebx,[n_plane]
  323.                                 mov edx,[v_cur_y]
  324.  
  325.                                 mov ecx,[v_zoom]
  326.                                 cmp ecx,[scaled_zoom]
  327.                                 jle .no_c_coord_0
  328.                                         ;¯à¥®¡à §®¢ ­¨¥ ª®®à¤¨­ â, á ãç¥â®¬ 㢥«¨ç¥­¨ï
  329.                                         ;sub ecx,[scaled_zoom] ;¢ ecx ¯à¨à®áâ ¬ áèâ ¡  (ecx>0)
  330.                                         mov ecx,[scaled_zoom]
  331.  
  332.                                         mov edi,[cam_x]
  333.                                         shl edi,cl
  334.                                         add eax,edi
  335.                                         mov edi,[cam_y]
  336.                                         shl edi,cl
  337.                                         add ebx,edi
  338.                                         mov edi,[cam_z]
  339.                                         shl edi,cl
  340.                                         add edx,edi
  341.                                 .no_c_coord_0:
  342.  
  343.                                 ;®â«¨ç î騩áï ¯ à ¬¥âà ¤«ï ä㭪樨 ᮧ¤ ­¨ï ¢®ªá¥«ï
  344.                                 cmp dword[v_pen_mode],1
  345.                                 jne @f
  346.                                         push dword[v_color]
  347.                                 @@:
  348.  
  349.                                 ;¢ë§®¢ ®¡é¨å ¯ à ¬¥â஢ ¤«ï ä㭪権
  350.                                 push dword[v_zoom]
  351.                                 push edx
  352.                                 push ebx
  353.                                 push eax
  354.                                 push dword[open_file_vox]
  355.  
  356.                                 ;¢ë§®¢ ä㭪権
  357.                                 cmp dword[v_pen_mode],1
  358.                                 jne @f
  359.                                         call buf2d_vox_obj_create_node
  360.                                         ;stdcall buf2d_vox_obj_create_node, [open_file_vox], eax,ebx,edx, [v_zoom], [v_color]
  361.                                         jmp .end_1
  362.                                 @@:
  363.                                         call buf2d_vox_obj_delete_node
  364.                                         ;stdcall buf2d_vox_obj_delete_node, [open_file_vox], eax,ebx,edx, [v_zoom]
  365.  
  366.                         .end_1:
  367.                         call draw_objects
  368.                         call draw_pok
  369.         .end_f:
  370.         popad
  371.         ret
  372.  
  373. ;input:
  374. ; eax - coord y
  375. ; ebx - coord x
  376. align 4
  377. proc get_buf_color, buf:dword
  378. pushad
  379.         mov edi,[buf]
  380.         cmp ax,buf2d_t
  381.         jl .end_f
  382.         sub ax,buf2d_t
  383.         cmp eax,buf2d_h
  384.         jg .end_f
  385.         cmp bx,buf2d_l
  386.         jl .end_f
  387.         sub bx,buf2d_l
  388.         cmp ebx,buf2d_w
  389.         jg .end_f
  390.                 stdcall [buf2d_get_pixel], edi,ebx,eax
  391.                 mov [v_color],eax
  392.                 call on_change_color ;®â®¡à ¦ ¥¬ ¨§¬¥­¥­¨ï 梥â 
  393.         .end_f:
  394. popad
  395.         ret
  396. endp
  397.  
  398. ;¯à¥®¡à §®¢ë¢ ¥¬ ª®®à¤¨­ âã y (§­ ç¥­¨¥ ¤®«¦­® 㢥«¨ç¨¢ âìáï á ­¨§ã ¢¢¥àå)
  399. align 4
  400. convert_y:
  401.         push ecx edx
  402.         mov ecx,[v_zoom]
  403.         cmp ecx,[scaled_zoom]
  404.         jle @f
  405.                 mov ecx,[scaled_zoom]
  406.         @@:
  407.         mov edx,1
  408.         cmp ecx,1
  409.         jl @f
  410.                 shl edx,cl
  411.         @@:
  412.         sub edx,eax
  413.         dec edx
  414.         mov eax,edx
  415.         pop edx ecx
  416.         ret
  417.  
  418. align 4
  419. draw_window:
  420. pushad
  421.         mcall 12,1
  422.  
  423.         ; *** à¨á®¢ ­¨¥ £« ¢­®£® ®ª­  (¢ë¯®«­ï¥âáï 1 à § ¯à¨ § ¯ã᪥) ***
  424.         mov edx,[sc.work]
  425.         or  edx,(3 shl 24)+0x30000000
  426.         mov edi,caption
  427.         mcall 0,dword[wnd_s_pos],dword[wnd_s_pos+4]
  428.  
  429.         ; *** ᮧ¤ ­¨¥ ª­®¯®ª ­  ¯ ­¥«ì ***
  430.         mov eax,8
  431.         mov ebx,(5 shl 16)+20
  432.         mov ecx,(5 shl 16)+20
  433.         mov edx,3
  434.         mov esi,[sc.work_button]
  435.         int 0x40
  436.  
  437.         mov ebx,(30 shl 16)+20
  438.         mov edx,4
  439.         int 0x40
  440.         add ebx,25 shl 16
  441.         mov edx,5
  442.         int 0x40
  443.         add ebx,30 shl 16
  444.         mov edx,6
  445.         int 0x40
  446.         add ebx,25 shl 16
  447.         mov edx,7
  448.         int 0x40
  449.         add ebx,25 shl 16
  450.         mov edx,8
  451.         int 0x40
  452.         add ebx,25 shl 16
  453.         mov edx,9
  454.         int 0x40
  455.         add ebx,25 shl 16
  456.         mov edx,10
  457.         int 0x40
  458.         add ebx,25 shl 16
  459.         mov edx,11
  460.         int 0x40
  461.         add ebx,25 shl 16
  462.         mov edx,12
  463.         int 0x40
  464.         add ebx,25 shl 16
  465.         mov edx,13
  466.         int 0x40
  467.         add ebx,25 shl 16
  468.         mov edx,14
  469.         int 0x40
  470.         add ebx,25 shl 16
  471.         mov edx,15
  472.         int 0x40
  473.         add ebx,25 shl 16
  474.         mov edx,16
  475.         int 0x40
  476.         add ebx,25 shl 16
  477.         mov edx,17
  478.         int 0x40
  479.         add ebx,25 shl 16
  480.         mov edx,18
  481.         int 0x40
  482.         add ebx,25 shl 16
  483.         mov edx,19
  484.         int 0x40
  485.         add ebx,25 shl 16
  486.         mov edx,20
  487.         int 0x40
  488.         add ebx,25 shl 16
  489.         mov edx,21
  490.         int 0x40
  491.         add ebx,25 shl 16
  492.         mov edx,22
  493.         int 0x40
  494.         add ebx,25 shl 16
  495.         mov edx,23
  496.         int 0x40
  497.  
  498.         ; *** à¨á®¢ ­¨¥ ¨ª®­®ª ­  ª­®¯ª å ***
  499.         mov eax,7
  500.         mov ebx,[image_data_toolbar]
  501.         mov ecx,(16 shl 16)+16
  502.         mov edx,(7 shl 16)+7 ;icon new
  503.         int 0x40
  504.  
  505.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  506.         add edx,(25 shl 16) ;icon open
  507.         int 0x40
  508.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  509.         add edx,(25 shl 16) ;icon save
  510.         int 0x40
  511.  
  512.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  513.         add edx,(30 shl 16) ;㢥«¨ç. ¬ áèâ ¡
  514.         int 0x40
  515.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  516.         add edx,(25 shl 16) ;㬥­ìè. ¬ áèâ ¡
  517.         int 0x40
  518.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  519.         add edx,(25 shl 16) ;¯®¢®à®â 1
  520.         int 0x40
  521.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  522.         add edx,(25 shl 16) ;¯®¢®à®â 2
  523.         int 0x40
  524.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  525.         add edx,(25 shl 16) ;ᤢ¨£ ¯«®áª®á⨠+
  526.         int 0x40
  527.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  528.         add edx,(25 shl 16) ;ᤢ¨£ ¯«®áª®á⨠-
  529.         int 0x40
  530.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  531.         add edx,(25 shl 16) ;¨­áâà㬥­â ª à ­¤ è
  532.         int 0x40
  533.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  534.         add edx,(25 shl 16) ;¨­áâà㬥­â ª¨áâì
  535.         int 0x40
  536.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  537.         add edx,(25 shl 16) ;¨­áâà㬥­â § â¨à çª 
  538.         int 0x40
  539.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  540.         add edx,(25 shl 16) ;¢ë¡®à 梥â 
  541.         int 0x40
  542.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  543.         add edx,(25 shl 16) ;®á¢¥é¥­¨¥
  544.         int 0x40
  545.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  546.         add edx,(25 shl 16) ;७¤¥à 2*2
  547.         int 0x40
  548.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  549.         add edx,(25 shl 16) ;ᮧ¤ âì ª¨áâì
  550.         int 0x40
  551.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  552.         add edx,(25 shl 16) ;­ à¨á®¢ âì ª¨áâì
  553.         int 0x40
  554.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  555.         add edx,(25 shl 16) ;è¨à¨­  ª¨á⨠-1
  556.         int 0x40
  557.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  558.         add edx,(25 shl 16) ;è¨à¨­  ª¨á⨠+1
  559.         int 0x40
  560.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  561.         add edx,(25 shl 16) ;¢ëá®â  ª¨á⨠-1
  562.         int 0x40
  563.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  564.         add edx,(25 shl 16) ;¢ëá®â  ª¨á⨠+1
  565.         int 0x40
  566.  
  567.         ; *** à¨á®¢ ­¨¥ ¡ãä¥à®¢ ***
  568.         call draw_objects
  569.         call draw_pok
  570.  
  571.         mcall 12,2
  572. popad
  573.         ret
  574.  
  575. align 4
  576. draw_pok:
  577.         mov eax,47
  578.         mov ecx,[v_zoom]
  579.         mov ebx,(3 shl 16)+(1 shl 31)
  580.         mov edx,((350+6*9) shl 16)+OT_CAPT_Y_COLOR+2
  581.         mov esi,[sc.work_button_text]
  582.         or  esi,(1 shl 30)
  583.         mov edi,[sc.work_button]
  584.         int 0x40 ;¬ áèâ ¡
  585.         mov ecx,[n_plane]
  586.         add edx,115 shl 16 ;9
  587.         int 0x40 ;­®¬¥à á¥ç¥­¨ï
  588.  
  589.         ;®¡­®¢«¥­¨¥ ¯ à ¬¥â஢ ªãàá®à 
  590.         mov dword[txt_curor.size],0
  591.         mov eax,dword[v_cur_x]
  592.         mov edi,txt_curor.size
  593.         call convert_int_to_str
  594.         stdcall str_cat, edi,txt_mull
  595.         mov eax,dword[v_cur_y]
  596.         mov edi,txt_buf
  597.         call convert_int_to_str
  598.         stdcall str_cat, txt_curor.size,edi
  599.         stdcall str_cat, txt_curor.size,txt_space ;§ ¢¥àè î騩 ¯à®¡¥«
  600.  
  601.         ;®¡­®¢«¥­¨¥ ¯ à ¬¥â஢ ª¨áâ¨
  602.         mov dword[txt_brush.size],0
  603.         mov eax,dword[brush_w]
  604.         mov edi,txt_brush.size
  605.         call convert_int_to_str
  606.         stdcall str_cat, edi,txt_mull
  607.         mov eax,dword[brush_h]
  608.         mov edi,txt_buf
  609.         call convert_int_to_str
  610.         stdcall str_cat, txt_brush.size,edi
  611.         stdcall str_cat, txt_brush.size,txt_space ;§ ¢¥àè î騩 ¯à®¡¥«
  612.  
  613.         mov eax,4 ;à¨á®¢ ­¨¥ ⥪áâ 
  614.         mov ebx,(OT_CAPT_X_COLOR shl 16)+OT_CAPT_Y_COLOR+2
  615.         mov ecx,[sc.work_text]
  616.         or  ecx,0x80000000 ;or (1 shl 30)
  617.         mov edx,txt_color
  618.         int 0x40
  619.  
  620.         mov edx,txt_curor
  621.         add ebx,115 shl 16
  622.         or  ecx,(1 shl 30)
  623.         mov edi,[sc.work]
  624.         int 0x40
  625.  
  626.         mov edx,txt_brush
  627.         add ebx,115 shl 16
  628.         int 0x40
  629.  
  630.         mov edx,txt_zoom
  631.         add ebx,115 shl 16
  632.         int 0x40
  633.  
  634.         mov edx,txt_n_plane
  635.         add ebx,115 shl 16
  636.         int 0x40
  637.  
  638.         call on_change_color
  639.         ret
  640.  
  641. align 4
  642. on_change_color:
  643. pushad
  644.         mov ebx,((OT_CAPT_X_COLOR+35) shl 16)+16 ;¯® ®á¨ x
  645.         mov ecx,(OT_CAPT_Y_COLOR shl 16)+12 ;¯® ®á¨ y
  646.         mov edx,[v_color]
  647.         mcall 13
  648.  
  649.         mov ebx,(1 shl 8)+(6 shl 16)
  650.         mov ecx,edx
  651.         mov edx,((OT_CAPT_X_COLOR+55) shl 16)+OT_CAPT_Y_COLOR+2
  652.         mov esi,[sc.work_text]
  653.         add esi,(1 shl 30)
  654.         mov edi,[sc.work]
  655.         mcall 47
  656. popad
  657.         ret
  658.  
  659. align 4
  660. key:
  661.         mcall 2
  662.         jmp still
  663.  
  664.  
  665. align 4
  666. button:
  667.         mcall 17
  668.         cmp ah,3
  669.         jne @f
  670.                 call but_new_file
  671.                 call draw_objects
  672.                 call draw_pok
  673.         @@:
  674.         cmp ah,4
  675.         jne @f
  676.                 call but_open_file
  677.         @@:
  678.         cmp ah,5
  679.         jne @f
  680.                 call but_save_file
  681.         @@:
  682.         cmp ah,6
  683.         jne @f
  684.                 call but_zoom_p
  685.         @@:
  686.         cmp ah,7
  687.         jne @f
  688.                 call but_zoom_m
  689.         @@:
  690.         cmp ah,8
  691.         jne @f
  692.                 call but_3
  693.         @@:
  694.         cmp ah,9
  695.         jne @f
  696.                 call but_4
  697.         @@:
  698.         cmp ah,10
  699.         jne @f
  700.                 call but_5
  701.         @@:
  702.         cmp ah,11
  703.         jne @f
  704.                 call but_6
  705.         @@:
  706.         cmp ah,12
  707.         jne @f
  708.                 call but_mode_pen
  709.         @@:
  710.         cmp ah,13
  711.         jne @f
  712.                 call but_mode_brush
  713.         @@:
  714.         cmp ah,14
  715.         jne @f
  716.                 call but_mode_clear
  717.         @@:
  718.         cmp ah,15
  719.         jne @f
  720.                 stdcall set_pen_mode,PEN_MODE_SELECT_COLOR,3,((9 shl 8)+9) shl 16
  721.                 call draw_palete
  722.         @@:
  723.         cmp ah,16
  724.         jne @f
  725.                 call but_light
  726.         @@:
  727.         cmp ah,17
  728.         jne @f
  729.                 call but_rend_2_2
  730.         @@:
  731.         cmp ah,18
  732.         jne @f
  733.                 call but_brush_copy
  734.         @@:
  735.         cmp ah,19
  736.         jne @f
  737.                 call but_brush_draw
  738.         @@:
  739.         cmp ah,20
  740.         jne @f
  741.                 call but_bru_w_m
  742.         @@:
  743.         cmp ah,21
  744.         jne @f
  745.                 call but_bru_w_p
  746.         @@:
  747.         cmp ah,22
  748.         jne @f
  749.                 call but_bru_h_m
  750.         @@:
  751.         cmp ah,23
  752.         jne @f
  753.                 call but_bru_h_p
  754.         @@:
  755.         cmp ah,1
  756.         jne still
  757. .exit:
  758.         stdcall [buf2d_delete],buf_0
  759.         stdcall [buf2d_delete],buf_0z
  760.         cmp dword[buf_r_img],0
  761.         je @f
  762.                 stdcall [buf2d_delete],buf_r_img
  763.                 stdcall [buf2d_delete],buf_r_z
  764.         @@:
  765.         stdcall [buf2d_vox_brush_delete], buf_vox
  766.         stdcall [buf2d_delete],buf_curs
  767.         stdcall [buf2d_delete],buf_curs_8
  768.         stdcall mem.Free,[image_data_toolbar]
  769.         stdcall mem.Free,[open_file_vox]
  770.         mcall -1
  771.  
  772. align 4
  773. vox_new_data:
  774.         db 2,0,0,0
  775.         db 000b,001b,010b,011b, 100b,101b,110b,111b ;default table
  776.         dd 0 ;null node
  777.  
  778. align 4
  779. proc but_new_file uses ecx edi esi
  780.         mov ecx,vox_offs_data+4
  781.         mov esi,vox_new_data
  782.         mov edi,[open_file_vox]
  783.         cld
  784.         rep movsb
  785.         ret
  786. endp
  787.  
  788. align 4
  789. open_file_vox dd 0 ;㪠§ â¥«ì ­  ®¡« áâì ¤«ï ®âªàëâ¨ï ä ©«®¢
  790.  
  791. align 4
  792. but_open_file:
  793.         pushad
  794.         copy_path open_dialog_name,communication_area_default_path,file_name,0
  795.         mov [OpenDialog_data.type],0
  796.         stdcall [OpenDialog_Start],OpenDialog_data
  797.         cmp [OpenDialog_data.status],2
  798.         je .end_open_file
  799.         ;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
  800.  
  801.         mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
  802.         mov [run_file_70.Function], 0
  803.         mov [run_file_70.Position], 0
  804.         mov [run_file_70.Flags], 0
  805.         m2m dword[run_file_70.Count], dword[max_open_file_size]
  806.         m2m [run_file_70.Buffer], [open_file_vox]
  807.         mov byte[run_file_70+20], 0
  808.         mov dword[run_file_70.FileName], openfile_path
  809.         mov ebx,run_file_70
  810.         int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
  811.         cmp ebx,0xffffffff
  812.         je .end_open_file
  813.  
  814.         ;add ebx,[open_file_vox]
  815.         ;mov byte[ebx],0 ;­  á«ãç © ¥á«¨ à ­¥¥ ¡ë« ®âªàëâ ä ©« ¡®«ì襣® à §¬¥à  ç¨á⨬ ª®­¥æ ¡ãä¥à  á ä ©«®¬
  816.         mcall 71,1,openfile_path
  817.  
  818.         ;---
  819.         ;
  820.         mov eax,[open_file_vox]
  821.         movzx eax,byte[eax]
  822.         and eax,0xff ;¡¥à¥¬ ¬ áèâ ¡ ¯® 㬮«ç ­¨î
  823.         mov dword[v_zoom],eax ;¡¥à¥¬ ¬ áèâ ¡ ¯® 㬮«ç ­¨î
  824.         mov dword[cam_x],0
  825.         mov dword[cam_y],0
  826.         mov dword[cam_z],0
  827.         call draw_objects
  828.         .end_open_file:
  829.         popad
  830.         ret
  831.  
  832. align 4
  833. but_save_file:
  834.         pushad
  835.                 copy_path open_dialog_name,communication_area_default_path,file_name,0
  836.                 mov [OpenDialog_data.type],1
  837.                 stdcall [OpenDialog_Start],OpenDialog_data
  838.                 cmp [OpenDialog_data.status],2
  839.                 je .end_save_file
  840.                 ;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
  841.  
  842.                 mov eax,dword[v_zoom] ;§ ¤ ¥¬ ¬ áèâ ¡ ¯® 㬮«ç ­¨î
  843.                 mov ebx,[open_file_vox]
  844.                 mov byte[ebx],al
  845.  
  846.                 stdcall buf2d_vox_obj_get_size, ebx
  847.                 mov dword[run_file_70.Count], eax ;à §¬¥à ä ©« 
  848.                 mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
  849.                 mov [run_file_70.Function], 2
  850.                 mov [run_file_70.Position], 0
  851.                 mov [run_file_70.Flags], 0
  852.                 mov ebx, dword[open_file_vox]
  853.                 mov [run_file_70.Buffer], ebx
  854.                 mov byte[run_file_70+20], 0
  855.                 mov dword[run_file_70.FileName], openfile_path
  856.                 mov ebx,run_file_70
  857.                 int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
  858.                 cmp ebx,0xffffffff
  859.                 je .end_save_file
  860.  
  861.                 .end_save_file:
  862.         popad
  863.         ret
  864.  
  865. ;㢥«¨ç¥­¨¥ ¬ áèâ ¡ 
  866. align 4
  867. but_zoom_p:
  868.         cmp dword[v_zoom],10 ;¬ ªá¨¬ «ì­ë© à §¬¥à, ¤® ª®â®à®£® ¬®¦­® 㢥«¨ç¨âì 2^10=1024
  869.         jge @f
  870.                 inc dword[v_zoom]
  871.                 shl dword[n_plane],1
  872.                 push eax
  873.                 mov eax,[v_zoom]
  874.                 cmp eax,[scaled_zoom]
  875.                 jl .end_0
  876.                         push ecx
  877.                         mov ecx,[scaled_zoom]
  878.                         xor eax,eax
  879.                         inc eax
  880.                         shl eax,cl
  881.                         shl dword[cam_x],1
  882.                         shl dword[cam_y],1
  883.                         shl dword[cam_z],1
  884.                         cmp eax,[n_plane]
  885.                         jg .end_1
  886.                                 ;ª®à¥ªâ¨à®¢ª  ¯®«§ã­ª 
  887.                                 sub [n_plane],eax
  888.                                 inc dword[cam_y]
  889.                         .end_1:
  890.                         pop ecx
  891.                 .end_0:
  892.                 pop eax
  893.                 call draw_objects
  894.                 call draw_pok
  895.         @@:
  896.         ret
  897.  
  898. ;㬥­ì襭¨¥ ¬ áèâ ¡ 
  899. align 4
  900. but_zoom_m:
  901.         cmp dword[v_zoom],1
  902.         jl @f
  903.                 dec dword[v_zoom]
  904.                 shr dword[n_plane],1
  905.                 push eax
  906.                 mov eax,[v_zoom]
  907.                 cmp eax,[scaled_zoom]
  908.                 jl .end_0
  909.                         shr dword[cam_x],1
  910.                         shr dword[cam_y],1
  911.                         jnc .end_1
  912.                                 ;ª®à¥ªâ¨à®¢ª  ¯®«§ã­ª 
  913.                                 push ecx
  914.                                 mov ecx,[scaled_zoom]
  915.                                 dec ecx
  916.                                 xor eax,eax
  917.                                 inc eax
  918.                                 shl eax,cl
  919.                                 add [n_plane],eax
  920.                                 pop ecx
  921.                         .end_1:
  922.                         shr dword[cam_z],1
  923.                 .end_0:
  924.                 pop eax
  925.                 call draw_objects
  926.                 call draw_pok
  927.         @@:
  928.         ret
  929.  
  930. align 4
  931. but_3:
  932.         stdcall vox_obj_rot_z, [open_file_vox]
  933.         call draw_objects
  934.         ret
  935.  
  936. align 4
  937. but_4:
  938.         stdcall vox_obj_rot_x, [open_file_vox]
  939.         call draw_objects
  940.         ret
  941.  
  942. ;ᤢ¨£ ¥¬ ¯«®áª®áâì á१ 
  943. align 4
  944. but_5:
  945. push eax ecx
  946.         inc dword[n_plane]
  947.         mov eax,[v_zoom]
  948.         cmp eax,[scaled_zoom]
  949.         jle .end_0
  950.                 ;¯à®¨á室¨â ¬ áèâ ¡¨à®¢ ­¨¥
  951.                 mov ecx,[scaled_zoom]
  952.                 xor eax,eax
  953.                 inc eax
  954.                 shl eax,cl
  955.                 cmp eax,[n_plane]
  956.                 jg @f
  957.                         mov dword[n_plane],0
  958.                         inc dword[cam_y] ;¯¥à¥å®¤¨¬ ¢ á®á¥¤­¨© ªã¡
  959.                         neg ecx
  960.                         ;inc ecx
  961.                         add ecx,[v_zoom]
  962.                         xor eax,eax
  963.                         inc eax
  964.                         shl eax,cl
  965.                         cmp eax,[cam_y]
  966.                         jg @f
  967.                                 mov dword[cam_y],0 ;§ æ¨ª«¨¢ ¥¬ ¥á«¨ ¢ë«¥§«¨ §  ¯à¥¤¥«ë ¯®á«¥¤­¥£® ªã¡ 
  968.                 @@:
  969.                 jmp .end_1
  970.         .end_0:
  971.                 ;¬ áèâ ¡¨à®¢ ­¨¥ ­¥ ¯à®¨á室¨â
  972.                 mov ecx,eax
  973.                 xor eax,eax
  974.                 inc eax
  975.                 shl eax,cl
  976.                 cmp eax,[n_plane]
  977.                 jg .end_1
  978.                         mov dword[n_plane],0
  979.         .end_1:
  980.         call draw_objects
  981.         call draw_pok
  982. pop ecx eax
  983.         ret
  984.  
  985. ;ᤢ¨£ ¥¬ ¯«®áª®áâì á१ 
  986. align 4
  987. but_6:
  988.         dec dword[n_plane]
  989.         cmp dword[n_plane],0
  990.         jge .end_f
  991. push eax ecx
  992.         mov ecx,[scaled_zoom]
  993.         xor eax,eax
  994.         inc eax
  995.         shl eax,cl
  996.         dec eax
  997.         mov dword[n_plane],eax
  998.  
  999.         mov eax,[v_zoom]
  1000.         cmp eax,[scaled_zoom]
  1001.         jle .end_0
  1002.                 ;¯à®¨á室¨â ¬ áèâ ¡¨à®¢ ­¨¥
  1003.                 dec dword[cam_y] ;¯¥à¥å®¤¨¬ ¢ á®á¥¤­¨© ªã¡
  1004.                 cmp dword[cam_y],0
  1005.                 jge .end_0
  1006.  
  1007.                 mov ecx,eax
  1008.                 sub ecx,[scaled_zoom]
  1009.                 xor eax,eax
  1010.                 inc eax
  1011.                 shl eax,cl
  1012.                 dec eax
  1013.                 mov dword[cam_y],eax ;¥á«¨ ­®¬¥à ªã¡  ®ª § «áï ¬¥­ìè¥ 0 ¨á¯à ¢«ï¥¬ ­  ¬ ªá¨¬ «ì­®¥ §­ ç¥­¨¥
  1014.         .end_0:
  1015. pop ecx eax
  1016.         .end_f:
  1017.         call draw_objects
  1018.         call draw_pok
  1019.         ret
  1020.  
  1021. align 4
  1022. but_mode_pen:
  1023.         push eax
  1024.         mov eax,dword[v_pen_mode]
  1025.         stdcall set_pen_mode,1,0,((9 shl 8)+9) shl 16 ;pen
  1026.         cmp eax,PEN_MODE_SELECT_COLOR
  1027.         jne @f
  1028.                 call draw_objects
  1029.         @@:
  1030.         pop eax
  1031.         ret
  1032.  
  1033. align 4
  1034. but_mode_brush:
  1035.         push eax
  1036.         mov eax,dword[v_pen_mode]
  1037.         stdcall set_pen_mode,3,1,((9 shl 8)+9) shl 16 ;brush
  1038.         cmp eax,PEN_MODE_SELECT_COLOR
  1039.         jne @f
  1040.                 call draw_objects
  1041.         @@:
  1042.         pop eax
  1043.         ret
  1044.  
  1045. align 4
  1046. but_mode_clear:
  1047.         push eax
  1048.         mov eax,dword[v_pen_mode]
  1049.         stdcall set_pen_mode,PEN_MODE_CLEAR,2,((15 shl 8)+9) shl 16
  1050.         cmp eax,PEN_MODE_SELECT_COLOR
  1051.         jne @f
  1052.                 call draw_objects
  1053.         @@:
  1054.         pop eax
  1055.         ret
  1056.  
  1057. align 4
  1058. but_light:
  1059.         xor dword[mode_light],1
  1060.         call draw_objects
  1061.         ret
  1062.  
  1063. align 4
  1064. but_rend_2_2:
  1065. push edi
  1066.         cmp dword[buf_r_img],0
  1067.         jne @f
  1068.                 ;ᮧ¤ ­¨¥ ¡ãä¥à  ¤«ï ७¤¥à 
  1069.                 push ecx esi
  1070.                 mov edi,buf_r_img
  1071.                 mov esi,buf_0
  1072.                 mov ecx,BUF_STRUCT_SIZE
  1073.                 cld
  1074.                 rep movsb ;ª®¯¨à㥬 ¢á¥ ¯ à ¬¥âàë á ®á­®¢­®£® ¡ãä¥à 
  1075.                 mov edi,buf_r_img
  1076.                 mov buf2d_data,0
  1077.                 shl buf2d_w,1 ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¡ãä¥à 
  1078.                 shl buf2d_h,1
  1079.                 stdcall [buf2d_create],buf_r_img
  1080.  
  1081.                 mov edi,buf_r_z
  1082.                 mov esi,buf_0z
  1083.                 mov ecx,BUF_STRUCT_SIZE
  1084.                 cld
  1085.                 rep movsb ;ª®¯¨à㥬 ¢á¥ ¯ à ¬¥âàë á ®á­®¢­®£® ¡ãä¥à 
  1086.                 mov edi,buf_r_z
  1087.                 mov buf2d_data,0
  1088.                 shl buf2d_w,1 ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¡ãä¥à 
  1089.                 shl buf2d_h,1
  1090.                 stdcall [buf2d_create],buf_r_z
  1091.                 pop esi ecx
  1092.         @@:
  1093.         stdcall [buf2d_clear], buf_r_img, [buf_0.color] ;ç¨á⨬ ¡ãä¥à
  1094.         stdcall [buf2d_clear], buf_r_z, 0 ;ç¨á⨬ ¡ãä¥à
  1095.  
  1096.         push eax ebx ecx
  1097.                 mov eax,[v_zoom]
  1098.                 cmp eax,[scaled_zoom]
  1099.                 jle .end_scaled
  1100.                         ;७¤¥à 㢥«¨ç¥­­®© ç á⨠®¡ê¥ªâ 
  1101.                         mov ebx,[scaled_zoom]
  1102.                         sub eax,ebx
  1103.                         inc ebx
  1104.                         stdcall [buf2d_vox_obj_draw_3g_scaled], buf_r_img, buf_r_z, buf_vox,\
  1105.                                 [open_file_vox], 0,0, 0, ebx, [cam_x],[cam_y],[cam_z],eax, [sc.work_graph]
  1106.                         bt dword[mode_light],0
  1107.                         jnc @f
  1108.                                 stdcall [buf2d_vox_obj_draw_3g_shadows], buf_r_img, buf_r_z, buf_vox, 0,0, 0, ebx, 3
  1109.                         @@:
  1110.                         xor ebx,ebx
  1111.                         xor ecx,ecx
  1112.                         mov edi,buf_r_img
  1113.                         stdcall [buf2d_img_hdiv2], edi
  1114.                         shr buf2d_h,1
  1115.                         stdcall [buf2d_img_wdiv2], edi
  1116.                         shr buf2d_w,1
  1117.                         jmp .show
  1118.                 .end_scaled:
  1119.  
  1120.                 inc eax
  1121.                 stdcall [buf2d_vox_obj_draw_3g], buf_r_img, buf_r_z, buf_vox, [open_file_vox], 0,0, 0, eax
  1122.                 stdcall [buf2d_vox_obj_draw_1g], buf_r_img, buf_r_z, [open_file_vox], 0,0, eax
  1123.                 bt dword[mode_light],0
  1124.                 jnc @f
  1125.                         stdcall [buf2d_vox_obj_draw_3g_shadows], buf_r_img, buf_r_z, buf_vox, 0,0, 0, eax, 3
  1126.                 @@:
  1127.  
  1128.                 mov edi,buf_r_img
  1129.                 stdcall [buf2d_img_hdiv2], edi
  1130.                 shr buf2d_h,1
  1131.                 stdcall [buf2d_img_wdiv2], edi
  1132.                 shr buf2d_w,1
  1133.  
  1134.                 stdcall [buf2d_vox_obj_get_img_w_3g], buf_vox,[v_zoom]
  1135.                 mov ebx,[buf_0.w]
  1136.                 sub ebx,eax
  1137.                 shr ebx,1 ;ebx - ¤«ï 業â஢ª¨ ¬ «¥­ìª¨å ¨§®¡à ¦¥­¨© ¯® £®à¨§®­â «¨
  1138.                 stdcall [buf2d_vox_obj_get_img_h_3g], buf_vox,[v_zoom]
  1139.                 cmp eax,[buf_0.h]
  1140.                 jg @f
  1141.                         mov ecx,[buf_0.h]
  1142.                         sub ecx,eax
  1143.                         shr ecx,1 ;ecx - ¤«ï 業â஢ª¨ ¬ «¥­ìª¨å ¨§®¡à ¦¥­¨© ¯® ¢¥à⨪ «¨
  1144.                 @@:
  1145.                 .show:
  1146.                 stdcall [buf2d_bit_blt], buf_0, ebx,ecx, edi
  1147.                 shl buf2d_h,1
  1148.                 shl buf2d_w,1
  1149.         pop ecx ebx eax
  1150. pop edi
  1151.         stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
  1152.         ret
  1153.  
  1154. ;㬥­ìè ¥¬ è¨à¨­ã ª¨áâ¨
  1155. align 4
  1156. but_bru_w_m:
  1157.         cmp dword[brush_w],1
  1158.         jle @f
  1159.                 dec dword[brush_w]
  1160.                 pushad
  1161.                 call draw_pok
  1162.                 call draw_vox_cursor
  1163.                 stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
  1164.                 popad
  1165.         @@:
  1166.         ret
  1167. ;㢥«¨ç¨¢ ¥¬ è¨à¨­ã ª¨áâ¨
  1168. align 4
  1169. but_bru_w_p:
  1170.         cmp dword[brush_w],32
  1171.         jge @f
  1172.                 inc dword[brush_w]
  1173.                 pushad
  1174.                 call draw_pok
  1175.                 call draw_vox_cursor
  1176.                 stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
  1177.                 popad
  1178.         @@:
  1179.         ret
  1180. ;㬥­ìè ¥¬ ¢ëá®âã ª¨áâ¨
  1181. align 4
  1182. but_bru_h_m:
  1183.         cmp dword[brush_h],1
  1184.         jle @f
  1185.                 dec dword[brush_h]
  1186.                 pushad
  1187.                 call draw_pok
  1188.                 call draw_vox_cursor
  1189.                 stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
  1190.                 popad
  1191.         @@:
  1192.         ret
  1193. ;㢥«¨ç¨¢ ¥¬ ¢ëá®âã ª¨áâ¨
  1194. align 4
  1195. but_bru_h_p:
  1196.         cmp dword[brush_h],32
  1197.         jge @f
  1198.                 inc dword[brush_h]
  1199.                 pushad
  1200.                 call draw_pok
  1201.                 call draw_vox_cursor
  1202.                 stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
  1203.                 popad
  1204.         @@:
  1205.         ret
  1206.  
  1207. align 4
  1208. but_brush_copy:
  1209.         cmp dword[v_pen_mode],3
  1210.         jne .end_f
  1211. pushad
  1212.         mov eax,[v_cur_x]
  1213.         mov ebx,[n_plane]
  1214.         mov edx,[v_cur_y]
  1215.                
  1216.         mov ecx,[v_zoom]
  1217.         cmp ecx,[scaled_zoom]
  1218.         jle @f
  1219.                 ;¯à¥®¡à §®¢ ­¨¥ ª®®à¤¨­ â, á ãç¥â®¬ 㢥«¨ç¥­¨ï
  1220.                 ;sub ecx,[scaled_zoom] ;¢ ecx ¯à¨à®áâ ¬ áèâ ¡  (ecx>0)
  1221.                 mov ecx,[scaled_zoom]
  1222.  
  1223.                 mov edi,[cam_x]
  1224.                 shl edi,cl
  1225.                 add eax,edi
  1226.                 mov edi,[cam_y]
  1227.                 shl edi,cl
  1228.                 add ebx,edi
  1229.                 mov edi,[cam_z]
  1230.                 shl edi,cl
  1231.                 add edx,edi
  1232.         @@:
  1233.  
  1234.         cld
  1235.         mov edi,brush_data
  1236.         mov esi,edx
  1237.         sub esi,[brush_h]
  1238.         .cycle_0:
  1239.         mov ecx,[brush_w]
  1240.         @@:
  1241.                 push eax
  1242.                 stdcall buf2d_vox_obj_node_get_color, [open_file_vox], eax,ebx,edx, [v_zoom]
  1243.                 cmp eax,[v_color]
  1244.                 jne .end_0
  1245.                         mov eax,1 shl 30
  1246.                 .end_0:
  1247.                 mov dword[edi],eax ;color
  1248.                 pop eax
  1249.                 inc eax
  1250.                 add edi,4
  1251.                 loop @b
  1252.         dec edx
  1253.         sub eax,[brush_w]
  1254.         cmp edx,esi
  1255.         jg .cycle_0
  1256.  
  1257.         call draw_objects
  1258. popad
  1259.         .end_f:
  1260.         ret
  1261.  
  1262. align 4
  1263. but_brush_draw:
  1264.         cmp dword[v_pen_mode],3
  1265.         jne .end_f
  1266. pushad
  1267.         mov eax,[v_cur_x]
  1268.         mov ebx,[n_plane]
  1269.         mov edx,[v_cur_y]
  1270.                
  1271.         mov ecx,[v_zoom]
  1272.         cmp ecx,[scaled_zoom]
  1273.         jle @f
  1274.                 ;¯à¥®¡à §®¢ ­¨¥ ª®®à¤¨­ â, á ãç¥â®¬ 㢥«¨ç¥­¨ï
  1275.                 ;sub ecx,[scaled_zoom] ;¢ ecx ¯à¨à®áâ ¬ áèâ ¡  (ecx>0)
  1276.                 mov ecx,[scaled_zoom]
  1277.  
  1278.                 mov edi,[cam_x]
  1279.                 shl edi,cl
  1280.                 add eax,edi
  1281.                 mov edi,[cam_y]
  1282.                 shl edi,cl
  1283.                 add ebx,edi
  1284.                 mov edi,[cam_z]
  1285.                 shl edi,cl
  1286.                 add edx,edi
  1287.         @@:
  1288.  
  1289.         cld
  1290.         mov edi,brush_data
  1291.         mov esi,edx
  1292.         sub esi,[brush_h]
  1293.         .cycle_0:
  1294.         mov ecx,[brush_w]
  1295.         @@:
  1296.                 bt dword[edi],31 ;¡¨â ¯à®§à ç­®áâ¨
  1297.                 jc .end_2
  1298.                 bt dword[edi],30 ;¡¨â ⥪ã饣® 梥â 
  1299.                 jnc .end_0
  1300.                         push dword[v_color]
  1301.                         jmp .end_1
  1302.                 .end_0:
  1303.                         push dword[edi]
  1304.                 .end_1:
  1305.                 stdcall buf2d_vox_obj_create_node, [open_file_vox], eax,ebx,edx, [v_zoom] ;, color
  1306.                 .end_2:
  1307.                 inc eax
  1308.                 add edi,4
  1309.                 loop @b
  1310.         dec edx
  1311.         sub eax,[brush_w]
  1312.         cmp edx,esi
  1313.         jg .cycle_0
  1314.  
  1315.         call draw_objects
  1316. popad
  1317.         .end_f:
  1318.         ret
  1319.  
  1320. align 4
  1321. draw_palete:
  1322.         stdcall [buf2d_clear], buf_0, [buf_0.color] ;ç¨á⨬ ¡ãä¥à
  1323.         stdcall buf2d_draw_palete, buf_0, 5,3, 9,6, 18, 512
  1324.         stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
  1325.         ret
  1326.  
  1327. align 4
  1328. v_zoom dd 3 ;⥪ã騩 ¬ áèâ ¡
  1329. v_cur_x dd 0 ;ª®®à¤¨­ â  ªãàá®à  x
  1330. v_cur_y dd 0 ;ª®®à¤¨­ â  ªãàá®à  y (­® ®áì ¢ ®¡ê¥ªâ¥ z)
  1331. n_plane dd 0 ;¯«®áª®áâì á¥ç¥­¨ï
  1332. v_color dd 0xff ;梥⠪ à ­¤ è 
  1333. v_pen_mode dd PEN_MODE_NONE ;०¨¬ à ¡®âë ªãàá®à  (á¬. ª®­áâ ­âë PEN_MODE_...)
  1334. mode_light dd 1 ;०¨¬ ®á¢¥é¥­¨ï
  1335. cam_x dd 0
  1336. cam_y dd 0
  1337. cam_z dd 0
  1338. scaled_zoom dd 5 ;¬ áèâ ¡ ¯®á«¥ ª®â®à®£® ­ ç¨­ ¥âáï à¨á®¢ ­¨¥ ç á⨠¨§®¡à ¦¥­¨ï
  1339. tile_size dd ? ;à §¬¥à ª¢ ¤à â¨ª  ­  ¯«®áª®á⨠á á¥ç¥­¨¥¬
  1340. max_open_file_size dd ?
  1341. brush_w dd 5 ;è¨à¨­  ª¨áâ¨
  1342. brush_h dd 5 ;¢ëá®â  ª¨áâ¨
  1343. brush_data dd 1 shl 31,1 shl 30,1 shl 30,1 shl 30,1 shl 31
  1344. dd 1 shl 30,1 shl 30,1 shl 30,1 shl 30,1 shl 30
  1345. dd 1 shl 30,1 shl 30,1 shl 30,1 shl 30,1 shl 30
  1346. dd 1 shl 30,1 shl 30,1 shl 30,1 shl 30,1 shl 30
  1347. dd 1 shl 31,1 shl 30,1 shl 30,1 shl 30,1 shl 31
  1348. rd 999 ;32*32-25
  1349.  
  1350. txt_zoom db 'Œ áèâ ¡:',0
  1351. txt_curor: db 'Šãàá®à: '
  1352. .size: rb 10
  1353. txt_n_plane db '‘¥ç¥­¨¥:',0
  1354. txt_color db '–¢¥â:',0
  1355. txt_brush: db 'Š¨áâì: '
  1356. .size: rb 10
  1357. txt_mull db '*',0
  1358. txt_space db ' ',0
  1359. txt_buf rb 16
  1360.  
  1361. align 4
  1362. draw_objects:
  1363.         stdcall [buf2d_clear], buf_0, [buf_0.color] ;ç¨á⨬ ¡ãä¥à
  1364.         stdcall [buf2d_clear], buf_0z, 0 ;ç¨á⨬ ¡ãä¥à
  1365.         stdcall [buf2d_clear], buf_pl, [buf_pl.color] ;ç¨á⨬ ¡ãä¥à
  1366.  
  1367.         cmp dword[v_pen_mode],PEN_MODE_SELECT_COLOR
  1368.         jne @f
  1369.                 call draw_palete
  1370.                 jmp .end_f
  1371.         @@:
  1372.         push eax ebx ecx
  1373.         stdcall [buf2d_vox_obj_get_img_w_3g], buf_vox,[v_zoom]
  1374.         mov ebx,[buf_0.w]
  1375.         sub ebx,eax
  1376.         shr ebx,1 ;ebx - ¤«ï 業â஢ª¨ ¬ «¥­ìª¨å ¨§®¡à ¦¥­¨© ¯® £®à¨§®­â «¨
  1377.  
  1378.         xor ecx,ecx
  1379.         stdcall [buf2d_vox_obj_get_img_h_3g], buf_vox,[v_zoom]
  1380.         cmp eax,[buf_0.h]
  1381.         jg @f
  1382.                 mov ecx,[buf_0.h]
  1383.                 sub ecx,eax
  1384.                 shr ecx,1 ;ecx - ¤«ï 業â஢ª¨ ¬ «¥­ìª¨å ¨§®¡à ¦¥­¨© ¯®
  1385.         @@:
  1386.  
  1387.         mov eax,[v_zoom]
  1388.         cmp eax,[scaled_zoom]
  1389.         jg @f
  1390.                 ;®¡ëç­ë© ०¨¬ ¨§®¡à ¦¥­¨ï
  1391.                 stdcall [buf2d_vox_obj_draw_3g], buf_0, buf_0z, buf_vox,\
  1392.                         [open_file_vox], ebx,ecx, 0, eax
  1393.                 stdcall [buf2d_vox_obj_draw_pl], buf_pl, [open_file_vox],\
  1394.                         OT_MAP_X,OT_MAP_Y,[tile_size], eax, [n_plane], [sc.work_graph]
  1395.                 stdcall [buf2d_vox_obj_draw_1g], buf_0, buf_0z,\
  1396.                         [open_file_vox], 0,0, eax
  1397.                 bt dword[mode_light],0
  1398.                 jnc .end_1
  1399.                         stdcall [buf2d_vox_obj_draw_3g_shadows], buf_0, buf_0z, buf_vox, ebx,ecx, 0, eax, 3
  1400.                 .end_1:
  1401.                 jmp .end_0
  1402.         @@:
  1403.                 ;०¨¬ ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
  1404.                 sub eax,[scaled_zoom]
  1405.                 stdcall [buf2d_vox_obj_draw_3g_scaled], buf_0, buf_0z, buf_vox,\
  1406.                         [open_file_vox], 0,0, 0, [scaled_zoom], [cam_x],[cam_y],[cam_z],eax, [sc.work_graph] ;scroll -> 2^eax
  1407.                 stdcall [buf2d_vox_obj_draw_pl_scaled], buf_pl, [open_file_vox],\
  1408.                         OT_MAP_X,OT_MAP_Y,[tile_size], [scaled_zoom], [n_plane], [sc.work_graph],[cam_x],[cam_y],[cam_z],eax
  1409.                 bt dword[mode_light],0
  1410.                 jnc .end_2
  1411.                         stdcall [buf2d_vox_obj_draw_3g_shadows], buf_0, buf_0z, buf_vox, 0,0, 0, [scaled_zoom], 3
  1412.                 .end_2:
  1413.         .end_0:
  1414.         pop ecx ebx eax
  1415.  
  1416.         call draw_vox_cursor
  1417.         stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
  1418.         stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
  1419.         .end_f:
  1420.         ret
  1421.  
  1422. ;à¨á®¢ ­¨¥ ªãàá®à 
  1423. align 4
  1424. draw_vox_cursor:
  1425. pushad
  1426.         mov ecx,[v_zoom]
  1427.         cmp ecx,[scaled_zoom]
  1428.         jle @f
  1429.                 mov ecx,[scaled_zoom]
  1430.         @@:
  1431.         xor edx,edx
  1432.         inc edx
  1433.         shl edx,cl
  1434.  
  1435.         mov eax,[v_cur_x]
  1436.         cmp eax,edx
  1437.         jge .end_f ;ªãàá®à §  ¯à¥¤¥« ¬¨ ¯®«ï
  1438.         mov edi,[tile_size]
  1439.         imul eax,edi
  1440.         add eax,OT_MAP_X
  1441.         mov ebx,edx
  1442.         dec ebx
  1443.         sub ebx,[v_cur_y]
  1444.         imul ebx,edi
  1445.         add ebx,OT_MAP_Y
  1446.         inc eax
  1447.         inc ebx
  1448.         sub edi,2
  1449.         stdcall [buf2d_rect_by_size], buf_pl, eax,ebx, edi,edi,[sc.work_graph]
  1450.         dec ebx
  1451.         add edi,2
  1452.  
  1453.         cmp dword[v_pen_mode],3
  1454.         je .brush
  1455.  
  1456.         ;£®à¨§®­â «ì­ë¥ «¨­¨¨
  1457.         sub eax,2
  1458.         mov ecx,edi
  1459.         imul edi,edx
  1460.         shr ecx,1
  1461.         add ebx,ecx ;業â஢ª  ¯® á¥à¥¤¨­¥ ª«¥âª¨
  1462.         mov ecx,OT_MAP_X
  1463.         add edi,ecx
  1464.         stdcall [buf2d_line], buf_pl, ecx,ebx, eax,ebx,[sc.work_graph]
  1465.         add eax,[tile_size]
  1466.         inc eax
  1467.         cmp eax,edi
  1468.         jge @f ;¥á«¨ ªãàá®à ­  ªà î ¯®«ï
  1469.                 dec edi
  1470.                 stdcall [buf2d_line], buf_pl, eax,ebx, edi,ebx,[sc.work_graph]
  1471.         @@:
  1472.         jmp .end_f
  1473.  
  1474.         ;à ¬ª  ¤«ï ª¨áâ¨
  1475.         .brush:
  1476.         dec eax
  1477.         mov ecx,[brush_w]
  1478.         imul ecx,[tile_size]
  1479.         ;mov edi,eax
  1480.         mov edi,ecx
  1481.         mov esi,[brush_h]
  1482.         imul esi,[tile_size]
  1483.         stdcall [buf2d_rect_by_size], buf_pl, eax,ebx, edi,esi,[sc.work_graph]
  1484.  
  1485.         .end_f:
  1486. popad
  1487.         ret
  1488.  
  1489. ;hot_p - ª®®à¤¨­ âë £®àï祩 â®çª¨ ªãàá®à , ᬥ饭­ë¥ ­  ¡¨â 16 ((cx shl 8) + cy) shl 16
  1490. align 4
  1491. proc set_pen_mode uses eax ebx ecx edx, mode:dword, icon:dword, hot_p:dword
  1492.         mov eax,[mode]
  1493.         cmp [v_pen_mode],eax
  1494.         je @f
  1495.                 mov [v_pen_mode],eax
  1496.                 mov edx,[hot_p]
  1497.                 mov dx,2 ;LOAD_INDIRECT
  1498.                 mov ecx,[icon]
  1499.                 shl ecx,12 ;㬭®¦ ¥¬ ­  4 ª¡
  1500.                 add ecx,[buf_curs.data]
  1501.                 mcall 37,4
  1502.  
  1503.                 cmp eax,0
  1504.                 je @f
  1505.                         mov [cursor_pointer],eax
  1506.                         mcall 37,5,[cursor_pointer]
  1507.         @@:
  1508.         ret
  1509. endp
  1510.  
  1511. if 0
  1512. ;input:
  1513. ; buf - 㪠§ â¥«ì ­  áâபã, ç¨á«® ¤®«¦­® ¡ëâì ¢ 10 ¨«¨ 16 à¨ç­®¬ ¢¨¤¥
  1514. ;output:
  1515. ; eax - ç¨á«®
  1516. align 4
  1517. proc conv_str_to_int, buf:dword
  1518.         xor eax,eax
  1519.         push ebx ecx esi
  1520.         xor ebx,ebx
  1521.         mov esi,[buf]
  1522.         ;®¯à¥¤¥«¥­¨¥ ®âà¨æ â¥«ì­ëå ç¨á¥«
  1523.         xor ecx,ecx
  1524.         inc ecx
  1525.         cmp byte[esi],'-'
  1526.         jne @f
  1527.                 dec ecx
  1528.                 inc esi
  1529.         @@:
  1530.  
  1531.         cmp word[esi],'0x'
  1532.         je .load_digit_16
  1533.  
  1534.         .load_digit_10: ;áç¨â뢠­¨¥ 10-â¨ç­ëå æ¨äà
  1535.                 mov bl,byte[esi]
  1536.                 cmp bl,'0'
  1537.                 jl @f
  1538.                 cmp bl,'9'
  1539.                 jg @f
  1540.                         sub bl,'0'
  1541.                         imul eax,10
  1542.                         add eax,ebx
  1543.                         inc esi
  1544.                         jmp .load_digit_10
  1545.         jmp @f
  1546.  
  1547.         .load_digit_16: ;áç¨â뢠­¨¥ 16-à¨ç­ëå æ¨äà
  1548.                 add esi,2
  1549.         .cycle_16:
  1550.                 mov bl,byte[esi]
  1551.                 cmp bl,'0'
  1552.                 jl @f
  1553.                 cmp bl,'f'
  1554.                 jg @f
  1555.                 cmp bl,'9'
  1556.                 jle .us1
  1557.                         cmp bl,'A'
  1558.                         jl @f ;®âᥨ¢ ¥¬ ᨬ¢®«ë >'9' ¨ <'A'
  1559.                 .us1: ;á®áâ ¢­®¥ ãá«®¢¨¥
  1560.                 cmp bl,'F'
  1561.                 jle .us2
  1562.                         cmp bl,'a'
  1563.                         jl @f ;®âᥨ¢ ¥¬ ᨬ¢®«ë >'F' ¨ <'a'
  1564.                         sub bl,32 ;¯¥à¥¢®¤¨¬ ᨬ¢®«ë ¢ ¢¥àå­¨© ॣ¨áâà, ¤«ï ã¯à®é¥­¨ï ¨å ¯®á«¥¤ã饩 ®¡à ¡®âª¨
  1565.                 .us2: ;á®áâ ¢­®¥ ãá«®¢¨¥
  1566.                         sub bl,'0'
  1567.                         cmp bl,9
  1568.                         jle .cor1
  1569.                                 sub bl,7 ;convert 'A' to '10'
  1570.                         .cor1:
  1571.                         shl eax,4
  1572.                         add eax,ebx
  1573.                         inc esi
  1574.                         jmp .cycle_16
  1575.         @@:
  1576.         cmp ecx,0 ;¥á«¨ ç¨á«® ®âà¨æ â¥«ì­®¥
  1577.         jne @f
  1578.                 sub ecx,eax
  1579.                 mov eax,ecx
  1580.         @@:
  1581.         pop esi ecx ebx
  1582.         ret
  1583. endp
  1584. end if
  1585.  
  1586. ;input:
  1587. ; eax = value
  1588. ; edi = string buffer
  1589. ;output:
  1590. align 4
  1591. convert_int_to_str:
  1592.         pushad
  1593.                 mov dword[edi+1],0
  1594.                 mov word[edi+5],0
  1595.                 call .str
  1596.         popad
  1597.         ret
  1598.  
  1599. align 4
  1600. .str:
  1601.         mov ecx,0x0a ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï ¨§¬¥­ïîâáï ॣ¨áâàë ebx,eax,ecx,edx ¢å®¤­ë¥ ¯ à ¬¥âàë eax - ç¨á«®
  1602.     ;¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâப㠢§®¤­ë¥ ¤ ­­ë¥ ecx=á¨á⥬  áç¨á«¥­ï edi  ¤à¥á ªã¤  § ¯¨á뢠âì, ¡ã¤¥¬ áâபã, ¯à¨ç¥¬ ª®­¥æ ¯¥à¥¬¥­­®©
  1603.         cmp eax,ecx  ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
  1604.         jb @f
  1605.                 xor edx,edx  ;®ç¨áâ¨âì edx
  1606.                 div ecx      ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
  1607.                 push edx     ;¯®«®¦¨âì ¢ á⥪
  1608.                 ;dec edi             ;ᬥ饭¨¥ ­¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®­æ  áâப¨
  1609.                 call .str ;¯¥à¥©â¨ ­  á ¬ã ᥡï â.¥. ¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
  1610.                 pop eax
  1611.         @@: ;cmp al,10 ;¯à®¢¥à¨âì ­¥ ¬¥­ìè¥ «¨ §­ ç¥­¨¥ ¢ al 祬 10 (¤«ï á¨á⥬ë áç¨á«¥­ï 10 ¤ ­­ ï ª®¬ ­¤  - «¨è­ ï))
  1612.         or al,0x30  ;¤ ­­ ï ª®¬ ­¤  ª®à®ç¥  ç¥¬ ¤¢¥ ¢ëè¥
  1613.         stosb       ;§ ¯¨á âì í«¥¬¥­â ¨§ ॣ¨áâà  al ¢ ï祪㠯 ¬ï⨠es:edi
  1614.         ret           ;¢¥à­ãâìáï ç¥­ì ¨­â¥à¥á­ë© 室 â.ª. ¯®ª  ¢ á⥪¥ åà ­¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï
  1615.  
  1616. align 4
  1617. proc str_cat, str1:dword, str2:dword
  1618.         push eax ecx edi esi
  1619.         mov esi,dword[str2]
  1620.         stdcall str_len,esi
  1621.         mov ecx,eax
  1622.         inc ecx
  1623.         mov edi,dword[str1]
  1624.         stdcall str_len,edi
  1625.         add edi,eax
  1626.         cld
  1627.         repne movsb
  1628.         pop esi edi ecx eax
  1629.         ret
  1630. endp
  1631.  
  1632. ;output:
  1633. ; eax = strlen
  1634. align 4
  1635. proc str_len, str1:dword
  1636.         mov eax,[str1]
  1637.         @@:
  1638.                 cmp byte[eax],0
  1639.                 je @f
  1640.                 inc eax
  1641.                 jmp @b
  1642.         @@:
  1643.         sub eax,[str1]
  1644.         ret
  1645. endp
  1646.  
  1647. ;¤ ­­ë¥ ¤«ï ¤¨ «®£  ®âªàëâ¨ï ä ©«®¢
  1648. align 4
  1649. OpenDialog_data:
  1650. .type                   dd 0 ;0 - ®âªàëâì, 1 - á®åà ­¨âì, 2 - ¢ë¡à âì ¤â४â®à¨î
  1651. .procinfo               dd procinfo     ;+4
  1652. .com_area_name          dd communication_area_name      ;+8
  1653. .com_area               dd 0    ;+12
  1654. .opendir_path           dd plugin_path  ;+16
  1655. .dir_default_path       dd default_dir ;+20
  1656. .start_path             dd file_name ;+24 ¯ãâì ª ¤¨ «®£ã ®âªàëâ¨ï ä ©«®¢
  1657. .draw_window            dd draw_window  ;+28
  1658. .status                 dd 0    ;+32
  1659. .openfile_path          dd openfile_path        ;+36 ¯ãâì ª ®âªà뢠¥¬®¬ã ä ©«ã
  1660. .filename_area          dd filename_area        ;+40
  1661. .filter_area            dd Filter
  1662. .x:
  1663. .x_size                 dw 420 ;+48 ; Window X size
  1664. .x_start                dw 10 ;+50 ; Window X position
  1665. .y:
  1666. .y_size                 dw 320 ;+52 ; Window y size
  1667. .y_start                dw 10 ;+54 ; Window Y position
  1668.  
  1669. default_dir db '/rd/1',0
  1670.  
  1671. communication_area_name:
  1672.         db 'FFFFFFFF_open_dialog',0
  1673. open_dialog_name:
  1674.         db 'opendial',0
  1675. communication_area_default_path:
  1676.         db '/rd/1/File managers/',0
  1677.  
  1678. Filter:
  1679. dd Filter.end - Filter ;.1
  1680. .1:
  1681. db 'VOX',0
  1682. .end:
  1683. db 0
  1684.  
  1685.  
  1686.  
  1687. head_f_i:
  1688. head_f_l db '‘¨á⥬­ ï ®è¨¡ª ',0
  1689.  
  1690. system_dir_0 db '/sys/lib/'
  1691. lib_name_0 db 'proc_lib.obj',0
  1692. err_message_found_lib_0 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,0
  1693. err_message_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,0
  1694.  
  1695. system_dir_1 db '/sys/lib/'
  1696. lib_name_1 db 'libimg.obj',0
  1697. err_message_found_lib_1 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'libimg.obj',39,0
  1698. err_message_import_1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libimg.obj',39,0
  1699.  
  1700. system_dir_2 db '/sys/lib/'
  1701. lib_name_2 db 'buf2d.obj',0
  1702. err_msg_found_lib_2 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'buf2d.obj',39,0
  1703. err_msg_import_2 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'buf2d',39,0
  1704.  
  1705. system_dir_3 db '/sys/lib/'
  1706. lib_name_3 db 'libini.obj',0
  1707. err_msg_found_lib_3 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'libini.obj',39,0
  1708. err_msg_import_3 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libini',39,0
  1709.  
  1710. l_libs_start:
  1711.         lib0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
  1712.                 err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i
  1713.         lib1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\
  1714.                 err_message_found_lib_1, head_f_l, import_libimg, err_message_import_1, head_f_i
  1715.         lib_2 l_libs lib_name_2, sys_path, library_path, system_dir_2,\
  1716.                 err_msg_found_lib_2,head_f_l,import_buf2d,err_msg_import_2,head_f_i
  1717.         lib_3 l_libs lib_name_3, sys_path, library_path, system_dir_3,\
  1718.                 err_msg_found_lib_3,head_f_l,import_libini,err_msg_import_3,head_f_i
  1719. l_libs_end:
  1720.  
  1721. align 4
  1722. import_libimg:
  1723.         dd alib_init1
  1724.         img_is_img  dd aimg_is_img
  1725.         img_info    dd aimg_info
  1726.         img_from_file dd aimg_from_file
  1727.         img_to_file dd aimg_to_file
  1728.         img_from_rgb dd aimg_from_rgb
  1729.         img_to_rgb  dd aimg_to_rgb
  1730.         img_to_rgb2 dd aimg_to_rgb2
  1731.         img_decode  dd aimg_decode
  1732.         img_encode  dd aimg_encode
  1733.         img_create  dd aimg_create
  1734.         img_destroy dd aimg_destroy
  1735.         img_destroy_layer dd aimg_destroy_layer
  1736.         img_count   dd aimg_count
  1737.         img_lock_bits dd aimg_lock_bits
  1738.         img_unlock_bits dd aimg_unlock_bits
  1739.         img_flip    dd aimg_flip
  1740.         img_flip_layer dd aimg_flip_layer
  1741.         img_rotate  dd aimg_rotate
  1742.         img_rotate_layer dd aimg_rotate_layer
  1743.         img_draw    dd aimg_draw
  1744.  
  1745.         dd 0,0
  1746.         alib_init1   db 'lib_init',0
  1747.         aimg_is_img  db 'img_is_img',0 ;®¯à¥¤¥«ï¥â ¯® ¤ ­­ë¬, ¬®¦¥â «¨ ¡¨¡«¨®â¥ª  ᤥ« âì ¨§ ­¨å ¨§®¡à ¦¥­¨¥
  1748.         aimg_info    db 'img_info',0
  1749.         aimg_from_file db 'img_from_file',0
  1750.         aimg_to_file db 'img_to_file',0
  1751.         aimg_from_rgb db 'img_from_rgb',0
  1752.         aimg_to_rgb  db 'img_to_rgb',0 ;¯à¥®¡à §®¢ ­¨¥ ¨§®¡à ¦¥­¨ï ¢ ¤ ­­ë¥ RGB
  1753.         aimg_to_rgb2 db 'img_to_rgb2',0
  1754.         aimg_decode  db 'img_decode',0 ; ¢â®¬ â¨ç¥áª¨ ®¯à¥¤¥«ï¥â ä®à¬ â £à ä¨ç¥áª¨å ¤ ­­ëå
  1755.         aimg_encode  db 'img_encode',0
  1756.         aimg_create  db 'img_create',0
  1757.         aimg_destroy db 'img_destroy',0
  1758.         aimg_destroy_layer db 'img_destroy_layer',0
  1759.         aimg_count   db 'img_count',0
  1760.         aimg_lock_bits db 'img_lock_bits',0
  1761.         aimg_unlock_bits db 'img_unlock_bits',0
  1762.         aimg_flip    db 'img_flip',0
  1763.         aimg_flip_layer db 'img_flip_layer',0
  1764.         aimg_rotate  db 'img_rotate',0
  1765.         aimg_rotate_layer db 'img_rotate_layer',0
  1766.         aimg_draw    db 'img_draw',0
  1767.  
  1768. align 4
  1769. proclib_import: ;®¯¨á ­¨¥ íªá¯®àâ¨à㥬ëå ä㭪権
  1770.         OpenDialog_Init dd aOpenDialog_Init
  1771.         OpenDialog_Start dd aOpenDialog_Start
  1772. dd 0,0
  1773.         aOpenDialog_Init db 'OpenDialog_init',0
  1774.         aOpenDialog_Start db 'OpenDialog_start',0
  1775.  
  1776. align 4
  1777. import_buf2d:
  1778.         init dd sz_init
  1779.         buf2d_create dd sz_buf2d_create
  1780.         buf2d_create_f_img dd sz_buf2d_create_f_img
  1781.         buf2d_clear dd sz_buf2d_clear
  1782.         buf2d_draw dd sz_buf2d_draw
  1783.         buf2d_delete dd sz_buf2d_delete
  1784.         buf2d_line dd sz_buf2d_line
  1785.         buf2d_rect_by_size dd sz_buf2d_rect_by_size
  1786.         buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size
  1787.         buf2d_circle dd sz_buf2d_circle
  1788.         buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
  1789.         buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
  1790.         buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
  1791.         buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
  1792.         buf2d_bit_blt dd sz_buf2d_bit_blt
  1793.         buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
  1794.         buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
  1795.         buf2d_curve_bezier dd sz_buf2d_curve_bezier
  1796.         buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
  1797.         buf2d_draw_text dd sz_buf2d_draw_text
  1798.         buf2d_crop_color dd sz_buf2d_crop_color
  1799.         buf2d_offset_h dd sz_buf2d_offset_h
  1800.         buf2d_flood_fill dd sz_buf2d_flood_fill
  1801.         buf2d_set_pixel dd sz_buf2d_set_pixel
  1802.         buf2d_get_pixel dd sz_buf2d_get_pixel
  1803.         buf2d_vox_brush_create dd sz_buf2d_vox_brush_create
  1804.         buf2d_vox_brush_delete dd sz_buf2d_vox_brush_delete
  1805.         buf2d_vox_obj_get_img_w_3g dd sz_buf2d_vox_obj_get_img_w_3g
  1806.         buf2d_vox_obj_get_img_h_3g dd sz_buf2d_vox_obj_get_img_h_3g
  1807.         buf2d_vox_obj_draw_1g dd sz_buf2d_vox_obj_draw_1g
  1808.         buf2d_vox_obj_draw_3g dd sz_buf2d_vox_obj_draw_3g
  1809.         buf2d_vox_obj_draw_3g_scaled dd sz_buf2d_vox_obj_draw_3g_scaled
  1810.         buf2d_vox_obj_draw_3g_shadows dd sz_buf2d_vox_obj_draw_3g_shadows
  1811.         buf2d_vox_obj_draw_pl dd sz_buf2d_vox_obj_draw_pl
  1812.         buf2d_vox_obj_draw_pl_scaled dd sz_buf2d_vox_obj_draw_pl_scaled
  1813.  
  1814.         dd 0,0
  1815.         sz_init db 'lib_init',0
  1816.         sz_buf2d_create db 'buf2d_create',0
  1817.         sz_buf2d_create_f_img db 'buf2d_create_f_img',0
  1818.         sz_buf2d_clear db 'buf2d_clear',0
  1819.         sz_buf2d_draw db 'buf2d_draw',0
  1820.         sz_buf2d_delete db 'buf2d_delete',0
  1821.         sz_buf2d_line db 'buf2d_line',0
  1822.         sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0
  1823.         sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0
  1824.         sz_buf2d_circle db 'buf2d_circle',0
  1825.         sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
  1826.         sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
  1827.         sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
  1828.         sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
  1829.         sz_buf2d_bit_blt db 'buf2d_bit_blt',0
  1830.         sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
  1831.         sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
  1832.         sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
  1833.         sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
  1834.         sz_buf2d_draw_text db 'buf2d_draw_text',0
  1835.         sz_buf2d_crop_color db 'buf2d_crop_color',0
  1836.         sz_buf2d_offset_h db 'buf2d_offset_h',0
  1837.         sz_buf2d_flood_fill db 'buf2d_flood_fill',0
  1838.         sz_buf2d_set_pixel db 'buf2d_set_pixel',0
  1839.         sz_buf2d_get_pixel db 'buf2d_get_pixel',0
  1840.         sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
  1841.         sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
  1842.         sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
  1843.         sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
  1844.         sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
  1845.         sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0
  1846.         sz_buf2d_vox_obj_draw_3g_scaled db 'buf2d_vox_obj_draw_3g_scaled',0
  1847.         sz_buf2d_vox_obj_draw_3g_shadows db 'buf2d_vox_obj_draw_3g_shadows',0
  1848.         sz_buf2d_vox_obj_draw_pl db 'buf2d_vox_obj_draw_pl',0
  1849.         sz_buf2d_vox_obj_draw_pl_scaled db 'buf2d_vox_obj_draw_pl_scaled',0
  1850.  
  1851. align 4
  1852. import_libini:
  1853.         dd alib_init2
  1854.         ini_get_str   dd aini_get_str
  1855.         ini_get_int   dd aini_get_int
  1856.         ini_get_color dd aini_get_color
  1857. dd 0,0
  1858.         alib_init2     db 'lib_init',0
  1859.         aini_get_str   db 'ini_get_str',0
  1860.         aini_get_int   db 'ini_get_int',0
  1861.         aini_get_color db 'ini_get_color',0
  1862.  
  1863. mouse_dd dd 0x0
  1864. sc system_colors
  1865.  
  1866. align 16
  1867. procinfo process_information
  1868.  
  1869. ;¡ãä¥à ®á­®¢­®£® ¨§®¡à ¦¥­¨ï
  1870. align 4
  1871. buf_0: dd 0 ;㪠§ â¥«ì ­  ¤a­ë¥ ¨§®¡à ¦¥­¨ï
  1872. .l: dw 5 ;+4 left
  1873. .t: dw 45 ;+6 top
  1874. .w: dd 192+6 ;+8 w
  1875. .h: dd 224+7 ;+12 h
  1876. .color: dd 0xffffff ;+16 color
  1877.         db 24 ;+20 bit in pixel
  1878.  
  1879. ;¡ãä¥à £«ã¡¨­ë ®á­®¢­®£® ¨§®¡à ¦¥­¨ï
  1880. align 4
  1881. buf_0z: dd 0
  1882.         dw 0 ;+4 left
  1883.         dw 0 ;+6 top
  1884. .w: dd 192+6 ;+8 w
  1885. .h: dd 224+7 ;+12 h
  1886. .color: dd 0 ;+16 color
  1887.         db 32 ;+20 bit in pixel
  1888.  
  1889. ;¡ãä¥à ¤«ï à¨á®¢ ­¨ï á१  ®¡ê¥ªâ 
  1890. align 4
  1891. buf_pl: dd 0
  1892. .l: dw 15+192+6 ;+4 left
  1893. .t: dw 45 ;+6 top
  1894. .w: dd 320 ;+8 w
  1895. .h: dd 330 ;+12 h
  1896. .color: dd 0xffffff ;+16 color
  1897.         db 24 ;+20 bit in pixel
  1898.  
  1899. ;¡ãä¥à ¤«ï ã«ãç襭®£® ७¤¥à 
  1900. align 4
  1901. buf_r_img:
  1902.         rb BUF_STRUCT_SIZE
  1903. align 4
  1904. buf_r_z:
  1905.         rb BUF_STRUCT_SIZE
  1906.  
  1907. align 4
  1908. cursor_pointer dd 0 ;㪠§ â¥«ì ­  ¤ ­­ë¥ ¤«ï ªãàá®à 
  1909.  
  1910. buf_curs: ;¡ãä¥à á ªãàá®à ¬¨
  1911. .data: dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
  1912.         dw 0 ;+4 left
  1913.         dw 0 ;+6 top
  1914.         dd 32 ;+8 w
  1915.         dd 32*cursors_count ;+12 h
  1916.         dd 0 ;+16 color
  1917.         db 24 ;+20 bit in pixel
  1918.  
  1919. align 4
  1920. buf_curs_8: ;¡ãä¥à á ¯à®§à ç­®áâìî ¤«ï ªãàá®à®¢
  1921. .data: dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
  1922.         dw 0 ;+4 left
  1923.         dw 0 ;+6 top
  1924.         dd 32 ;+8 w
  1925.         dd 32*cursors_count ;+12 h
  1926.         dd 0 ;+16 color
  1927.         db 24 ;+20 bit in pixel
  1928.  
  1929. ;¤ ­­ë¥ ¤«ï ᮧ¤ ­¨ï ¬¨­¨¬ «ì­®£® ¥¤¨­¨ç­®£® ¢®ªá¥«ï
  1930. align 4
  1931. vox_6_7_z:
  1932. dd 0,0,1,1,0,0,\
  1933.    0,2,2,2,2,0,\
  1934.    2,2,2,2,2,2,\
  1935.    2,3,2,2,3,2,\
  1936.    2,3,3,3,3,2,\
  1937.    0,3,3,3,3,0,\
  1938.    0,0,3,3,0,0
  1939.  
  1940. align 4
  1941. buf_vox:
  1942.         db 6,7,4,3 ;w,h,h_osn,n
  1943.         rb BUF_STRUCT_SIZE*(3+1)
  1944.  
  1945. i_end:
  1946.         wnd_s_pos: ;¬¥áâ® ¤«ï ­ áâ஥ª áâ à⮢®© ¯®§¨æ¨¨ ®ª­ 
  1947.                 rq 0
  1948.         rb 4096 ;2048
  1949. stacktop:
  1950.         sys_path rb 1024
  1951.         file_name:
  1952.                 rb 1024 ;4096
  1953.         library_path rb 1024
  1954.         plugin_path rb 1024 ;4096
  1955.         openfile_path rb 1024 ;4096
  1956.         filename_area rb 256
  1957. mem:
  1958.