Skip to content

Commit

Permalink
Fix inaccurate denotations to the concepts of tile, tile collision, a…
Browse files Browse the repository at this point in the history
…nd collision permission (#1078)
  • Loading branch information
xCrystal committed Jan 7, 2024
1 parent 7f3b879 commit e0c278a
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 76 deletions.
2 changes: 1 addition & 1 deletion constants/collision_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DEF WALL_TILE EQU $0f
DEF TALK EQU $10

; collision data types (see data/tilesets/*_collision.asm)
; TileCollisionTable indexes (see data/collision/collision_permissions.asm)
; CollisionPermissionTable indexes (see data/collision/collision_permissions.asm)
DEF COLL_FLOOR EQU $00
DEF COLL_01 EQU $01 ; garbage
DEF COLL_03 EQU $03 ; garbage
Expand Down
2 changes: 1 addition & 1 deletion constants/map_object_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DEF OBJECT_STEP_DURATION rb ; 0a
DEF OBJECT_ACTION rb ; 0b
DEF OBJECT_STEP_FRAME rb ; 0c
DEF OBJECT_FACING rb ; 0d
DEF OBJECT_TILE rb ; 0e
DEF OBJECT_TILE_COLLISION rb ; 0e
DEF OBJECT_LAST_TILE rb ; 0f
DEF OBJECT_MAP_X rb ; 10
DEF OBJECT_MAP_Y rb ; 11
Expand Down
4 changes: 2 additions & 2 deletions data/collision/collision_permissions.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TileCollisionTable::
CollisionPermissionTable::
; entries correspond to COLL_* constants
table_width 1, TileCollisionTable
table_width 1, CollisionPermissionTable
db LAND_TILE ; COLL_FLOOR
db LAND_TILE ; COLL_01
db LAND_TILE ; 02
Expand Down
4 changes: 2 additions & 2 deletions docs/bugs_and_glitches.md
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ This bug is why the Lapras in [maps/UnionCaveB2F.asm](https://github.com/pret/po
cp PLAYER_SURF_PIKA
jr z, .fail
call GetFacingTileCoord
call GetTileCollision
call GetTilePermission
cp WATER_TILE
- jr z, .facingwater
+ jr nz, .fail
Expand Down Expand Up @@ -2144,7 +2144,7 @@ If `[wWalkingDirection]` is `STANDING` (`$FF`), this will check `[.EdgeWarps + $
ld d, 0
ld hl, .EdgeWarps
add hl, de
ld a, [wPlayerTile]
ld a, [wPlayerTileCollision]
cp [hl]
jr nz, .not_warp

Expand Down
10 changes: 5 additions & 5 deletions engine/events/overworld.asm
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ SurfFunction:
cp PLAYER_SURF_PIKA
jr z, .alreadyfail
call GetFacingTileCoord
call GetTileCollision
call GetTilePermission
cp WATER_TILE
jr nz, .cannotsurf
call CheckDirection
Expand Down Expand Up @@ -494,7 +494,7 @@ TrySurfOW::

; Must be facing water.
ld a, [wFacingTileID]
call GetTileCollision
call GetTilePermission
cp WATER_TILE
jr nz, .quit

Expand Down Expand Up @@ -686,7 +686,7 @@ Script_UsedWaterfall:
.CheckContinueWaterfall:
xor a
ld [wScriptVar], a
ld a, [wPlayerTile]
ld a, [wPlayerTileCollision]
call CheckWaterfallTile
ret z
farcall StubbedTrainerRankings_Waterfall
Expand Down Expand Up @@ -1449,7 +1449,7 @@ FishFunction:
cp PLAYER_SURF_PIKA
jr z, .fail
call GetFacingTileCoord
call GetTileCollision
call GetTilePermission
cp WATER_TILE
jr z, .facingwater
.fail
Expand Down Expand Up @@ -1693,7 +1693,7 @@ BikeFunction:
jr .nope

.ok
call GetPlayerTile
call GetPlayerTilePermission
and $f ; lo nybble only
jr nz, .nope ; not FLOOR_TILE
xor a
Expand Down
2 changes: 1 addition & 1 deletion engine/overworld/cmd_queue.asm
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ CmdQueue_StoneTable:
cp SPRITEMOVEDATA_STRENGTH_BOULDER
jr nz, .next

ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, de
ld a, [hl]
call CheckPitTile
Expand Down
6 changes: 3 additions & 3 deletions engine/overworld/events.asm
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ CheckTileEvent:
ret

.warp_tile
ld a, [wPlayerTile]
ld a, [wPlayerTileCollision]
call CheckPitTile
jr nz, .not_pit
ld a, PLAYEREVENT_FALL
Expand Down Expand Up @@ -1186,7 +1186,7 @@ CanEncounterWildMonInThisTile::
jr nc, .no

.ice_check
ld a, [wPlayerTile]
ld a, [wPlayerTileCollision]
call CheckIceTile
jr z, .no
scf
Expand Down Expand Up @@ -1257,7 +1257,7 @@ ChooseWildEncounter_BugContest::
ret

TryWildEncounter_BugContest:
ld a, [wPlayerTile]
ld a, [wPlayerTileCollision]
call CheckSuperTallGrassTile
ld b, 40 percent
jr z, .ok
Expand Down
22 changes: 11 additions & 11 deletions engine/overworld/map_objects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ CopyCoordsTileToLastCoordsTile:
ld hl, OBJECT_LAST_MAP_Y
add hl, bc
ld [hl], a
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld a, [hl]
ld hl, OBJECT_LAST_TILE
add hl, bc
ld [hl], a
call SetTallGrassFlags
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld a, [hl]
call UselessAndA
Expand All @@ -228,12 +228,12 @@ UpdateTallGrassFlags:
add hl, bc
bit OVERHEAD_F, [hl]
jr z, .ok
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld a, [hl]
call SetTallGrassFlags
.ok
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld a, [hl]
call UselessAndA
Expand Down Expand Up @@ -321,9 +321,9 @@ GetNextTile:
ld [hl], a
ld e, a
push bc
call GetCoordTile
call GetCoordTileCollision
pop bc
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld [hl], a
ret
Expand Down Expand Up @@ -502,9 +502,9 @@ StepFunction_Reset:
add hl, bc
ld e, [hl]
push bc
call GetCoordTile
call GetCoordTileCollision
pop bc
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld [hl], a
call CopyCoordsTileToLastCoordsTile
Expand Down Expand Up @@ -656,7 +656,7 @@ MovementFunction_Strength:
dw .stop

.start:
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld a, [hl]
call CheckPitTile
Expand Down Expand Up @@ -2278,9 +2278,9 @@ UpdateObjectTile:
ld hl, OBJECT_MAP_Y
add hl, bc
ld e, [hl]
call GetCoordTile
call GetCoordTileCollision
pop bc
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld [hl], a
farcall UpdateTallGrassFlags ; no need to farcall
Expand Down
8 changes: 4 additions & 4 deletions engine/overworld/map_setup.asm
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@ SkipUpdateMapSprites:

CheckUpdatePlayerSprite:
nop
call .CheckBiking
call .CheckForcedBiking
jr c, .ok
call .CheckSurfing
jr c, .ok
call .CheckSurfing2
call .ResetSurfingOrBikingState
jr c, .ok
ret

.ok
call UpdatePlayerSprite
ret

.CheckBiking:
.CheckForcedBiking:
and a
ld hl, wBikeFlags
bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
Expand All @@ -119,7 +119,7 @@ CheckUpdatePlayerSprite:
scf
ret

.CheckSurfing2:
.ResetSurfingOrBikingState:
ld a, [wPlayerState]
cp PLAYER_NORMAL
jr z, .nope
Expand Down
2 changes: 1 addition & 1 deletion engine/overworld/movement.asm
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ NormalStep:
add hl, bc
ld [hl], OBJECT_ACTION_STEP

ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld a, [hl]
call CheckSuperTallGrassTile
Expand Down
18 changes: 9 additions & 9 deletions engine/overworld/npc_movement.asm
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ WillObjectBumpIntoWater:
add hl, bc
bit OAM_PRIORITY, [hl]
jp nz, WillObjectRemainOnWater
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld a, [hl]
ld d, a
call GetTileCollision
call GetTilePermission
and a ; LAND_TILE
jr z, WillObjectBumpIntoTile
scf
Expand All @@ -83,17 +83,17 @@ WillObjectBumpIntoWater:
WillObjectBumpIntoLand:
call CanObjectLeaveTile
ret c
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld a, [hl]
call GetTileCollision
call GetTilePermission
cp WATER_TILE
jr z, WillObjectBumpIntoTile
scf
ret

WillObjectBumpIntoTile:
ld hl, OBJECT_TILE
ld hl, OBJECT_TILE_COLLISION
add hl, bc
ld a, [hl]
call GetSideWallDirectionMask
Expand Down Expand Up @@ -210,13 +210,13 @@ WillObjectRemainOnWater:
inc e

.continue
call GetCoordTile
call GetTileCollision
call GetCoordTileCollision
call GetTilePermission
pop de
and a ; LAND_TILE
jr nz, .not_land
call GetCoordTile
call GetTileCollision
call GetCoordTileCollision
call GetTilePermission
and a ; LAND_TILE
jr nz, .not_land
xor a
Expand Down
22 changes: 11 additions & 11 deletions engine/overworld/player_movement.asm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ DoPlayerMovement::
; Tiles such as waterfalls and warps move the player
; in a given direction, overriding input.

ld a, [wPlayerTile]
ld a, [wPlayerTileCollision]
ld c, a
call CheckWhirlpoolTile
jr c, .not_whirlpool
Expand Down Expand Up @@ -270,7 +270,7 @@ DoPlayerMovement::
cp 2
jr z, .bump

ld a, [wPlayerTile]
ld a, [wPlayerTileCollision]
call CheckIceTile
jr nc, .ice

Expand Down Expand Up @@ -352,7 +352,7 @@ DoPlayerMovement::
ret

.TryJump:
ld a, [wPlayerTile]
ld a, [wPlayerTileCollision]
ld e, a
and $f0
cp HI_NYBBLE_LEDGES
Expand Down Expand Up @@ -398,7 +398,7 @@ DoPlayerMovement::
ld d, 0
ld hl, .EdgeWarps
add hl, de
ld a, [wPlayerTile]
ld a, [wPlayerTileCollision]
cp [hl]
jr nz, .not_warp

Expand Down Expand Up @@ -592,7 +592,7 @@ DoPlayerMovement::
ld h, [hl]
ld l, a
ld a, [hl]
ld [wWalkingTile], a
ld [wWalkingTileCollision], a
ret

MACRO player_action
Expand All @@ -603,7 +603,7 @@ ENDM

.action_table:
.action_table_1
player_action STANDING, FACE_CURRENT, 0, 0, wPlayerTile
player_action STANDING, FACE_CURRENT, 0, 0, wPlayerTileCollision
.action_table_1_end
player_action RIGHT, FACE_RIGHT, 1, 0, wTileRight
player_action LEFT, FACE_LEFT, -1, 0, wTileLeft
Expand Down Expand Up @@ -693,7 +693,7 @@ ENDM
and d
jr nz, .NotWalkable

ld a, [wWalkingTile]
ld a, [wWalkingTileCollision]
call .CheckWalkable
jr c, .NotWalkable

Expand All @@ -714,7 +714,7 @@ ENDM
and d
jr nz, .NotSurfable

ld a, [wWalkingTile]
ld a, [wWalkingTileCollision]
call .CheckSurfable
jr c, .NotSurfable

Expand All @@ -735,7 +735,7 @@ ENDM
.CheckWalkable:
; Return 0 if tile a is land. Otherwise, return carry.

call GetTileCollision
call GetTilePermission
and a ; LAND_TILE
ret z
scf
Expand All @@ -745,7 +745,7 @@ ENDM
; Return 0 if tile a is water, or 1 if land.
; Otherwise, return carry.

call GetTileCollision
call GetTilePermission
cp WATER_TILE
jr z, .Water

Expand Down Expand Up @@ -789,7 +789,7 @@ CheckStandingOnIce::
jr z, .not_ice
cp $f0
jr z, .not_ice
ld a, [wPlayerTile]
ld a, [wPlayerTileCollision]
call CheckIceTile
jr nc, .yep
ld a, [wPlayerState]
Expand Down
Loading

0 comments on commit e0c278a

Please sign in to comment.