possible smooth buffer resizing,

fix and clean code,
fix and update examples

git-svn-id: svn://kolibrios.org@8069 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2020-09-19 19:57:00 +00:00
parent b60e6d45cf
commit d3fd66f14b
21 changed files with 465 additions and 491 deletions

View File

@ -19,30 +19,30 @@ proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword
fld dword[ebx+GLVertex.pc+offs_X] ;st0 = v.pc.X fld dword[ebx+GLVertex.pc+offs_X] ;st0 = v.pc.X
fmul st0,st1 fmul st0,st1
fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_X] fmul dword[eax+GLContext.viewport+GLViewport.scale+offs_X]
fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_X] fadd dword[eax+GLContext.viewport+GLViewport.trans+offs_X]
fistp dword[ebx+GLVertex.zp] ;v.zp.x = st0, st0 = st1 fistp dword[ebx+GLVertex.zp] ;v.zp.x = st0, st0 = st1
fld dword[ebx+GLVertex.pc+offs_Y] ;st0 = v.pc.Y fld dword[ebx+GLVertex.pc+offs_Y] ;st0 = v.pc.Y
fmul st0,st1 fmul st0,st1
fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Y] fmul dword[eax+GLContext.viewport+GLViewport.scale+offs_Y]
fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_Y] fadd dword[eax+GLContext.viewport+GLViewport.trans+offs_Y]
fistp dword[ebx+GLVertex.zp+offs_zbup_y] ;v.zp.y = st0, st0 = st1 fistp dword[ebx+GLVertex.zp+ZBufferPoint.y] ;v.zp.y = st0, st0 = st1
fld dword[ebx+GLVertex.pc+offs_Z] ;st0 = v.pc.Z fld dword[ebx+GLVertex.pc+offs_Z] ;st0 = v.pc.Z
fmulp fmulp
fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Z] fmul dword[eax+GLContext.viewport+GLViewport.scale+offs_Z]
fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_Z] fadd dword[eax+GLContext.viewport+GLViewport.trans+offs_Z]
fistp dword[ebx+GLVertex.zp+offs_zbup_z] ;v.zp.z = st0, st0 = st1 fistp dword[ebx+GLVertex.zp+ZBufferPoint.z] ;v.zp.z = st0, st0 = st1
; color ; color
cmp dword[eax+GLContext.lighting_enabled],0 ;if (context.lighting_enabled) cmp dword[eax+GLContext.lighting_enabled],0 ;if (context.lighting_enabled)
je @f je @f
lea ecx,[ebx+GLVertex.zp+offs_zbup_b] lea ecx,[ebx+GLVertex.zp+ZBufferPoint.b]
push ecx push ecx
add ecx,offs_zbup_g-offs_zbup_b add ecx,ZBufferPoint.g-ZBufferPoint.b
push ecx push ecx
add ecx,offs_zbup_r-offs_zbup_g add ecx,ZBufferPoint.r-ZBufferPoint.g
push ecx push ecx
stdcall RGBFtoRGBI, dword[ebx+GLVertex.color],dword[ebx+GLVertex.color+4],dword[ebx+GLVertex.color+8] stdcall RGBFtoRGBI, dword[ebx+GLVertex.color],dword[ebx+GLVertex.color+4],dword[ebx+GLVertex.color+8]
jmp .end_if jmp .end_if
@ -50,11 +50,11 @@ align 4
@@: @@:
; no need to convert to integer if no lighting : take current color ; no need to convert to integer if no lighting : take current color
mov ecx,[eax+GLContext.longcurrent_color] mov ecx,[eax+GLContext.longcurrent_color]
mov dword[ebx+GLVertex.zp+offs_zbup_r],ecx mov dword[ebx+GLVertex.zp+ZBufferPoint.r],ecx
mov ecx,[eax+GLContext.longcurrent_color+4] mov ecx,[eax+GLContext.longcurrent_color+4]
mov dword[ebx+GLVertex.zp+offs_zbup_g],ecx mov dword[ebx+GLVertex.zp+ZBufferPoint.g],ecx
mov ecx,[eax+GLContext.longcurrent_color+8] mov ecx,[eax+GLContext.longcurrent_color+8]
mov dword[ebx+GLVertex.zp+offs_zbup_b],ecx mov dword[ebx+GLVertex.zp+ZBufferPoint.b],ecx
.end_if: .end_if:
; texture ; texture
@ -66,12 +66,12 @@ align 4
fild dword[eax+offs_text_images+offs_imag_s_bound] fild dword[eax+offs_text_images+offs_imag_s_bound]
fmul dword[ebx+GLVertex.tex_coord+offs_X] fmul dword[ebx+GLVertex.tex_coord+offs_X]
fistp dword[ebx+GLVertex.zp+offs_zbup_s] fistp dword[ebx+GLVertex.zp+ZBufferPoint.s]
;v.zp.s=(int)(v.tex_coord.X * im.s_bound) ;v.zp.s=(int)(v.tex_coord.X * im.s_bound)
fild dword[eax+offs_text_images+offs_imag_t_bound] fild dword[eax+offs_text_images+offs_imag_t_bound]
fmul dword[ebx+GLVertex.tex_coord+offs_Y] fmul dword[ebx+GLVertex.tex_coord+offs_Y]
fistp dword[ebx+GLVertex.zp+offs_zbup_t] fistp dword[ebx+GLVertex.zp+ZBufferPoint.t]
;v.zp.t=(int)(v.tex_coord.Y * im.t_bound) ;v.zp.t=(int)(v.tex_coord.Y * im.t_bound)
@@: @@:
ret ret
@ -117,7 +117,7 @@ proc gl_draw_point uses eax ebx, context:dword, p0:dword
mov eax,[context] mov eax,[context]
cmp dword[eax+GLContext.render_mode],GL_SELECT cmp dword[eax+GLContext.render_mode],GL_SELECT
jne .els jne .els
stdcall gl_add_select, eax,dword[ebx+GLVertex.zp+offs_zbup_z],dword[ebx+GLVertex.zp+offs_zbup_z] ;p0.zp.z,p0.zp.z stdcall gl_add_select, eax,dword[ebx+GLVertex.zp+ZBufferPoint.z],dword[ebx+GLVertex.zp+ZBufferPoint.z] ;p0.zp.z,p0.zp.z
jmp @f jmp @f
align 4 align 4
.els: .els:
@ -286,8 +286,8 @@ pushad
;if ( (p1.clip_code | p2.clip_code) == 0) ;if ( (p1.clip_code | p2.clip_code) == 0)
cmp dword[edx+GLContext.render_mode],GL_SELECT ;if (context.render_mode == GL_SELECT) cmp dword[edx+GLContext.render_mode],GL_SELECT ;if (context.render_mode == GL_SELECT)
jne .els_1 jne .els_1
stdcall gl_add_select1, edx,dword[edi+GLVertex.zp+offs_zbup_z],\ stdcall gl_add_select1, edx,dword[edi+GLVertex.zp+ZBufferPoint.z],\
dword[esi+GLVertex.zp+offs_zbup_z],dword[esi+GLVertex.zp+offs_zbup_z] dword[esi+GLVertex.zp+ZBufferPoint.z],dword[esi+GLVertex.zp+ZBufferPoint.z]
jmp .end_f jmp .end_f
align 4 align 4
.els_1: .els_1:
@ -425,20 +425,20 @@ align 4
stdcall gl_transform_to_viewport, edx,eax stdcall gl_transform_to_viewport, edx,eax
sub eax,sizeof.GLVertex ;eax = &q1 sub eax,sizeof.GLVertex ;eax = &q1
lea ebx,[eax+GLVertex.zp+offs_zbup_b] lea ebx,[eax+GLVertex.zp+ZBufferPoint.b]
push ebx push ebx
add ebx,offs_zbup_g-offs_zbup_b add ebx,ZBufferPoint.g-ZBufferPoint.b
push ebx push ebx
add ebx,offs_zbup_r-offs_zbup_g add ebx,ZBufferPoint.r-ZBufferPoint.g
push ebx push ebx
stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8] stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8]
add eax,sizeof.GLVertex ;eax = &q2 add eax,sizeof.GLVertex ;eax = &q2
lea ebx,[eax+GLVertex.zp+offs_zbup_b] lea ebx,[eax+GLVertex.zp+ZBufferPoint.b]
push ebx push ebx
add ebx,offs_zbup_g-offs_zbup_b add ebx,ZBufferPoint.g-ZBufferPoint.b
push ebx push ebx
add ebx,offs_zbup_r-offs_zbup_g add ebx,ZBufferPoint.r-ZBufferPoint.g
push ebx push ebx
stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8] stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8]
@ -637,11 +637,11 @@ align 4
or eax,eax ;if (q.clip_code==0) or eax,eax ;if (q.clip_code==0)
jnz @f jnz @f
stdcall gl_transform_to_viewport,[context],edi stdcall gl_transform_to_viewport,[context],edi
lea eax,[edi+GLVertex.zp+offs_zbup_b] lea eax,[edi+GLVertex.zp+ZBufferPoint.b]
push eax push eax
add eax,offs_zbup_g-offs_zbup_b add eax,ZBufferPoint.g-ZBufferPoint.b
push eax push eax
add eax,offs_zbup_r-offs_zbup_g add eax,ZBufferPoint.r-ZBufferPoint.g
push eax push eax
stdcall RGBFtoRGBI, dword[edi+GLVertex.color],dword[edi+GLVertex.color+4],dword[edi+GLVertex.color+8] stdcall RGBFtoRGBI, dword[edi+GLVertex.color],dword[edi+GLVertex.color+4],dword[edi+GLVertex.color+8]
@@: @@:
@ -672,21 +672,21 @@ pushad
;or edi,___ - было выше ;or edi,___ - было выше
jnz .els_0 jnz .els_0
;if (co==0) ;if (co==0)
mov edi,dword[edx+GLVertex.zp+offs_zbup_x] mov edi,dword[edx+GLVertex.zp+ZBufferPoint.x]
sub edi,dword[ebx+GLVertex.zp+offs_zbup_x] sub edi,dword[ebx+GLVertex.zp+ZBufferPoint.x]
mov dword[norm],edi ;p2.x-p0.x mov dword[norm],edi ;p2.x-p0.x
fild dword[norm] fild dword[norm]
mov edi,dword[ecx+GLVertex.zp+offs_zbup_y] mov edi,dword[ecx+GLVertex.zp+ZBufferPoint.y]
sub edi,dword[ebx+GLVertex.zp+offs_zbup_y] sub edi,dword[ebx+GLVertex.zp+ZBufferPoint.y]
mov dword[norm],edi ;p1.y-p0.y mov dword[norm],edi ;p1.y-p0.y
fimul dword[norm] fimul dword[norm]
fchs fchs
mov edi,dword[ecx+GLVertex.zp+offs_zbup_x] mov edi,dword[ecx+GLVertex.zp+ZBufferPoint.x]
sub edi,dword[ebx+GLVertex.zp+offs_zbup_x] sub edi,dword[ebx+GLVertex.zp+ZBufferPoint.x]
mov dword[norm],edi ;p1.x-p0.x mov dword[norm],edi ;p1.x-p0.x
fild dword[norm] fild dword[norm]
mov edi,dword[edx+GLVertex.zp+offs_zbup_y] mov edi,dword[edx+GLVertex.zp+ZBufferPoint.y]
sub edi,dword[ebx+GLVertex.zp+offs_zbup_y] sub edi,dword[ebx+GLVertex.zp+ZBufferPoint.y]
mov dword[norm],edi ;p2.y-p0.y mov dword[norm],edi ;p2.y-p0.y
fimul dword[norm] fimul dword[norm]
faddp faddp

View File

@ -78,7 +78,7 @@ red_win:
jge @f jge @f
mov eax,120 ;min size mov eax,120 ;min size
@@: @@:
sub eax,42 sub eax,43
mov ebx,dword[procinfo.box.width] mov ebx,dword[procinfo.box.width]
cmp ebx,200 cmp ebx,200
jge @f jge @f
@ -91,8 +91,10 @@ red_win:
align 16 align 16
still: still:
call draw_3d call draw_3d
cmp dword[stop],1
je @f
stdcall Fps, 365,4 stdcall Fps, 365,4
mov dword[esp-4],eax mov dword[esp-4],eax
fild dword[esp-4] fild dword[esp-4]
fmul dword[a2] fmul dword[a2]
@ -101,6 +103,11 @@ still:
fstp dword[angle] fstp dword[angle]
mcall SF_CHECK_EVENT mcall SF_CHECK_EVENT
jmp .end0
align 4
@@:
mcall SF_WAIT_EVENT
.end0:
cmp al,1 cmp al,1
jz red_win jz red_win
cmp al,2 cmp al,2
@ -156,7 +163,7 @@ draw_window:
mcall SF_REDRAW,SSF_BEGIN_DRAW mcall SF_REDRAW,SSF_BEGIN_DRAW
mcall SF_CREATE_WINDOW,(50 shl 16)+409,(30 shl 16)+425,0x33404040,,title1 mcall SF_CREATE_WINDOW,(50 shl 16)+409,(30 shl 16)+425,0x33404040,,title1
stdcall [kosglSwapBuffers] call [kosglSwapBuffers]
;Title ;Title
mcall SF_DRAW_TEXT,(338 shl 16)+4,0xc0c0c0,fps, fps.end-fps mcall SF_DRAW_TEXT,(338 shl 16)+4,0xc0c0c0,fps, fps.end-fps
@ -179,49 +186,54 @@ key:
fld dword[scale] fld dword[scale]
fdiv dword[delt_sc] fdiv dword[delt_sc]
fstp dword[scale] fstp dword[scale]
call draw_3d jmp still
@@: @@:
cmp ah,61 ;= cmp ah,61 ;=
jne @f jne @f
fld dword[scale] fld dword[scale]
fdiv dword[delt_sc] fdiv dword[delt_sc]
fstp dword[scale] fstp dword[scale]
call draw_3d jmp still
@@: @@:
cmp ah,45 ;- cmp ah,45 ;-
jne @f jne @f
fld dword[scale] fld dword[scale]
fmul dword[delt_sc] fmul dword[delt_sc]
fstp dword[scale] fstp dword[scale]
call draw_3d jmp still
@@:
cmp ah,112 ;P
jne @f
xor dword[stop],1
jmp still
@@: @@:
cmp ah,178 ;Up cmp ah,178 ;Up
jne @f jne @f
fld dword[view_rotx] fld dword[view_rotx]
fadd dword[delt_size] fadd dword[delt_size]
fstp dword[view_rotx] fstp dword[view_rotx]
call draw_3d jmp still
@@: @@:
cmp ah,177 ;Down cmp ah,177 ;Down
jne @f jne @f
fld dword[view_rotx] fld dword[view_rotx]
fsub dword[delt_size] fsub dword[delt_size]
fstp dword[view_rotx] fstp dword[view_rotx]
call draw_3d jmp still
@@: @@:
cmp ah,176 ;Left cmp ah,176 ;Left
jne @f jne @f
fld dword[view_roty] fld dword[view_roty]
fadd dword[delt_size] fadd dword[delt_size]
fstp dword[view_roty] fstp dword[view_roty]
call draw_3d jmp still
@@: @@:
cmp ah,179 ;Right cmp ah,179 ;Right
jne @f jne @f
fld dword[view_roty] fld dword[view_roty]
fsub dword[delt_size] fsub dword[delt_size]
fstp dword[view_roty] fstp dword[view_roty]
call draw_3d jmp still
@@: @@:
jmp still jmp still
@ -237,9 +249,9 @@ button:
align 4 align 4
title1: db 'TinyGL in KolibriOS' title1: db 'TinyGL in KolibriOS'
.end: db 0 .end: db 0
title2: db 'F full screen' ;title2: db 'F full screen'
.end: db 0 ;.end: db 0
title3: db 'ESC - exit Arrow keys - rotate +/- zoom' title3: db 'ESC - exit, Arrow keys - rotate, +/- zoom, P - pause'
.end: db 0 .end: db 0
fps: db 'FPS:' fps: db 'FPS:'
.end: db 0 .end: db 0
@ -248,19 +260,19 @@ align 16
draw_3d: draw_3d:
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT
stdcall [glPushMatrix] call [glPushMatrix]
stdcall [glScalef], [scale], [scale], [scale] stdcall [glScalef], [scale], [scale], [scale]
stdcall [glRotatef], [view_rotx], 1.0, 0.0, 0.0 stdcall [glRotatef], [view_rotx], 1.0, 0.0, 0.0
stdcall [glRotatef], [view_roty], 0.0, 1.0, 0.0 stdcall [glRotatef], [view_roty], 0.0, 1.0, 0.0
stdcall [glRotatef], [view_rotz], 0.0, 0.0, 1.0 stdcall [glRotatef], [view_rotz], 0.0, 0.0, 1.0
stdcall [glPushMatrix] call [glPushMatrix]
stdcall [glTranslatef], -3.0, -2.0, 0.0 stdcall [glTranslatef], -3.0, -2.0, 0.0
stdcall [glRotatef], [angle], 0.0, 0.0, 1.0 stdcall [glRotatef], [angle], 0.0, 0.0, 1.0
stdcall [glCallList],[gear1] stdcall [glCallList],[gear1]
stdcall [glPopMatrix] call [glPopMatrix]
stdcall [glPushMatrix] call [glPushMatrix]
stdcall [glTranslatef], 3.1, -2.0, 0.0 stdcall [glTranslatef], 3.1, -2.0, 0.0
push dword 1.0 push dword 1.0
push dword 0.0 push dword 0.0
@ -277,9 +289,9 @@ draw_3d:
sub esp,4 sub esp,4
call [glRotatef] ;, -2.0*angle-9.0, 0.0, 0.0, 1.0 call [glRotatef] ;, -2.0*angle-9.0, 0.0, 0.0, 1.0
stdcall [glCallList],[gear2] stdcall [glCallList],[gear2]
stdcall [glPopMatrix] call [glPopMatrix]
stdcall [glPushMatrix] call [glPushMatrix]
stdcall [glTranslatef], -3.1, 4.2, 0.0 stdcall [glTranslatef], -3.1, 4.2, 0.0
push dword 1.0 push dword 1.0
push dword 0.0 push dword 0.0
@ -296,11 +308,11 @@ draw_3d:
sub esp,4 sub esp,4
call [glRotatef] ;, -2.0*angle-25.0, 0.0, 0.0, 1.0 call [glRotatef] ;, -2.0*angle-25.0, 0.0, 0.0, 1.0
stdcall [glCallList],[gear3] stdcall [glCallList],[gear3]
stdcall [glPopMatrix] call [glPopMatrix]
stdcall [glPopMatrix] call [glPopMatrix]
stdcall [kosglSwapBuffers] call [kosglSwapBuffers]
; count++; ; count++;
; if (count==limit) { ; if (count==limit) {
@ -330,6 +342,7 @@ angle dd 0.0
limit dd ? limit dd ?
count dd 1 count dd 1
stop dd 0 ;пауза
; ;
; Draw a gear wheel. You'll probably want to call this function when ; Draw a gear wheel. You'll probably want to call this function when

View File

@ -33,7 +33,7 @@ red_win:
align 16 align 16
still: still:
mcall SF_CHECK_EVENT mcall SF_WAIT_EVENT
cmp al,1 cmp al,1
jz red_win jz red_win
cmp al,2 cmp al,2
@ -71,6 +71,7 @@ key:
fstp dword[angle_z] fstp dword[angle_z]
call draw_3d call draw_3d
call [kosglSwapBuffers] call [kosglSwapBuffers]
jmp still
@@: @@:
cmp ah,179 ;Right cmp ah,179 ;Right
jne @f jne @f
@ -79,6 +80,7 @@ key:
fstp dword[angle_z] fstp dword[angle_z]
call draw_3d call draw_3d
call [kosglSwapBuffers] call [kosglSwapBuffers]
;jmp still
@@: @@:
jmp still jmp still

View File

@ -32,7 +32,7 @@ red_win:
align 16 align 16
still: still:
mcall SF_CHECK_EVENT mcall SF_WAIT_EVENT
cmp al,1 cmp al,1
jz red_win jz red_win
cmp al,2 cmp al,2
@ -70,6 +70,7 @@ key:
fstp dword[angle_z] fstp dword[angle_z]
call draw_3d call draw_3d
call [kosglSwapBuffers] call [kosglSwapBuffers]
jmp still
@@: @@:
cmp ah,179 ;Right cmp ah,179 ;Right
jne @f jne @f
@ -78,6 +79,7 @@ key:
fstp dword[angle_z] fstp dword[angle_z]
call draw_3d call draw_3d
call [kosglSwapBuffers] call [kosglSwapBuffers]
;jmp still
@@: @@:
jmp still jmp still
@ -114,7 +116,7 @@ call [glPushMatrix]
stdcall [glVertex3f], -0.636,-0.636, 0.1 stdcall [glVertex3f], -0.636,-0.636, 0.1
stdcall [glVertex3f], -0.9, 0.0, 0.1 stdcall [glVertex3f], -0.9, 0.0, 0.1
stdcall [glVertex3f], -0.636, 0.636, 0.1 stdcall [glVertex3f], -0.636, 0.636, 0.1
stdcall [glEnd] call [glEnd]
stdcall [glBegin],GL_LINE_LOOP stdcall [glBegin],GL_LINE_LOOP
stdcall [glVertex3f], 0.0, 1.1, 0.1 stdcall [glVertex3f], 0.0, 1.1, 0.1
@ -125,7 +127,7 @@ call [glPushMatrix]
stdcall [glVertex3f], -0.778, -0.778, 0.1 stdcall [glVertex3f], -0.778, -0.778, 0.1
stdcall [glVertex3f], -2.1, 0.0, 0.1 stdcall [glVertex3f], -2.1, 0.0, 0.1
stdcall [glVertex3f], -0.778, 0.778, 0.1 stdcall [glVertex3f], -0.778, 0.778, 0.1
stdcall [glEnd] call [glEnd]
call [glPopMatrix] call [glPopMatrix]
ret ret

View File

@ -62,7 +62,7 @@ red_win:
align 16 align 16
still: still:
mcall SF_CHECK_EVENT mcall SF_WAIT_EVENT
cmp al,1 cmp al,1
jz red_win jz red_win
cmp al,2 cmp al,2
@ -100,6 +100,7 @@ key:
fstp dword[angle_z] fstp dword[angle_z]
call draw_3d call draw_3d
call [kosglSwapBuffers] call [kosglSwapBuffers]
jmp still
@@: @@:
cmp ah,179 ;Right cmp ah,179 ;Right
jne @f jne @f
@ -108,6 +109,7 @@ key:
fstp dword[angle_z] fstp dword[angle_z]
call draw_3d call draw_3d
call [kosglSwapBuffers] call [kosglSwapBuffers]
;jmp still
@@: @@:
jmp still jmp still
@ -134,7 +136,7 @@ call [glPushMatrix]
stdcall [glCallList],[obj1] stdcall [glCallList],[obj1]
stdcall [glPopMatrix] call [glPopMatrix]
ret ret
align 4 align 4

View File

@ -34,7 +34,7 @@ red_win:
align 16 align 16
still: still:
mcall SF_CHECK_EVENT mcall SF_WAIT_EVENT
cmp al,1 cmp al,1
jz red_win jz red_win
cmp al,2 cmp al,2
@ -72,6 +72,7 @@ key:
fstp dword[angle_z] fstp dword[angle_z]
call draw_3d call draw_3d
call [kosglSwapBuffers] call [kosglSwapBuffers]
jmp still
@@: @@:
cmp ah,179 ;Right cmp ah,179 ;Right
jne @f jne @f
@ -80,6 +81,7 @@ key:
fstp dword[angle_z] fstp dword[angle_z]
call draw_3d call draw_3d
call [kosglSwapBuffers] call [kosglSwapBuffers]
;jmp still
@@: @@:
jmp still jmp still
@ -126,9 +128,9 @@ call [glPushMatrix]
stdcall [glColor3f],1.0, 1.0, 1.0 stdcall [glColor3f],1.0, 1.0, 1.0
stdcall [glVertex3f], -0.25, 0.433, 0.1 stdcall [glVertex3f], -0.25, 0.433, 0.1
stdcall [glEnd] call [glEnd]
stdcall [glPopMatrix] call [glPopMatrix]
ret ret
angle_z dd 15.0 angle_z dd 15.0

View File

@ -1,16 +1,13 @@
use32 use32
org 0x0 org 0
db 'MENUET01' db 'MENUET01'
dd 0x1 dd 1,start,i_end,mem,stacktop,0,cur_dir_path
dd start
dd i_end
dd mem,stacktop
dd 0,cur_dir_path
include '../../../../../../programs/proc32.inc' include '../../../../../proc32.inc'
include '../../../../../../programs/macros.inc' include '../../../../../macros.inc'
include '../../../../../../programs/develop/libraries/box_lib/load_lib.mac' include '../../../../../KOSfuncs.inc'
include '../../../../../../programs/dll.inc' include '../../../../../develop/libraries/box_lib/load_lib.mac'
include '../../../../../dll.inc'
include '../opengl_const.inc' include '../opengl_const.inc'
@use_library @use_library
@ -19,10 +16,10 @@ align 4
start: start:
load_library name_tgl, cur_dir_path, library_path, system_path, \ 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 err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
cmp eax,-1 cmp eax,SF_TERMINATE_PROCESS
jz button.exit jz button.exit
mcall 40,0x27 mcall SF_SET_EVENTS_MASK,0x27
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1 stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
stdcall [glEnable], GL_DEPTH_TEST stdcall [glEnable], GL_DEPTH_TEST
@ -37,9 +34,9 @@ align 4
red_win: red_win:
call draw_window call draw_window
align 4 align 16
still: still:
mcall 10 mcall SF_WAIT_EVENT
cmp al,1 cmp al,1
jz red_win jz red_win
cmp al,2 cmp al,2
@ -51,19 +48,19 @@ still:
align 4 align 4
draw_window: draw_window:
pushad pushad
mcall 12,1 mcall SF_REDRAW,SSF_BEGIN_DRAW
mov edx,0x33ffffff ;0x73ffffff mov edx,0x33ffffff ;0x73ffffff
mcall 0,(50 shl 16)+330,(30 shl 16)+275,,,caption mcall SF_CREATE_WINDOW,(50 shl 16)+330,(30 shl 16)+275,,,caption
stdcall [kosglSwapBuffers] call [kosglSwapBuffers]
mcall 12,2 mcall SF_REDRAW,SSF_END_DRAW
popad popad
ret ret
align 4 align 4
key: key:
mcall 2 mcall SF_GET_KEY
cmp ah,27 ;Esc cmp ah,27 ;Esc
je button.exit je button.exit
@ -74,7 +71,8 @@ key:
fadd dword[delt_sc] fadd dword[delt_sc]
fstp dword[scale] fstp dword[scale]
call draw_3d call draw_3d
stdcall [kosglSwapBuffers] call [kosglSwapBuffers]
jmp still
@@: @@:
cmp ah,45 ;- cmp ah,45 ;-
jne @f jne @f
@ -82,7 +80,8 @@ key:
fsub dword[delt_sc] fsub dword[delt_sc]
fstp dword[scale] fstp dword[scale]
call draw_3d call draw_3d
stdcall [kosglSwapBuffers] call [kosglSwapBuffers]
jmp still
@@: @@:
cmp ah,178 ;Up cmp ah,178 ;Up
jne @f jne @f
@ -90,7 +89,8 @@ key:
fadd dword[delt_size] fadd dword[delt_size]
fstp dword[angle_y] fstp dword[angle_y]
call draw_3d call draw_3d
stdcall [kosglSwapBuffers] call [kosglSwapBuffers]
jmp still
@@: @@:
cmp ah,177 ;Down cmp ah,177 ;Down
jne @f jne @f
@ -98,7 +98,8 @@ key:
fsub dword[delt_size] fsub dword[delt_size]
fstp dword[angle_y] fstp dword[angle_y]
call draw_3d call draw_3d
stdcall [kosglSwapBuffers] call [kosglSwapBuffers]
jmp still
@@: @@:
cmp ah,176 ;Left cmp ah,176 ;Left
jne @f jne @f
@ -106,7 +107,8 @@ key:
fadd dword[delt_size] fadd dword[delt_size]
fstp dword[angle_z] fstp dword[angle_z]
call draw_3d call draw_3d
stdcall [kosglSwapBuffers] call [kosglSwapBuffers]
jmp still
@@: @@:
cmp ah,179 ;Right cmp ah,179 ;Right
jne @f jne @f
@ -114,26 +116,24 @@ key:
fsub dword[delt_size] fsub dword[delt_size]
fstp dword[angle_z] fstp dword[angle_z]
call draw_3d call draw_3d
stdcall [kosglSwapBuffers] call [kosglSwapBuffers]
;jmp still
@@: @@:
jmp still jmp still
align 4 align 4
button: button:
mcall 17 mcall SF_GET_BUTTON
cmp ah,1 cmp ah,1
jne still jne still
.exit: .exit:
stdcall [gluDeleteQuadric], [qObj] stdcall [gluDeleteQuadric], [qObj]
mcall -1 mcall SF_TERMINATE_PROCESS
align 4 align 4
caption db 'Test gluSphere, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0 caption db 'Test gluSphere, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
align 4
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
;sizeof.TinyGLContext = 28
align 4 align 4
draw_3d: draw_3d:
@ -141,7 +141,7 @@ stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим б
stdcall [glColor3f], 1.0, 1.0, 0.0 stdcall [glColor3f], 1.0, 1.0, 0.0
stdcall [glPushMatrix] call [glPushMatrix]
stdcall [glTranslatef], 0.0,0.0,0.5 stdcall [glTranslatef], 0.0,0.0,0.5
stdcall [glScalef], [scale], [scale], [scale] stdcall [glScalef], [scale], [scale], [scale]
@ -156,9 +156,10 @@ stdcall [glPushMatrix]
stdcall [glColor3f], 0.0, 0.0, 1.0 stdcall [glColor3f], 0.0, 0.0, 1.0
stdcall [glTranslatef], 3.2,0.0,0.0 stdcall [glTranslatef], 3.2,0.0,0.0
stdcall [gluSphere], [qObj], 0.55, 8,8 stdcall [gluSphere], [qObj], 0.55, 8,8
stdcall [glPopMatrix] call [glPopMatrix]
ret ret
align 4
qObj dd 0 qObj dd 0
scale dd 0.4 scale dd 0.4
@ -186,14 +187,18 @@ include '../export.inc'
;-------------------------------------------------- ;--------------------------------------------------
system_path db '/sys/lib/' system_path db '/sys/lib/'
name_tgl db 'tinygl.obj',0 name_tgl db 'tinygl.obj',0
err_message_found_lib db 'Sorry I cannot load library tinygl.obj',0
head_f_i: head_f_i:
head_f_l db 'System error',0 head_f_l db '"System error',0
err_message_import db 'Error on load import library tinygl.obj',0 err_message_import db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
err_message_found_lib db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
;-------------------------------------------------- ;--------------------------------------------------
align 16
i_end: i_end:
rb 1024 ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
;sizeof.TinyGLContext = 28
rb 2048
stacktop: stacktop:
cur_dir_path: cur_dir_path:
rb 4096 rb 4096

View File

@ -41,13 +41,13 @@ pushad
; viewport ; viewport
xor eax,eax xor eax,eax
mov dword[edx+GLContext.viewport+offs_vpor_xmin],eax mov dword[edx+GLContext.viewport+GLViewport.xmin],eax
mov dword[edx+GLContext.viewport+offs_vpor_ymin],eax mov dword[edx+GLContext.viewport+GLViewport.ymin],eax
mov eax,[ecx+offs_zbuf_xsize] mov eax,[ecx+ZBuffer.xsize]
mov dword[edx+GLContext.viewport+offs_vpor_xsize],eax mov dword[edx+GLContext.viewport+GLViewport.xsize],eax
mov eax,[ecx+offs_zbuf_ysize] mov eax,[ecx+ZBuffer.ysize]
mov dword[edx+GLContext.viewport+offs_vpor_ysize],eax mov dword[edx+GLContext.viewport+GLViewport.ysize],eax
mov dword[edx+GLContext.viewport+offs_vpor_updated],1 mov dword[edx+GLContext.viewport+GLViewport.updated],1
; shared state ; shared state
stdcall initSharedState,edx stdcall initSharedState,edx

View File

@ -40,22 +40,16 @@ ends
align 4 align 4
proc gl_resize_viewport uses ebx ecx edx edi esi, context:dword, xsize_ptr:dword, ysize_ptr:dword proc gl_resize_viewport uses ebx ecx edx edi esi, context:dword, xsize_ptr:dword, ysize_ptr:dword
xor eax,eax
mov ecx,[xsize_ptr] ; ecx = &xsize mov ecx,[xsize_ptr] ; ecx = &xsize
mov edi,[ecx] ; edi = xsize mov edi,[ecx] ; edi = xsize
mov esi,[ysize_ptr] ; esi = &ysize mov esi,[ysize_ptr] ; esi = &ysize
mov esi,[esi] ; esi = ysize mov esi,[esi] ; esi = ysize
; we ensure that xsize and ysize are multiples of 2 for the zbuffer. xor eax,eax
; TODO: find a better solution or edi,edi
and edi, not 3 jnz @f
and esi, not 3 or esi,esi
jnz @f
cmp edi,0
jne @f
cmp esi,0
jne @f
mov eax,-1 mov eax,-1
jmp .end_f jmp .end_f
@@: @@:
@ -68,10 +62,10 @@ proc gl_resize_viewport uses ebx ecx edx edi esi, context:dword, xsize_ptr:dword
mov ebx,[context] mov ebx,[context]
mov edx,[ebx+GLContext.opaque] ; edx = (TinyGLContext *)context.opaque mov edx,[ebx+GLContext.opaque] ; edx = (TinyGLContext *)context.opaque
mov [edx+4],edi mov [edx+TinyGLContext.xsize],edi
mov [edx+12],edi ;d_x = xsize mov [edx+TinyGLContext.d_x],edi
mov [edx+8],esi mov [edx+TinyGLContext.ysize],esi
mov [edx+16],esi ;d_y = ysize mov [edx+TinyGLContext.d_y],esi
; resize the Z buffer ; resize the Z buffer
stdcall ZB_resize, dword[ebx+GLContext.zb],0,edi,esi stdcall ZB_resize, dword[ebx+GLContext.zb],0,edi,esi
@ -87,13 +81,13 @@ proc kosglMakeCurrent uses ebx ecx, win_x0:dword, win_y0:dword, win_x:dword, win
jne .end_f jne .end_f
; create the TinyGL context ; create the TinyGL context
mov ecx,[win_x0] mov ecx,[win_x0]
mov [ebx+20],ecx ;ctx.x = win_x0 mov [ebx+TinyGLContext.x],ecx
mov ecx,[win_y0] mov ecx,[win_y0]
mov [ebx+24],ecx ;ctx.y = win_y0 mov [ebx+TinyGLContext.y],ecx
mov ecx,[win_x] mov ecx,[win_x]
mov [ebx+12],ecx ;ctx.d_x = win_x mov [ebx+TinyGLContext.d_x],ecx
mov ecx,[win_y] mov ecx,[win_y]
mov [ebx+16],ecx ;ctx.d_y = win_y mov [ebx+TinyGLContext.d_y],ecx
; currently, we only support 16 bit rendering ; currently, we only support 16 bit rendering
xor eax,eax xor eax,eax
@ -116,8 +110,8 @@ proc kosglMakeCurrent uses ebx ecx, win_x0:dword, win_y0:dword, win_x:dword, win
mov dword[eax+GLContext.gl_resize_viewport],gl_resize_viewport mov dword[eax+GLContext.gl_resize_viewport],gl_resize_viewport
; set the viewport : we force a call to gl_resize_viewport ; set the viewport : we force a call to gl_resize_viewport
dec dword[eax+GLContext.viewport+offs_vpor_xsize] dec dword[eax+GLContext.viewport+GLViewport.xsize]
dec dword[eax+GLContext.viewport+offs_vpor_ysize] dec dword[eax+GLContext.viewport+GLViewport.ysize]
stdcall glViewport, 0, 0, [win_x], [win_y] stdcall glViewport, 0, 0, [win_x], [win_y]
.end_f: .end_f:
@ -132,15 +126,15 @@ proc kosglSwapBuffers uses eax ebx ecx edx esi
; retrieve the current TinyGLContext ; retrieve the current TinyGLContext
call gl_get_context call gl_get_context
mov ebx,[eax+GLContext.zb] mov ebx,[eax+GLContext.zb]
mov ebx,[ebx+offs_zbuf_pbuf] mov ebx,[ebx+ZBuffer.pbuf]
mov esi,[eax+GLContext.opaque] ;esi = &context.opaque mov esi,[eax+GLContext.opaque] ;esi = &context.opaque
mov eax,7 mov eax,SF_PUT_IMAGE
mov ecx,[esi+12] ;d_x mov ecx,[esi+TinyGLContext.d_x]
shl ecx,16 shl ecx,16
mov cx,[esi+16] ;d_y mov cx,word[esi+TinyGLContext.d_y]
mov edx,[esi+20] ;x mov edx,[esi+TinyGLContext.x]
shl edx,16 shl edx,16
mov dx,[esi+24] ;y mov dx,word[esi+TinyGLContext.y]
int 0x40 int 0x40
ret ret
endp endp

View File

@ -5,7 +5,6 @@ macro ADD_OP a,b,c
db 'gl',`a,' ',c,0 db 'gl',`a,' ',c,0
} }
include 'opinfo.inc' include 'opinfo.inc'
purge ADD_OP
;указатели на функции ;static void (*op_table_func[])(GLContext *,GLParam *)= ;указатели на функции ;static void (*op_table_func[])(GLContext *,GLParam *)=
align 4 align 4
@ -15,7 +14,6 @@ macro ADD_OP a,b,c
dd glop#a dd glop#a
} }
include 'opinfo.inc' include 'opinfo.inc'
purge ADD_OP
;число параметров в функциях ;число параметров в функциях
align 4 align 4
@ -25,7 +23,6 @@ macro ADD_OP a,b,c
dd b+1 dd b+1
} }
include 'opinfo.inc' include 'opinfo.inc'
purge ADD_OP
;коды функций у которых нет входных параметров ;коды функций у которых нет входных параметров
align 4 align 4
@ -36,7 +33,6 @@ if b eq 0
end if end if
} }
include 'opinfo.inc' include 'opinfo.inc'
purge ADD_OP
;output: ;output:
@ -332,19 +328,13 @@ proc glNewList uses eax ebx, list:dword, mode:dword
endp endp
align 4 align 4
proc glEndList uses eax ebx proc glEndList uses eax
locals
p dd ?
endl
call gl_get_context call gl_get_context
; assert(c->compile_flag == 1); ; assert(c->compile_flag == 1);
; end of list ; end of list
mov dword[p],OP_EndList stdcall gl_compile_op,eax,op_EndList
mov ebx,ebp
sub ebx,4 ;=sizeof(dd)
stdcall gl_compile_op,eax,ebx
mov dword[eax+GLContext.compile_flag],0 mov dword[eax+GLContext.compile_flag],0
mov dword[eax+GLContext.exec_flag],1 mov dword[eax+GLContext.exec_flag],1

View File

@ -23,16 +23,16 @@ endl
; we may need to resize the zbuffer ; we may need to resize the zbuffer
cmp dword[edx+GLContext.viewport+offs_vpor_ysize],ecx cmp dword[edx+GLContext.viewport+GLViewport.ysize],ecx
jne @f jne @f
mov ecx,[xmin] mov ecx,[xmin]
cmp dword[edx+GLContext.viewport+offs_vpor_xmin],ecx cmp dword[edx+GLContext.viewport+GLViewport.xmin],ecx
jne @f jne @f
mov ecx,[ymin] mov ecx,[ymin]
cmp dword[edx+GLContext.viewport+offs_vpor_ymin],ecx cmp dword[edx+GLContext.viewport+GLViewport.ymin],ecx
jne @f jne @f
mov ecx,[xsize] mov ecx,[xsize]
cmp dword[edx+GLContext.viewport+offs_vpor_xsize],ecx cmp dword[edx+GLContext.viewport+GLViewport.xsize],ecx
jne @f jne @f
jmp .end_f jmp .end_f
@@: @@:
@ -70,15 +70,15 @@ endl
stdcall dbg_print,sz_glViewport,err_5 stdcall dbg_print,sz_glViewport,err_5
@@: @@:
mov ecx,[xmin] mov ecx,[xmin]
mov dword[edx+GLContext.viewport+offs_vpor_xmin],ecx mov dword[edx+GLContext.viewport+GLViewport.xmin],ecx
mov ecx,[ymin] mov ecx,[ymin]
mov dword[edx+GLContext.viewport+offs_vpor_ymin],ecx mov dword[edx+GLContext.viewport+GLViewport.ymin],ecx
mov ecx,[xsize] mov ecx,[xsize]
mov dword[edx+GLContext.viewport+offs_vpor_xsize],ecx mov dword[edx+GLContext.viewport+GLViewport.xsize],ecx
mov ecx,[ysize] mov ecx,[ysize]
mov dword[edx+GLContext.viewport+offs_vpor_ysize],ecx mov dword[edx+GLContext.viewport+GLViewport.ysize],ecx
mov dword[edx+GLContext.viewport+offs_vpor_updated],1 mov dword[edx+GLContext.viewport+GLViewport.updated],1
.end_f: .end_f:
ret ret
endp endp

View File

@ -2,8 +2,9 @@ format MS COFF
public EXPORTS public EXPORTS
section '.flat' code readable align 16 section '.flat' code readable align 16
include '../../../../../programs/proc32.inc' include '../../../../proc32.inc'
include '../../../../../programs/macros.inc' include '../../../../macros.inc'
include '../../../../KOSfuncs.inc'
DEBUG equ 0 DEBUG equ 0
@ -85,23 +86,22 @@ endp
align 4 align 4
.str: .str:
mov ecx,0x0a ;задается система счисления изменяются регистры ebx,eax,ecx,edx входные параметры eax - число mov ecx,10
;преревод числа в ASCII строку входные данные ecx=система счисленя edi адрес куда записывать, будем строку, причем конец переменной cmp eax,ecx
cmp eax,ecx ;сравнить если в eax меньше чем в ecx то перейти на @@-1 т.е. на pop eax
jb @f jb @f
xor edx,edx ;очистить edx xor edx,edx
div ecx ;разделить - остаток в edx div ecx
push edx ;положить в стек push edx
call .str ;перейти на саму себя т.е. вызвать саму себя и так до того момента пока в eax не станет меньше чем в ecx call .str
pop eax pop eax
@@: ;cmp al,10 ;проверить не меньше ли значение в al чем 10 (для системы счисленя 10 данная команда - лишная)) @@:
cmp edi,esi cmp edi,esi
jge @f jge @f
or al,0x30 ;данная команда короче чем две выше or al,0x30
stosb ;записать элемент из регистра al в ячеку памяти es:edi stosb
mov byte[edi],0 ;в конец строки ставим 0, что-бы не вылазил мусор mov byte[edi],0
@@: @@:
ret ;пока в стеке храниться кол-во вызовов то столько раз мы и будем вызываться ret
end if end if
; *** ; ***
@ -156,8 +156,8 @@ f_fill_tr_nll db ' len',0
align 4 align 4
proc dbg_print, fun:dword, mes:dword proc dbg_print, fun:dword, mes:dword
pushad pushad
mov eax,63 mov eax,SF_BOARD
mov ebx,1 mov ebx,SSF_DEBUG_WRITE
mov esi,[fun] mov esi,[fun]
@@: @@:

View File

@ -85,31 +85,31 @@ endl
fadd st1,st0 ;st1 = 2.0 fadd st1,st0 ;st1 = 2.0
fdiv st0,st1 ;st0 = 0.5 fdiv st0,st1 ;st0 = 0.5
fild dword[eax+offs_vpor_xsize] fild dword[eax+GLViewport.xsize]
fsub st0,st1 fsub st0,st1
fdiv st0,st2 fdiv st0,st2
fst dword[eax+offs_vpor_scale+offs_X] fst dword[eax+GLViewport.scale+offs_X]
fiadd dword[eax+offs_vpor_xmin] fiadd dword[eax+GLViewport.xmin]
fstp dword[eax+offs_vpor_trans+offs_X] fstp dword[eax+GLViewport.trans+offs_X]
fild dword[eax+offs_vpor_ysize] fild dword[eax+GLViewport.ysize]
fsub st0,st1 fsub st0,st1
fdiv st0,st2 fdiv st0,st2
fchs fchs
fst dword[eax+offs_vpor_scale+offs_Y] fst dword[eax+GLViewport.scale+offs_Y]
fchs fchs
fiadd dword[eax+offs_vpor_ymin] fiadd dword[eax+GLViewport.ymin]
fstp dword[eax+offs_vpor_trans+offs_Y] fstp dword[eax+GLViewport.trans+offs_Y]
fld dword[zsize] fld dword[zsize]
fsub st0,st1 fsub st0,st1
fdiv st0,st2 fdiv st0,st2
fchs fchs
fst dword[eax+offs_vpor_scale+offs_Z] fst dword[eax+GLViewport.scale+offs_Z]
fchs fchs
mov dword[zsize],(1 shl ZB_POINT_Z_FRAC_BITS) / 2 mov dword[zsize],(1 shl ZB_POINT_Z_FRAC_BITS) / 2
fiadd dword[zsize] fiadd dword[zsize]
fstp dword[eax+offs_vpor_trans+offs_Z] fstp dword[eax+GLViewport.trans+offs_Z]
ret ret
endp endp
@ -197,10 +197,10 @@ align 4
.end_mmpu: .end_mmpu:
; viewport ; viewport
cmp dword[edx+GLContext.viewport+offs_vpor_updated],0 ;if (context.viewport.updated) cmp dword[edx+GLContext.viewport+GLViewport.updated],0 ;if (context.viewport.updated)
je @f je @f
stdcall gl_eval_viewport,edx stdcall gl_eval_viewport,edx
mov dword[edx+GLContext.viewport+offs_vpor_updated],0 mov dword[edx+GLContext.viewport+GLViewport.updated],0
@@: @@:
; triangle drawing functions ; triangle drawing functions
cmp dword[edx+GLContext.render_mode],GL_SELECT cmp dword[edx+GLContext.render_mode],GL_SELECT

View File

@ -20,15 +20,13 @@ proc ZB_open uses ecx edi, xsize:dword, ysize:dword, mode:dword,\
mov edi,eax mov edi,eax
mov eax,[ysize] mov eax,[ysize]
mov [edi+offs_zbuf_ysize],eax mov [edi+ZBuffer.ysize],eax
mov eax,[xsize] mov eax,[xsize]
mov [edi+offs_zbuf_xsize],eax mov [edi+ZBuffer.xsize],eax
imul eax,PSZB imul eax,PSZB
add eax,3 mov [edi+ZBuffer.linesize],eax
and eax,not 3
mov [edi+offs_zbuf_linesize],eax
mov eax,[mode] mov eax,[mode]
mov [edi+offs_zbuf_mode],eax mov [edi+ZBuffer.mode],eax
if TGL_FEATURE_32_BITS eq 1 if TGL_FEATURE_32_BITS eq 1
cmp eax,ZB_MODE_RGBA cmp eax,ZB_MODE_RGBA
@ -41,29 +39,29 @@ end if
cmp eax,ZB_MODE_5R6G5B cmp eax,ZB_MODE_5R6G5B
jne @f jne @f
.correct: .correct:
mov dword[edi+offs_zbuf_nb_colors],0 mov dword[edi+ZBuffer.nb_colors],0
jmp .end_s jmp .end_s
@@: ;default: @@: ;default:
stdcall dbg_print,f_zb_opn,err_3 stdcall dbg_print,f_zb_opn,err_3
jmp .error jmp .error
.end_s: .end_s:
mov ecx,[edi+offs_zbuf_xsize] mov ecx,[edi+ZBuffer.xsize]
imul ecx,[edi+offs_zbuf_ysize] imul ecx,[edi+ZBuffer.ysize]
shl ecx,1 ;*= 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+ZBuffer.zbuf],eax
cmp eax,0 cmp eax,0
jne @f jne @f
stdcall dbg_print,f_zb_opn,err_2 stdcall dbg_print,f_zb_opn,err_2
jmp .error jmp .error
@@: @@:
mov dword[edi+offs_zbuf_frame_buffer_allocated],0 mov dword[edi+ZBuffer.frame_buffer_allocated],0
mov dword[edi+offs_zbuf_pbuf],0 ;NULL mov dword[edi+ZBuffer.pbuf],0 ;NULL
mov dword[edi+offs_zbuf_current_texture],0 ;NULL mov dword[edi+ZBuffer.current_texture],0 ;NULL
mov eax,edi mov eax,edi
jmp .end_f jmp .end_f
@ -87,45 +85,41 @@ align 16
proc ZB_resize uses eax ebx ecx edi esi, zb:dword, frame_buffer:dword, xsize:dword, ysize:dword proc ZB_resize uses eax ebx ecx edi esi, zb:dword, frame_buffer:dword, xsize:dword, ysize:dword
mov ebx,[zb] mov ebx,[zb]
; xsize must be a multiple of 4
mov edi,[xsize] mov edi,[xsize]
and edi,not 3
mov esi,[ysize] mov esi,[ysize]
mov [ebx+offs_zbuf_xsize], edi mov [ebx+ZBuffer.xsize], edi
mov [ebx+offs_zbuf_ysize], esi mov [ebx+ZBuffer.ysize], esi
mov eax,edi mov eax,edi
imul eax,PSZB imul eax,PSZB
add eax,3 mov [ebx+ZBuffer.linesize],eax ;zb.linesize = (xsize * PSZB + 3) & ~3
and eax,not 3
mov [ebx+offs_zbuf_linesize],eax ;zb.linesize = (xsize * PSZB + 3) & ~3
mov ecx,edi mov ecx,edi
imul ecx,esi imul ecx,esi
shl ecx,1 ;*= sizeof(unsigned short) shl ecx,1 ;*= sizeof(unsigned short)
stdcall gl_free,dword[ebx+offs_zbuf_zbuf] stdcall gl_free,dword[ebx+ZBuffer.zbuf]
stdcall gl_malloc,ecx stdcall gl_malloc,ecx
mov [ebx+offs_zbuf_zbuf],eax mov [ebx+ZBuffer.zbuf],eax
cmp dword[ebx+offs_zbuf_frame_buffer_allocated],0 cmp dword[ebx+ZBuffer.frame_buffer_allocated],0
je @f je @f
stdcall gl_free,dword[ebx+offs_zbuf_pbuf] stdcall gl_free,dword[ebx+ZBuffer.pbuf]
@@: @@:
cmp dword[frame_buffer],0 cmp dword[frame_buffer],0
jne .els_0 jne .els_0
inc esi inc esi
imul esi,dword[ebx+offs_zbuf_linesize] imul esi,dword[ebx+ZBuffer.linesize]
stdcall gl_malloc,esi stdcall gl_malloc,esi
mov dword[ebx+offs_zbuf_pbuf],eax mov dword[ebx+ZBuffer.pbuf],eax
mov dword[ebx+offs_zbuf_frame_buffer_allocated],1 mov dword[ebx+ZBuffer.frame_buffer_allocated],1
jmp @f jmp @f
.els_0: .els_0:
mov eax,[frame_buffer] mov eax,[frame_buffer]
mov dword[ebx+offs_zbuf_pbuf],eax mov dword[ebx+ZBuffer.pbuf],eax
mov dword[ebx+offs_zbuf_frame_buffer_allocated],0 mov dword[ebx+ZBuffer.frame_buffer_allocated],0
@@: @@:
ret ret
endp endp
@ -434,11 +428,12 @@ proc memset_l uses eax ecx edi, adr:dword, val:dword, count:dword
ret ret
endp endp
; count must be a multiple of 4 and >= 4 ;input:
; count - число пикселей RGB для закраски
;destroy: ;destroy:
; edi, esi ; eax, ecx, edi, esi
align 16 align 16
proc memset_RGB24 uses eax ecx, adr:dword, r:dword, g:dword, b:dword, count:dword proc memset_RGB24, adr:dword, r:dword, g:dword, b:dword, count:dword
mov esi,[adr] mov esi,[adr]
mov eax,[r] ;копируем в буфер первые 12 байт (минимальное число кратное 3 и 4) mov eax,[r] ;копируем в буфер первые 12 байт (минимальное число кратное 3 и 4)
mov byte[esi],al mov byte[esi],al
@ -461,17 +456,20 @@ proc memset_RGB24 uses eax ecx, adr:dword, r:dword, g:dword, b:dword, count:dwor
cmp ecx,1 cmp ecx,1
jle .end_f ;если ширина буфера меньше 12 байт, то выходим jle .end_f ;если ширина буфера меньше 12 байт, то выходим
dec ecx dec ecx
mov edi,esi lea edi,[esi+12]
add edi,12
mov eax,[esi] mov eax,[esi]
cmp eax,[esi+4] cmp eax,[esi+4]
jne @f jne @f
;если r=g и g=b и b=r ;если r=g и g=b и b=r
mov esi,ecx lea ecx,[ecx+2*ecx] ;ecx*=3
shl ecx,2
sub ecx,esi ;ecx*=3
rep stosd rep stosd
mov ecx,[count]
and ecx,3
cmp ecx,0
je .end_f
lea ecx,[ecx+2*ecx] ;ecx*=3
rep stosb
jmp .end_f jmp .end_f
align 16 align 16
@@: ;если r!=g или g!=b или b!=r @@: ;если r!=g или g!=b или b!=r
@ -480,6 +478,12 @@ align 16
movsd movsd
sub esi,12 sub esi,12
loop @b loop @b
mov ecx,[count]
and ecx,3
cmp ecx,0
je .end_f
lea ecx,[ecx+2*ecx] ;ecx*=3
rep movsb
.end_f: .end_f:
ret ret
endp endp
@ -494,14 +498,19 @@ proc ZB_clear uses eax ebx ecx edi esi, zb:dword, clear_z:dword, z:dword,\
mov eax,[zb] mov eax,[zb]
cmp dword[clear_z],0 cmp dword[clear_z],0
je @f je @f
mov ebx,[eax+offs_zbuf_xsize] mov ebx,[eax+ZBuffer.xsize]
imul ebx,[eax+offs_zbuf_ysize] imul ebx,[eax+ZBuffer.ysize]
stdcall memset_s, [eax+offs_zbuf_zbuf],[z],ebx stdcall memset_s, [eax+ZBuffer.zbuf],[z],ebx
@@: @@:
cmp dword[clear_color],0 cmp dword[clear_color],0
je @f je @f
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 if TGL_FEATURE_RENDER_BITS eq 24
mov ebx,[eax+offs_zbuf_xsize] mov ebx,[eax+ZBuffer.xsize]
imul ebx,[eax+ZBuffer.ysize]
push ebx push ebx
mov ebx,[b] mov ebx,[b]
shr ebx,8 shr ebx,8
@ -512,22 +521,8 @@ if TGL_FEATURE_RENDER_BITS eq 24
mov ebx,[r] mov ebx,[r]
shr ebx,8 shr ebx,8
push ebx push ebx
add esp,16 stdcall memset_RGB24, [eax+ZBuffer.pbuf]
end if end if
mov ebx,[eax+offs_zbuf_pbuf]
mov ecx,[eax+offs_zbuf_ysize]
align 4
.cycle_0:
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 ret
endp endp

View File

@ -63,6 +63,7 @@ struct ZBuffer
xsize dd ? ;int xsize dd ? ;int
ysize dd ? ;int ysize dd ? ;int
linesize dd ? ;int ;line size, in bytes linesize dd ? ;int ;line size, in bytes
dd ? ;fix old error offset
mode dd ? ;int mode dd ? ;int
zbuf dd ? ;*unsigned short zbuf dd ? ;*unsigned short
@ -78,21 +79,6 @@ struct ZBuffer
t_bound dd ? ;unsigned int t_bound dd ? ;unsigned int
ends ends
offs_zbuf_xsize equ 0
offs_zbuf_ysize equ 4
offs_zbuf_linesize equ 8
offs_zbuf_mode equ 16
offs_zbuf_zbuf equ 20
offs_zbuf_pbuf equ 24
offs_zbuf_frame_buffer_allocated equ 28
offs_zbuf_nb_colors equ 32
offs_zbuf_dctable equ 36
offs_zbuf_ctable equ 40
offs_zbuf_current_texture equ 44
offs_zbuf_s_log2 equ 48
offs_zbuf_s_bound equ 52
offs_zbuf_t_bound equ 56
struct ZBufferPoint struct ZBufferPoint
x dd ? ;int ;integer coordinates in the zbuffer x dd ? ;int ;integer coordinates in the zbuffer
y dd ? ;int y dd ? ;int
@ -107,17 +93,6 @@ struct ZBufferPoint
tz dd ? ;float tz dd ? ;float
ends ends
offs_zbup_x equ 0
offs_zbup_y equ 4
offs_zbup_z equ 8
offs_zbup_s equ 12
offs_zbup_t equ 16
offs_zbup_r equ 20
offs_zbup_g equ 24
offs_zbup_b equ 28
offs_zbup_sz equ 32
offs_zbup_tz equ 36
; ztriangle.c ; ztriangle.c
; ;

View File

@ -97,14 +97,6 @@ struct GLViewport
updated dd ? ;int updated dd ? ;int
ends ends
offs_vpor_xmin equ 0
offs_vpor_ymin equ 4
offs_vpor_xsize equ 8
offs_vpor_ysize equ 12
offs_vpor_scale equ 16
offs_vpor_trans equ 28
offs_vpor_updated equ 40
struct GLParamBuffer struct GLParamBuffer
ops rd OP_BUFFER_MAX_SIZE ;GLParam[OP_BUFFER_MAX_SIZE] ops rd OP_BUFFER_MAX_SIZE ;GLParam[OP_BUFFER_MAX_SIZE]
next dd ? ;struct GLParamBuffer* next dd ? ;struct GLParamBuffer*

View File

@ -3,27 +3,27 @@ align 4
proc ZB_plot uses eax ebx ecx edx edi, zb:dword, p:dword proc ZB_plot uses eax ebx ecx edx edi, zb:dword, p:dword
mov eax,[zb] mov eax,[zb]
mov ebx,[p] mov ebx,[p]
mov ecx,[ebx+offs_zbup_y] mov ecx,[ebx+ZBufferPoint.y]
imul ecx,[eax+offs_zbuf_xsize] imul ecx,[eax+ZBuffer.xsize]
add ecx,[ebx+offs_zbup_x] add ecx,[ebx+ZBufferPoint.x]
shl ecx,1 shl ecx,1
add ecx,[eax+offs_zbuf_zbuf] add ecx,[eax+ZBuffer.zbuf]
mov edx,[eax+offs_zbuf_linesize] mov edx,[eax+ZBuffer.linesize]
imul edx,[ebx+offs_zbup_y] imul edx,[ebx+ZBufferPoint.y]
mov edi,[ebx+offs_zbup_x] mov edi,[ebx+ZBufferPoint.x]
imul edi,PSZB imul edi,PSZB
add edx,edi add edx,edi
add edx,[eax+offs_zbuf_pbuf] add edx,[eax+ZBuffer.pbuf]
mov edi,[ebx+offs_zbup_z] mov edi,[ebx+ZBufferPoint.z]
shr edi,ZB_POINT_Z_FRAC_BITS shr edi,ZB_POINT_Z_FRAC_BITS
cmp di,word[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+ZBufferPoint.r]
mov byte[edx],ah mov byte[edx],ah
mov eax,[ebx+offs_zbup_g] mov eax,[ebx+ZBufferPoint.g]
mov byte[edx+1],ah mov byte[edx+1],ah
mov eax,[ebx+offs_zbup_b] mov eax,[ebx+ZBufferPoint.b]
mov byte[edx+2],ah mov byte[edx+2],ah
else else
; *pp = RGB_TO_PIXEL(p->r, p->g, p->b); ; *pp = RGB_TO_PIXEL(p->r, p->g, p->b);
@ -60,7 +60,7 @@ if DEBUG ;ZB_line_z
push edi push edi
mov ecx,80 mov ecx,80
mov eax,[p1] mov eax,[p1]
mov eax,[eax+offs_zbup_x] mov eax,[eax+ZBufferPoint.x]
lea edi,[buf_param] lea edi,[buf_param]
stdcall convert_int_to_str,ecx stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2 stdcall str_n_cat,edi,txt_zp_sp,2
@ -69,7 +69,7 @@ push edi
sub ecx,eax sub ecx,eax
mov eax,[p1] mov eax,[p1]
mov eax,[eax+offs_zbup_y] mov eax,[eax+ZBufferPoint.y]
stdcall convert_int_to_str,ecx stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2 stdcall str_n_cat,edi,txt_zp_sp,2
stdcall str_len,edi stdcall str_len,edi
@ -77,7 +77,7 @@ push edi
sub ecx,eax sub ecx,eax
mov eax,[p2] mov eax,[p2]
mov eax,[eax+offs_zbup_x] mov eax,[eax+ZBufferPoint.x]
stdcall convert_int_to_str,ecx stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2 stdcall str_n_cat,edi,txt_zp_sp,2
stdcall str_len,edi stdcall str_len,edi
@ -85,7 +85,7 @@ push edi
sub ecx,eax sub ecx,eax
mov eax,[p2] mov eax,[p2]
mov eax,[eax+offs_zbup_y] mov eax,[eax+ZBufferPoint.y]
stdcall convert_int_to_str,ecx stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_nl,2 stdcall str_n_cat,edi,txt_nl,2
@ -93,10 +93,10 @@ push edi
pop edi pop edi
end if end if
mov ebx,[p1] mov ebx,[p1]
RGB_TO_PIXEL dword[ebx+offs_zbup_r],dword[ebx+offs_zbup_g],dword[ebx+offs_zbup_b] RGB_TO_PIXEL dword[ebx+ZBufferPoint.r],dword[ebx+ZBufferPoint.g],dword[ebx+ZBufferPoint.b]
mov ecx,eax mov ecx,eax
mov ebx,[p2] mov ebx,[p2]
RGB_TO_PIXEL dword[ebx+offs_zbup_r],dword[ebx+offs_zbup_g],dword[ebx+offs_zbup_b] RGB_TO_PIXEL dword[ebx+ZBufferPoint.r],dword[ebx+ZBufferPoint.g],dword[ebx+ZBufferPoint.b]
; choose if the line should have its color interpolated or not ; choose if the line should have its color interpolated or not
cmp ecx,eax cmp ecx,eax
@ -115,7 +115,7 @@ if DEBUG ;ZB_line
push edi push edi
mov ecx,80 mov ecx,80
mov eax,[p1] mov eax,[p1]
mov eax,[eax+offs_zbup_x] mov eax,[eax+ZBufferPoint.x]
lea edi,[buf_param] lea edi,[buf_param]
stdcall convert_int_to_str,ecx stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2 stdcall str_n_cat,edi,txt_zp_sp,2
@ -124,7 +124,7 @@ push edi
sub ecx,eax sub ecx,eax
mov eax,[p1] mov eax,[p1]
mov eax,[eax+offs_zbup_y] mov eax,[eax+ZBufferPoint.y]
stdcall convert_int_to_str,ecx stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2 stdcall str_n_cat,edi,txt_zp_sp,2
stdcall str_len,edi stdcall str_len,edi
@ -132,7 +132,7 @@ push edi
sub ecx,eax sub ecx,eax
mov eax,[p2] mov eax,[p2]
mov eax,[eax+offs_zbup_x] mov eax,[eax+ZBufferPoint.x]
stdcall convert_int_to_str,ecx stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2 stdcall str_n_cat,edi,txt_zp_sp,2
stdcall str_len,edi stdcall str_len,edi
@ -140,7 +140,7 @@ push edi
sub ecx,eax sub ecx,eax
mov eax,[p2] mov eax,[p2]
mov eax,[eax+offs_zbup_y] mov eax,[eax+ZBufferPoint.y]
stdcall convert_int_to_str,ecx stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_nl,2 stdcall str_n_cat,edi,txt_nl,2
@ -148,10 +148,10 @@ push edi
pop edi pop edi
end if end if
mov ebx,[p1] mov ebx,[p1]
RGB_TO_PIXEL dword[ebx+offs_zbup_r],dword[ebx+offs_zbup_g],dword[ebx+offs_zbup_b] RGB_TO_PIXEL dword[ebx+ZBufferPoint.r],dword[ebx+ZBufferPoint.g],dword[ebx+ZBufferPoint.b]
mov ecx,eax mov ecx,eax
mov ebx,[p2] mov ebx,[p2]
RGB_TO_PIXEL dword[ebx+offs_zbup_r],dword[ebx+offs_zbup_g],dword[ebx+offs_zbup_b] RGB_TO_PIXEL dword[ebx+ZBufferPoint.r],dword[ebx+ZBufferPoint.g],dword[ebx+ZBufferPoint.b]
; choose if the line should have its color interpolated or not ; choose if the line should have its color interpolated or not
cmp ecx,eax cmp ecx,eax

View File

@ -24,12 +24,12 @@ pushad
mov eax,[p1] mov eax,[p1]
mov ebx,[p2] mov ebx,[p2]
mov ecx,[ebx+offs_zbup_y] mov ecx,[ebx+ZBufferPoint.y]
cmp [eax+offs_zbup_y], ecx ;if (p1.y > p2.y) cmp [eax+ZBufferPoint.y], ecx ;if (p1.y > p2.y)
jg @f jg @f
jl .end_0 ;if (p1.y != p2.y) jl .end_0 ;if (p1.y != p2.y)
mov ecx,[ebx+offs_zbup_x] mov ecx,[ebx+ZBufferPoint.x]
cmp [eax+offs_zbup_x], ecx ;if (p1.x > p2.x) cmp [eax+ZBufferPoint.x], ecx ;if (p1.x > p2.x)
jle .end_0 ;if (p1.x <= p2.x) jle .end_0 ;if (p1.x <= p2.x)
@@: ;if (p1.y > p2.y || (p1.y == p2.y && p1.x > p2.x)) @@: ;if (p1.y > p2.y || (p1.y == p2.y && p1.x > p2.x))
mov [p1],ebx mov [p1],ebx
@ -37,42 +37,42 @@ pushad
.end_0: .end_0:
mov eax,[zb] mov eax,[zb]
mov edx,[eax+offs_zbuf_xsize] mov edx,[eax+ZBuffer.xsize]
mov [sx],edx mov [sx],edx
mov ecx,[p1] mov ecx,[p1]
mov edi,[eax+offs_zbuf_linesize] mov edi,[eax+ZBuffer.linesize]
imul edi,[ecx+offs_zbup_y] imul edi,[ecx+ZBufferPoint.y]
mov edx,[ecx+offs_zbup_x] mov edx,[ecx+ZBufferPoint.x]
imul edx,PSZB imul edx,PSZB
add edi,edx add edi,edx
add edi,[eax+offs_zbuf_pbuf] ;edi = (zb.pbuf + zb.linesize*p1.y + p1.x*PSZB) add edi,[eax+ZBuffer.pbuf] ;edi = (zb.pbuf + zb.linesize*p1.y + p1.x*PSZB)
if INTERP_Z eq 1 if INTERP_Z eq 1
mov edx,[ecx+offs_zbup_y] mov edx,[ecx+ZBufferPoint.y]
imul edx,[sx] imul edx,[sx]
add edx,[ecx+offs_zbup_x] add edx,[ecx+ZBufferPoint.x]
shl edx,1 shl edx,1
add edx,[eax+offs_zbuf_zbuf] add edx,[eax+ZBuffer.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+ZBufferPoint.z]
mov [z],edx ;z = p1.z mov [z],edx ;z = p1.z
end if end if
mov ebx,[p2] mov ebx,[p2]
mov eax,[ebx+offs_zbup_x] mov eax,[ebx+ZBufferPoint.x]
sub eax,[ecx+offs_zbup_x] sub eax,[ecx+ZBufferPoint.x]
mov [d_x],eax ;d_x = p2.x - p1.x mov [d_x],eax ;d_x = p2.x - p1.x
mov eax,[ebx+offs_zbup_y] mov eax,[ebx+ZBufferPoint.y]
sub eax,[ecx+offs_zbup_y] sub eax,[ecx+ZBufferPoint.y]
mov [d_y],eax ;d_y = p2.y - p1.y mov [d_y],eax ;d_y = p2.y - p1.y
if TGL_FEATURE_RENDER_BITS eq 24 if TGL_FEATURE_RENDER_BITS eq 24
; for 24 bits, we store the colors in different variables ; for 24 bits, we store the colors in different variables
mov eax,[ebx+offs_zbup_r] mov eax,[ebx+ZBufferPoint.r]
shr eax,8 shr eax,8
mov [r],eax ;r = p2.r >> 8 mov [r],eax ;r = p2.r >> 8
mov eax,[ebx+offs_zbup_g] mov eax,[ebx+ZBufferPoint.g]
shr eax,8 shr eax,8
mov [g],eax ;g = p2.g >> 8 mov [g],eax ;g = p2.g >> 8
mov eax,[ebx+offs_zbup_b] mov eax,[ebx+ZBufferPoint.b]
shr eax,8 shr eax,8
mov [b],eax ;b = p2.b >> 8 mov [b],eax ;b = p2.b >> 8
end if end if
@ -123,12 +123,12 @@ local .mz_2
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+ZBufferPoint.z]
cmp eax,[ebx+offs_zbup_z] cmp eax,[ebx+ZBufferPoint.z]
jg .mz_0 jg .mz_0
je .mz_1 je .mz_1
;if(p2.z<p1.z) ;if(p2.z<p1.z)
sub eax,[ebx+offs_zbup_z] sub eax,[ebx+ZBufferPoint.z]
neg eax neg eax
inc eax inc eax
xor edx,edx xor edx,edx
@ -137,7 +137,7 @@ if INTERP_Z eq 1
inc eax inc eax
jmp .mz_2 jmp .mz_2
.mz_0: .mz_0:
sub eax,[ebx+offs_zbup_z] sub eax,[ebx+ZBufferPoint.z]
xor edx,edx xor edx,edx
div dword[n] div dword[n]
jmp .mz_2 jmp .mz_2

View File

@ -25,12 +25,12 @@ pushad
mov eax,[p1] mov eax,[p1]
mov ebx,[p2] mov ebx,[p2]
mov ecx,[ebx+offs_zbup_y] mov ecx,[ebx+ZBufferPoint.y]
cmp [eax+offs_zbup_y], ecx ;if (p1.y > p2.y) cmp [eax+ZBufferPoint.y], ecx ;if (p1.y > p2.y)
jg @f jg @f
jl .end_0 ;if (p1.y != p2.y) jl .end_0 ;if (p1.y != p2.y)
mov ecx,[ebx+offs_zbup_x] mov ecx,[ebx+ZBufferPoint.x]
cmp [eax+offs_zbup_x], ecx ;if (p1.x > p2.x) cmp [eax+ZBufferPoint.x], ecx ;if (p1.x > p2.x)
jle .end_0 ;if (p1.x <= p2.x) jle .end_0 ;if (p1.x <= p2.x)
@@: ;if (p1.y > p2.y || (p1.y == p2.y && p1.x > p2.x)) @@: ;if (p1.y > p2.y || (p1.y == p2.y && p1.x > p2.x))
mov [p1],ebx mov [p1],ebx
@ -38,41 +38,41 @@ pushad
.end_0: .end_0:
mov eax,[zb] mov eax,[zb]
mov edx,[eax+offs_zbuf_xsize] mov edx,[eax+ZBuffer.xsize]
mov [sx],edx mov [sx],edx
mov ecx,[p1] mov ecx,[p1]
mov edi,[eax+offs_zbuf_linesize] mov edi,[eax+ZBuffer.linesize]
imul edi,[ecx+offs_zbup_y] imul edi,[ecx+ZBufferPoint.y]
mov edx,[ecx+offs_zbup_x] mov edx,[ecx+ZBufferPoint.x]
imul edx,PSZB imul edx,PSZB
add edi,edx add edi,edx
add edi,[eax+offs_zbuf_pbuf] ;edi = (zb.pbuf + zb.linesize*p1.y + p1.x*PSZB) add edi,[eax+ZBuffer.pbuf] ;edi = (zb.pbuf + zb.linesize*p1.y + p1.x*PSZB)
if INTERP_Z eq 1 if INTERP_Z eq 1
mov edx,[ecx+offs_zbup_y] mov edx,[ecx+ZBufferPoint.y]
imul edx,[sx] imul edx,[sx]
add edx,[ecx+offs_zbup_x] add edx,[ecx+ZBufferPoint.x]
shl edx,1 shl edx,1
add edx,[eax+offs_zbuf_zbuf] add edx,[eax+ZBuffer.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+ZBufferPoint.z]
mov [z],edx ;z = p1.z mov [z],edx ;z = p1.z
end if end if
mov ebx,[p2] mov ebx,[p2]
mov eax,[ebx+offs_zbup_x] mov eax,[ebx+ZBufferPoint.x]
sub eax,[ecx+offs_zbup_x] sub eax,[ecx+ZBufferPoint.x]
mov [d_x],eax ;d_x = p2.x - p1.x mov [d_x],eax ;d_x = p2.x - p1.x
mov eax,[ebx+offs_zbup_y] mov eax,[ebx+ZBufferPoint.y]
sub eax,[ecx+offs_zbup_y] sub eax,[ecx+ZBufferPoint.y]
mov [d_y],eax ;d_y = p2.y - p1.y mov [d_y],eax ;d_y = p2.y - p1.y
mov eax,[ecx+offs_zbup_r] mov eax,[ecx+ZBufferPoint.r]
shl eax,8 shl eax,8
mov [r],eax ;r = p1.r << 8 mov [r],eax ;r = p1.r << 8
mov eax,[ecx+offs_zbup_g] mov eax,[ecx+ZBufferPoint.g]
shl eax,8 shl eax,8
mov [g],eax ;g = p1.g << 8 mov [g],eax ;g = p1.g << 8
mov eax,[ecx+offs_zbup_b] mov eax,[ecx+ZBufferPoint.b]
shl eax,8 shl eax,8
mov [b],eax ;b = p1.b << 8 mov [b],eax ;b = p1.b << 8
@ -134,12 +134,12 @@ local .mb_2
mov ebx,[p1] mov ebx,[p1]
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+ZBufferPoint.z]
cmp eax,[ebx+offs_zbup_z] cmp eax,[ebx+ZBufferPoint.z]
jg .mz_0 jg .mz_0
je .mz_1 je .mz_1
;if(p2.z<p1.z) ;if(p2.z<p1.z)
sub eax,[ebx+offs_zbup_z] sub eax,[ebx+ZBufferPoint.z]
neg eax neg eax
inc eax inc eax
xor edx,edx xor edx,edx
@ -148,7 +148,7 @@ if INTERP_Z eq 1
inc eax inc eax
jmp .mz_2 jmp .mz_2
.mz_0: .mz_0:
sub eax,[ebx+offs_zbup_z] sub eax,[ebx+ZBufferPoint.z]
xor edx,edx xor edx,edx
div dword[n] div dword[n]
jmp .mz_2 jmp .mz_2
@ -159,12 +159,12 @@ if INTERP_Z eq 1
end if end if
;ebx=&p1, ecx=&p2 ;ebx=&p1, ecx=&p2
mov eax,[ecx+offs_zbup_r] mov eax,[ecx+ZBufferPoint.r]
cmp eax,[ebx+offs_zbup_r] cmp eax,[ebx+ZBufferPoint.r]
jg .mr_0 jg .mr_0
je .mr_1 je .mr_1
;if(p2.r<p1.r) ;if(p2.r<p1.r)
sub eax,[ebx+offs_zbup_r] sub eax,[ebx+ZBufferPoint.r]
neg eax neg eax
inc eax inc eax
shl eax,8 shl eax,8
@ -174,7 +174,7 @@ end if
inc eax inc eax
jmp .mr_2 jmp .mr_2
.mr_0: .mr_0:
sub eax,[ebx+offs_zbup_r] sub eax,[ebx+ZBufferPoint.r]
shl eax,8 shl eax,8
xor edx,edx xor edx,edx
div dword[n] div dword[n]
@ -184,12 +184,12 @@ end if
.mr_2: .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+ZBufferPoint.g]
cmp eax,[ebx+offs_zbup_g] cmp eax,[ebx+ZBufferPoint.g]
jg .mg_0 jg .mg_0
je .mg_1 je .mg_1
;if(p2.g<p1.g) ;if(p2.g<p1.g)
sub eax,[ebx+offs_zbup_g] sub eax,[ebx+ZBufferPoint.g]
neg eax neg eax
inc eax inc eax
shl eax,8 shl eax,8
@ -199,7 +199,7 @@ end if
inc eax inc eax
jmp .mg_2 jmp .mg_2
.mg_0: .mg_0:
sub eax,[ebx+offs_zbup_g] sub eax,[ebx+ZBufferPoint.g]
shl eax,8 shl eax,8
xor edx,edx xor edx,edx
div dword[n] div dword[n]
@ -209,12 +209,12 @@ end if
.mg_2: .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+ZBufferPoint.b]
cmp eax,[ebx+offs_zbup_b] cmp eax,[ebx+ZBufferPoint.b]
jg .mb_0 jg .mb_0
je .mb_1 je .mb_1
;if(p2.b<p1.b) ;if(p2.b<p1.b)
sub eax,[ebx+offs_zbup_b] sub eax,[ebx+ZBufferPoint.b]
neg eax neg eax
inc eax inc eax
shl eax,8 shl eax,8
@ -224,7 +224,7 @@ end if
inc eax inc eax
jmp .mb_2 jmp .mb_2
.mb_0: .mb_0:
sub eax,[ebx+offs_zbup_b] sub eax,[ebx+ZBufferPoint.b]
shl eax,8 shl eax,8
xor edx,edx xor edx,edx
div dword[n] div dword[n]

View File

@ -38,12 +38,12 @@ macro DRAW_INIT
{ {
if TGL_FEATURE_RENDER_BITS eq 24 if TGL_FEATURE_RENDER_BITS eq 24
mov ecx,[p2] mov ecx,[p2]
mov eax,[ecx+offs_zbup_r] mov eax,[ecx+ZBufferPoint.r]
mov [colorR],ah ;colorR=p2.r>>8 mov [colorB],ah ;colorB=p2.r>>8
mov eax,[ecx+offs_zbup_g] mov eax,[ecx+ZBufferPoint.g]
mov [colorG],ah ;colorG=p2.g>>8 mov [colorG],ah ;colorG=p2.g>>8
mov eax,[ecx+offs_zbup_b] mov eax,[ecx+ZBufferPoint.b]
mov [colorB],ah ;colorB=p2.b>>8 mov [colorR],ah ;colorR=p2.b>>8
;else ;else
;color=RGB_TO_PIXEL(p2.r,p2.g,p2.b) ;color=RGB_TO_PIXEL(p2.r,p2.g,p2.b)
end if end if
@ -52,6 +52,9 @@ end if
macro PUT_PIXEL _a macro PUT_PIXEL _a
{ {
local .end_0 local .end_0
if _a eq 0
mov ebx,[dzdx]
end if
mov eax,[z] mov eax,[z]
shr eax,ZB_POINT_Z_FRAC_BITS shr eax,ZB_POINT_Z_FRAC_BITS
cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) cmp ax,word[esi+2*_a] ;if (zz >= pz[_a])
@ -59,26 +62,24 @@ local .end_0
;edi = pp ;edi = pp
mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение
if TGL_FEATURE_RENDER_BITS eq 24 if TGL_FEATURE_RENDER_BITS eq 24
mov al,[colorR] mov ax,word[colorB] ;сохраняем colorB и colorG
mov ah,[colorG]
mov word[edi+3*_a],ax mov word[edi+3*_a],ax
mov al,[colorB] mov al,[colorR]
mov byte[edi+3*_a +2],al mov byte[edi+3*_a +2],al
;else ;else
;pp[_a]=color ;pp[_a]=color
end if end if
.end_0: .end_0:
mov eax,[dzdx] add [z],ebx
add [z],eax
} }
align 16 align 16
proc ZB_fillTriangleFlat, zb:dword, p0:dword, p1:dword, p2:dword proc ZB_fillTriangleFlat, zb:dword, p0:dword, p1:dword, p2:dword
locals locals
if TGL_FEATURE_RENDER_BITS eq 24 if TGL_FEATURE_RENDER_BITS eq 24
colorR db ? colorB db ?
colorG db ? colorG db ?
colorB db ? ;unsigned char colorR db ? ;unsigned char
else else
color dd ? ;int color dd ? ;int
end if end if
@ -106,9 +107,8 @@ local .end_0
;edi = pp ;edi = pp
mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение
if TGL_FEATURE_RENDER_BITS eq 24 if TGL_FEATURE_RENDER_BITS eq 24
mov ebx,[or1]
mov eax,[og1] mov eax,[og1]
mov al,bh mov al,byte[or1+1]
mov word[edi+3*_a],ax mov word[edi+3*_a],ax
mov eax,[ob1] mov eax,[ob1]
mov byte[edi+3*_a +2],ah mov byte[edi+3*_a +2],ah
@ -117,12 +117,14 @@ end if
;pp[_a] = RGB_TO_PIXEL(or1, og1, ob1) ;pp[_a] = RGB_TO_PIXEL(or1, og1, ob1)
;end if ;end if
.end_0: .end_0:
mov eax,[dzdx] if _a eq 0
add [z],eax mov ebx,[dzdx]
mov eax,[dgdx] mov ecx,[dgdx]
add [og1],eax mov edx,[drdx]
mov eax,[drdx] end if
add [or1],eax add [z],ebx
add [og1],ecx
add [or1],edx
mov eax,[dbdx] mov eax,[dbdx]
add [ob1],eax add [ob1],eax
} }
@ -137,13 +139,13 @@ proc ZB_setTexture uses eax ebx, zb:dword, texture:dword,\
s_bound:dword, t_bound:dword, s_log2:dword s_bound:dword, t_bound:dword, s_log2:dword
mov eax,[zb] mov eax,[zb]
mov ebx,[texture] mov ebx,[texture]
mov dword[eax+offs_zbuf_current_texture],ebx mov dword[eax+ZBuffer.current_texture],ebx
mov ebx,[s_log2] mov ebx,[s_log2]
mov dword[eax+offs_zbuf_s_log2],ebx mov dword[eax+ZBuffer.s_log2],ebx
mov ebx,[s_bound] mov ebx,[s_bound]
mov dword[eax+offs_zbuf_s_bound],ebx mov dword[eax+ZBuffer.s_bound],ebx
mov ebx,[t_bound] mov ebx,[t_bound]
mov dword[eax+offs_zbuf_t_bound],ebx mov dword[eax+ZBuffer.t_bound],ebx
ret ret
endp endp
@ -153,13 +155,13 @@ INTERP_ST equ 1
macro DRAW_INIT macro DRAW_INIT
{ {
mov eax,[zb] mov eax,[zb]
mov ebx,[eax+offs_zbuf_current_texture] mov ebx,[eax+ZBuffer.current_texture]
mov [texture],ebx mov [texture],ebx
mov ebx,[eax+offs_zbuf_s_log2] mov ebx,[eax+ZBuffer.s_log2]
mov [s_log2],ebx ;s_log2 = zb.s_log2 mov [s_log2],ebx ;s_log2 = zb.s_log2
mov ebx,[eax+offs_zbuf_s_bound] mov ebx,[eax+ZBuffer.s_bound]
mov [s_bound],ebx ;s_bound = zb.s_bound mov [s_bound],ebx ;s_bound = zb.s_bound
mov ebx,[eax+offs_zbuf_t_bound] mov ebx,[eax+ZBuffer.t_bound]
mov [t_bound],ebx ;t_bound = zb.t_bound mov [t_bound],ebx ;t_bound = zb.t_bound
} }
@ -181,7 +183,7 @@ if TGL_FEATURE_RENDER_BITS eq 24
and eax,[s_bound] and eax,[s_bound]
shr eax,ZB_POINT_TEXEL_SIZE shr eax,ZB_POINT_TEXEL_SIZE
or ebx,eax or ebx,eax
imul ebx,3 lea ebx,[ebx+2*ebx]
add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | s) >> 14) * 3 add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | s) >> 14) * 3
mov ax,word[ebx] mov ax,word[ebx]
mov word[edi+3*_a],ax ;pp[3 * _a]= ptr[0,1] mov word[edi+3*_a],ax ;pp[3 * _a]= ptr[0,1]
@ -222,13 +224,13 @@ NB_INTERP equ 8
macro DRAW_INIT macro DRAW_INIT
{ {
mov eax,[zb] mov eax,[zb]
mov ebx,[eax+offs_zbuf_current_texture] mov ebx,[eax+ZBuffer.current_texture]
mov [texture],ebx mov [texture],ebx
mov ebx,[eax+offs_zbuf_s_log2] mov ebx,[eax+ZBuffer.s_log2]
mov [s_log2],ebx ;s_log2 = zb.s_log2 mov [s_log2],ebx ;s_log2 = zb.s_log2
mov ebx,[eax+offs_zbuf_s_bound] mov ebx,[eax+ZBuffer.s_bound]
mov [s_bound],ebx ;s_bound = zb.s_bound mov [s_bound],ebx ;s_bound = zb.s_bound
mov ebx,[eax+offs_zbuf_t_bound] mov ebx,[eax+ZBuffer.t_bound]
mov [t_bound],ebx ;t_bound = zb.t_bound mov [t_bound],ebx ;t_bound = zb.t_bound
mov dword[esp-4],NB_INTERP mov dword[esp-4],NB_INTERP
fild dword[esp-4] fild dword[esp-4]
@ -261,7 +263,7 @@ if TGL_FEATURE_RENDER_BITS eq 24
and eax,[s_bound] and eax,[s_bound]
shr eax,ZB_POINT_TEXEL_SIZE shr eax,ZB_POINT_TEXEL_SIZE
or ebx,eax or ebx,eax
imul ebx,3 lea ebx,[ebx+2*ebx]
add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | (s & 0x003FC000)) >> 14) * 3 add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | (s & 0x003FC000)) >> 14) * 3
mov ax,word[ebx] mov ax,word[ebx]
mov word[edi+3*_a],ax ;pp[3 * _a]= ptr[0,1] mov word[edi+3*_a],ax ;pp[3 * _a]= ptr[0,1]

View File

@ -119,18 +119,18 @@ pushad
mov ebx,[p0] mov ebx,[p0]
mov ecx,[p1] mov ecx,[p1]
mov edx,[p2] mov edx,[p2]
mov eax,[edx+offs_zbup_y] mov eax,[edx+ZBufferPoint.y]
cmp [ecx+offs_zbup_y],eax ;(2-1) cmp [ecx+ZBufferPoint.y],eax ;(2-1)
jle @f jle @f
xchg edx,ecx xchg edx,ecx
@@: @@:
mov eax,[ecx+offs_zbup_y] mov eax,[ecx+ZBufferPoint.y]
cmp [ebx+offs_zbup_y],eax ;(1-0) cmp [ebx+ZBufferPoint.y],eax ;(1-0)
jle @f jle @f
xchg ecx,ebx xchg ecx,ebx
@@: @@:
mov eax,[edx+offs_zbup_y] mov eax,[edx+ZBufferPoint.y]
cmp [ecx+offs_zbup_y],eax ;(2-1) cmp [ecx+ZBufferPoint.y],eax ;(2-1)
jle @f jle @f
xchg edx,ecx xchg edx,ecx
@@: @@:
@ -139,18 +139,18 @@ pushad
mov [p2],edx mov [p2],edx
; we compute dXdx and dXdy for all interpolated values ; we compute dXdx and dXdy for all interpolated values
mov eax,[ecx+offs_zbup_x] mov eax,[ecx+ZBufferPoint.x]
sub eax,[ebx+offs_zbup_x] sub eax,[ebx+ZBufferPoint.x]
mov [fdx1],eax ;p1.x - p0.x mov [fdx1],eax ;p1.x - p0.x
mov eax,[ecx+offs_zbup_y] mov eax,[ecx+ZBufferPoint.y]
sub eax,[ebx+offs_zbup_y] sub eax,[ebx+ZBufferPoint.y]
mov [fdy1],eax ;p1.y - p0.y mov [fdy1],eax ;p1.y - p0.y
mov eax,[edx+offs_zbup_x] mov eax,[edx+ZBufferPoint.x]
sub eax,[ebx+offs_zbup_x] sub eax,[ebx+ZBufferPoint.x]
mov [fdx2],eax ;p2.x - p0.x mov [fdx2],eax ;p2.x - p0.x
mov eax,[edx+offs_zbup_y] mov eax,[edx+ZBufferPoint.y]
sub eax,[ebx+offs_zbup_y] sub eax,[ebx+ZBufferPoint.y]
mov [fdy2],eax ;p2.y - p0.y mov [fdy2],eax ;p2.y - p0.y
fild dword[fdx1] fild dword[fdx1]
@ -183,11 +183,11 @@ pushad
fstp dword[fdy2] ;fdy2 *= fz fstp dword[fdy2] ;fdy2 *= fz
if INTERP_Z eq 1 if INTERP_Z eq 1
mov eax,[ecx+offs_zbup_z] mov eax,[ecx+ZBufferPoint.z]
sub eax,[ebx+offs_zbup_z] sub eax,[ebx+ZBufferPoint.z]
mov [d1],eax mov [d1],eax
mov eax,[edx+offs_zbup_z] mov eax,[edx+ZBufferPoint.z]
sub eax,[ebx+offs_zbup_z] sub eax,[ebx+ZBufferPoint.z]
mov [d2],eax mov [d2],eax
fild dword[d1] ;d1 = p1.z - p0.z fild dword[d1] ;d1 = p1.z - p0.z
fild dword[d2] ;d2 = p2.z - p0.z fild dword[d2] ;d2 = p2.z - p0.z
@ -198,11 +198,11 @@ if INTERP_Z eq 1
end if end if
if INTERP_RGB eq 1 if INTERP_RGB eq 1
mov eax,[ecx+offs_zbup_r] mov eax,[ecx+ZBufferPoint.r]
sub eax,[ebx+offs_zbup_r] sub eax,[ebx+ZBufferPoint.r]
mov [d1],eax mov [d1],eax
mov eax,[edx+offs_zbup_r] mov eax,[edx+ZBufferPoint.r]
sub eax,[ebx+offs_zbup_r] sub eax,[ebx+ZBufferPoint.r]
mov [d2],eax mov [d2],eax
fild dword[d1] ;d1 = p1.r - p0.r fild dword[d1] ;d1 = p1.r - p0.r
fild dword[d2] ;d2 = p2.r - p0.r fild dword[d2] ;d2 = p2.r - p0.r
@ -211,11 +211,11 @@ if INTERP_RGB eq 1
;drdy = (int) (fdx1*d2 - fdx2*d1) ;drdy = (int) (fdx1*d2 - fdx2*d1)
calc_d1d2 fi, drdx, drdy calc_d1d2 fi, drdx, drdy
mov eax,[ecx+offs_zbup_g] mov eax,[ecx+ZBufferPoint.g]
sub eax,[ebx+offs_zbup_g] sub eax,[ebx+ZBufferPoint.g]
mov [d1],eax mov [d1],eax
mov eax,[edx+offs_zbup_g] mov eax,[edx+ZBufferPoint.g]
sub eax,[ebx+offs_zbup_g] sub eax,[ebx+ZBufferPoint.g]
mov [d2],eax mov [d2],eax
fild dword[d1] ;d1 = p1.g - p0.g fild dword[d1] ;d1 = p1.g - p0.g
fild dword[d2] ;d2 = p2.g - p0.g fild dword[d2] ;d2 = p2.g - p0.g
@ -224,11 +224,11 @@ if INTERP_RGB eq 1
;dgdy = (int) (fdx1*d2 - fdx2*d1) ;dgdy = (int) (fdx1*d2 - fdx2*d1)
calc_d1d2 fi, dgdx, dgdy calc_d1d2 fi, dgdx, dgdy
mov eax,[ecx+offs_zbup_b] mov eax,[ecx+ZBufferPoint.b]
sub eax,[ebx+offs_zbup_b] sub eax,[ebx+ZBufferPoint.b]
mov [d1],eax mov [d1],eax
mov eax,[edx+offs_zbup_b] mov eax,[edx+ZBufferPoint.b]
sub eax,[ebx+offs_zbup_b] sub eax,[ebx+ZBufferPoint.b]
mov [d2],eax mov [d2],eax
fild dword[d1] ;d1 = p1.b - p0.b fild dword[d1] ;d1 = p1.b - p0.b
fild dword[d2] ;d2 = p2.b - p0.b fild dword[d2] ;d2 = p2.b - p0.b
@ -239,11 +239,11 @@ if INTERP_RGB eq 1
end if end if
if INTERP_ST eq 1 if INTERP_ST eq 1
mov eax,[ecx+offs_zbup_s] mov eax,[ecx+ZBufferPoint.s]
sub eax,[ebx+offs_zbup_s] sub eax,[ebx+ZBufferPoint.s]
mov [d1],eax mov [d1],eax
mov eax,[edx+offs_zbup_s] mov eax,[edx+ZBufferPoint.s]
sub eax,[ebx+offs_zbup_s] sub eax,[ebx+ZBufferPoint.s]
mov [d2],eax mov [d2],eax
fild dword[d1] ;d1 = p1.s - p0.s fild dword[d1] ;d1 = p1.s - p0.s
fild dword[d2] ;d2 = p2.s - p0.s fild dword[d2] ;d2 = p2.s - p0.s
@ -252,11 +252,11 @@ if INTERP_ST eq 1
;dsdy = (int) (fdx1*d2 - fdx2*d1) ;dsdy = (int) (fdx1*d2 - fdx2*d1)
calc_d1d2 fi, dsdx, dsdy calc_d1d2 fi, dsdx, dsdy
mov eax,[ecx+offs_zbup_t] mov eax,[ecx+ZBufferPoint.t]
sub eax,[ebx+offs_zbup_t] sub eax,[ebx+ZBufferPoint.t]
mov [d1],eax mov [d1],eax
mov eax,[edx+offs_zbup_t] mov eax,[edx+ZBufferPoint.t]
sub eax,[ebx+offs_zbup_t] sub eax,[ebx+ZBufferPoint.t]
mov [d2],eax mov [d2],eax
fild dword[d1] ;d1 = p1.t - p0.t fild dword[d1] ;d1 = p1.t - p0.t
fild dword[d2] ;d2 = p2.t - p0.t fild dword[d2] ;d2 = p2.t - p0.t
@ -267,43 +267,43 @@ if INTERP_ST eq 1
end if end if
if INTERP_STZ eq 1 if INTERP_STZ eq 1
fild dword[ebx+offs_zbup_z] fild dword[ebx+ZBufferPoint.z]
fild dword[ebx+offs_zbup_s] fild dword[ebx+ZBufferPoint.s]
fmul st0,st1 fmul st0,st1
fstp dword[ebx+offs_zbup_sz] ;p0.sz = (float) p0.s * p0.z fstp dword[ebx+ZBufferPoint.fsz] ;p0.sz = (float) p0.s * p0.z
fild dword[ebx+offs_zbup_t] fild dword[ebx+ZBufferPoint.t]
fmulp fmulp
fstp dword[ebx+offs_zbup_tz] ;p0.tz = (float) p0.t * p0.z fstp dword[ebx+ZBufferPoint.tz] ;p0.tz = (float) p0.t * p0.z
fild dword[ecx+offs_zbup_z] fild dword[ecx+ZBufferPoint.z]
fild dword[ecx+offs_zbup_s] fild dword[ecx+ZBufferPoint.s]
fmul st0,st1 fmul st0,st1
fstp dword[ecx+offs_zbup_sz] ;p1.sz = (float) p1.s * p1.z fstp dword[ecx+ZBufferPoint.fsz] ;p1.sz = (float) p1.s * p1.z
fild dword[ecx+offs_zbup_t] fild dword[ecx+ZBufferPoint.t]
fmulp fmulp
fstp dword[ecx+offs_zbup_tz] ;p1.tz = (float) p1.t * p1.z fstp dword[ecx+ZBufferPoint.tz] ;p1.tz = (float) p1.t * p1.z
fild dword[edx+offs_zbup_z] fild dword[edx+ZBufferPoint.z]
fild dword[edx+offs_zbup_s] fild dword[edx+ZBufferPoint.s]
fmul st0,st1 fmul st0,st1
fstp dword[edx+offs_zbup_sz] ;p2.sz = (float) p2.s * p2.z fstp dword[edx+ZBufferPoint.fsz] ;p2.sz = (float) p2.s * p2.z
fild dword[edx+offs_zbup_t] fild dword[edx+ZBufferPoint.t]
fmulp fmulp
fstp dword[edx+offs_zbup_tz] ;p2.tz = (float) p2.t * p2.z fstp dword[edx+ZBufferPoint.tz] ;p2.tz = (float) p2.t * p2.z
fld dword[ecx+offs_zbup_sz] fld dword[ecx+ZBufferPoint.fsz]
fsub dword[ebx+offs_zbup_sz] ;d1 = p1.sz - p0.sz fsub dword[ebx+ZBufferPoint.fsz] ;d1 = p1.sz - p0.sz
fld dword[edx+offs_zbup_sz] fld dword[edx+ZBufferPoint.fsz]
fsub dword[ebx+offs_zbup_sz] ;d2 = p2.sz - p0.sz fsub dword[ebx+ZBufferPoint.fsz] ;d2 = p2.sz - p0.sz
;dszdx = (fdy2*d1 - fdy1*d2) ;dszdx = (fdy2*d1 - fdy1*d2)
;dszdy = (fdx1*d2 - fdx2*d1) ;dszdy = (fdx1*d2 - fdx2*d1)
calc_d1d2 f, dszdx, dszdy calc_d1d2 f, dszdx, dszdy
fld dword[ecx+offs_zbup_tz] fld dword[ecx+ZBufferPoint.tz]
fsub dword[ebx+offs_zbup_tz] ;d1 = p1.tz - p0.tz fsub dword[ebx+ZBufferPoint.tz] ;d1 = p1.tz - p0.tz
fld dword[edx+offs_zbup_tz] fld dword[edx+ZBufferPoint.tz]
fsub dword[ebx+offs_zbup_tz] ;d2 = p2.tz - p0.tz fsub dword[ebx+ZBufferPoint.tz] ;d2 = p2.tz - p0.tz
;dtzdx = (fdy2*d1 - fdy1*d2) ;dtzdx = (fdy2*d1 - fdy1*d2)
;dtzdy = (fdx1*d2 - fdx2*d1) ;dtzdy = (fdx1*d2 - fdx2*d1)
@ -312,14 +312,14 @@ end if
; screen coordinates ; screen coordinates
mov eax,[zb] mov eax,[zb]
mov edx,[eax+offs_zbuf_linesize] mov edx,[eax+ZBuffer.linesize]
imul edx,[ebx+offs_zbup_y] imul edx,[ebx+ZBufferPoint.y]
add edx,[eax+offs_zbuf_pbuf] add edx,[eax+ZBuffer.pbuf]
mov [pp1],edx ;pp1 = zb.pbuf + zb.linesize * p0.y mov [pp1],edx ;pp1 = zb.pbuf + zb.linesize * p0.y
mov edx,[eax+offs_zbuf_xsize] mov edx,[eax+ZBuffer.xsize]
imul edx,[ebx+offs_zbup_y] imul edx,[ebx+ZBufferPoint.y]
shl edx,1 shl edx,1
add edx,[eax+offs_zbuf_zbuf] add edx,[eax+ZBuffer.zbuf]
mov [pz1],edx ;pz1 = zb.zbuf + zb.xsize * p0.y mov [pz1],edx ;pz1 = zb.zbuf + zb.xsize * p0.y
DRAW_INIT DRAW_INIT
@ -349,8 +349,8 @@ align 4
mov [l2],ecx mov [l2],ecx
mov [pr2],edx mov [pr2],edx
.end_1: .end_1:
mov eax,[ecx+offs_zbup_y] mov eax,[ecx+ZBufferPoint.y]
sub eax,[ebx+offs_zbup_y] sub eax,[ebx+ZBufferPoint.y]
mov [nb_lines],eax ;nb_lines = p1.y - p0.y mov [nb_lines],eax ;nb_lines = p1.y - p0.y
jmp .end_0 jmp .end_0
align 4 align 4
@ -374,8 +374,8 @@ align 4
mov [l1],ecx mov [l1],ecx
mov [l2],edx mov [l2],edx
.end_2: .end_2:
mov eax,[edx+offs_zbup_y] mov eax,[edx+ZBufferPoint.y]
sub eax,[ecx+offs_zbup_y] sub eax,[ecx+ZBufferPoint.y]
inc eax inc eax
mov [nb_lines],eax ;nb_lines = p2.y - p1.y + 1 mov [nb_lines],eax ;nb_lines = p2.y - p1.y + 1
.end_0: .end_0:
@ -385,11 +385,11 @@ align 4
je .end_upd_l je .end_upd_l
mov ebx,[l1] mov ebx,[l1]
mov ecx,[l2] mov ecx,[l2]
mov edx,[ecx+offs_zbup_y] mov edx,[ecx+ZBufferPoint.y]
sub edx,[ebx+offs_zbup_y] sub edx,[ebx+ZBufferPoint.y]
mov [dy1],edx ;dy1 = l2.y - l1.y mov [dy1],edx ;dy1 = l2.y - l1.y
mov eax,[ecx+offs_zbup_x] mov eax,[ecx+ZBufferPoint.x]
sub eax,[ebx+offs_zbup_x] sub eax,[ebx+ZBufferPoint.x]
mov [dx1],eax ;dx1 = l2.x - l1.x mov [dx1],eax ;dx1 = l2.x - l1.x
cmp edx,0 ;if (dy1 > 0) cmp edx,0 ;if (dy1 > 0)
jle .els_3 jle .els_3
@ -412,7 +412,7 @@ align 4
.els_3: .els_3:
xor eax,eax xor eax,eax
.end_3: .end_3:
mov edx,[ebx+offs_zbup_x] mov edx,[ebx+ZBufferPoint.x]
mov [x1],edx ;x1 = l1.x mov [x1],edx ;x1 = l1.x
mov dword[error],0 ;error = 0 mov dword[error],0 ;error = 0
mov dword[derror],eax mov dword[derror],eax
@ -424,7 +424,7 @@ align 4
if INTERP_Z eq 1 if INTERP_Z eq 1
mov eax,[l1] mov eax,[l1]
mov eax,[eax+offs_zbup_z] mov eax,[eax+ZBufferPoint.z]
mov [z1],eax ;z1 = l1.z mov [z1],eax ;z1 = l1.z
mov eax,[dzdx] mov eax,[dzdx]
imul eax,[dxdy_min] imul eax,[dxdy_min]
@ -435,7 +435,7 @@ if INTERP_Z eq 1
end if end if
if INTERP_RGB eq 1 if INTERP_RGB eq 1
mov ebx,[l1] mov ebx,[l1]
mov eax,[ebx+offs_zbup_r] mov eax,[ebx+ZBufferPoint.r]
mov [r1],eax ;r1 = l1.r mov [r1],eax ;r1 = l1.r
mov eax,[drdx] mov eax,[drdx]
imul eax,[dxdy_min] imul eax,[dxdy_min]
@ -444,7 +444,7 @@ if INTERP_RGB eq 1
add eax,[drdx] add eax,[drdx]
mov [drdl_max],eax ;drdl_max = drdl_min +drdx mov [drdl_max],eax ;drdl_max = drdl_min +drdx
mov eax,[ebx+offs_zbup_g] mov eax,[ebx+ZBufferPoint.g]
mov [g1],eax ;g1 = l1.g mov [g1],eax ;g1 = l1.g
mov eax,[dgdx] mov eax,[dgdx]
imul eax,[dxdy_min] imul eax,[dxdy_min]
@ -453,7 +453,7 @@ if INTERP_RGB eq 1
add eax,[dgdx] add eax,[dgdx]
mov [dgdl_max],eax ;dgdl_max = dgdl_min +dgdx mov [dgdl_max],eax ;dgdl_max = dgdl_min +dgdx
mov eax,[ebx+offs_zbup_b] mov eax,[ebx+ZBufferPoint.b]
mov [b1],eax ;b1 = l1.b mov [b1],eax ;b1 = l1.b
mov eax,[dbdx] mov eax,[dbdx]
imul eax,[dxdy_min] imul eax,[dxdy_min]
@ -464,7 +464,7 @@ if INTERP_RGB eq 1
end if end if
if INTERP_ST eq 1 if INTERP_ST eq 1
mov ebx,[l1] mov ebx,[l1]
mov eax,[ebx+offs_zbup_s] mov eax,[ebx+ZBufferPoint.s]
mov [s1],eax ;s1 = l1.s mov [s1],eax ;s1 = l1.s
mov eax,[dsdx] mov eax,[dsdx]
imul eax,[dxdy_min] imul eax,[dxdy_min]
@ -473,7 +473,7 @@ if INTERP_ST eq 1
add eax,[dsdx] add eax,[dsdx]
mov [dsdl_max],eax ;dsdl_max = dsdl_min +dsdx mov [dsdl_max],eax ;dsdl_max = dsdl_min +dsdx
mov eax,[ebx+offs_zbup_t] mov eax,[ebx+ZBufferPoint.t]
mov [t1],eax ;t1 = l1.t mov [t1],eax ;t1 = l1.t
mov eax,[dtdx] mov eax,[dtdx]
imul eax,[dxdy_min] imul eax,[dxdy_min]
@ -484,7 +484,7 @@ if INTERP_ST eq 1
end if end if
if INTERP_STZ eq 1 if INTERP_STZ eq 1
mov ebx,[l1] mov ebx,[l1]
mov eax,[ebx+offs_zbup_sz] mov eax,[ebx+ZBufferPoint.fsz]
mov [sz1],eax ;sz1 = l1.sz - преобразований нет, потому без сопроцессора mov [sz1],eax ;sz1 = l1.sz - преобразований нет, потому без сопроцессора
fild dword[dxdy_min] fild dword[dxdy_min]
fmul dword[dszdx] fmul dword[dszdx]
@ -493,7 +493,7 @@ if INTERP_STZ eq 1
fadd dword[dszdx] fadd dword[dszdx]
fstp dword[dszdl_max] ;dszdl_max = dszdl_min +dszdx fstp dword[dszdl_max] ;dszdl_max = dszdl_min +dszdx
mov eax,[ebx+offs_zbup_tz] mov eax,[ebx+ZBufferPoint.tz]
mov [tz1],eax ;tz1 = l1.tz - преобразований нет, потому без сопроцессора mov [tz1],eax ;tz1 = l1.tz - преобразований нет, потому без сопроцессора
fild dword[dxdy_min] fild dword[dxdy_min]
fmul dword[dtzdx] fmul dword[dtzdx]
@ -510,14 +510,14 @@ end if
je .end_upd_r je .end_upd_r
mov ebx,[pr1] mov ebx,[pr1]
mov ecx,[pr2] mov ecx,[pr2]
mov edx,[ebx+offs_zbup_x] mov edx,[ebx+ZBufferPoint.x]
mov eax,[ecx+offs_zbup_x] mov eax,[ecx+ZBufferPoint.x]
sub eax,edx sub eax,edx
;mov [dx2],eax ;dx2 = pr2.x - pr1.x ;mov [dx2],eax ;dx2 = pr2.x - pr1.x
shl edx,16 shl edx,16
mov [x2],edx ; x2 = pr1.x << 16 mov [x2],edx ; x2 = pr1.x << 16
mov edx,[ecx+offs_zbup_y] mov edx,[ecx+ZBufferPoint.y]
sub edx,[ebx+offs_zbup_y] sub edx,[ebx+ZBufferPoint.y]
mov [dy2],edx ;dy2 = pr2.y - pr1.y mov [dy2],edx ;dy2 = pr2.y - pr1.y
cmp edx,0 ;if (dy2 > 0) cmp edx,0 ;if (dy2 > 0)
jle .els_4 jle .els_4
@ -763,9 +763,9 @@ end if
; screen coordinates ; screen coordinates
mov ebx,[zb] mov ebx,[zb]
mov eax,[ebx+offs_zbuf_linesize] mov eax,[ebx+ZBuffer.linesize]
add [pp1],eax add [pp1],eax
mov eax,[ebx+offs_zbuf_xsize] mov eax,[ebx+ZBuffer.xsize]
shl eax,1 shl eax,1
add [pz1],eax add [pz1],eax
jmp .beg_w_lin jmp .beg_w_lin