/programs/demos/3DS/A_PROCS.INC |
---|
12,7 → 12,9 |
mov edi,[Zbuffer_ptr] |
push edi |
; clear Zbuffer temporally used as image buffer |
mov ecx,SIZE_X*SIZE_Y |
movzx ecx,word[size_x_var] |
movzx eax,word[size_y_var] |
imul ecx,eax ;SIZE_X*SIZE_Y |
xor eax,eax |
cld |
rep stosd |
67,11 → 69,12 |
mov eax,.new_y |
or eax,eax |
jl .skip |
cmp eax,SIZE_Y |
movzx ebx,word[size_y_var] |
cmp eax,ebx ;SIZE_Y |
jg .skip |
; mov edx,SIZE_X |
; mul edx |
shl eax,9 |
movzx edx,word[size_x_var] |
mul edx |
; shl eax,9 |
add eax,dword .x |
lea ebx,[eax*3] |
mov eax,[esi] |
79,17 → 82,24 |
.skip: |
add esi,3 |
inc dword .x |
cmp dword .x,SIZE_X |
movzx edx,word[size_x_var] |
cmp dword .x,edx ;SIZE_X |
jl .again |
mov dword .x,0 |
inc dword .y |
cmp dword .y,SIZE_Y |
movzx edx,word[size_y_var] |
cmp dword .y,edx ;SIZE_Y |
jl .again |
; copy from temporary buffer -> Zbuffer to screen |
mov esi,[Zbuffer_ptr] |
mov edi,[screen_ptr] |
mov ecx,SIZE_X*SIZE_Y*3/4 |
movzx ecx,word[size_x_var] |
movzx eax,word[size_y_var] |
imul ecx,eax |
lea ecx,[ecx*3] |
shr ecx,2 |
; mov ecx,SIZE_X*SIZE_Y*3/4 |
cld |
rep movsd |
112,11 → 122,11 |
jl @f |
or bx,bx |
jl @f |
cmp ax,SIZE_Y |
cmp ax,[size_y_var] ;SIZE_Y |
jge @f |
cmp bx,SIZE_X |
cmp bx,[size_x_var] ;SIZE_X |
jge @f |
mov edx,SIZE_X ; SIZE_X not only power of 2 -> 256,512,... |
movzx edx,word[size_x_var] ;SIZE_X ; SIZE_X not only power of 2 -> 256,512,... |
mul edx |
add eax,ebx |
mov edi,[screen_ptr] |
130,7 → 140,100 |
ret |
do_emboss: |
do_emboss: ; sse2 version only |
if Ext >= SSE2 |
movzx ecx,[bumps_deep_flag] |
inc ecx |
call blur_screen ;blur n times |
mov eax,[size_y_var] ;load both x, y |
mov ebx,eax |
shr ebx,16 |
cwde |
mul ebx |
mov ecx,eax |
sub ecx,ebx |
sub ecx,ebx |
mov esi,[screen_ptr] |
mov edi,[Zbuffer_ptr] |
lea ebx,[ebx*3] |
mov edx,esi |
add esi,ebx |
lea ebx,[ebx+esi] |
pxor xmm0,xmm0 |
push eax |
@@: |
movlps xmm1,[esi+3] |
movhps xmm1,[esi+6] |
punpcklbw xmm1,xmm0 |
movlps xmm2,[esi-3] |
movhps xmm2,[esi] |
punpcklbw xmm2,xmm0 |
movlps xmm3,[ebx] |
movhps xmm3,[ebx+3] |
movlps xmm4,[edx] |
movhps xmm4,[edx+3] |
punpcklbw xmm3,xmm0 |
punpcklbw xmm4,xmm0 |
psubsw xmm1,xmm2 |
paddw xmm1,[.bias] |
psubsw xmm3,xmm4 |
paddw xmm3,[.bias] |
pmulhw xmm1,xmm3 |
movaps xmm7,xmm1 |
movaps xmm6,xmm1 |
psrlq xmm7,2*8 |
psrlq xmm6,4*8 |
pmaxsw xmm1,xmm7 |
pmaxsw xmm1,xmm6 |
if 0 |
movaps xmm7,xmm3 |
movaps xmm6,xmm3 |
psrlq xmm7,2*8 |
psrlq xmm6,4*8 |
pmaxsw xmm3,xmm7 |
pmaxsw xmm3,xmm6 |
end if |
pmaxsw xmm1,xmm3 |
movd eax,xmm1 |
movzx eax,al |
lea eax,[eax*3+envmap_cub] |
mov eax,[eax] |
mov [edi],eax ;xmm1 |
psrldq xmm1,8 |
movd eax,xmm1 |
movzx eax,al |
lea eax,[eax*3+envmap_cub] |
mov eax,[eax] |
mov [edi+4],eax |
add edi,8 |
add esi,6 |
add ebx,6 |
add edx,6 |
sub ecx,2 |
jnc @b |
pop ecx ;,eax |
mov edi,[screen_ptr] |
mov esi,[Zbuffer_ptr] |
@@: |
movsd |
dec edi |
loop @b |
end if |
ret |
align 16 |
.bias: |
dw 128, 128, 128, 128, 128, 128, 128, 128 |
if 0 ; old emb proc |
; emboss - after drawing all, |
; transfer screen buffer into bump map |
; and draw two bump triangles |
227,6 → 330,7 |
pop ebp |
ret |
end if |
;********************************EMBOSS DONE******************************* |
/programs/demos/3DS/BUMP3.INC |
---|
97,11 → 97,12 |
test edx,80000000h ; Check only X |
jne .loop23_done |
cmp .x1,SIZE_X ; { |
mov dx,[size_x_var] |
cmp .x1,dx ;SIZE_X ; { |
jg .loop23_done |
cmp .x2,SIZE_X ; This can be optimized with effort |
cmp .x2,dx ;SIZE_X ; This can be optimized with effort |
jg .loop23_done |
cmp .x3,SIZE_X |
cmp .x3,dx ;SIZE_X |
jg .loop23_done ; { |
462,7 → 463,8 |
mov ecx,.y |
or ecx,ecx |
jl .bl_end |
cmp ecx,SIZE_Y |
movzx edx,word[size_y_var] |
cmp ecx,edx ;SIZE_Y |
jge .bl_end |
cmp eax,ebx |
497,8 → 499,10 |
.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 eax,SIZE_X*3 |
mov ebx,.y |
mul ebx |
mov ecx,.x1 |
/programs/demos/3DS/BUMP_CAT.INC |
---|
780,7 → 780,9 |
mov ecx,.y |
or ecx,ecx |
jl .bl_end |
cmp ecx,SIZE_Y |
; mov dx,[size_x_var] |
; dec dx |
cmp cx,[size_y_var] ;SIZE_Y |
jge .bl_end |
cmp eax,ebx |
828,8 → 830,9 |
push eax |
push ebx ;store x1, x2 |
cmp .x1,SIZE_X |
movzx edx,word[size_x_var] |
dec edx |
cmp .x1,edx ;SIZE_X |
jge .bl_end |
cmp .x2,0 |
jle .bl_end |
919,11 → 922,13 |
imul ebx |
add .ey1,eax |
@@: |
cmp .x2,SIZE_X |
movzx edx,word[size_x_var] |
dec edx |
cmp .x2,edx ;SIZE_X |
jl @f |
mov .x2,SIZE_X |
mov .x2,edx ;SIZE_X |
@@: |
mov eax,SIZE_X ;calc memory begin in buffers |
movzx eax,word[size_x_var] ;SIZE_X ;calc memory begin in buffers |
mov ebx,.y |
mul ebx |
mov ebx,.x1 |
/programs/demos/3DS/BUMP_TEX.INC |
---|
1279,7 → 1279,8 |
mov ecx,.y |
or ecx,ecx |
jl .bl_end |
cmp ecx,SIZE_Y |
movzx edx,word[size_y_var] |
cmp ecx,edx ;SIZE_Y |
jge .bl_end |
cmp eax,ebx |
1380,7 → 1381,9 |
push eax |
push ebx ;store x1, x2 |
cmp dword .x1,SIZE_X |
movzx ebx,word[size_x_var] |
; mov eax,.x1 |
cmp dword .x1,ebx ;dword .x1,SIZE_X |
jge .bl_end |
cmp dword .x2,0 |
jle .bl_end |
1532,11 → 1535,14 |
add .ty1,eax |
@@: |
cmp dword .x2,SIZE_X |
; mov ebx,.x2 |
movzx eax,word[size_x_var] |
; cmp dword .x2,SIZE_X |
cmp dword .x2,eax ; eax,ebx |
jl @f |
mov dword .x2,SIZE_X |
mov dword .x2,eax ;SIZE_X |
@@: |
mov eax,SIZE_X ;calc memory begin in buffers |
movzx eax,word[size_x_var] ;SIZE_X ;calc memory begin in buffers |
mul .y |
add eax,.x1 |
lea esi,[4*eax] |
/programs/demos/3DS/B_PROCS.INC |
---|
747,16 → 747,29 |
shufps xmm5,xmm5,0 |
.again_blur: |
push ecx |
mov edi,screen |
mov ecx,SIZE_X*3/4 |
mov edi,[screen_ptr] |
movzx ecx,word[size_x_var] ;SIZE_X*3/4 |
lea ecx,[ecx*3] |
shr ecx,2 |
; mov ecx,SIZE_X*3/4 |
xor eax,eax |
rep stosd |
mov ecx,(SIZE_X*(SIZE_Y-3))*3/16 |
if 1 |
movzx ebx,word[size_x_var] |
movzx ecx,word[size_y_var] |
sub ecx,3 |
imul ecx,ebx |
lea ecx,[ecx*3] |
shr ecx,4 |
lea ebx,[ebx*3] |
; mov ecx,(SIZE_X*(SIZE_Y-3))*3/16 |
.blr: |
@@: |
movaps xmm0,[edi+SIZE_X*3] |
movaps xmm1,[edi-SIZE_X*3] |
push ecx |
movups xmm0,[edi+ebx] |
mov ecx,edi |
sub ecx,ebx |
movups xmm1,[ecx] |
movups xmm2,[edi-3] |
movups xmm3,[edi+3] |
766,14 → 779,17 |
psubusb xmm0,xmm5 ; importand if fire |
movaps [edi],xmm0 |
movups [edi],xmm0 |
add edi,16 |
add esi,16 |
pop ecx |
loop .blr |
end if |
xor eax,eax |
mov ecx,SIZE_X*3/4 |
movzx ecx,word[size_x_var] |
lea ecx,[ecx*3] |
shr ecx,2 |
; mov ecx,SIZE_X*3/4 |
rep stosd |
pop ecx |
loop .again_blur |
790,17 → 806,25 |
movq mm4,[esp] |
.again_blur: |
push ecx |
mov edi,screen |
mov ecx,SIZE_X*3/4 |
mov edi,[screen_ptr] |
movzx ecx,word[size_x_var] ;SIZE_X*3/4 |
lea ecx,[ecx*3] |
shr ecx,2 |
; pxor mm5,mm5 |
xor eax,eax |
rep stosd |
mov ecx,(SIZE_X*(SIZE_Y-3))*3/8 |
movzx ebx,word[size_x_var] |
movzx ecx,word[size_y_var] |
sub ecx,3 |
imul ecx,ebx |
lea ecx,[ecx*3] |
shr ecx,3 |
lea ebx,[ebx*3] |
; mov ecx,(SIZE_X*(SIZE_Y-3))*3/8 |
.blr: |
@@: |
movq mm0,[edi+SIZE_X*3] |
movq mm1,[edi-SIZE_X*3] |
movq mm0,[edi+ebx] |
movq mm1,[edi-ebx] |
movq mm2,[edi-3] |
movq mm3,[edi+3] |
817,7 → 841,10 |
loop .blr |
xor eax,eax |
mov ecx,SIZE_X*3/4 |
mov ecx,[size_x_var] |
lea ecx,[ecx*3] |
shr ecx,2 |
; SIZE_X*3/4 |
rep stosd |
pop ecx |
loop .again_blur |
833,7 → 860,7 |
push dword 0x01010101 |
.again_blur: |
push ecx |
mov edi,screen |
mov edi,[screen_ptr] |
mov ecx,SIZE_X*3/4 |
pxor mm5,mm5 |
xor eax,eax |
/programs/demos/3DS/DATA.INC |
---|
12,8 → 12,8 |
xobs dw 0 ;SIZE_X / 2 ;200 ;observer = camera |
yobs dw 0 ;SIZE_Y / 2 ;200 ;coordinates |
zobs dw -500 |
size_x dw SIZE_X |
size_y dw SIZE_Y |
; size_x dw SIZE_X |
; size_y dw SIZE_Y |
re_alloc_flag db 0 |
angle_counter dw 0 |
80,7 → 80,7 |
db 8 |
db 'culling ' |
db 2 |
culling_flag db 1 |
culling_flag db 0 |
dd onoff_f |
db 9 |
314,7 → 314,7 |
if Ext=SSE2 |
db ' (SSE2)' |
end if |
db ' 0.065',0 |
db ' 0.066',0 |
labellen: |
STRdata db '-1 ' |
436,6 → 436,10 |
screen_ptr dd ? |
Zbuffer_ptr dd ? |
; edges_ptr dd ? |
size_y_var: |
dw ? |
size_x_var: |
dw ? |
;=== |
/programs/demos/3DS/FLAT3.INC |
---|
47,11 → 47,12 |
test edx,80008000h ; Check both X&Y at once |
jne .end_triangle |
cmp word[.x1],SIZE_X ; { |
mov dx,[size_x_var] |
cmp word[.x1],dx ;SIZE_X ; { |
jg .end_triangle |
cmp word[.x2],SIZE_X ; This can be optimized with effort |
cmp word[.x2],dx ;SIZE_X ; This can be optimized with effort |
jg .end_triangle |
cmp word[.x3],SIZE_X |
cmp word[.x3],dx ;SIZE_X |
jg .end_triangle ; } |
shr eax,16 |
176,10 → 177,13 |
jcxz .end_hor_l |
; or edx,edx |
; jl .end_hor_l |
cmp edx,SIZE_Y |
movzx esi,word[size_y_var] |
cmp edx,esi ;SIZE_Y |
jg .end_hor_l |
push eax |
mov eax,SIZE_X*3 |
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 |
/programs/demos/3DS/FLAT_CAT.INC |
---|
291,10 → 291,10 |
mov ax,.y |
or ax,ax |
jl .fl_quit |
;; mov bx,[size_y] |
;; dec bx |
cmp ax,[size_y] |
cmp ax,SIZE_Y-1 |
mov bx,[size_y_var] |
dec bx |
cmp ax,bx ;[size_y_var] |
; cmp ax,SIZE_Y-1 |
jg .fl_quit |
; cmp .x1,0 |
318,9 → 318,9 |
xchg edx,.z2 |
mov .z1,edx |
.fl_ok: |
;; mov bx,[size_x] |
;; dec bx |
cmp .x1,SIZE_X-1 |
mov bx,[size_x_var] |
dec bx |
cmp .x1,bx ;SIZE_X-1 |
jg .fl_quit |
cmp .x2,0 |
jle .fl_quit |
343,11 → 343,12 |
add .z1,eax |
mov .x1,0 |
@@: |
cmp .x2,SIZE_X |
movzx edx,word[size_x_var] |
cmp .x2,dx ;[size_x_var] ;SIZE_X |
jl @f |
mov .x2,SIZE_X |
mov .x2,dx ;[size_x_var] ;SIZE_X |
@@: |
mov edx,SIZE_X |
; movzx edx,[size_x_var] ;SIZE_X |
movsx eax,.y |
mul edx ; edi = edi + (SIZE_X * y + x1)*3 |
movsx edx,.x1 |
/programs/demos/3DS/GRD3.INC |
---|
78,14 → 78,17 |
or edx,ecx |
test edx,80000000h |
jne .gt_loop2_end |
mov dx,[size_x_var] |
dec dx |
shr eax,16 |
cmp ax,SIZE_X-1 |
cmp ax,dx ;SIZE_X-1 |
jg .gt_loop2_end |
shr ebx,16 |
cmp bx,SIZE_X-1 |
cmp bx,dx ;SIZE_X-1 |
jg .gt_loop2_end |
shr ecx,16 |
cmp cx,SIZE_X-1 |
cmp cx,dx ;SIZE_X-1 |
jg .gt_loop2_end |
443,7 → 446,9 |
mov ax,.y |
or ax,ax |
jl .gl_quit |
cmp ax,SIZE_Y-1 |
mov dx,[size_y_var] |
dec dx |
cmp ax,dx ;SIZE_Y-1 |
jg .gl_quit |
mov ax,.x1 |
479,7 → 484,9 |
; jl .gl_quit |
movsx ecx,.y |
mov eax,SIZE_X*3 |
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] |
/programs/demos/3DS/GRD_CAT.INC |
---|
514,7 → 514,9 |
mov ax,.y |
or ax,ax |
jl .gl_quit |
cmp ax,SIZE_Y |
mov bx,[size_y_var] |
dec bx |
cmp ax,bx ;SIZE_Y |
jge .gl_quit |
mov eax,dword[.x1] |
531,7 → 533,9 |
xchg eax,.z2 |
mov .z1,eax |
@@: |
cmp word[.x1],SIZE_X |
mov bx,[size_x_var] |
dec bx |
cmp word[.x1],bx ;SIZE_X |
jge .gl_quit |
cmp word[.x2],0 |
jle .gl_quit |
594,12 → 598,14 |
add word[.c1b],ax |
@@: |
cmp word[.x2],SIZE_X |
mov bx,[size_x_var] |
dec bx |
cmp word[.x2],bx ;SIZE_X |
jl @f |
mov word[.x2],SIZE_X |
mov word[.x2],bx ;SIZE_X |
@@: |
sub esp,16 ; calculate memory begin |
mov edx,SIZE_X ; in buffers |
movzx edx,word[size_x_var] ;SIZE_X ; in buffers |
movzx eax,.y |
mul edx |
movzx edx,word[.x1] |
/programs/demos/3DS/GRD_LINE.INC |
---|
41,7 → 41,15 |
.ccoord equ ebp-60 ;current coordinate |
.czbuf equ ebp-64 |
.cscr equ ebp-68 |
;.lasty equ ebp-72 |
.xres equ ebp-72 |
.yres equ ebp-76 |
.xresm1 equ ebp-80 |
.yresm1 equ ebp-84 |
.xresp1 equ ebp-88 |
.yresp1 equ ebp-92 |
.xres3 equ ebp-96 |
.xres4 equ ebp-100 |
macro .update_cur_var |
{ |
if Ext=NON |
126,15 → 134,35 |
or eax,ebx |
test eax,80008000h |
jne .end_line |
cmp word[.x1],SIZE_X |
movzx edx,word [size_x_var] |
mov [.xres],edx |
movzx ecx,word [size_y_var] |
mov [.yres],ecx |
cmp word[.x1],dx ;SIZE_X |
jg .end_line |
cmp word[.x2],SIZE_X |
cmp word[.x2],dx ;SIZE_X |
jg .end_line |
cmp word[.y1],SIZE_Y |
cmp word[.y1],cx ;SIZE_Y |
jg .end_line |
cmp word[.y2],SIZE_Y |
cmp word[.y2],cx ;SIZE_Y |
jg .end_line |
mov edx,[.xres] |
shl edx,2 |
mov [.xres4],edx |
shr edx,2 |
lea edx,[edx*3] |
mov [.xres3],edx |
mov edx,[.xres] |
mov ecx,[.yres] |
dec edx |
dec ecx |
mov [.xresm1],edx |
mov [.yresm1],ecx |
add edx,2 |
add ecx,2 |
mov [.xresp1],edx |
mov [.yresp1],ecx |
mov [.screen],edi |
mov cx,[.x1] |
181,7 → 209,7 |
call .calc_delta |
mov eax,SIZE_X |
movzx eax,word [size_x_var] ;SIZE_X |
movsx ebx,word[.y1] |
mul ebx |
add esi,eax |
247,7 → 275,7 |
call .calc_delta |
mov eax,SIZE_X |
movzx eax,word[size_x_var] ;SIZE_X |
movsx ebx,word[.y1] |
mul ebx |
add esi,eax |
290,8 → 318,8 |
.draw_pixel |
@@: |
add edi,SIZE_X*3 |
add esi,SIZE_X*4 |
add edi,[.xres3] |
add esi,[.xres4] |
.update_cur_var |
318,7 → 346,7 |
call .calc_delta |
mov eax,SIZE_X |
mov eax,[.xres] |
movsx ebx,word[.y1] ;calc begin values in screen and Z buffers |
mul ebx |
lea ebx,[3*eax] |
359,12 → 387,16 |
@@: |
cmp dword[.delta_y],0 |
jl @f |
add edi,SIZE_X*3+3 |
add esi,SIZE_X*4+4 |
add edi,[.xres3] ;SIZE_X*3+3 |
add edi,3 |
add esi,[.xres4] ;SIZE_X*4+4 |
add esi,4 |
jmp .d45_1 |
@@: |
sub edi,(SIZE_X*3)-3 |
sub esi,(SIZE_X*4)-4 |
sub edi,[.xres3] ;(SIZE_X*3)-3 |
sub edi,3 |
sub esi,[.xres4] ;(SIZE_X*4)-4 |
sub esi,4 |
.d45_1: |
.update_cur_var |
395,7 → 427,7 |
call .calc_delta |
mov eax,SIZE_X |
mov eax,[.xres] ;SIZE_X |
movsx ebx,word[.y1] ;calc begin values in screen and Z buffers |
mul ebx |
lea ebx,[3*eax] |
446,9 → 478,11 |
@@: |
mov eax,[.delta] |
mov ebx,[.xres3] |
add [.ccoord],eax |
add dword[.cscr],SIZE_X*3 ; |
add dword[.czbuf],SIZE_X*4 |
mov eax,[.xres4] |
add dword[.cscr],ebx ;SIZE_X*3 ; |
add dword[.czbuf],eax ;SIZE_X*4 |
.d_m_v1: |
.update_cur_var |
518,7 → 552,7 |
mov esi,[.czbuf] |
mov eax,[.ccoord] ; ccoord - cur y coordinate |
sar eax,ROUND |
mov ebx,SIZE_X |
mov ebx,[.xres] ;SIZE_X |
mul ebx |
add esi,eax |
lea eax,[eax*3] |
/programs/demos/3DS/GRD_TEX.INC |
---|
742,7 → 742,7 |
or cx,cx |
jl .quit_l |
cmp cx,SIZE_Y |
cmp cx,word[size_y_var] ;SIZE_Y |
jge .quit_l |
cmp ax,bx |
805,7 → 805,7 |
@@: |
or bx,bx |
jle .quit_l |
cmp ax,SIZE_X |
cmp ax,word[size_x_var] ;SIZE_X |
jge .quit_l |
push ax |
880,7 → 880,7 |
imul ebx |
add .tex_y1,eax |
@@: |
mov edx,SIZE_X |
movsx edx,word[size_x_var] ;SIZE_X |
cmp .x2,dx |
jl @f |
mov .x2,dx |
/programs/demos/3DS/History.txt |
---|
1,4 → 1,8 |
View3ds 0.065 - Feb 2015 |
1. Asc files support. |
----------------------------------------------------------------------------------- |
View3ds 0.064 - Nov 2012 |
1. Bug fixes. |
----------------------------------------------------------------------------------- |
29,9 → 33,9 |
----------------------------------------------------------------------------------- |
View3ds 0.058 - June 2011. |
1. Blur function optimization on SSE and SSE2 (buttons 'blur' and 'fire'). |
1. Blur function optimization on SSE and SSE2 (buttons 'blur' and 'fire'). |
----------------------------------------------------------------------------------- |
View3ds 0.057 - April 2011. |
1. By opening file bigger then ~18 KB, and choosing env mode program terminate. |
I remove this bug |
89,7 → 93,7 |
1. Two shading models: smooth + texture, spherical environment mapping + texture. |
Version only with z coordinate interpolation. |
2. Bit changed rotary. I took attempt in SSE instuctions. ( matrix multiplication ) |
3. Color position depend drawing model instead spot light ( I hope,spot light come |
3. Color position depend drawing model instead spot light ( I hope,spot light come |
back in future ). |
----------------------------------------------------------------------------------- |
/programs/demos/3DS/README.TXT |
---|
1,7 → 1,10 |
View3ds 0.065 - tiny viewer to .3ds and .asc files. |
View3ds 0.066 - tiny viewer to .3ds and .asc files with several graphics |
effects implementation. |
What's new? |
1. Asc files support. |
1. App window size according to current screen resolution; |
2, New emboss procedure. |
Buttons description: |
1. rotary: choosing rotary axle: x, y, x+y. |
13,14 → 16,13 |
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: 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 |
10.11,12,13. loseless operations (rotary 90, 180 degrees). |
12. emboss: Do emboss effect( flat bumps ), use blur to do edges more deep. |
carefull with emboss + fire - it looks annoying. |
12. emboss: Do emboss effect( flat bumps ), use 'bumps deep' button to do edges more deep. |
13. fire: do motion blur ( looks like fire ). |
14. move: changes meaning x,y,z +/- buttons -> obj: moving object, camr: moving camera, wave: x,y +/- increase, |
decrease wave effect frequency and amplitude. |
27,10 → 29,10 |
15. generate: Generates some objects: node, Thorn Crown, heart... |
16. bumps: random, according to texture. |
17. bumps deep -> create bumps deeper or lighter. |
18. re-map tex -> re-map texture and bump map coordinates, to change spherical mapping |
18. re-map tex -> re-map texture and bump map coordinates, to change spherical mapping |
around axle use 'xchg' and 'mirror' buttons, then press 're-map tex' button. |
19. bright + -> increase picture brightness. |
20. bright - -> decrease picture brightness. |
21. wav effect -> do effect based sine function. |
Maciej Guba Feb 2015 |
Maciej Guba X 2016 |
/programs/demos/3DS/TEX3.INC |
---|
82,37 → 82,37 |
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 |
; cmp ax,SIZE_Y |
; jg .tt_end |
ror eax,16 |
; or ax,ax |
; jl .tt_end |
cmp ax,SIZE_X |
cmp ax,dx ;SIZE_X |
jg .tt_end |
rol eax,16 |
; or bx,bx |
; jl .tt_end |
cmp bx,SIZE_Y |
jg .tt_end |
; cmp bx,SIZE_Y |
; jg .tt_end |
ror ebx,16 |
; or bx,bx |
; jl .tt_end |
cmp bx,SIZE_X |
cmp bx,dx ;SIZE_X |
jg .tt_end |
rol ebx,16 |
; or cx,cx |
; jl .tt_end |
cmp cx,SIZE_Y |
jg .tt_end |
; cmp cx,SIZE_Y |
; jg .tt_end |
ror ecx,16 |
; or cx,cx |
; jl .tt_end |
cmp cx,SIZE_X |
cmp cx,dx ;SIZE_X |
jg .tt_end |
rol ecx,16 ; uff.. parameters was checked |
432,7 → 432,8 |
mov ax,.y |
or ax,ax |
jl .tl_quit |
cmp ax,SIZE_Y |
mov dx,[size_y_var] |
cmp ax,dx ;SIZE_Y |
jg .tl_quit |
mov ax,.x1 |
465,7 → 466,9 |
mov ebx,edi |
movsx edi,.y |
mov eax,SIZE_X*3 |
movzx eax,word[size_x_var] |
lea eax,[eax*3] |
; mov eax,SIZE_X*3 |
mul edi |
mov edi,eax |
movsx eax,.x1 |
/programs/demos/3DS/TEX_CAT.INC |
---|
95,22 → 95,22 |
and edx,eax |
test edx,80008000h ; Check both X&Y at once |
jne .tt_loop2_end |
cmp ax,SIZE_Y |
jl @f |
cmp bx,SIZE_Y |
jl @f |
cmp cx,SIZE_Y |
jl @f |
; cmp ax,SIZE_Y |
; jl @f |
; cmp bx,SIZE_Y |
; jl @f |
; cmp cx,SIZE_Y |
; jl @f |
ror eax,16 |
ror ebx,16 |
ror ecx,16 |
cmp ax,SIZE_X |
jl @f |
cmp bx,SIZE_X |
jl @f |
cmp cx,SIZE_X |
jl @f |
jmp .tt_loop2_end |
; cmp ax,SIZE_X |
; jl @f |
; cmp bx,SIZE_X |
; jl @f |
; cmp cx,SIZE_X |
; jl @f |
; jmp .tt_loop2_end |
@@: |
mov eax,dword[.tex_x1] ; texture coords must be in [0..TEX_X(Y)] |
mov ebx,dword[.tex_x2] |
440,7 → 440,9 |
mov ax,.y |
or ax,ax |
jl .tl_quit |
cmp ax,SIZE_Y |
mov bx,[size_y_var] |
dec bx |
cmp ax,bx ;SIZE_Y |
jge .tl_quit |
mov ax,.x1 |
472,7 → 474,9 |
mov .z1,eax |
.tl_ok: |
cmp .x1,SIZE_X |
mov cx,[size_x_var] |
dec cx |
cmp .x1,cx ;SIZE_X |
jge .tl_quit |
cmp .x2,0 |
jle .tl_quit |
517,13 → 521,13 |
add dword[.tex_x1],eax |
@@: |
cmp .x2,SIZE_X |
cmp .x2,cx ;SIZE_X |
jl @f |
mov .x2,SIZE_X |
mov .x2,cx ;SIZE_X |
@@: |
movsx ebx,.y ; calc mem begin in buffers |
mov eax,SIZE_X |
movzx eax,word[size_x_var] ;SIZE_X |
mul ebx |
movsx ebx,.x1 |
add eax,ebx |
/programs/demos/3DS/TWO_TEX.INC |
---|
32,58 → 32,58 |
;---------------------- pointer io Z buffer----- |
;-- Z-buffer - filled with coordinates as dword -------- |
;-- (Z coor. as word) shl CATMULL_SHIFT ---------------- |
.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 - first texture |
.b_x3 equ ebp+12 |
.b_y3 equ ebp+14 ; e - second texture |
.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 |
.z1 equ word[ebp+28] |
.z2 equ word[ebp+30] |
.z3 equ word[ebp+32] |
.z_buff equ dword[ebp+34] ; pointer to Z-buffer |
.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 - first texture |
.b_x3 equ ebp+12 |
.b_y3 equ ebp+14 ; e - second texture |
.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 |
.z1 equ word[ebp+28] |
.z2 equ word[ebp+30] |
.z3 equ word[ebp+32] |
.z_buff equ dword[ebp+34] ; pointer to Z-buffer |
.t_bmap equ dword[ebp-4] ; pointer to b. texture |
.t_emap equ dword[ebp-8] ; pointer to e. texture |
.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] |
.t_bmap equ dword[ebp-4] ; pointer to b. texture |
.t_emap equ dword[ebp-8] ; pointer to e. texture |
.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] |
.dby12q equ [ebp-32] |
.dby12q equ [ebp-32] |
.dex12 equ dword[ebp-36] |
.dey12 equ dword[ebp-40] |
.dey12q equ [ebp-40] |
.dey12q equ [ebp-40] |
.dz12 equ dword[ebp-44] |
.dx13 equ dword[ebp-48] |
.dbx13 equ dword[ebp-52] |
.dby13 equ dword[ebp-56] |
.dby13q equ [ebp-56] |
.dby13q equ [ebp-56] |
.dex13 equ dword[ebp-60] |
.dey13 equ dword[ebp-64] |
.dey13q equ [ebp-64] |
.dey13q equ [ebp-64] |
.dz13 equ dword[ebp-68] |
.dx23 equ dword[ebp-72] |
.dbx23 equ dword[ebp-76] |
.dby23 equ dword[ebp-80] |
.dby23q equ [ebp-80] |
.dby23q equ [ebp-80] |
.dex23 equ dword[ebp-84] |
.dey23 equ dword[ebp-88] |
.dey23q equ [ebp-88] |
.dey23q equ [ebp-88] |
.dz23 equ dword[ebp-92] |
.cx1 equ dword[ebp-96] ; current variables |
106,10 → 106,10 |
cld |
end if |
mov ebp,esp |
push edx esi ; store bump map |
push edx esi ; store bump map |
; push esi ; store e. map |
; sub esp,120 |
.sort3: ; sort triangle coordinates... |
.sort3: ; sort triangle coordinates... |
cmp ax,bx |
jle .sort1 |
xchg eax,ebx |
123,30 → 123,30 |
xchg dx,.z2 |
mov .z1,dx |
.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 |
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 |
mov dx,.z2 |
xchg dx,.z3 |
mov .z2,dx |
jmp .sort3 |
jmp .sort3 |
.sort2: |
push eax ebx ecx ; store triangle coords in variables |
push eax ebx ecx ; store triangle coords in variables |
; push ebx |
; push ecx |
mov edx,80008000h ; eax,ebx,ecx are ANDd together into edx which means that |
and edx,ebx ; if *all* of them are negative a sign flag is raised |
and edx,ecx |
and edx,eax |
test edx,80008000h ; Check both X&Y at once |
jne .loop23_done |
mov edx,80008000h ; eax,ebx,ecx are ANDd together into edx which means that |
and edx,ebx ; if *all* of them are negative a sign flag is raised |
and edx,ecx |
and edx,eax |
test edx,80008000h ; Check both X&Y at once |
jne .loop23_done |
; 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 |
161,44 → 161,44 |
; jg .loop23_done ; { |
mov bx,.y2 ; calc delta 12 |
sub bx,.y1 |
jnz .bt_dx12_make |
mov ecx,6 |
xor edx,edx |
mov bx,.y2 ; calc delta 12 |
sub bx,.y1 |
jnz .bt_dx12_make |
mov ecx,6 |
xor edx,edx |
@@: |
push edx ;dword 0 |
loop @b |
jmp .bt_dx12_done |
push edx ;dword 0 |
loop @b |
jmp .bt_dx12_done |
.bt_dx12_make: |
mov ax,.x2 |
sub ax,.x1 |
mov ax,.x2 |
sub ax,.x1 |
cwde |
movsx ebx,bx |
shl eax,ROUND |
movsx ebx,bx |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dx12,eax |
push eax |
push eax |
if Ext=SSE |
sub esp,16 |
cvtsi2ss xmm3,ebx ;rcps |
sub esp,16 |
cvtsi2ss xmm3,ebx ;rcps |
; mov eax,255 |
cvtsi2ss xmm4,[i255d] ;eax |
divss xmm3,xmm4 |
rcpss xmm3,xmm3 |
divss xmm3,xmm4 |
rcpss xmm3,xmm3 |
; mulss xmm3,xmm4 |
shufps xmm3,xmm3,0 |
shufps xmm3,xmm3,0 |
movd mm0,[.b_x1] |
movd mm1,[.b_x2] |
movd mm2,[.e_x1] |
movd mm3,[.e_x2] |
movd mm0,[.b_x1] |
movd mm1,[.b_x2] |
movd mm2,[.e_x1] |
movd mm3,[.e_x2] |
; psubsw mm3,mm2 |
; psubsw mm1,mm0 |
pxor mm4,mm4 |
pxor mm4,mm4 |
punpcklwd mm0,mm4 |
punpcklwd mm1,mm4 |
punpcklwd mm2,mm4 |
208,12 → 208,12 |
; pslld mm2,ROUND |
; pslld mm3,ROUND |
cvtpi2ps xmm0,mm0 |
movlhps xmm0,xmm0 |
movlhps xmm0,xmm0 |
cvtpi2ps xmm0,mm2 |
cvtpi2ps xmm1,mm1 |
movlhps xmm1,xmm1 |
movlhps xmm1,xmm1 |
cvtpi2ps xmm1,mm3 |
subps xmm1,xmm0 |
subps xmm1,xmm0 |
; pxor mm4,mm4 |
; movq mm5,mm1 |
241,13 → 241,13 |
; movlhps xmm0,xmm0 |
; cvtpi2ps xmm0,mm3 |
; divps xmm1,xmm3 |
mulps xmm1,xmm3 |
shufps xmm1,xmm1,10110001b |
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords |
movhlps xmm1,xmm1 |
mulps xmm1,xmm3 |
shufps xmm1,xmm1,10110001b |
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords |
movhlps xmm1,xmm1 |
cvtps2pi mm1,xmm1 |
movq .dey12q,mm0 |
movq .dby12q,mm1 |
movq .dey12q,mm0 |
movq .dby12q,mm1 |
; movd .dex12,mm0 |
; psrlq mm0,32 |
259,75 → 259,75 |
; movd .dby12,mm0 |
else |
mov ax,word[.b_x2] |
sub ax,word[.b_x1] |
mov ax,word[.b_x2] |
sub ax,word[.b_x1] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dbx12,eax |
push eax |
push eax |
mov ax,word[.b_y2] |
sub ax,word[.b_y1] |
mov ax,word[.b_y2] |
sub ax,word[.b_y1] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dby12,eax |
push eax |
push eax |
; mov eax,.dbx12 |
; mov ebx,.dby12 |
; int3 |
mov ax,word[.e_x2] |
sub ax,word[.e_x1] |
mov ax,word[.e_x2] |
sub ax,word[.e_x1] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dex12,eax |
push eax |
push eax |
mov ax,word[.e_y2] |
sub ax,word[.e_y1] |
mov ax,word[.e_y2] |
sub ax,word[.e_y1] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dey12,eax |
push eax |
push eax |
end if |
mov ax,.z2 |
sub ax,.z1 |
cwde |
shl eax,CATMULL_SHIFT |
cdq |
idiv ebx |
push eax |
mov ax,.z2 |
sub ax,.z1 |
cwde |
shl eax,CATMULL_SHIFT |
cdq |
idiv ebx |
push eax |
.bt_dx12_done: |
mov bx,.y3 ; calc delta13 |
sub bx,.y1 |
jnz .bt_dx13_make |
mov ecx,6 |
xor edx,edx |
mov bx,.y3 ; calc delta13 |
sub bx,.y1 |
jnz .bt_dx13_make |
mov ecx,6 |
xor edx,edx |
@@: |
push edx ;dword 0 |
loop @b |
jmp .bt_dx13_done |
push edx ;dword 0 |
loop @b |
jmp .bt_dx13_done |
.bt_dx13_make: |
mov ax,.x3 |
sub ax,.x1 |
mov ax,.x3 |
sub ax,.x1 |
cwde |
movsx ebx,bx |
shl eax,ROUND |
movsx ebx,bx |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dx13,eax |
push eax |
push eax |
if Ext=SSE |
334,18 → 334,18 |
cvtsi2ss xmm3,ebx |
; mov eax,255 |
cvtsi2ss xmm4,[i255d] |
divss xmm3,xmm4 |
rcpss xmm3,xmm3 |
divss xmm3,xmm4 |
rcpss xmm3,xmm3 |
; mulss xmm3,xmm4 |
shufps xmm3,xmm3,0 |
sub esp,16 |
shufps xmm3,xmm3,0 |
sub esp,16 |
movd mm0,[.b_x1] |
movd mm1,[.b_x3] |
movd mm2,[.e_x1] |
movd mm3,[.e_x3] |
movd mm0,[.b_x1] |
movd mm1,[.b_x3] |
movd mm2,[.e_x1] |
movd mm3,[.e_x3] |
pxor mm4,mm4 |
pxor mm4,mm4 |
punpcklwd mm0,mm4 |
punpcklwd mm1,mm4 |
punpcklwd mm2,mm4 |
352,59 → 352,59 |
punpcklwd mm3,mm4 |
cvtpi2ps xmm0,mm0 |
movlhps xmm0,xmm0 |
movlhps xmm0,xmm0 |
cvtpi2ps xmm0,mm2 |
cvtpi2ps xmm1,mm1 |
movlhps xmm1,xmm1 |
movlhps xmm1,xmm1 |
cvtpi2ps xmm1,mm3 |
subps xmm1,xmm0 |
subps xmm1,xmm0 |
; divps xmm1,xmm3 |
mulps xmm1,xmm3 |
shufps xmm1,xmm1,10110001b |
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords |
movhlps xmm1,xmm1 |
mulps xmm1,xmm3 |
shufps xmm1,xmm1,10110001b |
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords |
movhlps xmm1,xmm1 |
cvtps2pi mm1,xmm1 |
movq .dey13q,mm0 |
movq .dby13q,mm1 |
movq .dey13q,mm0 |
movq .dby13q,mm1 |
else |
mov ax,word[.b_x3] |
sub ax,word[.b_x1] |
mov ax,word[.b_x3] |
sub ax,word[.b_x1] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dbx13,eax |
push eax |
push eax |
mov ax,word[.b_y3] |
sub ax,word[.b_y1] |
mov ax,word[.b_y3] |
sub ax,word[.b_y1] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dby13,eax |
push eax |
push eax |
mov ax,word[.e_x3] |
sub ax,word[.e_x1] |
mov ax,word[.e_x3] |
sub ax,word[.e_x1] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dex13,eax |
push eax |
push eax |
mov ax,word[.e_y3] |
sub ax,word[.e_y1] |
mov ax,word[.e_y3] |
sub ax,word[.e_y1] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dey13,eax |
push eax |
push eax |
end if |
418,25 → 418,25 |
push eax |
.bt_dx13_done: |
mov bx,.y3 ; calc delta23 |
sub bx,.y2 |
jnz .bt_dx23_make |
mov ecx,6 |
xor edx,edx |
mov bx,.y3 ; calc delta23 |
sub bx,.y2 |
jnz .bt_dx23_make |
mov ecx,6 |
xor edx,edx |
@@: |
push edx ;dword 0 |
loop @b |
jmp .bt_dx23_done |
push edx ;dword 0 |
loop @b |
jmp .bt_dx23_done |
.bt_dx23_make: |
mov ax,.x3 |
sub ax,.x2 |
mov ax,.x3 |
sub ax,.x2 |
cwde |
movsx ebx,bx |
shl eax,ROUND |
movsx ebx,bx |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dx23,eax |
push eax |
push eax |
if Ext=SSE |
443,16 → 443,16 |
cvtsi2ss xmm3,ebx |
; mov eax,255 |
cvtsi2ss xmm4,[i255d] ;eax |
divss xmm3,xmm4 |
shufps xmm3,xmm3,0 |
sub esp,16 |
divss xmm3,xmm4 |
shufps xmm3,xmm3,0 |
sub esp,16 |
movd mm0,[.b_x2] |
movd mm1,[.b_x3] |
movd mm2,[.e_x2] |
movd mm3,[.e_x3] |
movd mm0,[.b_x2] |
movd mm1,[.b_x3] |
movd mm2,[.e_x2] |
movd mm3,[.e_x3] |
pxor mm4,mm4 |
pxor mm4,mm4 |
punpcklwd mm0,mm4 |
punpcklwd mm1,mm4 |
punpcklwd mm2,mm4 |
459,58 → 459,58 |
punpcklwd mm3,mm4 |
cvtpi2ps xmm0,mm0 |
movlhps xmm0,xmm0 |
movlhps xmm0,xmm0 |
cvtpi2ps xmm0,mm2 |
cvtpi2ps xmm1,mm1 |
movlhps xmm1,xmm1 |
movlhps xmm1,xmm1 |
cvtpi2ps xmm1,mm3 |
subps xmm1,xmm0 |
subps xmm1,xmm0 |
divps xmm1,xmm3 |
shufps xmm1,xmm1,10110001b |
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords |
movhlps xmm1,xmm1 |
divps xmm1,xmm3 |
shufps xmm1,xmm1,10110001b |
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords |
movhlps xmm1,xmm1 |
cvtps2pi mm1,xmm1 |
movq .dey23q,mm0 |
movq .dby23q,mm1 |
movq .dey23q,mm0 |
movq .dby23q,mm1 |
else |
mov ax,word[.b_x3] |
sub ax,word[.b_x2] |
mov ax,word[.b_x3] |
sub ax,word[.b_x2] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dbx23,eax |
push eax |
push eax |
mov ax,word[.b_y3] |
sub ax,word[.b_y2] |
mov ax,word[.b_y3] |
sub ax,word[.b_y2] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dby23,eax |
push eax |
push eax |
mov ax,word[.e_x3] |
sub ax,word[.e_x2] |
mov ax,word[.e_x3] |
sub ax,word[.e_x2] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dex23,eax |
push eax |
push eax |
mov ax,word[.e_y3] |
sub ax,word[.e_y2] |
mov ax,word[.e_y3] |
sub ax,word[.e_y2] |
cwde |
shl eax,ROUND |
shl eax,ROUND |
cdq |
idiv ebx |
idiv ebx |
; mov .dey23,eax |
push eax |
push eax |
end if |
mov ax,.z3 |
sub ax,.z2 |
522,203 → 522,203 |
push eax |
; sub esp,40 |
.bt_dx23_done: |
movsx eax,.x1 |
shl eax,ROUND |
movsx eax,.x1 |
shl eax,ROUND |
; mov .cx1,eax |
; mov .cx2,eax |
push eax eax |
push eax eax |
; push eax |
movsx eax,word[.b_x1] |
shl eax,ROUND |
mov .cbx1,eax |
mov .cbx2,eax |
movsx eax,word[.b_x1] |
shl eax,ROUND |
mov .cbx1,eax |
mov .cbx2,eax |
; push eax eax |
; push eax |
movsx eax,word[.b_y1] |
shl eax,ROUND |
mov .cby1,eax |
mov .cby2,eax |
movsx eax,word[.b_y1] |
shl eax,ROUND |
mov .cby1,eax |
mov .cby2,eax |
; push eax eax |
; push eax |
movsx eax,word[.e_x1] |
shl eax,ROUND |
mov .cex1,eax |
mov .cex2,eax |
movsx eax,word[.e_x1] |
shl eax,ROUND |
mov .cex1,eax |
mov .cex2,eax |
; push eax eax |
;push eax |
movsx eax,word[.e_y1] |
shl eax,ROUND |
mov .cey1,eax |
mov .cey2,eax |
sub esp,32 |
movsx eax,word[.e_y1] |
shl eax,ROUND |
mov .cey1,eax |
mov .cey2,eax |
sub esp,32 |
; push eax eax |
;push eax |
movsx eax,.z1 |
shl eax,CATMULL_SHIFT |
movsx eax,.z1 |
shl eax,CATMULL_SHIFT |
; mov .cz1,eax |
; mov .cz2,eax |
push eax eax |
;push eax |
movsx ecx,.y1 |
cmp cx,.y2 |
jge .loop12_done |
movsx ecx,.y1 |
cmp cx,.y2 |
jge .loop12_done |
.loop12: |
call .call_line |
call .call_line |
mov eax,.dx13 |
add .cx1,eax |
mov ebx,.dx12 |
add .cx2,ebx |
mov eax,.dx13 |
add .cx1,eax |
mov ebx,.dx12 |
add .cx2,ebx |
if Ext>= SSE2 |
movups xmm0,.cey1 |
movups xmm1,.cey2 |
movups xmm2,.dey12q |
movups xmm3,.dey13q |
paddd xmm0,xmm3 |
paddd xmm1,xmm2 |
movups .cey1,xmm0 |
movups .cey2,xmm1 |
movups xmm0,.cey1 |
movups xmm1,.cey2 |
movups xmm2,.dey12q |
movups xmm3,.dey13q |
paddd xmm0,xmm3 |
paddd xmm1,xmm2 |
movups .cey1,xmm0 |
movups .cey2,xmm1 |
else if (Ext = MMX) | (Ext=SSE) |
movq mm0,.cby2 ; with this optimization object |
movq mm1,.cby1 ; looks bit annoying |
movq mm2,.cey2 |
movq mm3,.cey1 |
paddd mm0,.dby12q |
paddd mm1,.dby13q |
paddd mm2,.dey12q |
paddd mm3,.dey13q |
movq .cby2,mm0 |
movq .cby1,mm1 |
movq .cey1,mm3 |
movq .cey2,mm2 |
movq mm0,.cby2 ; with this optimization object |
movq mm1,.cby1 ; looks bit annoying |
movq mm2,.cey2 |
movq mm3,.cey1 |
paddd mm0,.dby12q |
paddd mm1,.dby13q |
paddd mm2,.dey12q |
paddd mm3,.dey13q |
movq .cby2,mm0 |
movq .cby1,mm1 |
movq .cey1,mm3 |
movq .cey2,mm2 |
else |
mov edx,.dbx13 |
add .cbx1,edx |
mov eax,.dbx12 |
add .cbx2,eax |
mov ebx,.dby13 |
add .cby1,ebx |
mov edx,.dby12 |
add .cby2,edx |
mov edx,.dbx13 |
add .cbx1,edx |
mov eax,.dbx12 |
add .cbx2,eax |
mov ebx,.dby13 |
add .cby1,ebx |
mov edx,.dby12 |
add .cby2,edx |
mov eax,.dex13 |
add .cex1,eax |
mov ebx,.dex12 |
add .cex2,ebx |
mov edx,.dey13 |
add .cey1,edx |
mov eax,.dey12 |
add .cey2,eax |
mov eax,.dex13 |
add .cex1,eax |
mov ebx,.dex12 |
add .cex2,ebx |
mov edx,.dey13 |
add .cey1,edx |
mov eax,.dey12 |
add .cey2,eax |
end if |
mov ebx,.dz13 |
add .cz1,ebx |
mov edx,.dz12 |
add .cz2,edx |
mov ebx,.dz13 |
add .cz1,ebx |
mov edx,.dz12 |
add .cz2,edx |
inc ecx |
cmp cx,.y2 |
jl .loop12 |
inc ecx |
cmp cx,.y2 |
jl .loop12 |
.loop12_done: |
movsx ecx,.y2 |
cmp cx,.y3 |
jge .loop23_done |
movsx ecx,.y2 |
cmp cx,.y3 |
jge .loop23_done |
movsx eax,.z2 |
shl eax,CATMULL_SHIFT |
mov .cz2,eax |
movsx eax,.z2 |
shl eax,CATMULL_SHIFT |
mov .cz2,eax |
movsx eax,.x2 |
shl eax,ROUND |
mov .cx2,eax |
movsx eax,.x2 |
shl eax,ROUND |
mov .cx2,eax |
movzx eax,word[.b_x2] |
shl eax,ROUND |
mov .cbx2,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[.b_y2] |
shl eax,ROUND |
mov .cby2,eax |
movzx eax,word[.e_x2] |
shl eax,ROUND |
mov .cex2,eax |
movzx eax,word[.e_x2] |
shl eax,ROUND |
mov .cex2,eax |
movzx eax,word[.e_y2] |
shl eax,ROUND |
mov .cey2,eax |
movzx eax,word[.e_y2] |
shl eax,ROUND |
mov .cey2,eax |
.loop23: |
call .call_line |
call .call_line |
;if Ext = NON |
mov eax,.dx13 |
add .cx1,eax |
mov ebx,.dx23 |
add .cx2,ebx |
mov eax,.dx13 |
add .cx1,eax |
mov ebx,.dx23 |
add .cx2,ebx |
if Ext>= SSE2 |
movups xmm0,.cey1 |
movups xmm1,.cey2 |
movups xmm2,.dey23q |
movups xmm3,.dey13q |
paddd xmm0,xmm3 |
paddd xmm1,xmm2 |
movups .cey1,xmm0 |
movups .cey2,xmm1 |
movups xmm0,.cey1 |
movups xmm1,.cey2 |
movups xmm2,.dey23q |
movups xmm3,.dey13q |
paddd xmm0,xmm3 |
paddd xmm1,xmm2 |
movups .cey1,xmm0 |
movups .cey2,xmm1 |
else if (Ext = MMX) | ( Ext = SSE) |
movq mm0,.cby2 ; with this mmx optimization object looks bit |
movq mm1,.cby1 ; annoying |
movq mm2,.cey2 |
movq mm3,.cey1 |
paddd mm0,.dby23q |
paddd mm1,.dby13q |
paddd mm2,.dey23q |
paddd mm3,.dey13q |
movq .cby2,mm0 |
movq .cby1,mm1 |
movq .cey2,mm2 |
movq .cey1,mm3 |
movq mm0,.cby2 ; with this mmx optimization object looks bit |
movq mm1,.cby1 ; annoying |
movq mm2,.cey2 |
movq mm3,.cey1 |
paddd mm0,.dby23q |
paddd mm1,.dby13q |
paddd mm2,.dey23q |
paddd mm3,.dey13q |
movq .cby2,mm0 |
movq .cby1,mm1 |
movq .cey2,mm2 |
movq .cey1,mm3 |
else |
mov edx,.dbx13 |
add .cbx1,edx |
mov eax,.dbx23 |
add .cbx2,eax |
mov ebx,.dby13 |
add .cby1,ebx |
mov edx,.dby23 |
add .cby2,edx |
mov edx,.dbx13 |
add .cbx1,edx |
mov eax,.dbx23 |
add .cbx2,eax |
mov ebx,.dby13 |
add .cby1,ebx |
mov edx,.dby23 |
add .cby2,edx |
mov eax,.dex13 |
add .cex1,eax |
mov ebx,.dex23 |
add .cex2,ebx |
mov edx,.dey13 |
add .cey1,edx |
mov eax,.dey23 |
add .cey2,eax |
mov eax,.dex13 |
add .cex1,eax |
mov ebx,.dex23 |
add .cex2,ebx |
mov edx,.dey13 |
add .cey1,edx |
mov eax,.dey23 |
add .cey2,eax |
end if |
mov ebx,.dz13 |
add .cz1,ebx |
mov edx,.dz23 |
add .cz2,edx |
mov ebx,.dz13 |
add .cz1,ebx |
mov edx,.dz23 |
add .cz2,edx |
;else |
; movq mm0,.db13q |
; movq mm1,.cbx1q |
inc ecx |
cmp cx,.y3 |
jl .loop23 |
inc ecx |
cmp cx,.y3 |
jl .loop23 |
.loop23_done: |
mov esp,ebp |
mov esp,ebp |
ret 34 |
.call_line: |
725,27 → 725,27 |
pushad |
push .cz1 |
push .cz2 |
push .z_buff |
push .t_bmap |
push .t_emap |
push dword .cey2 |
push .cex2 |
push dword .cey1 |
push .cex1 |
push dword .cby2 |
push .cbx2 |
push dword .cby1 |
push .cbx1 |
push ecx |
push .cz1 |
push .cz2 |
push .z_buff |
push .t_bmap |
push .t_emap |
push dword .cey2 |
push .cex2 |
push dword .cey1 |
push .cex1 |
push dword .cby2 |
push .cbx2 |
push dword .cby1 |
push .cbx1 |
push ecx |
mov eax,.cx1 |
sar eax,ROUND |
mov ebx,.cx2 |
sar ebx,ROUND |
mov eax,.cx1 |
sar eax,ROUND |
mov ebx,.cx2 |
sar ebx,ROUND |
call two_tex_line_z |
call two_tex_line_z |
popad |
ret |
754,92 → 754,93 |
;-------------- ebx - x2 |
;-------------- edi - pointer to screen buffer |
;stack - another parameters : |
.y equ dword [ebp+4] |
.bx1 equ [ebp+8] ; --- |
.by1 equ [ebp+12] ; | |
.bx2 equ [ebp+16] ; | |
.by2 equ [ebp+20] ; |> b. texture and e. texture coords |
.ex1 equ [ebp+24] ; |> shifted shl ROUND |
.ey1 equ [ebp+28] ; | |
.ex2 equ [ebp+32] ; | |
.ey2 equ [ebp+36] ; --- |
.emap equ [ebp+40] ; b texture offset |
.bmap equ [ebp+44] ; e texture offset |
.y equ dword [ebp+4] |
.bx1 equ [ebp+8] ; --- |
.by1 equ [ebp+12] ; | |
.bx2 equ [ebp+16] ; | |
.by2 equ [ebp+20] ; |> b. texture and e. texture coords |
.ex1 equ [ebp+24] ; |> shifted shl ROUND |
.ey1 equ [ebp+28] ; | |
.ex2 equ [ebp+32] ; | |
.ey2 equ [ebp+36] ; --- |
.emap equ [ebp+40] ; b texture offset |
.bmap equ [ebp+44] ; e texture offset |
.z_buff equ dword [ebp+48] |
.z2 equ dword [ebp+52] ; -- |> z coords shifted |
.z1 equ dword [ebp+56] ; -- shl CATMULL_SHIFT |
.z2 equ dword [ebp+52] ; -- |> z coords shifted |
.z1 equ dword [ebp+56] ; -- shl CATMULL_SHIFT |
.x1 equ dword [ebp-4] |
.x2 equ dword [ebp-8] |
.dbx equ [ebp-12] |
.dex equ [ebp-16] |
.dby equ [ebp-20] |
.dey equ [ebp-24] |
.dz equ dword [ebp-28] |
.cbx equ [ebp-32] |
.cex equ [ebp-36] |
.cby equ [ebp-40] |
.cey equ [ebp-44] |
.cz equ dword [ebp-48] |
.x1 equ dword [ebp-4] |
.x2 equ dword [ebp-8] |
.dbx equ [ebp-12] |
.dex equ [ebp-16] |
.dby equ [ebp-20] |
.dey equ [ebp-24] |
.dz equ dword [ebp-28] |
.cbx equ [ebp-32] |
.cex equ [ebp-36] |
.cby equ [ebp-40] |
.cey equ [ebp-44] |
.cz equ dword [ebp-48] |
.czbuff equ dword [ebp-52] |
mov ebp,esp |
mov ebp,esp |
mov ecx,.y |
or ecx,ecx |
jl .bl_end |
cmp ecx,SIZE_Y |
jge .bl_end |
mov ecx,.y |
or ecx,ecx |
jl .bl_end |
cmp cx,word[size_y_var] ;SIZE_Y |
jge .bl_end |
cmp eax,ebx |
jl @f |
je .bl_end |
cmp eax,ebx |
jl @f |
je .bl_end |
xchg eax,ebx |
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,.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 |
mov edx,.ex1 |
xchg edx,.ex2 |
mov .ex1,edx |
mov edx,.ey1 |
xchg edx,.ey2 |
mov .ey1,edx |
else |
movq mm0,.bx1 |
movq mm1,.ex1 |
movq mm2,.bx2 |
movq mm3,.ex2 |
movq .bx2,mm0 |
movq .ex2,mm1 |
movq .bx1,mm2 |
movq .ex1,mm3 |
movq mm0,.bx1 |
movq mm1,.ex1 |
movq mm2,.bx2 |
movq mm3,.ex2 |
movq .bx2,mm0 |
movq .ex2,mm1 |
movq .bx1,mm2 |
movq .ex1,mm3 |
end if |
mov edx,.z1 |
xchg edx,.z2 |
mov .z1,edx |
mov edx,.z1 |
xchg edx,.z2 |
mov .z1,edx |
@@: |
push eax ebx |
; push ebx ;store x1, x2 |
push eax ebx ;store x1, x2 |
mov ebx,.x1 |
movzx edx,word[size_x_var] |
cmp ebx,edx |
; cmp bx,word[size_x_var] ;SIZE_X |
jg .bl_end |
cmp .x2,0 |
jle .bl_end |
cmp .x1,SIZE_X |
jge .bl_end |
cmp .x2,0 |
jle .bl_end |
mov ebx,.x2 |
sub ebx,.x1 |
mov ebx,.x2 |
sub ebx,.x1 |
if Ext>=SSE |
sub esp,16 |
cvtsi2ss xmm3,ebx ;rcps |
shufps xmm3,xmm3,0 |
sub esp,16 |
cvtsi2ss xmm3,ebx ;rcps |
shufps xmm3,xmm3,0 |
; movq mm0,.bx1q |
; movq mm1,.bx2q |
852,107 → 853,117 |
; cvtpi2ps xmm1,mm3 |
cvtpi2ps xmm0,.bx1 ;mm0 ; bx1; by1 |
movlhps xmm0,xmm0 |
movlhps xmm0,xmm0 |
cvtpi2ps xmm0,.ex1 ;mm2 ; ex1; ey1 |
cvtpi2ps xmm1,.bx2 ;mm1 ; bx2; by2 |
movlhps xmm1,xmm1 |
movlhps xmm1,xmm1 |
cvtpi2ps xmm1,.ex2 ;mm3 ; ex2; ey2 |
subps xmm1,xmm0 |
; hi lo |
divps xmm1,xmm3 ; xmm1 -> dby; dbx; dey; dex |
subps xmm1,xmm0 |
; hi lo |
divps xmm1,xmm3 ; xmm1 -> dby; dbx; dey; dex |
shufps xmm1,xmm1,11011000b |
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords |
movhlps xmm1,xmm1 |
shufps xmm1,xmm1,11011000b |
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords |
movhlps xmm1,xmm1 |
cvtps2pi mm1,xmm1 |
movq .dex,mm0 ; hi - lo -> dbx, dex |
movq .dey,mm1 ; hi - lo -> dby, dey |
movq .dex,mm0 ; hi - lo -> dbx, dex |
movq .dey,mm1 ; hi - lo -> dby, dey |
else |
mov eax,.bx2 ; calc .dbx |
sub eax,.bx1 |
cdq |
idiv ebx |
push eax |
mov eax,.bx2 ; calc .dbx |
sub eax,.bx1 |
cdq |
idiv ebx |
push eax |
mov eax,.ex2 ; calc .dby |
sub eax,.ex1 |
cdq |
idiv ebx |
push eax |
mov eax,.ex2 ; calc .dby |
sub eax,.ex1 |
cdq |
idiv ebx |
push eax |
mov eax,.by2 ; calc .dex |
sub eax,.by1 |
cdq |
idiv ebx |
push eax |
mov eax,.by2 ; calc .dex |
sub eax,.by1 |
cdq |
idiv ebx |
push eax |
mov eax,.ey2 ; calc .dey |
sub eax,.ey1 |
cdq |
idiv ebx |
push eax |
mov eax,.ey2 ; calc .dey |
sub eax,.ey1 |
cdq |
idiv ebx |
push eax |
end if |
mov eax,.z2 ; calc .dz |
sub eax,.z1 |
cdq |
idiv ebx |
push eax |
mov eax,.z2 ; calc .dz |
sub eax,.z1 |
cdq |
idiv ebx |
push eax |
cmp .x1,0 ; set correctly begin variable |
jge @f ; CLIPPING ON FUNCTION |
; cutting triangle exceedes screen |
mov ebx,.x1 |
neg ebx |
imul ebx ; eax = .dz * abs(.x1) |
add .z1,eax |
mov .x1,0 |
cmp .x1,0 ; set correctly begin variable |
jge @f ; CLIPPING ON FUNCTION |
; cutting triangle exceedes screen |
mov ebx,.x1 |
neg ebx |
imul ebx ; eax = .dz * abs(.x1) |
add .z1,eax |
mov .x1,0 |
mov eax,.dbx |
imul ebx |
add .bx1,eax |
mov eax,.dbx |
imul ebx |
add .bx1,eax |
mov eax,.dby |
imul ebx |
add .by1,eax |
mov eax,.dby |
imul ebx |
add .by1,eax |
mov eax,.dex |
imul ebx |
add .ex1,eax |
mov eax,.dex |
imul ebx |
add .ex1,eax |
mov eax,.dey |
imul ebx |
add .ey1,eax |
mov eax,.dey |
imul ebx |
add .ey1,eax |
@@: |
cmp .x2,SIZE_X |
jl @f |
mov .x2,SIZE_X |
movzx eax,word[size_x_var] ;SIZE_X ;word[size_x_var] |
mov ebx,.x2 |
cmp eax,ebx |
jg @f |
mov .x2,eax |
@@: |
mov eax,SIZE_X ;calc memory begin in buffers |
mov ebx,.y |
mul ebx |
mov ebx,.x1 |
add eax,ebx |
mov ebx,eax |
lea eax,[eax*3] |
add edi,eax ; edi - screen |
mov esi,.z_buff ; z-buffer filled with dd variables |
shl ebx,2 |
add esi,ebx ; esi - Z buffer |
; movd mm0,eax |
; movd mm1,.x2 |
; pminsw mm0,mm1 |
; movd .x2,mm0 |
; cmp .x2,SIZE_X ;eax | |
; jl @f |> this dont work idk cause |
; mov .x2,SIZE_X ;eax | |
@@: |
; movzx eax,word[size_x_var] ;calc memory begin in buffers |
mov ebx,.y |
mul ebx |
mov ebx,.x1 |
add eax,ebx |
mov ebx,eax |
lea eax,[eax*3] |
add edi,eax ; edi - screen |
mov esi,.z_buff ; z-buffer filled with dd variables |
shl ebx,2 |
add esi,ebx ; esi - Z buffer |
mov ecx,.x2 |
sub ecx,.x1 |
; init current variables |
push dword .bx1 ;.by1 .ex1 .ey1 .z1 esi |
push dword .ex1 |
push dword .by1 |
push dword .ey1 |
mov ecx,.x2 |
sub ecx,.x1 |
; init current variables |
push dword .bx1 ;.by1 .ex1 .ey1 .z1 esi |
push dword .ex1 |
push dword .by1 |
push dword .ey1 |
push .z1 ; current z shl CATMULL_SHIFT |
push esi |
push .z1 ; current z shl CATMULL_SHIFT |
push esi |
if Ext >= MMX |
pxor mm0,mm0 |
971,104 → 982,104 |
.draw: |
; if TEX = SHIFTING ;bump drawing only in shifting mode |
if Ext=NON |
mov esi,.czbuff ; .czbuff current address in buffer |
mov ebx,.cz ; .cz - cur z position |
cmp ebx,dword[esi] |
mov esi,.czbuff ; .czbuff current address in buffer |
mov ebx,.cz ; .cz - cur z position |
cmp ebx,dword[esi] |
else |
mov ebx,.cz |
cmp ebx,dword[edx] |
mov ebx,.cz |
cmp ebx,dword[edx] |
end if |
jge .skip |
jge .skip |
if Ext=NON |
mov eax,.cby |
mov esi,.cbx |
sar eax,ROUND |
sar esi,ROUND |
shl eax,TEX_SHIFT ;- |
add esi,eax |
lea esi,[esi*3] ;- ; esi - current b. texture addres |
add esi,.bmap |
mov eax,.cby |
mov esi,.cbx |
sar eax,ROUND |
sar esi,ROUND |
shl eax,TEX_SHIFT ;- |
add esi,eax |
lea esi,[esi*3] ;- ; esi - current b. texture addres |
add esi,.bmap |
mov ebx,.cex ;.cex - current env map X |
mov eax,.cey ;.cey - current env map y |
sar ebx,ROUND |
sar eax,ROUND |
mov ebx,.cex ;.cex - current env map X |
mov eax,.cey ;.cey - current env map y |
sar ebx,ROUND |
sar eax,ROUND |
shl eax,TEX_SHIFT |
add ebx,eax |
lea ebx,[ebx*3] |
add ebx,.emap |
shl eax,TEX_SHIFT |
add ebx,eax |
lea ebx,[ebx*3] |
add ebx,.emap |
else |
movq mm5,mm4 ;.cey |
psrad mm5,ROUND |
pslld mm5,TEX_SHIFT |
movq mm6,mm3 ;.cex |
psrad mm6,ROUND |
paddd mm5,mm6 |
movq mm6,mm5 |
paddd mm5,mm5 |
paddd mm5,mm6 |
paddd mm5,.emap |
movd esi,mm5 |
psrlq mm5,32 |
movd ebx,mm5 |
movq mm5,mm4 ;.cey |
psrad mm5,ROUND |
pslld mm5,TEX_SHIFT |
movq mm6,mm3 ;.cex |
psrad mm6,ROUND |
paddd mm5,mm6 |
movq mm6,mm5 |
paddd mm5,mm5 |
paddd mm5,mm6 |
paddd mm5,.emap |
movd esi,mm5 |
psrlq mm5,32 |
movd ebx,mm5 |
end if |
if Ext>=MMX |
movd mm1,[esi] |
movd mm2,[ebx] |
punpcklbw mm1,mm0 |
punpcklbw mm2,mm0 |
pmullw mm1,mm2 |
psrlw mm1,8 |
packuswb mm1,mm0 |
movd [edi],mm1 |
mov ebx,.cz |
mov dword[edx],ebx |
movd mm1,[esi] |
movd mm2,[ebx] |
punpcklbw mm1,mm0 |
punpcklbw mm2,mm0 |
pmullw mm1,mm2 |
psrlw mm1,8 |
packuswb mm1,mm0 |
movd [edi],mm1 |
mov ebx,.cz |
mov dword[edx],ebx |
else |
cld ; esi - tex e. |
lodsb ; ebx - tex b. |
mov dl,[ebx] |
mul dl |
shr ax,8 |
stosb |
inc ebx |
lodsb |
mov dl,[ebx] |
mul dl |
shr ax,8 |
stosb |
inc ebx |
lodsb |
mov dl,[ebx] |
mul dl |
shr ax,8 |
stosb |
mov ebx,.cz |
mov esi,.czbuff |
mov dword[esi],ebx |
jmp .no_skip |
cld ; esi - tex e. |
lodsb ; ebx - tex b. |
mov dl,[ebx] |
mul dl |
shr ax,8 |
stosb |
inc ebx |
lodsb |
mov dl,[ebx] |
mul dl |
shr ax,8 |
stosb |
inc ebx |
lodsb |
mov dl,[ebx] |
mul dl |
shr ax,8 |
stosb |
mov ebx,.cz |
mov esi,.czbuff |
mov dword[esi],ebx |
jmp .no_skip |
end if |
.skip: |
add edi,3 |
add edi,3 |
if Ext = NON |
.no_skip: |
add .czbuff,4 |
mov eax,.dbx |
add .cbx,eax |
mov eax,.dby |
add .cby,eax |
mov eax,.dex |
add .cex,eax |
mov eax,.dey |
add .cey,eax |
add .czbuff,4 |
mov eax,.dbx |
add .cbx,eax |
mov eax,.dby |
add .cby,eax |
mov eax,.dex |
add .cex,eax |
mov eax,.dey |
add .cey,eax |
else |
add edx,4 |
paddd mm3,.dex |
paddd mm4,.dey |
add edx,4 |
paddd mm3,.dex |
paddd mm4,.dey |
; movq mm5,mm3 |
; movq mm6,mm4 |
; psrad mm5,ROUND |
1076,16 → 1087,16 |
; movq .cex,mm3 |
; movq .cey,mm4 |
end if |
mov eax,.dz |
add .cz,eax |
mov eax,.dz |
add .cz,eax |
if Ext = NON |
dec ecx |
jnz .draw |
dec ecx |
jnz .draw |
else |
loop .draw |
loop .draw |
end if |
.bl_end: |
mov esp,ebp |
mov esp,ebp |
ret 56 |
/programs/demos/3DS/VIEW3DS.ASM |
---|
1,12 → 1,13 |
; application : View3ds ver. 0.065 - tiny .3ds and .asc files viewer. |
; application : View3ds ver. 0.066 - tiny .3ds and .asc files viewer |
; with a few graphics effects demonstration. |
; compiler : FASM |
; system : KolibriOS |
; author : Macgub aka Maciej Guba |
; email : macgub3@wp.pl |
; web : www.macgub.hekko.pl |
; Fell free to use this intro in your own distribution of KolibriOS/MenuetOS. |
; Special greetings to all MenuetOS maniax in the world. |
; web : www.macgub.hekko.pl |
; Fell free to use this intro in your own distribution of KolibriOS. |
; Special greetings to KolibriOS team . |
; I hope because my intros Christian Belive will be near to each of You. |
16,22 → 17,22 |
; can be: |
; 1) Read from a file (*.3DS standard) |
; 2) Written in manually (at the end of the code) |
;include 'proc32.inc' |
SIZE_X equ 512 |
SIZE_Y equ 512 ; ///// I want definitely |
TIMEOUT equ 10 ; ------ say: |
ROUND equ 10 ; \ @ @/ keep smiling every |
TEX_X equ 512 ; texture width ; \ ./ / day. |
TEX_Y equ 512 ; height ; \/ / |
TEX_SHIFT equ 9 ; texture width shifting ; __||__ / |
TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1 ; /| | |
TEX equ SHIFTING ; TEX={SHIFTING | FLUENTLY} ; / \ / |
FLUENTLY = 0 ; / | | |
SHIFTING = 1 ; ------ |
CATMULL_SHIFT equ 8 ; | | |
LIGHT_SIZE equ 22 ; | | |
NON = 0 ; -/ \- |
SIZE_Y equ 512 ; ///// I want definitely |
TIMEOUT equ 10 ; ------ say: |
ROUND equ 10 ; \ @ @/ keep smiling every |
TEX_X equ 512 ; texture width ; \ ./ / day. |
TEX_Y equ 512 ; height ; \/ / |
TEX_SHIFT equ 9 ; texture width shifting ; __||__ / |
TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1 ; /| | |
TEX equ SHIFTING ; TEX={SHIFTING | FLUENTLY} ; / \ / |
FLUENTLY = 0 ; / | | |
SHIFTING = 1 ; ------ |
CATMULL_SHIFT equ 8 ; | | |
LIGHT_SIZE equ 22 ; | | |
NON = 0 ; -/ \- |
MMX = 1 |
SSE = 2 |
SSE2 = 3 |
53,6 → 54,27 |
START: ; start of execution |
cld |
mov eax,14 |
int 0x40 |
sub eax,150 shl 16 + 150 |
mov [size_y_var],ax |
shr ax,1 |
mov [vect_y],ax |
shr ax,1 |
movzx ebx,ax |
push ebx |
fninit |
fild dword[esp] |
fstp [rsscale] |
pop ebx |
shr eax,16 |
mov [size_x_var],ax |
shr ax,1 |
mov [vect_x],ax |
call alloc_buffer_mem |
call read_param |
call read_from_disk ; read, if all is ok eax = 0 |
150,9 → 172,9 |
jne .next_m6 |
cmp [dr_flag],2 |
jne @f |
; call init_envmap2 ; <----! this don't works in env mode |
; and more than ~18 kb objects |
; call init_envmap_cub2 |
; call init_envmap2 ; <----! this don't works in env mode |
; and more than ~18 kb objects |
; call init_envmap_cub2 |
@@: |
cmp [dr_flag],4 |
jne @f |
179,19 → 201,19 |
fstp [rsscale] |
@@: |
cmp ah,9 ; lights random ; 'flat' 0 |
cmp ah,9 ; lights random ; 'flat' 0 |
jne .next_m5 ; 'grd ' 1 |
call make_random_lights ; 'env ' 2 |
call normalize_all_light_vectors ; 'bump' 3 |
call do_color_buffer ; intit color_map ; 'tex ' 4 |
; cmp [emboss_flag],1 ; 'pos ' 5 |
; je @f ; 'dots' 6 |
; cmp [dr_flag],8 |
; jge @f |
; cmp [dr_flag],2 ; 'txgr' 7 |
; jl .next_m5 ; '2tex' 8 |
; cmp [dr_flag],3 ; 'btex' 9 |
; jg .next_m5 |
call do_color_buffer ; intit color_map ; 'tex ' 4 |
; cmp [emboss_flag],1 ; 'pos ' 5 |
; je @f ; 'dots' 6 |
; cmp [dr_flag],8 |
; jge @f |
; cmp [dr_flag],2 ; 'txgr' 7 |
; jl .next_m5 ; '2tex' 8 |
; cmp [dr_flag],3 ; 'btex' 9 |
; jg .next_m5 |
; @@: |
call init_envmap2 ; update env map if shading model = environment or bump |
.next_m5: |
213,15 → 235,15 |
cmp [emboss_flag],1 |
call init_envmap2 |
@@: |
; cmp ah,17 |
; jne .next_m |
; cmp [move_flag],2 |
; jne @f |
; call draw_window ; redraw other labels to navigation buttons |
; cmp ah,17 |
; jne .next_m |
; cmp [move_flag],2 |
; jne @f |
; call draw_window ; redraw other labels to navigation buttons |
; @@: |
; cmp [move_flag],0 |
; jne .next_m |
; call draw_window ; redraw other labels to navigation buttons |
; cmp [move_flag],0 |
; jne .next_m |
; call draw_window ; redraw other labels to navigation buttons |
.next_m: |
cmp ah,18 |
jne .next_m2 |
276,8 → 298,8 |
jne .next |
cmp [move_flag],0 |
jne @f |
; cmp [move_flag],2 |
; je .set_light1 |
; cmp [move_flag],2 |
; je .set_light1 |
sub [vect_y],10 |
jmp .next |
@@: |
288,19 → 310,19 |
@@: |
sub [sin_amplitude],10 |
;-------------------------------------------------- |
; .set_light1: ; r - |
; movzx ebx,[light_no_flag] ; * 22 |
; mov ecx,ebx |
; shl ebx,4 |
; shl ecx,1 |
; add ebx,ecx |
; shl ecx,1 |
; add ebx,ecx |
; add ebx,lights+6 ; 6 -> light vector size |
; .set_light1: ; r - |
; movzx ebx,[light_no_flag] ; * 22 |
; mov ecx,ebx |
; shl ebx,4 |
; shl ecx,1 |
; add ebx,ecx |
; shl ecx,1 |
; add ebx,ecx |
; add ebx,lights+6 ; 6 -> light vector size |
; |
; movzx ecx,[light_comp_flag] |
; lea ecx,[ecx*3} |
; add ebx,ecx ; ebx -> color to set |
; movzx ecx,[light_comp_flag] |
; lea ecx,[ecx*3} |
; add ebx,ecx ; ebx -> color to set |
;--------------------------------------------------- |
.next: |
361,7 → 383,7 |
jne .next5 |
cmp [move_flag],0 |
jne @f |
; call add_vector |
; call add_vector |
add [vect_y],10 |
jmp .next5 |
@@: |
434,9 → 456,9 |
movzx ecx,[points_count_var] |
call translate_points |
; cmp [dr_flag],5 |
; jne @f |
; call calc_attenuation_light |
; cmp [dr_flag],5 |
; jne @f |
; call calc_attenuation_light |
; @@: |
cmp [fire_flag],0 |
jne @f |
493,8 → 515,11 |
je .no_inc_bright |
movzx ebx,[inc_bright_flag] |
shl ebx,4 |
mov esi,screen |
mov ecx,SIZE_X*SIZE_Y*3 |
mov esi,[screen_ptr] |
movzx ecx,word[size_y_var] |
movzx eax,word[size_x_var] |
mul ecx |
lea ecx,[eax*3] |
if (Ext = MMX)|(Ext = SSE) |
mov bh,bl |
push bx |
538,7 → 563,7 |
movaps [esi],xmm1 |
add esi,16 |
sub ecx,16 |
jnz .oop |
jnc .oop |
end if |
.no_inc_bright: |
548,9 → 573,12 |
je .no_dec_bright |
movzx ebx,[dec_bright_flag] |
shl ebx,4 |
mov esi,screen |
mov ecx,SIZE_X*SIZE_Y*3 |
if (Ext = MMX)|(Ext = SSE) |
mov esi,[screen_ptr] |
movzx eax,word[size_x_var] |
movzx ecx,word[size_y_var] |
mul ecx |
lea ecx,[eax*3] |
if (Ext = MMX)|(Ext = SSE) |
mov bh,bl |
push bx |
shl ebx,16 |
590,7 → 618,7 |
movaps [esi],xmm1 |
add esi,16 |
sub ecx,16 |
jnz .oop1 |
jnc .oop1 |
end if |
.no_dec_bright: |
;======================================commmented==================== |
600,7 → 628,7 |
je .no_max |
;movzx ebx,[max_flag] |
.again_max: |
; push ecx |
; push ecx |
mov edi,screen |
mov ecx,SIZE_X*3/4 |
; ; pxor mm5,mm5 |
633,7 → 661,7 |
if Ext >= SSE |
cmp [min_flag],0 |
je .no_min |
; push ecx |
; push ecx |
mov edi,screen |
mov ecx,SIZE_X*3/4 |
; ; pxor mm5,mm5 |
680,18 → 708,29 |
mov eax,7 ; put image |
mov ebx,screen |
mov ecx,SIZE_X shl 16 + SIZE_Y |
mov ecx,[size_y_var] |
; mov ecx,SIZE_X shl 16 + SIZE_Y |
mov edx,5 shl 16 + 25 |
int 0x40 |
mov eax,13 |
mov ebx,530*65536+60 |
mov ecx,510*65536+9 |
mov eax,13 |
mov bx,[size_x_var] |
add ebx,18 |
shl ebx,16 |
mov bx,60 |
mov cx,[size_y_var] |
sub cx,2 |
shl ecx,16 |
mov cx,9 |
xor edx,edx |
int 40h |
mov eax,4 ; function 4 : write text to window |
mov ebx,530*65536+510 ; [x start] *65536 + [y start] |
mov bx,[size_x_var] |
add ebx,18 |
shl ebx,16 |
mov bx,[size_y_var] |
sub bx,2 ; [x start] *65536 + [y start] |
mov ecx,0x00888888 |
mov edx,STRdata ; pointer to text beginning |
mov esi,10 ; text length |
726,16 → 765,18 |
alloc_buffer_mem: |
movzx ecx,[size_x] |
movzx eax,[size_y] |
movzx ecx,word[size_x_var] |
movzx eax,word[size_y_var] |
mul ecx |
lea ecx,[eax*3] |
add ecx,16 |
and ecx,0xfffffff0 |
push ecx |
shl eax,2 |
add ecx,eax |
add ecx,MEM_END |
mov ebx,1 |
mov eax,64 ; allocate mem - resize app mem |
mov eax,64 ; allocate mem - resize app mem |
int 0x40 |
mov [screen_ptr],MEM_END |
mov [Zbuffer_ptr],MEM_END |
745,7 → 786,7 |
update_flags: |
; updates flags and writing flag description |
; in ah - button number |
; in ah - button number |
push ax |
mov edi,menu |
.ch_another: |
765,7 → 806,7 |
jne .ch_another |
.write: |
; clreol {pascal never dies} |
; * eax = 13 - function number |
; * eax = 13 - function number |
; * ebx = [coordinate on axis x]*65536 + [size on axis x] |
; * ecx = [coordinate on axis y]*65536 + [size on axis y] |
; * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill |
777,8 → 818,10 |
lea ecx,[ecx*5] |
add ecx,28 |
shl ecx,16 |
add ecx,14 ; ecx = [coord y]*65536 + [size y] |
mov ebx,(SIZE_X+12+70)*65536+25 ; [x start] *65536 + [size x] |
add ecx,14 ; ecx = [coord y]*65536 + [size y] |
mov bx,[size_x_var] |
shl ebx,16 |
add ebx,(12+70)*65536+25 ; [x start] *65536 + [size x] |
mov edx,0x00000000 ; color 0x00RRGGBB |
int 0x40 |
787,7 → 830,10 |
sub bl,2 |
lea ebx,[ebx*3] |
lea ebx,[ebx*5] |
add ebx,(SIZE_X+12+70)*65536+28 ; [x start] *65536 + [y start] |
mov cx,[size_x_var] |
shl ecx,16 |
add ebx,ecx |
add ebx,(12+70)*65536+28 ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
movzx edx,byte[edi+12] ; current flag |
shl edx,2 ; * 4 = text length |
802,7 → 848,7 |
normalize_all_light_vectors: |
mov edi,lights |
@@: |
call normalize_vector ; 3dmath.inc |
call normalize_vector ; 3dmath.inc |
add edi,LIGHT_SIZE |
cmp edi,lightsend ;ecx |
jl @b |
810,14 → 856,14 |
calc_bumpmap_coords: ; map texture, bump |
;macro .comment222 |
; ; planar mapping |
; mov esi,points |
; mov edi,tex_points |
; ; planar mapping |
; mov esi,points |
; mov edi,tex_points |
; @@: |
; add esi,2 |
; movsd |
; cmp dword[esi],dword -1 |
; jne @b |
; add esi,2 |
; movsd |
; cmp dword[esi],dword -1 |
; jne @b |
; .Pi2 equ dword[ebp-4] |
831,8 → 877,8 |
mov edi,tex_points |
movzx ecx,[points_count_var] |
inc ecx |
; cmp [map_tex_flag],1 |
; jne .cylindric |
; cmp [map_tex_flag],1 |
; jne .cylindric |
; spherical mapping around y axle |
@@: |
839,7 → 885,7 |
fld dword[esi] ; x coord |
fld dword[esi+8] ; z coord |
fpatan ; arctg(st1/st) |
; fdiv .Pi2 |
; fdiv .Pi2 |
fdiv st0,st1 |
fimul [tex_x_div2] |
fiadd [tex_x_div2] |
866,26 → 912,26 |
add edi,4 |
loop @b |
ffree st0 |
; jmp .end_map |
; jmp .end_map |
; .cylindric: |
; fld dword[esi] ; around y axle |
; fld dword[esi+8] |
; fpatan |
; fdiv st0,st1 |
; fimul [tex_x_div2] |
; fiadd [tex_x_div2] |
; fistp word[edi] |
; fld dword[esi] ; around y axle |
; fld dword[esi+8] |
; fpatan |
; fdiv st0,st1 |
; fimul [tex_x_div2] |
; fiadd [tex_x_div2] |
; fistp word[edi] |
; fld dword[esi+4] |
; fimul [tex_y_div2] |
; fiadd [tex_y_div2] |
; fistp word[edi+2] |
; fld dword[esi+4] |
; fimul [tex_y_div2] |
; fiadd [tex_y_div2] |
; fistp word[edi+2] |
; add esi,12 |
; add edi,4 |
; loop .cylindric |
; ffree st0 |
;; mov esp,ebp |
; add esi,12 |
; add edi,4 |
; loop .cylindric |
; ffree st0 |
;; mov esp,ebp |
; .end_map: |
ret |
905,9 → 951,9 |
mov edi,envmap |
fninit |
mov dx,- TEX_Y / 2 ;256 ; dx - vertical coordinate = y |
mov dx,- TEX_Y / 2 ;256 ; dx - vertical coordinate = y |
.ie_ver: |
mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x |
mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x |
.ie_hor: |
xor ebx,ebx |
mov dword .col_b, 0 |
979,8 → 1025,8 |
mov al,byte[esi+15] ; r |
push ax |
push eax ; earlier - dot pr |
; fstp .dot_product |
; push .dot_product |
; fstp .dot_product |
; push .dot_product |
call calc_one_col |
pop ebp |
; eax-0x00rrggbb |
1021,7 → 1067,7 |
do_color_buffer: ; do color buffer for Gouraud, flat shading |
;env_map 512 x 512 x 3 bytes ; many lights using |
;env_map 512 x 512 x 3 bytes ; many lights using |
.temp equ word [ebp-2] |
.nz equ dword [ebp-6] ; dword |
.ny equ dword [ebp-10] |
1036,9 → 1082,9 |
mov edi,color_map |
fninit |
mov dx,- TEX_Y / 2 ;-256 ; dx - vertical coordinate = y |
mov dx,- TEX_Y / 2 ;-256 ; dx - vertical coordinate = y |
.ie_ver: |
mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x |
mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x |
.ie_hor: |
mov .temp,cx |
fild .temp |
1103,8 → 1149,8 |
mov al,byte[esi+15] ; r |
push ax |
push eax ; earlier - dot pr |
; fstp .dot_product |
; push .dot_product |
; fstp .dot_product |
; push .dot_product |
call calc_one_col |
pop ebp |
; eax-0x00rrggbb |
1203,7 → 1249,7 |
push esi |
mov esi,ecx |
lea esi,[esi*3] |
; lea esi,[triangles_normals+esi*4] |
; lea esi,[triangles_normals+esi*4] |
shl esi,2 |
add esi,[triangles_normals_ptr] |
1257,7 → 1303,7 |
mov ebx,vectors |
movzx esi,word[ebp] ; first point index |
lea esi,[esi*3] |
; lea esi,[points+esi*2] ; esi - pointer to 1st 3d point |
; 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 |
1264,9 → 1310,9 |
lea edi,[edi*3] |
shl edi,2 |
add edi,[points_ptr] |
; movzx edi,word[ebp+2] ; second point index |
; lea edi,[edi*3] |
; lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point |
; 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_r |
add ebx,12 |
mov esi,edi |
1274,7 → 1320,7 |
lea edi,[edi*3] |
shl edi,2 |
add edi,[points_ptr] |
; lea edi,[points+edi*2] |
; lea edi,[points+edi*2] |
call make_vector_r |
mov edi,ebx ; edi - pointer to 2nd vector |
mov esi,ebx |
1311,7 → 1357,7 |
mov ax,cx |
; cwd |
; idiv word[i3] |
; idiv word[i3] |
movsd ; store vertex coordinates |
movsw |
stosw ; middle vertex coordinate 'z' in triangles_with_z list |
1320,8 → 1366,8 |
movsd ; copy end mark |
mov eax,4 |
lea edx,[edi-8-trizdd] |
; lea edx, [edi-8] |
; sub edx,[triangles_w_z_ptr] |
; lea edx, [edi-8] |
; sub edx,[triangles_w_z_ptr] |
mov [high],edx |
call quicksort |
mov eax,4 |
1337,10 → 1383,10 |
lea ecx,[eax+edx] |
shr ecx,4 |
lea ecx,[ecx*8-4]; |
; mov edi,[triangles_w_z_ptr] |
; mov ebx,[edi+eax] |
; mov esi,[edi+ecx] |
; mov edi,[edi+edx] |
; mov edi,[triangles_w_z_ptr] |
; mov ebx,[edi+eax] |
; mov esi,[edi+ecx] |
; mov edi,[edi+edx] |
mov ebx,[trizdd+eax]; trizdd[l] |
mov esi,[trizdd+ecx]; trizdd[i] |
mov edi,[trizdd+edx]; trizdd[h] |
1356,13 → 1402,13 |
mov ebx,[trizdd+eax] |
mov esi,[trizdd+ecx] |
else |
; push ebx |
; mov ebx,[triangles_w_z_ptr] |
; movq mm0,[ebx+eax-4] |
; movq mm1,[ebx+ecx-4] |
; movq [ebx+ecx-4],mm0 |
; movq [ebx+eax-4],mm1 |
; pop ebx |
; push ebx |
; mov ebx,[triangles_w_z_ptr] |
; movq mm0,[ebx+eax-4] |
; movq mm1,[ebx+ecx-4] |
; movq [ebx+ecx-4],mm0 |
; movq [ebx+eax-4],mm1 |
; pop ebx |
movq mm0,[trizdq+eax-4] |
movq mm1,[trizdq+ecx-4] |
movq [trizdq+ecx-4],mm0 |
1382,17 → 1428,17 |
mov ebx,[trizdd+eax] |
mov edi,[trizdd+edx] |
else |
; push ebx |
; mov ebx,[triangles_w_z_ptr] |
; movq mm0,[ebx+eax-4] |
; movq mm1,[ebx+edx-4] |
; movq [ebx+edx-4],mm0 |
; movq [ebx+eax-4],mm1 |
; push ebx |
; mov ebx,[triangles_w_z_ptr] |
; movq mm0,[ebx+eax-4] |
; movq mm1,[ebx+edx-4] |
; movq [ebx+edx-4],mm0 |
; movq [ebx+eax-4],mm1 |
movq mm0,[trizdq+eax-4] |
movq mm1,[trizdq+edx-4] |
movq [trizdq+edx-4],mm0 |
movq [trizdq+eax-4],mm1 |
; pop ebx |
; pop ebx |
xchg ebx,edi |
end if |
@@: |
1406,13 → 1452,13 |
mov [trizdd+ecx-4],edi |
mov [trizdd+edx-4],esi |
else |
; push ebx |
; mov ebx,[triangles_w_z_ptr] |
; movq mm0,[ebx+ecx-4] |
; movq mm1,[ebx+edx-4] |
; movq [ebx+edx-4],mm0 |
; movq [ebx+ecx-4],mm1 |
; pop ebx |
; push ebx |
; mov ebx,[triangles_w_z_ptr] |
; movq mm0,[ebx+ecx-4] |
; movq mm1,[ebx+edx-4] |
; movq [ebx+edx-4],mm0 |
; movq [ebx+ecx-4],mm1 |
; pop ebx |
movq mm0,[trizdq+ecx-4] |
movq mm1,[trizdq+edx-4] |
1433,13 → 1479,13 |
mov [trizdd+ecx-4],esi |
mov [trizdd+ebp-4],edi |
else |
; push ebx |
; mov ebx,[triangles_w_z_ptr] |
; movq mm0,[ebx+ebp-4] |
; movq mm1,[ebx+ecx-4] |
; movq [ebx+ecx-4],mm0 |
; movq [ebx+ebp-4],mm1 |
; pop ebx |
; push ebx |
; mov ebx,[triangles_w_z_ptr] |
; movq mm0,[ebx+ebp-4] |
; movq mm1,[ebx+ecx-4] |
; movq [ebx+ecx-4],mm0 |
; movq [ebx+ebp-4],mm1 |
; pop ebx |
movq mm0,[trizdq+ebp-4] |
movq mm1,[trizdq+ecx-4] |
1448,20 → 1494,20 |
end if |
mov ecx,edx ; i; direction |
mov ebx,[trizdd+ebp]; trizdd[j] |
; mov ebx, [triangles_w_z_ptr] |
; add ebx, ebp |
; mov ebx, [triangles_w_z_ptr] |
; add ebx, ebp |
; push eax |
; mov eax, [triangles_w_z_ptr] |
; push eax |
; mov eax, [triangles_w_z_ptr] |
.loop: |
sub ecx,8 ; direction |
cmp [trizdd+ecx],ebx |
; cmp [eax+ecx],ebx |
; cmp [eax+ecx],ebx |
jl .loop ; direction |
@@: |
add ebp,8 ; direction |
cmp [trizdd+ebp],ebx |
; cmp [eax+ebp],ebx |
; cmp [eax+ebp],ebx |
jg @b ; direction |
cmp ebp,ecx |
jge @f ; direction |
1475,10 → 1521,10 |
mov [trizdd+ebp-4],edi |
mov [trizdd+ecx-4],esi |
else |
; movq mm0,[eax+ecx-4] |
; movq mm1,[eax+ebp-4] |
; movq [eax+ebp-4],mm0 |
; movq [eax+ecx-4],mm1 |
; movq mm0,[eax+ecx-4] |
; movq mm1,[eax+ebp-4] |
; movq [eax+ebp-4],mm0 |
; movq [eax+ecx-4],mm1 |
movq mm0,[trizdq+ecx-4] |
movq mm1,[trizdq+ebp-4] |
movq [trizdq+ebp-4],mm0 |
1485,7 → 1531,7 |
movq [trizdq+ecx-4],mm1 |
end if |
jmp .loop |
; pop eax |
; pop eax |
@@: |
if Ext=NON |
mov esi,[trizdd+ecx] |
1497,13 → 1543,13 |
mov [trizdd+eax+4],edi |
mov [trizdd+ecx-4],esi |
else |
; push edx |
; mov edx,[triangles_w_z_ptr] |
; movq mm0,[edx+ecx-4] |
; movq mm1,[edx+eax+4]; dir |
; movq [edx+eax+4],mm0; dir |
; movq [edx+ecx-4],mm1 |
; pop edx |
; push edx |
; mov edx,[triangles_w_z_ptr] |
; movq mm0,[edx+ecx-4] |
; movq mm1,[edx+eax+4]; dir |
; movq [edx+eax+4],mm0; dir |
; movq [edx+ecx-4],mm1 |
; pop edx |
movq mm0,[trizdq+ecx-4] |
movq mm1,[trizdq+eax+4]; dir |
1525,25 → 1571,25 |
cmp esi,edx |
ja .exit |
mov ebx,[trizdd+esi] |
; mov ebx,[triangles_w_z_ptr] |
; add ebx,esi |
; mov ebx,[triangles_w_z_ptr] |
; add ebx,esi |
if Ext=NON |
mov ecx,[trizdd+esi-4] |
else |
; push ebx |
; mov ebx,[triangles_w_z_ptr] |
; movq mm1,[ebx+esi-4] |
; push ebx |
; mov ebx,[triangles_w_z_ptr] |
; movq mm1,[ebx+esi-4] |
movq mm1,[trizdq+esi-4] |
; pop ebx |
; pop ebx |
end if |
mov edi,esi |
@@: |
cmp edi,eax |
jna @f |
; push eax |
; mov eax,[triangles_w_z_ptr] |
; cmp [eax+edi-8],ebx |
; pop eax |
; push eax |
; mov eax,[triangles_w_z_ptr] |
; cmp [eax+edi-8],ebx |
; pop eax |
cmp [trizdd+edi-8],ebx |
jg @f ; direction |
if Ext=NON |
1552,13 → 1598,13 |
mov ebp,[trizdd+edi-12] |
mov [trizdd+edi-4],ebp |
else |
; push eax |
; mov eax,[triangles_w_z_ptr] |
; movq mm0,[eax+edi-12] |
; movq [eax+edi-4],mm0 |
; push eax |
; mov eax,[triangles_w_z_ptr] |
; movq mm0,[eax+edi-12] |
; movq [eax+edi-4],mm0 |
movq mm0,[trizdq+edi-12] |
movq [trizdq+edi-4],mm0 |
; pop eax |
; pop eax |
end if |
sub edi,8 |
jmp @b |
1567,11 → 1613,11 |
mov [trizdd+edi],ebx |
mov [trizdd+edi-4],ecx |
else |
; push eax |
; mov eax,[triangles_w_z_ptr] |
; movq [eax+edi-4],mm1 |
; push eax |
; mov eax,[triangles_w_z_ptr] |
; movq [eax+edi-4],mm1 |
movq [trizdq+edi-4],mm1 |
; pop eax |
; pop eax |
end if |
jmp .start |
.exit: |
1579,8 → 1625,8 |
end_sort: |
; translate triangles_with_z to sorted_triangles |
mov esi,triangles_with_z |
; mov esi,[triangles_w_z_ptr] |
; mov edi,sorted_triangles |
; mov esi,[triangles_w_z_ptr] |
; mov edi,sorted_triangles |
mov edi,[triangles_ptr] |
again_copy: |
if Ext=NON |
1596,7 → 1642,7 |
cmp dword[esi],-1 |
jne again_copy |
; if Ext=MMX |
; emms |
; emms |
; end if |
movsd ; copy end mark too |
ret |
1603,11 → 1649,15 |
clrscr: |
mov edi,screen |
mov ecx,SIZE_X*SIZE_Y*3/4 |
movzx ecx,word[size_x_var] |
movzx eax,word[size_y_var] |
imul ecx,eax |
lea ecx,[ecx*3] |
shr ecx,2 |
xor eax,eax |
if Ext=NON |
rep stosd |
else |
else if Ext = MMX |
pxor mm0,mm0 |
@@: |
movq [edi+00],mm0 |
1617,7 → 1667,24 |
add edi,32 |
sub ecx,8 |
jnc @b |
else |
push ecx |
mov ecx,edi |
and ecx,0x0000000f |
rep stosb |
pop ecx |
and ecx,0xfffffff0 |
xorps xmm0,xmm0 |
@@: |
movaps [edi],xmm0 |
movaps [edi+16],xmm0 |
movaps [edi+32],xmm0 |
movaps [edi+48],xmm0 |
add edi,64 |
sub ecx,16 |
jnz @b |
end if |
ret |
1657,7 → 1724,7 |
mov [point_index3],ax |
lea eax,[eax*3] |
add eax,eax |
; push ebp |
; push ebp |
add ebp,eax |
mov eax,[ebp] |
mov dword[xx3],eax |
1666,8 → 1733,8 |
else |
mov eax,dword[esi] ; don't know MMX |
mov dword[point_index1],eax |
; shr eax,16 |
; mov [point_index2],ax |
; shr eax,16 |
; mov [point_index2],ax |
mov ax,word[esi+4] |
mov [point_index3],ax |
movq mm0,[esi] |
1686,7 → 1753,7 |
movq qword[xx1],mm0 |
movq qword[xx2],mm1 |
movq qword[xx3],mm2 |
; emms |
; emms |
end if ; ********************************* |
push esi ; |
fninit ; DO culling AT FIRST |
1699,7 → 1766,7 |
lea eax,[eax*3] |
shl eax,2 |
add eax,[points_normals_rot_ptr] |
; lea eax,[eax+point_normals_rotated] |
; lea eax,[eax+point_normals_rotated] |
fld dword[eax+8] ; ***************************** |
ftst ; CHECKING OF Z COOFICIENT OF |
fstsw ax ; NORMAL VECTOR |
1775,44 → 1842,44 |
jnz .again_grd_draw |
jmp .both_draw |
; movzx edi,[point_index3] ;gouraud shading according to light vector |
; lea edi,[edi*3] |
; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
; mov esi,light_vector |
; call dot_product |
; fabs |
; fimul [orginal_color_r] |
; fistp [temp_col] |
; and [temp_col],0x00ff |
; push [temp_col] |
; push [temp_col] |
; push [temp_col] |
; movzx edi,[point_index3] ;gouraud shading according to light vector |
; lea edi,[edi*3] |
; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
; mov esi,light_vector |
; call dot_product |
; fabs |
; fimul [orginal_color_r] |
; fistp [temp_col] |
; and [temp_col],0x00ff |
; push [temp_col] |
; push [temp_col] |
; push [temp_col] |
; movzx edi,[point_index2] |
; lea edi,[edi*3] |
; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
; mov esi,light_vector |
; call dot_product |
; fabs |
; fimul [orginal_color_r] |
; fistp [temp_col] |
; and [temp_col],0x00ff |
; push [temp_col] |
; push [temp_col] |
; push [temp_col] |
; movzx edi,[point_index2] |
; lea edi,[edi*3] |
; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
; mov esi,light_vector |
; call dot_product |
; fabs |
; fimul [orginal_color_r] |
; fistp [temp_col] |
; and [temp_col],0x00ff |
; push [temp_col] |
; push [temp_col] |
; push [temp_col] |
; movzx edi,[point_index1] |
; lea edi,[edi*3] |
; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
; mov esi,light_vector |
; call dot_product |
; fabs |
; fimul [orginal_color_r] |
; fistp [temp_col] |
; and [temp_col],0x00ff |
; push [temp_col] |
; push [temp_col] |
; push [temp_col] |
; movzx edi,[point_index1] |
; lea edi,[edi*3] |
; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
; mov esi,light_vector |
; call dot_product |
; fabs |
; fimul [orginal_color_r] |
; fistp [temp_col] |
; and [temp_col],0x00ff |
; push [temp_col] |
; push [temp_col] |
; push [temp_col] |
.rainbow: |
cmp [catmull_flag],1 ; put on stack z coordinate if necessary |
jne @f |
1852,7 → 1919,7 |
lea edi,[screen] |
cmp [catmull_flag],0 |
je @f |
; lea esi,[Z_buffer] |
; lea esi,[Z_buffer] |
mov esi,[Zbuffer_ptr] |
call gouraud_triangle_z |
jmp .end_draw |
1898,17 → 1965,17 |
; mov ax,[zz1] ; z position depend draw |
; add ax,[zz2] |
; add ax,[zz3] |
; cwd |
; idiv [i3] ; = -((a+b+c)/3+130) |
; add ax,130 |
; neg al |
; xor edx,edx |
; mov ah,al ;set color according to z position |
; shl eax,8 |
; mov edx,eax |
; mov ax,[zz1] ; z position depend draw |
; add ax,[zz2] |
; add ax,[zz3] |
; cwd |
; idiv [i3] ; = -((a+b+c)/3+130) |
; add ax,130 |
; neg al |
; xor edx,edx |
; mov ah,al ;set color according to z position |
; shl eax,8 |
; mov edx,eax |
mov eax,dword[xx1] |
ror eax,16 |
1916,11 → 1983,11 |
ror ebx,16 |
mov ecx,dword[xx3] |
ror ecx,16 |
; mov edi,screen |
; mov edi,screen |
lea edi,[screen] |
cmp [catmull_flag],0 |
je @f |
; lea esi,[Z_buffer] |
; lea esi,[Z_buffer] |
mov esi,[Zbuffer_ptr] |
push word[zz3] |
push word[zz2] |
1948,17 → 2015,17 |
shl eax,2 |
add eax,[points_normals_rot_ptr] ;point_normals_rotated |
; # |
; fld dword[eax] |
; fmul dword[eax+4] |
; fld1 |
; fld1 |
; faddp |
; fmulp |
; fimul [correct_tex] |
; fiadd [correct_tex] |
; fistp word[edi] |
; mov word[edi+2],0 |
;; fistp word[edi+2] |
; fld dword[eax] |
; fmul dword[eax+4] |
; fld1 |
; fld1 |
; faddp |
; fmulp |
; fimul [correct_tex] |
; fiadd [correct_tex] |
; fistp word[edi] |
; mov word[edi+2],0 |
;; fistp word[edi+2] |
; # last change |
; texture x=(rotated point normal -> x * 255)+255 |
fld dword[eax] |
1985,7 → 2052,7 |
mov esi,envmap |
cmp [catmull_flag],0 |
je @f |
; mov edx,Z_buffer |
; mov edx,Z_buffer |
mov edx,[Zbuffer_ptr] |
call tex_triangle_z |
jmp .end_draw |
2021,18 → 2088,18 |
fiadd [correct_tex] |
fistp word[edi] |
mov word[edi+2],0 |
; fistp word[edi+2] |
; fistp word[edi+2] |
; # last change |
; ; texture x=(rotated point normal -> x * 255)+255 |
; fld dword[eax] |
; fimul [correct_tex] |
; fiadd [correct_tex] |
; fistp word[edi] |
; ; texture y=(rotated point normal -> y * 255)+255 |
; fld dword[eax+4] |
; fimul [correct_tex] |
; fiadd [correct_tex] |
; fistp word[edi+2] |
; ; texture x=(rotated point normal -> x * 255)+255 |
; fld dword[eax] |
; fimul [correct_tex] |
; fiadd [correct_tex] |
; fistp word[edi] |
; ; texture y=(rotated point normal -> y * 255)+255 |
; fld dword[eax+4] |
; fimul [correct_tex] |
; fiadd [correct_tex] |
; fistp word[edi+2] |
; # end of last ch. |
add edi,4 |
add esi,2 |
2044,11 → 2111,11 |
ror ebx,16 |
mov ecx,dword[xx3] |
ror ecx,16 |
mov edi,screen |
mov edi,[screen_ptr] |
mov esi,envmap_cub |
cmp [catmull_flag],0 |
je @f |
; mov edx,Z_buffer |
; mov edx,Z_buffer |
mov edx,[Zbuffer_ptr] |
call tex_triangle_z |
jmp .end_draw |
2062,7 → 2129,7 |
; fninit |
cmp [catmull_flag],0 |
je @f |
; push Z_buffer |
; push Z_buffer |
push [Zbuffer_ptr] |
push [zz3] |
push [zz2] |
2099,17 → 2166,17 |
movzx esi,[point_index2] |
shl esi,2 |
add esi,tex_points |
; lea esi,[esi*3] |
; lea esi,[points+2+esi*2] |
; lea esi,[esi*3] |
; lea esi,[points+2+esi*2] |
push dword[esi] |
; push dword[xx2] |
; push dword[xx2] |
movzx esi,[point_index1] |
shl esi,2 |
add esi,tex_points |
; lea esi,[esi*3] |
; lea esi,[points+2+esi*2] |
; lea esi,[esi*3] |
; lea esi,[points+2+esi*2] |
push dword[esi] |
; push dword[xx1] |
; push dword[xx1] |
mov eax,dword[xx1] |
ror eax,16 |
2161,47 → 2228,47 |
mov esi,texmap |
cmp [catmull_flag],0 |
je @f |
; mov edx,Z_buffer |
; mov edx,Z_buffer |
mov edx,[Zbuffer_ptr] |
call tex_triangle_z |
; call tex_plus_grd_trianlgle |
; 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 |
; je @f |
; push [zz3] ; spot light with attenuation |
; grd_triangle according to points index |
; cmp [catmull_flag],0 |
; je @f |
; push [zz3] ; spot light with attenuation |
; @@: |
; movzx eax,[point_index3] ; env_map - points color list |
; shl eax,1 ; each color as word, 0x00rr00gg00bb.. |
; lea eax,[3*eax+bumpmap] |
; push word[eax] |
; push word[eax+2] |
; push word[eax+4] |
; cmp [catmull_flag],0 |
; je @f |
; push [zz2] |
; movzx eax,[point_index3] ; env_map - points color list |
; shl eax,1 ; each color as word, 0x00rr00gg00bb.. |
; lea eax,[3*eax+bumpmap] |
; push word[eax] |
; push word[eax+2] |
; push word[eax+4] |
; cmp [catmull_flag],0 |
; je @f |
; push [zz2] |
; @@: |
; movzx eax,[point_index2] ; env_map - points color list |
; shl eax,1 ; each color as word, 0x00rr00gg00bb.. |
; lea eax,[eax*3+bumpmap] |
; push word[eax] |
; push word[eax+2] |
; push word[eax+4] |
; cmp [catmull_flag],0 |
; je @f |
; push [zz1] |
; movzx eax,[point_index2] ; env_map - points color list |
; shl eax,1 ; each color as word, 0x00rr00gg00bb.. |
; lea eax,[eax*3+bumpmap] |
; push word[eax] |
; push word[eax+2] |
; push word[eax+4] |
; cmp [catmull_flag],0 |
; je @f |
; push [zz1] |
; @@: |
; movzx eax,[point_index1] ; env_map - points color list |
; shl eax,1 ; each color as word, 0xrr00gg00bb00.. |
; lea eax,[eax*3+bumpmap] |
; push word[eax] |
; push word[eax+2] |
; push word[eax+4] |
; jmp .both_draw |
; movzx eax,[point_index1] ; env_map - points color list |
; shl eax,1 ; each color as word, 0xrr00gg00bb00.. |
; lea eax,[eax*3+bumpmap] |
; push word[eax] |
; push word[eax+2] |
; push word[eax+4] |
; jmp .both_draw |
.grd_tex: ; smooth shading + texture |
push ebp |
2386,9 → 2453,9 |
add esi,2 |
loop @b |
; push dword 1 shl 16 + 1 ; emap coords |
; push dword 127 shl 16 + 1 |
; push dword 127 shl 16 + 127 |
; push dword 1 shl 16 + 1 ; emap coords |
; push dword 127 shl 16 + 1 |
; push dword 127 shl 16 + 127 |
movzx esi,[point_index3] ; bump map coords |
shl esi,2 |
2404,9 → 2471,9 |
add esi,tex_points |
push dword[esi] |
; push dword 1 shl 16 + 127 |
; push dword 127 shl 16 + 127 |
; push dword 1 shl 16 + 1 ; bump coords |
; push dword 1 shl 16 + 127 |
; push dword 127 shl 16 + 127 |
; push dword 1 shl 16 + 1 ; bump coords |
mov eax,dword[xx1] |
ror eax,16 |
2455,11 → 2522,11 |
dec ecx |
jnz .again_line_param |
; mov eax,[edges_ptr] ; this not works correctly |
; add eax,[edges_counter] ; I mean chosing overlapped edges. |
; mov bl,[eax] ; |
; test bl,00000001b ; |
; jz @f ; |
; mov eax,[edges_ptr] ; this not works correctly |
; add eax,[edges_counter] ; I mean chosing overlapped edges. |
; mov bl,[eax] ; |
; test bl,00000001b ; |
; jz @f ; |
mov edi,screen |
mov esi,[Zbuffer_ptr] |
2489,11 → 2556,11 |
call smooth_line |
@@: |
; mov eax,[edges_ptr] ; this not works correctly |
; add eax,[edges_counter] |
; mov bl,[eax] |
; test bl,00000010b |
; jz @f |
; mov eax,[edges_ptr] ; this not works correctly |
; add eax,[edges_counter] |
; mov bl,[eax] |
; test bl,00000010b |
; jz @f |
mov edi,screen |
mov esi,[Zbuffer_ptr] |
2525,11 → 2592,11 |
call smooth_line |
@@: |
; mov eax,[edges_ptr] ; this not works correctly |
; add eax,[edges_counter] ; |
; mov bl,[eax] ; |
; test bl,00000100b ; |
; jz @f ; |
; mov eax,[edges_ptr] ; this not works correctly |
; add eax,[edges_counter] ; |
; mov bl,[eax] ; |
; test bl,00000100b ; |
; jz @f ; |
mov edi,screen |
mov esi,[Zbuffer_ptr] |
2572,13 → 2639,35 |
fill_Z_buffer: |
mov eax,0x70000000 |
; mov edi,Z_buffer |
mov edi,[Zbuffer_ptr] |
mov ecx,SIZE_X*SIZE_Y |
movzx ecx,word[size_x_var] |
movzx ebx,word[size_y_var] |
imul ecx,ebx |
if Ext>=SSE2 |
movd xmm0,eax |
shufps xmm0,xmm0,0 |
push ecx |
mov ecx,edi |
and edi,0xffffff00 |
and ecx,0x000000ff |
mov edx,ecx |
rep stosd |
pop ecx |
sub ecx,edx |
@@: |
movaps [edi],xmm0 |
movaps [edi+16],xmm0 |
movaps [edi+32],xmm0 |
movaps [edi+48],xmm0 |
add edi,64 |
sub ecx,16 |
jnc @b |
else |
rep stosd |
end if |
ret |
read_tp_variables: ; read [triangles_count_var] and [points_count_var] |
read_tp_variables: ; read [triangles_count_var] and [points_count_var] |
; and allocate memory |
xor ebx,ebx |
xor ebp,ebp |
2650,7 → 2739,7 |
add ebx,6 |
add esi,12 |
; dec ecx |
; dec ecx |
loop @b |
@@: |
2668,7 → 2757,7 |
add esi,8 |
dec ecx |
jnz @b |
; xor ecx,ecx |
; xor ecx,ecx |
add ebp,edx |
jmp .find4k |
mov eax,-1 ;<---mark if OK |
2689,11 → 2778,11 |
end if |
cmp [esi],word 4D4Dh |
jne .exit ;Must be legal .3DS file |
; cmp dword[esi+2],EndFile-SourceFile |
; jne .exit ;This must tell the length |
; cmp dword[esi+2],EndFile-SourceFile |
; jne .exit ;This must tell the length |
mov eax,dword[esi+2] |
; cmp eax,[fsize] |
; jne .exit |
; cmp eax,[fsize] |
; jne .exit |
add eax,esi |
mov [EndFile],eax ; |
2750,12 → 2839,12 |
push dword[esi+0] |
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 |
; 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 |
2762,7 → 2851,7 |
dec ecx |
jnz @b |
@@: |
; mov dword[points+ebx],-1 |
; mov dword[points+ebx],-1 |
push edi |
mov edi,[points_ptr] |
mov dword[edi+ebx*2],-1 ; end mark (not always in use) |
2776,7 → 2865,7 |
movzx ecx,word[esi+6] |
add [triangles_count_var],cx |
add esi,8 |
;mov edi,triangles |
;mov edi,triangles |
@@: |
movsd |
movsw |
2812,28 → 2901,28 |
int 0x40 ; -> allocate memory to triangles |
mov [triangles_ptr], eax ; -> eax = pointer to allocated mem |
; mov eax, 68 |
; movzx ecx, [triangles_count_var] |
; inc ecx |
; mov edx,[edges_ptr] |
; int 0x40 ; -> allocate memory to edges |
; mov [edges_ptr], eax ; -> eax = pointer to allocated mem |
; mov eax, 68 |
; movzx ecx, [triangles_count_var] |
; inc ecx |
; mov edx,[edges_ptr] |
; int 0x40 ; -> allocate memory to edges |
; mov [edges_ptr], eax ; -> eax = pointer to allocated mem |
; mov eax,-1 ; fill edges list |
; movzx ecx,[triangles_count_var] ; importand if object generated |
; shr ecx,2 |
; inc ecx |
; mov edi,[edges_ptr] |
; cld |
; rep stosd |
; mov eax,-1 ; fill edges list |
; movzx ecx,[triangles_count_var] ; importand if object generated |
; shr ecx,2 |
; inc ecx |
; mov edi,[edges_ptr] |
; cld |
; rep stosd |
; mov eax, 68 |
; mov ebx, 12 |
; movzx ecx, [triangles_count_var] |
; shl ecx, 4 |
; int 0x40 |
; mov [triangles_w_z_ptr], eax ; for trainagles_with_z list |
; mov eax, 68 |
; mov ebx, 12 |
; movzx ecx, [triangles_count_var] |
; shl ecx, 4 |
; int 0x40 |
; mov [triangles_w_z_ptr], eax ; for trainagles_with_z list |
; ststic memory |
mov eax, 68 |
2853,7 → 2942,7 |
mov [points_normals_ptr], eax |
mov eax, 68 |
; mov ebx, 12 |
; mov ebx, 12 |
movzx ecx, [points_count_var] |
lea ecx,[3+ecx*3] |
shl ecx, 2 |
2927,7 → 3016,7 |
; mov ecx,ebx |
; add ecx,MEM_END |
; mov ebx,1 |
; mov eax,64 ; allocate mem - resize app mem |
; mov eax,64 ; allocate mem - resize app mem |
; for points and triangles |
int 0x40 |
2958,8 → 3047,10 |
buttons: ; draw some buttons (all but navigation and close ) |
mov edi,menu |
.again: |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+10)*65536+62 ; [x start] *65536 + [x size] |
mov eax,8 ; function 8 : define and draw button |
mov bx,[size_x_var] |
shl ebx,16 |
add ebx,(10)*65536+62 ; [x start] *65536 + [x size] |
movzx ecx,byte[edi] ; button id = position+2 |
sub cl,2 |
lea ecx,[ecx*5] |
2976,7 → 3067,10 |
sub bl,2 ; button id, according to position |
lea ebx,[ebx*3] |
lea ebx,[ebx*5] |
add ebx,(SIZE_X+12)*65536+28 ; [x start] *65536 + [y start] |
mov cx,[size_x_var] |
shl ecx,16 |
add ebx,ecx |
add ebx,(12)*65536+28 ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
lea edx,[edi+1] ; pointer to text beginning |
mov esi,10 ; text length |
2984,14 → 3078,14 |
cmp byte[edi+11],255 ; if max_flag=255 |
je @f ; skip |
; flag description |
; mov eax,4 ; function 4 : write text to window |
; movzx ebx,byte[edi] |
; sub bl,2 |
; lea ebx,[ebx*3] |
; lea ebx,[ebx*5] |
; add ebx,(SIZE_X+12+70)*65536+28 ; [x start] *65536 + [y start] |
; mov eax,4 ; function 4 : write text to window |
; movzx ebx,byte[edi] |
; sub bl,2 |
; lea ebx,[ebx*3] |
; lea ebx,[ebx*5] |
; add ebx,(SIZE_X+12+70)*65536+28 ; [x start] *65536 + [y start] |
add ebx,70*65536 |
; mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
; mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
movzx edx,byte[edi+12] ; current flag |
shl edx,2 ; * 4 = text length |
add edx,dword[edi+13] ; pointer to text beginning |
3013,11 → 3107,11 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536;+SIZE_X;+80+30 ; [x start] *65536 + [x size] |
mov ecx,100*65536;+SIZE_Y;+30 ; [y start] *65536 + [y size] |
mov bx,[size_x] |
mov ebx,50*65536;+SIZE_X;+80+30 ; [x start] *65536 + [x size] |
mov ecx,50*65536;+SIZE_Y;+30 ; [y start] *65536 + [y size] |
mov bx,[size_x_var] |
add bx,115 |
mov cx,[size_y] |
mov cx,[size_y_var] |
add cx,30 |
mov edx,0x14000000 ; color of work area RRGGBB,8->color gl |
mov edi,labelt ; WINDOW LABEL |
3027,20 → 3121,24 |
.Y_ADD equ 1 ;-> offset of 'add vector' buttons |
; ADD VECTOR LABEL ; add vector buttons - 30 ++ |
; ADD VECTOR LABEL ; add vector buttons - 30 ++ |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+12)*65536+(168+15*(13+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(12)*65536+(168+15*(13+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelvector ; pointer to text beginning |
mov esi,labelvectorend-labelvector ; text length |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; @@: |
int 0x40 |
; VECTOR Y- BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+30)*65536+20 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,30*65536+20 ; [x start] *65536 + [x size] |
mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,30 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3047,18 → 3145,22 |
int 0x40 |
;VECTOR Y- LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+32)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(32)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelyminus ; pointer to text beginning |
mov esi,labelyminusend-labelyminus ; text length |
cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; jne @f |
; add edx,navigation_size |
; @@: |
int 0x40 |
; VECTOR Z+ BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+51)*65536+21 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(51)*65536+21 ; [x start] *65536 + [x size] |
mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,31 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3065,19 → 3167,23 |
int 0x40 |
;VECTOR Z+ LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+53)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(53)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelzplus ; pointer to text beginning |
mov esi,labelzplusend-labelzplus ; text length |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; @@: |
int 0x40 |
; VECTOR x- BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+10)*65536+21 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(10)*65536+21 ; [x start] *65536 + [x size] |
mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,32 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3084,18 → 3190,22 |
int 0x40 |
;VECTOR x- LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+12)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(12)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelxminus ; pointer to text beginning |
mov esi,labelxminusend-labelxminus ; text length |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; @@: |
int 0x40 |
; VECTOR x+ BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+51)*65536+21 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(51)*65536+21 ; [x start] *65536 + [x size] |
mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,33 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3102,18 → 3212,22 |
int 0x40 |
;VECTOR x+ LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+53)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(53)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelxplus ; pointer to text beginning |
mov esi,labelxplusend-labelxplus ; text length |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; @@: |
int 0x40 |
; VECTOR z- BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+10)*65536+62-41 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(10)*65536+62-41 ; [x start] *65536 + [x size] |
mov ecx,(25+140+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,34 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3120,18 → 3234,22 |
int 0x40 |
;VECTOR z- LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+12)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(12)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelzminus ; pointer to text beginning |
mov esi,labelzminusend-labelzminus ; text length |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; @@: |
int 0x40 |
;VECTOR Y+ BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+10+20)*65536+20 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(10+20)*65536+20 ; [x start] *65536 + [x size] |
mov ecx,(165+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,35 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3138,13 → 3256,15 |
int 0x40 |
;VECTOR Y+ LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+32)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(32)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelyplus ; pointer to text beginning |
mov esi,labelyplusend-labelyplus ; text length |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; cmp [move_flag],2 |
; jne @f |
; add edx,navigation_size |
; @@: |
int 0x40 |
3154,8 → 3274,8 |
ret |
; DATA AREA ************************************ |
; DATA AREA ************************************ |
include 'DATA.INC' |
align 16 |
MEM_END: |