Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2.  
  3. BUF_STRUCT_SIZE equ 21
  4. buf2d_data equ dword[edi] ;¤ ­­ë¥ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  5. buf2d_w equ dword[edi+8] ;è¨à¨­  ¡ãä¥à 
  6. buf2d_h equ dword[edi+12] ;¢ëá®â  ¡ãä¥à 
  7. buf2d_l equ word[edi+4]
  8. buf2d_t equ word[edi+6] ;®âáâ㯠ᢥàåã
  9. buf2d_size_lt equ dword[edi+4] ;®âáâ㯠᫥¢  ¨ á¯à ¢  ¤«ï ¡ãä¥à 
  10. buf2d_color equ dword[edi+16] ;梥â ä®­  ¡ãä¥à 
  11. buf2d_bits equ byte[edi+20] ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
  12.  
  13. vox_offs_tree_table equ 4
  14. vox_offs_data equ 12
  15.  
  16. ;description:
  17. ; äã­ªæ¨ï à¨áãîé ï ®¤¨­®ç­ë© ¢®ªá¥«
  18. ;input:
  19. ; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
  20. ; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
  21. ; buf_v - ¡ãä¥à á ¨§®¡à ¦¥­¨¥¬ ¢®ªá¥«ï (32 ¡¨â )
  22. ; v_color - 梥â
  23. align 4
  24. proc draw_vox, buf_i:dword, buf_z:dword, buf_v:dword,\
  25. coord_x:dword, coord_y:dword, coord_z:dword, v_color:dword
  26. pushad
  27.         mov eax,[coord_x]
  28.         mov ebx,[coord_y]
  29.         mov edi,[buf_v]
  30.         mov ecx,buf2d_h
  31.         mov esi,buf2d_w
  32.         imul ecx,esi
  33.         add esi,eax
  34.         mov edx,buf2d_data
  35.         cld
  36.         ;ecx - count pixels in voxel
  37.         ;edx - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢ ¢®ªá¥«ì­®¬ ¡ãä¥à¥
  38.         ;edi - 㪠§ â¥«ì ­  ¢®ªá¥«ì­ë© ¡ãä¥à
  39.         ;esi - width voxel buffer add coord x
  40.         .cycle:
  41.                 cmp dword[edx],0
  42.                 je @f
  43.                         ;¯à®¢¥à塞 ¡ãä¥à £«ã¡¨­ë
  44.                         push eax
  45.                         stdcall [buf2d_get_pixel], [buf_z],eax,ebx
  46.                         sub eax,[coord_z]
  47.                         cmp eax,[edx]
  48.                         jl .dr_pixel
  49.                                 pop eax
  50.                                 jmp @f
  51.                         .dr_pixel:
  52.                                 ;à¨á㥬 â®çªã
  53.                                 pop eax
  54.                                 stdcall [buf2d_set_pixel], [buf_i],eax,ebx,[v_color]
  55.                                 push ecx
  56.                                 mov ecx,[coord_z]
  57.                                 add ecx,[edx]
  58.                                 stdcall [buf2d_set_pixel], [buf_z],eax,ebx,ecx
  59.                                 pop ecx
  60.                 @@:
  61.                 add edx,4
  62.                 inc eax
  63.                 cmp eax,esi
  64.                 jl @f
  65.                         inc ebx
  66.                         sub eax,buf2d_w
  67.                 @@:
  68.                 loop .cycle
  69. popad
  70.         ret
  71. endp
  72.  
  73. ;description:
  74. ; äã­ªæ¨ï à¨áãîé ï ¢®ªá¥«ì­ë© ®¡ê¥ªâ
  75. ;input:
  76. ; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
  77. ; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
  78. ; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
  79. ; v_obj - ¢®ªá¥«ì­ë© ®¡ê¥ªâ
  80. ; k_scale - ª®íä. ¤«ï ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
  81. align 4
  82. proc buf2d_vox_obj_draw_3g, buf_i:dword, buf_z:dword, h_br:dword, v_obj:dword,\
  83. coord_x:dword, coord_y:dword, coord_z:dword, k_scale:dword
  84. pushad
  85.         mov edi,[v_obj]
  86.         mov eax,[k_scale]
  87.         mov ebx,[coord_x]
  88.  
  89. ;---
  90.         ;â¥á⮢ ï à ¬ª 
  91.         mov ecx,[h_br]
  92.  
  93.         movzx edx,byte[ecx]
  94.         movzx esi,byte[ecx+1]
  95.         cmp eax,1
  96.         jl .end_c0
  97.                 mov ecx,eax
  98.                 shl edx,cl
  99.                 shl esi,cl
  100.         .end_c0:
  101.         stdcall [buf2d_rect_by_size], [buf_i], ebx,[coord_y],edx,esi, 0xd0d0d0
  102. ;---
  103.  
  104.         mov ecx,[coord_y]
  105.         mov edx,eax
  106.         add edi,vox_offs_data
  107.  
  108.         mov esi,[coord_z]
  109.         stdcall vox_go_in_node, [buf_i], [buf_z], [h_br], [v_obj]
  110.  
  111. popad
  112.         ret
  113. endp
  114.  
  115. ;description:
  116. ; äã­ªæ¨ï à¨áãîé ï ⥭¨
  117. ;input:
  118. ; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
  119. ; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
  120. ; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
  121. ; k_scale - ª®íä. ¤«ï ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
  122. align 4
  123. proc buf2d_vox_obj_draw_3g_shadows, buf_i:dword, buf_z:dword, h_br:dword, \
  124. coord_x:dword, coord_y:dword, color:dword, k_scale:dword, prop:dword
  125. locals
  126.         correct_z dd 0 ;ª®à¥ªâ¨à®¢ª  ¤«ï ¡ãä¥à  £«ã¡¨­ë
  127. endl
  128. pushad
  129.         mov eax,[k_scale]
  130.         add eax,[prop]
  131.         mov dword[correct_z],8
  132.         sub [correct_z],eax
  133.         mov ebx,[coord_x]
  134.         ;correct_z = 8-k_scale-prop
  135.  
  136.         stdcall buf2d_vox_obj_get_img_w_3g, [h_br],[k_scale]
  137.         mov edx,eax ;edx - è¨à¨­  ¨§®¡à ¦¥­¨ï
  138.         stdcall buf2d_vox_obj_get_img_h_3g, [h_br],[k_scale]
  139.         mov esi,eax
  140.  
  141.         mov edi,[coord_y]
  142.         mov ecx,edx
  143.         add edx,ebx ;è¨à¨­  + ®âáâ㯠᫥¢ 
  144.         imul ecx,esi
  145.         cld
  146.         .cycle_0:
  147.                 stdcall [buf2d_get_pixel], [buf_z],ebx,edi
  148.                 cmp eax,0
  149.                 je @f
  150.                         stdcall vox_correct_z, [correct_z]
  151.                         push eax
  152.                         stdcall [buf2d_get_pixel], [buf_i],ebx,edi
  153.                         stdcall combine_colors_3,eax,[color] ;,eax
  154.                         stdcall [buf2d_set_pixel], [buf_i],ebx,edi,eax
  155.                 @@:
  156.                 inc ebx
  157.                 cmp ebx,edx
  158.                 jl @f
  159.                         mov ebx,[coord_x]
  160.                         inc edi
  161.                 @@:
  162.                 loop .cycle_0
  163.  
  164. popad
  165.         ret
  166. endp
  167.  
  168. ;output:
  169. ; eax - scaled coord z
  170. align 4
  171. proc vox_correct_z uses ecx, correct_z:dword
  172.         mov ecx,[correct_z]
  173.         cmp ecx,0
  174.         je .end_f
  175.         jl .end_0
  176.                 shl eax,cl
  177.                 jmp .end_f
  178.         .end_0:
  179.                 neg ecx
  180.                 inc ecx
  181.                 shr eax,cl
  182.         .end_f:
  183.         ret
  184. endp
  185.  
  186. ;output:
  187. ; eax - color
  188. align 4
  189. proc combine_colors_3 uses ebx ecx edx edi esi, col_0:dword, col_1:dword, alpha:dword
  190.  
  191.         mov ebx,[col_0]
  192.         mov ecx,[col_1]
  193.         movzx di,byte[alpha] ;pro
  194.         mov si,0x00ff ;---get transparent---
  195.         sub si,di ;256-pro
  196.  
  197.         ;---blye---
  198.         movzx ax,bl
  199.         imul ax,si
  200.         movzx dx,cl
  201.         imul dx,di
  202.         add ax,dx
  203.         mov cl,ah
  204.         ;---green---
  205.         movzx ax,bh
  206.         imul ax,si
  207.         movzx dx,ch
  208.         imul dx,di
  209.         add ax,dx
  210.         mov ch,ah
  211.         shr ebx,16
  212.         ror ecx,16
  213.         ;---red---
  214.         movzx ax,bl
  215.         imul ax,si
  216.         movzx dx,cl
  217.         imul dx,di
  218.         add ax,dx
  219.  
  220.         shl eax,8
  221.         ror ecx,16
  222.         mov ax,cx
  223.         and eax,0xffffff
  224.  
  225.         ret
  226. endp
  227.  
  228. ;input:
  229. ; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
  230. ; ebx - coord_x
  231. ; ecx - coord_y
  232. ; esi - coord_z
  233. ; edx - ã஢¥­ì ⥪ã襣® 㧫 
  234. ; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
  235. align 4
  236. proc vox_go_in_node, buf_i:dword, buf_z:dword, h_br:dword, v_obj:dword
  237. ;, coord_z:dword
  238.         cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
  239.         je .sub_trees
  240.                 ;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
  241.                 push eax ecx
  242.  
  243.                 ;¯à®à¨á®¢ª  à ¬ª¨ ¥á«¨ à §¬¥à 㧫  = 1
  244.                 cmp edx,0
  245.                 jne .end_2
  246.                         push eax
  247.                                 stdcall vox_get_sub_brush,[h_br],0 ;®¯à¥¤¥«ï¥¬ ª¨áâì ¤«ï à¨á®¢ ­¨ï
  248.                                 cmp eax,0 ;¥á«¨ ª¨áâì ­¥ ­ ©¤¥­ 
  249.                                 je @f
  250.                                         stdcall draw_vox, [buf_i], [buf_z], eax, ebx,ecx,esi, [edi]
  251.                                 @@:
  252.                         pop eax
  253.                 .end_2:
  254.  
  255.                 ;¢å®¤ ¢­ãâàì 㧫 
  256.                 dec edx
  257. ;---
  258.                 push ebx
  259.                         ;mov eax,(7-4/2)
  260.                         mov ebx,[h_br]
  261.                         movzx eax,byte[ebx+1]
  262.                         movzx ebx,byte[ebx+2]
  263.                         shr ebx,1
  264.                         sub eax,ebx
  265.                 cmp edx,1
  266.                 jl .end_c1
  267.                 push ecx
  268.                         mov ecx,edx
  269.                         shl eax,cl
  270.                         shl ebx,cl ;???
  271.                 pop ecx
  272.                 .end_c1:
  273.                 add esi,ebx ;???
  274.                 pop ebx
  275.                 add ecx,eax ;ª®à¥ªâ¨à®¢ª  ¢ëá®âë ¯®¤ ¢®ªá¥«ì ­¨¦­¥£® ã஢­ï
  276. ;---
  277.                 mov ah,byte[edi+3]
  278.                 add edi,4
  279.                 mov al,8
  280.                 .cycle:
  281.                         bt ax,8 ;â¥áâ¨à㥬 ⮫쪮 ah
  282.                         jnc .c_next
  283.                                 push ebx ecx esi
  284.                                 stdcall vox_corect_coords, [h_br], [v_obj]
  285.                                 stdcall vox_go_in_node, [buf_i], [buf_z], [h_br], [v_obj]
  286.                                 pop esi ecx ebx
  287.                         .c_next:
  288.                         shr ah,1
  289.                         dec al
  290.                         jnz .cycle
  291.  
  292.                 ;¢ë室 ¨§ 㧫 
  293.                 inc edx
  294.                 pop ecx eax
  295.  
  296.                 jmp .end_f
  297.         .sub_trees:
  298.                 ;à¨á㥬 㧥«
  299.                 push eax
  300.                         stdcall vox_get_sub_brush,[h_br],edx ;®¯à¥¤¥«ï¥¬ ª¨áâì ¤«ï à¨á®¢ ­¨ï
  301.                         cmp eax,0 ;¥á«¨ ª¨áâì ­¥ ­ ©¤¥­ 
  302.                         je @f
  303.                                 stdcall draw_vox, [buf_i], [buf_z], eax, ebx,ecx,esi, [edi]
  304.                         @@:
  305.                 pop eax
  306.  
  307.                 add edi,4
  308.         .end_f:
  309.         ret
  310. endp
  311.  
  312. ;¨§¢«¥ª ¥¬ ¨§ h_br 㪠§ â¥«ì ­  ¡ãä¥à á ¨§®¡à ¦¥­¨¥¬ ¢®ªá¥«ï, 㪠§ ­­®£® ¯®à浪  n
  313. align 4
  314. proc vox_get_sub_brush uses ebx ecx, h_br:dword, n:dword
  315.         xor eax,eax
  316.         mov ebx,[n]
  317.         cmp ebx,0
  318.         jl @f
  319.         mov ecx,[h_br]
  320.         cmp bl,byte[ecx+3]
  321.         jg @f
  322.                 add ecx,4
  323.                 imul ebx,BUF_STRUCT_SIZE
  324.                 mov eax,ebx
  325.                 add eax,ecx
  326.         @@:
  327.         ret
  328. endp
  329.  
  330. ;äã­ªæ¨ï ¤«ï ª®à¥ªâ¨à®¢ª¨ ª®®à¤¨­ â
  331. ;­ ¯à ¢«¥­¨ï ®á¥© ª®®à¤¨­ â ¢ ¢®ªá¥«¥:
  332. ;*z
  333. ;|
  334. ;+
  335. ;  * y
  336. ; /
  337. ;+
  338. ; \
  339. ;  * x
  340. ;input:
  341. ;  al - ­®¬¥à 㧫  ¢ ¤¥à¥¢¥ (®â 1 ¤® 8)
  342. ; ebx - ª®®à¤¨­ â  x
  343. ; ecx - ª®®à¤¨­ â  y
  344. ; esi - ª®®à¤¨­ â  z
  345. ; edx - ã஢¥­ì ⥪ã襣® 㧫 
  346. ;output:
  347. ; ebx - ­®¢ ï ª®®à¤¨­ â  x
  348. ; ecx - ­®¢ ï ª®®à¤¨­ â  y
  349. ; esi - ­®¢ ï ª®®à¤¨­ â  z
  350. align 4
  351. proc vox_corect_coords, h_br:dword, v_obj:dword
  352. locals
  353.         osn_w_2 dd ? ;è¨à¨­  ®á­®¢ ­¨ï ¥¤¨­¨ç­®£® ¢®ªá¥«ï : 2
  354.         vox_h dd ? ;¢ëá®â  ¥¤¨­¨ç­®£® ¢®ªá¥«ï
  355. endl
  356.         cmp edx,0
  357.         jl .end_f ;¤«ï ã᪮७¨ï ®âà¨á®¢ª¨
  358.  
  359.         push eax edi
  360.         and eax,15 ;¢ë¤¥«ï¥¬ ­®¬¥à 㧫  ¢ ¤¥à¥¢¥
  361.         mov edi,[v_obj]
  362.         add edi,vox_offs_tree_table
  363.         add edi,8
  364.         sub edi,eax
  365.  
  366.         push ebx ecx
  367.                 mov ebx,[h_br]
  368.  
  369.                 movzx ecx,byte[ebx]
  370.                 shr ecx,1
  371.                 mov dword[osn_w_2],ecx
  372.  
  373.                 movzx ecx,byte[ebx+2]
  374.                 movzx ebx,byte[ebx+1]
  375.                 sub ebx,ecx
  376.                 mov dword[vox_h],ebx
  377.                 shr ecx,1
  378.                 mov eax,ecx ;eax - ¢ëá®â  ®á­®¢ ­¨ï ¥¤¨­¨ç­®£® ¢®ªá¥«ï : 2
  379.         pop ecx ebx
  380.  
  381.         cmp edx,1
  382.         jl .no_scale ;¢® ¨§¡¥¦ ­¨¥ § æ¨ª«¨¢ ­¨ï
  383.         push ecx
  384.                 mov ecx,edx
  385.                 shl eax,cl
  386.                 shl dword[osn_w_2],cl
  387.                 shl dword[vox_h],cl
  388.         pop ecx
  389.         .no_scale:
  390.  
  391. ;       add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z (ª®¬¯¥­á æ¨ï ¤«ï ª®®à¤¨­ âë y)
  392.         bt word[edi],0 ;test voxel coord x
  393.         jnc @f
  394.                 add ebx,[osn_w_2]
  395.                 add ecx,eax
  396.                 add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
  397.         @@:
  398.         bt word[edi],1 ;test voxel coord y
  399.         jnc @f
  400.                 add ebx,[osn_w_2]
  401.                 sub ecx,eax
  402.                 sub esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
  403.         @@:
  404.         bt word[edi],2 ;test voxel coord z
  405.         jnc @f
  406.                 sub ecx,[vox_h]
  407.         @@:
  408.         pop edi eax
  409.         .end_f:
  410.         ret
  411. endp
  412.  
  413. ;
  414. ;x0y0 - x1y0
  415. ;x1y0 - x1y1
  416. ;x0y1 - x0y0
  417. ;x1y1 - x0y1
  418. align 4
  419. proc vox_obj_rot_z uses eax ebx ecx, v_obj:dword
  420.         mov ebx,[v_obj]
  421.         add ebx,vox_offs_tree_table
  422.         mov ecx,2
  423.         cld
  424.         @@:
  425.                 mov eax,dword[ebx]
  426.                 mov byte[ebx+1],al
  427.                 mov byte[ebx+3],ah
  428.                 shr eax,16
  429.                 mov byte[ebx],al
  430.                 mov byte[ebx+2],ah
  431.                 add ebx,4
  432.                 loop @b
  433.         ret
  434. endp
  435.  
  436. ;
  437. ;y0z0 - y0z1
  438. ;y0z1 - y1z1
  439. ;y1z1 - y1z0
  440. ;y1z0 - y0z0
  441. align 4
  442. proc vox_obj_rot_x uses eax ebx ecx, v_obj:dword
  443.         mov ebx,[v_obj]
  444.         add ebx,vox_offs_tree_table
  445.         mov eax,dword[ebx]
  446.         mov ecx,dword[ebx+4]
  447.  
  448.         mov byte[ebx+4],al
  449.         mov byte[ebx+5],ah
  450.         shr eax,16
  451.         mov byte[ebx+0],al
  452.         mov byte[ebx+1],ah
  453.  
  454.         mov byte[ebx+6],cl
  455.         mov byte[ebx+7],ch
  456.         shr ecx,16
  457.         mov byte[ebx+2],cl
  458.         mov byte[ebx+3],ch
  459.  
  460.         ret
  461. endp
  462.  
  463. ;à¨á®¢ ­¨¥ á१  ¨§®¡à ¦¥­¨ï
  464. ; v_size - à §¬¥à ª¢ ¤à â  á ¢®ªá¥«¥¬
  465. ; k_scale - á⥯¥­ì ¤¥â «¨§ æ¨¨ ¨§®¡à ¦¥­¨ï
  466. ; n_plane - ­®¬¥à ¯«®áª®á⨠á¥ç­¨ï (¢ ¯à¥¤¥« å ®â 0 ¤® 2^k_scale - 1)
  467. ; b_color - 梥⠣࠭¨æë
  468. align 4
  469. proc buf2d_vox_obj_draw_pl, buf_i:dword, v_obj:dword, coord_x:dword,\
  470. coord_y:dword, v_size:dword, k_scale:dword, n_plane:dword, b_color:dword
  471.         cmp [k_scale],0
  472.         jl .end_f
  473. pushad
  474.         mov eax,[v_size]
  475.         mov ecx,[k_scale]
  476.         mov ebx,eax
  477.         cmp ecx,1
  478.         jl @f
  479.                 shl ebx,cl
  480.         @@:
  481.         ;ebx - ¯®«­ë© à §¬¥à ¨§®¡à ¦¥­¨ï
  482.         stdcall [buf2d_rect_by_size], [buf_i], [coord_x],[coord_y],ebx,ebx, [b_color] ;à ¬ª  ­  à¨áã­®ª
  483.         add ebx,[coord_y]
  484.         mov edx,[n_plane]
  485.         imul edx,eax
  486.         add edx,[coord_x]
  487.         stdcall [buf2d_filled_rect_by_size], [buf_i], edx,ebx, eax,eax, [b_color] ;ª¢ ¤à â¨ª, ¯®ª §ë¢ î騩 ­®¬¥à á¥ç¥­¨ï
  488.  
  489.         ;à¨á®¢ ­¨¥ â®ç¥ª ¤«ï á¥âª¨
  490.         push ecx
  491.         mov edi,1
  492.         cmp ecx,1
  493.         jl @f
  494.                 shl edi,cl
  495.         @@:
  496.         dec edi
  497.         cmp edi,1
  498.         jl .end_0
  499.         mov ecx,edi
  500.         imul ecx,edi
  501.         mov ebx,[coord_x]
  502.         mov edx,[coord_y]
  503.         add edx,eax
  504.         xor esi,esi
  505.         cld
  506.         @@:
  507.                 add ebx,eax
  508.                 inc esi
  509.                 stdcall [buf2d_set_pixel], [buf_i], ebx,edx, [b_color]
  510.                 cmp esi,edi
  511.                 jl .end_1
  512.                         ;¯¥à¥å®¤ â®ç¥ª ­  ­®¢ãî áâபã
  513.                         xor esi,esi
  514.                         mov ebx,[coord_x]
  515.                         add edx,eax
  516.                 .end_1:
  517.                 loop @b
  518.         .end_0:
  519.         pop ecx
  520.  
  521.         ;eax - à §¬¥à ®¤­®£® ª¢ ¤à â 
  522.         ;edi - 㪠§ â¥«ì à¨áã¥¬ë¥ ¤ ­­ë¥ ¨§ ®¡ê¥ªâ 
  523.         mov ebx,[coord_x]
  524.         mov edx,[coord_y]
  525.         mov edi,[v_obj]
  526.         add edi,vox_offs_data
  527.         xor esi,esi
  528.         push eax
  529.         imul eax,[n_plane]
  530.         stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj], eax
  531. popad
  532.         .end_f:
  533.         ret
  534. endp
  535.  
  536. ;input:
  537. ; ebx - coord_x
  538. ; edx - coord_y
  539. ; esi - coord_z
  540. ; ecx - ã஢¥­ì ⥪ã襣® 㧫 
  541. ; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
  542. align 4
  543. proc draw_sub_vox_obj_pl, buf_i:dword, v_obj:dword, clip_z:dword,\
  544. v_size:dword
  545.         cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
  546.         je .sub_trees
  547.  
  548.                 ;¯à®à¨á®¢ª  à ¬ª¨ ¥á«¨ à §¬¥à 㧫  = 1
  549.                 cmp ecx,0
  550.                 jne @f
  551.                 ;¯à®¢¥àª  £«ã¡¨­ë esi
  552.                 ;clip_z=n_plane*v_size
  553.                 stdcall vox_is_clip, [clip_z],[v_size]
  554.                 cmp eax,0
  555.                 je @f
  556.                         push ecx
  557.                         mov ecx,dword[edi]
  558.                         and ecx,0xffffff
  559.                         stdcall [buf2d_rect_by_size], [buf_i], ebx,edx, [v_size],[v_size],ecx
  560.                         pop ecx
  561.                 @@:
  562.  
  563.                 ;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
  564.                 push edx
  565.  
  566.                 ;¢å®¤ ¢­ãâàì 㧫 
  567.                 dec ecx
  568. ;---
  569.                 mov eax,[v_size]
  570.                 cmp ecx,1
  571.                 jl @f
  572.                         shl eax,cl
  573.                 @@:
  574.                 add edx,eax ;ª®à¥ªâ¨à®¢ª  ¢ëá®âë ¯®¤ ¢®ªá¥«ì ­¨¦­¥£® ã஢­ï
  575. ;---
  576.                 mov ah,byte[edi+3]
  577.                 add edi,4
  578.                 mov al,8
  579.                 .cycle:
  580.                         bt ax,8 ;â¥áâ¨à㥬 ⮫쪮 ah
  581.                         jnc .c_next
  582.                                 push eax ebx edx esi
  583.                                 stdcall vox_corect_coords_pl, [v_obj],[v_size]
  584.                                 stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj],[clip_z],[v_size]
  585.                                 pop esi edx ebx eax
  586.                         .c_next:
  587.                         shr ah,1
  588.                         dec al
  589.                         jnz .cycle
  590.  
  591.                 ;¢ë室 ¨§ 㧫 
  592.                 inc ecx
  593.                 pop edx
  594.  
  595.                 jmp .end_f
  596.         .sub_trees:
  597.                 cmp ecx,0
  598.                 jl .end_0 ;­¥ à¨á㥬 ®ç¥­ì ¬ «¥­ìª¨¥ ¢®ªá¥«¨
  599.  
  600.                 ;¯à®¢¥àª  £«ã¡¨­ë esi
  601.                 ;clip_z=n_plane*v_size
  602.                 stdcall vox_is_clip, [clip_z],[v_size]
  603.                 cmp eax,0
  604.                 je .end_0
  605.  
  606.                 ;à¨á㥬 㧥«
  607.                 mov eax,[edi]
  608.                 and eax,0xffffff
  609.                 push eax ;梥â 㧫 
  610.  
  611.                 mov eax,[v_size]
  612.                 cmp ecx,1
  613.                 jl @f
  614.                         shl eax,cl ;à §¬¥à 㧫 
  615.                 @@:
  616.  
  617.                 stdcall [buf2d_filled_rect_by_size], [buf_i], ebx,edx, eax,eax
  618.                 .end_0:
  619.                 add edi,4
  620.         .end_f:
  621.         ret
  622. endp
  623.  
  624. ;¯à®¢¥àª  £«ã¡¨­ë esi
  625. ;input:
  626. ; ecx - ã஢¥­ì ⥪ã襣® 㧫 
  627. ; esi - coord z
  628. ; clip_z - n_plane*v_size
  629. ;output:
  630. ; eax - 0 if no draw, 1 if draw
  631. align 4
  632. proc vox_is_clip uses ebx edi, clip_z:dword, v_size:dword
  633.         xor eax,eax
  634.         mov ebx,[clip_z]
  635.         mov edi,[v_size]
  636.         cmp ecx,1
  637.         jl @f
  638.                 shl edi,cl
  639.         @@:
  640.         ;edi = 2^ecx
  641.         add edi,esi
  642.         cmp edi,ebx ;if (esi+2^ecx*v_size <= (n_plane*v_size)) no draw
  643.         jle @f
  644.         add ebx,[v_size]
  645.         cmp esi,ebx ;if (esi >= (n_plane+1)*v_size) no draw
  646.         jge @f
  647.                 inc eax
  648.         @@:
  649.         ret
  650. endp
  651.  
  652. ;äã­ªæ¨ï ¤«ï ª®à¥ªâ¨à®¢ª¨ ª®®à¤¨­ â
  653. ;­ ¯à ¢«¥­¨ï ®á¥© ª®®à¤¨­ â ¢ ¢®ªá¥«¥:
  654. ;*z
  655. ;|
  656. ;+-* x
  657. ;input:
  658. ;  al - ­®¬¥à 㧫  ¢ ¤¥à¥¢¥ (®â 1 ¤® 8)
  659. ; ebx - ª®®à¤¨­ â  x
  660. ; edx - ª®®à¤¨­ â  y
  661. ; esi - ª®®à¤¨­ â  z
  662. ; ecx - ã஢¥­ì ⥪ã襣® 㧫 
  663. ;output:
  664. ; ebx - ­®¢ ï ª®®à¤¨­ â  x
  665. ; edx - ­®¢ ï ª®®à¤¨­ â  y
  666. ; esi - ­®¢ ï ª®®à¤¨­ â  z
  667. align 4
  668. proc vox_corect_coords_pl, v_obj:dword, v_size:dword
  669.         cmp ecx,0
  670.         jl .end_f ;¤«ï ã᪮७¨ï ®âà¨á®¢ª¨
  671.  
  672.         push eax edi
  673.         and eax,15 ;¢ë¤¥«ï¥¬ ­®¬¥à 㧫  ¢ ¤¥à¥¢¥
  674.         mov edi,[v_obj]
  675.         add edi,vox_offs_tree_table
  676.         add edi,8
  677.         sub edi,eax
  678.  
  679.         mov eax,[v_size] ;eax - ¢ëá®â  ®á­®¢ ­¨ï ¥¤¨­¨ç­®£® ¢®ªá¥«ï
  680.         cmp ecx,1
  681.         jl @f ;¢® ¨§¡¥¦ ­¨¥ § æ¨ª«¨¢ ­¨ï
  682.                 shl eax,cl
  683.         @@:
  684.  
  685.         bt word[edi],0 ;test voxel coord x
  686.         jnc @f
  687.                 add ebx,eax
  688.         @@:
  689.         bt word[edi],1 ;test voxel coord y
  690.         jnc @f
  691.                 add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
  692.         @@:
  693.         bt word[edi],2 ;test voxel coord z
  694.         jnc @f
  695.                 sub edx,eax
  696.         @@:
  697.         pop edi eax
  698.         .end_f:
  699.         ret
  700. endp
  701.  
  702. ;
  703. ;output:
  704. ; eax - ç¨á«® 㧫®¢ ¢ ®¡ê¥ªâ¥ v_obj
  705. align 4
  706. proc vox_obj_get_nodes uses edi, v_obj:dword
  707.         mov edi,[v_obj]
  708.         add edi,vox_offs_data
  709.         xor eax,eax
  710.         stdcall vox_obj_rec0
  711.         ret
  712. endp
  713.  
  714. ;input:
  715. ; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
  716. ;output:
  717. ; eax - eax + ç¨á«® 㧫®¢ ¢ ¤ ­­ëå ¢®ªá. ®¡ê¥ªâ 
  718. ; edi - 㪠§ â¥«ì ­  ᬥ饭­ë¥ ¤ ­­ë¥ ¢®ªá. ®¡ê¥ªâ 
  719. align 4
  720. proc vox_obj_rec0
  721.         inc eax
  722.         cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
  723.         je .sub_trees
  724.  
  725.                 ;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
  726.                 push ebx ecx
  727.                 mov bh,byte[edi+3]
  728.                 add edi,4
  729.                 mov bl,8
  730.                 .cycle:
  731.                         bt bx,8 ;â¥áâ¨à㥬 ⮫쪮 bh
  732.                         jnc .c_next
  733.                                 stdcall vox_obj_rec0
  734.                         .c_next:
  735.                         shr bh,1
  736.                         dec bl
  737.                         jnz .cycle
  738.                 pop ecx ebx
  739.  
  740.                 jmp .end_f
  741.         .sub_trees:
  742.                 add edi,4
  743.         .end_f:
  744.         ret
  745. endp
  746.  
  747. ;
  748. ;output:
  749. ; eax - à §¬¥à ¢ ¡ ©â å § ­¨¬ ¥¬ë© ®¡ê¥ªâ®¬ v_obj
  750. align 4
  751. proc buf2d_vox_obj_get_size, v_obj:dword
  752.         stdcall vox_obj_get_nodes,[v_obj]
  753.         shl eax,2
  754.         add eax,vox_offs_data
  755.         ret
  756. endp
  757.  
  758. if 0
  759. ;output:
  760. ; eax - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ï
  761. align 4
  762. proc buf2d_vox_obj_is_node uses ebx ecx edx edi esi, v_obj:dword,\
  763. coord_x:dword,coord_y:dword,coord_z:dword,k_scale:dword
  764.         mov edi,[v_obj]
  765.         add edi,vox_offs_data
  766.         mov esi,[k_scale]
  767.         xor eax,eax
  768.         xor edx,edx
  769.         stdcall vox_obj_rec1, [v_obj],[coord_x],[coord_y],[coord_z], 0,0,0
  770.         ret
  771. endp
  772.  
  773. ;input:
  774. ; eax - ...
  775. ; edx - ...
  776. ; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
  777. ; esi - ã஢¥­ì ¨áª®¬®£® ¢®ªá¥«ï
  778. align 4
  779. proc vox_obj_rec1, v_obj:dword, coord_x:dword,coord_y:dword,coord_z, tc_x:dword,tc_y:dword,tc_z
  780.         cmp edx,esi
  781.         jne @f
  782.                 mov ebx,[tc_x]
  783.                 cmp [coord_x],ebx
  784.                 jne @f
  785.                 mov ebx,[tc_y]
  786.                 cmp [coord_y],ebx
  787.                 jne @f
  788.                 mov ebx,[tc_z]
  789.                 cmp [coord_z],ebx
  790.                 jne @f
  791.                 mov eax,edi
  792.         @@:
  793.  
  794.         cmp eax,0
  795.         jne .end_f ;¥á«¨ 㪠§ â¥«ì 㦥 ­ ©¤¥­
  796.  
  797.         cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
  798.         je .sub_trees
  799.                 inc edx
  800.                 shl dword[tc_x],1
  801.                 shl dword[tc_y],1
  802.                 shl dword[tc_z],1
  803.                 ;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
  804.                
  805.                 mov bh,byte[edi+3]
  806.                 add edi,4
  807.                 ;mov bl,8
  808.                 xor bl,bl
  809.                 .cycle:
  810.                         bt bx,8 ;â¥áâ¨à㥬 ⮫쪮 bh
  811.                         jnc .c_next
  812. push dword[tc_x]
  813. push dword[tc_y]
  814. push dword[tc_z]
  815.                                 push edx
  816.                                 movzx edx,bl
  817.                                 add edx,[v_obj]
  818.                                 add edx,vox_offs_tree_table
  819.                                 bt word[edx],0 ;coord x
  820.                                 jnc .end_x
  821.                                         inc dword[tc_x]
  822.                                 .end_x:
  823.                                 bt word[edx],1 ;coord y
  824.                                 jnc .end_y
  825.                                         inc dword[tc_y]
  826.                                 .end_y:
  827.                                 bt word[edx],2 ;coord z
  828.                                 jnc .end_z
  829.                                         inc dword[tc_z]
  830.                                 .end_z:
  831.                                 pop edx
  832.                                 push ebx ecx
  833.                                 stdcall vox_obj_rec1, [v_obj],[coord_x],[coord_y],[coord_z], [tc_x],[tc_y],[tc_z]
  834.                                 pop ecx ebx
  835. pop dword[tc_z]
  836. pop dword[tc_y]
  837. pop dword[tc_x]
  838.                         .c_next:
  839.                         shr bh,1
  840.                         inc bl
  841.                         ;jnz .cycle
  842.                         cmp bl,8
  843.                         jl .cycle
  844.                
  845.                 dec edx
  846.                 jmp .end_f
  847.         .sub_trees:
  848.                 add edi,4
  849.         .end_f:
  850.         ret
  851. endp
  852. end if
  853.  
  854. ; ᮧ¤ ­¨¥ ¢®ªá¥«ï ¢ 3 íâ ¯ :
  855. ; 1) ¨é¥¬ ¬¥áâ® ¢ áâàãªâãॠ¤¥à¥¢ , ªã¤  ­ ¤® ¢áâ ¢¨âì (¥á«¨ ¢¥â¢ì áãé¥áâ¢ã¥â, 2-© íâ ¯ ¯à®¯ã᪠¥¬)
  856. ; 2) ¢áâ ¢«ï¥¬ ­®¢ãî ¢¥â¢ì á ¢®ªá¥«¥¬ (3-© íâ ¯ 㦥 ­¥ ¤¥« ¥¬)
  857. ; 3) ¬¥­ï¥¬ 梥⠢®ªá¥«ï
  858. align 4
  859. proc buf2d_vox_obj_create_node, v_obj:dword,coord_x:dword,coord_y:dword,\
  860. coord_z:dword,color:dword,k_scale:dword
  861. pushad
  862. locals
  863.         p_node dd 0 ;த¨â¥«ì᪨© 㧥«
  864. endl
  865. ;stdcall print_err, txt_f1, txt_b
  866.  
  867.         mov edi,[v_obj]
  868.         add edi,vox_offs_data
  869.         mov esi,[k_scale]
  870.         cmp esi,1
  871.         jl .change
  872.         ; *** (1) ***
  873.         .found:
  874.         stdcall vox_obj_get_node_position, [v_obj],[coord_x],[coord_y],[coord_z],esi
  875.         movzx bx,byte[edi+3]
  876.         mov [p_node],edi
  877.         add edi,4
  878. ;stdcall print_err, txt_chi, txt_e
  879.         cmp eax,0
  880.         je .end_1
  881.         mov ecx,eax
  882.         cld
  883.         @@: ; 横«  ¤«ï ¯à®¯ã᪠ ¯à¥¤ë¤ãé¨å ¯®¤¤¥à¥¢ì¥¢ ¢ 㧫¥
  884.                 bt bx,0 ;¯à®¢¥à塞 ¥áâì «¨ ¤®ç¥à­¨¥ 㧫ë
  885.                 jnc .end_0
  886. ;stdcall print_err, txt_st, txt_e
  887.                         xor eax,eax
  888.                         stdcall vox_obj_rec0 ;¢ eax ¢ëç¨á«ï¥âáï ç¨á«® ¤®ç¥à­¨å 㧫®¢, ¢ ¤ ­­®© ¢¥â¢¨
  889.                 .end_0:
  890.                 shr bx,1
  891.                 loop @b
  892.         .end_1:
  893.         bt bx,0
  894.         jnc .creat ;¥á«¨ ¯®¤¤¥à¥¢  ­¥ áãé¥áâ¢ã¥â, ¯¥à¥å®¤¨¬ ª ᮧ¤ ­¨î
  895.         dec esi
  896.         cmp esi,0
  897.         jg .found
  898.         jmp .change
  899.  
  900.         ; *** (2) ***
  901.         .creat:
  902.         mov edx,[color] ;¬¥­ï¥¬ 梥â
  903.         and edx,0xffffff ;¤«ï ¯à®ä¨« ªâ¨ª¨
  904.         mov ecx,esi
  905.         stdcall vox_obj_add_nodes_mem, [v_obj],edi,ecx ;à áè¨à塞 ¬¥áâ® § ­¨¬ ¥¬®¥ ®¡ê¥ªâ®¬, ¤«ï ¤®¡ ¢«¥­¨ï ­®¢ëå 㧫®¢
  906.         mov ebx,[p_node]
  907.         cld
  908.         @@:
  909.                 mov dword[edi],edx
  910.                 stdcall vox_obj_get_node_bit_mask, [v_obj],[coord_x],[coord_y],[coord_z],esi
  911.                 or byte[ebx+3],al
  912.  
  913.                 mov ebx,edi
  914.                 add edi,4
  915.                 dec esi
  916.                 loop @b
  917.         jmp .end_2
  918.  
  919.         ; *** (3) ***
  920.         .change:
  921.         mov eax,[color] ;¬¥­ï¥¬ 梥â
  922.         mov word[edi],ax
  923.         shr eax,16
  924.         mov byte[edi+2],al
  925.  
  926.         .end_2:
  927. popad
  928.         ret
  929. endp
  930.  
  931. ; 㤠«¥­¨¥ ¢®ªá¥«ï ¢ 3 íâ ¯ :
  932. ; 1) ¨é¥¬ ¬¥áâ® ¢ áâàãªâãॠ¤¥à¥¢ , £¤¥ ¥áâì 㤠«ï¥¬ë© 㧥« (¥á«¨ ¢¥â¢ì ­¥ áãé¥áâ¢ã¥â, ¢ë室¨¬ ¨§ ä㭪樨)
  933. ; 2) ¢áâ ¢«ï¥¬ ­®¢ãî ¢¥â¢ì á ¢®ªá¥«¥¬
  934. align 4
  935. proc buf2d_vox_obj_delete_node, v_obj:dword,coord_x:dword,coord_y:dword,\
  936. coord_z:dword,k_scale:dword
  937. pushad
  938. locals
  939.         p_node dd 0 ;த¨â¥«ì᪨© 㧥«
  940. endl
  941.         mov edi,[v_obj]
  942.         add edi,vox_offs_data
  943.         mov esi,[k_scale]
  944.         cmp esi,1
  945.         jl .end_2
  946.         ; *** (1) ***
  947.         .found:
  948.         stdcall vox_obj_get_node_position, [v_obj],[coord_x],[coord_y],[coord_z],esi
  949.         movzx bx,byte[edi+3]
  950.         mov [p_node],edi
  951.         add edi,4
  952.         cmp eax,0
  953.         je .end_1
  954.         mov ecx,eax
  955.         cld
  956.         @@: ; 横«  ¤«ï ¯à®¯ã᪠ ¯à¥¤ë¤ãé¨å ¯®¤¤¥à¥¢ì¥¢ ¢ 㧫¥
  957.                 bt bx,0 ;¯à®¢¥à塞 ¥áâì «¨ ¤®ç¥à­¨¥ 㧫ë
  958.                 jnc .end_0
  959.                         xor eax,eax
  960.                         stdcall vox_obj_rec0 ;¢ eax ¢ëç¨á«ï¥âáï ç¨á«® ¤®ç¥à­¨å 㧫®¢, ¢ ¤ ­­®© ¢¥â¢¨
  961.                 .end_0:
  962.                 shr bx,1
  963.                 loop @b
  964.         .end_1:
  965.         bt bx,0
  966.         jnc .end_2 ;¥á«¨ ¯®¤¤¥à¥¢  ­¥ áãé¥áâ¢ã¥â
  967.         dec esi
  968.         cmp esi,0
  969.         jg .found
  970.  
  971.         ; *** (2) ***
  972.         ;delete
  973.         stdcall vox_obj_del_nodes_mem, [v_obj],edi ;á㦠¥¬ ¬¥áâ® § ­¨¬ ¥¬®¥ ®¡ê¥ªâ®¬, ¯à¨ 㤠«¥­¨¨ 㧫 
  974.         mov ebx,[p_node]
  975.  
  976.         stdcall vox_obj_get_node_bit_mask, [v_obj],[coord_x],[coord_y],[coord_z],esi
  977.         xor byte[ebx+3],al
  978.  
  979.         .end_2:
  980. popad
  981.         ret
  982. endp
  983.  
  984. ; ᤢ¨£ ¥â ã§«ë ¤«ï ¤®¡ ¢«¥­¨ï ­®¢ëå 㧫®¢
  985. ;input:
  986. ; p_insert - ¯®§¨æ¨ï ¤«ï ¢áâ ¢ª¨
  987. ; count - ª®««¨ç¥á⢮ ¢áâ ¢«ï¥¬ëå 㧫®¢
  988. align 4
  989. proc vox_obj_add_nodes_mem uses eax ecx edi esi, v_obj:dword,p_insert:dword,count:dword
  990.         stdcall buf2d_vox_obj_get_size,[v_obj]
  991.         mov esi,[v_obj]
  992.         add esi,eax ;esi - 㪠§ â¥«ì ­  ª®­¥æ ä ©« 
  993.         mov edi,[count]
  994.         shl edi,2
  995.         add edi,esi ;edi - 㪠§ â¥«ì ­  ¡ã¤ã騩 ª®­¥æ ä ©« 
  996.         mov ecx,esi
  997.         sub ecx,[p_insert]
  998.         shr ecx,2 ;ecx - ç¨á«® 横«®¢ ¤«ï ª®¯¨à®¢ ­¨ï
  999.         sub esi,4 ;esi - 㪠§ â¥«ì ­  ¯®á«¥¤­¨© 㧥«
  1000.         sub edi,4 ;edi - 㪠§ â¥«ì ­  ¡ã¤ã騩 ¯®á«¥¤­¨© 㧥«
  1001.         std
  1002.         rep movsd ;ᤢ¨£ ¥¬ ¯ ¬ïâì
  1003.         ret
  1004. endp
  1005.  
  1006. ;input:
  1007. ; p_insert - ¯®§¨æ¨ï ¤«ï ...
  1008. align 4
  1009. proc vox_obj_del_nodes_mem uses eax ecx edi esi, v_obj:dword,p_insert:dword
  1010.         stdcall buf2d_vox_obj_get_size,[v_obj]
  1011.         mov ecx,eax
  1012.         mov edi,[p_insert]
  1013.         add ecx,[v_obj]
  1014.         sub ecx,edi
  1015.         xor eax,eax
  1016.         stdcall vox_obj_rec0
  1017.         shr ecx,2
  1018.         sub ecx,eax ;ecx - ç¨á«® 横«®¢ ¤«ï ª®¯¨à®¢ ­¨ï
  1019.         shl eax,2
  1020.         add eax,[p_insert]
  1021.         mov esi,eax
  1022.         mov edi,[p_insert]
  1023.         cld
  1024.         rep movsd ;ᤢ¨£ ¥¬ ¯ ¬ïâì
  1025.         ret
  1026. endp
  1027.  
  1028. ; ®¯à¥¤¥«¥­¨¥ ¯®§¨æ¨¨ 㧫  ¢ ¤¥à¥¢¥ (®â 0 ¤® 7)
  1029. align 4
  1030. proc vox_obj_get_node_position uses ebx ecx edi, v_obj:dword,\
  1031. coord_x:dword,coord_y:dword,coord_z:dword,k_scale:dword
  1032.         mov ecx,[k_scale]
  1033.         dec ecx
  1034.         mov eax,[coord_x]
  1035.         mov ebx,[coord_y]
  1036.         mov edi,[coord_z]
  1037.         cmp ecx,1
  1038.         jl .end_0
  1039.                 shr eax,cl
  1040.                 shr ebx,cl
  1041.                 shr edi,cl
  1042.         .end_0:
  1043.         and eax,1
  1044.         bt ebx,0
  1045.         jnc @f
  1046.                 bts eax,1
  1047.         @@:
  1048.         bt edi,0
  1049.         jnc @f
  1050.                 bts eax,2
  1051.         @@:
  1052.  
  1053.         mov edi,[v_obj]
  1054.         add edi,vox_offs_tree_table
  1055.         @@:
  1056.                 cmp al,byte[edi]
  1057.                 je @f
  1058.                 inc edi
  1059.                 jmp @b
  1060.         @@:
  1061.         sub edi,[v_obj]
  1062.         sub edi,vox_offs_tree_table
  1063.         mov eax,edi
  1064.        
  1065.         ret
  1066. endp
  1067.  
  1068. ;output:
  1069. ; eax - 1,2,4,8,16, ... ,128
  1070. align 4
  1071. proc vox_obj_get_node_bit_mask uses ebx ecx edi, v_obj:dword,\
  1072. coord_x:dword,coord_y:dword,coord_z:dword,k_scale:dword
  1073.         mov ecx,[k_scale]
  1074.         dec ecx
  1075.         mov eax,[coord_x]
  1076.         mov ebx,[coord_y]
  1077.         mov edi,[coord_z]
  1078.         cmp ecx,1
  1079.         jl .end_0
  1080.                 shr eax,cl
  1081.                 shr ebx,cl
  1082.                 shr edi,cl
  1083.         .end_0:
  1084.         and eax,1
  1085.         bt ebx,0
  1086.         jnc @f
  1087.                 bts eax,1
  1088.         @@:
  1089.         bt edi,0
  1090.         jnc @f
  1091.                 bts eax,2
  1092.         @@:
  1093.  
  1094.         mov ecx,[v_obj]
  1095.         add ecx,vox_offs_tree_table
  1096.         @@:
  1097.                 cmp al,byte[ecx]
  1098.                 je @f
  1099.                 inc ecx
  1100.                 jmp @b
  1101.         @@:
  1102.         mov eax,1 ;ãáâ ­ ¢«¨¢ ¥¬ ¯¥à¢®­ ç «ì­®¥ §­ ç¥­¨¥ ¡¨â 
  1103.         sub ecx,[v_obj]
  1104.         sub ecx,vox_offs_tree_table
  1105.         jz @f
  1106.                 shl eax,cl ;ᤢ¨£ ¥¬ ¡¨â
  1107.         @@:
  1108.        
  1109.         ret
  1110. endp
  1111.  
  1112. align 4
  1113. proc buf2d_vox_obj_get_img_w_3g uses ecx, h_br:dword,k_scale:dword
  1114.         mov ecx,[h_br]
  1115.  
  1116.         movzx eax,byte[ecx]
  1117.         cmp dword[k_scale],1
  1118.         jl .end_c0
  1119.                 mov ecx,[k_scale]
  1120.                 shl eax,cl
  1121.         .end_c0:
  1122.         ret
  1123. endp
  1124.  
  1125. align 4
  1126. proc buf2d_vox_obj_get_img_h_3g uses ecx, h_br:dword,k_scale:dword
  1127.         mov ecx,[h_br]
  1128.  
  1129.         movzx eax,byte[ecx+1]
  1130.         cmp dword[k_scale],1
  1131.         jl .end_c0
  1132.                 mov ecx,[k_scale]
  1133.                 shl eax,cl
  1134.         .end_c0:
  1135.         ret
  1136. endp
  1137.  
  1138. ;äã­ªæ¨ï ¤«ï à¨á®¢ ­¨ï ¯ «¨âàë
  1139. align 4
  1140. proc buf2d_draw_palete, buf:dword, coord_x:dword, coord_y:dword,\
  1141. cell_w:dword, cell_h:dword, colors_w:dword, colors:dword
  1142. pushad
  1143.         mov ebx,[coord_x]
  1144.         mov edx,[coord_y]
  1145.         mov ecx,[colors]
  1146.         xor edi,edi
  1147.         mov esi,[cell_h]
  1148.         cld
  1149.         .cycle_0:
  1150.                 stdcall get_palete_color, ecx,3
  1151.                 stdcall [buf2d_filled_rect_by_size], [buf], ebx,edx, [cell_w],esi,eax
  1152.                 inc edi
  1153.                 cmp edi,[colors_w]
  1154.                 jl @f
  1155.                         mov ebx,[coord_x]
  1156.                         sub ebx,[cell_w]
  1157.                         dec ebx
  1158.                         add edx,esi ;¢ëá®â  ï祩ª¨
  1159.                         inc edx ;®âáâ㯠¬¥¦¤ã ï祩ª ¬¨
  1160.                         xor edi,edi
  1161.                 @@:
  1162.                 add ebx,[cell_w]
  1163.                 inc ebx
  1164.                 loop .cycle_0
  1165. popad
  1166.         ret
  1167. endp
  1168.  
  1169. ;input:
  1170. ; ¥á«¨ r = 1 â® äã­ªæ¨ï ¢®§¢à é ¥â 8 梥⮢, 2 - 64, 3 - 512
  1171. ;output:
  1172. ; eax - color
  1173. align 4
  1174. proc get_palete_color uses ebx ecx edx edi, ind:dword, r:dword
  1175.         mov ecx,[r]
  1176.         xor edi,edi
  1177.         inc edi
  1178.  
  1179.         mov ebx,[ind]
  1180.         ;b = b xor (b shr 1)
  1181.         ;¯à¥®¡à §ã¥¬ ¨­¤¥ªá ¢ ª®¤¨à®¢ªã ƒà¥ï ¤«ï ¯®«ã祭¨ï ¡®«¥¥ ¯« ¢­ëå 梥⮢ëå ¯¥à¥å®¤®¢
  1182.         mov eax,ebx
  1183.         shr eax,1
  1184.         xor ebx,eax
  1185.  
  1186.         mov edx,ebx
  1187.         shr edx,cl
  1188.         mov eax,edx
  1189.         shr eax,cl
  1190.  
  1191.         mov ch,8
  1192.         sub ch,cl
  1193.         shr ecx,8
  1194.         shl ebx,cl
  1195.         shl edx,cl
  1196.         shl eax,cl
  1197.  
  1198.         shl edi,cl
  1199.         dec edi ;edi - 1...1b
  1200.  
  1201.         or ebx,edi
  1202.         or edx,edi
  1203.         or eax,edi
  1204.  
  1205.         shl eax,8
  1206.         mov al,dl
  1207.         shl eax,8
  1208.         mov al,bl
  1209.         and eax,0xffffff
  1210.         ret
  1211. endp
  1212.  
  1213.  
  1214. if 0
  1215. txt_f1 db 13,10,'f1',0
  1216. txt_chi db ' chi',0
  1217. txt_st db '  st',0
  1218.  
  1219. txt_b db 'beg'
  1220. txt_e db 13,10,0
  1221.  
  1222. align 4
  1223. proc print_err, fun:dword, mes:dword ;¢ë¢®¤¨¬ á®®¡é¥­¨¥ ®¡ 訡ª¥ ­  ¤®áªã ®â« ¤ª¨
  1224.         pushad
  1225.         mov eax,63
  1226.         mov ebx,1
  1227.  
  1228.         mov esi,[fun]
  1229.         @@:
  1230.                 mov cl,byte[esi]
  1231.                 int 0x40
  1232.                 inc esi
  1233.                 cmp byte[esi],0
  1234.                 jne @b
  1235.         mov cl,':'
  1236.         int 0x40
  1237.         mov cl,' '
  1238.         int 0x40
  1239.         mov esi,[mes]
  1240.         @@:
  1241.                 mov cl,byte[esi]
  1242.                 int 0x40
  1243.                 inc esi
  1244.                 cmp byte[esi],0
  1245.                 jne @b
  1246.         popad
  1247.         ret
  1248. endp
  1249. end if
  1250.