summaryrefslogtreecommitdiff
path: root/src/easy_chat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/easy_chat.c')
-rw-r--r--src/easy_chat.c162
1 files changed, 83 insertions, 79 deletions
diff --git a/src/easy_chat.c b/src/easy_chat.c
index ba54de783..86349cbd6 100644
--- a/src/easy_chat.c
+++ b/src/easy_chat.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "alloc.h"
+#include "malloc.h"
#include "bard_music.h"
#include "bg.h"
#include "data.h"
@@ -31,6 +31,7 @@
#include "constants/event_objects.h"
#include "constants/flags.h"
#include "constants/lilycove_lady.h"
+#include "constants/mauville_old_man.h"
#include "constants/songs.h"
#include "constants/species.h"
#include "constants/rgb.h"
@@ -121,8 +122,8 @@ static void sub_811B768(void);
static u8 sub_811B960(u8);
static void sub_811B9A0(void);
static u8 sub_811BA1C(void);
-static int sub_811BF20(void);
-static u16 sub_811BF40(void);
+static int DidPlayerInputMysteryGiftPhrase(void);
+static u16 DidPlayerInputABerryMasterWifePhrase(void);
static bool8 sub_811CE94(void);
static void sub_811CF64(void);
static void sub_811CF04(void);
@@ -209,7 +210,7 @@ static void sub_811D830(void);
static void sub_811D058(u8, u8, const u8 *, u8, u8, u8, u8, u8, u8);
static void sub_811DD84(void);
static void sub_811D6F4(void);
-static void sub_811D758(void);
+static void PrintEasyChatKeyboardText(void);
static void sub_811D794(void);
static const u8 *GetEasyChatWordGroupName(u8);
static void sub_811D864(u8, u8);
@@ -220,8 +221,8 @@ static void sub_811E0EC(s8, s8);
static void sub_811E1A4(s8, s8);
static void sub_811E2DC(struct Sprite *);
static void sub_811E34C(u8, u8);
-static bool8 sub_811F0F8(void);
-static u16 sub_811F108(void);
+static bool8 EasyChatIsNationalPokedexEnabled(void);
+static u16 GetRandomUnlockedEasyChatPokemon(void);
static void sub_811F2D4(void);
static void sub_811F46C(void);
static u8 *CopyEasyChatWordPadded(u8 *, u16, u16);
@@ -531,11 +532,11 @@ static const u16 sMysteryGiftPhrase[] = {
};
static const u16 sBerryMasterWifePhrases[][2] = {
- {EC_WORD_GREAT, EC_WORD_BATTLE},
- {EC_WORD_CHALLENGE, EC_WORD_CONTEST},
- {EC_WORD_OVERWHELMING, EC_POKEMON(LATIAS)},
- {EC_WORD_COOL, EC_POKEMON(LATIOS)},
- {EC_WORD_SUPER, EC_WORD_HUSTLE},
+ [PHRASE_GREAT_BATTLE - 1] = {EC_WORD_GREAT, EC_WORD_BATTLE},
+ [PHRASE_CHALLENGE_CONTEST - 1] = {EC_WORD_CHALLENGE, EC_WORD_CONTEST},
+ [PHRASE_OVERWHELMING_LATIAS - 1] = {EC_WORD_OVERWHELMING, EC_POKEMON(LATIAS)},
+ [PHRASE_COOL_LATIOS - 1] = {EC_WORD_COOL, EC_POKEMON(LATIOS)},
+ [PHRASE_SUPER_HUSTLE - 1] = {EC_WORD_SUPER, EC_WORD_HUSTLE},
};
static const u16 sEasyChatTriangleCursorPalette[] = INCBIN_U16("graphics/easy_chat/triangle_cursor.gbapal");
@@ -698,11 +699,12 @@ static const struct WindowTemplate sEasyChatYesNoWindowTemplate = {
static const u8 sText_Clear17[] = _("{CLEAR 17}");
-static const u8 *const sUnknown_08597C90[] = {
- gUnknown_862B810,
- gUnknown_862B832,
- gUnknown_862B84B,
- gUnknown_862B86C,
+static const u8 *const sEasyChatKeyboardText[] =
+{
+ gText_EasyChatKeyboard_ABCDEFothers,
+ gText_EasyChatKeyboard_GHIJKL,
+ gText_EasyChatKeyboard_MNOPQRS,
+ gText_EasyChatKeyboard_TUVWXYZ,
};
static const struct SpriteSheet sEasyChatSpriteSheets[] = {
@@ -1262,7 +1264,7 @@ void ShowEasyChatScreen(void)
break;
case EASY_CHAT_TYPE_BARD_SONG:
bard = &gSaveBlock1Ptr->oldMan.bard;
- for (i = 0; i < 6; i ++)
+ for (i = 0; i < BARD_SONG_LENGTH; i ++)
bard->temporaryLyrics[i] = bard->songLyrics[i];
words = bard->temporaryLyrics;
@@ -1318,7 +1320,7 @@ void ShowEasyChatScreen(void)
words = &gSaveBlock1Ptr->lilycoveLady.quiz.correctAnswer;
break;
case EASY_CHAT_TYPE_APPRENTICE:
- words = gSaveBlock2Ptr->apprentices[0].easyChatWords;
+ words = gSaveBlock2Ptr->apprentices[0].speechWon;
break;
case EASY_CHAT_TYPE_QUESTIONNAIRE:
words = sub_801B058();
@@ -1339,7 +1341,7 @@ static void CB2_QuizLadyQuestion(void)
switch (gMain.state)
{
case 0:
- FadeScreen(1, 0);
+ FadeScreen(FADE_TO_BLACK, 0);
break;
case 1:
if (!gPaletteFade.active)
@@ -2596,17 +2598,17 @@ static int FooterHasFourOptions_(void)
return FooterHasFourOptions();
}
-u8 sub_811BC7C(const u16 *arg0, u8 arg1)
+static bool8 IsPhraseDifferentThanPlayerInput(const u16 *phrase, u8 phraseLength)
{
u8 i;
- for (i = 0; i < arg1; i++)
+ for (i = 0; i < phraseLength; i++)
{
- if (arg0[i] != sEasyChatScreen->ecWordBuffer[i])
- return 1;
+ if (phrase[i] != sEasyChatScreen->ecWordBuffer[i])
+ return TRUE;
}
- return 0;
+ return FALSE;
}
static u8 GetDisplayedPersonType(void)
@@ -2729,7 +2731,7 @@ static void sub_811BE9C(void)
FlagSet(FLAG_SYS_CHAT_USED);
break;
case EASY_CHAT_TYPE_QUESTIONNAIRE:
- if (sub_811BF20())
+ if (DidPlayerInputMysteryGiftPhrase())
gSpecialVar_0x8004 = 2;
else
gSpecialVar_0x8004 = 0;
@@ -2739,22 +2741,22 @@ static void sub_811BE9C(void)
gSpecialVar_0x8004 = sub_81226D8(sEasyChatScreen->ecWordBuffer);
break;
case EASY_CHAT_TYPE_GOOD_SAYING:
- gSpecialVar_0x8004 = sub_811BF40();
+ gSpecialVar_0x8004 = DidPlayerInputABerryMasterWifePhrase();
break;
}
}
-static int sub_811BF20(void)
+static int DidPlayerInputMysteryGiftPhrase(void)
{
- return sub_811BC7C(sMysteryGiftPhrase, ARRAY_COUNT(sMysteryGiftPhrase)) == 0;
+ return !IsPhraseDifferentThanPlayerInput(sMysteryGiftPhrase, ARRAY_COUNT(sMysteryGiftPhrase));
}
-static u16 sub_811BF40(void)
+static u16 DidPlayerInputABerryMasterWifePhrase(void)
{
int i;
- for (i = 0; i < 5; i++)
+ for (i = 0; i < (int)ARRAY_COUNT(sBerryMasterWifePhrases); i++)
{
- if (!sub_811BC7C(sBerryMasterWifePhrases[i], ARRAY_COUNT(*sBerryMasterWifePhrases)))
+ if (!IsPhraseDifferentThanPlayerInput(sBerryMasterWifePhrases[i], ARRAY_COUNT(*sBerryMasterWifePhrases)))
return i + 1;
}
@@ -3701,7 +3703,7 @@ static void sub_811CFCC(void)
xOffset = GetStringCenterAlignXOffset(1, titleText, 144);
FillWindowPixelBuffer(0, PIXEL_FILL(0));
- sub_811D058(0, 1, titleText, xOffset, 1, 0xFF, 0, 2, 3);
+ sub_811D058(0, 1, titleText, xOffset, 1, 0xFF, TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY);
PutWindowTilemap(0);
CopyWindowToVram(0, 3);
}
@@ -3711,12 +3713,12 @@ void sub_811D028(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, vo
AddTextPrinterParameterized(windowId, fontId, str, x, y, speed, callback);
}
-static void sub_811D058(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, u8 red, u8 green, u8 blue)
+static void sub_811D058(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, u8 bg, u8 fg, u8 shadow)
{
u8 color[3];
- color[0] = red;
- color[1] = green;
- color[2] = blue;
+ color[0] = bg;
+ color[1] = fg;
+ color[2] = shadow;
AddTextPrinterParameterized3(windowId, fontId, left, top, color, speed, str);
}
@@ -3967,7 +3969,7 @@ static void sub_811D698(u32 arg0)
sub_811D6F4();
break;
case 1:
- sub_811D758();
+ PrintEasyChatKeyboardText();
break;
case 2:
sub_811D794();
@@ -4010,12 +4012,12 @@ static void sub_811D6F4(void)
}
}
-static void sub_811D758(void)
+static void PrintEasyChatKeyboardText(void)
{
u32 i;
- for (i = 0; i < ARRAY_COUNT(sUnknown_08597C90); i++)
- sub_811D028(2, 1, sUnknown_08597C90[i], 10, 97 + i * 16, 0xFF, NULL);
+ for (i = 0; i < ARRAY_COUNT(sEasyChatKeyboardText); i++)
+ sub_811D028(2, 1, sEasyChatKeyboardText[i], 10, 97 + i * 16, 0xFF, NULL);
}
static void sub_811D794(void)
@@ -4087,7 +4089,7 @@ static void sub_811D864(u8 arg0, u8 arg1)
if (!sub_811BF88(easyChatWord))
sub_811D028(2, 1, sUnknown_0203A11C->unkCC, (j * 13 + 3) * 8, y, 0xFF, NULL);
else
- sub_811D058(2, 1, sUnknown_0203A11C->unkCC, (j * 13 + 3) * 8, y, 0xFF, 1, 5, 3);
+ sub_811D058(2, 1, sUnknown_0203A11C->unkCC, (j * 13 + 3) * 8, y, 0xFF, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_RED, TEXT_COLOR_LIGHT_GREY);
}
}
@@ -4808,7 +4810,7 @@ static void sub_811E948(void)
PutWindowTilemap(windowId);
}
-static bool8 sub_811EA28(u8 groupId)
+static bool8 IsEasyChatGroupUnlocked(u8 groupId)
{
switch (groupId)
{
@@ -4819,7 +4821,7 @@ static bool8 sub_811EA28(u8 groupId)
case EC_GROUP_MOVE_2:
return FlagGet(FLAG_SYS_GAME_CLEAR);
case EC_GROUP_POKEMON_2:
- return sub_811F0F8();
+ return EasyChatIsNationalPokedexEnabled();
default:
return TRUE;
}
@@ -4830,7 +4832,7 @@ u16 EasyChat_GetNumWordsInGroup(u8 groupId)
if (groupId == EC_GROUP_POKEMON)
return GetNationalPokedexCount(FLAG_GET_SEEN);
- if (sub_811EA28(groupId))
+ if (IsEasyChatGroupUnlocked(groupId))
return gEasyChatGroups[groupId].numEnabledWords;
return 0;
@@ -5037,24 +5039,24 @@ static u16 GetEasyChatWordStringLength(u16 easyChatWord)
}
}
-bool8 sub_811EDC4(const u16 *easyChatWords, u8 arg1, u8 arg2, u16 arg3)
+static bool8 CanPhraseFitInXRowsYCols(const u16 *easyChatWords, u8 numRows, u8 numColumns, u16 maxLength)
{
u8 i, j;
- for (i = 0; i < arg2; i++)
+ for (i = 0; i < numColumns; i++)
{
- u16 totalLength = arg1 - 1;
- for (j = 0; j < arg1; j++)
+ u16 totalLength = numRows - 1;
+ for (j = 0; j < numRows; j++)
totalLength += GetEasyChatWordStringLength(*(easyChatWords++));
- if (totalLength > arg3)
+ if (totalLength > maxLength)
return TRUE;
}
return FALSE;
}
-u16 sub_811EE38(u16 groupId)
+u16 GetRandomEasyChatWordFromGroup(u16 groupId)
{
u16 index = Random() % gEasyChatGroups[groupId].numWords;
if (groupId == EC_GROUP_POKEMON
@@ -5068,18 +5070,18 @@ u16 sub_811EE38(u16 groupId)
return EC_WORD(groupId, index);
}
-u16 sub_811EE90(u16 groupId)
+u16 GetRandomEasyChatWordFromUnlockedGroup(u16 groupId)
{
- if (!sub_811EA28(groupId))
+ if (!IsEasyChatGroupUnlocked(groupId))
return 0xFFFF;
if (groupId == EC_GROUP_POKEMON)
- return sub_811F108();
+ return GetRandomUnlockedEasyChatPokemon();
- return sub_811EE38(groupId);
+ return GetRandomEasyChatWordFromGroup(groupId);
}
-void sub_811EECC(void)
+void ShowEasyChatProfile(void)
{
u16 *easyChatWords;
int columns, rows;
@@ -5092,7 +5094,7 @@ void sub_811EECC(void)
break;
case 1:
easyChatWords = gSaveBlock1Ptr->easyChatBattleStart;
- if (sub_811EDC4(gSaveBlock1Ptr->easyChatBattleStart, 3, 2, 18))
+ if (CanPhraseFitInXRowsYCols(gSaveBlock1Ptr->easyChatBattleStart, 3, 2, 18))
{
columns = 2;
rows = 3;
@@ -5121,23 +5123,24 @@ void sub_811EECC(void)
ShowFieldAutoScrollMessage(gStringVar4);
}
-void sub_811EF6C(void)
+// The phrase that a man in Dewford Hall suggests has a "deep link" to the current trendy phrase
+void BufferDeepLinkPhrase(void)
{
int groupId = Random() & 1 ? EC_GROUP_HOBBIES : EC_GROUP_LIFESTYLE;
- u16 easyChatWord = sub_811EE90(groupId);
+ u16 easyChatWord = GetRandomEasyChatWordFromUnlockedGroup(groupId);
CopyEasyChatWord(gStringVar2, easyChatWord);
}
-static bool8 sub_811EF98(u8 additionalPhraseId)
+static bool8 IsAdditionalPhraseUnlocked(u8 additionalPhraseId)
{
int byteOffset = additionalPhraseId / 8;
int shift = additionalPhraseId % 8;
return (gSaveBlock1Ptr->additionalPhrases[byteOffset] >> shift) & 1;
}
-void sub_811EFC0(u8 additionalPhraseId)
+void UnlockAdditionalPhrase(u8 additionalPhraseId)
{
- if (additionalPhraseId < 33)
+ if (additionalPhraseId < NUM_ADDITIONAL_PHRASES)
{
int byteOffset = additionalPhraseId / 8;
int shift = additionalPhraseId % 8;
@@ -5145,32 +5148,32 @@ void sub_811EFC0(u8 additionalPhraseId)
}
}
-u8 sub_811EFF0(void)
+static u8 GetNumAdditionalPhrasesUnlocked(void)
{
u8 i;
u8 numAdditionalPhrasesUnlocked;
- for (i = 0, numAdditionalPhrasesUnlocked = 0; i < 33; i++)
+ for (i = 0, numAdditionalPhrasesUnlocked = 0; i < NUM_ADDITIONAL_PHRASES; i++)
{
- if (sub_811EF98(i))
+ if (IsAdditionalPhraseUnlocked(i))
numAdditionalPhrasesUnlocked++;
}
return numAdditionalPhrasesUnlocked;
}
-u16 sub_811F01C(void)
+u16 GetNewHipsterPhraseToTeach(void)
{
u16 i;
u16 additionalPhraseId;
- u8 numAdditionalPhrasesUnlocked = sub_811EFF0();
- if (numAdditionalPhrasesUnlocked == 33)
+ u8 numAdditionalPhrasesUnlocked = GetNumAdditionalPhrasesUnlocked();
+ if (numAdditionalPhrasesUnlocked == NUM_ADDITIONAL_PHRASES)
return 0xFFFF;
- additionalPhraseId = Random() % (33 - numAdditionalPhrasesUnlocked);
- for (i = 0; i < 33; i++)
+ additionalPhraseId = Random() % (NUM_ADDITIONAL_PHRASES - numAdditionalPhrasesUnlocked);
+ for (i = 0; i < NUM_ADDITIONAL_PHRASES; i++)
{
- if (!sub_811EF98(i))
+ if (!IsAdditionalPhraseUnlocked(i))
{
if (additionalPhraseId)
{
@@ -5178,7 +5181,7 @@ u16 sub_811F01C(void)
}
else
{
- sub_811EFC0(i);
+ UnlockAdditionalPhrase(i);
return EC_WORD(EC_GROUP_TRENDY_SAYING, i);
}
}
@@ -5187,17 +5190,18 @@ u16 sub_811F01C(void)
return 0xFFFF;
}
-u16 sub_811F090(void)
+// Unused
+u16 GetRandomTaughtHipsterPhrase(void)
{
u16 i;
- u16 additionalPhraseId = sub_811EFF0();
+ u16 additionalPhraseId = GetNumAdditionalPhrasesUnlocked();
if (additionalPhraseId == 0)
return 0xFFFF;
additionalPhraseId = Random() % additionalPhraseId;
- for (i = 0; i < 33; i++)
+ for (i = 0; i < NUM_ADDITIONAL_PHRASES; i++)
{
- if (sub_811EF98(i))
+ if (IsAdditionalPhraseUnlocked(i))
{
if (additionalPhraseId)
additionalPhraseId--;
@@ -5209,12 +5213,12 @@ u16 sub_811F090(void)
return 0xFFFF;
}
-static bool8 sub_811F0F8(void)
+static bool8 EasyChatIsNationalPokedexEnabled(void)
{
return IsNationalPokedexEnabled();
}
-static u16 sub_811F108(void)
+static u16 GetRandomUnlockedEasyChatPokemon(void)
{
u16 i;
u16 numWords;
@@ -5496,7 +5500,7 @@ static bool8 sub_811F764(u16 wordIndex, u8 groupId)
case EC_GROUP_MOVE_2:
return TRUE;
case EC_GROUP_TRENDY_SAYING:
- return sub_811EF98(wordIndex);
+ return IsAdditionalPhraseUnlocked(wordIndex);
default:
return gEasyChatGroups[groupId].wordData.words[wordIndex].enabled;
}
@@ -5544,7 +5548,7 @@ bool32 sub_811F8D8(int easyChatWord)
int groupId = EC_GROUP(easyChatWord);
int mask = 0x7F;
int index = EC_INDEX(easyChatWord);
- if (!sub_811EA28(groupId & mask))
+ if (!IsEasyChatGroupUnlocked(groupId & mask))
return FALSE;
else
return sub_811F764(index, groupId & mask);