From 9198f4d4b1b671973fe6c03766e1dc085c087173 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Thu, 4 Jan 2024 22:30:40 +0100 Subject: [PATCH] Fix CheckOnWater while on a space tile (#34) [bugfix to aa91909388f46924f6c1e2721f70d451b80c2319] --- engine/overworld/map_setup.asm | 9 ++++----- home/map_objects.asm | 12 ++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/engine/overworld/map_setup.asm b/engine/overworld/map_setup.asm index 9e759d397..cc641b172 100644 --- a/engine/overworld/map_setup.asm +++ b/engine/overworld/map_setup.asm @@ -93,12 +93,11 @@ SkipUpdateMapSprites: ret CheckUpdatePlayerSprite: - nop - call .CheckBiking + call .CheckForcedBiking jr c, .ok call .CheckSurfing jr c, .ok - call .CheckSurfing2 + call .ResetSurfingOrBikingState jr c, .ok ret @@ -106,7 +105,7 @@ CheckUpdatePlayerSprite: call UpdatePlayerSprite ret -.CheckBiking: +.CheckForcedBiking: and a ld hl, wBikeFlags bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl] @@ -116,7 +115,7 @@ CheckUpdatePlayerSprite: scf ret -.CheckSurfing2: +.ResetSurfingOrBikingState: ld a, [wPlayerState] cp PLAYER_NORMAL jr z, .nope diff --git a/home/map_objects.asm b/home/map_objects.asm index 32ffbafba..10208dd11 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -78,13 +78,25 @@ GetPlayerTile:: ret CheckOnWater:: +; return z if on water, nz otherwise. +; if tile permission is SPACE_TILE, wPlayerState dictates whether player is on water or not. +; otherwise the current tile permission being LAND_TILE or WATER_TILE dictates it. ld a, [wPlayerTile] call GetTileCollision + cp SPACE_TILE + jr z, .check_player_state sub WATER_TILE ret z and a ret +.check_player_state + ld a, [wPlayerState] + cp PLAYER_SURF + ret z + cp PLAYER_SURF_PIKA + ret + GetTileCollision:: ; Get the collision type of tile a.