Rename/organize part 1 of 4

rename functions, clean up address/wram comments, other misc
only broken up so that all changes are viewable on github
This commit is contained in:
U-Daniel-PC\Daniel 2015-07-03 14:37:53 -05:00
parent ae420a4d8f
commit cd649184f5
90 changed files with 1070 additions and 1066 deletions

View file

@ -5,7 +5,7 @@ CableClubNPC: ; 71c5 (1:71c5)
bit 5, a ; received pokedex?
jp nz, .receivedPokedex
; if the player hasn't received the pokedex
ld c, $3c
ld c, 60
call DelayFrames
ld hl, CableClubNPCMakingPreparationsText
call PrintText
@ -72,24 +72,24 @@ CableClubNPC: ; 71c5 (1:71c5)
ld hl, wUnknownSerialCounter
ld a, [hli]
inc a
jr nz, Func_72a8 ; 0x726b $3b
jr nz, Func_72a8
ld a, [hl]
inc a
jr nz, Func_72a8 ; 0x726f $37
jr nz, Func_72a8
ld b, $a
.asm_7273
call DelayFrame
call Serial_SendZeroByte
dec b
jr nz, .asm_7273 ; 0x727a $f7
jr nz, .asm_7273
call CloseLinkConnection
ld hl, CableClubNPCLinkClosedBecauseOfInactivityText
call PrintText
jr Func_7298 ; 0x7285 $11
jr Func_7298
.failedToEstablishConnection
ld hl, CableClubNPCAreaReservedFor2FriendsLinkedByCableText
call PrintText
jr Func_7298 ; 0x728d $9
jr Func_7298
.choseNo
call CloseLinkConnection
ld hl, CableClubNPCPleaseComeAgainText

View file

@ -2,16 +2,16 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006)
ld hl, wd730
set 6, [hl]
xor a
ld [wCurrentMenuItem], a ; wCurrentMenuItem
ld [wCurrentMenuItem], a
ld a, $3
ld [wMenuWatchedKeys], a ; wMenuWatchedKeys
ld [wMenuWatchedKeys], a
ld a, [wcd37]
dec a
ld [wMaxMenuItem], a ; wMaxMenuItem
ld [wMaxMenuItem], a
ld a, $2
ld [wTopMenuItemY], a ; wTopMenuItemY
ld [wTopMenuItemY], a
ld a, $1
ld [wTopMenuItemX], a ; wTopMenuItemX
ld [wTopMenuItemX], a
ld a, [wcd37]
dec a
ld bc, $2
@ -30,7 +30,7 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006)
bit 1, a
jr nz, .asm_610a7
ld hl, wcc5b
ld a, [wCurrentMenuItem] ; wCurrentMenuItem
ld a, [wCurrentMenuItem]
ld d, $0
ld e, a
add hl, de
@ -55,7 +55,7 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006)
ld hl, LabFossil_610ae
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem] ; wCurrentMenuItem
ld a, [wCurrentMenuItem]
and a
jr nz, .asm_610a7
ld hl, LabFossil_610b3

View file

@ -1,7 +1,7 @@
UsedCut: ; ef54 (3:6f54)
xor a
ld [wcd6a], a
ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
ld a, [W_CURMAPTILESET]
and a ; OVERWORLD
jr z, .asm_ef6b
cp GYM
@ -9,28 +9,28 @@ UsedCut: ; ef54 (3:6f54)
ld a, [wTileInFrontOfPlayer]
cp $50 ; gym cut tree
jr nz, .asm_ef77
jr asm_ef82
jr .asm_ef82
.asm_ef6b
dec a
ld a, [wTileInFrontOfPlayer]
cp $3d ; cut tree
jr z, asm_ef82
jr z, .asm_ef82
cp $52 ; grass
jr z, asm_ef82
jr z, .asm_ef82
.asm_ef77
ld hl, NothingToCutText
ld hl, .NothingToCutText
jp PrintText
NothingToCutText: ; ef7d (3:6f7d)
.NothingToCutText
TX_FAR _NothingToCutText
db "@"
asm_ef82: ; ef82 (3:6f82)
.asm_ef82
ld [wcd4d], a
ld a, $1
ld [wcd6a], a
ld a, [wWhichPokemon] ; wWhichPokemon
ld hl, wPartyMonNicks ; wPartyMonNicks
ld a, [wWhichPokemon]
ld hl, wPartyMonNicks
call GetPartyMonName
ld hl, wd730
set 6, [hl]
@ -54,7 +54,7 @@ asm_ef82: ; ef82 (3:6f82)
ld a, $ff
ld [wUpdateSpritesEnabled], a
call AnimateCutTree
ld de, CutTreeBlockSwaps ; $7100
ld de, CutTreeBlockSwaps
call Func_f09f
call RedrawMapView
callba Func_79e96
@ -75,15 +75,15 @@ AnimateCutTree: ; eff7 (3:6ff7)
xor a
ld [wcd50], a
ld a, $e4
ld [rOBP1], a ; $ff49
ld [rOBP1], a
ld a, [wcd4d]
cp $52
jr z, .asm_f020
ld de, Overworld_GFX + $2d0 ; $42d0 ; cuttable tree sprite top row
ld de, Overworld_GFX + $2d0 ; cuttable tree sprite top row
ld hl, vChars1 + $7c0
ld bc, (BANK(Overworld_GFX) << 8) + $02
call CopyVideoData
ld de, Overworld_GFX + $3d0 ; $43d0 ; cuttable tree sprite bottom row
ld de, Overworld_GFX + $3d0 ; cuttable tree sprite bottom row
ld hl, vChars1 + $7e0
ld bc, (BANK(Overworld_GFX) << 8) + $02
call CopyVideoData
@ -111,7 +111,7 @@ AnimateCutTree: ; eff7 (3:6ff7)
ret
LoadCutTreeAnimationTilePattern: ; f04c (3:704c)
ld de, AnimationTileset2 + $60 ; $474e ; tile depicting a leaf
ld de, AnimationTileset2 + $60 ; tile depicting a leaf
ld bc, (BANK(AnimationTileset2) << 8) + $01
jp CopyVideoData
@ -173,7 +173,7 @@ BoulderDustAnimationOffsets: ; f097 (3:7097)
Func_f09f: ; f09f (3:709f)
push de
ld a, [W_CURMAPWIDTH] ; wd369
ld a, [W_CURMAPWIDTH]
add $6
ld c, a
ld b, $0
@ -190,22 +190,22 @@ Func_f09f: ; f09f (3:709f)
jr z, .asm_f0cf
cp $8
jr z, .asm_f0d7
ld a, [W_XBLOCKCOORD] ; wd364
ld a, [W_XBLOCKCOORD]
and a
jr z, .asm_f0e0
jr .asm_f0ec
.asm_f0c7
ld a, [W_YBLOCKCOORD] ; wd363
ld a, [W_YBLOCKCOORD]
and a
jr z, .asm_f0e0
jr .asm_f0df
.asm_f0cf
ld a, [W_YBLOCKCOORD] ; wd363
ld a, [W_YBLOCKCOORD]
and a
jr z, .asm_f0e1
jr .asm_f0e0
.asm_f0d7
ld a, [W_XBLOCKCOORD] ; wd364
ld a, [W_XBLOCKCOORD]
and a
jr z, .asm_f0e6
jr .asm_f0e0

View file

@ -15,9 +15,9 @@ Func_79e96: ; 79e96 (1e:5e96)
ld [wd08a], a
ld c, $2
call AdjustOAMBlockXPos2
ld a, [rOBP1] ; $ff49
ld a, [rOBP1]
xor $64
ld [rOBP1], a ; $ff49
ld [rOBP1], a
call DelayFrame
pop bc
dec c
@ -65,9 +65,9 @@ Func_79eed: ; 79eed (1e:5eed)
ld [wd08a], a
ld c, $1
call AdjustOAMBlockXPos2
ld a, [rOBP1] ; $ff49
ld a, [rOBP1]
xor $64
ld [rOBP1], a ; $ff49
ld [rOBP1], a
call DelayFrame
pop bc
dec c

View file

@ -1,8 +1,8 @@
; returns whether the player is standing on a door tile in carry
IsPlayerStandingOnDoorTile: ; 1a609 (6:6609)
push de
ld hl, DoorTileIDPointers ; $662c
ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
ld hl, DoorTileIDPointers
ld a, [W_CURMAPTILESET]
ld de, $3
call IsInArray
pop de

View file

@ -10,7 +10,7 @@ ShakeElevator: ; 7bf15 (1e:7f15)
ld d, a
ld e, $1
; number of times to play collision sfx
ld b, $64
ld b, 100
.asm_7bf30
ld a, e
xor $fe
@ -22,7 +22,7 @@ ShakeElevator: ; 7bf15 (1e:7f15)
ld a, (SFX_02_5b - SFX_Headers_02) / 3
call PlayMusic
pop bc
ld c, $2
ld c, 2
call DelayFrames
dec b
jr nz, .asm_7bf30

View file

@ -2,7 +2,7 @@ EmotionBubble: ; 17c47 (5:7c47)
ld a, [wcd50]
ld c, a
ld b, $0
ld hl, EmotionBubblesPointerTable ; $7caf
ld hl, EmotionBubblesPointerTable
add hl, bc
add hl, bc
ld e, [hl]
@ -45,10 +45,10 @@ EmotionBubble: ; 17c47 (5:7c47)
ld a, [hl]
add $8
ld c, a
ld de, EmotionBubblesOAM ; $7cb5
ld de, EmotionBubblesOAM
xor a
call WriteOAMBlock
ld c, $3c
ld c, 60
call DelayFrames
pop af
ld [wUpdateSpritesEnabled], a

View file

@ -1,5 +1,5 @@
AnimateHealingMachine: ; 70433 (1c:4433)
ld de, PokeCenterFlashingMonitorAndHealBall ; $44b7
ld de, PokeCenterFlashingMonitorAndHealBall
ld hl, vChars0 + $7c0
ld bc, (BANK(PokeCenterFlashingMonitorAndHealBall) << 8) + $03
call CopyVideoData
@ -8,12 +8,12 @@ AnimateHealingMachine: ; 70433 (1c:4433)
push af
ld [hl], $ff
push hl
ld a, [rOBP1] ; $ff49
ld a, [rOBP1]
push af
ld a, $e0
ld [rOBP1], a ; $ff49
ld [rOBP1], a
ld hl, wOAMBuffer + $84
ld de, PokeCenterOAMData ; $44d7
ld de, PokeCenterOAMData
call Func_70503
ld a, $4
ld [wMusicHeaderPointer], a
@ -24,13 +24,13 @@ AnimateHealingMachine: ; 70433 (1c:4433)
ld a, [wMusicHeaderPointer]
and a
jr nz, .asm_70464
ld a, [wPartyCount] ; wPartyCount
ld a, [wPartyCount]
ld b, a
.asm_7046e
call Func_70503
ld a, (SFX_02_4a - SFX_Headers_02) / 3
call PlaySound
ld c, $1e
ld c, 30
call DelayFrames
dec b
jr nz, .asm_7046e
@ -53,10 +53,10 @@ AnimateHealingMachine: ; 70433 (1c:4433)
ld a, [wc026]
cp MUSIC_PKMN_HEALED
jr z, .asm_704a2
ld c, $20
ld c, 32
call DelayFrames
pop af
ld [rOBP1], a ; $ff49
ld [rOBP1], a
pop hl
pop af
ld [hl], a

View file

@ -22,7 +22,6 @@ HiddenItems: ; 76688 (1d:6688)
INCLUDE "data/hidden_item_coords.asm"
FoundHiddenItemText: ; 7675b (1d:675b)
; XXX where is the pointer to this?
TX_FAR _FoundHiddenItemText
db $8
ld a, [wWhichTrade] ; item ID
@ -36,8 +35,8 @@ FoundHiddenItemText: ; 7675b (1d:675b)
ld b, $1
predef FlagActionPredef
ld a, (SFX_02_3b - SFX_Headers_02) / 3
call PlaySoundWaitForCurrent ; play sound
call WaitForSoundToFinish ; wait for sound to finish playing
call PlaySoundWaitForCurrent
call WaitForSoundToFinish
jp TextScriptEnd
.BagFull
call WaitForTextScrollButtonPress ; wait for button press
@ -146,10 +145,10 @@ Func_76857: ; 76857 (1d:6857)
cp $ff ; end of the list?
ret z ; if so, we're done here
cp b
jr nz, .asm_76877 ; 0x7686b $a
jr nz, .asm_76877
ld a, [hli]
cp d
jr nz, .asm_76878 ; 0x7686f $7
jr nz, .asm_76878
ld a, [hli]
cp e
jr nz, .loop

View file

@ -1,7 +1,7 @@
PickupItem:
call EnableAutoTextBoxDrawing
ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
ld a, [H_DOWNARROWBLINKCNT2]
ld b, a
ld hl, W_MISSABLEOBJECTLIST
.missableObjectsListLoop
@ -18,7 +18,7 @@ PickupItem:
ld [$ffdb], a
ld hl, W_MAPSPRITEEXTRADATA
ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
ld a, [H_DOWNARROWBLINKCNT2]
dec a
add a
ld d, 0

View file

@ -2,7 +2,7 @@ HandleLedges: ; 1a672 (6:6672)
ld a, [wd736]
bit 6, a ; already jumping down ledge
ret nz
ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
ld a, [W_CURMAPTILESET]
and a ; OVERWORLD
ret nz
predef GetTileAndCoordsInFrontOfPlayer

View file

@ -22,7 +22,7 @@ UpdatePlayerSprite: ; 4e31 (1:4e31)
.lowerLeftTileIsMapTile
call DetectCollisionBetweenSprites
ld h, $c1
ld a, [wWalkCounter] ; wcfc5
ld a, [wWalkCounter]
and a
jr nz, .asm_4e90
ld a, [wd528]
@ -108,7 +108,7 @@ Func_4ed1: ; 4ed1 (1:4ed1)
swap a
dec a
add a
ld hl, W_MAPSPRITEDATA ; wd4e4
ld hl, W_MAPSPRITEDATA
add l
ld l, a
ld a, [hl] ; read movement byte 2
@ -138,7 +138,7 @@ Func_4ed1: ; 4ed1 (1:4ed1)
jp z, UpdateSpriteMovementDelay ; c1x1 == 2
cp $3
jp z, UpdateSpriteInWalkingAnimation ; c1x1 == 3
ld a, [wWalkCounter] ; wcfc5
ld a, [wWalkCounter]
and a
ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability)
call InitializeSpriteScreenPosition
@ -212,7 +212,7 @@ Func_4ed1: ; 4ed1 (1:4ed1)
cp $2
jr z, .moveRight ; movement byte 2 = $2 only allows left or right
.moveUp
ld de, -2*20 ; $ffd8
ld de, -2*20
add hl, de ; move tile pointer two rows up
ld de, $ff00
ld bc, $804
@ -440,7 +440,7 @@ InitializeSpriteScreenPosition: ; 50bd (1:50bd)
ld a, [H_CURRENTSPRITEOFFSET]
add $4
ld l, a
ld a, [W_YCOORD] ; wd361
ld a, [W_YCOORD]
ld b, a
ld a, [hl] ; c2x4 (Y position + 4)
sub b ; relative to player position
@ -449,7 +449,7 @@ InitializeSpriteScreenPosition: ; 50bd (1:50bd)
dec h
ld [hli], a ; c1x4 (screen Y position)
inc h
ld a, [W_XCOORD] ; wd362
ld a, [W_XCOORD]
ld b, a
ld a, [hli] ; c2x6 (X position + 4)
sub b ; relative to player position
@ -475,7 +475,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc)
add $4
ld l, a
ld b, [hl] ; c2x4: Y pos (+4)
ld a, [W_YCOORD] ; wd361
ld a, [W_YCOORD]
cp b
jr z, .skipYVisibilityTest
jr nc, .spriteInvisible ; above screen region
@ -485,7 +485,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc)
.skipYVisibilityTest
inc l
ld b, [hl] ; c2x5: X pos (+4)
ld a, [W_XCOORD] ; wd362
ld a, [W_XCOORD]
cp b
jr z, .skipXVisibilityTest
jr nc, .spriteInvisible ; left of screen region
@ -503,7 +503,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc)
ld a, [hld]
cp d
jr nc, .spriteInvisible ; standing on tile with ID >=$60 (bottom right tile)
ld bc, -20 ; $ffec
ld bc, -20
add hl, bc ; go back one row of tiles
ld a, [hli]
cp d
@ -521,7 +521,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc)
jr .done
.spriteVisible
ld c, a
ld a, [wWalkCounter] ; wcfc5
ld a, [wWalkCounter]
and a
jr nz, .done ; if player is currently walking, we're done
call UpdateSpriteImage

View file

@ -52,7 +52,7 @@ ProfOakMovementScriptPointerTable: ; 1a442 (6:6442)
dw Func_1a4f4
Func_1a44c: ; 1a44c (6:644c)
ld a, [W_XCOORD] ; wd362
ld a, [W_XCOORD]
sub $a
ld [wcca1], a
jr z, .asm_1a475
@ -63,7 +63,7 @@ Func_1a44c: ; 1a44c (6:644c)
call FillMemory
ld [hl], $ff
ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
ld [H_DOWNARROWBLINKCNT2], a
ld de, wNPCMovementDirections2
call MoveSprite
ld a, $1

View file

@ -1,10 +1,10 @@
OaksAideScript ; 0x59035
OaksAideScript: ; 0x59035
ld hl, OaksAideHiText
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jr nz, .asm_59086 ; 0x59042 $42
jr nz, .asm_59086
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
@ -13,8 +13,8 @@ OaksAideScript ; 0x59035
ld b, a
ld a, [$ffdb]
cp b
jr z, .asm_59059 ; 0x59055 $2
jr nc, .asm_5907c ; 0x59057 $23
jr z, .asm_59059
jr nc, .asm_5907c
.asm_59059
ld hl, OaksAideHereYouGoText
call PrintText
@ -26,17 +26,17 @@ OaksAideScript ; 0x59035
ld hl, OaksAideGotItemText
call PrintText
ld a, $1
jr .asm_5908e ; 0x59071 $1b
jr .asm_5908e
.BagFull
ld hl, OaksAideNoRoomText
call PrintText
xor a
jr .asm_5908e ; 0x5907a $12
jr .asm_5908e
.asm_5907c
ld hl, OaksAideUhOhText
call PrintText
ld a, $80
jr .asm_5908e ; 0x59084 $8
jr .asm_5908e
.asm_59086
ld hl, OaksAideComeBackText
call PrintText

View file

@ -58,7 +58,7 @@ EnterMapAnim: ; 70510 (1c:4510)
ld a, 12
ld [hli], a ; wFlyAnimCounter
ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing right)
ld de, FlyAnimationEnterScreenCoords ; $4592
ld de, FlyAnimationEnterScreenCoords
call DoFlyAnimation
call LoadPlayerSpriteGraphics
jr .restoreDefaultMusic
@ -154,7 +154,7 @@ _LeaveMapAnim: ; 705ba (1c:45ba)
ld a, $c
ld [hli], a ; wFlyAnimCounter
ld [hl], $c ; wFlyAnimBirdSpriteImageIndex (facing right)
ld de, FlyAnimationScreenCoords1 ; $464f
ld de, FlyAnimationScreenCoords1
call DoFlyAnimation
ld c, 40
call DelayFrames
@ -162,7 +162,7 @@ _LeaveMapAnim: ; 705ba (1c:45ba)
ld a, 11
ld [hli], a ; wFlyAnimCounter
ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing left)
ld de, FlyAnimationScreenCoords2 ; $4667
ld de, FlyAnimationScreenCoords2
call DoFlyAnimation
call GBFadeOutToWhite
jp RestoreFacingDirectionAndYScreenPos
@ -248,11 +248,11 @@ DoFlyAnimation: ; 706ae (1c:46ae)
ret
LoadBirdSpriteGraphics: ; 706d7 (1c:46d7)
ld de, BirdSprite ; $4d80
ld de, BirdSprite
ld hl, vNPCSprites
ld bc, (BANK(BirdSprite) << 8) + $0c
call CopyVideoData
ld de, BirdSprite + $c0 ; $4e40 ; moving amination sprite
ld de, BirdSprite + $c0 ; moving amination sprite
ld hl, vNPCSprites2
ld bc, (BANK(BirdSprite) << 8) + $0c
jp CopyVideoData
@ -379,28 +379,28 @@ IsPlayerStandingOnWarpPadOrHole: ; 70787 (1c:4787)
db $FF
Func_707b6: ; 707b6 (1c:47b6)
ld c, $a
ld c, 10
call DelayFrames
ld hl, wd736
set 6, [hl]
ld de, RedSprite ; $4180
ld de, RedSprite
ld hl, vNPCSprites
ld bc, (BANK(RedSprite) << 8) + $0c
call CopyVideoData
ld a, $4
ld hl, RedFishingTiles ; $4866
ld hl, RedFishingTiles
call LoadAnimSpriteGfx
ld a, [wSpriteStateData1 + 2]
ld c, a
ld b, $0
ld hl, FishingRodGfxProperties ; $4856
ld hl, FishingRodGfxProperties
add hl, bc
ld de, wOAMBuffer + $9c
ld bc, $4
call CopyData
ld c, $64
ld c, 100
call DelayFrames
ld a, [wWhichTrade] ; wWhichTrade
ld a, [wWhichTrade]
and a
ld hl, NoNibbleText
jr z, .asm_70836

View file

@ -43,7 +43,7 @@ DisplayPokemonCenterDialogue_: ; 6fe6 (1:6fe6)
.done
ld hl, PokemonCenterFarewellText
call PrintText
jp UpdateSprites ; move sprites
jp UpdateSprites
PokemonCenterWelcomeText: ; 705d (1:705d)
TX_FAR _PokemonCenterWelcomeText

View file

@ -1,7 +1,7 @@
DisplayPokemartDialogue_: ; 6c20 (1:6c20)
ld a,[wListScrollOffset]
ld [wd07e],a
call UpdateSprites ; move sprites
call UpdateSprites
xor a
ld [wcf0a],a ; flag that is set if something is sold or bought
.loop
@ -36,7 +36,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
ld [wcf93],a
ld a,$02
ld [wd11b],a
callab Func_39bd5
callab InitList
ld a,[wNumBagItems]
and a
jp z,.bagEmpty
@ -113,7 +113,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
ld [wcf93],a
ld a,$03
ld [wd11b],a
callab Func_39bd5
callab InitList
ld hl,PokemartBuyingGreetingText
call PrintText
call SaveScreenTilesToBuffer1 ; save screen
@ -204,7 +204,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
call PrintText
ld a,$01
ld [wUpdateSpritesEnabled],a
call UpdateSprites ; move sprites
call UpdateSprites
ld a,[wd07e]
ld [wListScrollOffset],a
ret

View file

@ -84,7 +84,7 @@ LoadSmokeTileFourTimes: ; 79fc0 (1e:5fc0)
ret
LoadSmokeTile: ; 79fd4 (1e:5fd4)
ld de, SSAnneSmokePuffTile ; $5fdd
ld de, SSAnneSmokePuffTile
ld bc, (BANK(SSAnneSmokePuffTile) << 8) + $01
jp CopyVideoData

View file

@ -77,7 +77,7 @@ _SetSpritePosition2: ; 5685d (15:685d)
TrainerWalkUpToPlayer: ; 56881 (15:6881)
ld a, [wSpriteIndex]
swap a
ld [wTrainerSpriteOffset], a ; wWhichTrade
ld [wTrainerSpriteOffset], a
call ReadTrainerScreenPosition
ld a, [wTrainerFacingDirection]
and a
@ -164,7 +164,7 @@ GetSpriteDataPointer: ; 56903 (15:6903)
TrainerEngage: ; 5690f (15:690f)
push hl
push de
ld a, [wTrainerSpriteOffset] ; wWhichTrade
ld a, [wTrainerSpriteOffset]
add $2
ld d, $0
ld e, a
@ -175,7 +175,7 @@ TrainerEngage: ; 5690f (15:690f)
jr nz, .spriteOnScreen ; test if sprite is on screen
jp .noEngage
.spriteOnScreen
ld a, [wTrainerSpriteOffset] ; wWhichTrade
ld a, [wTrainerSpriteOffset]
add $9
ld d, $0
ld e, a
@ -218,7 +218,7 @@ TrainerEngage: ; 5690f (15:690f)
jp .noEngage
.engage
call CheckPlayerIsInFrontOfSprite
ld a, [wTrainerSpriteOffset] ; wWhichTrade
ld a, [wTrainerSpriteOffset]
and a
jr z, .noEngage
ld hl, wFlags_0xcd60
@ -226,14 +226,14 @@ TrainerEngage: ; 5690f (15:690f)
call EngageMapTrainer
ld a, $ff
.noEngage: ; 56988 (15:6988)
ld [wTrainerSpriteOffset], a ; wWhichTrade
ld [wTrainerSpriteOffset], a
pop de
pop hl
ret
; reads trainer's Y position to wTrainerScreenY and X position to wTrainerScreenX
ReadTrainerScreenPosition: ; 5698e (15:698e)
ld a, [wTrainerSpriteOffset] ; wWhichTrade
ld a, [wTrainerSpriteOffset]
add $4
ld d, $0
ld e, a
@ -241,7 +241,7 @@ ReadTrainerScreenPosition: ; 5698e (15:698e)
add hl, de
ld a, [hl]
ld [wTrainerScreenY], a
ld a, [wTrainerSpriteOffset] ; wWhichTrade
ld a, [wTrainerSpriteOffset]
add $6
ld d, $0
ld e, a
@ -291,10 +291,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] ; W_CURMAP
ld a, [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] ; wWhichTrade
jp z, .engage ; bypass this for power plant to get voltorb fake items to work
ld a, [wTrainerSpriteOffset]
add $4
ld d, $0
ld e, a
@ -306,7 +306,7 @@ CheckPlayerIsInFrontOfSprite: ; 569e3 (15:69e3)
ld a, $c
.notOnTopmostTile
ld [wTrainerScreenY], a
ld a, [wTrainerSpriteOffset] ; wWhichTrade
ld a, [wTrainerSpriteOffset]
add $6
ld d, $0
ld e, a
@ -345,5 +345,5 @@ CheckPlayerIsInFrontOfSprite: ; 569e3 (15:69e3)
.noEngage
xor a
.done
ld [wTrainerSpriteOffset], a ; wWhichTrade
ld [wTrainerSpriteOffset], a
ret