Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8013 → Rev 8014

/programs/demos/3DS/FLAT3.INC
File deleted
/programs/demos/3DS/BUMP3.INC
File deleted
\ No newline at end of file
/programs/demos/3DS/TEX3.INC
File deleted
/programs/demos/3DS/GRD3.INC
File deleted
/programs/demos/3DS/3DMATH.INC
160,6 → 160,7
ret
 
make_vector_r:
if Ext < SSE2
fninit
fld dword[edi] ;edi+x3d
fsub dword[esi] ;esi+x3d
172,6 → 173,14
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/ASC.INC
31,7 → 31,7
mov ebx,eax
push eax
call ascii_to_integer
mov [points_count_var],dx
mov [points_count_var],edx
pop eax
 
@@:
59,7 → 59,7
mov ebx,eax
push eax
call ascii_to_integer
mov [triangles_count_var],dx
mov [triangles_count_var],edx
pop eax
 
@@:
114,7 → 114,7
jne .decode_coord
pop ebx
inc ebx
cmp bx,[points_count_var]
cmp ebx,[points_count_var]
jne .decode_vertices
mov dword[edi],-1
 
175,9 → 175,9
call ascii_to_integer
mov eax,edx
 
stosw
stosd
pop esi
add esi,2
add esi,4
 
pop ecx
inc ecx
185,7 → 185,7
jne .next_vertex_number
pop edx
inc edx
cmp dx,[triangles_count_var]
cmp edx,[triangles_count_var]
jne .decode_face
mov dword[edi],-1 ;dword[triangles+ebx+2],-1 ; end mark
mov eax,1 ;-> mark if ok
/programs/demos/3DS/A_PROCS.INC
111,7 → 111,7
 
draw_dots:
mov esi,[points_translated_ptr]
movzx ecx,[points_count_var]
mov ecx,[points_count_var]
.drw:
@@:
lodsd
486,24 → 486,24
jle .next
 
mov edi,[triangles_ptr]
mov ax,4
mov bx,4+4
mov [triangles_count_var],164*3 ;140
mov eax,4
mov ebx,4+4
mov [triangles_count_var],160*3 ;164*3 ;140
 
mov cx,80*3 ;68
mov ecx,80*3 ;68
@@:
stosw ;----
mov [edi],bx ; |
add edi,2 ; |
inc ax ; |
stosw ; |repeat 4 times
stosd ;----
mov [edi],ebx ; |
add edi,4 ; |
inc eax ; |
stosd ; |repeat 4 times
 
mov [edi],bx ; |
inc bx
add edi,2
stosw ; |
mov [edi],bx ; |
add edi,2 ;----
mov [edi],ebx ; |
inc ebx
add edi,4
stosd ; |
mov [edi],ebx ; |
add edi,4 ;----
loop @b
 
 
627,57 → 627,57
; init triangles list
 
mov edi,[triangles_ptr]
mov ax,5
mov bx,5+5
mov [triangles_count_var],204
mov eax,5
mov ebx,5+5
mov [triangles_count_var],200 ;204
 
mov cx,100
mov ecx,100
@@:
stosw ;----
mov [edi],bx ; |
add edi,2 ; |
inc ax ; |
stosw ; |repeat
stosd ;----
mov [edi],ebx ; |
add edi,4 ; |
inc eax ; |
stosd ; |repeat
 
mov [edi],bx ; |
inc bx
add edi,2
stosw ; |
mov [edi],bx ; |
add edi,2 ;----
mov [edi],ebx ; |
inc ebx
add edi,4
stosd ; |
mov [edi],ebx ; |
add edi,4 ;----
loop @b
 
mov ax,5
mov bx,[points_count_var]
sub bx,2
mov eax,5
mov ebx,[points_count_var]
sub ebx,2
mov dl,2
.nx:
mov cx,5
add [triangles_count_var],cx
mov ecx,5
add [triangles_count_var],ecx
@@:
stosw
add ax,5
stosw
mov word[edi],bx
add edi,2
stosd
add eax,5
stosd
mov dword[edi],ebx
add edi,4
loop @b
 
cmp dl,1
je @f
 
inc bx
inc ebx
jmp .lab
@@:
dec bx
dec ebx
.lab:
mov cx,5
add [triangles_count_var],cx
mov ecx,5
add [triangles_count_var],ecx
@@:
stosw
add ax,5
stosw
mov word[edi],bx
add edi,2
stosd
add eax,5
stosd
mov dword[edi],ebx
add edi,4
loop @b
 
dec dl
684,19 → 684,19
or dl,dl
jnz .nx
 
sub ax,25
stosw
sub ax,50
stosw
mov word[edi],bx
add edi,2
sub eax,25
stosd
sub eax,50
stosd
mov dword[edi],ebx
add edi,4
 
stosw
add ax,50
stosw
inc bx
mov word[edi],bx
add edi,2
stosd
add eax,50
stosd
inc ebx
mov dword[edi],ebx
add edi,4
add [triangles_count_var],2
 
mov dword[edi],-1 ; < - end mark
706,3 → 706,4
pop ebp
 
ret
 
/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 dx,[points_count_var]
mov edx,[points_count_var]
fld dword[edi+ebx]
fst .max
fstp .min
add edi,12
dec dx
dec edx
.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 dx
dec edx
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 dx,[points_count_var] ; substraction all coords - center point
mov edx,[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 dx
dec edx
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>
movzx ecx,[points_count_var]
mov ecx,[points_count_var]
@@:
fld dword[edi]
fdiv .maxxx
405,78 → 405,78
;init triangles list
mov edi,[triangles_ptr]
 
xor si,si
xor ax,ax
mov bx,.N+1
mov cx,(.N*2)+2 ;--
mov dx,(.N*3)+3 ;---
xor esi,esi
xor eax,eax
mov ebx,.N+1
mov ecx,(.N*2)+2 ;--
mov edx,(.N*3)+3 ;---
mov [triangles_count_var],0
.again_tri:
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
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
 
 
add edi,4
add edi,8
 
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 ;----
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 ;----
 
dec ax ; border of wave
dec bx
dec cx
dec dx
dec eax ; border of wave
dec ebx
dec ecx
dec edx
 
stosw ; first border
inc ax
stosw
mov word[edi],dx
add edi,2
stosd ; first border
inc eax
stosd
mov dword[edi],edx
add edi,4
 
mov word[edi],dx
add edi,2
stosw
inc dx
mov word[edi],dx
mov dword[edi],edx
add edi,4
stosd
inc edx
mov dword[edi],edx
 
mov word[edi+2],bx ; second border
mov word[edi+4],cx
inc bx
mov word[edi+6],bx
mov dword[edi+4],ebx ; second border
mov dword[edi+8],ecx
inc ebx
mov dword[edi+12],ebx
 
mov word[edi+8],bx
mov word[edi+10],cx
inc cx
mov word[edi+12],cx
add edi,14
mov dword[edi+16],ebx
mov dword[edi+20],ecx
inc ecx
mov dword[edi+24],ecx
add edi,28
 
add [triangles_count_var],8 ;10
inc si
cmp si,.N
inc esi
cmp esi,.N
jne .again_tri
 
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
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
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,11 → 824,8
; mov ecx,(SIZE_X*(SIZE_Y-3))*3/8
.blr:
@@:
push ecx
mov ecx,edi
sub ecx,ebx
movq mm0,[edi+ebx]
movq mm1,[ecx]
movq mm1,[edi-ebx]
movq mm2,[edi-3]
movq mm3,[edi+3]
 
841,7 → 838,7
movq [edi],mm0
add edi,8
add esi,8
pop ecx
 
loop .blr
 
xor eax,eax
995,7 → 992,7
mov edi,[points_ptr] ; one real point - triple float
mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z
fninit
movzx ecx,[points_count_var]
mov ecx,[points_count_var]
 
cmp ah,11
je @f
1044,7 → 1041,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
movzx ecx,[points_count_var]
mov ecx,[points_count_var]
 
cmp [xchg_flag],1
je @f
/programs/demos/3DS/DATA.INC
74,7 → 74,7
db 3
db 'shd. model'
db 12
dr_flag db 0
dr_flag db 0 ; 6 - dots
dd shd_f
 
db 4
457,8 → 457,8
scale dd ? ; help scale variable
edges_counter dd ?
;==
triangles_count_var dw ?
points_count_var dw ?
triangles_count_var dd ?
points_count_var dd ?
; triangles_ptr dd ?
; triangles_w_z_ptr dd ?
; triangles_normals_ptr dd ?
485,9 → 485,9
 
;===
 
point_index1 dw ? ;-\
point_index2 dw ? ; } don't change order
point_index3 dw ? ;-/
point_index1 dd ? ;-\
point_index2 dd ? ; } don't change order
point_index3 dd ? ;-/
temp_col dw ?
high dd ?
rand_seed dw ?
/programs/demos/3DS/History.txt
1,9 → 1,8
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,6 → 1,15
View3ds 0.068b - tiny viewer to .3ds and .asc files with several graphics
View3ds 0.069 - 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
11,8 → 20,7
mapping), grdl (Gouraud lines - edges only).
3. speed: idle, full.
4,5. zoom in, out: no comment.
6. catmull: on -> use z buffer ( z coordinate interpolation), off -> depth sorting, painters
alghoritm).Txgrd, 2tex and bumptex models only with catmull = on.
6. catmull: disabled
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
34,4 → 42,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 XI 2016
Maciej Guba V 2020
/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
movzx ecx,[points_count_var]
mov 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
movzx ecx,[points_count_var]
mov ecx,[points_count_var]
call rotary
 
; RDTSC
512,7 → 512,7
 
mov esi,[points_rotated_ptr]
mov edi,[points_translated_ptr]
movzx ecx,[points_count_var]
mov 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
call sort_triangles
; cmp [catmull_flag],1 ;non sort if Catmull = on
; je .no_sort
; 64 indexes 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
movzx ecx,[points_count_var]
mov ecx,[points_count_var]
inc ecx
; cmp [map_tex_flag],1
; jne .cylindric
1422,16 → 1422,16
@@:
push ebx
mov ebx,vectors
movzx esi,word[ebp] ; first point index
mov esi,dword[ebp] ; first point index
lea esi,[esi*3]
lea esi,[points+esi*2] ; esi - pointer to 1st 3d point
movzx edi,word[ebp+2] ; second point index
movzx edi,dword[ebp+4] ; 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,word[ebp+4] ; third point index
movzx edi,dword[ebp+8] ; third point index
lea edi,[edi*3]
lea edi,[points+edi*2]
call make_vector
1442,22 → 1442,23
call cross_product
mov edi,ebx
call normalize_vector
add ebp,6
add ebp,12
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 word [ebp-26]
.hit_faces equ word [ebp-28]
.point_number equ dword [ebp-28]
.hit_faces equ dword [ebp-32]
 
fninit
mov ebp,esp
sub esp,28
sub esp,32
mov edi,[points_normals_ptr]
mov .point_number,0
.ipn_loop:
1470,8 → 1471,8
.ipn_check_face:
xor ebx,ebx ; ebx - 'position' in one triangle
.ipn_check_vertex:
movzx eax,word[esi+ebx] ; eax - point_number
cmp ax,.point_number
mov eax,dword[esi+ebx] ; eax - point_number
cmp eax,.point_number
jne .ipn_next_vertex
push esi
mov esi,ecx
1493,13 → 1494,13
inc .hit_faces
jmp .ipn_next_face
.ipn_next_vertex:
add ebx,2
cmp ebx,6
add ebx,4
cmp ebx,12
jne .ipn_check_vertex
.ipn_next_face:
add esi,6
add esi,12
inc ecx
cmp cx,[triangles_count_var]
cmp ecx,[triangles_count_var]
jne .ipn_check_face
 
fld .x
1514,8 → 1515,8
call normalize_vector
add edi,12 ;type vector 3d
inc .point_number
mov dx,.point_number
cmp dx,[points_count_var]
mov edx,.point_number
cmp edx,[points_count_var]
jne .ipn_loop
 
mov esp,ebp
1525,15 → 1526,17
init_triangles_normals2:
mov ebx,[triangles_normals_ptr]
mov ebp,[triangles_ptr]
mov ecx,[triangles_count_var]
@@:
push ecx
push ebx
mov ebx,vectors
movzx esi,word[ebp] ; first point index
mov esi,dword[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]
movzx edi,word[ebp+2] ; first point index
mov edi,dword[ebp+4] ; first point index
lea edi,[edi*3]
shl edi,2
add edi,[points_ptr]
1543,7 → 1546,7
call make_vector_r
add ebx,12
mov esi,edi
movzx edi,word[ebp+4] ; third point index
mov edi,dword[ebp+8] ; third point index
lea edi,[edi*3]
shl edi,2
add edi,[points_ptr]
1556,13 → 1559,16
call cross_product
mov edi,ebx
call normalize_vector
add ebp,6
add ebp,12
add ebx,12
cmp dword[ebp],-1
jne @b
pop ecx
sub ecx,1
jnz @b
; cmp dword[ebp],-1
; jne @b
ret
if 0 ; ind 64 but
 
 
;=================================================================
sort_triangles:
mov esi,[triangles_ptr]
1873,7 → 1879,7
; end if
movsd ; copy end mark too
ret
 
end if ; 64 ind
clrscr:
mov edi,[screen_ptr]
movzx ecx,word[size_x_var]
1937,28 → 1943,31
 
mov esi,[triangles_ptr]
mov [edges_counter],0
mov ecx,[triangles_count_var]
.again_dts:
push ecx
mov ebp,[points_translated_ptr]
if Ext=NON
movzx eax,word[esi]
mov [point_index1],ax
if Ext >= SSE2
mov eax,dword[esi]
mov [point_index1],eax
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
 
 
movzx eax,word[esi+2]
mov [point_index2],ax
mov eax,dword[esi+4]
mov [point_index2],eax
lea eax,[eax*3]
add eax,eax
push ebp
1970,8 → 1979,8
pop ebp
 
 
movzx eax,word[esi+4] ; xyz3 = [ebp+[esi+4]*6]
mov [point_index3],ax
mov eax,dword[esi+8] ; xyz3 = [ebp+[esi+4]*6]
mov [point_index3],eax
lea eax,[eax*3]
add eax,eax
; push ebp
1981,19 → 1990,22
mov eax,[ebp+4]
mov [zz3],ax
else
mov eax,dword[esi] ; don't know MMX
mov dword[point_index1],eax
movq mm0,[esi] ; don't know MMX
mov qword[point_index1],mm0
; shr eax,16
; mov [point_index2],ax
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
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
and eax,0FFFFh
and ebx,0FFFFh
and ecx,0FFFFh
2050,7 → 2062,7
mov esi,point_index1 ; *********************************
mov ecx,3 ;
@@:
movzx eax,word[esi]
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr]
2090,7 → 2102,7
mov esi,point_index3 ; do Gouraud shading
mov ecx,3
.again_grd_draw:
movzx eax,word[esi]
mov eax,dword[esi]
shl eax,2
lea eax,[eax*3]
add eax,[points_normals_rot_ptr]
2111,11 → 2123,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
2125,7 → 2137,7
shr eax,24
push ax ;b
 
sub esi,2
sub esi,4
dec cx
jnz .again_grd_draw
jmp .both_draw
2179,19 → 2191,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
2205,21 → 2217,20
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
cmp [catmull_flag],0
je @f
; lea esi,[Z_buffer]
; cmp [catmull_flag],0
; je @f
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
movzx eax,[point_index1]
movzx ebx,[point_index2]
movzx ecx,[point_index3]
mov eax,[point_index1]
mov ebx,[point_index2]
mov ecx,[point_index3]
shl eax,2
shl ebx,2
shl ecx,2
2246,7 → 2257,8
mov edx,dword[esp-8]
shl edx,TEX_SHIFT
add edx,dword[esp-4]
lea eax,[3*edx+color_map]
lea eax,[3*edx]
add eax,color_map
mov edx,dword[eax]
 
and edx,0x00ffffff ; edx = 0x00rrggbb
2271,11 → 2283,9
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
; mov edi,screen
mov edi,[screen_ptr]
cmp [catmull_flag],0
je @f
; lea esi,[Z_buffer]
; cmp [catmull_flag],0
; je @f
mov esi,[Zbuffer_ptr]
push word[zz3]
push word[zz2]
2282,23 → 2292,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
@@:
movzx eax,word[esi]
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated
2327,7 → 2337,7
fistp word[edi+2]
; # end of last ch.
add edi,4
add esi,2
add esi,4
loop @b
 
mov eax,dword[xx1]
2338,30 → 2348,30
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap
cmp [catmull_flag],0
je @f
; mov edx,Z_buffer
; cmp [catmull_flag],0
; je @f
 
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
@@:
movzx eax,word[esi]
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated
2390,7 → 2400,7
; fistp word[edi+2]
; # end of last ch.
add edi,4
add esi,2
add esi,4
loop @b
 
mov eax,dword[xx1]
2401,34 → 2411,33
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap_cub
cmp [catmull_flag],0
je @f
; mov edx,Z_buffer
; cmp [catmull_flag],0
; je @f
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
; push Z_buffer
; cmp [catmull_flag],0
; je @f
 
push [Zbuffer_ptr]
push [zz3]
push [zz2]
push [zz1]
@@:
; @@:
mov esi,point_index1
sub esp,12
mov edi,esp
mov ecx,3
@@:
movzx eax,word[esi]
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated
2444,14 → 2453,14
fistp word[edi+2]
 
add edi,4
add esi,2
add esi,4
loop @b
 
movzx esi,[point_index3] ; bump map coords
mov esi,[point_index3] ; bump map coords
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index2]
mov esi,[point_index2]
shl esi,2
add esi,tex_points
; lea esi,[esi*3]
2458,7 → 2467,7
; lea esi,[points+2+esi*2]
push dword[esi]
; push dword[xx2]
movzx esi,[point_index1]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
; lea esi,[esi*3]
2476,32 → 2485,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]
@@:
movzx esi,[point_index3] ; tex map coords
; @@:
mov esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index2]
mov esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index1]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
2514,16 → 2523,14
ror ecx,16
mov edi,[screen_ptr]
mov esi,texmap
cmp [catmull_flag],0
je @f
; mov edx,Z_buffer
; cmp [catmull_flag],0
; je @f
mov edx,[Zbuffer_ptr]
call tex_triangle_z
; call tex_plus_grd_trianlgle
; jmp .end_draw
; @@:
; call tex_triangle
jmp .end_draw
@@:
call tex_triangle
jmp .end_draw
; .ray:
; grd_triangle according to points index
; cmp [catmull_flag],0
2564,15 → 2571,15
sub esp,4
push ebp
 
movzx esi,[point_index3] ; tex map coords
mov esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi] ; texture coords as first
movzx esi,[point_index2] ; group of parameters
mov esi,[point_index2] ; group of parameters
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index1]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
2585,7 → 2592,7
lea edx,[ecx*3]
push word[edx*2+xx1-2] ; zz1 ,2 ,3
 
movzx eax,word[esi]
mov eax,dword[esi]
shl eax,2
lea eax,[eax*3] ;+point_normals_rotated]
add eax,[points_normals_rot_ptr]
2616,7 → 2623,7
shr eax,24
push ax ;b
 
sub esi,2
sub esi,4
dec cx
jnz .aagain_grd_draw
 
2644,15 → 2651,15
push word[zz2]
push word[zz1]
 
movzx esi,[point_index3] ; tex map coords
mov esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index2]
mov esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index1]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
2662,7 → 2669,7
mov edi,esp
mov ecx,3
@@:
movzx eax,word[esi]
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr]
2678,7 → 2685,7
fistp word[edi+2]
 
add edi,4
add esi,2
add esi,4
loop @b
 
mov eax,dword[xx1]
2695,15 → 2702,15
jmp .end_draw
 
.bump_tex:
movzx esi,[point_index3] ; tex map coords
mov esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index2]
mov esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index1]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
2722,7 → 2729,7
mov edi,esp
mov ecx,3
@@:
movzx eax,word[esi]
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr]
2738,7 → 2745,7
fistp word[edi+2]
 
add edi,4
add esi,2
add esi,4
loop @b
 
; push dword 1 shl 16 + 1 ; emap coords
2745,16 → 2752,16
; push dword 127 shl 16 + 1
; push dword 127 shl 16 + 127
 
movzx esi,[point_index3] ; bump map coords
mov esi,[point_index3] ; bump map coords
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index2]
mov esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
 
movzx esi,[point_index1]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
2781,7 → 2788,7
mov esi,point_index3
mov ecx,3
.again_line_param:
movzx eax,word[esi]
mov eax,dword[esi]
shl eax,2
lea eax,[eax*3]
add eax,[points_normals_rot_ptr]
2806,7 → 2813,7
shl ebx,2
mov [ebx+col1],eax
 
sub esi,2
sub esi,4
dec ecx
jnz .again_line_param
 
2918,10 → 2925,12
 
.end_draw:
pop esi
add esi,6
add esi,12
inc [edges_counter]
cmp dword[esi],-1
jne .again_dts
pop ecx
sub ecx,1
; cmp dword[esi],-1
jnz .again_dts
ret
 
 
2930,6 → 2939,10
 
 
 
 
 
 
 
draw_handlers:
 
push ebp
3021,7 → 3034,7
add esi,6
inc dword[.counter]
mov ecx,[.counter]
cmp cx,[points_count_var]
cmp ecx,[points_count_var]
jng .loop
 
mov esp,ebp
3064,8 → 3077,8
; and allocate memory
xor ebx,ebx
xor ebp,ebp
mov [points_count_var],bx
mov [triangles_count_var],bx
mov [points_count_var],ebx
mov [triangles_count_var],ebx
if USE_LFN = 0
mov esi,SourceFile
else
3124,7 → 3137,7
jmp @b
@@:
movzx ecx,word[esi+6]
add [points_count_var],cx
add [points_count_var],ecx
 
mov edx,ecx
add esi,8
3143,7 → 3156,7
jmp @b
@@:
movzx ecx,word[esi+6]
add [triangles_count_var],cx
add [triangles_count_var],ecx
add esi,8
 
@@:
3218,7 → 3231,7
jmp @b
@@:
movzx ecx,word[esi+6]
add [points_count_var],cx
add [points_count_var],ecx
 
mov edx,ecx
add esi,8
3232,12 → 3245,6
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
3256,16 → 3263,20
jmp @b
@@:
movzx ecx,word[esi+6]
add [triangles_count_var],cx
add [triangles_count_var],ecx
add esi,8
;mov edi,triangles
@@:
movsd
movsw
add word[edi-6],bp
add word[edi-4],bp
add word[edi-2],bp
add esi,2
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
dec ecx
jnz @b
add ebp,edx
3286,10 → 3297,10
mov ebx,20
.alloc:
 
movzx ecx, [triangles_count_var]
inc ecx
mov ecx,[triangles_count_var]
add ecx,20
lea ecx, [ecx*3]
add ecx, ecx
shl ecx,2
mov edx,[triangles_ptr]
int 0x40 ; -> allocate memory to triangles
mov [triangles_ptr], eax ; -> eax = pointer to allocated mem
3319,7 → 3330,7
; ststic memory
 
mov eax, 68
movzx ecx, [triangles_count_var]
mov ecx, [triangles_count_var]
lea ecx, [3+ecx*3]
shl ecx, 2
mov edx,[triangles_normals_ptr]
3334,7 → 3345,7
; mov dword[vertices_index_ptr], eax
 
mov eax, 68
movzx ecx, [points_count_var]
mov ecx, [points_count_var]
lea ecx,[3+ecx*3]
shl ecx, 2
mov edx,[points_normals_ptr]
3348,7 → 3359,7
 
mov eax, 68
; mov ebx, 12
movzx ecx, [points_count_var]
mov ecx, [points_count_var]
lea ecx,[3+ecx*3]
shl ecx, 2
mov edx,[points_normals_rot_ptr]
3366,7 → 3377,7
mov [points_rotated_ptr], eax
 
mov eax, 68
movzx ecx, [points_count_var]
mov ecx, [points_count_var]
inc ecx
shl ecx, 3
mov edx,[points_translated_ptr]
3381,7 → 3392,7
;-
mov eax, 68
mov ebx, 11
int 0x40 ; -> init heap
int 0x40 ; -> create heap
 
;mov eax, 70
;mov ebx, file_info
3392,6 → 3403,8
;inc ebx
;mov [fsize], ebx
 
 
 
;mov eax, 68
;mov ebx, 12
;mov ecx, [fsize]
3402,21 → 3415,10
;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,I_Param
mov ecx,file_name
int 0x40
 
mov [fsize],edx
3454,6 → 3456,8
end if
; eax = 0 -> ok file loaded
ret
; eax = 0 -> ok file loaded
ret
read_param:
mov esi,I_Param
cmp dword[esi],0