forked from KolibriOS/kolibrios
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:
parent
f38db0969e
commit
755cc27ea4
@ -18,17 +18,30 @@ proc glopClearDepth uses eax ebx, context:dword, p:dword
|
||||
ret
|
||||
endp
|
||||
|
||||
;void glopClear(GLContext *c,GLParam *p)
|
||||
;{
|
||||
; int mask=p[1].i;
|
||||
; int z=0;
|
||||
; int r=(int)(c->clear_color.v[0]*65535);
|
||||
; int g=(int)(c->clear_color.v[1]*65535);
|
||||
; int b=(int)(c->clear_color.v[2]*65535);
|
||||
;
|
||||
; /* TODO : correct value of Z */
|
||||
;
|
||||
; ZB_clear(c->zb,mask & GL_DEPTH_BUFFER_BIT,z,
|
||||
; mask & GL_COLOR_BUFFER_BIT,r,g,b);
|
||||
;}
|
||||
align 4
|
||||
proc glopClear uses eax ebx, context:dword, p:dword
|
||||
mov eax,[context]
|
||||
mov ebx,[eax+offs_cont_clear_color+8] ;context.clear_color.v[2]
|
||||
shl ebx,16
|
||||
push ebx
|
||||
mov ebx,[eax+offs_cont_clear_color+4] ;context.clear_color.v[1]
|
||||
shl ebx,16
|
||||
push ebx
|
||||
mov ebx,[eax+offs_cont_clear_color] ;context.clear_color.v[0]
|
||||
shl ebx,16
|
||||
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
|
||||
|
||||
|
||||
|
173
programs/develop/libraries/TinyGL/asm_fork/examples/test0.asm
Normal file
173
programs/develop/libraries/TinyGL/asm_fork/examples/test0.asm
Normal 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:
|
174
programs/develop/libraries/TinyGL/asm_fork/examples/test1.asm
Normal file
174
programs/develop/libraries/TinyGL/asm_fork/examples/test1.asm
Normal 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:
|
@ -74,7 +74,6 @@ glGetFloatv: ;(int pname, float *v)
|
||||
|
||||
; ***
|
||||
glopLight:
|
||||
glopClear:
|
||||
glopCallList:
|
||||
|
||||
if DEBUG
|
||||
|
@ -57,7 +57,7 @@ end if
|
||||
|
||||
mov ecx,[edi+offs_zbuf_xsize]
|
||||
imul ecx,[edi+offs_zbuf_ysize]
|
||||
shl ecx,2 ;*= sizeof(unsigned short)
|
||||
shl ecx,1 ;*= sizeof(unsigned short)
|
||||
|
||||
stdcall gl_malloc, ecx
|
||||
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
|
||||
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_malloc,ecx
|
||||
@ -432,114 +432,135 @@ endp
|
||||
;}
|
||||
;
|
||||
;#endif /* TGL_FEATURE_RENDER_BITS == 32 */
|
||||
|
||||
|
||||
;
|
||||
; adr must be aligned on an 'int'
|
||||
;
|
||||
;/*
|
||||
; * adr must be aligned on an 'int'
|
||||
; */
|
||||
;void memset_s(void *adr, int val, int count)
|
||||
;{
|
||||
; int i, n, v;
|
||||
; unsigned int *p;
|
||||
; unsigned short *q;
|
||||
;
|
||||
; p = adr;
|
||||
; v = val | (val << 16);
|
||||
;
|
||||
; n = count >> 3;
|
||||
; for (i = 0; i < n; i++) {
|
||||
; p[0] = v;
|
||||
; p[1] = v;
|
||||
; p[2] = v;
|
||||
; p[3] = v;
|
||||
; p += 4;
|
||||
; }
|
||||
;
|
||||
; q = (unsigned short *) p;
|
||||
; n = count & 7;
|
||||
; for (i = 0; i < n; i++)
|
||||
; *q++ = val;
|
||||
;}
|
||||
;
|
||||
;void memset_l(void *adr, int val, int count)
|
||||
;{
|
||||
; int i, n, v;
|
||||
; unsigned int *p;
|
||||
;
|
||||
; p = adr;
|
||||
; v = val;
|
||||
; n = count >> 2;
|
||||
; for (i = 0; i < n; i++) {
|
||||
; p[0] = v;
|
||||
; p[1] = v;
|
||||
; p[2] = v;
|
||||
; p[3] = v;
|
||||
; p += 4;
|
||||
; }
|
||||
;
|
||||
; n = count & 3;
|
||||
; for (i = 0; i < n; i++)
|
||||
; *p++ = val;
|
||||
;}
|
||||
;
|
||||
;/* count must be a multiple of 4 and >= 4 */
|
||||
;void memset_RGB24(void *adr,int r, int v, int b,long count)
|
||||
;{
|
||||
; long i, n;
|
||||
; register long v1,v2,v3,*pt=(long *)(adr);
|
||||
; unsigned char *p,R=(unsigned char)r,V=(unsigned char)v,B=(unsigned char)b;
|
||||
;
|
||||
; p=(unsigned char *)adr;
|
||||
; *p++=R;
|
||||
; *p++=V;
|
||||
; *p++=B;
|
||||
; *p++=R;
|
||||
; *p++=V;
|
||||
; *p++=B;
|
||||
; *p++=R;
|
||||
; *p++=V;
|
||||
; *p++=B;
|
||||
; *p++=R;
|
||||
; *p++=V;
|
||||
; *p++=B;
|
||||
; v1=*pt++;
|
||||
; v2=*pt++;
|
||||
; v3=*pt++;
|
||||
; n = count >> 2;
|
||||
; for(i=1;i<n;i++) {
|
||||
; *pt++=v1;
|
||||
; *pt++=v2;
|
||||
; *pt++=v3;
|
||||
; }
|
||||
;}
|
||||
;
|
||||
;void ZB_clear(ZBuffer * zb, int clear_z, int z,
|
||||
; int clear_color, int r, int g, int b)
|
||||
;{
|
||||
;#if TGL_FEATURE_RENDER_BITS != 24
|
||||
; int color;
|
||||
;#endif
|
||||
; int y;
|
||||
; PIXEL *pp;
|
||||
;
|
||||
; if (clear_z) {
|
||||
; memset_s(zb->zbuf, z, zb->xsize * zb->ysize);
|
||||
; }
|
||||
; if (clear_color) {
|
||||
; pp = zb->pbuf;
|
||||
; for (y = 0; y < zb->ysize; y++) {
|
||||
;#if TGL_FEATURE_RENDER_BITS == 15 || TGL_FEATURE_RENDER_BITS == 16
|
||||
; color = RGB_TO_PIXEL(r, g, b);
|
||||
; memset_s(pp, color, zb->xsize);
|
||||
;#elif TGL_FEATURE_RENDER_BITS == 32
|
||||
; color = RGB_TO_PIXEL(r, g, b);
|
||||
; memset_l(pp, color, zb->xsize);
|
||||
;#elif TGL_FEATURE_RENDER_BITS == 24
|
||||
; memset_RGB24(pp,r>>8,g>>8,b>>8,zb->xsize);
|
||||
;#else
|
||||
;#error TODO
|
||||
;#endif
|
||||
; pp = (PIXEL *) ((char *) pp + zb->linesize);
|
||||
; }
|
||||
; }
|
||||
;}
|
||||
align 4
|
||||
proc memset_s uses eax ecx edi, adr:dword, val:dword, count:dword
|
||||
mov eax,[val]
|
||||
mov di,ax
|
||||
ror eax,16
|
||||
mov ax,di
|
||||
mov ecx,[count]
|
||||
shr ecx,1
|
||||
mov edi,[adr]
|
||||
rep stosd
|
||||
|
||||
bt dword[count],0
|
||||
jnc @f
|
||||
stosw
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc memset_l uses eax ecx edi, adr:dword, val:dword, count:dword
|
||||
mov eax,[val]
|
||||
mov ecx,[count]
|
||||
mov edi,[adr]
|
||||
rep stosd
|
||||
ret
|
||||
endp
|
||||
|
||||
; count must be a multiple of 4 and >= 4
|
||||
align 4
|
||||
proc memset_RGB24 uses eax ecx edi esi, adr:dword, r:dword, g:dword, b:dword, count:dword
|
||||
mov esi,[adr]
|
||||
mov eax,[r] ;копируем в буфер первые 12 байт (минимальное число кратное 3 и 4)
|
||||
mov byte[esi],al
|
||||
mov byte[esi+3],al
|
||||
mov byte[esi+6],al
|
||||
mov byte[esi+9],al
|
||||
mov eax,[g]
|
||||
mov byte[esi+1],al
|
||||
mov byte[esi+4],al
|
||||
mov byte[esi+7],al
|
||||
mov byte[esi+10],al
|
||||
mov eax,[b]
|
||||
mov byte[esi+2],al
|
||||
mov byte[esi+5],al
|
||||
mov byte[esi+8],al
|
||||
mov byte[esi+11],al
|
||||
|
||||
mov ecx,[count]
|
||||
shr ecx,2
|
||||
cmp ecx,1
|
||||
jle .end_f ;если ширина буфера меньше 12 байт, то выходим
|
||||
dec ecx
|
||||
mov edi,esi
|
||||
add edi,12
|
||||
|
||||
mov eax,[esi]
|
||||
cmp eax,[esi+4]
|
||||
jne @f
|
||||
;если r=g и g=b и b=r
|
||||
mov esi,ecx
|
||||
shl ecx,2
|
||||
sub ecx,esi ;ecx*=3
|
||||
rep stosd
|
||||
jmp .end_f
|
||||
@@:
|
||||
|
||||
;если r!=g или g!=b или b!=r
|
||||
@@:
|
||||
movsd
|
||||
movsd
|
||||
movsd
|
||||
sub esi,12
|
||||
loop @b
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc ZB_clear uses eax ebx ecx, zb:dword, clear_z:dword, z:dword, clear_color:dword,\
|
||||
r:dword, g:dword, b:dword
|
||||
;if TGL_FEATURE_RENDER_BITS != 24
|
||||
; color dd ?
|
||||
;end if
|
||||
|
||||
mov eax,[zb]
|
||||
cmp dword[clear_z],0
|
||||
je @f
|
||||
mov ebx,[eax+offs_zbuf_xsize]
|
||||
imul ebx,[eax+offs_zbuf_ysize]
|
||||
stdcall memset_s, [eax+offs_zbuf_zbuf],[z],ebx
|
||||
@@:
|
||||
cmp dword[clear_color],0
|
||||
je @f
|
||||
if TGL_FEATURE_RENDER_BITS eq 24
|
||||
mov ebx,[eax+offs_zbuf_xsize]
|
||||
push ebx
|
||||
mov ebx,[b]
|
||||
shr ebx,8
|
||||
push ebx
|
||||
mov ebx,[g]
|
||||
shr ebx,8
|
||||
push ebx
|
||||
mov ebx,[r]
|
||||
shr ebx,8
|
||||
push ebx
|
||||
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
|
||||
|
@ -6,6 +6,7 @@ proc ZB_plot uses eax ebx ecx edx edi, zb:dword, p:dword
|
||||
mov ecx,[ebx+offs_zbup_y]
|
||||
imul ecx,[eax+offs_zbuf_xsize]
|
||||
add ecx,[ebx+offs_zbup_x]
|
||||
shl ecx,1
|
||||
add ecx,[eax+offs_zbuf_zbuf]
|
||||
mov edx,[eax+offs_zbuf_linesize]
|
||||
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]
|
||||
mov edi,[ebx+offs_zbup_z]
|
||||
shr edi,ZB_POINT_Z_FRAC_BITS
|
||||
cmp edi,[ecx]
|
||||
cmp di,word[ecx]
|
||||
jl .end_f
|
||||
if TGL_FEATURE_RENDER_BITS eq 24
|
||||
mov eax,[ebx+offs_zbup_r]
|
||||
@ -27,7 +28,7 @@ if TGL_FEATURE_RENDER_BITS eq 24
|
||||
else
|
||||
; *pp = RGB_TO_PIXEL(p->r, p->g, p->b);
|
||||
end if
|
||||
mov [ecx],edi
|
||||
mov word[ecx],di
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
@ -50,6 +50,7 @@ if INTERP_Z eq 1
|
||||
mov edx,[ecx+offs_zbup_y]
|
||||
imul edx,[sx]
|
||||
add edx,[ecx+offs_zbup_x]
|
||||
shl edx,1
|
||||
add edx,[eax+offs_zbuf_zbuf]
|
||||
mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x)
|
||||
mov edx,[ecx+offs_zbup_z]
|
||||
@ -98,28 +99,51 @@ local .end_0
|
||||
mov eax,[z]
|
||||
shr eax, ZB_POINT_Z_FRAC_BITS
|
||||
mov [zz],eax
|
||||
cmp eax,[pz]
|
||||
mov ebx,[pz]
|
||||
cmp ax,word[ebx]
|
||||
jl .end_0
|
||||
RGBPIXEL
|
||||
mov eax,dword[zz]
|
||||
mov [pz],eax
|
||||
mov ebx,[pz]
|
||||
mov word[ebx],ax
|
||||
.end_0:
|
||||
else ; INTERP_Z
|
||||
else
|
||||
RGBPIXEL
|
||||
end if ; INTERP_Z
|
||||
end if
|
||||
}
|
||||
|
||||
macro DRAWLINE d_x,d_y,inc_1,inc_2
|
||||
{
|
||||
local .mz_0
|
||||
local .mz_1
|
||||
local .mz_2
|
||||
|
||||
mov eax,d_x
|
||||
mov [n],eax
|
||||
if INTERP_Z eq 1
|
||||
mov ebx,[p1]
|
||||
mov eax,[p2]
|
||||
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]
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
jmp .mz_2
|
||||
.mz_1:
|
||||
xor eax,eax
|
||||
.mz_2:
|
||||
mov [zinc],eax ;zinc=(p2.z-p1.z)/n
|
||||
end if
|
||||
shl dword d_y,1
|
||||
@ -154,6 +178,7 @@ end if
|
||||
add edi,[pp_inc_1]
|
||||
if INTERP_Z eq 1
|
||||
mov eax,inc_1
|
||||
shl eax,1
|
||||
add [pz],eax
|
||||
end if
|
||||
mov eax,d_x
|
||||
@ -164,6 +189,7 @@ end if
|
||||
add edi,[pp_inc_2]
|
||||
if INTERP_Z eq 1
|
||||
mov eax,inc_2
|
||||
shl eax,1
|
||||
add [pz],eax
|
||||
end if
|
||||
mov eax,d_y
|
||||
|
@ -51,6 +51,7 @@ if INTERP_Z eq 1
|
||||
mov edx,[ecx+offs_zbup_y]
|
||||
imul edx,[sx]
|
||||
add edx,[ecx+offs_zbup_x]
|
||||
shl edx,1
|
||||
add edx,[eax+offs_zbuf_zbuf]
|
||||
mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x)
|
||||
mov edx,[ecx+offs_zbup_z]
|
||||
@ -99,19 +100,34 @@ local .end_0
|
||||
mov eax,[z]
|
||||
shr eax, ZB_POINT_Z_FRAC_BITS
|
||||
mov [zz],eax
|
||||
cmp eax,[pz]
|
||||
mov ebx,[pz]
|
||||
cmp ax,word[ebx]
|
||||
jl .end_0
|
||||
RGBPIXEL
|
||||
mov eax,dword[zz]
|
||||
mov [pz],eax
|
||||
mov ebx,[pz]
|
||||
mov word[ebx],ax
|
||||
.end_0:
|
||||
else ; INTERP_Z
|
||||
else
|
||||
RGBPIXEL
|
||||
end if ; INTERP_Z
|
||||
end if
|
||||
}
|
||||
|
||||
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 [n],eax
|
||||
|
||||
@ -119,32 +135,103 @@ macro DRAWLINE d_x,d_y,inc_1,inc_2
|
||||
mov ecx,[p2]
|
||||
if INTERP_Z eq 1
|
||||
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]
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
jmp .mz_2
|
||||
.mz_1:
|
||||
xor eax,eax
|
||||
.mz_2:
|
||||
mov [zinc],eax ;zinc=(p2.z-p1.z)/n
|
||||
end if
|
||||
|
||||
;ebx=&p1, ecx=&p2
|
||||
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]
|
||||
shl eax,8
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
jmp .mr_2
|
||||
.mr_1:
|
||||
xor eax,eax
|
||||
.mr_2:
|
||||
mov [rinc],eax ;rinc=((p2.r-p1.r)<<8)/n
|
||||
|
||||
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]
|
||||
shl eax,8
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
jmp .mg_2
|
||||
.mg_1:
|
||||
xor eax,eax
|
||||
.mg_2:
|
||||
mov [ginc],eax ;ginc=((p2.g-p1.g)<<8)/n
|
||||
|
||||
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]
|
||||
shl eax,8
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
jmp .mb_2
|
||||
.mb_1:
|
||||
xor eax,eax
|
||||
.mb_2:
|
||||
mov [binc],eax ;binc=((p2.b-p1.b)<<8)/n
|
||||
|
||||
shl dword d_y,1
|
||||
@ -185,6 +272,7 @@ end if
|
||||
add edi,[pp_inc_1]
|
||||
if INTERP_Z eq 1
|
||||
mov eax,inc_1
|
||||
shl eax,1
|
||||
add [pz],eax
|
||||
end if
|
||||
mov eax,d_x
|
||||
@ -195,6 +283,7 @@ end if
|
||||
add edi,[pp_inc_2]
|
||||
if INTERP_Z eq 1
|
||||
mov eax,inc_2
|
||||
shl eax,1
|
||||
add [pz],eax
|
||||
end if
|
||||
mov eax,d_y
|
||||
|
Loading…
Reference in New Issue
Block a user