Identify battle bg effects functions and constants (#773)

Identify battle bg effects functions and constants
This commit is contained in:
7Soul
2020-10-06 16:45:09 -03:00
committed by GitHub
parent fc08ff2c38
commit cf26f55985
5 changed files with 406 additions and 367 deletions

View File

@@ -85,9 +85,9 @@ BattleBGEffects:
dw BattleBGEffect_WhiteHues
dw BattleBGEffect_BlackHues
dw BattleBGEffect_AlternateHues
dw BattleBGEffect_06
dw BattleBGEffect_07
dw BattleBGEffect_08
dw BattleBGEffect_CycleOBPalsGrayAndYellow
dw BattleBGEffect_CycleMidOBPalsGrayAndYellow
dw BattleBGEffect_CycleBGPals_Inverted
dw BattleBGEffect_HideMon
dw BattleBGEffect_ShowMon
dw BattleBGEffect_EnterMon
@@ -101,38 +101,38 @@ BattleBGEffects:
dw BattleBGEffect_DoubleTeam
dw BattleBGEffect_AcidArmor
dw BattleBGEffect_RapidFlash
dw BattleBGEffect_16
dw BattleBGEffect_17
dw BattleBGEffect_18
dw BattleBGEffect_19
dw BattleBGEffect_1a
dw BattleBGEffect_1b
dw BattleBGEffect_1c
dw BattleBGEffect_1d
dw BattleBGEffect_1e
dw BattleBGEffect_1f
dw BattleBGEffect_20
dw BattleBGEffect_FadeMonToLight
dw BattleBGEffect_FadeMonToBlack
dw BattleBGEffect_FadeMonToLightRepeating
dw BattleBGEffect_FadeMonToBlackRepeating
dw BattleBGEffect_CycleMonLightDarkRepeating
dw BattleBGEffect_FlashMonRepeating
dw BattleBGEffect_FadeMonsToBlackRepeating
dw BattleBGEffect_FadeMonToWhiteWaitFadeBack
dw BattleBGEffect_FadeMonFromWhite
dw BattleBGEffect_ShakeScreenX
dw BattleBGEffect_ShakeScreenY
dw BattleBGEffect_Withdraw
dw BattleBGEffect_BounceDown
dw BattleBGEffect_Dig
dw BattleBGEffect_Tackle
dw BattleBGEffect_25
dw BattleBGEffect_26
dw BattleBGEffect_27
dw BattleBGEffect_28
dw BattleBGEffect_Psychic
dw BattleBGEffect_2a
dw BattleBGEffect_2b
dw BattleBGEffect_2c
dw BattleBGEffect_2d
dw BattleBGEffect_2e
dw BattleBGEffect_2f
dw BattleBGEffect_30
dw BattleBGEffect_31
dw BattleBGEffect_32
dw BattleBGEffect_VibrateMon
dw BattleBGEffect_BodySlam
dw BattleBGEffect_WobbleMon
dw BattleBGEffect_35
dw BattleBGEffect_RemoveMon
dw BattleBGEffect_WaveDeformMon
dw BattleBGEffect_Psychic
dw BattleBGEffect_BetaSendOutMon1
dw BattleBGEffect_BetaSendOutMon2
dw BattleBGEffect_Flail
dw BattleBGEffect_BetaPursuit
dw BattleBGEffect_Rollout
dw BattleBGEffect_VitalThrow
dw BattleBGEffect_StartWater
dw BattleBGEffect_Water
dw BattleBGEffect_EndWater
dw BattleBGEffect_VibrateMon
dw BattleBGEffect_WobblePlayer
dw BattleBGEffect_WobbleScreen
BattleBGEffect_End:
call EndBattleBGEffect
@@ -280,7 +280,7 @@ BattleBGEffect_AlternateHues:
dc 2, 1, 0, 0
db -2
BattleBGEffect_06:
BattleBGEffect_CycleOBPalsGrayAndYellow:
call BattleBGEffects_CheckSGB
jr nz, .sgb
ld de, .PalsCGB
@@ -303,7 +303,7 @@ BattleBGEffect_06:
dc 3, 0, 0, 0
db -2
BattleBGEffect_07:
BattleBGEffect_CycleMidOBPalsGrayAndYellow:
call BattleBGEffects_CheckSGB
jr nz, .sgb
ld de, .PalsCGB
@@ -326,7 +326,7 @@ BattleBGEffect_07:
dc 3, 0, 3, 0
db -2
BattleBGEffect_08:
BattleBGEffect_CycleBGPals_Inverted:
ld de, .Pals
call BattleBGEffect_GetNthDMGPal
ld [wBGP], a
@@ -541,7 +541,8 @@ _QueueBattleAnimation:
callfar QueueBattleAnimation
ret
BattleBGEffect_27:
BattleBGEffect_RemoveMon:
; Slides mon out of screen
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
@@ -985,7 +986,7 @@ BattleBGEffect_Whirlpool:
ld a, $5e
ldh [hLYOverrideEnd], a
lb de, 2, 2
call Functionc8f2e
call DeformScreen
ret
.one
@@ -996,14 +997,15 @@ BattleBGEffect_Whirlpool:
call BattleAnim_ResetLCDStatCustom
ret
BattleBGEffect_30:
BattleBGEffect_StartWater:
call BattleBGEffects_ClearLYOverrides
ld a, LOW(rSCY)
call BattleBGEffect_SetLCDStatCustoms1
call EndBattleBGEffect
ret
BattleBGEffect_31:
BattleBGEffect_Water:
; BG_EFFECT_STRUCT_JT_INDEX: defines Y position of deformation
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld a, [hl]
@@ -1029,7 +1031,7 @@ BattleBGEffect_31:
jr nc, .done
inc [hl]
inc [hl]
call Functionc8f9a
call DeformWater
ret
.done
@@ -1037,11 +1039,12 @@ BattleBGEffect_31:
call EndBattleBGEffect
ret
BattleBGEffect_32:
BattleBGEffect_EndWater:
call BattleAnim_ResetLCDStatCustom
ret
BattleBGEffect_Psychic:
; Hardcoded to always affect opponent
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
@@ -1058,7 +1061,7 @@ BattleBGEffect_Psychic:
ld a, $5f
ldh [hLYOverrideEnd], a
lb de, 6, 5
call Functionc8f2e
call DeformScreen
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld [hl], $0
@@ -1091,7 +1094,7 @@ BattleBGEffect_Teleport:
ld a, LOW(rSCX)
call BattleBGEffect_SetLCDStatCustoms1
lb de, 6, 5
call Functionc8f2e
call DeformScreen
ret
.one
@@ -1118,7 +1121,7 @@ BattleBGEffect_NightShade:
add hl, bc
ld e, [hl]
ld d, 2
call Functionc8f2e
call DeformScreen
ret
.one
@@ -1239,7 +1242,7 @@ BattleBGEffect_AcidArmor:
add hl, bc
ld e, [hl]
ld d, 2
call Functionc8f2e
call DeformScreen
ld h, HIGH(wLYOverridesBackup)
ldh a, [hLYOverrideEnd]
ld l, a
@@ -1403,11 +1406,14 @@ BattleBGEffect_Tackle:
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
dw Tackle_BGEffect25_2d_one
dw Tackle_BGEffect25_2d_two
dw Tackle_MoveForward
dw Tackle_ReturnMove
dw .three
.zero
; Prepares mon to move forward (player moves right, enemy moves left)
; BG_EFFECT_STRUCT_03 will keep track of distance moved, so it's reset to 0 here
; BG_EFFECT_STRUCT_BATTLE_TURN is set to 2 or -2 depending on target
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
ld a, LOW(rSCX)
@@ -1433,15 +1439,18 @@ BattleBGEffect_Tackle:
call BattleAnim_ResetLCDStatCustom
ret
BattleBGEffect_25:
BattleBGEffect_BodySlam:
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
dw Tackle_BGEffect25_2d_one
dw Tackle_BGEffect25_2d_two
dw Tackle_MoveForward
dw Tackle_ReturnMove
dw .three
.zero
; Prepares mon to move forward (player moves right, enemy moves left)
; BG_EFFECT_STRUCT_03 will keep track of distance moved, so it's reset to 0 here
; BG_EFFECT_STRUCT_BATTLE_TURN is set to 2 or -2 depending on target
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
ld a, LOW(rSCX)
@@ -1467,7 +1476,10 @@ BattleBGEffect_25:
call BattleAnim_ResetLCDStatCustom
ret
Tackle_BGEffect25_2d_one:
Tackle_MoveForward:
; Moves user horizontally in a direction that can be positive or negative. When the limit is reached (8 pixels) we move to the next function in the jumptable (Tackle_ReturnMove)
; BG_EFFECT_STRUCT_BATTLE_TURN: speed and direction
; BG_EFFECT_STRUCT_03: keeps track of distance moved
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld a, [hl]
@@ -1488,14 +1500,17 @@ Tackle_BGEffect25_2d_one:
ld [hl], a
ret
Tackle_BGEffect25_2d_two:
Tackle_ReturnMove:
; Move user horizontally back to initial position. When we back to position 0, we move to the next function in the jumptable
; BG_EFFECT_STRUCT_BATTLE_TURN: is turned into a negative number (this number is not saved to preserve the initial number)
; BG_EFFECT_STRUCT_03: keeps track of distance moved
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld a, [hl]
and a
jr nz, .asm_c8893
jr nz, .move_back
call BattleBGEffects_IncrementJumptable
.asm_c8893
.move_back
call Functionc88a5
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
@@ -1560,19 +1575,21 @@ Functionc88a5:
jr nz, .loop
ret
BattleBGEffect_2d:
BattleBGEffect_BetaPursuit: ; unused
call BattleBGEffects_AnonJumptable
.anon_dw
dw BGEffect2d_2f_zero
dw Tackle_BGEffect25_2d_one
dw Tackle_BGEffect25_2d_two
dw VitalThrow_MoveBackwards
dw Tackle_MoveForward
dw Tackle_ReturnMove
dw .three
.three
call BattleAnim_ResetLCDStatCustom
ret
BGEffect2d_2f_zero:
VitalThrow_MoveBackwards:
; Prepares mon to move back back (player moves left, enemy moves right)
; BG_EFFECT_STRUCT_03: keeps track of distance moved, so it's reset to 0 here
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
ld a, LOW(rSCX)
@@ -1594,13 +1611,13 @@ BGEffect2d_2f_zero:
ld [hl], a
ret
BattleBGEffect_2f:
BattleBGEffect_VitalThrow:
call BattleBGEffects_AnonJumptable
.anon_dw
dw BGEffect2d_2f_zero
dw Tackle_BGEffect25_2d_one
dw VitalThrow_MoveBackwards
dw Tackle_MoveForward
dw .two
dw Tackle_BGEffect25_2d_two
dw Tackle_ReturnMove
dw .four
.four
@@ -1608,7 +1625,8 @@ BattleBGEffect_2f:
.two
ret
BattleBGEffect_26:
BattleBGEffect_WobbleMon:
; Similar to BattleBGEffect_WobblePlayer, except it can affect either side and the sine movement has a radius of 8 instead of 6 and it moves at twice the rate
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
@@ -1646,7 +1664,7 @@ BattleBGEffect_26:
call BattleAnim_ResetLCDStatCustom
ret
BattleBGEffect_2c:
BattleBGEffect_Flail:
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
@@ -1700,7 +1718,7 @@ BattleBGEffect_2c:
call BattleAnim_ResetLCDStatCustom
ret
BattleBGEffect_28:
BattleBGEffect_WaveDeformMon:
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
@@ -1723,7 +1741,7 @@ BattleBGEffect_28:
inc [hl]
ld d, a
ld e, 4
call Functionc8f2e
call DeformScreen
ret
.two
@@ -1735,7 +1753,7 @@ BattleBGEffect_28:
dec [hl]
ld d, a
ld e, 4
call Functionc8f2e
call DeformScreen
ret
.reset
@@ -1792,7 +1810,7 @@ BattleBGEffect_BounceDown:
call BattleAnim_ResetLCDStatCustom
ret
BattleBGEffect_2a:
BattleBGEffect_BetaSendOutMon1: ; unused
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
@@ -1900,7 +1918,7 @@ BattleBGEffect_2a:
db $00, $40, $90, $e4
db -1
BattleBGEffect_2b:
BattleBGEffect_BetaSendOutMon2: ; unused
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
@@ -1929,14 +1947,14 @@ BattleBGEffect_2b:
and $f
ld d, a
ld e, a
call Functionc8f2e
call DeformScreen
ret
.done
call BattleAnim_ResetLCDStatCustom
ret
BattleBGEffect_1c:
BattleBGEffect_FadeMonsToBlackRepeating:
ldh a, [hCGB]
and a
jr nz, .cgb
@@ -2094,7 +2112,7 @@ BattleBGEffect_1c:
db $40, $fc
db $90, $f8
BattleBGEffect_RapidFlash:
BattleBGEffect_RapidFlash: ; unused
ld de, .FlashPals
call BGEffect_RapidCyclePals
ret
@@ -2102,7 +2120,8 @@ BattleBGEffect_RapidFlash:
.FlashPals:
db $e4, $6c, $fe
BattleBGEffect_16:
BattleBGEffect_FadeMonToLight:
; BG_EFFECT_STRUCT_BATTLE_TURN: 0 = target of animation, 1 = user
ld de, .Pals
call BGEffect_RapidCyclePals
ret
@@ -2110,7 +2129,8 @@ BattleBGEffect_16:
.Pals:
db $e4, $90, $40, $ff
BattleBGEffect_17:
BattleBGEffect_FadeMonToBlack:
; BG_EFFECT_STRUCT_BATTLE_TURN: 0 = target of animation, 1 = user
ld de, .Pals
call BGEffect_RapidCyclePals
ret
@@ -2118,7 +2138,8 @@ BattleBGEffect_17:
.Pals:
db $e4, $f8, $fc, $ff
BattleBGEffect_18:
BattleBGEffect_FadeMonToLightRepeating:
; BG_EFFECT_STRUCT_BATTLE_TURN: 0 = target of animation, 1 = user
ld de, .Pals
call BGEffect_RapidCyclePals
ret
@@ -2126,7 +2147,8 @@ BattleBGEffect_18:
.Pals:
db $e4, $90, $40, $90, $fe
BattleBGEffect_19:
BattleBGEffect_FadeMonToBlackRepeating:
; BG_EFFECT_STRUCT_BATTLE_TURN: 0 = target of animation, 1 = user
ld de, .Pals
call BGEffect_RapidCyclePals
ret
@@ -2134,7 +2156,8 @@ BattleBGEffect_19:
.Pals:
db $e4, $f8, $fc, $f8, $fe
BattleBGEffect_1a:
BattleBGEffect_CycleMonLightDarkRepeating:
; BG_EFFECT_STRUCT_BATTLE_TURN: 0 = target of animation, 1 = user
ld de, .Pals
call BGEffect_RapidCyclePals
ret
@@ -2142,7 +2165,8 @@ BattleBGEffect_1a:
.Pals:
db $e4, $f8, $fc, $f8, $e4, $90, $40, $90, $fe
BattleBGEffect_1b:
BattleBGEffect_FlashMonRepeating: ; unused
; BG_EFFECT_STRUCT_BATTLE_TURN: 0 = target of animation, 1 = user
ld de, .Pals
call BGEffect_RapidCyclePals
ret
@@ -2150,7 +2174,8 @@ BattleBGEffect_1b:
.Pals:
db $e4, $fc, $e4, $00, $fe
BattleBGEffect_1d:
BattleBGEffect_FadeMonToWhiteWaitFadeBack:
; BG_EFFECT_STRUCT_BATTLE_TURN: 0 = target of animation, 1 = user
ld de, .Pals
call BGEffect_RapidCyclePals
ret
@@ -2158,7 +2183,8 @@ BattleBGEffect_1d:
.Pals:
db $e4, $90, $40, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $40, $90, $e4, $ff
BattleBGEffect_1e:
BattleBGEffect_FadeMonFromWhite: ; unused
; BG_EFFECT_STRUCT_BATTLE_TURN: 0 = target of animation, 1 = user
ld de, .Pals
call BGEffect_RapidCyclePals
ret
@@ -2167,6 +2193,8 @@ BattleBGEffect_1e:
db $00, $40, $90, $e4, $ff
BattleBGEffect_VibrateMon:
; Moves mon back and forth sideways for $20 frames
; BG_EFFECT_STRUCT_BATTLE_TURN: 0 = target of animation, 1 = user
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
@@ -2210,7 +2238,8 @@ BattleBGEffect_VibrateMon:
call BattleAnim_ResetLCDStatCustom
ret
BattleBGEffect_WobbleMon:
BattleBGEffect_WobblePlayer:
; Always affects the player
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
@@ -2251,7 +2280,7 @@ BattleBGEffect_WobbleMon:
call BattleAnim_ResetLCDStatCustom
ret
BattleBGEffect_2e:
BattleBGEffect_Rollout:
call Functionc8d0b
jr c, .xor_a
bit 7, a
@@ -2268,7 +2297,7 @@ BattleBGEffect_2e:
ld [wAnimObject01YOffset], a
ret
BattleBGEffect_1f:
BattleBGEffect_ShakeScreenX:
call Functionc8d0b
jr nc, .skip
xor a
@@ -2276,7 +2305,7 @@ BattleBGEffect_1f:
ldh [hSCX], a
ret
BattleBGEffect_20:
BattleBGEffect_ShakeScreenY:
call Functionc8d0b
jr nc, .skip
xor a
@@ -2322,7 +2351,7 @@ Functionc8d0b:
and a
ret
BattleBGEffect_35:
BattleBGEffect_WobbleScreen:
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld a, [hl]
@@ -2367,6 +2396,7 @@ BattleBGEffect_GetNthDMGPal:
ret
BGEffect_RapidCyclePals:
; Last index in DE: $fe signals a loop, $ff signals end
ldh a, [hCGB]
and a
jr nz, .cgb
@@ -2674,7 +2704,11 @@ BattleBGEffects_ResetVideoHRAM:
call BattleBGEffects_ClearLYOverrides
ret
Functionc8f2e:
DeformScreen:
; wBattleAnimTemp0: Progress of the sine wave
; wBattleAnimTemp1 (e): Distance to skip
; wBattleAnimTemp2 (d): Size of wave
; wBattleAnimTemp3: Timer
push bc
xor a
ld [wBattleAnimTemp0], a
@@ -2737,7 +2771,7 @@ InitSurfWaves:
pop bc
ret
Functionc8f9a:
DeformWater:
push bc
ld [wBattleAnimTemp3], a
ld a, e