3ds0066: upload new version by macgub

git-svn-id: svn://kolibrios.org@6619 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2016-10-27 09:39:38 +00:00
parent 5add26b5b5
commit 88e99ce6e8
18 changed files with 1518 additions and 1172 deletions

View File

@ -12,7 +12,9 @@ do_sinus:
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 @@ end if
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 @@ end if
.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 @@ draw_dots:
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 @@ draw_dots:
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 @@ end if
pop ebp
ret
end if
;********************************EMBOSS DONE*******************************

View File

@ -97,11 +97,12 @@ bump_triangle:
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 @@ bump_line:
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 @@ end if
.bl_ok:
push eax
push ebx ;store x1, x2
movzx eax,word[size_x_var]
lea eax,[eax*3]
mov eax,SIZE_X*3
; mov eax,SIZE_X*3
mov ebx,.y
mul ebx
mov ecx,.x1

View File

@ -780,7 +780,9 @@ bump_line_z:
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 @@ end if
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 @@ end if
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

View File

@ -1279,7 +1279,8 @@ bump_tex_line_z:
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 @@ end if
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 @@ end if
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]

View File

@ -747,16 +747,29 @@ if Ext>=SSE2
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 @@ if Ext>=SSE2
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 @@ if Ext=SSE
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 @@ if Ext=SSE
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 @@ if Ext=MMX
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

View File

@ -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 @@ catmull_flag db 1
db 8
db 'culling '
db 2
culling_flag db 1
culling_flag db 0
dd onoff_f
db 9
@ -314,7 +314,7 @@ base_vector:
if Ext=SSE2
db ' (SSE2)'
end if
db ' 0.065',0
db ' 0.066',0
labellen:
STRdata db '-1 '
@ -436,6 +436,10 @@ align 8
screen_ptr dd ?
Zbuffer_ptr dd ?
; edges_ptr dd ?
size_y_var:
dw ?
size_x_var:
dw ?
;===

View File

@ -47,11 +47,12 @@ draw_triangle:
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 @@ ret
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

View File

@ -291,10 +291,10 @@ flat_line_z:
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 @@ flat_line_z:
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 @@ flat_line_z:
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

View File

@ -78,14 +78,17 @@ gouraud_triangle:
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 @@ gouraud_line:
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 @@ end if
; 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]

View File

@ -514,7 +514,9 @@ gouraud_line_z:
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 @@ gouraud_line_z:
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 @@ gouraud_line_z:
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]

View File

@ -41,7 +41,15 @@ smooth_line:
.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 @@ end if
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 @@ end if
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 @@ end if
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 @@ end if
.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 @@ end if
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 @@ end if
@@:
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 @@ end if
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 @@ end if
@@:
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 @@ end if
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]

View File

@ -742,7 +742,7 @@ horizontal_tex_grd_line:
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 @@ end if
@@:
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 @@ end if
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

View File

@ -1,4 +1,8 @@
View3ds 0.065 - Feb 2015
1. Asc files support.
-----------------------------------------------------------------------------------
View3ds 0.064 - Nov 2012
1. Bug fixes.
-----------------------------------------------------------------------------------

View File

@ -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 @@ Buttons description:
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
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.
@ -33,4 +35,4 @@ Buttons description:
20. bright - -> decrease picture brightness.
21. wav effect -> do effect based sine function.
Maciej Guba Feb 2015
Maciej Guba X 2016

View File

@ -82,37 +82,37 @@ tex_triangle:
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 @@ textured_line:
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 @@ end if
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

View File

@ -95,22 +95,22 @@ tex_triangle_z:
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 @@ textured_line_z:
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 @@ end if
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 @@ end if
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

View File

@ -788,7 +788,7 @@ two_tex_line_z:
mov ecx,.y
or ecx,ecx
jl .bl_end
cmp ecx,SIZE_Y
cmp cx,word[size_y_var] ;SIZE_Y
jge .bl_end
cmp eax,ebx
@ -824,11 +824,12 @@ end if
xchg edx,.z2
mov .z1,edx
@@:
push eax ebx
; push ebx ;store x1, x2
cmp .x1,SIZE_X
jge .bl_end
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
@ -927,11 +928,21 @@ end if
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
; 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

View File

@ -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.
; 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,7 +17,7 @@
; 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
@ -53,6 +54,27 @@ use32
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
@ -493,8 +515,11 @@ still:
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 @@ else
movaps [esi],xmm1
add esi,16
sub ecx,16
jnz .oop
jnc .oop
end if
.no_inc_bright:
@ -548,9 +573,12 @@ end if
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 @@ else
movaps [esi],xmm1
add esi,16
sub ecx,16
jnz .oop1
jnc .oop1
end if
.no_dec_bright:
;======================================commmented====================
@ -680,18 +708,29 @@ end if
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 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,10 +765,12 @@ include "ASC.INC"
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
@ -778,7 +819,9 @@ update_flags:
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]
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 @@ update_flags:
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
@ -1603,11 +1649,15 @@ ret
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 @@ clrscr:
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
@ -2044,7 +2111,7 @@ draw_triangles:
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
@ -2572,10 +2639,32 @@ ret
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]
@ -2959,7 +3048,9 @@ 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 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 @@ buttons: ; draw some buttons (all but navigation and close )
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
@ -3013,11 +3107,11 @@ ret
; 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
@ -3029,7 +3123,9 @@ ret
; 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
@ -3040,14 +3136,18 @@ ret
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
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
@ -3058,14 +3158,18 @@ ret
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
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
@ -3077,14 +3181,18 @@ ret
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
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
@ -3095,14 +3203,18 @@ ret
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
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
@ -3113,14 +3225,18 @@ ret
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
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
@ -3131,14 +3247,18 @@ ret
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
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
@ -3157,5 +3277,5 @@ ret
; DATA AREA ************************************
include 'DATA.INC'
align 16
MEM_END: