/programs/develop/libraries/TinyGL/asm_fork/api.asm |
---|
28,6 → 28,13 |
endp |
align 4 |
proc glVertex2fv uses eax, v:dword |
mov eax,[v] |
stdcall glVertex4f,[eax],[eax+4],0.0,1.0 |
ret |
endp |
align 4 |
proc glVertex3f, x:dword, y:dword, z:dword |
stdcall glVertex4f,[x],[y],[z],1.0 |
ret |
40,6 → 47,13 |
ret |
endp |
align 4 |
proc glVertex4fv uses eax, v:dword |
mov eax,[v] |
stdcall glVertex4f,[eax],[eax+4],[eax+8],[eax+12] |
ret |
endp |
; glNormal |
align 4 |
548,7 → 562,7 |
ret |
endp |
;/* lightening */ |
; lightening |
align 4 |
proc glMaterialfv uses eax ecx, mode:dword, type:dword, v:dword |
721,7 → 735,7 |
ret |
endp |
;/* clear */ |
; clear |
align 4 |
proc glClear uses eax, mask:dword |
775,7 → 789,7 |
ret |
endp |
;/* textures */ |
; textures |
align 4 |
proc glTexImage2D uses ecx edi esi,\ |
879,7 → 893,7 |
ret |
endp |
;/* selection */ |
; selection |
align 4 |
proc glInitNames uses eax |
954,7 → 968,7 |
ret |
endp |
;/* Special Functions */ |
; Special Functions |
align 4 |
proc glCallList uses eax, list:dword |
/programs/develop/libraries/TinyGL/asm_fork/arrays.asm |
---|
174,18 → 174,23 |
add esi,[edx+offs_cont_color_array] ;esi = &context.color_array[i] |
mov edi,ebp |
sub edi,28 ;edi = &p[1] |
movsd ;p[1].f = context.color_array[i] |
movsd |
movsd |
mov ebx,[esi+8] |
mov [edi],ebx ;p[1].f = context.color_array[i+2] |
mov ebx,[esi+4] |
mov [edi+4],ebx ;p[2].f = context.color_array[i+1] |
mov ebx,[esi] |
mov [edi+8],ebx ;p[3].f = context.color_array[i] |
add edi,12 |
cmp dword[size],3 |
jle .e1 |
add esi,12 |
movsd |
sub edi,20 ;&p[0] |
jmp .e2 |
.e1: |
mov dword[edi],1.0 ;если задано 3 параметра, то 4-й ставим по умолчанию 1.0 |
sub edi,16 ;&p[0] |
.e2: |
mov edi,ebp |
sub edi,32 ;edi = &p[0] |
mov ebx,ebp |
sub ebx,12 ;ebp-12 = &p[5] |
push ebx |
256,6 → 261,7 |
.e6: |
mov dword[edi],0.0 ;если задано 2 параметра, то 3-й ставим по умолчанию 0.0 |
add edi,4 |
jmp .e8 ;и 4-й тоже ставим по умолчанию |
.e7: |
cmp dword[size],3 |
jle .e8 |
302,7 → 308,7 |
align 4 |
proc glopDrawElements uses eax ebx edx, context:dword, param:dword |
locals |
p rd 5 |
p rd 8 |
endl |
mov edx,[context] |
318,7 → 324,7 |
mov eax,[ebx+4] |
mov [p+4],eax ;p[1].i = param[1].i |
mov eax,ebp |
sub eax,20 ;=sizeof(dd)*5 |
sub eax,32 ;=sizeof(dd)*8 |
stdcall glopBegin, edx,eax |
; for (int ii=0; ii<count; ii++) { |
360,7 → 366,7 |
; } |
; } |
mov eax,ebp |
sub eax,20 ;=sizeof(dd)*5 |
sub eax,32 ;=sizeof(dd)*8 |
stdcall glopEnd, edx,eax |
ret |
endp |
/programs/develop/libraries/TinyGL/asm_fork/clip.asm |
---|
13,6 → 13,10 |
offs_Z equ 8 |
offs_W equ 12 |
if DEBUG |
f_ttv db ' gl_transform_to_viewport',0 |
end if |
align 4 |
proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword |
locals |
69,8 → 73,8 |
.end_if: |
; texture |
bt dword[eax+offs_cont_texture_2d_enabled],0 |
jnc @f |
cmp dword[eax+offs_cont_texture_2d_enabled],0 |
je @f |
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 |
84,7 → 88,7 |
add dword[ebx+offs_vert_zp+offs_zbup_s],ZB_POINT_T_MIN |
@@: |
if DEBUG ;gl_transform_to_viewport |
push edi |
pushad |
mov ecx,80 |
mov eax,[ebx+offs_vert_zp] |
lea edi,[buf_param] |
106,7 → 110,7 |
stdcall str_n_cat,edi,txt_nl,2 |
stdcall dbg_print,f_ttv,buf_param |
pop edi |
popad |
end if |
ret |
endp |
170,11 → 174,11 |
fld dword[t] |
; интерполяция по координатам |
fld dword[ecx+offs_vert_pc+offs_X] |
fsub dword[ebx+offs_vert_pc+offs_X] |
fld dword[ecx+offs_vert_pc] |
fsub dword[ebx+offs_vert_pc] |
fmul st0,st1 |
fadd dword[ebx+offs_vert_pc+offs_X] |
fstp dword[eax+offs_vert_pc+offs_X] |
fadd dword[ebx+offs_vert_pc] |
fstp dword[eax+offs_vert_pc] ;q.pc.X = p0.pc.X + (p1.pc.X - p0.pc.X) * t |
fld dword[ecx+offs_vert_pc+offs_Y] |
fsub dword[ebx+offs_vert_pc+offs_Y] |
663,8 → 667,8 |
stdcall gl_clipcode, [ebx+offs_vert_pc+offs_X],[ebx+offs_vert_pc+offs_Y],\ |
[ebx+offs_vert_pc+offs_Z],[ebx+offs_vert_pc+offs_W] |
mov dword[ebx+offs_vert_clip_code],eax |
cmp eax,0 ;if (q.clip_code==0) |
jne @f |
or eax,eax ;if (q.clip_code==0) |
jnz @f |
stdcall gl_transform_to_viewport,[context],ebx |
mov eax,ebx |
add eax,offs_vert_zp+offs_zbup_b |
689,7 → 693,6 |
mov ebx,[p0] |
mov ecx,[p1] |
mov edx,[p2] |
mov edi,[ebx+offs_vert_clip_code] |
mov dword[cc],edi |
mov eax,[ecx+offs_vert_clip_code] |
700,8 → 703,9 |
or edi,eax ;co = cc[0] | cc[1] | cc[2] |
; we handle the non clipped case here to go faster |
cmp edi,0 ;if (co==0) |
jne .els_0 |
;or edi,___ - было выше |
jnz .els_0 |
;if (co==0) |
mov edi,dword[edx+offs_vert_zp+offs_zbup_x] |
sub edi,dword[ebx+offs_vert_zp+offs_zbup_x] |
mov dword[norm],edi |
728,13 → 732,12 |
fstsw ax |
sahf |
je .end_f |
jb @f |
jbe @f ;jb @f ??? |
inc dword[front] ;front = 0.0 > norm |
@@: |
mov edi,[context] |
mov eax,dword[edi+offs_cont_current_front_face] |
xor dword[front],eax ;front ^= context.current_front_face |
; back face culling |
cmp dword[edi+offs_cont_cull_face_enabled],0 |
je .els_1 |
765,8 → 768,8 |
;eax = cc[2] |
and eax,[cc] |
and eax,[cc+4] ;eax = c_and = cc[0] & cc[1] & cc[2] |
cmp eax,0 ;if (c_and==0) |
jne .end_f |
or eax,eax ;if (c_and==0) |
jnz .end_f |
stdcall gl_draw_triangle_clip, [context],ebx,ecx,edx,0 |
.end_f: |
popad |
799,8 → 802,8 |
or edi,eax |
mov [co],edi ;co = cc[0] | cc[1] | cc[2] |
cmp edi,0 ;if (co == 0) |
jne .els_0 |
or edi,edi ;if (co == 0) |
jnz .els_0 |
stdcall gl_draw_triangle, [context],ebx,ecx,edx |
jmp .end_f |
.els_0: |
809,8 → 812,8 |
and eax,[cc+4] ;c_and = cc[0] & cc[1] & cc[2] |
; the triangle is completely outside |
cmp eax,0 ;if (c_and!=0) return |
jne .end_f |
or eax,eax ;if (c_and!=0) return |
jnz .end_f |
; find the next direction to clip |
.cycle_0: ;while (clip_bit < 6 && (co & (1 << clip_bit)) == 0) |
821,8 → 824,8 |
mov ecx,[clip_bit] |
shl eax,cl |
and eax,[co] |
cmp eax,0 |
jne .cycle_0_end |
or eax,eax |
jnz .cycle_0_end |
inc dword[clip_bit] |
jmp .cycle_0 |
.cycle_0_end: |
854,13 → 857,13 |
mov ecx,[p1] ;востанавливаем после shl ___,cl |
cmp eax,0 ;if (co1) |
je .els_1 |
or eax,eax ;if (co1) |
jz .els_1 |
; one point outside |
mov eax,[cc] |
and eax,[clip_mask] |
cmp eax,0 ;if (cc[0] & clip_mask) |
je .els_2 |
or eax,eax ;if (cc[0] & clip_mask) |
jz .els_2 |
;q[0]=p0 q[1]=p1 q[2]=p2 |
mov [q],ebx |
mov [q+4],ecx |
869,8 → 872,8 |
.els_2: |
mov eax,[cc+4] |
and eax,[clip_mask] |
cmp eax,0 ;else if (cc[1] & clip_mask) |
je .els_3 |
or eax,eax ;else if (cc[1] & clip_mask) |
jz .els_3 |
;q[0]=p1 q[1]=p2 q[2]=p0 |
mov [q],ecx |
mov [q+4],edx |
917,7 → 920,7 |
stdcall updateTmp,[context],edi,ebx,edx,eax ;updateTmp(c,&tmp2,q[0],q[2],tt) |
mov eax,[ebx+offs_vert_edge_flag] |
mov [tmp1+offs_vert_edge_flag],eax ;q[0].edge_flag |
mov [tmp1.edge_flag],eax ;q[0].edge_flag |
mov eax,[edx+offs_vert_edge_flag] |
mov [edge_flag_tmp],eax ;q[2].edge_flag |
mov dword[edx+offs_vert_edge_flag],0 ;q[2].edge_flag=0 |
992,11 → 995,9 |
sub edi,offs_vert_pc |
stdcall updateTmp,[context],edi,[q],[q+8],eax |
mov edx,[q+8] |
mov dword[tmp1+offs_vert_edge_flag],1 |
mov eax,[edx+offs_vert_edge_flag] |
mov dword[tmp1+offs_vert_edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag |
mov dword[tmp1.edge_flag],1 |
mov eax,[edx+offs_vert_edge_flag-offs_vert_pc] |
mov dword[tmp2.edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag |
mov eax,[clip_bit] |
inc eax |
push eax |
/programs/develop/libraries/TinyGL/asm_fork/examples/test_array0.asm |
---|
192,7 → 192,7 |
;-------------------------------------------------- |
i_end: |
rb 1024 |
rb 4096 |
stacktop: |
cur_dir_path: |
rb 4096 |
/programs/develop/libraries/TinyGL/asm_fork/matrix.asm |
---|
384,11 → 384,13 |
loop @b |
if DEBUG ;glopScale |
pushad |
stdcall dbg_print,txt_gl_scal,txt_nl |
mov ebx,[eax+offs_cont_matrix_mode] |
shl ebx,2 |
add ebx,eax |
stdcall gl_print_matrix,[ebx+offs_cont_matrix_stack_ptr],4 |
popad |
end if |
gl_matrix_update eax,ebx |
ret |
429,11 → 431,13 |
fincstp |
if DEBUG ;glopTranslate |
pushad |
stdcall dbg_print,txt_gl_tran,txt_nl |
mov ebx,[eax+offs_cont_matrix_mode] |
shl ebx,2 |
add ebx,eax |
stdcall gl_print_matrix,[ebx+offs_cont_matrix_stack_ptr],4 |
popad |
end if |
gl_matrix_update eax,ebx |
ret |
/programs/develop/libraries/TinyGL/asm_fork/tinygl.asm |
---|
12,9 → 12,9 |
include 'clip.asm' |
include 'vertex.asm' |
include 'api.asm' |
include 'list.asm' |
include 'list.asm' ;gl_add_op |
include 'init.asm' |
include 'matrix.asm' |
include 'matrix.asm' ;gl_print_matrix |
include 'texture.asm' |
include 'misc.asm' |
include 'clear.asm' |
36,42 → 36,7 |
if DEBUG |
include 'info_fun_float.inc' |
end if |
; *** |
glVertex2d: ;(double ,double) |
glVertex2fv: ;(float *) |
glVertex2dv: ;(double *) |
glVertex3d: ;(double ,double ,double) |
glVertex3dv: ;(double *) |
glVertex4d: ;(double ,double ,double, double ) |
glVertex4fv: ;(float *) |
glVertex4dv: ;(double *) |
glColor3d: ;(double ,double ,double) |
glColor3dv: ;(double *) |
glColor4d: ;(double ,double ,double, double ) |
glColor4dv: ;(double *) |
glNormal3d: ;(double ,double ,double) |
glNormal3dv: ;(double *) |
glTexCoord1f: ;(float) |
glTexCoord1d: ;(double) |
glTexCoord1fv: ;(float *) |
glTexCoord1dv: ;(double *) |
glTexCoord2d: ;(double ,double) |
glTexCoord2dv: ;(double *) |
glTexCoord3f: ;(float ,float ,float) |
glTexCoord3d: ;(double ,double ,double) |
glTexCoord3fv: ;(float *) |
glTexCoord3dv: ;(double *) |
glTexCoord4d: ;(double ,double ,double, double ) |
glTexCoord4fv: ;(float *) |
glTexCoord4dv: ;(double *) |
glGenTextures: ;(int n, unsigned int *textures) |
glDeleteTextures: ;(int n, const unsigned int *textures) |
glGetIntegerv: ;(int pname,int *params) |
glGetFloatv: ;(int pname, float *v) |
if DEBUG |
align 4 |
txt_nl db 13,10,0 |
txt_sp db ' ',0 |
140,6 → 105,37 |
ret ;пока в стеке храниться кол-во вызовов то столько раз мы и будем вызываться |
end if |
; *** |
glVertex2d: ;(double ,double) |
glVertex2dv: ;(double *) |
glVertex3d: ;(double ,double ,double) |
glVertex3dv: ;(double *) |
glVertex4d: ;(double ,double ,double, double ) |
glVertex4dv: ;(double *) |
glColor3d: ;(double ,double ,double) |
glColor3dv: ;(double *) |
glColor4d: ;(double ,double ,double, double ) |
glColor4dv: ;(double *) |
glNormal3d: ;(double ,double ,double) |
glNormal3dv: ;(double *) |
glTexCoord1f: ;(float) |
glTexCoord1d: ;(double) |
glTexCoord1fv: ;(float *) |
glTexCoord1dv: ;(double *) |
glTexCoord2d: ;(double ,double) |
glTexCoord2dv: ;(double *) |
glTexCoord3f: ;(float ,float ,float) |
glTexCoord3d: ;(double ,double ,double) |
glTexCoord3fv: ;(float *) |
glTexCoord3dv: ;(double *) |
glTexCoord4d: ;(double ,double ,double, double ) |
glTexCoord4fv: ;(float *) |
glTexCoord4dv: ;(double *) |
glGenTextures: ;(int n, unsigned int *textures) |
glDeleteTextures: ;(int n, const unsigned int *textures) |
glGetIntegerv: ;(int pname,int *params) |
glGetFloatv: ;(int pname, float *v) |
align 4 |
f_kosgl_1 db 'kosglMakeCurrent',0 |
err_0 db 'Error while initializing Z buffer',13,10,0 |
151,20 → 147,13 |
err_4 db 'error while resizing display',13,10,0 |
err_5 db 'size too small',13,10,0 |
f_clipcode db ' gl_clipcode',0 |
f_ttv db ' gl_transform_to_viewport',0 |
f_vt db ' gl_vertex_transform',0 |
f_ev db ' gl_eval_viewport',0 |
f_zbz db ' ZB_line_z',0 |
f_zb db ' ZB_line',0 |
f_m4m db 'gl_M4_Mul',0 |
f_m4ml db 'gl_M4_MulLeft',0 |
f_find_l db 'find_list',0 |
f_alloc_l db 'alloc_list',0 |
f_is_l db 'glIsList',0 |
f_gen_l db 'glGenLists',0 |
f_end_l db 'glEndList',0 |
;f_fill_trf db 'ZB_fillTriangleFlat',0 |
;f_fill_trrgb db 'ZB_fillTriangleSmooth',0 |
f_fill_tr db 'ZB_fillTriangle...',0 |
f_fill_tr_nl db ' lines',0 |
f_fill_tr_nll db ' len',0 |
/programs/develop/libraries/TinyGL/asm_fork/vertex.asm |
---|
1,3 → 1,6 |
if DEBUG |
f_vt db ' gl_vertex_transform',0 |
end if |
align 4 |
proc glopNormal uses ecx esi edi, context:dword, p:dword |
117,7 → 120,7 |
locals |
tmp M4 |
endl |
; assert(c->in_begin == 0); |
;assert(context.in_begin == 0) |
mov edx,[context] |
mov ebx,[p] |
137,7 → 140,7 |
end if |
; precompute inverse modelview |
mov ebx,ebp |
sub ebx,64 |
sub ebx,sizeof.M4 |
stdcall gl_M4_Inv, ebx,dword[edx+offs_cont_matrix_stack_ptr] |
if DEBUG ;tmp |
stdcall dbg_print,txt_sp,txt_nl |
165,18 → 168,21 |
fcomp st1 |
fstsw ax |
sahf |
jne .end_if_0 |
jne @f |
fld dword[ecx+13*4] |
fcomp st1 |
fstsw ax |
sahf |
jne .end_if_0 |
jne @f |
fld dword[ecx+14*4] |
fcomp st1 |
fstsw ax |
sahf |
jne .end_if_0 |
jne @f |
mov dword[edx+offs_cont_matrix_model_projection_no_w_transform],1 |
@@: |
ffree st0 ;0.0 |
fincstp |
.end_if_0: |
; test if the texture matrix is not Identity |
/programs/develop/libraries/TinyGL/asm_fork/zmath.asm |
---|
3,6 → 3,11 |
; ******* Gestion des matrices 4x4 ****** |
if DEBUG |
f_m4m db 'gl_M4_Mul',0 |
f_m4ml db 'gl_M4_MulLeft',0 |
end if |
align 4 |
proc gl_M4_Id uses eax ecx edi, a:dword |
mov edi,[a] |
115,14 → 120,13 |
mov edx,[c] |
mov dword[i],0 |
mov eax,ebp |
sub eax,sizeof.M4 |
.cycle_0: ;i |
xor ebx,ebx |
xor ebx,ebx ;j=0 |
.cycle_1: ;j |
finit |
fldz ;sum=0 |
xor ecx,ecx |
mov eax,ebp |
sub eax,sizeof.M4 |
xor ecx,ecx ;k=0 |
M4_reg edi,eax,dword[i],0 |
.cycle_2: ;k |
fld dword[edi] |
129,9 → 133,8 |
add edi,4 |
M4_reg esi,[b],ecx,ebx |
fmul dword[esi] |
fadd st0,st1 ;sum += a[i][k] * b[k][j] |
faddp ;sum += a[i][k] * b[k][j] |
inc ecx |
add eax,4 |
cmp ecx,4 |
jl .cycle_2 |
fstp dword[edx] ;c[i][j] = sum |
142,7 → 145,6 |
inc dword[i] |
cmp dword[i],4 |
jl .cycle_0 |
finit |
if DEBUG ;gl_M4_MulLeft |
stdcall dbg_print,f_m4ml,txt_nl |
stdcall gl_print_matrix,[c],4 |