/programs/develop/libraries/TinyGL/asm_fork/image_util.asm |
---|
243,21 → 243,4 |
jnz .cycyle_0 |
popad |
ret |
endp |
align 4 |
proc gl_getPervPowerOfTwo uses ebx, n:dword |
mov ebx,[n] |
mov eax,(1 shl ZB_POINT_TEXEL_SIZE) ;max size |
cmp ebx,eax |
jge .set |
@@: |
shr eax,1 |
cmp ebx,eax |
jl @b |
cmp eax,8 ;min size |
jge .set |
mov eax,8 |
.set: |
ret |
endp |
/programs/develop/libraries/TinyGL/asm_fork/texture.asm |
---|
209,8 → 209,6 |
locals |
pixels1 dd ? |
do_free dd ? |
aligned_width dd ? |
aligned_height dd ? |
endl |
pushad |
mov edi,[p] |
238,30 → 236,22 |
stdcall dbg_print,sz_glTexImage2D,err_8 ;"glTexImage2D: combinaison of parameters not handled" |
@@: |
stdcall gl_getPervPowerOfTwo,edx |
mov [aligned_width],eax |
stdcall gl_getPervPowerOfTwo,esi |
mov [aligned_height],eax |
mov dword[do_free],0 |
cmp edx,[aligned_width] |
cmp edx,256 |
jne .else |
cmp esi,[aligned_height] |
cmp esi,256 |
jne .else |
mov eax,[edi+36] |
mov [pixels1],eax ;pixels1=pixels |
jmp @f |
align 4 |
.else: ;if (width != aligned_width || height != aligned_height) |
imul eax,[aligned_width] |
imul eax,3 |
stdcall gl_malloc, eax |
mov [pixels1],eax ;pixels1 = gl_malloc(aligned_width * aligned_height * 3) |
.else: ;if (width != 256 || height != 256) |
stdcall gl_malloc, 256*256*3 |
mov [pixels1],eax ;pixels1 = gl_malloc(256 * 256 * 3) |
; no interpolation is done here to respect the original image aliasing ! |
stdcall gl_resizeImage, eax,[aligned_width],[aligned_height],[edi+36],edx,esi |
stdcall gl_resizeImage, eax,256,256,[edi+36],edx,esi |
mov dword[do_free],1 |
mov edx,[aligned_width] |
mov esi,[aligned_height] |
mov edx,256 |
mov esi,256 |
@@: |
mov ecx,[context] |
269,29 → 259,8 |
add ecx,offs_text_images |
imul ebx,sizeof.GLTexture |
add ecx,ebx ;ecx = &context.current_texture.images[level] |
mov [ecx+offs_imag_xsize],edx ;im.xsize=width |
mov [ecx+offs_imag_ysize],esi ;im.ysize=height |
mov ebx,edx |
dec ebx |
shl ebx,ZB_POINT_TEXEL_SIZE |
mov [ecx+offs_imag_s_bound],ebx ;im.s_bound = (unsigned int)(width-1) |
shr ebx,ZB_POINT_TEXEL_SIZE |
mov dword[ecx+offs_imag_xsize_log2],ZB_POINT_TEXEL_SIZE |
or ebx,ebx |
jz .set_l2 |
@@: |
dec dword[ecx+offs_imag_xsize_log2] |
shr ebx,1 |
or ebx,ebx |
jnz @b |
.set_l2: |
;im.xsize_log2 = ZB_POINT_TEXEL_SIZE-log_2(width) |
dec esi |
shl esi,ZB_POINT_TEXEL_SIZE |
mov [ecx+offs_imag_t_bound],esi ;im.t_bound = (unsigned int)(height-1) |
shr esi,ZB_POINT_TEXEL_SIZE |
inc esi |
mov dword[ecx+offs_imag_xsize],edx ;im.xsize=width |
mov dword[ecx+offs_imag_ysize],esi ;im.ysize=height |
cmp dword[ecx+offs_imag_pixmap],0 ;if (im.pixmap!=NULL) |
je @f |
stdcall gl_free, [ecx+offs_imag_pixmap] |
/programs/develop/libraries/TinyGL/asm_fork/clip.asm |
---|
10,6 → 10,9 |
align 16 |
proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword |
locals |
point dd ? |
endl |
mov eax,[context] |
mov ebx,[v] |
61,19 → 64,17 |
; texture |
cmp dword[eax+offs_cont_texture_2d_enabled],0 |
je @f |
mov eax,[eax+offs_cont_current_texture] ;eax = &context.current_texture |
mov eax,[eax] ;eax = context.current_texture |
;[eax+offs_text_images] = im = &context.current_texture.images[0] |
fild dword[eax+offs_text_images+offs_imag_s_bound] |
fmul dword[ebx+offs_vert_tex_coord+offs_X] |
mov dword[point],dword(ZB_POINT_S_MAX - ZB_POINT_S_MIN) |
fild dword[point] |
fmul dword[ebx+offs_vert_tex_coord] ;st0 *= v.tex_coord.X |
fistp dword[ebx+offs_vert_zp+offs_zbup_s] |
;v.zp.s=(int)(v.tex_coord.X * im.s_bound) |
add dword[ebx+offs_vert_zp+offs_zbup_s],ZB_POINT_S_MIN |
fild dword[eax+offs_text_images+offs_imag_t_bound] |
fmul dword[ebx+offs_vert_tex_coord+offs_Y] |
mov dword[point],dword(ZB_POINT_T_MAX - ZB_POINT_T_MIN) |
fild dword[point] |
fmul dword[ebx+offs_vert_tex_coord+offs_Y] ;st0 *= v.tex_coord.Y |
fistp dword[ebx+offs_vert_zp+offs_zbup_t] |
;v.zp.t=(int)(v.tex_coord.Y * im.t_bound) |
add dword[ebx+offs_vert_zp+offs_zbup_t],ZB_POINT_T_MIN |
@@: |
ret |
endp |
1041,11 → 1042,10 |
if PROFILE eq 1 |
inc dword[count_triangles_textured] |
end if |
mov eax,[edx+offs_cont_current_texture] |
mov eax,dword[edx+offs_cont_current_texture] |
mov eax,[eax] ;переход по указателю |
;так как offs_text_images+offs_imag_pixmap = 0 то context.current_texture.images[0].pixmap = [eax] |
stdcall ZB_setTexture, [edx+offs_cont_zb], [eax],\ |
[eax+offs_imag_s_bound],[eax+offs_imag_t_bound],[eax+offs_imag_xsize_log2] |
stdcall ZB_setTexture, dword[edx+offs_cont_zb],dword[eax] |
mov eax,[p0] |
add eax,offs_vert_zp |
push ecx |
/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm |
---|
133,17 → 133,10 |
include 'ztriangle.inc' |
align 16 |
proc ZB_setTexture uses eax ebx, zb:dword, texture:dword,\ |
s_bound:dword, t_bound:dword, s_log2:dword |
proc ZB_setTexture uses eax ebx, zb:dword, texture:dword |
mov eax,[zb] |
mov ebx,[texture] |
mov dword[eax+offs_zbuf_current_texture],ebx |
mov ebx,[s_log2] |
mov dword[eax+offs_zbuf_s_log2],ebx |
mov ebx,[s_bound] |
mov dword[eax+offs_zbuf_s_bound],ebx |
mov ebx,[t_bound] |
mov dword[eax+offs_zbuf_t_bound],ebx |
ret |
endp |
153,14 → 146,8 |
macro DRAW_INIT |
{ |
mov eax,[zb] |
mov ebx,[eax+offs_zbuf_current_texture] |
mov [texture],ebx |
mov ebx,[eax+offs_zbuf_s_log2] |
mov [s_log2],ebx ;s_log2 = zb.s_log2 |
mov ebx,[eax+offs_zbuf_s_bound] |
mov [s_bound],ebx ;s_bound = zb.s_bound |
mov ebx,[eax+offs_zbuf_t_bound] |
mov [t_bound],ebx ;t_bound = zb.t_bound |
mov eax,[eax+offs_zbuf_current_texture] |
mov [texture],eax |
} |
macro PUT_PIXEL _a |
174,13 → 161,11 |
mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение |
if TGL_FEATURE_RENDER_BITS eq 24 |
mov ebx,[t] |
and ebx,[t_bound] |
mov ecx,[s_log2] |
shr ebx,cl ;(t & t_bound) >> s_log2 |
and ebx,0x3fc00000 |
mov eax,[s] |
and eax,[s_bound] |
shr eax,ZB_POINT_TEXEL_SIZE |
and eax,0x003fc000 |
or ebx,eax |
shr ebx,14 |
imul ebx,3 |
add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | s) >> 14) * 3 |
mov ax,word[ebx] |
203,9 → 188,6 |
proc ZB_fillTriangleMapping, zb:dword, p0:dword, p1:dword, p2:dword |
locals |
texture dd ? ;PIXEL* |
s_log2 dd ? ;unsigned int |
s_bound dd ? ;unsigned int |
t_bound dd ? ;unsigned int |
include 'ztriangle.inc' |
; |
213,6 → 195,7 |
; We use the gradient method to make less divisions. |
; TODO: pipeline the division |
; |
if 1 |
INTERP_Z equ 1 |
INTERP_STZ equ 1 |
222,14 → 205,8 |
macro DRAW_INIT |
{ |
mov eax,[zb] |
mov ebx,[eax+offs_zbuf_current_texture] |
mov [texture],ebx |
mov ebx,[eax+offs_zbuf_s_log2] |
mov [s_log2],ebx ;s_log2 = zb.s_log2 |
mov ebx,[eax+offs_zbuf_s_bound] |
mov [s_bound],ebx ;s_bound = zb.s_bound |
mov ebx,[eax+offs_zbuf_t_bound] |
mov [t_bound],ebx ;t_bound = zb.t_bound |
mov eax,[eax+offs_zbuf_current_texture] |
mov [texture],eax |
mov dword[esp-4],NB_INTERP |
fild dword[esp-4] |
fild dword[dzdx] |
254,13 → 231,11 |
mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение |
if TGL_FEATURE_RENDER_BITS eq 24 |
mov ebx,[t] |
and ebx,[t_bound] |
mov ecx,[s_log2] |
shr ebx,cl ;(t & t_bound) >> s_log2 |
and ebx,0x3fc00000 |
mov eax,[s] |
and eax,[s_bound] |
shr eax,ZB_POINT_TEXEL_SIZE |
and eax,0x003fc000 |
or ebx,eax |
shr ebx,14 |
imul ebx,3 |
add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | (s & 0x003FC000)) >> 14) * 3 |
mov ax,word[ebx] |
392,7 → 367,64 |
ndtzdx dd ? ;float |
zinv dd ? ;float |
f_z dd ? ;float - переменная отвечающая за геометрию текстуры |
s_log2 dd ? ;unsigned int |
s_bound dd ? ;unsigned int |
t_bound dd ? ;unsigned int |
include 'ztriangle.inc' |
end if |
if 0 |
; slow but exact version (only there for reference, incorrect for 24 |
; bits) |
INTERP_Z equ 1 |
INTERP_STZ equ 1 |
macro DRAW_INIT |
{ |
mov eax,[zb] |
mov eax,[eax+offs_zbuf_current_texture] |
mov [texture],eax |
} |
macro PUT_PIXEL _a |
{ |
local .end_0 |
mov eax,[z] |
shr eax,ZB_POINT_Z_FRAC_BITS |
cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) |
jl .end_0 |
;edi = pp |
mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение |
fild dword[z] |
fld dword[s_z] |
fdiv st0,st1 |
fistp dword[esp-4] ;s = (int) (s_z / (float) z) |
fld dword[t_z] |
fdiv st0,st1 |
fistp dword[esp-8] ;t = (int) (t_z / (float) z) |
mov eax,dword[esp-8] |
and eax,0x3FC00000 |
or eax,dword[esp-4] |
shr eax,12 ;14 |
add eax,[texture] |
mov eax,[eax] |
stosd ;pp[_a] = texture[((t & 0x3FC00000) | s) >> 14] |
sub edi,4 |
.end_0: |
mov eax,[dzdx] |
add [z],eax |
fld dword[dszdx] |
fadd dword[s_z] |
fstp dword[s_z] |
fld dword,[dtzdx] |
fadd dword[t_z] |
fstp dword[t_z] |
} |
align 16 |
proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword |
locals |
texture dd ? ;PIXEL* |
include 'ztriangle.inc' |
end if |
/programs/develop/libraries/TinyGL/asm_fork/zgl.inc |
---|
169,17 → 169,11 |
pixmap dd ? ;void* |
xsize dd ? ;int |
ysize dd ? ;int |
xsize_log2 dd ? ;unsigned int |
s_bound dd ? ;unsigned int |
t_bound dd ? ;unsigned int |
ends |
offs_imag_pixmap equ 0 |
offs_imag_xsize equ 4 |
offs_imag_ysize equ 8 |
offs_imag_xsize_log2 equ 12 |
offs_imag_s_bound equ 16 |
offs_imag_t_bound equ 20 |
; textures |
/programs/develop/libraries/TinyGL/asm_fork/light.asm |
---|
32,7 → 32,6 |
;add edi,offs_mate_emission ;offs_mate_emission=0 |
rep movsd |
jmp .end_f |
align 4 |
@@: |
cmp ebx,GL_AMBIENT |
jne @f |
39,7 → 38,6 |
add edi,offs_mate_ambient |
rep movsd |
jmp .end_f |
align 4 |
@@: |
cmp ebx,GL_DIFFUSE |
jne @f |
46,7 → 44,6 |
add edi,offs_mate_diffuse |
rep movsd |
jmp .end_f |
align 4 |
@@: |
cmp ebx,GL_SPECULAR |
jne @f |
53,7 → 50,6 |
add edi,offs_mate_specular |
rep movsd |
jmp .end_f |
align 4 |
@@: |
cmp ebx,GL_SHININESS |
jne @f |
65,7 → 61,6 |
fimul dword[edi] |
fistp dword[edi] ;m.shininess_i = (v[0]/128.0f)*SPECULAR_BUFFER_RESOLUTION |
jmp .end_f |
align 4 |
@@: |
cmp ebx,GL_AMBIENT_AND_DIFFUSE |
jne @f |
76,7 → 71,6 |
mov ecx,4 |
rep movsd |
jmp .end_f |
align 4 |
@@: ;default |
; assert(0); |
.end_f: |
121,7 → 115,6 |
mov ecx,4 |
rep movsd ;l.ambient=v |
jmp .end_f |
align 4 |
@@: |
cmp ecx,GL_DIFFUSE |
jne @f |
132,7 → 125,6 |
mov ecx,4 |
rep movsd ;l.diffuse=v |
jmp .end_f |
align 4 |
@@: |
cmp ecx,GL_SPECULAR |
jne @f |
143,7 → 135,6 |
mov ecx,4 |
rep movsd ;l.specular=v |
jmp .end_f |
align 4 |
@@: |
cmp ecx,GL_POSITION |
jne @f |
177,7 → 168,6 |
ffree st0 |
fincstp |
jmp .end_f |
align 4 |
@@: |
cmp ecx,GL_SPOT_DIRECTION |
jne @f |
198,7 → 188,6 |
add edx,offs_ligh_norm_spot_direction |
stdcall gl_V3_Norm,edx |
jmp .end_f |
align 4 |
@@: |
cmp ecx,GL_SPOT_EXPONENT |
jne @f |
205,7 → 194,6 |
mov ecx,[ebx+12] |
mov [edi+offs_ligh_spot_exponent],ecx ;l.spot_exponent=p[3] |
jmp .end_f |
align 4 |
@@: |
cmp ecx,GL_SPOT_CUTOFF |
jne .end_spot_c |
226,7 → 214,6 |
ffree st0 |
fincstp |
jmp .end_f |
align 4 |
.end_spot_c: |
cmp ecx,GL_CONSTANT_ATTENUATION |
jne @f |
233,7 → 220,6 |
mov ecx,[ebx+12] |
mov [edi+offs_ligh_attenuation],ecx ;l->attenuation[0]=p[3] |
jmp .end_f |
align 4 |
@@: |
cmp ecx,GL_LINEAR_ATTENUATION |
jne @f |
240,7 → 226,6 |
mov ecx,[ebx+12] |
mov [edi+offs_ligh_attenuation+4],ecx ;l->attenuation[1]=p[3] |
jmp .end_f |
align 4 |
@@: |
cmp ecx,GL_QUADRATIC_ATTENUATION |
jne @f |
247,7 → 232,6 |
mov ecx,[ebx+12] |
mov [edi+offs_ligh_attenuation+8],ecx ;l->attenuation[2]=p[3] |
jmp .end_f |
align 4 |
@@: ;default: |
; assert(0); |
.end_f: |
270,7 → 254,6 |
add edi,offs_cont_ambient_light_model |
rep movsd ;for(i=0;i<4;i++) context.ambient_light_model.v[i]=v[i] |
jmp .end_f |
align 4 |
@@: |
cmp ebx,GL_LIGHT_MODEL_LOCAL_VIEWER |
jne @f |
277,7 → 260,6 |
fld dword[esi] ;st0 = p[2] |
fistp dword[edi+offs_cont_local_light_model] |
jmp .end_f |
align 4 |
@@: |
cmp ebx,GL_LIGHT_MODEL_TWO_SIDE |
jne @f |
284,7 → 266,6 |
fld dword[esi] ;st0 = p[2] |
fistp dword[edi+offs_cont_light_model_two_side] |
jmp .end_f |
align 4 |
@@: ;default: |
; tgl_warning("glopLightModel: illegal pname: 0x%x\n", ebx); |
; //assert(0); |
306,7 → 287,6 |
fincstp |
mov eax,0.0 |
jmp .end_m ;return 0.0 |
align 4 |
.o_1: |
fld1 ;else if (a>=1.0) |
fcompp |
315,7 → 295,6 |
ja .o_2 |
mov eax,1.0 |
jmp .end_m ;return 1.0 |
align 4 |
.o_2: |
mov eax,dword a ;else return a |
.end_m: |
344,7 → 323,6 |
mov [eax+offs_cont_first_light],ebx ;context.first_light = l |
mov dword[ebx+offs_ligh_prev],0 ;l.prev = NULL |
jmp .end_f |
align 4 |
@@: |
xor ecx,ecx |
cmp dword[v],0 |
361,7 → 339,6 |
jne .els_0 |
mov [eax+offs_cont_first_light],ecx ;context.first_light = l.next |
jmp @f |
align 4 |
.els_0: |
mov eax,[ebx+offs_ligh_prev] |
mov [eax+offs_ligh_next],ecx ;l.prev.next = l.next |
379,7 → 356,7 |
fl_1e_3 dd 1.0e-3 |
; non optimized lightening model |
align 16 |
align 4 |
proc gl_shade_vertex, context:dword, v:dword |
locals |
R dd ? ;float ebp-96 |
475,7 → 452,6 |
mov [d+offs_Z],eax ;d.Z=l.norm_position.v[2] |
mov dword[att],1.0 |
jmp .els_0_end |
align 4 |
.els_0: |
; distance attenuation |
ffree st0 ;l.position.v[3] |
601,7 → 577,6 |
fincstp |
mov ebx,[ebx+offs_ligh_next] |
jmp .cycle_0 ;continue |
align 4 |
.els_1: |
; TODO: optimize |
fld dword[ebx+offs_ligh_spot_exponent] |
627,7 → 602,6 |
fmul dword[att] |
fstp dword[att] ;att=att*pow(dot_spot,l.spot_exponent) |
jmp .if1_end_f1 |
align 4 |
@@: |
ffree st0 ;l.spot_exponent |
fincstp |
658,7 → 632,6 |
fsub dword[vcoord+offs_Z] |
fstp dword[s+offs_Z] ;s.Z=d.Z-vcoord.Z |
jmp .els_2_end |
align 4 |
.els_2: |
mov eax,[d] |
mov [s],eax ;s.X=d.X |
761,7 → 734,6 |
fincstp |
mov ebx,[ebx+offs_ligh_next] |
jmp .cycle_0 |
align 4 |
.cycle_0_end: |
clampf [R],0,1 |
/programs/develop/libraries/TinyGL/asm_fork/zbuffer.inc |
---|
8,8 → 8,10 |
ZB_POINT_Z_FRAC_BITS equ 14 |
ZB_POINT_TEXEL_SIZE equ 12 ;точность множителя для вычисления координат текселя |
;влияет на максимальный размер текстуры |
ZB_POINT_S_MIN equ (1 shl 13) |
ZB_POINT_S_MAX equ ( (1 shl 22)-(1 shl 13) ) |
ZB_POINT_T_MIN equ (1 shl 21) |
ZB_POINT_T_MAX equ ( (1 shl 30)-(1 shl 21) ) |
ZB_POINT_RED_MIN equ (1 shl 8) |
ZB_POINT_RED_MAX equ ( (1 shl 16)-1 ) |
25,8 → 27,27 |
ZB_MODE_RGB24 equ 4 ; 24 bit rgb mode |
ZB_NB_COLORS equ 225 ; number of colors for 8 bit display |
if TGL_FEATURE_RENDER_BITS eq 24 |
if TGL_FEATURE_RENDER_BITS eq 15 |
;#define RGB_TO_PIXEL(r,g,b) \ |
; ((((r) >> 1) & 0x7c00) | (((g) >> 6) & 0x03e0) | ((b) >> 11)) |
;typedef unsigned short PIXEL; |
; bytes per pixel |
;PSZB equ 2 |
; bits per pixel = (1 << PSZH) |
;PSZSH equ 4 |
else if TGL_FEATURE_RENDER_BITS eq 16 |
; 16 bit mode |
;#define RGB_TO_PIXEL(r,g,b) \ |
; (((r) & 0xF800) | (((g) >> 5) & 0x07E0) | ((b) >> 11)) |
;typedef unsigned short PIXEL; |
;PSZB equ 2 |
;PSZSH equ 4 |
else if TGL_FEATURE_RENDER_BITS eq 24 |
macro RGB_TO_PIXEL r,g,b |
{ |
mov eax,b |
73,9 → 94,6 |
dctable dd ? ;*unsigned char |
ctable dd ? ;*int |
current_texture dd ? ;*PIXEL |
s_log2 dd ? ;unsigned int |
s_bound dd ? ;unsigned int |
t_bound dd ? ;unsigned int |
ends |
offs_zbuf_xsize equ 0 |
89,9 → 107,6 |
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 |