From cf71f9e08ab8b7dfaef12be031c43af8be97e865 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Thu, 31 Jul 2025 14:15:13 +0200 Subject: [PATCH] player: Added special flag that indicates if a player is inside a covered area (e.g. inside a room) --- src/defs.s | 7 +++++++ src/player.s | 14 ++++++++++++++ src/wram.s | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/src/defs.s b/src/defs.s index ce51a5f..1bea292 100644 --- a/src/defs.s +++ b/src/defs.s @@ -64,6 +64,7 @@ ; when units want to draw .de DRAWF_SKIP_UNIT_OBJS, 1 + ; gameplay flags .se 1 @@ -82,6 +83,12 @@ ; so that objects are behind the tile .de CF_COVERED, 8 + ; player special flags + ; set if player is currently on a covered tile. + ; this can be used for drawing units that + ; are inside +.def int PLAYERSF_CF_COVERED = CF_COVERED + ; cells struct .se 0 .de c_tile, 1 diff --git a/src/player.s b/src/player.s index de93ec5..5a8e8c9 100644 --- a/src/player.s +++ b/src/player.s @@ -24,6 +24,20 @@ unit_player_update: or a, OAM_FXFLIP ld [hl], a pop de + + ; check if the player is currently + ; on a convered tile or not + push de + call unit_get_pos + call map_get_tile + ; a = tile flags + and a, CF_COVERED + ld b, a + ld a, [player_rt_special_flags] + and a, (~CF_COVERED) & 0xFF + or a, b + ld [player_rt_special_flags], a + pop de ; check for exit flags push de diff --git a/src/wram.s b/src/wram.s index cd7e7dd..795d53f 100644 --- a/src/wram.s +++ b/src/wram.s @@ -46,6 +46,9 @@ menu_cursor_index: .adv 1 draw_flags: .adv 1 gameplay_flags: .adv 1 + + ; special flags that are set by the player unit +player_rt_special_flags: .adv 1 ; shadow UI is a buffer for drawing the UI ; this UI is then re-drawn on request in vblank @@ -140,6 +143,7 @@ player_eq_amulet: .adv 2 player_unit: .adv 0 p0_units: .adv act_size * UNITS_MAX + ; list of seeds used ; for the current maps ; fill using mapgen_seed -- 2.30.2