From 56ca39eb7ff87e7a9216c3c302566b2bf96a5264 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 19 Oct 2024 05:13:20 +0200 Subject: [PATCH] Adding collision tile mask --- src/collision.s | 11 +++++++++++ src/player.s | 6 +++++- src/wram.s | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/collision.s b/src/collision.s index 93192b8..c602dc5 100644 --- a/src/collision.s +++ b/src/collision.s @@ -37,6 +37,7 @@ collision_tile_lut: ; inputs: ; hl: ptr to y/x position ; de: collision point table + ; ct_mask: bit mask for flag to check ; returns: ; a = 0 -> no collision ; a = 1 -> collision @@ -96,6 +97,7 @@ collision_tile_table_check: ; inputs: ; d : y pos ; e : x pos + ; ct_mask: bit mask for flag to check (tile & mask) ; returns: ; a = 0 -> no collision ; a = 1 -> collision @@ -126,4 +128,13 @@ collision_tile: ld a, [hl] ; a = map flags row offset add a, e ; row + x = position of tile in map + ld d, 0 + ld e, a ; de = tile offset + ld hl, curr_room_flags ; hl = flags for currently loaded room + add hl, de ; hl + de + ld a, [hl] ; load flags + ld d, a + ld a, [ct_mask] + and a, d + ret diff --git a/src/player.s b/src/player.s index 30eb25f..16205c9 100644 --- a/src/player.s +++ b/src/player.s @@ -49,7 +49,11 @@ player_init: ; inputs: ; hl: pointer to player memory player_update: - ; update + ; update + + ; set collision mask + ld a, RF_WALL + ld [ct_mask], a ; d: player_y ; e: player_x diff --git a/src/wram.s b/src/wram.s index 9e7e8de..755b57f 100644 --- a/src/wram.s +++ b/src/wram.s @@ -125,3 +125,4 @@ game_mode: .adv 1 ; collision tile tmp values ct_poy: .adv 1 ct_pox: .adv 1 +ct_mask: .adv 1 -- 2.30.2