aboutsummaryrefslogtreecommitdiffstats
path: root/engine/overworld
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2023-11-21 20:56:28 -0600
committerdannye <33dannye@gmail.com>2023-11-21 20:56:28 -0600
commit04f7f7f506a1dbb877e4678601261e8157fd0e57 (patch)
treebfe62d3872c5f031ee40df9488910bd58b0e1b15 /engine/overworld
parentExtend tools/pcm.c to allow decoding .pcm to .wav (diff)
parentFix some map text constants (diff)
downloadpokeyellow-04f7f7f506a1dbb877e4678601261e8157fd0e57.tar.gz
pokeyellow-04f7f7f506a1dbb877e4678601261e8157fd0e57.tar.xz
pokeyellow-04f7f7f506a1dbb877e4678601261e8157fd0e57.zip
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to 'engine/overworld')
-rw-r--r--engine/overworld/auto_movement.asm4
-rw-r--r--engine/overworld/movement.asm6
-rw-r--r--engine/overworld/sprite_collisions.asm63
3 files changed, 30 insertions, 43 deletions
diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm
index 65888294..39c1f380 100644
--- a/engine/overworld/auto_movement.asm
+++ b/engine/overworld/auto_movement.asm
@@ -17,7 +17,7 @@ PlayerStepOutFromDoor::
ret
.notStandingOnDoor
xor a
- ld [wWastedByteCD3A], a
+ ld [wUnusedCD3A], a
ld [wSimulatedJoypadStatesIndex], a
ld [wSimulatedJoypadStatesEnd], a
ld hl, wd736
@@ -39,7 +39,7 @@ _EndNPCMovementScript::
ld [wNPCMovementScriptSpriteOffset], a
ld [wNPCMovementScriptFunctionNum], a
ld [wNPCMovementScriptPointerTableNum], a
- ld [wWastedByteCD3A], a
+ ld [wUnusedCD3A], a
ld [wSimulatedJoypadStatesIndex], a
ld [wSimulatedJoypadStatesEnd], a
ret
diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm
index e6ca8748..48a6f3aa 100644
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -114,7 +114,7 @@ UpdateNPCSprite:
and a
jp z, InitializeSpriteStatus
call CheckSpriteAvailability
- ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking
+ ret c ; don't do anything if sprite is invisible
ld h, HIGH(wSpriteStateData1)
ldh a, [hCurrentSpriteOffset]
ld l, a
@@ -135,7 +135,7 @@ UpdateNPCSprite:
jp z, Func_5357
ld a, [wWalkCounter]
and a
- ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability)
+ ret nz ; don't do anything yet if player is currently moving
call InitializeSpriteScreenPosition
ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset]
@@ -166,7 +166,7 @@ UpdateNPCSprite:
res 0, [hl]
xor a
ld [wSimulatedJoypadStatesIndex], a
- ld [wWastedByteCD3A], a
+ ld [wUnusedCD3A], a
ret
.next
cp WALK
diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm
index b29dc108..186ff504 100644
--- a/engine/overworld/sprite_collisions.asm
+++ b/engine/overworld/sprite_collisions.asm
@@ -82,7 +82,7 @@ DetectCollisionBetweenSprites:
and $f0
or c
- ldh [hFF90], a ; store Y coordinate 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
@@ -95,7 +95,7 @@ DetectCollisionBetweenSprites:
and $f0
or c
- ldh [hFF91], a ; store X coordinate adjusted for direction of movement
+ ldh [hCollidingSpriteTempXValue], a ; x adjusted for direction of movement
ld a, l
add 7
@@ -105,15 +105,15 @@ DetectCollisionBetweenSprites:
ld [hld], a ; zero [i#SPRITESTATEDATA1_0D] XXX what's this for?
ld [hld], a ; zero [i#SPRITESTATEDATA1_COLLISIONDATA]
- ldh a, [hFF91]
+ ldh a, [hCollidingSpriteTempXValue]
ld [hld], a ; [i#SPRITESTATEDATA1_XADJUSTED]
- ldh a, [hFF90]
+ ldh a, [hCollidingSpriteTempYValue]
ld [hl], a ; [i#SPRITESTATEDATA1_YADJUSTED]
xor a ; zero the loop counter
.loop
- ldh [hFF8F], a ; store loop counter
+ ldh [hCollidingSpriteOffset], a
swap a
ld e, a
ldh a, [hCurrentSpriteOffset]
@@ -157,7 +157,7 @@ DetectCollisionBetweenSprites:
cpl
inc a
.noCarry1
- ldh [hFF90], 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
@@ -179,11 +179,11 @@ DetectCollisionBetweenSprites:
ld b, 9
.next1
- ldh a, [hFF90] ; a = distance between adjusted Y coordinates
+ ldh a, [hCollidingSpriteTempYValue] ; a = distance between adjusted Y coordinates
sub b
- ldh [hFF92], a ; store distance adjusted using sprite i's direction
+ ldh [hCollidingSpriteAdjustedDistance], a
ld a, b
- ldh [hFF90], 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.
@@ -196,7 +196,7 @@ DetectCollisionBetweenSprites:
ld b, 9
.next2
- ldh a, [hFF92] ; a = distance adjusted using sprite i's direction
+ 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
@@ -228,7 +228,7 @@ DetectCollisionBetweenSprites:
cpl
inc a
.noCarry2
- ldh [hFF91], 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
@@ -250,11 +250,11 @@ DetectCollisionBetweenSprites:
ld b, 9
.next3
- ldh a, [hFF91] ; a = distance between adjusted X coordinates
+ ldh a, [hCollidingSpriteTempXValue] ; a = distance between adjusted X coordinates
sub b
- ldh [hFF92], a ; store distance adjusted using sprite i's direction
+ ldh [hCollidingSpriteAdjustedDistance], a
ld a, b
- ldh [hFF91], 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.
@@ -267,7 +267,7 @@ DetectCollisionBetweenSprites:
ld b, 9
.next4
- ldh a, [hFF92] ; a = distance adjusted using sprite i's direction
+ 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
@@ -278,15 +278,15 @@ DetectCollisionBetweenSprites:
jr nz, .asm_4cd9
xor a
ld [wd434], a
- ldh a, [hFF8F]
+ ldh a, [hCollidingSpriteOffset]
cp $f
jr nz, .asm_4cd9
call Func_4d0a
jr .asm_4cef
.asm_4cd9
- ldh a, [hFF91] ; 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, [hFF90] ; 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.
@@ -310,7 +310,7 @@ DetectCollisionBetweenSprites:
inc l
inc l
.asm_4cef
- ldh a, [hFF8F] ; a = loop counter
+ ldh a, [hCollidingSpriteOffset]
ld de, SpriteCollisionBitTable
add a
add e
@@ -327,7 +327,7 @@ DetectCollisionBetweenSprites:
ld [hl], a
.next
- ldh a, [hFF8F] ; a = loop counter
+ ldh a, [hCollidingSpriteOffset]
inc a
cp $10
jp nz, .loop
@@ -339,9 +339,9 @@ DetectCollisionBetweenSprites:
; c = 7 if delta X/Y is 1
; c = 9 if delta X/Y is -1
Func_4d0a:
- ldh a, [hFF91]
+ ldh a, [hCollidingSpriteTempXValue]
ld b, a
- ldh a, [hFF90]
+ ldh a, [hCollidingSpriteTempYValue]
inc l
cp b
jr c, .asm_4d17
@@ -374,19 +374,6 @@ SetSpriteCollisionValues:
ret
SpriteCollisionBitTable:
- db %00000000,%00000001
- db %00000000,%00000010
- db %00000000,%00000100
- db %00000000,%00001000
- db %00000000,%00010000
- db %00000000,%00100000
- db %00000000,%01000000
- db %00000000,%10000000
- db %00000001,%00000000
- db %00000010,%00000000
- db %00000100,%00000000
- db %00001000,%00000000
- db %00010000,%00000000
- db %00100000,%00000000
- db %01000000,%00000000
- db %10000000,%00000000
+FOR n, $10
+ bigdw 1 << n
+ENDR