Added dedicated memory space for animation target coordinates
authorLukas Krickl <lukas@krickl.dev>
Mon, 9 Dec 2024 12:08:30 +0000 (13:08 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 9 Dec 2024 12:08:30 +0000 (13:08 +0100)
src/actor.s
src/player.s
src/wram.s

index b8d9a59aa63e713a5273d018fdc716a43ed9cc69..80f55a89cadb5bd9666d16f0c713a9728f3485d3 100644 (file)
@@ -98,6 +98,20 @@ actor_right:
   ld [anim_move_y], a
   ret
 
+  ; verify actor animation
+  ; by checking for collision 
+  ; clear anim memory if check fails 
+  ; inputs: 
+  ;   bc: actor ptr
+actor_anim_verify:
+  inc bc ; bc = y/x 
+  ld a, [bc]
+  ; TODO implement
+
+  dec bc
+  ret
+
 ; function ptrs for each actor type 
 ; inputs:
 ;   bc: actor ptr
@@ -155,6 +169,9 @@ actor_update_bat:
   cp a, 3
   call z, actor_right
 
+  ; check anim collision
+  call actor_anim_verify
+
   turn_finish
 
 @skip:
index 2e53370a7487de30657ced4fd7d310e296a76124..8b826a0883cbb9823583ee85e6e4065e447e2a41 100644 (file)
@@ -104,15 +104,15 @@ player_update:
   ld a, RF_WALL 
   ld [ct_mask], a
   
-  ; tmp = y movement offset 
-  ; tmp+1 = x movement offset
+  ; anim_target_y = y movement target 
+  ; anim_target_x = x movement target
   ; load tmp and +1 with the current position by 
   ; default
   ld a, [hl+]
-  ld [tmp], a
+  ld [anim_target_y], a
   ld a, [hl]
   dec hl
-  ld [tmp+1], a
+  ld [anim_target_x], a
 
   ; input handling
   input_held BTNDOWN
@@ -127,7 +127,7 @@ player_update:
     ; set expected offset 
     ld a, ANIM_MOVE_TILE_SIZE
     add a, [hl]
-    ld [tmp], a
+    ld [anim_target_y], a
     
     call play_noise
     turn_finish
@@ -145,7 +145,7 @@ player_update:
     ; set expected offset 
     ld a, 0xFF - ANIM_MOVE_TILE_SIZE + 1
     add a, [hl]
-    ld [tmp], a
+    ld [anim_target_y], a
 
     call play_noise
     turn_finish
@@ -166,7 +166,7 @@ player_update:
     inc hl
     add a, [hl]
     dec hl
-    ld [tmp+1], a
+    ld [anim_target_x], a
     
     call play_noise
     turn_finish
@@ -186,7 +186,7 @@ player_update:
     inc hl
     add a, [hl]
     dec hl
-    ld [tmp+1], a
+    ld [anim_target_x], a
 
     call play_noise
     turn_finish
@@ -236,10 +236,10 @@ player_update:
   ; if any collision happens now 
   ; we stop the animation
   push hl ; need to save hl
-  ld a, [tmp
+  ld a, [anim_target_y
   add a, 8
   ld d, a ; d = target y + 8 to center on tile 
-  ld a, [tmp+1]
+  ld a, [anim_target_x]
   add a, 8
   ld e, a ; e = target x + 8 to center on tile 
   call collision_tile 
index dcfc52baea3946c0573d309d14a3be7e61813fdb..7ff1de70fff42f431378a5a1318051db8d6990b5 100644 (file)
@@ -178,6 +178,10 @@ anim_move_x: .adv 1
 anim_step_y: .adv 1
 anim_step_x: .adv 1
 
+; tmp storage for new animation position
+anim_target_y: .adv 1
+anim_target_x: .adv 1
+
   ; collision tile tmp values  
 ct_poy: .adv 1
 ct_pox: .adv 1