Subversion Repositories Kolibri OS

Rev

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