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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -40,22 +40,16 @@ ends
align 4
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 edi,[ecx] ; edi = xsize
mov esi,[ysize_ptr] ; esi = &ysize
mov esi,[esi] ; esi = ysize
; we ensure that xsize and ysize are multiples of 2 for the zbuffer.
; TODO: find a better solution
and edi, not 3
and esi, not 3
cmp edi,0
jne @f
cmp esi,0
jne @f
xor eax,eax
or edi,edi
jnz @f
or esi,esi
jnz @f
mov eax,-1
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 edx,[ebx+GLContext.opaque] ; edx = (TinyGLContext *)context.opaque
mov [edx+4],edi
mov [edx+12],edi ;d_x = xsize
mov [edx+8],esi
mov [edx+16],esi ;d_y = ysize
mov [edx+TinyGLContext.xsize],edi
mov [edx+TinyGLContext.d_x],edi
mov [edx+TinyGLContext.ysize],esi
mov [edx+TinyGLContext.d_y],esi
; resize the Z buffer
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
; create the TinyGL context
mov ecx,[win_x0]
mov [ebx+20],ecx ;ctx.x = win_x0
mov [ebx+TinyGLContext.x],ecx
mov ecx,[win_y0]
mov [ebx+24],ecx ;ctx.y = win_y0
mov [ebx+TinyGLContext.y],ecx
mov ecx,[win_x]
mov [ebx+12],ecx ;ctx.d_x = win_x
mov [ebx+TinyGLContext.d_x],ecx
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
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
; set the viewport : we force a call to gl_resize_viewport
dec dword[eax+GLContext.viewport+offs_vpor_xsize]
dec dword[eax+GLContext.viewport+offs_vpor_ysize]
dec dword[eax+GLContext.viewport+GLViewport.xsize]
dec dword[eax+GLContext.viewport+GLViewport.ysize]
stdcall glViewport, 0, 0, [win_x], [win_y]
.end_f:
@ -132,15 +126,15 @@ proc kosglSwapBuffers uses eax ebx ecx edx esi
; retrieve the current TinyGLContext
call gl_get_context
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 eax,7
mov ecx,[esi+12] ;d_x
mov eax,SF_PUT_IMAGE
mov ecx,[esi+TinyGLContext.d_x]
shl ecx,16
mov cx,[esi+16] ;d_y
mov edx,[esi+20] ;x
mov cx,word[esi+TinyGLContext.d_y]
mov edx,[esi+TinyGLContext.x]
shl edx,16
mov dx,[esi+24] ;y
mov dx,word[esi+TinyGLContext.y]
int 0x40
ret
endp

View File

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

View File

@ -23,16 +23,16 @@ endl
; 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
mov ecx,[xmin]
cmp dword[edx+GLContext.viewport+offs_vpor_xmin],ecx
cmp dword[edx+GLContext.viewport+GLViewport.xmin],ecx
jne @f
mov ecx,[ymin]
cmp dword[edx+GLContext.viewport+offs_vpor_ymin],ecx
cmp dword[edx+GLContext.viewport+GLViewport.ymin],ecx
jne @f
mov ecx,[xsize]
cmp dword[edx+GLContext.viewport+offs_vpor_xsize],ecx
cmp dword[edx+GLContext.viewport+GLViewport.xsize],ecx
jne @f
jmp .end_f
@@:
@ -70,15 +70,15 @@ endl
stdcall dbg_print,sz_glViewport,err_5
@@:
mov ecx,[xmin]
mov dword[edx+GLContext.viewport+offs_vpor_xmin],ecx
mov dword[edx+GLContext.viewport+GLViewport.xmin],ecx
mov ecx,[ymin]
mov dword[edx+GLContext.viewport+offs_vpor_ymin],ecx
mov dword[edx+GLContext.viewport+GLViewport.ymin],ecx
mov ecx,[xsize]
mov dword[edx+GLContext.viewport+offs_vpor_xsize],ecx
mov dword[edx+GLContext.viewport+GLViewport.xsize],ecx
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:
ret
endp

View File

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

View File

@ -85,31 +85,31 @@ endl
fadd st1,st0 ;st1 = 2.0
fdiv st0,st1 ;st0 = 0.5
fild dword[eax+offs_vpor_xsize]
fild dword[eax+GLViewport.xsize]
fsub st0,st1
fdiv st0,st2
fst dword[eax+offs_vpor_scale+offs_X]
fiadd dword[eax+offs_vpor_xmin]
fstp dword[eax+offs_vpor_trans+offs_X]
fst dword[eax+GLViewport.scale+offs_X]
fiadd dword[eax+GLViewport.xmin]
fstp dword[eax+GLViewport.trans+offs_X]
fild dword[eax+offs_vpor_ysize]
fild dword[eax+GLViewport.ysize]
fsub st0,st1
fdiv st0,st2
fchs
fst dword[eax+offs_vpor_scale+offs_Y]
fst dword[eax+GLViewport.scale+offs_Y]
fchs
fiadd dword[eax+offs_vpor_ymin]
fstp dword[eax+offs_vpor_trans+offs_Y]
fiadd dword[eax+GLViewport.ymin]
fstp dword[eax+GLViewport.trans+offs_Y]
fld dword[zsize]
fsub st0,st1
fdiv st0,st2
fchs
fst dword[eax+offs_vpor_scale+offs_Z]
fst dword[eax+GLViewport.scale+offs_Z]
fchs
mov dword[zsize],(1 shl ZB_POINT_Z_FRAC_BITS) / 2
fiadd dword[zsize]
fstp dword[eax+offs_vpor_trans+offs_Z]
fstp dword[eax+GLViewport.trans+offs_Z]
ret
endp
@ -197,10 +197,10 @@ align 4
.end_mmpu:
; 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
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
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 eax,[ysize]
mov [edi+offs_zbuf_ysize],eax
mov [edi+ZBuffer.ysize],eax
mov eax,[xsize]
mov [edi+offs_zbuf_xsize],eax
mov [edi+ZBuffer.xsize],eax
imul eax,PSZB
add eax,3
and eax,not 3
mov [edi+offs_zbuf_linesize],eax
mov [edi+ZBuffer.linesize],eax
mov eax,[mode]
mov [edi+offs_zbuf_mode],eax
mov [edi+ZBuffer.mode],eax
if TGL_FEATURE_32_BITS eq 1
cmp eax,ZB_MODE_RGBA
@ -41,29 +39,29 @@ end if
cmp eax,ZB_MODE_5R6G5B
jne @f
.correct:
mov dword[edi+offs_zbuf_nb_colors],0
mov dword[edi+ZBuffer.nb_colors],0
jmp .end_s
@@: ;default:
stdcall dbg_print,f_zb_opn,err_3
jmp .error
.end_s:
mov ecx,[edi+offs_zbuf_xsize]
imul ecx,[edi+offs_zbuf_ysize]
mov ecx,[edi+ZBuffer.xsize]
imul ecx,[edi+ZBuffer.ysize]
shl ecx,1 ;*= sizeof(unsigned short)
stdcall gl_malloc, ecx
mov [edi+offs_zbuf_zbuf],eax
mov [edi+ZBuffer.zbuf],eax
cmp eax,0
jne @f
stdcall dbg_print,f_zb_opn,err_2
jmp .error
@@:
mov dword[edi+offs_zbuf_frame_buffer_allocated],0
mov dword[edi+offs_zbuf_pbuf],0 ;NULL
mov dword[edi+ZBuffer.frame_buffer_allocated],0
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
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
mov ebx,[zb]
; xsize must be a multiple of 4
mov edi,[xsize]
and edi,not 3
mov esi,[ysize]
mov [ebx+offs_zbuf_xsize], edi
mov [ebx+offs_zbuf_ysize], esi
mov [ebx+ZBuffer.xsize], edi
mov [ebx+ZBuffer.ysize], esi
mov eax,edi
imul eax,PSZB
add eax,3
and eax,not 3
mov [ebx+offs_zbuf_linesize],eax ;zb.linesize = (xsize * PSZB + 3) & ~3
mov [ebx+ZBuffer.linesize],eax ;zb.linesize = (xsize * PSZB + 3) & ~3
mov ecx,edi
imul ecx,esi
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
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
stdcall gl_free,dword[ebx+offs_zbuf_pbuf]
stdcall gl_free,dword[ebx+ZBuffer.pbuf]
@@:
cmp dword[frame_buffer],0
jne .els_0
inc esi
imul esi,dword[ebx+offs_zbuf_linesize]
imul esi,dword[ebx+ZBuffer.linesize]
stdcall gl_malloc,esi
mov dword[ebx+offs_zbuf_pbuf],eax
mov dword[ebx+offs_zbuf_frame_buffer_allocated],1
mov dword[ebx+ZBuffer.pbuf],eax
mov dword[ebx+ZBuffer.frame_buffer_allocated],1
jmp @f
.els_0:
mov eax,[frame_buffer]
mov dword[ebx+offs_zbuf_pbuf],eax
mov dword[ebx+offs_zbuf_frame_buffer_allocated],0
mov dword[ebx+ZBuffer.pbuf],eax
mov dword[ebx+ZBuffer.frame_buffer_allocated],0
@@:
ret
endp
@ -434,11 +428,12 @@ proc memset_l uses eax ecx edi, adr:dword, val:dword, count:dword
ret
endp
; count must be a multiple of 4 and >= 4
;input:
; count - число пикселей RGB для закраски
;destroy:
; edi, esi
; eax, ecx, edi, esi
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 eax,[r] ;копируем в буфер первые 12 байт (минимальное число кратное 3 и 4)
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
jle .end_f ;если ширина буфера меньше 12 байт, то выходим
dec ecx
mov edi,esi
add edi,12
lea edi,[esi+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
lea ecx,[ecx+2*ecx] ;ecx*=3
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
align 16
@@: ;если r!=g или g!=b или b!=r
@ -480,6 +478,12 @@ align 16
movsd
sub esi,12
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:
ret
endp
@ -494,14 +498,19 @@ proc ZB_clear uses eax ebx ecx edi esi, zb:dword, clear_z:dword, z:dword,\
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
mov ebx,[eax+ZBuffer.xsize]
imul ebx,[eax+ZBuffer.ysize]
stdcall memset_s, [eax+ZBuffer.zbuf],[z],ebx
@@:
cmp dword[clear_color],0
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
mov ebx,[eax+offs_zbuf_xsize]
mov ebx,[eax+ZBuffer.xsize]
imul ebx,[eax+ZBuffer.ysize]
push ebx
mov ebx,[b]
shr ebx,8
@ -512,22 +521,8 @@ if TGL_FEATURE_RENDER_BITS eq 24
mov ebx,[r]
shr ebx,8
push ebx
add esp,16
stdcall memset_RGB24, [eax+ZBuffer.pbuf]
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
endp

View File

@ -63,6 +63,7 @@ struct ZBuffer
xsize dd ? ;int
ysize dd ? ;int
linesize dd ? ;int ;line size, in bytes
dd ? ;fix old error offset
mode dd ? ;int
zbuf dd ? ;*unsigned short
@ -78,21 +79,6 @@ struct ZBuffer
t_bound dd ? ;unsigned int
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
x dd ? ;int ;integer coordinates in the zbuffer
y dd ? ;int
@ -107,17 +93,6 @@ struct ZBufferPoint
tz dd ? ;float
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
;

View File

@ -97,14 +97,6 @@ struct GLViewport
updated dd ? ;int
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
ops rd OP_BUFFER_MAX_SIZE ;GLParam[OP_BUFFER_MAX_SIZE]
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
mov eax,[zb]
mov ebx,[p]
mov ecx,[ebx+offs_zbup_y]
imul ecx,[eax+offs_zbuf_xsize]
add ecx,[ebx+offs_zbup_x]
mov ecx,[ebx+ZBufferPoint.y]
imul ecx,[eax+ZBuffer.xsize]
add ecx,[ebx+ZBufferPoint.x]
shl ecx,1
add ecx,[eax+offs_zbuf_zbuf]
mov edx,[eax+offs_zbuf_linesize]
imul edx,[ebx+offs_zbup_y]
mov edi,[ebx+offs_zbup_x]
add ecx,[eax+ZBuffer.zbuf]
mov edx,[eax+ZBuffer.linesize]
imul edx,[ebx+ZBufferPoint.y]
mov edi,[ebx+ZBufferPoint.x]
imul edi,PSZB
add edx,edi
add edx,[eax+offs_zbuf_pbuf]
mov edi,[ebx+offs_zbup_z]
add edx,[eax+ZBuffer.pbuf]
mov edi,[ebx+ZBufferPoint.z]
shr edi,ZB_POINT_Z_FRAC_BITS
cmp di,word[ecx]
jl .end_f
if TGL_FEATURE_RENDER_BITS eq 24
mov eax,[ebx+offs_zbup_r]
mov eax,[ebx+ZBufferPoint.r]
mov byte[edx],ah
mov eax,[ebx+offs_zbup_g]
mov eax,[ebx+ZBufferPoint.g]
mov byte[edx+1],ah
mov eax,[ebx+offs_zbup_b]
mov eax,[ebx+ZBufferPoint.b]
mov byte[edx+2],ah
else
; *pp = RGB_TO_PIXEL(p->r, p->g, p->b);
@ -60,7 +60,7 @@ if DEBUG ;ZB_line_z
push edi
mov ecx,80
mov eax,[p1]
mov eax,[eax+offs_zbup_x]
mov eax,[eax+ZBufferPoint.x]
lea edi,[buf_param]
stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2
@ -69,7 +69,7 @@ push edi
sub ecx,eax
mov eax,[p1]
mov eax,[eax+offs_zbup_y]
mov eax,[eax+ZBufferPoint.y]
stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2
stdcall str_len,edi
@ -77,7 +77,7 @@ push edi
sub ecx,eax
mov eax,[p2]
mov eax,[eax+offs_zbup_x]
mov eax,[eax+ZBufferPoint.x]
stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2
stdcall str_len,edi
@ -85,7 +85,7 @@ push edi
sub ecx,eax
mov eax,[p2]
mov eax,[eax+offs_zbup_y]
mov eax,[eax+ZBufferPoint.y]
stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_nl,2
@ -93,10 +93,10 @@ push edi
pop edi
end if
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 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
cmp ecx,eax
@ -115,7 +115,7 @@ if DEBUG ;ZB_line
push edi
mov ecx,80
mov eax,[p1]
mov eax,[eax+offs_zbup_x]
mov eax,[eax+ZBufferPoint.x]
lea edi,[buf_param]
stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2
@ -124,7 +124,7 @@ push edi
sub ecx,eax
mov eax,[p1]
mov eax,[eax+offs_zbup_y]
mov eax,[eax+ZBufferPoint.y]
stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2
stdcall str_len,edi
@ -132,7 +132,7 @@ push edi
sub ecx,eax
mov eax,[p2]
mov eax,[eax+offs_zbup_x]
mov eax,[eax+ZBufferPoint.x]
stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_zp_sp,2
stdcall str_len,edi
@ -140,7 +140,7 @@ push edi
sub ecx,eax
mov eax,[p2]
mov eax,[eax+offs_zbup_y]
mov eax,[eax+ZBufferPoint.y]
stdcall convert_int_to_str,ecx
stdcall str_n_cat,edi,txt_nl,2
@ -148,10 +148,10 @@ push edi
pop edi
end if
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 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
cmp ecx,eax

View File

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

View File

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

View File

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

View File

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