Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1978 → Rev 1979

/programs/demos/3DS/data.inc
File deleted
\ No newline at end of file
/programs/demos/3DS/BUMP_CAT.INC
805,7 → 805,7
mov ebx,.x2
sub ebx,.x1
 
if Ext >= SSE
if 0 ;Ext >= SSE
 
sub esp,16
cvtsi2ss xmm3,ebx ;rcps
913,30 → 913,16
 
push .z1 ; current z shl CATMULL_SHIFT
push esi
; It's my first attempt at MMX :), have mercy - Macgub
;if Ext = SSE2
; movups xmm1,.dey
;end if
if Ext>=MMX
movq mm0,.cby
movq mm1,.cey
movq mm2,.dby
movq mm3,.dey
end if
 
;; if Ext = MMX
; mov dword[.temp1],esi
; mov dword[.temp1+4],esi
;; movq mm0,.cbyq ; mm0 - current bump coords
;; movq mm1,.ceyq ; mm1 - current env coords
;; movq mm2,.dbyq ; mm2 - delta bump
;; movq mm3,.deyq ; mm3 - delta env
; movd mm6,.z1 ; mm6 - cur z
; movq mm7,qword.[temp1] ; mm7 = lo = hi dword = current z buff
;; mov dword [.temp2],1
;; mov dword [.temp2+4],-1
;; mov dword [.temp3],TEXTURE_SIZE
;; mov dword [.temp3+4],TEXTURE_SIZE
;; mov esi,.bmap
;; mov dword [.temp4],esi
;; mov dword [.temp4+4],esi
;; mov dword [.temp5],TEX_X
;; mov dword [.temp5+4],- TEX_X
; mov dword [.temp1],TEX_SHIFT
; mov dword [.temp1+4],0
;; end if
 
.draw:
; if TEX = SHIFTING ;bump drawing only in shifting mode
mov esi,.czbuff ; .czbuff current address in buffer
943,29 → 929,22
mov ebx,.cz ; .cz - cur z position
cmp ebx,dword[esi]
jge .skip
;; if Ext=NON
 
if Ext>=MMX
movq mm6,mm0
psrld mm6,ROUND
movd eax,mm6
psrlq mm6,32
movd esi,mm6
else
mov eax,.cby
sar eax,ROUND
mov esi,.cbx
sar esi,ROUND
;; else
;; movq mm4,mm0 ; mm4 - copies of cur bump coords
;; psrad mm4,ROUND ; mm4 = lo dword = y b coord, hi dword = x b coord
;; movd eax,mm4 ; -
;; psrlq mm4,32 ; -
;; movd esi,mm4 ; -
;;
;;; punpckldq mm5,mm4 ;
;;; psllq mm5,TEX_SHIFT
;;; paddq mm4,mm5 ; mm4 - lo dword index to b. map
;;
;; ; packqd mm4,mm5
; movq mm5,mm4 ; mm5 ~~ current bump map index?
 
;; end if
end if
shl eax,TEX_SHIFT ;-
add esi,eax ;- ; esi - current bump map index
;; if Ext = NON
 
mov ebx,esi
dec ebx
and ebx,TEXTURE_SIZE
977,21 → 956,9
and ebx,TEXTURE_SIZE
add ebx,.bmap
movzx ebx,byte [ebx]
;; else ;-------------------------------------------
;; mov dword [.temp1],esi ;-
;; mov dword [.temp1+4],esi ;-
;; movq mm5, qword[.temp1] ;-
;; paddd mm5, qword[.temp2] ; .temp2 == low dword = 1, high dword = -1
;; pand mm5, qword[.temp3] ; .temp3 == low = high dword = TEX_SIZE
;; paddd mm5, qword[.temp4] ; .temp4 == low = high dword = .bmap
;; movd ebx,mm5
;; psrlq mm5,32
;; movd eax,mm5
;; movzx ebx,byte[ebx]
;; movzx eax,byte[eax]
;; end if
 
sub eax,ebx
;; if Ext=NON
 
mov ebx,esi
sub ebx,TEX_X
and ebx,TEXTURE_SIZE
1003,21 → 970,11
and ebx,TEXTURE_SIZE
add ebx,.bmap
movzx ebx,byte [ebx]
;; else
;; movq mm5, qword[.temp1] ;-
;; paddd mm5, qword[.temp5] ; .temp5 == low dword = TEX_X, high dword = -TEX_X
;; pand mm5, qword[.temp3] ; .temp3 == low = high dword = TEX_SIZE
;; paddd mm5, qword[.temp4] ; .temp4 == low = high dword = offset .bmap
;; movd ebx,mm5
;; psrlq mm5,32
;; movd edx,mm5
;; movzx ebx,byte[ebx]
;; movzx edx,byte[edx]
;; end if
 
sub edx,ebx
; eax - horizontal sub
; edx - vertical sub
;; if Ext=NON
if Ext = NON
mov ebx,.cex ;.cex - current env map X
sar ebx,ROUND
add eax,ebx ; eax - modified x coord
1025,19 → 982,15
mov ebx,.cey ;.cey - current env map y
sar ebx,ROUND
add edx,ebx ; edx - modified y coord
;; else
;; movq mm5,mm1 ; mm5 - copy of cur env coords
;; psrad mm5,ROUND
;; movq qword[.temp1],mm5
;; add eax,dword [.temp1]
;; add edx,dword [.temp1+4]
;; ; movd ebx,mm5
;; ; add eax,ebx
;; ; psrlq mm5,32
;; ; movd ebx,mm5
; add edx,ebx
;; end if
 
else
movq mm6,mm1 ; mm5 - copy of cur env coords
psrld mm6,ROUND
movd ebx,mm6
psrlq mm6,32
add eax,ebx
movd ebx,mm6
add edx,ebx
end if
or eax,eax
jl .black
cmp eax,TEX_X
1049,9 → 1002,9
 
shl edx,TEX_SHIFT
add edx,eax
lea edx,[edx*3]
add edx,.emap
mov eax,dword[edx]
lea esi,[edx*3]
add esi,.emap
lodsd
jmp .put_pixel
.black:
xor eax,eax
1066,15 → 1019,19
add edi,3
.no_skip:
add .czbuff,4
;; if Ext = NON
 
;if Ext = SSE2
; movups xmm0,.cey
; paddd xmm0,xmm1
; movups .cey,xmm0
;
;end if
if Ext >= MMX
movq mm0,.cby
movq mm1,.cey
paddd mm0,.dby
paddd mm1,.dey
movq .cby,mm0
movq .cey,mm1
else
paddd mm0,mm2
paddd mm1,mm3
end if
 
if Ext=NON
mov eax,.dbx
add .cbx,eax
mov eax,.dby
1084,10 → 1041,6
mov eax,.dey
add .cey,eax
end if
;; else
;; paddd mm0,mm2
;; paddd mm1,mm3
;; end if
mov eax,.dz
add .cz,eax
 
/programs/demos/3DS/BUMP_TEX.INC
1593,6 → 1593,19
push dword .tx1 ; .ctx
push dword .ty1 ; .cty
push edi ; .c_scr
;if Ext = SSE2
; mov eax,TEXTURE_SIZE
; movd xmm1,eax
; shufps xmm1,xmm1,0
; push dword TEX_X
; push dword -TEX_X
; push dword 1
; push dword -1
; movups xmm2,[esp]
; movd xmm3,.bmap
; shufps xmm3,xmm3,0
;end if
 
if Ext>=MMX
movq mm7,.cty
movq mm6,.cby
1620,10 → 1633,35
movd esi,mm1
end if
 
 
shl eax,TEX_SHIFT
add esi,eax ;- ; esi - current bump map index
 
;if Ext = SSE2
;
; movd xmm0,esi
; shufps xmm0,xmm0,0
; paddd xmm0,xmm2
; pand xmm0,xmm1
; paddd xmm0,xmm3
;
; movd ebx,xmm0
; movzx eax,byte[ebx]
;
; shufps xmm0,xmm0,11100001b
; movd ebx,xmm0
; movzx ebx,byte[ebx]
; sub eax,ebx
;
; shufps xmm0,xmm0,11111110b
; movd ebx,xmm0
; movzx edx, byte [ebx]
;
; shufps xmm0,xmm0,11111111b
; movd ebx,xmm0
; movzx ebx, byte [ebx]
; sub edx,ebx
;
;else
mov ebx,esi
dec ebx
and ebx,TEXTURE_SIZE
1649,8 → 1687,8
add ebx,.bmap
movzx ebx,byte [ebx]
sub edx,ebx
;end if
 
 
; eax - horizontal sub modificated x coord
; edx - vertical sub modificated y coord
if Ext=NON
/programs/demos/3DS/B_PROCS.INC
739,10 → 739,96
;in - ecx times count
;.counter equ dword[esp-4]
.counter1 equ dword[esp-8]
if Ext>=MMX
if Ext>=SSE2
push ebp
mov ebp,esp
push dword 0x01010101
movss xmm5,[esp]
shufps xmm5,xmm5,0
.again_blur:
push ecx
mov edi,screen
mov ecx,SIZE_X*3/4
xor eax,eax
rep stosd
 
mov ecx,(SIZE_X*(SIZE_Y-3))*3/16
.blr:
@@:
movups xmm0,[edi+SIZE_X*3]
movups xmm1,[edi-SIZE_X*3]
movups xmm2,[edi-3]
movups xmm3,[edi+3]
 
pavgb xmm0,xmm1
pavgb xmm2,xmm3
pavgb xmm0,xmm2
 
psubusb xmm0,xmm5 ; importand if fire
 
movups [edi],xmm0
add edi,16
add esi,16
 
loop .blr
 
xor eax,eax
mov ecx,SIZE_X*3/4
rep stosd
pop ecx
loop .again_blur
mov esp,ebp
pop ebp
end if
 
if Ext=SSE
emms
push ebp
mov ebp,esp
push dword 0x01010101
push dword 0x01010101
movq mm4,[esp]
.again_blur:
push ecx
mov edi,screen
mov ecx,SIZE_X*3/4
; pxor mm5,mm5
xor eax,eax
rep stosd
 
mov ecx,(SIZE_X*(SIZE_Y-3))*3/8
.blr:
@@:
movq mm0,[edi+SIZE_X*3]
movq mm1,[edi-SIZE_X*3]
movq mm2,[edi-3]
movq mm3,[edi+3]
 
pavgb mm0,mm1
pavgb mm2,mm3
pavgb mm0,mm2
 
psubusb mm0,mm4 ; importand if fire
 
movq [edi],mm0
add edi,8
add esi,8
 
loop .blr
 
xor eax,eax
mov ecx,SIZE_X*3/4
rep stosd
pop ecx
loop .again_blur
mov esp,ebp
pop ebp
end if
 
if Ext=MMX
emms
push ebp
mov ebp,esp
push dword 0x0
push dword 0x01010101
.again_blur:
/programs/demos/3DS/DATA.INC
0,0 → 1,477
; DATA AREA ************************************
 
i3 dw 3
i256 dw 256
i255d dd 255
dot_max dd 1.0 ; dot product max and min
dot_min dd 0.0
env_const dd 1.05
correct_tex dw 255
tex_x_div2 dw TEX_X / 2
tex_y_div2 dw TEX_Y / 2
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
 
re_alloc_flag db 0
angle_counter dw 0
piD180 dd 0.017453292519943295769236907684886
piD128 dd 0.024544
const6 dw 6,6,6,6
x_offset dw SIZE_X / 2
y_offset dw SIZE_Y / 2
z_offset dw 0
rsscale dd 175.0 ; next real scale
vect_x dw SIZE_X / 2
vect_y dw SIZE_Y / 2
vect_z dw 0
angle_x dw 0
angle_y dw 0
angle_z dw 0
 
 
menu:
db 2 ; button number = index
db 'rotary ' ; label
db 3 ; max flag + 1 , if = 255, no flag
r_flag db 1 ; flag
dd axl_f ; offset to flags description
 
db 3
db 'shd. model'
db 11
dr_flag db 0
dd shd_f
 
db 4
db 'speed '
db 2
speed_flag db 0
dd spd_f
 
db 5
db 'zoom out '
db 255
db ?
dd ?
 
db 6
db 'zoom in '
db 255
db ?
dd ?
 
db 7
db 'catmull '
db 2
catmull_flag db 1
dd onoff_f
 
db 8
db 'culling '
db 2
culling_flag db 1
dd onoff_f
 
db 9
db 'rand.light'
db 255
db ?
dd ?
 
db 10
db 'blur '
db 6
blur_flag db 0
dd blur_f
 
db 11
db 'mirror x '
db 2
mirr_x_flag db 0
dd onoff_f
 
db 12
db 'mirror y '
db 2
mirr_y_flag db 0
dd onoff_f
 
db 13
db 'mirror z '
db 2
mirr_z_flag db 0
dd onoff_f
 
db 14
db 'xchg '
db 4
xchg_flag db 0
dd xchg_f
 
db 15
db 'emboss '
db 2
emboss_flag db 0
dd onoff_f
 
db 16
db 'fire '
db 3
fire_flag db 0
dd blur_f
 
db 17
db 'move '
db 2
move_flag db 0
dd move_f
 
db 18
db 'generate '
db 6
generator_flag db 0
dd blur_f
 
db 19
db 'bumps '
db 2
bumps_flag db 0
dd bumps_f
 
db 20
db 'bumps deep'
db 4
bumps_deep_flag db 3
dd bumps_d_f
 
db 21
db 're-map tex'
db 255
map_tex_flag db ? ;1
dd ? ;bumps_d_f
; db 21
; db 'light No. '
; db 3
;light_no_flag db 0
; dd bumps_d_f
 
; db 22
; db 'light comp'
; db 3
;light_comp_flag db 0
; dd light_component_f
 
;; db 23
;; db 'col. comp'
;; db 3
;;color_comp_flag db 0
;; dd color_component_f
 
 
db -1 ; end mark
 
 
flags: ; flags description
shd_f:
db 'flat'
db 'grd '
db 'env '
db 'bump'
db 'tex '
db 'pos '
db 'dots'
db 'txgr'
db '2tex'
db 'btex'
db 'cenv'
spd_f:
db 'idle'
db 'full'
axl_f:
db ' y '
db 'x+y '
db ' x '
onoff_f:
db 'off '
db 'on '
; light_component_f:
; db 'norm ' ; diffuse |
; db 'min' ; specular | or sth. like this
; db 'max ' ; emmisive |
 
;; color_component_f:
;; db ' r '
;; db ' g '
;; db ' b '
 
blur_f: ; blur, fire
db 'off '
bumps_d_f: db ' 1 '
db ' 2 '
db ' 3 '
db ' 4 '
db ' 5 '
 
xchg_f:
db 'no '
db 'x<>y'
db 'z<>x'
db 'y<>z'
move_f:
db 'obj '
db 'camr'
; db 'lght'
bumps_f:
db 'rand'
db 'tex '
; db 'cscl'
base_vector:
labelvector:
db 'add vector'
labelvectorend:
labelyminus:
db 'y -'
labelyminusend:
labelzplus:
db 'z +'
labelzplusend:
labelxminus:
db 'x -'
labelxminusend:
labelxplus:
db 'x +'
labelxplusend:
labelzminus:
db 'z -'
labelzminusend:
labelyplus:
db 'y +'
labelyplusend:
 
;navigation_size = $ - labelvector
; db 'set color '
; db 'r -'
; db 'g +'
; db 'b -'
; db 'b +'
; db 'g -'
; db 'r +'
 
labelt:
db 'DEUS CARITAS EST'
if Ext=MMX
db ' (MMX)'
end if
if Ext=SSE
db ' (SSE)'
end if
if Ext=SSE2
db ' (SSE2)'
end if
db ' 0.059'
labellen:
STRdata db '-1 '
 
all_lights_size dw lightsend-lights
 
if USE_LFN
 
file_info:
dd 0
dd 0
dd 0
fsize dd 0 ;180000 ; sizeof(workarea)
fptr dd 0 ;workarea
file_name:
db '/rd/1/3d/house.3ds',0
 
else
 
file_info:
dd 0
dd 0
fsize dd 1
dd workarea
dd hash_table
file_name:
db '/rd/1/teapot.3ds',0
end if
 
I_END:
 
rb 256
 
;=============================================
lights:
.light_vector dd 0.0,0.0,-1.0 ; x,y,z Z cooficient of vector must be negative
.orginal_color_r db 1 ; +12
.orginal_color_g db 255 ;
.orginal_color_b db 1 ; +14
.min_color_r db 1 ;
.min_color_g db 1 ; +16
.min_color_b db 1 ;
.max_color_r db 255 ;
.max_color_g db 255 ;
.max_color_b db 255 ;
.shine db 24 ; +21
; LIGHT_SIZE equ ($-lights)
 
dd -0.5,-0.5,-1.0 ; x,y,z ; .light_vector
db 5 ; .orginal_color_r
db 1 ; .orginal_color_g
db 135 ; .orginal_color_b
db 19 ; .min_color_r
db 19 ; .min_color_g
db 19 ; .min_color_b
db 255 ; .max_color_r
db 255 ; .max_color_g
db 255 ; .max_color_b
db 16 ; .shine
 
dd 0.5,0.5,-1.0 ; x,y,z ; .light_vector
db 135 ; .orginal_color_r
db 1 ; .orginal_color_g
db 1 ; .orginal_color_b
db 19 ; .min_color_r
db 19 ; .min_color_g
db 19 ; .min_color_b
db 255 ; .max_color_r
db 255 ; .max_color_g
db 20 ; .max_color_b
db 16 ; .shine
; ALL_LIGHTS_SIZE equ ($ - lights)
;#all_lights_size dw ($ - lights) ;ALL_LIGHTS_SIZE
;===============================================
 
lightsend:
 
if USE_LFN = 0
hash_table rb 4096
SourceFile:
workarea rb 180000
else
SourceFile:
workarea rb 180
end if
EndFile dd ?
align 8
sinbeta dd ?;+32
cosbeta dd ?
 
xsub dw ?
zsub dw ?;+40
ysub dw ?
 
xx1 dw ?
yy1 dw ?
zz1 dw ?;+48 xx1 + 4
xx2 dw ?
yy2 dw ?
zz2 dw ? ; xx1 + 10
xx3 dw ?;+56
yy3 dw ?
zz3 dw ? ; xx1 + 16
scale dd ? ; help scale variable
;==
triangles_count_var dw ?
points_count_var dw ?
triangles_ptr dd ?
triangles_w_z_ptr dd ?
triangles_normals_ptr dd ?
points_normals_ptr dd ?
points_normals_rot_ptr dd ?
points_ptr dd ?
points_rotated_ptr dd ?
points_translated_ptr dd ?
screen_ptr dd ?
Zbuffer_ptr dd ?
 
;===
 
point_index1 dw ? ;-\
point_index2 dw ? ; } don't change order
point_index3 dw ? ;-/
temp_col dw ?
high dd ?
rand_seed dw ?
align 8
buffer dq ?
errr dd ?
drr dd ?
xx dd ?
yy dd ?
xst dd ?
yst dd ?
; screen_ptr dd ?
; Zbuffer_ptr dd ?
 
matrix rb 36
cos_tab rd 360
sin_tab rd 360
 
align 16
 
if USE_LFN = 0
points:
rw (EndFile-SourceFile)/12*3
points_count = ($-points)/6
triangles:
rw (EndFile-SourceFile)/12*3
triangles_count = ($-triangles)/6
align 16
real_points rd points_count*3 + 1
align 16
rotated_points_r rd points_count*3 + 1
align 16
points_rotated rw points_count*3 + 2 ;means translated
align 16
triangles_normals rb triangles_count * 12 ;
align 16
point_normals rb points_count * 12 ;one 3dvector - triple float dword x,y,z
align 16
point_normals_rotated rb points_count * 12
align 16
triangles_normals_rotated rb triangles_count * 12
 
else
points_count = 180000/6*3
triangles_count = 180000 / 6 ;($-triangles)/6
end if
align 16
label trizdd dword
label trizdq qword
triangles_with_z rw triangles_count*4 + 2 ; triangles triple dw + z position
align 16
vectors rb 24
;align 16
; points_color rb 6*points_count ; each color as word
; sorted_triangles rw triangles_count*3 + 2
align 16
bumpmap rb TEXTURE_SIZE + 1
align 16
bumpmap2 rb TEXTURE_SIZE + 1
align 16
envmap rb (TEXTURE_SIZE +1) * 3
align 16
envmap_cub rb TEX_X * 3
align 16
texmap rb (TEXTURE_SIZE +1) * 3
align 16
color_map rb (TEXTURE_SIZE +1) * 3
align 16
tex_points rb points_count * 4 ; bump_map and texture coords
; each point word x, word y
align 16
; SourceFile: ; source file temporally in screen area
; workarea dd ?
 
; screen rb SIZE_X * SIZE_Y * 3 ; screen buffer
;align 16
; Z_buffer rb SIZE_X * SIZE_Y * 4
I_Param rb 256
memStack rb 4000 ;memory area for stack
align 16
screen:
/programs/demos/3DS/History.txt
1,3 → 1,14
View3ds 0.059 - June 2011.
1. Bump and pararell two texture mapping functions optimizations.
(files bump_cat.inc & two_tex.inc)
On my P4 changes are rather non visable, but on dual core in KlbrInWin
optimizations runs preety nice.
-----------------------------------------------------------------------------------
 
View3ds 0.058 - June 2011.
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
/programs/demos/3DS/TWO_TEX.INC
990,10 → 990,10
 
 
else
movq mm5,.cey
movq mm5,mm4 ;.cey
psrad mm5,ROUND
pslld mm5,TEX_SHIFT
movq mm6,.cex
movq mm6,mm3 ;.cex
psrad mm6,ROUND
paddd mm5,mm6
movq mm6,mm5
1061,8 → 1061,8
; movq mm6,mm4
; psrad mm5,ROUND
; psrad mm6,ROUND
movq .cex,mm3
movq .cey,mm4
; movq .cex,mm3
; movq .cey,mm4
end if
mov eax,.dz
add .cz,eax
/programs/demos/3DS/VIEW3DS.ASM
1,5 → 1,5
 
; application : View3ds ver. 0.057 - tiny .3ds files viewer.
; application : View3ds ver. 0.059 - tiny .3ds files viewer.
; compiler : FASM
; system : KolibriOS
; author : Macgub aka Maciej Guba
34,7 → 34,8
NON = 0 ; -/ \-
MMX = 1
SSE = 2
Ext = MMX ;Ext={ NON | MMX | SSE}
SSE2 = 3
Ext = MMX ;Ext={ NON | MMX | SSE | SSE2 }
 
; 0 for short names (Menuet-compatible), 1 for long names (Kolibri features)
USE_LFN = 1
2796,6 → 2797,6
 
; DATA AREA ************************************
 
include 'data.inc'
include 'DATA.INC'
 
MEM_END:
/programs/demos/3DS/readme.txt
1,9 → 1,12
View3ds 0.057 - tiny viewer to .3ds files.
View3ds 0.059 - tiny viewer to .3ds files.
 
What's new?
1. By opening file bigger then ~18 KB, and choosing env mode program terminate.
I remove this bug
1. Bump and pararell two texture mapping functions optimizations.
(files bump_cat.inc & two_tex.inc)
On my P4 changes are rather non visable, but on dual core in KlbrInWin
optimizations runs preety nice.
 
 
Buttons description:
1. rotary: choosing rotary axle: x, y, x+y.
2. shd. model: choosing shading model: flat, grd (smooth), env (spherical
30,4 → 33,4
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.
 
Macgub April 2011
Macgub Jun 2011