1) fix rgb interpolation and z-buffer

2) add function glClear

git-svn-id: svn://kolibrios.org@5159 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2014-11-03 13:16:54 +00:00
parent f38db0969e
commit 755cc27ea4
8 changed files with 631 additions and 135 deletions

View File

@ -18,17 +18,30 @@ proc glopClearDepth uses eax ebx, context:dword, p:dword
ret ret
endp endp
;void glopClear(GLContext *c,GLParam *p) align 4
;{ proc glopClear uses eax ebx, context:dword, p:dword
; int mask=p[1].i; mov eax,[context]
; int z=0; mov ebx,[eax+offs_cont_clear_color+8] ;context.clear_color.v[2]
; int r=(int)(c->clear_color.v[0]*65535); shl ebx,16
; int g=(int)(c->clear_color.v[1]*65535); push ebx
; int b=(int)(c->clear_color.v[2]*65535); mov ebx,[eax+offs_cont_clear_color+4] ;context.clear_color.v[1]
; shl ebx,16
; /* TODO : correct value of Z */ push ebx
; mov ebx,[eax+offs_cont_clear_color] ;context.clear_color.v[0]
; ZB_clear(c->zb,mask & GL_DEPTH_BUFFER_BIT,z, shl ebx,16
; mask & GL_COLOR_BUFFER_BIT,r,g,b); push ebx
;}
mov ebx,[p]
mov ebx,[ebx+4] ;ebx = p[1]
and ebx,GL_COLOR_BUFFER_BIT
push ebx
mov ebx,[p]
mov ebx,[ebx+4] ;ebx = p[1]
and ebx,GL_DEPTH_BUFFER_BIT
; TODO : correct value of Z
stdcall ZB_clear,[eax+offs_cont_zb],ebx,0 ;,...,r,g,b
ret
endp

View File

@ -0,0 +1,173 @@
use32
org 0x0
db 'MENUET01'
dd 0x1
dd start
dd i_end
dd mem,stacktop
dd 0,cur_dir_path
include '../../../../../../programs/proc32.inc'
include '../../../../../../programs/macros.inc'
include '../../../../../../programs/develop/libraries/box_lib/load_lib.mac'
include '../../../../../../programs/dll.inc'
include '../opengl_const.inc'
@use_library
align 4
start:
load_library name_tgl, cur_dir_path, library_path, system_path, \
err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
cmp eax,-1
jz button.exit
mcall 40,0x27
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
stdcall [glEnable], GL_DEPTH_TEST
call draw_3d
align 4
red_win:
call draw_window
align 4
still:
mcall 10
cmp al,1
jz red_win
cmp al,2
jz key
cmp al,3
jz button
jmp still
align 4
draw_window:
pushad
mcall 12,1
mov edx,0x33ffffff ;0x73ffffff
mcall 0,(50 shl 16)+330,(30 shl 16)+275,,,caption
stdcall [kosglSwapBuffers]
mcall 12,2
popad
ret
align 4
key:
mcall 2
cmp ah,27 ;Esc
je button.exit
;178 ;Up
;177 ;Down
cmp ah,176 ;Left
jne @f
fld dword[angle_z]
fadd dword[delt_size]
fstp dword[angle_z]
call draw_3d
stdcall [kosglSwapBuffers]
@@:
cmp ah,179 ;Right
jne @f
fld dword[angle_z]
fsub dword[delt_size]
fstp dword[angle_z]
call draw_3d
stdcall [kosglSwapBuffers]
@@:
jmp still
align 4
button:
mcall 17
cmp ah,1
jne still
.exit:
mcall -1
align 4
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
align 4
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
;sizeof.TinyGLContext = 28
align 4
draw_3d:
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
stdcall [glPushMatrix]
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
stdcall [glColor3f],1.0, 0.0, 0.0
stdcall [glBegin],GL_POINTS
stdcall [glVertex3f], 0.0, 0.5, 0.1
stdcall [glVertex3f], 0.354, 0.354, 0.1
stdcall [glVertex3f], 0.5, 0.0, 0.1
stdcall [glVertex3f], 0.354, -0.354, 0.1
stdcall [glVertex3f], 0.0, -0.5, 0.1
stdcall [glVertex3f], -0.354,-0.354, 0.1
stdcall [glVertex3f], -0.5, 0.0, 0.1
stdcall [glVertex3f], -0.354, 0.354, 0.1
stdcall [glEnd]
stdcall [glBegin],GL_LINES
stdcall [glVertex3f], 0, 0.7, 0.3
stdcall [glVertex3f], 0.495, 0.495, 0.7
stdcall [glVertex3f], 0.7, 0.0, 0.3
stdcall [glColor3f],1.0, 1.0, 0.0
stdcall [glVertex3f], 0.495, -0.495, 0.7
stdcall [glVertex3f], 0.0, -0.7, 0.3
stdcall [glVertex3f], -0.495,-0.495, 0.7
stdcall [glVertex3f], -0.7, 0.0, 0.3
stdcall [glColor3f],1.0, 0.0, 0.0
stdcall [glVertex3f], -0.495, 0.495, 0.7
stdcall [glEnd]
stdcall [glPopMatrix]
ret
angle_z dd 0.0
delt_size dd 3.0
;--------------------------------------------------
align 4
import_lib_tinygl:
macro E_LIB n
{
n dd sz_#n
}
include '../export.inc'
dd 0,0
macro E_LIB n
{
sz_#n db `n,0
}
include '../export.inc'
;--------------------------------------------------
system_path db '/sys/lib/'
name_tgl db 'tinygl.obj',0
err_message_found_lib db 'Sorry I cannot load library tinygl.obj',0
head_f_i:
head_f_l db 'System error',0
err_message_import db 'Error on load import library tinygl.obj',0
;--------------------------------------------------
i_end:
rb 1024
stacktop:
cur_dir_path:
rb 4096
library_path:
rb 4096
mem:

View File

@ -0,0 +1,174 @@
use32
org 0x0
db 'MENUET01'
dd 0x1
dd start
dd i_end
dd mem,stacktop
dd 0,cur_dir_path
include '../../../../../../programs/proc32.inc'
include '../../../../../../programs/macros.inc'
include '../../../../../../programs/develop/libraries/box_lib/load_lib.mac'
include '../../../../../../programs/dll.inc'
include '../opengl_const.inc'
@use_library
align 4
start:
load_library name_tgl, cur_dir_path, library_path, system_path, \
err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
cmp eax,-1
jz button.exit
mcall 40,0x27
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
stdcall [glEnable], GL_DEPTH_TEST
call draw_3d
align 4
red_win:
call draw_window
align 4
still:
mcall 10
cmp al,1
jz red_win
cmp al,2
jz key
cmp al,3
jz button
jmp still
align 4
draw_window:
pushad
mcall 12,1
mov edx,0x33ffffff ;0x73ffffff
mcall 0,(50 shl 16)+330,(30 shl 16)+275,,,caption
stdcall [kosglSwapBuffers]
mcall 12,2
popad
ret
align 4
key:
mcall 2
cmp ah,27 ;Esc
je button.exit
;178 ;Up
;177 ;Down
cmp ah,176 ;Left
jne @f
fld dword[angle_z]
fadd dword[delt_size]
fstp dword[angle_z]
call draw_3d
stdcall [kosglSwapBuffers]
@@:
cmp ah,179 ;Right
jne @f
fld dword[angle_z]
fsub dword[delt_size]
fstp dword[angle_z]
call draw_3d
stdcall [kosglSwapBuffers]
@@:
jmp still
align 4
button:
mcall 17
cmp ah,1
jne still
.exit:
mcall -1
align 4
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
align 4
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
;sizeof.TinyGLContext = 28
align 4
draw_3d:
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
stdcall [glPushMatrix]
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
stdcall [glScalef], 0.3,0.3,0.3
stdcall [glColor3f],1.0, 0.0, 0.0
stdcall [glBegin],GL_LINE_LOOP
stdcall [glVertex3f], 0, 0.9, 0.1
stdcall [glVertex3f], 0.636, 0.636, 0.1
stdcall [glVertex3f], 0.9, 0.0, 0.1
stdcall [glVertex3f], 0.636, -0.636, 0.1
stdcall [glColor3f],0.0, 0.0, 1.0
stdcall [glVertex3f], 0.0, -0.9, 0.1
stdcall [glVertex3f], -0.636,-0.636, 0.1
stdcall [glVertex3f], -0.9, 0.0, 0.1
stdcall [glVertex3f], -0.636, 0.636, 0.1
stdcall [glEnd]
stdcall [glBegin],GL_LINE_LOOP
stdcall [glVertex3f], 0.0, 1.1, 0.1
stdcall [glVertex3f], 0.778, 0.778, 0.1
stdcall [glVertex3f], 2.1, 0.0, 0.1
stdcall [glVertex3f], 0.778, -0.778, 0.1
stdcall [glVertex3f], 0.0, -1.1, 0.1
stdcall [glVertex3f], -0.778, -0.778, 0.1
stdcall [glVertex3f], -2.1, 0.0, 0.1
stdcall [glVertex3f], -0.778, 0.778, 0.1
stdcall [glEnd]
stdcall [glPopMatrix]
ret
angle_z dd 0.0
delt_size dd 3.0
;--------------------------------------------------
align 4
import_lib_tinygl:
macro E_LIB n
{
n dd sz_#n
}
include '../export.inc'
dd 0,0
macro E_LIB n
{
sz_#n db `n,0
}
include '../export.inc'
;--------------------------------------------------
system_path db '/sys/lib/'
name_tgl db 'tinygl.obj',0
err_message_found_lib db 'Sorry I cannot load library tinygl.obj',0
head_f_i:
head_f_l db 'System error',0
err_message_import db 'Error on load import library tinygl.obj',0
;--------------------------------------------------
i_end:
rb 1024
stacktop:
cur_dir_path:
rb 4096
library_path:
rb 4096
mem:

View File

@ -74,7 +74,6 @@ glGetFloatv: ;(int pname, float *v)
; *** ; ***
glopLight: glopLight:
glopClear:
glopCallList: glopCallList:
if DEBUG if DEBUG

View File

@ -57,7 +57,7 @@ end if
mov ecx,[edi+offs_zbuf_xsize] mov ecx,[edi+offs_zbuf_xsize]
imul ecx,[edi+offs_zbuf_ysize] imul ecx,[edi+offs_zbuf_ysize]
shl ecx,2 ;*= sizeof(unsigned short) shl ecx,1 ;*= sizeof(unsigned short)
stdcall gl_malloc, ecx stdcall gl_malloc, ecx
mov [edi+offs_zbuf_zbuf],eax mov [edi+offs_zbuf_zbuf],eax
@ -115,7 +115,7 @@ proc ZB_resize uses eax ebx ecx edi esi, zb:dword, frame_buffer:dword, xsize:dwo
mov ecx,edi mov ecx,edi
imul ecx,esi imul ecx,esi
shl ecx,2 ;*= sizeof(unsigned short) shl ecx,1 ;*= sizeof(unsigned short)
stdcall gl_free,dword[ebx+offs_zbuf_zbuf] stdcall gl_free,dword[ebx+offs_zbuf_zbuf]
stdcall gl_malloc,ecx stdcall gl_malloc,ecx
@ -432,114 +432,135 @@ endp
;} ;}
; ;
;#endif /* TGL_FEATURE_RENDER_BITS == 32 */ ;#endif /* TGL_FEATURE_RENDER_BITS == 32 */
; ;
; adr must be aligned on an 'int'
; ;
;/* align 4
; * adr must be aligned on an 'int' proc memset_s uses eax ecx edi, adr:dword, val:dword, count:dword
; */ mov eax,[val]
;void memset_s(void *adr, int val, int count) mov di,ax
;{ ror eax,16
; int i, n, v; mov ax,di
; unsigned int *p; mov ecx,[count]
; unsigned short *q; shr ecx,1
; mov edi,[adr]
; p = adr; rep stosd
; v = val | (val << 16);
; bt dword[count],0
; n = count >> 3; jnc @f
; for (i = 0; i < n; i++) { stosw
; p[0] = v; @@:
; p[1] = v; ret
; p[2] = v; endp
; p[3] = v;
; p += 4; align 4
; } proc memset_l uses eax ecx edi, adr:dword, val:dword, count:dword
; mov eax,[val]
; q = (unsigned short *) p; mov ecx,[count]
; n = count & 7; mov edi,[adr]
; for (i = 0; i < n; i++) rep stosd
; *q++ = val; ret
;} endp
;
;void memset_l(void *adr, int val, int count) ; count must be a multiple of 4 and >= 4
;{ align 4
; int i, n, v; proc memset_RGB24 uses eax ecx edi esi, adr:dword, r:dword, g:dword, b:dword, count:dword
; unsigned int *p; mov esi,[adr]
; mov eax,[r] ;копируем в буфер первые 12 байт (минимальное число кратное 3 и 4)
; p = adr; mov byte[esi],al
; v = val; mov byte[esi+3],al
; n = count >> 2; mov byte[esi+6],al
; for (i = 0; i < n; i++) { mov byte[esi+9],al
; p[0] = v; mov eax,[g]
; p[1] = v; mov byte[esi+1],al
; p[2] = v; mov byte[esi+4],al
; p[3] = v; mov byte[esi+7],al
; p += 4; mov byte[esi+10],al
; } mov eax,[b]
; mov byte[esi+2],al
; n = count & 3; mov byte[esi+5],al
; for (i = 0; i < n; i++) mov byte[esi+8],al
; *p++ = val; mov byte[esi+11],al
;}
; mov ecx,[count]
;/* count must be a multiple of 4 and >= 4 */ shr ecx,2
;void memset_RGB24(void *adr,int r, int v, int b,long count) cmp ecx,1
;{ jle .end_f ;если ширина буфера меньше 12 байт, то выходим
; long i, n; dec ecx
; register long v1,v2,v3,*pt=(long *)(adr); mov edi,esi
; unsigned char *p,R=(unsigned char)r,V=(unsigned char)v,B=(unsigned char)b; add edi,12
;
; p=(unsigned char *)adr; mov eax,[esi]
; *p++=R; cmp eax,[esi+4]
; *p++=V; jne @f
; *p++=B; ;если r=g и g=b и b=r
; *p++=R; mov esi,ecx
; *p++=V; shl ecx,2
; *p++=B; sub ecx,esi ;ecx*=3
; *p++=R; rep stosd
; *p++=V; jmp .end_f
; *p++=B; @@:
; *p++=R;
; *p++=V; ;если r!=g или g!=b или b!=r
; *p++=B; @@:
; v1=*pt++; movsd
; v2=*pt++; movsd
; v3=*pt++; movsd
; n = count >> 2; sub esi,12
; for(i=1;i<n;i++) { loop @b
; *pt++=v1; .end_f:
; *pt++=v2; ret
; *pt++=v3; endp
; }
;} align 4
; proc ZB_clear uses eax ebx ecx, zb:dword, clear_z:dword, z:dword, clear_color:dword,\
;void ZB_clear(ZBuffer * zb, int clear_z, int z, r:dword, g:dword, b:dword
; int clear_color, int r, int g, int b) ;if TGL_FEATURE_RENDER_BITS != 24
;{ ; color dd ?
;#if TGL_FEATURE_RENDER_BITS != 24 ;end if
; int color;
;#endif mov eax,[zb]
; int y; cmp dword[clear_z],0
; PIXEL *pp; je @f
; mov ebx,[eax+offs_zbuf_xsize]
; if (clear_z) { imul ebx,[eax+offs_zbuf_ysize]
; memset_s(zb->zbuf, z, zb->xsize * zb->ysize); stdcall memset_s, [eax+offs_zbuf_zbuf],[z],ebx
; } @@:
; if (clear_color) { cmp dword[clear_color],0
; pp = zb->pbuf; je @f
; for (y = 0; y < zb->ysize; y++) { if TGL_FEATURE_RENDER_BITS eq 24
;#if TGL_FEATURE_RENDER_BITS == 15 || TGL_FEATURE_RENDER_BITS == 16 mov ebx,[eax+offs_zbuf_xsize]
; color = RGB_TO_PIXEL(r, g, b); push ebx
; memset_s(pp, color, zb->xsize); mov ebx,[b]
;#elif TGL_FEATURE_RENDER_BITS == 32 shr ebx,8
; color = RGB_TO_PIXEL(r, g, b); push ebx
; memset_l(pp, color, zb->xsize); mov ebx,[g]
;#elif TGL_FEATURE_RENDER_BITS == 24 shr ebx,8
; memset_RGB24(pp,r>>8,g>>8,b>>8,zb->xsize); push ebx
;#else mov ebx,[r]
;#error TODO shr ebx,8
;#endif push ebx
; pp = (PIXEL *) ((char *) pp + zb->linesize); add esp,16
; } end if
; } mov ebx,[eax+offs_zbuf_pbuf]
;} mov ecx,[eax+offs_zbuf_ysize]
.cycle_0:
if (TGL_FEATURE_RENDER_BITS eq 15) ;or (TGL_FEATURE_RENDER_BITS eq 16)
;color = RGB_TO_PIXEL(r, g, b);
;memset_s(ebx, color, zb->xsize);
end if
if TGL_FEATURE_RENDER_BITS eq 32
;color = RGB_TO_PIXEL(r, g, b);
;memset_l(ebx, color, zb->xsize);
end if
if TGL_FEATURE_RENDER_BITS eq 24
sub esp,16
stdcall memset_RGB24,ebx
end if
add ebx,[eax+offs_zbuf_linesize]
loop .cycle_0
@@:
ret
endp

View File

@ -6,6 +6,7 @@ proc ZB_plot uses eax ebx ecx edx edi, zb:dword, p:dword
mov ecx,[ebx+offs_zbup_y] mov ecx,[ebx+offs_zbup_y]
imul ecx,[eax+offs_zbuf_xsize] imul ecx,[eax+offs_zbuf_xsize]
add ecx,[ebx+offs_zbup_x] add ecx,[ebx+offs_zbup_x]
shl ecx,1
add ecx,[eax+offs_zbuf_zbuf] add ecx,[eax+offs_zbuf_zbuf]
mov edx,[eax+offs_zbuf_linesize] mov edx,[eax+offs_zbuf_linesize]
imul edx,[ebx+offs_zbup_y] imul edx,[ebx+offs_zbup_y]
@ -15,7 +16,7 @@ proc ZB_plot uses eax ebx ecx edx edi, zb:dword, p:dword
add edx,[eax+offs_zbuf_pbuf] add edx,[eax+offs_zbuf_pbuf]
mov edi,[ebx+offs_zbup_z] mov edi,[ebx+offs_zbup_z]
shr edi,ZB_POINT_Z_FRAC_BITS shr edi,ZB_POINT_Z_FRAC_BITS
cmp edi,[ecx] cmp di,word[ecx]
jl .end_f jl .end_f
if TGL_FEATURE_RENDER_BITS eq 24 if TGL_FEATURE_RENDER_BITS eq 24
mov eax,[ebx+offs_zbup_r] mov eax,[ebx+offs_zbup_r]
@ -27,7 +28,7 @@ if TGL_FEATURE_RENDER_BITS eq 24
else else
; *pp = RGB_TO_PIXEL(p->r, p->g, p->b); ; *pp = RGB_TO_PIXEL(p->r, p->g, p->b);
end if end if
mov [ecx],edi mov word[ecx],di
.end_f: .end_f:
ret ret
endp endp

View File

@ -50,6 +50,7 @@ if INTERP_Z eq 1
mov edx,[ecx+offs_zbup_y] mov edx,[ecx+offs_zbup_y]
imul edx,[sx] imul edx,[sx]
add edx,[ecx+offs_zbup_x] add edx,[ecx+offs_zbup_x]
shl edx,1
add edx,[eax+offs_zbuf_zbuf] add edx,[eax+offs_zbuf_zbuf]
mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x) mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x)
mov edx,[ecx+offs_zbup_z] mov edx,[ecx+offs_zbup_z]
@ -98,28 +99,51 @@ local .end_0
mov eax,[z] mov eax,[z]
shr eax, ZB_POINT_Z_FRAC_BITS shr eax, ZB_POINT_Z_FRAC_BITS
mov [zz],eax mov [zz],eax
cmp eax,[pz] mov ebx,[pz]
cmp ax,word[ebx]
jl .end_0 jl .end_0
RGBPIXEL RGBPIXEL
mov eax,dword[zz] mov eax,dword[zz]
mov [pz],eax mov ebx,[pz]
mov word[ebx],ax
.end_0: .end_0:
else ; INTERP_Z else
RGBPIXEL RGBPIXEL
end if ; INTERP_Z end if
} }
macro DRAWLINE d_x,d_y,inc_1,inc_2 macro DRAWLINE d_x,d_y,inc_1,inc_2
{ {
local .mz_0
local .mz_1
local .mz_2
mov eax,d_x mov eax,d_x
mov [n],eax mov [n],eax
if INTERP_Z eq 1 if INTERP_Z eq 1
mov ebx,[p1] mov ebx,[p1]
mov eax,[p2] mov eax,[p2]
mov eax,[eax+offs_zbup_z] mov eax,[eax+offs_zbup_z]
cmp eax,[ebx+offs_zbup_z]
jg .mz_0
je .mz_1
;if(p2.z<p1.z)
sub eax,[ebx+offs_zbup_z]
neg eax
inc eax
xor edx,edx
div dword[n]
neg eax
inc eax
jmp .mz_2
.mz_0:
sub eax,[ebx+offs_zbup_z] sub eax,[ebx+offs_zbup_z]
xor edx,edx xor edx,edx
div dword[n] div dword[n]
jmp .mz_2
.mz_1:
xor eax,eax
.mz_2:
mov [zinc],eax ;zinc=(p2.z-p1.z)/n mov [zinc],eax ;zinc=(p2.z-p1.z)/n
end if end if
shl dword d_y,1 shl dword d_y,1
@ -154,6 +178,7 @@ end if
add edi,[pp_inc_1] add edi,[pp_inc_1]
if INTERP_Z eq 1 if INTERP_Z eq 1
mov eax,inc_1 mov eax,inc_1
shl eax,1
add [pz],eax add [pz],eax
end if end if
mov eax,d_x mov eax,d_x
@ -164,6 +189,7 @@ end if
add edi,[pp_inc_2] add edi,[pp_inc_2]
if INTERP_Z eq 1 if INTERP_Z eq 1
mov eax,inc_2 mov eax,inc_2
shl eax,1
add [pz],eax add [pz],eax
end if end if
mov eax,d_y mov eax,d_y

View File

@ -51,6 +51,7 @@ if INTERP_Z eq 1
mov edx,[ecx+offs_zbup_y] mov edx,[ecx+offs_zbup_y]
imul edx,[sx] imul edx,[sx]
add edx,[ecx+offs_zbup_x] add edx,[ecx+offs_zbup_x]
shl edx,1
add edx,[eax+offs_zbuf_zbuf] add edx,[eax+offs_zbuf_zbuf]
mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x) mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x)
mov edx,[ecx+offs_zbup_z] mov edx,[ecx+offs_zbup_z]
@ -99,19 +100,34 @@ local .end_0
mov eax,[z] mov eax,[z]
shr eax, ZB_POINT_Z_FRAC_BITS shr eax, ZB_POINT_Z_FRAC_BITS
mov [zz],eax mov [zz],eax
cmp eax,[pz] mov ebx,[pz]
cmp ax,word[ebx]
jl .end_0 jl .end_0
RGBPIXEL RGBPIXEL
mov eax,dword[zz] mov eax,dword[zz]
mov [pz],eax mov ebx,[pz]
mov word[ebx],ax
.end_0: .end_0:
else ; INTERP_Z else
RGBPIXEL RGBPIXEL
end if ; INTERP_Z end if
} }
macro DRAWLINE d_x,d_y,inc_1,inc_2 macro DRAWLINE d_x,d_y,inc_1,inc_2
{ {
local .mz_0
local .mz_1
local .mz_2
local .mr_0
local .mr_1
local .mr_2
local .mg_0
local .mg_1
local .mg_2
local .mb_0
local .mb_1
local .mb_2
mov eax,d_x mov eax,d_x
mov [n],eax mov [n],eax
@ -119,32 +135,103 @@ macro DRAWLINE d_x,d_y,inc_1,inc_2
mov ecx,[p2] mov ecx,[p2]
if INTERP_Z eq 1 if INTERP_Z eq 1
mov eax,[ecx+offs_zbup_z] mov eax,[ecx+offs_zbup_z]
cmp eax,[ebx+offs_zbup_z]
jg .mz_0
je .mz_1
;if(p2.z<p1.z)
sub eax,[ebx+offs_zbup_z]
neg eax
inc eax
xor edx,edx
div dword[n]
neg eax
inc eax
jmp .mz_2
.mz_0:
sub eax,[ebx+offs_zbup_z] sub eax,[ebx+offs_zbup_z]
xor edx,edx xor edx,edx
div dword[n] div dword[n]
jmp .mz_2
.mz_1:
xor eax,eax
.mz_2:
mov [zinc],eax ;zinc=(p2.z-p1.z)/n mov [zinc],eax ;zinc=(p2.z-p1.z)/n
end if end if
;ebx=&p1, ecx=&p2 ;ebx=&p1, ecx=&p2
mov eax,[ecx+offs_zbup_r] mov eax,[ecx+offs_zbup_r]
cmp eax,[ebx+offs_zbup_r]
jg .mr_0
je .mr_1
;if(p2.r<p1.r)
sub eax,[ebx+offs_zbup_r]
neg eax
inc eax
shl eax,8
xor edx,edx
div dword[n]
neg eax
inc eax
jmp .mr_2
.mr_0:
sub eax,[ebx+offs_zbup_r] sub eax,[ebx+offs_zbup_r]
shl eax,8 shl eax,8
xor edx,edx xor edx,edx
div dword[n] div dword[n]
jmp .mr_2
.mr_1:
xor eax,eax
.mr_2:
mov [rinc],eax ;rinc=((p2.r-p1.r)<<8)/n mov [rinc],eax ;rinc=((p2.r-p1.r)<<8)/n
mov eax,[ecx+offs_zbup_g] mov eax,[ecx+offs_zbup_g]
cmp eax,[ebx+offs_zbup_g]
jg .mg_0
je .mg_1
;if(p2.g<p1.g)
sub eax,[ebx+offs_zbup_g]
neg eax
inc eax
shl eax,8
xor edx,edx
div dword[n]
neg eax
inc eax
jmp .mg_2
.mg_0:
sub eax,[ebx+offs_zbup_g] sub eax,[ebx+offs_zbup_g]
shl eax,8 shl eax,8
xor edx,edx xor edx,edx
div dword[n] div dword[n]
jmp .mg_2
.mg_1:
xor eax,eax
.mg_2:
mov [ginc],eax ;ginc=((p2.g-p1.g)<<8)/n mov [ginc],eax ;ginc=((p2.g-p1.g)<<8)/n
mov eax,[ecx+offs_zbup_b] mov eax,[ecx+offs_zbup_b]
cmp eax,[ebx+offs_zbup_b]
jg .mb_0
je .mb_1
;if(p2.b<p1.b)
sub eax,[ebx+offs_zbup_b]
neg eax
inc eax
shl eax,8
xor edx,edx
div dword[n]
neg eax
inc eax
jmp .mb_2
.mb_0:
sub eax,[ebx+offs_zbup_b] sub eax,[ebx+offs_zbup_b]
shl eax,8 shl eax,8
xor edx,edx xor edx,edx
div dword[n] div dword[n]
jmp .mb_2
.mb_1:
xor eax,eax
.mb_2:
mov [binc],eax ;binc=((p2.b-p1.b)<<8)/n mov [binc],eax ;binc=((p2.b-p1.b)<<8)/n
shl dword d_y,1 shl dword d_y,1
@ -185,6 +272,7 @@ end if
add edi,[pp_inc_1] add edi,[pp_inc_1]
if INTERP_Z eq 1 if INTERP_Z eq 1
mov eax,inc_1 mov eax,inc_1
shl eax,1
add [pz],eax add [pz],eax
end if end if
mov eax,d_x mov eax,d_x
@ -195,6 +283,7 @@ end if
add edi,[pp_inc_2] add edi,[pp_inc_2]
if INTERP_Z eq 1 if INTERP_Z eq 1
mov eax,inc_2 mov eax,inc_2
shl eax,1
add [pz],eax add [pz],eax
end if end if
mov eax,d_y mov eax,d_y