Subversion Repositories Kolibri OS

Rev

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

  1. ;PUTPIXEL -> RGBPIXEL
  2.  
  3. locals
  4.         n dd ?
  5.         d_x dd ?
  6.         d_y dd ?
  7.         sx dd ? ;ширина буфера в пикселях
  8.         pp_inc_1 dd ?
  9.         pp_inc_2 dd ?
  10.         a dd ? ;register int
  11.         r dd ? ;register unsigned int
  12.         g dd ?
  13.         b dd ?
  14.         rinc dd ? ;register unsigned int
  15.         ginc dd ?
  16.         binc dd ?
  17. if INTERP_Z eq 1
  18.         pz dd ? ;register unsigned short *
  19.         zinc dd ?
  20.         z dd ? ;register int
  21.         zz dd ?
  22. end if
  23. endl
  24. pushad
  25.  
  26.         mov eax,[p1]
  27.         mov ebx,[p2]
  28.         mov ecx,[ebx+offs_zbup_y]
  29.         cmp [eax+offs_zbup_y], ecx ;if (p1.y > p2.y)
  30.         jg @f
  31.         jl .end_0 ;if (p1.y != p2.y)
  32.         mov ecx,[ebx+offs_zbup_x]
  33.         cmp [eax+offs_zbup_x], ecx ;if (p1.x > p2.x)
  34.         jle .end_0 ;if (p1.x <= p2.x)
  35.         @@: ;if (p1.y > p2.y || (p1.y == p2.y && p1.x > p2.x))
  36.                 mov [p1],ebx
  37.                 mov [p2],eax
  38.         .end_0:
  39.  
  40.         mov eax,[zb]
  41.         mov edx,[eax+offs_zbuf_xsize]
  42.         mov [sx],edx
  43.         mov ecx,[p1]
  44.         mov edi,[eax+offs_zbuf_linesize]
  45.         imul edi,[ecx+offs_zbup_y]
  46.         mov edx,[ecx+offs_zbup_x]
  47.         imul edx,PSZB
  48.         add edi,edx
  49.         add edi,[eax+offs_zbuf_pbuf] ;edi = (zb.pbuf + zb.linesize*p1.y + p1.x*PSZB)
  50. if INTERP_Z eq 1
  51.         mov edx,[ecx+offs_zbup_y]
  52.         imul edx,[sx]
  53.         add edx,[ecx+offs_zbup_x]
  54.         add edx,[eax+offs_zbuf_zbuf]
  55.         mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x)
  56.         mov edx,[ecx+offs_zbup_z]
  57.         mov [z],edx ;z = p1.z
  58. end if
  59.  
  60.         mov ebx,[p2]
  61.         mov eax,[ebx+offs_zbup_x]
  62.         sub eax,[ecx+offs_zbup_x]
  63.         mov [d_x],eax ;d_x = p2.x - p1.x
  64.         mov eax,[ebx+offs_zbup_y]
  65.         sub eax,[ecx+offs_zbup_y]
  66.         mov [d_y],eax ;d_y = p2.y - p1.y
  67.  
  68.         mov eax,[ecx+offs_zbup_r]
  69.         shl eax,8
  70.         mov [r],eax ;r = p1.r << 8
  71.         mov eax,[ecx+offs_zbup_g]
  72.         shl eax,8
  73.         mov [g],eax ;g = p1.g << 8
  74.         mov eax,[ecx+offs_zbup_b]
  75.         shl eax,8
  76.         mov [b],eax ;b = p1.b << 8
  77.  
  78. macro RGBPIXEL
  79. {
  80. if TGL_FEATURE_RENDER_BITS eq 24
  81.         mov eax,[r]
  82.         shr eax,16
  83.         mov byte[edi],al
  84.         mov eax,[g]
  85.         shr eax,16
  86.         mov byte[edi+1],al
  87.         mov eax,[b]
  88.         shr eax,16
  89.         mov byte[edi+2],al
  90. ;;;     else
  91. ;*pp = RGB_TO_PIXEL(r >> 8,g >> 8,b >> 8)
  92. end if
  93. }
  94.  
  95. macro PUTPIXEL
  96. {
  97. if INTERP_Z eq 1
  98. local .end_0
  99.         mov eax,[z]
  100.         shr eax, ZB_POINT_Z_FRAC_BITS
  101.         mov [zz],eax
  102.         cmp eax,[pz]
  103.         jl .end_0
  104.                 RGBPIXEL
  105.                 mov eax,dword[zz]
  106.                 mov [pz],eax
  107.         .end_0:
  108. else ; INTERP_Z
  109.         RGBPIXEL
  110. end if ; INTERP_Z
  111. }
  112.  
  113. macro DRAWLINE d_x,d_y,inc_1,inc_2
  114. {
  115.         mov eax,d_x
  116.         mov [n],eax
  117.  
  118.         mov ebx,[p1]
  119.         mov ecx,[p2]
  120. if INTERP_Z eq 1
  121.         mov eax,[ecx+offs_zbup_z]
  122.         sub eax,[ebx+offs_zbup_z]
  123.         xor edx,edx
  124.         div dword[n]
  125.         mov [zinc],eax ;zinc=(p2.z-p1.z)/n
  126. end if
  127.  
  128.         ;ebx=&p1, ecx=&p2
  129.         mov eax,[ecx+offs_zbup_r]
  130.         sub eax,[ebx+offs_zbup_r]
  131.         shl eax,8
  132.         xor edx,edx
  133.         div dword[n]
  134.         mov [rinc],eax ;rinc=((p2.r-p1.r)<<8)/n
  135.  
  136.         mov eax,[ecx+offs_zbup_g]
  137.         sub eax,[ebx+offs_zbup_g]
  138.         shl eax,8
  139.         xor edx,edx
  140.         div dword[n]
  141.         mov [ginc],eax ;ginc=((p2.g-p1.g)<<8)/n
  142.  
  143.         mov eax,[ecx+offs_zbup_b]
  144.         sub eax,[ebx+offs_zbup_b]
  145.         shl eax,8
  146.         xor edx,edx
  147.         div dword[n]
  148.         mov [binc],eax ;binc=((p2.b-p1.b)<<8)/n
  149.  
  150.         shl dword d_y,1
  151.         mov eax, d_y
  152.         sub eax, d_x
  153.         mov [a],eax ;a=2*d_y-d_x
  154.         shl dword d_x,1
  155.         mov eax, d_y
  156.         sub d_x,eax
  157.         mov eax,inc_1
  158.         imul eax,PSZB
  159.         mov [pp_inc_1],eax ;pp_inc_1 = inc_1*PSZB
  160.         mov eax,inc_2
  161.         imul eax,PSZB
  162.         mov [pp_inc_2],eax ;pp_inc_2 = inc_2*PSZB
  163.  
  164. local .do_cycle
  165. local .els_0
  166. local .end_0
  167.  
  168. align 4
  169. .do_cycle:
  170.  
  171.         PUTPIXEL
  172. if INTERP_Z eq 1
  173.         mov eax,[zinc]
  174.         add [z],eax
  175. end if
  176.         mov eax,[rinc]
  177.         add [r],eax
  178.         mov eax,[ginc]
  179.         add [g],eax
  180.         mov eax,[binc]
  181.         add [b],eax
  182.  
  183.         cmp dword[a],0
  184.         jle .els_0
  185.         add edi,[pp_inc_1]
  186. if INTERP_Z eq 1
  187.         mov eax,inc_1
  188.         add [pz],eax
  189. end if
  190.         mov eax,d_x
  191.         sub [a],eax
  192.         jmp .end_0
  193.  
  194. .els_0:
  195.         add edi,[pp_inc_2]
  196. if INTERP_Z eq 1
  197.         mov eax,inc_2
  198.         add [pz],eax
  199. end if
  200.         mov eax,d_y
  201.         add [a],eax
  202.  
  203. .end_0:
  204.         dec dword[n]
  205.         cmp dword[n],0
  206.         jge .do_cycle
  207. }
  208.  
  209. ; fin macro
  210.  
  211.         mov eax,[d_x]
  212.         cmp eax,0
  213.         jne .els_0
  214.         cmp dword[d_y],0
  215.         jne .els_0
  216.                 ;if (d_x==0 && d_y==0)
  217.                 PUTPIXEL
  218.                 jmp .end_2
  219.         .els_0:
  220.         cmp eax,0
  221.         jle .els_3
  222.                 ;if (d_x > 0)
  223.                 mov esi,[sx]
  224.                 inc esi
  225.                 cmp eax,[d_y]
  226.                 jl .els_2
  227.                         ;if (d_x >= d_y)
  228.                         DRAWLINE [d_x], [d_y], esi, 1
  229.                         jmp .end_2
  230.                 .els_2:
  231.                         DRAWLINE [d_y], [d_x], esi, [sx]
  232.                         jmp .end_2
  233.         .els_3:
  234.                 xor eax,eax
  235.                 sub eax,[d_x]
  236.                 mov [d_x],eax
  237.                 mov esi,[sx]
  238.                 dec esi
  239.                 cmp eax,[d_y]
  240.                 jl .els_4
  241.                         ;if (d_x >= d_y)
  242.                         DRAWLINE [d_x], [d_y], esi, -1
  243.                         jmp .end_2
  244.                 .els_4:
  245.                         DRAWLINE [d_y], [d_x], esi, [sx]
  246.         .end_2:
  247.  
  248. popad
  249.         ret
  250. endp
  251.  
  252. restore INTERP_Z
  253.  
  254. ; internal defines
  255. purge DRAWLINE
  256. purge PUTPIXEL
  257. purge RGBPIXEL
  258.