summaryrefslogtreecommitdiff
path: root/engine/overworld/trainers.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/overworld/trainers.asm')
-rwxr-xr-xengine/overworld/trainers.asm94
1 files changed, 47 insertions, 47 deletions
diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm
index 8968332a..b05ddbf1 100755
--- a/engine/overworld/trainers.asm
+++ b/engine/overworld/trainers.asm
@@ -1,7 +1,7 @@
Func_567f9: ; 567f9 (15:67f9)
ld hl, wSpriteStateData1
ld de, $4
- ld a, [$cf13]
+ ld a, [wcf13]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call Func_56903
ld a, [hli]
@@ -20,26 +20,26 @@ Func_567f9: ; 567f9 (15:67f9)
Func_56819: ; 56819 (15:6819)
ld hl, wSpriteStateData1
ld de, $0004
- ld a, [$cf13]
+ ld a, [wcf13]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call Func_56903
ld a, [hli]
- ld [$d130], a
+ ld [wd130], a
inc hl
ld a, [hl]
- ld [$d131], a
+ ld [wd131], a
ld de, $00fe
add hl, de
ld a, [hli]
- ld [$d132], a
+ ld [wd132], a
ld a, [hl]
- ld [$d133], a
+ ld [wd133], a
ret
Func_5683d: ; 5683d (15:683d)
ld hl, wSpriteStateData1
ld de, $4
- ld a, [$cf13]
+ ld a, [wcf13]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call Func_56903
ld a, [$ffeb]
@@ -58,26 +58,26 @@ Func_5683d: ; 5683d (15:683d)
Func_5685d: ; 5685d (15:685d)
ld hl, wSpriteStateData1
ld de, $0004
- ld a, [$cf13]
+ ld a, [wcf13]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call Func_56903
- ld a, [$d130]
+ ld a, [wd130]
ld [hli], a
inc hl
- ld a, [$d131]
+ ld a, [wd131]
ld [hl], a
ld de, $00fe
add hl, de
- ld a, [$d132]
+ ld a, [wd132]
ld [hli], a
- ld a, [$d133]
+ ld a, [wd133]
ld [hl], a
ret
TrainerWalkUpToPlayer: ; 56881 (15:6881)
- ld a, [$cf13]
+ ld a, [wcf13]
swap a
- ld [wTrainerSpriteOffset], a ; $cd3d
+ ld [wTrainerSpriteOffset], a ; wWhichTrade
call ReadTrainerScreenPosition
ld a, [wTrainerFacingDirection]
and a
@@ -127,7 +127,7 @@ TrainerWalkUpToPlayer: ; 56881 (15:6881)
ld a, $c0 ; a = direction to go to
jr .writeWalkScript
.facingLeft
- ld a, [$cd41]
+ ld a, [wTrainerScreenX]
ld b, a
ld a, $40 ; (fixed) player screen X pos
call CalcDifference
@@ -139,11 +139,11 @@ TrainerWalkUpToPlayer: ; 56881 (15:6881)
ld b, $0
ld a, $80 ; a = direction to go to
.writeWalkScript
- ld hl, $cc97
- ld de, $cc97
+ ld hl, wcc97
+ ld de, wcc97
call FillMemory ; write the necessary steps to reach player
ld [hl], $ff ; write end of list sentinel
- ld a, [$cf13]
+ ld a, [wcf13]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
jp MoveSprite_
@@ -159,10 +159,10 @@ Func_56903: ; 56903 (15:6903)
ret
; tests if this trainer is in the right position to engage the player and do so if she is.
-CheckEngagePlayer: ; 5690f (15:690f)
+TrainerEngage: ; 5690f (15:690f)
push hl
push de
- ld a, [wTrainerSpriteOffset] ; $cd3d
+ ld a, [wTrainerSpriteOffset] ; wWhichTrade
add $2
ld d, $0
ld e, a
@@ -173,21 +173,21 @@ CheckEngagePlayer: ; 5690f (15:690f)
jr nz, .spriteOnScreen ; test if sprite is on screen
jp .noEngage
.spriteOnScreen
- ld a, [wTrainerSpriteOffset] ; $cd3d
+ ld a, [wTrainerSpriteOffset] ; wWhichTrade
add $9
ld d, $0
ld e, a
ld hl, wSpriteStateData1
add hl, de
ld a, [hl] ; c1x9: facing direction
- ld [$cd3f], a
+ ld [wTrainerFacingDirection], a
call ReadTrainerScreenPosition
- ld a, [$cd40] ; sprite screen Y pos
+ ld a, [wTrainerScreenY] ; sprite screen Y pos
ld b, a
ld a, $3c
cp b
jr z, .linedUpY
- ld a, [$cd41] ; sprite screen X pos
+ ld a, [wTrainerScreenX] ; sprite screen X pos
ld b, a
ld a, $40
cp b
@@ -195,7 +195,7 @@ CheckEngagePlayer: ; 5690f (15:690f)
xor a
jp .noEngage
.linedUpY
- ld a, [$cd41] ; sprite screen X pos
+ ld a, [wTrainerScreenX] ; sprite screen X pos
ld b, a
ld a, $40 ; (fixed) player X position
call CalcDifference ; calc distance
@@ -205,7 +205,7 @@ CheckEngagePlayer: ; 5690f (15:690f)
xor a
jr .noEngage
.linedUpX
- ld a, [$cd40] ; sprite screen Y pos
+ ld a, [wTrainerScreenY] ; sprite screen Y pos
ld b, a
ld a, $3c ; (fixed) player Y position
call CalcDifference ; calc distance
@@ -216,7 +216,7 @@ CheckEngagePlayer: ; 5690f (15:690f)
jp .noEngage
.engage
call CheckPlayerIsInFrontOfSprite
- ld a, [wTrainerSpriteOffset] ; $cd3d
+ ld a, [wTrainerSpriteOffset] ; wWhichTrade
and a
jr z, .noEngage
ld hl, wFlags_0xcd60
@@ -224,29 +224,29 @@ CheckEngagePlayer: ; 5690f (15:690f)
call EngageMapTrainer
ld a, $ff
.noEngage: ; 56988 (15:6988)
- ld [wTrainerSpriteOffset], a ; $cd3d
+ ld [wTrainerSpriteOffset], a ; wWhichTrade
pop de
pop hl
ret
-; reads trainer's Y position to $cd40 and X position to $cd41
+; reads trainer's Y position to wTrainerScreenY and X position to wTrainerScreenX
ReadTrainerScreenPosition: ; 5698e (15:698e)
- ld a, [wTrainerSpriteOffset] ; $cd3d
+ ld a, [wTrainerSpriteOffset] ; wWhichTrade
add $4
ld d, $0
ld e, a
ld hl, wSpriteStateData1
add hl, de
ld a, [hl]
- ld [$cd40], a
- ld a, [wTrainerSpriteOffset] ; $cd3d
+ ld [wTrainerScreenY], a
+ ld a, [wTrainerSpriteOffset] ; wWhichTrade
add $6
ld d, $0
ld e, a
ld hl, wSpriteStateData1
add hl, de
ld a, [hl]
- ld [$cd41], a
+ ld [wTrainerScreenX], a
ret
; checks if the sprite is properly lined up with the player with respect to the direction it's looking. Also checks the distance between player and sprite
@@ -259,7 +259,7 @@ CheckSpriteCanSeePlayer: ; 569af (15:69af)
jr nc, .checkIfLinedUp
jr .notInLine ; player too far away
.checkIfLinedUp
- ld a, [$cd3f] ; sprite facing direction
+ ld a, [wTrainerFacingDirection] ; sprite facing direction
cp $0 ; down
jr z, .checkXCoord
cp $4 ; up
@@ -270,13 +270,13 @@ CheckSpriteCanSeePlayer: ; 569af (15:69af)
jr z, .checkYCoord
jr .notInLine
.checkXCoord
- ld a, [$cd41] ; sprite screen X position
+ ld a, [wTrainerScreenX] ; sprite screen X position
ld b, a
cp $40
jr z, .inLine
jr .notInLine
.checkYCoord
- ld a, [$cd40] ; sprite screen Y position
+ ld a, [wTrainerScreenY] ; sprite screen Y position
ld b, a
cp $3c
jr nz, .notInLine
@@ -289,10 +289,10 @@ CheckSpriteCanSeePlayer: ; 569af (15:69af)
; tests if the player is in front of the sprite (rather than behind it)
CheckPlayerIsInFrontOfSprite: ; 569e3 (15:69e3)
- ld a, [W_CURMAP] ; $d35e
+ ld a, [W_CURMAP] ; W_CURMAP
cp POWER_PLANT
jp z, .engage ; XXX not sure why bypass this for power plant (maybe to get voltorb fake items to work?)
- ld a, [wTrainerSpriteOffset] ; $cd3d
+ ld a, [wTrainerSpriteOffset] ; wWhichTrade
add $4
ld d, $0
ld e, a
@@ -303,38 +303,38 @@ CheckPlayerIsInFrontOfSprite: ; 569e3 (15:69e3)
jr nz, .notOnTopmostTile ; special case if sprite is on topmost tile (Y = $fc (-4)), make it come down a block
ld a, $c
.notOnTopmostTile
- ld [$cd40], a
- ld a, [wTrainerSpriteOffset] ; $cd3d
+ ld [wTrainerScreenY], a
+ ld a, [wTrainerSpriteOffset] ; wWhichTrade
add $6
ld d, $0
ld e, a
ld hl, wSpriteStateData1
add hl, de
ld a, [hl] ; c1x6 (sprite screen X pos)
- ld [$cd41], a
- ld a, [$cd3f] ; facing direction
+ ld [wTrainerScreenX], a
+ ld a, [wTrainerFacingDirection] ; facing direction
cp $0
jr nz, .notFacingDown
- ld a, [$cd40] ; sprite screen Y pos
+ ld a, [wTrainerScreenY] ; sprite screen Y pos
cp $3c
jr c, .engage ; sprite above player
jr .noEngage ; sprite below player
.notFacingDown
cp $4
jr nz, .notFacingUp
- ld a, [$cd40] ; sprite screen Y pos
+ ld a, [wTrainerScreenY] ; sprite screen Y pos
cp $3c
jr nc, .engage ; sprite below player
jr .noEngage ; sprite above player
.notFacingUp
cp $8
jr nz, .notFacingLeft
- ld a, [$cd41] ; sprite screen X pos
+ ld a, [wTrainerScreenX] ; sprite screen X pos
cp $40
jr nc, .engage ; sprite right of player
jr .noEngage ; sprite left of player
.notFacingLeft
- ld a, [$cd41] ; sprite screen X pos
+ ld a, [wTrainerScreenX] ; sprite screen X pos
cp $40
jr nc, .noEngage ; sprite right of player
.engage
@@ -343,5 +343,5 @@ CheckPlayerIsInFrontOfSprite: ; 569e3 (15:69e3)
.noEngage
xor a
.done
- ld [wTrainerSpriteOffset], a ; $cd3d
+ ld [wTrainerSpriteOffset], a ; wWhichTrade
ret