Skip to content

Commit

Permalink
Remove redundant move grammar tables (Credit: Kurausukun)
Browse files Browse the repository at this point in the history
  • Loading branch information
lioniac committed Mar 17, 2021
1 parent 96c6f5a commit 312f088
Showing 1 changed file with 1 addition and 210 deletions.
211 changes: 1 addition & 210 deletions src/battle_message.c
Expand Up @@ -37,8 +37,6 @@ struct BattleWindowText
static EWRAM_DATA u8 sBattlerAbilities[MAX_BATTLERS_COUNT] = {};
static EWRAM_DATA struct BattleMsgData *sBattleMsgDataPtr = NULL;

static void ChooseMoveUsedParticle(u8 *textPtr);
static void ChooseTypeOfMoveUsedString(u8 *textPtr);
static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst);

static const u8 sText_Empty1[] = _("");
Expand Down Expand Up @@ -417,7 +415,7 @@ static const u8 sText_FoePkmnPrefix3[] = _("Foe");
static const u8 sText_AllyPkmnPrefix2[] = _("Ally");
static const u8 sText_FoePkmnPrefix4[] = _("Foe");
static const u8 sText_AllyPkmnPrefix3[] = _("Ally");
static const u8 sText_AttackerUsedX[] = _("{B_ATK_NAME_WITH_PREFIX} used\n{B_BUFF2}");
static const u8 sText_AttackerUsedX[] = _("{B_ATK_NAME_WITH_PREFIX} used\n{B_BUFF2}!");
static const u8 sText_ExclamationMark[] = _("!");
static const u8 sText_ExclamationMark2[] = _("!");
static const u8 sText_ExclamationMark3[] = _("!");
Expand Down Expand Up @@ -1335,130 +1333,6 @@ static const u8 *const sATypeMove_Table[] = {
gUnknown_83FE976
};

static const u16 sGrammarMoveUsedTable[] = {
MOVE_SWORDS_DANCE,
MOVE_STRENGTH,
MOVE_GROWTH,
MOVE_HARDEN,
MOVE_MINIMIZE,
MOVE_SMOKESCREEN,
MOVE_WITHDRAW,
MOVE_DEFENSE_CURL,
MOVE_EGG_BOMB,
MOVE_SMOG,
MOVE_BONE_CLUB,
MOVE_FLASH,
MOVE_SPLASH,
MOVE_ACID_ARMOR,
MOVE_BONEMERANG,
MOVE_REST,
MOVE_SHARPEN,
MOVE_SUB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MOVE_LICK,
MOVE_CLAMP,
MOVE_CONSTRICT,
MOVE_POISON_GAS,
MOVE_BUBBLE,
MOVE_SLASH,
MOVE_SPIDER_WEB,
MOVE_NIGHTMARE,
MOVE_CURSE,
MOVE_FORESIGHT,
MOVE_CHARM,
MOVE_ATTRACT,
MOVE_ROCK_SMASH,
MOVE_UPROAR,
MOVE_SPIT_UP,
MOVE_SWALLOW,
MOVE_TORMENT,
MOVE_FLATTER,
MOVE_ROLE_PLAY,
MOVE_ENDEAVOR,
MOVE_TICKLE,
MOVE_COVET,
MOVE_NONE
};

// code
void BufferStringBattle(u16 stringId)
{
Expand Down Expand Up @@ -1622,14 +1496,11 @@ void BufferStringBattle(u16 stringId)
}
break;
case STRINGID_USEDMOVE: // pokemon used a move msg
ChooseMoveUsedParticle(gBattleTextBuff1); // buff1 doesn't appear in the string, leftover from japanese move names

if (sBattleMsgDataPtr->currentMove >= MOVES_COUNT)
StringCopy(gBattleTextBuff2, sATypeMove_Table[*(&gBattleStruct->stringMoveType)]);
else
StringCopy(gBattleTextBuff2, gMoveNames[sBattleMsgDataPtr->currentMove]);

ChooseTypeOfMoveUsedString(gBattleTextBuff2);
stringPtr = sText_AttackerUsedX;
break;
case STRINGID_BATTLEEND: // battle end
Expand Down Expand Up @@ -2269,86 +2140,6 @@ 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 ChooseTypeOfMoveUsedString
// below to effect changes in the meaning of the line.
static void ChooseMoveUsedParticle(u8* textBuff)
{
s32 counter = 0;
u32 i = 0;

while (counter != MAX_MON_MOVES)
{
if (sGrammarMoveUsedTable[i] == 0)
counter++;
if (sGrammarMoveUsedTable[i++] == sBattleMsgDataPtr->currentMove)
break;
}

if (counter >= 0)
{
if (counter <= 2)
StringCopy(textBuff, sText_SpaceIs); // is
else if (counter <= MAX_MON_MOVES)
StringCopy(textBuff, sText_ApostropheS); // 's
}
}

// Appends "!" to the text buffer `dst`. In the original Japanese this looked
// 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>!".
//
// sText_ExclamationMark2 was "を つかった!". This resulted in the translation
// "<NAME> used <ATTACK>!", which was used for all attacks in English.
//
// sText_ExclamationMark3 was "した!". This was used for those moves whose
// names were verbs, such as Recover, and resulted in translations like "<NAME>
// recovered itself!".
//
// sText_ExclamationMark4 was "を した!" This resulted in a translation of
// "<NAME> did an <ATTACK>!".
//
// sText_ExclamationMark5 was " こうげき!" This resulted in a translation of
// "<NAME>'s <ATTACK> attack!".
static void ChooseTypeOfMoveUsedString(u8* dst)
{
s32 counter = 0;
s32 i = 0;

while (*dst != EOS)
dst++;

while (counter != MAX_MON_MOVES)
{
if (sGrammarMoveUsedTable[i] == MOVE_NONE)
counter++;
if (sGrammarMoveUsedTable[i++] == sBattleMsgDataPtr->currentMove)
break;
}

switch (counter)
{
case 0:
StringCopy(dst, sText_ExclamationMark);
break;
case 1:
StringCopy(dst, sText_ExclamationMark2);
break;
case 2:
StringCopy(dst, sText_ExclamationMark3);
break;
case 3:
StringCopy(dst, sText_ExclamationMark4);
break;
case 4:
StringCopy(dst, sText_ExclamationMark5);
break;
}
}

static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = {
{PIXEL_FILL(0xf), 2, 0x02, 2, 0, 2, 1, 0x1, 0xf, 0x6},
{PIXEL_FILL(0xf), 2, 0x02, 2, 0, 2, 0, 0x1, 0xf, 0x6},
Expand Down

0 comments on commit 312f088

Please sign in to comment.