summaryrefslogtreecommitdiff
path: root/yellow
diff options
context:
space:
mode:
Diffstat (limited to 'yellow')
-rw-r--r--yellow/bank3c/overworld.asm482
-rw-r--r--yellow/bank3d/random.asm30
-rw-r--r--yellow/bank3f/main.asm480
3 files changed, 496 insertions, 496 deletions
diff --git a/yellow/bank3c/overworld.asm b/yellow/bank3c/overworld.asm
index e601ff52..778244d6 100644
--- a/yellow/bank3c/overworld.asm
+++ b/yellow/bank3c/overworld.asm
@@ -1,242 +1,242 @@
-_AdvancePlayerSprite:: ; f010c (3c:410c)
- ld a,[wSpriteStateData1 + 3] ; delta Y
- ld b,a
- ld a,[wSpriteStateData1 + 5] ; delta X
- ld c,a
- ld hl,wWalkCounter ; walking animation counter
- dec [hl]
- jr nz,.afterUpdateMapCoords
-; if it's the end of the animation, update the player's map coordinates
- ld a,[W_YCOORD]
- add b
- ld [W_YCOORD],a
- ld a,[W_XCOORD]
- add c
- ld [W_XCOORD],a
-.afterUpdateMapCoords
- ld a,[wWalkCounter] ; walking animation counter
- cp a,$07
- jp nz,.scrollBackgroundAndSprites
-; if this is the first iteration of the animation
- ld a,c
- cp a,$01
- jr nz,.checkIfMovingWest
-; moving east
- ld a,[wMapViewVRAMPointer]
- ld e,a
- and a,$e0
- ld d,a
- ld a,e
- add a,$02
- and a,$1f
- or d
- ld [wMapViewVRAMPointer],a
- jr .adjustXCoordWithinBlock
-.checkIfMovingWest
- cp a,$ff
- jr nz,.checkIfMovingSouth
-; moving west
- ld a,[wMapViewVRAMPointer]
- ld e,a
- and a,$e0
- ld d,a
- ld a,e
- sub a,$02
- and a,$1f
- or d
- ld [wMapViewVRAMPointer],a
- jr .adjustXCoordWithinBlock
-.checkIfMovingSouth
- ld a,b
- cp a,$01
- jr nz,.checkIfMovingNorth
-; moving south
- ld a,[wMapViewVRAMPointer]
- add a,$40
- ld [wMapViewVRAMPointer],a
- jr nc,.adjustXCoordWithinBlock
- ld a,[wMapViewVRAMPointer + 1]
- inc a
- and a,$03
- or a,$98
- ld [wMapViewVRAMPointer + 1],a
- jr .adjustXCoordWithinBlock
-.checkIfMovingNorth
- cp a,$ff
- jr nz,.adjustXCoordWithinBlock
-; moving north
- ld a,[wMapViewVRAMPointer]
- sub a,$40
- ld [wMapViewVRAMPointer],a
- jr nc,.adjustXCoordWithinBlock
- ld a,[wMapViewVRAMPointer + 1]
- dec a
- and a,$03
- or a,$98
- ld [wMapViewVRAMPointer + 1],a
-.adjustXCoordWithinBlock
- ld a,c
- and a
- jr z,.pointlessJump ; mistake?
-.pointlessJump
- ld hl,W_XBLOCKCOORD
- ld a,[hl]
- add c
- ld [hl],a
- cp a,$02
- jr nz,.checkForMoveToWestBlock
-; moved into the tile block to the east
- xor a
- ld [hl],a
- ld hl,wXOffsetSinceLastSpecialWarp
- inc [hl]
- ld de,wCurrentTileBlockMapViewPointer
- call MoveTileBlockMapPointerEast
- jr .updateMapView
-.checkForMoveToWestBlock
- cp a,$ff
- jr nz,.adjustYCoordWithinBlock
-; moved into the tile block to the west
- ld a,$01
- ld [hl],a
- ld hl,wXOffsetSinceLastSpecialWarp
- dec [hl]
- ld de,wCurrentTileBlockMapViewPointer
- call MoveTileBlockMapPointerWest
- jr .updateMapView
-.adjustYCoordWithinBlock
- ld hl,W_YBLOCKCOORD
- ld a,[hl]
- add b
- ld [hl],a
- cp a,$02
- jr nz,.checkForMoveToNorthBlock
-; moved into the tile block to the south
- xor a
- ld [hl],a
- ld hl,wYOffsetSinceLastSpecialWarp
- inc [hl]
- ld de,wCurrentTileBlockMapViewPointer
- ld a,[W_CURMAPWIDTH]
- call MoveTileBlockMapPointerSouth
- jr .updateMapView
-.checkForMoveToNorthBlock
- cp a,$ff
- jr nz,.updateMapView
-; moved into the tile block to the north
- ld a,$01
- ld [hl],a
- ld hl,wYOffsetSinceLastSpecialWarp
- dec [hl]
- ld de,wCurrentTileBlockMapViewPointer
- ld a,[W_CURMAPWIDTH]
- call MoveTileBlockMapPointerNorth
-.updateMapView
- call LoadCurrentMapView
- ld a,[wSpriteStateData1 + 3] ; delta Y
- cp a,$01
- jr nz,.checkIfMovingNorth2
-; if moving south
- call ScheduleSouthRowRedraw
- jr .scrollBackgroundAndSprites
-.checkIfMovingNorth2
- cp a,$ff
- jr nz,.checkIfMovingEast2
-; if moving north
- call ScheduleNorthRowRedraw
- jr .scrollBackgroundAndSprites
-.checkIfMovingEast2
- ld a,[wSpriteStateData1 + 5] ; delta X
- cp a,$01
- jr nz,.checkIfMovingWest2
-; if moving east
- call ScheduleEastColumnRedraw
- jr .scrollBackgroundAndSprites
-.checkIfMovingWest2
- cp a,$ff
- jr nz,.scrollBackgroundAndSprites
-; if moving west
- call ScheduleWestColumnRedraw
-.scrollBackgroundAndSprites
- ld a,[wSpriteStateData1 + 3] ; delta Y
- ld b,a
- ld a,[wSpriteStateData1 + 5] ; delta X
- ld c,a
- sla b
- sla c
- ld a,[hSCY]
- add b
- ld [hSCY],a ; update background scroll Y
- ld a,[hSCX]
- add c
- ld [hSCX],a ; update background scroll X
-; shift all the sprites in the direction opposite of the player's motion
-; so that the player appears to move relative to them
- ld hl,wSpriteStateData1 + $14
- ld a,[W_NUMSPRITES] ; number of sprites
- and a ; are there any sprites?
- jr z,.done
- ld e,a
-.spriteShiftLoop
- ld a,[hl]
- sub b
- ld [hli],a
- inc l
- ld a,[hl]
- sub c
- ld [hl],a
- ld a,$0e
- add l
- ld l,a
- dec e
- jr nz,.spriteShiftLoop
-.done
- ret
-
-MoveTileBlockMapPointerEast:: ; 0e65 (0:0e65)
- ld a,[de]
- add a,$01
- ld [de],a
- ret nc
- inc de
- ld a,[de]
- inc a
- ld [de],a
- ret
-
-MoveTileBlockMapPointerWest:: ; 0e6f (0:0e6f)
- ld a,[de]
- sub a,$01
- ld [de],a
- ret nc
- inc de
- ld a,[de]
- dec a
- ld [de],a
- ret
-
-MoveTileBlockMapPointerSouth:: ; 0e79 (0:0e79)
- add a,$06
- ld b,a
- ld a,[de]
- add b
- ld [de],a
- ret nc
- inc de
- ld a,[de]
- inc a
- ld [de],a
- ret
-
-MoveTileBlockMapPointerNorth:: ; 0e85 (0:0e85)
- add a,$06
- ld b,a
- ld a,[de]
- sub b
- ld [de],a
- ret nc
- inc de
- ld a,[de]
- dec a
- ld [de],a
+_AdvancePlayerSprite:: ; f010c (3c:410c)
+ ld a,[wSpriteStateData1 + 3] ; delta Y
+ ld b,a
+ ld a,[wSpriteStateData1 + 5] ; delta X
+ ld c,a
+ ld hl,wWalkCounter ; walking animation counter
+ dec [hl]
+ jr nz,.afterUpdateMapCoords
+; if it's the end of the animation, update the player's map coordinates
+ ld a,[W_YCOORD]
+ add b
+ ld [W_YCOORD],a
+ ld a,[W_XCOORD]
+ add c
+ ld [W_XCOORD],a
+.afterUpdateMapCoords
+ ld a,[wWalkCounter] ; walking animation counter
+ cp a,$07
+ jp nz,.scrollBackgroundAndSprites
+; if this is the first iteration of the animation
+ ld a,c
+ cp a,$01
+ jr nz,.checkIfMovingWest
+; moving east
+ ld a,[wMapViewVRAMPointer]
+ ld e,a
+ and a,$e0
+ ld d,a
+ ld a,e
+ add a,$02
+ and a,$1f
+ or d
+ ld [wMapViewVRAMPointer],a
+ jr .adjustXCoordWithinBlock
+.checkIfMovingWest
+ cp a,$ff
+ jr nz,.checkIfMovingSouth
+; moving west
+ ld a,[wMapViewVRAMPointer]
+ ld e,a
+ and a,$e0
+ ld d,a
+ ld a,e
+ sub a,$02
+ and a,$1f
+ or d
+ ld [wMapViewVRAMPointer],a
+ jr .adjustXCoordWithinBlock
+.checkIfMovingSouth
+ ld a,b
+ cp a,$01
+ jr nz,.checkIfMovingNorth
+; moving south
+ ld a,[wMapViewVRAMPointer]
+ add a,$40
+ ld [wMapViewVRAMPointer],a
+ jr nc,.adjustXCoordWithinBlock
+ ld a,[wMapViewVRAMPointer + 1]
+ inc a
+ and a,$03
+ or a,$98
+ ld [wMapViewVRAMPointer + 1],a
+ jr .adjustXCoordWithinBlock
+.checkIfMovingNorth
+ cp a,$ff
+ jr nz,.adjustXCoordWithinBlock
+; moving north
+ ld a,[wMapViewVRAMPointer]
+ sub a,$40
+ ld [wMapViewVRAMPointer],a
+ jr nc,.adjustXCoordWithinBlock
+ ld a,[wMapViewVRAMPointer + 1]
+ dec a
+ and a,$03
+ or a,$98
+ ld [wMapViewVRAMPointer + 1],a
+.adjustXCoordWithinBlock
+ ld a,c
+ and a
+ jr z,.pointlessJump ; mistake?
+.pointlessJump
+ ld hl,W_XBLOCKCOORD
+ ld a,[hl]
+ add c
+ ld [hl],a
+ cp a,$02
+ jr nz,.checkForMoveToWestBlock
+; moved into the tile block to the east
+ xor a
+ ld [hl],a
+ ld hl,wXOffsetSinceLastSpecialWarp
+ inc [hl]
+ ld de,wCurrentTileBlockMapViewPointer
+ call MoveTileBlockMapPointerEast
+ jr .updateMapView
+.checkForMoveToWestBlock
+ cp a,$ff
+ jr nz,.adjustYCoordWithinBlock
+; moved into the tile block to the west
+ ld a,$01
+ ld [hl],a
+ ld hl,wXOffsetSinceLastSpecialWarp
+ dec [hl]
+ ld de,wCurrentTileBlockMapViewPointer
+ call MoveTileBlockMapPointerWest
+ jr .updateMapView
+.adjustYCoordWithinBlock
+ ld hl,W_YBLOCKCOORD
+ ld a,[hl]
+ add b
+ ld [hl],a
+ cp a,$02
+ jr nz,.checkForMoveToNorthBlock
+; moved into the tile block to the south
+ xor a
+ ld [hl],a
+ ld hl,wYOffsetSinceLastSpecialWarp
+ inc [hl]
+ ld de,wCurrentTileBlockMapViewPointer
+ ld a,[W_CURMAPWIDTH]
+ call MoveTileBlockMapPointerSouth
+ jr .updateMapView
+.checkForMoveToNorthBlock
+ cp a,$ff
+ jr nz,.updateMapView
+; moved into the tile block to the north
+ ld a,$01
+ ld [hl],a
+ ld hl,wYOffsetSinceLastSpecialWarp
+ dec [hl]
+ ld de,wCurrentTileBlockMapViewPointer
+ ld a,[W_CURMAPWIDTH]
+ call MoveTileBlockMapPointerNorth
+.updateMapView
+ call LoadCurrentMapView
+ ld a,[wSpriteStateData1 + 3] ; delta Y
+ cp a,$01
+ jr nz,.checkIfMovingNorth2
+; if moving south
+ call ScheduleSouthRowRedraw
+ jr .scrollBackgroundAndSprites
+.checkIfMovingNorth2
+ cp a,$ff
+ jr nz,.checkIfMovingEast2
+; if moving north
+ call ScheduleNorthRowRedraw
+ jr .scrollBackgroundAndSprites
+.checkIfMovingEast2
+ ld a,[wSpriteStateData1 + 5] ; delta X
+ cp a,$01
+ jr nz,.checkIfMovingWest2
+; if moving east
+ call ScheduleEastColumnRedraw
+ jr .scrollBackgroundAndSprites
+.checkIfMovingWest2
+ cp a,$ff
+ jr nz,.scrollBackgroundAndSprites
+; if moving west
+ call ScheduleWestColumnRedraw
+.scrollBackgroundAndSprites
+ ld a,[wSpriteStateData1 + 3] ; delta Y
+ ld b,a
+ ld a,[wSpriteStateData1 + 5] ; delta X
+ ld c,a
+ sla b
+ sla c
+ ld a,[hSCY]
+ add b
+ ld [hSCY],a ; update background scroll Y
+ ld a,[hSCX]
+ add c
+ ld [hSCX],a ; update background scroll X
+; shift all the sprites in the direction opposite of the player's motion
+; so that the player appears to move relative to them
+ ld hl,wSpriteStateData1 + $14
+ ld a,[W_NUMSPRITES] ; number of sprites
+ and a ; are there any sprites?
+ jr z,.done
+ ld e,a
+.spriteShiftLoop
+ ld a,[hl]
+ sub b
+ ld [hli],a
+ inc l
+ ld a,[hl]
+ sub c
+ ld [hl],a
+ ld a,$0e
+ add l
+ ld l,a
+ dec e
+ jr nz,.spriteShiftLoop
+.done
+ ret
+
+MoveTileBlockMapPointerEast:: ; 0e65 (0:0e65)
+ ld a,[de]
+ add a,$01
+ ld [de],a
+ ret nc
+ inc de
+ ld a,[de]
+ inc a
+ ld [de],a
+ ret
+
+MoveTileBlockMapPointerWest:: ; 0e6f (0:0e6f)
+ ld a,[de]
+ sub a,$01
+ ld [de],a
+ ret nc
+ inc de
+ ld a,[de]
+ dec a
+ ld [de],a
+ ret
+
+MoveTileBlockMapPointerSouth:: ; 0e79 (0:0e79)
+ add a,$06
+ ld b,a
+ ld a,[de]
+ add b
+ ld [de],a
+ ret nc
+ inc de
+ ld a,[de]
+ inc a
+ ld [de],a
+ ret
+
+MoveTileBlockMapPointerNorth:: ; 0e85 (0:0e85)
+ add a,$06
+ ld b,a
+ ld a,[de]
+ sub b
+ ld [de],a
+ ret nc
+ inc de
+ ld a,[de]
+ dec a
+ ld [de],a
ret \ No newline at end of file
diff --git a/yellow/bank3d/random.asm b/yellow/bank3d/random.asm
index c7245c3e..b7fb0edd 100644
--- a/yellow/bank3d/random.asm
+++ b/yellow/bank3d/random.asm
@@ -1,15 +1,15 @@
-SECTION "bank3d",ROMX[$67DC],BANK[$3D]
-
-Random_::
-; Generate a random 16-bit value.
- ld a, [rDIV]
- ld b, a
- ld a, [hRandomAdd]
- adc b
- ld [hRandomAdd], a
- ld a, [rDIV]
- ld b, a
- ld a, [hRandomSub]
- sbc b
- ld [hRandomSub], a
- ret
+SECTION "bank3d",ROMX[$67DC],BANK[$3D]
+
+Random_::
+; Generate a random 16-bit value.
+ ld a, [rDIV]
+ ld b, a
+ ld a, [hRandomAdd]
+ adc b
+ ld [hRandomAdd], a
+ ld a, [rDIV]
+ ld b, a
+ ld a, [hRandomSub]
+ sbc b
+ ld [hRandomSub], a
+ ret
diff --git a/yellow/bank3f/main.asm b/yellow/bank3f/main.asm
index 06fc81bb..c9662acd 100644
--- a/yellow/bank3f/main.asm
+++ b/yellow/bank3f/main.asm
@@ -1,240 +1,240 @@
-INCLUDE "yellow/bank3f/data/map_songs.asm"
-INCLUDE "yellow/bank3f/data/map_header_pointers.asm"
-INCLUDE "yellow/bank3f/data/map_header_banks.asm"
-
-Func_fc4dd:: ; fc4dd (3f:44dd)
-; possibly to test if pika should be out?
- ld a,[wd430]
- bit 5,a
- jr nz,.asm_fc4f8 ; 3f:44f8
- ld a,[wd430]
- bit 7,a
- jr nz,.asm_fc4f8
- call Func_fcdb8
- jr nc,.asm_fc4f8
- ld a,[wWalkBikeSurfState]
- and a
- jr nz,.asm_fc4f8
- scf
- ret
-.asm_fc4f8
- and a
- ret
-
-Func_fc5fa:: ; fc5fa (3f:44fa)
- ld hl,wd430
- bit 4,[hl]
- res 4,[hl]
- jr nz,.asm_fc515
- call Func_1542
- call Func_fc523
- ld a,$ff
- ld [wSpriteStateData1 + $f2],a
- call Func_fcb84
- call Func_fc5bc
- ret
-
-.asm_fc515
- call Func_fc53f
- xor a
- ld [wd431],a
- ld a,[wSpriteStateData1 + $9]
- ld [wSpriteStateData1 + $f9],a
- ret
-
-Func_fc523:: ; fc523 (3f:4523)
- ld hl,wSpriteStateData1 + $f0
- call Func_fc52c
- ld hl,wSpriteStateData2 + $f0
-Func_fc52c:: ; fc52c (3f:4523)
- ld bc,$10
- xor a
- call FillMemory
- ret
-
-Func_fc534:: ; fc534 (3f:4534)
- call Func_fc53f
- call Func_fc5bc
- xor a
- ld [wd431],a
- ret
-
-Func_fc53f:: ; fc53f (3f:453f)
- ld bc,wSpriteStateData1 + $10
- ld a,[W_YCOORD]
- add $4
- ld e,a
- ld a,[W_XCOORD]
- add $4
- ld d,a
- ld a,[wd431]
- and a
- jr z,.asm_fc5aa
- cp $1
- jr z,.asm_fc59e
- cp $2
- jr z,.asm_fc584
- cp $3
- jr z,.asm_fc5aa
- cp $4
- jr z,.asm_fc5a4
- cp $5
- jr z,.asm_fc5a7
- cp $6
- jr z,.asm_fc5a1
- cp $7
- jr z,.asm_fc572
- jr .asm_fc59e
-
-.asm_fc572
- ld a,[wSpriteStateData1 + $9]
- and a ; SPRITE_FACING_DOWN
- jr z,.asm_fc5a4
- cp SPRITE_FACING_UP
- jr z,.asm_fc5a7
- cp SPRITE_FACING_LEFT
- jr z,.asm_fc5a1
- cp SPRITE_FACING_RIGHT
- jr z,.asm_fc59e
-.asm_fc584
- ld a,[wSpriteStateData1 + $9]
- and a
- jr nz,.asm_fc58d
- dec e
- jr .asm_fc5aa
-.asm_fc58d
- cp SPRITE_FACING_UP
- jr nz,.asm_fc594
- inc e
- jr .asm_fc5aa
-.asm_fc594
- cp SPRITE_FACING_LEFT
- jr nz,.asm_fc59b
- inc d
- jr .asm_fc5aa
-.asm_fc59b
- dec d
- jr .asm_fc5aa
-.asm_fc59e
- inc d
- jr .asm_fc5aa
-.asm_fc5a1
- dec d
- jr .asm_fc5aa
-.asm_fc5a4
- inc e
- jr .asm_fc5aa
-.asm_fc5a7
- dec e
- jr .asm_fc5aa ; useless jr
-.asm_fc5aa
- ld hl,$104
- add hl,bc
- ld [hl],e
- inc hl
- ld [hl],d
- inc hl
-Func_fc4b2:: ; fc4b2 (3f:44b2)
- ld [hl],$fe
- push hl
- ld hl,wd472
- set 5,[hl]
- pop hl
- ret
-
-Func_fc5bc:: ; fc5bc (3f:45bc)
- ld a,$49
- ld [wSpriteStateData1 + $f0],a
- ld a,$ff
- ld [wSpriteStateData1 + $f2],a
- ld a,[wd431]
- and a
- jr z,.asm_fc5e4
- cp $1
- jr z,.asm_fc5e4
- cp $3
- jr z,.asm_fc5eb
- cp $4
- jr z,.asm_fc5e4
- cp $6
- jr z,.asm_fc5e4
- cp $7
- jr z,.asm_fc5f1
- call Func_fc4b2
- ret
-
-.asm_fc5e4
- ld a,[wSpriteStateData1 + $9]
- ld [wSpriteStateData1 + $f9],a
- ret
-.asm_fc5eb
- ld a,$0
- ld [wSpriteStateData1 + $f9],a
- ret
-.asm_fc5f1
- ld a,[wSpriteStateData1 + $9]
- xor $4
- ld [wSpriteStateData1 + $f9],a
- ret
-
-Func_fc5fa:: ; fc5fa (3f:45fa)
- ld a,[W_CURMAP]
- cp OAKS_LAB
- jr z,.asm_fc63d
- cp ROUTE_22_GATE
- jr z,.asm_fc62d
- cp MT_MOON_2
- jr z,.asm_fc635
- cp ROCK_TUNNEL_1
- jr z,.asm_fc645
- ld a,[W_CURMAP]
- ld hl,Pointer_fc64b
- call Func_1568 ; similar to IsInArray, but not the same
- jr c,.asm_fc639
- ld a,[W_CURMAP]
- ld hl,Pointer_fc653
- call Func_1568
- jr nc,.asm_fc641
- ld a,[wSpriteStateData1 + $9]
- and a
- jr nz,.asm_fc641
- ld a,$3
- jr .asm_fc647
-
-.asm_fc62d
- ld a,[wSpriteStateData1 + $9]
- and a
- jr z,.asm_fc645
- jr .asm_fc641
-.asm_fc635
- ld a,$3
- jr .asm_fc647
-.asm_fc639
- ld a,$4
- jr .asm_fc647
-.asm_fc63d
- ld a,$6
- jr .asm_fc647
-.asm_fc641
- ld a,$1
- jr .asm_fc647
-.asm_fc645
- ld a,$3
-.asm_fc647
- ld [wd431],a
- ret
-
-Pointer_fc64b:: ; fc64b (3f:464b)
- db $c2,$4c,$4f,$ba,$be,$b8,$54,$ff
-
-Pointer_fc653:: ; fc653 (3f:4653)
- db $2f,$e6,$3e,$5e,$80,$31,$a4,$ff
-
-Func_fc65b:: ; fc65b (3f:465b)
- ld a,[W_CURMAP]
-
-Func_fc69a:: ; fc69a (3f:469a)
-
-Func_fcc08:: ; fcc08 (3f:4c08)
-
-Func_fcf0c:: ; fcf0c (3f:4f0c)
+INCLUDE "yellow/bank3f/data/map_songs.asm"
+INCLUDE "yellow/bank3f/data/map_header_pointers.asm"
+INCLUDE "yellow/bank3f/data/map_header_banks.asm"
+
+Func_fc4dd:: ; fc4dd (3f:44dd)
+; possibly to test if pika should be out?
+ ld a,[wd430]
+ bit 5,a
+ jr nz,.asm_fc4f8 ; 3f:44f8
+ ld a,[wd430]
+ bit 7,a
+ jr nz,.asm_fc4f8
+ call Func_fcdb8
+ jr nc,.asm_fc4f8
+ ld a,[wWalkBikeSurfState]
+ and a
+ jr nz,.asm_fc4f8
+ scf
+ ret
+.asm_fc4f8
+ and a
+ ret
+
+Func_fc5fa:: ; fc5fa (3f:44fa)
+ ld hl,wd430
+ bit 4,[hl]
+ res 4,[hl]
+ jr nz,.asm_fc515
+ call Func_1542
+ call Func_fc523
+ ld a,$ff
+ ld [wSpriteStateData1 + $f2],a
+ call Func_fcb84
+ call Func_fc5bc
+ ret
+
+.asm_fc515
+ call Func_fc53f
+ xor a
+ ld [wd431],a
+ ld a,[wSpriteStateData1 + $9]
+ ld [wSpriteStateData1 + $f9],a
+ ret
+
+Func_fc523:: ; fc523 (3f:4523)
+ ld hl,wSpriteStateData1 + $f0
+ call Func_fc52c
+ ld hl,wSpriteStateData2 + $f0
+Func_fc52c:: ; fc52c (3f:4523)
+ ld bc,$10
+ xor a
+ call FillMemory
+ ret
+
+Func_fc534:: ; fc534 (3f:4534)
+ call Func_fc53f
+ call Func_fc5bc
+ xor a
+ ld [wd431],a
+ ret
+
+Func_fc53f:: ; fc53f (3f:453f)
+ ld bc,wSpriteStateData1 + $10
+ ld a,[W_YCOORD]
+ add $4
+ ld e,a
+ ld a,[W_XCOORD]
+ add $4
+ ld d,a
+ ld a,[wd431]
+ and a
+ jr z,.asm_fc5aa
+ cp $1
+ jr z,.asm_fc59e
+ cp $2
+ jr z,.asm_fc584
+ cp $3
+ jr z,.asm_fc5aa
+ cp $4
+ jr z,.asm_fc5a4
+ cp $5
+ jr z,.asm_fc5a7
+ cp $6
+ jr z,.asm_fc5a1
+ cp $7
+ jr z,.asm_fc572
+ jr .asm_fc59e
+
+.asm_fc572
+ ld a,[wSpriteStateData1 + $9]
+ and a ; SPRITE_FACING_DOWN
+ jr z,.asm_fc5a4
+ cp SPRITE_FACING_UP
+ jr z,.asm_fc5a7
+ cp SPRITE_FACING_LEFT
+ jr z,.asm_fc5a1
+ cp SPRITE_FACING_RIGHT
+ jr z,.asm_fc59e
+.asm_fc584
+ ld a,[wSpriteStateData1 + $9]
+ and a
+ jr nz,.asm_fc58d
+ dec e
+ jr .asm_fc5aa
+.asm_fc58d
+ cp SPRITE_FACING_UP
+ jr nz,.asm_fc594
+ inc e
+ jr .asm_fc5aa
+.asm_fc594
+ cp SPRITE_FACING_LEFT
+ jr nz,.asm_fc59b
+ inc d
+ jr .asm_fc5aa
+.asm_fc59b
+ dec d
+ jr .asm_fc5aa
+.asm_fc59e
+ inc d
+ jr .asm_fc5aa
+.asm_fc5a1
+ dec d
+ jr .asm_fc5aa
+.asm_fc5a4
+ inc e
+ jr .asm_fc5aa
+.asm_fc5a7
+ dec e
+ jr .asm_fc5aa ; useless jr
+.asm_fc5aa
+ ld hl,$104
+ add hl,bc
+ ld [hl],e
+ inc hl
+ ld [hl],d
+ inc hl
+Func_fc4b2:: ; fc4b2 (3f:44b2)
+ ld [hl],$fe
+ push hl
+ ld hl,wd472
+ set 5,[hl]
+ pop hl
+ ret
+
+Func_fc5bc:: ; fc5bc (3f:45bc)
+ ld a,$49
+ ld [wSpriteStateData1 + $f0],a
+ ld a,$ff
+ ld [wSpriteStateData1 + $f2],a
+ ld a,[wd431]
+ and a
+ jr z,.asm_fc5e4
+ cp $1
+ jr z,.asm_fc5e4
+ cp $3
+ jr z,.asm_fc5eb
+ cp $4
+ jr z,.asm_fc5e4
+ cp $6
+ jr z,.asm_fc5e4
+ cp $7
+ jr z,.asm_fc5f1
+ call Func_fc4b2
+ ret
+
+.asm_fc5e4
+ ld a,[wSpriteStateData1 + $9]
+ ld [wSpriteStateData1 + $f9],a
+ ret
+.asm_fc5eb
+ ld a,$0
+ ld [wSpriteStateData1 + $f9],a
+ ret
+.asm_fc5f1
+ ld a,[wSpriteStateData1 + $9]
+ xor $4
+ ld [wSpriteStateData1 + $f9],a
+ ret
+
+Func_fc5fa:: ; fc5fa (3f:45fa)
+ ld a,[W_CURMAP]
+ cp OAKS_LAB
+ jr z,.asm_fc63d
+ cp ROUTE_22_GATE
+ jr z,.asm_fc62d
+ cp MT_MOON_2
+ jr z,.asm_fc635
+ cp ROCK_TUNNEL_1
+ jr z,.asm_fc645
+ ld a,[W_CURMAP]
+ ld hl,Pointer_fc64b
+ call Func_1568 ; similar to IsInArray, but not the same
+ jr c,.asm_fc639
+ ld a,[W_CURMAP]
+ ld hl,Pointer_fc653
+ call Func_1568
+ jr nc,.asm_fc641
+ ld a,[wSpriteStateData1 + $9]
+ and a
+ jr nz,.asm_fc641
+ ld a,$3
+ jr .asm_fc647
+
+.asm_fc62d
+ ld a,[wSpriteStateData1 + $9]
+ and a
+ jr z,.asm_fc645
+ jr .asm_fc641
+.asm_fc635
+ ld a,$3
+ jr .asm_fc647
+.asm_fc639
+ ld a,$4
+ jr .asm_fc647
+.asm_fc63d
+ ld a,$6
+ jr .asm_fc647
+.asm_fc641
+ ld a,$1
+ jr .asm_fc647
+.asm_fc645
+ ld a,$3
+.asm_fc647
+ ld [wd431],a
+ ret
+
+Pointer_fc64b:: ; fc64b (3f:464b)
+ db $c2,$4c,$4f,$ba,$be,$b8,$54,$ff
+
+Pointer_fc653:: ; fc653 (3f:4653)
+ db $2f,$e6,$3e,$5e,$80,$31,$a4,$ff
+
+Func_fc65b:: ; fc65b (3f:465b)
+ ld a,[W_CURMAP]
+
+Func_fc69a:: ; fc69a (3f:469a)
+
+Func_fcc08:: ; fcc08 (3f:4c08)
+
+Func_fcf0c:: ; fcf0c (3f:4f0c)