From 7ecea5fa5ccc94e33b47c48e8e3bb8948b5b0e29 Mon Sep 17 00:00:00 2001 From: blondie7575 Date: Tue, 22 Aug 2017 20:33:07 -0700 Subject: [PATCH] Basic projectile updating --- gamemanager.s | 5 +++- gscats.2mg | Bin 819264 -> 819264 bytes player.s | 2 +- projectile.s | 78 +++++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 76 insertions(+), 9 deletions(-) diff --git a/gamemanager.s b/gamemanager.s index 84bc932..7df3279 100644 --- a/gamemanager.s +++ b/gamemanager.s @@ -60,9 +60,12 @@ gameplayLoopAngle: gameplayLoopFire: lda fireRequested - beq gameplayLoopEndFrame + beq gameplayLoopProjectiles jsr fire +gameplayLoopProjectiles: + jsr updateProjectiles + gameplayLoopEndFrame: lda quitRequested diff --git a/gscats.2mg b/gscats.2mg index 6b39d0264d990d474070f7d1d9383994bb226c84..3e57b2c42ec411474dea5cfa9af302114c31209e 100644 GIT binary patch delta 459 zcmYL>&npCB7{}k)#ja)4BH2B?anxq*v}tyeUxjesFqBdg&jGdnfCF1gTwZLG+a6pt z4ZZ9doA#hAsa0<4AUBkY%NQq;^^8@X`n=!o^X>gU7xBi9{-kT@Bc&ZLop{PgV>j5~yXZFxIp>@-TyU^)#&ecoverVv!pa$-?X3TG1SM z4$ccRzuB)(&L(}!p9?CU;AseUa2;A>9GDKHf5Xzi4>3FjcK9Fe1F>tw9;4%Vw;>@~ c8=@s34#bI6A=O9?;zHa=E#f&7tvYGz2iu6gf&c&j delta 392 zcmX@mV056tXhRmO;IkM85oIGm28P2793TeMWJji>n;qE1>KHd|4sXfiW;C08u-_a= z{_J;TG}~-F!QGkBVsi84T*mgvA1@n=txDOsF0^+|%FYd;z3WnTZVK()kfN|@v(=Rj zUPi9ThaW1%8l`;TR0tHDW0a!sFI2%QWvxz%0kgu@r%K@?L8O;76P*;#!i%EsM=iccrM@M04CpN-cRkk jpBRCd35c12m<5PgftU@5*@2h?h&h3nYdh~JZsR@x!>pN4 diff --git a/player.s b/player.s index 52d255d..01abbb5 100644 --- a/player.s +++ b/player.s @@ -11,7 +11,7 @@ playerData: .word 40 ; X pos in pixels (from left terrain edge) .word 38 ; Y pos in pixels (from bottom terrain edge) - .word 90+45 ; Angle in degrees from +X + .word 45 ; Angle in degrees from +X .word 50 ; Power PD_POSX = 0 ; Byte offsets into player data structure diff --git a/projectile.s b/projectile.s index 5cd96bd..c6be334 100644 --- a/projectile.s +++ b/projectile.s @@ -8,13 +8,20 @@ projectileData: ; gameobject data - .word 40 ; X pos in pixels (from left terrain edge) - .word 38 ; Y pos in pixels (from bottom terrain edge) + .word -1 ; Pos X in pixels (from left terrain edge) + .word 0 ; Pos Y in pixels (from bottom terrain edge) + .word 0 ; Pos X (8.8 fixed point) + .word 0 ; Pos Y (8.8 fixed point) .word 0 ; Velocity X (8.8 fixed point) .word 0 ; Velocity Y (8.8 fixed point) -JD_V = 4 ; Byte offsets into projectile data structure +JD_POSX = 0 ; Byte offsets into projectile data structure +JD_POSY = 2 +JD_PRECISEX = 4 +JD_PRECISEY = 6 +JD_VX = 8 +JD_VY = 10 projectileParams: @@ -46,6 +53,18 @@ fireProjectile: iny iny + lda projectileParams ; Fixed point version of X pos + xba + sta (SCRATCHL),y + iny + iny + + lda projectileParams+2 ; Fixed point version of Y pos + xba + sta (SCRATCHL),y + iny + iny + lda projectileParams+4 ; Convert angle to vector asl tax @@ -61,9 +80,54 @@ fireProjectile: lda angleToVectorY,x ; Velocity Y sta (SCRATCHL),y - brk -fireProjectileLoop: - - + RESTORE_AXY + rts + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; updateProjectiles +; +; Trashes SCRATCHL +; +updateProjectiles: + SAVE_AXY + lda projectileData+JD_POSX + bmi updateProjectilesDone + + ; Integrate X velocity over position + lda projectileData+JD_PRECISEX + clc + adc projectileData+JD_VX + sta projectileData+JD_PRECISEX + + ; Convert to integral for rendering + lsr + lsr + lsr + lsr + lsr + lsr + lsr + lsr + sta projectileData+JD_POSX + + ; Integrate Y velocity over position + lda projectileData+JD_PRECISEY + clc + adc projectileData+JD_VY + sta projectileData+JD_PRECISEY + + ; Convert to integral for rendering + lsr + lsr + lsr + lsr + lsr + lsr + lsr + lsr + sta projectileData+JD_POSY +brk +updateProjectilesDone: RESTORE_AXY rts