summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorluckytyphlosion <alan.rj.huang@gmail.com>2016-03-17 18:22:37 -0400
committerluckytyphlosion <alan.rj.huang@gmail.com>2016-03-17 18:22:37 -0400
commit29b6c60cb7801a4b240f398dd85938f020190234 (patch)
tree5715b7675a9576513b7e716886bbef27703d7c4e /engine
parentb6d2115df4b4f9d86be898292fca473222941f1d (diff)
Replaced some wram labels before committing, need to commit now.
Diffstat (limited to 'engine')
-rwxr-xr-xengine/battle/animations.asm128
-rw-r--r--engine/battle/animations_.asm394
-rwxr-xr-xengine/menu/naming_screen.asm2
3 files changed, 459 insertions, 65 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index aa9a6c3b..00c828e6 100755
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -4,18 +4,18 @@ DrawFrameBlock: ; 78000 (1e:4000)
ld l,c
ld h,b
ld a,[hli]
- ld [W_NUMFBTILES],a
- ld a,[W_FBDESTADDR + 1]
+ ld [wNumFBTiles],a
+ ld a,[wFBDestAddr + 1]
ld e,a
- ld a,[W_FBDESTADDR]
+ ld a,[wFBDestAddr]
ld d,a
xor a
- ld [W_FBTILECOUNTER],a ; loop counter
+ ld [wFBTileCounter],a ; loop counter
.loop
- ld a,[W_FBTILECOUNTER]
+ ld a,[wFBTileCounter]
inc a
- ld [W_FBTILECOUNTER],a
- ld a,[W_SUBANIMTRANSFORM]
+ ld [wFBTileCounter],a
+ ld a,[wSubAnimTransform]
dec a
jr z,.flipHorizontalAndVertical ; 1
dec a
@@ -43,7 +43,7 @@ DrawFrameBlock: ; 78000 (1e:4000)
ld b,a
ld a,168
sub b ; flip X base coordinate
-.finishCopying ; finish copying values to OAM (when [W_SUBANIMTRANSFORM] not 1 or 2)
+.finishCopying ; finish copying values to OAM (when [wSubAnimTransform] not 1 or 2)
add [hl] ; X offset
ld [de],a ; store X
inc hl
@@ -125,19 +125,19 @@ DrawFrameBlock: ; 78000 (1e:4000)
ld [de],a
inc de
.nextTile
- ld a,[W_FBTILECOUNTER]
+ ld a,[wFBTileCounter]
ld c,a
- ld a,[W_NUMFBTILES]
+ ld a,[wNumFBTiles]
cp c
jp nz,.loop ; go back up if there are more tiles to draw
.afterDrawingTiles
- ld a,[W_FBMODE]
+ ld a,[wFBMode]
cp a,2
jr z,.advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer
- ld a,[W_SUBANIMFRAMEDELAY]
+ ld a,[wSubAnimFrameDelay]
ld c,a
call DelayFrames
- ld a,[W_FBMODE]
+ ld a,[wFBMode]
cp a,3
jr z,.advanceFrameBlockDestAddr ; skip cleaning OAM buffer
cp a,4
@@ -149,22 +149,22 @@ DrawFrameBlock: ; 78000 (1e:4000)
.resetFrameBlockDestAddr
ld hl,wOAMBuffer ; OAM buffer
ld a,l
- ld [W_FBDESTADDR + 1],a
+ ld [wFBDestAddr + 1],a
ld a,h
- ld [W_FBDESTADDR],a ; set destination address to beginning of OAM buffer
+ ld [wFBDestAddr],a ; set destination address to beginning of OAM buffer
ret
.advanceFrameBlockDestAddr
ld a,e
- ld [W_FBDESTADDR + 1],a
+ ld [wFBDestAddr + 1],a
ld a,d
- ld [W_FBDESTADDR],a
+ ld [wFBDestAddr],a
.done
ret
PlayAnimation: ; 780f1 (1e:40f1)
xor a
ld [$FF8B],a ; it looks like nothing reads this
- ld [W_SUBANIMTRANSFORM],a
+ ld [wSubAnimTransform],a
ld a,[wAnimationID] ; get animation number
dec a
ld l,a
@@ -217,7 +217,7 @@ PlayAnimation: ; 780f1 (1e:40f1)
.playSubanimation
ld c,a
and a,%00111111
- ld [W_SUBANIMFRAMEDELAY],a
+ ld [wSubAnimFrameDelay],a
xor a
sla c
rla
@@ -235,9 +235,9 @@ PlayAnimation: ; 780f1 (1e:40f1)
ld de,SubanimationPointers
add hl,de
ld a,l
- ld [W_SUBANIMADDRPTR],a
+ ld [wSubAnimAddrPtr],a
ld a,h
- ld [W_SUBANIMADDRPTR + 1],a
+ ld [wSubAnimAddrPtr + 1],a
ld l,c
ld h,b
push hl
@@ -257,9 +257,9 @@ PlayAnimation: ; 780f1 (1e:40f1)
ret
LoadSubanimation: ; 7817c (1e:417c)
- ld a,[W_SUBANIMADDRPTR + 1]
+ ld a,[wSubAnimAddrPtr + 1]
ld h,a
- ld a,[W_SUBANIMADDRPTR]
+ ld a,[wSubAnimAddrPtr]
ld l,a
ld a,[hli]
ld e,a
@@ -268,7 +268,7 @@ LoadSubanimation: ; 7817c (1e:417c)
ld a,[de]
ld b,a
and a,31
- ld [W_SUBANIMCOUNTER],a ; number of frame blocks
+ ld [wSubAnimCounter],a ; number of frame blocks
ld a,b
and a,%11100000
cp a,5 << 5 ; is subanimation type 5?
@@ -282,12 +282,12 @@ LoadSubanimation: ; 7817c (1e:417c)
; place the upper 3 bits of a into bits 0-2 of a before storing
srl a
swap a
- ld [W_SUBANIMTRANSFORM],a
+ ld [wSubAnimTransform],a
cp a,4 ; is the animation reversed?
ld hl,0
jr nz,.storeSubentryAddr
; if the animation is reversed, then place the initial subentry address at the end of the list of subentries
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
dec a
ld bc,3
.loop
@@ -298,9 +298,9 @@ LoadSubanimation: ; 7817c (1e:417c)
inc de
add hl,de
ld a,l
- ld [W_SUBANIMSUBENTRYADDR],a
+ ld [wSubAnimSubEntryAddr],a
ld a,h
- ld [W_SUBANIMSUBENTRYADDR + 1],a
+ ld [wSubAnimSubEntryAddr + 1],a
ret
; called if the subanimation type is not 5
@@ -403,9 +403,9 @@ MoveAnimation: ; 78d5e (1e:4d5e)
.AnimationFinished
call WaitForSoundToFinish
xor a
- ld [W_SUBANIMSUBENTRYADDR],a
+ ld [wSubAnimSubEntryAddr],a
ld [wUnusedD09B],a
- ld [W_SUBANIMTRANSFORM],a
+ ld [wSubAnimTransform],a
dec a
ld [wAnimSoundID],a
pop af
@@ -550,12 +550,12 @@ PlaySubanimation: ; 78e53 (1e:4e53)
.skipPlayingSound
ld hl,wOAMBuffer ; base address of OAM buffer
ld a,l
- ld [W_FBDESTADDR + 1],a
+ ld [wFBDestAddr + 1],a
ld a,h
- ld [W_FBDESTADDR],a
- ld a,[W_SUBANIMSUBENTRYADDR + 1]
+ ld [wFBDestAddr],a
+ ld a,[wSubAnimSubEntryAddr + 1]
ld h,a
- ld a,[W_SUBANIMSUBENTRYADDR]
+ ld a,[wSubAnimSubEntryAddr]
ld l,a
.loop
push hl
@@ -583,18 +583,18 @@ PlaySubanimation: ; 78e53 (1e:4e53)
pop hl
inc hl
ld a,[hl] ; frame block mode
- ld [W_FBMODE],a
+ ld [wFBMode],a
call DrawFrameBlock
call DoSpecialEffectByAnimationId ; run animation-specific function (if there is one)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
dec a
- ld [W_SUBANIMCOUNTER],a
+ ld [wSubAnimCounter],a
ret z
- ld a,[W_SUBANIMSUBENTRYADDR + 1]
+ ld a,[wSubAnimSubEntryAddr + 1]
ld h,a
- ld a,[W_SUBANIMSUBENTRYADDR]
+ ld a,[wSubAnimSubEntryAddr]
ld l,a
- ld a,[W_SUBANIMTRANSFORM]
+ ld a,[wSubAnimTransform]
cp a,4 ; is the animation reversed?
ld bc,3
jr nz,.nextSubanimationSubentry
@@ -602,9 +602,9 @@ PlaySubanimation: ; 78e53 (1e:4e53)
.nextSubanimationSubentry
add hl,bc
ld a,h
- ld [W_SUBANIMSUBENTRYADDR + 1],a
+ ld [wSubAnimSubEntryAddr + 1],a
ld a,l
- ld [W_SUBANIMSUBENTRYADDR],a
+ ld [wSubAnimSubEntryAddr],a
jp .loop
AnimationCleanOAM: ; 78ec8 (1e:4ec8)
@@ -729,7 +729,7 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e)
xor a,%00111100 ; complement colors 1 and 2
ld [rOBP0],a
.skipFlashingEffect
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,11 ; is it the beginning of the subanimation?
jr nz,.skipPlayingSound
; if it is the beginning of the subanimation, play a sound
@@ -743,7 +743,7 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e)
cp a,$10 ; is the enemy pokemon the Ghost Marowak?
ret nz
; if the enemy pokemon is the Ghost Marowak, make it dodge during the last 3 frames
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,3
jr z,.moveGhostMarowakLeft
cp a,2
@@ -767,15 +767,15 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e)
ld [rNR10],a ; Channel 1 sweep register
ret
.isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,3
ret nz
dec a
- ld [W_SUBANIMCOUNTER],a
+ ld [wSubAnimCounter],a
ret
DoBallShakeSpecialEffects: ; 78f96 (1e:4f96)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,4 ; is it the beginning of a shake?
jr nz,.skipPlayingSound
; if it is the beginning of a shake, play a sound and wait 2/3 of a second
@@ -784,7 +784,7 @@ DoBallShakeSpecialEffects: ; 78f96 (1e:4f96)
ld c,40
call DelayFrames
.skipPlayingSound
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
dec a
ret nz
; if it's the end of the ball shaking subanimation, check if more shakes are left and restart the subanimation
@@ -793,30 +793,30 @@ DoBallShakeSpecialEffects: ; 78f96 (1e:4f96)
ld [wNumShakes],a
ret z
; if there are shakes left, restart the subanimation
- ld a,[W_SUBANIMSUBENTRYADDR]
+ ld a,[wSubAnimSubEntryAddr]
ld l,a
- ld a,[W_SUBANIMSUBENTRYADDR + 1]
+ ld a,[wSubAnimSubEntryAddr + 1]
ld h,a
ld de,-(4 * 3) ; 4 subentries and 3 bytes per subentry
add hl,de
ld a,l
- ld [W_SUBANIMSUBENTRYADDR],a
+ ld [wSubAnimSubEntryAddr],a
ld a,h
- ld [W_SUBANIMSUBENTRYADDR + 1],a
+ ld [wSubAnimSubEntryAddr + 1],a
ld a,5 ; number of subentries in the ball shaking subanimation plus one
- ld [W_SUBANIMCOUNTER],a
+ ld [wSubAnimCounter],a
ret
; plays a sound after the second frame of the poof animation
DoPoofSpecialEffects: ; 78fce (1e:4fce)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,5
ret nz
ld a,SFX_BALL_POOF
jp PlaySound
DoRockSlideSpecialEffects: ; 78fd9 (1e:4fd9)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,12
ret nc
cp a,8
@@ -832,21 +832,21 @@ DoRockSlideSpecialEffects: ; 78fd9 (1e:4fd9)
predef_jump PredefShakeScreenVertically ; shake vertically
FlashScreenEveryEightFrameBlocks: ; 78ff7 (1e:4ff7)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
and a,7 ; is the subanimation counter exactly 8?
call z,AnimationFlashScreen ; if so, flash the screen
ret
; flashes the screen if the subanimation counter is divisible by 4
FlashScreenEveryFourFrameBlocks: ; 79000 (1e:5000)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
and a,3
call z,AnimationFlashScreen
ret
; used for Explosion and Selfdestruct
DoExplodeSpecialEffects: ; 79009 (1e:5009)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,1 ; is it the end of the subanimation?
jr nz,FlashScreenEveryFourFrameBlocks
; if it's the end of the subanimation, make the attacking pokemon disappear
@@ -855,7 +855,7 @@ DoExplodeSpecialEffects: ; 79009 (1e:5009)
; flashes the screen when subanimation counter is 1 modulo 4
DoBlizzardSpecialEffects: ; 79016 (1e:5016)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,13
jp z,AnimationFlashScreen
cp a,9
@@ -869,7 +869,7 @@ DoBlizzardSpecialEffects: ; 79016 (1e:5016)
; flashes the screen at 3 points in the subanimation
; unused
FlashScreenUnused: ; 7902e (1e:502e)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,14
jp z,AnimationFlashScreen
cp a,9
@@ -880,7 +880,7 @@ FlashScreenUnused: ; 7902e (1e:502e)
; function to make the pokemon disappear at the beginning of the animation
TradeHidePokemon: ; 79041 (1e:5041)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,6
ret nz
ld a,2 * SCREEN_WIDTH + 7
@@ -888,7 +888,7 @@ TradeHidePokemon: ; 79041 (1e:5041)
; function to make a shaking pokeball jump up at the end of the animation
TradeShakePokeball: ; 7904c (1e:504c)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,1
ret nz
; if it's the end of the animation, make the ball jump up
@@ -968,7 +968,7 @@ DoGrowlSpecialEffects: ; 790bc (1e:50bc)
ld de,wOAMBuffer + $10
ld bc,$10
call CopyData ; copy the musical note graphic
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
dec a
call z,AnimationCleanOAM ; clean up at the end of the subanimation
ret
@@ -976,7 +976,7 @@ DoGrowlSpecialEffects: ; 790bc (1e:50bc)
; this is associated with Tail Whip, but Tail Whip doesn't use any subanimations
TailWhipAnimationUnused: ; 790d0 (1e:50d0)
ld a,1
- ld [W_SUBANIMCOUNTER],a
+ ld [wSubAnimCounter],a
ld c,20
jp DelayFrames
diff --git a/engine/battle/animations_.asm b/engine/battle/animations_.asm
new file mode 100644
index 00000000..f9260802
--- /dev/null
+++ b/engine/battle/animations_.asm
@@ -0,0 +1,394 @@
+; Draws a "frame block". Frame blocks are blocks of tiles that are put
+; together to form frames in battle animations.
+DrawFrameBlock: ; 78000 (1e:4000)
+ ld l,c
+ ld h,b
+ ld a,[hli]
+ ld [W_NUMFBTILES],a
+ ld a,[W_FBDESTADDR + 1]
+ ld e,a
+ ld a,[W_FBDESTADDR]
+ ld d,a
+ xor a
+ ld [W_FBTILECOUNTER],a ; loop counter
+.loop
+ ld a,[W_FBTILECOUNTER]
+ inc a
+ ld [W_FBTILECOUNTER],a
+ ld a,[W_SUBANIMTRANSFORM]
+ dec a
+ jr z,.flipHorizontalAndVertical ; 1
+ dec a
+ jp z,.flipHorizontalTranslateDown ; 2
+ dec a
+ jr z,.flipBaseCoords ; 3
+.noTransformation
+ ld a,[wBaseCoordY]
+ add [hl]
+ ld [de],a ; store Y
+ inc hl
+ inc de
+ ld a,[wBaseCoordX]
+ jr .finishCopying
+.flipBaseCoords
+ ld a,[wBaseCoordY]
+ ld b,a
+ ld a,136
+ sub b ; flip Y base coordinate
+ add [hl] ; Y offset
+ ld [de],a ; store Y
+ inc hl
+ inc de
+ ld a,[wBaseCoordX]
+ ld b,a
+ ld a,168
+ sub b ; flip X base coordinate
+.finishCopying ; finish copying values to OAM (when [W_SUBANIMTRANSFORM] not 1 or 2)
+ add [hl] ; X offset
+ ld [de],a ; store X
+ inc hl
+ inc de
+ ld a,[hli]
+ add a,$31 ; base tile ID for battle animations
+ ld [de],a ; store tile ID
+ inc de
+ ld a,[hli]
+ ld [de],a ; store flags
+ inc de
+ jp .nextTile
+.flipHorizontalAndVertical
+ ld a,[wBaseCoordY]
+ add [hl] ; Y offset
+ ld b,a
+ ld a,136
+ sub b ; flip Y coordinate
+ ld [de],a ; store Y
+ inc hl
+ inc de
+ ld a,[wBaseCoordX]
+ add [hl] ; X offset
+ ld b,a
+ ld a,168
+ sub b ; flip X coordinate
+ ld [de],a ; store X
+ inc hl
+ inc de
+ ld a,[hli]
+ add a,$31 ; base tile ID for battle animations
+ ld [de],a ; store tile ID
+ inc de
+; toggle horizontal and vertical flip
+ ld a,[hli] ; flags
+ and a
+ ld b,OAM_VFLIP | OAM_HFLIP
+ jr z,.storeFlags1
+ cp a,OAM_HFLIP
+ ld b,OAM_VFLIP
+ jr z,.storeFlags1
+ cp a,OAM_VFLIP
+ ld b,OAM_HFLIP
+ jr z,.storeFlags1
+ ld b,0
+.storeFlags1
+ ld a,b
+ ld [de],a
+ inc de
+ jp .nextTile
+.flipHorizontalTranslateDown
+ ld a,[wBaseCoordY]
+ add [hl]
+ add a,40 ; translate Y coordinate downwards
+ ld [de],a ; store Y
+ inc hl
+ inc de
+ ld a,[wBaseCoordX]
+ add [hl]
+ ld b,a
+ ld a,168
+ sub b ; flip X coordinate
+ ld [de],a ; store X
+ inc hl
+ inc de
+ ld a,[hli]
+ add a,$31 ; base tile ID for battle animations
+ ld [de],a ; store tile ID
+ inc de
+ ld a,[hli]
+ bit 5,a ; is horizontal flip enabled?
+ jr nz,.disableHorizontalFlip
+.enableHorizontalFlip
+ set 5,a
+ jr .storeFlags2
+.disableHorizontalFlip
+ res 5,a
+.storeFlags2
+ ld [de],a
+ inc de
+.nextTile
+ ld a,[W_FBTILECOUNTER]
+ ld c,a
+ ld a,[W_NUMFBTILES]
+ cp c
+ jp nz,.loop ; go back up if there are more tiles to draw
+.afterDrawingTiles
+ ld a,[W_FBMODE]
+ cp a,2
+ jr z,.advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer
+ ld a,[W_SUBANIMFRAMEDELAY]
+ ld c,a
+ call DelayFrames
+ ld a,[W_FBMODE]
+ cp a,3
+ jr z,.advanceFrameBlockDestAddr ; skip cleaning OAM buffer
+ cp a,4
+ jr z,.done ; skip cleaning OAM buffer and don't advance the frame block destination address
+ ld a,[wAnimationID]
+ cp a,GROWL
+ jr z,.resetFrameBlockDestAddr
+ call AnimationCleanOAM
+.resetFrameBlockDestAddr
+ ld hl,wOAMBuffer ; OAM buffer
+ ld a,l
+ ld [W_FBDESTADDR + 1],a
+ ld a,h
+ ld [W_FBDESTADDR],a ; set destination address to beginning of OAM buffer
+ ret
+.advanceFrameBlockDestAddr
+ ld a,e
+ ld [W_FBDESTADDR + 1],a
+ ld a,d
+ ld [W_FBDESTADDR],a
+.done
+ ret
+
+PlayAnimation: ; 78124 (1e:4124)
+ xor a
+ ld [$FF8B],a ; it looks like nothing reads this
+ ld [W_SUBANIMTRANSFORM],a
+ ld a,[wAnimationID] ; get animation number
+ dec a
+ ld l,a
+ ld h,0
+ add hl,hl
+ ld de,AttackAnimationPointers ; animation command stream pointers
+ add hl,de
+ ld a,[hli]
+ ld h,[hl]
+ ld l,a
+.animationLoop
+ ld a,[hli]
+ cp a,$FF
+ jr z,.AnimationOver
+ cp a,$C0 ; is this subanimation or a special effect?
+ jr c,.playSubanimation
+.doSpecialEffect
+ ld c,a
+ ld de,SpecialEffectPointers
+.searchSpecialEffectTableLoop
+ ld a,[de]
+ cp c
+ jr z,.foundMatch
+ inc de
+ inc de
+ inc de
+ jr .searchSpecialEffectTableLoop
+.foundMatch
+ ld a,[hli]
+ cp a,$FF ; is there a sound to play?
+ jr z,.skipPlayingSound
+ ld [wAnimSoundID],a ; store sound
+ push hl
+ push de
+ call GetMoveSound
+ call PlaySound
+ pop de
+ pop hl
+.skipPlayingSound
+ push hl
+ inc de
+ ld a,[de]
+ ld l,a
+ inc de
+ ld a,[de]
+ ld h,a
+ ld de,.nextAnimationCommand
+ push de
+ jp [hl] ; jump to special effect function
+.playSubanimation
+ ld c,a
+ and a,%00111111
+ ld [W_SUBANIMFRAMEDELAY],a
+ xor a
+ sla c
+ rla
+ sla c
+ rla
+ ld [wWhichBattleAnimTileset],a
+ ld a,[hli] ; sound
+ ld [wAnimSoundID],a ; store sound
+ ld a,[hli] ; subanimation ID
+ ld c,l
+ ld b,h
+ ld l,a
+ ld h,0
+ add hl,hl
+ ld de,SubanimationPointers
+ add hl,de
+ ld a,l
+ ld [W_SUBANIMADDRPTR],a
+ ld a,h
+ ld [W_SUBANIMADDRPTR + 1],a
+ ld l,c
+ ld h,b
+ push hl
+ ld a,[rOBP0]
+ push af
+ ld a,[wAnimPalette]
+ ld [rOBP0],a
+ call UpdateGBCPal_OBP0
+ call LoadAnimationTileset
+ call LoadSubanimation
+ call PlaySubanimation
+ pop af
+ ld [rOBP0],a
+ call UpdateGBCPal_OBP0
+.nextAnimationCommand
+ pop hl
+ jr .animationLoop
+.AnimationOver ; 417B
+ ret
+
+LoadSubanimation: ; 781b5 (1e:41b5)
+ ld a,[W_SUBANIMADDRPTR + 1]
+ ld h,a
+ ld a,[W_SUBANIMADDRPTR]
+ ld l,a
+ ld a,[hli]
+ ld e,a
+ ld a,[hl]
+ ld d,a ; de = address of subanimation
+ ld a,[de]
+ ld b,a
+ and a,31
+ ld [W_SUBANIMCOUNTER],a ; number of frame blocks
+ ld a,b
+ and a,%11100000
+ cp a,5 << 5 ; is subanimation type 5?
+ jr nz,.isNotType5
+.isType5
+ call GetSubanimationTransform2
+ jr .saveTransformation
+.isNotType5
+ call GetSubanimationTransform1
+.saveTransformation
+; place the upper 3 bits of a into bits 0-2 of a before storing
+ srl a
+ swap a
+ ld [W_SUBANIMTRANSFORM],a
+ cp a,4 ; is the animation reversed?
+ ld hl,0
+ jr nz,.storeSubentryAddr
+; if the animation is reversed, then place the initial subentry address at the end of the list of subentries
+ ld a,[W_SUBANIMCOUNTER]
+ dec a
+ ld bc,3
+.loop
+ add hl,bc
+ dec a
+ jr nz,.loop
+.storeSubentryAddr
+ inc de
+ add hl,de
+ ld a,l
+ ld [W_SUBANIMSUBENTRYADDR],a
+ ld a,h
+ ld [W_SUBANIMSUBENTRYADDR + 1],a
+ ret
+
+; called if the subanimation type is not 5
+; sets the transform to 0 (i.e. no transform) if it's the player's turn
+; sets the transform to the subanimation type if it's the enemy's turn
+GetSubanimationTransform1: ; 781fb (1e:41fb)
+ ld b,a
+ ld a,[H_WHOSETURN]
+ and a
+ ld a,b
+ ret nz
+ xor a
+ ret
+
+; called if the subanimation type is 5
+; sets the transform to 2 (i.e. horizontal and vertical flip) if it's the player's turn
+; sets the transform to 0 (i.e. no transform) if it's the enemy's turn
+GetSubanimationTransform2: ; 78203 (1e:4203)
+ ld a,[H_WHOSETURN]
+ and a
+ ld a,2 << 5
+ ret z
+ xor a
+ ret
+
+; loads tile patterns for battle animations
+LoadAnimationTileset: ; 7820b (1e:420b)
+ ld a,[wWhichBattleAnimTileset]
+ add a
+ add a
+ ld hl,AnimationTilesetPointers
+ ld e,a
+ ld d,0
+ add hl,de
+ ld a,[hli]
+ ld [wTempTilesetNumTiles],a ; number of tiles
+ ld a,[hli]
+ ld e,a
+ ld a,[hl]
+ ld d,a ; de = address of tileset
+ ld hl,vSprites + $310
+ ld b, BANK(AnimationTileset1) ; ROM bank
+ ld a,[wTempTilesetNumTiles]
+ ld c,a ; number of tiles
+ jp CopyVideoData ; load tileset
+
+AnimationTilesetPointers: ; 7822b (1e:422b)
+ db 79 ; number of tiles
+ dw AnimationTileset1
+ db $FF
+
+ db 79 ; number of tiles
+ dw AnimationTileset2
+ db $FF
+
+ db 64 ; number of tiles
+ dw AnimationTileset1
+ db $FF
+
+AnimationTileset1: ; 78237 (1e:4237)
+ INCBIN "gfx/attack_anim_1.2bpp"
+
+AnimationTileset2: ; 78757 (1e:4757)
+ INCBIN "gfx/attack_anim_2.2bpp"
+
+SlotMachineTiles2: ; 78bde (1e:4c17)
+ INCBIN "gfx/slotmachine2.2bpp"
+
+ dr $78d97,$78e98
+Func_78e98: ; 78e98 (1e:4e98)
+ dr $78e98,$79349
+AnimationSlideMonOff: ; 79349 (1e:5349)
+ dr $79349,$79353
+AnimationSlideEnemyMonOff: ; 79353 (1e:5353)
+ dr $79353,$7966e
+AnimationMinimizeMon: ; 7966e (1e:566e)
+ dr $7966e,$797af
+AnimationSubstitute: ; 797af (1e:57af)
+ dr $797af,$79816
+HideSubstituteShowMonAnim: ; 79816 (1e:5816)
+ dr $79816,$798b2
+ReshowSubstituteAnim: ; 798b2 (1e:58b2)
+ dr $798b2,$798c8
+AnimationTransformMon: ; 798c8 (1e:58c8)
+ dr $798c8,$798d4
+ChangeMonPic: ; 798d4 (1e:58d4)
+ dr $798d4,$79929
+Func_79929: ; 79929 (1e:5929)
+ dr $79929,$7a037 \ No newline at end of file
diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm
index fd9a55af..de0c696c 100755
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -164,7 +164,7 @@ DisplayNamingScreen: ; 6307 (1:6307)
call RunDefaultPaletteCommand
call GBPalNormal
xor a
- ld [W_SUBANIMTRANSFORM], a
+ ld [wSubAnimTransform], a
ld hl, wd730
res 6, [hl]
ld a, [wIsInBattle]