summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_main.c1
-rw-r--r--src/battle_message.c51
-rw-r--r--src/battle_script_commands.c39
3 files changed, 46 insertions, 45 deletions
diff --git a/src/battle_main.c b/src/battle_main.c
index a0d812a94..a846f5769 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -561,6 +561,7 @@ static const u8 sUnknown_0831BCE0[][3] = {{0, 0, 0}, {3, 5, 0}, {2, 3, 0}, {1, 2
static const u8 sUnknown_0831BCEF[] = {4, 3, 2, 1};
static const u8 sUnknown_0831BCF3[] = {4, 4, 4, 4};
+// code
void CB2_InitBattle(void)
{
MoveSaveBlocks_ResetHeap();
diff --git a/src/battle_message.c b/src/battle_message.c
index 896b2197e..41b36ae13 100644
--- a/src/battle_message.c
+++ b/src/battle_message.c
@@ -45,7 +45,6 @@ extern const u8 gText_PkmnBoxLanettesPCFull[];
extern const u8 gText_PkmnTransferredSomeonesPC[];
extern const u8 gText_PkmnTransferredLanettesPC[];
-extern u16 sub_8068BB0(void); // pokemon_1
extern u8 sub_81A4D00(void); // battle_frontier_2
extern u8 GetFrontierOpponentClass(u16 trainerId); // battle_tower
extern u8 sub_81D5530(u16 trainerId); // pokenav
@@ -58,8 +57,8 @@ extern void sub_81D572C(u8 arg0, u16 trainerId); // pokenav
extern void GetFrontierTrainerName(u8 *dst, u16 trainerId);
// this file's functions
-static void sub_814F8F8(u8 *textPtr);
-static void sub_814F950(u8 *dst);
+static void ChooseMoveUsedParticle(u8 *textPtr);
+static void ChooseTypeOfMoveUsedString(u8 *dst);
static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst);
// ewram variables
@@ -1322,8 +1321,8 @@ static const u8 sText_LinkTrainerWantsToBattlePause[] = _("{B_20}\nwants to batt
static const u8 sText_TwoLinkTrainersWantToBattlePause[] = _("{B_20} and {B_21}\nwant to battle!{PAUSE 49}");
// This is four lists of moves which use a different attack string in Japanese
-// to the default. See the documentation for sub_814F950 for more detail.
-static const u16 sUnknownMoveTable[] =
+// to the default. See the documentation for ChooseTypeOfMoveUsedString for more detail.
+static const u16 sGrammarMoveUsedTable[] =
{
MOVE_SWORDS_DANCE, MOVE_STRENGTH, MOVE_GROWTH,
MOVE_HARDEN, MOVE_MINIMIZE, MOVE_SMOKESCREEN,
@@ -2142,14 +2141,14 @@ void BufferStringBattle(u16 stringID)
}
break;
case STRINGID_USEDMOVE: // pokemon used a move msg
- sub_814F8F8(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 (gStringInfo->currentMove > LAST_MOVE_INDEX)
StringCopy(gBattleTextBuff2, sATypeMove_Table[*(&gBattleStruct->stringMoveType)]);
else
StringCopy(gBattleTextBuff2, gMoveNames[gStringInfo->currentMove]);
- sub_814F950(gBattleTextBuff2);
+ ChooseTypeOfMoveUsedString(gBattleTextBuff2);
stringPtr = sText_AttackerUsedX;
break;
case STRINGID_BATTLEEND: // battle end
@@ -2740,10 +2739,6 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
return dstID;
}
-// TODO: move these to a general header like util.h
-#define ByteRead16(ptr) ((ptr)[0] | ((ptr)[1] << 8))
-#define ByteRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24)
-
static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
{
u32 srcID = 1;
@@ -2757,7 +2752,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
switch (src[srcID])
{
case B_BUFF_STRING: // battle string
- hword = ByteRead16(&src[srcID + 1]);
+ hword = T1_READ_16(&src[srcID + 1]);
StringAppend(dst, gBattleStringsTable[hword - BATTLESTRINGS_ID_ADDER]);
srcID += 3;
break;
@@ -2768,17 +2763,17 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
value = 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 B_BUFF_MOVE: // move name
- StringAppend(dst, gMoveNames[ByteRead16(&src[srcID + 1])]);
+ StringAppend(dst, gMoveNames[T1_READ_16(&src[srcID + 1])]);
srcID += 3;
break;
case B_BUFF_TYPE: // type name
@@ -2808,7 +2803,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
srcID += 2;
break;
case B_BUFF_SPECIES: // species name
- GetSpeciesName(dst, ByteRead16(&src[srcID + 1]));
+ GetSpeciesName(dst, T1_READ_16(&src[srcID + 1]));
srcID += 3;
break;
case B_BUFF_MON_NICK: // poke nick without prefix
@@ -2828,7 +2823,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
srcID += 2;
break;
case B_BUFF_ITEM: // item name
- hword = ByteRead16(&src[srcID + 1]);
+ hword = T1_READ_16(&src[srcID + 1]);
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
{
if (hword == ITEM_ENIGMA_BERRY)
@@ -2839,13 +2834,19 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
StringAppend(dst, sText_BerrySuffix);
}
else
+ {
StringAppend(dst, sText_EnigmaBerry);
+ }
}
else
+ {
CopyItemName(hword, dst);
+ }
}
else
+ {
CopyItemName(hword, dst);
+ }
srcID += 3;
break;
}
@@ -2854,18 +2855,18 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
// Loads one of two text strings into the provided buffer. This is functionally
// unused, since the value loaded into the buffer is not read; it loaded one of
-// two particles (either "は" or "の") which works in tandem with sub_814F950
+// two particles (either "は" or "の") which works in tandem with ChooseTypeOfMoveUsedString
// below to effect changes in the meaning of the line.
-static void sub_814F8F8(u8* textBuff)
+static void ChooseMoveUsedParticle(u8* textBuff)
{
s32 counter = 0;
u32 i = 0;
while (counter != 4)
{
- if (sUnknownMoveTable[i] == 0)
+ if (sGrammarMoveUsedTable[i] == 0)
counter++;
- if (sUnknownMoveTable[i++] == gStringInfo->currentMove)
+ if (sGrammarMoveUsedTable[i++] == gStringInfo->currentMove)
break;
}
@@ -2879,7 +2880,7 @@ static void sub_814F8F8(u8* textBuff)
}
// Appends "!" to the text buffer `dst`. In the original Japanese this looked
-// into the table of moves at sUnknownMoveTable and varied the line accordingly.
+// into the table of moves at sGrammarMoveUsedTable and varied the line accordingly.
//
// sText_ExclamationMark was a plain "!", used for any attack not on the list.
// It resulted in the translation "<NAME>'s <ATTACK>!".
@@ -2896,7 +2897,7 @@ static void sub_814F8F8(u8* textBuff)
//
// sText_ExclamationMark5 was " こうげき!" This resulted in a translation of
// "<NAME>'s <ATTACK> attack!".
-static void sub_814F950(u8* dst)
+static void ChooseTypeOfMoveUsedString(u8* dst)
{
s32 counter = 0;
s32 i = 0;
@@ -2906,9 +2907,9 @@ static void sub_814F950(u8* dst)
while (counter != 4)
{
- if (sUnknownMoveTable[i] == MOVE_NONE)
+ if (sGrammarMoveUsedTable[i] == MOVE_NONE)
counter++;
- if (sUnknownMoveTable[i++] == gStringInfo->currentMove)
+ if (sGrammarMoveUsedTable[i++] == gStringInfo->currentMove)
break;
}
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index fb77ab4c4..ecba9f934 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -67,7 +67,6 @@ extern bool8 sub_81B1250(void); // ?
extern bool8 InBattlePike(void);
extern bool8 InBattlePyramid(void);
extern u16 GetBattlePyramidPickupItemId(void);
-extern u8 Overworld_GetMapTypeOfSaveblockLocation(void);
extern u8 sub_813B21C(void);
extern u16 get_unknown_box_id(void);
@@ -185,7 +184,7 @@ static void atk5B_yesnoboxstoplearningmove(void);
static void atk5C_hitanimation(void);
static void atk5D_getmoneyreward(void);
static void atk5E(void);
-static void atk5F(void);
+static void atk5F_swapattackerwithtarget(void);
static void atk60_incrementgamestat(void);
static void atk61_drawpartystatussummary(void);
static void atk62_hidepartystatussummary(void);
@@ -327,7 +326,7 @@ static void atkE9_setweatherballtype(void);
static void atkEA_tryrecycleitem(void);
static void atkEB_settypetoterrain(void);
static void atkEC_pursuitrelated(void);
-static void atkEF_snatchsetbanks(void);
+static void atkEF_snatchsetbattlers(void);
static void atkEE_removelightscreenreflect(void);
static void atkEF_handleballthrow(void);
static void atkF0_givecaughtmon(void);
@@ -437,7 +436,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
atk5C_hitanimation,
atk5D_getmoneyreward,
atk5E,
- atk5F,
+ atk5F_swapattackerwithtarget,
atk60_incrementgamestat,
atk61_drawpartystatussummary,
atk62_hidepartystatussummary,
@@ -579,7 +578,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
atkEA_tryrecycleitem,
atkEB_settypetoterrain,
atkEC_pursuitrelated,
- atkEF_snatchsetbanks,
+ atkEF_snatchsetbattlers,
atkEE_removelightscreenreflect,
atkEF_handleballthrow,
atkF0_givecaughtmon,
@@ -1172,7 +1171,7 @@ static void atk01_accuracycheck(void)
calc = (calc * 130) / 100; // 1.3 compound eyes boost
if (WEATHER_HAS_EFFECT && gBattleMons[gBattlerTarget].ability == ABILITY_SAND_VEIL && gBattleWeather & WEATHER_SANDSTORM_ANY)
calc = (calc * 80) / 100; // 1.2 sand veil loss
- if (gBattleMons[gBattlerAttacker].ability == ABILITY_HUSTLE && type < 9)
+ if (gBattleMons[gBattlerAttacker].ability == ABILITY_HUSTLE && IS_MOVE_PHYSICAL(type))
calc = (calc * 80) / 100; // 1.2 hustle loss
if (gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY)
@@ -4676,12 +4675,12 @@ static void atk49_moveend(void)
gBattleScripting.atk49_state++;
break;
case 14: // This case looks interesting, although I am not certain what it does. Probably fine tunes edge cases.
- if (gHitMarker & HITMARKER_PURSUIT_TRAP)
+ if (gHitMarker & HITMARKER_SWAP_ATTACKER_TARGET)
{
gActiveBattler = gBattlerAttacker;
gBattlerAttacker = gBattlerTarget;
gBattlerTarget = gActiveBattler;
- gHitMarker &= ~(HITMARKER_PURSUIT_TRAP);
+ gHitMarker &= ~(HITMARKER_SWAP_ATTACKER_TARGET);
}
if (gHitMarker & HITMARKER_ATTACKSTRING_PRINTED)
{
@@ -5950,7 +5949,7 @@ static void atk5E(void)
if (gBattleControllerExecFlags == 0)
{
s32 i;
- struct BattlePokemon* bufferPoke = (struct BattlePokemon*) &gBattleBufferB[gActiveBattler][4];
+ struct BattlePokemon *bufferPoke = (struct BattlePokemon*) &gBattleBufferB[gActiveBattler][4];
for (i = 0; i < 4; i++)
{
gBattleMons[gActiveBattler].moves[i] = bufferPoke->moves[i];
@@ -5962,16 +5961,16 @@ static void atk5E(void)
}
}
-static void atk5F(void)
+static void atk5F_swapattackerwithtarget(void)
{
gActiveBattler = gBattlerAttacker;
gBattlerAttacker = gBattlerTarget;
gBattlerTarget = gActiveBattler;
- if (gHitMarker & HITMARKER_PURSUIT_TRAP)
- gHitMarker &= ~(HITMARKER_PURSUIT_TRAP);
+ if (gHitMarker & HITMARKER_SWAP_ATTACKER_TARGET)
+ gHitMarker &= ~(HITMARKER_SWAP_ATTACKER_TARGET);
else
- gHitMarker |= HITMARKER_PURSUIT_TRAP;
+ gHitMarker |= HITMARKER_SWAP_ATTACKER_TARGET;
gBattlescriptCurrInstr++;
}
@@ -5987,8 +5986,8 @@ static void atk60_incrementgamestat(void)
static void atk61_drawpartystatussummary(void)
{
s32 i;
- struct Pokemon* party;
- struct HpAndStatus hpStatuses[6];
+ struct Pokemon *party;
+ struct HpAndStatus hpStatuses[PARTY_SIZE];
if (gBattleControllerExecFlags)
return;
@@ -6000,7 +5999,7 @@ static void atk61_drawpartystatussummary(void)
else
party = gEnemyParty;
- for (i = 0; i < 6; i++)
+ for (i = 0; i < PARTY_SIZE; i++)
{
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
@@ -8595,7 +8594,7 @@ static void atkAE_healpartystatus(void)
if (gCurrentMove == MOVE_HEAL_BELL)
{
- struct Pokemon* party;
+ struct Pokemon *party;
s32 i;
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
@@ -8633,7 +8632,7 @@ static void atkAE_healpartystatus(void)
}
}
- for (i = 0; i < 6; i++)
+ for (i = 0; i < PARTY_SIZE; i++)
{
u16 species = GetMonData(&party[i], MON_DATA_SPECIES2);
u8 abilityBit = GetMonData(&party[i], MON_DATA_ALT_ABILITY);
@@ -10053,7 +10052,7 @@ static void atkEC_pursuitrelated(void)
}
}
-static void atkEF_snatchsetbanks(void)
+static void atkEF_snatchsetbattlers(void)
{
gEffectBattler = gBattlerAttacker;
@@ -10131,7 +10130,7 @@ static void atkEF_handleballthrow(void)
ballMultiplier = 10;
break;
case ITEM_DIVE_BALL:
- if (Overworld_GetMapTypeOfSaveblockLocation() == 5)
+ if (Overworld_GetMapTypeOfSaveblockLocation() == MAP_TYPE_UNDERWATER)
ballMultiplier = 35;
else
ballMultiplier = 10;