From: Lukas Krickl Date: Mon, 9 Dec 2024 12:08:30 +0000 (+0100) Subject: Added dedicated memory space for animation target coordinates X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=c3c32abd3c7abafbfd187156f2f3db25c52ff5c4;p=gbrg%2F.git Added dedicated memory space for animation target coordinates --- diff --git a/src/actor.s b/src/actor.s index b8d9a59..80f55a8 100644 --- a/src/actor.s +++ b/src/actor.s @@ -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: diff --git a/src/player.s b/src/player.s index 2e53370..8b826a0 100644 --- a/src/player.s +++ b/src/player.s @@ -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 diff --git a/src/wram.s b/src/wram.s index dcfc52b..7ff1de7 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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