diff options
author | Aiden Gall <aiden@aidengall.xyz> | 2024-01-30 00:28:25 +0000 |
---|---|---|
committer | Aiden Gall <aiden@aidengall.xyz> | 2024-01-30 00:28:25 +0000 |
commit | adbd980a411487d7686d279bdfd53f52932b6126 (patch) | |
tree | 3a7f511b9ab53556bb8b086bf32d8a29883dce8e | |
parent | 5f83664e8a4891945512c9adb4d2f0743cbb3afc (diff) |
-rw-r--r-- | ball-sim.asm | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/ball-sim.asm b/ball-sim.asm index 769def2..567fbb7 100644 --- a/ball-sim.asm +++ b/ball-sim.asm @@ -99,20 +99,21 @@ no_click: movaps xmm3, xmm2 movaps xmm4, xmm0 - ; dirty, rotten, low-down, no-good hack - cmpnleps xmm2, xmm1 ; out of left/top bounds mask - cmpltps xmm0, xmm1 ; out of right/bottom bounds mask - orps xmm0, xmm2 ; or the masks - andps xmm0, [restitution_minus_one] ; mask & restitution coefficient minus one - addps xmm0, [ones] ; add ones to create bounce vector (0.0 -> 1.0, restitution - 1.0 -> restitution) + ; dirty, rotten, low-down, no-good hack (bitmasks on floats and weird constants) + cmpnleps xmm2, xmm1 + cmpltps xmm0, xmm1 + orps xmm0, xmm2 + andps xmm0, [restitution_coef] + addps xmm0, [air_resistance_coef] + + ; keep position in bounds maxps xmm1, xmm3 - minps xmm1, xmm4 ; keep position in bounds + minps xmm1, xmm4 ; scale velocity by bounce vector mulps xmm0, [ball.vel] - ; apply air resistance and gravity - mulps xmm0, [air_resistance_coef] + ; apply gravity addps xmm0, [grav_accel] ; store position @@ -136,7 +137,7 @@ move_and_draw: ; sphere movlps xmm0, [ball.pos] movss xmm1, [ball.rad] - mov rdi, 0xFF2C7500 ; green + mov edi, 0xFF2C7500 ; green call DrawCircleV call EndDrawing @@ -150,11 +151,10 @@ loop_entr: call _exit section '.data' writable align 16 - mouse_seek_speed splat 0.5 - minimum_radius splat 2.5 - air_resistance_coef splat 0.99 - restitution_minus_one splat -1.8 - ones splat 1.0 + mouse_seek_speed splat 0.5 + minimum_radius splat 2.5 + air_resistance_coef splat 0.99 + restitution_coef splat -1.782 ; -(restitution + 1) * air resistance grav_accel Vec2 0.0, 0.69 |