Rename symbols using Ruby as a reference

This commit is contained in:
PikalaxALT 2018-05-07 18:11:20 -04:00
parent 0231ed13ee
commit 61cc1d5574
11 changed files with 226 additions and 230 deletions

View File

@ -1438,7 +1438,7 @@ _080E791A:
add r1, r9 add r1, r9
movs r2, 0x40 movs r2, 0x40
bl memcpy bl memcpy
bl sub_8120670 bl ResetMauvilleOldManFlag
add sp, 0x10 add sp, 0x10
pop {r3,r4} pop {r3,r4}
mov r8, r3 mov r8, r3

View File

@ -51,8 +51,8 @@ _08133A12:
.pool .pool
thumb_func_end sub_81339F8 thumb_func_end sub_81339F8
thumb_func_start sub_8133A60 thumb_func_start Trader_ResetFlag
sub_8133A60: @ 8133A60 Trader_ResetFlag: @ 8133A60
ldr r0, =gSaveBlock1Ptr ldr r0, =gSaveBlock1Ptr
ldr r0, [r0] ldr r0, [r0]
ldr r1, =0x00002e59 ldr r1, =0x00002e59
@ -61,7 +61,7 @@ sub_8133A60: @ 8133A60
strb r1, [r0] strb r1, [r0]
bx lr bx lr
.pool .pool
thumb_func_end sub_8133A60 thumb_func_end Trader_ResetFlag
thumb_func_start sub_8133A78 thumb_func_start sub_8133A78
sub_8133A78: @ 8133A78 sub_8133A78: @ 8133A78

View File

@ -1 +1 @@
gUnknown_03006130 gBardSong

View File

@ -10,7 +10,7 @@ MauvilleCity_PokemonCenter_1F_MapScript1_210E66: @ 8210E66
end end
MauvilleCity_PokemonCenter_1F_EventScript_210E74:: @ 8210E74 MauvilleCity_PokemonCenter_1F_EventScript_210E74:: @ 8210E74
special sub_8120B5C special ScrSpecial_SetMauvilleOldManMapObjGfx
end end
MauvilleCity_PokemonCenter_1F_EventScript_210E78:: @ 8210E78 MauvilleCity_PokemonCenter_1F_EventScript_210E78:: @ 8210E78

View File

@ -1,5 +1,5 @@
MauvilleCity_PokemonCenter_1F_EventScript_28E066:: @ 828E066 MauvilleCity_PokemonCenter_1F_EventScript_28E066:: @ 828E066
special sub_81201DC special ScrSpecial_GetCurrentMauvilleMan
switch VAR_RESULT switch VAR_RESULT
case 0, MauvilleCity_PokemonCenter_1F_EventScript_28E0A6 case 0, MauvilleCity_PokemonCenter_1F_EventScript_28E0A6
case 1, MauvilleCity_PokemonCenter_1F_EventScript_28E167 case 1, MauvilleCity_PokemonCenter_1F_EventScript_28E167
@ -20,9 +20,9 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E0A6:: @ 828E0A6
MauvilleCity_PokemonCenter_1F_EventScript_28E0C7:: @ 828E0C7 MauvilleCity_PokemonCenter_1F_EventScript_28E0C7:: @ 828E0C7
setvar VAR_0x8004, 0 setvar VAR_0x8004, 0
special sub_8120340 special ScrSpecial_PlayBardSong
delay 60 delay 60
special sub_81201F4 special ScrSpecial_HasBardSongBeenChanged
compare VAR_RESULT, 0 compare VAR_RESULT, 0
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E0F4 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E0F4
msgbox MauvilleCity_PokemonCenter_1F_Text_2903E6, 4 msgbox MauvilleCity_PokemonCenter_1F_Text_2903E6, 4
@ -51,12 +51,12 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E113:: @ 828E113
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E15D goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E15D
msgbox MauvilleCity_PokemonCenter_1F_Text_2904C1, 4 msgbox MauvilleCity_PokemonCenter_1F_Text_2904C1, 4
setvar VAR_0x8004, 1 setvar VAR_0x8004, 1
special sub_8120340 special ScrSpecial_PlayBardSong
delay 60 delay 60
msgbox MauvilleCity_PokemonCenter_1F_Text_2904EB, 5 msgbox MauvilleCity_PokemonCenter_1F_Text_2904EB, 5
compare VAR_RESULT, 0 compare VAR_RESULT, 0
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E113 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E113
special sub_8120210 special ScrSpecial_SaveBardSongLyrics
msgbox MauvilleCity_PokemonCenter_1F_Text_290514, 4 msgbox MauvilleCity_PokemonCenter_1F_Text_290514, 4
release release
end end
@ -71,7 +71,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E167:: @ 828E167
faceplayer faceplayer
setflag FLAG_SYS_HIPSTER_MEET setflag FLAG_SYS_HIPSTER_MEET
msgbox MauvilleCity_PokemonCenter_1F_Text_29054C, 4 msgbox MauvilleCity_PokemonCenter_1F_Text_29054C, 4
special sub_8120358 special ScrSpecial_GetHipsterSpokenFlag
compare VAR_RESULT, 0 compare VAR_RESULT, 0
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E18C goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E18C
msgbox MauvilleCity_PokemonCenter_1F_Text_290598, 4 msgbox MauvilleCity_PokemonCenter_1F_Text_290598, 4
@ -79,7 +79,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E167:: @ 828E167
end end
MauvilleCity_PokemonCenter_1F_EventScript_28E18C:: @ 828E18C MauvilleCity_PokemonCenter_1F_EventScript_28E18C:: @ 828E18C
special sub_812038C special ScrSpecial_HipsterTeachWord
compare VAR_RESULT, 1 compare VAR_RESULT, 1
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E1A4 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E1A4
msgbox MauvilleCity_PokemonCenter_1F_Text_290602, 4 msgbox MauvilleCity_PokemonCenter_1F_Text_290602, 4
@ -88,7 +88,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E18C:: @ 828E18C
MauvilleCity_PokemonCenter_1F_EventScript_28E1A4:: @ 828E1A4 MauvilleCity_PokemonCenter_1F_EventScript_28E1A4:: @ 828E1A4
msgbox MauvilleCity_PokemonCenter_1F_Text_290666, 4 msgbox MauvilleCity_PokemonCenter_1F_Text_290666, 4
special sub_8120374 special ScrSpecial_SetHipsterSpokenFlag
release release
end end
@ -813,20 +813,20 @@ MauvilleCity_PokemonCenter_1F_EventScript_29014A:: @ 829014A
msgbox MauvilleCity_PokemonCenter_1F_Text_28E5F6, 5 msgbox MauvilleCity_PokemonCenter_1F_Text_28E5F6, 5
compare VAR_RESULT, 0 compare VAR_RESULT, 0
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_290219 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_290219
specialvar VAR_RESULT, sub_81213B0 specialvar VAR_RESULT, ScrSpecial_StorytellerGetFreeStorySlot
compare VAR_RESULT, 0 compare VAR_RESULT, 0
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_2901DA goto_eq MauvilleCity_PokemonCenter_1F_EventScript_2901DA
message MauvilleCity_PokemonCenter_1F_Text_28E673 message MauvilleCity_PokemonCenter_1F_Text_28E673
waitmessage waitmessage
special sub_8121388 special ScrSpecial_StorytellerStoryListMenu
waitstate waitstate
compare VAR_RESULT, 0 compare VAR_RESULT, 0
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_2901B7 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_2901B7
setvar VAR_0x8008, 1 setvar VAR_0x8008, 1
special sub_812139C special ScrSpecial_StorytellerDisplayStory
waitmessage waitmessage
waitbuttonpress waitbuttonpress
specialvar VAR_RESULT, sub_81213D8 specialvar VAR_RESULT, ScrSpecial_StorytellerUpdateStat
compare VAR_RESULT, 0 compare VAR_RESULT, 0
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_2901BD goto_eq MauvilleCity_PokemonCenter_1F_EventScript_2901BD
goto MauvilleCity_PokemonCenter_1F_EventScript_29020F goto MauvilleCity_PokemonCenter_1F_EventScript_29020F
@ -837,7 +837,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_2901B7:: @ 82901B7
MauvilleCity_PokemonCenter_1F_EventScript_2901BD:: @ 82901BD MauvilleCity_PokemonCenter_1F_EventScript_2901BD:: @ 82901BD
msgbox MauvilleCity_PokemonCenter_1F_Text_28E78A, 4 msgbox MauvilleCity_PokemonCenter_1F_Text_28E78A, 4
specialvar VAR_RESULT, sub_8121424 specialvar VAR_RESULT, ScrSpecial_HasStorytellerAlreadyRecorded
compare VAR_RESULT, 1 compare VAR_RESULT, 1
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_29022D goto_eq MauvilleCity_PokemonCenter_1F_EventScript_29022D
goto MauvilleCity_PokemonCenter_1F_EventScript_2901E2 goto MauvilleCity_PokemonCenter_1F_EventScript_2901E2
@ -849,7 +849,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_2901E2:: @ 82901E2
msgbox MauvilleCity_PokemonCenter_1F_Text_28E7EE, 5 msgbox MauvilleCity_PokemonCenter_1F_Text_28E7EE, 5
compare VAR_RESULT, 0 compare VAR_RESULT, 0
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_290219 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_290219
specialvar VAR_RESULT, sub_8121450 specialvar VAR_RESULT, ScrSpecial_StorytellerInitializeRandomStat
compare VAR_RESULT, 1 compare VAR_RESULT, 1
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_29020F goto_eq MauvilleCity_PokemonCenter_1F_EventScript_29020F
msgbox MauvilleCity_PokemonCenter_1F_Text_28E881, 4 msgbox MauvilleCity_PokemonCenter_1F_Text_28E881, 4
@ -903,7 +903,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_2902F6:: @ 82902F6
end end
MauvilleCity_PokemonCenter_1F_EventScript_290317:: @ 8290317 MauvilleCity_PokemonCenter_1F_EventScript_290317:: @ 8290317
special sub_81203C4 special ScrSpecial_GiddyShouldTellAnotherTale
compare VAR_RESULT, 1 compare VAR_RESULT, 1
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_290359 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_290359
compare VAR_RESULT, 0 compare VAR_RESULT, 0
@ -911,7 +911,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_290317:: @ 8290317
end end
MauvilleCity_PokemonCenter_1F_EventScript_290331:: @ 8290331 MauvilleCity_PokemonCenter_1F_EventScript_290331:: @ 8290331
special sub_81203C4 special ScrSpecial_GiddyShouldTellAnotherTale
compare VAR_RESULT, 1 compare VAR_RESULT, 1
goto_eq MauvilleCity_PokemonCenter_1F_EventScript_29034B goto_eq MauvilleCity_PokemonCenter_1F_EventScript_29034B
compare VAR_RESULT, 0 compare VAR_RESULT, 0
@ -924,7 +924,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_29034B:: @ 829034B
end end
MauvilleCity_PokemonCenter_1F_EventScript_290359:: @ 8290359 MauvilleCity_PokemonCenter_1F_EventScript_290359:: @ 8290359
special sub_81203FC special ScrSpecial_GenerateGiddyLine
special ShowFieldMessageStringVar4 special ShowFieldMessageStringVar4
waitmessage waitmessage
yesnobox 20, 8 yesnobox 20, 8

View File

@ -108,22 +108,22 @@ gSpecials:: @ 81DBA64
def_special sub_80FAFF8 def_special sub_80FAFF8
def_special easy_chat_input_maybe def_special easy_chat_input_maybe
def_special sub_811EECC def_special sub_811EECC
def_special sub_81201DC def_special ScrSpecial_GetCurrentMauvilleMan
def_special sub_81201F4 def_special ScrSpecial_HasBardSongBeenChanged
def_special sub_8120210 def_special ScrSpecial_SaveBardSongLyrics
def_special sub_8120358 def_special ScrSpecial_GetHipsterSpokenFlag
def_special sub_8120374 def_special ScrSpecial_SetHipsterSpokenFlag
def_special sub_812038C def_special ScrSpecial_HipsterTeachWord
def_special sub_8120340 def_special ScrSpecial_PlayBardSong
def_special sub_8120B5C def_special ScrSpecial_SetMauvilleOldManMapObjGfx
def_special sub_81203FC def_special ScrSpecial_GenerateGiddyLine
def_special sub_81203C4 def_special ScrSpecial_GiddyShouldTellAnotherTale
def_special sub_81213B0 def_special ScrSpecial_StorytellerGetFreeStorySlot
def_special sub_812139C def_special ScrSpecial_StorytellerDisplayStory
def_special sub_8121388 def_special ScrSpecial_StorytellerStoryListMenu
def_special sub_81213D8 def_special ScrSpecial_StorytellerUpdateStat
def_special sub_8121450 def_special ScrSpecial_StorytellerInitializeRandomStat
def_special sub_8121424 def_special ScrSpecial_HasStorytellerAlreadyRecorded
def_special sub_8133EC0 def_special sub_8133EC0
def_special sub_8133CD8 def_special sub_8133CD8
def_special sub_8133CF4 def_special sub_8133CF4

View File

@ -453,7 +453,7 @@ struct MauvilleManStoryteller
u8 gameStatIDs[4]; u8 gameStatIDs[4];
u8 trainerNames[4][7]; u8 trainerNames[4][7];
u8 statValues[4][4]; u8 statValues[4][4];
u8 unk34[4]; u8 language[4];
}; };
struct MauvilleManGiddy struct MauvilleManGiddy
@ -477,9 +477,9 @@ struct MauvilleOldManTrader
{ {
u8 unk0; u8 unk0;
u8 unk1[4]; u8 unk1[4];
u8 unk5[4][11]; u8 playerNames[4][11];
u8 unk31; u8 unk31;
u8 unk32[4]; u8 language[4];
}; };
typedef union OldMan typedef union OldMan

View File

@ -12,7 +12,8 @@ enum MauvilleOldManType
}; };
void SetMauvilleOldMan(void); void SetMauvilleOldMan(void);
u8 sub_81201C8(void); u8 GetCurrentMauvilleOldMan(void);
extern struct BardSong gUnknown_03006130; extern struct BardSong gBardSong;
void ScrSpecial_SetMauvilleOldManMapObjGfx(void);
#endif // GUARD_MAUVILLE_OLD_MAN_H #endif // GUARD_MAUVILLE_OLD_MAN_H

View File

@ -7,5 +7,7 @@
void sub_8133DA0(u8 taskId); void sub_8133DA0(u8 taskId);
void sub_8133E1C(u8 taskId); void sub_8133E1C(u8 taskId);
void sub_81339F8(void);
void Trader_ResetFlag(void);
#endif //GUARD_TRADER_H #endif //GUARD_TRADER_H

View File

@ -1146,7 +1146,7 @@ const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8 graphicsId)
} }
if (graphicsId == 0x45) if (graphicsId == 0x45)
{ {
bard = sub_81201C8(); bard = GetCurrentMauvilleOldMan();
return gMauvilleOldManGraphicsInfoPointers[bard]; return gMauvilleOldManGraphicsInfoPointers[bard];
} }
if (graphicsId >= NUM_OBJECT_GRAPHICS_INFO) if (graphicsId >= NUM_OBJECT_GRAPHICS_INFO)

View File

@ -21,27 +21,25 @@
#include "overworld.h" #include "overworld.h"
#include "field_message_box.h" #include "field_message_box.h"
#include "script_menu.h" #include "script_menu.h"
#include "trader.h"
#define CHAR_SONG_WORD_SEPARATOR 0x37 #define CHAR_SONG_WORD_SEPARATOR 0x37
extern struct MusicPlayerInfo gMPlayInfo_SE2; extern struct MusicPlayerInfo gMPlayInfo_SE2;
void sub_81204DC(void); static void InitGiddyTaleList(void);
void sub_81206C0(bool8 useTemporaryLyrics); // StartBardSong static void StartBardSong(bool8 useTemporaryLyrics);
void sub_8120944(u8 taskId); static void Task_BardSong(u8 taskId);
void sub_8120B5C(void); static void StorytellerSetup(void);
void sub_8120E08(void); // StorytellerSetup static void Storyteller_ResetFlag(void);
void sub_8120E50(void);
void sub_81339F8(void); // TraderSetup
void sub_8133A60(void);
IWRAM_DATA u8 gUnknown_03001178; IWRAM_DATA u8 sSelectedStory;
struct BardSong gUnknown_03006130; struct BardSong gBardSong;
EWRAM_DATA u16 gUnknown_0203A128 = 0; static EWRAM_DATA u16 sUnknownBardRelated = 0;
EWRAM_DATA struct MauvilleManStoryteller * gUnknown_0203A12C = NULL; static EWRAM_DATA struct MauvilleManStoryteller * sStorytellerPtr = NULL;
EWRAM_DATA u8 gUnknown_0203A130 = 0; static EWRAM_DATA u8 sStorytellerWindowId = 0;
static const u16 sDefaultBardSongLyrics[6] = { static const u16 sDefaultBardSongLyrics[6] = {
EC_WORD_SHAKE, EC_WORD_SHAKE,
@ -97,7 +95,7 @@ static void SetupHipster(void)
static void SetupStoryteller(void) static void SetupStoryteller(void)
{ {
sub_8120E08(); StorytellerSetup();
} }
static void SetupGiddy(void) static void SetupGiddy(void)
@ -138,22 +136,22 @@ void SetMauvilleOldMan(void)
SetupGiddy(); SetupGiddy();
break; break;
} }
sub_8120B5C(); ScrSpecial_SetMauvilleOldManMapObjGfx();
} }
u8 sub_81201C8(void) // GetCurrentMauvilleOldMan u8 GetCurrentMauvilleOldMan(void)
{ {
struct MauvilleManCommon *common = &gSaveBlock1Ptr->oldMan.common; struct MauvilleManCommon *common = &gSaveBlock1Ptr->oldMan.common;
return common->id; return common->id;
} }
void sub_81201DC(void) // ScrSpecial_GetCurrentMauvilleMan void ScrSpecial_GetCurrentMauvilleMan(void)
{ {
gSpecialVar_Result = sub_81201C8(); gSpecialVar_Result = GetCurrentMauvilleOldMan();
} }
void sub_81201F4(void) // ScrSpecial_HasBardSongBeenChanged void ScrSpecial_HasBardSongBeenChanged(void)
{ {
u16 *scriptResult = &gSpecialVar_Result; // why?? u16 *scriptResult = &gSpecialVar_Result; // why??
struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard;
@ -161,7 +159,7 @@ void sub_81201F4(void) // ScrSpecial_HasBardSongBeenChanged
*scriptResult = bard->hasChangedSong; *scriptResult = bard->hasChangedSong;
} }
void sub_8120210(void) // ScrSpecial_SaveBardSongLyrics void ScrSpecial_SaveBardSongLyrics(void)
{ {
u16 i; u16 i;
struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard;
@ -178,20 +176,14 @@ void sub_8120210(void) // ScrSpecial_SaveBardSongLyrics
} }
// Copies lyrics into gStringVar4 // Copies lyrics into gStringVar4
void sub_8120280(void) static void PrepareSongText(void)
{ {
struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard;
u16 specialVar = gSpecialVar_0x8004; // It's a bit odd to use this temp variable, but it seems needed to match. u16 * lyrics = gSpecialVar_0x8004 == 0 ? bard->songLyrics : bard->temporaryLyrics;
u16 *lyrics; u8 * wordEnd = gStringVar4;
u8 * str = wordEnd;
u16 lineNum; u16 lineNum;
u8 *wordEnd;
u8 *str;
lyrics = bard->temporaryLyrics;
if (specialVar == 0)
lyrics = bard->songLyrics;
wordEnd = gStringVar4;
str = wordEnd;
// Put three words on each line // Put three words on each line
for (lineNum = 0; lineNum < 2; lineNum++) for (lineNum = 0; lineNum < 2; lineNum++)
{ {
@ -233,13 +225,13 @@ void sub_8120280(void)
} }
} }
void sub_8120340(void) // ScrSpecial_PlayBardSong void ScrSpecial_PlayBardSong(void)
{ {
sub_81206C0(gSpecialVar_0x8004); StartBardSong(gSpecialVar_0x8004);
ScriptContext1_Stop(); ScriptContext1_Stop();
} }
void sub_8120358(void) // ScrSpecial_GetHipsterSpokenFlag void ScrSpecial_GetHipsterSpokenFlag(void)
{ {
u16 *scriptResult = &gSpecialVar_Result; // again?? u16 *scriptResult = &gSpecialVar_Result; // again??
struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster;
@ -247,14 +239,14 @@ void sub_8120358(void) // ScrSpecial_GetHipsterSpokenFlag
*scriptResult = hipster->alreadySpoken; *scriptResult = hipster->alreadySpoken;
} }
void sub_8120374(void) // ScrSpecial_SetHipsterSpokenFlag void ScrSpecial_SetHipsterSpokenFlag(void)
{ {
struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster;
hipster->alreadySpoken = TRUE; hipster->alreadySpoken = TRUE;
} }
void sub_812038C(void) // ScrSpecial_HipsterTeachWord void ScrSpecial_HipsterTeachWord(void)
{ {
u16 var = sub_811F01C(); u16 var = sub_811F01C();
@ -269,7 +261,7 @@ void sub_812038C(void) // ScrSpecial_HipsterTeachWord
} }
} }
void sub_81203C4(void) // ScrSpecial_GiddyShouldTellAnotherTale void ScrSpecial_GiddyShouldTellAnotherTale(void)
{ {
struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy; struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy;
@ -284,12 +276,12 @@ void sub_81203C4(void) // ScrSpecial_GiddyShouldTellAnotherTale
} }
} }
void sub_81203FC(void) // ScrSpecial_GenerateGiddyLine void ScrSpecial_GenerateGiddyLine(void)
{ {
struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy; struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy;
if (giddy->taleCounter == 0) if (giddy->taleCounter == 0)
sub_81204DC(); InitGiddyTaleList();
if (giddy->randomWords[giddy->taleCounter] != 0xFFFF) // is not the last element of the array? if (giddy->randomWords[giddy->taleCounter] != 0xFFFF) // is not the last element of the array?
{ {
@ -315,7 +307,7 @@ void sub_81203FC(void) // ScrSpecial_GenerateGiddyLine
gSpecialVar_Result = TRUE; gSpecialVar_Result = TRUE;
} }
void sub_81204DC(void) static void InitGiddyTaleList(void)
{ {
struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy; struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy;
u16 arr[][2] = { u16 arr[][2] = {
@ -371,50 +363,50 @@ void sub_81204DC(void)
} }
} }
} }
void sub_8120628(void) static void ResetBardFlag(void)
{ {
struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard;
bard->hasChangedSong = FALSE; bard->hasChangedSong = FALSE;
} }
void sub_8120640(void) static void ResetHipsterFlag(void)
{ {
struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster;
hipster->alreadySpoken = FALSE; hipster->alreadySpoken = FALSE;
} }
void sub_8120658(void) static void ResetTraderFlag(void)
{ {
sub_8133A60(); Trader_ResetFlag();
} }
void sub_8120664(void) static void ResetStorytellerFlag(void)
{ {
sub_8120E50(); Storyteller_ResetFlag();
} }
void sub_8120670(void) // ResetMauvilleOldManFlag void ResetMauvilleOldManFlag(void) // ResetMauvilleOldManFlag
{ {
switch (sub_81201C8()) switch (GetCurrentMauvilleOldMan())
{ {
case MAUVILLE_MAN_BARD: case MAUVILLE_MAN_BARD:
sub_8120628(); ResetBardFlag();
break; break;
case MAUVILLE_MAN_HIPSTER: case MAUVILLE_MAN_HIPSTER:
sub_8120640(); ResetHipsterFlag();
break; break;
case MAUVILLE_MAN_STORYTELLER: case MAUVILLE_MAN_STORYTELLER:
sub_8120664(); ResetStorytellerFlag();
break; break;
case MAUVILLE_MAN_TRADER: case MAUVILLE_MAN_TRADER:
sub_8120658(); ResetTraderFlag();
break; break;
case MAUVILLE_MAN_GIDDY: case MAUVILLE_MAN_GIDDY:
break; break;
} }
sub_8120B5C(); ScrSpecial_SetMauvilleOldManMapObjGfx();
} }
@ -426,32 +418,32 @@ void sub_8120670(void) // ResetMauvilleOldManFlag
#define MACRO1(a) (((a) & 3) + (((a) / 8) & 1)) #define MACRO1(a) (((a) & 3) + (((a) / 8) & 1))
#define MACRO2(a) (((a) % 4) + (((a) / 8) & 1)) #define MACRO2(a) (((a) % 4) + (((a) / 8) & 1))
void sub_81206C0(bool8 useTemporaryLyrics) static void StartBardSong(bool8 useTemporaryLyrics)
{ {
u8 taskId = CreateTask(sub_8120944, 80); u8 taskId = CreateTask(Task_BardSong, 80);
gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics; gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics;
} }
void sub_81206F0(void) static void sub_81206F0(void)
{ {
gUnknown_03002F84 = FALSE; gUnknown_03002F84 = FALSE;
} }
void sub_81206FC(struct TextSubPrinter * printer, u16 a1) static void BardSong_TextSubPrinter(struct TextSubPrinter * printer, u16 a1)
{ {
gUnknown_03002F84 = TRUE; gUnknown_03002F84 = TRUE;
} }
void sub_8120708(const u8 * src) static void sub_8120708(const u8 * src)
{ {
NewMenuHelpers_DrawDialogueFrame(0, 0); NewMenuHelpers_DrawDialogueFrame(0, 0);
PrintTextOnWindow(0, 1, src, 0, 1, 1, sub_81206FC); PrintTextOnWindow(0, 1, src, 0, 1, 1, BardSong_TextSubPrinter);
gUnknown_03002F84 = TRUE; gUnknown_03002F84 = TRUE;
CopyWindowToVram(0, 3); CopyWindowToVram(0, 3);
} }
void sub_8120748(struct Task *task, struct BardSong *song) // BardSing static void BardSing(struct Task *task, struct BardSong *song)
{ {
switch (task->tState) switch (task->tState)
{ {
@ -554,15 +546,15 @@ void sub_8120748(struct Task *task, struct BardSong *song) // BardSing
} }
} }
void sub_8120944(u8 taskId) static void Task_BardSong(u8 taskId)
{ {
struct Task *task = &gTasks[taskId]; // r5 struct Task *task = &gTasks[taskId]; // r5
sub_8120748(task, &gUnknown_03006130); BardSing(task, &gBardSong);
switch (task->tState) switch (task->tState)
{ {
case 0: // Initialize song case 0: // Initialize song
sub_8120280(); PrepareSongText();
sub_8120708(gStringVar4); sub_8120708(gStringVar4);
task->data[1] = 0; task->data[1] = 0;
task->data[2] = 0; task->data[2] = 0;
@ -593,14 +585,14 @@ void sub_8120944(u8 taskId)
wordLen++; wordLen++;
} }
if (!task->tUseTemporaryLyrics) if (!task->tUseTemporaryLyrics)
gUnknown_0203A128 = MACRO2(bard->songLyrics[task->tCurrWord]); sUnknownBardRelated = MACRO2(bard->songLyrics[task->tCurrWord]);
else else
gUnknown_0203A128 = MACRO2(bard->temporaryLyrics[task->tCurrWord]); sUnknownBardRelated = MACRO2(bard->temporaryLyrics[task->tCurrWord]);
temp = gUnknown_03006130.length / wordLen; temp = gBardSong.length / wordLen;
zero = 0; zero = 0;
gUnknown_03006130.length = temp; gBardSong.length = temp;
if (gUnknown_03006130.length <= 0) if (gBardSong.length <= 0)
gUnknown_03006130.length = 1; gBardSong.length = 1;
task->tCurrWord++; task->tCurrWord++;
if (task->data[2] == 0) if (task->data[2] == 0)
task->tState = 3; task->tState = 3;
@ -664,7 +656,7 @@ void sub_8120944(u8 taskId)
case 2: case 2:
task->tCharIndex++; task->tCharIndex++;
task->data[1] = 0; task->data[1] = 0;
task->data[2] = gUnknown_03006130.length; task->data[2] = gBardSong.length;
task->tState = 4; task->tState = 4;
break; break;
} }
@ -679,11 +671,13 @@ void sub_8120944(u8 taskId)
sub_8197224(); sub_8197224();
} }
void sub_8120B5C(void) void ScrSpecial_SetMauvilleOldManMapObjGfx(void)
{ {
VarSet(VAR_0x4010, MAP_OBJ_GFX_BARD); VarSet(VAR_0x4010, MAP_OBJ_GFX_BARD);
} }
// Language fixers?
void sub_8120B70(union OldMan * oldMan) void sub_8120B70(union OldMan * oldMan)
{ {
s32 i; s32 i;
@ -696,9 +690,9 @@ void sub_8120B70(union OldMan * oldMan)
struct MauvilleOldManTrader * trader = &oldMan->trader; struct MauvilleOldManTrader * trader = &oldMan->trader;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (trader->unk32[i] == LANGUAGE_JAPANESE) if (trader->language[i] == LANGUAGE_JAPANESE)
{ {
ConvertInternationalString(trader->unk5[i], LANGUAGE_JAPANESE); ConvertInternationalString(trader->playerNames[i], LANGUAGE_JAPANESE);
} }
} }
} }
@ -717,7 +711,7 @@ void sub_8120B70(union OldMan * oldMan)
memset(sp00, CHAR_SPACE, 8); memset(sp00, CHAR_SPACE, 8);
StringCopy(sp00, gText_Friend); StringCopy(sp00, gText_Friend);
memcpy(storyteller->trainerNames[i], sp00, 7); memcpy(storyteller->trainerNames[i], sp00, 7);
storyteller->unk34[i] = GAME_LANGUAGE; storyteller->language[i] = GAME_LANGUAGE;
} }
} }
} }
@ -738,13 +732,13 @@ void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (IsStringJapanese(trader->unk5[i])) if (IsStringJapanese(trader->playerNames[i]))
{ {
trader->unk32[i] = r8; trader->language[i] = r8;
} }
else else
{ {
trader->unk32[i] = r7; trader->language[i] = r7;
} }
} }
} }
@ -757,11 +751,11 @@ void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3)
{ {
if (IsStringJapanese(storyteller->trainerNames[i])) if (IsStringJapanese(storyteller->trainerNames[i]))
{ {
storyteller->unk34[i] = r8; storyteller->language[i] = r8;
} }
else else
{ {
storyteller->unk34[i] = r7; storyteller->language[i] = r7;
} }
} }
} }
@ -814,9 +808,9 @@ void sub_8120CD0(union OldMan * oldMan, u32 unused, u32 a2)
memcpy(sp00, storyteller->trainerNames[i], 7); memcpy(sp00, storyteller->trainerNames[i], 7);
sp00[7] = EOS; sp00[7] = EOS;
if (IsStringJapanese(sp00)) if (IsStringJapanese(sp00))
storyteller->unk34[i] = LANGUAGE_JAPANESE; storyteller->language[i] = LANGUAGE_JAPANESE;
else else
storyteller->unk34[i] = GAME_LANGUAGE; storyteller->language[i] = GAME_LANGUAGE;
} }
} }
} }
@ -836,23 +830,23 @@ void sub_8120D34(union OldMan * oldMan, u32 r1, u32 r6)
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
u8 * str = trader->unk5[i]; u8 * str = trader->playerNames[i];
if (str[0] == EXT_CTRL_CODE_BEGIN && str[1] == EXT_CTRL_CODE_JPN) if (str[0] == EXT_CTRL_CODE_BEGIN && str[1] == EXT_CTRL_CODE_JPN)
{ {
StripExtCtrlCodes(str); StripExtCtrlCodes(str);
trader->unk32[i] = LANGUAGE_JAPANESE; trader->language[i] = LANGUAGE_JAPANESE;
} }
else else
trader->unk32[i] = r6; trader->language[i] = r6;
} }
} }
else else
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (trader->unk32[i] == LANGUAGE_JAPANESE) if (trader->language[i] == LANGUAGE_JAPANESE)
{ {
StripExtCtrlCodes(trader->unk5[i]); StripExtCtrlCodes(trader->playerNames[i]);
} }
} }
} }
@ -869,7 +863,7 @@ void sub_8120D34(union OldMan * oldMan, u32 r1, u32 r6)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (storyteller->gameStatIDs[i] != 0) if (storyteller->gameStatIDs[i] != 0)
storyteller->unk34[i] = r6; storyteller->language[i] = r6;
} }
} }
} }
@ -916,7 +910,7 @@ struct Story
const u8 *fullText; const u8 *fullText;
}; };
const struct Story gUnknown_0859F048[] = { static const struct Story sStorytellerStories[] = {
{GAME_STAT_50, 1, MauvilleCity_PokemonCenter_1F_Text_28E930, MauvilleCity_PokemonCenter_1F_Text_28E947, MauvilleCity_PokemonCenter_1F_Text_28E956}, {GAME_STAT_50, 1, MauvilleCity_PokemonCenter_1F_Text_28E930, MauvilleCity_PokemonCenter_1F_Text_28E947, MauvilleCity_PokemonCenter_1F_Text_28E956},
{GAME_STAT_STARTED_TRENDS, 1, MauvilleCity_PokemonCenter_1F_Text_28E9D7, MauvilleCity_PokemonCenter_1F_Text_28E9EF, MauvilleCity_PokemonCenter_1F_Text_28E9FE}, {GAME_STAT_STARTED_TRENDS, 1, MauvilleCity_PokemonCenter_1F_Text_28E9D7, MauvilleCity_PokemonCenter_1F_Text_28E9EF, MauvilleCity_PokemonCenter_1F_Text_28E9FE},
{GAME_STAT_PLANTED_BERRIES, 1, MauvilleCity_PokemonCenter_1F_Text_28EA7D, MauvilleCity_PokemonCenter_1F_Text_28EA98, MauvilleCity_PokemonCenter_1F_Text_28EAA8}, {GAME_STAT_PLANTED_BERRIES, 1, MauvilleCity_PokemonCenter_1F_Text_28EA7D, MauvilleCity_PokemonCenter_1F_Text_28EA98, MauvilleCity_PokemonCenter_1F_Text_28EAA8},
@ -955,84 +949,84 @@ const struct Story gUnknown_0859F048[] = {
{GAME_STAT_ENTERED_HOT_SPRINGS, 1, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB} {GAME_STAT_ENTERED_HOT_SPRINGS, 1, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB}
}; };
void sub_8120E08(void) // StorytellerSetup static void StorytellerSetup(void)
{ {
s32 i; s32 i;
gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller;
gUnknown_0203A12C->id = MAUVILLE_MAN_STORYTELLER; sStorytellerPtr->id = MAUVILLE_MAN_STORYTELLER;
gUnknown_0203A12C->alreadyRecorded = FALSE; sStorytellerPtr->alreadyRecorded = FALSE;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
gUnknown_0203A12C->gameStatIDs[i] = 0; sStorytellerPtr->gameStatIDs[i] = 0;
gUnknown_0203A12C->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead? sStorytellerPtr->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead?
} }
} }
void sub_8120E50(void) static void Storyteller_ResetFlag(void)
{ {
gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller;
gUnknown_0203A12C->id = MAUVILLE_MAN_STORYTELLER; sStorytellerPtr->id = MAUVILLE_MAN_STORYTELLER;
gUnknown_0203A12C->alreadyRecorded = FALSE; sStorytellerPtr->alreadyRecorded = FALSE;
} }
u32 sub_8120E74(u8 stat) // StorytellerGetGameStat static u32 StorytellerGetGameStat(u8 stat)
{ {
if (stat == 50) if (stat == 50)
stat = 0; stat = 0;
return GetGameStat(stat); return GetGameStat(stat);
} }
const struct Story *sub_8120E88(u32 stat) // GetStoryByStat static const struct Story *GetStoryByStat(u32 stat)
{ {
s32 i; s32 i;
for (i = 0; i < 36; i++) for (i = 0; i < 36; i++)
{ {
if (gUnknown_0859F048[i].stat == stat) if (sStorytellerStories[i].stat == stat)
return &gUnknown_0859F048[i]; return &sStorytellerStories[i];
} }
return &gUnknown_0859F048[35]; return &sStorytellerStories[35];
} }
const u8 *sub_8120EB4(u32 stat) // GetStoryTitleByStat static const u8 *GetStoryTitleByStat(u32 stat)
{ {
return sub_8120E88(stat)->title; return GetStoryByStat(stat)->title;
} }
const u8 *sub_8120EC0(u32 stat) // GetStoryTextByStat static const u8 *GetStoryTextByStat(u32 stat)
{ {
return sub_8120E88(stat)->fullText; return GetStoryByStat(stat)->fullText;
} }
const u8 *sub_8120ECC(u32 stat) // GetStoryActionByStat static const u8 *GetStoryActionByStat(u32 stat)
{ {
return sub_8120E88(stat)->action; return GetStoryByStat(stat)->action;
} }
u8 sub_8120ED8(void) // GetFreeStorySlot static u8 GetFreeStorySlot(void)
{ {
u8 i; u8 i;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (gUnknown_0203A12C->gameStatIDs[i] == 0) if (sStorytellerPtr->gameStatIDs[i] == 0)
break; break;
} }
return i; return i;
} }
u32 sub_8120F08(u32 trainer) // StorytellerGetRecordedTrainerStat static u32 StorytellerGetRecordedTrainerStat(u32 trainer)
{ {
u8 *ptr = gUnknown_0203A12C->statValues[trainer]; u8 *ptr = sStorytellerPtr->statValues[trainer];
return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);
} }
void sub_8120F2C(u32 trainer, u32 val) // StorytellerSetRecordedTrainerStat static void StorytellerSetRecordedTrainerStat(u32 trainer, u32 val)
{ {
u8 *ptr = gUnknown_0203A12C->statValues[trainer]; u8 *ptr = sStorytellerPtr->statValues[trainer];
ptr[0] = val; ptr[0] = val;
ptr[1] = val >> 8; ptr[1] = val >> 8;
@ -1040,41 +1034,41 @@ void sub_8120F2C(u32 trainer, u32 val) // StorytellerSetRecordedTrainerStat
ptr[3] = val >> 24; ptr[3] = val >> 24;
} }
bool32 sub_8120F4C(u32 trainer) // HasTrainerStatIncreased static bool32 HasTrainerStatIncreased(u32 trainer)
{ {
if (sub_8120E74(gUnknown_0203A12C->gameStatIDs[trainer]) > sub_8120F08(trainer)) if (StorytellerGetGameStat(sStorytellerPtr->gameStatIDs[trainer]) > StorytellerGetRecordedTrainerStat(trainer))
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
} }
void sub_8120F7C(u32 player, void *dst) // GetStoryByStattellerPlayerName static void GetStoryByStattellerPlayerName(u32 player, void *dst)
{ {
u8 *name = gUnknown_0203A12C->trainerNames[player]; u8 *name = sStorytellerPtr->trainerNames[player];
memset(dst, EOS, 8); memset(dst, EOS, 8);
memcpy(dst, name, 7); memcpy(dst, name, 7);
} }
void sub_8120FAC(u32 player, const u8 * src) // StorytellerSetPlayerName static void StorytellerSetPlayerName(u32 player, const u8 * src)
{ {
u8 * name = gUnknown_0203A12C->trainerNames[player]; u8 * name = sStorytellerPtr->trainerNames[player];
memset(name, EOS, 7); memset(name, EOS, 7);
memcpy(name, src, 7); memcpy(name, src, 7);
} }
void sub_8120FDC(u32 player, u32 stat) // StorytellerRecordNewStat static void StorytellerRecordNewStat(u32 player, u32 stat)
{ {
gUnknown_0203A12C->gameStatIDs[player] = stat; sStorytellerPtr->gameStatIDs[player] = stat;
sub_8120FAC(player, gSaveBlock2Ptr->playerName); StorytellerSetPlayerName(player, gSaveBlock2Ptr->playerName);
sub_8120F2C(player, sub_8120E74(stat)); StorytellerSetRecordedTrainerStat(player, StorytellerGetGameStat(stat));
ConvertIntToDecimalStringN(gStringVar1, sub_8120E74(stat), STR_CONV_MODE_LEFT_ALIGN, 10); ConvertIntToDecimalStringN(gStringVar1, StorytellerGetGameStat(stat), STR_CONV_MODE_LEFT_ALIGN, 10);
StringCopy(gStringVar2, sub_8120ECC(stat)); StringCopy(gStringVar2, GetStoryActionByStat(stat));
gUnknown_0203A12C->unk34[player] = gGameLanguage; sStorytellerPtr->language[player] = gGameLanguage;
} }
void sub_8121064(u8 * arr, s32 count) // ScrambleStatList static void ScrambleStatList(u8 * arr, s32 count)
{ {
s32 i; s32 i;
@ -1092,57 +1086,57 @@ void sub_8121064(u8 * arr, s32 count) // ScrambleStatList
struct UnknownStruct_0859F288 struct UnknownStruct_0859F288
{ {
u32 length; s32 length;
u32 unused2; u32 unused2;
}; };
const struct UnknownStruct_0859F288 gUnknown_0859F288 = { static const struct UnknownStruct_0859F288 sStorytellerStuff = {
36, ARRAY_COUNT(sStorytellerStories),
8 sizeof(sStorytellerStuff)
}; };
bool8 sub_81210B8(void) // StorytellerInitializeRandomStat static bool8 StorytellerInitializeRandomStat(void)
{ {
u8 arr[gUnknown_0859F288.length]; u8 arr[sStorytellerStuff.length];
s32 i; s32 i;
s32 j; s32 j;
sub_8121064(arr, 36); ScrambleStatList(arr, ARRAY_COUNT(sStorytellerStories));
for (i = 0; i < 36; i++) for (i = 0; i < (s32)ARRAY_COUNT(sStorytellerStories); i++)
{ {
u8 stat = gUnknown_0859F048[arr[i]].stat; u8 stat = sStorytellerStories[arr[i]].stat;
u8 minVal = gUnknown_0859F048[arr[i]].minVal; u8 minVal = sStorytellerStories[arr[i]].minVal;
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
if (gUnknown_0203A12C->gameStatIDs[j] == stat) if (sStorytellerPtr->gameStatIDs[j] == stat)
break; break;
} }
if (j == 4 && sub_8120E74(stat) >= minVal) if (j == 4 && StorytellerGetGameStat(stat) >= minVal)
{ {
gUnknown_0203A12C->alreadyRecorded = TRUE; sStorytellerPtr->alreadyRecorded = TRUE;
if (sub_8120ED8() == 4) if (GetFreeStorySlot() == 4)
sub_8120FDC(gUnknown_03001178, stat); StorytellerRecordNewStat(sSelectedStory, stat);
else else
sub_8120FDC(sub_8120ED8(), stat); StorytellerRecordNewStat(GetFreeStorySlot(), stat);
return TRUE; return TRUE;
} }
} }
return FALSE; return FALSE;
} }
void sub_8121178(u32 player) // StorytellerDisplayStory static void StorytellerDisplayStory(u32 player)
{ {
u8 stat = gUnknown_0203A12C->gameStatIDs[player]; u8 stat = sStorytellerPtr->gameStatIDs[player];
ConvertIntToDecimalStringN(gStringVar1, sub_8120F08(player), 0, 10); ConvertIntToDecimalStringN(gStringVar1, StorytellerGetRecordedTrainerStat(player), 0, 10);
StringCopy(gStringVar2, sub_8120ECC(stat)); StringCopy(gStringVar2, GetStoryActionByStat(stat));
sub_8120F7C(player, gStringVar3); GetStoryByStattellerPlayerName(player, gStringVar3);
ConvertInternationalString(gStringVar3, gUnknown_0203A12C->unk34[player]); ConvertInternationalString(gStringVar3, sStorytellerPtr->language[player]);
ShowFieldMessage(sub_8120EC0(stat)); ShowFieldMessage(GetStoryTextByStat(stat));
} }
void sub_81211EC(void) // PrintStoryList static void PrintStoryList(void)
{ {
s32 i; s32 i;
s32 width = GetStringWidth(1, gText_Exit, 0); s32 width = GetStringWidth(1, gText_Exit, 0);
@ -1150,29 +1144,29 @@ void sub_81211EC(void) // PrintStoryList
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
s32 curWidth; s32 curWidth;
u16 gameStatID = gUnknown_0203A12C->gameStatIDs[i]; u16 gameStatID = sStorytellerPtr->gameStatIDs[i];
if (gameStatID == 0) if (gameStatID == 0)
break; break;
curWidth = GetStringWidth(1, sub_8120EB4(gameStatID), 0); curWidth = GetStringWidth(1, GetStoryTitleByStat(gameStatID), 0);
if (curWidth > width) if (curWidth > width)
width = curWidth; width = curWidth;
} }
gUnknown_0203A130 = CreateWindowFromRect(0, 0, convert_pixel_width_to_tile_width(width), sub_8120ED8() * 2 + 2); sStorytellerWindowId = CreateWindowFromRect(0, 0, convert_pixel_width_to_tile_width(width), GetFreeStorySlot() * 2 + 2);
SetStandardWindowBorderStyle(gUnknown_0203A130, 0); SetStandardWindowBorderStyle(sStorytellerWindowId, 0);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
u16 gameStatID = gUnknown_0203A12C->gameStatIDs[i]; u16 gameStatID = sStorytellerPtr->gameStatIDs[i];
if (gameStatID == 0) if (gameStatID == 0)
break; break;
PrintTextOnWindow(gUnknown_0203A130, 1, sub_8120EB4(gameStatID), 8, 16 * i + 1, 0xFF, NULL); PrintTextOnWindow(sStorytellerWindowId, 1, GetStoryTitleByStat(gameStatID), 8, 16 * i + 1, 0xFF, NULL);
} }
PrintTextOnWindow(gUnknown_0203A130, 1, gText_Exit, 8, 16 * i + 1, 0xFF, NULL); PrintTextOnWindow(sStorytellerWindowId, 1, gText_Exit, 8, 16 * i + 1, 0xFF, NULL);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_0203A130, sub_8120ED8() + 1, 0); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sStorytellerWindowId, GetFreeStorySlot() + 1, 0);
CopyWindowToVram(gUnknown_0203A130, 3); CopyWindowToVram(sStorytellerWindowId, 3);
} }
void sub_81212FC(u8 taskId) // Task_StoryListMenu static void Task_StoryListMenu(u8 taskId) // Task_StoryListMenu
{ {
struct Task *task = &gTasks[taskId]; struct Task *task = &gTasks[taskId];
s32 selection; s32 selection;
@ -1180,23 +1174,23 @@ void sub_81212FC(u8 taskId) // Task_StoryListMenu
switch (task->data[0]) switch (task->data[0])
{ {
case 0: case 0:
sub_81211EC(); PrintStoryList();
task->data[0]++; task->data[0]++;
break; break;
case 1: case 1:
selection = ProcessMenuInput(); selection = ProcessMenuInput();
if (selection == -2) if (selection == -2)
break; break;
if (selection == -1 || selection == sub_8120ED8()) if (selection == -1 || selection == GetFreeStorySlot())
{ {
gSpecialVar_Result = 0; gSpecialVar_Result = 0;
} }
else else
{ {
gSpecialVar_Result = 1; gSpecialVar_Result = 1;
gUnknown_03001178 = selection; sSelectedStory = selection;
} }
sub_80E2A78(gUnknown_0203A130); sub_80E2A78(sStorytellerWindowId);
DestroyTask(taskId); DestroyTask(taskId);
EnableBothScriptContexts(); EnableBothScriptContexts();
break; break;
@ -1204,51 +1198,50 @@ void sub_81212FC(u8 taskId) // Task_StoryListMenu
} }
// Sets gSpecialVar_Result to TRUE if player selected a story // Sets gSpecialVar_Result to TRUE if player selected a story
void sub_8121388(void) // ScrSpecial_StorytellerStoryListMenu void ScrSpecial_StorytellerStoryListMenu(void)
{ {
CreateTask(sub_81212FC, 80); CreateTask(Task_StoryListMenu, 80);
} }
void sub_812139C(void) // ScrSpecial_StorytellerDisplayStory void ScrSpecial_StorytellerDisplayStory(void)
{ {
sub_8121178(gUnknown_03001178); StorytellerDisplayStory(sSelectedStory);
} }
u8 sub_81213B0(void) // ScrSpecial_StorytellerDisplayStory u8 ScrSpecial_StorytellerGetFreeStorySlot(void)
{ {
gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller;
return sub_8120ED8(); return GetFreeStorySlot();
} }
// Returns TRUE if stat has increased // Returns TRUE if stat has increased
bool8 sub_81213D8(void) // ScrSpecial_StorytellerUpdateStat bool8 ScrSpecial_StorytellerUpdateStat(void)
{ {
u8 r4; u8 r4;
gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller;
r4 = gUnknown_0203A12C->gameStatIDs[gUnknown_03001178]; r4 = sStorytellerPtr->gameStatIDs[sSelectedStory];
if (sub_8120F4C(gUnknown_03001178) == TRUE) if (HasTrainerStatIncreased(sSelectedStory) == TRUE)
{ {
sub_8120FDC(gUnknown_03001178, r4); StorytellerRecordNewStat(sSelectedStory, r4);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
bool8 ScrSpecial_HasStorytellerAlreadyRecorded(void)
bool8 sub_8121424(void) // ScrSpecial_HasStorytellerAlreadyRecorded
{ {
gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller;
if (gUnknown_0203A12C->alreadyRecorded == FALSE) if (sStorytellerPtr->alreadyRecorded == FALSE)
return FALSE; return FALSE;
else else
return TRUE; return TRUE;
} }
bool8 sub_8121450(void) // ScrSpecial_StorytellerInitializeRandomStat bool8 ScrSpecial_StorytellerInitializeRandomStat(void)
{ {
gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller;
return sub_81210B8(); return StorytellerInitializeRandomStat();
} }