Subversion Repositories Kolibri OS

Rev

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

  1. format MS COFF
  2. public EXPORTS
  3. section '.flat' code readable align 16
  4.  
  5. include '../../../../macros.inc'
  6. include '../../../../proc32.inc'
  7.  
  8. ;-----------------------------------------------------------------------------
  9. mem.alloc   dd ? ;äã­ªæ¨ï ¤«ï ¢ë¤¥«¥­¨ï ¯ ¬ïâ¨
  10. mem.free    dd ? ;äã­ªæ¨ï ¤«ï ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
  11. mem.realloc dd ? ;äã­ªæ¨ï ¤«ï ¯¥à¥à á¯à¥¤¥«¥­¨ï ¯ ¬ïâ¨
  12. dll.load    dd ?
  13.  
  14. BUF_STRUCT_SIZE equ 21
  15. buf2d_data equ dword[edi] ;¤ ­­ë¥ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  16. buf2d_w equ dword[edi+8] ;è¨à¨­  ¡ãä¥à 
  17. buf2d_h equ dword[edi+12] ;¢ëá®â  ¡ãä¥à 
  18. buf2d_l equ word[edi+4]
  19. buf2d_t equ word[edi+6] ;®âáâ㯠ᢥàåã
  20. buf2d_size_lt equ dword[edi+4] ;®âáâ㯠᫥¢  ¨ á¯à ¢  ¤«ï ¡ãä¥à 
  21. buf2d_color equ dword[edi+16] ;梥â ä®­  ¡ãä¥à 
  22. buf2d_bits equ byte[edi+20] ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
  23.  
  24. struct buf_2d_header
  25.         img_data dd ?
  26.         left dw ? ;+4 left
  27.         top dw ? ;+6 top
  28.         size_x dd ? ;+8 w
  29.         size_y dd ? ;+12 h
  30.         color dd ? ;+16 color
  31.         bit_pp db ? ;+21 bit in pixel
  32. ends
  33.  
  34. macro swap v1, v2 {
  35.   push v1
  36.   push v2
  37.   pop v1
  38.   pop v2
  39. }
  40.  
  41. ;ä« £¨, ¤«ï ä㭪樨 ®¡à¥§ ­¨ï ¡ãä¥à 
  42. BUF2D_OPT_CROP_TOP equ 1 ;®¡à¥§ª  ᢥàåã
  43. BUF2D_OPT_CROP_LEFT equ 2 ;®¡à¥§ª  á«¥¢ 
  44. BUF2D_OPT_CROP_BOTTOM equ 4 ;®¡à¥§ª  á­¨§ã
  45. BUF2D_OPT_CROP_RIGHT equ 8 ;®¡à¥§ª  á¯à ¢ 
  46. BUF2D_BIT_OPT_CROP_TOP equ 0
  47. BUF2D_BIT_OPT_CROP_LEFT equ 1
  48. BUF2D_BIT_OPT_CROP_BOTTOM equ 2
  49. BUF2D_BIT_OPT_CROP_RIGHT equ 3
  50.  
  51. vox_offs_tree_table equ 4
  52. vox_offs_data equ 12
  53.  
  54. ;input:
  55. ; eax = 㪠§ â¥«ì ­  äã­ªæ¨î ¢ë¤¥«¥­¨ï ¯ ¬ïâ¨
  56. ; ebx = ... ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
  57. ; ecx = ... ¯¥à¥à á¯à¥¤¥«¥­¨ï ¯ ¬ïâ¨
  58. ; edx = ... § £à㧪¨ ¡¨¡«¨®â¥ª¨ (¯®ª  ­¥ ¨á¯®«ì§ã¥âáï)
  59. align 16
  60. lib_init:
  61.         mov dword[mem.alloc], eax
  62.         mov dword[mem.free], ebx
  63.         mov dword[mem.realloc], ecx
  64.         mov dword[dll.load], edx
  65.         ret
  66.  
  67. ;input:
  68. ; ebx = coord x
  69. ; ecx = coord y
  70. ; edx = pixel color
  71. ; edi = pointer to buffer struct
  72. align 4
  73. draw_pixel:
  74.         ;cmp buf2d_bits,24
  75.         ;jne @f
  76.         bt ebx,31
  77.         jc @f
  78.         bt ecx,31
  79.         jc @f
  80.         cmp ebx,buf2d_w
  81.         jge @f
  82.         cmp ecx,buf2d_h
  83.         jge @f
  84.         push esi
  85.                 mov esi,buf2d_w ;size x
  86.                 imul esi,ecx ;size_x*y
  87.                 add esi,ebx      ;size_x*y+x
  88.                 cmp buf2d_bits,8
  89.                 je .beg8
  90.                 cmp buf2d_bits,32
  91.                 je .beg32
  92.                         lea esi,[esi+esi*2] ;(size_x*y+x)*3
  93.                         add esi,buf2d_data  ;ptr+(size_x*y+x)*3
  94.                         mov word[esi],dx ;copy pixel color
  95.                         ror edx,16
  96.                         mov byte[esi+2],dl
  97.                         ror edx,16
  98.                         jmp .end_draw
  99.                 .beg8: ;à¨á®¢ ­¨¥ â®çª¨ ¢ 8 ¡¨â­®¬ ¡ãä¥à¥
  100.                         add esi,buf2d_data  ;ptr+(size_x*y+x)
  101.                         mov byte[esi],dl
  102.                         jmp .end_draw
  103.                 .beg32: ;à¨á®¢ ­¨¥ â®çª¨ ¢ 32 ¡¨â­®¬ ¡ãä¥à¥
  104.                         shl esi,2
  105.                         add esi,buf2d_data  ;ptr+(size_x*y+x)
  106.                         mov dword[esi],edx
  107.                 .end_draw:
  108.         pop esi
  109.         @@:
  110.         ret
  111.  
  112. ;input:
  113. ; ebx = coord x
  114. ; ecx = coord y
  115. ; edi = pointer to buffer struct
  116. ;output:
  117. ; eax = 梥â â®çª¨
  118. ; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
  119. align 4
  120. get_pixel_8:
  121.         mov eax,0xffffffff
  122.  
  123.         bt ebx,31
  124.         jc @f
  125.         bt ecx,31
  126.         jc @f
  127.         cmp ebx,buf2d_w
  128.         jge @f
  129.         cmp ecx,buf2d_h
  130.         jge @f
  131.         push esi
  132.                 mov esi,buf2d_w ;size x
  133.                 imul esi,ecx ;size_x*y
  134.                 add esi,ebx      ;size_x*y+x
  135.                 add esi,buf2d_data  ;ptr+(size_x*y+x)
  136.  
  137.                 movzx eax,byte[esi] ;copy pixel color
  138.         pop esi
  139.         @@:
  140.         ret
  141.  
  142. ;input:
  143. ; ebx = coord x
  144. ; ecx = coord y
  145. ; edi = pointer to buffer struct
  146. ;output:
  147. ; eax = 梥â â®çª¨
  148. ; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
  149. align 4
  150. get_pixel_24:
  151.         mov eax,0xffffffff
  152.  
  153.         bt ebx,31
  154.         jc @f
  155.         bt ecx,31
  156.         jc @f
  157.         cmp ebx,buf2d_w
  158.         jge @f
  159.         cmp ecx,buf2d_h
  160.         jge @f
  161.         push esi
  162.                 mov esi,buf2d_w ;size x
  163.                 imul esi,ecx ;size_x*y
  164.                 add esi,ebx      ;size_x*y+x
  165.                 lea esi,[esi+esi*2] ;(size_x*y+x)*3
  166.                 add esi,buf2d_data  ;ptr+(size_x*y+x)*3
  167.  
  168.                 xor eax,eax
  169.                 mov ax,word[esi] ;copy pixel color
  170.                 ror eax,16
  171.                 mov al,byte[esi+2]
  172.                 ror eax,16
  173.         pop esi
  174.         @@:
  175.         ret
  176.  
  177. ;input:
  178. ; ebx = coord x
  179. ; ecx = coord y
  180. ; edi = pointer to buffer struct
  181. ;output:
  182. ; eax = 梥â â®çª¨
  183. ; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
  184. align 4
  185. get_pixel_32:
  186.         mov eax,0xffffffff
  187.  
  188.         bt ebx,31
  189.         jc @f
  190.         bt ecx,31
  191.         jc @f
  192.         cmp ebx,buf2d_w
  193.         jge @f
  194.         cmp ecx,buf2d_h
  195.         jge @f
  196.         push esi
  197.                 mov esi,buf2d_w ;size x
  198.                 imul esi,ecx ;size_x*y
  199.                 add esi,ebx      ;size_x*y+x
  200.                 shl esi,2
  201.                 add esi,buf2d_data  ;ptr+(size_x*y+x)*4
  202.  
  203.                 mov eax,dword[esi] ;copy pixel color
  204.         pop esi
  205.         @@:
  206.         ret
  207.  
  208. ;input:
  209. ; ebx = coord x
  210. ; ecx = coord y
  211. ; edx = pixel color + transparent
  212. ; edi = pointer to buffer struct
  213. ; t_prop, m_prop - ª®íä¨æ¨¥­âë ­¥®¡å®¤¨¬ë¥ ¤«ï ¢ëç¨á«¥­¨ï á⥯¥­¨ ¯à®§à ç­®áâ¨
  214. align 4
  215. transp_32 dd 0 ;梥â à¨á㥬®© â®çª¨ + ¯à®§à ç­®áâì
  216. align 4
  217. proc draw_pixel_transp, t_prop:dword, m_prop:dword
  218.         ;cmp buf2d_bits,24
  219.         ;jne @f
  220.         bt ebx,31
  221.         jc @f
  222.         bt ecx,31
  223.         jc @f
  224.         cmp ebx,buf2d_w
  225.         jge @f
  226.         cmp ecx,buf2d_h
  227.         jge @f
  228.         push eax ebx edx edi esi
  229.                 mov esi,buf2d_w ;size x
  230.                 imul esi,ecx ;size_x*y
  231.                 add esi,ebx      ;size_x*y+x
  232.                 lea esi,[esi+esi*2] ;(size_x*y+x)*3
  233.                 add esi,buf2d_data  ;ptr+(size_x*y+x)*3
  234.  
  235.                 mov edi,esi ;㪠§ â¥«ì ­  梥â ä®­ 
  236.                 mov dword[transp_32],edx ;梥â à¨á㥬®© â®çª¨
  237.  
  238.                 xor edx,edx
  239.                 mov eax,[t_prop]
  240.                 shl eax,8 ;*=256
  241.                 mov ebx,[m_prop]
  242.                 div ebx ;¢ëç¨á«ï¥¬ ª®íä. ¯à®§à ç­®á⨠(¤®«¦¥­ ¡ëâì ®â 0 ¤® 255)
  243.                 bt ax,8
  244.                 jnc .over_255
  245.                         ;¥á«¨ ª®¥ä. ¯à®§à ç­®á⨠>=256 ⮠㬥­ìè ¥¬ ¥£® ¤® 255
  246.                         mov al,0xff
  247.                 .over_255:
  248.  
  249.                 mov byte[transp_32+3],al ;¯à®§à ç­®áâì à¨á㥬®© â®çª¨
  250.                 mov esi,dword transp_32 ;㪠§ â¥«ì ­  梥â à¨á㥬®© â®çª¨
  251.  
  252.                 call combine_colors_0
  253.         pop esi edi edx ebx eax
  254.         @@:
  255.         ret
  256. endp
  257.  
  258. ;ᮧ¤ ­¨¥ ¡ãä¥à 
  259. align 4
  260. proc buf_create, buf_struc:dword
  261.         pushad
  262.         mov edi,dword[buf_struc]
  263.         mov ecx,buf2d_w
  264.         mov ebx,buf2d_h
  265.         imul ecx,ebx
  266.         cmp buf2d_bits,24
  267.         jne @f
  268.                 lea ecx,[ecx+ecx*2] ; 24 bit = 3
  269.                 ;;;inc ecx ;§ ¯ á­®© ¡ ©â ¢ ª®­æ¥ ¡ãä¥à , çâ®-¡ë ­¥ £«î稫¨ ­¥ª®â®àë¥ ä㭪樨 ­  ¨§®¡à ¦¥­¨ïå ªà â­ëå 4Š
  270.         @@:
  271.         cmp buf2d_bits,32
  272.         jne @f
  273.                 shl ecx,2 ; 32 bit = 4
  274.         @@:
  275.         invoke mem.alloc,ecx
  276.         mov buf2d_data,eax
  277.  
  278.         stdcall buf_clear,edi,buf2d_color ;®ç¨á⪠ ¡ãä¥à  ä®­®¢ë¬ 梥⮬
  279.         popad
  280.         ret
  281. endp
  282.  
  283. ;ᮧ¤ ­¨¥ ¡ãä¥à  ­  ®á­®¢¥ ¨§®¡à ¦¥­¨ï rgb
  284. align 4
  285. proc buf_create_f_img, buf_struc:dword, rgb_data:dword
  286.         pushad
  287.         mov edi,dword[buf_struc]
  288.         mov ecx,buf2d_w
  289.         mov ebx,buf2d_h
  290.         imul ecx,ebx
  291.         cmp buf2d_bits,24
  292.         jne @f
  293.                 lea ecx,[ecx+ecx*2] ; 24 bit = 3
  294.                 ;;;inc ecx ;§ ¯ á­®© ¡ ©â ¢ ª®­æ¥ ¡ãä¥à , çâ®-¡ë ­¥ £«î稫¨ ­¥ª®â®àë¥ ä㭪樨 ­  ¨§®¡à ¦¥­¨ïå ªà â­ëå 4Š
  295.         @@:
  296.         cmp buf2d_bits,32
  297.         jne @f
  298.                 shl ecx,2 ; 32 bit = 4
  299.         @@:
  300.         invoke mem.alloc,ecx
  301.         mov buf2d_data,eax
  302.  
  303.         cmp buf2d_bits,24
  304.         jne @f
  305.                 cld
  306.                 mov esi,[rgb_data]
  307.                 mov edi,eax ;eax=buf2d_data
  308.                 rep movsb ;ª®¯¨à㥬 ¡¨âë ¨§®¡à ¦¥­¨ï ¢ ¡ãä¥à
  309.                 jmp .end_create
  310.         @@:
  311.                 stdcall buf_clear,edi,buf2d_color ;®ç¨á⪠ ¡ãä¥à  ä®­®¢ë¬ 梥⮬
  312.         .end_create:
  313.         popad
  314.         ret
  315. endp
  316.  
  317. align 4
  318. proc buf_clear, buf_struc:dword, color:dword ;®ç¨á⪠ ¡ãä¥à  § ¤ ­ë¬ 梥⮬
  319.         pushad
  320.         mov edi,dword[buf_struc]
  321.  
  322.         mov ecx,buf2d_w
  323.         mov ebx,buf2d_h
  324.         imul ecx,ebx
  325.  
  326.         cld
  327.  
  328.         cmp buf2d_bits,8
  329.         jne .end_clear_8
  330.                 mov edi,buf2d_data
  331.                 mov al,byte[color]
  332.                 rep stosb
  333.                 jmp .end_clear_32
  334.         .end_clear_8:
  335.  
  336.         cmp buf2d_bits,24
  337.         jne .end_clear_24
  338.                 mov edi,buf2d_data
  339.                 mov eax,dword[color]
  340.                 mov ebx,eax
  341.                 shr ebx,16
  342.                 @@:
  343.                         stosw
  344.                         mov byte[edi],bl
  345.                         inc edi
  346.                         loop @b
  347.                 jmp .end_clear_32
  348.         .end_clear_24:
  349.  
  350.         cmp buf2d_bits,32
  351.         jne .end_clear_32
  352.                 mov edi,buf2d_data
  353.                 mov eax,dword[color]
  354.                 rep stosd
  355.                 ;jmp .end_clear_32
  356.         .end_clear_32:
  357.         popad
  358.         ret
  359. endp
  360.  
  361. ;äã­ªæ¨ï ¤«ï ®¡à¥§ ­¨ï ¡ãä¥à®¢ 8 ¨ 24 ¡¨â­ëå, ¯® § ¤ ­®¬ã 梥âã.
  362. ;¯ à ¬¥âà opt § ¤ ¥âáï ª®¬¡¨­ æ¨¥© ª®­áâ ­â:
  363. ; BUF2D_OPT_CROP_TOP - ®¡à¥§ª  ᢥàåã
  364. ; BUF2D_OPT_CROP_LEFT - ®¡à¥§ª  á«¥¢ 
  365. ; BUF2D_OPT_CROP_BOTTOM - ®¡à¥§ª  á­¨§ã
  366. ; BUF2D_OPT_CROP_RIGHT - ®¡à¥§ª  á¯à ¢ 
  367. align 4
  368. proc buf_crop_color, buf_struc:dword, color:dword, opt:dword
  369. locals
  370.         crop_r dd ?
  371. endl
  372.         pushad
  373.         mov edi,dword[buf_struc]
  374.         cmp buf2d_bits,24
  375.         jne .24end_f
  376.  
  377.         bt dword[opt],BUF2D_BIT_OPT_CROP_BOTTOM
  378.         jae .24no_crop_bottom
  379.                 mov eax,dword[color]
  380.                 mov edx,eax ;ax = colors - r,g
  381.                 shr edx,16 ;dl = color - b
  382.                 mov ecx,buf2d_h
  383.                 cmp ecx,1
  384.                 jle .24no_crop_bottom ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
  385.                 mov ebx,buf2d_w
  386.                 imul ecx,ebx
  387.                 lea esi,[ecx+ecx*2] ;esi=3*ecx
  388.                 add esi,buf2d_data
  389.                 cld
  390.                 @@:
  391.                         sub esi,3
  392.                         cmp word[esi],ax
  393.                         jne @f
  394.                         cmp byte[esi+2],dl
  395.                         jne @f
  396.                         loop @b
  397.                 @@:
  398.                 lea ebx,[ebx+ebx*2]
  399.                 xor edx,edx
  400.                 mov eax,buf2d_h
  401.                 imul eax,ebx
  402.                 add eax,buf2d_data ;eax - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  403.                 @@:
  404.                         add esi,ebx
  405.                         cmp esi,eax
  406.                         jge @f
  407.                         inc edx ;¢ëç¨á«ï¥¬ ç¨á«® ¯®«­ëå áâப ¤«ï ®¡à¥§ ­¨ï
  408.                         loop @b
  409.                 @@:
  410.                 cmp edx,0
  411.                 je .24no_crop_bottom
  412.                         cmp edx,buf2d_h
  413.                         jge .24no_crop_bottom ;çâ®-¡ë ­¥ ¯®«ãç¨âì ¯ãá⮩ ¡ãä¥à
  414.                         sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
  415.                         mov ecx,buf2d_h
  416.                         imul ecx,ebx ;ecx = ­®¢ë© à §¬¥à ¨§®¡à ¦¥­¨ï
  417.                         invoke mem.realloc,buf2d_data,ecx
  418.                         mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
  419.         .24no_crop_bottom:
  420.  
  421.         bt dword[opt],BUF2D_BIT_OPT_CROP_TOP
  422.         jae .24no_crop_top
  423.                 mov eax,dword[color]
  424.                 mov edx,eax ;ax = colors - r,g
  425.                 shr edx,16 ;dl = color - b
  426.                 mov esi,buf2d_data
  427.                 mov ecx,buf2d_h
  428.                 cmp ecx,1
  429.                 jle .24no_crop_top ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
  430.                 dec ecx ;¯à¨ ®¡à¥§ ­¨¨ ¤®«¦­  ®áâ âìáï ¬¨­¨¬ã¬ 1-­  áâப  ¯¨ªá¥«¥©
  431.                 mov ebx,buf2d_w
  432.                 imul ecx,ebx
  433.                 cld
  434.                 @@:
  435.                         cmp word[esi],ax
  436.                         jne @f
  437.                         cmp byte[esi+2],dl
  438.                         jne @f
  439.                         add esi,3
  440.                         loop @b
  441.                 @@:
  442.                 lea ebx,[ebx+ebx*2]
  443.                 xor edx,edx
  444.                 @@:
  445.                         sub esi,ebx
  446.                         cmp esi,buf2d_data
  447.                         jl @f
  448.                         inc edx ;¢ëç¨á«ï¥¬ ç¨á«® ¯®«­ëå áâப ¤«ï ®¡à¥§ ­¨ï
  449.                         loop @b
  450.                 @@:
  451.                 cmp edx,0
  452.                 je .24no_crop_top
  453.                         xor eax,eax
  454.                         sub eax,edx
  455.                         mov ebx,buf2d_h
  456.                         sub ebx,edx
  457.                         stdcall buf_offset_h, edi, eax, edx, ebx ;ᤢ¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢ ¡ãä¥à¥ ¢¢¥àå (eax<0)
  458.                         sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
  459.                         mov ecx,buf2d_h
  460.                         add buf2d_t,dx ;ᤢ¨£ ¥¬ ®âáâ㯠¢­¨§, ­  ç¨á«® ®¡à¥§ ­­ëå áâப
  461.                         mov ebx,buf2d_w
  462.                         imul ecx,ebx
  463.                         lea ecx,[ecx+ecx*2]
  464.                         invoke mem.realloc,buf2d_data,ecx
  465.                         mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
  466.         .24no_crop_top:
  467.  
  468.         bt dword[opt],BUF2D_BIT_OPT_CROP_RIGHT
  469.         jae .24no_crop_right
  470.                 mov eax,dword[color]
  471.                 mov edx,eax ;ax = colors - r,g
  472.                 shr edx,16 ;dl = color - b
  473.                 mov ebx,buf2d_w
  474.                 cmp ebx,1
  475.                 jle .24no_crop_right ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
  476.                 lea ebx,[ebx+ebx*2]
  477.                 mov esi,ebx
  478.                 imul esi,buf2d_h
  479.                 add esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  480.                 mov dword[crop_r],0
  481.                 cld
  482.                 .24found_beg_right:
  483.                 sub esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
  484.                 mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
  485.                 @@:
  486.                         cmp word[esi],ax
  487.                         jne .24found_right
  488.                         cmp byte[esi+2],dl
  489.                         jne .24found_right
  490.                         sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
  491.                         loop @b
  492.                 inc dword[crop_r]
  493.  
  494.                 mov ecx,buf2d_w
  495.                 dec ecx ;1 ª®«®­ª  ­  § ¯ á
  496.                 cmp dword[crop_r],ecx
  497.                 jge .24found_right
  498.  
  499.                 sub esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
  500.                 mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
  501.                 @@:
  502.                         add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
  503.                         cmp word[esi],ax
  504.                         jne .24found_right
  505.                         cmp byte[esi+2],dl
  506.                         jne .24found_right
  507.                         loop @b
  508.                 inc dword[crop_r]
  509.  
  510.                 mov ecx,buf2d_w
  511.                 dec ecx ;1 ª®«®­ª  ­  § ¯ á
  512.                 cmp dword[crop_r],ecx
  513.                 jl .24found_beg_right
  514.  
  515.                 .24found_right:
  516.                 cmp dword[crop_r],0
  517.                 je .24no_crop_right
  518.                         mov ecx,buf2d_w
  519.                         sub ecx,dword[crop_r]
  520.                         stdcall img_rgb_crop_r, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
  521.                         mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
  522.                         mov ebx,buf2d_h
  523.                         imul ecx,ebx
  524.                         lea ecx,[ecx+ecx*2]
  525.                         invoke mem.realloc,buf2d_data,ecx
  526.                         mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
  527.         .24no_crop_right:
  528.  
  529.         bt dword[opt],BUF2D_BIT_OPT_CROP_LEFT
  530.         jae .24no_crop_left
  531.                 mov eax,dword[color]
  532.                 mov edx,eax ;ax = colors - r,g
  533.                 shr edx,16 ;dl = color - b
  534.                 mov ebx,buf2d_w
  535.                 cmp ebx,1
  536.                 jle .24no_crop_left ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
  537.                 lea ebx,[ebx+ebx*2]
  538.                 mov esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ­ ç®«® ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  539.                 mov dword[crop_r],0
  540.                 cld
  541.                 .24found_beg_left:
  542.  
  543.                 mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
  544.                 @@:
  545.                         cmp word[esi],ax
  546.                         jne .24found_left
  547.                         cmp byte[esi+2],dl
  548.                         jne .24found_left
  549.                         add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
  550.                         loop @b
  551.                 inc dword[crop_r]
  552.                 add esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
  553.  
  554.                 mov ecx,buf2d_w
  555.                 dec ecx ;1 ª®«®­ª  ­  § ¯ á
  556.                 cmp dword[crop_r],ecx
  557.                 jge .24found_left
  558.  
  559.                 mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
  560.                 @@:
  561.                         sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
  562.                         cmp word[esi],ax
  563.                         jne .24found_left
  564.                         cmp byte[esi+2],dl
  565.                         jne .24found_left
  566.                         loop @b
  567.                 inc dword[crop_r]
  568.                 add esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
  569.  
  570.                 mov ecx,buf2d_w
  571.                 dec ecx ;1 ª®«®­ª  ­  § ¯ á
  572.                 cmp dword[crop_r],ecx
  573.                 jl .24found_beg_left
  574.  
  575.                 .24found_left:
  576.                 cmp dword[crop_r],0
  577.                 je .24no_crop_left
  578.                         mov ecx,buf2d_w
  579.                         sub ecx,dword[crop_r]
  580.                         stdcall img_rgb_crop_l, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
  581.                         mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
  582.                         mov ebx,buf2d_h
  583.                         imul ecx,ebx
  584.                         lea ecx,[ecx+ecx*2]
  585.                         invoke mem.realloc,buf2d_data,ecx
  586.                         mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
  587.                         mov eax,dword[crop_r]
  588.                         add buf2d_l,ax
  589.         .24no_crop_left:
  590.  
  591.         .24end_f:
  592.  
  593.  
  594.         cmp buf2d_bits,8
  595.         jne .8end_f
  596.  
  597.         bt dword[opt],BUF2D_BIT_OPT_CROP_BOTTOM
  598.         jae .8no_crop_bottom
  599.                 mov eax,dword[color]
  600.                 mov esi,buf2d_data
  601.                 mov ecx,buf2d_h
  602.                 cmp ecx,1
  603.                 jle .8no_crop_bottom ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
  604.                 mov ebx,buf2d_w
  605.                 imul ecx,ebx
  606.                 mov esi,ecx
  607.                 add esi,buf2d_data
  608.                 cld
  609.                 @@:
  610.                         dec esi
  611.                         cmp byte[esi],al
  612.                         jne @f
  613.                         loop @b
  614.                 @@:
  615.                 xor edx,edx
  616.                 mov eax,buf2d_h
  617.                 imul eax,ebx
  618.                 add eax,buf2d_data ;eax - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  619.                 @@:
  620.                         add esi,ebx
  621.                         cmp esi,eax
  622.                         jge @f
  623.                         inc edx
  624.                         loop @b
  625.                 @@:
  626.                 cmp edx,0
  627.                 je .8no_crop_bottom
  628.                         cmp edx,buf2d_h
  629.                         jge .8no_crop_bottom ;çâ®-¡ë ­¥ ¯®«ãç¨âì ¯ãá⮩ ¡ãä¥à
  630.                         sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
  631.                         mov ecx,buf2d_h
  632.                         imul ecx,ebx ;ecx = ­®¢ë© à §¬¥à ¨§®¡à ¦¥­¨ï
  633.                         invoke mem.realloc,buf2d_data,ecx
  634.                         mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
  635.         .8no_crop_bottom:
  636.  
  637.         bt dword[opt],BUF2D_BIT_OPT_CROP_TOP
  638.         jae .8no_crop_top
  639.                 mov eax,dword[color]
  640.                 mov esi,buf2d_data
  641.                 mov ecx,buf2d_h
  642.                 cmp ecx,1
  643.                 jle .8no_crop_top ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
  644.                 dec ecx ;¯à¨ ®¡à¥§ ­¨¨ ¤®«¦­  ®áâ âìáï ¬¨­¨¬ã¬ 1-­  áâப  ¯¨ªá¥«¥©
  645.                 mov ebx,buf2d_w
  646.                 imul ecx,ebx
  647.                 cld
  648.                 @@:
  649.                         cmp byte[esi],al
  650.                         jne @f
  651.                         inc esi
  652.                         loop @b
  653.                 @@:
  654.                 xor edx,edx
  655.                 @@:
  656.                         sub esi,ebx
  657.                         cmp esi,buf2d_data
  658.                         jl @f
  659.                         inc edx
  660.                         loop @b
  661.                 @@:
  662.                 cmp edx,0
  663.                 je .8no_crop_top
  664.                         xor eax,eax
  665.                         sub eax,edx
  666.                         mov ebx,buf2d_h
  667.                         sub ebx,edx
  668.                         stdcall buf_offset_h, edi, eax, edx, ebx
  669.                         mov ecx,buf2d_h
  670.                         sub ecx,edx
  671.                         mov buf2d_h,ecx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
  672.                         add buf2d_t,dx ;ᤢ¨£ ¥¬ ®âáâ㯠¢­¨§, ­  ç¨á«® ®¡à¥§ ­­ëå áâப
  673.                         mov ebx,buf2d_w
  674.                         imul ecx,ebx
  675.                         invoke mem.realloc,buf2d_data,ecx
  676.                         mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
  677.         .8no_crop_top:
  678.  
  679.         bt dword[opt],BUF2D_BIT_OPT_CROP_RIGHT
  680.         jae .8no_crop_right
  681.                 mov eax,dword[color]
  682.                 mov ebx,buf2d_w
  683.                 cmp ebx,1
  684.                 jle .8no_crop_right ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
  685.                 mov esi,ebx
  686.                 imul esi,buf2d_h
  687.                 add esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  688.                 xor edx,edx
  689.                 cld
  690.  
  691.                 .8found_beg:
  692.                 dec esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
  693.                 mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
  694.                 @@:
  695.                         cmp byte[esi],al
  696.                         jne .8found
  697.                         sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
  698.                         loop @b
  699.                 inc edx
  700.                 mov ecx,buf2d_w
  701.                 dec ecx ;1 ª®«®­ª  ­  § ¯ á
  702.                 cmp edx,ecx
  703.                 jge .8found
  704.  
  705.                 dec esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
  706.                 mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
  707.                 @@:
  708.                         add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
  709.                         cmp byte[esi],al
  710.                         jne .8found
  711.                         loop @b
  712.                 inc edx
  713.  
  714.                 mov ecx,buf2d_w
  715.                 dec ecx ;1 ª®«®­ª  ­  § ¯ á
  716.                 cmp edx,ecx
  717.                 jl .8found_beg
  718.  
  719.                 .8found:
  720.                 cmp edx,0
  721.                 je .8no_crop_right
  722.                         mov ecx,buf2d_w
  723.                         sub ecx,edx
  724.                         stdcall img_gray_crop_r, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
  725.                         mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
  726.                         mov ebx,buf2d_h
  727.                         imul ecx,ebx
  728.                         invoke mem.realloc,buf2d_data,ecx
  729.                         mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
  730.         .8no_crop_right:
  731.  
  732.         bt dword[opt],BUF2D_BIT_OPT_CROP_LEFT
  733.         jae .8no_crop_left
  734.                 mov eax,dword[color]
  735.                 mov ebx,buf2d_w
  736.                 cmp ebx,1
  737.                 jle .8no_crop_left ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
  738.                 mov esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ­ ç®«® ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  739.                 mov edx,0
  740.                 cld
  741.                 .8found_beg_left:
  742.  
  743.                 mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
  744.                 @@:
  745.                         cmp word[esi],ax
  746.                         jne .8found_left
  747.                         add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
  748.                         loop @b
  749.                 inc edx
  750.                 inc esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
  751.  
  752.                 mov ecx,buf2d_w
  753.                 dec ecx ;1 ª®«®­ª  ­  § ¯ á
  754.                 cmp edx,ecx
  755.                 jge .8found_left
  756.  
  757.                 mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
  758.                 @@:
  759.                         sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
  760.                         cmp word[esi],ax
  761.                         jne .8found_left
  762.                         loop @b
  763.                 inc edx
  764.                 inc esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
  765.  
  766.                 mov ecx,buf2d_w
  767.                 dec ecx ;1 ª®«®­ª  ­  § ¯ á
  768.                 cmp edx,ecx
  769.                 jl .8found_beg_left
  770.  
  771.                 .8found_left:
  772.                 cmp edx,0
  773.                 je .8no_crop_left
  774.                         mov ecx,buf2d_w
  775.                         sub ecx,edx
  776.                         stdcall img_gray_crop_l, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
  777.                         mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
  778.                         mov ebx,buf2d_h
  779.                         imul ecx,ebx
  780.                         invoke mem.realloc,buf2d_data,ecx
  781.                         mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
  782.                         mov eax,edx
  783.                         add buf2d_l,ax
  784.         .8no_crop_left:
  785.  
  786.         .8end_f:
  787.  
  788.         popad
  789.         ret
  790. endp
  791.  
  792. ;®¡à¥§ ¥¬ 梥⭮¥ ¨§®¡à ¦¥­¨¥ á ¯à ¢®© áâ®à®­ë
  793. ;input:
  794. ;data_rgb - pointer to rgb data
  795. ;size_w_old - width img in pixels
  796. ;size_w_new - new width img in pixels
  797. ;size_h - height img in pixels
  798. align 4
  799. proc img_rgb_crop_r, data_rgb:dword, size_w_old:dword, size_w_new:dword, size_h:dword
  800.         pushad
  801.         mov eax, dword[size_w_old]
  802.         lea eax, dword[eax+eax*2] ;eax = width(old) * 3(rgb)
  803.         mov ebx, dword[size_w_new]
  804.         lea ebx, dword[ebx+ebx*2] ;ebx = width(new) * 3(rgb)
  805.         mov edx, dword[size_h]
  806.         mov edi, dword[data_rgb] ;edi - ¯®«ã砥⠤ ­­ë¥
  807.         mov esi, edi
  808.         add edi, ebx
  809.         add esi, eax
  810.         cld
  811.         @@:
  812.                 dec edx ;㬥­ìè ¥¬ áç¥â稪 ®áâ ¢è¨åáï áâப ­  1
  813.                 cmp edx,0
  814.                 jle @f
  815.                 mov ecx, ebx
  816.                 rep movsb ;¯¥à¥­®á (ª®¯¨à®¢ ­¨¥) áâப¨ ¯¨ªá¥«¥©
  817.                 add esi,eax ;¯¥à¥å®¤ ­  ­®¢ãî áâà®çªã ¨§®¡à ¦¥­¨ï
  818.                 sub esi,ebx
  819.                 jmp @b
  820.         @@:
  821.         popad
  822.         ret
  823. endp
  824.  
  825. ;®¡à¥§ ¥¬ á¥à®¥ ¨§®¡à ¦¥­¨¥ á ¯à ¢®© áâ®à®­ë
  826. ;input:
  827. ;data_gray - pointer to gray data
  828. ;size_w_old - width img in pixels
  829. ;size_w_new - new width img in pixels
  830. ;size_h - height img in pixels
  831. align 4
  832. proc img_gray_crop_r, data_gray:dword, size_w_old:dword, size_w_new:dword, size_h:dword
  833.         pushad
  834.         mov eax, dword[size_w_old]
  835.         mov ebx, dword[size_w_new]
  836.         mov edx, dword[size_h]
  837.         mov edi, dword[data_gray] ;edi - ¯®«ã砥⠤ ­­ë¥
  838.         mov esi, edi
  839.         add edi, ebx
  840.         add esi, eax
  841.         cld
  842.         @@:
  843.                 dec edx ;㬥­ìè ¥¬ áç¥â稪 ®áâ ¢è¨åáï áâப ­  1
  844.                 cmp edx,0
  845.                 jle @f
  846.                 mov ecx, ebx
  847.                 rep movsb ;¯¥à¥­®á (ª®¯¨à®¢ ­¨¥) áâப¨ ¯¨ªá¥«¥©
  848.                 add esi,eax ;¯¥à¥å®¤ ­  ­®¢ãî áâà®çªã ¨§®¡à ¦¥­¨ï
  849.                 sub esi,ebx
  850.                 jmp @b
  851.         @@:
  852.         popad
  853.         ret
  854. endp
  855.  
  856. ;®¡à¥§ ¥¬ 梥⭮¥ ¨§®¡à ¦¥­¨¥ á «¥¢®© áâ®à®­ë
  857. ;input:
  858. ;data_rgb - pointer to rgb data
  859. ;size_w_old - width img in pixels
  860. ;size_w_new - new width img in pixels
  861. ;size_h - height img in pixels
  862. align 4
  863. proc img_rgb_crop_l, data_rgb:dword, size_w_old:dword, size_w_new:dword, size_h:dword
  864.         pushad
  865.         mov edi,dword[data_rgb]
  866.         mov esi,edi
  867.         mov eax,dword[size_w_old]
  868.         mov ebx,dword[size_w_new]
  869.         cmp eax,ebx
  870.         jle .end_f ;áâ àë© à §¬¥à ¨§®¡à ¦¥­¨ï ­¥ ¬®¦¥â ¡ëâì ¬¥­ìè¥ ­®¢®£® (¯à¨ ãá«®¢¨¨ ®¡à¥§ ­¨ï ª à⨭ª¨)
  871.                 lea eax,[eax+eax*2]
  872.                 lea ebx,[ebx+ebx*2]
  873.                 sub eax,ebx
  874.                 mov edx,dword[size_h] ;¢ëá®â  ¨§®¡à ¦¥­¨ï
  875.                 cld
  876.                 @@:
  877.                         add esi,eax
  878.                         mov ecx,ebx
  879.                         rep movsb
  880.                         dec edx
  881.                         cmp edx,0
  882.                         jg @b
  883.         .end_f:
  884.         popad
  885.         ret
  886. endp
  887.  
  888. ;®¡à¥§ ¥¬ á¥à®¥ ¨§®¡à ¦¥­¨¥ á «¥¢®© áâ®à®­ë
  889. ;input:
  890. ;data_gray - pointer to gray data
  891. ;size_w_old - width img in pixels
  892. ;size_w_new - new width img in pixels
  893. ;size_h - height img in pixels
  894. align 4
  895. proc img_gray_crop_l, data_gray:dword, size_w_old:dword, size_w_new:dword, size_h:dword
  896.         pushad
  897.         mov edi,dword[data_gray]
  898.         mov esi,edi
  899.         mov eax,dword[size_w_old]
  900.         mov ebx,dword[size_w_new]
  901.         cmp eax,ebx
  902.         jle .end_f ;áâ àë© à §¬¥à ¨§®¡à ¦¥­¨ï ­¥ ¬®¦¥â ¡ëâì ¬¥­ìè¥ ­®¢®£® (¯à¨ ãá«®¢¨¨ ®¡à¥§ ­¨ï ª à⨭ª¨)
  903.                 sub eax,ebx
  904.                 mov edx,dword[size_h] ;¢ëá®â  ¨§®¡à ¦¥­¨ï
  905.                 cld
  906.                 @@:
  907.                         add esi,eax
  908.                         mov ecx,ebx
  909.                         rep movsb
  910.                         dec edx
  911.                         cmp edx,0
  912.                         jg @b
  913.         .end_f:
  914.         popad
  915.         ret
  916. endp
  917.  
  918. ;hoffs - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ­  ª®âàë¥ ¯®¤­¨¬ ¥âáï/®¯ã᪠¥âáï ¨§®¡à ¦¥­¨¥
  919. ;img_t - ¢ëá®â , á ª®â®à®© ­ ç¨­ ¥âáï ¤¢¨£ îé ïáï ç áâì ¨§®¡à ¦¥­¨ï
  920. align 4
  921. proc buf_offset_h, buf_struc:dword, hoffs:dword, img_t:dword, img_h:dword ;ᤢ¨£ ¥â ¨§®¡à ¦¥­¨¥ ¯® ¢ëá®â¥
  922.         pushad
  923.         mov edi,dword[buf_struc]
  924.         cmp buf2d_bits,24
  925.         jne .end_move_24
  926.  
  927.         mov eax,[hoffs]
  928.         cmp eax,0
  929.         je .end_move_24
  930.                 mov ebx,buf2d_w
  931.                 mov edx,dword[img_t]
  932.                         mov ecx,dword[img_h] ;ecx - ¢ëá®â  ᤢ¨£ ¥¬ëå ¤ ­­ëå
  933.                         cmp ecx,buf2d_h
  934.                         jge .end_f ;®è¨¡®ç­®¥ ãá«®¢¨¥, ¢ëá®â  ¨§®¡à ¦¥­¨ï ¬¥­ìè¥ ç¥¬ ¢ëá®â  ᤢ¨£ ¥¬®£® ¨§®¡à ¦¥­¨ï
  935.                         imul ecx,ebx ;ecx - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ ᤢ¨£ ¥¬ëå ¤ ­­ëå
  936.                         lea ecx,[ecx+ecx*2]
  937.                 imul ebx,edx
  938.                 lea ebx,[ebx+ebx*2]
  939.                 mov esi,buf2d_data
  940.                 add esi,ebx
  941.  
  942.                 add edx,eax ;edx = img_t+hoffs (hoffs<0)
  943.                 mov ebx,buf2d_w
  944.                 imul ebx,edx
  945.                 lea ebx,[ebx+ebx*2]
  946.                 mov edi,buf2d_data ;¯®§¨æ¨ï, ªã¤  ¡ã¤¥â ¤¢¨£ âìáï ¨§®¡à ¦¥­¨¥
  947.                 add edi,ebx
  948.  
  949.                 cmp eax,0
  950.                 jg .move_down_24
  951.                         ;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢¢¥àå
  952.                         cld
  953.                         rep movsb
  954.                         jmp .end_f
  955.                 .move_down_24:
  956.                         ;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢­¨§
  957.                         add esi,ecx
  958.                         dec esi
  959.                         add edi,ecx
  960.                         dec edi
  961.                         std
  962.                         rep movsb
  963.                         jmp .end_f
  964.         .end_move_24:
  965.  
  966. ;stdcall print_err,sz_buf2d_offset_h,txt_err_n24b
  967.  
  968.         cmp buf2d_bits,8
  969.         jne .end_move_8
  970.  
  971.         mov eax,[hoffs]
  972.         cmp eax,0
  973.         je .end_move_8
  974.                 ;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢¢¥àå
  975.                 mov ebx,buf2d_w
  976.                 mov edx,dword[img_t]
  977.                         mov ecx,dword[img_h] ;ecx - ¢ëá®â  ᤢ¨£ ¥¬ëå ¤ ­­ëå
  978.                         cmp ecx,buf2d_h
  979.                         jge .end_f ;®è¨¡®ç­®¥ ãá«®¢¨¥, ¢ëá®â  ¨§®¡à ¦¥­¨ï ¬¥­ìè¥ ç¥¬ ¢ëá®â  ᤢ¨£ ¥¬®£® ¨§®¡à ¦¥­¨ï
  980.                         imul ecx,ebx ;ecx - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ ᤢ¨£ ¥¬ëå ¤ ­­ëå
  981.                 imul ebx,edx
  982.                 mov esi,buf2d_data
  983.                 add esi,ebx
  984.  
  985.                 add edx,eax ;edx = img_t+hoffs (hoffs<0)
  986.                 mov ebx,buf2d_w
  987.                 imul ebx,edx
  988.                 mov edi,buf2d_data ;¯®§¨æ¨ï, ªã¤  ¡ã¤¥â ¤¢¨£ âìáï ¨§®¡à ¦¥­¨¥
  989.                 add edi,ebx
  990.  
  991.                 cmp eax,0
  992.                 jg .move_down_8
  993.                         cld
  994.                         rep movsb
  995.                         jmp .end_f
  996.                 .move_down_8:
  997.                         ;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢­¨§
  998.                         add esi,ecx
  999.                         dec esi
  1000.                         add edi,ecx
  1001.                         dec edi
  1002.                         std
  1003.                         rep movsb
  1004.                         jmp .end_f
  1005.         .end_move_8:
  1006.  
  1007.         .end_f:
  1008.         popad
  1009.         ret
  1010. endp
  1011.  
  1012.  
  1013. align 4
  1014. proc buf_draw_buf, buf_struc:dword
  1015.         pushad
  1016.         mov edi,dword[buf_struc]
  1017.         cmp buf2d_bits,24
  1018.         jne .error
  1019.                 mov eax,7
  1020.                 mov ebx,buf2d_data
  1021.  
  1022.                 mov ecx,buf2d_w
  1023.                 ror ecx,16
  1024.                 mov edx,buf2d_h
  1025.                 mov cx,dx
  1026.  
  1027.                 mov edx,buf2d_size_lt
  1028.                 ror edx,16
  1029.                 int 0x40
  1030.                 jmp .end_draw_24
  1031.         .error:
  1032.                 stdcall print_err,sz_buf2d_draw,txt_err_n24b
  1033.         .end_draw_24:
  1034.         popad
  1035.         ret
  1036. endp
  1037.  
  1038. align 4
  1039. proc buf_delete, buf_struc:dword
  1040.         push eax edi
  1041.         mov edi,dword[buf_struc]
  1042.         invoke mem.free,buf2d_data
  1043.         pop edi eax
  1044.         ret
  1045. endp
  1046.  
  1047. align 4
  1048. proc buf_resize, buf_struc:dword, new_w:dword, new_h:dword
  1049.         pushad
  1050.         mov edi,dword[buf_struc]
  1051.         cmp buf2d_bits,24
  1052.         jne .24bit
  1053.                 mov eax,dword[new_w]
  1054.                 cmp eax,1
  1055.                 jl @f
  1056.                         mov buf2d_w,eax
  1057.                 @@:
  1058.                 mov ecx,buf2d_w
  1059.                 mov eax,dword[new_h]
  1060.                 cmp eax,1
  1061.                 jl @f
  1062.                         mov buf2d_h,eax
  1063.                 @@:
  1064.                 mov ebx,buf2d_h
  1065.                 imul ecx,ebx
  1066.                 lea ecx,[ecx+ecx*2] ; 24 bit = 3
  1067.                 invoke mem.realloc,buf2d_data,ecx ;¨§¬¥­ï¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
  1068.                 mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
  1069.         .24bit:
  1070.         popad
  1071.         ret
  1072. endp
  1073.  
  1074. align 4
  1075. rot_table: ;â ¡«¨æ  ¤«ï 㪠§ ­¨ï ­  ¯®¤ä㭪樨 ¤«ï ¯®¢®à®â®¢
  1076.         dd buf_rotate.8b90,buf_rotate.24b90,buf_rotate.32b90,\
  1077.         buf_rotate.8b180,buf_rotate.24b180,buf_rotate.32b180
  1078.  
  1079. ;¯®¢®à®â ¨§®¡à ¦¥­¨ï ­  90 ¨«¨ 180 £à ¤ãᮢ
  1080. align 4
  1081. proc buf_rotate, buf_struc:dword, angle:dword
  1082. locals
  1083.         n_data dd ?
  1084.         dec_h dd ? ;ç¨á«® ¡ ©â, ¤«ï 㬥­ì襭¨ï ª®®à¤¨­ âë y
  1085. endl
  1086.         pushad
  1087.         mov edi,[buf_struc]
  1088.         mov ebx,buf2d_w
  1089.         mov ecx,buf2d_h
  1090.  
  1091.         lea eax,[rot_table]
  1092.         cmp dword[angle],90 ;¯à®¢¥àª  㣫  ¯®¢®à®â 
  1093.         je .beg_0
  1094.         cmp dword[angle],180
  1095.         jne @f
  1096.                 add eax,12
  1097.                 jmp .beg_0
  1098.         @@:
  1099.         jmp .end_f
  1100.         .beg_0: ;¯à®¢¥àª  ¡¨â­®á⨠¡ãä¥à 
  1101.         cmp buf2d_bits,8
  1102.         jne @f
  1103.                 jmp dword[eax]
  1104.         @@:
  1105.         cmp buf2d_bits,24
  1106.         jne @f
  1107.                 add eax,4
  1108.                 jmp dword[eax]
  1109.         @@:
  1110.         cmp buf2d_bits,32
  1111.         jne @f
  1112.                 add eax,8
  1113.                 jmp dword[eax]
  1114.         @@:
  1115.         jmp .end_f
  1116.  
  1117.         .8b90: ;¯®¢®à®â 8 ¡¨â­®£® ¡ãä¥à  ­  90 £à ¤ãᮢ
  1118.                 mov edx,ecx ;edx - buf_h
  1119.                 imul ecx,ebx
  1120.                 invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
  1121.                 cmp eax,0
  1122.                 je .end_f
  1123.                 mov [n_data],eax
  1124.                 mov [dec_h],ecx
  1125.                 inc dword[dec_h]
  1126.  
  1127.                 ;copy buf --> mem
  1128.                 mov edi,[buf_struc]
  1129.                 mov esi,buf2d_data
  1130.                 mov edi,eax ;[n_data]
  1131.                 dec edx ;ª®à¥ªâ¨à㥬 edx ­  1 ¡ ©â, ¤«ï ª®¬¯¥­á æ¨¨ ᤢ¨£  ¢ movsb
  1132.                 add edi,edx
  1133.                 xor eax,eax
  1134.                 cld
  1135.                 .cycle_0:
  1136.                         movsb
  1137.                         add edi,edx
  1138.                         inc eax
  1139.                         cmp eax,ebx
  1140.                         jl @f
  1141.                                 xor eax,eax
  1142.                                 sub edi,[dec_h]
  1143.                         @@:
  1144.                         loop .cycle_0
  1145.  
  1146.                 ;change buf_w <---> buf_h
  1147.                 mov esi,[n_data]
  1148.                 mov edi,[buf_struc]
  1149.                 mov edi,buf2d_data
  1150.                 mov ecx,ebx
  1151.                 inc edx ;¨á¯à ¢«ï¥¬ ᪮४â¨à®¢ ­­ë© edx
  1152.                 imul ecx,edx
  1153.                 ;copy buf <-- mem
  1154.                 ;cld
  1155.                 rep movsb
  1156.                 invoke mem.free,[n_data]
  1157.                 jmp .change_w_h
  1158.         .24b90: ;¯®¢®à®â 24 ¡¨â­®£® ¡ãä¥à  ­  90 £à ¤ãᮢ
  1159.                 mov esi,ecx
  1160.                 imul esi,ebx
  1161.                 lea ecx,[ecx+ecx*2]
  1162.                 mov edx,ecx ;edx - buf_h * 3
  1163.                 imul ecx,ebx
  1164.                 invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
  1165.                 cmp eax,0
  1166.                 je .end_f
  1167.                 mov [n_data],eax
  1168.                 mov [dec_h],ecx
  1169.                 add dword[dec_h],3
  1170.  
  1171.                 ;copy buf --> mem
  1172.                
  1173.                 mov edi,[buf_struc]
  1174.                 mov ecx,esi
  1175.                 mov esi,buf2d_data
  1176.                 mov edi,eax ;[n_data]
  1177.                 sub edx,3 ;ª®à¥ªâ¨à㥬 edx ­  3 ¡ ©â , ¤«ï ª®¬¯¥­á æ¨¨ ᤢ¨£ 
  1178.                 add edi,edx
  1179.                 xor eax,eax
  1180.                 cld
  1181.                 .cycle_1:
  1182.                         movsw
  1183.                         movsb
  1184.                         add edi,edx
  1185.                         inc eax
  1186.                         cmp eax,ebx
  1187.                         jl @f
  1188.                                 xor eax,eax
  1189.                                 sub edi,[dec_h]
  1190.                         @@:
  1191.                         loop .cycle_1
  1192.  
  1193.                 ;copy buf <-- mem
  1194.                 mov esi,[n_data]
  1195.                 mov edi,[buf_struc]
  1196.                 mov edi,buf2d_data
  1197.                 mov ecx,ebx
  1198.                 add edx,3 ;¨á¯à ¢«ï¥¬ ᪮४â¨à®¢ ­­ë© edx
  1199.                 imul ecx,edx
  1200.                 ;cld
  1201.                 rep movsb
  1202.                 invoke mem.free,[n_data]
  1203.                 jmp .change_w_h
  1204.         .32b90: ;¯®¢®à®â 32 ¡¨â­®£® ¡ãä¥à  ­  90 £à ¤ãᮢ
  1205.                 shl ecx,2
  1206.                 mov edx,ecx ;edx - buf_h * 4
  1207.                 imul ecx,ebx
  1208.                 invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
  1209.                 cmp eax,0
  1210.                 je .end_f
  1211.                 mov [n_data],eax
  1212.                 mov [dec_h],ecx
  1213.                 add dword[dec_h],4
  1214.  
  1215.                 ;copy buf --> mem
  1216.                 mov edi,[buf_struc]
  1217.                 shr ecx,2
  1218.                 mov esi,buf2d_data
  1219.                 mov edi,eax ;[n_data]
  1220.                 sub edx,4 ;ª®à¥ªâ¨à㥬 edx ­  4 ¡ ©â , ¤«ï ª®¬¯¥­á æ¨¨ ᤢ¨£  ¢ movsd
  1221.                 add edi,edx
  1222.                 xor eax,eax
  1223.                 cld
  1224.                 .cycle_2:
  1225.                         movsd
  1226.                         add edi,edx
  1227.                         inc eax
  1228.                         cmp eax,ebx
  1229.                         jl @f
  1230.                                 xor eax,eax
  1231.                                 sub edi,[dec_h]
  1232.                         @@:
  1233.                         loop .cycle_2
  1234.  
  1235.                 ;copy buf <-- mem
  1236.                 mov esi,[n_data]
  1237.                 mov edi,[buf_struc]
  1238.                 mov edi,buf2d_data
  1239.                 mov ecx,ebx
  1240.                 add edx,4 ;¨á¯à ¢«ï¥¬ ᪮४â¨à®¢ ­­ë© edx
  1241.                 imul ecx,edx
  1242.                 shr ecx,2
  1243.                 ;cld
  1244.                 rep movsd
  1245.                 invoke mem.free,[n_data]
  1246.                 ;jmp .change_w_h
  1247.         .change_w_h: ;change buf_w <---> buf_h
  1248.                 mov edi,[buf_struc]
  1249.                 mov eax,buf2d_w
  1250.                 mov ebx,buf2d_h
  1251.                 mov buf2d_h,eax
  1252.                 mov buf2d_w,ebx
  1253.                 jmp .end_f
  1254.         .8b180: ;¯®¢®à®â 8 ¡¨â­®£® ¡ãä¥à  ­  180 £à ¤ãᮢ
  1255.                 mov edi,buf2d_data
  1256.                 mov esi,edi
  1257.                 imul ecx,ebx
  1258.                 add esi,ecx
  1259.                 dec esi
  1260.                 shr ecx,1 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¡ãä¥à  : 2
  1261.                 std
  1262.                 @@:
  1263.                         lodsb
  1264.                         mov ah,byte[edi]
  1265.                         mov byte[esi+1],ah
  1266.                         mov byte[edi],al
  1267.                         inc edi
  1268.                         loop @b
  1269.                         jmp .end_f
  1270.         .24b180: ;¯®¢®à®â 24 ¡¨â­®£® ¡ãä¥à  ­  180 £à ¤ãᮢ
  1271.                 mov esi,buf2d_data
  1272.                 mov edi,esi
  1273.                 imul ecx,ebx
  1274.                 mov eax,ecx
  1275.                 lea ecx,[ecx+ecx*2]
  1276.                 add edi,ecx
  1277.                 sub edi,3
  1278.                 shr eax,1
  1279.                 mov ecx,eax ;ecx - ç¨á«® ¯¨ªá¥«¥© ¡ãä¥à  : 2
  1280.                 cld
  1281.                 @@:
  1282.                         lodsw
  1283.                         mov edx,eax
  1284.                         lodsb
  1285.                         mov bx,word[edi]
  1286.                         mov word[esi-3],bx
  1287.                         mov bl,byte[edi+2]
  1288.                         mov byte[esi-1],bl
  1289.                         mov byte[edi+2],al
  1290.                         mov word[edi],dx
  1291.                         sub edi,3
  1292.                         loop @b
  1293.                         jmp .end_f
  1294.         .32b180: ;¯®¢®à®â 32 ¡¨â­®£® ¡ãä¥à  ­  180 £à ¤ãᮢ
  1295.                 mov edi,buf2d_data
  1296.                 mov esi,edi
  1297.                 imul ecx,ebx
  1298.                 shl ecx,2
  1299.                 add esi,ecx
  1300.                 sub esi,4
  1301.                 shr ecx,3 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¡ãä¥à  : 2
  1302.                 std
  1303.                 @@:
  1304.                         lodsd
  1305.                         mov ebx,dword[edi]
  1306.                         mov dword[esi+4],ebx
  1307.                         mov dword[edi],eax
  1308.                         add edi,4
  1309.                         loop @b
  1310.                 ;jmp .end_f
  1311.  
  1312.         .end_f:
  1313.         popad
  1314.         ret
  1315. endp
  1316.  
  1317. align 4
  1318. proc buf_line_brs, buf_struc:dword, coord_x0:dword, coord_y0:dword, coord_x1:dword, coord_y1:dword, color:dword
  1319. locals
  1320.         loc_1 dd ?
  1321.         loc_2 dd ?
  1322.         napravl db ?
  1323. endl
  1324.         pushad
  1325.                 mov eax,dword[coord_x1]
  1326.                 sub eax,dword[coord_x0]
  1327.                 bt eax,31
  1328.                 jae @f
  1329.                         neg eax
  1330.                         inc eax
  1331.                 @@:
  1332.                 mov ebx,dword[coord_y1]
  1333.                 sub ebx,dword[coord_y0]
  1334.                 jnz @f
  1335.                         ;¥á«¨ § ¤ ­  £®à¨§®­â «ì­ ï «¨­¨ï y0=y1
  1336.                         stdcall buf_line_h, [buf_struc], [coord_x0], [coord_y0], [coord_x1], [color]
  1337.                         jmp .coord_end
  1338.                 @@:
  1339.                 bt ebx,31
  1340.                 jae @f
  1341.                         neg ebx
  1342.                         inc ebx
  1343.                 @@:
  1344.                 mov edx,dword[color]
  1345.  
  1346.                 mov [napravl],byte 0 ;bool steep=false
  1347.                 cmp eax,ebx
  1348.                 jle @f
  1349.                         mov [napravl],byte 1 ;bool steep=true
  1350.                         swap dword[coord_x0],dword[coord_y0] ;swap(x0, y0);
  1351.                         swap dword[coord_x1],dword[coord_y1] ;swap(x1, y1);
  1352.                 @@:
  1353.                 mov eax,dword[coord_y0] ;x0
  1354.                 cmp eax,dword[coord_y1] ;if(x0>x1)
  1355.                 jle @f
  1356.                         swap dword[coord_y0],dword[coord_y1] ;swap(x0, x1);
  1357.                         swap dword[coord_x0],dword[coord_x1] ;swap(y0, y1);
  1358.                 @@:
  1359.  
  1360. ; int deltax esi
  1361. ; int deltay edi
  1362. ; int error  ebp-6
  1363. ; int ystep  ebp-8
  1364.  
  1365.                 mov eax,dword[coord_y0]
  1366.                 mov esi,dword[coord_y1]
  1367.                 sub esi,eax ;deltax = y1-y0
  1368.                 mov ebx,esi
  1369.                 shr ebx,1
  1370.                 mov [loc_1],ebx ;error = deltax/2
  1371.  
  1372.                 mov eax,dword[coord_x0]
  1373.                 mov edi,dword[coord_x1]
  1374.                 mov [loc_2],dword -1 ;ystep = -1
  1375.                 cmp eax,edi ;if (x0<x1) ystep = 1;
  1376.                 jge @f
  1377.                         mov [loc_2],dword 1 ;ystep = 1
  1378.                 @@:
  1379.                 sub edi,eax ;x1-x0
  1380.  
  1381.                 bts edi,31
  1382.                 jae @f
  1383.                         neg edi
  1384.                         inc edi
  1385.                 @@:
  1386.                 and edi,0x7fffffff ;deltay = abs(x1-x0)
  1387.  
  1388.                 mov eax,edi
  1389.                 mov edi,[buf_struc]
  1390.                 cmp buf2d_bits,8
  1391.                 je @f
  1392.                 cmp buf2d_bits,24
  1393.                 je @f
  1394.                         jmp .coord_end
  1395.                 @@:
  1396.  
  1397.                 cmp [napravl],0
  1398.                 jne .coord_yx
  1399.                         mov ebx,dword[coord_x0]
  1400.                         mov ecx,dword[coord_y0]
  1401.  
  1402.                         @@: ;for (x=x0 ; x<x1; x++) ;------------------------------------
  1403.                                 cmp ecx,dword[coord_y1]
  1404.                                 jg @f ;jge ???
  1405.                                 call draw_pixel
  1406.  
  1407.                                 sub dword[loc_1],eax ;error -= deltay
  1408.                                 cmp dword[loc_1],0 ;if(error<0)
  1409.                                 jge .if0
  1410.                                         add ebx,[loc_2] ;y += ystep
  1411.                                         add [loc_1],esi ;error += deltax
  1412.                                 .if0:
  1413.                                 inc ecx
  1414.                                 jmp @b
  1415.                         @@:
  1416.                         jmp .coord_end
  1417.                 .coord_yx:
  1418.                         mov ebx,dword[coord_y0]
  1419.                         mov ecx,dword[coord_x0]
  1420.  
  1421.                         @@: ;for (x=x0 ; x<x1; x++) ;------------------------------------
  1422.                                 cmp ebx,dword[coord_y1]
  1423.                                 jg @f ;jge ???
  1424.                                 call draw_pixel
  1425.  
  1426.                                 sub dword[loc_1],eax ;error -= deltay
  1427.                                 cmp dword[loc_1],0 ;if(error<0)
  1428.                                 jge .if1
  1429.                                         add ecx,[loc_2] ;y += ystep
  1430.                                         add [loc_1],esi ;error += deltax
  1431.                                 .if1:
  1432.                                 inc ebx
  1433.                                 jmp @b
  1434.                         @@:
  1435.         .coord_end:
  1436.         popad
  1437.         ret
  1438. endp
  1439.  
  1440. ;à¨á®¢ ­¨¥ ᣫ ¦¥­­®© «¨­¨¨
  1441. align 4
  1442. proc buf_line_brs_sm, buf_struc:dword, coord_x0:dword, coord_y0:dword, coord_x1:dword, coord_y1:dword, color:dword
  1443. locals
  1444.         loc_1 dd ?
  1445.         loc_2 dd ?
  1446.         napravl db ?
  1447. endl
  1448.         pushad
  1449.                 mov eax,dword[coord_x1]
  1450.                 sub eax,dword[coord_x0]
  1451.                 bt eax,31
  1452.                 jae @f
  1453.                         neg eax
  1454.                         inc eax
  1455.                 @@:
  1456.                 mov ebx,dword[coord_y1]
  1457.                 sub ebx,dword[coord_y0]
  1458.                 jnz @f
  1459.                         ;¥á«¨ § ¤ ­  £®à¨§®­â «ì­ ï «¨­¨ï y0=y1
  1460.                         stdcall buf_line_h, [buf_struc], [coord_x0], [coord_y0], [coord_x1], [color]
  1461.                         jmp .coord_end
  1462.                 @@:
  1463.                 bt ebx,31
  1464.                 jae @f
  1465.                         neg ebx
  1466.                         inc ebx
  1467.                 @@:
  1468.                 mov edx,dword[color]
  1469.  
  1470.                 mov [napravl],byte 0 ;bool steep=false
  1471.                 cmp eax,ebx
  1472.                 jle @f
  1473.                         mov [napravl],byte 1 ;bool steep=true
  1474.                         swap dword[coord_x0],dword[coord_y0] ;swap(x0, y0);
  1475.                         swap dword[coord_x1],dword[coord_y1] ;swap(x1, y1);
  1476.                 @@:
  1477.                 mov eax,dword[coord_y0] ;x0
  1478.                 cmp eax,dword[coord_y1] ;if(x0>x1)
  1479.                 jle @f
  1480.                         swap dword[coord_y0],dword[coord_y1] ;swap(x0, x1);
  1481.                         swap dword[coord_x0],dword[coord_x1] ;swap(y0, y1);
  1482.                 @@:
  1483.  
  1484. ; int deltax esi
  1485. ; int deltay edi
  1486. ; int error  ebp-6
  1487. ; int ystep  ebp-8
  1488.  
  1489.                 mov eax,dword[coord_y0]
  1490.                 mov esi,dword[coord_y1]
  1491.                 sub esi,eax ;deltax = y1-y0
  1492.                 mov ebx,esi
  1493.                 shr ebx,1
  1494.                 mov [loc_1],ebx ;error = deltax/2
  1495.  
  1496.                 mov eax,dword[coord_x0]
  1497.                 mov edi,dword[coord_x1]
  1498.                 mov [loc_2],dword -1 ;ystep = -1
  1499.                 cmp eax,edi ;if (x0<x1) ystep = 1;
  1500.                 jge @f
  1501.                         mov [loc_2],dword 1 ;ystep = 1
  1502.                 @@:
  1503.                 sub edi,eax ;x1-x0
  1504.  
  1505.                 bts edi,31
  1506.                 jae @f
  1507.                         neg edi
  1508.                         inc edi
  1509.                 @@:
  1510.                 and edi,0x7fffffff ;deltay = abs(x1-x0)
  1511.  
  1512.                 mov eax,edi
  1513.                 mov edi,[buf_struc]
  1514.                 cmp buf2d_bits,24
  1515.                 jne .coord_end
  1516.  
  1517.                 cmp [napravl],0
  1518.                 jne .coord_yx
  1519.                         mov ebx,dword[coord_x0]
  1520.                         mov ecx,dword[coord_y0]
  1521.  
  1522.                         @@: ;for (x=x0 ; x<x1; x++) ;------------------------------------
  1523.                                 cmp ecx,dword[coord_y1]
  1524.                                 jg @f ;jge ???
  1525.                                 push eax
  1526.                                         mov eax,esi
  1527.                                         sub eax,[loc_1]
  1528.                                         stdcall draw_pixel_transp, eax,esi
  1529.                                 pop eax
  1530.                                 add ebx,[loc_2]
  1531.                                 stdcall draw_pixel_transp, [loc_1],esi
  1532.                                 sub ebx,[loc_2]
  1533.  
  1534.                                 sub dword[loc_1],eax ;error -= deltay
  1535.                                 cmp dword[loc_1],0 ;if(error<0)
  1536.                                 jge .if0
  1537.                                         add ebx,[loc_2] ;y += ystep
  1538.                                         add [loc_1],esi ;error += deltax
  1539.                                 .if0:
  1540.                                 inc ecx
  1541.                                 jmp @b
  1542.                         @@:
  1543.                         jmp .coord_end
  1544.                 .coord_yx:
  1545.                         mov ebx,dword[coord_y0]
  1546.                         mov ecx,dword[coord_x0]
  1547.  
  1548.                         @@: ;for (x=x0 ; x<x1; x++) ;------------------------------------
  1549.                                 cmp ebx,dword[coord_y1]
  1550.                                 jg @f ;jge ???
  1551.                                 push eax
  1552.                                         mov eax,esi
  1553.                                         sub eax,[loc_1]
  1554.                                         stdcall draw_pixel_transp, eax,esi
  1555.                                 pop eax
  1556.                                 add ecx,[loc_2]
  1557.                                 stdcall draw_pixel_transp, [loc_1],esi
  1558.                                 sub ecx,[loc_2]
  1559.  
  1560.                                 sub dword[loc_1],eax ;error -= deltay
  1561.                                 cmp dword[loc_1],0 ;if(error<0)
  1562.                                 jge .if1
  1563.                                         add ecx,[loc_2] ;y += ystep
  1564.                                         add [loc_1],esi ;error += deltax
  1565.                                 .if1:
  1566.                                 inc ebx
  1567.                                 jmp @b
  1568.                         @@:
  1569.         .coord_end:
  1570.         popad
  1571.         ret
  1572. endp
  1573.  
  1574. ;à¨á®¢ ­¨¥ £®à¨§®­â «ì­®© «¨­¨¨, ¯®â®¬ã ­¥â ¯ à ¬¥âà  coord_y1
  1575. align 4
  1576. proc buf_line_h, buf_struc:dword, coord_x0:dword, coord_y0:dword, coord_x1:dword, color:dword
  1577.         pushad
  1578.         pushfd
  1579.                 mov edi,[buf_struc]
  1580.                 cmp buf2d_bits,8
  1581.                 je @f
  1582.                 cmp buf2d_bits,24
  1583.                 je @f
  1584.                         jmp .end24
  1585.                 @@: ;®¯à¥¤¥«¥­¨¥ ª®®à¤¨­ â «¨­¨¨ ®â­®á¨â¥«ì­® ¡ãä¥à 
  1586.  
  1587.                 mov ecx,dword[coord_y0]
  1588.                 bt ecx,31
  1589.                 jc .end24 ;¥á«¨ ª®®à¤¨­ â  y0 ®âà¨æ â¥«ì­ ï
  1590.                 cmp ecx,buf2d_h
  1591.                 jge .end24 ;¥á«¨ ª®®à¤¨­ â  y0 ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
  1592.  
  1593.                 mov ebx,dword[coord_x0]
  1594.                 mov esi,dword[coord_x1]
  1595.                 cmp ebx,esi
  1596.                 jle @f
  1597.                         xchg ebx,esi ;¥á«¨ x0 > x1 â® ¬¥­ï¥¬ ¬¥áâ ¬¨ x0 ¨ x1
  1598.                 @@:
  1599.                 bt ebx,31
  1600.                 jae @f
  1601.                         ;¥á«¨ ª®®à¤¨­ â  x0 ®âà¨æ â¥«ì­ ï
  1602.                         xor ebx,ebx
  1603.                 @@:
  1604.                 cmp esi,buf2d_w
  1605.                 jl @f
  1606.                         ;¥á«¨ ª®®à¤¨­ â  x0 ¡®«ìè¥ è¨à¨­ë ¡ãä¥à 
  1607.                         mov esi,buf2d_w
  1608.                         dec esi
  1609.                 @@:
  1610.                 cmp ebx,esi
  1611.                 jg .end24 ;¥á«¨ x0 > x1 ¬®¦¥â ¢®§­¨ª­ãâì ª®£¤  ®¡¥ ª®®à¤¨­ âë x0, x1 ­ å®¤¨«¨áì §  ®¤­¨¬ ¨§ ¯à¥¤¥«®¢ ¡ãä¥à 
  1612.  
  1613.                 cmp buf2d_bits,24
  1614.                 je .beg24
  1615.                         ;à¨á®¢ ­¨¥ ¢ 8 ¡¨â­®¬ ¡ãä¥à¥
  1616.                         ;¢ edx ¢ëç¨á«ï¥¬ ­ ç «® 1-© â®çª¨ «¨­¨¨ ¢ ¡ãä¥à¥ ¨§®¡à ¦¥­¨ï
  1617.                         mov edx,buf2d_w ;size x
  1618.                         imul edx,ecx ;size_x*y
  1619.                         add edx,ebx      ;size_x*y+x
  1620.                         add edx,buf2d_data ;ptr+(size_x*y+x)
  1621.                         mov edi,edx ;⥯¥àì ¬®¦¥¬ ¯®àâ¨âì 㪠§ â¥«ì ­  ¡ãä¥à
  1622.  
  1623.                         mov ecx,esi
  1624.                         sub ecx,ebx ;¢ ecx ª®««¨ç¥á⢮ â®ç¥ª «¨­¨¨ ¢ë¢®¤¨¬ëå ¢ ¡ãä¥à
  1625.                         inc ecx ;çâ®-¡ë ¯®á«¥¤­ïï â®çª  «¨­¨¨ â ª¦¥ ®â®¡à ¦ « áì
  1626.                         mov eax,dword[color] ;¡ã¤¥¬ ¨á¯®«ì§®¢ âì ⮫쪮 §­ ç¥­¨¥ ¢ al
  1627.                         cld
  1628.                         rep stosb ;横« ¯® ®á¨ x ®â x0 ¤® x1 (¢ª«îç ï x1)
  1629.                         jmp .end24
  1630.  
  1631.                 .beg24: ;à¨á®¢ ­¨¥ ¢ 24 ¡¨â­®¬ ¡ãä¥à¥
  1632.                 ;¢ eax ¢ëç¨á«ï¥¬ ­ ç «® 1-© â®çª¨ «¨­¨¨ ¢ ¡ãä¥à¥ ¨§®¡à ¦¥­¨ï
  1633.                 mov eax,buf2d_w ;size x
  1634.                 imul eax,ecx ;size_x*y
  1635.                 add eax,ebx      ;size_x*y+x
  1636.                 lea eax,[eax+eax*2] ;(size_x*y+x)*3
  1637.                 add eax,buf2d_data  ;ptr+(size_x*y+x)*3
  1638.  
  1639.                 mov ecx,esi
  1640.                 sub ecx,ebx ;¢ ecx ª®««¨ç¥á⢮ â®ç¥ª «¨­¨¨ ¢ë¢®¤¨¬ëå ¢ ¡ãä¥à
  1641.                 inc ecx ;çâ®-¡ë ¯®á«¥¤­ïï â®çª  «¨­¨¨ â ª¦¥ ®â®¡à ¦ « áì
  1642.                 mov edx,dword[color]
  1643.                 mov ebx,edx ;ª®®à¤¨­ â  x0 ¢ ebx 㦥 ­¥ ­ã¦­ 
  1644.                 ror edx,16 ;¯®¢®à ç¨¢ ¥¬ ॣ¨áâà çâ® ¡ë 3-© ¡ ©â ¯®¯ « ¢ dl
  1645.                 cld
  1646.                 @@: ;横« ¯® ®á¨ x ®â x0 ¤® x1 (¢ª«îç ï x1)
  1647.                         mov word[eax],bx ;copy pixel color
  1648.                         mov byte[eax+2],dl
  1649.                         add eax,3
  1650.                         loop @b
  1651.                 .end24:
  1652.         popfd
  1653.         popad
  1654.         ret
  1655. endp
  1656.  
  1657. align 4
  1658. proc buf_rect_by_size, buf_struc:dword, coord_x:dword,coord_y:dword,w:dword,h:dword, color:dword
  1659. pushad
  1660.         mov edi,[buf_struc]
  1661.         cmp buf2d_bits,8
  1662.         je @f
  1663.         cmp buf2d_bits,24
  1664.         je @f
  1665.                 jmp .coord_end
  1666.         @@:
  1667.  
  1668.                 mov eax,[coord_x]
  1669.                 mov ebx,[coord_y]
  1670.                 mov ecx,[w]
  1671.                 ;cmp ecx,1
  1672.                 ;jl .coord_end
  1673.                 cmp ecx,0
  1674.                 je .coord_end
  1675.                 jg @f
  1676.                         add eax,ecx
  1677.                         inc eax
  1678.                         neg ecx
  1679.                 @@:
  1680.                 add ecx,eax
  1681.                 dec ecx
  1682.                 mov edx,[h]
  1683.                 ;cmp edx,1
  1684.                 ;jl .coord_end
  1685.                 cmp edx,0
  1686.                 je .coord_end
  1687.                 jg @f
  1688.                         add ebx,edx
  1689.                         inc ebx
  1690.                         neg edx
  1691.                 @@:
  1692.  
  1693.                 add edx,ebx
  1694.                 dec edx
  1695.                 mov esi,dword[color]
  1696.                 stdcall buf_line_h, edi, eax, ebx, ecx, esi ;«¨­¨ï -
  1697.                 stdcall buf_line_brs, edi, eax, ebx, eax, edx, esi ;«¨­¨ï |
  1698.                 stdcall buf_line_h, edi, eax, edx, ecx, esi ;«¨­¨ï -
  1699.                 stdcall buf_line_brs, edi, ecx, ebx, ecx, edx, esi ;«¨­¨ï |
  1700.         .coord_end:
  1701. popad
  1702.         ret
  1703. endp
  1704.  
  1705. align 4
  1706. proc buf_filled_rect_by_size, buf_struc:dword, coord_x:dword,coord_y:dword,w:dword,h:dword, color:dword
  1707. pushad
  1708.         mov edi,[buf_struc]
  1709.         cmp buf2d_bits,8
  1710.         je @f
  1711.         cmp buf2d_bits,24
  1712.         je @f
  1713.                 jmp .coord_end
  1714.         @@:
  1715.                 mov eax,[coord_x]
  1716.                 mov ebx,[coord_y]
  1717.                 mov edx,[w]
  1718.                 cmp edx,0
  1719.                 je .coord_end ;¥á«¨ ¢ëá®â  0 ¯¨ªá¥«¥©
  1720.                 jg @f ;¥á«¨ ¢ëá®â  ¯®«®¦¨â¥«ì­ ï
  1721.                         add eax,edx
  1722.                         inc eax
  1723.                         neg edx ;è¨à¨­ã ¤¥« ¥¬ ¯®«®¦¨â¥«ì­®©
  1724.                         ;inc edx ;¯®ç¥¬ã âãâ ­¥ ¤®¡ ¢«ï¥¬ 1-æã ï ­¥ §­ î, ­® á ­¥© à ¡®â ¥â ­¥ ¯à ¢¨«ì­®
  1725.                 @@:
  1726.                 add edx,eax
  1727.                 dec edx
  1728.                 mov ecx,[h]
  1729.                 cmp ecx,0
  1730.                 je .coord_end ;¥á«¨ ¢ëá®â  0 ¯¨ªá¥«¥©
  1731.                 jg @f ;¥á«¨ ¢ëá®â  ¯®«®¦¨â¥«ì­ ï
  1732.                         add ebx,ecx ;ᤢ¨£ ¥¬ ¢¥àå­îî ª®®à¤¨­ âã ¯àאַ㣮«ì­¨ª 
  1733.                         inc ebx
  1734.                         neg ecx ;¢ëá®âã ¤¥« ¥¬ ¯®«®¦¨â¥«ì­®©
  1735.                         ;inc ecx ;¯®ç¥¬ã âãâ ­¥ ¤®¡ ¢«ï¥¬ 1-æã ï ­¥ §­ î, ­® á ­¥© à ¡®â ¥â ­¥ ¯à ¢¨«ì­®
  1736.                 @@:
  1737.                 mov esi,dword[color]
  1738.                 cld
  1739.                 @@:
  1740.                         stdcall buf_line_h, edi, eax, ebx, edx, esi ;«¨­¨ï -
  1741.                         inc ebx
  1742.                         loop @b
  1743.         .coord_end:
  1744. popad
  1745.         ret
  1746. endp
  1747.  
  1748. align 4
  1749. proc buf_circle, buf_struc:dword, coord_x:dword, coord_y:dword, r:dword, color:dword
  1750. locals
  1751.         po_x dd ?
  1752.         po_y dd ?
  1753. endl
  1754.         pushad
  1755.         mov edi,dword[buf_struc]
  1756.         cmp buf2d_bits,8
  1757.         je @f
  1758.         cmp buf2d_bits,24
  1759.         je @f
  1760.                 jmp .error
  1761.         @@:
  1762.                 mov edx,dword[color]
  1763.  
  1764.                 finit
  1765.                 fild dword[coord_x]
  1766.                 fild dword[coord_y]
  1767.                 fild dword[r]
  1768.                 fldz ;px=0
  1769.                 fld st1 ;py=r
  1770.  
  1771.                 fldpi
  1772.                 fmul st0,st3
  1773.                 fistp dword[po_x]
  1774.                 mov esi,dword[po_x] ;esi=pi*r
  1775.                 shl esi,1 ;esi=2*pi*r
  1776.  
  1777.                 ;st0 = py
  1778.                 ;st1 = px
  1779.                 ;st2 = r
  1780.                 ;st3 = y
  1781.                 ;st4 = x
  1782.  
  1783.                 @@:
  1784.                         ;Point(px + x, y - py)
  1785.                         fld st1 ;st0=px
  1786.                         fadd st0,st5 ;st0=px+x
  1787.                         fistp dword[po_x]
  1788.                         mov ebx,dword[po_x]
  1789.                         fld st3 ;st0=y
  1790.                         fsub st0,st1 ;st0=y-py
  1791.                         fistp dword[po_y]
  1792.                         mov ecx,dword[po_y]
  1793.                         call draw_pixel
  1794.                         ;px += py/r
  1795.                         fld st0 ;st0=py
  1796.                         fdiv st0,st3 ;st0=py/r
  1797.                         faddp st2,st0 ;st3+=st0
  1798.                         ;py -= px/r
  1799.                         fld st1 ;st0=px
  1800.                         fdiv st0,st3 ;st0=px/r
  1801.                         fsubp st1,st0 ;st2-=st0
  1802.  
  1803.                         dec esi
  1804.                         cmp esi,0
  1805.                         jge @b
  1806.                 jmp .exit_fun
  1807.         .error:
  1808.                 stdcall print_err,sz_buf2d_circle,txt_err_n8_24b
  1809.         .exit_fun:
  1810.  
  1811.         popad
  1812.         ret
  1813. endp
  1814.  
  1815. ;äã­ªæ¨ï ¤«ï § «¨¢ª¨ ®¡« á⨠¢ë¡à ­­ë¬ 梥⮬
  1816. align 4
  1817. proc buf_flood_fill, buf_struc:dword, coord_x:dword, coord_y:dword, mode:dword, color_f:dword, color_b:dword
  1818.         pushad
  1819.                 mov edi,[buf_struc]
  1820.                 cmp buf2d_bits,24
  1821.                 jne .end24
  1822.  
  1823.                         mov ebx,dword[coord_x]
  1824.                         mov ecx,dword[coord_y]
  1825.                         mov edx,dword[color_f]
  1826.                         mov esi,dword[color_b]
  1827.  
  1828.                         cmp dword[mode],1 ;¢ § ¢¨á¨¬®á⨠®â 'mode' ®¯à¥¤¥«ï¥¬ ª ª¨¬  «£®à¨â¬®¬ ¡ã¤¥¬ ¯®«ì§®¢ âìáï
  1829.                         je @f
  1830.                                 call buf_flood_fill_recurs_0 ;§ «¨¢ ¥¬ ¤® ¯¨ªá¥«¥© æ¢¥â  esi
  1831.                                 jmp .end24
  1832.                         @@:
  1833.                                 call buf_flood_fill_recurs_1 ;§ «¨¢ ¥¬ ¯¨ªá¥«¨ ¨¬¥î騥 梥â esi
  1834.  
  1835.                 .end24:
  1836.         popad
  1837.         ret
  1838. endp
  1839.  
  1840. ;input:
  1841. ; ebx = coord_x
  1842. ; ecx = coord_y
  1843. ; edx = 梥⠧ «¨¢ª¨
  1844. ; esi = 梥⠣࠭¨æë, ¤® ª®â®à®© ¡ã¤¥â ¨â¨ § «¨¢ª 
  1845. ; edi = buf_struc
  1846. ;output:
  1847. ; eax = ¯®àâ¨âáï
  1848. align 4
  1849. buf_flood_fill_recurs_0:
  1850.         call get_pixel_24
  1851.         cmp eax,0xffffffff ;if error coords
  1852.         je .end_fun
  1853.         cmp eax,edx ;¥á«¨ 梥⠯¨ªá¥«ï ᮢ¯ « á 梥⮬ § «¨¢ª¨, §­ ç¨â § «¨¢ª  ¢ í⮩ ®¡« á⨠㦥 ¡ë«  ᤥ« ­ 
  1854.         je .end_fun
  1855.  
  1856.                 call draw_pixel
  1857.  
  1858.                 dec ebx
  1859.                 call get_pixel_24
  1860.                 cmp eax,esi
  1861.                 je @f
  1862.                         call buf_flood_fill_recurs_0
  1863.                 @@:
  1864.                 inc ebx
  1865.  
  1866.  
  1867.                 inc ebx
  1868.                 call get_pixel_24
  1869.                 cmp eax,esi
  1870.                 je @f
  1871.                         call buf_flood_fill_recurs_0
  1872.                 @@:
  1873.                 dec ebx
  1874.  
  1875.                 dec ecx
  1876.                 call get_pixel_24
  1877.                 cmp eax,esi
  1878.                 je @f
  1879.                         call buf_flood_fill_recurs_0
  1880.                 @@:
  1881.                 inc ecx
  1882.  
  1883.                 inc ecx
  1884.                 call get_pixel_24
  1885.                 cmp eax,esi
  1886.                 je @f
  1887.                         call buf_flood_fill_recurs_0
  1888.                 @@:
  1889.                 dec ecx
  1890.  
  1891.         .end_fun:
  1892.         ret
  1893.  
  1894. ;input:
  1895. ; ebx = coord_x
  1896. ; ecx = coord_y
  1897. ; edx = 梥⠧ «¨¢ª¨
  1898. ; esi = 梥⠯¨ªá¥«¥©, ¯® ª®â®àë¬ ¡ã¤¥â ¨â¨ § «¨¢ª 
  1899. ; edi = buf_struc
  1900. ;output:
  1901. ; eax = ¯®àâ¨âáï
  1902. align 4
  1903. buf_flood_fill_recurs_1:
  1904.         call get_pixel_24
  1905.         cmp eax,0xffffffff ;if error coords
  1906.         je .end_fun
  1907.         cmp eax,edx ;¥á«¨ 梥⠯¨ªá¥«ï ᮢ¯ « á 梥⮬ § «¨¢ª¨, §­ ç¨â § «¨¢ª  ¢ í⮩ ®¡« á⨠㦥 ¡ë«  ᤥ« ­ 
  1908.         je .end_fun
  1909.         cmp eax,esi ;¥á«¨ 梥⠯¨ªá¥«ï ­¥ ᮢ¯ « á § «¨¢ ¥¬ë¬ 梥⮬ § «¨¢ª¨, â® ¯à¥ªà é ¥¬ § «¨¢ªã
  1910.         jne .end_fun
  1911.  
  1912.                 call draw_pixel
  1913.  
  1914.                 dec ebx
  1915.                 call get_pixel_24
  1916.                 cmp eax,esi
  1917.                 jne @f
  1918.                         call buf_flood_fill_recurs_1
  1919.                 @@:
  1920.                 inc ebx
  1921.  
  1922.  
  1923.                 inc ebx
  1924.                 call get_pixel_24
  1925.                 cmp eax,esi
  1926.                 jne @f
  1927.                         call buf_flood_fill_recurs_1
  1928.                 @@:
  1929.                 dec ebx
  1930.  
  1931.                 dec ecx
  1932.                 call get_pixel_24
  1933.                 cmp eax,esi
  1934.                 jne @f
  1935.                         call buf_flood_fill_recurs_1
  1936.                 @@:
  1937.                 inc ecx
  1938.  
  1939.                 inc ecx
  1940.                 call get_pixel_24
  1941.                 cmp eax,esi
  1942.                 jne @f
  1943.                         call buf_flood_fill_recurs_1
  1944.                 @@:
  1945.                 dec ecx
  1946.  
  1947.         .end_fun:
  1948.         ret
  1949.  
  1950. ;äã­ªæ¨ï ¤«ï à¨á®¢ ­¨ï â®çª¨
  1951. align 4
  1952. proc buf_set_pixel uses ebx ecx edx edi, buf_struc:dword, coord_x:dword, coord_y:dword, color:dword
  1953.         mov edi,dword[buf_struc]
  1954.         mov ebx,dword[coord_x]
  1955.         mov ecx,dword[coord_y]
  1956.         mov edx,dword[color]
  1957.         call draw_pixel
  1958.         ret
  1959. endp
  1960.  
  1961. ;output:
  1962. ; eax = 梥â â®çª¨
  1963. ; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
  1964. align 4
  1965. proc buf_get_pixel uses ebx ecx edi, buf_struc:dword, coord_x:dword, coord_y:dword
  1966.         mov edi,dword[buf_struc]
  1967.         mov ebx,[coord_x]
  1968.         mov ecx,[coord_y]
  1969.  
  1970.         cmp buf2d_bits,8
  1971.         jne @f
  1972.                 call get_pixel_8
  1973.                 jmp .end_fun
  1974.         @@:
  1975.         cmp buf2d_bits,24
  1976.         jne @f
  1977.                 call get_pixel_24
  1978.                 jmp .end_fun
  1979.         @@:
  1980.         cmp buf2d_bits,32
  1981.         jne @f
  1982.                 call get_pixel_32
  1983.                 ;jmp .end_fun
  1984.         @@:
  1985.         .end_fun:
  1986.         ret
  1987. endp
  1988.  
  1989. align 4
  1990. proc buf_img_wdiv2, buf_struc:dword
  1991.         pushad
  1992.         mov edi,dword[buf_struc]
  1993.         cmp buf2d_bits,8
  1994.         jne @f
  1995.                 mov eax,buf2d_w
  1996.                 mov ecx,buf2d_h
  1997.                 imul ecx,eax
  1998.                 stdcall img_8b_wdiv2, buf2d_data,ecx
  1999.         @@:
  2000.         cmp buf2d_bits,24
  2001.         jne @f
  2002.                 mov eax,buf2d_w
  2003.                 mov ecx,buf2d_h
  2004.                 imul ecx,eax
  2005.                 stdcall img_rgb24_wdiv2, buf2d_data,ecx
  2006.         @@:
  2007.         cmp buf2d_bits,32
  2008.         jne @f
  2009.                 mov eax,buf2d_w
  2010.                 mov ecx,buf2d_h
  2011.                 imul ecx,eax
  2012.                 stdcall img_rgba32_wdiv2, buf2d_data,ecx
  2013.         @@:
  2014.         popad
  2015.         ret
  2016. endp
  2017.  
  2018. ;input:
  2019. ;data_8b - pointer to rgb data
  2020. ;size - count img pixels (size img data / 3(rgb) )
  2021. align 4
  2022. proc img_8b_wdiv2 data_8b:dword, size:dword
  2023.         mov eax,dword[data_8b]
  2024.         mov ecx,dword[size] ;ecx = size
  2025.         cld
  2026.         @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
  2027.                 shr byte[eax],1
  2028.                 inc eax
  2029.                 loop @b
  2030.  
  2031.         mov eax,dword[data_8b]
  2032.         mov ecx,dword[size] ;ecx = size
  2033.         shr ecx,1
  2034.         @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
  2035.                 mov bl,byte[eax+1] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
  2036.                 add byte[eax],bl
  2037.                 add eax,2
  2038.                 loop @b
  2039.  
  2040.         mov eax,dword[data_8b]
  2041.         inc eax
  2042.         mov ebx,eax
  2043.         inc ebx
  2044.         mov ecx,dword[size] ;ecx = size
  2045.         shr ecx,1
  2046.         dec ecx ;«¨è­¨© ¯¨ªá¥«ì
  2047.         @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
  2048.                 mov dl,byte[ebx]
  2049.                 mov byte[eax],dl
  2050.  
  2051.                 inc eax
  2052.                 add ebx,2
  2053.                 loop @b
  2054.         ret
  2055. endp
  2056.  
  2057. ;input:
  2058. ;data_rgb - pointer to rgb data
  2059. ;size - count img pixels (size img data / 3(rgb) )
  2060. align 4
  2061. proc img_rgb24_wdiv2 data_rgb:dword, size:dword
  2062.   mov eax,dword[data_rgb]
  2063.   mov ecx,dword[size] ;ecx = size
  2064.   lea ecx,[ecx+ecx*2]
  2065.   cld
  2066.   @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
  2067.                 shr byte[eax],1
  2068.                 inc eax
  2069.                 loop @b
  2070.  
  2071.   mov eax,dword[data_rgb]
  2072.   mov ecx,dword[size] ;ecx = size
  2073.   shr ecx,1
  2074.   @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
  2075.                 mov bx,word[eax+3] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
  2076.                 add word[eax],bx
  2077.                 mov bl,byte[eax+5] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
  2078.                 add byte[eax+2],bl
  2079.                 add eax,6 ;=2*3
  2080.                 loop @b
  2081.  
  2082.   mov eax,dword[data_rgb]
  2083.   add eax,3
  2084.   mov ebx,eax
  2085.   add ebx,3
  2086.   mov ecx,dword[size] ;ecx = size
  2087.   shr ecx,1
  2088.   dec ecx ;«¨è­¨© ¯¨ªá¥«ì
  2089.   @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
  2090.                 mov edx,dword[ebx]
  2091.                 mov word[eax],dx
  2092.                 shr edx,16
  2093.                 mov byte[eax+2],dl
  2094.  
  2095.                 add eax,3
  2096.                 add ebx,6
  2097.                 loop @b
  2098.   ret
  2099. endp
  2100.  
  2101. ;input:
  2102. ;data_rgba - pointer to rgba data
  2103. ;size - count img pixels (size img data / 4(rgba) )
  2104. align 4
  2105. proc img_rgba32_wdiv2 data_rgba:dword, size:dword
  2106.         mov eax,dword[data_rgba]
  2107.  
  2108.         mov eax,dword[data_rgba]
  2109.         mov ebx,eax
  2110.         add ebx,4
  2111.         mov ecx,dword[size] ;ecx = size
  2112.         shr ecx,1
  2113.         @@: ;ᬥ訢 ­¨¥ 梥⮢ ¯¨ªá¥«¥©
  2114.                 call combine_colors_1
  2115.                 mov [eax],edx
  2116.                 add eax,8 ;=2*4
  2117.                 add ebx,8
  2118.                 loop @b
  2119.  
  2120.         mov eax,dword[data_rgba]
  2121.         add eax,4
  2122.         mov ebx,eax
  2123.         add ebx,4
  2124.         mov ecx,dword[size] ;ecx = size
  2125.         shr ecx,1
  2126.         dec ecx ;«¨è­¨© ¯¨ªá¥«ì
  2127.         @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
  2128.                 mov edx,dword[ebx]
  2129.                 mov dword[eax],edx
  2130.  
  2131.                 add eax,4
  2132.                 add ebx,8
  2133.                 loop @b
  2134.         ret
  2135. endp
  2136.  
  2137. align 4
  2138. proc buf_img_hdiv2, buf_struc:dword
  2139.         pushad
  2140.         mov edi,dword[buf_struc]
  2141.         cmp buf2d_bits,8
  2142.         jne @f
  2143.                 mov eax,buf2d_w
  2144.                 mov ecx,buf2d_h
  2145.                 imul ecx,eax
  2146.                 stdcall img_8b_hdiv2, buf2d_data,ecx,eax
  2147.         @@:
  2148.         cmp buf2d_bits,24
  2149.         jne @f
  2150.                 mov eax,buf2d_w
  2151.                 mov ecx,buf2d_h
  2152.                 imul ecx,eax
  2153.                 stdcall img_rgb24_hdiv2, buf2d_data,ecx,eax
  2154.         @@:
  2155.         cmp buf2d_bits,32
  2156.         jne @f
  2157.                 mov eax,buf2d_w
  2158.                 mov ecx,buf2d_h
  2159.                 imul ecx,eax
  2160.                 shl eax,2
  2161.                 stdcall img_rgba32_hdiv2, buf2d_data,ecx,eax
  2162.         @@:
  2163.         popad
  2164.         ret
  2165. endp
  2166.  
  2167. ;input:
  2168. ;data_8b - pointer to 8 bit data
  2169. ;size - count img pixels (size img data)
  2170. ;size_w - width img in pixels
  2171. align 4
  2172. proc img_8b_hdiv2, data_8b:dword, size:dword, size_w:dword
  2173.  
  2174.         mov eax,dword[data_8b] ;eax =
  2175.         mov ecx,dword[size]
  2176.         cld
  2177.         @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
  2178.                 shr byte[eax],1
  2179.                 inc eax
  2180.                 loop @b
  2181.  
  2182.         mov eax,dword[data_8b] ;eax =
  2183.         mov esi,dword[size_w]
  2184.         mov ebx,esi
  2185.         add ebx,eax
  2186.         mov ecx,dword[size]  ;ecx = size
  2187.         shr ecx,1
  2188.         xor edi,edi
  2189.         @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
  2190.                 mov dl,byte[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
  2191.                 add byte[eax],dl
  2192.  
  2193.                 inc eax
  2194.                 inc ebx
  2195.                 inc edi
  2196.                 cmp edi,dword[size_w]
  2197.                 jl .old_line
  2198.                         add eax,esi
  2199.                         add ebx,esi
  2200.                         xor edi,edi
  2201.                 .old_line:
  2202.                 loop @b
  2203.  
  2204.  
  2205.         mov eax,dword[data_8b] ;eax =
  2206.         add eax,esi ;esi = width*3(rgb)
  2207.         mov ebx,eax
  2208.         add ebx,esi
  2209.         mov ecx,dword[size] ;ecx = size
  2210.         shr ecx,1
  2211.         sub ecx,dword[size_w] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
  2212.         xor edi,edi
  2213.         @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
  2214.                 mov dl,byte[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
  2215.                 mov byte[eax],dl
  2216.  
  2217.                 inc eax
  2218.                 inc ebx
  2219.                 inc edi
  2220.                 cmp edi,dword[size_w]
  2221.                 jl .old_line_2
  2222.                         add ebx,esi
  2223.                         xor edi,edi
  2224.                 .old_line_2:
  2225.                 loop @b
  2226.  
  2227.         ret
  2228. endp
  2229.  
  2230. ;input:
  2231. ;data_rgb - pointer to rgb data
  2232. ;size - count img pixels (size img data / 3(rgb) )
  2233. ;size_w - width img in pixels
  2234. align 4
  2235. proc img_rgb24_hdiv2, data_rgb:dword, size:dword, size_w:dword
  2236.  
  2237.   mov eax,dword[data_rgb] ;eax =
  2238.   mov ecx,dword[size]     ;ecx = size
  2239.   lea ecx,[ecx+ecx*2]
  2240.   cld
  2241.   @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
  2242.     shr byte[eax],1
  2243.     inc eax
  2244.     loop @b
  2245.  
  2246.   mov eax,dword[data_rgb] ;eax =
  2247.   mov esi,dword[size_w]
  2248.   lea esi,[esi+esi*2] ;esi = width*3(rgb)
  2249.   mov ebx,esi
  2250.   add ebx,eax
  2251.   mov ecx,dword[size]  ;ecx = size
  2252.   shr ecx,1
  2253.   xor edi,edi
  2254.   @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
  2255.     mov dx,word[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
  2256.     add word[eax],dx
  2257.     mov dl,byte[ebx+2] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
  2258.     add byte[eax+2],dl
  2259.  
  2260.     add eax,3
  2261.     add ebx,3
  2262.     inc edi
  2263.     cmp edi,dword[size_w]
  2264.     jl .old_line
  2265.       add eax,esi
  2266.       add ebx,esi
  2267.       xor edi,edi
  2268.     .old_line:
  2269.     loop @b
  2270.  
  2271.  
  2272.   mov eax,dword[data_rgb] ;eax =
  2273.   add eax,esi ;esi = width*3(rgb)
  2274.   mov ebx,eax
  2275.   add ebx,esi
  2276.   mov ecx,dword[size] ;ecx = size
  2277.   shr ecx,1
  2278.   sub ecx,dword[size_w] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
  2279.   xor edi,edi
  2280.   @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
  2281.     mov edx,dword[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
  2282.     mov word[eax],dx
  2283.     shr edx,16
  2284.     mov byte[eax+2],dl
  2285.  
  2286.     add eax,3
  2287.     add ebx,3
  2288.     inc edi
  2289.     cmp edi,dword[size_w]
  2290.     jl .old_line_2
  2291.       add ebx,esi
  2292.       xor edi,edi
  2293.     .old_line_2:
  2294.     loop @b
  2295.  
  2296.   ret
  2297. endp
  2298.  
  2299. ;input:
  2300. ;data_rgba - pointer to rgba data
  2301. ;size - count img pixels (size img data / 4(rgba) )
  2302. ;size_w_b - width img in bytes
  2303. align 4
  2304. proc img_rgba32_hdiv2, data_rgba:dword, size:dword, size_w_b:dword
  2305.  
  2306.         mov eax,dword[data_rgba] ;eax =
  2307.         mov ebx,dword[size_w_b]
  2308.         add ebx,eax
  2309.         mov ecx,dword[size]  ;ecx = size
  2310.         shr ecx,1
  2311.         xor edi,edi
  2312.         @@: ;ᬥ訢 ­¨¥ 梥⮢ ¯¨ªá¥«¥©
  2313.                 call combine_colors_1
  2314.                 mov dword[eax],edx
  2315.  
  2316.                 add eax,4
  2317.                 add ebx,4
  2318.                 add edi,4
  2319.                 cmp edi,dword[size_w_b]
  2320.                 jl .old_line
  2321.                         add eax,dword[size_w_b]
  2322.                         add ebx,dword[size_w_b]
  2323.                         xor edi,edi
  2324.                 .old_line:
  2325.                 loop @b
  2326.  
  2327.  
  2328.         mov eax,dword[data_rgba] ;eax =
  2329.         mov ebx,dword[size_w_b]
  2330.         add eax,ebx
  2331.         add ebx,eax
  2332.         mov ecx,dword[size] ;ecx = size
  2333.         shl ecx,1
  2334.         sub ecx,dword[size_w_b] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
  2335.         shr ecx,2
  2336.         xor edi,edi
  2337.         @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
  2338.                 mov edx,dword[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
  2339.                 mov dword[eax],edx
  2340.  
  2341.                 add eax,4
  2342.                 add ebx,4
  2343.                 add edi,4
  2344.                 cmp edi,dword[size_w_b]
  2345.                 jl .old_line_2
  2346.                         add ebx,dword[size_w_b]
  2347.                         xor edi,edi
  2348.                 .old_line_2:
  2349.                 loop @b
  2350.  
  2351.         ret
  2352. endp
  2353.  
  2354. ;input:
  2355. ; eax - 㪠§ â¥«ì ­  32-¡¨â­ë© 梥â
  2356. ; ebx - 㪠§ â¥«ì ­  32-¡¨â­ë© 梥â
  2357. ;output:
  2358. ; edx - 32-¡¨â­ë© 梥â ᬥ蠭­ë© á ãç¥â®¬ ¯à®§à ç­®áâ¨
  2359. ;destroy:
  2360. ; esi
  2361. align 4
  2362. proc combine_colors_1 uses ecx edi
  2363. locals
  2364.         c_blye dd ?
  2365.         c_green dd ?
  2366.         c_red dd ?
  2367. endl           
  2368.         movzx edi,byte[eax+3]
  2369.         cmp edi,255
  2370.         je .c0z
  2371.         movzx esi,byte[ebx+3]
  2372.         cmp esi,255
  2373.         je .c1z
  2374.         cmp edi,esi
  2375.         je .c0_c1
  2376.  
  2377.         ;¯¥à¥¢®à ç¨¢ ¥¬ §­ ç¥­¨ï ¯à®§à ç­®á⥩
  2378.         neg edi
  2379.         inc edi
  2380.         add edi,255
  2381.         neg esi
  2382.         inc esi
  2383.         add esi,255
  2384.  
  2385.         movzx ecx,byte[eax]
  2386.         imul ecx,edi
  2387.         mov [c_blye],ecx
  2388.         movzx ecx,byte[ebx]
  2389.         imul ecx,esi
  2390.         add [c_blye],ecx
  2391.  
  2392.         movzx ecx,byte[eax+1]
  2393.         imul ecx,edi
  2394.         mov [c_green],ecx
  2395.         movzx ecx,byte[ebx+1]
  2396.         imul ecx,esi
  2397.         add [c_green],ecx
  2398.  
  2399.         movzx ecx,byte[eax+2]
  2400.         imul ecx,edi
  2401.         mov [c_red],ecx
  2402.         movzx ecx,byte[ebx+2]
  2403.         imul ecx,esi
  2404.         add [c_red],ecx
  2405.  
  2406. push eax ebx
  2407.         xor ebx,ebx
  2408.         mov eax,[c_red]
  2409.         xor edx,edx
  2410.         mov ecx,edi
  2411.         add ecx,esi
  2412.         div ecx
  2413.         mov bl,al
  2414.         shl ebx,16
  2415.         mov eax,[c_green]
  2416.         xor edx,edx
  2417.         div ecx
  2418.         mov bh,al
  2419.         mov eax,[c_blye]
  2420.         xor edx,edx
  2421.         div ecx
  2422.         mov bl,al
  2423.  
  2424.         shr ecx,1
  2425.         ;¯¥à¥¢®à ç¨¢ ¥¬ §­ ç¥­¨ï ¯à®§à ç­®áâ¨
  2426.         neg ecx
  2427.         inc ecx
  2428.         add ecx,255
  2429.  
  2430.         shl ecx,24
  2431.         add ebx,ecx
  2432.         mov edx,ebx
  2433. pop ebx eax
  2434.  
  2435.         jmp .end_f
  2436.         .c0_c1: ;¥á«¨ ¯à®§à ç­®á⨠®¡®¨å 梥⮢ ᮢ¯ ¤ îâ
  2437.                 mov edx,dword[eax]
  2438.                 shr edx,1
  2439.                 and edx,011111110111111101111111b
  2440.                 mov esi,dword[ebx]
  2441.                 shr esi,1
  2442.                 and esi,011111110111111101111111b
  2443.                 add edx,esi
  2444.                 ror edi,8 ;¯¥à¥¬¥é ¥¬ §­ ç¥­¨¥ ¯à®§à ç­®á⨠¢ áâ à訩 ¡ ©â edi
  2445.                 or edx,edi
  2446.                 jmp .end_f
  2447.         .c0z: ;¥á«¨ 梥⠢ eax ¯à®§à ç­ë©
  2448.                 mov edx,dword[ebx]
  2449.                 movzx edi,byte[ebx+3]
  2450.                 jmp @f
  2451.         .c1z: ;¥á«¨ 梥⠢ ebx ¯à®§à ç­ë©
  2452.                 mov edx,dword[eax]
  2453.         @@:
  2454.                 add edi,255 ;¤¥« ¥¬ 梥⠭  ¯®«®¢¨­ã ¯à®§à ç­ë¬
  2455.                 shr edi,1
  2456.                 cmp edi,255
  2457.                 jl @f
  2458.                         mov edi,255 ;¬ ªá¨¬ «ì­ ï ¯à®§à ç­®áâì ­¥ ¡®«¥¥ 255
  2459.                 @@:
  2460.                 shl edi,24
  2461.                 and edx,0xffffff ;á­¨¬ ¥¬ áâ àãî ¯à®§à ç­®áâì
  2462.                 add edx,edi
  2463.         .end_f:
  2464.         ret
  2465. endp
  2466.  
  2467. ;¯à¥®¡à §®¢ ­¨¥ ¡ãä¥à  ¨§ 24-¡¨â­®£® ¢ 8-¡¨â­ë©
  2468. ; spectr - ®¯à¥¤¥«ï¥â ª ª®© ᯥªâà ¡à âì ¯à¨ ¯à¥®¡à §®¢ ­¨¨ 0-ᨭ¨©, 1-§¥«¥­ë©, 2-ªà á­ë©
  2469. align 4
  2470. proc buf_conv_24_to_8, buf_struc:dword, spectr:dword
  2471.         pushad
  2472.         mov edi,dword[buf_struc]
  2473.         cmp buf2d_bits,24
  2474.         jne .error
  2475.                 mov eax,buf2d_w
  2476.                 mov ecx,buf2d_h
  2477.                 imul ecx,eax
  2478.                 mov esi,ecx
  2479.                 ;ebx - ¯ ¬ïâì ¨§ ª®â®à®© ª®¯¨àã¥âáï
  2480.                 ;edx - ¯ ¬ïâì ªã¤  ª®¯¨àã¥âáï
  2481.                 mov edx,buf2d_data
  2482.                 mov ebx,edx
  2483.                 cmp [spectr],3
  2484.                 jge @f
  2485.                         add ebx,[spectr]
  2486.                 @@:
  2487.                         mov al,byte[ebx]
  2488.                         mov byte[edx],al
  2489.                         add ebx,3
  2490.                         inc edx
  2491.                         loop @b
  2492.                 mov buf2d_bits,8
  2493.                 invoke mem.realloc,buf2d_data,esi ;㬥­ìè ¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
  2494.                 jmp .end_conv
  2495.         .error:
  2496.                 stdcall print_err,sz_buf2d_conv_24_to_8,txt_err_n24b
  2497.         .end_conv:
  2498.         popad
  2499.         ret
  2500. endp
  2501.  
  2502. ;¯à¥®¡à §®¢ ­¨¥ ¡ãä¥à  ¨§ 24-¡¨â­®£® ¢ 32-¡¨â­ë©
  2503. align 4
  2504. proc buf_conv_24_to_32, buf_struc:dword, buf_str8:dword
  2505.         pushad
  2506.         mov edi,dword[buf_struc]
  2507.         cmp buf2d_bits,24
  2508.         jne .error1
  2509.                 mov ecx,buf2d_w
  2510.                 mov ebx,buf2d_h
  2511.                 imul ebx,ecx
  2512.                 mov ecx,ebx ;ecx = size  8 b
  2513.                 shl ebx,2   ;ebx = size 32 b
  2514.                 invoke mem.realloc,buf2d_data,ebx ;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
  2515.                 mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
  2516.                 mov buf2d_bits,32
  2517.                 mov edx,ebx ;edx = size 32 b
  2518.                 sub ebx,ecx ;ebx = size 24 b
  2519.                 mov eax,ecx
  2520.                 ;eax - à §¬¥à  8 ¡¨â­ëå ¤ ­­ëå
  2521.                 ;ebx - à §¬¥à 24 ¡¨â­ëå ¤ ­­ëå
  2522.                 ;edx - à §¬¥à 32 ¡¨â­ëå ¤ ­­ëå
  2523.                 add ebx,buf2d_data
  2524.                 add edx,buf2d_data
  2525.                 mov edi,dword[buf_str8]
  2526.                 cmp buf2d_bits,8
  2527.                 jne .error2
  2528.                 add eax,buf2d_data
  2529.                 mov edi,edx
  2530.                 ;eax - 㪠§ â¥«ì ­  ª®­¥æ  8 ¡¨â­ëå ¤ ­­ëå
  2531.                 ;ebx - 㪠§ â¥«ì ­  ª®­¥æ 24 ¡¨â­ëå ¤ ­­ëå
  2532.                 ;edi - 㪠§ â¥«ì ­  ª®­¥æ 32 ¡¨â­ëå ¤ ­­ëå
  2533.                 @@:
  2534.                         sub edi,4 ;®â­¨¬ ¥¬ ¢ ­ ç «¥ 横« ,
  2535.                         sub ebx,3 ; ¯®â®¬ã, ç⮠㪠§ â¥«¨ áâ®ïâ
  2536.                         dec eax   ; §  ¯à¥¤¥« ¬¨ ¡ãä¥à®¢
  2537.                         mov edx,dword[ebx]
  2538.                         mov dword[edi],edx
  2539.                         mov dl,byte[eax]
  2540.                         mov byte[edi+3],dl
  2541.                         loop @b
  2542.  
  2543.                 jmp .end_conv
  2544.         .error1:
  2545.                 stdcall print_err,sz_buf2d_conv_24_to_32,txt_err_n24b
  2546.                 jmp .end_conv
  2547.         .error2:
  2548.                 stdcall print_err,sz_buf2d_conv_24_to_32,txt_err_n8b
  2549.         .end_conv:
  2550.         popad
  2551.         ret
  2552. endp
  2553.  
  2554. ;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (24b|32b) ¢ buf_destination (24b)
  2555. ; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
  2556. ; ¯à®§à ç­®áâì ¯à¨ ª®¯¨à®¢ ­¨¨ ­¥ ãç¨â뢠¥âáï
  2557. align 4
  2558. proc buf_bit_blt, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
  2559.         locals
  2560.                 right_bytes dd ?
  2561.         endl
  2562.         pushad
  2563.  
  2564.         mov edi,[buf_source]
  2565.         cmp buf2d_bits,24
  2566.         je .sou24
  2567.         cmp buf2d_bits,32
  2568.         je .sou32
  2569.                 jmp .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
  2570.  
  2571.         .sou24: ;¢ ¨áâ®ç­¨ª¥ 24 ¡¨â­ ï ª à⨭ª 
  2572.         mov eax,buf2d_w
  2573.         mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
  2574.         mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
  2575.  
  2576.         mov edi,[buf_destination]
  2577.         cmp buf2d_bits,24
  2578.         jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
  2579.         mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
  2580.         cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
  2581.         jge .copy_end     ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
  2582.                 mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
  2583.                 mov ecx,[coord_y]
  2584.                 cmp ecx,0
  2585.                 jge @f
  2586.                         ;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
  2587.                         add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
  2588.                         cmp edx,0
  2589.                         jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
  2590.                         neg ecx
  2591.                         ;inc ecx
  2592.                         imul ecx,eax
  2593.                         lea ecx,[ecx+ecx*2] ;¯® 3 ¡ ©â  ­  ¯¨ªá¥«ì
  2594.                         add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
  2595.                         xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
  2596.                 @@:
  2597.                 cmp ecx,ebx
  2598.                 jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
  2599.                 add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
  2600.                 cmp ecx,ebx
  2601.                 jle @f
  2602.                         sub ecx,ebx
  2603.                         sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
  2604.                 @@:
  2605.                 mov ebx,buf2d_w
  2606.                 mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
  2607.                 cmp ecx,0
  2608.                 jg .end_otr_c_y_24
  2609.                         ;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
  2610.                         mov ecx,[coord_x]
  2611.                         jmp @f
  2612.                 .end_otr_c_y_24:
  2613.                 imul ecx,ebx
  2614.                 add ecx,[coord_x]
  2615.                 @@:
  2616.                 lea ecx,[ecx+ecx*2]
  2617.                 add ecx,buf2d_data
  2618.                 sub ebx,eax
  2619.                 mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
  2620.  
  2621.         mov [right_bytes],0
  2622.         mov ecx,[coord_x]
  2623.         cmp ecx,ebx
  2624.         jl @f
  2625.                 sub ecx,ebx
  2626.                 sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
  2627.                 add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
  2628.                 lea ecx,[ecx+ecx*2] ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
  2629.                 mov [right_bytes],ecx
  2630.         @@:
  2631.  
  2632.         lea eax,[eax+eax*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
  2633.         lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
  2634.  
  2635.         cld
  2636.         cmp [right_bytes],0
  2637.         jg .copy_1
  2638.         .copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
  2639.                 mov ecx,eax
  2640.                 rep movsb
  2641.                 add edi,ebx
  2642.                 dec edx
  2643.                 cmp edx,0
  2644.                 jg .copy_0
  2645.         jmp .copy_end
  2646.         .copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
  2647.                 mov ecx,eax
  2648.                 rep movsb
  2649.                 add edi,ebx
  2650.                 add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
  2651.                 dec edx
  2652.                 cmp edx,0
  2653.                 jg .copy_1
  2654.         jmp .copy_end
  2655.  
  2656.         .sou32: ;¢ ¨áâ®ç­¨ª¥ 32 ¡¨â­ ï ª à⨭ª 
  2657.         mov eax,buf2d_w
  2658.         mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
  2659.         mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
  2660.  
  2661.         mov edi,[buf_destination]
  2662.         cmp buf2d_bits,24
  2663.         jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
  2664.         mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
  2665.         cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
  2666.         jge .copy_end     ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
  2667.                 mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
  2668.                 mov ecx,[coord_y]
  2669.                 cmp ecx,0
  2670.                 jge @f
  2671.                         ;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
  2672.                         add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
  2673.                         cmp edx,0
  2674.                         jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
  2675.                         neg ecx
  2676.                         ;inc ecx
  2677.                         imul ecx,eax
  2678.                         shl ecx,2 ;¯® 4 ¡ ©â  ­  ¯¨ªá¥«ì
  2679.                         add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
  2680.                         xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
  2681.                 @@:
  2682.                 cmp ecx,ebx
  2683.                 jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
  2684.                 add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
  2685.                 cmp ecx,ebx
  2686.                 jle @f
  2687.                         sub ecx,ebx
  2688.                         sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
  2689.                 @@:
  2690.                 mov ebx,buf2d_w
  2691.                 ;mov ecx,ebx ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
  2692.                 ;imul ecx,[coord_y]
  2693.                 ;add ecx,[coord_x]
  2694.                 mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
  2695.                 cmp ecx,0
  2696.                 jg .end_otr_c_y_32
  2697.                         ;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
  2698.                         mov ecx,[coord_x]
  2699.                         jmp @f
  2700.                 .end_otr_c_y_32:
  2701.                 imul ecx,ebx
  2702.                 add ecx,[coord_x]
  2703.                 @@:
  2704.                 lea ecx,[ecx+ecx*2]
  2705.                 add ecx,buf2d_data
  2706.                 sub ebx,eax
  2707.                 mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
  2708.  
  2709.         mov [right_bytes],0
  2710.         mov ecx,[coord_x]
  2711.         cmp ecx,ebx
  2712.         jl @f
  2713.                 sub ecx,ebx
  2714.                 sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
  2715.                 add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
  2716.                 shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
  2717.                 mov [right_bytes],ecx
  2718.         @@:
  2719.  
  2720.         ;eax - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
  2721.         lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
  2722.  
  2723.         cld
  2724.         cmp [right_bytes],0
  2725.         jg .copy_3
  2726.         .copy_2: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
  2727.                 mov ecx,eax
  2728.                 @@:
  2729.                         movsw
  2730.                         movsb
  2731.                         inc esi
  2732.                         loop @b
  2733.                 add edi,ebx
  2734.                 dec edx
  2735.                 cmp edx,0
  2736.                 jg .copy_2
  2737.         jmp .copy_end
  2738.         .copy_3: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
  2739.                 mov ecx,eax
  2740.                 @@:
  2741.                         movsw
  2742.                         movsb
  2743.                         inc esi
  2744.                         loop @b
  2745.                 add edi,ebx
  2746.                 add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
  2747.                 dec edx
  2748.                 cmp edx,0
  2749.                 jg .copy_3
  2750.  
  2751.         .copy_end:
  2752.         popad
  2753.         ret
  2754. endp
  2755.  
  2756. ;input:
  2757. ; esi = pointer to color1 + transparent
  2758. ; edi = pointer to background color2
  2759. ;output:
  2760. ; [edi] = combine color
  2761. align 4
  2762. combine_colors_0:
  2763.         push ax bx cx dx
  2764.         mov bx,0x00ff ;---get transparent---
  2765.         movzx cx,byte[esi+3] ;pro
  2766.         sub bx,cx ;256-pro
  2767.         ;---blye---
  2768.         movzx ax,byte[esi]
  2769.         imul ax,bx
  2770.         movzx dx,byte[edi]
  2771.         imul dx,cx
  2772.         add ax,dx
  2773.         mov byte[edi],ah
  2774.         ;---green---
  2775.         movzx ax,byte[esi+1]
  2776.         imul ax,bx
  2777.         movzx dx,byte[edi+1]
  2778.         imul dx,cx
  2779.         add ax,dx
  2780.         mov byte[edi+1],ah
  2781.         ;---red---
  2782.         movzx ax,byte[esi+2]
  2783.         imul ax,bx
  2784.         movzx dx,byte[edi+2]
  2785.         imul dx,cx
  2786.         add ax,dx
  2787.         mov byte[edi+2],ah
  2788.  
  2789.         pop dx cx bx ax
  2790.         ret
  2791.  
  2792. ;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (32b) ¢ buf_destination (24b)
  2793. ; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
  2794. ; ¯à¨ ª®¯¨à®¢ ­¨¨ ãç¨â뢠¥âáï ¯à®§à ç­®áâì
  2795. align 4
  2796. proc buf_bit_blt_transp, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
  2797.         locals
  2798.                 lost_bytes dd ?
  2799.         endl
  2800.         pushad
  2801.  
  2802.         mov edi,[buf_source]
  2803.         cmp buf2d_bits,32
  2804.         jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
  2805.         mov eax,buf2d_w
  2806.         mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
  2807.         mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
  2808.  
  2809.         mov edi,[buf_destination]
  2810.         cmp buf2d_bits,24
  2811.         jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
  2812.                 mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
  2813.                 mov ecx,[coord_y]
  2814.                 cmp ecx,0
  2815.                 jge @f
  2816.                         ;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
  2817.                         add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
  2818.                         cmp edx,0
  2819.                         jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
  2820.                         neg ecx
  2821.                         ;inc ecx
  2822.                         imul ecx,eax
  2823.                         shl ecx,2 ;¯® 4 ¡ ©â  ­  ¯¨ªá¥«ì
  2824.                         add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
  2825.                         xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
  2826.                 @@:
  2827.                 cmp ecx,ebx
  2828.                 jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
  2829.                 add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
  2830.                 cmp ecx,ebx
  2831.                 jle @f
  2832.                         sub ecx,ebx
  2833.                         sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
  2834.                 @@:
  2835.                 mov ebx,buf2d_w
  2836.                 mov ecx,ebx ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
  2837.                 cmp [coord_y],0
  2838.                 jg .end_otr_c_y
  2839.                         ;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
  2840.                         mov ecx,[coord_x]
  2841.                         jmp @f
  2842.                 .end_otr_c_y:
  2843.                 imul ecx,[coord_y]
  2844.                 add ecx,[coord_x]
  2845.                 @@:
  2846.                 lea ecx,[ecx+ecx*2]
  2847.                 add ecx,buf2d_data
  2848.                 sub ebx,eax
  2849.                 mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
  2850.  
  2851.         mov dword[lost_bytes],0
  2852.         mov ecx,[coord_x]
  2853.         cmp ecx,0
  2854.         jge @f
  2855.                 neg ecx
  2856.                 ;inc ecx
  2857.                 cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
  2858.                 jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w)
  2859.                 shl ecx,2
  2860.                 mov [lost_bytes],ecx
  2861.                 add esi,ecx
  2862.                 shr ecx,2
  2863.                 sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
  2864.                 add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
  2865.                 lea ecx,[ecx+ecx*2]
  2866.                 add edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
  2867.                 xor ecx,ecx
  2868.         @@:
  2869.         cmp ecx,ebx
  2870.         jle @f
  2871.                 sub ecx,ebx
  2872.                 sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
  2873.                 add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
  2874.                 shl ecx,2 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
  2875.                 add [lost_bytes],ecx
  2876.         @@:
  2877.  
  2878. ;       mov [right_bytes],0
  2879. ;       mov ecx,[coord_x]
  2880. ;       cmp ecx,ebx
  2881. ;       jl @f
  2882. ;               sub ecx,ebx
  2883. ;               sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
  2884. ;               add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
  2885. ;               shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
  2886. ;               mov [right_bytes],ecx
  2887. ;       @@:
  2888.  
  2889.         lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
  2890.  
  2891.         cld
  2892.         cmp [lost_bytes],0
  2893.         jg .copy_1
  2894.         .copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
  2895.                 mov ecx,eax
  2896.                 @@:
  2897.                         call combine_colors_0
  2898.                         add edi,3
  2899.                         add esi,4
  2900.                         loop @b
  2901.                 add edi,ebx
  2902.                 dec edx
  2903.                 cmp edx,0
  2904.                 jg .copy_0
  2905.         jmp .copy_end
  2906.         .copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
  2907.                 mov ecx,eax
  2908.                 @@:
  2909.                         call combine_colors_0
  2910.                         add edi,3
  2911.                         add esi,4
  2912.                         loop @b
  2913.                 add edi,ebx
  2914.                 add esi,[lost_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
  2915.                 dec edx
  2916.                 cmp edx,0
  2917.                 jg .copy_1
  2918.  
  2919.         .copy_end:
  2920.         popad
  2921.         ret
  2922. endp
  2923.  
  2924. ;input:
  2925. ; ebx - color1
  2926. ; esi = pointer to transparent
  2927. ; edi = pointer to background color2
  2928. ;output:
  2929. ; [edi] = combine color
  2930. align 4
  2931. combine_colors_2:
  2932.         push ax ebx cx dx si
  2933.         mov cl,byte[esi] ;pro
  2934.         xor ch,ch
  2935.         mov si,0x00ff ;---get transparent---
  2936.         sub si,cx ;256-pro
  2937.  
  2938.                 ;---blye---
  2939.                 movzx ax,bl
  2940.                 shr ebx,8
  2941.                 imul ax,si
  2942.                 movzx dx,byte[edi]
  2943.                 imul dx,cx
  2944.                 add ax,dx
  2945.                 mov byte[edi],ah
  2946.                 ;---green---
  2947.                 movzx ax,bl
  2948.                 shr ebx,8
  2949.                 imul ax,si
  2950.                 movzx dx,byte[edi+1]
  2951.                 imul dx,cx
  2952.                 add ax,dx
  2953.                 mov byte[edi+1],ah
  2954.                 ;---red---
  2955.                 movzx ax,bl
  2956.                 imul ax,si
  2957.                 movzx dx,byte[edi+2]
  2958.                 imul dx,cx
  2959.                 add ax,dx
  2960.                 mov byte[edi+2],ah
  2961.  
  2962.         pop si dx cx ebx ax
  2963.         ret
  2964.  
  2965. ;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (8b) ¢ buf_destination (24b)
  2966. ; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
  2967. align 4
  2968. proc buf_bit_blt_alpha, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword, color:dword
  2969.         locals
  2970.                 lost_bytes dd ? ;ç¨á«® ¯®â¥àï­­ëå ¡ ©â®¢ ¢ áâப¥ ª®¯¨à㥬®£® ¨§®¡à ¦¥­ï (â¥å çâ® ­¥ ¢« §ïâ ¢ ¡ãä¥à)
  2971.                 dest_w_bytes dd ? ;ª®««¨ç¥á⢮ ¡ ©â ¢ ¡ãä¥à¥ ¯à¨¥¬­¨ª¥ ¯® è¨à¨­¥ - è¨à¨­  ¢áâ ¢«ï¥¬®© ª à⨭ª¨
  2972.         endl
  2973.         pushad
  2974.  
  2975.         mov edi,[buf_source]
  2976.         cmp buf2d_bits,8
  2977.         jne .error1 ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
  2978.         mov eax,buf2d_w ;è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
  2979.         mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
  2980.         mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
  2981.  
  2982.         mov edi,[buf_destination]
  2983.         cmp buf2d_bits,24
  2984.         jne .error2 ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
  2985.         mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
  2986.         cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
  2987.         jge .copy_end     ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
  2988.                 mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
  2989.                 mov ecx,[coord_y]
  2990.                 cmp ecx,0
  2991.                 jge @f
  2992.                         ;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
  2993.                         add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
  2994.                         cmp edx,0
  2995.                         jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
  2996.                         neg ecx
  2997.                         ;inc ecx
  2998.                         imul ecx,eax
  2999.                         add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
  3000.                         xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
  3001.                 @@:
  3002.                 cmp ecx,ebx
  3003.                 jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
  3004.                 add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
  3005.                 cmp ecx,ebx
  3006.                 jle @f
  3007.                         sub ecx,ebx
  3008.                         sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
  3009.                 @@:
  3010.                 mov ebx,buf2d_w
  3011.                 mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
  3012.                 cmp ecx,0
  3013.                 jg .end_otr_c_y
  3014.                         ;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
  3015.                         mov ecx,[coord_x]
  3016.                         jmp @f
  3017.                 .end_otr_c_y:
  3018.                 imul ecx,ebx
  3019.                 add ecx,[coord_x]
  3020.                 @@:
  3021.                 lea ecx,[ecx+ecx*2]
  3022.                 add ecx,buf2d_data ;buf2d_data ¤ ­­ë¥ ®á­®¢­®£® ¡ãä¥à 
  3023.                 sub ebx,eax ;ebx - è¨à¨­  ®á­®¢­®£® ¡ãä¥à  ¬¨­ãá è¨à¨­  à¨á㥬®£® ¡ãä¥à 
  3024.                 mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
  3025.  
  3026.         mov dword[lost_bytes],0
  3027.         mov ecx,[coord_x]
  3028.         cmp ecx,0
  3029.         jge @f
  3030.                 neg ecx
  3031.                 ;inc ecx
  3032.                 cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
  3033.                 jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w)
  3034.                 mov [lost_bytes],ecx
  3035.                 sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
  3036.                 add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
  3037.                 add esi,ecx
  3038.                 lea ecx,[ecx+ecx*2]
  3039.                 add edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
  3040.                 xor ecx,ecx
  3041.         @@:
  3042.         cmp ecx,ebx
  3043.         jle @f
  3044.                 sub ecx,ebx
  3045.                 sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
  3046.                 add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
  3047.                 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
  3048.                 add [lost_bytes],ecx
  3049.         @@:
  3050.  
  3051.         lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
  3052.         mov [dest_w_bytes],ebx
  3053.         mov ebx,[color]
  3054.  
  3055.         cld
  3056.         cmp dword[lost_bytes],0
  3057.         jg .copy_1
  3058.         .copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
  3059.                 mov ecx,eax
  3060.                 @@:
  3061.                         call combine_colors_2
  3062.                         add edi,3
  3063.                         inc esi
  3064.                         loop @b
  3065.                 add edi,[dest_w_bytes]
  3066.                 dec edx
  3067.                 cmp edx,0
  3068.                 jg .copy_0
  3069.         jmp .copy_end
  3070.         .copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  «¥¢ãî ¨/¨«¨ ¯à ¢ãî áâ®à®­ã)
  3071.                 mov ecx,eax
  3072.                 @@:
  3073.                         call combine_colors_2
  3074.                         add edi,3
  3075.                         inc esi
  3076.                         loop @b
  3077.                 add edi,[dest_w_bytes]
  3078.                 add esi,[lost_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
  3079.                 dec edx
  3080.                 cmp edx,0
  3081.                 jg .copy_1
  3082.  
  3083.         jmp .copy_end
  3084.         .error1:
  3085.                 stdcall print_err,sz_buf2d_bit_blt_alpha,txt_err_n8b
  3086.                 jmp .copy_end
  3087.         .error2:
  3088.                 stdcall print_err,sz_buf2d_bit_blt_alpha,txt_err_n24b
  3089.         .copy_end:
  3090.         popad
  3091.         ret
  3092. endp
  3093.  
  3094. ;¯à¥®¡à §®¢ ­¨¥ 8-¡¨â­®£® ¡ãä¥à  à §¬¥à®¬ 16*16 ¢ à §¬¥à 1*256 ᨬ¢®«®¢
  3095. align 4
  3096. proc buf_convert_text_matrix, buf_struc:dword
  3097.         locals
  3098.                 tmp_mem dd ?
  3099.                 c1 dw ?
  3100.                 c2 dd ?
  3101.                 c3 dw ?
  3102.         endl
  3103.         pushad
  3104.         mov edi,dword[buf_struc]
  3105.         cmp buf2d_bits,8
  3106.         jne .error
  3107.                 mov ecx,buf2d_h
  3108.                 mov ebx,ecx
  3109.                 shr ebx,4 ;¯à¥¤¯®« £ ¥¬ çâ® ¢ ¡ãä¥à¥ 16 áâப á ᨬ¢®« ¬¨, ¯®â®¬ã ¤¥«¨¬ ­  2^4
  3110.                 mov edx,buf2d_w
  3111.                 imul ecx,edx ;ecx = size  8 b
  3112.                 invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
  3113.                 mov [tmp_mem],eax ;eax - new memory
  3114.  
  3115.                 shr edx,4 ;¯à¥¤¯®« £ ¥¬ çâ® ¢ ¡ãä¥à¥ 16 ª®«®­®ª á ᨬ¢®« ¬¨, ¯®â®¬ã ¤¥«¨¬ ­  2^4
  3116.                 mov eax,ebx
  3117.                 imul ebx,edx ;¢ëç¨á«ï¥¬ ª®®«¨ç¥á⢮ ¯¨ªá¥«¥© ­  1 ᨬ¢®«
  3118.                 ;eax = bhe - ¢ëá®â  ¡ãª¢ë
  3119.                 ;ebx = bwi*bhe - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ 1-© ¡ãª¢¥
  3120.                 ;edx = bwi - è¨à¨­  ¡ãª¢ë
  3121.                 ;ecx,esi,edi - ¨á¯®«ì§ãîâáï ¢ 横«¥ .c_0
  3122.                 shr buf2d_w,4
  3123.                 shl buf2d_h,4 ;¯à¥®¡à §®¢ë¢ ¥¬ à §¬¥àë ¡ãä¥à 
  3124.  
  3125.                 cld
  3126.                 mov esi,buf2d_data
  3127.                 mov edi,[tmp_mem]
  3128.                 mov word[c3],16
  3129.                 .c_3:
  3130.                         mov dword[c2],eax
  3131.                         .c_2:
  3132.                                 mov word[c1],16
  3133.                                 .c_1:
  3134.                                         mov ecx,edx ;.c_0:
  3135.                                         rep movsb
  3136.                                         add edi,ebx
  3137.                                         sub edi,edx ;edi+=(bwi*bhe-bwi)
  3138.                                         dec word[c1]
  3139.                                         cmp word[c1],0
  3140.                                         jg .c_1
  3141.                                 add edi,edx
  3142.                                 shl ebx,4
  3143.                                 sub edi,ebx ;edi-=(16*bwi*bhe-bwi)
  3144.                                 shr ebx,4
  3145.                                 dec dword[c2]
  3146.                                 cmp dword[c2],0
  3147.                                 jg .c_2
  3148.                         sub edi,ebx
  3149.                         shl ebx,4
  3150.                         add edi,ebx ;edi+=(15*bwi*bhe)
  3151.                         shr ebx,4
  3152.                         dec word[c3]
  3153.                         cmp word[c3],0
  3154.                         jg .c_3
  3155.  
  3156.                 mov edi,dword[buf_struc] ;ª®¯¨à®¢ ­¨¥ ­®¢®© ¬ âà¨æë ¢ ®á­®¢­®© ¡ãä¥à
  3157.                 mov edi,buf2d_data
  3158.                 mov esi,[tmp_mem]
  3159.                 mov ecx,ebx
  3160.                 shl ecx,8
  3161.                 rep movsb
  3162.                 invoke mem.free,[tmp_mem] ;ç¨á⨬ ¢à¥¬¥­­ãî ¯ ¬ïâì
  3163.                 jmp .end_conv
  3164.         .error:
  3165.                 stdcall print_err,sz_buf2d_convert_text_matrix,txt_err_n8b
  3166.         .end_conv:
  3167.         popad
  3168.         ret
  3169. endp
  3170.  
  3171. align 4
  3172. buf_s_matr buf_2d_header ? ;«®ª «ì­ ï ¬ âà¨æ  ᨬ¢®« 
  3173.  
  3174. align 4
  3175. proc buf_draw_text, buf_struc:dword, buf_t_matr:dword, text:dword, coord_x:dword, coord_y:dword, color:dword
  3176.         locals
  3177.                 buf_t_matr_offs dd ?
  3178.         endl
  3179.         pushad
  3180.         mov edi,dword[buf_struc]
  3181.         cmp buf2d_bits,24
  3182.         jne .error2
  3183.         mov edi,dword[buf_t_matr]
  3184.         cmp buf2d_bits,8
  3185.         jne .error1
  3186.                 mov edx,buf2d_data
  3187.                 mov [buf_t_matr_offs],edx
  3188.                 mov ecx,BUF_STRUCT_SIZE ;ª®¯¨à㥬 áâàãªâãàã ⥪á⮢®© ¬ âà¨æë
  3189.                 mov esi,edi
  3190.                 lea edi,[buf_s_matr]
  3191.                 cld
  3192.                 rep movsb
  3193.                 lea edi,[buf_s_matr]
  3194.                 shr buf2d_h,8 ;¤¥«¨¬ ¢ëá®âã ᨬ¢®«ì­®£® ¡ãä¥à  ­  256, ¤«ï ­ å®¦¤¥­¨ï ¢ëá®âë 1-£® ᨬ¢®« 
  3195.                 mov ebx,buf2d_h ;¡¥à¥¬ ¢ëá®âã ᨬ¢®« 
  3196.                 mov ecx,buf2d_w ;¡¥à¥¬ è¨à¨­ã ᨬ¢®« 
  3197.  
  3198.                 mov eax,[coord_x]
  3199.                 mov esi,[text]
  3200.                 cmp byte[esi],0
  3201.                 je .end_draw ;¥á«¨ ¯ãáâ ï áâப 
  3202.                 @@:
  3203.                         xor edx,edx
  3204.                         mov dl,byte[esi] ;¡¥à¥¬ ª®¤ ᨬ¢®« 
  3205.                         imul edx,ebx ;㬭®¦ ¥¬ ¥£® ­  ¢ëá®âã ᨬ¢®« 
  3206.                         imul edx,ecx ;㬭®¦ ¥¬ ­  è¨à¨­ã ᨬ¢®« 
  3207.                         add edx,[buf_t_matr_offs] ;¯à¨¡ ¢«ï¥¬ ᬥ饭¨¥ 0-£® ᨬ¢®« , â. ¥. ¯®«ãç ¥âáï ᬥ饭¨¥ ¢ë¢®¤¨¬®£® ᨬ¢®« 
  3208.                         mov buf2d_data,edx ;¢ «®ª «ì­ë© ¡ãä¥à ᨬ¢®« , áâ ¢¨¬ 㪠§ â¥«ì ­  ­ã¦­ë© ᨬ¢®« ¨§ ¡ãä¥à  buf_t_matr
  3209.                         stdcall buf_bit_blt_alpha, [buf_struc], eax,[coord_y], edi,[color]
  3210.                         add eax,ecx
  3211.                         .new_s:
  3212.                                 inc esi
  3213.                                 cmp byte[esi],13
  3214.                                 jne .no_13
  3215.                                         mov eax,[coord_x]
  3216.                                         add [coord_y],ebx
  3217.                                         jmp .new_s
  3218.                                 .no_13:
  3219.                         cmp byte[esi],0
  3220.                         jne @b
  3221.                 jmp .end_draw
  3222.         .error1:
  3223.                 stdcall print_err,sz_buf2d_draw_text,txt_err_n8b
  3224.                 jmp .end_draw
  3225.         .error2:
  3226.                 stdcall print_err,sz_buf2d_draw_text,txt_err_n24b
  3227.         .end_draw:
  3228.         popad
  3229.         ret
  3230. endp
  3231.  
  3232. align 4
  3233. proc print_err, fun:dword, mes:dword ;¢ë¢®¤¨¬ á®®¡é¥­¨¥ ®¡ 訡ª¥ ­  ¤®áªã ®â« ¤ª¨
  3234.         pushad
  3235.         mov eax,63
  3236.         mov ebx,1
  3237.  
  3238.         mov esi,[fun]
  3239.         @@:
  3240.                 mov cl,byte[esi]
  3241.                 int 0x40
  3242.                 inc esi
  3243.                 cmp byte[esi],0
  3244.                 jne @b
  3245.         mov cl,':'
  3246.         int 0x40
  3247.         mov cl,' '
  3248.         int 0x40
  3249.         mov esi,[mes]
  3250.         @@:
  3251.                 mov cl,byte[esi]
  3252.                 int 0x40
  3253.                 inc esi
  3254.                 cmp byte[esi],0
  3255.                 jne @b
  3256.         popad
  3257.         ret
  3258. endp
  3259.  
  3260. ;input:
  3261. ; ebp+8  = p0
  3262. ; ebp+12 = p1
  3263. align 4
  3264. line_len4i:
  3265.         push ebp
  3266.         mov ebp,esp
  3267.                 finit
  3268.                 fild word [ebp+8]
  3269.                 fisub word [ebp+12]
  3270.                 fmul st0,st0 ;st0=x^2
  3271.                 fild word [ebp+10]
  3272.                 fisub word [ebp+14]
  3273.                 fmul st0,st0 ;st0=y^2
  3274.                 fadd st0,st1
  3275.                 fsqrt
  3276.                 fstp dword [ebp+12]
  3277.         pop ebp
  3278.         ret 4 ;8
  3279.  
  3280. align 4
  3281. proc buf_curve_bezier, buffer:dword, coord_p0:dword,coord_p1:dword,coord_p2:dword, color:dword
  3282.         locals
  3283.                 delt_t dd ?
  3284.                 opr_param dd ?
  3285.                 v_poi_0 dd ?
  3286.         endl
  3287.         pushad
  3288.  
  3289. ;float t, xt,yt;
  3290. ;for(t=.0;t<1.;t+=.005){
  3291. ;  xt=pow(1.-t,2)*x0+2*t*(1.-t)*x1+pow(t,2)*x2;
  3292. ;  yt=pow(1.-t,2)*y0+2*t*(1.-t)*y1+pow(t,2)*y2;
  3293. ;  dc.SetPixel(xt,yt,255L);
  3294. ;}
  3295.  
  3296.         mov edx,[color] ;set curve color
  3297.         mov edi,[buffer]
  3298.         xor ebx,ebx
  3299.         xor ecx,ecx
  3300.  
  3301.         finit
  3302.  
  3303.         ; calculate delta t
  3304.         stdcall line_len4i, dword[coord_p1],dword[coord_p0]
  3305.         fadd dword[esp]
  3306.         add esp,4 ;pop ...
  3307.  
  3308.         stdcall line_len4i, dword[coord_p2],dword[coord_p1]
  3309.         fadd dword[esp]
  3310.         add esp,4 ;pop ...
  3311.  
  3312.         fadd st0,st0 ; len*=2
  3313.         ftst
  3314.         fstsw ax
  3315.  
  3316.         fld1
  3317.         sahf
  3318.         jle @f ;¨§¡¥£ ¥¬ ¤¥«¥­¨ï ­  0
  3319.                 fdiv st0,st1
  3320.         @@:
  3321.         fstp dword[delt_t]
  3322.  
  3323.         finit
  3324.  
  3325.         ;fild word[coord_p2+2] ;y2
  3326.         fild word[coord_p1+2] ;y1
  3327.         fild word[coord_p0+2] ;y0
  3328.         fild word[coord_p2] ;x2
  3329.         fild word[coord_p1] ;x1
  3330.         fild word[coord_p0] ;x0
  3331.         fld dword[delt_t]
  3332.         fldz ;t=.0
  3333.  
  3334.         @@:
  3335.                 fld1
  3336.                 fsub st0,st1 ;1.-t
  3337.                 fmul st0,st0 ;pow(1.-t,2)
  3338.                 fmul st0,st3 ;...*x0
  3339.                 fstp dword[opr_param]
  3340.  
  3341.                 fld1
  3342.                 fsub st0,st1 ;1.-t
  3343.                 fmul st0,st1 ;(1.-t)*t
  3344.                 fadd st0,st0
  3345.                 fmul st0,st4 ;...*x1
  3346.                 mov esi,dword[opr_param]
  3347.                 fstp dword[opr_param]
  3348.  
  3349.                 fldz
  3350.                 fadd st0,st1 ;0+t
  3351.                 fmul st0,st0 ;t*t
  3352.                 fmul st0,st5 ;...*x2
  3353.  
  3354.                 fadd dword[opr_param]
  3355.                 mov dword[opr_param],esi
  3356.                 fadd dword[opr_param]
  3357.                 fistp word[v_poi_0] ;x
  3358.  
  3359.                 fld1
  3360.                 fsub st0,st1 ;1.-t
  3361.                 fmul st0,st0 ;pow(1.-t,2)
  3362.                 fmul st0,st6 ;...*y0
  3363.                 fstp dword[opr_param]
  3364.  
  3365.                 fld1
  3366.                 fsub st0,st1 ;1.-t
  3367.                 fmul st0,st1 ;(1.-t)*t
  3368.                 fadd st0,st0
  3369.                 fmul st0,st7 ;...*y1
  3370.                 mov esi,dword[opr_param]
  3371.                 fstp dword[opr_param]
  3372.  
  3373.                 fldz
  3374.                 fadd st0,st1 ;0+t
  3375.                 fmul st0,st0 ;t*t
  3376.                 fimul word[coord_p2+2] ;...*y2
  3377.  
  3378.                 fadd dword[opr_param]
  3379.                 mov dword[opr_param],esi
  3380.                 fadd dword[opr_param]
  3381.                 fistp word[v_poi_0+2] ;y
  3382.  
  3383.                 mov eax,1
  3384.                 mov bx,word[v_poi_0+2]
  3385.                 mov cx,word[v_poi_0]
  3386.                 call draw_pixel
  3387.  
  3388.                 fadd st0,st1 ;t+dt
  3389.  
  3390.                 fld1
  3391.                 fcomp
  3392.                 fstsw ax
  3393.                 sahf
  3394.         jae @b
  3395.  
  3396.         popad
  3397.         ret
  3398. endp
  3399.  
  3400.  
  3401.  
  3402. ;*** ä㭪樨 ¤«ï à ¡®âë á ¢®ªá¥«ì­®© £à ä¨ª®© ***
  3403.  
  3404.  
  3405.  
  3406. ;ᮧ¤ ­¨¥ ¢®ªá¥«ì­ëå ª¨á⥩
  3407. align 4
  3408. proc vox_brush_create uses eax ebx ecx edi, h_br:dword, buf_z:dword
  3409.         mov edi,[h_br]
  3410.         movzx ecx,byte[edi+3]
  3411.         add edi,4
  3412.  
  3413.         ; *** ᮧ¤ ­¨¥ ¥¤¨­¨ç­®© ª¨á⨠***
  3414.         mov eax,[buf_z]
  3415.         mov buf2d_data,eax
  3416.         movzx eax,byte[edi-4] ;è¨à¨­  ¥¤¨­¨ç­®© ª¨áâ¨
  3417.         mov buf2d_w,eax ;è¨à¨­  ¡ãä¥à 
  3418.         movzx eax,byte[edi-4+1] ;¢ëá®â  ¥¤¨­¨ç­®© ª¨áâ¨
  3419.         mov buf2d_h,eax ;¢ëá®â  ¡ãä¥à 
  3420.         mov buf2d_size_lt,0 ;®âáâ㯠᫥¢  ¨ á¯à ¢  ¤«ï ¡ãä¥à 
  3421.         mov buf2d_color,0 ;梥â ä®­  ¡ãä¥à 
  3422.         mov buf2d_bits,32 ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
  3423.  
  3424.         ; *** ᮧ¤ ­¨¥ á«¥¤ãîé¨å ª¨á⥩ ***
  3425.         cmp ecx,1
  3426.         jl .end_creat
  3427.         movzx ebx,byte[edi-4+2] ;¢ëá®â  ®á­®¢ ­¨ï ¥¤¨­¨ç­®© ª¨áâ¨
  3428.         shr ebx,1
  3429.         cld
  3430.         @@:
  3431.                 mov eax,edi
  3432.                 add edi,BUF_STRUCT_SIZE
  3433.                 stdcall vox_create_next_brush, eax, edi, ebx
  3434.                 shl ebx,1
  3435.                 loop @b
  3436.         .end_creat:
  3437.         ret
  3438. endp
  3439.  
  3440. ;㤠«¥­¨¥ ¢®ªá¥«ì­ëå ª¨á⥩
  3441. align 4
  3442. proc vox_brush_delete uses ecx edi, h_br:dword
  3443.         mov edi,[h_br]
  3444.         movzx ecx,byte[edi+3]
  3445.         add edi,4
  3446.  
  3447.         ; *** 㤠«¥­¨¥ ª¨á⥩ ***
  3448.         cmp ecx,1
  3449.         jl .end_delete
  3450.         cld
  3451.         @@:
  3452.                 add edi,BUF_STRUCT_SIZE
  3453.                 stdcall buf_delete, edi
  3454.                 loop @b
  3455.         .end_delete:
  3456.         ret
  3457. endp
  3458.  
  3459. ;äã­ªæ¨ï ¤«ï ᮧ¤ ­¨ï ¢®ªá¥«ï á«¥¤ãî饣® ¯®à浪 
  3460. ; buf_v1 - ¡ãä¥à á ¨á室­ë¬ ¢®ªá¥«¥¬
  3461. ; buf_v2 - ¡ãä¥à á 㢥«¨ç¥­ë¬ ¢®ªá¥«¥¬
  3462. ; h - ¢ëá®â  ®á­®¢ ­¨ï ¨á室­®£® ¢®ªá¥«ï : 2
  3463. align 4
  3464. proc vox_create_next_brush uses eax ebx ecx edx edi, buf_v1:dword, buf_v2:dword, h:dword
  3465.         mov edi,[buf_v1]
  3466.         mov ebx,buf2d_h
  3467.         mov ecx,buf2d_w
  3468.         mov edi,[buf_v2]
  3469.         mov buf2d_h,ebx
  3470.         shl buf2d_h,1
  3471.         mov buf2d_w,ecx
  3472.         shl buf2d_w,1
  3473.         mov buf2d_color,0
  3474.         mov buf2d_bits,32
  3475.  
  3476.         stdcall buf_create, [buf_v2] ;ᮧ¤ ­¨¥ ¡ãä¥à  £«ã¡¨­ë
  3477.         shr ecx,1
  3478.         mov edx,[h]
  3479.         shl edx,1
  3480.         sub ebx,edx
  3481.         ;ecx - è¨à¨­  ¨á室­®£® ¢®ªá¥«ï : 2
  3482.         ;ebx - ¢ëá®â  ¨á室­®£® ¢®ªá¥«ï (¡¥§ ®á­®¢ ­¨ï)
  3483.         ;edx - ¢ëá®â  ®á­®¢ ­¨ï ¨á室­®£® ¢®ªá¥«ï
  3484.         mov eax,[h]
  3485.         cmp eax,0
  3486.         je @f
  3487.                 stdcall vox_add, [buf_v2], [buf_v1], ecx,0,0
  3488.                 stdcall vox_add, [buf_v2], [buf_v1], ecx,ebx,0
  3489.  
  3490.                 stdcall vox_add, [buf_v2], [buf_v1], 0,eax,eax
  3491.                 push eax ;stdcall ...
  3492.                 add eax,ebx
  3493.                 stdcall vox_add, [buf_v2], [buf_v1], 0,eax ;,...
  3494.                 sub eax,ebx
  3495.                 shl ecx,1
  3496.  
  3497.                 ;ecx - è¨à¨­  ¨á室­®£® ¢®ªá¥«ï
  3498.                 stdcall vox_add, [buf_v2], [buf_v1], ecx,eax,eax
  3499.                 push eax ;stdcall ...,[h]
  3500.                 add eax,ebx
  3501.                 stdcall vox_add, [buf_v2], [buf_v1], ecx,eax;,[h]
  3502.                 ;sub eax,ebx
  3503.                 shr ecx,1
  3504.  
  3505.                 ;ecx - è¨à¨­  ¨á室­®£® ¢®ªá¥«ï : 2
  3506.                 stdcall vox_add, [buf_v2], [buf_v1], ecx,edx,edx
  3507.                 add ebx,edx
  3508.                 stdcall vox_add, [buf_v2], [buf_v1], ecx,ebx,edx
  3509.  
  3510.                 jmp .end_0
  3511.         @@:
  3512.                 ;¥á«¨ h = 0, ⮣¤  ¯®«ãç ¥¬ ª¨áâì ­  2 £à ­¨
  3513.                 ;¢ â ª®¬ á«ãç ¥ ¤«ï ¯®«ã祭¨ï £«ã¡¨­ë ¡¥à¥¬ è¨à¨­ã / 2
  3514.                 mov eax,ecx
  3515.                 ;2 «¥¢ëå ¢®ªá¥«ï
  3516.                 stdcall vox_add, [buf_v2], [buf_v1], 0,0,eax
  3517.                 stdcall vox_add, [buf_v2], [buf_v1], 0,ebx,eax
  3518.                 shl eax,1
  3519.                 ;2 業âà «ì­ëå ¯¥à¥¤­¨å ¢®ªá¥«ï (§ ¤­¨¥ 業âà «ì­ë¥ ­¥ ¢ë¢®¤¨¬)
  3520.                 stdcall vox_add, [buf_v2], [buf_v1], ecx,0,eax
  3521.                 stdcall vox_add, [buf_v2], [buf_v1], ecx,ebx,eax
  3522.                 shr eax,1
  3523.                 shl ecx,1
  3524.                 ;2 ¯à ¢ëå ¢®ªá¥«ï
  3525.                 stdcall vox_add, [buf_v2], [buf_v1], ecx,0,eax
  3526.                 stdcall vox_add, [buf_v2], [buf_v1], ecx,ebx,eax
  3527.  
  3528.         .end_0:
  3529.  
  3530.  
  3531.         ret
  3532. endp
  3533.  
  3534. ;
  3535. align 4
  3536. proc vox_add, buf_v1:dword, buf_v2:dword, coord_x:dword, coord_y:dword, coord_z:dword
  3537. pushad
  3538.         mov ebx,[coord_x]
  3539.         mov eax,[coord_y]
  3540.         mov edi,[buf_v2]
  3541.         mov ecx,buf2d_h
  3542.         mov esi,buf2d_w
  3543.         imul ecx,esi
  3544.         add esi,ebx
  3545.         mov edx,buf2d_data
  3546.         cld
  3547.         ;ecx - count pixels in voxel
  3548.         ;edx - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢ ¢®ªá¥«ì­®¬ ¡ãä¥à¥
  3549.         ;edi - 㪠§ â¥«ì ­  ¢®ªá¥«ì­ë© ¡ãä¥à
  3550.         ;esi - width voxel buffer add coord x
  3551.         .cycle:
  3552.                 cmp dword[edx],0
  3553.                 je @f
  3554.                         ;¯à®¢¥à塞 ¡ãä¥à £«ã¡¨­ë
  3555.                         push eax ecx edi esi
  3556.                         mov ecx,eax
  3557.                         mov edi,[buf_v1]
  3558.                         call get_pixel_32 ;stdcall buf_get_pixel, [buf_v1],ebx,ecx
  3559.                         mov esi,[edx]
  3560.                         add esi,[coord_z]
  3561.                         cmp eax,esi
  3562.                         jge .end_draw
  3563.                         stdcall buf_set_pixel, [buf_v1],ebx,ecx,esi ;esi = new coord z
  3564.                         .end_draw:
  3565.                         pop esi edi ecx eax
  3566.                 @@:
  3567.                 add edx,4
  3568.                 inc ebx
  3569.                 cmp ebx,esi
  3570.                 jl @f
  3571.                         inc eax
  3572.                         sub ebx,buf2d_w
  3573.                 @@:
  3574.                 loop .cycle
  3575. popad
  3576.         ret
  3577. endp
  3578.  
  3579. ;description:
  3580. ; ¢®§¢à è ¥â è¨à¨­ã ¢®ªá¥«ì­®£® ¨§®¡à ¦¥­¨ï á 3-¬ï £à ­ï¬¨
  3581. ; ¯à¨­¨¬ ¥â 㪠§ â¥«ì ­  ª¨áâì ¨ ¬ áèâ ¡
  3582. align 4
  3583. proc buf_vox_obj_get_img_w_3g uses ecx, h_br:dword,k_scale:dword
  3584.         mov ecx,[h_br]
  3585.  
  3586.         movzx eax,byte[ecx]
  3587.         cmp dword[k_scale],1
  3588.         jl .end_c0
  3589.                 mov ecx,[k_scale]
  3590.                 shl eax,cl
  3591.         .end_c0:
  3592.         ret
  3593. endp
  3594.  
  3595. ;description:
  3596. ; ¢®§¢à è ¥â ¢ëá®âã ¢®ªá¥«ì­®£® ¨§®¡à ¦¥­¨ï á 3-¬ï £à ­ï¬¨
  3597. ; ¯à¨­¨¬ ¥â 㪠§ â¥«ì ­  ª¨áâì ¨ ¬ áèâ ¡
  3598. align 4
  3599. proc buf_vox_obj_get_img_h_3g uses ecx, h_br:dword,k_scale:dword
  3600.         mov ecx,[h_br]
  3601.  
  3602.         movzx eax,byte[ecx+1]
  3603.         cmp dword[k_scale],1
  3604.         jl .end_c0
  3605.                 mov ecx,[k_scale]
  3606.                 shl eax,cl
  3607.         .end_c0:
  3608.         ret
  3609. endp
  3610.  
  3611. ;description:
  3612. ; äã­ªæ¨ï à¨áãîé ï ¢®ªá¥«ì­ë© ®¡ê¥ªâ (¢¨¤­  1 £à ­ì)
  3613. ;input:
  3614. ; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
  3615. ; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
  3616. align 4
  3617. proc buf_vox_obj_draw_1g, buf_i:dword, buf_z:dword, v_obj:dword, coord_x:dword,\
  3618. coord_y:dword, k_scale:dword
  3619.         cmp [k_scale],0
  3620.         jl .end_f
  3621. pushad
  3622.         mov edi,[buf_i]
  3623.         cmp buf2d_bits,24
  3624.         jne .error1
  3625.         mov edi,[buf_z]
  3626.         cmp buf2d_bits,32
  3627.         jne .error2
  3628.  
  3629.         mov ecx,[k_scale]
  3630.         mov ebx,[coord_x]
  3631.         mov edx,[coord_y]
  3632.         mov edi,[v_obj]
  3633.         add edi,vox_offs_data
  3634.         xor esi,esi
  3635.         stdcall draw_sub_vox_obj_1g, [buf_i],[buf_z],[v_obj]
  3636.  
  3637.         jmp .end_0
  3638.         .error1:
  3639.                 stdcall print_err,sz_buf2d_vox_obj_draw_1g,txt_err_n24b
  3640.                 jmp .end_0
  3641.         .error2:
  3642.                 stdcall print_err,sz_buf2d_vox_obj_draw_1g,txt_err_n32b
  3643.         .end_0:
  3644. popad
  3645.         .end_f:
  3646.         ret
  3647. endp
  3648.  
  3649. ;input:
  3650. ; ebx - coord_x
  3651. ; edx - coord_y
  3652. ; esi - coord_z
  3653. ; ecx - ã஢¥­ì ⥪ã襣® 㧫 
  3654. ; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
  3655. align 4
  3656. proc draw_sub_vox_obj_1g, buf_i:dword, buf_z:dword, v_obj:dword
  3657.         cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
  3658.         je .sub_trees
  3659.  
  3660.                 ;¯à®à¨á®¢ª  à ¬ª¨ ¥á«¨ à §¬¥à 㧫  = 1
  3661.                 cmp ecx,0
  3662.                 jne @f
  3663.                         ;¯à®¢¥àª  £«ã¡¨­ë esi
  3664.                         stdcall buf_get_pixel, [buf_z], ebx,edx, esi
  3665.                         cmp eax,esi
  3666.                         jge @f
  3667.                                 push ecx
  3668.                                 mov ecx,dword[edi]
  3669.                                 and ecx,0xffffff
  3670.                                 stdcall buf_set_pixel, [buf_i], ebx,edx, ecx
  3671.                                 stdcall buf_set_pixel, [buf_z], ebx,edx, esi
  3672.                                 pop ecx
  3673.                 @@:
  3674.  
  3675.                 ;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
  3676.                 push edx
  3677.                 ;¢å®¤ ¢­ãâàì 㧫 
  3678.                 dec ecx
  3679.  
  3680.                 mov eax,1
  3681.                 cmp ecx,1
  3682.                 jl @f
  3683.                         shl eax,cl
  3684.                 @@:
  3685.  
  3686.                 add edx,eax ;ª®à¥ªâ¨à®¢ª  ¢ëá®âë ¯®¤ ¢®ªá¥«ì ­¨¦­¥£® ã஢­ï
  3687.  
  3688.                 mov ah,byte[edi+3]
  3689.                 add edi,4
  3690.                 mov al,8
  3691.                 .cycle:
  3692.                         bt ax,8 ;â¥áâ¨à㥬 ⮫쪮 ah
  3693.                         jnc .c_next
  3694.                                 push eax ebx edx esi
  3695.                                 stdcall vox_corect_coords_pl, [v_obj],1
  3696.                                 stdcall draw_sub_vox_obj_1g, [buf_i],[buf_z],[v_obj]
  3697.                                 pop esi edx ebx eax
  3698.                         .c_next:
  3699.                         shr ah,1
  3700.                         dec al
  3701.                         jnz .cycle
  3702.                 ;¢ë室 ¨§ 㧫 
  3703.                 inc ecx
  3704.                 pop edx
  3705.                 jmp .end_f
  3706.         .sub_trees:
  3707.                 cmp ecx,0
  3708.                 jl .end_0 ;­¥ à¨á㥬 ®ç¥­ì ¬ «¥­ìª¨¥ ¢®ªá¥«¨
  3709.  
  3710.                         ;à¨á㥬 㧥«
  3711.                         mov eax,[edi]
  3712.                         and eax,0xffffff
  3713.                        
  3714.                         cmp ecx,1
  3715.                         jl @f
  3716.                                 ;ª¢ ¤à â ¡®«ìè¥ â¥ªã饣® ¬ áèâ ¡ 
  3717.                                 stdcall vox_draw_square_1g, [buf_i],[buf_z],eax
  3718.                                 jmp .end_0
  3719.                         @@:
  3720.                                 ;ª¢ ¤à â ⥪ã饣® ¬ áèâ ¡ 
  3721.                                 push ecx
  3722.                                 mov ecx,eax
  3723.                                 stdcall buf_get_pixel, [buf_z], ebx,edx
  3724.                                 cmp eax,esi
  3725.                                 jge .end_1
  3726.                                 stdcall buf_set_pixel, [buf_i], ebx,edx,ecx
  3727.                                 stdcall buf_set_pixel, [buf_z], ebx,edx,esi
  3728.                                 .end_1:
  3729.                                 pop ecx
  3730.                 .end_0:
  3731.                 add edi,4
  3732.         .end_f:
  3733.         ret
  3734. endp
  3735.  
  3736. ;output:
  3737. ; eax - à §àãè ¥âáï
  3738. align 4
  3739. proc vox_draw_square_1g uses ecx edx edi, buf_i:dword, buf_z:dword, color:dword
  3740. locals
  3741.         img_size dd ?
  3742.         coord_y dd ?
  3743. endl
  3744.         mov edi,[buf_z]
  3745.         xor eax,eax
  3746.         inc eax
  3747.         shl eax,cl
  3748.         mov [img_size],eax
  3749.         mov [coord_y],eax
  3750.         .cycle_0:
  3751.         push ebx
  3752.         mov ecx,[img_size]
  3753.         cld
  3754.         .cycle_1:
  3755.                 push ecx
  3756.                 mov ecx,edx
  3757.                 call get_pixel_32
  3758.                 pop ecx
  3759.                 cmp eax,esi
  3760.                 jge @f
  3761.                         stdcall buf_set_pixel, [buf_i], ebx,edx, [color]
  3762.                         stdcall buf_set_pixel, edi, ebx,edx, esi
  3763.                 @@:
  3764.                 inc ebx
  3765.         loop .cycle_1
  3766.         pop ebx
  3767.         inc edx
  3768.         dec dword[coord_y]
  3769.         jnz .cycle_0
  3770.         ret
  3771. endp
  3772.  
  3773. ;description:
  3774. ; äã­ªæ¨ï à¨áãîé ï ¢®ªá¥«ì­ë© ®¡ê¥ªâ (¢¨¤­® 3 £à ­¨)
  3775. ;input:
  3776. ; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
  3777. ; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
  3778. ; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
  3779. ; v_obj - ¢®ªá¥«ì­ë© ®¡ê¥ªâ
  3780. ; k_scale - ª®íä. ¤«ï ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
  3781. align 4
  3782. proc buf_vox_obj_draw_3g, buf_i:dword, buf_z:dword, h_br:dword, v_obj:dword,\
  3783. coord_x:dword, coord_y:dword, coord_z:dword, k_scale:dword
  3784. pushad
  3785.         mov edi,[v_obj]
  3786.         mov ecx,[k_scale]
  3787.         mov ebx,[coord_x]
  3788.         mov edx,[coord_y]
  3789.         add edi,vox_offs_data
  3790.         mov esi,[coord_z]
  3791.         stdcall vox_go_in_node, [buf_i], [buf_z], [h_br], [v_obj]
  3792. popad
  3793.         ret
  3794. endp
  3795.  
  3796. ;description:
  3797. ; äã­ªæ¨ï à¨áãîé ï ç áâì ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
  3798. ;input:
  3799. ; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
  3800. ; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
  3801. ; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
  3802. ; v_obj - ¢®ªá¥«ì­ë© ®¡ê¥ªâ
  3803. ; k_scale - ª®íä. ¤«ï ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
  3804. align 4
  3805. proc buf_vox_obj_draw_3g_scaled, buf_i:dword, buf_z:dword, h_br:dword, v_obj:dword,\
  3806. coord_x:dword, coord_y:dword, coord_z:dword, k_scale:dword,\
  3807. s_c_x:dword, s_c_y:dword, s_c_z:dword, s_k_scale:dword,b_color:dword
  3808. pushad
  3809. locals
  3810.         p_node dd 0 ;த¨â¥«ì᪨© 㧥«
  3811. endl
  3812.         mov edi,[v_obj]
  3813.         add edi,vox_offs_data
  3814.  
  3815.         mov ecx,[k_scale]
  3816.         mov ebx,[coord_x]
  3817.  
  3818.         ;â¥á⮢ ï à ¬ª 
  3819.         mov eax,[h_br]
  3820.  
  3821.         movzx edx,byte[eax]
  3822.         movzx esi,byte[eax+1]
  3823.         cmp ecx,1
  3824.         jl .end_c0
  3825.                 shl edx,cl
  3826.                 shl esi,cl
  3827.         .end_c0:
  3828.         ;stdcall buf_rect_by_size, [buf_i], ebx,[coord_y],edx,esi, [b_color]
  3829.  
  3830.         ;¢¥à⨪ «ì­ ï ¯®«®á 
  3831.         add ebx,edx
  3832.         shr edx,cl
  3833.         stdcall buf_rect_by_size, [buf_i], ebx,[coord_y],edx,esi, [b_color]
  3834.         mov ecx,[s_k_scale]
  3835.         shr esi,cl
  3836.         xor eax,eax
  3837.         inc eax
  3838.         shl eax,cl
  3839.         dec eax
  3840.         sub eax,[s_c_z] ;§­ ç¥­¨ï ¯® ®á¨ z ¢®§à áâ îâ á ­¨§ã ¢¢¥àå
  3841.         imul eax,esi
  3842.         add eax,[coord_y]
  3843.         stdcall buf_filled_rect_by_size, [buf_i], ebx,eax,edx,esi, [b_color]
  3844.         mov ebx,[coord_y]
  3845.         shl esi,cl
  3846.         add ebx,esi
  3847.         stdcall buf_vox_obj_get_img_w_3g, [h_br],[k_scale]
  3848.         shr eax,1
  3849.         mov esi,[h_br]
  3850.         movzx esi,byte[esi+1]
  3851.         ;¯®«§ã­®ª
  3852.         stdcall draw_polz_hor, [buf_i], [coord_x],ebx,eax,esi, [s_c_x], [s_k_scale], [b_color]
  3853.         mov edx,[coord_x]
  3854.         add edx,eax
  3855.         ;¯®«§ã­®ª
  3856.         stdcall draw_polz_hor, [buf_i], edx,ebx,eax,esi, [s_c_y], [s_k_scale], [b_color]
  3857. ;---
  3858.  
  3859.         mov esi,[s_k_scale]
  3860.         cmp esi,1
  3861.         jl .end_2
  3862.  
  3863.         ; *** (1) ***
  3864.         .found:
  3865.         stdcall vox_obj_get_node_position, [v_obj],[s_c_x],[s_c_y],[s_c_z],esi
  3866.         movzx bx,byte[edi+3]
  3867.         mov [p_node],edi
  3868.         add edi,4
  3869.         cmp eax,0
  3870.         je .end_1
  3871.         mov ecx,eax
  3872.         cld
  3873.         @@: ;横« ¤«ï ¯à®¯ã᪠ ¯à¥¤ë¤ãé¨å ¯®¤¤¥à¥¢ì¥¢ ¢ 㧫¥
  3874.                 bt bx,0 ;¯à®¢¥à塞 ¥áâì «¨ ¤®ç¥à­¨¥ 㧫ë
  3875.                 jnc .end_0
  3876.                         xor eax,eax
  3877.                         stdcall vox_obj_rec0 ;¢ eax ¢ëç¨á«ï¥âáï ç¨á«® ¤®ç¥à­¨å 㧫®¢, ¢ ¤ ­­®© ¢¥â¢¨
  3878.                 .end_0:
  3879.                 shr bx,1
  3880.                 loop @b
  3881.         .end_1:
  3882.         bt bx,0
  3883.         jnc .end_2 ;¥á«¨ ¯®¤¤¥à¥¢  ­¥ áãé¥áâ¢ã¥â
  3884.         dec esi
  3885.         cmp esi,0
  3886.         jg .found
  3887.  
  3888.         ; *** (2) ***
  3889.         ;à¨á®¢ ­¨¥ ç á⨠®¡ê¥ªâ 
  3890.         mov ecx,[k_scale]
  3891.         mov ebx,[coord_x]
  3892.         mov edx,[coord_y]
  3893.         mov esi,[coord_z]
  3894.         stdcall vox_go_in_node, [buf_i], [buf_z], [h_br], [v_obj]
  3895.         .end_2:
  3896.  
  3897. popad
  3898.         ret
  3899. endp
  3900.  
  3901. ;input:
  3902. ; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
  3903. ; ebx - coord_x
  3904. ; edx - coord_y
  3905. ; esi - coord_z
  3906. ; ecx - ã஢¥­ì ⥪ã襣® 㧫 
  3907. ; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
  3908. align 4
  3909. proc vox_go_in_node, buf_i:dword, buf_z:dword, h_br:dword, v_obj:dword
  3910.         cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
  3911.         je .sub_trees
  3912.                 ;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
  3913.                 push eax edx
  3914.  
  3915.                 ;¯à®à¨á®¢ª  à ¬ª¨ ¥á«¨ à §¬¥à 㧫  = 1
  3916.                 cmp ecx,0
  3917.                 jne .end_2
  3918.                         push eax
  3919.                                 stdcall vox_get_sub_brush,[h_br],0 ;®¯à¥¤¥«ï¥¬ ª¨áâì ¤«ï à¨á®¢ ­¨ï
  3920.                                 cmp eax,0 ;¥á«¨ ª¨áâì ­¥ ­ ©¤¥­ 
  3921.                                 je @f
  3922.                                         stdcall draw_vox, [buf_i], [buf_z], eax, ebx,edx,esi, [edi]
  3923.                                 @@:
  3924.                         pop eax
  3925.                 .end_2:
  3926.  
  3927.                 ;¢å®¤ ¢­ãâàì 㧫 
  3928.                 dec ecx
  3929. ;---
  3930.                 push ebx
  3931.                         ;mov eax,(h-h_osn/2)
  3932.                         mov ebx,[h_br]
  3933.                         movzx eax,byte[ebx+1]
  3934.                         cmp byte[ebx+2],0
  3935.                         je @f
  3936.                                 ;¥á«¨ ª¨áâì á 3-¬ï £à ­ï¬¨
  3937.                                 movzx ebx,byte[ebx+2]
  3938.                                 shr ebx,1
  3939.                                 sub eax,ebx
  3940.                                 jmp .end_0
  3941.                         @@:
  3942.                                 ;¥á«¨ ª¨áâì á 2-¬ï £à ­ï¬¨
  3943.                                 movzx ebx,byte[ebx]
  3944.                                 shr ebx,1
  3945.                         .end_0:
  3946.                 cmp ecx,1
  3947.                 jl @f
  3948.                         shl eax,cl
  3949.                         shl ebx,cl
  3950.                 @@:
  3951.                 add esi,ebx
  3952.                 pop ebx
  3953.                 add edx,eax ;ª®à¥ªâ¨à®¢ª  ¢ëá®âë ¯®¤ ¢®ªá¥«ì ­¨¦­¥£® ã஢­ï
  3954. ;---
  3955.                 mov ah,byte[edi+3]
  3956.                 add edi,4
  3957.                 mov al,8
  3958.                 .cycle:
  3959.                         bt ax,8 ;â¥áâ¨à㥬 ⮫쪮 ah
  3960.                         jnc .c_next
  3961.                                 push ebx edx esi
  3962.                                 stdcall vox_corect_coords, [h_br], [v_obj]
  3963.                                 stdcall vox_go_in_node, [buf_i], [buf_z], [h_br], [v_obj]
  3964.                                 pop esi edx ebx
  3965.                         .c_next:
  3966.                         shr ah,1
  3967.                         dec al
  3968.                         jnz .cycle
  3969.  
  3970.                 ;¢ë室 ¨§ 㧫 
  3971.                 inc ecx
  3972.                 pop edx eax
  3973.  
  3974.                 jmp .end_f
  3975.         .sub_trees:
  3976.                 ;à¨á㥬 㧥«
  3977.                 push eax
  3978.                         stdcall vox_get_sub_brush,[h_br],ecx ;®¯à¥¤¥«ï¥¬ ª¨áâì ¤«ï à¨á®¢ ­¨ï
  3979.                         cmp eax,0 ;¥á«¨ ª¨áâì ­¥ ­ ©¤¥­ 
  3980.                         je @f
  3981.                                 stdcall draw_vox, [buf_i], [buf_z], eax, ebx,edx,esi, [edi]
  3982.                         @@:
  3983.                 pop eax
  3984.  
  3985.                 add edi,4
  3986.         .end_f:
  3987.         ret
  3988. endp
  3989.  
  3990. ;description:
  3991. ; äã­ªæ¨ï à¨áãîé ï ®¤¨­®ç­ë© ¢®ªá¥«
  3992. ;input:
  3993. ; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
  3994. ; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
  3995. ; buf_v - ¡ãä¥à á ¨§®¡à ¦¥­¨¥¬ ¢®ªá¥«ï (32 ¡¨â )
  3996. ; v_color - 梥â
  3997. align 4
  3998. proc draw_vox, buf_i:dword, buf_z:dword, buf_v:dword,\
  3999. coord_x:dword, coord_y:dword, coord_z:dword, v_color:dword
  4000. pushad
  4001.         mov eax,[coord_x]
  4002.         mov ebx,[coord_y]
  4003.         mov edi,[buf_v]
  4004.         mov ecx,buf2d_h
  4005.         mov esi,buf2d_w
  4006.         imul ecx,esi
  4007.         add esi,eax
  4008.         mov edx,buf2d_data
  4009.         cld
  4010.         ;ecx - count pixels in voxel
  4011.         ;edx - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢ ¢®ªá¥«ì­®¬ ¡ãä¥à¥
  4012.         ;edi - 㪠§ â¥«ì ­  ¢®ªá¥«ì­ë© ¡ãä¥à
  4013.         ;esi - width voxel buffer add coord x
  4014.         .cycle:
  4015.                 cmp dword[edx],0
  4016.                 je @f
  4017.                         ;¯à®¢¥à塞 ¡ãä¥à £«ã¡¨­ë
  4018.                         push eax
  4019.                         stdcall buf_get_pixel, [buf_z],eax,ebx
  4020.                         sub eax,[coord_z]
  4021.                         cmp eax,[edx]
  4022.                         jl .dr_pixel
  4023.                                 pop eax
  4024.                                 jmp @f
  4025.                         .dr_pixel:
  4026.                                 ;à¨á㥬 â®çªã
  4027.                                 pop eax
  4028.                                 stdcall buf_set_pixel, [buf_i],eax,ebx,[v_color]
  4029.                                 push ecx
  4030.                                 mov ecx,[coord_z]
  4031.                                 add ecx,[edx]
  4032.                                 stdcall buf_set_pixel, [buf_z],eax,ebx,ecx
  4033.                                 pop ecx
  4034.                 @@:
  4035.                 add edx,4
  4036.                 inc eax
  4037.                 cmp eax,esi
  4038.                 jl @f
  4039.                         inc ebx
  4040.                         sub eax,buf2d_w
  4041.                 @@:
  4042.                 loop .cycle
  4043. popad
  4044.         ret
  4045. endp
  4046.  
  4047. ;description:
  4048. ;äã­ªæ¨ï ¤«ï ª®à¥ªâ¨à®¢ª¨ ª®®à¤¨­ â
  4049. ;­ ¯à ¢«¥­¨ï ®á¥© ª®®à¤¨­ â ¢ ¢®ªá¥«¥:
  4050. ;*z
  4051. ;|
  4052. ;+
  4053. ;  * y
  4054. ; /
  4055. ;+
  4056. ; \
  4057. ;  * x
  4058. ;input:
  4059. ;  al - ­®¬¥à 㧫  ¢ ¤¥à¥¢¥ (®â 1 ¤® 8)
  4060. ; ebx - ª®®à¤¨­ â  x
  4061. ; edx - ª®®à¤¨­ â  y
  4062. ; esi - ª®®à¤¨­ â  z
  4063. ; ecx - ã஢¥­ì ⥪ã襣® 㧫 
  4064. ;output:
  4065. ; ebx - ­®¢ ï ª®®à¤¨­ â  x
  4066. ; edx - ­®¢ ï ª®®à¤¨­ â  y
  4067. ; esi - ­®¢ ï ª®®à¤¨­ â  z
  4068. align 4
  4069. proc vox_corect_coords, h_br:dword, v_obj:dword
  4070. locals
  4071.         osn_w_2 dd ? ;è¨à¨­  ®á­®¢ ­¨ï ¥¤¨­¨ç­®£® ¢®ªá¥«ï : 2
  4072.         vox_h dd ? ;¢ëá®â  ¥¤¨­¨ç­®£® ¢®ªá¥«ï
  4073. endl
  4074.         cmp ecx,0
  4075.         jl .end_f ;¤«ï ã᪮७¨ï ®âà¨á®¢ª¨
  4076.  
  4077.         push eax edi
  4078.         and eax,15 ;¢ë¤¥«ï¥¬ ­®¬¥à 㧫  ¢ ¤¥à¥¢¥
  4079.         mov edi,[v_obj]
  4080.         add edi,vox_offs_tree_table
  4081.         add edi,8
  4082.         sub edi,eax
  4083.  
  4084.         push ebx ecx
  4085.                 mov ebx,[h_br]
  4086.  
  4087.                 movzx ecx,byte[ebx]
  4088.                 shr ecx,1
  4089.                 mov dword[osn_w_2],ecx
  4090.  
  4091.                 movzx ecx,byte[ebx+2]
  4092.                 movzx ebx,byte[ebx+1]
  4093.                 sub ebx,ecx
  4094.                 mov dword[vox_h],ebx
  4095.                 shr ecx,1
  4096.                 mov eax,ecx ;eax - ¢ëá®â  ®á­®¢ ­¨ï ¥¤¨­¨ç­®£® ¢®ªá¥«ï : 2
  4097.         pop ecx ebx
  4098.  
  4099.         cmp ecx,1
  4100.         jl @f ;¢® ¨§¡¥¦ ­¨¥ § æ¨ª«¨¢ ­¨ï
  4101.                 shl eax,cl
  4102.                 shl dword[osn_w_2],cl
  4103.                 shl dword[vox_h],cl
  4104.         @@:
  4105.  
  4106. ;       add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z (ª®¬¯¥­á æ¨ï ¤«ï ª®®à¤¨­ âë y)
  4107.         bt word[edi],0 ;test voxel coord x
  4108.         jnc @f
  4109.                 add ebx,[osn_w_2]
  4110.                 cmp eax,0
  4111.                 jne .end_0
  4112.                         add esi,[osn_w_2] ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
  4113.                         jmp @f
  4114.                 .end_0:
  4115.                 add edx,eax
  4116.                 add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
  4117.         @@:
  4118.         bt word[edi],1 ;test voxel coord y
  4119.         jnc @f
  4120.                 add ebx,[osn_w_2]
  4121.                 cmp eax,0
  4122.                 jne .end_1
  4123.                         sub esi,[osn_w_2] ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
  4124.                         jmp @f
  4125.                 .end_1:
  4126.                 sub edx,eax
  4127.                 sub esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
  4128.         @@:
  4129.         bt word[edi],2 ;test voxel coord z
  4130.         jnc @f
  4131.                 sub edx,[vox_h]
  4132.         @@:
  4133.         pop edi eax
  4134.         .end_f:
  4135.         ret
  4136. endp
  4137.  
  4138. ;¨§¢«¥ª ¥¬ ¨§ h_br 㪠§ â¥«ì ­  ¡ãä¥à á ¨§®¡à ¦¥­¨¥¬ ¢®ªá¥«ï, 㪠§ ­­®£® ¯®à浪  n
  4139. align 4
  4140. proc vox_get_sub_brush uses ebx ecx, h_br:dword, n:dword
  4141.         xor eax,eax
  4142.         mov ebx,[n]
  4143.         cmp ebx,0
  4144.         jl @f
  4145.         mov ecx,[h_br]
  4146.         cmp bl,byte[ecx+3]
  4147.         jg @f
  4148.                 add ecx,4
  4149.                 imul ebx,BUF_STRUCT_SIZE
  4150.                 mov eax,ebx
  4151.                 add eax,ecx
  4152.         @@:
  4153.         ret
  4154. endp
  4155.  
  4156. ;description:
  4157. ; äã­ªæ¨ï à¨áãîé ï á१ ¢®ªá¥«ì­®£® ®¡ì¥ªâ 
  4158. ;input:
  4159. ; v_size - à §¬¥à ª¢ ¤à â  á ¢®ªá¥«¥¬
  4160. ; k_scale - á⥯¥­ì ¤¥â «¨§ æ¨¨ ¨§®¡à ¦¥­¨ï
  4161. ; n_plane - ­®¬¥à ¯«®áª®á⨠á¥ç­¨ï (¢ ¯à¥¤¥« å ®â 0 ¤® 2^k_scale - 1)
  4162. ; b_color - 梥⠣࠭¨æë
  4163. align 4
  4164. proc buf_vox_obj_draw_pl, buf_i:dword, v_obj:dword, coord_x:dword,\
  4165. coord_y:dword, v_size:dword, k_scale:dword, n_plane:dword, b_color:dword
  4166.         cmp [k_scale],0
  4167.         jl .end_f
  4168. pushad
  4169.         mov eax,[v_size]
  4170.         mov ecx,[k_scale]
  4171.         mov ebx,eax
  4172.         cmp ecx,1
  4173.         jl @f
  4174.                 shl ebx,cl
  4175.         @@:
  4176.         ;ebx - ¯®«­ë© à §¬¥à ¨§®¡à ¦¥­¨ï
  4177.         stdcall buf_rect_by_size, [buf_i], [coord_x],[coord_y],ebx,ebx, [b_color] ;à ¬ª  ­  à¨áã­®ª
  4178.         mov edx,ebx
  4179.         add ebx,[coord_y]
  4180.         stdcall draw_polz_hor, [buf_i], [coord_x],ebx,edx,eax, [n_plane], [k_scale], [b_color] ;¯®«§ã­®ª, ¯®ª §ë¢ î騩 ­®¬¥à á¥ç¥­¨ï
  4181.  
  4182.         ;à¨á®¢ ­¨¥ â®ç¥ª ¤«ï á¥âª¨
  4183.         push ecx
  4184.         mov edi,1
  4185.         cmp ecx,1
  4186.         jl @f
  4187.                 shl edi,cl
  4188.         @@:
  4189.         dec edi
  4190.         cmp edi,1
  4191.         jl .end_0
  4192.         mov ecx,edi
  4193.         imul ecx,edi
  4194.         mov ebx,[coord_x]
  4195.         mov edx,[coord_y]
  4196.         add edx,eax
  4197.         xor esi,esi
  4198.         cld
  4199.         @@:
  4200.                 add ebx,eax
  4201.                 inc esi
  4202.                 stdcall buf_set_pixel, [buf_i], ebx,edx, [b_color]
  4203.                 cmp esi,edi
  4204.                 jl .end_1
  4205.                         ;¯¥à¥å®¤ â®ç¥ª ­  ­®¢ãî áâபã
  4206.                         xor esi,esi
  4207.                         mov ebx,[coord_x]
  4208.                         add edx,eax
  4209.                 .end_1:
  4210.                 loop @b
  4211.         .end_0:
  4212.         pop ecx
  4213.  
  4214.         ;eax - à §¬¥à ®¤­®£® ª¢ ¤à â 
  4215.         ;edi - 㪠§ â¥«ì ­  à¨áã¥¬ë¥ ¤ ­­ë¥ ¨§ ®¡ê¥ªâ 
  4216.         mov ebx,[coord_x]
  4217.         mov edx,[coord_y]
  4218.         mov edi,[v_obj]
  4219.         add edi,vox_offs_data
  4220.         xor esi,esi
  4221.         push eax
  4222.         mov eax,1
  4223.         shl eax,cl
  4224.         dec eax
  4225.         sub eax,[n_plane]
  4226.         stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj],eax
  4227. popad
  4228.         .end_f:
  4229.         ret
  4230. endp
  4231.  
  4232. ;description:
  4233. ; äã­ªæ¨ï à¨áãîé ï á१ ç á⨠¢®ªá¥«ì­®£® ®¡ì¥ªâ 
  4234. ;input:
  4235. ; s_c_x, s_c_y, s_c_z, s_k_scale - ¯ à ¬¥âàë ®¯à¥¤¥«ïî騥 ç áâì ¢®ªá¥«ì­®£® ®¡ê¥ªâ , ª®â®à ï ¡ã¤¥â à¨á®¢ âìáï
  4236. align 4
  4237. proc buf_vox_obj_draw_pl_scaled, buf_i:dword, v_obj:dword, coord_x:dword,\
  4238. coord_y:dword, v_size:dword, k_scale:dword, n_plane:dword, b_color:dword,\
  4239. s_c_x:dword, s_c_y:dword, s_c_z:dword, s_k_scale:dword
  4240.         cmp [k_scale],0
  4241.         jl .end_f
  4242. pushad
  4243. locals
  4244.         p_node dd 0 ;த¨â¥«ì᪨© 㧥«
  4245. endl
  4246.         mov eax,[v_size]
  4247.         mov ecx,[k_scale]
  4248.         mov ebx,eax
  4249.         cmp ecx,1
  4250.         jl @f
  4251.                 shl ebx,cl
  4252.         @@:
  4253.         ;ebx - ¯®«­ë© à §¬¥à ¨§®¡à ¦¥­¨ï
  4254.         stdcall buf_rect_by_size, [buf_i], [coord_x],[coord_y],ebx,ebx, [b_color] ;à ¬ª  ­  à¨áã­®ª
  4255.         mov edx,ebx
  4256.         add ebx,[coord_y]
  4257.         stdcall draw_polz_hor, [buf_i], [coord_x],ebx,edx,eax, [n_plane], [k_scale], [b_color] ;¯®«§ã­®ª, ¯®ª §ë¢ î騩 ­®¬¥à á¥ç¥­¨ï
  4258.  
  4259.         ;à¨á®¢ ­¨¥ â®ç¥ª ¤«ï á¥âª¨
  4260.         push ecx
  4261.         mov edi,1
  4262.         cmp ecx,1
  4263.         jl @f
  4264.                 shl edi,cl
  4265.         @@:
  4266.         dec edi
  4267.         cmp edi,1
  4268.         jl .end_3
  4269.         mov ecx,edi
  4270.         imul ecx,edi
  4271.         mov ebx,[coord_x]
  4272.         mov edx,[coord_y]
  4273.         add edx,eax
  4274.         xor esi,esi
  4275.         cld
  4276.         @@:
  4277.                 add ebx,eax
  4278.                 inc esi
  4279.                 stdcall buf_set_pixel, [buf_i], ebx,edx, [b_color]
  4280.                 cmp esi,edi
  4281.                 jl .end_4
  4282.                         ;¯¥à¥å®¤ â®ç¥ª ­  ­®¢ãî áâபã
  4283.                         xor esi,esi
  4284.                         mov ebx,[coord_x]
  4285.                         add edx,eax
  4286.                 .end_4:
  4287.                 loop @b
  4288.         .end_3:
  4289.         pop ecx
  4290.  
  4291.         mov esi,[s_k_scale]
  4292.         cmp esi,1
  4293.         jl .end_2
  4294.         mov edi,[v_obj]
  4295.         add edi,vox_offs_data
  4296.  
  4297.         ; *** (1) ***
  4298.         .found:
  4299.         stdcall vox_obj_get_node_position, [v_obj],[s_c_x],[s_c_y],[s_c_z],esi
  4300.         movzx bx,byte[edi+3]
  4301.         mov [p_node],edi
  4302.         add edi,4
  4303.         cmp eax,0
  4304.         je .end_1
  4305.         mov ecx,eax
  4306.         cld
  4307.         @@: ;横« ¤«ï ¯à®¯ã᪠ ¯à¥¤ë¤ãé¨å ¯®¤¤¥à¥¢ì¥¢ ¢ 㧫¥
  4308.                 bt bx,0 ;¯à®¢¥à塞 ¥áâì «¨ ¤®ç¥à­¨¥ 㧫ë
  4309.                 jnc .end_0
  4310.                         xor eax,eax
  4311.                         stdcall vox_obj_rec0 ;¢ eax ¢ëç¨á«ï¥âáï ç¨á«® ¤®ç¥à­¨å 㧫®¢, ¢ ¤ ­­®© ¢¥â¢¨
  4312.                 .end_0:
  4313.                 shr bx,1
  4314.                 loop @b
  4315.         .end_1:
  4316.         bt bx,0
  4317.         jnc .end_2 ;¥á«¨ ¯®¤¤¥à¥¢  ­¥ áãé¥áâ¢ã¥â
  4318.         dec esi
  4319.         cmp esi,0
  4320.         jg .found
  4321.  
  4322.         mov eax,[v_size]
  4323.         ;eax - à §¬¥à ®¤­®£® ª¢ ¤à â 
  4324.         ;edi - 㪠§ â¥«ì ­  à¨áã¥¬ë¥ ¤ ­­ë¥ ¨§ ®¡ê¥ªâ 
  4325.         mov ecx,[k_scale]
  4326.         mov ebx,[coord_x]
  4327.         mov edx,[coord_y]
  4328.         xor esi,esi
  4329.         push eax
  4330.         mov eax,1
  4331.         shl eax,cl
  4332.         dec eax
  4333.         sub eax,[n_plane]
  4334.         stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj], eax
  4335.  
  4336.         .end_2:
  4337. popad
  4338.         .end_f:
  4339.         ret
  4340. endp
  4341.  
  4342. ;description:
  4343. ; ®¯à¥¤¥«¥­¨¥ ¯®§¨æ¨¨ 㧫  ¢ ¤¥à¥¢¥ (®â 0 ¤® 7)
  4344. align 4
  4345. proc vox_obj_get_node_position uses ebx ecx edi, v_obj:dword,\
  4346. coord_x:dword,coord_y:dword,coord_z:dword,k_scale:dword
  4347.         mov ecx,[k_scale]
  4348.         dec ecx
  4349.         mov eax,[coord_x]
  4350.         mov ebx,[coord_y]
  4351.         mov edi,[coord_z]
  4352.         cmp ecx,1
  4353.         jl .end_0
  4354.                 shr eax,cl
  4355.                 shr ebx,cl
  4356.                 shr edi,cl
  4357.         .end_0:
  4358.         and eax,1
  4359.         bt ebx,0
  4360.         jnc @f
  4361.                 bts eax,1
  4362.         @@:
  4363.         bt edi,0
  4364.         jnc @f
  4365.                 bts eax,2
  4366.         @@:
  4367.  
  4368.         mov edi,[v_obj]
  4369.         add edi,vox_offs_tree_table
  4370.         @@:
  4371.                 cmp al,byte[edi]
  4372.                 je @f
  4373.                 inc edi
  4374.                 jmp @b
  4375.         @@:
  4376.         sub edi,[v_obj]
  4377.         sub edi,vox_offs_tree_table
  4378.         mov eax,edi
  4379.        
  4380.         ret
  4381. endp
  4382.  
  4383. ;input:
  4384. ; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
  4385. ;output:
  4386. ; eax - eax + ç¨á«® 㧫®¢ ¢ ¤ ­­ëå ¢®ªá. ®¡ê¥ªâ 
  4387. ; edi - 㪠§ â¥«ì ­  ᬥ饭­ë¥ ¤ ­­ë¥ ¢®ªá. ®¡ê¥ªâ 
  4388. align 4
  4389. proc vox_obj_rec0
  4390.         inc eax
  4391.         cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
  4392.         je .sub_trees
  4393.  
  4394.                 ;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
  4395.                 push ebx ecx
  4396.                 mov bh,byte[edi+3]
  4397.                 add edi,4
  4398.                 mov bl,8
  4399.                 .cycle:
  4400.                         bt bx,8 ;â¥áâ¨à㥬 ⮫쪮 bh
  4401.                         jnc .c_next
  4402.                                 stdcall vox_obj_rec0
  4403.                         .c_next:
  4404.                         shr bh,1
  4405.                         dec bl
  4406.                         jnz .cycle
  4407.                 pop ecx ebx
  4408.  
  4409.                 jmp .end_f
  4410.         .sub_trees:
  4411.                 add edi,4
  4412.         .end_f:
  4413.         ret
  4414. endp
  4415.  
  4416. ;description:
  4417. ; äã­ªæ¨ï à¨áãîé ï £®à¨§®­â «ì­ãî ¯®«®áã á ¯®«§ã­ª®¬
  4418. align 4
  4419. proc draw_polz_hor uses eax ebx ecx, buf:dword, coord_x:dword, coord_y:dword,\
  4420. size_x:dword, size_y:dword, pos:dword, k_scale:dword, color:dword
  4421.         mov ebx,[size_x]
  4422.         stdcall buf_rect_by_size, [buf], [coord_x],[coord_y],ebx,[size_y], [color]
  4423.         mov ecx,[k_scale]
  4424.         shr ebx,cl
  4425.         mov eax,[pos]
  4426.         imul eax,ebx
  4427.         add eax,[coord_x]
  4428.         stdcall buf_filled_rect_by_size, [buf], eax,[coord_y],ebx,[size_y], [color]
  4429.         ret
  4430. endp
  4431.  
  4432. ;input:
  4433. ; ebx - coord_x
  4434. ; edx - coord_y
  4435. ; esi - coord_z
  4436. ; ecx - ã஢¥­ì ⥪ã襣® 㧫 
  4437. ; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
  4438. align 4
  4439. proc draw_sub_vox_obj_pl, buf_i:dword, v_obj:dword, clip_z:dword,\
  4440. v_size:dword
  4441.         cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
  4442.         je .sub_trees
  4443.  
  4444.                 ;¯à®à¨á®¢ª  à ¬ª¨ ¥á«¨ à §¬¥à 㧫  = 1
  4445.                 cmp ecx,0
  4446.                 jne @f
  4447.                         ;¯à®¢¥àª  £«ã¡¨­ë esi
  4448.                         ;clip_z=n_plane
  4449.                         stdcall vox_is_clip, [clip_z];,[v_size]
  4450.                         cmp eax,0
  4451.                         je @f
  4452.                                 push ecx
  4453.                                 mov ecx,dword[edi]
  4454.                                 and ecx,0xffffff
  4455.                                 stdcall buf_rect_by_size, [buf_i], ebx,edx, [v_size],[v_size],ecx
  4456.                                 pop ecx
  4457.                 @@:
  4458.  
  4459.                 ;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
  4460.                 push edx
  4461.                 ;¢å®¤ ¢­ãâàì 㧫 
  4462.                 dec ecx
  4463.  
  4464.                 mov eax,[v_size]
  4465.                 cmp ecx,1
  4466.                 jl @f
  4467.                         shl eax,cl
  4468.                 @@:
  4469.  
  4470.                 add edx,eax ;ª®à¥ªâ¨à®¢ª  ¢ëá®âë ¯®¤ ¢®ªá¥«ì ­¨¦­¥£® ã஢­ï
  4471.  
  4472.                 mov ah,byte[edi+3]
  4473.                 add edi,4
  4474.                 mov al,8
  4475.                 .cycle:
  4476.                         bt ax,8 ;â¥áâ¨à㥬 ⮫쪮 ah
  4477.                         jnc .c_next
  4478.                                 push eax ebx edx esi
  4479.                                 stdcall vox_corect_coords_pl, [v_obj],[v_size]
  4480.                                 stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj],[clip_z],[v_size]
  4481.                                 pop esi edx ebx eax
  4482.                         .c_next:
  4483.                         shr ah,1
  4484.                         dec al
  4485.                         jnz .cycle
  4486.                 ;¢ë室 ¨§ 㧫 
  4487.                 inc ecx
  4488.                 pop edx
  4489.                 jmp .end_f
  4490.         .sub_trees:
  4491.                 cmp ecx,0
  4492.                 jl .end_0 ;­¥ à¨á㥬 ®ç¥­ì ¬ «¥­ìª¨¥ ¢®ªá¥«¨
  4493.  
  4494.                         ;¯à®¢¥àª  £«ã¡¨­ë esi
  4495.                         ;clip_z=n_plane
  4496.                         stdcall vox_is_clip, [clip_z]
  4497.                         cmp eax,0
  4498.                         je .end_0
  4499.  
  4500.                         ;à¨á㥬 㧥«
  4501.                         mov eax,[edi]
  4502.                         and eax,0xffffff
  4503.                         push eax ;梥â 㧫 
  4504.  
  4505.                         mov eax,[v_size]
  4506.                         cmp ecx,1
  4507.                         jl @f
  4508.                                 ;ª¢ ¤à â ¡®«ìè¥ â¥ªã饣® ¬ áèâ ¡ 
  4509.                                 shl eax,cl ;à §¬¥à 㧫 
  4510.                                 stdcall buf_filled_rect_by_size, [buf_i], ebx,edx, eax,eax
  4511.                                 push ebx edx esi
  4512.                                 mov esi,eax
  4513.                                 inc ebx
  4514.                                 inc edx
  4515.                                 sub esi,2
  4516.                                 mov eax,[buf_i]
  4517.                                 push dword 128
  4518.                                 push dword[eax+16] ;+16 - b_color
  4519.                                 stdcall combine_colors_3,[edi]
  4520.                                 stdcall buf_rect_by_size, [buf_i], ebx,edx, esi,esi,eax
  4521.                                 pop esi edx ebx
  4522.                                 jmp .end_0
  4523.                         @@:
  4524.                                 ;ª¢ ¤à â ⥪ã饣® ¬ áèâ ¡ 
  4525.                                 stdcall buf_filled_rect_by_size, [buf_i], ebx,edx, eax,eax
  4526.                 .end_0:
  4527.                 add edi,4
  4528.         .end_f:
  4529.         ret
  4530. endp
  4531.  
  4532. ;description:
  4533. ; ¢á¯®¬®£ â¥«ì­ ï äã­ªæ¨ï ¤«ï ¯à®¢¥àª¨ £«ã¡¨­ë esi
  4534. ;input:
  4535. ; ecx - ã஢¥­ì ⥪ã襣® 㧫 
  4536. ; esi - coord z
  4537. ; clip_z - n_plane
  4538. ;output:
  4539. ; eax - 0 if no draw, 1 if draw
  4540. align 4
  4541. proc vox_is_clip uses ebx edi, clip_z:dword
  4542.         xor eax,eax
  4543.         mov ebx,[clip_z]
  4544.         mov edi,1
  4545.         cmp ecx,1
  4546.         jl @f
  4547.                 shl edi,cl
  4548.         @@:
  4549.         ;edi = 2^ecx
  4550.         add edi,esi
  4551.         cmp edi,ebx ;if (esi+2^ecx <= n_plane) no draw
  4552.         jle @f
  4553.         inc ebx
  4554.         cmp esi,ebx ;if (esi >= (n_plane+1)) no draw
  4555.         jge @f
  4556.                 inc eax
  4557.         @@:
  4558.         ret
  4559. endp
  4560.  
  4561. ;äã­ªæ¨ï ¤«ï ª®à¥ªâ¨à®¢ª¨ ª®®à¤¨­ â
  4562. ;­ ¯à ¢«¥­¨ï ®á¥© ª®®à¤¨­ â ¢ ¢®ªá¥«¥:
  4563. ;*z
  4564. ;|
  4565. ;+-* x
  4566. ;input:
  4567. ;  al - ­®¬¥à 㧫  ¢ ¤¥à¥¢¥ (®â 1 ¤® 8)
  4568. ; ebx - ª®®à¤¨­ â  x
  4569. ; edx - ª®®à¤¨­ â  y
  4570. ; esi - ª®®à¤¨­ â  z
  4571. ; ecx - ã஢¥­ì ⥪ã襣® 㧫 
  4572. ;output:
  4573. ; ebx - ­®¢ ï ª®®à¤¨­ â  x
  4574. ; edx - ­®¢ ï ª®®à¤¨­ â  y
  4575. ; esi - ­®¢ ï ª®®à¤¨­ â  z
  4576. align 4
  4577. proc vox_corect_coords_pl, v_obj:dword, v_size:dword
  4578.         cmp ecx,0
  4579.         jl .end_f ;¤«ï ã᪮७¨ï ®âà¨á®¢ª¨
  4580.  
  4581.         push eax edi
  4582.         and eax,15 ;¢ë¤¥«ï¥¬ ­®¬¥à 㧫  ¢ ¤¥à¥¢¥
  4583.         mov edi,[v_obj]
  4584.         add edi,vox_offs_tree_table
  4585.         add edi,8
  4586.         sub edi,eax
  4587.  
  4588.         mov eax,[v_size]
  4589.         cmp ecx,1
  4590.         jl @f
  4591.                 shl eax,cl
  4592.         @@:
  4593.  
  4594.         bt word[edi],0 ;test voxel coord x
  4595.         jnc @f
  4596.                 add ebx,eax
  4597.         @@:
  4598.         bt word[edi],2 ;test voxel coord z
  4599.         jnc @f
  4600.                 sub edx,eax
  4601.         @@:
  4602.         bt word[edi],1 ;test voxel coord y
  4603.         jc @f
  4604.                 mov eax,1
  4605.                 cmp ecx,1
  4606.                 jl .end_0
  4607.                         shl eax,cl
  4608.                 .end_0:
  4609.                 add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
  4610.         @@:
  4611.         pop edi eax
  4612.         .end_f:
  4613.         ret
  4614. endp
  4615.  
  4616. ;description:
  4617. ; äã­ªæ¨ï à¨áãîé ï ⥭¨
  4618. ;input:
  4619. ; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
  4620. ; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
  4621. ; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
  4622. ; k_scale - ª®íä. ¤«ï ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
  4623. align 4
  4624. proc buf_vox_obj_draw_3g_shadows, buf_i:dword, buf_z:dword, h_br:dword, \
  4625. coord_x:dword, coord_y:dword, color:dword, k_scale:dword, prop:dword
  4626. locals
  4627.         correct_z dd 0 ;ª®à¥ªâ¨à®¢ª  ¤«ï ¡ãä¥à  £«ã¡¨­ë
  4628. endl
  4629. pushad
  4630.         mov eax,[k_scale]
  4631.         add eax,[prop]
  4632.         mov dword[correct_z],8
  4633.         sub [correct_z],eax
  4634.         mov ebx,[coord_x]
  4635.         ;correct_z = 8-k_scale-prop
  4636.  
  4637.         stdcall buf_vox_obj_get_img_w_3g, [h_br],[k_scale]
  4638.         mov edx,eax ;edx - è¨à¨­  ¨§®¡à ¦¥­¨ï
  4639.         stdcall buf_vox_obj_get_img_h_3g, [h_br],[k_scale]
  4640.         mov esi,eax
  4641.  
  4642.         mov edi,[coord_y]
  4643.         mov ecx,edx
  4644.         add edx,ebx ;è¨à¨­  + ®âáâ㯠᫥¢ 
  4645.         imul ecx,esi
  4646.         cld
  4647.         .cycle_0:
  4648.                 stdcall buf_get_pixel, [buf_z],ebx,edi
  4649.                 cmp eax,0
  4650.                 je @f
  4651.                         stdcall vox_correct_z, [correct_z]
  4652.                         push eax
  4653.                         stdcall buf_get_pixel, [buf_i],ebx,edi
  4654.                         stdcall combine_colors_3,eax,[color] ;,eax
  4655.                         stdcall buf_set_pixel, [buf_i],ebx,edi,eax
  4656.                 @@:
  4657.                 inc ebx
  4658.                 cmp ebx,edx
  4659.                 jl @f
  4660.                         mov ebx,[coord_x]
  4661.                         inc edi
  4662.                 @@:
  4663.                 loop .cycle_0
  4664.  
  4665. popad
  4666.         ret
  4667. endp
  4668.  
  4669. ;output:
  4670. ; eax - scaled coord z
  4671. align 4
  4672. proc vox_correct_z uses ecx, correct_z:dword
  4673.         mov ecx,[correct_z]
  4674.         cmp ecx,0
  4675.         je .end_f
  4676.         jl .end_0
  4677.                 shl eax,cl
  4678.                 jmp .end_f
  4679.         .end_0:
  4680.                 neg ecx
  4681.                 inc ecx
  4682.                 shr eax,cl
  4683.         .end_f:
  4684.         ret
  4685. endp
  4686.  
  4687. ;output:
  4688. ; eax - color
  4689. align 4
  4690. proc combine_colors_3 uses ebx ecx edx edi esi, col_0:dword, col_1:dword, alpha:dword
  4691.  
  4692.         mov ebx,[col_0]
  4693.         mov ecx,[col_1]
  4694.         movzx di,byte[alpha] ;pro
  4695.         mov si,0x00ff ;---get transparent---
  4696.         sub si,di ;256-pro
  4697.  
  4698.         ;---blye---
  4699.         movzx ax,bl
  4700.         imul ax,si
  4701.         movzx dx,cl
  4702.         imul dx,di
  4703.         add ax,dx
  4704.         mov cl,ah
  4705.         ;---green---
  4706.         movzx ax,bh
  4707.         imul ax,si
  4708.         movzx dx,ch
  4709.         imul dx,di
  4710.         add ax,dx
  4711.         mov ch,ah
  4712.         shr ebx,16
  4713.         ror ecx,16
  4714.         ;---red---
  4715.         movzx ax,bl
  4716.         imul ax,si
  4717.         movzx dx,cl
  4718.         imul dx,di
  4719.         add ax,dx
  4720.  
  4721.         shl eax,8
  4722.         ror ecx,16
  4723.         mov ax,cx
  4724.         and eax,0xffffff
  4725.  
  4726.         ret
  4727. endp
  4728.  
  4729. txt_err_n8b db 'need buffer 8 bit',13,10,0
  4730. txt_err_n24b db 'need buffer 24 bit',13,10,0
  4731. txt_err_n32b db 'need buffer 32 bit',13,10,0
  4732. txt_err_n8_24b db 'need buffer 8 or 24 bit',13,10,0
  4733.  
  4734. align 16
  4735. EXPORTS:
  4736.         dd sz_lib_init, lib_init
  4737.         dd sz_buf2d_create, buf_create
  4738.         dd sz_buf2d_create_f_img, buf_create_f_img
  4739.         dd sz_buf2d_clear, buf_clear
  4740.         dd sz_buf2d_draw, buf_draw_buf
  4741.         dd sz_buf2d_delete, buf_delete
  4742.         dd sz_buf2d_resize, buf_resize
  4743.         dd sz_buf2d_rotate, buf_rotate
  4744.         dd sz_buf2d_line, buf_line_brs
  4745.         dd sz_buf2d_line_sm, buf_line_brs_sm
  4746.         dd sz_buf2d_rect_by_size, buf_rect_by_size
  4747.         dd sz_buf2d_filled_rect_by_size, buf_filled_rect_by_size
  4748.         dd sz_buf2d_circle, buf_circle
  4749.         dd sz_buf2d_img_hdiv2, buf_img_hdiv2
  4750.         dd sz_buf2d_img_wdiv2, buf_img_wdiv2
  4751.         dd sz_buf2d_conv_24_to_8, buf_conv_24_to_8
  4752.         dd sz_buf2d_conv_24_to_32, buf_conv_24_to_32
  4753.         dd sz_buf2d_bit_blt, buf_bit_blt
  4754.         dd sz_buf2d_bit_blt_transp, buf_bit_blt_transp
  4755.         dd sz_buf2d_bit_blt_alpha, buf_bit_blt_alpha
  4756.         dd sz_buf2d_curve_bezier, buf_curve_bezier
  4757.         dd sz_buf2d_convert_text_matrix, buf_convert_text_matrix
  4758.         dd sz_buf2d_draw_text, buf_draw_text
  4759.         dd sz_buf2d_crop_color, buf_crop_color
  4760.         dd sz_buf2d_offset_h, buf_offset_h
  4761.         dd sz_buf2d_flood_fill, buf_flood_fill
  4762.         dd sz_buf2d_set_pixel, buf_set_pixel
  4763.         dd sz_buf2d_get_pixel, buf_get_pixel
  4764.         dd sz_buf2d_vox_brush_create, vox_brush_create
  4765.         dd sz_buf2d_vox_brush_delete, vox_brush_delete
  4766.         dd sz_buf2d_vox_obj_get_img_w_3g, buf_vox_obj_get_img_w_3g
  4767.         dd sz_buf2d_vox_obj_get_img_h_3g, buf_vox_obj_get_img_h_3g
  4768.         dd sz_buf2d_vox_obj_draw_1g, buf_vox_obj_draw_1g
  4769.         dd sz_buf2d_vox_obj_draw_3g, buf_vox_obj_draw_3g
  4770.         dd sz_buf2d_vox_obj_draw_3g_scaled, buf_vox_obj_draw_3g_scaled
  4771.         dd sz_buf2d_vox_obj_draw_pl, buf_vox_obj_draw_pl
  4772.         dd sz_buf2d_vox_obj_draw_pl_scaled, buf_vox_obj_draw_pl_scaled
  4773.         dd sz_buf2d_vox_obj_draw_3g_shadows, buf_vox_obj_draw_3g_shadows
  4774.         dd 0,0
  4775.         sz_lib_init db 'lib_init',0
  4776.         sz_buf2d_create db 'buf2d_create',0
  4777.         sz_buf2d_create_f_img db 'buf2d_create_f_img',0
  4778.         sz_buf2d_clear db 'buf2d_clear',0 ;®ç¨á⪠ ¡ãä¥à  㪠§ ­­ë¬ 梥⮬
  4779.         sz_buf2d_draw db 'buf2d_draw',0
  4780.         sz_buf2d_delete db 'buf2d_delete',0
  4781.         sz_buf2d_resize db 'buf2d_resize',0
  4782.         sz_buf2d_rotate db 'buf2d_rotate',0
  4783.         sz_buf2d_line db 'buf2d_line',0 ;à¨á®¢ ­¨¥ «¨­¨¨
  4784.         sz_buf2d_line_sm db 'buf2d_line_sm',0 ;à¨á®¢ ­¨¥ ᣫ ¦¥­­®© «¨­¨¨
  4785.         sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0 ;à¨á®¢ ­¨¥ à ¬ª¨ ¯àאַ㣮«ì­¨ª , 2-ï ª®®à¤¨­ â  § ¤ ­  ¯® à §¬¥àã
  4786.         sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0 ;à¨á®¢ ­¨¥ § «¨â®£® ¯àאַ㣮«ì­¨ª , 2-ï ª®®à¤¨­ â  § ¤ ­  ¯® à §¬¥àã
  4787.         sz_buf2d_circle db 'buf2d_circle',0 ;à¨á®¢ ­¨¥ ®ªà㦭®áâ¨
  4788.         sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0 ;ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® ¢ëá®â¥ ¢ 2 à §  (à §¬¥à ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
  4789.         sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0 ;ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® è¨à¨­¥ ¢ 2 à §  (à §¬¥à ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
  4790.         sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
  4791.         sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
  4792.         sz_buf2d_bit_blt db 'buf2d_bit_blt',0
  4793.         sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
  4794.         sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
  4795.         sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
  4796.         sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
  4797.         sz_buf2d_draw_text db 'buf2d_draw_text',0
  4798.         sz_buf2d_crop_color db 'buf2d_crop_color',0
  4799.         sz_buf2d_offset_h db 'buf2d_offset_h',0
  4800.         sz_buf2d_flood_fill db 'buf2d_flood_fill',0
  4801.         sz_buf2d_set_pixel db 'buf2d_set_pixel',0
  4802.         sz_buf2d_get_pixel db 'buf2d_get_pixel',0
  4803.         sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
  4804.         sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
  4805.         sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
  4806.         sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
  4807.         sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
  4808.         sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0
  4809.         sz_buf2d_vox_obj_draw_3g_scaled db 'buf2d_vox_obj_draw_3g_scaled',0
  4810.         sz_buf2d_vox_obj_draw_pl db 'buf2d_vox_obj_draw_pl',0
  4811.         sz_buf2d_vox_obj_draw_pl_scaled db 'buf2d_vox_obj_draw_pl_scaled',0
  4812.         sz_buf2d_vox_obj_draw_3g_shadows db 'buf2d_vox_obj_draw_3g_shadows',0
  4813.