Move all trainer defines to trainers.h and identify frontier brain trainer id

This commit is contained in:
DizzyEggg 2018-06-30 18:55:34 +02:00
parent bfc64c9689
commit 2d0be91217
15 changed files with 97 additions and 90 deletions

View File

@ -19881,7 +19881,7 @@ sub_81A4CB0: @ 81A4CB0
ands r0, r1 ands r0, r1
cmp r0, 0 cmp r0, 0
beq _081A4CD0 beq _081A4CD0
bl sub_8185EA0 bl GetRecordedBattleFrontierFacility
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
b _081A4CDA b _081A4CDA
@ -19893,7 +19893,7 @@ _081A4CD0:
lsrs r0, 16 lsrs r0, 16
_081A4CDA: _081A4CDA:
ldr r2, =gTrainers ldr r2, =gTrainers
ldr r1, =gUnknown_08611D30 ldr r1, =gFacilityToBrainTrainerId
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -19907,8 +19907,8 @@ _081A4CDA:
.pool .pool
thumb_func_end sub_81A4CB0 thumb_func_end sub_81A4CB0
thumb_func_start sub_81A4D00 thumb_func_start GetFrontierBrainTrainerClass
sub_81A4D00: @ 81A4D00 GetFrontierBrainTrainerClass: @ 81A4D00
push {lr} push {lr}
ldr r0, =gBattleTypeFlags ldr r0, =gBattleTypeFlags
ldr r0, [r0] ldr r0, [r0]
@ -19917,7 +19917,7 @@ sub_81A4D00: @ 81A4D00
ands r0, r1 ands r0, r1
cmp r0, 0 cmp r0, 0
beq _081A4D20 beq _081A4D20
bl sub_8185EA0 bl GetRecordedBattleFrontierFacility
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
b _081A4D2A b _081A4D2A
@ -19929,7 +19929,7 @@ _081A4D20:
lsrs r0, 16 lsrs r0, 16
_081A4D2A: _081A4D2A:
ldr r2, =gTrainers ldr r2, =gTrainers
ldr r1, =gUnknown_08611D30 ldr r1, =gFacilityToBrainTrainerId
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -19941,10 +19941,10 @@ _081A4D2A:
pop {r1} pop {r1}
bx r1 bx r1
.pool .pool
thumb_func_end sub_81A4D00 thumb_func_end GetFrontierBrainTrainerClass
thumb_func_start sub_81A4D50 thumb_func_start CopyFrontierBrainTrainerName
sub_81A4D50: @ 81A4D50 CopyFrontierBrainTrainerName: @ 81A4D50
push {r4,lr} push {r4,lr}
adds r4, r0, 0 adds r4, r0, 0
ldr r0, =gBattleTypeFlags ldr r0, =gBattleTypeFlags
@ -19954,7 +19954,7 @@ sub_81A4D50: @ 81A4D50
ands r0, r1 ands r0, r1
cmp r0, 0 cmp r0, 0
beq _081A4D70 beq _081A4D70
bl sub_8185EA0 bl GetRecordedBattleFrontierFacility
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
b _081A4D7A b _081A4D7A
@ -19968,7 +19968,7 @@ _081A4D7A:
movs r3, 0 movs r3, 0
lsls r0, 1 lsls r0, 1
ldr r2, =gTrainers ldr r2, =gTrainers
ldr r1, =gUnknown_08611D30 ldr r1, =gFacilityToBrainTrainerId
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
lsls r0, r1, 2 lsls r0, r1, 2
@ -19991,7 +19991,7 @@ _081A4D90:
pop {r0} pop {r0}
bx r0 bx r0
.pool .pool
thumb_func_end sub_81A4D50 thumb_func_end CopyFrontierBrainTrainerName
thumb_func_start sub_81A4DB8 thumb_func_start sub_81A4DB8
sub_81A4DB8: @ 81A4DB8 sub_81A4DB8: @ 81A4DB8
@ -20483,7 +20483,7 @@ sub_81A51A8: @ 81A51A8
ands r0, r1 ands r0, r1
cmp r0, 0 cmp r0, 0
beq _081A51D4 beq _081A51D4
bl sub_8185EA0 bl GetRecordedBattleFrontierFacility
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
bl sub_8185EAC bl sub_8185EAC

View File

@ -1479,7 +1479,7 @@ _08162C08:
ldr r0, =0x000003fe ldr r0, =0x000003fe
cmp r4, r0 cmp r4, r0
bne _08162C1C bne _08162C1C
bl sub_81A4D00 bl GetFrontierBrainTrainerClass
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
b _08162D1E b _08162D1E
@ -1729,7 +1729,7 @@ _08162E54:
cmp r5, r0 cmp r5, r0
bne _08162E68 bne _08162E68
adds r0, r6, 0 adds r0, r6, 0
bl sub_81A4D50 bl CopyFrontierBrainTrainerName
b _08162F62 b _08162F62
.pool .pool
_08162E68: _08162E68:

View File

@ -1,5 +1,6 @@
#include "constants/moves.h" #include "constants/moves.h"
#include "constants/species.h" #include "constants/species.h"
#include "constants/trainers.h"
.include "asm/macros.inc" .include "asm/macros.inc"
.include "constants/constants.inc" .include "constants/constants.inc"
@ -1049,8 +1050,10 @@ gUnknown_08611D08:: @ 8611D08
.4byte gUnknown_085EE3C4 .4byte gUnknown_085EE3C4
.align 1 .align 1
gUnknown_08611D30:: @ 8611D30 gFacilityToBrainTrainerId:: @ 8611D30
.2byte 0x0325, 0x0326, 0x0327, 0x0328, 0x0329, 0x032a, 0x032b, 0x0000 .2byte TRAINER_ANABEL, TRAINER_TUCKER, TRAINER_SPENSER
.2byte TRAINER_GRETA, TRAINER_NOLAND, TRAINER_LUCY
.2byte TRAINER_BRANDON
.align 2 .align 2
gUnknown_08611D40:: @ 8611D40 gUnknown_08611D40:: @ 8611D40

View File

@ -478,7 +478,7 @@ void DrawBattleEntryBackground(void)
} }
else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER)) else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{ {
if (!(gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || gPartnerTrainerId == STEVEN_PARTNER_ID) if (!(gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || gPartnerTrainerId == TRAINER_STEVEN_PARTNER)
{ {
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void*)(VRAM + 0x4000)); LZDecompressVram(gBattleTerrainAnimTiles_Building, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void*)(VRAM + 0xE000)); LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void*)(VRAM + 0xE000));

View File

@ -1232,7 +1232,7 @@ static void OpponentHandleDrawTrainerPic(void)
{ {
trainerPicId = GetSecretBaseTrainerPicIndex(); trainerPicId = GetSecretBaseTrainerPicIndex();
} }
else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE) else if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
{ {
trainerPicId = sub_81A4CB0(); trainerPicId = sub_81A4CB0();
} }
@ -1316,7 +1316,7 @@ static void OpponentHandleTrainerSlide(void)
{ {
trainerPicId = GetSecretBaseTrainerPicIndex(); trainerPicId = GetSecretBaseTrainerPicIndex();
} }
else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE) else if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
{ {
trainerPicId = sub_81A4CB0(); trainerPicId = sub_81A4CB0();
} }

View File

@ -15,6 +15,7 @@
#include "constants/songs.h" #include "constants/songs.h"
#include "sound.h" #include "sound.h"
#include "constants/moves.h" #include "constants/moves.h"
#include "constants/trainers.h"
#include "window.h" #include "window.h"
#include "m4a.h" #include "m4a.h"
#include "palette.h" #include "palette.h"
@ -2259,9 +2260,9 @@ static void DoSwitchOutAnimation(void)
} }
} }
// some explanation here // In emerald it's possible to have a tag battle in the battle frontier facilities with AI
// in emerald it's possible to have a tag battle in the battle frontier facilities with AI // which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven)
// which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven) that use the back pic as well as animate it // that use an animated back pic.
static void PlayerHandleDrawTrainerPic(void) static void PlayerHandleDrawTrainerPic(void)
{ {
s16 xPos, yPos; s16 xPos, yPos;
@ -2272,12 +2273,12 @@ static void PlayerHandleDrawTrainerPic(void)
if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_FIRE_RED if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_FIRE_RED
|| (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_LEAF_GREEN) || (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_LEAF_GREEN)
{ {
trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + BACK_PIC_RED; trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + TRAINER_BACK_PIC_RED;
} }
else if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_RUBY else if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_RUBY
|| (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_SAPPHIRE) || (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_SAPPHIRE)
{ {
trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + BACK_PIC_RS_BRENDAN; trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN;
} }
else else
{ {
@ -2296,7 +2297,7 @@ static void PlayerHandleDrawTrainerPic(void)
else // first mon else // first mon
xPos = 32; xPos = 32;
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId != STEVEN_PARTNER_ID) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId != TRAINER_STEVEN_PARTNER)
{ {
xPos = 90; xPos = 90;
yPos = (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 80; yPos = (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 80;
@ -2314,7 +2315,7 @@ static void PlayerHandleDrawTrainerPic(void)
} }
// Use front pic table for any tag battles unless your partner is Steven. // Use front pic table for any tag battles unless your partner is Steven.
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId != STEVEN_PARTNER_ID) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId != TRAINER_STEVEN_PARTNER)
{ {
trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender); trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender);
DecompressTrainerFrontPic(trainerPicId, gActiveBattler); DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
@ -2354,12 +2355,12 @@ static void PlayerHandleTrainerSlide(void)
if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_FIRE_RED if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_FIRE_RED
|| (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_LEAF_GREEN) || (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_LEAF_GREEN)
{ {
trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + BACK_PIC_RED; trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + TRAINER_BACK_PIC_RED;
} }
else if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_RUBY else if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_RUBY
|| (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_SAPPHIRE) || (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_SAPPHIRE)
{ {
trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + BACK_PIC_RS_BRENDAN; trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN;
} }
else else
{ {

View File

@ -11,6 +11,7 @@
#include "util.h" #include "util.h"
#include "main.h" #include "main.h"
#include "constants/songs.h" #include "constants/songs.h"
#include "constants/trainers.h"
#include "sound.h" #include "sound.h"
#include "window.h" #include "window.h"
#include "m4a.h" #include "m4a.h"
@ -1308,9 +1309,9 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
s16 xPos, yPos; s16 xPos, yPos;
u32 trainerPicId; u32 trainerPicId;
if (gPartnerTrainerId == STEVEN_PARTNER_ID) if (gPartnerTrainerId == TRAINER_STEVEN_PARTNER)
{ {
trainerPicId = BACK_PIC_STEVEN; trainerPicId = TRAINER_BACK_PIC_STEVEN;
xPos = 90; xPos = 90;
yPos = (8 - gTrainerBackPicCoords[trainerPicId].coords) * 4 + 80; yPos = (8 - gTrainerBackPicCoords[trainerPicId].coords) * 4 + 80;
} }
@ -1322,7 +1323,7 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
} }
// Use back pic only if the partner is Steven // Use back pic only if the partner is Steven
if (gPartnerTrainerId == STEVEN_PARTNER_ID) if (gPartnerTrainerId == TRAINER_STEVEN_PARTNER)
{ {
DecompressTrainerBackPic(trainerPicId, gActiveBattler); DecompressTrainerBackPic(trainerPicId, gActiveBattler);
sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler));
@ -1793,9 +1794,9 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void)
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F9); paletteNum = AllocSpritePalette(0xD6F9);
if (gPartnerTrainerId == STEVEN_PARTNER_ID) if (gPartnerTrainerId == TRAINER_STEVEN_PARTNER)
{ {
u8 spriteId = BACK_PIC_STEVEN; u8 spriteId = TRAINER_BACK_PIC_STEVEN;
LoadCompressedPalette(gTrainerBackPicPaletteTable[spriteId].data, 0x100 + paletteNum * 16, 32); LoadCompressedPalette(gTrainerBackPicPaletteTable[spriteId].data, 0x100 + paletteNum * 16, 32);
} }
else else

View File

@ -15,6 +15,7 @@
#include "constants/songs.h" #include "constants/songs.h"
#include "sound.h" #include "sound.h"
#include "constants/moves.h" #include "constants/moves.h"
#include "constants/trainers.h"
#include "window.h" #include "window.h"
#include "m4a.h" #include "m4a.h"
#include "palette.h" #include "palette.h"
@ -1037,11 +1038,11 @@ static void WallyHandleReturnMonToBall(void)
static void WallyHandleDrawTrainerPic(void) static void WallyHandleDrawTrainerPic(void)
{ {
DecompressTrainerBackPic(BACK_PIC_WALLY, gActiveBattler); DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler);
sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); sub_806A12C(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
80, 80,
80 + 4 * (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords), 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].coords),
30); 30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
@ -1052,11 +1053,11 @@ static void WallyHandleDrawTrainerPic(void)
static void WallyHandleTrainerSlide(void) static void WallyHandleTrainerSlide(void)
{ {
DecompressTrainerBackPic(BACK_PIC_WALLY, gActiveBattler); DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler);
sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); sub_806A12C(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
80, 80,
80 + 4 * (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords), 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].coords),
30); 30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -96; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -96;
@ -1444,7 +1445,7 @@ static void WallyHandleIntroTrainerBallThrow(void)
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F8); paletteNum = AllocSpritePalette(0xD6F8);
LoadCompressedPalette(gTrainerBackPicPaletteTable[BACK_PIC_WALLY].data, 0x100 + paletteNum * 16, 32); LoadCompressedPalette(gTrainerBackPicPaletteTable[TRAINER_BACK_PIC_WALLY].data, 0x100 + paletteNum * 16, 32);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(sub_816AC04, 5); taskId = CreateTask(sub_816AC04, 5);

View File

@ -614,7 +614,7 @@ static void CB2_InitBattleInternal(void)
gBattle_WIN0H = 240; gBattle_WIN0H = 240;
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId != STEVEN_PARTNER_ID) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId != TRAINER_STEVEN_PARTNER)
{ {
gBattle_WIN0V = 159; gBattle_WIN0V = 159;
gBattle_WIN1H = 240; gBattle_WIN1H = 240;
@ -1914,7 +1914,7 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir
s32 i, j; s32 i, j;
u8 monsCount; u8 monsCount;
if (trainerNum == SECRET_BASE_OPPONENT) if (trainerNum == TRAINER_SECRET_BASE)
return 0; return 0;
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & (BATTLE_TYPE_FRONTIER if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & (BATTLE_TYPE_FRONTIER
@ -4982,7 +4982,7 @@ static void HandleEndTurn_BattleWon(void)
BattleStopLowHpSound(); BattleStopLowHpSound();
gBattlescriptCurrInstr = BattleScript_FrontierTrainerBattleWon; gBattlescriptCurrInstr = BattleScript_FrontierTrainerBattleWon;
if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE) if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
PlayBGM(MUS_KACHI3); PlayBGM(MUS_KACHI3);
else else
PlayBGM(MUS_KACHI1); PlayBGM(MUS_KACHI1);

View File

@ -33,7 +33,7 @@ struct BattleWindowText
extern u8 gUnknown_0203C7B4; extern u8 gUnknown_0203C7B4;
extern const u8 gMoveNames[LAST_MOVE_INDEX + 1][13]; extern const u8 gMoveNames[MOVES_COUNT][13];
extern const u8 gTrainerClassNames[][13]; extern const u8 gTrainerClassNames[][13];
extern const u16 gUnknown_08D85620[]; extern const u16 gUnknown_08D85620[];
@ -43,11 +43,11 @@ extern const u8 gText_PkmnBoxLanettesPCFull[];
extern const u8 gText_PkmnTransferredSomeonesPC[]; extern const u8 gText_PkmnTransferredSomeonesPC[];
extern const u8 gText_PkmnTransferredLanettesPC[]; extern const u8 gText_PkmnTransferredLanettesPC[];
extern u8 sub_81A4D00(void); // battle_frontier_2 extern u8 GetFrontierBrainTrainerClass(void); // battle_frontier_2
extern u8 GetFrontierOpponentClass(u16 trainerId); // battle_tower extern u8 GetFrontierOpponentClass(u16 trainerId); // battle_tower
extern u8 sub_81D5530(u16 trainerId); // pokenav extern u8 sub_81D5530(u16 trainerId); // pokenav
extern u8 GetEreaderTrainerClassId(void); // battle_tower extern u8 GetEreaderTrainerClassId(void); // battle_tower
extern void sub_81A4D50(u8 *txtPtr); // battle_frontier_2 extern void CopyFrontierBrainTrainerName(u8 *txtPtr); // battle_frontier_2
extern void sub_81D5554(u8 *txtPtr, u16 trainerId); // pokenav extern void sub_81D5554(u8 *txtPtr, u16 trainerId); // pokenav
extern void GetEreaderTrainerName(u8 *txtPtr); extern void GetEreaderTrainerName(u8 *txtPtr);
extern void sub_81A36D0(u8 arg0, u16 trainerId); // battle_frontier_2 extern void sub_81A36D0(u8 arg0, u16 trainerId); // battle_frontier_2
@ -2139,7 +2139,7 @@ void BufferStringBattle(u16 stringID)
case STRINGID_USEDMOVE: // pokemon used a move msg case STRINGID_USEDMOVE: // pokemon used a move msg
ChooseMoveUsedParticle(gBattleTextBuff1); // buff1 doesn't appear in the string, leftover from japanese move names ChooseMoveUsedParticle(gBattleTextBuff1); // buff1 doesn't appear in the string, leftover from japanese move names
if (gBattleMsgDataPtr->currentMove > LAST_MOVE_INDEX) if (gBattleMsgDataPtr->currentMove >= MOVES_COUNT)
StringCopy(gBattleTextBuff2, sATypeMove_Table[*(&gBattleStruct->stringMoveType)]); StringCopy(gBattleTextBuff2, sATypeMove_Table[*(&gBattleStruct->stringMoveType)]);
else else
StringCopy(gBattleTextBuff2, gMoveNames[gBattleMsgDataPtr->currentMove]); StringCopy(gBattleTextBuff2, gMoveNames[gBattleMsgDataPtr->currentMove]);
@ -2427,13 +2427,13 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler, gBattlerPartyIndexes[gBattleScripting.battler]) HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler, gBattlerPartyIndexes[gBattleScripting.battler])
break; break;
case B_TXT_CURRENT_MOVE: // current move name case B_TXT_CURRENT_MOVE: // current move name
if (gBattleMsgDataPtr->currentMove > LAST_MOVE_INDEX) if (gBattleMsgDataPtr->currentMove >= MOVES_COUNT)
toCpy = sATypeMove_Table[gBattleStruct->stringMoveType]; toCpy = sATypeMove_Table[gBattleStruct->stringMoveType];
else else
toCpy = gMoveNames[gBattleMsgDataPtr->currentMove]; toCpy = gMoveNames[gBattleMsgDataPtr->currentMove];
break; break;
case B_TXT_LAST_MOVE: // originally used move name case B_TXT_LAST_MOVE: // originally used move name
if (gBattleMsgDataPtr->originallyUsedMove > LAST_MOVE_INDEX) if (gBattleMsgDataPtr->originallyUsedMove >= MOVES_COUNT)
toCpy = sATypeMove_Table[gBattleStruct->stringMoveType]; toCpy = sATypeMove_Table[gBattleStruct->stringMoveType];
else else
toCpy = gMoveNames[gBattleMsgDataPtr->originallyUsedMove]; toCpy = gMoveNames[gBattleMsgDataPtr->originallyUsedMove];
@ -2501,8 +2501,8 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
toCpy = gTrainerClassNames[GetSecretBaseTrainerClass()]; toCpy = gTrainerClassNames[GetSecretBaseTrainerClass()];
else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00) else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
toCpy = gTrainerClassNames[sub_8068BB0()]; toCpy = gTrainerClassNames[sub_8068BB0()];
else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE) else if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
toCpy = gTrainerClassNames[sub_81A4D00()]; toCpy = gTrainerClassNames[GetFrontierBrainTrainerClass()];
else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
toCpy = gTrainerClassNames[GetFrontierOpponentClass(gTrainerBattleOpponent_A)]; toCpy = gTrainerClassNames[GetFrontierOpponentClass(gTrainerBattleOpponent_A)];
else if (gBattleTypeFlags & BATTLE_TYPE_x4000000) else if (gBattleTypeFlags & BATTLE_TYPE_x4000000)
@ -2525,9 +2525,9 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
{ {
toCpy = gLinkPlayers[multiplayerID ^ BIT_SIDE].name; toCpy = gLinkPlayers[multiplayerID ^ BIT_SIDE].name;
} }
else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE) else if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
{ {
sub_81A4D50(text); CopyFrontierBrainTrainerName(text);
toCpy = text; toCpy = text;
} }
else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER)

View File

@ -3533,7 +3533,7 @@ static void atk24(void)
if (gBattleControllerExecFlags) if (gBattleControllerExecFlags)
return; return;
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId == STEVEN_PARTNER_ID) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId == TRAINER_STEVEN_PARTNER)
{ {
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
@ -5870,7 +5870,7 @@ static u32 GetTrainerMoneyToGive(u16 trainerId)
u32 lastMonLevel = 0; u32 lastMonLevel = 0;
u32 moneyReward = 0; u32 moneyReward = 0;
if (trainerId == SECRET_BASE_OPPONENT) if (trainerId == TRAINER_SECRET_BASE)
{ {
moneyReward = 20 * gBattleResources->secretBase->party.levels[0] * gBattleStruct->moneyMultiplier; moneyReward = 20 * gBattleResources->secretBase->party.levels[0] * gBattleStruct->moneyMultiplier;
} }
@ -8124,7 +8124,7 @@ static void atk9E_metronome(void)
s32 i; s32 i;
gCurrentMove = (Random() & 0x1FF) + 1; gCurrentMove = (Random() & 0x1FF) + 1;
if (gCurrentMove > LAST_MOVE_INDEX) if (gCurrentMove >= MOVES_COUNT)
continue; continue;
for (i = 0; i < 4; i++); // ? for (i = 0; i < 4; i++); // ?

View File

@ -798,7 +798,7 @@ static u8 GetTrainerBattleTransition(void)
u8 enemyLevel; u8 enemyLevel;
u8 playerLevel; u8 playerLevel;
if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE)
return B_TRANSITION_CHAMPION; return B_TRANSITION_CHAMPION;
if (gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_ELITE_FOUR) if (gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_ELITE_FOUR)
@ -1305,7 +1305,7 @@ void BattleSetup_StartTrainerBattle(void)
static void CB2_EndTrainerBattle(void) static void CB2_EndTrainerBattle(void)
{ {
if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE)
{ {
SetMainCallback2(CB2_ReturnToFieldContinueScript); SetMainCallback2(CB2_ReturnToFieldContinueScript);
} }
@ -1329,7 +1329,7 @@ static void CB2_EndTrainerBattle(void)
static void CB2_EndRematchBattle(void) static void CB2_EndRematchBattle(void)
{ {
if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE)
{ {
SetMainCallback2(CB2_ReturnToFieldContinueScript); SetMainCallback2(CB2_ReturnToFieldContinueScript);
} }
@ -1497,7 +1497,7 @@ const u8 *GetTrainerALoseText(void)
{ {
const u8 *string; const u8 *string;
if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE)
string = GetSecretBaseTrainerLoseText(); string = GetSecretBaseTrainerLoseText();
else else
string = sTrainerADefeatSpeech; string = sTrainerADefeatSpeech;

View File

@ -2488,7 +2488,7 @@ static bool8 ShouldGetStatBadgeBoost(u16 badgeFlag, u8 battlerId)
return FALSE; return FALSE;
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER) if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
return FALSE; return FALSE;
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gTrainerBattleOpponent_A == TRAINER_SECRET_BASE)
return FALSE; return FALSE;
if (FlagGet(badgeFlag)) if (FlagGet(badgeFlag))
return TRUE; return TRUE;
@ -5678,7 +5678,7 @@ const u8 *GetTrainerPartnerName(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
{ {
if (gPartnerTrainerId == STEVEN_PARTNER_ID) if (gPartnerTrainerId == TRAINER_STEVEN_PARTNER)
{ {
return gTrainers[TRAINER_STEVEN].trainerName; return gTrainers[TRAINER_STEVEN].trainerName;
} }
@ -5891,15 +5891,15 @@ void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality)
const u8 *GetTrainerClassNameFromId(u16 trainerId) const u8 *GetTrainerClassNameFromId(u16 trainerId)
{ {
if (trainerId > NO_OF_TRAINERS) if (trainerId >= TRAINERS_COUNT)
trainerId = 0; trainerId = TRAINER_NONE;
return gTrainerClassNames[gTrainers[trainerId].trainerClass]; return gTrainerClassNames[gTrainers[trainerId].trainerClass];
} }
const u8 *GetTrainerNameFromId(u16 trainerId) const u8 *GetTrainerNameFromId(u16 trainerId)
{ {
if (trainerId > NO_OF_TRAINERS) if (trainerId >= TRAINERS_COUNT)
trainerId = 0; trainerId = TRAINER_NONE;
return gTrainers[trainerId].trainerName; return gTrainers[trainerId].trainerName;
} }

View File

@ -79,7 +79,7 @@ EWRAM_DATA static u16 sUnknown_0203C79C[4] = {0};
EWRAM_DATA static u16 sUnknown_0203C7A4[4] = {0}; EWRAM_DATA static u16 sUnknown_0203C7A4[4] = {0};
EWRAM_DATA static u8 sUnknown_0203C7AC = 0; EWRAM_DATA static u8 sUnknown_0203C7AC = 0;
EWRAM_DATA static u8 sUnknown_0203C7AD = 0; EWRAM_DATA static u8 sUnknown_0203C7AD = 0;
EWRAM_DATA static u8 sUnknown_0203C7AE = 0; EWRAM_DATA static u8 sRecordedBattle_FrontierFacility = 0;
EWRAM_DATA static u8 sUnknown_0203C7AF = 0; EWRAM_DATA static u8 sUnknown_0203C7AF = 0;
EWRAM_DATA static MainCallback sCallback2_AfterRecordedBattle = NULL; EWRAM_DATA static MainCallback sCallback2_AfterRecordedBattle = NULL;
EWRAM_DATA u8 gUnknown_0203C7B4 = 0; EWRAM_DATA u8 gUnknown_0203C7B4 = 0;
@ -139,7 +139,7 @@ void sub_8184E58(void)
if (sUnknown_0203C7AC == 1) if (sUnknown_0203C7AC == 1)
{ {
gRecordedBattleRngSeed = gRngValue; gRecordedBattleRngSeed = gRngValue;
sUnknown_0203C7AE = VarGet(VAR_FRONTIER_FACILITY); sRecordedBattle_FrontierFacility = VarGet(VAR_FRONTIER_FACILITY);
sUnknown_0203C7AF = sub_81A513C(); sUnknown_0203C7AF = sub_81A513C();
} }
else if (sUnknown_0203C7AC == 2) else if (sUnknown_0203C7AC == 2)
@ -391,7 +391,7 @@ u32 MoveRecordedBattleToSaveData(void)
battleSave->partnerId = gPartnerTrainerId; battleSave->partnerId = gPartnerTrainerId;
battleSave->field_4FA = gUnknown_0203C7B4; battleSave->field_4FA = gUnknown_0203C7B4;
battleSave->field_4FC = gSaveBlock2Ptr->field_CA9_b; battleSave->field_4FC = gSaveBlock2Ptr->field_CA9_b;
battleSave->field_4FD = sUnknown_0203C7AE; battleSave->field_4FD = sRecordedBattle_FrontierFacility;
battleSave->field_4FE = sUnknown_0203C7AF; battleSave->field_4FE = sUnknown_0203C7AF;
battleSave->battleStyle = gSaveBlock2Ptr->optionsBattleStyle; battleSave->battleStyle = gSaveBlock2Ptr->optionsBattleStyle;
battleSave->textSpeed = gSaveBlock2Ptr->optionsTextSpeed; battleSave->textSpeed = gSaveBlock2Ptr->optionsTextSpeed;
@ -700,7 +700,7 @@ _081854E2:\n\
ldr r5, =0x000004fc\n\ ldr r5, =0x000004fc\n\
adds r1, r7, r5\n\ adds r1, r7, r5\n\
strb r0, [r1]\n\ strb r0, [r1]\n\
ldr r0, =sUnknown_0203C7AE\n\ ldr r0, =sRecordedBattle_FrontierFacility\n\
ldrb r1, [r0]\n\ ldrb r1, [r0]\n\
adds r2, 0x3\n\ adds r2, 0x3\n\
adds r0, r7, r2\n\ adds r0, r7, r2\n\
@ -1354,7 +1354,7 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src)
gPartnerTrainerId = src->partnerId; gPartnerTrainerId = src->partnerId;
gUnknown_0203C7B4 = src->field_4FA; gUnknown_0203C7B4 = src->field_4FA;
sUnknown_0203C7AD = gSaveBlock2Ptr->frontierChosenLvl; sUnknown_0203C7AD = gSaveBlock2Ptr->frontierChosenLvl;
sUnknown_0203C7AE = src->field_4FD; sRecordedBattle_FrontierFacility = src->field_4FD;
sUnknown_0203C7AF = src->field_4FE; sUnknown_0203C7AF = src->field_4FE;
sRecordedBattle_BattleStyle = src->battleStyle; sRecordedBattle_BattleStyle = src->battleStyle;
sRecordedBattle_TextSpeed = src->textSpeed; sRecordedBattle_TextSpeed = src->textSpeed;
@ -1415,9 +1415,9 @@ static void CB2_RecordedBattle(void)
RunTasks(); RunTasks();
} }
u8 sub_8185EA0(void) u8 GetRecordedBattleFrontierFacility(void)
{ {
return sUnknown_0203C7AE; return sRecordedBattle_FrontierFacility;
} }
u8 sub_8185EAC(void) u8 sub_8185EAC(void)

View File

@ -11,6 +11,7 @@
#include "link.h" #include "link.h"
#include "sprite.h" #include "sprite.h"
#include "constants/species.h" #include "constants/species.h"
#include "constants/trainers.h"
#include "battle_interface.h" #include "battle_interface.h"
#include "battle_anim.h" #include "battle_anim.h"
#include "data2.h" #include "data2.h"
@ -144,20 +145,20 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
break; break;
case 19: case 19:
{ {
u8 opponentBank; u8 opponentBattler;
u16 species; u16 species;
LoadAndCreateEnemyShadowSprites(); LoadAndCreateEnemyShadowSprites();
opponentBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); opponentBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBank]], MON_DATA_SPECIES); species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBattler]], MON_DATA_SPECIES);
SetBattlerShadowSpriteCallback(opponentBank, species); SetBattlerShadowSpriteCallback(opponentBattler, species);
if (IsDoubleBattle()) if (IsDoubleBattle())
{ {
opponentBank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); opponentBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBank]], MON_DATA_SPECIES); species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBattler]], MON_DATA_SPECIES);
SetBattlerShadowSpriteCallback(opponentBank, species); SetBattlerShadowSpriteCallback(opponentBattler, species);
} }
ActionSelectionCreateCursorAt(gActionSelectionCursor[gBattlerInMenuId], 0); ActionSelectionCreateCursorAt(gActionSelectionCursor[gBattlerInMenuId], 0);
@ -204,10 +205,10 @@ static bool8 LoadBattlerSpriteGfx(u8 battler)
else else
BattleLoadSubstituteOrMonSpriteGfx(battler, FALSE); BattleLoadSubstituteOrMonSpriteGfx(battler, FALSE);
} }
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0) else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == B_POSITION_PLAYER_LEFT) // Should be checking position, not battler.
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, battler); DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, battler);
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0) else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == B_POSITION_PLAYER_LEFT) // Should be checking position, not battler.
DecompressTrainerBackPic(BACK_PIC_WALLY, battler); DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, battler);
else if (!gBattleSpritesDataPtr->battlerData[battler].behindSubstitute) else if (!gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battler]], battler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
else else
@ -245,7 +246,7 @@ static void CreateBattlerSprite(u8 battler)
if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies == SPECIES_CASTFORM) if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies == SPECIES_CASTFORM)
gSprites[gBattlerSpriteIds[battler]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM]; gSprites[gBattlerSpriteIds[battler]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM];
} }
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0) else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == B_POSITION_PLAYER_LEFT)
{ {
sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT)); sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT));
gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, 0x50, gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, 0x50,
@ -255,11 +256,11 @@ static void CreateBattlerSprite(u8 battler)
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battler]].data[0] = battler; gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
} }
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0) else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == B_POSITION_PLAYER_LEFT)
{ {
sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(0)); sub_806A12C(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(0));
gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, 0x50, gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, 0x50,
(8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords) * 4 + 80, (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].coords) * 4 + 80,
sub_80A82E4(0)); sub_80A82E4(0));
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler; gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
@ -292,9 +293,9 @@ static void CreateHealthboxSprite(u8 battler)
{ {
u8 healthboxSpriteId; u8 healthboxSpriteId;
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0) if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == B_POSITION_PLAYER_LEFT)
healthboxSpriteId = CreateSafariPlayerHealthboxSprites(); healthboxSpriteId = CreateSafariPlayerHealthboxSprites();
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0) else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == B_POSITION_PLAYER_LEFT)
return; return;
else else
healthboxSpriteId = CreateBattlerHealthboxSprites(battler); healthboxSpriteId = CreateBattlerHealthboxSprites(battler);