Start misc battle documentation

This commit is contained in:
GriffinR 2021-10-04 10:21:03 -04:00
parent e26f9d10d7
commit 31b501e7eb
46 changed files with 1002 additions and 1031 deletions

1
.gitignore vendored
View File

@ -34,3 +34,4 @@ porymap.project.cfg
*.a *.a
.fuse_hidden* .fuse_hidden*
*.sna *.sna
*.diff

View File

@ -34,20 +34,20 @@
.Lcreatetask_\@_2: .Lcreatetask_\@_2:
.endm .endm
.macro delay param0:req .macro delay frames:req
.byte 0x4 .byte 0x4
.byte \param0 .byte \frames
.endm .endm
.macro waitforvisualfinish .macro waitforvisualfinish
.byte 0x5 .byte 0x5
.endm .endm
.macro hang1 .macro nop
.byte 0x6 .byte 0x6
.endm .endm
.macro hang2 .macro nop2
.byte 0x7 .byte 0x7
.endm .endm
@ -79,30 +79,30 @@
.byte 0xd .byte 0xd
.endm .endm
.macro call param0:req .macro call ptr:req
.byte 0xe .byte 0xe
.4byte \param0 .4byte \ptr
.endm .endm
.macro return .macro return
.byte 0xf .byte 0xf
.endm .endm
.macro setarg param0:req, param1:req .macro setarg argId:req, value:req
.byte 0x10 .byte 0x10
.byte \param0 .byte \argId
.2byte \param1 .2byte \value
.endm .endm
.macro choosetwoturnanim param0:req, param1:req .macro choosetwoturnanim ptr1:req, ptr2:req
.byte 0x11 .byte 0x11
.4byte \param0 .4byte \ptr1
.4byte \param1 .4byte \ptr2
.endm .endm
.macro jumpifmoveturn param0:req, ptr:req .macro jumpifmoveturn value:req, ptr:req
.byte 0x12 .byte 0x12
.byte \param0 .byte \value
.4byte \ptr .4byte \ptr
.endm .endm
@ -144,13 +144,13 @@
.byte \pan .byte \pan
.endm .endm
.macro panse_1B se:req, param1:req, param2:req, param3:req, param4:req .macro panse se:req, currentPan:req, targetPan:req, incrementPan:req, delay:req
.byte 0x1b .byte 0x1b
.2byte \se .2byte \se
.byte \param1 .byte \currentPan
.byte \param2 .byte \targetPan
.byte \param3 .byte \incrementPan
.byte \param4 .byte \delay
.endm .endm
.macro loopsewithpan se:req, pan:req, wait:req, times:req .macro loopsewithpan se:req, pan:req, wait:req, times:req
@ -168,9 +168,9 @@
.byte \wait .byte \wait
.endm .endm
.macro setbldcnt param0:req .macro setbldcnt bldcnt:req
.byte 0x1e .byte 0x1e
.2byte \param0 .2byte \bldcnt
.endm .endm
.macro createsoundtask addr:req, argv:vararg .macro createsoundtask addr:req, argv:vararg
@ -186,10 +186,10 @@
.byte 0x20 .byte 0x20
.endm .endm
.macro jumpargeq param0:req, param1:req, ptr:req .macro jumpargeq argId:req, value:req, ptr:req
.byte 0x21 .byte 0x21
.byte \param0 .byte \argId
.2byte \param1 .2byte \value
.4byte \ptr .4byte \ptr
.endm .endm
@ -208,29 +208,29 @@
.4byte \ptr .4byte \ptr
.endm .endm
.macro fadetobgfromset param0:req, param1:req, param2:req .macro fadetobgfromset bgOpponent:req, bgPlayer:req, bgContest:req
.byte 0x25 .byte 0x25
.byte \param0 .byte \bgOpponent
.byte \param1 .byte \bgPlayer
.byte \param2 .byte \bgContest
.endm .endm
.macro panse_26 se:req, param1:req, param2:req, param3:req, param4:req .macro panse_adjustnone se:req, currentPan:req, targetPan:req, incrementPan:req, delay:req
.byte 0x26 .byte 0x26
.2byte \se .2byte \se
.byte \param1 .byte \currentPan
.byte \param2 .byte \targetPan
.byte \param3 .byte \incrementPan
.byte \param4 .byte \delay
.endm .endm
.macro panse_27 se:req, param1:req, param2:req, param3:req, param4:req .macro panse_adjustall se:req, currentPan:req, targetPan:req, incrementPan:req, delay:req
.byte 0x27 .byte 0x27
.2byte \se .2byte \se
.byte \param1 .byte \currentPan
.byte \param2 .byte \targetPan
.byte \param3 .byte \incrementPan
.byte \param4 .byte \delay
.endm .endm
.macro monbgprio_28 battler:req .macro monbgprio_28 battler:req

View File

@ -2234,7 +2234,7 @@ Move_ICY_WIND:
playsewithpan SE_M_ICY_WIND, 0 playsewithpan SE_M_ICY_WIND, 0
waitbgfadein waitbgfadein
waitforvisualfinish waitforvisualfinish
panse_1B SE_M_GUST, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_GUST, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
call IcyWindSwirlingSnowballs call IcyWindSwirlingSnowballs
delay 5 delay 5
call IcyWindSwirlingSnowballs call IcyWindSwirlingSnowballs
@ -2551,7 +2551,7 @@ Move_SING:
monbg ANIM_DEF_PARTNER monbg ANIM_DEF_PARTNER
createvisualtask AnimTask_MusicNotesRainbowBlend, 2 createvisualtask AnimTask_MusicNotesRainbowBlend, 2
waitforvisualfinish waitforvisualfinish
panse_1B SE_M_SING, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_SING, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
createsprite gWavyMusicNotesSpriteTemplate, ANIM_TARGET, 2, 7, 0, 12 createsprite gWavyMusicNotesSpriteTemplate, ANIM_TARGET, 2, 7, 0, 12
delay 5 delay 5
createsprite gWavyMusicNotesSpriteTemplate, ANIM_TARGET, 2, 6, 1, 12 createsprite gWavyMusicNotesSpriteTemplate, ANIM_TARGET, 2, 6, 1, 12
@ -3460,7 +3460,7 @@ Move_HEAT_WAVE:
createvisualtask AnimTask_BlendParticle, 5, ANIM_TAG_FLYING_DIRT, 0, 6, 6, RGB_RED createvisualtask AnimTask_BlendParticle, 5, ANIM_TAG_FLYING_DIRT, 0, 6, 6, RGB_RED
createvisualtask AnimTask_LoadSandstormBackground, 5, TRUE createvisualtask AnimTask_LoadSandstormBackground, 5, TRUE
createvisualtask AnimTask_BlendBackground, 6, 6, RGB_RED createvisualtask AnimTask_BlendBackground, 6, 6, RGB_RED
panse_1B SE_M_HEAT_WAVE, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_HEAT_WAVE, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
delay 4 delay 4
createvisualtask AnimTask_MoveHeatWaveTargets, 5 createvisualtask AnimTask_MoveHeatWaveTargets, 5
delay 12 delay 12
@ -4232,7 +4232,7 @@ Move_GRASS_WHISTLE:
waitforvisualfinish waitforvisualfinish
createvisualtask AnimTask_MusicNotesRainbowBlend, 2 createvisualtask AnimTask_MusicNotesRainbowBlend, 2
waitforvisualfinish waitforvisualfinish
panse_1B SE_M_GRASSWHISTLE, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_GRASSWHISTLE, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
createsprite gWavyMusicNotesSpriteTemplate, ANIM_TARGET, 2, 7, 1, 0 createsprite gWavyMusicNotesSpriteTemplate, ANIM_TARGET, 2, 7, 1, 0
delay 5 delay 5
createsprite gWavyMusicNotesSpriteTemplate, ANIM_TARGET, 2, 6, 1, 0 createsprite gWavyMusicNotesSpriteTemplate, ANIM_TARGET, 2, 6, 1, 0
@ -4464,7 +4464,7 @@ Move_WATER_SPORT:
delay 44 delay 44
playsewithpan SE_M_SURF, SOUND_PAN_ATTACKER playsewithpan SE_M_SURF, SOUND_PAN_ATTACKER
delay 44 delay 44
panse_1B SE_M_SURF, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_SURF, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
end end
Move_CALM_MIND: Move_CALM_MIND:
@ -5475,7 +5475,7 @@ SolarBeamAbsorbEffect:
return return
SolarBeamUnleash: SolarBeamUnleash:
call SetSolarbeamBg call SetSolarbeamBg
panse_1B SE_M_SOLAR_BEAM, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_SOLAR_BEAM, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
createvisualtask AnimTask_CreateSmallSolarbeamOrbs, 5 createvisualtask AnimTask_CreateSmallSolarbeamOrbs, 5
createsprite gSolarbeamBigOrbSpriteTemplate, ANIM_TARGET, 3, 15, 0, 20, 0 createsprite gSolarbeamBigOrbSpriteTemplate, ANIM_TARGET, 3, 15, 0, 20, 0
delay 4 delay 4
@ -5527,7 +5527,7 @@ BlizzardContinue:
createvisualtask AnimTask_StartSlidingBg, 5, -2304, 0, 1, -1 createvisualtask AnimTask_StartSlidingBg, 5, -2304, 0, 1, -1
waitbgfadein waitbgfadein
waitforvisualfinish waitforvisualfinish
panse_1B SE_M_BLIZZARD, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_BLIZZARD, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
call BlizzardIceCrystals call BlizzardIceCrystals
call BlizzardIceCrystals call BlizzardIceCrystals
playsewithpan SE_M_BLIZZARD2, SOUND_PAN_TARGET playsewithpan SE_M_BLIZZARD2, SOUND_PAN_TARGET
@ -5573,7 +5573,7 @@ Move_POWDER_SNOW:
monbg ANIM_DEF_PARTNER monbg ANIM_DEF_PARTNER
createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 1, 0, 3, RGB_BLACK createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 1, 0, 3, RGB_BLACK
waitforvisualfinish waitforvisualfinish
panse_1B SE_M_GUST, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_GUST, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
call PowderSnowSnowballs call PowderSnowSnowballs
call PowderSnowSnowballs call PowderSnowSnowballs
playsewithpan SE_M_GUST2, SOUND_PAN_TARGET playsewithpan SE_M_GUST2, SOUND_PAN_TARGET
@ -5610,7 +5610,7 @@ Move_HYDRO_PUMP:
setalpha 12, 8 setalpha 12, 8
createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 0, 2, 40, 1 createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 0, 2, 40, 1
delay 6 delay 6
panse_1B SE_M_HYDRO_PUMP, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_HYDRO_PUMP, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
createvisualtask AnimTask_StartSinAnimTimer, 5, 100 createvisualtask AnimTask_StartSinAnimTimer, 5, 100
call HydroPumpBeams call HydroPumpBeams
call HydroPumpBeams call HydroPumpBeams
@ -5655,7 +5655,7 @@ Move_SIGNAL_BEAM:
loadspritegfx ANIM_TAG_DUCK loadspritegfx ANIM_TAG_DUCK
createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 0, 2, 25, 1 createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 0, 2, 25, 1
delay 6 delay 6
panse_1B SE_M_BUBBLE_BEAM, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +1, 0 panse SE_M_BUBBLE_BEAM, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +1, 0
createvisualtask AnimTask_StartSinAnimTimer, 5, 100 createvisualtask AnimTask_StartSinAnimTimer, 5, 100
call SignalBeamOrbs call SignalBeamOrbs
call SignalBeamOrbs call SignalBeamOrbs
@ -6297,7 +6297,7 @@ Move_CRABHAMMER:
Move_SURF: Move_SURF:
createvisualtask AnimTask_CreateSurfWave, 2, FALSE createvisualtask AnimTask_CreateSurfWave, 2, FALSE
delay 24 delay 24
panse_1B SE_M_SURF, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_SURF, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
waitforvisualfinish waitforvisualfinish
end end
@ -6309,7 +6309,7 @@ Move_FLAMETHROWER:
createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 0, 2, 46, 1 createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 0, 2, 46, 1
delay 6 delay 6
createvisualtask AnimTask_StartSinAnimTimer, 5, 100 createvisualtask AnimTask_StartSinAnimTimer, 5, 100
panse_1B SE_M_FLAMETHROWER, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_FLAMETHROWER, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
call FlamethrowerCreateFlames call FlamethrowerCreateFlames
call FlamethrowerCreateFlames call FlamethrowerCreateFlames
call FlamethrowerCreateFlames call FlamethrowerCreateFlames
@ -6722,7 +6722,7 @@ Move_SUNNY_DAY:
setalpha 13, 3 setalpha 13, 3
createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x781, 1, 0, 6, RGB_WHITE createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x781, 1, 0, 6, RGB_WHITE
waitforvisualfinish waitforvisualfinish
panse_26 SE_M_PETAL_DANCE, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +1, 0 panse_adjustnone SE_M_PETAL_DANCE, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +1, 0
call SunnyDayLightRay call SunnyDayLightRay
call SunnyDayLightRay call SunnyDayLightRay
call SunnyDayLightRay call SunnyDayLightRay
@ -7599,7 +7599,7 @@ Move_MIMIC:
setalpha 11, 5 setalpha 11, 5
monbg_22 ANIM_DEF_PARTNER monbg_22 ANIM_DEF_PARTNER
monbgprio_29 monbgprio_29
panse_1B SE_M_MINIMIZE, SOUND_PAN_TARGET, SOUND_PAN_ATTACKER, -3, 0 panse SE_M_MINIMIZE, SOUND_PAN_TARGET, SOUND_PAN_ATTACKER, -3, 0
createvisualtask AnimTask_ShrinkTargetCopy, 5, 128, 24 createvisualtask AnimTask_ShrinkTargetCopy, 5, 128, 24
delay 15 delay 15
createsprite gMimicOrbSpriteTemplate, ANIM_TARGET, 2, -12, 24 createsprite gMimicOrbSpriteTemplate, ANIM_TARGET, 2, -12, 24
@ -7943,7 +7943,7 @@ Move_PERISH_SONG:
createsprite gPerishSongMusicNoteSpriteTemplate, ANIM_ATTACKER, 4, 15, 0, 240 createsprite gPerishSongMusicNoteSpriteTemplate, ANIM_ATTACKER, 4, 15, 0, 240
createsprite gPerishSongMusicNote2SpriteTemplate, ANIM_ATTACKER, 4, 15, 0, 0 createsprite gPerishSongMusicNote2SpriteTemplate, ANIM_ATTACKER, 4, 15, 0, 0
delay 20 delay 20
panse_1B SE_M_PERISH_SONG, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_PERISH_SONG, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
delay 80 delay 80
createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 0, 16, RGB_BLACK createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 0, 16, RGB_BLACK
createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 4, 0 createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 4, 0
@ -8150,7 +8150,7 @@ Move_WISH:
loadspritegfx ANIM_TAG_SPARKLE_2 loadspritegfx ANIM_TAG_SPARKLE_2
createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 0, 10, RGB_BLACK createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 0, 10, RGB_BLACK
waitforvisualfinish waitforvisualfinish
panse_27 SE_M_REFLECT, SOUND_PAN_TARGET, SOUND_PAN_ATTACKER, -3, 0 panse_adjustall SE_M_REFLECT, SOUND_PAN_TARGET, SOUND_PAN_ATTACKER, -3, 0
createsprite gWishStarSpriteTemplate, ANIM_ATTACKER, 40 createsprite gWishStarSpriteTemplate, ANIM_ATTACKER, 40
waitforvisualfinish waitforvisualfinish
delay 60 delay 60
@ -8591,7 +8591,7 @@ ArmThrustLeft:
goto ArmThrustContinue goto ArmThrustContinue
Move_MUDDY_WATER: Move_MUDDY_WATER:
panse_1B SE_M_WHIRLPOOL, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_WHIRLPOOL, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
createvisualtask AnimTask_CreateSurfWave, 2, TRUE createvisualtask AnimTask_CreateSurfWave, 2, TRUE
waitforvisualfinish waitforvisualfinish
end end
@ -8689,7 +8689,7 @@ Move_MUD_SHOT:
createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 0, 2, 46, 1 createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 0, 2, 46, 1
delay 6 delay 6
createvisualtask AnimTask_StartSinAnimTimer, 5, 100 createvisualtask AnimTask_StartSinAnimTimer, 5, 100
panse_1B SE_M_WHIRLPOOL, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +1, 0 panse SE_M_WHIRLPOOL, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +1, 0
call MudShotOrbs call MudShotOrbs
call MudShotOrbs call MudShotOrbs
call MudShotOrbs call MudShotOrbs
@ -8717,7 +8717,7 @@ Move_METEOR_MASH:
loadspritegfx ANIM_TAG_GOLD_STARS loadspritegfx ANIM_TAG_GOLD_STARS
loadspritegfx ANIM_TAG_IMPACT loadspritegfx ANIM_TAG_IMPACT
loadspritegfx ANIM_TAG_HANDS_AND_FEET loadspritegfx ANIM_TAG_HANDS_AND_FEET
panse_1B SE_M_BARRIER, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +3, 0 panse SE_M_BARRIER, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +3, 0
fadetobg BG_COSMIC fadetobg BG_COSMIC
waitbgfadein waitbgfadein
waitforvisualfinish waitforvisualfinish
@ -8860,7 +8860,7 @@ Move_METAL_SOUND:
waitforvisualfinish waitforvisualfinish
end end
MetalSoundRings: MetalSoundRings:
panse_1B SE_M_SCREECH, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_SCREECH, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
createsprite gMetalSoundSpriteTemplate, ANIM_TARGET, 2, 16, 0, 0, 0, 30, 0 createsprite gMetalSoundSpriteTemplate, ANIM_TARGET, 2, 16, 0, 0, 0, 30, 0
delay 2 delay 2
return return
@ -9154,7 +9154,7 @@ Move_ROCK_TOMB:
Move_SILVER_WIND: Move_SILVER_WIND:
loadspritegfx ANIM_TAG_SPARKLE_6 loadspritegfx ANIM_TAG_SPARKLE_6
panse_1B SE_M_GUST, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_GUST, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
playsewithpan SE_M_MORNING_SUN, 0 playsewithpan SE_M_MORNING_SUN, 0
delay 0 delay 0
monbg ANIM_DEF_PARTNER monbg ANIM_DEF_PARTNER
@ -9368,7 +9368,7 @@ Move_HYDRO_CANNON:
delay 10 delay 10
createvisualtask AnimTask_InvertScreenColor, 2, 257, 257, 257 createvisualtask AnimTask_InvertScreenColor, 2, 257, 257, 257
delay 30 delay 30
panse_1B SE_M_HYDRO_PUMP, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 panse SE_M_HYDRO_PUMP, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
call HydroCannonBeam call HydroCannonBeam
createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 10, 0, 40, 1 createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 10, 0, 40, 1
createsprite gWaterHitSplatSpriteTemplate, ANIM_TARGET, 2, 0, 0, ANIM_TARGET, 0 createsprite gWaterHitSplatSpriteTemplate, ANIM_TARGET, 2, 0, 0, ANIM_TARGET, 0
@ -10296,7 +10296,7 @@ Status_Nightmare:
General_CastformChange: General_CastformChange:
createvisualtask AnimTask_IsMonInvisible, 2 createvisualtask AnimTask_IsMonInvisible, 2
jumpreteq 1, CastformChangeSkipAnim jumpreteq TRUE, CastformChangeSkipAnim
goto CastformChangeContinue goto CastformChangeContinue
CastformChangeContinue: CastformChangeContinue:
monbg ANIM_ATTACKER monbg ANIM_ATTACKER

View File

@ -2829,10 +2829,12 @@ BattleScript_HandleFaintedMon::
jumpifbyte CMP_NOT_EQUAL, gBattleOutcome, 0, BattleScript_FaintedMonEnd jumpifbyte CMP_NOT_EQUAL, gBattleOutcome, 0, BattleScript_FaintedMonEnd
jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_FaintedMonTryChooseAnother jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_FaintedMonTryChooseAnother
jumpifword CMP_NO_COMMON_BITS, gHitMarker, HITMARKER_PLAYER_FAINTED, BattleScript_FaintedMonTryChooseAnother jumpifword CMP_NO_COMMON_BITS, gHitMarker, HITMARKER_PLAYER_FAINTED, BattleScript_FaintedMonTryChooseAnother
@ Yes/No for sending out a new Pokémon, when sending out is optional
printstring STRINGID_USENEXTPKMN printstring STRINGID_USENEXTPKMN
setbyte gBattleCommunication, 0 setbyte gBattleCommunication, 0
yesnobox yesnobox
jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 0, BattleScript_FaintedMonTryChooseAnother jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 0, BattleScript_FaintedMonTryChooseAnother
@ Player said no, try to run
jumpifplayerran BattleScript_FaintedMonEnd jumpifplayerran BattleScript_FaintedMonEnd
printstring STRINGID_CANTESCAPE2 printstring STRINGID_CANTESCAPE2
BattleScript_FaintedMonTryChooseAnother:: BattleScript_FaintedMonTryChooseAnother::
@ -2904,7 +2906,7 @@ BattleScript_HandleFaintedMonLoop::
hidepartystatussummary BS_FAINTED hidepartystatussummary BS_FAINTED
switchinanim BS_FAINTED, FALSE switchinanim BS_FAINTED, FALSE
waitstate waitstate
switchineffects 5 switchineffects BS_UNK_5
jumpifbytenotequal gBattlerFainted, gBattlersCount, BattleScript_HandleFaintedMonLoop jumpifbytenotequal gBattlerFainted, gBattlersCount, BattleScript_HandleFaintedMonLoop
BattleScript_HandleFaintedMonMultipleEnd:: BattleScript_HandleFaintedMonMultipleEnd::
end2 end2

View File

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 286 B

View File

@ -32,7 +32,6 @@
#define B_ACTION_EXEC_SCRIPT 10 #define B_ACTION_EXEC_SCRIPT 10
#define B_ACTION_TRY_FINISH 11 #define B_ACTION_TRY_FINISH 11
#define B_ACTION_FINISHED 12 #define B_ACTION_FINISHED 12
#define B_ACTION_CANCEL_PARTNER 12 // when choosing an action #define B_ACTION_CANCEL_PARTNER 12 // when choosing an action
#define B_ACTION_NOTHING_FAINTED 13 // when choosing an action #define B_ACTION_NOTHING_FAINTED 13 // when choosing an action
#define B_ACTION_NONE 0xFF #define B_ACTION_NONE 0xFF
@ -50,14 +49,17 @@
#define MSG_DISPLAY 7 #define MSG_DISPLAY 7
#define BATTLE_COMMUNICATION_ENTRIES_COUNT 8 #define BATTLE_COMMUNICATION_ENTRIES_COUNT 8
#define MOVE_TARGET_SELECTED 0x0 #define MOVE_TARGET_SELECTED 0
#define MOVE_TARGET_DEPENDS 0x1 #define MOVE_TARGET_DEPENDS (1 << 0)
#define MOVE_TARGET_USER_OR_SELECTED 0x2 #define MOVE_TARGET_USER_OR_SELECTED (1 << 1)
#define MOVE_TARGET_RANDOM 0x4 #define MOVE_TARGET_RANDOM (1 << 2)
#define MOVE_TARGET_BOTH 0x8 #define MOVE_TARGET_BOTH (1 << 3)
#define MOVE_TARGET_USER 0x10 #define MOVE_TARGET_USER (1 << 4)
#define MOVE_TARGET_FOES_AND_ALLY 0x20 #define MOVE_TARGET_FOES_AND_ALLY (1 << 5)
#define MOVE_TARGET_OPPONENTS_FIELD 0x40 #define MOVE_TARGET_OPPONENTS_FIELD (1 << 6)
// For the second argument of GetMoveTarget, when no target override is needed
#define NO_TARGET_OVERRIDE 0
#define BATTLE_BUFFER_LINK_SIZE 0x1000 #define BATTLE_BUFFER_LINK_SIZE 0x1000
@ -115,7 +117,7 @@ struct ProtectStruct
u32 confusionSelfDmg:1; u32 confusionSelfDmg:1;
u32 targetNotAffected:1; u32 targetNotAffected:1;
u32 chargingTurn:1; u32 chargingTurn:1;
u32 fleeFlag:2; // For RunAway and Smoke Ball. u32 fleeType:2; // 0: Normal, 1: FLEE_ITEM, 2: FLEE_ABILITY
u32 usedImprisonedMove:1; u32 usedImprisonedMove:1;
u32 loveImmobility:1; u32 loveImmobility:1;
u32 usedDisabledMove:1; u32 usedDisabledMove:1;
@ -426,7 +428,7 @@ struct BattleStruct
u8 unused_6[3]; u8 unused_6[3];
u8 givenExpMons; // Bits for enemy party's pokemon that gave exp to player's party. u8 givenExpMons; // Bits for enemy party's pokemon that gave exp to player's party.
u8 lastTakenMoveFrom[MAX_BATTLERS_COUNT * MAX_BATTLERS_COUNT * 2]; // a 3-D array [target][attacker][byte] u8 lastTakenMoveFrom[MAX_BATTLERS_COUNT * MAX_BATTLERS_COUNT * 2]; // a 3-D array [target][attacker][byte]
u16 castformPalette[MAX_BATTLERS_COUNT][16]; u16 castformPalette[NUM_CASTFORM_FORMS][16];
union { union {
struct LinkBattlerHeader linkBattlerHeader; struct LinkBattlerHeader linkBattlerHeader;
u32 battleVideo[2]; u32 battleVideo[2];
@ -447,10 +449,14 @@ struct BattleStruct
u8 alreadyStatusedMoveAttempt; // As bits for battlers; For example when using Thunder Wave on an already paralyzed pokemon. u8 alreadyStatusedMoveAttempt; // As bits for battlers; For example when using Thunder Wave on an already paralyzed pokemon.
}; };
#define F_DYNAMIC_TYPE_1 (1 << 6)
#define F_DYNAMIC_TYPE_2 (1 << 7)
#define DYNAMIC_TYPE_MASK (F_DYNAMIC_TYPE_1 - 1)
#define GET_MOVE_TYPE(move, typeArg) \ #define GET_MOVE_TYPE(move, typeArg) \
{ \ { \
if (gBattleStruct->dynamicMoveType) \ if (gBattleStruct->dynamicMoveType) \
typeArg = gBattleStruct->dynamicMoveType & 0x3F; \ typeArg = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; \
else \ else \
typeArg = gBattleMoves[move].type; \ typeArg = gBattleMoves[move].type; \
} }
@ -502,7 +508,7 @@ struct BattleScripting
u8 reshowMainState; u8 reshowMainState;
u8 reshowHelperState; u8 reshowHelperState;
u8 levelUpHP; u8 levelUpHP;
u8 windowsType; // 0 - normal, 1 - battle arena u8 windowsType; // B_WIN_TYPE_*
u8 multiplayerId; u8 multiplayerId;
u8 specialTrainerBattleType; u8 specialTrainerBattleType;
}; };
@ -624,8 +630,8 @@ extern u8 gBattleTextBuff3[TEXT_BUFF_ARRAY_COUNT];
extern u32 gBattleTypeFlags; extern u32 gBattleTypeFlags;
extern u8 gBattleTerrain; extern u8 gBattleTerrain;
extern u32 gUnusedFirstBattleVar1; extern u32 gUnusedFirstBattleVar1;
extern u8 *gUnknown_0202305C; extern u8 *gBattleAnimBgTileBuffer;
extern u8 *gUnknown_02023060; extern u8 *gBattleAnimBgTilemapBuffer;
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern u8 gActiveBattler; extern u8 gActiveBattler;

View File

@ -64,12 +64,12 @@ s8 BattleAnimAdjustPanning(s8 pan);
s8 BattleAnimAdjustPanning2(s8 pan); s8 BattleAnimAdjustPanning2(s8 pan);
s16 KeepPanInRange(s16 a, int oldPan); s16 KeepPanInRange(s16 a, int oldPan);
s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan); s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan);
void sub_80A4720(u16 a, u16 *b, u32 c, u8 d); void RelocateBattleBgPal(u16 paletteNum, u16 *dest, u32 offset, bool8 largeScreen);
void ResetBattleAnimBg(bool8); void ResetBattleAnimBg(bool8);
// battle_intro.c // battle_intro.c
void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value); void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value);
void sub_8118FBC(int bgId, u8 arg1, u8 arg2, u8 battlerPosition, u8 arg4, u8 *arg5, u16 *arg6, u16 arg7); void DrawBattlerOnBg(int bgId, u8 x, u8 y, u8 battlerPosition, u8 paletteId, u8 *tiles, u16 *tilemap, u16 tilesOffset);
void HandleIntroSlide(u8 terrainId); void HandleIntroSlide(u8 terrainId);
int GetAnimBgAttribute(u8 bgId, u8 attributeId); int GetAnimBgAttribute(u8 bgId, u8 attributeId);
@ -107,7 +107,7 @@ void AnimTranslateLinear_WaitEnd(struct Sprite *sprite);
u8 GetBattlerSpriteBGPriority(u8 battlerId); u8 GetBattlerSpriteBGPriority(u8 battlerId);
void *LoadPointerFromVars(s16 bottom, s16 top); void *LoadPointerFromVars(s16 bottom, s16 top);
void StorePointerInVars(s16 *bottom, s16 *top, const void *ptr); void StorePointerInVars(s16 *bottom, s16 *top, const void *ptr);
void sub_80A8278(void); void InitPrioritiesForVisibleBattlers(void);
void GetBattleAnimBg1Data(struct BattleAnimBgData*); void GetBattleAnimBg1Data(struct BattleAnimBgData*);
void GetBattleAnimBgData(struct BattleAnimBgData*, u32 arg1); void GetBattleAnimBgData(struct BattleAnimBgData*, u32 arg1);
u8 GetBattlerSpriteSubpriority(u8 battlerId); u8 GetBattlerSpriteSubpriority(u8 battlerId);
@ -125,7 +125,7 @@ u8 AnimDummyReturnArg(u8 battler);
s16 CloneBattlerSpriteWithBlend(u8); s16 CloneBattlerSpriteWithBlend(u8);
void obj_delete_but_dont_free_vram(struct Sprite*); void obj_delete_but_dont_free_vram(struct Sprite*);
u8 CreateInvisibleSpriteCopy(int, u8, int); u8 CreateInvisibleSpriteCopy(int, u8, int);
void AnimLoadCompressedBgTilemapHandleContest(struct BattleAnimBgData*, const void*, u32); void AnimLoadCompressedBgTilemapHandleContest(struct BattleAnimBgData*, const void*, bool32);
void AnimLoadCompressedBgGfx(u32, const u32*, u32); void AnimLoadCompressedBgGfx(u32, const u32*, u32);
void UpdateAnimBg3ScreenSize(bool8); void UpdateAnimBg3ScreenSize(bool8);
void TranslateSpriteInGrowingCircleOverDuration(struct Sprite *); void TranslateSpriteInGrowingCircleOverDuration(struct Sprite *);

View File

@ -7,7 +7,6 @@ void BattleArena_InitPoints(void);
void BattleArena_AddMindPoints(u8 battler); void BattleArena_AddMindPoints(u8 battler);
void BattleArena_AddSkillPoints(u8 battler); void BattleArena_AddSkillPoints(u8 battler);
void BattleArena_DeductMindPoints(u8 battler, u16 stringId); void BattleArena_DeductMindPoints(u8 battler, u16 stringId);
void sub_81A586C(u8 battler);
void DrawArenaRefereeTextBox(void); void DrawArenaRefereeTextBox(void);
void EraseArenaRefereeTextBox(void); void EraseArenaRefereeTextBox(void);

View File

@ -18,7 +18,6 @@ void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId);
void DecompressTrainerBackPic(u16 backPicId, u8 battlerId); void DecompressTrainerBackPic(u16 backPicId, u8 battlerId);
void BattleGfxSfxDummy3(u8 gender); void BattleGfxSfxDummy3(u8 gender);
void FreeTrainerFrontPicPalette(u16 frontPicId); void FreeTrainerFrontPicPalette(u16 frontPicId);
void sub_805DFFC(void);
bool8 BattleLoadAllHealthBoxesGfx(u8 state); bool8 BattleLoadAllHealthBoxesGfx(u8 state);
void LoadBattleBarGfx(u8 arg0); void LoadBattleBarGfx(u8 arg0);
bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId); bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId);

View File

@ -7,7 +7,8 @@ struct TrainerMoney
u8 value; u8 value;
}; };
struct UnknownPokemonStruct4 // For displaying a multi battle partner's Pokémon in the party menu
struct MultiPartnerMenuPokemon
{ {
/*0x00*/ u16 species; /*0x00*/ u16 species;
/*0x02*/ u16 heldItem; /*0x02*/ u16 heldItem;
@ -46,8 +47,6 @@ struct UnknownPokemonStruct4
void CB2_InitBattle(void); void CB2_InitBattle(void);
void BattleMainCB2(void); void BattleMainCB2(void);
void CB2_QuitRecordedBattle(void); void CB2_QuitRecordedBattle(void);
void sub_8038528(struct Sprite* sprite);
void sub_8038A04(void); // unused
void VBlankCB_Battle(void); void VBlankCB_Battle(void);
void SpriteCB_VsLetterDummy(struct Sprite *sprite); void SpriteCB_VsLetterDummy(struct Sprite *sprite);
void SpriteCB_VsLetterInit(struct Sprite *sprite); void SpriteCB_VsLetterInit(struct Sprite *sprite);
@ -59,13 +58,12 @@ void SpriteCallbackDummy_2(struct Sprite *sprite);
void SpriteCB_FaintOpponentMon(struct Sprite *sprite); void SpriteCB_FaintOpponentMon(struct Sprite *sprite);
void SpriteCb_ShowAsMoveTarget(struct Sprite *sprite); void SpriteCb_ShowAsMoveTarget(struct Sprite *sprite);
void SpriteCb_HideAsMoveTarget(struct Sprite *sprite); void SpriteCb_HideAsMoveTarget(struct Sprite *sprite);
void SpriteCb_OpponentMonFromBall(struct Sprite *sprite); void SpriteCB_OpponentMonFromBall(struct Sprite *sprite);
void SpriteCB_BattleSpriteStartSlideLeft(struct Sprite *sprite); void SpriteCB_BattleSpriteStartSlideLeft(struct Sprite *sprite);
void SpriteCB_FaintSlideAnim(struct Sprite *sprite); void SpriteCB_FaintSlideAnim(struct Sprite *sprite);
void DoBounceEffect(u8 battlerId, u8 b, s8 c, s8 d); void DoBounceEffect(u8 battlerId, u8 b, s8 c, s8 d);
void EndBounceEffect(u8 battlerId, bool8 b); void EndBounceEffect(u8 battlerId, bool8 b);
void SpriteCb_PlayerMonFromBall(struct Sprite *sprite); void SpriteCB_PlayerMonFromBall(struct Sprite *sprite);
void sub_8039E60(struct Sprite *sprite);
void SpriteCB_TrainerThrowObject(struct Sprite *sprite); void SpriteCB_TrainerThrowObject(struct Sprite *sprite);
void sub_8039E9C(struct Sprite *sprite); void sub_8039E9C(struct Sprite *sprite);
void BeginBattleIntroDummy(void); void BeginBattleIntroDummy(void);
@ -82,9 +80,9 @@ void RunBattleScriptCommands(void);
bool8 TryRunFromBattle(u8 battlerId); bool8 TryRunFromBattle(u8 battlerId);
void SpecialStatusesClear(void); void SpecialStatusesClear(void);
extern struct UnknownPokemonStruct4 gMultiPartnerParty[MULTI_PARTY_SIZE]; extern struct MultiPartnerMenuPokemon gMultiPartnerParty[MULTI_PARTY_SIZE];
extern const struct SpriteTemplate gUnknown_0831AC88; extern const struct SpriteTemplate gUnusedBattleInitSprite;
extern const struct OamData gOamData_BattleSpriteOpponentSide; extern const struct OamData gOamData_BattleSpriteOpponentSide;
extern const struct OamData gOamData_BattleSpritePlayerSide; extern const struct OamData gOamData_BattleSpritePlayerSide;
extern const u8 gTypeEffectiveness[336]; extern const u8 gTypeEffectiveness[336];

View File

@ -63,7 +63,6 @@ void CB2_PyramidBagMenuFromStartMenu(void);
void CB2_ReturnToPyramidBagMenu(void); void CB2_ReturnToPyramidBagMenu(void);
void UpdatePyramidBagList(void); void UpdatePyramidBagList(void);
void UpdatePyramidBagCursorPos(void); void UpdatePyramidBagCursorPos(void);
void sub_81C4EFC(void);
void GoToBattlePyramidBagMenu(u8 location, void (*exitCallback)(void)); void GoToBattlePyramidBagMenu(u8 location, void (*exitCallback)(void));
void Task_CloseBattlePyramidBagMessage(u8 taskId); void Task_CloseBattlePyramidBagMessage(u8 taskId);
void TryStoreHeldItemsInPyramidBag(void); void TryStoreHeldItemsInPyramidBag(void);

View File

@ -11,8 +11,7 @@ void GetBg0TilesDst(u16 **tilemap, u16 **tileset);
extern const struct SpritePalette gSpritePalette_Pokeball; extern const struct SpritePalette gSpritePalette_Pokeball;
enum // TRANSITION_MUGSHOT enum {
{
MUGSHOT_SIDNEY, MUGSHOT_SIDNEY,
MUGSHOT_PHOEBE, MUGSHOT_PHOEBE,
MUGSHOT_GLACIA, MUGSHOT_GLACIA,
@ -21,52 +20,64 @@ enum // TRANSITION_MUGSHOT
MUGSHOTS_COUNT MUGSHOTS_COUNT
}; };
// credits for the names go to Dyskinesia, Tetrable and Farore enum {
// names are naturally subject to change B_TRANSITION_BLUR,
B_TRANSITION_SWIRL,
B_TRANSITION_SHUFFLE,
B_TRANSITION_BIG_POKEBALL,
B_TRANSITION_POKEBALLS_TRAIL,
B_TRANSITION_CLOCKWISE_BLACKFADE,
B_TRANSITION_RIPPLE,
B_TRANSITION_WAVE,
B_TRANSITION_SLICE,
B_TRANSITION_WHITEFADE,
B_TRANSITION_GRID_SQUARES,
B_TRANSITION_SHARDS,
B_TRANSITION_SIDNEY,
B_TRANSITION_PHOEBE,
B_TRANSITION_GLACIA,
B_TRANSITION_DRAKE,
B_TRANSITION_CHAMPION,
B_TRANSITION_AQUA, // Here below added in Emerald
B_TRANSITION_MAGMA,
B_TRANSITION_REGICE,
B_TRANSITION_REGISTEEL,
B_TRANSITION_REGIROCK,
B_TRANSITION_KYOGRE,
B_TRANSITION_GROUDON,
B_TRANSITION_RAYQUAZA,
B_TRANSITION_SHRED_SPLIT,
B_TRANSITION_BLACKHOLE1,
B_TRANSITION_BLACKHOLE2,
B_TRANSITION_RECTANGULAR_SPIRAL,
B_TRANSITION_FRONTIER_LOGO_WIGGLE,
B_TRANSITION_FRONTIER_LOGO_WAVE,
B_TRANSITION_FRONTIER_SQUARES,
B_TRANSITION_FRONTIER_SQUARES_SCROLL,
B_TRANSITION_FRONTIER_SQUARES_SPIRAL,
B_TRANSITION_FRONTIER_CIRCLES_MEET,
B_TRANSITION_FRONTIER_CIRCLES_CROSS,
B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL,
B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL,
B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ,
B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ,
B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ,
B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ,
B_TRANSITION_COUNT
};
#define B_TRANSITION_BLUR 0 // IDs for GetSpecialBattleTransition
#define B_TRANSITION_SWIRL 1 enum {
#define B_TRANSITION_SHUFFLE 2 B_TRANSITION_GROUP_B_TOWER,
#define B_TRANSITION_BIG_POKEBALL 3 B_TRANSITION_GROUP_B_DOME = 3,
#define B_TRANSITION_POKEBALLS_TRAIL 4 B_TRANSITION_GROUP_B_PALACE,
#define B_TRANSITION_CLOCKWISE_BLACKFADE 5 B_TRANSITION_GROUP_B_ARENA,
#define B_TRANSITION_RIPPLE 6 B_TRANSITION_GROUP_B_FACTORY,
#define B_TRANSITION_WAVE 7 B_TRANSITION_GROUP_B_PIKE,
#define B_TRANSITION_SLICE 8 B_TRANSITION_GROUP_B_PYRAMID = 10,
#define B_TRANSITION_WHITEFADE 9 B_TRANSITION_GROUP_TRAINER_HILL,
#define B_TRANSITION_GRID_SQUARES 10 B_TRANSITION_GROUP_SECRET_BASE,
#define B_TRANSITION_SHARDS 11 B_TRANSITION_GROUP_E_READER,
#define B_TRANSITION_SIDNEY 12 };
#define B_TRANSITION_PHOEBE 13
#define B_TRANSITION_GLACIA 14
#define B_TRANSITION_DRAKE 15
#define B_TRANSITION_CHAMPION 16
// added in Emerald
#define B_TRANSITION_AQUA 17
#define B_TRANSITION_MAGMA 18
#define B_TRANSITION_REGICE 19
#define B_TRANSITION_REGISTEEL 20
#define B_TRANSITION_REGIROCK 21
#define B_TRANSITION_KYOGRE 22
#define B_TRANSITION_GROUDON 23
#define B_TRANSITION_RAYQUAZA 24
#define B_TRANSITION_SHRED_SPLIT 25
#define B_TRANSITION_BLACKHOLE1 26
#define B_TRANSITION_BLACKHOLE2 27
#define B_TRANSITION_RECTANGULAR_SPIRAL 28
#define B_TRANSITION_FRONTIER_LOGO_WIGGLE 29
#define B_TRANSITION_FRONTIER_LOGO_WAVE 30
#define B_TRANSITION_FRONTIER_SQUARES 31
#define B_TRANSITION_FRONTIER_SQUARES_SCROLL 32
#define B_TRANSITION_FRONTIER_SQUARES_SPIRAL 33
#define B_TRANSITION_FRONTIER_CIRCLES_MEET 34
#define B_TRANSITION_FRONTIER_CIRCLES_CROSS 35
#define B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL 36
#define B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL 37
#define B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ 38
#define B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ 39
#define B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ 40
#define B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ 41
#define B_TRANSITION_COUNT 42
#endif // GUARD_BATTLE_TRANSITION_H #endif // GUARD_BATTLE_TRANSITION_H

View File

@ -7,38 +7,42 @@
#define MOVE_LIMITATION_TORMENTED (1 << 3) #define MOVE_LIMITATION_TORMENTED (1 << 3)
#define MOVE_LIMITATION_TAUNT (1 << 4) #define MOVE_LIMITATION_TAUNT (1 << 4)
#define MOVE_LIMITATION_IMPRISON (1 << 5) #define MOVE_LIMITATION_IMPRISON (1 << 5)
#define MOVE_LIMITATIONS_ALL 0xFF
#define ABILITYEFFECT_ON_SWITCHIN 0x0 #define ABILITYEFFECT_ON_SWITCHIN 0
#define ABILITYEFFECT_ENDTURN 0x1 #define ABILITYEFFECT_ENDTURN 1
#define ABILITYEFFECT_MOVES_BLOCK 0x2 #define ABILITYEFFECT_MOVES_BLOCK 2
#define ABILITYEFFECT_ABSORBING 0x3 #define ABILITYEFFECT_ABSORBING 3
#define ABILITYEFFECT_ON_DAMAGE 0x4 #define ABILITYEFFECT_ON_DAMAGE 4
#define ABILITYEFFECT_IMMUNITY 0x5 #define ABILITYEFFECT_IMMUNITY 5
#define ABILITYEFFECT_FORECAST 0x6 #define ABILITYEFFECT_FORECAST 6
#define ABILITYEFFECT_SYNCHRONIZE 0x7 #define ABILITYEFFECT_SYNCHRONIZE 7
#define ABILITYEFFECT_ATK_SYNCHRONIZE 0x8 #define ABILITYEFFECT_ATK_SYNCHRONIZE 8
#define ABILITYEFFECT_INTIMIDATE1 0x9 #define ABILITYEFFECT_INTIMIDATE1 9
#define ABILITYEFFECT_INTIMIDATE2 0xA #define ABILITYEFFECT_INTIMIDATE2 10
#define ABILITYEFFECT_TRACE 0xB #define ABILITYEFFECT_TRACE 11
#define ABILITYEFFECT_CHECK_OTHER_SIDE 0xC #define ABILITYEFFECT_CHECK_OTHER_SIDE 12
#define ABILITYEFFECT_CHECK_BATTLER_SIDE 0xD #define ABILITYEFFECT_CHECK_BATTLER_SIDE 13
#define ABILITYEFFECT_FIELD_SPORT 0xE #define ABILITYEFFECT_FIELD_SPORT 14
#define ABILITYEFFECT_CHECK_FIELD_EXCEPT_BATTLER 0xF #define ABILITYEFFECT_CHECK_FIELD_EXCEPT_BATTLER 15
#define ABILITYEFFECT_COUNT_OTHER_SIDE 0x10 #define ABILITYEFFECT_COUNT_OTHER_SIDE 16
#define ABILITYEFFECT_COUNT_BATTLER_SIDE 0x11 #define ABILITYEFFECT_COUNT_BATTLER_SIDE 17
#define ABILITYEFFECT_COUNT_ON_FIELD 0x12 #define ABILITYEFFECT_COUNT_ON_FIELD 18
#define ABILITYEFFECT_CHECK_ON_FIELD 0x13 #define ABILITYEFFECT_CHECK_ON_FIELD 19
#define ABILITYEFFECT_MUD_SPORT 0xFD #define ABILITYEFFECT_MUD_SPORT 253
#define ABILITYEFFECT_WATER_SPORT 0xFE #define ABILITYEFFECT_WATER_SPORT 254
#define ABILITYEFFECT_SWITCH_IN_WEATHER 0xFF #define ABILITYEFFECT_SWITCH_IN_WEATHER 255
#define ABILITY_ON_OPPOSING_FIELD(battlerId, abilityId)(AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, battlerId, abilityId, 0, 0)) #define ABILITY_ON_OPPOSING_FIELD(battlerId, abilityId)(AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, battlerId, abilityId, 0, 0))
#define ABILITY_ON_FIELD(abilityId)(AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, abilityId, 0, 0)) #define ABILITY_ON_FIELD(abilityId)(AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, abilityId, 0, 0))
#define ABILITY_ON_FIELD2(abilityId)(AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, abilityId, 0, 0)) #define ABILITY_ON_FIELD2(abilityId)(AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, abilityId, 0, 0))
#define ITEMEFFECT_ON_SWITCH_IN 0x0 // For the first argument of ItemBattleEffects, to deteremine which block of item effects to try
#define ITEMEFFECT_MOVE_END 0x3 #define ITEMEFFECT_ON_SWITCH_IN 0
#define ITEMEFFECT_KINGSROCK_SHELLBELL 0x4 #define ITEMEFFECT_NORMAL 1
#define ITEMEFFECT_DUMMY 2 // Unused, empty
#define ITEMEFFECT_MOVE_END 3
#define ITEMEFFECT_KINGSROCK_SHELLBELL 4
#define WEATHER_HAS_EFFECT ((!ABILITY_ON_FIELD(ABILITY_CLOUD_NINE) && !ABILITY_ON_FIELD(ABILITY_AIR_LOCK))) #define WEATHER_HAS_EFFECT ((!ABILITY_ON_FIELD(ABILITY_CLOUD_NINE) && !ABILITY_ON_FIELD(ABILITY_AIR_LOCK)))
#define WEATHER_HAS_EFFECT2 ((!ABILITY_ON_FIELD2(ABILITY_CLOUD_NINE) && !ABILITY_ON_FIELD2(ABILITY_AIR_LOCK))) #define WEATHER_HAS_EFFECT2 ((!ABILITY_ON_FIELD2(ABILITY_CLOUD_NINE) && !ABILITY_ON_FIELD2(ABILITY_AIR_LOCK)))

View File

@ -306,4 +306,17 @@
#define B_WAIT_TIME_MED 48 #define B_WAIT_TIME_MED 48
#define B_WAIT_TIME_SHORT 32 #define B_WAIT_TIME_SHORT 32
#define CASTFORM_NORMAL 0
#define CASTFORM_FIRE 1
#define CASTFORM_WATER 2
#define CASTFORM_ICE 3
#define NUM_CASTFORM_FORMS 4
#define CASTFORM_SUBSTITUTE (1 << 7)
#define FLEE_ITEM 1
#define FLEE_ABILITY 2
#define B_WIN_TYPE_NORMAL 0
#define B_WIN_TYPE_ARENA 1
#endif // GUARD_CONSTANTS_BATTLE_H #endif // GUARD_CONSTANTS_BATTLE_H

View File

@ -318,7 +318,7 @@
#define SOUND_PAN_TARGET 63 #define SOUND_PAN_TARGET 63
// move background ids // move background ids
#define BG_DARK_ 0 // the same as BG_DARK but is unused #define BG_NONE 0 // the same as BG_DARK but is unused
#define BG_DARK 1 #define BG_DARK 1
#define BG_GHOST 2 #define BG_GHOST 2
#define BG_PSYCHIC 3 #define BG_PSYCHIC 3

View File

@ -294,7 +294,7 @@ struct ContestResources
u8 * contestBgTilemaps[CONTESTANT_COUNT]; u8 * contestBgTilemaps[CONTESTANT_COUNT];
void * boxBlinkTiles1; void * boxBlinkTiles1;
void * boxBlinkTiles2; void * boxBlinkTiles2;
void * field_3c; void * animBgTileBuffer;
}; };
#define eContest (*gContestResources->contest) #define eContest (*gContestResources->contest)

View File

@ -66,7 +66,7 @@ enum {
REMATCH_TRENT, REMATCH_TRENT,
REMATCH_SAWYER, REMATCH_SAWYER,
REMATCH_KIRA_AND_DAN, REMATCH_KIRA_AND_DAN,
REMATCH_WALLY_3, // Entries above WALLY are considered normal trainers, from Wally below are special trainers REMATCH_WALLY_VR, // Entries above WALLY are considered normal trainers, from Wally below are special trainers
REMATCH_ROXANNE, REMATCH_ROXANNE,
REMATCH_BRAWLY, REMATCH_BRAWLY,
REMATCH_WATTSON, REMATCH_WATTSON,
@ -75,7 +75,7 @@ enum {
REMATCH_WINONA, REMATCH_WINONA,
REMATCH_TATE_AND_LIZA, REMATCH_TATE_AND_LIZA,
REMATCH_JUAN, REMATCH_JUAN,
REMATCH_SIDNEY, // Entries below SIDNEY are considered part of REMATCH_ELITE_FOUR_ENTRIES. REMATCH_SIDNEY, // Entries from SIDNEY below are considered part of REMATCH_ELITE_FOUR_ENTRIES.
REMATCH_PHOEBE, REMATCH_PHOEBE,
REMATCH_GLACIA, REMATCH_GLACIA,
REMATCH_DRAKE, REMATCH_DRAKE,
@ -83,7 +83,7 @@ enum {
REMATCH_TABLE_ENTRIES // The total number of rematch entries. Must be last in enum REMATCH_TABLE_ENTRIES // The total number of rematch entries. Must be last in enum
}; };
#define REMATCH_SPECIAL_TRAINER_START REMATCH_WALLY_3 #define REMATCH_SPECIAL_TRAINER_START REMATCH_WALLY_VR
#define REMATCH_ELITE_FOUR_ENTRIES REMATCH_SIDNEY #define REMATCH_ELITE_FOUR_ENTRIES REMATCH_SIDNEY
void UpdateGymLeaderRematch(void); void UpdateGymLeaderRematch(void);

View File

@ -9,7 +9,7 @@ extern u8 gRecordedBattleMultiplayerId;
#define B_RECORD_MODE_PLAYBACK 2 #define B_RECORD_MODE_PLAYBACK 2
void RecordedBattle_Init(u8 arg0); void RecordedBattle_Init(u8 arg0);
void sub_8184E58(void); void RecordedBattle_SetTrainerInfo(void);
void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action); void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action);
void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear); void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear);
u8 RecordedBattle_GetBattlerAction(u8 battlerId); u8 RecordedBattle_GetBattlerAction(u8 battlerId);
@ -30,8 +30,8 @@ u8 GetTextSpeedInRecordedBattle(void);
void RecordedBattle_CopyBattlerMoves(void); void RecordedBattle_CopyBattlerMoves(void);
void sub_818603C(u8 arg0); void sub_818603C(u8 arg0);
u32 GetAiScriptsInRecordedBattle(void); u32 GetAiScriptsInRecordedBattle(void);
void sub_8186444(void); void RecordedBattle_SetPlaybackFinished(void);
bool8 sub_8186450(void); bool8 RecordedBattle_CanStopPlayback(void);
void GetRecordedBattleRecordMixFriendName(u8 *dst); void GetRecordedBattleRecordMixFriendName(u8 *dst);
u8 GetRecordedBattleRecordMixFriendClass(void); u8 GetRecordedBattleRecordMixFriendClass(void);
u8 GetRecordedBattleApprenticeId(void); u8 GetRecordedBattleApprenticeId(void);

View File

@ -334,7 +334,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
defaultScoreMoves >>= 1; defaultScoreMoves >>= 1;
} }
moveLimitations = CheckMoveLimitations(gActiveBattler, 0, 0xFF); moveLimitations = CheckMoveLimitations(gActiveBattler, 0, MOVE_LIMITATIONS_ALL);
// Ignore moves that aren't possible to use. // Ignore moves that aren't possible to use.
for (i = 0; i < MAX_MON_MOVES; i++) for (i = 0; i < MAX_MON_MOVES; i++)

View File

@ -27,15 +27,14 @@ extern struct MusicPlayerInfo gMPlayInfo_SE2;
extern const u16 gMovesWithQuietBGM[]; extern const u16 gMovesWithQuietBGM[];
extern const u8 *const gBattleAnims_Moves[]; extern const u8 *const gBattleAnims_Moves[];
// this file's functions
static void ScriptCmd_loadspritegfx(void); static void ScriptCmd_loadspritegfx(void);
static void ScriptCmd_unloadspritegfx(void); static void ScriptCmd_unloadspritegfx(void);
static void ScriptCmd_createsprite(void); static void ScriptCmd_createsprite(void);
static void ScriptCmd_createvisualtask(void); static void ScriptCmd_createvisualtask(void);
static void ScriptCmd_delay(void); static void ScriptCmd_delay(void);
static void ScriptCmd_waitforvisualfinish(void); static void ScriptCmd_waitforvisualfinish(void);
static void ScriptCmd_hang1(void); static void ScriptCmd_nop(void);
static void ScriptCmd_hang2(void); static void ScriptCmd_nop2(void);
static void ScriptCmd_end(void); static void ScriptCmd_end(void);
static void ScriptCmd_playse(void); static void ScriptCmd_playse(void);
static void ScriptCmd_monbg(void); static void ScriptCmd_monbg(void);
@ -55,7 +54,7 @@ static void ScriptCmd_waitbgfadein(void);
static void ScriptCmd_changebg(void); static void ScriptCmd_changebg(void);
static void ScriptCmd_playsewithpan(void); static void ScriptCmd_playsewithpan(void);
static void ScriptCmd_setpan(void); static void ScriptCmd_setpan(void);
static void ScriptCmd_panse_1B(void); static void ScriptCmd_panse(void);
static void ScriptCmd_loopsewithpan(void); static void ScriptCmd_loopsewithpan(void);
static void ScriptCmd_waitplaysewithpan(void); static void ScriptCmd_waitplaysewithpan(void);
static void ScriptCmd_setbldcnt(void); static void ScriptCmd_setbldcnt(void);
@ -66,8 +65,8 @@ static void ScriptCmd_monbg_22(void);
static void ScriptCmd_clearmonbg_23(void); static void ScriptCmd_clearmonbg_23(void);
static void ScriptCmd_jumpifcontest(void); static void ScriptCmd_jumpifcontest(void);
static void ScriptCmd_fadetobgfromset(void); static void ScriptCmd_fadetobgfromset(void);
static void ScriptCmd_panse_26(void); static void ScriptCmd_panse_adjustnone(void);
static void ScriptCmd_panse_27(void); static void ScriptCmd_panse_adjustall(void);
static void ScriptCmd_monbgprio_28(void); static void ScriptCmd_monbgprio_28(void);
static void ScriptCmd_monbgprio_29(void); static void ScriptCmd_monbgprio_29(void);
static void ScriptCmd_monbgprio_2A(void); static void ScriptCmd_monbgprio_2A(void);
@ -79,8 +78,8 @@ static void ScriptCmd_stopsound(void);
static void RunAnimScriptCommand(void); static void RunAnimScriptCommand(void);
static void task_pA_ma0A_obj_to_bg_pal(u8 taskId); static void task_pA_ma0A_obj_to_bg_pal(u8 taskId);
static void sub_80A46A0(void); static void FlipBattlerBgTiles(void);
static void sub_80A4980(u8 taskId); static void Task_ClearMonBg(u8 taskId);
static void sub_80A4BB0(u8 taskId); static void sub_80A4BB0(u8 taskId);
static void Task_FadeToBg(u8 taskId); static void Task_FadeToBg(u8 taskId);
static void Task_PanFromInitialToTarget(u8 taskId); static void Task_PanFromInitialToTarget(u8 taskId);
@ -89,11 +88,10 @@ static void Task_WaitAndPlaySE(u8 taskId);
static void LoadDefaultBg(void); static void LoadDefaultBg(void);
static void LoadMoveBg(u16 bgId); static void LoadMoveBg(u16 bgId);
// ewram
EWRAM_DATA static const u8 *sBattleAnimScriptPtr = NULL; EWRAM_DATA static const u8 *sBattleAnimScriptPtr = NULL;
EWRAM_DATA static const u8 *sBattleAnimScriptRetAddr = NULL; EWRAM_DATA static const u8 *sBattleAnimScriptRetAddr = NULL;
EWRAM_DATA void (*gAnimScriptCallback)(void) = NULL; EWRAM_DATA void (*gAnimScriptCallback)(void) = NULL;
EWRAM_DATA static s8 gAnimFramesToWait = 0; EWRAM_DATA static s8 sAnimFramesToWait = 0;
EWRAM_DATA bool8 gAnimScriptActive = FALSE; EWRAM_DATA bool8 gAnimScriptActive = FALSE;
EWRAM_DATA u8 gAnimVisualTaskCount = 0; EWRAM_DATA u8 gAnimVisualTaskCount = 0;
EWRAM_DATA u8 gAnimSoundTaskCount = 0; EWRAM_DATA u8 gAnimSoundTaskCount = 0;
@ -1711,7 +1709,7 @@ const struct CompressedSpritePalette gBattleAnimPaletteTable[] =
const struct BattleAnimBackground gBattleAnimBackgroundTable[] = const struct BattleAnimBackground gBattleAnimBackgroundTable[] =
{ {
[BG_DARK_] = {gBattleAnimBgImage_Dark, gBattleAnimBgPalette_Dark, gBattleAnimBgTilemap_Dark}, [BG_NONE] = {gBattleAnimBgImage_Dark, gBattleAnimBgPalette_Dark, gBattleAnimBgTilemap_Dark},
[BG_DARK] = {gBattleAnimBgImage_Dark, gBattleAnimBgPalette_Dark, gBattleAnimBgTilemap_Dark}, [BG_DARK] = {gBattleAnimBgImage_Dark, gBattleAnimBgPalette_Dark, gBattleAnimBgTilemap_Dark},
[BG_GHOST] = {gBattleAnimBgImage_Ghost, gBattleAnimBgPalette_Ghost, gBattleAnimBgTilemap_Ghost}, [BG_GHOST] = {gBattleAnimBgImage_Ghost, gBattleAnimBgPalette_Ghost, gBattleAnimBgTilemap_Ghost},
[BG_PSYCHIC] = {gBattleAnimBgImage_Psychic, gBattleAnimBgPalette_Psychic, gBattleAnimBgTilemap_Psychic}, [BG_PSYCHIC] = {gBattleAnimBgImage_Psychic, gBattleAnimBgPalette_Psychic, gBattleAnimBgTilemap_Psychic},
@ -1748,8 +1746,8 @@ static void (* const sScriptCmdTable[])(void) =
ScriptCmd_createvisualtask, ScriptCmd_createvisualtask,
ScriptCmd_delay, ScriptCmd_delay,
ScriptCmd_waitforvisualfinish, ScriptCmd_waitforvisualfinish,
ScriptCmd_hang1, ScriptCmd_nop,
ScriptCmd_hang2, ScriptCmd_nop2,
ScriptCmd_end, ScriptCmd_end,
ScriptCmd_playse, ScriptCmd_playse,
ScriptCmd_monbg, ScriptCmd_monbg,
@ -1769,7 +1767,7 @@ static void (* const sScriptCmdTable[])(void) =
ScriptCmd_changebg, ScriptCmd_changebg,
ScriptCmd_playsewithpan, ScriptCmd_playsewithpan,
ScriptCmd_setpan, ScriptCmd_setpan,
ScriptCmd_panse_1B, ScriptCmd_panse,
ScriptCmd_loopsewithpan, ScriptCmd_loopsewithpan,
ScriptCmd_waitplaysewithpan, ScriptCmd_waitplaysewithpan,
ScriptCmd_setbldcnt, ScriptCmd_setbldcnt,
@ -1780,8 +1778,8 @@ static void (* const sScriptCmdTable[])(void) =
ScriptCmd_clearmonbg_23, ScriptCmd_clearmonbg_23,
ScriptCmd_jumpifcontest, ScriptCmd_jumpifcontest,
ScriptCmd_fadetobgfromset, ScriptCmd_fadetobgfromset,
ScriptCmd_panse_26, ScriptCmd_panse_adjustnone,
ScriptCmd_panse_27, ScriptCmd_panse_adjustall,
ScriptCmd_monbgprio_28, ScriptCmd_monbgprio_28,
ScriptCmd_monbgprio_29, ScriptCmd_monbgprio_29,
ScriptCmd_monbgprio_2A, ScriptCmd_monbgprio_2A,
@ -1792,12 +1790,11 @@ static void (* const sScriptCmdTable[])(void) =
ScriptCmd_stopsound ScriptCmd_stopsound
}; };
// code
void ClearBattleAnimationVars(void) void ClearBattleAnimationVars(void)
{ {
s32 i; s32 i;
gAnimFramesToWait = 0; sAnimFramesToWait = 0;
gAnimScriptActive = FALSE; gAnimScriptActive = FALSE;
gAnimVisualTaskCount = 0; gAnimVisualTaskCount = 0;
gAnimSoundTaskCount = 0; gAnimSoundTaskCount = 0;
@ -1837,7 +1834,7 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
if (!IsContest()) if (!IsContest())
{ {
sub_80A8278(); InitPrioritiesForVisibleBattlers();
UpdateOamPriorityInAllHealthboxes(0); UpdateOamPriorityInAllHealthboxes(0);
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{ {
@ -1865,7 +1862,7 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
sMonAnimTaskIdArray[1] = TASK_NONE; sMonAnimTaskIdArray[1] = TASK_NONE;
sBattleAnimScriptPtr = animsTable[tableId]; sBattleAnimScriptPtr = animsTable[tableId];
gAnimScriptActive = TRUE; gAnimScriptActive = TRUE;
gAnimFramesToWait = 0; sAnimFramesToWait = 0;
gAnimScriptCallback = RunAnimScriptCommand; gAnimScriptCallback = RunAnimScriptCommand;
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
@ -1938,14 +1935,14 @@ static void ClearSpriteIndex(u16 index)
static void WaitAnimFrameCount(void) static void WaitAnimFrameCount(void)
{ {
if (gAnimFramesToWait <= 0) if (sAnimFramesToWait <= 0)
{ {
gAnimScriptCallback = RunAnimScriptCommand; gAnimScriptCallback = RunAnimScriptCommand;
gAnimFramesToWait = 0; sAnimFramesToWait = 0;
} }
else else
{ {
gAnimFramesToWait--; sAnimFramesToWait--;
} }
} }
@ -1954,7 +1951,7 @@ static void RunAnimScriptCommand(void)
do do
{ {
sScriptCmdTable[sBattleAnimScriptPtr[0]](); sScriptCmdTable[sBattleAnimScriptPtr[0]]();
} while (gAnimFramesToWait == 0 && gAnimScriptActive); } while (sAnimFramesToWait == 0 && gAnimScriptActive);
} }
static void ScriptCmd_loadspritegfx(void) static void ScriptCmd_loadspritegfx(void)
@ -1967,7 +1964,7 @@ static void ScriptCmd_loadspritegfx(void)
LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(index)]); LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(index)]);
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
AddSpriteIndex(GET_TRUE_SPRITE_INDEX(index)); AddSpriteIndex(GET_TRUE_SPRITE_INDEX(index));
gAnimFramesToWait = 1; sAnimFramesToWait = 1;
gAnimScriptCallback = WaitAnimFrameCount; gAnimScriptCallback = WaitAnimFrameCount;
} }
@ -2070,9 +2067,9 @@ static void ScriptCmd_createvisualtask(void)
static void ScriptCmd_delay(void) static void ScriptCmd_delay(void)
{ {
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
gAnimFramesToWait = sBattleAnimScriptPtr[0]; sAnimFramesToWait = sBattleAnimScriptPtr[0];
if (gAnimFramesToWait == 0) if (sAnimFramesToWait == 0)
gAnimFramesToWait = -1; sAnimFramesToWait = -1;
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
gAnimScriptCallback = WaitAnimFrameCount; gAnimScriptCallback = WaitAnimFrameCount;
} }
@ -2083,19 +2080,19 @@ static void ScriptCmd_waitforvisualfinish(void)
if (gAnimVisualTaskCount == 0) if (gAnimVisualTaskCount == 0)
{ {
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
gAnimFramesToWait = 0; sAnimFramesToWait = 0;
} }
else else
{ {
gAnimFramesToWait = 1; sAnimFramesToWait = 1;
} }
} }
static void ScriptCmd_hang1(void) static void ScriptCmd_nop(void)
{ {
} }
static void ScriptCmd_hang2(void) static void ScriptCmd_nop2(void)
{ {
} }
@ -2109,7 +2106,7 @@ static void ScriptCmd_end(void)
|| sMonAnimTaskIdArray[0] != TASK_NONE || sMonAnimTaskIdArray[1] != TASK_NONE) || sMonAnimTaskIdArray[0] != TASK_NONE || sMonAnimTaskIdArray[1] != TASK_NONE)
{ {
sSoundAnimFramesToWait = 0; sSoundAnimFramesToWait = 0;
gAnimFramesToWait = 1; sAnimFramesToWait = 1;
return; return;
} }
@ -2118,7 +2115,7 @@ static void ScriptCmd_end(void)
{ {
if (++sSoundAnimFramesToWait <= 90) // Wait 90 frames, then halt the sound effect. if (++sSoundAnimFramesToWait <= 90) // Wait 90 frames, then halt the sound effect.
{ {
gAnimFramesToWait = 1; sAnimFramesToWait = 1;
return; return;
} }
else else
@ -2146,7 +2143,7 @@ static void ScriptCmd_end(void)
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256); m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256);
if (!IsContest()) if (!IsContest())
{ {
sub_80A8278(); InitPrioritiesForVisibleBattlers();
UpdateOamPriorityInAllHealthboxes(1); UpdateOamPriorityInAllHealthboxes(1);
} }
gAnimScriptActive = FALSE; gAnimScriptActive = FALSE;
@ -2160,11 +2157,16 @@ static void ScriptCmd_playse(void)
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
} }
#define t1_MONBG_BATTLER 0 // These two tasks share context and similar task data
#define t1_MON_IN_BG2 1 // To differentiate them their task data is prefixed t1/t2
// Task data for sub_80A40F4
#define t1_BattlerSpriteId data[0]
#define t1_InBg2 data[1]
#define t1_CREATE_ANOTHER_TASK 2 #define t1_CREATE_ANOTHER_TASK 2
#define t1_IS_SECONDMON_BG 3 #define t1_IS_SECONDMON_BG 3
// Task data for task_pA_ma0A_obj_to_bg_pal
#define t2_BATTLER_SPRITE_ID 0 #define t2_BATTLER_SPRITE_ID 0
#define t2_MON_IN_BG2 5 #define t2_MON_IN_BG2 5
#define t2_MONBG_BATTLER 6 #define t2_MONBG_BATTLER 6
@ -2173,11 +2175,11 @@ static void sub_80A40F4(u8 taskId)
{ {
u8 newTaskId; u8 newTaskId;
s16 *selfData = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
u8 battlerSpriteId = gBattlerSpriteIds[selfData[t1_MONBG_BATTLER]]; u8 battlerSpriteId = gBattlerSpriteIds[t1_BattlerSpriteId];
gSprites[battlerSpriteId].invisible = TRUE; gSprites[battlerSpriteId].invisible = TRUE;
if (!selfData[t1_CREATE_ANOTHER_TASK]) if (!data[t1_CREATE_ANOTHER_TASK])
{ {
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);
return; return;
@ -2188,7 +2190,7 @@ static void sub_80A40F4(u8 taskId)
gTasks[newTaskId].data[1] = gSprites[battlerSpriteId].x + gSprites[battlerSpriteId].x2; gTasks[newTaskId].data[1] = gSprites[battlerSpriteId].x + gSprites[battlerSpriteId].x2;
gTasks[newTaskId].data[2] = gSprites[battlerSpriteId].y + gSprites[battlerSpriteId].y2; gTasks[newTaskId].data[2] = gSprites[battlerSpriteId].y + gSprites[battlerSpriteId].y2;
if (!selfData[t1_MON_IN_BG2]) if (!t1_InBg2)
{ {
gTasks[newTaskId].data[3] = gBattle_BG1_X; gTasks[newTaskId].data[3] = gBattle_BG1_X;
gTasks[newTaskId].data[4] = gBattle_BG1_Y; gTasks[newTaskId].data[4] = gBattle_BG1_Y;
@ -2199,9 +2201,9 @@ static void sub_80A40F4(u8 taskId)
gTasks[newTaskId].data[4] = gBattle_BG2_Y; gTasks[newTaskId].data[4] = gBattle_BG2_Y;
} }
gTasks[newTaskId].data[t2_MON_IN_BG2] = selfData[t1_MON_IN_BG2]; gTasks[newTaskId].data[t2_MON_IN_BG2] = t1_InBg2;
gTasks[newTaskId].data[t2_MONBG_BATTLER] = selfData[t1_MONBG_BATTLER]; gTasks[newTaskId].data[t2_MONBG_BATTLER] = t1_BattlerSpriteId;
sMonAnimTaskIdArray[selfData[t1_IS_SECONDMON_BG]] = newTaskId; sMonAnimTaskIdArray[data[t1_IS_SECONDMON_BG]] = newTaskId;
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);
} }
@ -2231,8 +2233,8 @@ static void ScriptCmd_monbg(void)
MoveBattlerSpriteToBG(battlerId, toBG_2, FALSE); MoveBattlerSpriteToBG(battlerId, toBG_2, FALSE);
taskId = CreateTask(sub_80A40F4, 10); taskId = CreateTask(sub_80A40F4, 10);
gAnimVisualTaskCount++; gAnimVisualTaskCount++;
gTasks[taskId].data[t1_MONBG_BATTLER] = battlerId; gTasks[taskId].t1_BattlerSpriteId = battlerId;
gTasks[taskId].data[t1_MON_IN_BG2] = toBG_2; gTasks[taskId].t1_InBg2 = toBG_2;
gTasks[taskId].data[t1_CREATE_ANOTHER_TASK] = TRUE; gTasks[taskId].data[t1_CREATE_ANOTHER_TASK] = TRUE;
gTasks[taskId].data[t1_IS_SECONDMON_BG] = 0; gTasks[taskId].data[t1_IS_SECONDMON_BG] = 0;
@ -2257,7 +2259,7 @@ static void ScriptCmd_monbg(void)
} }
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
gAnimFramesToWait = 1; sAnimFramesToWait = 1;
gAnimScriptCallback = WaitAnimFrameCount; gAnimScriptCallback = WaitAnimFrameCount;
} }
@ -2329,10 +2331,10 @@ void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible)
else else
battlerPosition = GetBattlerPosition(battlerId); battlerPosition = GetBattlerPosition(battlerId);
sub_8118FBC(1, 0, 0, battlerPosition, animBg.paletteId, animBg.bgTiles, animBg.bgTilemap, animBg.tilesOffset); DrawBattlerOnBg(1, 0, 0, battlerPosition, animBg.paletteId, animBg.bgTiles, animBg.bgTilemap, animBg.tilesOffset);
if (IsContest()) if (IsContest())
sub_80A46A0(); FlipBattlerBgTiles();
} }
else else
{ {
@ -2359,11 +2361,11 @@ void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible)
LoadPalette(&gPlttBufferUnfaded[0x100 + battlerId * 16], 0x90, 0x20); LoadPalette(&gPlttBufferUnfaded[0x100 + battlerId * 16], 0x90, 0x20);
CpuCopy32(&gPlttBufferUnfaded[0x100 + battlerId * 16], (void*)(BG_PLTT + 0x120), 0x20); CpuCopy32(&gPlttBufferUnfaded[0x100 + battlerId * 16], (void*)(BG_PLTT + 0x120), 0x20);
sub_8118FBC(2, 0, 0, GetBattlerPosition(battlerId), animBg.paletteId, animBg.bgTiles + 0x1000, animBg.bgTilemap + 0x400, animBg.tilesOffset); DrawBattlerOnBg(2, 0, 0, GetBattlerPosition(battlerId), animBg.paletteId, animBg.bgTiles + 0x1000, animBg.bgTilemap + 0x400, animBg.tilesOffset);
} }
} }
static void sub_80A46A0(void) static void FlipBattlerBgTiles(void)
{ {
s32 i, j; s32 i, j;
struct BattleAnimBgData animBg; struct BattleAnimBgData animBg;
@ -2377,10 +2379,8 @@ static void sub_80A46A0(void)
{ {
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
u16 temp = ptr[j + i * 32]; u16 temp;
SWAP(ptr[j + i * 32], ptr[7 - j + i * 32], temp);
ptr[j + i * 32] = ptr[7 - j + i * 32];
ptr[7 - j + i * 32] = temp;
} }
} }
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
@ -2391,20 +2391,20 @@ static void sub_80A46A0(void)
} }
} }
void sub_80A4720(u16 a, u16 *b, u32 c, u8 d) void RelocateBattleBgPal(u16 paletteNum, u16 *dest, u32 offset, bool8 largeScreen)
{ {
s32 i, j; s32 i, j;
s32 var; s32 size;
if (d == 0) if (!largeScreen)
var = 32; size = 32;
else else
var = 64; size = 64;
a <<= 12; paletteNum <<= 12;
for (i = 0; i < var; i++) for (i = 0; i < size; i++)
{ {
for (j = 0; j < 32; j++) for (j = 0; j < 32; j++)
b[j + i * 32] = ((b[j + i * 32] & 0xFFF) | a) + c; dest[j + i * 32] = ((dest[j + i * 32] & 0xFFF) | paletteNum) + offset;
} }
} }
@ -2446,8 +2446,8 @@ static void task_pA_ma0A_obj_to_bg_pal(u8 taskId)
gBattle_BG1_X = x + gTasks[taskId].data[3]; gBattle_BG1_X = x + gTasks[taskId].data[3];
gBattle_BG1_Y = y + gTasks[taskId].data[4]; gBattle_BG1_Y = y + gTasks[taskId].data[4];
src = gPlttBufferFaded + 0x100 + palIndex * 16; src = &gPlttBufferFaded[0x100 + palIndex * 16];
dst = gPlttBufferFaded + 0x100 + animBg.paletteId * 16 - 256; dst = &gPlttBufferFaded[0x100 + animBg.paletteId * 16 - 256];
CpuCopy32(src, dst, 0x20); CpuCopy32(src, dst, 0x20);
} }
else else
@ -2457,8 +2457,8 @@ static void task_pA_ma0A_obj_to_bg_pal(u8 taskId)
gBattle_BG2_X = x + gTasks[taskId].data[3]; gBattle_BG2_X = x + gTasks[taskId].data[3];
gBattle_BG2_Y = y + gTasks[taskId].data[4]; gBattle_BG2_Y = y + gTasks[taskId].data[4];
src = gPlttBufferFaded + 0x100 + palIndex * 16; src = &gPlttBufferFaded[0x100 + palIndex * 16];
dst = gPlttBufferFaded + 0x100 - 112; dst = &gPlttBufferFaded[0x100 - 112];
CpuCopy32(src, dst, 0x20); CpuCopy32(src, dst, 0x20);
} }
} }
@ -2489,14 +2489,14 @@ static void ScriptCmd_clearmonbg(void)
else else
animBattlerId = 0; animBattlerId = 0;
taskId = CreateTask(sub_80A4980, 5); taskId = CreateTask(Task_ClearMonBg, 5);
gTasks[taskId].data[0] = animBattlerId; gTasks[taskId].data[0] = animBattlerId;
gTasks[taskId].data[2] = battlerId; gTasks[taskId].data[2] = battlerId;
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
} }
static void sub_80A4980(u8 taskId) static void Task_ClearMonBg(u8 taskId)
{ {
gTasks[taskId].data[1]++; gTasks[taskId].data[1]++;
if (gTasks[taskId].data[1] != 1) if (gTasks[taskId].data[1] != 1)
@ -2625,8 +2625,8 @@ static void sub_80A4BB0(u8 taskId)
} }
} }
#undef t1_MONBG_BATTLER #undef t1_BattlerSpriteId
#undef t1_MON_IN_BG2 #undef t1_InBg2
#undef t1_CREATE_ANOTHER_TASK #undef t1_CREATE_ANOTHER_TASK
#undef t1_IS_SECONDMON_BG #undef t1_IS_SECONDMON_BG
@ -2676,6 +2676,10 @@ static void ScriptCmd_return(void)
static void ScriptCmd_setarg(void) static void ScriptCmd_setarg(void)
{ {
// Save original address to return to
// after the T1_READ_16, + 4.
// They could have equivalently just advanced
// sBattleAnimScriptPtr by 2 afterwards.
const u8 *addr = sBattleAnimScriptPtr; const u8 *addr = sBattleAnimScriptPtr;
u16 value; u16 value;
u8 argId; u8 argId;
@ -2809,17 +2813,17 @@ static void LoadMoveBg(u16 bgId)
void *dmaDest; void *dmaDest;
LZDecompressWram(tilemap, gDecompressionBuffer); LZDecompressWram(tilemap, gDecompressionBuffer);
sub_80A4720(GetBattleBgPaletteNum(), (void*)(gDecompressionBuffer), 0x100, 0); RelocateBattleBgPal(GetBattleBgPaletteNum(), (void*)gDecompressionBuffer, 0x100, FALSE);
dmaSrc = gDecompressionBuffer; dmaSrc = gDecompressionBuffer;
dmaDest = (void *)(BG_SCREEN_ADDR(26)); dmaDest = (void *)BG_SCREEN_ADDR(26);
DmaCopy32(3, dmaSrc, dmaDest, 0x800); DmaCopy32(3, dmaSrc, dmaDest, 0x800);
LZDecompressVram(gBattleAnimBackgroundTable[bgId].image, (void *)(BG_SCREEN_ADDR(4))); LZDecompressVram(gBattleAnimBackgroundTable[bgId].image, (void *)BG_SCREEN_ADDR(4));
LoadCompressedPalette(gBattleAnimBackgroundTable[bgId].palette, GetBattleBgPaletteNum() * 16, 32); LoadCompressedPalette(gBattleAnimBackgroundTable[bgId].palette, GetBattleBgPaletteNum() * 16, 32);
} }
else else
{ {
LZDecompressVram(gBattleAnimBackgroundTable[bgId].tilemap, (void *)(BG_SCREEN_ADDR(26))); LZDecompressVram(gBattleAnimBackgroundTable[bgId].tilemap, (void *)BG_SCREEN_ADDR(26));
LZDecompressVram(gBattleAnimBackgroundTable[bgId].image, (void *)(BG_CHAR_ADDR(2))); LZDecompressVram(gBattleAnimBackgroundTable[bgId].image, (void *)BG_CHAR_ADDR(2));
LoadCompressedPalette(gBattleAnimBackgroundTable[bgId].palette, 32, 32); LoadCompressedPalette(gBattleAnimBackgroundTable[bgId].palette, 32, 32);
} }
} }
@ -2850,11 +2854,11 @@ static void ScriptCmd_waitbgfadeout(void)
if (sAnimBackgroundFadeState == 2) if (sAnimBackgroundFadeState == 2)
{ {
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
gAnimFramesToWait = 0; sAnimFramesToWait = 0;
} }
else else
{ {
gAnimFramesToWait = 1; sAnimFramesToWait = 1;
} }
} }
@ -2863,11 +2867,11 @@ static void ScriptCmd_waitbgfadein(void)
if (sAnimBackgroundFadeState == 0) if (sAnimBackgroundFadeState == 0)
{ {
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
gAnimFramesToWait = 0; sAnimFramesToWait = 0;
} }
else else
{ {
gAnimFramesToWait = 1; sAnimFramesToWait = 1;
} }
} }
@ -2992,7 +2996,7 @@ static void ScriptCmd_setpan(void)
#define tCurrentPan data[4] #define tCurrentPan data[4]
#define tFrameCounter data[8] #define tFrameCounter data[8]
static void ScriptCmd_panse_1B(void) static void ScriptCmd_panse(void)
{ {
u16 songNum; u16 songNum;
s8 currentPanArg, incrementPan, incrementPanArg, currentPan, targetPan; s8 currentPanArg, incrementPan, incrementPanArg, currentPan, targetPan;
@ -3002,13 +3006,14 @@ static void ScriptCmd_panse_1B(void)
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
songNum = T1_READ_16(sBattleAnimScriptPtr); songNum = T1_READ_16(sBattleAnimScriptPtr);
currentPanArg = sBattleAnimScriptPtr[2]; currentPanArg = sBattleAnimScriptPtr[2];
incrementPan = sBattleAnimScriptPtr[3]; incrementPan = sBattleAnimScriptPtr[3]; // targetPan, var is re-used
incrementPanArg = sBattleAnimScriptPtr[4]; incrementPanArg = sBattleAnimScriptPtr[4];
framesToWait = sBattleAnimScriptPtr[5]; framesToWait = sBattleAnimScriptPtr[5];
currentPan = BattleAnimAdjustPanning(currentPanArg); currentPan = BattleAnimAdjustPanning(currentPanArg);
targetPan = BattleAnimAdjustPanning(incrementPan); targetPan = BattleAnimAdjustPanning(incrementPan);
incrementPan = CalculatePanIncrement(currentPan, targetPan, incrementPanArg); incrementPan = CalculatePanIncrement(currentPan, targetPan, incrementPanArg);
taskId = CreateTask(Task_PanFromInitialToTarget, 1); taskId = CreateTask(Task_PanFromInitialToTarget, 1);
gTasks[taskId].tInitialPan = currentPan; gTasks[taskId].tInitialPan = currentPan;
gTasks[taskId].tTargetPan = targetPan; gTasks[taskId].tTargetPan = targetPan;
@ -3064,7 +3069,7 @@ void Task_PanFromInitialToTarget(u8 taskId)
} }
} }
static void ScriptCmd_panse_26(void) static void ScriptCmd_panse_adjustnone(void)
{ {
u16 songId; u16 songId;
s8 currentPan, targetPan, incrementPan; s8 currentPan, targetPan, incrementPan;
@ -3091,7 +3096,7 @@ static void ScriptCmd_panse_26(void)
sBattleAnimScriptPtr += 6; sBattleAnimScriptPtr += 6;
} }
static void ScriptCmd_panse_27(void) static void ScriptCmd_panse_adjustall(void)
{ {
u16 songId; u16 songId;
s8 targetPanArg, incrementPanArg, currentPanArg, currentPan, targetPan, incrementPan; s8 targetPanArg, incrementPanArg, currentPanArg, currentPan, targetPan, incrementPan;
@ -3254,7 +3259,7 @@ static void ScriptCmd_waitsound(void)
if (gAnimSoundTaskCount != 0) if (gAnimSoundTaskCount != 0)
{ {
sSoundAnimFramesToWait = 0; sSoundAnimFramesToWait = 0;
gAnimFramesToWait = 1; sAnimFramesToWait = 1;
} }
else if (IsSEPlaying()) else if (IsSEPlaying())
{ {
@ -3266,14 +3271,14 @@ static void ScriptCmd_waitsound(void)
} }
else else
{ {
gAnimFramesToWait = 1; sAnimFramesToWait = 1;
} }
} }
else else
{ {
sSoundAnimFramesToWait = 0; sSoundAnimFramesToWait = 0;
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
gAnimFramesToWait = 0; sAnimFramesToWait = 0;
} }
} }

View File

@ -3250,7 +3250,7 @@ void AnimTask_HeartsBackground(u8 taskId)
SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y);
GetBattleAnimBg1Data(&animBg); GetBattleAnimBg1Data(&animBg);
AnimLoadCompressedBgGfx(animBg.bgId, &gBattleAnimBgImage_Attract, animBg.tilesOffset); AnimLoadCompressedBgGfx(animBg.bgId, &gBattleAnimBgImage_Attract, animBg.tilesOffset);
AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimBgTilemap_Attract, 0); AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimBgTilemap_Attract, FALSE);
LoadCompressedPalette(&gBattleAnimBgPalette_Attract, animBg.paletteId * 16, 32); LoadCompressedPalette(&gBattleAnimBgPalette_Attract, animBg.paletteId * 16, 32);
gTasks[taskId].func = AnimTask_HeartsBackground_Step; gTasks[taskId].func = AnimTask_HeartsBackground_Step;
} }
@ -3328,11 +3328,11 @@ void AnimTask_ScaryFace(u8 taskId)
SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y);
GetBattleAnimBg1Data(&animBg); GetBattleAnimBg1Data(&animBg);
if (IsContest()) if (IsContest())
AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimBgTilemap_ScaryFaceContest, 0); AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimBgTilemap_ScaryFaceContest, FALSE);
else if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_OPPONENT) else if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_OPPONENT)
AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimBgTilemap_ScaryFacePlayer, 0); AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimBgTilemap_ScaryFacePlayer, FALSE);
else else
AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimBgTilemap_ScaryFaceOpponent, 0); AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimBgTilemap_ScaryFaceOpponent, FALSE);
AnimLoadCompressedBgGfx(animBg.bgId, gBattleAnimBgImage_ScaryFace, animBg.tilesOffset); AnimLoadCompressedBgGfx(animBg.bgId, gBattleAnimBgImage_ScaryFace, animBg.tilesOffset);
LoadCompressedPalette(gBattleAnimBgPalette_ScaryFace, animBg.paletteId * 16, 32); LoadCompressedPalette(gBattleAnimBgPalette_ScaryFace, animBg.paletteId * 16, 32);

View File

@ -2388,7 +2388,7 @@ void AnimTask_MorningSunLightBeam(u8 taskId)
SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1); SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1);
GetBattleAnimBg1Data(&animBg); GetBattleAnimBg1Data(&animBg);
AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimMaskTilemap_LightBeam, 0); AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimMaskTilemap_LightBeam, FALSE);
if (IsContest()) if (IsContest())
{ {
gBattle_BG1_X = -56; gBattle_BG1_X = -56;
@ -2569,7 +2569,7 @@ void AnimTask_DoomDesireLightBeam(u8 taskId)
SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1); SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1);
GetBattleAnimBg1Data(&animBg); GetBattleAnimBg1Data(&animBg);
AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimMaskTilemap_LightBeam, 0); AnimLoadCompressedBgTilemapHandleContest(&animBg, &gBattleAnimMaskTilemap_LightBeam, FALSE);
if (IsContest()) if (IsContest())
{ {
gBattle_BG1_X = -56; gBattle_BG1_X = -56;

View File

@ -1000,7 +1000,7 @@ void AnimTask_HazeScrollingFog(u8 taskId)
GetBattleAnimBg1Data(&animBg); GetBattleAnimBg1Data(&animBg);
LoadBgTiles(animBg.bgId, gWeatherFogHorizontalTiles, 0x800, animBg.tilesOffset); LoadBgTiles(animBg.bgId, gWeatherFogHorizontalTiles, 0x800, animBg.tilesOffset);
AnimLoadCompressedBgTilemapHandleContest(&animBg, gBattleAnimFogTilemap, 0); AnimLoadCompressedBgTilemapHandleContest(&animBg, gBattleAnimFogTilemap, FALSE);
LoadPalette(&gFogPalette, animBg.paletteId * 16, 32); LoadPalette(&gFogPalette, animBg.paletteId * 16, 32);
gTasks[taskId].func = AnimTask_HazeScrollingFog_Step; gTasks[taskId].func = AnimTask_HazeScrollingFog_Step;
@ -1105,7 +1105,7 @@ void AnimTask_LoadMistTiles(u8 taskId)
GetBattleAnimBg1Data(&animBg); GetBattleAnimBg1Data(&animBg);
LoadBgTiles(animBg.bgId, gWeatherFogHorizontalTiles, 0x800, animBg.tilesOffset); LoadBgTiles(animBg.bgId, gWeatherFogHorizontalTiles, 0x800, animBg.tilesOffset);
AnimLoadCompressedBgTilemapHandleContest(&animBg, gBattleAnimFogTilemap, 0); AnimLoadCompressedBgTilemapHandleContest(&animBg, gBattleAnimFogTilemap, FALSE);
LoadPalette(&gFogPalette, animBg.paletteId * 16, 32); LoadPalette(&gFogPalette, animBg.paletteId * 16, 32);
gTasks[taskId].data[15] = -1; gTasks[taskId].data[15] = -1;

View File

@ -37,15 +37,15 @@ static void sub_80A8D78(struct Task *task, u8 taskId);
EWRAM_DATA static union AffineAnimCmd *gAnimTaskAffineAnim = NULL; EWRAM_DATA static union AffineAnimCmd *gAnimTaskAffineAnim = NULL;
// Const rom data // Const rom data
static const struct UCoords8 sBattlerCoords[][4] = static const struct UCoords8 sBattlerCoords[][MAX_BATTLERS_COUNT] =
{ {
{ { // Single battle
{ 72, 80 }, { 72, 80 },
{ 176, 40 }, { 176, 40 },
{ 48, 40 }, { 48, 40 },
{ 112, 80 }, { 112, 80 },
}, },
{ { // Double battle
{ 32, 80 }, { 32, 80 },
{ 200, 40 }, { 200, 40 },
{ 90, 88 }, { 90, 88 },
@ -54,29 +54,29 @@ static const struct UCoords8 sBattlerCoords[][4] =
}; };
// One entry for each of the four Castform forms. // One entry for each of the four Castform forms.
const struct MonCoords gCastformFrontSpriteCoords[] = const struct MonCoords gCastformFrontSpriteCoords[NUM_CASTFORM_FORMS] =
{ {
{ .size = 0x44, .y_offset = 17 }, // NORMAL [CASTFORM_NORMAL] = { .size = 0x44, .y_offset = 17 },
{ .size = 0x66, .y_offset = 9 }, // SUN [CASTFORM_FIRE] = { .size = 0x66, .y_offset = 9 },
{ .size = 0x46, .y_offset = 9 }, // RAIN [CASTFORM_WATER] = { .size = 0x46, .y_offset = 9 },
{ .size = 0x86, .y_offset = 8 }, // HAIL [CASTFORM_ICE] = { .size = 0x86, .y_offset = 8 },
}; };
static const u8 sCastformElevations[] = static const u8 sCastformElevations[NUM_CASTFORM_FORMS] =
{ {
13, // NORMAL [CASTFORM_NORMAL] = 13,
14, // SUN [CASTFORM_FIRE] = 14,
13, // RAIN [CASTFORM_WATER] = 13,
13, // HAIL [CASTFORM_ICE] = 13,
}; };
// Y position of the backsprite for each of the four Castform forms. // Y position of the backsprite for each of the four Castform forms.
static const u8 sCastformBackSpriteYCoords[] = static const u8 sCastformBackSpriteYCoords[NUM_CASTFORM_FORMS] =
{ {
0, // NORMAL [CASTFORM_NORMAL] = 0,
0, // SUN [CASTFORM_FIRE] = 0,
0, // RAIN [CASTFORM_WATER] = 0,
0, // HAIL [CASTFORM_ICE] = 0,
}; };
// Placeholders for pokemon sprites to be created for a move animation effect (e.g. Role Play / Snatch) // Placeholders for pokemon sprites to be created for a move animation effect (e.g. Role Play / Snatch)
@ -853,8 +853,8 @@ void GetBattleAnimBg1Data(struct BattleAnimBgData *out)
{ {
if (IsContest()) if (IsContest())
{ {
out->bgTiles = gUnknown_0202305C; out->bgTiles = gBattleAnimBgTileBuffer;
out->bgTilemap = (u16 *)gUnknown_02023060; out->bgTilemap = (u16 *)gBattleAnimBgTilemapBuffer;
out->paletteId = 14; out->paletteId = 14;
out->bgId = 1; out->bgId = 1;
out->tilesOffset = 0; out->tilesOffset = 0;
@ -862,8 +862,8 @@ void GetBattleAnimBg1Data(struct BattleAnimBgData *out)
} }
else else
{ {
out->bgTiles = gUnknown_0202305C; out->bgTiles = gBattleAnimBgTileBuffer;
out->bgTilemap = (u16 *)gUnknown_02023060; out->bgTilemap = (u16 *)gBattleAnimBgTilemapBuffer;
out->paletteId = 8; out->paletteId = 8;
out->bgId = 1; out->bgId = 1;
out->tilesOffset = 0x200; out->tilesOffset = 0x200;
@ -875,8 +875,8 @@ void GetBattleAnimBgData(struct BattleAnimBgData *out, u32 bgId)
{ {
if (IsContest()) if (IsContest())
{ {
out->bgTiles = gUnknown_0202305C; out->bgTiles = gBattleAnimBgTileBuffer;
out->bgTilemap = (u16 *)gUnknown_02023060; out->bgTilemap = (u16 *)gBattleAnimBgTilemapBuffer;
out->paletteId = 14; out->paletteId = 14;
out->bgId = 1; out->bgId = 1;
out->tilesOffset = 0; out->tilesOffset = 0;
@ -888,8 +888,8 @@ void GetBattleAnimBgData(struct BattleAnimBgData *out, u32 bgId)
} }
else else
{ {
out->bgTiles = gUnknown_0202305C; out->bgTiles = gBattleAnimBgTileBuffer;
out->bgTilemap = (u16 *)gUnknown_02023060; out->bgTilemap = (u16 *)gBattleAnimBgTilemapBuffer;
out->paletteId = 9; out->paletteId = 9;
out->bgId = 2; out->bgId = 2;
out->tilesOffset = 0x300; out->tilesOffset = 0x300;
@ -899,8 +899,8 @@ void GetBattleAnimBgData(struct BattleAnimBgData *out, u32 bgId)
void sub_80A6BFC(struct BattleAnimBgData *out, u8 unused) void sub_80A6BFC(struct BattleAnimBgData *out, u8 unused)
{ {
out->bgTiles = gUnknown_0202305C; out->bgTiles = gBattleAnimBgTileBuffer;
out->bgTilemap = (u16 *)gUnknown_02023060; out->bgTilemap = (u16 *)gBattleAnimBgTilemapBuffer;
if (IsContest()) if (IsContest())
{ {
out->paletteId = 14; out->paletteId = 14;
@ -937,9 +937,9 @@ void ClearBattleAnimBg(u32 bgId)
void AnimLoadCompressedBgGfx(u32 bgId, const u32 *src, u32 tilesOffset) void AnimLoadCompressedBgGfx(u32 bgId, const u32 *src, u32 tilesOffset)
{ {
CpuFill32(0, gUnknown_0202305C, 0x2000); CpuFill32(0, gBattleAnimBgTileBuffer, 0x2000);
LZDecompressWram(src, gUnknown_0202305C); LZDecompressWram(src, gBattleAnimBgTileBuffer);
LoadBgTiles(bgId, gUnknown_0202305C, 0x2000, tilesOffset); LoadBgTiles(bgId, gBattleAnimBgTileBuffer, 0x2000, tilesOffset);
} }
static void InitAnimBgTilemapBuffer(u32 bgId, const void *src) static void InitAnimBgTilemapBuffer(u32 bgId, const void *src)
@ -954,12 +954,12 @@ void AnimLoadCompressedBgTilemap(u32 bgId, const void *src)
CopyBgTilemapBufferToVram(bgId); CopyBgTilemapBufferToVram(bgId);
} }
void AnimLoadCompressedBgTilemapHandleContest(struct BattleAnimBgData *unk, const void *src, u32 arg2) void AnimLoadCompressedBgTilemapHandleContest(struct BattleAnimBgData *data, const void *src, bool32 largeScreen)
{ {
InitAnimBgTilemapBuffer(unk->bgId, src); InitAnimBgTilemapBuffer(data->bgId, src);
if (IsContest() == TRUE) if (IsContest() == TRUE)
sub_80A4720(unk->paletteId, unk->bgTilemap, 0, arg2); RelocateBattleBgPal(data->paletteId, data->bgTilemap, 0, largeScreen);
CopyBgTilemapBufferToVram(unk->bgId); CopyBgTilemapBufferToVram(data->bgId);
} }
u8 GetBattleBgPaletteNum(void) u8 GetBattleBgPaletteNum(void)
@ -1947,7 +1947,8 @@ void AnimTask_GetFrustrationPowerLevel(u8 taskId)
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);
} }
void sub_80A8174(u8 priority) // Unused
static void SetPriorityForVisibleBattlers(u8 priority)
{ {
if (IsBattlerSpriteVisible(gBattleAnimTarget)) if (IsBattlerSpriteVisible(gBattleAnimTarget))
gSprites[gBattlerSpriteIds[gBattleAnimTarget]].oam.priority = priority; gSprites[gBattlerSpriteIds[gBattleAnimTarget]].oam.priority = priority;
@ -1959,7 +1960,7 @@ void sub_80A8174(u8 priority)
gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gBattleAnimAttacker)]].oam.priority = priority; gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gBattleAnimAttacker)]].oam.priority = priority;
} }
void sub_80A8278(void) void InitPrioritiesForVisibleBattlers(void)
{ {
int i; int i;

View File

@ -409,7 +409,7 @@ void AnimTask_LoadSandstormBackground(u8 taskId)
GetBattleAnimBg1Data(&animBg); GetBattleAnimBg1Data(&animBg);
AnimLoadCompressedBgGfx(animBg.bgId, gBattleAnimBgImage_Sandstorm, animBg.tilesOffset); AnimLoadCompressedBgGfx(animBg.bgId, gBattleAnimBgImage_Sandstorm, animBg.tilesOffset);
AnimLoadCompressedBgTilemapHandleContest(&animBg, gBattleAnimBgTilemap_Sandstorm, 0); AnimLoadCompressedBgTilemapHandleContest(&animBg, gBattleAnimBgTilemap_Sandstorm, FALSE);
LoadCompressedPalette(gBattleAnimSpritePal_FlyingDirt, animBg.paletteId * 16, 32); LoadCompressedPalette(gBattleAnimSpritePal_FlyingDirt, animBg.paletteId * 16, 32);
if (gBattleAnimArgs[0] && GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) if (gBattleAnimArgs[0] && GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)

View File

@ -331,7 +331,7 @@ void AnimTask_DrawFallingWhiteLinesOnAttacker(u8 taskId)
spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);
newSpriteId = CreateInvisibleSpriteCopy(gBattleAnimAttacker, spriteId, species); newSpriteId = CreateInvisibleSpriteCopy(gBattleAnimAttacker, spriteId, species);
GetBattleAnimBg1Data(&animBgData); GetBattleAnimBg1Data(&animBgData);
AnimLoadCompressedBgTilemapHandleContest(&animBgData, gBattleAnimMaskTilemap_Curse, 0); AnimLoadCompressedBgTilemapHandleContest(&animBgData, gBattleAnimMaskTilemap_Curse, FALSE);
AnimLoadCompressedBgGfx(animBgData.bgId, gBattleAnimMaskImage_Curse, animBgData.tilesOffset); AnimLoadCompressedBgGfx(animBgData.bgId, gBattleAnimMaskImage_Curse, animBgData.tilesOffset);
LoadPalette(sCurseLinesPalette, animBgData.paletteId * 16 + 1, 2); LoadPalette(sCurseLinesPalette, animBgData.paletteId * 16 + 1, 2);
@ -470,9 +470,9 @@ static void StatsChangeAnimation_Step2(u8 taskId)
GetBattleAnimBg1Data(&animBgData); GetBattleAnimBg1Data(&animBgData);
if (sAnimStatsChangeData->data[0] == 0) if (sAnimStatsChangeData->data[0] == 0)
AnimLoadCompressedBgTilemapHandleContest(&animBgData, gBattleStatMask1_Tilemap, 0); AnimLoadCompressedBgTilemapHandleContest(&animBgData, gBattleStatMask1_Tilemap, FALSE);
else else
AnimLoadCompressedBgTilemapHandleContest(&animBgData, gBattleStatMask2_Tilemap, 0); AnimLoadCompressedBgTilemapHandleContest(&animBgData, gBattleStatMask2_Tilemap, FALSE);
AnimLoadCompressedBgGfx(animBgData.bgId, gBattleStatMask_Gfx, animBgData.tilesOffset); AnimLoadCompressedBgGfx(animBgData.bgId, gBattleStatMask_Gfx, animBgData.tilesOffset);
switch (sAnimStatsChangeData->data[1]) switch (sAnimStatsChangeData->data[1])
@ -821,7 +821,7 @@ void StartMonScrollingBgMask(u8 taskId, int unused, u16 scrollSpeed, u8 battler,
spriteId2 = CreateInvisibleSpriteCopy(battler2, gBattlerSpriteIds[battler2], species); spriteId2 = CreateInvisibleSpriteCopy(battler2, gBattlerSpriteIds[battler2], species);
GetBattleAnimBg1Data(&animBgData); GetBattleAnimBg1Data(&animBgData);
AnimLoadCompressedBgTilemapHandleContest(&animBgData, tilemap, 0); AnimLoadCompressedBgTilemapHandleContest(&animBgData, tilemap, FALSE);
AnimLoadCompressedBgGfx(animBgData.bgId, gfx, animBgData.tilesOffset); AnimLoadCompressedBgGfx(animBgData.bgId, gfx, animBgData.tilesOffset);
LoadCompressedPalette(palette, animBgData.paletteId * 16, 32); LoadCompressedPalette(palette, animBgData.paletteId * 16, 32);

View File

@ -54,9 +54,8 @@ static void AnimTask_WaterSport_Step(u8);
static void CreateWaterSportDroplet(struct Task*); static void CreateWaterSportDroplet(struct Task*);
static void CreateWaterPulseRingBubbles(struct Sprite*, int, int); static void CreateWaterPulseRingBubbles(struct Sprite*, int, int);
// Both unused static const u8 sUnusedWater_Gfx[] = INCBIN_U8("graphics/battle_anims/unused_water_gfx.4bpp");
const u8 gUnknown_8593C80[] = INCBIN_U8("graphics/unknown/unknown_593C80.4bpp"); static const u8 sUnusedWater[] = INCBIN_U8("graphics/battle_anims/unused_water.bin");
const u8 gUnknown_8593FFC[] = INCBIN_U8("graphics/unknown/unknown_593FFC.bin");
static const union AnimCmd sAnim_RainDrop[] = static const union AnimCmd sAnim_RainDrop[] =
{ {
@ -822,7 +821,7 @@ void AnimTask_CreateSurfWave(u8 taskId)
} }
else else
{ {
AnimLoadCompressedBgTilemapHandleContest(&animBg, gBattleAnimBgTilemap_SurfContest, 1); AnimLoadCompressedBgTilemapHandleContest(&animBg, gBattleAnimBgTilemap_SurfContest, TRUE);
} }
AnimLoadCompressedBgGfx(animBg.bgId, gBattleAnimBgImage_Surf, animBg.tilesOffset); AnimLoadCompressedBgGfx(animBg.bgId, gBattleAnimBgImage_Surf, animBg.tilesOffset);
if (gBattleAnimArgs[0] == 0) if (gBattleAnimArgs[0] == 0)

View File

@ -594,8 +594,8 @@ static const struct WindowTemplate gBattleArenaWindowTemplates[] =
const struct WindowTemplate * const gBattleWindowTemplates[] = const struct WindowTemplate * const gBattleWindowTemplates[] =
{ {
gStandardBattleWindowTemplates, [B_WIN_TYPE_NORMAL] = gStandardBattleWindowTemplates,
gBattleArenaWindowTemplates, [B_WIN_TYPE_ARENA] = gBattleArenaWindowTemplates,
}; };
static const struct BattleBackground gBattleTerrainTable[] = static const struct BattleBackground gBattleTerrainTable[] =
@ -691,20 +691,19 @@ static const struct BattleBackground gBattleTerrainTable[] =
}, },
}; };
static void sub_8035648(void); static void CB2_UnusedBattleInit(void);
// Unused static void UnusedBattleInit(void)
static void sub_8035608(void)
{ {
u8 spriteId; u8 spriteId;
ResetSpriteData(); ResetSpriteData();
spriteId = CreateSprite(&gUnknown_0831AC88, 0, 0, 0); spriteId = CreateSprite(&gUnusedBattleInitSprite, 0, 0, 0);
gSprites[spriteId].invisible = TRUE; gSprites[spriteId].invisible = TRUE;
SetMainCallback2(sub_8035648); SetMainCallback2(CB2_UnusedBattleInit);
} }
static void sub_8035648(void) static void CB2_UnusedBattleInit(void)
{ {
AnimateSprites(); AnimateSprites();
BuildOamBuffer(); BuildOamBuffer();
@ -717,13 +716,13 @@ void BattleInitBgsAndWindows(void)
if (gBattleTypeFlags & BATTLE_TYPE_ARENA) if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
{ {
gBattleScripting.windowsType = 1; gBattleScripting.windowsType = B_WIN_TYPE_ARENA;
SetBgTilemapBuffer(1, gUnknown_02023060); SetBgTilemapBuffer(1, gBattleAnimBgTilemapBuffer);
SetBgTilemapBuffer(2, gUnknown_02023060); SetBgTilemapBuffer(2, gBattleAnimBgTilemapBuffer);
} }
else else
{ {
gBattleScripting.windowsType = 0; gBattleScripting.windowsType = B_WIN_TYPE_NORMAL;
} }
InitWindows(gBattleWindowTemplates[gBattleScripting.windowsType]); InitWindows(gBattleWindowTemplates[gBattleScripting.windowsType]);

View File

@ -251,16 +251,16 @@ static void HandleInputChooseAction(void)
switch (gActionSelectionCursor[gActiveBattler]) switch (gActionSelectionCursor[gActiveBattler])
{ {
case 0: case B_ACTION_USE_MOVE:
BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, 0);
break; break;
case 1: case B_ACTION_USE_ITEM:
BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0);
break; break;
case 2: case B_ACTION_SWITCH:
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
break; break;
case 3: case B_ACTION_RUN:
BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0);
break; break;
} }
@ -858,7 +858,7 @@ static void SetLinkBattleEndCallbacks(void)
if (gReceivedRemoteLinkPlayers == 0) if (gReceivedRemoteLinkPlayers == 0)
{ {
m4aSongNumStop(SE_LOW_HEALTH); m4aSongNumStop(SE_LOW_HEALTH);
gMain.inBattle = 0; gMain.inBattle = FALSE;
gMain.callback1 = gPreBattleCallback1; gMain.callback1 = gPreBattleCallback1;
SetMainCallback2(CB2_InitEndLinkBattle); SetMainCallback2(CB2_InitEndLinkBattle);
if (gBattleOutcome == B_OUTCOME_WON) if (gBattleOutcome == B_OUTCOME_WON)
@ -871,7 +871,7 @@ static void SetLinkBattleEndCallbacks(void)
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
m4aSongNumStop(SE_LOW_HEALTH); m4aSongNumStop(SE_LOW_HEALTH);
gMain.inBattle = 0; gMain.inBattle = FALSE;
gMain.callback1 = gPreBattleCallback1; gMain.callback1 = gPreBattleCallback1;
SetMainCallback2(CB2_InitEndLinkBattle); SetMainCallback2(CB2_InitEndLinkBattle);
if (gBattleOutcome == B_OUTCOME_WON) if (gBattleOutcome == B_OUTCOME_WON)
@ -901,7 +901,7 @@ void SetBattleEndCallbacks(void)
else else
{ {
m4aSongNumStop(SE_LOW_HEALTH); m4aSongNumStop(SE_LOW_HEALTH);
gMain.inBattle = 0; gMain.inBattle = FALSE;
gMain.callback1 = gPreBattleCallback1; gMain.callback1 = gPreBattleCallback1;
SetMainCallback2(gMain.savedCallback); SetMainCallback2(gMain.savedCallback);
} }

View File

@ -115,7 +115,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
s32 i, var1, var2; s32 i, var1, var2;
s32 chosenMoveId = -1; s32 chosenMoveId = -1;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]);
u8 unusableMovesBits = CheckMoveLimitations(gActiveBattler, 0, 0xFF); u8 unusableMovesBits = CheckMoveLimitations(gActiveBattler, 0, MOVE_LIMITATIONS_ALL);
s32 percent = Random() % 100; s32 percent = Random() % 100;
// Heavy variable re-use here makes this hard to read without defines // Heavy variable re-use here makes this hard to read without defines
@ -438,9 +438,10 @@ bool8 TryHandleLaunchBattleTableAnimation(u8 activeBattler, u8 atkBattler, u8 de
{ {
u8 taskId; u8 taskId;
if (tableId == B_ANIM_CASTFORM_CHANGE && (argument & 0x80)) if (tableId == B_ANIM_CASTFORM_CHANGE && (argument & CASTFORM_SUBSTITUTE))
{ {
gBattleMonForms[activeBattler] = (argument & ~(0x80)); // If Castform is behind substitute, set the new form but skip the animation
gBattleMonForms[activeBattler] = (argument & ~CASTFORM_SUBSTITUTE);
return TRUE; return TRUE;
} }
if (gBattleSpritesDataPtr->battlerData[activeBattler].behindSubstitute if (gBattleSpritesDataPtr->battlerData[activeBattler].behindSubstitute
@ -593,7 +594,7 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
if (species == SPECIES_CASTFORM) if (species == SPECIES_CASTFORM)
{ {
paletteOffset = 0x100 + battlerId * 16; paletteOffset = 0x100 + battlerId * 16;
LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]); LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[CASTFORM_NORMAL]);
LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[battlerId]], paletteOffset, 0x20); LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[battlerId]], paletteOffset, 0x20);
} }
@ -656,7 +657,7 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
if (species == SPECIES_CASTFORM) if (species == SPECIES_CASTFORM)
{ {
paletteOffset = 0x100 + battlerId * 16; paletteOffset = 0x100 + battlerId * 16;
LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]); LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[CASTFORM_NORMAL]);
LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[battlerId]], paletteOffset, 0x20); LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[battlerId]], paletteOffset, 0x20);
} }
@ -895,7 +896,7 @@ void CopyBattleSpriteInvisibility(u8 battlerId)
gBattleSpritesDataPtr->battlerData[battlerId].invisible = gSprites[gBattlerSpriteIds[battlerId]].invisible; gBattleSpritesDataPtr->battlerData[battlerId].invisible = gSprites[gBattlerSpriteIds[battlerId]].invisible;
} }
void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform) void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 castform)
{ {
u16 paletteOffset; u16 paletteOffset;
u32 personalityValue; u32 personalityValue;
@ -903,7 +904,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform
u8 position; u8 position;
const u32 *lzPaletteData; const u32 *lzPaletteData;
if (notTransform) if (castform)
{ {
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerAtk]], gBattleSpritesDataPtr->animationData->animArg); StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerAtk]], gBattleSpritesDataPtr->animationData->animArg);
paletteOffset = 0x100 + battlerAtk * 16; paletteOffset = 0x100 + battlerAtk * 16;
@ -976,8 +977,8 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform
if (targetSpecies == SPECIES_CASTFORM) if (targetSpecies == SPECIES_CASTFORM)
{ {
gSprites[gBattlerSpriteIds[battlerAtk]].anims = gMonFrontAnimsPtrTable[targetSpecies]; gSprites[gBattlerSpriteIds[battlerAtk]].anims = gMonFrontAnimsPtrTable[targetSpecies];
LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]); LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[CASTFORM_NORMAL]);
LoadPalette(gBattleStruct->castformPalette[0] + gBattleMonForms[battlerDef] * 16, paletteOffset, 32); LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[battlerDef]], paletteOffset, 32);
} }
BlendPalette(paletteOffset, 16, 6, RGB_WHITE); BlendPalette(paletteOffset, 16, 6, RGB_WHITE);

View File

@ -584,36 +584,35 @@ static void BattleIntroSlidePartner(u8 taskId)
} }
} }
void sub_8118FBC(int bgId, u8 arg1, u8 arg2, u8 battlerPosition, u8 arg4, u8 *arg5, u16 *arg6, u16 tilesOffset) void DrawBattlerOnBg(int bgId, u8 x, u8 y, u8 battlerPosition, u8 paletteId, u8 *tiles, u16 *tilemap, u16 tilesOffset)
{ {
int i, j; int i, j;
u8 battler = GetBattlerAtPosition(battlerPosition); u8 battler = GetBattlerAtPosition(battlerPosition);
int offset = tilesOffset; int offset = tilesOffset;
CpuCopy16(gMonSpritesGfxPtr->sprites.ptr[battlerPosition] + BG_SCREEN_SIZE * gBattleMonForms[battler], arg5, BG_SCREEN_SIZE); CpuCopy16(gMonSpritesGfxPtr->sprites.ptr[battlerPosition] + BG_SCREEN_SIZE * gBattleMonForms[battler], tiles, BG_SCREEN_SIZE);
LoadBgTiles(bgId, arg5, 0x1000, tilesOffset); LoadBgTiles(bgId, tiles, 0x1000, tilesOffset);
for (i = arg2; i < arg2 + 8; i++) for (i = y; i < y + 8; i++)
{ {
for (j = arg1; j < arg1 + 8; j++) for (j = x; j < x + 8; j++)
{ {
arg6[i * 32 + j] = offset | (arg4 << 12); tilemap[i * 32 + j] = offset | (paletteId << 12);
offset++; offset++;
} }
} }
LoadBgTilemap(bgId, tilemap, BG_SCREEN_SIZE, 0);
LoadBgTilemap(bgId, arg6, BG_SCREEN_SIZE, 0);
} }
void unref_sub_8119094(u8 arg0, u8 arg1, u8 battlerPosition, u8 arg3, u8 arg4, u16 arg5, u8 arg6, u8 arg7) static void DrawBattlerOnBgDMA(u8 x, u8 y, u8 battlerPosition, u8 arg3, u8 paletteId, u16 arg5, u8 arg6, u8 arg7)
{ {
int i, j, offset; int i, j, offset;
DmaCopy16(3, gMonSpritesGfxPtr->sprites.ptr[battlerPosition] + BG_SCREEN_SIZE * arg3, (void *)BG_SCREEN_ADDR(0) + arg5, BG_SCREEN_SIZE); DmaCopy16(3, gMonSpritesGfxPtr->sprites.ptr[battlerPosition] + BG_SCREEN_SIZE * arg3, (void *)BG_SCREEN_ADDR(0) + arg5, BG_SCREEN_SIZE);
offset = (arg5 >> 5) - (arg7 << 9); offset = (arg5 >> 5) - (arg7 << 9);
for (i = arg1; i < arg1 + 8; i++) for (i = y; i < y + 8; i++)
{ {
for (j = arg0; j < arg0 + 8; j++) for (j = x; j < x + 8; j++)
{ {
*((u16 *)(BG_VRAM) + (i * 32) + (j + (arg6 << 10))) = offset | (arg4 << 12); *((u16 *)(BG_VRAM) + (i * 32) + (j + (arg6 << 10))) = offset | (paletteId << 12);
offset++; offset++;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -2053,7 +2053,8 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
static const struct BattleWindowText *const sBattleTextOnWindowsInfo[] = static const struct BattleWindowText *const sBattleTextOnWindowsInfo[] =
{ {
sTextOnWindowsInfo_Normal, sTextOnWindowsInfo_Arena [B_WIN_TYPE_NORMAL] = sTextOnWindowsInfo_Normal,
[B_WIN_TYPE_ARENA] = sTextOnWindowsInfo_Arena
}; };
static const u8 sRecordedBattleTextSpeeds[] = {8, 4, 1, 0}; static const u8 sRecordedBattleTextSpeeds[] = {8, 4, 1, 0};

View File

@ -1834,8 +1834,8 @@ static void Cmd_datahpupdate(void)
if (gBattleStruct->dynamicMoveType == 0) if (gBattleStruct->dynamicMoveType == 0)
moveType = gBattleMoves[gCurrentMove].type; moveType = gBattleMoves[gCurrentMove].type;
else if (!(gBattleStruct->dynamicMoveType & 0x40)) else if (!(gBattleStruct->dynamicMoveType & F_DYNAMIC_TYPE_1))
moveType = gBattleStruct->dynamicMoveType & 0x3F; moveType = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK;
else else
moveType = gBattleMoves[gCurrentMove].type; moveType = gBattleMoves[gCurrentMove].type;
@ -3489,6 +3489,8 @@ static void Cmd_getexp(void)
} }
} }
// For battles that aren't BATTLE_TYPE_LINK or BATTLE_TYPE_RECORDED_LINK, the only thing this
// command does is check whether the player has won/lost by totaling each team's HP
static void Cmd_unknown_24(void) static void Cmd_unknown_24(void)
{ {
u16 HP_count = 0; u16 HP_count = 0;
@ -3497,11 +3499,14 @@ static void Cmd_unknown_24(void)
if (gBattleControllerExecFlags) if (gBattleControllerExecFlags)
return; return;
// Get total HP for the player's party to determine if the player has lost
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId == TRAINER_STEVEN_PARTNER) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId == TRAINER_STEVEN_PARTNER)
{ {
// In multi battle with Steven, skip his Pokémon
for (i = 0; i < MULTI_PARTY_SIZE; i++) for (i = 0; i < MULTI_PARTY_SIZE; i++)
{ {
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES)
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP); HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
} }
} }
@ -3509,28 +3514,30 @@ static void Cmd_unknown_24(void)
{ {
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & gBitTable[i]))) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA)
|| !(gBattleStruct->arenaLostPlayerMons & gBitTable[i])))
{ {
HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP); HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
} }
} }
} }
if (HP_count == 0) if (HP_count == 0)
gBattleOutcome |= B_OUTCOME_LOST; gBattleOutcome |= B_OUTCOME_LOST;
HP_count = 0; HP_count = 0;
// Get total HP for the enemy's party to determine if the player has won
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES) && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostOpponentMons & gBitTable[i]))) && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA)
|| !(gBattleStruct->arenaLostOpponentMons & gBitTable[i])))
{ {
HP_count += GetMonData(&gEnemyParty[i], MON_DATA_HP); HP_count += GetMonData(&gEnemyParty[i], MON_DATA_HP);
} }
} }
if (HP_count == 0) if (HP_count == 0)
gBattleOutcome |= B_OUTCOME_WON; gBattleOutcome |= B_OUTCOME_WON;
@ -4844,7 +4851,7 @@ static void Cmd_openpartyscreen(void)
else if (!gSpecialStatuses[gActiveBattler].flag40) else if (!gSpecialStatuses[gActiveBattler].flag40)
{ {
ChooseMonToSendOut(PARTY_SIZE); ChooseMonToSendOut(PARTY_SIZE);
gSpecialStatuses[gActiveBattler].flag40 = 1; gSpecialStatuses[gActiveBattler].flag40 = TRUE;
} }
} }
else else
@ -4873,7 +4880,7 @@ static void Cmd_openpartyscreen(void)
else if (!gSpecialStatuses[gActiveBattler].flag40) else if (!gSpecialStatuses[gActiveBattler].flag40)
{ {
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[2]); ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[2]);
gSpecialStatuses[gActiveBattler].flag40 = 1; gSpecialStatuses[gActiveBattler].flag40 = TRUE;
} }
else else
{ {
@ -4895,7 +4902,7 @@ static void Cmd_openpartyscreen(void)
else if (!gSpecialStatuses[gActiveBattler].flag40) else if (!gSpecialStatuses[gActiveBattler].flag40)
{ {
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[0]); ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[0]);
gSpecialStatuses[gActiveBattler].flag40 = 1; gSpecialStatuses[gActiveBattler].flag40 = TRUE;
} }
else if (!(flags & 1)) else if (!(flags & 1))
{ {
@ -4916,7 +4923,7 @@ static void Cmd_openpartyscreen(void)
else if (!gSpecialStatuses[gActiveBattler].flag40) else if (!gSpecialStatuses[gActiveBattler].flag40)
{ {
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[3]); ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[3]);
gSpecialStatuses[gActiveBattler].flag40 = 1; gSpecialStatuses[gActiveBattler].flag40 = TRUE;
} }
else else
{ {
@ -4938,7 +4945,7 @@ static void Cmd_openpartyscreen(void)
else if (!gSpecialStatuses[gActiveBattler].flag40) else if (!gSpecialStatuses[gActiveBattler].flag40)
{ {
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[1]); ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[1]);
gSpecialStatuses[gActiveBattler].flag40 = 1; gSpecialStatuses[gActiveBattler].flag40 = TRUE;
} }
else if (!(flags & 2)) else if (!(flags & 2))
{ {
@ -5001,7 +5008,7 @@ static void Cmd_openpartyscreen(void)
else if (!gSpecialStatuses[gActiveBattler].flag40) else if (!gSpecialStatuses[gActiveBattler].flag40)
{ {
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[0]); ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[0]);
gSpecialStatuses[gActiveBattler].flag40 = 1; gSpecialStatuses[gActiveBattler].flag40 = TRUE;
} }
} }
if (gBitTable[3] & hitmarkerFaintBits && hitmarkerFaintBits & gBitTable[1]) if (gBitTable[3] & hitmarkerFaintBits && hitmarkerFaintBits & gBitTable[1])
@ -5017,7 +5024,7 @@ static void Cmd_openpartyscreen(void)
else if (!gSpecialStatuses[gActiveBattler].flag40) else if (!gSpecialStatuses[gActiveBattler].flag40)
{ {
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[1]); ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[1]);
gSpecialStatuses[gActiveBattler].flag40 = 1; gSpecialStatuses[gActiveBattler].flag40 = TRUE;
} }
} }
gBattlescriptCurrInstr += 6; gBattlescriptCurrInstr += 6;
@ -5175,7 +5182,7 @@ static void Cmd_switchineffects(void)
UpdateSentPokesToOpponentValue(gActiveBattler); UpdateSentPokesToOpponentValue(gActiveBattler);
gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler);
gSpecialStatuses[gActiveBattler].flag40 = 0; gSpecialStatuses[gActiveBattler].flag40 = FALSE;
if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES_DAMAGED) if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES_DAMAGED)
&& (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES) && (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES)
@ -5230,7 +5237,7 @@ static void Cmd_switchineffects(void)
*hpOnSwitchout = gBattleMons[i].hp; *hpOnSwitchout = gBattleMons[i].hp;
} }
if (gBattlescriptCurrInstr[1] == 5) if (gBattlescriptCurrInstr[1] == BS_UNK_5)
{ {
u32 hitmarkerFaintBits = gHitMarker >> 28; u32 hitmarkerFaintBits = gHitMarker >> 28;
@ -6282,7 +6289,7 @@ static void Cmd_various(void)
gBattleCommunication[0] = IsRunningFromBattleImpossible(); gBattleCommunication[0] = IsRunningFromBattleImpossible();
break; break;
case VARIOUS_GET_MOVE_TARGET: case VARIOUS_GET_MOVE_TARGET:
gBattlerTarget = GetMoveTarget(gCurrentMove, 0); gBattlerTarget = GetMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE);
break; break;
case VARIOUS_GET_BATTLER_FAINTED: case VARIOUS_GET_BATTLER_FAINTED:
if (gHitMarker & HITMARKER_FAINTED(gActiveBattler)) if (gHitMarker & HITMARKER_FAINTED(gActiveBattler))
@ -6597,7 +6604,7 @@ static void Cmd_trymirrormove(void)
{ {
gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED;
gCurrentMove = move; gCurrentMove = move;
gBattlerTarget = GetMoveTarget(gCurrentMove, 0); gBattlerTarget = GetMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE);
gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect];
} }
else if (validMovesCount) else if (validMovesCount)
@ -6605,7 +6612,7 @@ static void Cmd_trymirrormove(void)
gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED;
i = Random() % validMovesCount; i = Random() % validMovesCount;
gCurrentMove = movesArray[i]; gCurrentMove = movesArray[i];
gBattlerTarget = GetMoveTarget(gCurrentMove, 0); gBattlerTarget = GetMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE);
gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect];
} }
else else
@ -7805,7 +7812,7 @@ static void Cmd_metronome(void)
{ {
gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED;
gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect];
gBattlerTarget = GetMoveTarget(gCurrentMove, 0); gBattlerTarget = GetMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE);
return; return;
} }
} }
@ -8154,7 +8161,7 @@ static void Cmd_trychoosesleeptalkmove(void)
gCalledMove = gBattleMons[gBattlerAttacker].moves[movePosition]; gCalledMove = gBattleMons[gBattlerAttacker].moves[movePosition];
gCurrMovePos = movePosition; gCurrMovePos = movePosition;
gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED;
gBattlerTarget = GetMoveTarget(gCalledMove, 0); gBattlerTarget = GetMoveTarget(gCalledMove, NO_TARGET_OVERRIDE);
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
} }
@ -8758,17 +8765,14 @@ static void Cmd_recoverbasedonsunlight(void)
static void Cmd_hiddenpowercalc(void) static void Cmd_hiddenpowercalc(void)
{ {
u8 powerBits; u8 powerBits = ((gBattleMons[gBattlerAttacker].hpIV & 2) >> 1)
u8 typeBits;
powerBits = ((gBattleMons[gBattlerAttacker].hpIV & 2) >> 1)
| ((gBattleMons[gBattlerAttacker].attackIV & 2) << 0) | ((gBattleMons[gBattlerAttacker].attackIV & 2) << 0)
| ((gBattleMons[gBattlerAttacker].defenseIV & 2) << 1) | ((gBattleMons[gBattlerAttacker].defenseIV & 2) << 1)
| ((gBattleMons[gBattlerAttacker].speedIV & 2) << 2) | ((gBattleMons[gBattlerAttacker].speedIV & 2) << 2)
| ((gBattleMons[gBattlerAttacker].spAttackIV & 2) << 3) | ((gBattleMons[gBattlerAttacker].spAttackIV & 2) << 3)
| ((gBattleMons[gBattlerAttacker].spDefenseIV & 2) << 4); | ((gBattleMons[gBattlerAttacker].spDefenseIV & 2) << 4);
typeBits = ((gBattleMons[gBattlerAttacker].hpIV & 1) << 0) u8 typeBits = ((gBattleMons[gBattlerAttacker].hpIV & 1) << 0)
| ((gBattleMons[gBattlerAttacker].attackIV & 1) << 1) | ((gBattleMons[gBattlerAttacker].attackIV & 1) << 1)
| ((gBattleMons[gBattlerAttacker].defenseIV & 1) << 2) | ((gBattleMons[gBattlerAttacker].defenseIV & 1) << 2)
| ((gBattleMons[gBattlerAttacker].speedIV & 1) << 3) | ((gBattleMons[gBattlerAttacker].speedIV & 1) << 3)
@ -8777,10 +8781,12 @@ static void Cmd_hiddenpowercalc(void)
gDynamicBasePower = (40 * powerBits) / 63 + 30; gDynamicBasePower = (40 * powerBits) / 63 + 30;
gBattleStruct->dynamicMoveType = (15 * typeBits) / 63 + 1; // Subtract 3 instead of 1 below because 2 types are excluded (TYPE_NORMAL and TYPE_MYSTERY)
// The final + 1 skips past Normal, and the following conditional skips TYPE_MYSTERY
gBattleStruct->dynamicMoveType = ((NUMBER_OF_MON_TYPES - 3) * typeBits) / 63 + 1;
if (gBattleStruct->dynamicMoveType >= TYPE_MYSTERY) if (gBattleStruct->dynamicMoveType >= TYPE_MYSTERY)
gBattleStruct->dynamicMoveType++; gBattleStruct->dynamicMoveType++;
gBattleStruct->dynamicMoveType |= 0xC0; gBattleStruct->dynamicMoveType |= F_DYNAMIC_TYPE_1 | F_DYNAMIC_TYPE_2;
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
} }
@ -8972,7 +8978,7 @@ static void Cmd_callterrainattack(void) // nature power
{ {
gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED;
gCurrentMove = sNaturePowerMoves[gBattleTerrain]; gCurrentMove = sNaturePowerMoves[gBattleTerrain];
gBattlerTarget = GetMoveTarget(gCurrentMove, 0); gBattlerTarget = GetMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE);
BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]);
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
} }
@ -9382,7 +9388,7 @@ static void Cmd_assistattackselect(void)
{ {
gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED;
gCalledMove = movesArray[((Random() & 0xFF) * chooseableMovesNo) >> 8]; gCalledMove = movesArray[((Random() & 0xFF) * chooseableMovesNo) >> 8];
gBattlerTarget = GetMoveTarget(gCalledMove, 0); gBattlerTarget = GetMoveTarget(gCalledMove, NO_TARGET_OVERRIDE);
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
else else
@ -9527,7 +9533,7 @@ static void Cmd_pickup(void)
ability = gBaseStats[species].abilities[0]; ability = gBaseStats[species].abilities[0];
if (ability == ABILITY_PICKUP if (ability == ABILITY_PICKUP
&& species != 0 && species != SPECIES_NONE
&& species != SPECIES_EGG && species != SPECIES_EGG
&& heldItem == ITEM_NONE && heldItem == ITEM_NONE
&& (Random() % 10) == 0) && (Random() % 10) == 0)
@ -9550,7 +9556,7 @@ static void Cmd_pickup(void)
ability = gBaseStats[species].abilities[0]; ability = gBaseStats[species].abilities[0];
if (ability == ABILITY_PICKUP if (ability == ABILITY_PICKUP
&& species != 0 && species != SPECIES_NONE
&& species != SPECIES_EGG && species != SPECIES_EGG
&& heldItem == ITEM_NONE && heldItem == ITEM_NONE
&& (Random() % 10) == 0) && (Random() % 10) == 0)
@ -9586,7 +9592,7 @@ static void Cmd_docastformchangeanimation(void)
gActiveBattler = gBattleScripting.battler; gActiveBattler = gBattleScripting.battler;
if (gBattleMons[gActiveBattler].status2 & STATUS2_SUBSTITUTE) if (gBattleMons[gActiveBattler].status2 & STATUS2_SUBSTITUTE)
*(&gBattleStruct->formToChangeInto) |= 0x80; *(&gBattleStruct->formToChangeInto) |= CASTFORM_SUBSTITUTE;
BtlController_EmitBattleAnimation(0, B_ANIM_CASTFORM_CHANGE, gBattleStruct->formToChangeInto); BtlController_EmitBattleAnimation(0, B_ANIM_CASTFORM_CHANGE, gBattleStruct->formToChangeInto);
MarkBattlerForControllerExec(gActiveBattler); MarkBattlerForControllerExec(gActiveBattler);
@ -9643,15 +9649,15 @@ static void Cmd_setweatherballtype(void)
if (gBattleWeather & B_WEATHER_ANY) if (gBattleWeather & B_WEATHER_ANY)
gBattleScripting.dmgMultiplier = 2; gBattleScripting.dmgMultiplier = 2;
if (gBattleWeather & B_WEATHER_RAIN) if (gBattleWeather & B_WEATHER_RAIN)
*(&gBattleStruct->dynamicMoveType) = TYPE_WATER | 0x80; *(&gBattleStruct->dynamicMoveType) = TYPE_WATER | F_DYNAMIC_TYPE_2;
else if (gBattleWeather & B_WEATHER_SANDSTORM) else if (gBattleWeather & B_WEATHER_SANDSTORM)
*(&gBattleStruct->dynamicMoveType) = TYPE_ROCK | 0x80; *(&gBattleStruct->dynamicMoveType) = TYPE_ROCK | F_DYNAMIC_TYPE_2;
else if (gBattleWeather & B_WEATHER_SUN) else if (gBattleWeather & B_WEATHER_SUN)
*(&gBattleStruct->dynamicMoveType) = TYPE_FIRE | 0x80; *(&gBattleStruct->dynamicMoveType) = TYPE_FIRE | F_DYNAMIC_TYPE_2;
else if (gBattleWeather & B_WEATHER_HAIL) else if (gBattleWeather & B_WEATHER_HAIL)
*(&gBattleStruct->dynamicMoveType) = TYPE_ICE | 0x80; *(&gBattleStruct->dynamicMoveType) = TYPE_ICE | F_DYNAMIC_TYPE_2;
else else
*(&gBattleStruct->dynamicMoveType) = TYPE_NORMAL | 0x80; *(&gBattleStruct->dynamicMoveType) = TYPE_NORMAL | F_DYNAMIC_TYPE_2;
} }
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
@ -9663,10 +9669,10 @@ static void Cmd_tryrecycleitem(void)
gActiveBattler = gBattlerAttacker; gActiveBattler = gBattlerAttacker;
usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBattler]; usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBattler];
if (*usedHeldItem != 0 && gBattleMons[gActiveBattler].item == 0) if (*usedHeldItem != ITEM_NONE && gBattleMons[gActiveBattler].item == ITEM_NONE)
{ {
gLastUsedItem = *usedHeldItem; gLastUsedItem = *usedHeldItem;
*usedHeldItem = 0; *usedHeldItem = ITEM_NONE;
gBattleMons[gActiveBattler].item = gLastUsedItem; gBattleMons[gActiveBattler].item = gLastUsedItem;
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBattler].item); BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBattler].item);
@ -9704,7 +9710,7 @@ static void Cmd_pursuitrelated(void)
&& gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE && gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE
&& gChosenMoveByBattler[gActiveBattler] == MOVE_PURSUIT) && gChosenMoveByBattler[gActiveBattler] == MOVE_PURSUIT)
{ {
gActionsByTurnOrder[gActiveBattler] = 11; gActionsByTurnOrder[gActiveBattler] = B_ACTION_TRY_FINISH;
gCurrentMove = MOVE_PURSUIT; gCurrentMove = MOVE_PURSUIT;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
gBattleScripting.animTurn = 1; gBattleScripting.animTurn = 1;
@ -9849,7 +9855,7 @@ static void Cmd_handleballthrow(void)
} }
else else
{ {
if (gBattleResults.catchAttempts[gLastUsedItem - ITEM_ULTRA_BALL] < 0xFF) if (gBattleResults.catchAttempts[gLastUsedItem - ITEM_ULTRA_BALL] < 255)
gBattleResults.catchAttempts[gLastUsedItem - ITEM_ULTRA_BALL]++; gBattleResults.catchAttempts[gLastUsedItem - ITEM_ULTRA_BALL]++;
} }
} }

View File

@ -319,7 +319,7 @@ const struct RematchTrainer gRematchTable[REMATCH_TABLE_ENTRIES] =
[REMATCH_TRENT] = REMATCH(TRAINER_TRENT_1, TRAINER_TRENT_2, TRAINER_TRENT_3, TRAINER_TRENT_4, TRAINER_TRENT_5, ROUTE112), [REMATCH_TRENT] = REMATCH(TRAINER_TRENT_1, TRAINER_TRENT_2, TRAINER_TRENT_3, TRAINER_TRENT_4, TRAINER_TRENT_5, ROUTE112),
[REMATCH_SAWYER] = REMATCH(TRAINER_SAWYER_1, TRAINER_SAWYER_2, TRAINER_SAWYER_3, TRAINER_SAWYER_4, TRAINER_SAWYER_5, MT_CHIMNEY), [REMATCH_SAWYER] = REMATCH(TRAINER_SAWYER_1, TRAINER_SAWYER_2, TRAINER_SAWYER_3, TRAINER_SAWYER_4, TRAINER_SAWYER_5, MT_CHIMNEY),
[REMATCH_KIRA_AND_DAN] = REMATCH(TRAINER_KIRA_AND_DAN_1, TRAINER_KIRA_AND_DAN_2, TRAINER_KIRA_AND_DAN_3, TRAINER_KIRA_AND_DAN_4, TRAINER_KIRA_AND_DAN_5, ABANDONED_SHIP_ROOMS2_1F), [REMATCH_KIRA_AND_DAN] = REMATCH(TRAINER_KIRA_AND_DAN_1, TRAINER_KIRA_AND_DAN_2, TRAINER_KIRA_AND_DAN_3, TRAINER_KIRA_AND_DAN_4, TRAINER_KIRA_AND_DAN_5, ABANDONED_SHIP_ROOMS2_1F),
[REMATCH_WALLY_3] = REMATCH(TRAINER_WALLY_VR_2, TRAINER_WALLY_VR_3, TRAINER_WALLY_VR_4, TRAINER_WALLY_VR_5, TRAINER_WALLY_VR_5, VICTORY_ROAD_1F), [REMATCH_WALLY_VR] = REMATCH(TRAINER_WALLY_VR_2, TRAINER_WALLY_VR_3, TRAINER_WALLY_VR_4, TRAINER_WALLY_VR_5, TRAINER_WALLY_VR_5, VICTORY_ROAD_1F),
[REMATCH_ROXANNE] = REMATCH(TRAINER_ROXANNE_1, TRAINER_ROXANNE_2, TRAINER_ROXANNE_3, TRAINER_ROXANNE_4, TRAINER_ROXANNE_5, RUSTBORO_CITY), [REMATCH_ROXANNE] = REMATCH(TRAINER_ROXANNE_1, TRAINER_ROXANNE_2, TRAINER_ROXANNE_3, TRAINER_ROXANNE_4, TRAINER_ROXANNE_5, RUSTBORO_CITY),
[REMATCH_BRAWLY] = REMATCH(TRAINER_BRAWLY_1, TRAINER_BRAWLY_2, TRAINER_BRAWLY_3, TRAINER_BRAWLY_4, TRAINER_BRAWLY_5, DEWFORD_TOWN), [REMATCH_BRAWLY] = REMATCH(TRAINER_BRAWLY_1, TRAINER_BRAWLY_2, TRAINER_BRAWLY_3, TRAINER_BRAWLY_4, TRAINER_BRAWLY_5, DEWFORD_TOWN),
[REMATCH_WATTSON] = REMATCH(TRAINER_WATTSON_1, TRAINER_WATTSON_2, TRAINER_WATTSON_3, TRAINER_WATTSON_4, TRAINER_WATTSON_5, MAUVILLE_CITY), [REMATCH_WATTSON] = REMATCH(TRAINER_WATTSON_1, TRAINER_WATTSON_2, TRAINER_WATTSON_3, TRAINER_WATTSON_4, TRAINER_WATTSON_5, MAUVILLE_CITY),
@ -460,12 +460,12 @@ static void DoTrainerBattle(void)
TryUpdateGymLeaderRematchFromTrainer(); TryUpdateGymLeaderRematchFromTrainer();
} }
static void sub_80B0828(void) static void DoBattlePyramidTrainerHillBattle(void)
{ {
if (InBattlePyramid()) if (InBattlePyramid())
CreateBattleStartTask(GetSpecialBattleTransition(10), 0); CreateBattleStartTask(GetSpecialBattleTransition(B_TRANSITION_GROUP_B_PYRAMID), 0);
else else
CreateBattleStartTask(GetSpecialBattleTransition(11), 0); CreateBattleStartTask(GetSpecialBattleTransition(B_TRANSITION_GROUP_TRAINER_HILL), 0);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES); IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_TRAINER_BATTLES); IncrementGameStat(GAME_STAT_TRAINER_BATTLES);
@ -853,16 +853,7 @@ static u8 GetTrainerBattleTransition(void)
return sBattleTransitionTable_Trainer[transitionType][1]; return sBattleTransitionTable_Trainer[transitionType][1];
} }
// 0: Battle Tower #define RANDOM_TRANSITION(table)(table[Random() % ARRAY_COUNT(table)])
// 3: Battle Dome
// 4: Battle Palace
// 5: Battle Arena
// 6: Battle Factory
// 7: Battle Pike
// 10: Battle Pyramid
// 11: Trainer Hill
// 12: Secret Base
// 13: E-Reader
u8 GetSpecialBattleTransition(s32 id) u8 GetSpecialBattleTransition(s32 id)
{ {
u16 var; u16 var;
@ -873,35 +864,35 @@ u8 GetSpecialBattleTransition(s32 id)
{ {
switch (id) switch (id)
{ {
case 11: case B_TRANSITION_GROUP_TRAINER_HILL:
case 12: case B_TRANSITION_GROUP_SECRET_BASE:
case 13: case B_TRANSITION_GROUP_E_READER:
return B_TRANSITION_POKEBALLS_TRAIL; return B_TRANSITION_POKEBALLS_TRAIL;
case 10: case B_TRANSITION_GROUP_B_PYRAMID:
return sBattleTransitionTable_BattlePyramid[Random() % ARRAY_COUNT(sBattleTransitionTable_BattlePyramid)]; return RANDOM_TRANSITION(sBattleTransitionTable_BattlePyramid);
case 3: case B_TRANSITION_GROUP_B_DOME:
return sBattleTransitionTable_BattleDome[Random() % ARRAY_COUNT(sBattleTransitionTable_BattleDome)]; return RANDOM_TRANSITION(sBattleTransitionTable_BattleDome);
} }
if (VarGet(VAR_FRONTIER_BATTLE_MODE) != FRONTIER_MODE_LINK_MULTIS) if (VarGet(VAR_FRONTIER_BATTLE_MODE) != FRONTIER_MODE_LINK_MULTIS)
return sBattleTransitionTable_BattleFrontier[Random() % ARRAY_COUNT(sBattleTransitionTable_BattleFrontier)]; return RANDOM_TRANSITION(sBattleTransitionTable_BattleFrontier);
} }
else else
{ {
switch (id) switch (id)
{ {
case 11: case B_TRANSITION_GROUP_TRAINER_HILL:
case 12: case B_TRANSITION_GROUP_SECRET_BASE:
case 13: case B_TRANSITION_GROUP_E_READER:
return B_TRANSITION_BIG_POKEBALL; return B_TRANSITION_BIG_POKEBALL;
case 10: case B_TRANSITION_GROUP_B_PYRAMID:
return sBattleTransitionTable_BattlePyramid[Random() % ARRAY_COUNT(sBattleTransitionTable_BattlePyramid)]; return RANDOM_TRANSITION(sBattleTransitionTable_BattlePyramid);
case 3: case B_TRANSITION_GROUP_B_DOME:
return sBattleTransitionTable_BattleDome[Random() % ARRAY_COUNT(sBattleTransitionTable_BattleDome)]; return RANDOM_TRANSITION(sBattleTransitionTable_BattleDome);
} }
if (VarGet(VAR_FRONTIER_BATTLE_MODE) != FRONTIER_MODE_LINK_MULTIS) if (VarGet(VAR_FRONTIER_BATTLE_MODE) != FRONTIER_MODE_LINK_MULTIS)
return sBattleTransitionTable_BattleFrontier[Random() % ARRAY_COUNT(sBattleTransitionTable_BattleFrontier)]; return RANDOM_TRANSITION(sBattleTransitionTable_BattleFrontier);
} }
var = gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum * 2 + 0] var = gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum * 2 + 0]
@ -1319,7 +1310,7 @@ void BattleSetup_StartTrainerBattle(void)
gMain.savedCallback = CB2_EndTrainerBattle; gMain.savedCallback = CB2_EndTrainerBattle;
if (InBattlePyramid() || InTrainerHillChallenge()) if (InBattlePyramid() || InTrainerHillChallenge())
sub_80B0828(); DoBattlePyramidTrainerHillBattle();
else else
DoTrainerBattle(); DoTrainerBattle();
@ -1575,12 +1566,14 @@ static s32 TrainerIdToRematchTableId(const struct RematchTrainer *table, u16 tra
return -1; return -1;
} }
static bool32 sub_80B1D94(s32 rematchTableId) // Returns TRUE if the given trainer (by their entry in the rematch table) is not allowed to have rematches.
// This applies to the Elite Four and Victory Road Wally (if he's not been defeated yet)
static bool32 IsRematchForbidden(s32 rematchTableId)
{ {
if (rematchTableId >= REMATCH_ELITE_FOUR_ENTRIES) if (rematchTableId >= REMATCH_ELITE_FOUR_ENTRIES)
return TRUE; return TRUE;
else if (rematchTableId == REMATCH_WALLY_3) else if (rematchTableId == REMATCH_WALLY_VR)
return (FlagGet(FLAG_DEFEATED_WALLY_VICTORY_ROAD) == FALSE); return !FlagGet(FLAG_DEFEATED_WALLY_VICTORY_ROAD);
else else
return FALSE; return FALSE;
} }
@ -1609,7 +1602,7 @@ static bool32 UpdateRandomTrainerRematches(const struct RematchTrainer *table, u
for (i = 0; i <= REMATCH_SPECIAL_TRAINER_START; i++) for (i = 0; i <= REMATCH_SPECIAL_TRAINER_START; i++)
{ {
if (table[i].mapGroup == mapGroup && table[i].mapNum == mapNum && !sub_80B1D94(i)) if (table[i].mapGroup == mapGroup && table[i].mapNum == mapNum && !IsRematchForbidden(i))
{ {
if (gSaveBlock1Ptr->trainerRematches[i] != 0) if (gSaveBlock1Ptr->trainerRematches[i] != 0)
{ {

View File

@ -2025,7 +2025,7 @@ void DoSpecialTrainerBattle(void)
} }
CreateTask(Task_StartBattleAfterTransition, 1); CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0); PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(0)); BattleTransition_StartOnField(GetSpecialBattleTransition(B_TRANSITION_GROUP_B_TOWER));
break; break;
case SPECIAL_BATTLE_SECRET_BASE: case SPECIAL_BATTLE_SECRET_BASE:
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
@ -2035,7 +2035,7 @@ void DoSpecialTrainerBattle(void)
} }
CreateTask(Task_StartBattleAfterTransition, 1); CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0); PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(12)); BattleTransition_StartOnField(GetSpecialBattleTransition(B_TRANSITION_GROUP_SECRET_BASE));
break; break;
case SPECIAL_BATTLE_EREADER: case SPECIAL_BATTLE_EREADER:
ZeroEnemyPartyMons(); ZeroEnemyPartyMons();
@ -2045,7 +2045,7 @@ void DoSpecialTrainerBattle(void)
gTrainerBattleOpponent_A = 0; gTrainerBattleOpponent_A = 0;
CreateTask(Task_StartBattleAfterTransition, 1); CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0); PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(13)); BattleTransition_StartOnField(GetSpecialBattleTransition(B_TRANSITION_GROUP_E_READER));
break; break;
case SPECIAL_BATTLE_DOME: case SPECIAL_BATTLE_DOME:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_DOME; gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_DOME;
@ -2055,7 +2055,7 @@ void DoSpecialTrainerBattle(void)
FillFrontierTrainerParty(DOME_BATTLE_PARTY_SIZE); FillFrontierTrainerParty(DOME_BATTLE_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1); CreateTask(Task_StartBattleAfterTransition, 1);
CreateTask_PlayMapChosenOrBattleBGM(0); CreateTask_PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(3)); BattleTransition_StartOnField(GetSpecialBattleTransition(B_TRANSITION_GROUP_B_DOME));
break; break;
case SPECIAL_BATTLE_PALACE: case SPECIAL_BATTLE_PALACE:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_PALACE; gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_PALACE;
@ -2067,7 +2067,7 @@ void DoSpecialTrainerBattle(void)
FillTentTrainerParty(FRONTIER_PARTY_SIZE); FillTentTrainerParty(FRONTIER_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1); CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0); PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(4)); BattleTransition_StartOnField(GetSpecialBattleTransition(B_TRANSITION_GROUP_B_PALACE));
break; break;
case SPECIAL_BATTLE_ARENA: case SPECIAL_BATTLE_ARENA:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_ARENA; gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_ARENA;
@ -2077,7 +2077,7 @@ void DoSpecialTrainerBattle(void)
FillTentTrainerParty(FRONTIER_PARTY_SIZE); FillTentTrainerParty(FRONTIER_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1); CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0); PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(5)); BattleTransition_StartOnField(GetSpecialBattleTransition(B_TRANSITION_GROUP_B_ARENA));
break; break;
case SPECIAL_BATTLE_FACTORY: case SPECIAL_BATTLE_FACTORY:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_FACTORY; gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_FACTORY;
@ -2086,28 +2086,28 @@ void DoSpecialTrainerBattle(void)
FillFactoryTrainerParty(); FillFactoryTrainerParty();
CreateTask(Task_StartBattleAfterTransition, 1); CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0); PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(6)); BattleTransition_StartOnField(GetSpecialBattleTransition(B_TRANSITION_GROUP_B_FACTORY));
break; break;
case SPECIAL_BATTLE_PIKE_SINGLE: case SPECIAL_BATTLE_PIKE_SINGLE:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_BATTLE_TOWER; gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_BATTLE_TOWER;
FillFrontierTrainerParty(FRONTIER_PARTY_SIZE); FillFrontierTrainerParty(FRONTIER_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1); CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0); PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(7)); BattleTransition_StartOnField(GetSpecialBattleTransition(B_TRANSITION_GROUP_B_PIKE));
break; break;
case SPECIAL_BATTLE_PYRAMID: case SPECIAL_BATTLE_PYRAMID:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_PYRAMID; gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_PYRAMID;
FillFrontierTrainerParty(FRONTIER_PARTY_SIZE); FillFrontierTrainerParty(FRONTIER_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1); CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0); PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(10)); BattleTransition_StartOnField(GetSpecialBattleTransition(B_TRANSITION_GROUP_B_PYRAMID));
break; break;
case SPECIAL_BATTLE_PIKE_DOUBLE: case SPECIAL_BATTLE_PIKE_DOUBLE:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TWO_OPPONENTS; gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TWO_OPPONENTS;
FillFrontierTrainersParties(1); FillFrontierTrainersParties(1);
CreateTask(Task_StartBattleAfterTransition, 1); CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0); PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(7)); BattleTransition_StartOnField(GetSpecialBattleTransition(B_TRANSITION_GROUP_B_PIKE));
break; break;
case SPECIAL_BATTLE_STEVEN: case SPECIAL_BATTLE_STEVEN:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER; gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER;

File diff suppressed because it is too large Load Diff

View File

@ -34,8 +34,8 @@ void AllocateBattleResources(void)
gLinkBattleSendBuffer = AllocZeroed(BATTLE_BUFFER_LINK_SIZE); gLinkBattleSendBuffer = AllocZeroed(BATTLE_BUFFER_LINK_SIZE);
gLinkBattleRecvBuffer = AllocZeroed(BATTLE_BUFFER_LINK_SIZE); gLinkBattleRecvBuffer = AllocZeroed(BATTLE_BUFFER_LINK_SIZE);
gUnknown_0202305C = AllocZeroed(0x2000); gBattleAnimBgTileBuffer = AllocZeroed(0x2000);
gUnknown_02023060 = AllocZeroed(0x1000); gBattleAnimBgTilemapBuffer = AllocZeroed(0x1000);
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE) if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
{ {
@ -66,8 +66,8 @@ void FreeBattleResources(void)
FREE_AND_SET_NULL(gLinkBattleSendBuffer); FREE_AND_SET_NULL(gLinkBattleSendBuffer);
FREE_AND_SET_NULL(gLinkBattleRecvBuffer); FREE_AND_SET_NULL(gLinkBattleRecvBuffer);
FREE_AND_SET_NULL(gUnknown_0202305C); FREE_AND_SET_NULL(gBattleAnimBgTileBuffer);
FREE_AND_SET_NULL(gUnknown_02023060); FREE_AND_SET_NULL(gBattleAnimBgTilemapBuffer);
} }
} }

View File

@ -1136,9 +1136,9 @@ static void AllocContestResources(void)
gContestResources->contestBgTilemaps[3] = AllocZeroed(0x1000); gContestResources->contestBgTilemaps[3] = AllocZeroed(0x1000);
gContestResources->boxBlinkTiles1 = AllocZeroed(0x800); gContestResources->boxBlinkTiles1 = AllocZeroed(0x800);
gContestResources->boxBlinkTiles2 = AllocZeroed(0x800); gContestResources->boxBlinkTiles2 = AllocZeroed(0x800);
gContestResources->field_3c = AllocZeroed(0x2000); gContestResources->animBgTileBuffer = AllocZeroed(0x2000);
gUnknown_0202305C = gContestResources->field_3c; gBattleAnimBgTileBuffer = gContestResources->animBgTileBuffer;
gUnknown_02023060 = gContestResources->contestBgTilemaps[1]; gBattleAnimBgTilemapBuffer = gContestResources->contestBgTilemaps[1];
} }
static void FreeContestResources(void) static void FreeContestResources(void)
@ -1158,10 +1158,10 @@ static void FreeContestResources(void)
FREE_AND_SET_NULL(gContestResources->contestBgTilemaps[3]); FREE_AND_SET_NULL(gContestResources->contestBgTilemaps[3]);
FREE_AND_SET_NULL(gContestResources->boxBlinkTiles1); FREE_AND_SET_NULL(gContestResources->boxBlinkTiles1);
FREE_AND_SET_NULL(gContestResources->boxBlinkTiles2); FREE_AND_SET_NULL(gContestResources->boxBlinkTiles2);
FREE_AND_SET_NULL(gContestResources->field_3c); FREE_AND_SET_NULL(gContestResources->animBgTileBuffer);
FREE_AND_SET_NULL(gContestResources); FREE_AND_SET_NULL(gContestResources);
gUnknown_0202305C = NULL; gBattleAnimBgTileBuffer = NULL;
gUnknown_02023060 = NULL; gBattleAnimBgTilemapBuffer = NULL;
} }
void CB2_StartContest(void) void CB2_StartContest(void)

View File

@ -454,7 +454,7 @@ const u8 *const gMatchCallFlavorTexts[REMATCH_TABLE_ENTRIES][CHECK_PAGE_ENTRY_CO
[REMATCH_TRENT] = MCFLAVOR(Hiker_Trent), [REMATCH_TRENT] = MCFLAVOR(Hiker_Trent),
[REMATCH_SAWYER] = MCFLAVOR(Hiker_Sawyer), [REMATCH_SAWYER] = MCFLAVOR(Hiker_Sawyer),
[REMATCH_KIRA_AND_DAN] = MCFLAVOR(YoungCouple_LoisAndHal), [REMATCH_KIRA_AND_DAN] = MCFLAVOR(YoungCouple_LoisAndHal),
[REMATCH_WALLY_3] = MCFLAVOR(PkmnTrainer_Wally), [REMATCH_WALLY_VR] = MCFLAVOR(PkmnTrainer_Wally),
[REMATCH_ROXANNE] = MCFLAVOR(RockinWhiz_Roxanne), [REMATCH_ROXANNE] = MCFLAVOR(RockinWhiz_Roxanne),
[REMATCH_BRAWLY] = MCFLAVOR(TheBigHit_Brawly), [REMATCH_BRAWLY] = MCFLAVOR(TheBigHit_Brawly),
[REMATCH_WATTSON] = MCFLAVOR(SwellShock_Wattson), [REMATCH_WATTSON] = MCFLAVOR(SwellShock_Wattson),

View File

@ -944,7 +944,7 @@ static void DisplayPartyPokemonDataToTeachMove(u8 slot, u16 item, u8 tutor)
static void DisplayPartyPokemonDataForMultiBattle(u8 slot) static void DisplayPartyPokemonDataForMultiBattle(u8 slot)
{ {
struct PartyMenuBox *menuBox = &sPartyMenuBoxes[slot]; struct PartyMenuBox *menuBox = &sPartyMenuBoxes[slot];
u8 actualSlot = slot - (3); u8 actualSlot = slot - MULTI_PARTY_SIZE;
if (gMultiPartnerParty[actualSlot].species == SPECIES_NONE) if (gMultiPartnerParty[actualSlot].species == SPECIES_NONE)
{ {
@ -6103,7 +6103,7 @@ static void SlideMultiPartyMenuBoxSpritesOneStep(u8 taskId)
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
u8 i; u8 i;
for (i = 3; i < PARTY_SIZE; i++) for (i = MULTI_PARTY_SIZE; i < PARTY_SIZE; i++)
{ {
if (gMultiPartnerParty[i - MULTI_PARTY_SIZE].species != SPECIES_NONE) if (gMultiPartnerParty[i - MULTI_PARTY_SIZE].species != SPECIES_NONE)
{ {

View File

@ -801,9 +801,9 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBattler]], BATTLER_AFFINE_EMERGE); StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBattler]], BATTLER_AFFINE_EMERGE);
if (GetBattlerSide(sprite->sBattler) == B_SIDE_OPPONENT) if (GetBattlerSide(sprite->sBattler) == B_SIDE_OPPONENT)
gSprites[gBattlerSpriteIds[sprite->sBattler]].callback = SpriteCb_OpponentMonFromBall; gSprites[gBattlerSpriteIds[sprite->sBattler]].callback = SpriteCB_OpponentMonFromBall;
else else
gSprites[gBattlerSpriteIds[sprite->sBattler]].callback = SpriteCb_PlayerMonFromBall; gSprites[gBattlerSpriteIds[sprite->sBattler]].callback = SpriteCB_PlayerMonFromBall;
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBattler]]); AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBattler]]);
gSprites[gBattlerSpriteIds[sprite->sBattler]].data[1] = 0x1000; gSprites[gBattlerSpriteIds[sprite->sBattler]].data[1] = 0x1000;

View File

@ -38,6 +38,7 @@
#include "constants/abilities.h" #include "constants/abilities.h"
#include "constants/battle_frontier.h" #include "constants/battle_frontier.h"
#include "constants/battle_move_effects.h" #include "constants/battle_move_effects.h"
#include "constants/battle_script_commands.h"
#include "constants/hold_effects.h" #include "constants/hold_effects.h"
#include "constants/item_effects.h" #include "constants/item_effects.h"
#include "constants/items.h" #include "constants/items.h"
@ -3103,7 +3104,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
if (!typeOverride) if (!typeOverride)
type = gBattleMoves[move].type; type = gBattleMoves[move].type;
else else
type = typeOverride & 0x3F; type = typeOverride & DYNAMIC_TYPE_MASK;
attack = attacker->attack; attack = attacker->attack;
defense = defender->defense; defense = defender->defense;

View File

@ -336,7 +336,7 @@ static const struct MatchCallWally sWallyMatchCallHeader =
.type = MC_TYPE_WALLY, .type = MC_TYPE_WALLY,
.mapSec = 0, .mapSec = 0,
.flag = FLAG_ENABLE_WALLY_MATCH_CALL, .flag = FLAG_ENABLE_WALLY_MATCH_CALL,
.rematchTableIdx = REMATCH_WALLY_3, .rematchTableIdx = REMATCH_WALLY_VR,
.desc = gText_WallyMatchCallDesc, .desc = gText_WallyMatchCallDesc,
.textData = sWallyTextScripts, .textData = sWallyTextScripts,
.locationData = sWallyLocationData .locationData = sWallyLocationData

View File

@ -65,7 +65,7 @@ struct RecordedBattleSave
u8 recordMixFriendName[PLAYER_NAME_LENGTH + 1]; u8 recordMixFriendName[PLAYER_NAME_LENGTH + 1];
u8 recordMixFriendClass; u8 recordMixFriendClass;
u8 apprenticeId; u8 apprenticeId;
u16 easyChatSpeech[6]; u16 easyChatSpeech[EASY_CHAT_BATTLE_WORDS_COUNT];
u8 recordMixFriendLanguage; u8 recordMixFriendLanguage;
u8 apprenticeLanguage; u8 apprenticeLanguage;
u8 battleRecord[MAX_BATTLERS_COUNT][BATTLER_RECORD_SIZE]; u8 battleRecord[MAX_BATTLERS_COUNT][BATTLER_RECORD_SIZE];
@ -93,11 +93,11 @@ EWRAM_DATA static struct Pokemon sSavedPlayerParty[PARTY_SIZE] = {0};
EWRAM_DATA static struct Pokemon sSavedOpponentParty[PARTY_SIZE] = {0}; EWRAM_DATA static struct Pokemon sSavedOpponentParty[PARTY_SIZE] = {0};
EWRAM_DATA static u16 sPlayerMonMoves[2][MAX_MON_MOVES] = {0}; EWRAM_DATA static u16 sPlayerMonMoves[2][MAX_MON_MOVES] = {0};
EWRAM_DATA static struct PlayerInfo sPlayers[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA static struct PlayerInfo sPlayers[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static bool8 sUnknown_0203CCD0 = 0; EWRAM_DATA static bool8 sIsPlaybackFinished = 0;
EWRAM_DATA static u8 sRecordMixFriendName[PLAYER_NAME_LENGTH + 1] = {0}; EWRAM_DATA static u8 sRecordMixFriendName[PLAYER_NAME_LENGTH + 1] = {0};
EWRAM_DATA static u8 sRecordMixFriendClass = 0; EWRAM_DATA static u8 sRecordMixFriendClass = 0;
EWRAM_DATA static u8 sApprenticeId = 0; EWRAM_DATA static u8 sApprenticeId = 0;
EWRAM_DATA static u16 sEasyChatSpeech[6] = {0}; EWRAM_DATA static u16 sEasyChatSpeech[EASY_CHAT_BATTLE_WORDS_COUNT] = {0};
EWRAM_DATA static u8 sBattleOutcome = 0; EWRAM_DATA static u8 sBattleOutcome = 0;
static u8 sRecordMixFriendLanguage; static u8 sRecordMixFriendLanguage;
@ -113,7 +113,7 @@ void RecordedBattle_Init(u8 mode)
s32 i, j; s32 i, j;
sRecordMode = mode; sRecordMode = mode;
sUnknown_0203CCD0 = FALSE; sIsPlaybackFinished = FALSE;
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{ {
@ -124,16 +124,14 @@ void RecordedBattle_Init(u8 mode)
if (mode == B_RECORD_MODE_RECORDING) if (mode == B_RECORD_MODE_RECORDING)
{ {
for (j = 0; j < BATTLER_RECORD_SIZE; j++) for (j = 0; j < BATTLER_RECORD_SIZE; j++)
{
sBattleRecords[i][j] = 0xFF; sBattleRecords[i][j] = 0xFF;
}
sBattleFlags = gBattleTypeFlags; sBattleFlags = gBattleTypeFlags;
sAI_Scripts = gBattleResources->ai->aiFlags; sAI_Scripts = gBattleResources->ai->aiFlags;
} }
} }
} }
void sub_8184E58(void) void RecordedBattle_SetTrainerInfo(void)
{ {
s32 i, j; s32 i, j;
@ -150,6 +148,7 @@ void sub_8184E58(void)
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
// Link recorded battle, record info for all trainers
u8 linkPlayersCount; u8 linkPlayersCount;
u8 text[30]; u8 text[30];
@ -163,6 +162,7 @@ void sub_8184E58(void)
sPlayers[i].battlerId = gLinkPlayers[i].id; sPlayers[i].battlerId = gLinkPlayers[i].id;
sPlayers[i].language = gLinkPlayers[i].language; sPlayers[i].language = gLinkPlayers[i].language;
// Record names
if (i < linkPlayersCount) if (i < linkPlayersCount)
{ {
StringCopy(text, gLinkPlayers[i].name); StringCopy(text, gLinkPlayers[i].name);
@ -178,6 +178,7 @@ void sub_8184E58(void)
} }
else else
{ {
// Local battle, just record own info
sPlayers[0].trainerId = (gSaveBlock2Ptr->playerTrainerId[0]) sPlayers[0].trainerId = (gSaveBlock2Ptr->playerTrainerId[0])
| (gSaveBlock2Ptr->playerTrainerId[1] << 8) | (gSaveBlock2Ptr->playerTrainerId[1] << 8)
| (gSaveBlock2Ptr->playerTrainerId[2] << 16) | (gSaveBlock2Ptr->playerTrainerId[2] << 16)
@ -195,9 +196,7 @@ void sub_8184E58(void)
void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action) void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action)
{ {
if (sBattlerRecordSizes[battlerId] < BATTLER_RECORD_SIZE && sRecordMode != B_RECORD_MODE_PLAYBACK) if (sBattlerRecordSizes[battlerId] < BATTLER_RECORD_SIZE && sRecordMode != B_RECORD_MODE_PLAYBACK)
{
sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]++] = action; sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]++] = action;
}
} }
void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear) void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear)
@ -220,7 +219,7 @@ u8 RecordedBattle_GetBattlerAction(u8 battlerId)
{ {
gSpecialVar_Result = gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; // hah gSpecialVar_Result = gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; // hah
ResetPaletteFadeControl(); ResetPaletteFadeControl();
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
SetMainCallback2(CB2_QuitRecordedBattle); SetMainCallback2(CB2_QuitRecordedBattle);
return 0xFF; return 0xFF;
} }
@ -249,9 +248,7 @@ u8 RecordedBattle_BufferNewBattlerData(u8 *dst)
dst[idx++] = sBattlerRecordSizes[i] - sBattlerPrevRecordSizes[i]; dst[idx++] = sBattlerRecordSizes[i] - sBattlerPrevRecordSizes[i];
for (j = 0; j < sBattlerRecordSizes[i] - sBattlerPrevRecordSizes[i]; j++) for (j = 0; j < sBattlerRecordSizes[i] - sBattlerPrevRecordSizes[i]; j++)
{
dst[idx++] = sBattleRecords[i][sBattlerPrevRecordSizes[i] + j]; dst[idx++] = sBattleRecords[i][sBattlerPrevRecordSizes[i] + j];
}
sBattlerPrevRecordSizes[i] = sBattlerRecordSizes[i]; sBattlerPrevRecordSizes[i] = sBattlerRecordSizes[i];
} }
@ -283,11 +280,9 @@ void RecordedBattle_RecordAllBattlerData(u8 *src)
u8 numActions = GetNextRecordedDataByte(src, &idx, &size); u8 numActions = GetNextRecordedDataByte(src, &idx, &size);
for (i = 0; i < numActions; i++) for (i = 0; i < numActions; i++)
{
sBattleRecords[battlerId][sBattlerSavedRecordSizes[battlerId]++] = GetNextRecordedDataByte(src, &idx, &size); sBattleRecords[battlerId][sBattlerSavedRecordSizes[battlerId]++] = GetNextRecordedDataByte(src, &idx, &size);
} }
} }
}
} }
static u8 GetNextRecordedDataByte(u8 *data, u8 *idx, u8 *size) static u8 GetNextRecordedDataByte(u8 *data, u8 *idx, u8 *size)
@ -318,7 +313,7 @@ static bool32 IsRecordedBattleSaveValid(struct RecordedBattleSave *save)
static bool32 RecordedBattleToSave(struct RecordedBattleSave *battleSave, struct RecordedBattleSave *saveSection) static bool32 RecordedBattleToSave(struct RecordedBattleSave *battleSave, struct RecordedBattleSave *saveSection)
{ {
memset(saveSection, 0, 0x1000); memset(saveSection, 0, SECTOR_SIZE);
memcpy(saveSection, battleSave, sizeof(*battleSave)); memcpy(saveSection, battleSave, sizeof(*battleSave));
saveSection->checksum = CalcByteArraySum((void*)(saveSection), sizeof(*saveSection) - 4); saveSection->checksum = CalcByteArraySum((void*)(saveSection), sizeof(*saveSection) - 4);
@ -338,7 +333,7 @@ bool32 MoveRecordedBattleToSaveData(void)
saveAttempts = 0; saveAttempts = 0;
battleSave = AllocZeroed(sizeof(struct RecordedBattleSave)); battleSave = AllocZeroed(sizeof(struct RecordedBattleSave));
savSection = AllocZeroed(0x1000); savSection = AllocZeroed(SECTOR_SIZE);
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
@ -349,9 +344,7 @@ bool32 MoveRecordedBattleToSaveData(void)
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{ {
for (j = 0; j < PLAYER_NAME_LENGTH + 1; j++) for (j = 0; j < PLAYER_NAME_LENGTH + 1; j++)
{
battleSave->playersName[i][j] = sPlayers[i].name[j]; battleSave->playersName[i][j] = sPlayers[i].name[j];
}
battleSave->playersGender[i] = sPlayers[i].gender; battleSave->playersGender[i] = sPlayers[i].gender;
battleSave->playersLanguage[i] = sPlayers[i].language; battleSave->playersLanguage[i] = sPlayers[i].language;
battleSave->playersBattlers[i] = sPlayers[i].battlerId; battleSave->playersBattlers[i] = sPlayers[i].battlerId;
@ -471,12 +464,8 @@ bool32 MoveRecordedBattleToSaveData(void)
} }
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
for (j = 0; j < BATTLER_RECORD_SIZE; j++) for (j = 0; j < BATTLER_RECORD_SIZE; j++)
{
battleSave->battleRecord[i][j] = sBattleRecords[i][j]; battleSave->battleRecord[i][j] = sBattleRecords[i][j];
}
}
while (1) while (1)
{ {
@ -585,29 +574,21 @@ static void SetVariablesForRecordedBattle(struct RecordedBattleSave *src)
sAI_Scripts = src->AI_scripts; sAI_Scripts = src->AI_scripts;
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++) for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
{
sRecordMixFriendName[i] = src->recordMixFriendName[i]; sRecordMixFriendName[i] = src->recordMixFriendName[i];
}
sRecordMixFriendClass = src->recordMixFriendClass; sRecordMixFriendClass = src->recordMixFriendClass;
sApprenticeId = src->apprenticeId; sApprenticeId = src->apprenticeId;
sRecordMixFriendLanguage = src->recordMixFriendLanguage; sRecordMixFriendLanguage = src->recordMixFriendLanguage;
sApprenticeLanguage = src->apprenticeLanguage; sApprenticeLanguage = src->apprenticeLanguage;
for (i = 0; i < 6; i++) for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++)
{
sEasyChatSpeech[i] = src->easyChatSpeech[i]; sEasyChatSpeech[i] = src->easyChatSpeech[i];
}
gSaveBlock2Ptr->frontier.lvlMode = src->lvlMode; gSaveBlock2Ptr->frontier.lvlMode = src->lvlMode;
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
for (j = 0; j < BATTLER_RECORD_SIZE; j++) for (j = 0; j < BATTLER_RECORD_SIZE; j++)
{
sBattleRecords[i][j] = src->battleRecord[i][j]; sBattleRecords[i][j] = src->battleRecord[i][j];
}
}
} }
void PlayRecordedBattle(void (*CB2_After)(void)) void PlayRecordedBattle(void (*CB2_After)(void))
@ -741,17 +722,20 @@ void sub_818603C(u8 arg0)
for (battlerId = 0; battlerId < gBattlersCount; battlerId++) for (battlerId = 0; battlerId < gBattlersCount; battlerId++)
{ {
if (GetBattlerSide(battlerId) != B_SIDE_OPPONENT) // player's side only // Player's side only
if (GetBattlerSide(battlerId) != B_SIDE_OPPONENT)
{ {
if (arg0 == 1) if (arg0 == 1)
{ {
// Check if any of the battler's moves have changed
for (j = 0; j < MAX_MON_MOVES; j++) for (j = 0; j < MAX_MON_MOVES; j++)
{ {
if (gBattleMons[battlerId].moves[j] != sPlayerMonMoves[battlerId / 2][j]) if (gBattleMons[battlerId].moves[j] != sPlayerMonMoves[battlerId / 2][j])
break; break;
} }
if (j != MAX_MON_MOVES) // player's mon's move has been changed if (j != MAX_MON_MOVES)
{ {
// At least one of the moves has been changed
RecordedBattle_SetBattlerAction(battlerId, ACTION_MOVE_CHANGE); RecordedBattle_SetBattlerAction(battlerId, ACTION_MOVE_CHANGE);
for (j = 0; j < MAX_MON_MOVES; j++) for (j = 0; j < MAX_MON_MOVES; j++)
{ {
@ -779,9 +763,8 @@ void sub_818603C(u8 arg0)
RecordedBattle_GetBattlerAction(battlerId); RecordedBattle_GetBattlerAction(battlerId);
for (j = 0; j < MAX_MON_MOVES; j++) for (j = 0; j < MAX_MON_MOVES; j++)
{ ppBonuses[j] = ((gBattleMons[battlerId].ppBonuses & (3 << (j << 1))) >> (j << 1));
ppBonuses[j] = ((gBattleMons[battlerId].ppBonuses & ((3 << (j << 1)))) >> (j << 1));
}
for (j = 0; j < MAX_MON_MOVES; j++) for (j = 0; j < MAX_MON_MOVES; j++)
{ {
array1[j] = RecordedBattle_GetBattlerAction(battlerId); array1[j] = RecordedBattle_GetBattlerAction(battlerId);
@ -806,9 +789,8 @@ void sub_818603C(u8 arg0)
if (!(gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED)) if (!(gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED))
{ {
for (j = 0; j < MAX_MON_MOVES; j++) for (j = 0; j < MAX_MON_MOVES; j++)
{
ppBonuses[j] = ((GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_PP_BONUSES, NULL) & ((3 << (j << 1)))) >> (j << 1)); ppBonuses[j] = ((GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_PP_BONUSES, NULL) & ((3 << (j << 1)))) >> (j << 1));
}
for (j = 0; j < MAX_MON_MOVES; j++) for (j = 0; j < MAX_MON_MOVES; j++)
{ {
movePp.moves[j] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_MOVE1 + array1[j], NULL); movePp.moves[j] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_MOVE1 + array1[j], NULL);
@ -822,12 +804,10 @@ void sub_818603C(u8 arg0)
} }
var = 0; var = 0;
for (j = 0; j < MAX_MON_MOVES; j++) for (j = 0; j < MAX_MON_MOVES; j++)
{
var |= (array3[j]) << (j << 1); var |= (array3[j]) << (j << 1);
}
SetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_PP_BONUSES, &var); SetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_PP_BONUSES, &var);
} }
gChosenMoveByBattler[battlerId] = gBattleMons[battlerId].moves[*(gBattleStruct->chosenMovePositions + battlerId)]; gChosenMoveByBattler[battlerId] = gBattleMons[battlerId].moves[*(gBattleStruct->chosenMovePositions + battlerId)];
} }
} }
@ -840,24 +820,24 @@ u32 GetAiScriptsInRecordedBattle(void)
return sAI_Scripts; return sAI_Scripts;
} }
void sub_8186444(void) // Used to determine when the player is allowed to press B to end a recorded battle's playback
void RecordedBattle_SetPlaybackFinished(void)
{ {
sUnknown_0203CCD0 = TRUE; sIsPlaybackFinished = TRUE;
} }
bool8 sub_8186450(void) bool8 RecordedBattle_CanStopPlayback(void)
{ {
return (sUnknown_0203CCD0 == FALSE); return (sIsPlaybackFinished == FALSE);
} }
void GetRecordedBattleRecordMixFriendName(u8 *dst) void GetRecordedBattleRecordMixFriendName(u8 *dst)
{ {
s32 i; s32 i;
for (i = 0; i < 8; i++) for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
dst[i] = sRecordMixFriendName[i]; dst[i] = sRecordMixFriendName[i];
dst[PLAYER_NAME_LENGTH] = EOS;
dst[7] = EOS;
ConvertInternationalString(dst, sRecordMixFriendLanguage); ConvertInternationalString(dst, sRecordMixFriendLanguage);
} }