diff options
Diffstat (limited to 'engine/overworld/sprite_collisions.asm')
-rw-r--r-- | engine/overworld/sprite_collisions.asm | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm index 0e6b2d06..c5ff8ebb 100644 --- a/engine/overworld/sprite_collisions.asm +++ b/engine/overworld/sprite_collisions.asm @@ -6,7 +6,7 @@ _UpdateSprites:: ld l, a sub $e ld c, a - ld [H_CURRENTSPRITEOFFSET], a + ld [hCurrentSpriteOffset], a ld a, [hl] and a jr z, .skipSprite ; tests $c2Xe @@ -31,17 +31,17 @@ _UpdateSprites:: UpdateNonPlayerSprite: dec a swap a - ld [$ff93], a ; $10 * sprite# + ld [hTilePlayerStandingOn], a ; $10 * sprite# ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset? ld b, a - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] cp b jr nz, .unequal jp DoScriptedNPCMovement .unequal jp UpdateNPCSprite -; This detects if the current sprite (whose offset is at H_CURRENTSPRITEOFFSET) +; This detects if the current sprite (whose offset is at hCurrentSpriteOffset) ; is going to collide with another sprite by looping over the other sprites. ; The current sprite's offset will be labelled with i (e.g. $c1i0). ; The loop sprite's offset will labelled with j (e.g. $c1j0). @@ -54,7 +54,7 @@ DetectCollisionBetweenSprites: nop ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add wSpriteStateData1 % $100 ld l, a @@ -79,7 +79,7 @@ DetectCollisionBetweenSprites: and $f0 or c - ld [$ff90], a ; store Y coordinate adjusted for direction of movement + ld [hFF90], a ; store Y coordinate adjusted for direction of movement ld a, [hli] ; a = [$c1i5] (delta X) (-1, 0, or 1) call SetSpriteCollisionValues @@ -92,7 +92,7 @@ DetectCollisionBetweenSprites: and $f0 or c - ld [$ff91], a ; store X coordinate adjusted for direction of movement + ld [hFF91], a ; store X coordinate adjusted for direction of movement ld a, l add 7 @@ -102,18 +102,18 @@ DetectCollisionBetweenSprites: ld [hld], a ; zero [$c1id] XXX what's [$c1id] for? ld [hld], a ; zero [$c1ic] (directions in which collisions occurred) - ld a, [$ff91] + ld a, [hFF91] ld [hld], a ; [$c1ib] = adjusted X coordinate - ld a, [$ff90] + ld a, [hFF90] ld [hl], a ; [$c1ia] = adjusted Y coordinate xor a ; zero the loop counter .loop - ld [$ff8f], a ; store loop counter + ld [hFF8F], a ; store loop counter swap a ld e, a - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] cp e ; does the loop sprite match the current sprite? jp z, .next ; go to the next sprite if they match @@ -128,7 +128,7 @@ DetectCollisionBetweenSprites: inc a jp z, .next ; go the next sprite if offscreen - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add 10 ld l, a @@ -154,7 +154,7 @@ DetectCollisionBetweenSprites: cpl inc a .noCarry1 - ld [$ff90], a ; store the distance between the two sprites' adjusted Y values + ld [hFF90], 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 [$c1ic], @@ -176,11 +176,11 @@ DetectCollisionBetweenSprites: ld b, 9 .next1 - ld a, [$ff90] ; a = distance between adjusted Y coordinates + ld a, [hFF90] ; a = distance between adjusted Y coordinates sub b - ld [$ff92], a ; store distance adjusted using sprite i's direction + ld [hFF92], a ; store distance adjusted using sprite i's direction ld a, b - ld [$ff90], a ; store 7 or 9 depending on sprite i's delta Y + ld [hFF90], 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. @@ -193,7 +193,7 @@ DetectCollisionBetweenSprites: ld b, 9 .next2 - ld a, [$ff92] ; a = distance adjusted using sprite i's direction + ld a, [hFF92] ; a = distance adjusted using sprite i's direction 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 @@ -225,7 +225,7 @@ DetectCollisionBetweenSprites: cpl inc a .noCarry2 - ld [$ff91], a ; store the distance between the two sprites' adjusted X values + ld [hFF91], 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 [$c1ic], @@ -247,11 +247,11 @@ DetectCollisionBetweenSprites: ld b, 9 .next3 - ld a, [$ff91] ; a = distance between adjusted X coordinates + ld a, [hFF91] ; a = distance between adjusted X coordinates sub b - ld [$ff92], a ; store distance adjusted using sprite i's direction + ld [hFF92], a ; store distance adjusted using sprite i's direction ld a, b - ld [$ff91], a ; store 7 or 9 depending on sprite i's delta X + ld [hFF91], 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. @@ -264,15 +264,15 @@ DetectCollisionBetweenSprites: ld b, 9 .next4 - ld a, [$ff92] ; a = distance adjusted using sprite i's direction + ld a, [hFF92] ; a = distance adjusted using sprite i's direction 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 - ld a, [$ff91] ; a = 7 or 9 depending on sprite i's delta X + ld a, [hFF91] ; a = 7 or 9 depending on sprite i's delta X ld b, a - ld a, [$ff90] ; a = 7 or 9 depending on sprite i's delta Y + ld a, [hFF90] ; 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. @@ -294,7 +294,7 @@ DetectCollisionBetweenSprites: ; set bit in [$c1ie] or [$c1if] to indicate which sprite the collision occurred with inc l inc l - ld a, [$ff8f] ; a = loop counter + ld a, [hFF8F] ; a = loop counter ld de, SpriteCollisionBitTable add a add e @@ -311,7 +311,7 @@ DetectCollisionBetweenSprites: ld [hl], a .next - ld a, [$ff8f] ; a = loop counter + ld a, [hFF8F] ; a = loop counter inc a cp $10 jp nz, .loop |