From 95430924a5a4a772f0f2949cb0d39ca45811f2d2 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 8 Oct 2024 06:43:51 +0200 Subject: [PATCH] wip: iframe timer --- src/player.s | 27 +++++++++++++++++++++++---- src/wram.s | 6 ++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/player.s b/src/player.s index f7d26c1..e5076ab 100644 --- a/src/player.s +++ b/src/player.s @@ -5,6 +5,7 @@ .def int PLAYER_TILE_IDLE2 = 0x1E .def int PLAYER_TILE_IDLE3 = 0x2E +#define PLAYER_IFRAME_TIMER 8 #define DAMAGE_ANIM_LEN 20 ; init the player @@ -109,8 +110,7 @@ player_update: ; make sure we do not mess with hl push hl ; hl = player_x right now - inc hl - inc hl ; hl = player_hp + dec hl ; hl = player_y == player_base call player_take_damage ; call for UI redraw ld a, UI_REDRAW_HP @@ -224,11 +224,30 @@ player_use_resource: ; same as use_resource but specifically ; also starts a damage animation + ; and iframes + ; inputs: + ; [hl]: pointer to player + ; a : the amount to subtract player_take_damage: - ld [tmp], a + ld [tmp], a ; tmp store a + + ; set damage anim timer ld a, DAMAGE_ANIM_LEN ld [damage_anim], a - ld a, [tmp] + + ; set iframe timer + ld a, PLAYER_IFRAME_TIMER + push hl + ld e, player_timer_i + ld d, 0 + add hl, de ; hl = timer_ia + ld [hl], a + pop hl + + ld e, player_hp + ld d, 0 + add hl, de + ld a, [tmp] ; a = tmp jp player_use_resource ; gains a resource such as diff --git a/src/wram.s b/src/wram.s index 76eae6d..8a9c8e1 100644 --- a/src/wram.s +++ b/src/wram.s @@ -51,6 +51,12 @@ actor_table: .adv ACTORS_MAX * actor_size .de player_atk, 1 .de player_atk_max, 1 + ; player timer: + ; differnt timers for the player + ; iframe (i) + ; layout: + ; iiiiiiii +.de player_timer_i, 1 .de player_size, 0 player: .adv player_size -- 2.30.2