Unify ChooseMoveStruct; name BattleStruct fields

This commit is contained in:
PikalaxALT 2021-07-01 17:54:51 -04:00
parent d7018c1149
commit 4c2dce093c
18 changed files with 289 additions and 264 deletions

View File

@ -310,6 +310,15 @@ struct LinkBattleCommunicationHeader
u8 data[0];
};
struct ChooseMoveStruct {
u16 moves[4];
u8 currentPp[4];
u8 maxPp[4];
u16 species;
u8 monType1;
u8 monType2;
};
struct BattleStruct /* 0x2000000 */
{
u8 filler00000[0x14000];
@ -325,9 +334,9 @@ struct BattleStruct /* 0x2000000 */
/*0x1600E*/ u8 turnCountersTracker;
/*0x1600F*/ u8 getexpStateTracker;
/*0x16010*/ u8 moveTarget[MAX_BATTLERS_COUNT];
/*0x16014*/ u32 unk16014;
/*0x16014*/ u32 painSplitHP;
/*0x16018*/ u8 expGetterMonId;
/*0x16019*/ u8 unk16019;
/*0x16019*/ u8 unk16019; // unused
/*0x1601A*/ u8 atk5A_StateTracker; //also atk5B, statetracker
/*0x1601B*/ u8 wildVictorySong;
/*0x1601C*/ u8 dynamicMoveType;
@ -336,18 +345,17 @@ struct BattleStruct /* 0x2000000 */
/*0x1601F*/ u8 dmgMultiplier;
/*0x16020*/ u8 wrappedBy[MAX_BATTLERS_COUNT];
/*0x16024*/ u16 assistMove[PARTY_SIZE * MAX_MON_MOVES];
/*0x16054*/ u8 unk16054;
/*0x16055*/ u8 unk16055;
/*0x16054*/ u8 battlerPreventingSwitchout;
/*0x16055*/ u8 unk16055; // unused
/*0x16056*/ u8 moneyMultiplier;
/*0x16057*/ u8 unk16057;
/*0x16058*/ u8 unk16058;
/*0x16059*/ u8 sub80173A4_Tracker;
/*0x1605A*/ u8 unk1605A;
/*0x1605B*/ u8 unk1605B;
/*0x16057*/ u8 savedTurnActionNumber;
/*0x16058*/ u8 switchInAbilitiesCounter;
/*0x16059*/ u8 faintedActionsState;
/*0x1605A*/ u8 faintedActionsBattlerId;
/*0x1605C*/ u16 exp;
/*0x1605E*/ u8 unk1605E;
/*0x1605F*/ u8 sentInPokes;
/*0x16060*/ u8 unk16060[MAX_BATTLERS_COUNT];
/*0x16060*/ u8 selectionScriptFinished[MAX_BATTLERS_COUNT];
/*0x16064*/ u8 unk16064[MAX_BATTLERS_COUNT];
/*0x16068*/ u8 monToSwitchIntoId[MAX_BATTLERS_COUNT];
/*0x1606C*/ u8 unk1606C[MAX_BATTLERS_COUNT][3];
@ -359,26 +367,23 @@ struct BattleStruct /* 0x2000000 */
/*0x16087*/ u8 safariPkblThrowCounter;
/*0x16088*/ u8 safariFleeRate;
/*0x16089*/ u8 safariCatchFactor;
/*0x1608A*/ u8 unk1608A;
/*0x1608B*/ u8 unk1608B;
/*0x1608A*/ u8 linkBattleVsSpriteId_V;
/*0x1608B*/ u8 linkBattleVsSpriteId_S;
/*0x1608C*/ u8 ChosenMoveID[MAX_BATTLERS_COUNT];
/*0x16090*/ s32 bideDmg;
/*0x16094*/ u8 unk16094[4];
/*0x16098*/ u8 unk16098;
/*0x16099*/ u8 unk16099;
/*0x1609A*/ u8 unk1609a;
/*0x16094*/ u8 stateIdAfterSelScript[4];
/*0x16098*/ u8 unk16098[3]; // unused
/*0x1609B*/ u8 castformToChangeInto;
/*0x1609C*/ u8 atk6C_statetracker;
/*0x1609D*/ u8 unk1609D;
/*0x1609E*/ u8 unk1609E;
/*0x1609F*/ u8 unk1609F;
/*0x1609E*/ u8 unk1609E[2]; // debug
/*0x160A0*/ u8 stringMoveType;
/*0x160A1*/ u8 animTargetsHit;
/*0x160A2*/ u8 expGetterBattlerId;
/*0x160A3*/ u8 unk160A3;
/*0x160A4*/ u8 animArg1;
/*0x160A5*/ u8 animArg2;
/*0x160A6*/ u8 unk160A6;
/*0x160A6*/ u8 unk160A6; // related to gAbsentBattlerFlags, possibly absent flags turn ago?
/*0x160A7*/ u8 unk160A7;
/*0x160A8*/ u8 unk160A8;
/*0x160A9*/ u8 unk160A9;
@ -386,7 +391,7 @@ struct BattleStruct /* 0x2000000 */
/*0x160AB*/ u8 unk160AB;
/*0x160AC*/ u16 lastTakenMove[2 * 2 * 2];
/*0x160BC*/ u16 HP_OnSwitchout[2];
/*0x160C0*/ u8 unk160C0;
/*0x160C0*/ u8 abilityPreventingSwitchout;
/*0x160C1*/ u8 hpScale;
/*0x160C2*/ u16 unk160C2;
/*0x160C4*/ MainCallback unk160C4;

View File

@ -18,6 +18,50 @@ struct StringInfoBattle
u8 textBuffs[3][0x10];
};
#define B_TXT_BUFF1 0x0
#define B_TXT_BUFF2 0x1
#define B_TXT_PLAYER_MON1_NAME 0x2
#define B_TXT_OPPONENT_MON1_NAME 0x3
#define B_TXT_PLAYER_MON2_NAME 0x4
#define B_TXT_OPPONENT_MON2_NAME 0x5
#define B_TXT_LINK_PLAYER_MON1_NAME 0x6
#define B_TXT_LINK_OPPONENT_MON1_NAME 0x7
#define B_TXT_LINK_PLAYER_MON2_NAME 0x8
#define B_TXT_LINK_OPPONENT_MON2_NAME 0x9
#define B_TXT_ATK_NAME_WITH_PREFIX_MON1 0xA
#define B_TXT_ATK_PARTNER_NAME 0xB
#define B_TXT_ATK_NAME_WITH_PREFIX 0xC
#define B_TXT_DEF_NAME_WITH_PREFIX 0xD
#define B_TXT_EFF_NAME_WITH_PREFIX 0xE // EFF = short for gEffectBank
#define B_TXT_ACTIVE_NAME_WITH_PREFIX 0xF
#define B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX 0x10
#define B_TXT_CURRENT_MOVE 0x11
#define B_TXT_LAST_MOVE 0x12
#define B_TXT_LAST_ITEM 0x13
#define B_TXT_LAST_ABILITY 0x14
#define B_TXT_ATK_ABILITY 0x15
#define B_TXT_DEF_ABILITY 0x16
#define B_TXT_SCR_ACTIVE_ABILITY 0x17
#define B_TXT_EFF_ABILITY 0x18
#define B_TXT_TRAINER1_CLASS 0x19
#define B_TXT_TRAINER1_NAME 0x1A
#define B_TXT_LINK_PLAYER_NAME 0x1B
#define B_TXT_LINK_PARTNER_NAME 0x1C
#define B_TXT_LINK_OPPONENT1_NAME 0x1D
#define B_TXT_LINK_OPPONENT2_NAME 0x1E
#define B_TXT_LINK_SCR_TRAINER_NAME 0x1F
#define B_TXT_PLAYER_NAME 0x20
#define B_TXT_TRAINER1_LOSE_TEXT 0x21
#define B_TXT_22 0x22
#define B_TXT_PC_CREATOR_NAME 0x23
#define B_TXT_ATK_PREFIX1 0x24
#define B_TXT_DEF_PREFIX1 0x25
#define B_TXT_ATK_PREFIX2 0x26
#define B_TXT_DEF_PREFIX2 0x27
#define B_TXT_ATK_PREFIX3 0x28
#define B_TXT_DEF_PREFIX3 0x29
#define B_TXT_BUFF3 0x2A
// for B_TXT_BUFF1, B_TXT_BUFF2 and B_TXT_BUFF3
#define B_BUFF_STRING 0

View File

@ -2,7 +2,6 @@
#define GUARD_EWRAM_H
extern u8 gSharedMem[];
#define ewram_addr EWRAM // used in gSharedMem addr hacks
// Note: we have duplicate ewram labels because its clear some memory
// regions overlap others but have different definitions. Until some

View File

@ -501,7 +501,7 @@ const u8 *GetMonSpritePal(struct Pokemon *mon);
const u8 *GetMonSpritePalFromOtIdPersonality(u16, u32, u32);
const struct CompressedSpritePalette *GetMonSpritePalStructFromOtIdPersonality(u16, u32, u32);
bool8 IsOtherTrainer(u32, u8 *);
void sub_8040B8C(void);
void SetMonPreventsSwitchingString(void);
void SetWildMonHeldItem(void);
u8 *sub_8040D08();
bool32 ShouldHideGenderIconForLanguage(u16 species, u8 *name, u8 language);

View File

@ -402,10 +402,10 @@ static void BattleIntroTask_80E4C34(u8 taskId)
if (gTasks[taskId].tBgXOffset == 0)
{
gTasks[taskId].tState++;
gSprites[gBattleStruct->unk1608A].oam.objMode = 2;
gSprites[gBattleStruct->unk1608A].callback = sub_800FE20;
gSprites[gBattleStruct->unk1608B].oam.objMode = 2;
gSprites[gBattleStruct->unk1608B].callback = sub_800FE20;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].oam.objMode = 2;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].callback = sub_800FE20;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].oam.objMode = 2;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].callback = sub_800FE20;
REG_WININ = 0x3F;
REG_WINOUT = 0x3F06;
}

View File

@ -592,10 +592,10 @@ void InitLinkBattleVsScreen(u8 taskId)
case 1:
palette = AllocSpritePalette(10000);
gPlttBufferUnfaded[palette * 16 + 0x10f] = gPlttBufferFaded[palette * 16 + 0x10f] = 0x7fff;
gBattleStruct->unk1608A = CreateSprite(&gSpriteTemplate_81F9574, 108, 80, 0);
gBattleStruct->unk1608B = CreateSprite(&gSpriteTemplate_81F958C, 132, 80, 0);
gSprites[gBattleStruct->unk1608A].invisible = TRUE;
gSprites[gBattleStruct->unk1608B].invisible = TRUE;
gBattleStruct->linkBattleVsSpriteId_V = CreateSprite(&gSpriteTemplate_81F9574, 108, 80, 0);
gBattleStruct->linkBattleVsSpriteId_S = CreateSprite(&gSpriteTemplate_81F958C, 132, 80, 0);
gSprites[gBattleStruct->linkBattleVsSpriteId_V].invisible = TRUE;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].invisible = TRUE;
gTasks[taskId].data[0]++;
break;
@ -620,15 +620,15 @@ void InitLinkBattleVsScreen(u8 taskId)
}
PlaySE(SE_M_HARDEN);
DestroyTask(taskId);
gSprites[gBattleStruct->unk1608A].invisible = FALSE;
gSprites[gBattleStruct->unk1608B].invisible = FALSE;
gSprites[gBattleStruct->unk1608B].oam.tileNum += 0x40;
gSprites[gBattleStruct->unk1608A].data[0] = 0;
gSprites[gBattleStruct->unk1608B].data[0] = 1;
gSprites[gBattleStruct->unk1608A].data[1] = gSprites[gBattleStruct->unk1608A].x;
gSprites[gBattleStruct->unk1608B].data[1] = gSprites[gBattleStruct->unk1608B].x;
gSprites[gBattleStruct->unk1608A].data[2] = 0;
gSprites[gBattleStruct->unk1608B].data[2] = 0;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].invisible = FALSE;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].invisible = FALSE;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].oam.tileNum += 0x40;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].data[0] = 0;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].data[0] = 1;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].data[1] = gSprites[gBattleStruct->linkBattleVsSpriteId_V].x;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].data[1] = gSprites[gBattleStruct->linkBattleVsSpriteId_S].x;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].data[2] = 0;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].data[2] = 0;
}
break;
}

View File

@ -1430,11 +1430,6 @@ void OpponentHandlecmd19(void)
OpponentBufferExecCompleted();
}
struct ChooseMoveStruct
{
u16 moves[4];
};
#if DEBUG
NAKED
void OpponentHandlecmd20(void)

View File

@ -68,7 +68,7 @@ extern u16 gIntroSlideFlags;
extern u8 gUnknown_02024E68[];
extern struct SpriteTemplate gCreatingSpriteTemplate;
extern u8 gAnimMoveTurn;
extern u8 gUnknown_02038470[];
extern u8 gBattlePartyCurrentOrder[];
extern u8 gUnknown_03004344;
extern u8 gUnknown_0300434C[];
@ -76,7 +76,6 @@ extern const u8 BattleText_OtherMenu[];
extern const u8 BattleText_MenuOptions[];
extern const u8 BattleText_PP[];
extern void sub_802C68C(void);
extern void sub_802E1B0(void);
extern void sub_802E220();
extern void sub_802E2D4();
@ -151,7 +150,7 @@ extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern u8 gUnknown_0300434C[];
extern u8 gUnknown_0202E8F4;
extern u8 gUnknown_0202E8F5;
extern u8 gUnknown_02038470[];
extern u8 gBattlePartyCurrentOrder[];
extern u16 gSpecialVar_ItemId;
extern u8 gDisplayedStringBattle[];
extern const u8 BattleText_LinkStandby[];
@ -292,7 +291,7 @@ void (*const gPlayerBufferCommands[])(void) =
void PlayerBufferRunCommand(void);
void sub_802C2EC(void);
void sub_802C68C(void);
static void HandleAction_ChooseMove(void);
void sub_802CA60(void);
void sub_802D730(void);
void sub_802DA9C(u8);
@ -496,7 +495,7 @@ void sub_802C2EC(void)
{
PlaySE(SE_SELECT);
gSprites[gBattlerSpriteIds[gUnknown_03004344]].callback = sub_8010574;
gBattlerControllerFuncs[gActiveBattler] = sub_802C68C;
gBattlerControllerFuncs[gActiveBattler] = HandleAction_ChooseMove;
dp11b_obj_instanciate(gActiveBattler, 1, 7, 1);
dp11b_obj_instanciate(gActiveBattler, 0, 7, 1);
dp11b_obj_free(gUnknown_03004344, 1);
@ -595,21 +594,11 @@ void sub_802C2EC(void)
}
}
struct ChooseMoveStruct
{
u16 moves[4];
u8 pp[4];
u8 unkC[0x12-0xC];
u8 unk12;
u8 effectStringId;
u8 filler14[0x20-0x14];
};
const u8 gUnknown_081FAE80[] = _("{PALETTE 5}{COLOR_HIGHLIGHT_SHADOW WHITE LIGHT_BLUE WHITE2}");
void debug_sub_8030C24(void);
void sub_802C68C(void)
static void HandleAction_ChooseMove(void)
{
u32 r8 = 0;
#if DEBUG
@ -624,7 +613,12 @@ void sub_802C68C(void)
PlaySE(SE_SELECT);
if (r6->moves[gMoveSelectionCursor[gActiveBattler]] == MOVE_CURSE)
r4 = (r6->unk12 != TYPE_GHOST && (r6->effectStringId ^ 7)) ? 0x10 : 0;
{
if (r6->monType1 != TYPE_GHOST && r6->monType2 != TYPE_GHOST)
r4 = MOVE_TARGET_USER;
else
r4 = MOVE_TARGET_SELECTED;
}
else
r4 = gBattleMoves[r6->moves[gMoveSelectionCursor[gActiveBattler]]].target;
@ -642,7 +636,7 @@ void sub_802C68C(void)
{
if (!(r4 & 0x7D))
r8++;
if (r6->pp[gMoveSelectionCursor[gActiveBattler]] == 0)
if (r6->currentPp[gMoveSelectionCursor[gActiveBattler]] == 0)
{
r8 = 0;
}
@ -810,13 +804,13 @@ void sub_802CA60(void)
r9->moves[gMoveSelectionCursor[gActiveBattler]] = r9->moves[gUnknown_03004344];
r9->moves[gUnknown_03004344] = i;
i = r9->pp[gMoveSelectionCursor[gActiveBattler]];
r9->pp[gMoveSelectionCursor[gActiveBattler]] = r9->pp[gUnknown_03004344];
r9->pp[gUnknown_03004344] = i;
i = r9->currentPp[gMoveSelectionCursor[gActiveBattler]];
r9->currentPp[gMoveSelectionCursor[gActiveBattler]] = r9->currentPp[gUnknown_03004344];
r9->currentPp[gUnknown_03004344] = i;
i = r9->unkC[gMoveSelectionCursor[gActiveBattler]];
r9->unkC[gMoveSelectionCursor[gActiveBattler]] = r9->unkC[gUnknown_03004344];
r9->unkC[gUnknown_03004344] = i;
i = r9->maxPp[gMoveSelectionCursor[gActiveBattler]];
r9->maxPp[gMoveSelectionCursor[gActiveBattler]] = r9->maxPp[gUnknown_03004344];
r9->maxPp[gUnknown_03004344] = i;
if (gDisableStructs[gActiveBattler].mimickedMoves & gBitTable[gMoveSelectionCursor[gActiveBattler]])
{
@ -840,7 +834,7 @@ void sub_802CA60(void)
for (i = 0; i < 4; i++)
{
gBattleMons[gActiveBattler].moves[i] = r9->moves[i];
gBattleMons[gActiveBattler].pp[i] = r9->pp[i];
gBattleMons[gActiveBattler].pp[i] = r9->currentPp[i];
}
if (!(gBattleMons[gActiveBattler].status2 & 0x200000))
{
@ -882,7 +876,7 @@ void sub_802CA60(void)
{
sub_802E12C(gUnknown_03004344, BattleText_Format);
}
gBattlerControllerFuncs[gActiveBattler] = sub_802C68C;
gBattlerControllerFuncs[gActiveBattler] = HandleAction_ChooseMove;
gMoveSelectionCursor[gActiveBattler] = gUnknown_03004344;
sub_802E3B4(gMoveSelectionCursor[gActiveBattler], 0);
Text_FillWindowRect(&gWindowTemplate_Contest_MoveDescription, 0x1016, 0x17, 0x37, 0x1C, 0x3A);
@ -897,7 +891,7 @@ void sub_802CA60(void)
nullsub_7(gUnknown_03004344);
sub_802E3B4(gMoveSelectionCursor[gActiveBattler], 0);
sub_802E12C(gMoveSelectionCursor[gActiveBattler], BattleText_Format);
gBattlerControllerFuncs[gActiveBattler] = sub_802C68C;
gBattlerControllerFuncs[gActiveBattler] = HandleAction_ChooseMove;
Text_FillWindowRect(&gWindowTemplate_Contest_MoveDescription, 0x1016, 0x17, 0x37, 0x1C, 0x3A);
Text_InitWindow(&gWindowTemplate_Contest_MoveDescription, BattleText_PP, 0x290, 0x17, 0x37);
Text_PrintWindow8002F44(&gWindowTemplate_Contest_MoveDescription);
@ -1105,7 +1099,7 @@ void debug_sub_8030C24(void)
(i < 2) ? 0x37 : 0x39);
Text_PrintWindow8002F44(&gWindowTemplate_Contest_MoveDescription);
}
gBattlerControllerFuncs[gActiveBattler] = sub_802C68C;
gBattlerControllerFuncs[gActiveBattler] = HandleAction_ChooseMove;
}
}
@ -1529,7 +1523,7 @@ void sub_802DF88(void)
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
if (gUnknown_0202E8F4 == 1)
BtlController_EmitChosenMonReturnValue(1, gUnknown_0202E8F5, gUnknown_02038470);
BtlController_EmitChosenMonReturnValue(1, gUnknown_0202E8F5, gBattlePartyCurrentOrder);
else
BtlController_EmitChosenMonReturnValue(1, 6, NULL);
if ((gBattleBufferA[gActiveBattler][1] & 0xF) == 1)
@ -1629,9 +1623,9 @@ void sub_802E220(void)
str[1] = 0x14;
str[2] = 6;
str += 3;
str = ConvertIntToDecimalStringN(str, r4->pp[gMoveSelectionCursor[gActiveBattler]], 1, 2);
str = ConvertIntToDecimalStringN(str, r4->currentPp[gMoveSelectionCursor[gActiveBattler]], 1, 2);
*str++ = CHAR_SLASH;
ConvertIntToDecimalStringN(str, r4->unkC[gMoveSelectionCursor[gActiveBattler]], 1, 2);
ConvertIntToDecimalStringN(str, r4->maxPp[gMoveSelectionCursor[gActiveBattler]], 1, 2);
Text_InitWindow(&gWindowTemplate_Contest_MoveDescription, gDisplayedStringBattle, 0x2A2, 0x19, 0x37);
Text_PrintWindow8002F44(&gWindowTemplate_Contest_MoveDescription);
}
@ -2641,7 +2635,7 @@ void PlayerHandlecmd20(void)
{
MenuCursor_Create814A5C0(0, 0xFFFF, 12, 0x2D9F, 0);
sub_80304A8();
gBattlerControllerFuncs[gActiveBattler] = sub_802C68C;
gBattlerControllerFuncs[gActiveBattler] = HandleAction_ChooseMove;
}
void sub_80304A8(void)
@ -2668,7 +2662,7 @@ void PlayerHandleOpenBag(void)
gBattlerControllerFuncs[gActiveBattler] = sub_802E004;
gBankInMenu = gActiveBattler;
for (i = 0; i < 3; i++)
gUnknown_02038470[i] = gBattleBufferA[gActiveBattler][1 + i];
gBattlePartyCurrentOrder[i] = gBattleBufferA[gActiveBattler][1 + i];
}
void PlayerHandlecmd22(void)
@ -2677,11 +2671,11 @@ void PlayerHandlecmd22(void)
gUnknown_0300434C[gActiveBattler] = CreateTask(TaskDummy, 0xFF);
gTasks[gUnknown_0300434C[gActiveBattler]].data[0] = gBattleBufferA[gActiveBattler][1] & 0xF;
gBattleStruct->unk16054 = gBattleBufferA[gActiveBattler][1] >> 4;
gBattleStruct->battlerPreventingSwitchout = gBattleBufferA[gActiveBattler][1] >> 4;
gBattleStruct->unk1609D = gBattleBufferA[gActiveBattler][2];
gBattleStruct->unk160C0 = gBattleBufferA[gActiveBattler][3];
gBattleStruct->abilityPreventingSwitchout = gBattleBufferA[gActiveBattler][3];
for (i = 0; i < 3; i++)
gUnknown_02038470[i] = gBattleBufferA[gActiveBattler][4 + i];
gBattlePartyCurrentOrder[i] = gBattleBufferA[gActiveBattler][4 + i];
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0));
gBattlerControllerFuncs[gActiveBattler] = sub_802DF30;
gBankInMenu = gActiveBattler;

View File

@ -113,7 +113,7 @@ extern u8 gBattleOutcome;
extern u16 gIntroSlideFlags;
extern u8 gActionSelectionCursor[];
extern u8 gMoveSelectionCursor[];
extern u8 gUnknown_02038470[];
extern u8 gBattlePartyCurrentOrder[];
MainCallback gPreBattleCallback1;
u8 gUnknown_03004344;
u8 gUnknown_03004348;
@ -645,7 +645,7 @@ void sub_800F104(void)
if ((GetBlockReceivedStatus() & 0xF) == 0xF)
{
//s32 i;
// Get your multi battle partner's party
ResetBlockReceivedFlags();
for (i = 0; i < 4; i++)
{
@ -3943,7 +3943,7 @@ void sub_80119B4(void)
MarkBattlerForControllerExec(gActiveBattler);
}
}
gBattleStruct->unk16058 = 0;
gBattleStruct->switchInAbilitiesCounter = 0;
gBattleStruct->unk160F9 = 0;
gBattleStruct->unk160E6 = 0;
gBattleMainFunc = BattleBeginFirstTurn;
@ -3962,7 +3962,7 @@ void unref_sub_8011A68(void)
MarkBattlerForControllerExec(gActiveBattler);
}
}
gBattleStruct->unk16058 = 0;
gBattleStruct->switchInAbilitiesCounter = 0;
gBattleStruct->unk160F9 = 0;
gBattleStruct->unk160E6 = 0;
gBattleMainFunc = BattleBeginFirstTurn;
@ -3977,7 +3977,7 @@ void BattleBeginFirstTurn(void)
if (gBattleControllerExecFlags == 0)
{
if (gBattleStruct->unk16058 == 0)
if (gBattleStruct->switchInAbilitiesCounter == 0)
{
for (i = 0; i < gBattlersCount; i++)
gBattlerByTurnOrder[i] = i;
@ -3995,11 +3995,11 @@ void BattleBeginFirstTurn(void)
gBattleStruct->unk160E6 = 1;
return;
}
while (gBattleStruct->unk16058 < gBattlersCount)
while (gBattleStruct->switchInAbilitiesCounter < gBattlersCount)
{
if (AbilityBattleEffects(0, gBattlerByTurnOrder[gBattleStruct->unk16058], 0, 0, 0) != 0)
if (AbilityBattleEffects(0, gBattlerByTurnOrder[gBattleStruct->switchInAbilitiesCounter], 0, 0, 0) != 0)
r9++;
gBattleStruct->unk16058++;
gBattleStruct->switchInAbilitiesCounter++;
if (r9 != 0)
return;
}
@ -4038,7 +4038,7 @@ void BattleBeginFirstTurn(void)
gBattleStruct->wishPerishSongState = 0;
gBattleStruct->wishPerishSongBattlerId = 0;
gBattleStruct->cmd49StateTracker = 0;
gBattleStruct->sub80173A4_Tracker = 0;
gBattleStruct->faintedActionsState = 0;
gBattleStruct->turnCountersTracker = 0;
gMoveResultFlags = 0;
gRandomTurnNumber = Random();
@ -4083,7 +4083,7 @@ void BattleTurnPassed(void)
}
if (HandleFaintedMonActions() != 0)
return;
gBattleStruct->sub80173A4_Tracker = 0;
gBattleStruct->faintedActionsState = 0;
if (HandleWishPerishSongOnTurnEnd() != 0)
return;
TurnValuesCleanUp(0);
@ -4186,7 +4186,7 @@ void sub_8012258(u8 a)
u8 r1;
for (i = 0; i < 3; i++)
gUnknown_02038470[i] = gSharedMem[BSTRUCT_OFF(unk1606C) + i + a * 3];
gBattlePartyCurrentOrder[i] = gSharedMem[BSTRUCT_OFF(unk1606C) + i + a * 3];
r4 = pokemon_order_func(gBattlerPartyIndexes[a]);
r1 = pokemon_order_func(gSharedMem[BSTRUCT_OFF(monToSwitchIntoId) + a]);
sub_8094C98(r4, r1);
@ -4194,15 +4194,16 @@ void sub_8012258(u8 a)
{
for (i = 0; i < 3; i++)
{
gSharedMem[BSTRUCT_OFF(unk1606C) + i + a * 3] = gUnknown_02038470[i];
gSharedMem[BSTRUCT_OFF(unk1606C) + i + (a ^ BIT_FLANK) * 3] = gUnknown_02038470[i];
gSharedMem[BSTRUCT_OFF(unk1606C) + i + a * 3] = gBattlePartyCurrentOrder[i];
gSharedMem[BSTRUCT_OFF(unk1606C) + i + (a ^ BIT_FLANK) * 3] =
gBattlePartyCurrentOrder[i];
}
}
else
{
for (i = 0; i < 3; i++)
{
gSharedMem[BSTRUCT_OFF(unk1606C) + i + a * 3] = gUnknown_02038470[i];
gSharedMem[BSTRUCT_OFF(unk1606C) + i + a * 3] = gBattlePartyCurrentOrder[i];
}
}
}
@ -4280,8 +4281,8 @@ void sub_8012324(void)
if (AreAllMovesUnusable())
{
gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT;
gSharedMem[BSTRUCT_OFF(unk16060) + gActiveBattler] = FALSE;
gSharedMem[BSTRUCT_OFF(unk16094) + gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY;
gSharedMem[BSTRUCT_OFF(selectionScriptFinished) + gActiveBattler] = FALSE;
gSharedMem[BSTRUCT_OFF(stateIdAfterSelScript) + gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY;
gSharedMem[BSTRUCT_OFF(moveTarget) + gActiveBattler] = gBattleBufferB[gActiveBattler][3];
return;
}
@ -4293,14 +4294,7 @@ void sub_8012324(void)
}
else
{
struct ChooseMoveStruct {
u16 moves[4];
u8 currentPp[4];
u8 maxPp[4];
u16 species;
u8 monType1;
u8 monType2;
} moveInfo;
struct ChooseMoveStruct moveInfo;
moveInfo.species = gBattleMons[gActiveBattler].species;
moveInfo.monType1 = gBattleMons[gActiveBattler].type1;
@ -4327,8 +4321,8 @@ void sub_8012324(void)
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_ActionSelectionItemsCantBeUsed;
gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT;
gSharedMem[BSTRUCT_OFF(unk16060) + gActiveBattler] = FALSE;
gSharedMem[BSTRUCT_OFF(unk16094) + gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
gSharedMem[BSTRUCT_OFF(selectionScriptFinished) + gActiveBattler] = FALSE;
gSharedMem[BSTRUCT_OFF(stateIdAfterSelScript) + gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
return;
}
else
@ -4369,8 +4363,8 @@ void sub_8012324(void)
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_PrintFullBox;
gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT;
gSharedMem[BSTRUCT_OFF(unk16060) + gActiveBattler] = FALSE;
gSharedMem[BSTRUCT_OFF(unk16094) + gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
gSharedMem[BSTRUCT_OFF(selectionScriptFinished) + gActiveBattler] = FALSE;
gSharedMem[BSTRUCT_OFF(stateIdAfterSelScript) + gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
return;
}
break;
@ -4398,8 +4392,8 @@ void sub_8012324(void)
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_PrintCantEscapeFromBattle;
gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT;
gSharedMem[BSTRUCT_OFF(unk16060) + gActiveBattler] = FALSE;
gSharedMem[BSTRUCT_OFF(unk16094) + gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
gSharedMem[BSTRUCT_OFF(selectionScriptFinished) + gActiveBattler] = FALSE;
gSharedMem[BSTRUCT_OFF(stateIdAfterSelScript) + gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
return;
}
else
@ -4433,9 +4427,9 @@ void sub_8012324(void)
else if (TrySetCantSelectMoveBattleScript())
{
gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT;
gSharedMem[BSTRUCT_OFF(unk16060) + gActiveBattler] = FALSE;
gSharedMem[BSTRUCT_OFF(selectionScriptFinished) + gActiveBattler] = FALSE;
gBattleBufferB[gActiveBattler][1] = 0;
gSharedMem[BSTRUCT_OFF(unk16094) + gActiveBattler] = STATE_WAIT_ACTION_CHOSEN;
gSharedMem[BSTRUCT_OFF(stateIdAfterSelScript) + gActiveBattler] = STATE_WAIT_ACTION_CHOSEN;
return;
}
else
@ -4538,9 +4532,9 @@ void sub_8012324(void)
}
break;
case STATE_SELECTION_SCRIPT:
if (gSharedMem[BSTRUCT_OFF(unk16060) + gActiveBattler])
if (gSharedMem[BSTRUCT_OFF(selectionScriptFinished) + gActiveBattler])
{
gBattleCommunication[gActiveBattler] = gSharedMem[BSTRUCT_OFF(unk16094) + gActiveBattler];
gBattleCommunication[gActiveBattler] = gSharedMem[BSTRUCT_OFF(stateIdAfterSelScript) + gActiveBattler];
}
else
{
@ -4914,7 +4908,7 @@ static void RunTurnActionsFunctions(void)
if (gBattleOutcome != 0)
gCurrentActionFuncId = 12;
gBattleStruct->unk16057 = gCurrentTurnActionNumber;
gBattleStruct->savedTurnActionNumber = gCurrentTurnActionNumber;
gUnknown_081FA640[gCurrentActionFuncId]();
if (gCurrentTurnActionNumber >= gBattlersCount) // everyone did their actions, turn finished
@ -4924,7 +4918,7 @@ static void RunTurnActionsFunctions(void)
}
else
{
if (gBattleStruct->unk16057 != gCurrentTurnActionNumber) // action turn has been done, clear hitmarker bits for another bank
if (gBattleStruct->savedTurnActionNumber != gCurrentTurnActionNumber) // action turn has been done, clear hitmarker bits for another bank
{
gHitMarker &= ~(HITMARKER_NO_ATTACKSTRING);
gHitMarker &= ~(HITMARKER_UNABLE_TO_USE_MOVE);
@ -5655,7 +5649,7 @@ void HandleAction_Action11(void)
{
if (!HandleFaintedMonActions())
{
gBattleStruct->sub80173A4_Tracker = 0;
gBattleStruct->faintedActionsState = 0;
gCurrentActionFuncId = B_ACTION_FINISHED;
}
}

View File

@ -538,13 +538,13 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
while (*src != EOS)
{
if (*src == 0xFD)
if (*src == B_BUFF_PLACEHOLDER_BEGIN)
{
src++;
switch (*src)
{
case 0:
if (gBattleTextBuff1[0] == 0xFD)
case B_TXT_BUFF1:
if (gBattleTextBuff1[0] == B_BUFF_PLACEHOLDER_BEGIN)
{
ExpandBattleTextBuffPlaceholders(gBattleTextBuff1, gStringVar1);
toCpy = gStringVar1;
@ -552,12 +552,12 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
else
{
toCpy = TryGetStatusString(gBattleTextBuff1);
if (toCpy == 0)
if (toCpy == NULL)
toCpy = gBattleTextBuff1;
}
break;
case 1:
if (gBattleTextBuff2[0] == 0xFD)
case B_TXT_BUFF2:
if (gBattleTextBuff2[0] == B_BUFF_PLACEHOLDER_BEGIN)
{
ExpandBattleTextBuffPlaceholders(gBattleTextBuff2, gStringVar2);
toCpy = gStringVar2;
@ -565,8 +565,8 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
else
toCpy = gBattleTextBuff2;
break;
case 42:
if (gBattleTextBuff3[0] == 0xFD)
case B_TXT_BUFF3:
if (gBattleTextBuff3[0] == B_BUFF_PLACEHOLDER_BEGIN)
{
ExpandBattleTextBuffPlaceholders(gBattleTextBuff3, gStringVar3);
toCpy = gStringVar3;
@ -574,50 +574,50 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
else
toCpy = gBattleTextBuff3;
break;
case 2: // first player poke name
case B_TXT_PLAYER_MON1_NAME: // first player poke name
GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(0)]], MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case 3: // first enemy poke name
case B_TXT_OPPONENT_MON1_NAME: // first enemy poke name
GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(1)]], MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case 4: // second player poke name
case B_TXT_PLAYER_MON2_NAME: // second player poke name
GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(2)]], MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case 5: // second enemy poke name
case B_TXT_OPPONENT_MON2_NAME: // second enemy poke name
GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(3)]], MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case 6: // link first player poke name
case B_TXT_LINK_PLAYER_MON1_NAME: // link first player poke name
GetMonData(&gPlayerParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].id]], MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case 7: // link first opponent poke name
case B_TXT_LINK_OPPONENT_MON1_NAME: // link first opponent poke name
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].id ^ 1]], MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case 8: // link second player poke name
case B_TXT_LINK_PLAYER_MON2_NAME: // link second player poke name
GetMonData(&gPlayerParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].id ^ 2]], MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case 9: // link second opponent poke name
case B_TXT_LINK_OPPONENT_MON2_NAME: // link second opponent poke name
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].id ^ 3]], MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case 10: // attacker name with prefix, only bank 0/1
case B_TXT_ATK_NAME_WITH_PREFIX_MON1: // attacker name with prefix, only bank 0/1
HANDLE_NICKNAME_STRING_CASE(gBattlerAttacker, gBattlerPartyIndexes[GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) & 1)])
break;
case 11: // attacker partner name, only bank 0/1
case B_TXT_ATK_PARTNER_NAME: // attacker partner name, only bank 0/1
if (GetBattlerSide(gBattlerAttacker) == 0)
GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) & 1) + 2]], MON_DATA_NICKNAME, text);
else
@ -626,34 +626,34 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
StringGetEnd10(text);
toCpy = text;
break;
case 12: // attacker name with prefix
case B_TXT_ATK_NAME_WITH_PREFIX: // attacker name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattlerAttacker, gBattlerPartyIndexes[gBattlerAttacker])
break;
case 13: // target name with prefix
case B_TXT_DEF_NAME_WITH_PREFIX: // target name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattlerTarget, gBattlerPartyIndexes[gBattlerTarget])
break;
case 14: // effect bank name with prefix
case B_TXT_EFF_NAME_WITH_PREFIX: // effect bank name with prefix
HANDLE_NICKNAME_STRING_CASE(gEffectBattler, gBattlerPartyIndexes[gEffectBattler])
break;
case 15: // active bank name with prefix
case B_TXT_ACTIVE_NAME_WITH_PREFIX: // active bank name with prefix
HANDLE_NICKNAME_STRING_CASE(gActiveBattler, gBattlerPartyIndexes[gActiveBattler])
break;
case 16: // scripting active bank name with prefix
case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active bank name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattleStruct->scriptingActive, gBattlerPartyIndexes[gBattleStruct->scriptingActive])
break;
case 17: // current move name
if (gStringInfo->currentMove > 0x162)
case B_TXT_CURRENT_MOVE: // current move name
if (gStringInfo->currentMove >= NUM_MOVES)
toCpy = (void*) &gUnknown_08401674[gBattleStruct->stringMoveType];
else
toCpy = gMoveNames[gStringInfo->currentMove];
break;
case 18: // last used move name
if (gStringInfo->lastMove > 0x162)
case B_TXT_LAST_MOVE: // last used move name
if (gStringInfo->lastMove >= NUM_MOVES)
toCpy = (void*) &gUnknown_08401674[gBattleStruct->stringMoveType];
else
toCpy = gMoveNames[gStringInfo->lastMove];
break;
case 19: // last used item
case B_TXT_LAST_ITEM: // last used item
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
if (gLastUsedItem == ITEM_ENIGMA_BERRY)
@ -683,22 +683,22 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = text;
}
break;
case 20: // last used ability
case B_TXT_LAST_ABILITY: // last used ability
toCpy = gAbilityNames[gLastUsedAbility];
break;
case 21: // attacker ability
case B_TXT_ATK_ABILITY: // attacker ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBattlerAttacker]];
break;
case 22: // target ability
case B_TXT_DEF_ABILITY: // target ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBattlerTarget]];
break;
case 23: // scripting active ability
case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBattleStruct->scriptingActive]];
break;
case 24: // effect bank ability
case B_TXT_EFF_ABILITY: // effect bank ability
toCpy = gAbilityNames[gAbilitiesPerBank[gEffectBattler]];
break;
case 25: // trainer class name
case B_TXT_TRAINER1_CLASS: // trainer class name
#ifdef ENGLISH
if (gTrainerBattleOpponent == SECRET_BASE_OPPONENT)
toCpy = gTrainerClassNames[GetSecretBaseTrainerNameIndex()];
@ -720,7 +720,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = de_sub_8041024(0, gTrainerBattleOpponent);
break;
#endif
case 26: // trainer name
case B_TXT_TRAINER1_NAME: // trainer name
if (gTrainerBattleOpponent == SECRET_BASE_OPPONENT)
{
memset(text, 0xFF, 8);
@ -740,67 +740,67 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
else
toCpy = gTrainers[gTrainerBattleOpponent].trainerName;
break;
case 27: // link player name?
case B_TXT_LINK_PLAYER_NAME: // link player name?
toCpy = gLinkPlayers[multiplayerID].name;
break;
case 28: // link partner name?
case B_TXT_LINK_PARTNER_NAME: // link partner name?
toCpy = gLinkPlayers[sub_803FC34(2 ^ gLinkPlayers[multiplayerID].id)].name;
break;
case 29: // link opponent 1 name?
case B_TXT_LINK_OPPONENT1_NAME: // link opponent 1 name?
toCpy = gLinkPlayers[sub_803FC34(1 ^ gLinkPlayers[multiplayerID].id)].name;
break;
case 30: // link opponent 2 name?
case B_TXT_LINK_OPPONENT2_NAME: // link opponent 2 name?
toCpy = gLinkPlayers[sub_803FC34(3 ^ gLinkPlayers[multiplayerID].id)].name;
break;
case 31: // link scripting active name
case B_TXT_LINK_SCR_TRAINER_NAME: // link scripting active name
toCpy = gLinkPlayers[sub_803FC34(gBattleStruct->scriptingActive)].name;
break;
case 32: // player name
case B_TXT_PLAYER_NAME: // player name
toCpy = gSaveBlock2.playerName;
break;
case 33: // ?
case B_TXT_TRAINER1_LOSE_TEXT: // ?
toCpy = GetTrainerLoseText();
break;
case 34: // ?
case B_TXT_22: // ?
HANDLE_NICKNAME_STRING_CASE(gBattleStruct->scriptingActive, gBattleStruct->unk1605E)
break;
case 35: // lanette pc
case B_TXT_PC_CREATOR_NAME: // lanette pc
if (FlagGet(FLAG_SYS_PC_LANETTE))
toCpy = BattleText_Lanette;
else
toCpy = BattleText_Someone;
break;
case 38:
case B_TXT_ATK_PREFIX2:
if (GetBattlerSide(gBattlerAttacker) == 0)
toCpy = BattleText_Ally2;
else
toCpy = BattleText_Foe3;
break;
case 39:
case B_TXT_DEF_PREFIX2:
if (GetBattlerSide(gBattlerTarget) == 0)
toCpy = BattleText_Ally2;
else
toCpy = BattleText_Foe3;
break;
case 36:
case B_TXT_ATK_PREFIX1:
if (GetBattlerSide(gBattlerAttacker) == 0)
toCpy = BattleText_Ally;
else
toCpy = BattleText_Foe2;
break;
case 37:
case B_TXT_DEF_PREFIX1:
if (GetBattlerSide(gBattlerTarget) == 0)
toCpy = BattleText_Ally;
else
toCpy = BattleText_Foe2;
break;
case 40:
case B_TXT_ATK_PREFIX3:
if (GetBattlerSide(gBattlerAttacker) == 0)
toCpy = BattleText_Ally3;
else
toCpy = BattleText_Foe4;
break;
case 41:
case B_TXT_DEF_PREFIX3:
if (GetBattlerSide(gBattlerTarget) == 0)
toCpy = BattleText_Ally3;
else
@ -814,11 +814,11 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
dstID++;
toCpy++;
}
if (*src == 33)
if (*src == B_TXT_TRAINER1_LOSE_TEXT)
{
dst[dstID] = 0xFC;
dst[dstID] = EXT_CTRL_CODE_BEGIN;
dstID++;
dst[dstID] = 9;
dst[dstID] = EXT_CTRL_CODE_PAUSE_UNTIL_PRESS;
dstID++;
}
}
@ -834,9 +834,6 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
return dstID;
}
#define ByteRead16(ptr) ((ptr)[0] | ((ptr)[1] << 8))
#define ByteRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24)
void ExpandBattleTextBuffPlaceholders(u8* src, u8* dst)
{
u32 srcID = 1;
@ -849,8 +846,8 @@ void ExpandBattleTextBuffPlaceholders(u8* src, u8* dst)
{
switch (src[srcID])
{
case 0: // battle string
hword = ByteRead16(&src[srcID + 1]);
case B_BUFF_STRING: // battle string
hword = T1_READ_16(&src[srcID + 1]);
#ifdef GERMAN
if (hword == 209 || hword == 211)
srcID += 3;
@ -858,31 +855,31 @@ void ExpandBattleTextBuffPlaceholders(u8* src, u8* dst)
StringAppend(dst, gBattleStringsTable[hword - BATTLESTRING_TO_SUB]);
srcID += 3;
break;
case 1: // int to string
case B_BUFF_NUMBER: // int to string
switch (src[srcID + 1])
{
case 1:
value = src[srcID + 3];
value = T1_READ_8(&src[srcID + 3]);
break;
case 2:
value = ByteRead16(&src[srcID + 3]);
value = T1_READ_16(&src[srcID + 3]);
break;
case 4:
value = ByteRead32(&src[srcID + 3]);
value = T1_READ_32(&src[srcID + 3]);
break;
}
ConvertIntToDecimalStringN(dst, value, 0, src[srcID + 2]);
srcID += src[srcID + 1] + 3;
break;
case 2: // move name
StringAppend(dst, gMoveNames[ByteRead16(&src[srcID + 1])]);
case B_BUFF_MOVE: // move name
StringAppend(dst, gMoveNames[T1_READ_16(&src[srcID + 1])]);
srcID += 3;
break;
case 3: // type name
case B_BUFF_TYPE: // type name
StringAppend(dst, gTypeNames[src[srcID + 1]]);
srcID += 2;
break;
case 4: // poke nick with prefix
case B_BUFF_MON_NICK_WITH_PREFIX: // poke nick with prefix
#ifdef ENGLISH
if (GetBattlerSide(src[srcID + 1]) == 0)
{
@ -918,15 +915,15 @@ void ExpandBattleTextBuffPlaceholders(u8* src, u8* dst)
#endif
srcID += 3;
break;
case 5: // stats
case B_BUFF_STAT: // stats
StringAppend(dst, gUnknown_08400F58[src[srcID + 1]]);
srcID += 2;
break;
case 6: // species name
GetSpeciesName(dst, ByteRead16(&src[srcID + 1]));
case B_BUFF_SPECIES: // species name
GetSpeciesName(dst, T1_READ_16(&src[srcID + 1]));
srcID += 3;
break;
case 7: // poke nick without prefix
case B_BUFF_MON_NICK: // poke nick without prefix
if (GetBattlerSide(src[srcID + 1]) == 0)
GetMonData(&gPlayerParty[src[srcID + 2]], MON_DATA_NICKNAME, dst);
else
@ -934,17 +931,17 @@ void ExpandBattleTextBuffPlaceholders(u8* src, u8* dst)
StringGetEnd10(dst);
srcID += 3;
break;
case 8: // flavour table
case B_BUFF_NEGATIVE_FLAVOR: // flavour table
StringAppend(dst, gUnknown_08400F78[src[srcID + 1]]);
srcID += 2;
break;
case 9: // ability names
case B_BUFF_ABILITY: // ability names
StringAppend(dst, gAbilityNames[src[srcID + 1]]);
srcID += 2;
break;
case 10: // item name
case B_BUFF_ITEM: // item name
{
hword = ByteRead16(&src[srcID + 1]);
hword = T1_READ_16(&src[srcID + 1]);
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
if (hword == ITEM_ENIGMA_BERRY)

View File

@ -20,13 +20,16 @@
#include "text.h"
#include "ewram.h"
EWRAM_DATA u8 gBattlePartyCurrentOrder[3] = {};
EWRAM_DATA u8 gUnknown_02038473 = 0;
extern u8 sub_806BD58(u8, u8);
extern void PartyMenuPrintMonsLevelOrStatus(void);
extern void nullsub_13(void);
extern void sub_802E414(void);
extern void sub_80A6DCC(void);
extern u8 *sub_8040D08();
extern void sub_8040B8C(void);
extern void SetMonPreventsSwitchingString(void);
extern void nullsub_14();
extern u8 sub_803FBBC(void);
@ -37,8 +40,6 @@ extern u8 gBankInMenu;
extern u8 gUnknown_0202E8F4;
extern u8 gUnknown_0202E8F5;
extern u8 gPartyMenuMessage_IsPrinting;
extern u8 gUnknown_02038470[3];
extern u8 gUnknown_02038473;
extern u8 gUnknown_020384F0;
extern void (*gPokemonItemUseCallback)(); //don't know types yet
extern struct PokemonStorage gPokemonStorage;
@ -89,7 +90,7 @@ void unref_sub_8094940(struct PokemonStorage *ptr)
void sub_8094958(void)
{
sub_8094998(gUnknown_02038470, sub_803FBBC());
sub_8094998(gBattlePartyCurrentOrder, sub_803FBBC());
}
void sub_8094978(u8 arg1, u8 arg2)
@ -239,9 +240,9 @@ u8 sub_8094C20(u8 monIndex)
monIndex /= 2;
if (val)
retVal = gUnknown_02038470[monIndex] & 0xF;
retVal = gBattlePartyCurrentOrder[monIndex] & 0xF;
else
retVal = gUnknown_02038470[monIndex] >> 4;
retVal = gBattlePartyCurrentOrder[monIndex] >> 4;
return retVal;
}
@ -251,9 +252,9 @@ void sub_8094C54(u8 a, u8 b)
a /= 2;
if (val)
gUnknown_02038470[a] = (gUnknown_02038470[a] & 0xF0) | b;
gBattlePartyCurrentOrder[a] = (gBattlePartyCurrentOrder[a] & 0xF0) | b;
else
gUnknown_02038470[a] = (gUnknown_02038470[a] & 0xF) | (b << 4);
gBattlePartyCurrentOrder[a] = (gBattlePartyCurrentOrder[a] & 0xF) | (b << 4);
}
void sub_8094C98(u8 a, u8 b)
@ -272,10 +273,10 @@ u8 pokemon_order_func(u8 a)
for (i = 0, r2 = 0; i < 3; i++)
{
if ((gUnknown_02038470[i] >> 4) == a)
if ((gBattlePartyCurrentOrder[i] >> 4) == a)
return r2;
r2++;
if ((gUnknown_02038470[i] & 0xF) == a)
if ((gBattlePartyCurrentOrder[i] & 0xF) == a)
return r2;
r2++;
}
@ -698,7 +699,7 @@ static void Task_BattlePartyMenuShift(u8 taskId)
if (gUnknown_02038473 == 4)
{
PartyMenuEraseMsgBoxAndFrame();
sub_8040B8C();
SetMonPreventsSwitchingString();
DisplayPartyMenuMessage(gStringVar4, 0);
gTasks[taskId].func = Task_80954C0;
return;

View File

@ -292,8 +292,6 @@ extern u8 BattleScript_GrudgeTakesPp[];
#define RecordAbilitySetField6(ability, fieldValue) \
(gLastUsedAbility = ability, gBattleCommunication[6] = fieldValue, RecordAbilityBattle(gBattlerTarget, ability))
#define HP_ON_SWITCHOUT (((u16*)(ewram_addr + 0x160BC)))
static void atk00_attackcanceler(void);
static void atk01_accuracycheck(void);
static void atk02_attackstring(void);
@ -6017,7 +6015,7 @@ static void atk43_jumpifabilitypresent(void)
static void atk44_endselectionscript(void)
{
gSharedMem[BSTRUCT_OFF(unk16060) + gBattlerAttacker] = 1;
gSharedMem[BSTRUCT_OFF(selectionScriptFinished) + gBattlerAttacker] = 1;
}
static void atk45_playanimation(void)
@ -11524,10 +11522,10 @@ static void atkA5_painsplitdmgcalc(void)
s32 hp_diff = (gBattleMons[gBattlerAttacker].hp + gBattleMons[gBattlerTarget].hp) / 2;
s32 to_store = gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - hp_diff;
gSharedMem[BSTRUCT_OFF(unk16014) + 0] = sBYTE0_32(to_store);
gSharedMem[BSTRUCT_OFF(unk16014) + 1] = sBYTE1_32(to_store);
gSharedMem[BSTRUCT_OFF(unk16014) + 2] = sBYTE2_32(to_store);
gSharedMem[BSTRUCT_OFF(unk16014) + 3] = sBYTE3_32(to_store);
gSharedMem[BSTRUCT_OFF(painSplitHP) + 0] = sBYTE0_32(to_store);
gSharedMem[BSTRUCT_OFF(painSplitHP) + 1] = sBYTE1_32(to_store);
gSharedMem[BSTRUCT_OFF(painSplitHP) + 2] = sBYTE2_32(to_store);
gSharedMem[BSTRUCT_OFF(painSplitHP) + 3] = sBYTE3_32(to_store);
gBattleMoveDamage = gBattleMons[gBattlerAttacker].hp - hp_diff;
gSpecialStatuses[gBattlerTarget].dmg = 0xFFFF;

View File

@ -1289,11 +1289,11 @@ bool8 HandleFaintedMonActions(void)
do
{
int i;
switch (gBattleStruct->sub80173A4_Tracker)
switch (gBattleStruct->faintedActionsState)
{
case 0:
gBattleStruct->unk1605A = 0;
gBattleStruct->sub80173A4_Tracker++;
gBattleStruct->faintedActionsBattlerId = 0;
gBattleStruct->faintedActionsState++;
for (i = 0; i < gBattlersCount; i++)
{
if (gAbsentBattlerFlags & gBitTable[i] && !sub_8018018(i, 6, 6))
@ -1302,54 +1302,54 @@ bool8 HandleFaintedMonActions(void)
case 1:
do
{
gBank1 = gBattlerTarget = gBattleStruct->unk1605A;
if (gBattleMons[gBattleStruct->unk1605A].hp == 0 && !(gBattleStruct->givenExpMons & gBitTable[gBattlerPartyIndexes[gBattleStruct->unk1605A]]) && !(gAbsentBattlerFlags & gBitTable[gBattleStruct->unk1605A]))
gBank1 = gBattlerTarget = gBattleStruct->faintedActionsBattlerId;
if (gBattleMons[gBattleStruct->faintedActionsBattlerId].hp == 0 && !(gBattleStruct->givenExpMons & gBitTable[gBattlerPartyIndexes[gBattleStruct->faintedActionsBattlerId]]) && !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBattlerId]))
{
BattleScriptExecute(BattleScript_GiveExp);
gBattleStruct->sub80173A4_Tracker = 2;
gBattleStruct->faintedActionsState = 2;
return 1;
}
} while (++gBattleStruct->unk1605A != gBattlersCount);
gBattleStruct->sub80173A4_Tracker = 3;
} while (++gBattleStruct->faintedActionsBattlerId != gBattlersCount);
gBattleStruct->faintedActionsState = 3;
break;
case 2:
sub_8015740(gBank1);
if (++gBattleStruct->unk1605A == gBattlersCount)
gBattleStruct->sub80173A4_Tracker = 3;
if (++gBattleStruct->faintedActionsBattlerId == gBattlersCount)
gBattleStruct->faintedActionsState = 3;
else
gBattleStruct->sub80173A4_Tracker = 1;
gBattleStruct->faintedActionsState = 1;
break;
case 3:
gBattleStruct->unk1605A = 0;
gBattleStruct->sub80173A4_Tracker++;
gBattleStruct->faintedActionsBattlerId = 0;
gBattleStruct->faintedActionsState++;
case 4:
do
{
gBank1 = gBattlerTarget = gBattleStruct->unk1605A; //or should banks be switched?
if (gBattleMons[gBattleStruct->unk1605A].hp == 0 && !(gAbsentBattlerFlags & gBitTable[gBattleStruct->unk1605A]))
gBank1 = gBattlerTarget = gBattleStruct->faintedActionsBattlerId; //or should banks be switched?
if (gBattleMons[gBattleStruct->faintedActionsBattlerId].hp == 0 && !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBattlerId]))
{
BattleScriptExecute(BattleScript_HandleFaintedMon);
gBattleStruct->sub80173A4_Tracker = 5;
gBattleStruct->faintedActionsState = 5;
return 1;
}
} while (++gBattleStruct->unk1605A != gBattlersCount);
gBattleStruct->sub80173A4_Tracker = 6;
} while (++gBattleStruct->faintedActionsBattlerId != gBattlersCount);
gBattleStruct->faintedActionsState = 6;
break;
case 5:
if (++gBattleStruct->unk1605A == gBattlersCount)
gBattleStruct->sub80173A4_Tracker = 6;
if (++gBattleStruct->faintedActionsBattlerId == gBattlersCount)
gBattleStruct->faintedActionsState = 6;
else
gBattleStruct->sub80173A4_Tracker = 4;
gBattleStruct->faintedActionsState = 4;
break;
case 6:
if (AbilityBattleEffects(9, 0, 0, 0, 0) || AbilityBattleEffects(0xB, 0, 0, 0, 0) || ItemBattleEffects(1, 0, 1) || AbilityBattleEffects(6, 0, 0, 0, 0))
return 1;
gBattleStruct->sub80173A4_Tracker++;
gBattleStruct->faintedActionsState++;
break;
case 7:
break;
}
} while (gBattleStruct->sub80173A4_Tracker != HandleFaintedMonActions_MAX_CASE);
} while (gBattleStruct->faintedActionsState != HandleFaintedMonActions_MAX_CASE);
return 0;
}

View File

@ -5,8 +5,6 @@
#include "text.h"
#include "ewram.h"
#define WRAM ewram_addr // using gSharedMem doesn't match
void LZDecompressWram(const void *src, void *dest)
{
LZ77UnCompWram(src, dest);
@ -21,8 +19,8 @@ void LoadCompressedObjectPic(const struct CompressedSpriteSheet *src)
{
struct SpriteSheet dest;
LZ77UnCompWram(src->data, (void *)WRAM);
dest.data = (void *)WRAM;
LZ77UnCompWram(src->data, (void *)EWRAM);
dest.data = (void *)EWRAM;
dest.size = src->size;
dest.tag = src->tag;
LoadSpriteSheet(&dest);
@ -43,8 +41,8 @@ void LoadCompressedObjectPalette(const struct CompressedSpritePalette *src)
{
struct SpritePalette dest;
LZ77UnCompWram(src->data, (void *)WRAM);
dest.data = (void *)WRAM;
LZ77UnCompWram(src->data, (void *)EWRAM);
dest.data = (void *)EWRAM;
dest.tag = src->tag;
LoadSpritePalette(&dest);
}

View File

@ -1298,22 +1298,22 @@ void BoxMonRestorePP(struct BoxPokemon *boxMon)
}
}
void sub_8040B8C(void)
void SetMonPreventsSwitchingString(void)
{
gLastUsedAbility = gBattleStruct->unk160C0;;
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 4;
gBattleTextBuff1[2] = gBattleStruct->unk16054;
gBattleTextBuff1[4] = EOS;
if (!GetBattlerSide(gBattleStruct->unk16054))
gBattleTextBuff1[3] = pokemon_order_func(gBattlerPartyIndexes[gBattleStruct->unk16054]);
gLastUsedAbility = gBattleStruct->abilityPreventingSwitchout;;
gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN;
gBattleTextBuff1[1] = B_BUFF_MON_NICK_WITH_PREFIX;
gBattleTextBuff1[2] = gBattleStruct->battlerPreventingSwitchout;
gBattleTextBuff1[4] = B_BUFF_EOS;
if (GetBattlerSide(gBattleStruct->battlerPreventingSwitchout) == B_SIDE_PLAYER)
gBattleTextBuff1[3] = pokemon_order_func(gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout]);
else
gBattleTextBuff1[3] = gBattlerPartyIndexes[gBattleStruct->unk16054];
gBattleTextBuff2[0] = 0xFD;
gBattleTextBuff2[1] = 4;
gBattleTextBuff1[3] = gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout];
gBattleTextBuff2[0] = B_BUFF_PLACEHOLDER_BEGIN;
gBattleTextBuff2[1] = B_BUFF_MON_NICK_WITH_PREFIX;
gBattleTextBuff2[2] = gBankInMenu;
gBattleTextBuff2[3] = pokemon_order_func(gBattlerPartyIndexes[gBankInMenu]);
gBattleTextBuff2[4] = EOS;
gBattleTextBuff2[4] = B_BUFF_EOS;
BattleStringExpandPlaceholders(BattleText_PreventedSwitch, gStringVar4);
}

View File

@ -22,9 +22,6 @@ void sub_809665C(void);
void sub_80966F4(const u8 *sourceString, u16 x, u16 y);
void sub_8096784(struct Sprite *sprite);
EWRAM_DATA struct PokemonStorage gPokemonStorage = {0};
EWRAM_DATA u8 gUnknown_02038470[3] = {};
EWRAM_DATA u8 gUnknown_02038473 = 0;
EWRAM_DATA u8 gUnknown_02038474 = 0;
EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_02038478 = NULL;

View File

@ -7,6 +7,8 @@
#include "string_util.h"
#include "strings2.h"
EWRAM_DATA struct PokemonStorage gPokemonStorage = {0};
void HandleDrawSaveWindowInfo(s16 left, s16 top)
{
u32 width = 12;

View File

@ -15,35 +15,34 @@ gUnknown_020238C8 = .; /* 20238C8 */
. += 0x4;
gDisplayedStringBattle = .; /* 20238CC */
. += 0x12C;
. += 0x12C; /* 300 */
. = ALIGN(2);
gBattleTypeFlags = .; /* 20239F8 */
. += 0x4;
. += 0x2;
. = ALIGN(4);
gUnknown_020239FC = .; /* 20239FC */
. += 0x4;
. = ALIGN(4);
gMultiPartnerParty = .; /* 2023A00 */
. += 0x4;
gUnknown_02023A04 = .; /* 2023A04 */
. += 0x10;
gUnknown_02023A14 = .; /* 2023A14 */
. += 0x4C;
. += 0x60;
#if DEBUG
. = ALIGN(4);
gUnknown_02023A14_4C = .;
. += 0x4;
gUnknown_02023A14_50 = .;
. += 0x2;
. += 0x1;
. = ALIGN(2);
gUnknown_Debug_2023A76 = .;
gUnknown_Debug_2023A76_ = .;
. += 0x8C;
. = ALIGN(2);
gUnknown_Debug_2023B02 = .;
. += 0x60;
@ -317,6 +316,8 @@ gBattleMonForms = .; /* 2024E84 */
. = ALIGN(4); src/pokemon_menu.o(ewram_data);
. = ALIGN(4); src/pokedex.o(ewram_data);
. = ALIGN(4); src/trainer_card.o(ewram_data);
. = ALIGN(4); src/save_menu_util.o(ewram_data);
. = ALIGN(4); src/battle_party_menu.o(ewram_data);
. = ALIGN(4); src/pokemon_storage_system.o(ewram_data);
. = ALIGN(4); src/pokemon_storage_system_2.o(ewram_data);
. = ALIGN(4); src/pokemon_storage_system_3.o(ewram_data);