So, I am trying my luck with sdl2. A llittle cube defined by 8 points and the lines between it... Moving works, but the rotating stuff isn't working, it calculates wrong values.
Because of the sinus and cosinus, I had to go with sse2, but something seems to be wrong.
I have my data like this :
section .data
xs dq 0,0,0,0,0,0,0,0,0,0,0,0
ys dq 0,0,0,0,0,0,0,0,0,0,0,0
points resq 24
tempx dq 0
tempy dq 0
tempz dq 0
; reminder 960 x 720 window, haelfte 480 / 360
point dq -100, -100, 300,
dq 100, -100, 300,
dq -100, 100, 300,
dq 100, 100, 300,
dq -100, -100, 500,
dq 100, -100, 500,
dq -100, 100, 500,
dq 100, 100, 500
yaussen dq 700 ; war erst 900 und 400
yscreen dq 100 ; reminder 960 x 720 window, haelfte 480 / 360
cos1 dq 0.9998477 ; 0.9998477*x - 0.0174524*z;
sin1 dq 0.0174524
...the point-table will be written to the points-array. Works, shifting to left, right, up, down, and in the depth worksall, but than comes a try of rotation ...
roty1:
push rcx
push r15
mov rcx, 0
nochmal8: ; tempx:= 0.9998477*x - 0.0174524*z
movsd xmm0, qword [points+rcx*8] ; load x coordinate in xmm0
movsd xmm1, qword [cos1] ; load cos 1 from table in xmm1
mulsd xmm0, xmm1 ; multiply xmm0 and xmm1, store in xmm0
movsd xmm2, qword [points+rcx*8+16] ; load z coordinate in xmm2
movsd xmm3, qword [sin1] ; load sin 1 from table in xmm3
mulsd xmm2, xmm3 ; multiply xmm2 and xmm3, store in xmm2
subsd xmm0, xmm2 ; subtract xmm2 from xmm0, store in xmm0
mov r15, 0
cvtsd2si r15, xmm0 ; convert xmm0 to integer and store in r15
mov qword [tempx], r15 ; store tempx
; tempz:= 0.0174524*x + 0.9998477*z
movsd xmm0, qword [points+rcx*8] ; load x coordinate in xmm0
movsd xmm1, qword [sin1] ; load sin 1 from table
mulsd xmm0, xmm1 ; multiply and store in xmm0
movsd xmm2, qword [points+rcx*8+16] ; load z coordinate
movsd xmm3, qword [cos1] ; load cos 1 from table
mulsd xmm2, xmm3 ; multiply and store in xmm2
addsd xmm0, xmm2 ; add xmm0 and xmm2, store in xmm0
mov r15, 0
cvtsd2si r15, xmm0 ; convet xmm0 to integer and store in r15
mov qword [tempz], r15 ; store tempz
mov r15, 0
mov r15, [tempx]
mov [points+rcx*8], r15 ; write the new x coordinate to table
mov r15, 0
mov r15, [tempz]
mov [points+rcx*8+16], r15 ; same for z coordinate
inc rcx
inc rcx
inc rcx
cmp rcx, 24 ; eight point in the cube, each with three coordinates...
jne nochmal8
pop r15
pop rcx
ret
Rotation by y.
If I let calculate the stuff in Excel, I have good valuaes, but the conversion in Assembly-Code does not get me the right values.
Does anybody see obvious failures in the code?
Thanks in advance, Andy from the nightly sleeping Germany