Skip to content

Commit

Permalink
Tweak names further
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortyne committed Nov 20, 2023
1 parent f382da0 commit 3d43636
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
38 changes: 19 additions & 19 deletions engine/overworld/sprite_collisions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ DetectCollisionBetweenSprites:
and $f0
or c

ldh [hSpriteCollisionsTempYCoord], a ; y adjusted for direction of movement
ldh [hCollidingSpriteTempYValue], a ; y adjusted for direction of movement

ld a, [hli] ; a = [i#SPRITESTATEDATA1_XSTEPVECTOR] (-1, 0, or 1)
call SetSpriteCollisionValues
Expand All @@ -93,7 +93,7 @@ DetectCollisionBetweenSprites:
and $f0
or c

ldh [hSpriteCollisionsTempXCoord], a ; x adjusted for direction of movement
ldh [hCollidingSpriteTempXValue], a ; x adjusted for direction of movement

ld a, l
add 7
Expand All @@ -103,15 +103,15 @@ DetectCollisionBetweenSprites:
ld [hld], a ; zero [i#SPRITESTATEDATA1_0D] XXX what's this for?
ld [hld], a ; zero [i#SPRITESTATEDATA1_COLLISIONDATA]

ldh a, [hSpriteCollisionsTempXCoord]
ldh a, [hCollidingSpriteTempXValue]
ld [hld], a ; [i#SPRITESTATEDATA1_XADJUSTED]
ldh a, [hSpriteCollisionsTempYCoord]
ldh a, [hCollidingSpriteTempYValue]
ld [hl], a ; [i#SPRITESTATEDATA1_YADJUSTED]

xor a ; zero the loop counter

.loop
ldh [hSpriteCollisionsLoopCounter], a
ldh [hCollidingSpriteOffset], a
swap a
ld e, a
ldh a, [hCurrentSpriteOffset]
Expand Down Expand Up @@ -155,7 +155,7 @@ DetectCollisionBetweenSprites:
cpl
inc a
.noCarry1
ldh [hSpriteCollisionsTempYCoord], a ; store the distance between the two sprites' adjusted Y values
ldh [hCollidingSpriteTempYValue], a ; store the distance between the two sprites' adjusted Y values

; Use the carry flag set by the above subtraction to determine which sprite's
; Y coordinate is larger. This information is used later to set
Expand All @@ -177,11 +177,11 @@ DetectCollisionBetweenSprites:
ld b, 9

.next1
ldh a, [hSpriteCollisionsTempYCoord] ; a = distance between adjusted Y coordinates
ldh a, [hCollidingSpriteTempYValue] ; a = distance between adjusted Y coordinates
sub b
ldh [hSpriteCollisionsAdjustedDistance], a
ldh [hCollidingSpriteAdjustedDistance], a
ld a, b
ldh [hSpriteCollisionsTempYCoord], a ; store 7 or 9 depending on sprite i's delta Y
ldh [hCollidingSpriteTempYValue], a ; store 7 or 9 depending on sprite i's delta Y
jr c, .checkXDistance

; If sprite j's delta Y is 0, then b = 7, else b = 9.
Expand All @@ -194,7 +194,7 @@ DetectCollisionBetweenSprites:
ld b, 9

.next2
ldh a, [hSpriteCollisionsAdjustedDistance]
ldh a, [hCollidingSpriteAdjustedDistance]
sub b ; adjust distance using sprite j's direction
jr z, .checkXDistance
jr nc, .next ; go to next sprite if distance is still positive after both adjustments
Expand Down Expand Up @@ -226,7 +226,7 @@ DetectCollisionBetweenSprites:
cpl
inc a
.noCarry2
ldh [hSpriteCollisionsTempXCoord], a ; store the distance between the two sprites' adjusted X values
ldh [hCollidingSpriteTempXValue], a ; store the distance between the two sprites' adjusted X values

; Use the carry flag set by the above subtraction to determine which sprite's
; X coordinate is larger. This information is used later to set
Expand All @@ -248,11 +248,11 @@ DetectCollisionBetweenSprites:
ld b, 9

.next3
ldh a, [hSpriteCollisionsTempXCoord] ; a = distance between adjusted X coordinates
ldh a, [hCollidingSpriteTempXValue] ; a = distance between adjusted X coordinates
sub b
ldh [hSpriteCollisionsAdjustedDistance], a
ldh [hCollidingSpriteAdjustedDistance], a
ld a, b
ldh [hSpriteCollisionsTempXCoord], a ; store 7 or 9 depending on sprite i's delta X
ldh [hCollidingSpriteTempXValue], a ; store 7 or 9 depending on sprite i's delta X
jr c, .collision

; If sprite j's delta X is 0, then b = 7, else b = 9.
Expand All @@ -265,15 +265,15 @@ DetectCollisionBetweenSprites:
ld b, 9

.next4
ldh a, [hSpriteCollisionsAdjustedDistance]
ldh a, [hCollidingSpriteAdjustedDistance]
sub b ; adjust distance using sprite j's direction
jr z, .collision
jr nc, .next ; go to next sprite if distance is still positive after both adjustments

.collision
ldh a, [hSpriteCollisionsTempXCoord] ; a = 7 or 9 depending on sprite i's delta X
ldh a, [hCollidingSpriteTempXValue] ; a = 7 or 9 depending on sprite i's delta X
ld b, a
ldh a, [hSpriteCollisionsTempYCoord] ; a = 7 or 9 depending on sprite i's delta Y
ldh a, [hCollidingSpriteTempYValue] ; a = 7 or 9 depending on sprite i's delta Y
inc l

; If delta X isn't 0 and delta Y is 0, then b = %0011, else b = %1100.
Expand All @@ -296,7 +296,7 @@ DetectCollisionBetweenSprites:
; to indicate which sprite the collision occurred with
inc l
inc l
ldh a, [hSpriteCollisionsLoopCounter]
ldh a, [hCollidingSpriteOffset]
ld de, SpriteCollisionBitTable
add a
add e
Expand All @@ -313,7 +313,7 @@ DetectCollisionBetweenSprites:
ld [hl], a

.next
ldh a, [hSpriteCollisionsLoopCounter]
ldh a, [hCollidingSpriteOffset]
inc a
cp $10
jp nz, .loop
Expand Down
12 changes: 5 additions & 7 deletions ram/hram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ hSpriteScreenX:: db
hSpriteScreenY:: db

NEXTU
hSpriteCollisionsLoopCounter:: db
hSpriteCollisionsTempYCoord:: db
hSpriteCollisionsTempXCoord:: db
hSpriteCollisionsAdjustedDistance:: db
hCollidingSpriteOffset:: db
hCollidingSpriteTempYValue:: db
hCollidingSpriteTempXValue:: db
hCollidingSpriteAdjustedDistance:: db
ENDU

hTilePlayerStandingOn:: db
Expand Down Expand Up @@ -327,10 +327,8 @@ hItemCounter::
hSavedCoordIndex::
hMissableObjectIndex::
hGymTrashCanRandNumMask::
hInteractedWithBookshelf::
db

NEXTU
hInteractedWithBookshelf:: db ; set to 0 if you interacted with a bookshelf, $FF if not when attempting to interact with a hidden object
ENDU

ds 1
Expand Down

0 comments on commit 3d43636

Please sign in to comment.