/programs/demos/3DS/DATA.INC |
---|
74,7 → 74,7 |
db 3 |
db 'shd. model' |
db 12 |
dr_flag db 0 ; 6 - dots |
dr_flag db 0 |
dd shd_f |
db 4 |
457,8 → 457,8 |
scale dd ? ; help scale variable |
edges_counter dd ? |
;== |
triangles_count_var dd ? |
points_count_var dd ? |
triangles_count_var dw ? |
points_count_var dw ? |
; triangles_ptr dd ? |
; triangles_w_z_ptr dd ? |
; triangles_normals_ptr dd ? |
485,9 → 485,9 |
;=== |
point_index1 dd ? ;-\ |
point_index2 dd ? ; } don't change order |
point_index3 dd ? ;-/ |
point_index1 dw ? ;-\ |
point_index2 dw ? ; } don't change order |
point_index3 dw ? ;-/ |
temp_col dw ? |
high dd ? |
rand_seed dw ? |
/programs/demos/3DS/VIEW3DS.ASM |
---|
312,8 → 312,8 |
mov [re_alloc_flag],0 |
end if |
mov bl,[generator_flag] |
; or bl,bl |
; jz .next_m2 |
or bl,bl |
jz .next_m2 |
cmp bl,1 |
jne @f |
call generate_object |
492,7 → 492,7 |
mov esi,[points_normals_ptr] |
mov edi,[points_normals_rot_ptr] |
mov ebx,matrix |
mov ecx,[points_count_var] |
movzx ecx,[points_count_var] |
call rotary |
mov esi,matrix |
501,7 → 501,7 |
mov esi,[points_ptr] |
mov edi,[points_rotated_ptr] |
mov ebx,matrix |
mov ecx,[points_count_var] |
movzx ecx,[points_count_var] |
call rotary |
; RDTSC |
512,7 → 512,7 |
mov esi,[points_rotated_ptr] |
mov edi,[points_translated_ptr] |
mov ecx,[points_count_var] |
movzx ecx,[points_count_var] |
call translate_points |
; cmp [dr_flag],5 |
523,9 → 523,9 |
jne @f |
call clrscr ; clear the screen |
@@: |
; cmp [catmull_flag],1 ;non sort if Catmull = on |
; je .no_sort |
; 64 indexes call sort_triangles |
cmp [catmull_flag],1 ;non sort if Catmull = on |
je .no_sort |
call sort_triangles |
.no_sort: |
cmp [dr_flag],7 ; fill if 2tex and texgrd |
jge @f |
749,15 → 749,15 |
;-------------------------------------------------------------------------------- |
;-------------------------PROCEDURES--------------------------------------------- |
;-------------------------------------------------------------------------------- |
;include "TEX3.INC" |
include "TEX3.INC" |
include "FLAT_CAT.INC" |
include "TEX_CAT.INC" |
include "BUMP_CAT.INC" |
include "3DMATH.INC" |
include "GRD_LINE.INC" |
;include "GRD3.INC" |
;include "FLAT3.INC" |
;include "BUMP3.INC" |
include "GRD3.INC" |
include "FLAT3.INC" |
include "BUMP3.INC" |
include "B_PROCS.INC" |
include "A_PROCS.INC" |
include "GRD_CAT.INC" |
1102,7 → 1102,7 |
fadd st,st |
mov esi,[points_ptr] |
mov edi,tex_points |
mov ecx,[points_count_var] |
movzx ecx,[points_count_var] |
inc ecx |
; cmp [map_tex_flag],1 |
; jne .cylindric |
1422,16 → 1422,16 |
@@: |
push ebx |
mov ebx,vectors |
mov esi,dword[ebp] ; first point index |
movzx esi,word[ebp] ; first point index |
lea esi,[esi*3] |
lea esi,[points+esi*2] ; esi - pointer to 1st 3d point |
movzx edi,dword[ebp+4] ; second point index |
movzx edi,word[ebp+2] ; second point index |
lea edi,[edi*3] |
lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point |
call make_vector |
add ebx,12 |
mov esi,edi |
movzx edi,dword[ebp+8] ; third point index |
movzx edi,word[ebp+4] ; third point index |
lea edi,[edi*3] |
lea edi,[points+edi*2] |
call make_vector |
1442,23 → 1442,22 |
call cross_product |
mov edi,ebx |
call normalize_vector |
add ebp,12 |
add ebp,6 |
add ebx,12 |
cmp dword[ebp],-1 |
jne @b |
ret |
end if |
init_point_normals: |
.x equ dword [ebp-4] |
.y equ dword [ebp-8] |
.z equ dword [ebp-12] |
.point_number equ dword [ebp-28] |
.hit_faces equ dword [ebp-32] |
.point_number equ word [ebp-26] |
.hit_faces equ word [ebp-28] |
fninit |
mov ebp,esp |
sub esp,32 |
sub esp,28 |
mov edi,[points_normals_ptr] |
mov .point_number,0 |
.ipn_loop: |
1471,8 → 1470,8 |
.ipn_check_face: |
xor ebx,ebx ; ebx - 'position' in one triangle |
.ipn_check_vertex: |
mov eax,dword[esi+ebx] ; eax - point_number |
cmp eax,.point_number |
movzx eax,word[esi+ebx] ; eax - point_number |
cmp ax,.point_number |
jne .ipn_next_vertex |
push esi |
mov esi,ecx |
1494,13 → 1493,13 |
inc .hit_faces |
jmp .ipn_next_face |
.ipn_next_vertex: |
add ebx,4 |
cmp ebx,12 |
add ebx,2 |
cmp ebx,6 |
jne .ipn_check_vertex |
.ipn_next_face: |
add esi,12 |
add esi,6 |
inc ecx |
cmp ecx,[triangles_count_var] |
cmp cx,[triangles_count_var] |
jne .ipn_check_face |
fld .x |
1515,8 → 1514,8 |
call normalize_vector |
add edi,12 ;type vector 3d |
inc .point_number |
mov edx,.point_number |
cmp edx,[points_count_var] |
mov dx,.point_number |
cmp dx,[points_count_var] |
jne .ipn_loop |
mov esp,ebp |
1526,17 → 1525,15 |
init_triangles_normals2: |
mov ebx,[triangles_normals_ptr] |
mov ebp,[triangles_ptr] |
mov ecx,[triangles_count_var] |
@@: |
push ecx |
push ebx |
mov ebx,vectors |
mov esi,dword[ebp] ; first point index |
movzx esi,word[ebp] ; first point index |
lea esi,[esi*3] |
; lea esi,[points+esi*2] ; esi - pointer to 1st 3d point |
shl esi,2 |
add esi,[points_ptr] |
mov edi,dword[ebp+4] ; first point index |
movzx edi,word[ebp+2] ; first point index |
lea edi,[edi*3] |
shl edi,2 |
add edi,[points_ptr] |
1546,7 → 1543,7 |
call make_vector_r |
add ebx,12 |
mov esi,edi |
mov edi,dword[ebp+8] ; third point index |
movzx edi,word[ebp+4] ; third point index |
lea edi,[edi*3] |
shl edi,2 |
add edi,[points_ptr] |
1559,16 → 1556,13 |
call cross_product |
mov edi,ebx |
call normalize_vector |
add ebp,12 |
add ebp,6 |
add ebx,12 |
pop ecx |
sub ecx,1 |
jnz @b |
; cmp dword[ebp],-1 |
; jne @b |
cmp dword[ebp],-1 |
jne @b |
ret |
if 0 ; ind 64 but |
;================================================================= |
sort_triangles: |
mov esi,[triangles_ptr] |
1879,7 → 1873,7 |
; end if |
movsd ; copy end mark too |
ret |
end if ; 64 ind |
clrscr: |
mov edi,[screen_ptr] |
movzx ecx,word[size_x_var] |
1943,31 → 1937,28 |
mov esi,[triangles_ptr] |
mov [edges_counter],0 |
mov ecx,[triangles_count_var] |
.again_dts: |
push ecx |
mov ebp,[points_translated_ptr] |
if Ext >= SSE2 |
mov eax,dword[esi] |
mov [point_index1],eax |
if Ext=NON |
movzx eax,word[esi] |
mov [point_index1],ax |
lea eax,[eax*3] |
add eax,eax |
push ebp |
add ebp,eax |
mov eax,[ebp] |
; cmp [vertex_edit_no],0 |
; jne @f |
; |
; @@: |
cmp [vertex_edit_no],0 |
jne @f |
@@: |
mov dword[xx1],eax |
mov eax,[ebp+4] |
mov [zz1],ax |
pop ebp |
mov eax,dword[esi+4] |
mov [point_index2],eax |
movzx eax,word[esi+2] |
mov [point_index2],ax |
lea eax,[eax*3] |
add eax,eax |
push ebp |
1979,8 → 1970,8 |
pop ebp |
mov eax,dword[esi+8] ; xyz3 = [ebp+[esi+4]*6] |
mov [point_index3],eax |
movzx eax,word[esi+4] ; xyz3 = [ebp+[esi+4]*6] |
mov [point_index3],ax |
lea eax,[eax*3] |
add eax,eax |
; push ebp |
1990,22 → 1981,19 |
mov eax,[ebp+4] |
mov [zz3],ax |
else |
movq mm0,[esi] ; don't know MMX |
mov qword[point_index1],mm0 |
mov eax,dword[esi] ; don't know MMX |
mov dword[point_index1],eax |
; shr eax,16 |
; mov [point_index2],ax |
mov eax,dword[esi+8] |
mov [point_index3],eax |
movdqu xmm0,[esi] |
paddd xmm0,xmm0 |
movdqa xmm1,xmm0 |
paddd xmm0,xmm0 |
paddd xmm0,xmm1 |
movd eax,xmm0 |
psrldq xmm0,4 |
movd ebx,xmm0 |
psrldq xmm0,4 |
movd ecx,xmm0 |
mov ax,word[esi+4] |
mov [point_index3],ax |
movq mm0,[esi] |
pmullw mm0,qword[const6] |
movd eax,mm0 |
psrlq mm0,16 |
movd ebx,mm0 |
psrlq mm0,16 |
movd ecx,mm0 |
and eax,0FFFFh |
and ebx,0FFFFh |
and ecx,0FFFFh |
2062,7 → 2050,7 |
mov esi,point_index1 ; ********************************* |
mov ecx,3 ; |
@@: |
mov eax,dword[esi] |
movzx eax,word[esi] |
lea eax,[eax*3] |
shl eax,2 |
add eax,[points_normals_rot_ptr] |
2102,7 → 2090,7 |
mov esi,point_index3 ; do Gouraud shading |
mov ecx,3 |
.again_grd_draw: |
mov eax,dword[esi] |
movzx eax,word[esi] |
shl eax,2 |
lea eax,[eax*3] |
add eax,[points_normals_rot_ptr] |
2123,11 → 2111,11 |
add eax,ebx |
lea eax,[eax*3+color_map] |
mov eax,dword[eax] |
; cmp [catmull_flag],1 ; put on stack z coordinate if necessary |
; jne @f |
cmp [catmull_flag],1 ; put on stack z coordinate if necessary |
jne @f |
lea edx,[ecx*3] |
push word[edx*2+xx1-2] ; zz1 ,2 ,3 |
; @@: |
@@: |
ror eax,16 ; eax -0xxxrrggbb -> 0xggbbxxrr |
xor ah,ah |
push ax ;r |
2137,7 → 2125,7 |
shr eax,24 |
push ax ;b |
sub esi,4 |
sub esi,2 |
dec cx |
jnz .again_grd_draw |
jmp .both_draw |
2191,19 → 2179,19 |
push eax |
neg al |
push ax |
; cmp [catmull_flag],1 |
; jne @f |
cmp [catmull_flag],1 |
jne @f |
push [zz2] |
; @@: |
@@: |
mov eax,dword[yy2] |
and eax,ebx |
push eax |
neg al |
push ax |
; cmp [catmull_flag],1 |
; jne @f |
cmp [catmull_flag],1 |
jne @f |
push [zz1] |
; @@: |
@@: |
mov eax,dword[yy1] |
and eax,ebx |
push eax |
2217,20 → 2205,21 |
mov ecx,dword[xx3] |
ror ecx,16 |
mov edi,[screen_ptr] |
; cmp [catmull_flag],0 |
; je @f |
cmp [catmull_flag],0 |
je @f |
; lea esi,[Z_buffer] |
mov esi,[Zbuffer_ptr] |
call gouraud_triangle_z |
; jmp .end_draw |
; @@: |
; call gouraud_triangle |
jmp .end_draw |
@@: |
call gouraud_triangle |
jmp .end_draw |
.flat_draw: ;************************** |
; FLAT DRAWING |
mov eax,[point_index1] |
mov ebx,[point_index2] |
mov ecx,[point_index3] |
movzx eax,[point_index1] |
movzx ebx,[point_index2] |
movzx ecx,[point_index3] |
shl eax,2 |
shl ebx,2 |
shl ecx,2 |
2257,8 → 2246,7 |
mov edx,dword[esp-8] |
shl edx,TEX_SHIFT |
add edx,dword[esp-4] |
lea eax,[3*edx] |
add eax,color_map |
lea eax,[3*edx+color_map] |
mov edx,dword[eax] |
and edx,0x00ffffff ; edx = 0x00rrggbb |
2283,9 → 2271,11 |
ror ebx,16 |
mov ecx,dword[xx3] |
ror ecx,16 |
; mov edi,screen |
mov edi,[screen_ptr] |
; cmp [catmull_flag],0 |
; je @f |
cmp [catmull_flag],0 |
je @f |
; lea esi,[Z_buffer] |
mov esi,[Zbuffer_ptr] |
push word[zz3] |
push word[zz2] |
2292,23 → 2282,23 |
push word[zz1] |
call flat_triangle_z |
jmp .end_draw |
; @@: |
; call draw_triangle |
; jmp .end_draw |
@@: |
call draw_triangle |
jmp .end_draw |
.env_mapping: |
; fninit |
; cmp [catmull_flag],0 |
; je @f |
cmp [catmull_flag],0 |
je @f |
push [zz3] |
push [zz2] |
push [zz1] |
; @@: |
@@: |
mov esi,point_index1 |
sub esp,12 |
mov edi,esp |
mov ecx,3 |
@@: |
mov eax,dword[esi] |
movzx eax,word[esi] |
lea eax,[eax*3] |
shl eax,2 |
add eax,[points_normals_rot_ptr] ;point_normals_rotated |
2337,7 → 2327,7 |
fistp word[edi+2] |
; # end of last ch. |
add edi,4 |
add esi,4 |
add esi,2 |
loop @b |
mov eax,dword[xx1] |
2348,30 → 2338,30 |
ror ecx,16 |
mov edi,[screen_ptr] |
mov esi,envmap |
; cmp [catmull_flag],0 |
; je @f |
cmp [catmull_flag],0 |
je @f |
; mov edx,Z_buffer |
mov edx,[Zbuffer_ptr] |
call tex_triangle_z |
; jmp .end_draw |
; @@: |
; call tex_triangle |
jmp .end_draw |
@@: |
call tex_triangle |
jmp .end_draw |
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
.cubic_env_mapping: |
; fninit |
; cmp [catmull_flag],0 |
; je @f |
cmp [catmull_flag],0 |
je @f |
push [zz3] |
push [zz2] |
push [zz1] |
; @@: |
@@: |
mov esi,point_index1 |
sub esp,12 |
mov edi,esp |
mov ecx,3 |
@@: |
mov eax,dword[esi] |
movzx eax,word[esi] |
lea eax,[eax*3] |
shl eax,2 |
add eax,[points_normals_rot_ptr] ;point_normals_rotated |
2400,7 → 2390,7 |
; fistp word[edi+2] |
; # end of last ch. |
add edi,4 |
add esi,4 |
add esi,2 |
loop @b |
mov eax,dword[xx1] |
2411,33 → 2401,34 |
ror ecx,16 |
mov edi,[screen_ptr] |
mov esi,envmap_cub |
; cmp [catmull_flag],0 |
; je @f |
cmp [catmull_flag],0 |
je @f |
; mov edx,Z_buffer |
mov edx,[Zbuffer_ptr] |
call tex_triangle_z |
; jmp .end_draw |
; @@: |
; call tex_triangle |
jmp .end_draw |
@@: |
call tex_triangle |
jmp .end_draw |
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
.bump_mapping: |
; fninit |
; cmp [catmull_flag],0 |
; je @f |
cmp [catmull_flag],0 |
je @f |
; push Z_buffer |
push [Zbuffer_ptr] |
push [zz3] |
push [zz2] |
push [zz1] |
; @@: |
@@: |
mov esi,point_index1 |
sub esp,12 |
mov edi,esp |
mov ecx,3 |
@@: |
mov eax,dword[esi] |
movzx eax,word[esi] |
lea eax,[eax*3] |
shl eax,2 |
add eax,[points_normals_rot_ptr] ;point_normals_rotated |
2453,14 → 2444,14 |
fistp word[edi+2] |
add edi,4 |
add esi,4 |
add esi,2 |
loop @b |
mov esi,[point_index3] ; bump map coords |
movzx esi,[point_index3] ; bump map coords |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
mov esi,[point_index2] |
movzx esi,[point_index2] |
shl esi,2 |
add esi,tex_points |
; lea esi,[esi*3] |
2467,7 → 2458,7 |
; lea esi,[points+2+esi*2] |
push dword[esi] |
; push dword[xx2] |
mov esi,[point_index1] |
movzx esi,[point_index1] |
shl esi,2 |
add esi,tex_points |
; lea esi,[esi*3] |
2485,32 → 2476,32 |
mov esi,envmap |
mov edx,bumpmap ;BUMP_MAPPING |
; cmp [catmull_flag],0 |
; je @f |
cmp [catmull_flag],0 |
je @f |
call bump_triangle_z |
; jmp .end_draw |
; @@: |
; call bump_triangle |
jmp .end_draw |
@@: |
call bump_triangle |
jmp .end_draw |
.tex_mapping: |
; fninit |
; cmp [catmull_flag],0 |
; je @f |
cmp [catmull_flag],0 |
je @f |
push [zz3] |
push [zz2] |
push [zz1] |
; @@: |
mov esi,[point_index3] ; tex map coords |
@@: |
movzx esi,[point_index3] ; tex map coords |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
mov esi,[point_index2] |
movzx esi,[point_index2] |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
mov esi,[point_index1] |
movzx esi,[point_index1] |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
2523,14 → 2514,16 |
ror ecx,16 |
mov edi,[screen_ptr] |
mov esi,texmap |
; cmp [catmull_flag],0 |
; je @f |
cmp [catmull_flag],0 |
je @f |
; mov edx,Z_buffer |
mov edx,[Zbuffer_ptr] |
call tex_triangle_z |
; jmp .end_draw |
; @@: |
; call tex_triangle |
; call tex_plus_grd_trianlgle |
jmp .end_draw |
@@: |
call tex_triangle |
jmp .end_draw |
; .ray: |
; grd_triangle according to points index |
; cmp [catmull_flag],0 |
2571,15 → 2564,15 |
sub esp,4 |
push ebp |
mov esi,[point_index3] ; tex map coords |
movzx esi,[point_index3] ; tex map coords |
shl esi,2 |
add esi,tex_points |
push dword[esi] ; texture coords as first |
mov esi,[point_index2] ; group of parameters |
movzx esi,[point_index2] ; group of parameters |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
mov esi,[point_index1] |
movzx esi,[point_index1] |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
2592,7 → 2585,7 |
lea edx,[ecx*3] |
push word[edx*2+xx1-2] ; zz1 ,2 ,3 |
mov eax,dword[esi] |
movzx eax,word[esi] |
shl eax,2 |
lea eax,[eax*3] ;+point_normals_rotated] |
add eax,[points_normals_rot_ptr] |
2623,7 → 2616,7 |
shr eax,24 |
push ax ;b |
sub esi,4 |
sub esi,2 |
dec cx |
jnz .aagain_grd_draw |
2651,15 → 2644,15 |
push word[zz2] |
push word[zz1] |
mov esi,[point_index3] ; tex map coords |
movzx esi,[point_index3] ; tex map coords |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
mov esi,[point_index2] |
movzx esi,[point_index2] |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
mov esi,[point_index1] |
movzx esi,[point_index1] |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
2669,7 → 2662,7 |
mov edi,esp |
mov ecx,3 |
@@: |
mov eax,dword[esi] |
movzx eax,word[esi] |
lea eax,[eax*3] |
shl eax,2 |
add eax,[points_normals_rot_ptr] |
2685,7 → 2678,7 |
fistp word[edi+2] |
add edi,4 |
add esi,4 |
add esi,2 |
loop @b |
mov eax,dword[xx1] |
2702,15 → 2695,15 |
jmp .end_draw |
.bump_tex: |
mov esi,[point_index3] ; tex map coords |
movzx esi,[point_index3] ; tex map coords |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
mov esi,[point_index2] |
movzx esi,[point_index2] |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
mov esi,[point_index1] |
movzx esi,[point_index1] |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
2729,7 → 2722,7 |
mov edi,esp |
mov ecx,3 |
@@: |
mov eax,dword[esi] |
movzx eax,word[esi] |
lea eax,[eax*3] |
shl eax,2 |
add eax,[points_normals_rot_ptr] |
2745,7 → 2738,7 |
fistp word[edi+2] |
add edi,4 |
add esi,4 |
add esi,2 |
loop @b |
; push dword 1 shl 16 + 1 ; emap coords |
2752,16 → 2745,16 |
; push dword 127 shl 16 + 1 |
; push dword 127 shl 16 + 127 |
mov esi,[point_index3] ; bump map coords |
movzx esi,[point_index3] ; bump map coords |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
mov esi,[point_index2] |
movzx esi,[point_index2] |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
mov esi,[point_index1] |
movzx esi,[point_index1] |
shl esi,2 |
add esi,tex_points |
push dword[esi] |
2788,7 → 2781,7 |
mov esi,point_index3 |
mov ecx,3 |
.again_line_param: |
mov eax,dword[esi] |
movzx eax,word[esi] |
shl eax,2 |
lea eax,[eax*3] |
add eax,[points_normals_rot_ptr] |
2813,7 → 2806,7 |
shl ebx,2 |
mov [ebx+col1],eax |
sub esi,4 |
sub esi,2 |
dec ecx |
jnz .again_line_param |
2925,12 → 2918,10 |
.end_draw: |
pop esi |
add esi,12 |
add esi,6 |
inc [edges_counter] |
pop ecx |
sub ecx,1 |
; cmp dword[esi],-1 |
jnz .again_dts |
cmp dword[esi],-1 |
jne .again_dts |
ret |
2939,10 → 2930,6 |
draw_handlers: |
push ebp |
3034,7 → 3021,7 |
add esi,6 |
inc dword[.counter] |
mov ecx,[.counter] |
cmp ecx,[points_count_var] |
cmp cx,[points_count_var] |
jng .loop |
mov esp,ebp |
3077,8 → 3064,8 |
; and allocate memory |
xor ebx,ebx |
xor ebp,ebp |
mov [points_count_var],ebx |
mov [triangles_count_var],ebx |
mov [points_count_var],bx |
mov [triangles_count_var],bx |
if USE_LFN = 0 |
mov esi,SourceFile |
else |
3137,7 → 3124,7 |
jmp @b |
@@: |
movzx ecx,word[esi+6] |
add [points_count_var],ecx |
add [points_count_var],cx |
mov edx,ecx |
add esi,8 |
3156,7 → 3143,7 |
jmp @b |
@@: |
movzx ecx,word[esi+6] |
add [triangles_count_var],ecx |
add [triangles_count_var],cx |
add esi,8 |
@@: |
3231,7 → 3218,7 |
jmp @b |
@@: |
movzx ecx,word[esi+6] |
add [points_count_var],ecx |
add [points_count_var],cx |
mov edx,ecx |
add esi,8 |
3245,6 → 3232,12 |
push dword[esi+8] |
pop dword[edi+ebx*2+8] |
pop edi |
; fld dword[esi+4] |
; fstp dword[real_points+ebx*2+0] ; x |
; fld dword[esi+8] |
; fstp dword[real_points+ebx*2+4] ; y |
; fld dword[esi+0] |
; fstp dword[real_points+ebx*2+8] ; z |
add ebx,6 |
add esi,12 |
3263,20 → 3256,16 |
jmp @b |
@@: |
movzx ecx,word[esi+6] |
add [triangles_count_var],ecx |
add [triangles_count_var],cx |
add esi,8 |
;mov edi,triangles |
@@: |
movzx eax,word[esi] |
stosd |
movzx eax,word[esi+2] |
stosd |
movzx eax,word[esi+4] |
stosd |
add dword[edi-12],ebp |
add dword[edi-8],ebp |
add dword[edi-4],ebp |
add esi,8 |
movsd |
movsw |
add word[edi-6],bp |
add word[edi-4],bp |
add word[edi-2],bp |
add esi,2 |
dec ecx |
jnz @b |
add ebp,edx |
3297,10 → 3286,10 |
mov ebx,20 |
.alloc: |
mov ecx,[triangles_count_var] |
add ecx,20 |
movzx ecx, [triangles_count_var] |
inc ecx |
lea ecx, [ecx*3] |
shl ecx,2 |
add ecx, ecx |
mov edx,[triangles_ptr] |
int 0x40 ; -> allocate memory to triangles |
mov [triangles_ptr], eax ; -> eax = pointer to allocated mem |
3330,7 → 3319,7 |
; ststic memory |
mov eax, 68 |
mov ecx, [triangles_count_var] |
movzx ecx, [triangles_count_var] |
lea ecx, [3+ecx*3] |
shl ecx, 2 |
mov edx,[triangles_normals_ptr] |
3345,7 → 3334,7 |
; mov dword[vertices_index_ptr], eax |
mov eax, 68 |
mov ecx, [points_count_var] |
movzx ecx, [points_count_var] |
lea ecx,[3+ecx*3] |
shl ecx, 2 |
mov edx,[points_normals_ptr] |
3359,7 → 3348,7 |
mov eax, 68 |
; mov ebx, 12 |
mov ecx, [points_count_var] |
movzx ecx, [points_count_var] |
lea ecx,[3+ecx*3] |
shl ecx, 2 |
mov edx,[points_normals_rot_ptr] |
3377,7 → 3366,7 |
mov [points_rotated_ptr], eax |
mov eax, 68 |
mov ecx, [points_count_var] |
movzx ecx, [points_count_var] |
inc ecx |
shl ecx, 3 |
mov edx,[points_translated_ptr] |
3392,7 → 3381,7 |
;- |
mov eax, 68 |
mov ebx, 11 |
int 0x40 ; -> create heap |
int 0x40 ; -> init heap |
; mov eax, 70 |
; mov ebx, file_info |
3403,8 → 3392,6 |
; inc ebx |
; mov [fsize], ebx |
; mov eax, 68 |
; mov ebx, 12 |
; mov ecx, [fsize] |
3415,10 → 3402,21 |
; mov ebx, file_info |
; mov dword[ebx],0 |
; int 0x40 ; -> read file |
;mov [fsize],ebx |
;cmp eax,6 |
;jnz @f |
;xor eax,eax ;;;;--- |
;cmp eax,6 |
;jnz @f |
;xor eax,eax ;;;;--- |
;load kpacked files by Leency |
mov eax,68 |
mov ebx,27 |
mov ecx,file_name |
mov ecx,I_Param |
int 0x40 |
mov [fsize],edx |
3456,8 → 3454,6 |
end if |
; eax = 0 -> ok file loaded |
ret |
; eax = 0 -> ok file loaded |
ret |
read_param: |
mov esi,I_Param |
cmp dword[esi],0 |
/programs/demos/3DS/B_PROCS.INC |
---|
280,12 → 280,12 |
xor ebx,ebx ; ebx - x,y,z coord in real_points list |
.next_c: ; max/min/center x,y,z |
mov edi,[points_ptr] ; in real_point list minimum two points |
mov edx,[points_count_var] |
mov dx,[points_count_var] |
fld dword[edi+ebx] |
fst .max |
fstp .min |
add edi,12 |
dec edx |
dec dx |
.next_coord: ; next coord from real_points list |
fld dword [edi+ebx] ; real_points -> x,y,z |
fcom .max ; max_x,y,z |
305,7 → 305,7 |
.end_coords: |
add edi,12 |
; cmp dword[edi],-1 ; cmp with end mark |
dec edx |
dec dx |
jnz .next_coord |
; ok after this we found max_coord and min_coord |
fld .max ; find center point |
326,7 → 326,7 |
@@: |
ffree st |
mov edi,[points_ptr] |
mov edx,[points_count_var] ; substraction all coords - center point |
mov dx,[points_count_var] ; substraction all coords - center point |
@@: |
fld dword[edi+ebx] |
fsub .center |
334,7 → 334,7 |
add edi,12 |
; cmp dword[edi],-1 |
; jne @b |
dec edx |
dec dx |
jnz @b |
add ebx,4 ; ebx - x,y,z cooficientes in list real_points |
343,7 → 343,7 |
fld .maxxx |
mov edi,[points_ptr] ; create all coords in <-1.0,1.0> |
mov ecx,[points_count_var] |
movzx ecx,[points_count_var] |
@@: |
fld dword[edi] |
fdiv .maxxx |
405,78 → 405,78 |
;init triangles list |
mov edi,[triangles_ptr] |
xor esi,esi |
xor eax,eax |
mov ebx,.N+1 |
mov ecx,(.N*2)+2 ;-- |
mov edx,(.N*3)+3 ;--- |
xor si,si |
xor ax,ax |
mov bx,.N+1 |
mov cx,(.N*2)+2 ;-- |
mov dx,(.N*3)+3 ;--- |
mov [triangles_count_var],0 |
.again_tri: |
stosd ; main wave |
mov dword[edi],ebx |
inc eax |
add edi,4 |
stosd |
stosd |
mov dword[edi],ebx |
inc ebx |
mov dword[edi+4],ebx |
stosw ; main wave |
mov word[edi],bx |
inc ax |
add edi,2 |
stosw |
stosw |
mov word[edi],bx |
inc bx |
mov word[edi+2],bx |
add edi,8 |
add edi,4 |
mov dword[edi],ecx ;---- ; n2+2 ; xor ax,ax |
inc ecx ; n2+3 ; mov bx,.N+1 |
mov dword[edi+4],edx ; ; mov cx,(.N*2)+2 ;-- |
mov dword[edi+8],ecx ; n3+3 ; mov dx,(.N*3)+3 ;--- |
mov dword[edi+12],edx ; n3+3 ; |
inc edx ; ; |
mov dword[edi+16],edx ; n2+3 ; |
mov dword[edi+20],ecx ; n3+4 |
add edi,24 ;---- |
mov word[edi],cx ;---- ; n2+2 ; xor ax,ax |
inc cx ; n2+3 ; mov bx,.N+1 |
mov word[edi+2],dx ; ; mov cx,(.N*2)+2 ;-- |
mov word[edi+4],cx ; n3+3 ; mov dx,(.N*3)+3 ;--- |
mov word[edi+6],dx ; n3+3 ; |
inc dx ; ; |
mov word[edi+8],dx ; n2+3 ; |
mov word[edi+10],cx ; n3+4 |
add edi,12 ;---- |
dec eax ; border of wave |
dec ebx |
dec ecx |
dec edx |
dec ax ; border of wave |
dec bx |
dec cx |
dec dx |
stosd ; first border |
inc eax |
stosd |
mov dword[edi],edx |
add edi,4 |
stosw ; first border |
inc ax |
stosw |
mov word[edi],dx |
add edi,2 |
mov dword[edi],edx |
add edi,4 |
stosd |
inc edx |
mov dword[edi],edx |
mov word[edi],dx |
add edi,2 |
stosw |
inc dx |
mov word[edi],dx |
mov dword[edi+4],ebx ; second border |
mov dword[edi+8],ecx |
inc ebx |
mov dword[edi+12],ebx |
mov word[edi+2],bx ; second border |
mov word[edi+4],cx |
inc bx |
mov word[edi+6],bx |
mov dword[edi+16],ebx |
mov dword[edi+20],ecx |
inc ecx |
mov dword[edi+24],ecx |
add edi,28 |
mov word[edi+8],bx |
mov word[edi+10],cx |
inc cx |
mov word[edi+12],cx |
add edi,14 |
add [triangles_count_var],8 ;10 |
inc esi |
cmp esi,.N |
inc si |
cmp si,.N |
jne .again_tri |
add eax,((.N+1)*3)+1 |
add ebx,((.N+1)*3)+1 |
add ecx,((.N+1)*3)+1 |
add edx,((.N+1)*3)+1 |
xor esi,esi |
cmp eax,(.N*13)+13 ;;;(.N*23)+23 ; ax,(.N*13)+13 |
add ax,((.N+1)*3)+1 |
add bx,((.N+1)*3)+1 |
add cx,((.N+1)*3)+1 |
add dx,((.N+1)*3)+1 |
xor si,si |
cmp ax,(.N*13)+13 ;;;(.N*23)+23 ; ax,(.N*13)+13 |
jl .again_tri |
; mov dword[edi],-1 ; <--- end mark not always in use |
mov dword[edi],-1 ; <--- end mark not always in use |
; init real points list |
mov .x,-(.N/2) |
824,8 → 824,11 |
; mov ecx,(SIZE_X*(SIZE_Y-3))*3/8 |
.blr: |
@@: |
push ecx |
mov ecx,edi |
sub ecx,ebx |
movq mm0,[edi+ebx] |
movq mm1,[edi-ebx] |
movq mm1,[ecx] |
movq mm2,[edi-3] |
movq mm3,[edi+3] |
838,7 → 841,7 |
movq [edi],mm0 |
add edi,8 |
add esi,8 |
pop ecx |
loop .blr |
xor eax,eax |
992,7 → 995,7 |
mov edi,[points_ptr] ; one real point - triple float |
mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z |
fninit |
mov ecx,[points_count_var] |
movzx ecx,[points_count_var] |
cmp ah,11 |
je @f |
1041,7 → 1044,7 |
mov edi,[points_ptr] ; one real point - triple float |
mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z |
fninit ; exchange both points and normal vactors coords/coofics |
mov ecx,[points_count_var] |
movzx ecx,[points_count_var] |
cmp [xchg_flag],1 |
je @f |
/programs/demos/3DS/History.txt |
---|
1,8 → 1,9 |
View3ds 0.068b - V 2018 |
1. Fixed SSE build. |
----------------------------------------------------------------------------------- |
View3ds 0.068 - XI 2016 |
1. Editing option - new 'editor' button. |
2. For now I disable perspective correction, to make implemtation |
of editing option easier. |
2. For now I disable perspective correction, to make implemtation of editing option easier. |
----------------------------------------------------------------------------------- |
View3ds 0.067 - XI 2016 |
/programs/demos/3DS/README.TXT |
---|
1,15 → 1,6 |
View3ds 0.069 - tiny viewer to .3ds and .asc files with several graphics |
View3ds 0.068b - tiny viewer to .3ds and .asc files with several graphics |
effects implementation. |
What's new? |
1. KPacked files support by Leency. |
1. 32bit vertices indexes and ability to load whole RAM limited objects. |
(Above 65535 vertices and triangles), (by me). |
2. I switch off painters algotithm mode (depth sorting). In app impelementetion it has |
limited vertices count and produce less quality image than Z buffer Catmull algo. |
In addition this switch off reduces app size, (by me). |
Buttons description: |
1. rotary: choosing rotary axle: x, y, x+y. |
2. shd. model: choosing shading model: flat, grd (smooth), env (spherical |
20,7 → 11,8 |
mapping), grdl (Gouraud lines - edges only). |
3. speed: idle, full. |
4,5. zoom in, out: no comment. |
6. catmull: disabled |
6. catmull: on -> use z buffer ( z coordinate interpolation), off -> depth sorting, painters |
alghoritm).Txgrd, 2tex and bumptex models only with catmull = on. |
7. culling: backface culling on/ off. |
8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination). |
9. Blur: blur N times; N=0,1,2,3,4,5 |
42,4 → 34,4 |
is released apply current position. You may also decrease whole handlers count by enable culling (using |
appropriate button) - some back handlers become hidden. |
Maciej Guba V 2020 |
Maciej Guba XI 2016 |
/programs/demos/3DS/3DMATH.INC |
---|
160,7 → 160,6 |
ret |
make_vector_r: |
if Ext < SSE2 |
fninit |
fld dword[edi] ;edi+x3d |
fsub dword[esi] ;esi+x3d |
173,14 → 172,6 |
fld dword[edi+8] |
fsub dword[esi+8] |
fstp dword[ebx+vec_z] |
else |
movups xmm0,[esi] |
movups xmm1,[edi] |
subps xmm1,xmm0 |
movlps [ebx],xmm1 |
movhlps xmm1,xmm1 |
movss [ebx+8],xmm1 |
end if |
ret |
;---------------------- in: ------------------------------- |
/programs/demos/3DS/A_PROCS.INC |
---|
111,7 → 111,7 |
draw_dots: |
mov esi,[points_translated_ptr] |
mov ecx,[points_count_var] |
movzx ecx,[points_count_var] |
.drw: |
@@: |
lodsd |
486,24 → 486,24 |
jle .next |
mov edi,[triangles_ptr] |
mov eax,4 |
mov ebx,4+4 |
mov [triangles_count_var],160*3 ;164*3 ;140 |
mov ax,4 |
mov bx,4+4 |
mov [triangles_count_var],164*3 ;140 |
mov ecx,80*3 ;68 |
mov cx,80*3 ;68 |
@@: |
stosd ;---- |
mov [edi],ebx ; | |
add edi,4 ; | |
inc eax ; | |
stosd ; |repeat 4 times |
stosw ;---- |
mov [edi],bx ; | |
add edi,2 ; | |
inc ax ; | |
stosw ; |repeat 4 times |
mov [edi],ebx ; | |
inc ebx |
add edi,4 |
stosd ; | |
mov [edi],ebx ; | |
add edi,4 ;---- |
mov [edi],bx ; | |
inc bx |
add edi,2 |
stosw ; | |
mov [edi],bx ; | |
add edi,2 ;---- |
loop @b |
627,57 → 627,57 |
; init triangles list |
mov edi,[triangles_ptr] |
mov eax,5 |
mov ebx,5+5 |
mov [triangles_count_var],200 ;204 |
mov ax,5 |
mov bx,5+5 |
mov [triangles_count_var],204 |
mov ecx,100 |
mov cx,100 |
@@: |
stosd ;---- |
mov [edi],ebx ; | |
add edi,4 ; | |
inc eax ; | |
stosd ; |repeat |
stosw ;---- |
mov [edi],bx ; | |
add edi,2 ; | |
inc ax ; | |
stosw ; |repeat |
mov [edi],ebx ; | |
inc ebx |
add edi,4 |
stosd ; | |
mov [edi],ebx ; | |
add edi,4 ;---- |
mov [edi],bx ; | |
inc bx |
add edi,2 |
stosw ; | |
mov [edi],bx ; | |
add edi,2 ;---- |
loop @b |
mov eax,5 |
mov ebx,[points_count_var] |
sub ebx,2 |
mov ax,5 |
mov bx,[points_count_var] |
sub bx,2 |
mov dl,2 |
.nx: |
mov ecx,5 |
add [triangles_count_var],ecx |
mov cx,5 |
add [triangles_count_var],cx |
@@: |
stosd |
add eax,5 |
stosd |
mov dword[edi],ebx |
add edi,4 |
stosw |
add ax,5 |
stosw |
mov word[edi],bx |
add edi,2 |
loop @b |
cmp dl,1 |
je @f |
inc ebx |
inc bx |
jmp .lab |
@@: |
dec ebx |
dec bx |
.lab: |
mov ecx,5 |
add [triangles_count_var],ecx |
mov cx,5 |
add [triangles_count_var],cx |
@@: |
stosd |
add eax,5 |
stosd |
mov dword[edi],ebx |
add edi,4 |
stosw |
add ax,5 |
stosw |
mov word[edi],bx |
add edi,2 |
loop @b |
dec dl |
684,19 → 684,19 |
or dl,dl |
jnz .nx |
sub eax,25 |
stosd |
sub eax,50 |
stosd |
mov dword[edi],ebx |
add edi,4 |
sub ax,25 |
stosw |
sub ax,50 |
stosw |
mov word[edi],bx |
add edi,2 |
stosd |
add eax,50 |
stosd |
inc ebx |
mov dword[edi],ebx |
add edi,4 |
stosw |
add ax,50 |
stosw |
inc bx |
mov word[edi],bx |
add edi,2 |
add [triangles_count_var],2 |
mov dword[edi],-1 ; < - end mark |
706,4 → 706,3 |
pop ebp |
ret |
/programs/demos/3DS/BUMP3.INC |
---|
0,0 → 1,630 |
;------- Big thanks to majuma (www.majuma.xt.pl) for absolutelly great-- |
;------- 13h mode demos ------------------------------------------------ |
bump_triangle: |
;------------------in - eax - x1 shl 16 + y1 ----------- |
;---------------------- ebx - x2 shl 16 + y2 ----------- |
;---------------------- ecx - x3 shl 16 + y3 ----------- |
;---------------------- edx - pointer to bump map ------ |
;---------------------- esi - pointer to environment map |
;---------------------- edi - pointer to screen buffer-- |
;---------------------- stack : bump coordinates-------- |
;---------------------- environment coordinates- |
.b_x1 equ ebp+4 ; procedure don't save registers !!! |
.b_y1 equ ebp+6 ; each coordinate as word |
.b_x2 equ ebp+8 |
.b_y2 equ ebp+10 |
.b_x3 equ ebp+12 |
.b_y3 equ ebp+14 |
.e_x1 equ ebp+16 |
.e_y1 equ ebp+18 |
.e_x2 equ ebp+20 |
.e_y2 equ ebp+22 |
.e_x3 equ ebp+24 |
.e_y3 equ ebp+26 |
.t_bmap equ dword[ebp-4] |
.t_emap equ dword[ebp-8] |
.x1 equ word[ebp-10] |
.y1 equ word[ebp-12] |
.x2 equ word[ebp-14] |
.y2 equ word[ebp-16] |
.x3 equ word[ebp-18] |
.y3 equ word[ebp-20] |
.dx12 equ dword[ebp-24] |
.dbx12 equ dword[ebp-28] |
.dby12 equ dword[ebp-32] |
.dex12 equ dword[ebp-36] |
.dey12 equ dword[ebp-40] |
.dx13 equ dword[ebp-44] |
.dbx13 equ dword[ebp-48] |
.dby13 equ dword[ebp-52] |
.dex13 equ dword[ebp-56] |
.dey13 equ dword[ebp-60] |
.dx23 equ dword[ebp-64] |
.dbx23 equ dword[ebp-68] |
.dby23 equ dword[ebp-72] |
.dex23 equ dword[ebp-76] |
.dey23 equ dword[ebp-80] |
.cx1 equ dword[ebp-84] ; current variables |
.cx2 equ dword[ebp-88] |
.cbx1 equ dword[ebp-92] |
.cbx2 equ dword[ebp-96] |
.cby1 equ dword[ebp-100] |
.cby2 equ dword[ebp-104] |
.cex1 equ dword[ebp-108] |
.cex2 equ dword[ebp-112] |
.cey1 equ dword[ebp-116] |
.cey2 equ dword[ebp-120] |
mov ebp,esp |
push edx ; store bump map |
push esi ; store e. map |
; sub esp,120 |
.sort3: ; sort triangle coordinates... |
cmp ax,bx |
jle .sort1 |
xchg eax,ebx |
mov edx,dword[.b_x1] |
xchg edx,dword[.b_x2] |
mov dword[.b_x1],edx |
mov edx,dword[.e_x1] |
xchg edx,dword[.e_x2] |
mov dword[.e_x1],edx |
.sort1: |
cmp bx,cx |
jle .sort2 |
xchg ebx,ecx |
mov edx,dword[.b_x2] |
xchg edx,dword[.b_x3] |
mov dword[.b_x2],edx |
mov edx,dword[.e_x2] |
xchg edx,dword[.e_x3] |
mov dword[.e_x2],edx |
jmp .sort3 |
.sort2: |
push eax ; store triangle coords in variables |
push ebx |
push ecx |
mov edx,eax ; eax,ebx,ecx are ORd together into edx which means that |
or edx,ebx ; if any *one* of them is negative a sign flag is raised |
or edx,ecx |
test edx,80000000h ; Check only X |
jne .loop23_done |
mov dx,[size_x_var] |
cmp .x1,dx ;SIZE_X ; { |
jg .loop23_done |
cmp .x2,dx ;SIZE_X ; This can be optimized with effort |
jg .loop23_done |
cmp .x3,dx ;SIZE_X |
jg .loop23_done ; { |
mov bx,.y2 ; calc delta 12 |
sub bx,.y1 |
jnz .bt_dx12_make |
mov ecx,5 |
xor edx,edx |
@@: |
push edx ;dword 0 |
loop @b |
jmp .bt_dx12_done |
.bt_dx12_make: |
mov ax,.x2 |
sub ax,.x1 |
cwde |
movsx ebx,bx |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dx12,eax |
push eax |
mov ax,word[.b_x2] |
sub ax,word[.b_x1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dbx12,eax |
push eax |
mov ax,word[.b_y2] |
sub ax,word[.b_y1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dby12,eax |
push eax |
mov ax,word[.e_x2] |
sub ax,word[.e_x1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dex12,eax |
push eax |
mov ax,word[.e_y2] |
sub ax,word[.e_y1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dey12,eax |
push eax |
.bt_dx12_done: |
mov bx,.y3 ; calc delta13 |
sub bx,.y1 |
jnz .bt_dx13_make |
mov ecx,5 |
xor edx,edx |
@@: |
push edx ;dword 0 |
loop @b |
jmp .bt_dx13_done |
.bt_dx13_make: |
mov ax,.x3 |
sub ax,.x1 |
cwde |
movsx ebx,bx |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dx13,eax |
push eax |
mov ax,word[.b_x3] |
sub ax,word[.b_x1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dbx13,eax |
push eax |
mov ax,word[.b_y3] |
sub ax,word[.b_y1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dby13,eax |
push eax |
mov ax,word[.e_x3] |
sub ax,word[.e_x1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dex13,eax |
push eax |
mov ax,word[.e_y3] |
sub ax,word[.e_y1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dey13,eax |
push eax |
.bt_dx13_done: |
mov bx,.y3 ; calc delta23 |
sub bx,.y2 |
jnz .bt_dx23_make |
mov ecx,5 |
xor edx,edx |
@@: |
push edx ;dword 0 |
loop @b |
jmp .bt_dx23_done |
.bt_dx23_make: |
mov ax,.x3 |
sub ax,.x2 |
cwde |
movsx ebx,bx |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dx23,eax |
push eax |
mov ax,word[.b_x3] |
sub ax,word[.b_x2] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dbx23,eax |
push eax |
mov ax,word[.b_y3] |
sub ax,word[.b_y2] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dby23,eax |
push eax |
mov ax,word[.e_x3] |
sub ax,word[.e_x2] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dex23,eax |
push eax |
mov ax,word[.e_y3] |
sub ax,word[.e_y2] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dey23,eax |
push eax |
; sub esp,40 |
.bt_dx23_done: |
movsx eax,.x1 |
shl eax,ROUND |
; mov .cx1,eax |
; mov .cx2,eax |
push eax |
push eax |
movsx eax,word[.b_x1] |
shl eax,ROUND |
; mov .cbx1,eax |
; mov .cbx2,eax |
push eax |
push eax |
movsx eax,word[.b_y1] |
shl eax,ROUND |
; mov .cby1,eax |
; mov .cby2,eax |
push eax |
push eax |
movsx eax,word[.e_x1] |
shl eax,ROUND |
;mov .cex1,eax |
;mov .cex2,eax |
push eax |
push eax |
movsx eax,word[.e_y1] |
shl eax,ROUND |
;mov .cey1,eax |
;mov .cey2,eax |
push eax |
push eax |
movzx ecx,.y1 |
cmp cx,.y2 |
jge .loop12_done |
.loop12: |
call .call_bump_line |
mov eax,.dx13 |
add .cx1,eax |
mov eax,.dx12 |
add .cx2,eax |
mov eax,.dbx13 |
add .cbx1,eax |
mov eax,.dbx12 |
add .cbx2,eax |
mov eax,.dby13 |
add .cby1,eax |
mov eax,.dby12 |
add .cby2,eax |
mov eax,.dex13 |
add .cex1,eax |
mov eax,.dex12 |
add .cex2,eax |
mov eax,.dey13 |
add .cey1,eax |
mov eax,.dey12 |
add .cey2,eax |
inc ecx |
cmp cx,.y2 |
jl .loop12 |
.loop12_done: |
movzx ecx,.y2 |
cmp cx,.y3 |
jge .loop23_done |
movzx eax,.x2 |
shl eax,ROUND |
mov .cx2,eax |
movzx eax,word[.b_x2] |
shl eax,ROUND |
mov .cbx2,eax |
movzx eax,word[.b_y2] |
shl eax,ROUND |
mov .cby2,eax |
movzx eax,word[.e_x2] |
shl eax,ROUND |
mov .cex2,eax |
movzx eax,word[.e_y2] |
shl eax,ROUND |
mov .cey2,eax |
.loop23: |
call .call_bump_line |
mov eax,.dx13 |
add .cx1,eax |
mov eax,.dx23 |
add .cx2,eax |
mov eax,.dbx13 |
add .cbx1,eax |
mov eax,.dbx23 |
add .cbx2,eax |
mov eax,.dby13 |
add .cby1,eax |
mov eax,.dby23 |
add .cby2,eax |
mov eax,.dex13 |
add .cex1,eax |
mov eax,.dex23 |
add .cex2,eax |
mov eax,.dey13 |
add .cey1,eax |
mov eax,.dey23 |
add .cey2,eax |
inc ecx |
cmp cx,.y3 |
jl .loop23 |
.loop23_done: |
mov esp,ebp |
ret 24 |
.call_bump_line: |
; push ebp |
; push ecx |
pushad |
push .t_emap |
push .t_bmap |
push .cey2 |
push .cex2 |
push .cey1 |
push .cex1 |
push .cby2 |
push .cbx2 |
push .cby1 |
push .cbx1 |
push ecx |
mov eax,.cx1 |
sar eax,ROUND |
mov ebx,.cx2 |
sar ebx,ROUND |
call bump_line |
popad |
ret |
bump_line: |
;--------------in: eax - x1 |
;-------------- ebx - x2 |
;-------------- edi - pointer to screen buffer |
;stack - another parameters : |
.y equ dword [ebp+4] |
.bx1 equ [ebp+8] ; --- |
.by1 equ dword [ebp+12] ; | |
.bx2 equ [ebp+16] ; | |
.by2 equ dword [ebp+20] ; |> bump and env coords |
.ex1 equ [ebp+24] ; |> shifted shl ROUND |
.ey1 equ dword [ebp+28] ; | |
.ex2 equ [ebp+32] ; | |
.ey2 equ dword [ebp+36] ; --- |
.bmap equ dword [ebp+40] |
.emap equ dword [ebp+44] |
.x1 equ dword [ebp-4] |
.x2 equ dword [ebp-8] |
.dbx equ dword [ebp-12] |
.dby equ [ebp-16] |
.dex equ dword [ebp-20] |
.dey equ [ebp-24] |
.cbx equ dword [ebp-28] |
.cby equ [ebp-32] |
.cex equ dword [ebp-36] |
.cey equ [ebp-40] |
mov ebp,esp |
mov ecx,.y |
or ecx,ecx |
jl .bl_end |
movzx edx,word[size_y_var] |
cmp ecx,edx ;SIZE_Y |
jge .bl_end |
cmp eax,ebx |
jl .bl_ok |
je .bl_end |
xchg eax,ebx |
if Ext = NON |
mov edx,.bx1 |
xchg edx,.bx2 |
mov .bx1,edx |
mov edx,.by1 |
xchg edx,.by2 |
mov .by1,edx |
mov edx,.ex1 |
xchg edx,.ex2 |
mov .ex1,edx |
mov edx,.ey1 |
xchg edx,.ey2 |
mov .ey1,edx |
else |
movq mm0,.bx1 |
movq mm1,.bx2 |
movq mm2,.ex1 |
movq mm3,.ex2 |
movq .bx2,mm0 |
movq .bx1,mm1 |
movq .ex1,mm3 |
movq .ex2,mm2 |
end if |
.bl_ok: |
push eax |
push ebx ;store x1, x2 |
movzx eax,word[size_x_var] |
lea eax,[eax*3] |
; mov eax,SIZE_X*3 |
mov ebx,.y |
mul ebx |
mov ecx,.x1 |
lea ecx,[ecx*3] |
add eax,ecx |
add edi,eax |
mov ecx,.x2 |
sub ecx,.x1 |
mov eax,.bx2 ; calc .dbx |
sub eax,.bx1 |
cdq |
idiv ecx |
push eax |
mov eax,.by2 ; calc .dby |
sub eax,.by1 |
cdq |
idiv ecx |
push eax |
mov eax,.ex2 ; calc .dex |
sub eax,.ex1 |
cdq |
idiv ecx |
push eax |
mov eax,.ey2 ; calc .dey |
sub eax,.ey1 |
cdq |
idiv ecx |
push eax |
push dword .bx1 |
push .by1 |
push dword .ex1 |
push .ey1 |
.draw: |
; if TEX = SHIFTING ;bump drawing only in shifting mode |
mov eax,.cby |
sar eax,ROUND |
shl eax,TEX_SHIFT |
mov esi,.cbx |
sar esi,ROUND |
add esi,eax |
mov ebx,esi |
dec ebx |
and ebx,TEXTURE_SIZE |
add ebx,.bmap |
movzx eax,byte [ebx] |
mov ebx,esi |
inc ebx |
and ebx,TEXTURE_SIZE |
add ebx,.bmap |
movzx ebx,byte [ebx] |
sub eax,ebx |
mov ebx,esi |
sub ebx,TEX_X |
and ebx,TEXTURE_SIZE |
add ebx,.bmap |
movzx edx,byte [ebx] |
mov ebx,esi |
add ebx,TEX_X |
and ebx,TEXTURE_SIZE |
add ebx,.bmap |
movzx ebx,byte [ebx] |
sub edx,ebx |
mov ebx,.cex ;.cex - current env map X |
sar ebx,ROUND |
add eax,ebx ; eax - modified x coord |
mov ebx,.cey ;.cey - current env map y |
sar ebx,ROUND |
add edx,ebx ; edx - modified y coord |
or eax,eax |
jl .black |
cmp eax,TEX_X |
jg .black |
or edx,edx |
jl .black |
cmp edx,TEX_Y |
jg .black |
shl edx,TEX_SHIFT |
add edx,eax |
lea edx,[edx*3] |
add edx,.emap |
mov eax,dword[edx] |
jmp .put_pixel |
.black: |
xor eax,eax |
.put_pixel: |
stosd |
dec edi |
;if Ext >= MMX |
; movq mm0,.cby |
; movq mm1,.cey |
; paddd mm0,.dby |
; paddd mm1,.dey |
; movq .cby,mm0 |
; movq .cey,mm1 |
;else |
mov eax,.dbx |
add .cbx,eax |
mov eax,.dby |
add .cby,eax |
mov eax,.dex |
add .cex,eax |
mov eax,.dey |
add .cey,eax |
;end if |
dec ecx |
jnz .draw |
; end if |
.bl_end: |
mov esp,ebp |
ret 44 |
/programs/demos/3DS/FLAT3.INC |
---|
0,0 → 1,209 |
draw_triangle: |
;----------in - eax - x1 shl 16 + y1 |
;------------- -ebx - x2 shl 16 + y2 |
;---------------ecx - x3 shl 16 + y3 |
;---------------edx - color 0x00rrggbb |
;---------------edi - pointer to screen buffer |
.col equ ebp-4 ;dd ? |
.x1 equ ebp-6 ;dw ? |
.y1 equ ebp-8 ;dw ?;+8 |
.x2 equ ebp-10 ;dw ? |
.y2 equ ebp-12 ;dw ? |
.x3 equ ebp-14 ;dw ? |
.y3 equ ebp-16 ;dw ?;+16 |
.dx12 equ ebp-20 ; dd ? |
.dx13 equ ebp-24 ; dd ?;+24 |
.dx23 equ ebp-28 ; dd ? |
mov ebp,esp |
; sub esp,28 |
push edx |
.ch3: |
cmp ax,bx |
jg .ch1 |
.ch4: ; sort parameters |
cmp bx,cx |
jg .ch2 |
jle .chEnd |
.ch1: |
xchg eax,ebx |
jmp .ch4 |
.ch2: |
xchg ebx,ecx |
jmp .ch3 |
.chEnd: |
; mov dword[.y1],eax ; ..and store to user friendly variables |
; mov dword[.y2],ebx |
; mov dword[.y3],ecx |
; mov [.col],edx |
push eax |
push ebx |
push ecx |
sub esp,12 |
mov edx,eax ; eax,ebx,ecx are ORd together into edx which means that |
or edx,ebx ; if any *one* of them is negative a sign flag is raised |
or edx,ecx |
test edx,80008000h ; Check both X&Y at once |
jne .end_triangle |
mov dx,[size_x_var] |
cmp word[.x1],dx ;SIZE_X ; { |
jg .end_triangle |
cmp word[.x2],dx ;SIZE_X ; This can be optimized with effort |
jg .end_triangle |
cmp word[.x3],dx ;SIZE_X |
jg .end_triangle ; } |
shr eax,16 |
shr ebx,16 |
shr ecx,16 |
neg ax ; calculate delta 12 |
add ax,bx |
cwde |
shl eax,ROUND |
cdq |
mov bx,[.y2] |
mov cx,[.y1] |
sub bx,cx |
;cmp ebx,0 |
jne .noZero1 |
mov dword[.dx12],0 |
jmp .yesZero1 |
.noZero1: |
idiv ebx |
mov [.dx12],eax |
.yesZero1: |
mov ax,[.x3] ; calculate delta 13 |
sub ax,[.x1] |
cwde |
shl eax,ROUND |
cdq |
mov bx,[.y3] |
mov cx,[.y1] |
sub bx,cx |
;cmp ebx,0 |
jne .noZero2 |
mov dword[.dx13],0 |
jmp .yesZero2 |
.noZero2: |
idiv ebx |
mov [.dx13],eax |
.yesZero2: |
mov ax,[.x3] ; calculate delta 23 [dx23] |
sub ax,[.x2] |
cwde |
shl eax,ROUND |
cdq |
mov bx,[.y3] |
mov cx,[.y2] |
sub bx,cx |
;cmp ebx,0 |
jne .noZero3 |
mov dword[.dx23],0 |
jmp .yesZero3 |
.noZero3: |
idiv ebx |
mov [.dx23],eax |
.yesZero3: |
movsx eax,word[.x1] ; eax - xk1 ;;; |
shl eax,ROUND |
mov ebx,eax ; ebx - xk2 ;;; |
movsx esi,word[.y1] ; esi - y |
.next_line1: |
mov ecx,eax ; ecx - x11 |
sar ecx,ROUND |
mov edx,ebx ; edx - x12 |
sar edx,ROUND |
cmp ecx,edx |
jle .nochg |
xchg ecx,edx |
.nochg: |
pusha |
mov ebx,ecx |
sub edx,ecx |
mov ecx,edx |
mov edx,esi |
mov eax,[.col] |
call .horizontal_line |
popa |
add eax,[.dx13] |
add ebx,[.dx12] |
inc esi |
cmp si,[.y2] |
jl .next_line1 |
movzx esi,word[.y2] |
movzx ebx,word[.x2] |
shl ebx,ROUND |
.next_line2: |
mov ecx,eax |
sar ecx,ROUND |
mov edx,ebx |
sar edx,ROUND |
cmp ecx,edx |
jle .nochg1 |
xchg ecx,edx |
.nochg1: |
pusha |
mov ebx,ecx |
sub edx,ecx |
mov ecx,edx |
mov edx,esi |
mov eax,[.col] |
call .horizontal_line |
popa |
add eax,[.dx13] |
add ebx,[.dx23] |
inc esi |
cmp si,[.y3] |
jl .next_line2 |
.end_triangle: |
mov esp,ebp |
ret |
.horizontal_line: |
;---------in |
;---------eax - color of line, 0x00RRGGBB |
;---------ebx - x1 - x position of line begin |
;---------ecx - lenght of line |
;---------edx - y position of line |
;---------edi - pointer to buffer |
jcxz .end_hor_l |
; or edx,edx |
; jl .end_hor_l |
movzx esi,word[size_y_var] |
cmp edx,esi ;SIZE_Y |
jg .end_hor_l |
push eax |
movzx eax,word[size_x_var] |
lea eax,[eax*3] |
; mov eax,SIZE_X*3 |
mul edx |
add edi,eax ; calculate line begin adress |
;add edi,ebx |
;shl ebx,1 |
lea edi,[edi+ebx*2] |
add edi,ebx |
pop eax |
cld |
;mov dword[edi-3],0000FF00h |
dec ecx |
jecxz .last_pix |
.ddraw: ; Drawing horizontally: |
;push eax |
stosd ; 4 bytes at a time |
dec edi ; point to the 4th |
loop .ddraw |
.last_pix: |
stosw |
shr eax,16 |
stosb |
; mov byte[edi],0 ; The last 4th will be reset |
.end_hor_l: |
ret |
/programs/demos/3DS/GRD3.INC |
---|
0,0 → 1,697 |
gouraud_triangle: |
;------------------in - eax - x1 shl 16 + y1 --------- |
;---------------------- ebx - x2 shl 16 + y2 --------- |
;---------------------- ecx - x3 shl 16 + y3 --------- |
;---------------------- edi - pointer to screen buffer |
;---------------------- stack : colors---------------- |
;----------------- procedure don't save registers !!-- |
.col1r equ ebp+4 ; each color as word |
.col1g equ ebp+6 |
.col1b equ ebp+8 |
.col2r equ ebp+10 |
.col2g equ ebp+12 |
.col2b equ ebp+14 |
.col3r equ ebp+16 |
.col3g equ ebp+18 |
.col3b equ ebp+20 |
.x1 equ word[ebp-2] |
.y1 equ word[ebp-4] |
.x2 equ word[ebp-6] |
.y2 equ word[ebp-8] |
.x3 equ word[ebp-10] |
.y3 equ word[ebp-12] |
.dx12 equ dword[ebp-16] |
.dc12r equ dword[ebp-20] |
.dc12g equ [ebp-24] |
.dc12b equ dword[ebp-28] |
.dx13 equ dword[ebp-32] |
.dc13r equ dword[ebp-36] |
.dc13g equ [ebp-40] |
.dc13b equ dword[ebp-44] |
.dx23 equ dword[ebp-48] |
.dc23r equ dword[ebp-52] |
.dc23g equ [ebp-56] |
.dc23b equ dword[ebp-60] |
.c1r equ dword[ebp-64] |
.c1g equ [ebp-68] |
.c1b equ dword[ebp-72] |
.c2r equ dword[ebp-76] |
.c2g equ [ebp-80] |
.c2b equ dword[ebp-84] |
mov ebp,esp |
; sub esp,72 |
.sort3: ; sort triangle coordinates... |
cmp ax,bx |
jle .sort1 |
xchg eax,ebx |
mov edx,dword[.col1r] |
xchg edx,dword[.col2r] |
mov dword[.col1r],edx |
mov dx,word[.col1b] |
xchg dx,word[.col2b] |
mov word[.col1b],dx |
.sort1: |
cmp bx,cx |
jle .sort2 |
xchg ebx,ecx |
mov edx,dword[.col2r] |
xchg edx,dword[.col3r] |
mov dword[.col2r],edx |
mov dx,word[.col2b] |
xchg dx,word[.col3b] |
mov word[.col2b],dx |
jmp .sort3 |
.sort2: |
push eax ;store triangle coordinates in user friendly variables |
push ebx |
push ecx |
; sub esp,72 ; set correctly value of esp |
mov edx,eax ; check only X triangle coordinate |
or edx,ebx |
or edx,ecx |
test edx,80000000h |
jne .gt_loop2_end |
mov dx,[size_x_var] |
dec dx |
shr eax,16 |
cmp ax,dx ;SIZE_X-1 |
jg .gt_loop2_end |
shr ebx,16 |
cmp bx,dx ;SIZE_X-1 |
jg .gt_loop2_end |
shr ecx,16 |
cmp cx,dx ;SIZE_X-1 |
jg .gt_loop2_end |
mov bx,.y2 ; calc deltas |
sub bx,.y1 |
jnz .gt_dx12_make |
xor edx,edx |
mov ecx,4 |
@@: |
push edx |
loop @b |
; mov .dx12,0 |
; mov .dc12r,0 |
; mov .dc12g,0 |
; mov .dc12b,0 |
jmp .gt_dx12_done |
.gt_dx12_make: |
mov ax,.x2 |
sub ax,.x1 |
cwde |
movsx ebx,bx |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dx12,eax |
push eax |
mov ax,word[.col2r] |
sub ax,word[.col1r] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dc12r,eax |
push eax |
mov ax,word[.col2g] |
sub ax,word[.col1g] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dc12g,eax |
push eax |
mov ax,word[.col2b] |
sub ax,word[.col1b] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dc12b,eax |
push eax |
.gt_dx12_done: |
mov bx,.y3 |
sub bx,.y1 |
jnz .gt_dx13_make |
xor edx,edx |
mov ecx,4 |
@@: |
push edx |
loop @b |
; mov .dx13,0 |
; mov .dc13r,0 |
; mov .dc13g,0 |
; mov .dc13b,0 |
jmp .gt_dx13_done |
.gt_dx13_make: |
mov ax,.x3 |
sub ax,.x1 |
cwde |
movsx ebx,bx |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dx13,eax |
push eax |
mov ax,word[.col3r] |
sub ax,word[.col1r] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dc13r,eax |
push eax |
mov ax,word[.col3g] |
sub ax,word[.col1g] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dc13g,eax |
push eax |
mov ax,word[.col3b] |
sub ax,word[.col1b] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dc13b,eax |
push eax |
.gt_dx13_done: |
mov bx,.y3 |
sub bx,.y2 |
jnz .gt_dx23_make |
xor edx,edx |
mov ecx,4 |
@@: |
push edx |
loop @b |
; mov .dx23,0 |
; mov .dc23r,0 |
; mov .dc23g,0 |
; mov .dc23b,0 |
jmp .gt_dx23_done |
.gt_dx23_make: |
mov ax,.x3 |
sub ax,.x2 |
cwde |
movsx ebx,bx |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dx23,eax |
push eax |
mov ax,word[.col3r] |
sub ax,word[.col2r] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dc23r,eax |
push eax |
mov ax,word[.col3g] |
sub ax,word[.col2g] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dc23g,eax |
push eax |
mov ax,word[.col3b] |
sub ax,word[.col2b] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
; mov .dc23b,eax |
push eax |
.gt_dx23_done: |
sub esp,24 |
movsx eax,.x1 |
shl eax,ROUND |
mov ebx,eax |
movsx edx,word[.col1r] |
shl edx,ROUND |
mov .c1r,edx |
mov .c2r,edx |
movsx edx,word[.col1g] |
shl edx,ROUND |
mov .c1g,edx |
mov .c2g,edx |
movsx edx,word[.col1b] |
shl edx,ROUND |
mov .c1b,edx |
mov .c2b,edx |
mov cx,.y1 |
cmp cx,.y2 |
jge .gt_loop1_end |
.gt_loop1: |
push eax ; eax - cur x1 |
push ebx ; ebx - cur x2 |
push cx ; cx - cur y |
push edi |
push ebp |
sar ebx,ROUND |
push bx |
mov edx,.c2r ; c2r,c2g,c2b,c1r,c1g,c1b - current colors |
sar edx,ROUND |
push dx |
mov edx,.c2g |
sar edx,ROUND |
push dx |
mov edx,.c2b |
sar edx,ROUND |
push dx |
sar eax,ROUND |
push ax |
mov edx,.c1r |
sar edx,ROUND |
push dx |
mov edx,.c1g |
sar edx,ROUND |
push dx |
mov edx,.c1b |
sar edx,ROUND |
push dx |
push cx |
call gouraud_line |
pop ebp |
pop edi |
pop cx |
pop ebx |
pop eax |
if Ext >= MMX |
movq mm0,.c1g |
paddd mm0,.dc13g |
movq .c1g,mm0 |
else |
mov edx,.dc13r |
add .c1r,edx |
mov edx,.dc13g |
add .c1g,edx |
end if |
mov edx,.dc13b |
add .c1b,edx |
if Ext >= MMX |
movq mm0,.c2g |
paddd mm0,.dc12g |
movq .c2g,mm0 |
else |
mov edx,.dc12r |
add .c2r,edx |
mov edx,.dc12g |
add .c2g,edx |
end if |
mov edx,.dc12b |
add .c2b,edx |
add eax,.dx13 |
add ebx,.dx12 |
inc cx |
cmp cx,.y2 |
jl .gt_loop1 |
.gt_loop1_end: |
mov cx,.y2 |
cmp cx,.y3 |
jge .gt_loop2_end |
movsx ebx,.x2 |
shl ebx,ROUND |
movsx edx,word[.col2r] |
shl edx,ROUND |
mov .c2r,edx |
movsx edx,word[.col2g] |
shl edx,ROUND |
mov .c2g,edx |
movsx edx,word[.col2b] |
shl edx,ROUND |
mov .c2b,edx |
.gt_loop2: |
push eax ; eax - cur x1 |
push ebx ; ebx - cur x2 |
push cx |
push edi |
push ebp |
sar ebx,ROUND |
push bx |
mov edx,.c2r |
sar edx,ROUND |
push dx |
mov edx,.c2g |
sar edx,ROUND |
push dx |
mov edx,.c2b |
sar edx,ROUND |
push dx |
sar eax,ROUND |
push ax |
mov edx,.c1r |
sar edx,ROUND |
push dx |
mov edx,.c1g |
sar edx,ROUND |
push dx |
mov edx,.c1b |
sar edx,ROUND |
push dx |
push cx |
call gouraud_line |
pop ebp |
pop edi |
pop cx |
pop ebx |
pop eax |
if Ext >= MMX |
movq mm0,.c1g |
paddd mm0,.dc13g |
movq .c1g,mm0 |
else |
mov edx,.dc13r |
add .c1r,edx |
mov edx,.dc13g |
add .c1g,edx |
end if |
mov edx,.dc13b |
add .c1b,edx |
if Ext >= MMX |
movq mm0,.c2g |
paddd mm0,.dc23g |
movq .c2g,mm0 |
else |
mov edx,.dc23r |
add .c2r,edx |
mov edx,.dc23g |
add .c2g,edx |
end if |
mov edx,.dc23b |
add .c2b,edx |
add eax,.dx13 |
add ebx,.dx23 |
inc cx |
cmp cx,.y3 |
jl .gt_loop2 |
.gt_loop2_end: |
; add esp,84 |
mov esp,ebp |
ret 18 |
gouraud_line: |
;-------------in - edi - pointer to screen buffer |
;----------------- stack - another parameters |
.y equ word [ebp+4] |
.col1b equ ebp+6 |
.col1g equ ebp+8 |
.col1r equ ebp+10 |
.x1 equ [ebp+12] |
.col2b equ ebp+14 |
.col2g equ ebp+16 |
.col2r equ ebp+18 |
.x2 equ [ebp+20] |
.dc_r equ dword[ebp-4] |
.dc_g equ dword[ebp-8] |
.dc_b equ dword[ebp-12] |
mov ebp,esp |
mov ax,.y |
or ax,ax |
jl .gl_quit |
mov dx,[size_y_var] |
dec dx |
cmp ax,dx ;SIZE_Y-1 |
jg .gl_quit |
mov ax,.x1 |
cmp ax,.x2 |
je .gl_quit |
jl .gl_ok |
if Ext >= MMX |
movq mm0,[.col1b] |
movq mm1,[.col2b] |
movq [.col1b],mm1 |
movq [.col2b],mm0 |
else |
mov eax,[.col1b] |
xchg eax,[.col2b] |
mov [.col1b],eax |
mov eax,[.col1r] |
xchg eax,[.col2r] |
mov [.col1r],eax |
end if |
.gl_ok: |
; cmp .x1,SIZE_X-1 ;check |
; jg .gl_quit |
; cmp .x2,SIZE_X-1 |
; jl @f |
; mov .x2,SIZE_X-1 |
; @@: |
; cmp .x1,0 |
; jg @f |
; mov .x1,0 |
; @@: |
; cmp .x2,0 |
; jl .gl_quit |
movsx ecx,.y |
movzx eax,word[size_x_var] |
lea eax,[eax*3] |
; mov eax,SIZE_X*3 |
mul ecx |
movsx ebx,word .x1 |
lea ecx,[ebx*2+eax] |
add edi,ecx |
add edi,ebx |
mov ax,word[.col2r] |
sub ax,word[.col1r] |
cwde |
shl eax,ROUND |
cdq |
mov cx,.x2 |
sub cx,.x1 |
movsx ecx,cx |
idiv ecx |
;mov .dc_r,eax ;first delta |
push eax |
mov ax,word[.col2g] |
sub ax,word[.col1g] |
cwde |
shl eax,ROUND |
cdq |
idiv ecx |
;mov .dc_g,eax |
push eax |
mov ax,word[.col2b] |
sub ax,word[.col1b] |
cwde |
shl eax,ROUND |
cdq |
idiv ecx |
; mov .dc_b,eax |
push eax |
movsx ebx,word[.col1r] |
shl ebx,ROUND |
movsx edx,word[.col1g] |
shl edx,ROUND |
movsx esi,word[.col1b] |
shl esi,ROUND |
.gl_draw: |
mov eax,ebx |
sar eax,ROUND |
stosb |
mov eax,edx |
sar eax,ROUND |
stosb |
mov eax,esi |
sar eax,ROUND |
stosb |
add ebx,.dc_r |
add edx,.dc_g |
add esi,.dc_b |
loop .gl_draw |
.gl_quit: |
; add esp,12 |
mov esp,ebp |
ret 18 |
if 0 |
gouraud_line_SSE: ; new |
;-------------in - edi - pointer to screen buffer |
;----------------- stack - another parameters |
.y equ word [ebp+4] |
.col1b equ ebp+6 |
.col1g equ ebp+8 |
.col1r equ ebp+10 |
.x1 equ [ebp+12] |
.col2b equ ebp+14 |
.col2g equ ebp+16 |
.col2r equ ebp+18 |
.x2 equ [ebp+20] |
.dc_r equ dword[ebp-4] |
.dc_g equ dword[ebp-8] |
.dc_b equ dword[ebp-12] |
.lenght equ [ebp-16] |
.factor equ [ebp-24] ;new |
mov ebp,esp |
mov ax,.y |
or ax,ax |
jl .gl_quit |
cmp ax,SIZE_Y-1 |
jg .gl_quit |
mov ax,.x1 |
cmp ax,.x2 |
je .gl_quit |
jl .gl_ok |
if Ext >= MMX |
movq mm0,[.col1b] |
movq mm1,[.col2b] |
movq [.col1b],mm1 |
movq [.col2b],mm0 |
else |
mov eax,[.col1b] |
xchg eax,[.col2b] |
mov [.col1b],eax |
mov eax,[.col1r] |
xchg eax,[.col2r] |
mov [.col1r],eax |
end if |
.gl_ok: |
; cmp .x1,SIZE_X-1 ;check |
; jg .gl_quit |
; cmp .x2,SIZE_X-1 |
; jl @f |
; mov .x2,SIZE_X-1 |
; @@: |
; cmp .x1,0 |
; jg @f |
; mov .x1,0 |
; @@: |
; cmp .x2,0 |
; jl .gl_quit |
movsx ecx,.y |
mov eax,SIZE_X*3 |
mul ecx |
movsx ebx,word .x1 |
lea ecx,[ebx*2+eax] |
add edi,ecx |
add edi,ebx |
mov ax,word[.col2r] |
sub ax,word[.col1r] |
cwde |
shl eax,ROUND |
cdq |
mov cx,.x2 |
sub cx,.x1 |
movsx ecx,cx |
idiv ecx |
;mov .dc_r,eax ;first delta |
push eax |
mov ax,word[.col2g] |
sub ax,word[.col1g] |
cwde |
shl eax,ROUND |
cdq |
idiv ecx |
;mov .dc_g,eax |
push eax |
mov ax,word[.col2b] |
sub ax,word[.col1b] |
cwde |
shl eax,ROUND |
cdq |
idiv ecx |
; mov .dc_b,eax |
push eax |
movsx ebx,word[.col1r] |
shl ebx,ROUND |
movsx edx,word[.col1g] |
shl edx,ROUND |
movsx esi,word[.col1b] |
shl esi,ROUND |
push ecx ; store line lenght |
movd mm3,.dc_r |
psrlq mm3,16 ; load dr to lowest word of mm3 |
pxor mm2,mm2 ; clear mm2 |
movd mm4,.dc_g |
punpcklwd mm3,mm3 ; unpack dr to lower 2 words in in mm3 |
psrlq mm4,16 ; load dg to lowest word of mm4 |
movd mm5,.dc_b |
psrlq mm5,16 ; load db to lowest word of mm5 |
punpcklwd mm4,mm4 ; unpack dg to lower 2 words in in mm3 |
lea ecx,[factor] |
punpckldq mm3,mm3 |
punpcklwd mm5,mm5 ; unpack db to lower 2 words in in mm5 |
movq mm6,[.col1b] |
xor eax,eax |
pinsrw mm6,eax,3 ; clear the highest word in mm6 |
mov eax,010000h |
punpckldq mm4,mm4 ; unpack dg to 4 words in mm4 |
mov [ecx],eax |
mov eax,030002h |
punpckldq mm5,mm5 ; unpack db to 4 words in mm5 |
movq mm7,mm6 ; load r1r1,g1g1,b1b1 to the first three |
; words of mm7 |
pxor mm1,mm1 ; clear mm1 |
.gl_draw: |
mov eax,ebx |
sar eax,ROUND |
stosb |
mov eax,edx |
sar eax,ROUND |
stosb |
mov eax,esi |
sar eax,ROUND |
stosb |
add ebx,.dc_r |
add edx,.dc_g |
add esi,.dc_b |
loop .gl_draw |
.gl_quit: |
; add esp,12 |
mov esp,ebp |
ret 18 |
end if |
/programs/demos/3DS/TEX3.INC |
---|
0,0 → 1,546 |
;--------------------------------------------------------------------- |
;--------------------textured triangle procedure---------------------- |
;--------------------------------------------------------------------- |
tex_triangle: |
;----------in - eax - x1 shl 16 + y1 |
;-------------- ebx - x2 shl 16 + y2 |
;---------------ecx - x3 shl 16 + y3 |
;---------------edx - nothing |
;---------------esi - pointer to texture buffer |
;---------------edi - pointer to screen buffer |
;-------------stack - texture coordinates |
.tex_x1 equ ebp+4 |
.tex_y1 equ ebp+6 |
.tex_x2 equ ebp+8 |
.tex_y2 equ ebp+10 |
.tex_x3 equ ebp+12 |
.tex_y3 equ ebp+14 |
.x1 equ ebp-2 ;dw ? |
.y1 equ ebp-4 ;dw ? |
.x2 equ ebp-6 ;dw ? |
.y2 equ ebp-8 ;dw ? |
.x3 equ ebp-10 ;dw ? |
.y3 equ ebp-12 ;dw ? |
.dx12 equ ebp-16 ;dd ? |
.dx13 equ ebp-20 ;dd ? |
.dx23 equ ebp-24 ;dd ? |
.tex_dx12 equ ebp-28 ;dd ? |
.tex_dy12 equ ebp-32 ;dd ? |
.tex_dx13 equ ebp-36 ;dd ? |
.tex_dy13 equ ebp-40 ;dd ? |
.tex_dx23 equ ebp-44 ;dd ? |
.tex_dy23 equ ebp-48 ;dd ? |
.tex_ptr equ ebp-52 ;dd ? |
.scan_x2 equ ebp-56 ;dd ? |
.scan_y2 equ ebp-60 ;dd ? |
.scan_x1 equ ebp-64 ;dd ? |
.scan_y1 equ ebp-68 ;dd ? |
mov ebp,esp |
sub esp,68 |
;if Ext = MMX |
; emms |
;end if |
mov edx,dword[.tex_x1] ; check all parameters |
or dx,dx |
jl .tt_end |
cmp dx,TEX_X-1 |
jg .tt_end |
shr edx,16 |
or dx,dx |
jl .tt_end |
cmp dx,TEX_Y-1 |
jg .tt_end |
mov edx,dword[.tex_x2] |
or dx,dx |
jl .tt_end |
cmp dx,TEX_X-1 |
jg .tt_end |
shr edx,16 |
or dx,dx |
jl .tt_end |
cmp dx,TEX_Y-1 |
jg .tt_end |
mov edx,dword[.tex_x3] |
or dx,dx |
jl .tt_end |
cmp dx,TEX_X-1 |
jg .tt_end |
shr edx,16 |
cmp dx,TEX_Y-1 |
jg .tt_end |
or dx,dx |
jl .tt_end |
mov edx,eax ; check X&Y triangle coordinate |
or edx,ebx |
or edx,ecx |
test edx,80008000h |
jne .tt_end |
mov dx,[size_x_var] |
; or ax,ax |
; jl .tt_end |
; cmp ax,SIZE_Y |
; jg .tt_end |
ror eax,16 |
; or ax,ax |
; jl .tt_end |
cmp ax,dx ;SIZE_X |
jg .tt_end |
rol eax,16 |
; or bx,bx |
; jl .tt_end |
; cmp bx,SIZE_Y |
; jg .tt_end |
ror ebx,16 |
; or bx,bx |
; jl .tt_end |
cmp bx,dx ;SIZE_X |
jg .tt_end |
rol ebx,16 |
; or cx,cx |
; jl .tt_end |
; cmp cx,SIZE_Y |
; jg .tt_end |
ror ecx,16 |
; or cx,cx |
; jl .tt_end |
cmp cx,dx ;SIZE_X |
jg .tt_end |
rol ecx,16 ; uff.. parameters was checked |
cmp ax,bx ;sort all parameters |
jle .tt_sort1 |
xchg eax,ebx |
mov edx,dword [.tex_x1] |
xchg edx,dword [.tex_x2] |
mov dword[.tex_x1],edx |
.tt_sort1: |
cmp ax,cx |
jle .tt_sort2 |
xchg eax,ecx |
mov edx,dword [.tex_x1] |
xchg edx,dword [.tex_x3] |
mov dword [.tex_x1],edx |
.tt_sort2: |
cmp bx,cx |
jle .tt_sort3 |
xchg ebx,ecx |
mov edx,dword [.tex_x2] |
xchg edx,dword [.tex_x3] |
mov dword [.tex_x2],edx |
.tt_sort3: |
mov [.y1],ax ; and store to user friendly variables |
shr eax,16 |
mov [.x1],ax |
mov [.y2],bx |
shr ebx,16 |
mov [.x2],bx |
mov [.y3],cx |
shr ecx,16 |
mov [.x3],cx |
mov [.tex_ptr],esi |
movsx ebx,word[.y2] |
sub bx,[.y1] |
jnz .tt_dx12_make |
mov dword[.dx12],0 |
mov dword[.tex_dx12],0 |
mov dword[.tex_dy12],0 |
jmp .tt_dx12_done |
.tt_dx12_make: |
mov ax,[.x2] |
sub ax,[.x1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
mov [.dx12],eax ; dx12 = (x2-x1)/(y2-y1) |
mov ax,word[.tex_x2] |
sub ax,word[.tex_x1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
mov [.tex_dx12],eax ; tex_dx12 = (tex_x2-tex_x1)/(y2-y1) |
mov ax,word[.tex_y2] |
sub ax,word[.tex_y1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
mov [.tex_dy12],eax ; tex_dy12 = (tex_y2-tex_y1)/(y2-y1) |
.tt_dx12_done: |
movsx ebx,word[.y3] |
sub bx,word[.y1] |
jnz .tt_dx13_make |
mov dword [.dx13],0 |
mov dword [.tex_dx13],0 |
mov dword [.tex_dy13],0 |
jmp .tt_dx13_done |
.tt_dx13_make: |
mov ax,[.x3] |
sub ax,[.x1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
mov [.dx13],eax ; dx13 = (x3-x1)/(y3-y1) |
mov ax,word[.tex_x3] |
sub ax,word[.tex_x1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
mov [.tex_dx13],eax ; tex_dx13 = (tex_x3-tex_x1)/(y3-y1) |
mov ax,word[.tex_y3] |
sub ax,word[.tex_y1] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
mov [.tex_dy13],eax ; tex_dy13 = (tex_y3-tex_y1)/(y3-y1) |
.tt_dx13_done: |
movsx ebx,word[.y3] |
sub bx,word[.y2] |
jnz .tt_dx23_make |
mov dword [.dx23],0 |
mov dword [.tex_dx23],0 |
mov dword [.tex_dy23],0 |
jmp .tt_dx23_done |
.tt_dx23_make: |
mov ax,[.x3] |
sub ax,[.x2] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
mov [.dx23],eax ; dx23 = (x3-x2)/(y3-y2) |
mov ax,word[.tex_x3] |
sub ax,word[.tex_x2] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
mov [.tex_dx23],eax ; tex_dx23 = (tex_x3-tex_x2)/(y3-y2) |
mov ax,word[.tex_y3] |
sub ax,word[.tex_y2] |
cwde |
shl eax,ROUND |
cdq |
idiv ebx |
mov [.tex_dy23],eax ; tex_dy23 = (tex_y3-tex_y2)/(y3-y2) |
.tt_dx23_done: |
movsx eax,word[.x1] |
shl eax,ROUND |
mov ebx,eax |
movsx edx, word[.tex_x1] |
shl edx,ROUND |
mov [.scan_x1],edx |
mov [.scan_x2],edx |
movsx edx, word[.tex_y1] |
shl edx,ROUND |
mov [.scan_y1],edx |
mov [.scan_y2],edx |
mov cx,[.y1] |
cmp cx, [.y2] |
jge .tt_loop1_end |
.tt_loop1: |
push edi |
push eax |
push ebx |
push cx |
push ebp |
;; Madis |
;if Ext=MMX ; With MMX enabled it reverse light vectors ???? |
; mov dword[esp-8],ROUND |
; mov dword[esp-4],0 ; Is this a bug? Explanation down 3 lines |
; movq mm0,qword[.scan_y1] |
; movq mm1,qword[.scan_y2] |
; psrad mm0,[esp-8] ;This instr. won't allow modifiers BYTE, WORD, etc. |
; psrad mm1,[esp-8] ;It always defaults to QWORD |
; packssdw mm0,mm1 |
; movq [esp-8],mm0 |
; sub esp,8 |
;else |
push dword[.scan_y2] ; now I push variables on stack without shifting |
push dword[.scan_x2] |
push dword[.scan_y1] |
push dword[.scan_x1] |
;end if |
push dword[.tex_ptr] |
push cx |
mov edx,ebx |
sar edx,ROUND |
push dx |
mov edx,eax |
sar edx,ROUND |
push dx |
call textured_line |
pop ebp |
pop cx |
pop ebx |
pop eax |
pop edi |
mov edx, [.tex_dx13] |
add [.scan_x1], edx |
mov edx, [.tex_dx12] |
add [.scan_x2], edx |
mov edx, [.tex_dy13] |
add [.scan_y1], edx |
mov edx, [.tex_dy12] |
add [.scan_y2], edx |
add eax, [.dx13] |
add ebx, [.dx12] |
inc cx |
cmp cx,[.y2] |
jl .tt_loop1 |
.tt_loop1_end: |
mov cx, [.y2] |
cmp cx, [.y3] |
jge .tt_loop2_end |
movsx ebx,word[.x2] |
shl ebx,ROUND |
movsx edx, word[.tex_x2] |
shl edx,ROUND |
mov [.scan_x2],edx |
movsx edx, word[.tex_y2] |
shl edx,ROUND |
mov [.scan_y2],edx |
.tt_loop2: |
push edi |
push eax |
push ebx |
push cx |
push ebp |
;; Madis |
;if Ext=MMX |
; mov dword[esp-8],ROUND |
; mov dword[esp-4],0 ; Is this a bug? Explanation down 3 lines |
; movq mm0,qword[.scan_y1] |
; movq mm1,qword[.scan_y2] |
; psrad mm0,[esp-8] ;This instr. won't allow modifiers BYTE, WORD, etc. |
; psrad mm1,[esp-8] ;It always defaults to QWORD |
; packssdw mm0,mm1 |
; movq [esp-8],mm0 |
; sub esp,8 |
;else |
;end if |
push dword[.scan_y2] |
push dword[.scan_x2] |
push dword[.scan_y1] |
push dword[.scan_x1] |
push dword[.tex_ptr] |
push cx |
mov edx,ebx |
sar edx,ROUND |
push dx |
mov edx,eax |
sar edx,ROUND |
push dx |
call textured_line |
pop ebp |
pop cx |
pop ebx |
pop eax |
pop edi |
mov edx, [.tex_dx13] |
add [.scan_x1], edx |
mov edx, [.tex_dx23] |
add [.scan_x2], edx |
mov edx, [.tex_dy13] |
add [.scan_y1], edx |
mov edx, [.tex_dy23] |
add [.scan_y2], edx |
add eax, [.dx13] |
add ebx, [.dx23] |
inc cx |
cmp cx,[.y3] |
jl .tt_loop2 |
.tt_loop2_end: |
.tt_end: |
mov esp,ebp |
ret 12 |
textured_line: |
;-----in -edi screen buffer pointer |
;------------ stack: |
.x1 equ word [ebp+4] |
.x2 equ word [ebp+6] |
.y equ word [ebp+8] |
.tex_ptr equ dword [ebp+10] |
.tex_x1 equ [ebp+14] |
.tex_y1 equ [ebp+18] |
.tex_x2 equ [ebp+22] |
.tex_y2 equ [ebp+26] |
.tex_dx equ ebp-4 ;dd ? |
.tex_dy equ ebp-8 ;dd ? |
mov ebp,esp |
sub esp,8 |
mov ax,.y |
or ax,ax |
jl .tl_quit |
mov dx,[size_y_var] |
cmp ax,dx ;SIZE_Y |
jg .tl_quit |
mov ax,.x1 |
cmp ax,.x2 |
je .tl_quit |
jl .tl_ok |
xchg ax,.x2 |
mov .x1,ax |
if Ext >= MMX |
movq mm0,.tex_x1 |
movq mm1,.tex_x2 |
movq .tex_x2,mm0 |
movq .tex_x1,mm1 |
else |
mov eax,.tex_x1 |
xchg eax,.tex_x2 |
mov .tex_x1,eax |
mov eax,.tex_y1 |
xchg eax,.tex_y2 |
mov .tex_y1,eax |
end if |
.tl_ok: |
mov ebx,edi |
movsx edi,.y |
movzx eax,word[size_x_var] |
lea eax,[eax*3] |
; mov eax,SIZE_X*3 |
mul edi |
mov edi,eax |
movsx eax,.x1 |
add edi,eax |
shl eax,1 |
add edi,eax |
add edi,ebx |
mov cx,.x2 |
sub cx,.x1 |
movsx ecx,cx |
mov eax,.tex_x2 |
sub eax,.tex_x1 |
cdq |
idiv ecx |
mov [.tex_dx],eax ; tex_dx=(tex_x2-tex_x1)/(x2-x1) |
mov eax,.tex_y2 |
sub eax,.tex_y1 |
cdq |
idiv ecx |
mov [.tex_dy],eax ; tex_dy = (tex_y2-tex_y1)/(x2-x1) |
mov eax,.tex_x1 |
mov ebx,.tex_y1 |
cld |
.tl_loop: |
mov edx,eax ; eax - cur x |
mov esi,ebx ; ebx - cur y |
shr edx,ROUND |
shr esi,ROUND |
macro .fluent |
{ |
push eax |
push edx |
mov eax,TEX_X*3 |
mul esi |
mov esi,eax |
pop edx |
pop eax |
} |
macro .shift |
{ |
shl esi,TEX_SHIFT |
lea esi,[esi*3] |
;push edx |
;mov edx,esi |
;shl esi,1 |
;add esi,edx |
;pop edx |
} |
if TEX = FLUENTLY |
.fluent |
end if |
if TEX = SHIFTING |
.shift |
end if |
lea edx,[edx*3] |
add esi,edx |
; shl edx,1 |
; add esi,edx |
add esi,.tex_ptr |
movsd |
dec edi |
add eax,[.tex_dx] |
add ebx,[.tex_dy] |
loop .tl_loop |
.tl_quit: |
mov esp,ebp |
ret 18+8 |
; .tex_dx dd ? |
; .tex_dy dd ? |
/programs/demos/3DS/ASC.INC |
---|
31,7 → 31,7 |
mov ebx,eax |
push eax |
call ascii_to_integer |
mov [points_count_var],edx |
mov [points_count_var],dx |
pop eax |
@@: |
59,7 → 59,7 |
mov ebx,eax |
push eax |
call ascii_to_integer |
mov [triangles_count_var],edx |
mov [triangles_count_var],dx |
pop eax |
@@: |
114,7 → 114,7 |
jne .decode_coord |
pop ebx |
inc ebx |
cmp ebx,[points_count_var] |
cmp bx,[points_count_var] |
jne .decode_vertices |
mov dword[edi],-1 |
175,9 → 175,9 |
call ascii_to_integer |
mov eax,edx |
stosd |
stosw |
pop esi |
add esi,4 |
add esi,2 |
pop ecx |
inc ecx |
185,7 → 185,7 |
jne .next_vertex_number |
pop edx |
inc edx |
cmp edx,[triangles_count_var] |
cmp dx,[triangles_count_var] |
jne .decode_face |
mov dword[edi],-1 ;dword[triangles+ebx+2],-1 ; end mark |
mov eax,1 ;-> mark if ok |