From bfc4b338cbd3e78062c71ff6f72f821631277c1b Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Tue, 22 Aug 2017 17:34:42 -0500 Subject: rename some mauville man stuff --- src/easy_chat.c | 1 - src/mauville_old_man.c | 179 ++++++++++++++++++++++++++++++++----------------- src/new_game.c | 2 +- src/trader.c | 19 +++--- 4 files changed, 127 insertions(+), 74 deletions(-) (limited to 'src') diff --git a/src/easy_chat.c b/src/easy_chat.c index cca8c1355..e0073d8d8 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -19,7 +19,6 @@ extern const u8 gEasyChatGroupSizes[]; extern u16 gSpecialVar_0x8004; - u8 *sub_80EB3FC(u8 *dst, u16 word) { u16 group; diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 93684fc60..84c8f740c 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -1,6 +1,7 @@ #include "global.h" #include "mauville_old_man.h" #include "easy_chat.h" +#include "easy_chat_constants.h" #include "menu.h" #include "rng.h" #include "script.h" @@ -11,79 +12,129 @@ extern u16 gScriptResult; extern u16 gSpecialVar_0x8004; -extern u32 gUnknown_083E5388[]; -extern u32 gUnknown_083E53A8[]; +extern const u8 *gGiddyAdjectives[]; +extern const u8 *gGiddyQuestions[]; -extern u16 gUnknown_083E537C[]; - -void sub_80F7A34(void) +const u16 gDefaultBardSongLyrics[] = +{ +#ifdef ENGLISH + EC_WORD_SISTER, + EC_WORD_EATS, + EC_WORD_SWEETS, + EC_WORD_VORACIOUS, + EC_WORD_AND, + EC_WORD_DROOLING, +#else + EC_WORD_SISTER, + EC_WORD_MUST_BE, + EC_WORD_SWEETS, + EC_WORD_VORACIOUS, + EC_WORD_DROOLING, + EC_WORD_THICK, +#endif +}; + +void SetupBard(void) { u16 i; - OldMan *oldMan = &gSaveBlock1.oldMan; + struct MauvilleManBard *bard = &gSaveBlock1.oldMan.bard; - oldMan->oldMan1.unk_2D94 = 0; - oldMan->oldMan1.unk_2DBD = 0; - - for(i = 0; i < 6; i++) - oldMan->oldMan1.mauvilleOldMan_ecArray[i] = gUnknown_083E537C[i]; + bard->id = MAUVILLE_MAN_BARD; + bard->unk_2DBD = 0; + for (i = 0; i < 6; i++) + bard->songLyrics[i] = gDefaultBardSongLyrics[i]; } -void sub_80F7A6C(void) +void SetupHipster(void) { - struct UnkMauvilleOldManStruct *bard = &gSaveBlock1.oldMan.oldMan1; + struct MauvilleManHipster *hipster = &gSaveBlock1.oldMan.hipster; - bard->unk_2D94 = 1; - bard->unk_2D95 = 0; + hipster->id = MAUVILLE_MAN_HIPSTER; + hipster->unk1 = 0; } -void sub_80F7A7C(void) +void SetupStoryteller(void) { - sub_80F83F8(); + StorytellerSetup(); } -void sub_80F7A88(void) +void SetupGiddy(void) { - OldMan *oldMan = &gSaveBlock1.oldMan; + struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; - oldMan->oldMan1.unk_2D94 = 4; - oldMan->oldMan1.unk_2D95 = 0; + giddy->id = MAUVILLE_MAN_GIDDY; + giddy->unk1 = 0; } -void sub_80F7A98(void) +void SetupTrader(void) { - sub_81099CC(); + TraderSetup(); } -void SetMauvilleOldMan(void) +void SetupMauvilleOldMan(void) { - u32 var = ((u16)((gSaveBlock2.playerTrainerId[1] << 8 | gSaveBlock2.playerTrainerId[0])) % 10) / 2; + u16 trainerId = (gSaveBlock2.playerTrainerId[1] << 8) | gSaveBlock2.playerTrainerId[0]; - switch(var) + // Determine man based on the last digit of the player's trainer ID. + switch ((trainerId % 10) / 2) { - case 0: - sub_80F7A34(); + case MAUVILLE_MAN_BARD: + SetupBard(); break; - case 1: - sub_80F7A6C(); + case MAUVILLE_MAN_HIPSTER: + SetupHipster(); break; - case 2: - sub_80F7A98(); + case MAUVILLE_MAN_TRADER: + SetupTrader(); break; - case 3: - sub_80F7A7C(); + case MAUVILLE_MAN_STORYTELLER: + SetupStoryteller(); break; - case 4: - sub_80F7A88(); + case MAUVILLE_MAN_GIDDY: + SetupGiddy(); break; } sub_80F83D0(); } +/* +// Safely changes man to test functionality u8 GetCurrentMauvilleOldMan(void) { - OldMan *oldMan = &gSaveBlock1.oldMan; + u8 newMan = MAUVILLE_MAN_GIDDY; + struct MauvilleManCommon *common = &gSaveBlock1.oldMan.common; + + if (common->id != newMan) + { + switch (newMan) + { + case MAUVILLE_MAN_BARD: + SetupBard(); + break; + case MAUVILLE_MAN_HIPSTER: + SetupHipster(); + break; + case MAUVILLE_MAN_TRADER: + SetupTrader(); + break; + case MAUVILLE_MAN_STORYTELLER: + SetupStoryteller(); + break; + case MAUVILLE_MAN_GIDDY: + SetupGiddy(); + break; + } + sub_80F83D0(); + } + return common->id; +} +*/ + +u8 GetCurrentMauvilleOldMan(void) +{ + struct MauvilleManCommon *common = &gSaveBlock1.oldMan.common; - return oldMan->oldMan1.unk_2D94; + return common->id; } void sub_80F7B14(void) @@ -96,29 +147,28 @@ void sub_80F7B2C(void) u16 *scriptPtr = &gScriptResult; // why?? OldMan *oldMan = &gSaveBlock1.oldMan; - *scriptPtr = oldMan->oldMan1.unk_2DBD; + *scriptPtr = oldMan->bard.unk_2DBD; } void sub_80F7B40(void) { u16 i; - OldMan *oldMan = &gSaveBlock1.oldMan; - //struct UnkMauvilleOldManStruct *oldManStruct = &gSaveBlock1.oldManStruct; + struct MauvilleManBard *bard = &gSaveBlock1.oldMan.bard; - StringCopy(oldMan->oldMan1.playerName, gSaveBlock2.playerName); + StringCopy(bard->playerName, gSaveBlock2.playerName); for(i = 0; i < 4; i++) - oldMan->oldMan1.playerTrainerId[i] = gSaveBlock2.playerTrainerId[i]; + bard->playerTrainerId[i] = gSaveBlock2.playerTrainerId[i]; for(i = 0; i < 6; i++) - oldMan->oldMan1.mauvilleOldMan_ecArray[i] = oldMan->oldMan1.mauvilleOldMan_ecArray2[i]; + bard->songLyrics[i] = bard->mauvilleOldMan_ecArray2[i]; - oldMan->oldMan1.unk_2DBD = 1; + bard->unk_2DBD = 1; } void sub_80F7BA0(void) { - struct UnkMauvilleOldManStruct *oldMan = &gSaveBlock1.oldMan.oldMan1; + struct MauvilleManBard *oldMan = &gSaveBlock1.oldMan.bard; u16 specialVar = gSpecialVar_0x8004; // It's a bit odd to use this temp variable, but it seems needed to match. u16 *r5; u16 i; @@ -127,7 +177,7 @@ void sub_80F7BA0(void) r5 = oldMan->mauvilleOldMan_ecArray2; if (specialVar == 0) - r5 = oldMan->mauvilleOldMan_ecArray; + r5 = oldMan->songLyrics; ptr = gStringVar4; r4 = ptr; for (i = 0; i < 2; i++) @@ -178,14 +228,14 @@ void sub_80F7C70(void) u16 *scriptPtr = &gScriptResult; // again?? OldMan *oldMan = &gSaveBlock1.oldMan; - *scriptPtr = oldMan->oldMan1.unk_2D95; + *scriptPtr = oldMan->bard.unk_2D95; } void sub_80F7C84(void) { OldMan *oldMan = &gSaveBlock1.oldMan; - oldMan->oldMan1.unk_2D95 = 1; + oldMan->bard.unk_2D95 = 1; } void sub_80F7C90(void) @@ -207,41 +257,44 @@ void sub_80F7CC8(void) { OldMan *oldMan = &gSaveBlock1.oldMan; - if(oldMan->oldMan1.unk_2D95 == 10) + if (oldMan->bard.unk_2D95 == 10) { gScriptResult = FALSE; - oldMan->oldMan1.unk_2D95 = 0; + oldMan->bard.unk_2D95 = 0; } else + { gScriptResult = TRUE; + } } -void sub_80F7CF4(void) +void ScrSpecial_GenerateGiddyLine(void) { - struct UnkMauvilleOldManStruct2 *oldMan = &gSaveBlock1.oldMan.oldMan2; + struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; - if(oldMan->unk1 == 0) + if (giddy->unk1 == 0) sub_80F7DC0(); - if(oldMan->mauvilleOldMan_ecArray[oldMan->unk1] != 0xFFFF) // is not the last element of the array? + if (giddy->mauvilleOldMan_ecArray[giddy->unk1] != 0xFFFF) // is not the last element of the array? { u8 *stringPtr; - u32 random = Random(); + u32 adjective = Random(); - random %= 8; - stringPtr = sub_80EB3FC(gStringVar4, oldMan->mauvilleOldMan_ecArray[oldMan->unk1]); + adjective %= 8; + stringPtr = sub_80EB3FC(gStringVar4, giddy->mauvilleOldMan_ecArray[giddy->unk1]); stringPtr = StringCopy(stringPtr, gOtherText_Is); - stringPtr = StringCopy(stringPtr, (u8 *)gUnknown_083E5388[random]); + stringPtr = StringCopy(stringPtr, gGiddyAdjectives[adjective]); StringCopy(stringPtr, gOtherText_DontYouAgree); } else { - StringCopy(gStringVar4, (u8 *)gUnknown_083E53A8[oldMan->mauvilleOldMan_ecArray2[oldMan->unk2++]]); + StringCopy(gStringVar4, gGiddyQuestions[giddy->mauvilleOldMan_ecArray2[giddy->unk2++]]); } - if(!(Random() % 10)) - oldMan->unk1 = 10; + + if (!(Random() % 10)) + giddy->unk1 = 10; else - oldMan->unk1++; + giddy->unk1++; gScriptResult = TRUE; } diff --git a/src/new_game.c b/src/new_game.c index 226ac9bb7..1ef19bd00 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -157,7 +157,7 @@ void NewGameInitData(void) ClearPokeblocks(); ClearDecorationInventories(); InitEasyChatPhrases(); - SetMauvilleOldMan(); + SetupMauvilleOldMan(); InitDewfordTrend(); ResetFanClub(); ResetLotteryCorner(); diff --git a/src/trader.c b/src/trader.c index ea06058e9..9aeefa3d1 100644 --- a/src/trader.c +++ b/src/trader.c @@ -3,6 +3,7 @@ #include "decoration_inventory.h" #include "event_data.h" #include "main.h" +#include "mauville_old_man.h" #include "menu.h" #include "menu_helpers.h" #include "script.h" @@ -36,7 +37,7 @@ void sub_810993C(void) { u8 i, j; u8 buffer[12]; - struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; for (i = 0; i < 3; i++) { @@ -55,12 +56,12 @@ void sub_810993C(void) } } -void sub_81099CC(void) +void TraderSetup(void) { u8 i; - struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; - trader->unk0 = 2; + trader->id = MAUVILLE_MAN_TRADER; trader->unk31 = 0; for (i = 0; i < 4; i++) @@ -74,7 +75,7 @@ void sub_81099CC(void) void sub_8109A20(void) { - struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; trader->unk31 = 0; } @@ -88,7 +89,7 @@ void sub_8109A48(u8 taskId) u8 i; u8 numChoices = 1; u8 numDecorations = 0; - struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; for (i = 0; i < 4; i++) { @@ -141,7 +142,7 @@ void sub_8109B34(u8 taskId, u8 decorationId) void sub_8109B7C(u8 taskId) { - struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; if (gMain.newKeys & DPAD_UP) { @@ -176,7 +177,7 @@ void sub_8109B7C(u8 taskId) void sub_8109C44(void) { - struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; gScriptResult = trader->unk31; } @@ -244,7 +245,7 @@ void sub_8109DAC(u8 taskId) void sub_8109DE0(void) { - struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; sub_81340A8(gSpecialVar_0x8006); IsThereStorageSpaceForDecoration(gSpecialVar_0x8004); -- cgit v1.2.3 From 988f5a685a36d3591d07f71ca778d988fb26720a Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 01:10:30 -0500 Subject: decompile up to sub_80F8598 --- src/bard_music.c | 36 +-- src/m4a_4.c | 2 +- src/mauville_old_man.c | 726 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 725 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/bard_music.c b/src/bard_music.c index a31568475..ce2a1e9ec 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -1,41 +1,7 @@ #include "global.h" +#include "bard_music.h" #include "easy_chat.h" -struct BardSound -{ - u8 pad_00[48]; -}; - -struct UnkBard -{ - /*0x00*/ u8 var00; - /*0x01*/ s8 var01; - /*0x02*/ u16 var02; - /*0x04*/ u16 var04; - /*0x06*/ u16 var06; -}; - -struct UnkBard3 -{ - /*0x00*/ u16 var00; - /*0x02*/ u16 var02; - /*0x04*/ s16 var04; - /*0x06*/ u16 var06; -}; - -struct UnkBard2 -{ - /*0x00*/ u8 var00; - /*0x01*/ u8 var01; - /*0x02*/ u8 var02; - /*0x03*/ u8 var03; - /*0x04*/ u16 var04; - u8 pad06[4]; - /*0x0A*/ u16 var0A; - u8 pad0C[12]; - /*0x18*/ struct UnkBard3 var18[6]; -}; - extern struct BardSound *gBardMusicTable[]; extern s16 *gUnknown_08417068[]; extern u32 gUnknown_084170F4[]; diff --git a/src/m4a_4.c b/src/m4a_4.c index 99195ec00..2e1d140b4 100644 --- a/src/m4a_4.c +++ b/src/m4a_4.c @@ -45,7 +45,7 @@ void m4aMPlayVolumeControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u16 mplayInfo->ident = ID_NUMBER; } -void m4aMPlayPitchControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u16 pitch) +void m4aMPlayPitchControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, s16 pitch) { s32 i; u32 bit; diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 84c8f740c..87bc87e3b 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -1,19 +1,30 @@ #include "global.h" +#include "bard_music.h" #include "mauville_old_man.h" #include "easy_chat.h" #include "easy_chat_constants.h" +#include "event_data.h" +#include "m4a.h" #include "menu.h" +#include "rom4.h" #include "rng.h" #include "script.h" +#include "songs.h" +#include "sound.h" #include "string_util.h" #include "strings.h" +#include "task.h" #include "trader.h" +#define MACRO1(a) (((a) % 4) + (((a) / 8) & 1)) + +extern struct MusicPlayerInfo gMPlay_SE2; + extern u16 gScriptResult; extern u16 gSpecialVar_0x8004; +extern struct UnkBard2 gUnknown_03005DA0; -extern const u8 *gGiddyAdjectives[]; -extern const u8 *gGiddyQuestions[]; +extern u16 gUnknown_020388BC; // set but not used? const u16 gDefaultBardSongLyrics[] = { @@ -34,6 +45,33 @@ const u16 gDefaultBardSongLyrics[] = #endif }; +const u8 *const gGiddyAdjectives[] = +{ + OtherText_SoPretty, + OtherText_SoDarling, + OtherText_SoRelaxed, + OtherText_SoSunny, + OtherText_SoDesirable, + OtherText_SoExciting, + OtherText_SoAmusing, + OtherText_SoMagical, +}; + +const u8 *const gGiddyQuestions[] = +{ + OtherText_WantVacationNicePlace, + OtherText_BoughtCrayonsIsNice, + OtherText_IfWeCouldFloat, + OtherText_SandWashesAwayMakeSad, + OtherText_WhatsBottomSeaLike, + OtherText_SeeSettingSun, + OtherText_LyingInGreenGrass, + OtherText_SecretBasesWonderful, +}; + +void sub_80F8184(u8); +void sub_80F8428(void); + void SetupBard(void) { u16 i; @@ -288,7 +326,7 @@ void ScrSpecial_GenerateGiddyLine(void) } else { - StringCopy(gStringVar4, gGiddyQuestions[giddy->mauvilleOldMan_ecArray2[giddy->unk2++]]); + StringCopy(gStringVar4, gGiddyQuestions[giddy->questionList[giddy->questionNum++]]); } if (!(Random() % 10)) @@ -298,3 +336,685 @@ void ScrSpecial_GenerateGiddyLine(void) gScriptResult = TRUE; } + +#ifdef NONMATCHING +void sub_80F7DC0(void) +{ + u16 arr[][2] = + { + { 0x0, 0}, + { 0xC, 0}, + { 0xD, 0}, + {0x12, 0}, + {0x13, 0}, + {0x15, 0}, + }; + u16 i; + u16 r10; + u16 r7; + + for (i = 0; i < 8; i++) + { + struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; + + //gSaveBlock1.oldMan.giddy.questionList[i] = i; + giddy->questionList[i] = i; + } + + // Scramble questions + for (i = 0; i < 8; i++) + { + struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; + + /* + u16 r1 = Random() % (i + 1); + u8 r7 = gSaveBlock1.oldMan.giddy.questionList[i]; + gSaveBlock1.oldMan.giddy.questionList[i] = gSaveBlock1.oldMan.giddy.questionList[r1]; + gSaveBlock1.oldMan.giddy.questionList[r1] = r7; + */ + u16 r1 = Random() % (i + 1); + u8 r7 = giddy->questionList[i]; + giddy->questionList[i] = giddy->questionList[r1]; + giddy->questionList[r1] = r7; + } + + r10 = 0; + for (i = 0; i < 6; i++) + { + arr[i][1] = sub_80EAE88(arr[i][0]); + r10 += arr[i][1]; + } + + { + struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; + giddy->questionNum = 0; + } + //gSaveBlock1.oldMan.giddy.questionNum = 0; + + r7 = 0; + for (i = 0; i < 10; i++) + { + struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; + + u16 var = Random() % 10; + if (var < 3 && r7 < 8) + { + //gSaveBlock1.oldMan.giddy.mauvilleOldMan_ecArray[i] = 0xFFFF; + giddy->mauvilleOldMan_ecArray[i] = 0xFFFF; + r7++; + } + //_080F7E90 + else + { + s16 r2 = Random() % r10; + + u16 r1 = 0; + + while (i < 6) // comparing the wrong variable + { + r2 = arr[r1][1] - r2; + if (r2 <= 0) + break; + r1++; + } + + if (r1 == 6) + r1 = 0; + //gSaveBlock1.oldMan.giddy.mauvilleOldMan_ecArray[i] = sub_80EB784(arr[r1][0]); + giddy->mauvilleOldMan_ecArray[i] = sub_80EB784(arr[r1][0]); + } + } +} +#else + +const u16 gUnknown_083E53C8[][2] = +{ + { 0x0, 0}, + { 0xC, 0}, + { 0xD, 0}, + {0x12, 0}, + {0x13, 0}, + {0x15, 0}, +}; + +__attribute__((naked)) +void sub_80F7DC0(void) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x18\n\ + ldr r1, _080F7E84 @ =gUnknown_083E53C8\n\ + mov r0, sp\n\ + movs r2, 0x18\n\ + bl memcpy\n\ + movs r5, 0\n\ + movs r0, 0x2\n\ + add r0, sp\n\ + mov r8, r0\n\ + ldr r1, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ + adds r1, 0x18\n\ + adds r3, r1, 0\n\ +_080F7DE4:\n\ + adds r0, r3, r5\n\ + strb r5, [r0]\n\ + adds r0, r5, 0x1\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + cmp r5, 0x7\n\ + bls _080F7DE4\n\ + movs r5, 0\n\ + ldr r2, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ + adds r2, 0x4\n\ + mov r9, r2\n\ + adds r6, r1, 0\n\ +_080F7DFC:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + adds r4, r5, 0x1\n\ + adds r1, r4, 0\n\ + bl __modsi3\n\ + lsls r0, 16\n\ + lsrs r1, r0, 16\n\ + adds r2, r6, r5\n\ + ldrb r7, [r2]\n\ + adds r1, r6, r1\n\ + ldrb r0, [r1]\n\ + strb r0, [r2]\n\ + strb r7, [r1]\n\ + lsls r4, 16\n\ + lsrs r5, r4, 16\n\ + cmp r5, 0x7\n\ + bls _080F7DFC\n\ + movs r3, 0\n\ + mov r10, r3\n\ + movs r5, 0\n\ +_080F7E2A:\n\ + lsls r4, r5, 2\n\ + mov r1, sp\n\ + adds r0, r1, r4\n\ + ldrb r0, [r0]\n\ + bl sub_80EAE88\n\ + add r4, r8\n\ + strh r0, [r4]\n\ + add r0, r10\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r10, r0\n\ + adds r0, r5, 0x1\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + cmp r5, 0x5\n\ + bls _080F7E2A\n\ + movs r0, 0\n\ + ldr r2, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ + strb r0, [r2, 0x2]\n\ + movs r7, 0\n\ + movs r5, 0\n\ +_080F7E56:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0xA\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + lsrs r1, r0, 16\n\ + cmp r1, 0x2\n\ + bhi _080F7E90\n\ + cmp r7, 0x7\n\ + bhi _080F7E90\n\ + lsls r0, r5, 1\n\ + add r0, r9\n\ + ldr r1, _080F7E8C @ =0x0000ffff\n\ + strh r1, [r0]\n\ + adds r0, r7, 0x1\n\ + lsls r0, 16\n\ + lsrs r7, r0, 16\n\ + adds r4, r5, 0x1\n\ + b _080F7EE2\n\ + .align 2, 0\n\ +_080F7E84: .4byte gUnknown_083E53C8\n\ +_080F7E88: .4byte gSaveBlock1 + 0x2D94\n\ +_080F7E8C: .4byte 0x0000ffff\n\ +_080F7E90:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r1, r10\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + lsrs r2, r0, 16\n\ + movs r1, 0\n\ + adds r4, r5, 0x1\n\ + lsls r6, r5, 1\n\ + cmp r5, 0x5\n\ + bhi _080F7ECC\n\ + mov r3, r8\n\ + ldrh r0, [r3]\n\ + b _080F7EC2\n\ +_080F7EB2:\n\ + adds r0, r1, 0x1\n\ + lsls r0, 16\n\ + lsrs r1, r0, 16\n\ + cmp r5, 0x5\n\ + bhi _080F7ECC\n\ + lsls r0, r1, 2\n\ + adds r0, r3, r0\n\ + ldrh r0, [r0]\n\ +_080F7EC2:\n\ + subs r0, r2, r0\n\ + lsls r0, 16\n\ + lsrs r2, r0, 16\n\ + cmp r0, 0\n\ + bgt _080F7EB2\n\ +_080F7ECC:\n\ + cmp r1, 0x6\n\ + bne _080F7ED2\n\ + movs r1, 0\n\ +_080F7ED2:\n\ + lsls r0, r1, 2\n\ + add r0, sp\n\ + ldrh r0, [r0]\n\ + bl sub_80EB784\n\ + mov r2, r9\n\ + adds r1, r2, r6\n\ + strh r0, [r1]\n\ +_080F7EE2:\n\ + lsls r0, r4, 16\n\ + lsrs r5, r0, 16\n\ + cmp r5, 0x9\n\ + bls _080F7E56\n\ + add sp, 0x18\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided\n"); +} +#endif + +void sub_80F7EFC(void) +{ + struct MauvilleManBard *bard = &gSaveBlock1.oldMan.bard; + + bard->unk_2DBD = 0; +} + +void sub_80F7F0C(void) +{ + struct MauvilleManHipster *hipster = &gSaveBlock1.oldMan.hipster; + + hipster->unk1 = 0; +} + +void sub_80F7F18(void) +{ + sub_8109A20(); +} + +void sub_80F7F24(void) +{ + sub_80F8428(); +} + +void sub_80F7F30(void) +{ + switch (GetCurrentMauvilleOldMan()) + { + case MAUVILLE_MAN_BARD: + sub_80F7EFC(); + break; + case MAUVILLE_MAN_HIPSTER: + sub_80F7F0C(); + break; + case MAUVILLE_MAN_STORYTELLER: + sub_80F7F24(); + break; + case MAUVILLE_MAN_TRADER: + sub_80F7F18(); + break; + case MAUVILLE_MAN_GIDDY: + break; + } + sub_80F83D0(); +} + +void sub_80F7F80(u8 a) +{ + u8 taskId = CreateTask(sub_80F8184, 0x50); + + gTasks[taskId].data[5] = a; +} + +void BardSingWord(struct Task *task, struct UnkBard2 *b) +{ + switch (task->data[0]) + { + case 0: + { + struct MauvilleManBard *bard = &gSaveBlock1.oldMan.bard; + u16 *r2; + s32 i; + + if (gSpecialVar_0x8004 == 0) + r2 = bard->songLyrics; + else + r2 = bard->mauvilleOldMan_ecArray2; + for (i = 0; i < 6; i++) + b->var0C[i] = r2[i]; + for (i = 0; i < 6; i++) + { + b->var18[i].var00 = 0xFFFF; + b->var18[i].var02 = 0; + b->var18[i].var04 = 0; + b->var18[i].var06 = 0; + } + b->var00 = 0; + b->var01 = 0; + b->var04 = 0; + } + break; + case 1: + break; + case 2: + { + u16 r4 = b->var0C[b->var00]; + // TODO: fix this return type + struct UnkBard *r1 = (struct UnkBard *)sub_814A2D0(r4 / 0x200, r4 % 0x200); + + b->var04 = 0; + sub_814A2EC(b, r1, (r4 % 4) + ((r4 / 8) & 1)); + } + break; + case 3: + case 4: + { + struct UnkBard3 *r7 = &b->var18[b->var01]; + + switch (b->var03) + { + case 0: + if (b->var02 == 0) + { + if (b->var01 == 6 || r7->var00 == 0xFF) + { + b->var03 = 0xFE; + break; + } + b->var02 = r7->var02; + if (r7->var00 <= 50) + { + u16 r1 = r7->var00 / 3; + + m4aSongNumStart(249 + r1 * 3); + } + b->var03 = 1; + } + else + { + if (b->var0A > 10) + b->volume -= 2; + if (b->var0A & 1) + b->pitch += 64; + else + b->pitch -= 64; + m4aMPlayVolumeControl(&gMPlay_SE2, 0xFFFF, b->volume); + m4aMPlayPitchControl(&gMPlay_SE2, 0xFFFF, b->pitch); + b->var0A++; + } + b->var02--; + break; + case 1: + b->var01++; + b->var03 = 0; + if (r7->var00 <= 50) + { + b->volume = 0x100 + r7->var06 * 16; + m4aMPlayVolumeControl(&gMPlay_SE2, 0xFFFF, b->volume); + b->pitch = 0x200 + r7->var04; + m4aMPlayPitchControl(&gMPlay_SE2, 0xFFFF, b->pitch); + } + break; + case 0xFE: + m4aMPlayStop(&gMPlay_SE2); + b->var03 = 0xFF; + break; + } + } + break; + case 5: + break; + } +} + +void sub_80F8184(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; // r5 + + BardSingWord(task, &gUnknown_03005DA0); + switch (task->data[0]) + { + case 0: + sub_80F7BA0(); + InitWindowFromConfig(gMenuWindowPtr, &gWindowConfig_81E6CE4); + sub_8002EB0(gMenuWindowPtr, gStringVar4, 2, 4, 15); + task->data[1] = 0; + task->data[2] = 0; + task->data[3] = 0; + task->data[4] = 0; + FadeOutBGMTemporarily(4); + task->data[0] = 1; + break; + case 1: + if (IsBGMPausedOrStopped()) + task->data[0] = 2; + break; + case 2: + { + struct MauvilleManBard *bard = &gSaveBlock1.oldMan.bard; + u8 *string = gStringVar4 + task->data[3]; + u16 wordLen = 0; + // Can't get it to match without hacking + u32 temp; + register s16 zero asm("r1"); + + while (*string != CHAR_SPACE + && *string != CHAR_NEWLINE + && *string != EXT_CTRL_CODE_BEGIN + && *string != EOS) + { + string++; + wordLen++; + } + if (task->data[5] == 0) + gUnknown_020388BC = MACRO1(bard->songLyrics[task->data[4]]); + else + gUnknown_020388BC = MACRO1(bard->mauvilleOldMan_ecArray2[task->data[4]]); + temp = gUnknown_03005DA0.var04 / wordLen; + zero = 0; + gUnknown_03005DA0.var04 = temp; + if (gUnknown_03005DA0.var04 <= 0) + gUnknown_03005DA0.var04 = 1; + task->data[4]++; + if (task->data[2] == 0) + task->data[0] = 3; + else + task->data[0] = 5; + task->data[1] = zero; + } + break; + case 5: + if (task->data[2] == 0) + task->data[0] = 3; + else + task->data[2]--; + break; + case 3: + if (gStringVar4[task->data[3]] == EOS) + { + FadeInNewBGM(BGM_POKECEN, 6); + m4aMPlayFadeOutTemporarily(&gMPlay_SE2, 2); + EnableBothScriptContexts(); + DestroyTask(taskId); + } + else if (gStringVar4[task->data[3]] == CHAR_SPACE) + { + sub_8003418(gMenuWindowPtr); + task->data[3]++; + task->data[0] = 2; + task->data[2] = 0; + } + else if (gStringVar4[task->data[3]] == CHAR_NEWLINE) + { + task->data[3]++; + task->data[0] = 2; + task->data[2] = 0; + } + else if (gStringVar4[task->data[3]] == EXT_CTRL_CODE_BEGIN) + { + task->data[3] += 2; // skip over control codes + task->data[0] = 2; + task->data[2] = 8; + } + else if (gStringVar4[task->data[3]] == 0x37) // What is 0x37 supposed to be? + { + gStringVar4[task->data[3]] = 0; + sub_8003418(gMenuWindowPtr); + task->data[3]++; + task->data[2] = 0; + } + else + { + switch (task->data[1]) + { + case 0: + sub_8003418(gMenuWindowPtr); + task->data[1]++; + break; + case 1: + task->data[1]++; + break; + case 2: + task->data[3]++; + task->data[1] = 0; + task->data[2] = gUnknown_03005DA0.var04; + task->data[0] = 4; + break; + } + } + break; + case 4: + task->data[2]--; + if (task->data[2] == 0) + task->data[0] = 3; + break; + } +} + +void sub_80F83D0(void) +{ + VarSet(0x4010, 0x45 + GetCurrentMauvilleOldMan()); +} + +void StorytellerSetup(void) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + s32 i; + + storyteller->id = MAUVILLE_MAN_STORYTELLER; + storyteller->unk1 = 0; + for (i = 0; i < 4; i++) + { + storyteller->unk4[i] = 0; + storyteller->unk8[0][i] = EOS; // Maybe they meant storyteller->unk8[i][0] instead? + } +} + +void sub_80F8428(void) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + + storyteller->id = MAUVILLE_MAN_STORYTELLER; + storyteller->unk1 = 0; +} + +u32 sub_80F8438(u8 stat) +{ + if (stat == 50) + stat = 0; + GetGameStat(stat); +} + +struct UnknownStruct1 +{ + u8 unk0; + u8 unk1; + const u8 *unk4; + const u8 *unk8; + const u8 *unkC; +}; + +extern const struct UnknownStruct1 gUnknown_083E53E0[]; + +const struct UnknownStruct1 *sub_80F844C(u32 a) +{ + s32 i; + + for (i = 0; i < 36; i++) + { + if (gUnknown_083E53E0[i].unk0 == a) + return &gUnknown_083E53E0[i]; + } + return &gUnknown_083E53E0[35]; +} + +const u8 *sub_80F8478(u32 a) +{ + return sub_80F844C(a)->unk4; +} + +const u8 *sub_80F8484(u32 a) +{ + return sub_80F844C(a)->unkC; +} + +const u8 *sub_80F8490(u32 a) +{ + return sub_80F844C(a)->unk8; +} + +u8 sub_80F849C(void) +{ + u8 i; + + for (i = 0; i < 4; i++) + { + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + + if (storyteller->unk4[i] == 0) + break; + } + return i; +} + +u32 sub_80F84C8(u32 a) +{ + u8 *ptr = gSaveBlock1.oldMan.storyteller.unk24[a]; + + return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); +} + +void sub_80F84EC(u32 a, u32 b) +{ + u8 *ptr = gSaveBlock1.oldMan.storyteller.unk24[a]; + + ptr[0] = b; + ptr[1] = b >> 8; + ptr[2] = b >> 16; + ptr[3] = b >> 24; +} + +bool8 sub_80F8508(u32 a) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + + if (sub_80F8438(storyteller->unk4[a]) > sub_80F84C8(a)) + return TRUE; + else + return FALSE; +} + +void sub_80F8534(u32 a, void *b) +{ + u8 *ptr = gSaveBlock1.oldMan.storyteller.unk8[a]; + + memset(b, 0xFF, 8); + memcpy(b, ptr, 7); +} + +void sub_80F8560(u32 a, const u8 *b) +{ + u8 *ptr = gSaveBlock1.oldMan.storyteller.unk8[a]; + u8 len = StringLength(b); + + memset(ptr, 0xFF, 7); + StringCopyN(ptr, b, len); +} + +void sub_80F8598(u32 a, u32 b) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + + storyteller->unk4[a] = b; + sub_80F8560(a, gSaveBlock2.playerName); + sub_80F84EC(a, sub_80F8438(b)); + ConvertIntToDecimalStringN(gStringVar1, sub_80F8438(b), 0, 10); + StringCopy(gStringVar2, sub_80F8490(b)); +} -- cgit v1.2.3 From a277e60789d9ea78fe03a4bcded2edf7b91e548e Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 13:40:03 -0500 Subject: finish decompiling mauville_old_man --- src/mauville_old_man.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 165 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 87bc87e3b..9400dfc32 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -4,6 +4,7 @@ #include "easy_chat.h" #include "easy_chat_constants.h" #include "event_data.h" +#include "field_message_box.h" #include "m4a.h" #include "menu.h" #include "rom4.h" @@ -70,6 +71,7 @@ const u8 *const gGiddyQuestions[] = }; void sub_80F8184(u8); +void StorytellerSetup(void); void sub_80F8428(void); void SetupBard(void) @@ -889,7 +891,7 @@ void StorytellerSetup(void) s32 i; storyteller->id = MAUVILLE_MAN_STORYTELLER; - storyteller->unk1 = 0; + storyteller->unk1 = FALSE; for (i = 0; i < 4; i++) { storyteller->unk4[i] = 0; @@ -902,7 +904,7 @@ void sub_80F8428(void) struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; storyteller->id = MAUVILLE_MAN_STORYTELLER; - storyteller->unk1 = 0; + storyteller->unk1 = FALSE; } u32 sub_80F8438(u8 stat) @@ -981,7 +983,7 @@ void sub_80F84EC(u32 a, u32 b) ptr[3] = b >> 24; } -bool8 sub_80F8508(u32 a) +bool32 sub_80F8508(u32 a) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; @@ -1018,3 +1020,163 @@ void sub_80F8598(u32 a, u32 b) ConvertIntToDecimalStringN(gStringVar1, sub_80F8438(b), 0, 10); StringCopy(gStringVar2, sub_80F8490(b)); } + +void sub_80F85FC(u8 *arr, s32 count) +{ + s32 i; + + for (i = 0; i < count; i++) + arr[i] = i; + for (i = 0; i < count; i++) + { + u32 a = Random() % count; + u32 b = Random() % count; + u8 temp = arr[a]; + arr[a] = arr[b]; + arr[b] = temp; + } +} + +extern const struct {u32 unk0; struct MauvilleManStoryteller *unk4; u32 unk8;} gUnknown_083E5620; +/* +static const struct {u32 unk0; struct MauvilleManStoryteller *unk4; u32 unk8;} gUnknown_083E5620 = +{ + 36, + &gSaveBlock1.oldMan.storyteller, + 12, +}; +*/ + +bool8 sub_80F8650(void) +{ + u8 arr[gUnknown_083E5620.unk0]; + s32 i; + s32 j; + + sub_80F85FC(arr, 36); + for (i = 0; i < 36; i++) + { + u8 r4 = gUnknown_083E53E0[arr[i]].unk0; + u8 r6 = gUnknown_083E53E0[arr[i]].unk1; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + + for (j = 0; j < 4; j++) + { + if (gSaveBlock1.oldMan.storyteller.unk4[j] == r4) + break; + } + if (j == 4 && sub_80F8438(r4) >= r6) + { + storyteller->unk1 = TRUE; + sub_80F8598(sub_80F849C(), r4); + return TRUE; + } + } + return FALSE; +} + +void sub_80F8700(u32 a) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + u8 r6 = storyteller->unk4[a]; + + ConvertIntToDecimalStringN(gStringVar1, sub_80F84C8(a), 0, 10); + StringCopy(gStringVar2, sub_80F8490(r6)); + sub_80F8534(a, gStringVar3); + ShowFieldMessage(sub_80F8484(r6)); +} + +void sub_80F8758(void) +{ + s32 i; + + MenuDrawTextWindow(0, 0, 25, 4 + sub_80F849C() * 2); + for (i = 0; i < 4; i++) + { + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + u8 r0 = storyteller->unk4[i]; + + if (r0 == 0) + break; + MenuPrint(sub_80F8478(r0), 1, 2 + i * 2); + } + MenuPrint(gPCText_Cancel, 1, 2 + i * 2); +} + +extern u8 gUnknown_03000748; + +void sub_80F87C4(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + s32 selection; + + switch (task->data[0]) + { + case 0: + sub_80F8758(); + InitMenu(0, 1, 2, sub_80F849C() + 1, 0, 24); + task->data[0]++; + break; + case 1: + selection = ProcessMenuInput(); + if (selection == -2) + break; + if (selection == -1 || selection == sub_80F849C()) + { + gScriptResult = 0; + } + else + { + gScriptResult = 1; + gUnknown_03000748 = selection; + } + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 25, 12); + DestroyTask(taskId); + EnableBothScriptContexts(); + break; + } +} + +void sub_80F8874(void) +{ + CreateTask(sub_80F87C4, 0x50); +} + +void sub_80F8888(void) +{ + sub_80F8700(gUnknown_03000748); +} + +u8 sub_80F889C(void) +{ + return sub_80F849C(); +} + +bool8 sub_80F88AC(void) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + u8 r4 = storyteller->unk4[gUnknown_03000748]; + + if (sub_80F8508(gUnknown_03000748) == TRUE) + { + sub_80F8598(gUnknown_03000748, r4); + return TRUE; + } + return FALSE; +} + +bool8 sub_80F88E0(void) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + + if (storyteller->unk1 == FALSE) + return FALSE; + else + return TRUE; +} + +bool8 sub_80F88FC(void) +{ + return sub_80F8650(); +} -- cgit v1.2.3 From 1ae38be0a46d1d901a2d9e5bb22938a0cecf6b7f Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 15:19:55 -0500 Subject: do some renaming and reorganizing --- src/mauville_old_man.c | 337 +++++++++++++++++++++++++++++++++++-------------- src/record_mixing.c | 2 +- src/trader.c | 14 +- 3 files changed, 250 insertions(+), 103 deletions(-) (limited to 'src') diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 9400dfc32..3bf682ca0 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -23,11 +23,121 @@ extern struct MusicPlayerInfo gMPlay_SE2; extern u16 gScriptResult; extern u16 gSpecialVar_0x8004; + +extern const u8 UnknownString_81AEFFC[]; +extern const u8 UnknownString_81AF013[]; +extern const u8 UnknownString_81AF022[]; +extern const u8 UnknownString_81AF0A3[]; +extern const u8 UnknownString_81AF0BB[]; +extern const u8 UnknownString_81AF0CA[]; +extern const u8 UnknownString_81AF149[]; +extern const u8 UnknownString_81AF164[]; +extern const u8 UnknownString_81AF174[]; +extern const u8 UnknownString_81AF1E5[]; +extern const u8 UnknownString_81AF1FD[]; +extern const u8 UnknownString_81AF20A[]; +extern const u8 UnknownString_81AF281[]; +extern const u8 UnknownString_81AF299[]; +extern const u8 UnknownString_81AF2A9[]; +extern const u8 UnknownString_81AF32C[]; +extern const u8 UnknownString_81AF345[]; +extern const u8 UnknownString_81AF34D[]; +extern const u8 UnknownString_81AF3D0[]; +extern const u8 UnknownString_81AF3ED[]; +extern const u8 UnknownString_81AF3FC[]; +extern const u8 UnknownString_81AF46D[]; +extern const u8 UnknownString_81AF481[]; +extern const u8 UnknownString_81AF49B[]; +extern const u8 UnknownString_81AF511[]; +extern const u8 UnknownString_81AF529[]; +extern const u8 UnknownString_81AF536[]; +extern const u8 UnknownString_81AF5A9[]; +extern const u8 UnknownString_81AF5BD[]; +extern const u8 UnknownString_81AF5CD[]; +extern const u8 UnknownString_81AF63F[]; +extern const u8 UnknownString_81AF661[]; +extern const u8 UnknownString_81AF676[]; +extern const u8 UnknownString_81AF711[]; +extern const u8 UnknownString_81AF726[]; +extern const u8 UnknownString_81AF73D[]; +extern const u8 UnknownString_81AF7BF[]; +extern const u8 UnknownString_81AF7D9[]; +extern const u8 UnknownString_81AF7F1[]; +extern const u8 UnknownString_81AF88A[]; +extern const u8 UnknownString_81AF8A1[]; +extern const u8 UnknownString_81AF8AA[]; +extern const u8 UnknownString_81AF91B[]; +extern const u8 UnknownString_81AF935[]; +extern const u8 UnknownString_81AF943[]; +extern const u8 UnknownString_81AF9C8[]; +extern const u8 UnknownString_81AF9E0[]; +extern const u8 UnknownString_81AF9F6[]; +extern const u8 UnknownString_81AFA79[]; +extern const u8 UnknownString_81AFA92[]; +extern const u8 UnknownString_81AFA9E[]; +extern const u8 UnknownString_81AFB17[]; +extern const u8 UnknownString_81AFB2D[]; +extern const u8 UnknownString_81AFB48[]; +extern const u8 UnknownString_81AFBD8[]; +extern const u8 UnknownString_81AFBE7[]; +extern const u8 UnknownString_81AFC04[]; +extern const u8 UnknownString_81AFC8A[]; +extern const u8 UnknownString_81AFC9D[]; +extern const u8 UnknownString_81AFCBE[]; +extern const u8 UnknownString_81AFD44[]; +extern const u8 UnknownString_81AFD60[]; +extern const u8 UnknownString_81AFD80[]; +extern const u8 UnknownString_81AFE1D[]; +extern const u8 UnknownString_81AFE36[]; +extern const u8 UnknownString_81AFE42[]; +extern const u8 UnknownString_81AFEC2[]; +extern const u8 UnknownString_81AFEDD[]; +extern const u8 UnknownString_81AFEEE[]; +extern const u8 UnknownString_81AFF68[]; +extern const u8 UnknownString_81AFF7B[]; +extern const u8 UnknownString_81AFF88[]; +extern const u8 UnknownString_81AFFFB[]; +extern const u8 UnknownString_81B000D[]; +extern const u8 UnknownString_81B0015[]; +extern const u8 UnknownString_81B009D[]; +extern const u8 UnknownString_81B00B6[]; +extern const u8 UnknownString_81B00C9[]; +extern const u8 UnknownString_81B014D[]; +extern const u8 UnknownString_81B0165[]; +extern const u8 UnknownString_81B0173[]; +extern const u8 UnknownString_81B01E9[]; +extern const u8 UnknownString_81B0201[]; +extern const u8 UnknownString_81B0213[]; +extern const u8 UnknownString_81B0290[]; +extern const u8 UnknownString_81B02A5[]; +extern const u8 UnknownString_81B02B6[]; +extern const u8 UnknownString_81B0337[]; +extern const u8 UnknownString_81B0351[]; +extern const u8 UnknownString_81B0364[]; +extern const u8 UnknownString_81B03E9[]; +extern const u8 UnknownString_81B0401[]; +extern const u8 UnknownString_81B040C[]; +extern const u8 UnknownString_81B046E[]; +extern const u8 UnknownString_81B0489[]; +extern const u8 UnknownString_81B049A[]; +extern const u8 UnknownString_81B0523[]; +extern const u8 UnknownString_81B053E[]; +extern const u8 UnknownString_81B0554[]; +extern const u8 UnknownString_81B05D8[]; +extern const u8 UnknownString_81B05F3[]; +extern const u8 UnknownString_81B0610[]; +extern const u8 UnknownString_81B06A9[]; +extern const u8 UnknownString_81B06C6[]; +extern const u8 UnknownString_81B06D9[]; +extern const u8 UnknownString_81B0763[]; +extern const u8 UnknownString_81B0781[]; +extern const u8 UnknownString_81B0797[]; + extern struct UnkBard2 gUnknown_03005DA0; extern u16 gUnknown_020388BC; // set but not used? -const u16 gDefaultBardSongLyrics[] = +static const u16 gDefaultBardSongLyrics[] = { #ifdef ENGLISH EC_WORD_SISTER, @@ -46,7 +156,7 @@ const u16 gDefaultBardSongLyrics[] = #endif }; -const u8 *const gGiddyAdjectives[] = +static const u8 *const gGiddyAdjectives[] = { OtherText_SoPretty, OtherText_SoDarling, @@ -58,7 +168,7 @@ const u8 *const gGiddyAdjectives[] = OtherText_SoMagical, }; -const u8 *const gGiddyQuestions[] = +static const u8 *const gGiddyQuestions[] = { OtherText_WantVacationNicePlace, OtherText_BoughtCrayonsIsNice, @@ -70,24 +180,25 @@ const u8 *const gGiddyQuestions[] = OtherText_SecretBasesWonderful, }; -void sub_80F8184(u8); +void Task_BardSong(u8); +void StartBardSong(u8); void StorytellerSetup(void); void sub_80F8428(void); void SetupBard(void) { u16 i; - struct MauvilleManBard *bard = &gSaveBlock1.oldMan.bard; + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; bard->id = MAUVILLE_MAN_BARD; - bard->unk_2DBD = 0; + bard->hasChangedSong = FALSE; for (i = 0; i < 6; i++) bard->songLyrics[i] = gDefaultBardSongLyrics[i]; } void SetupHipster(void) { - struct MauvilleManHipster *hipster = &gSaveBlock1.oldMan.hipster; + struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; hipster->id = MAUVILLE_MAN_HIPSTER; hipster->unk1 = 0; @@ -100,7 +211,7 @@ void SetupStoryteller(void) void SetupGiddy(void) { - struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; giddy->id = MAUVILLE_MAN_GIDDY; giddy->unk1 = 0; @@ -137,12 +248,14 @@ void SetupMauvilleOldMan(void) sub_80F83D0(); } -/* +//#define TEST MAUVILLE_MAN_BARD + +#ifdef TEST // Safely changes man to test functionality u8 GetCurrentMauvilleOldMan(void) { - u8 newMan = MAUVILLE_MAN_GIDDY; - struct MauvilleManCommon *common = &gSaveBlock1.oldMan.common; + u8 newMan = TEST; + struct MauvilleManCommon *common = &gSaveBlock1.mauvilleMan.common; if (common->id != newMan) { @@ -168,56 +281,56 @@ u8 GetCurrentMauvilleOldMan(void) } return common->id; } -*/ - +#else u8 GetCurrentMauvilleOldMan(void) { - struct MauvilleManCommon *common = &gSaveBlock1.oldMan.common; + struct MauvilleManCommon *common = &gSaveBlock1.mauvilleMan.common; return common->id; } +#endif -void sub_80F7B14(void) +void ScrSpecial_GetCurrentMauvilleMan(void) { gScriptResult = GetCurrentMauvilleOldMan(); } -void sub_80F7B2C(void) +void ScrSpecial_HasBardSongBeenChanged(void) { - u16 *scriptPtr = &gScriptResult; // why?? - OldMan *oldMan = &gSaveBlock1.oldMan; + u16 *scriptResult = &gScriptResult; // why?? + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - *scriptPtr = oldMan->bard.unk_2DBD; + *scriptResult = bard->hasChangedSong; } -void sub_80F7B40(void) +void ScrSpecial_SaveBardSongLyrics(void) { u16 i; - struct MauvilleManBard *bard = &gSaveBlock1.oldMan.bard; + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; StringCopy(bard->playerName, gSaveBlock2.playerName); - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) bard->playerTrainerId[i] = gSaveBlock2.playerTrainerId[i]; - for(i = 0; i < 6; i++) + for (i = 0; i < 6; i++) bard->songLyrics[i] = bard->mauvilleOldMan_ecArray2[i]; - bard->unk_2DBD = 1; + bard->hasChangedSong = TRUE; } void sub_80F7BA0(void) { - struct MauvilleManBard *oldMan = &gSaveBlock1.oldMan.bard; + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; u16 specialVar = gSpecialVar_0x8004; // It's a bit odd to use this temp variable, but it seems needed to match. u16 *r5; u16 i; u8 *ptr; u8 *r4; - r5 = oldMan->mauvilleOldMan_ecArray2; + r5 = bard->mauvilleOldMan_ecArray2; if (specialVar == 0) - r5 = oldMan->songLyrics; + r5 = bard->songLyrics; ptr = gStringVar4; r4 = ptr; for (i = 0; i < 2; i++) @@ -230,7 +343,7 @@ void sub_80F7BA0(void) r4++; } r4++; - *(ptr++) = 0; + *(ptr++) = CHAR_SPACE; ptr = sub_80EB3FC(ptr, *(r5++)); while (ptr != r4) { @@ -239,7 +352,7 @@ void sub_80F7BA0(void) r4++; } r4++; - *(ptr++) = 0xFE; + *(ptr++) = CHAR_NEWLINE; ptr = sub_80EB3FC(ptr, *(r5++)); while (ptr != r4) { @@ -247,7 +360,6 @@ void sub_80F7BA0(void) *r4 = 0x37; r4++; } - //_080F7C2A if (i == 0) { *(ptr++) = EXT_CTRL_CODE_BEGIN; @@ -256,33 +368,33 @@ void sub_80F7BA0(void) } } -void sub_80F7C54(void) +void ScrSpecial_PlayBardSong(void) { - sub_80F7F80(gSpecialVar_0x8004); + StartBardSong(gSpecialVar_0x8004); MenuDisplayMessageBox(); ScriptContext1_Stop(); } void sub_80F7C70(void) { - u16 *scriptPtr = &gScriptResult; // again?? - OldMan *oldMan = &gSaveBlock1.oldMan; + u16 *scriptResult = &gScriptResult; // again?? + struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; - *scriptPtr = oldMan->bard.unk_2D95; + *scriptResult = hipster->unk1; } -void sub_80F7C84(void) +void ScrSpecial_SetHipsterSpokenFlag(void) { - OldMan *oldMan = &gSaveBlock1.oldMan; + struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; - oldMan->bard.unk_2D95 = 1; + hipster->unk1 = 1; } void sub_80F7C90(void) { u16 var = sub_80EB8EC(); - if(var == 0xFFFF) + if (var == 0xFFFF) { gScriptResult = FALSE; } @@ -295,12 +407,12 @@ void sub_80F7C90(void) void sub_80F7CC8(void) { - OldMan *oldMan = &gSaveBlock1.oldMan; + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - if (oldMan->bard.unk_2D95 == 10) + if (bard->unk_2D95 == 10) { gScriptResult = FALSE; - oldMan->bard.unk_2D95 = 0; + bard->unk_2D95 = 0; } else { @@ -310,7 +422,7 @@ void sub_80F7CC8(void) void ScrSpecial_GenerateGiddyLine(void) { - struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; if (giddy->unk1 == 0) sub_80F7DC0(); @@ -357,22 +469,22 @@ void sub_80F7DC0(void) for (i = 0; i < 8; i++) { - struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; - //gSaveBlock1.oldMan.giddy.questionList[i] = i; + //gSaveBlock1.mauvilleMan.giddy.questionList[i] = i; giddy->questionList[i] = i; } // Scramble questions for (i = 0; i < 8; i++) { - struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; /* u16 r1 = Random() % (i + 1); - u8 r7 = gSaveBlock1.oldMan.giddy.questionList[i]; - gSaveBlock1.oldMan.giddy.questionList[i] = gSaveBlock1.oldMan.giddy.questionList[r1]; - gSaveBlock1.oldMan.giddy.questionList[r1] = r7; + u8 r7 = gSaveBlock1.mauvilleMan.giddy.questionList[i]; + gSaveBlock1.mauvilleMan.giddy.questionList[i] = gSaveBlock1.mauvilleMan.giddy.questionList[r1]; + gSaveBlock1.mauvilleMan.giddy.questionList[r1] = r7; */ u16 r1 = Random() % (i + 1); u8 r7 = giddy->questionList[i]; @@ -388,20 +500,20 @@ void sub_80F7DC0(void) } { - struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; giddy->questionNum = 0; } - //gSaveBlock1.oldMan.giddy.questionNum = 0; + //gSaveBlock1.mauvilleMan.giddy.questionNum = 0; r7 = 0; for (i = 0; i < 10; i++) { - struct MauvilleManGiddy *giddy = &gSaveBlock1.oldMan.giddy; + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; u16 var = Random() % 10; if (var < 3 && r7 < 8) { - //gSaveBlock1.oldMan.giddy.mauvilleOldMan_ecArray[i] = 0xFFFF; + //gSaveBlock1.mauvilleMan.giddy.mauvilleOldMan_ecArray[i] = 0xFFFF; giddy->mauvilleOldMan_ecArray[i] = 0xFFFF; r7++; } @@ -422,7 +534,7 @@ void sub_80F7DC0(void) if (r1 == 6) r1 = 0; - //gSaveBlock1.oldMan.giddy.mauvilleOldMan_ecArray[i] = sub_80EB784(arr[r1][0]); + //gSaveBlock1.mauvilleMan.giddy.mauvilleOldMan_ecArray[i] = sub_80EB784(arr[r1][0]); giddy->mauvilleOldMan_ecArray[i] = sub_80EB784(arr[r1][0]); } } @@ -604,14 +716,14 @@ _080F7EE2:\n\ void sub_80F7EFC(void) { - struct MauvilleManBard *bard = &gSaveBlock1.oldMan.bard; + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - bard->unk_2DBD = 0; + bard->hasChangedSong = FALSE; } void sub_80F7F0C(void) { - struct MauvilleManHipster *hipster = &gSaveBlock1.oldMan.hipster; + struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; hipster->unk1 = 0; } @@ -648,9 +760,9 @@ void sub_80F7F30(void) sub_80F83D0(); } -void sub_80F7F80(u8 a) +void StartBardSong(u8 a) { - u8 taskId = CreateTask(sub_80F8184, 0x50); + u8 taskId = CreateTask(Task_BardSong, 0x50); gTasks[taskId].data[5] = a; } @@ -661,7 +773,7 @@ void BardSingWord(struct Task *task, struct UnkBard2 *b) { case 0: { - struct MauvilleManBard *bard = &gSaveBlock1.oldMan.bard; + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; u16 *r2; s32 i; @@ -756,7 +868,7 @@ void BardSingWord(struct Task *task, struct UnkBard2 *b) } } -void sub_80F8184(u8 taskId) +void Task_BardSong(u8 taskId) { struct Task *task = &gTasks[taskId]; // r5 @@ -780,7 +892,7 @@ void sub_80F8184(u8 taskId) break; case 2: { - struct MauvilleManBard *bard = &gSaveBlock1.oldMan.bard; + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; u8 *string = gStringVar4 + task->data[3]; u16 wordLen = 0; // Can't get it to match without hacking @@ -885,9 +997,58 @@ void sub_80F83D0(void) VarSet(0x4010, 0x45 + GetCurrentMauvilleOldMan()); } +struct UnknownStruct1 +{ + u8 unk0; + u8 unk1; + const u8 *unk4; + const u8 *unk8; + const u8 *unkC; +}; + +static const struct UnknownStruct1 gUnknown_083E53E0[] = +{ + {0x32, 1, UnknownString_81AEFFC, UnknownString_81AF013, UnknownString_81AF022}, + {0x02, 1, UnknownString_81AF0A3, UnknownString_81AF0BB, UnknownString_81AF0CA}, + {0x03, 1, UnknownString_81AF149, UnknownString_81AF164, UnknownString_81AF174}, + {0x04, 1, UnknownString_81AF1E5, UnknownString_81AF1FD, UnknownString_81AF20A}, + {0x06, 1, UnknownString_81AF281, UnknownString_81AF299, UnknownString_81AF2A9}, + {0x09, 1, UnknownString_81AF32C, UnknownString_81AF345, UnknownString_81AF34D}, + {0x0B, 1, UnknownString_81AF3D0, UnknownString_81AF3ED, UnknownString_81AF3FC}, + {0x0C, 1, UnknownString_81AF46D, UnknownString_81AF481, UnknownString_81AF49B}, + {0x0D, 1, UnknownString_81AF511, UnknownString_81AF529, UnknownString_81AF536}, + {0x0E, 1, UnknownString_81AF5A9, UnknownString_81AF5BD, UnknownString_81AF5CD}, + {0x0F, 1, UnknownString_81AF63F, UnknownString_81AF661, UnknownString_81AF676}, + {0x10, 1, UnknownString_81AF711, UnknownString_81AF726, UnknownString_81AF73D}, + {0x11, 1, UnknownString_81AF7BF, UnknownString_81AF7D9, UnknownString_81AF7F1}, + {0x12, 1, UnknownString_81AF88A, UnknownString_81AF8A1, UnknownString_81AF8AA}, + {0x13, 1, UnknownString_81AF91B, UnknownString_81AF935, UnknownString_81AF943}, + {0x14, 1, UnknownString_81AF9C8, UnknownString_81AF9E0, UnknownString_81AF9F6}, + {0x1A, 1, UnknownString_81AFA79, UnknownString_81AFA92, UnknownString_81AFA9E}, + {0x1B, 1, UnknownString_81AFB17, UnknownString_81AFB2D, UnknownString_81AFB48}, + {0x1C, 1, UnknownString_81AFBD8, UnknownString_81AFBE7, UnknownString_81AFC04}, + {0x1D, 2, UnknownString_81AFC8A, UnknownString_81AFC9D, UnknownString_81AFCBE}, + {0x1E, 1, UnknownString_81AFD44, UnknownString_81AFD60, UnknownString_81AFD80}, + {0x21, 1, UnknownString_81AFE1D, UnknownString_81AFE36, UnknownString_81AFE42}, + {0x24, 1, UnknownString_81AFEC2, UnknownString_81AFEDD, UnknownString_81AFEEE}, + {0x25, 1, UnknownString_81AFF68, UnknownString_81AFF7B, UnknownString_81AFF88}, + {0x26, 1, UnknownString_81AFFFB, UnknownString_81B000D, UnknownString_81B0015}, + {0x27, 1, UnknownString_81B009D, UnknownString_81B00B6, UnknownString_81B00C9}, + {0x28, 1, UnknownString_81B014D, UnknownString_81B0165, UnknownString_81B0173}, + {0x29, 1, UnknownString_81B01E9, UnknownString_81B0201, UnknownString_81B0213}, + {0x2A, 1, UnknownString_81B0290, UnknownString_81B02A5, UnknownString_81B02B6}, + {0x2B, 1, UnknownString_81B0337, UnknownString_81B0351, UnknownString_81B0364}, + {0x2C, 1, UnknownString_81B03E9, UnknownString_81B0401, UnknownString_81B040C}, + {0x2D, 1, UnknownString_81B046E, UnknownString_81B0489, UnknownString_81B049A}, + {0x2E, 1, UnknownString_81B0523, UnknownString_81B053E, UnknownString_81B0554}, + {0x2F, 1, UnknownString_81B05D8, UnknownString_81B05F3, UnknownString_81B0610}, + {0x30, 1, UnknownString_81B06A9, UnknownString_81B06C6, UnknownString_81B06D9}, + {0x31, 1, UnknownString_81B0763, UnknownString_81B0781, UnknownString_81B0797}, +}; + void StorytellerSetup(void) { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; s32 i; storyteller->id = MAUVILLE_MAN_STORYTELLER; @@ -901,7 +1062,7 @@ void StorytellerSetup(void) void sub_80F8428(void) { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; storyteller->id = MAUVILLE_MAN_STORYTELLER; storyteller->unk1 = FALSE; @@ -914,17 +1075,6 @@ u32 sub_80F8438(u8 stat) GetGameStat(stat); } -struct UnknownStruct1 -{ - u8 unk0; - u8 unk1; - const u8 *unk4; - const u8 *unk8; - const u8 *unkC; -}; - -extern const struct UnknownStruct1 gUnknown_083E53E0[]; - const struct UnknownStruct1 *sub_80F844C(u32 a) { s32 i; @@ -958,7 +1108,7 @@ u8 sub_80F849C(void) for (i = 0; i < 4; i++) { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; if (storyteller->unk4[i] == 0) break; @@ -968,14 +1118,14 @@ u8 sub_80F849C(void) u32 sub_80F84C8(u32 a) { - u8 *ptr = gSaveBlock1.oldMan.storyteller.unk24[a]; + u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk24[a]; return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); } void sub_80F84EC(u32 a, u32 b) { - u8 *ptr = gSaveBlock1.oldMan.storyteller.unk24[a]; + u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk24[a]; ptr[0] = b; ptr[1] = b >> 8; @@ -985,7 +1135,7 @@ void sub_80F84EC(u32 a, u32 b) bool32 sub_80F8508(u32 a) { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; if (sub_80F8438(storyteller->unk4[a]) > sub_80F84C8(a)) return TRUE; @@ -995,7 +1145,7 @@ bool32 sub_80F8508(u32 a) void sub_80F8534(u32 a, void *b) { - u8 *ptr = gSaveBlock1.oldMan.storyteller.unk8[a]; + u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk8[a]; memset(b, 0xFF, 8); memcpy(b, ptr, 7); @@ -1003,7 +1153,7 @@ void sub_80F8534(u32 a, void *b) void sub_80F8560(u32 a, const u8 *b) { - u8 *ptr = gSaveBlock1.oldMan.storyteller.unk8[a]; + u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk8[a]; u8 len = StringLength(b); memset(ptr, 0xFF, 7); @@ -1012,7 +1162,7 @@ void sub_80F8560(u32 a, const u8 *b) void sub_80F8598(u32 a, u32 b) { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; storyteller->unk4[a] = b; sub_80F8560(a, gSaveBlock2.playerName); @@ -1037,19 +1187,16 @@ void sub_80F85FC(u8 *arr, s32 count) } } -extern const struct {u32 unk0; struct MauvilleManStoryteller *unk4; u32 unk8;} gUnknown_083E5620; -/* -static const struct {u32 unk0; struct MauvilleManStoryteller *unk4; u32 unk8;} gUnknown_083E5620 = +static const struct {u32 length; struct MauvilleManStoryteller *unused1; u32 unused2;} gUnknown_083E5620 = { 36, - &gSaveBlock1.oldMan.storyteller, - 12, + &gSaveBlock1.mauvilleMan.storyteller, // unused + 12, // unused }; -*/ bool8 sub_80F8650(void) { - u8 arr[gUnknown_083E5620.unk0]; + u8 arr[gUnknown_083E5620.length]; s32 i; s32 j; @@ -1058,11 +1205,11 @@ bool8 sub_80F8650(void) { u8 r4 = gUnknown_083E53E0[arr[i]].unk0; u8 r6 = gUnknown_083E53E0[arr[i]].unk1; - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; for (j = 0; j < 4; j++) { - if (gSaveBlock1.oldMan.storyteller.unk4[j] == r4) + if (gSaveBlock1.mauvilleMan.storyteller.unk4[j] == r4) break; } if (j == 4 && sub_80F8438(r4) >= r6) @@ -1077,7 +1224,7 @@ bool8 sub_80F8650(void) void sub_80F8700(u32 a) { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; u8 r6 = storyteller->unk4[a]; ConvertIntToDecimalStringN(gStringVar1, sub_80F84C8(a), 0, 10); @@ -1093,7 +1240,7 @@ void sub_80F8758(void) MenuDrawTextWindow(0, 0, 25, 4 + sub_80F849C() * 2); for (i = 0; i < 4; i++) { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; u8 r0 = storyteller->unk4[i]; if (r0 == 0) @@ -1155,7 +1302,7 @@ u8 sub_80F889C(void) bool8 sub_80F88AC(void) { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; u8 r4 = storyteller->unk4[gUnknown_03000748]; if (sub_80F8508(gUnknown_03000748) == TRUE) @@ -1168,7 +1315,7 @@ bool8 sub_80F88AC(void) bool8 sub_80F88E0(void) { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.oldMan.storyteller; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; if (storyteller->unk1 == FALSE) return FALSE; diff --git a/src/record_mixing.c b/src/record_mixing.c index d1083910c..e5f892d20 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -40,7 +40,7 @@ static u8 gUnknown_0300071C[4]; void *recordMixingSecretBases = &gSaveBlock1.secretBases; void *recordMixingTvShows = &gSaveBlock1.tvShows; void *gUnknown_083D0274 = &gSaveBlock1.unknown_2ABC; -void *gUnknown_083D0278 = &gSaveBlock1.oldMan; +void *gUnknown_083D0278 = &gSaveBlock1.mauvilleMan; void *recordMixingEasyChatPairs = &gSaveBlock1.easyChatPairs; struct RecordMixing_UnknownStruct *gUnknown_083D0280 = &gUnknown_02038738; void *gUnknown_083D0284 = &gSaveBlock2.filler_A8; diff --git a/src/trader.c b/src/trader.c index 9aeefa3d1..d289f72a8 100644 --- a/src/trader.c +++ b/src/trader.c @@ -37,7 +37,7 @@ void sub_810993C(void) { u8 i, j; u8 buffer[12]; - struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; for (i = 0; i < 3; i++) { @@ -59,7 +59,7 @@ void sub_810993C(void) void TraderSetup(void) { u8 i; - struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; trader->id = MAUVILLE_MAN_TRADER; trader->unk31 = 0; @@ -75,7 +75,7 @@ void TraderSetup(void) void sub_8109A20(void) { - struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; trader->unk31 = 0; } @@ -89,7 +89,7 @@ void sub_8109A48(u8 taskId) u8 i; u8 numChoices = 1; u8 numDecorations = 0; - struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; for (i = 0; i < 4; i++) { @@ -142,7 +142,7 @@ void sub_8109B34(u8 taskId, u8 decorationId) void sub_8109B7C(u8 taskId) { - struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; if (gMain.newKeys & DPAD_UP) { @@ -177,7 +177,7 @@ void sub_8109B7C(u8 taskId) void sub_8109C44(void) { - struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; gScriptResult = trader->unk31; } @@ -245,7 +245,7 @@ void sub_8109DAC(u8 taskId) void sub_8109DE0(void) { - struct MauvilleManTrader *trader = &gSaveBlock1.oldMan.trader; + struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; sub_81340A8(gSpecialVar_0x8006); IsThereStorageSpaceForDecoration(gSpecialVar_0x8004); -- cgit v1.2.3 From 4a583141ba483dcd49f49760a29c403c5d259efb Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 15:33:07 -0500 Subject: more labeling and fix German build --- src/mauville_old_man.c | 70 ++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 3bf682ca0..4edcb1417 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -314,28 +314,29 @@ void ScrSpecial_SaveBardSongLyrics(void) bard->playerTrainerId[i] = gSaveBlock2.playerTrainerId[i]; for (i = 0; i < 6; i++) - bard->songLyrics[i] = bard->mauvilleOldMan_ecArray2[i]; + bard->songLyrics[i] = bard->temporaryLyrics[i]; bard->hasChangedSong = TRUE; } +// prepare song? void sub_80F7BA0(void) { struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; u16 specialVar = gSpecialVar_0x8004; // It's a bit odd to use this temp variable, but it seems needed to match. - u16 *r5; + u16 *lyrics; u16 i; u8 *ptr; u8 *r4; - r5 = bard->mauvilleOldMan_ecArray2; + lyrics = bard->temporaryLyrics; if (specialVar == 0) - r5 = bard->songLyrics; + lyrics = bard->songLyrics; ptr = gStringVar4; r4 = ptr; for (i = 0; i < 2; i++) { - ptr = sub_80EB3FC(ptr, *(r5++)); + ptr = sub_80EB3FC(ptr, *(lyrics++)); while (ptr != r4) { if (*r4 == 0) @@ -344,7 +345,7 @@ void sub_80F7BA0(void) } r4++; *(ptr++) = CHAR_SPACE; - ptr = sub_80EB3FC(ptr, *(r5++)); + ptr = sub_80EB3FC(ptr, *(lyrics++)); while (ptr != r4) { if (*r4 == 0) @@ -353,7 +354,7 @@ void sub_80F7BA0(void) } r4++; *(ptr++) = CHAR_NEWLINE; - ptr = sub_80EB3FC(ptr, *(r5++)); + ptr = sub_80EB3FC(ptr, *(lyrics++)); while (ptr != r4) { if (*r4 == 0) @@ -780,7 +781,7 @@ void BardSingWord(struct Task *task, struct UnkBard2 *b) if (gSpecialVar_0x8004 == 0) r2 = bard->songLyrics; else - r2 = bard->mauvilleOldMan_ecArray2; + r2 = bard->temporaryLyrics; for (i = 0; i < 6; i++) b->var0C[i] = r2[i]; for (i = 0; i < 6; i++) @@ -868,12 +869,15 @@ void BardSingWord(struct Task *task, struct UnkBard2 *b) } } +#define tState data[0] +#define tCharIndex data[3] + void Task_BardSong(u8 taskId) { struct Task *task = &gTasks[taskId]; // r5 BardSingWord(task, &gUnknown_03005DA0); - switch (task->data[0]) + switch (task->tState) { case 0: sub_80F7BA0(); @@ -881,19 +885,19 @@ void Task_BardSong(u8 taskId) sub_8002EB0(gMenuWindowPtr, gStringVar4, 2, 4, 15); task->data[1] = 0; task->data[2] = 0; - task->data[3] = 0; + task->tCharIndex = 0; task->data[4] = 0; FadeOutBGMTemporarily(4); - task->data[0] = 1; + task->tState = 1; break; case 1: if (IsBGMPausedOrStopped()) - task->data[0] = 2; + task->tState = 2; break; case 2: { struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - u8 *string = gStringVar4 + task->data[3]; + u8 *string = gStringVar4 + task->tCharIndex; u16 wordLen = 0; // Can't get it to match without hacking u32 temp; @@ -910,7 +914,7 @@ void Task_BardSong(u8 taskId) if (task->data[5] == 0) gUnknown_020388BC = MACRO1(bard->songLyrics[task->data[4]]); else - gUnknown_020388BC = MACRO1(bard->mauvilleOldMan_ecArray2[task->data[4]]); + gUnknown_020388BC = MACRO1(bard->temporaryLyrics[task->data[4]]); temp = gUnknown_03005DA0.var04 / wordLen; zero = 0; gUnknown_03005DA0.var04 = temp; @@ -918,50 +922,50 @@ void Task_BardSong(u8 taskId) gUnknown_03005DA0.var04 = 1; task->data[4]++; if (task->data[2] == 0) - task->data[0] = 3; + task->tState = 3; else - task->data[0] = 5; + task->tState = 5; task->data[1] = zero; } break; case 5: if (task->data[2] == 0) - task->data[0] = 3; + task->tState = 3; else task->data[2]--; break; case 3: - if (gStringVar4[task->data[3]] == EOS) + if (gStringVar4[task->tCharIndex] == EOS) { FadeInNewBGM(BGM_POKECEN, 6); m4aMPlayFadeOutTemporarily(&gMPlay_SE2, 2); EnableBothScriptContexts(); DestroyTask(taskId); } - else if (gStringVar4[task->data[3]] == CHAR_SPACE) + else if (gStringVar4[task->tCharIndex] == CHAR_SPACE) { sub_8003418(gMenuWindowPtr); - task->data[3]++; - task->data[0] = 2; + task->tCharIndex++; + task->tState = 2; task->data[2] = 0; } - else if (gStringVar4[task->data[3]] == CHAR_NEWLINE) + else if (gStringVar4[task->tCharIndex] == CHAR_NEWLINE) { - task->data[3]++; - task->data[0] = 2; + task->tCharIndex++; + task->tState = 2; task->data[2] = 0; } - else if (gStringVar4[task->data[3]] == EXT_CTRL_CODE_BEGIN) + else if (gStringVar4[task->tCharIndex] == EXT_CTRL_CODE_BEGIN) { - task->data[3] += 2; // skip over control codes - task->data[0] = 2; + task->tCharIndex += 2; // skip over control codes + task->tState = 2; task->data[2] = 8; } - else if (gStringVar4[task->data[3]] == 0x37) // What is 0x37 supposed to be? + else if (gStringVar4[task->tCharIndex] == 0x37) // What is 0x37 supposed to be? { - gStringVar4[task->data[3]] = 0; + gStringVar4[task->tCharIndex] = CHAR_SPACE; sub_8003418(gMenuWindowPtr); - task->data[3]++; + task->tCharIndex++; task->data[2] = 0; } else @@ -976,10 +980,10 @@ void Task_BardSong(u8 taskId) task->data[1]++; break; case 2: - task->data[3]++; + task->tCharIndex++; task->data[1] = 0; task->data[2] = gUnknown_03005DA0.var04; - task->data[0] = 4; + task->tState = 4; break; } } @@ -987,7 +991,7 @@ void Task_BardSong(u8 taskId) case 4: task->data[2]--; if (task->data[2] == 0) - task->data[0] = 3; + task->tState = 3; break; } } -- cgit v1.2.3 From 1b715eb7ba38ff408acf5e5e0a9ea88642f912bb Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 16:52:49 -0500 Subject: more Mauville man labeling --- src/mauville_old_man.c | 360 ++++++++++++++++++++++++------------------------- src/trader.c | 28 ++-- 2 files changed, 194 insertions(+), 194 deletions(-) (limited to 'src') diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 4edcb1417..e5d661e4a 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -24,114 +24,114 @@ extern struct MusicPlayerInfo gMPlay_SE2; extern u16 gScriptResult; extern u16 gSpecialVar_0x8004; -extern const u8 UnknownString_81AEFFC[]; -extern const u8 UnknownString_81AF013[]; -extern const u8 UnknownString_81AF022[]; -extern const u8 UnknownString_81AF0A3[]; -extern const u8 UnknownString_81AF0BB[]; -extern const u8 UnknownString_81AF0CA[]; -extern const u8 UnknownString_81AF149[]; -extern const u8 UnknownString_81AF164[]; -extern const u8 UnknownString_81AF174[]; -extern const u8 UnknownString_81AF1E5[]; -extern const u8 UnknownString_81AF1FD[]; -extern const u8 UnknownString_81AF20A[]; -extern const u8 UnknownString_81AF281[]; -extern const u8 UnknownString_81AF299[]; -extern const u8 UnknownString_81AF2A9[]; -extern const u8 UnknownString_81AF32C[]; -extern const u8 UnknownString_81AF345[]; -extern const u8 UnknownString_81AF34D[]; -extern const u8 UnknownString_81AF3D0[]; -extern const u8 UnknownString_81AF3ED[]; -extern const u8 UnknownString_81AF3FC[]; -extern const u8 UnknownString_81AF46D[]; -extern const u8 UnknownString_81AF481[]; -extern const u8 UnknownString_81AF49B[]; -extern const u8 UnknownString_81AF511[]; -extern const u8 UnknownString_81AF529[]; -extern const u8 UnknownString_81AF536[]; -extern const u8 UnknownString_81AF5A9[]; -extern const u8 UnknownString_81AF5BD[]; -extern const u8 UnknownString_81AF5CD[]; -extern const u8 UnknownString_81AF63F[]; -extern const u8 UnknownString_81AF661[]; -extern const u8 UnknownString_81AF676[]; -extern const u8 UnknownString_81AF711[]; -extern const u8 UnknownString_81AF726[]; -extern const u8 UnknownString_81AF73D[]; -extern const u8 UnknownString_81AF7BF[]; -extern const u8 UnknownString_81AF7D9[]; -extern const u8 UnknownString_81AF7F1[]; -extern const u8 UnknownString_81AF88A[]; -extern const u8 UnknownString_81AF8A1[]; -extern const u8 UnknownString_81AF8AA[]; -extern const u8 UnknownString_81AF91B[]; -extern const u8 UnknownString_81AF935[]; -extern const u8 UnknownString_81AF943[]; -extern const u8 UnknownString_81AF9C8[]; -extern const u8 UnknownString_81AF9E0[]; -extern const u8 UnknownString_81AF9F6[]; -extern const u8 UnknownString_81AFA79[]; -extern const u8 UnknownString_81AFA92[]; -extern const u8 UnknownString_81AFA9E[]; -extern const u8 UnknownString_81AFB17[]; -extern const u8 UnknownString_81AFB2D[]; -extern const u8 UnknownString_81AFB48[]; -extern const u8 UnknownString_81AFBD8[]; -extern const u8 UnknownString_81AFBE7[]; -extern const u8 UnknownString_81AFC04[]; -extern const u8 UnknownString_81AFC8A[]; -extern const u8 UnknownString_81AFC9D[]; -extern const u8 UnknownString_81AFCBE[]; -extern const u8 UnknownString_81AFD44[]; -extern const u8 UnknownString_81AFD60[]; -extern const u8 UnknownString_81AFD80[]; -extern const u8 UnknownString_81AFE1D[]; -extern const u8 UnknownString_81AFE36[]; -extern const u8 UnknownString_81AFE42[]; -extern const u8 UnknownString_81AFEC2[]; -extern const u8 UnknownString_81AFEDD[]; -extern const u8 UnknownString_81AFEEE[]; -extern const u8 UnknownString_81AFF68[]; -extern const u8 UnknownString_81AFF7B[]; -extern const u8 UnknownString_81AFF88[]; -extern const u8 UnknownString_81AFFFB[]; -extern const u8 UnknownString_81B000D[]; -extern const u8 UnknownString_81B0015[]; -extern const u8 UnknownString_81B009D[]; -extern const u8 UnknownString_81B00B6[]; -extern const u8 UnknownString_81B00C9[]; -extern const u8 UnknownString_81B014D[]; -extern const u8 UnknownString_81B0165[]; -extern const u8 UnknownString_81B0173[]; -extern const u8 UnknownString_81B01E9[]; -extern const u8 UnknownString_81B0201[]; -extern const u8 UnknownString_81B0213[]; -extern const u8 UnknownString_81B0290[]; -extern const u8 UnknownString_81B02A5[]; -extern const u8 UnknownString_81B02B6[]; -extern const u8 UnknownString_81B0337[]; -extern const u8 UnknownString_81B0351[]; -extern const u8 UnknownString_81B0364[]; -extern const u8 UnknownString_81B03E9[]; -extern const u8 UnknownString_81B0401[]; -extern const u8 UnknownString_81B040C[]; -extern const u8 UnknownString_81B046E[]; -extern const u8 UnknownString_81B0489[]; -extern const u8 UnknownString_81B049A[]; -extern const u8 UnknownString_81B0523[]; -extern const u8 UnknownString_81B053E[]; -extern const u8 UnknownString_81B0554[]; -extern const u8 UnknownString_81B05D8[]; -extern const u8 UnknownString_81B05F3[]; -extern const u8 UnknownString_81B0610[]; -extern const u8 UnknownString_81B06A9[]; -extern const u8 UnknownString_81B06C6[]; -extern const u8 UnknownString_81B06D9[]; -extern const u8 UnknownString_81B0763[]; -extern const u8 UnknownString_81B0781[]; -extern const u8 UnknownString_81B0797[]; +extern const u8 gTextStoryteller_Story1Title[]; +extern const u8 gTextStoryteller_Story1Action[]; +extern const u8 gTextStoryteller_Story1Text[]; +extern const u8 gTextStoryteller_Story2Title[]; +extern const u8 gTextStoryteller_Story2Action[]; +extern const u8 gTextStoryteller_Story2Text[]; +extern const u8 gTextStoryteller_Story3Title[]; +extern const u8 gTextStoryteller_Story3Action[]; +extern const u8 gTextStoryteller_Story3Text[]; +extern const u8 gTextStoryteller_Story4Title[]; +extern const u8 gTextStoryteller_Story4Action[]; +extern const u8 gTextStoryteller_Story4Text[]; +extern const u8 gTextStoryteller_Story5Title[]; +extern const u8 gTextStoryteller_Story5Action[]; +extern const u8 gTextStoryteller_Story5Text[]; +extern const u8 gTextStoryteller_Story6Title[]; +extern const u8 gTextStoryteller_Story6Action[]; +extern const u8 gTextStoryteller_Story6Text[]; +extern const u8 gTextStoryteller_Story7Title[]; +extern const u8 gTextStoryteller_Story7Action[]; +extern const u8 gTextStoryteller_Story7Text[]; +extern const u8 gTextStoryteller_Story8Title[]; +extern const u8 gTextStoryteller_Story8Action[]; +extern const u8 gTextStoryteller_Story8Text[]; +extern const u8 gTextStoryteller_Story9Title[]; +extern const u8 gTextStoryteller_Story9Action[]; +extern const u8 gTextStoryteller_Story9Text[]; +extern const u8 gTextStoryteller_Story10Title[]; +extern const u8 gTextStoryteller_Story10Action[]; +extern const u8 gTextStoryteller_Story10Text[]; +extern const u8 gTextStoryteller_Story11Title[]; +extern const u8 gTextStoryteller_Story11Action[]; +extern const u8 gTextStoryteller_Story11Text[]; +extern const u8 gTextStoryteller_Story12Title[]; +extern const u8 gTextStoryteller_Story12Action[]; +extern const u8 gTextStoryteller_Story12Text[]; +extern const u8 gTextStoryteller_Story13Title[]; +extern const u8 gTextStoryteller_Story13Action[]; +extern const u8 gTextStoryteller_Story13Text[]; +extern const u8 gTextStoryteller_Story14Title[]; +extern const u8 gTextStoryteller_Story14Action[]; +extern const u8 gTextStoryteller_Story14Text[]; +extern const u8 gTextStoryteller_Story15Title[]; +extern const u8 gTextStoryteller_Story15Action[]; +extern const u8 gTextStoryteller_Story15Text[]; +extern const u8 gTextStoryteller_Story16Title[]; +extern const u8 gTextStoryteller_Story16Action[]; +extern const u8 gTextStoryteller_Story16Text[]; +extern const u8 gTextStoryteller_Story17Title[]; +extern const u8 gTextStoryteller_Story17Action[]; +extern const u8 gTextStoryteller_Story17Text[]; +extern const u8 gTextStoryteller_Story18Title[]; +extern const u8 gTextStoryteller_Story18Action[]; +extern const u8 gTextStoryteller_Story18Text[]; +extern const u8 gTextStoryteller_Story19Title[]; +extern const u8 gTextStoryteller_Story19Action[]; +extern const u8 gTextStoryteller_Story19Text[]; +extern const u8 gTextStoryteller_Story20Title[]; +extern const u8 gTextStoryteller_Story20Action[]; +extern const u8 gTextStoryteller_Story20Text[]; +extern const u8 gTextStoryteller_Story21Title[]; +extern const u8 gTextStoryteller_Story21Action[]; +extern const u8 gTextStoryteller_Story21Text[]; +extern const u8 gTextStoryteller_Story22Title[]; +extern const u8 gTextStoryteller_Story22Action[]; +extern const u8 gTextStoryteller_Story22Text[]; +extern const u8 gTextStoryteller_Story23Title[]; +extern const u8 gTextStoryteller_Story23Action[]; +extern const u8 gTextStoryteller_Story23Text[]; +extern const u8 gTextStoryteller_Story24Title[]; +extern const u8 gTextStoryteller_Story24Action[]; +extern const u8 gTextStoryteller_Story24Text[]; +extern const u8 gTextStoryteller_Story25Title[]; +extern const u8 gTextStoryteller_Story25Action[]; +extern const u8 gTextStoryteller_Story25Text[]; +extern const u8 gTextStoryteller_Story26Title[]; +extern const u8 gTextStoryteller_Story26Action[]; +extern const u8 gTextStoryteller_Story26Text[]; +extern const u8 gTextStoryteller_Story27Title[]; +extern const u8 gTextStoryteller_Story27Action[]; +extern const u8 gTextStoryteller_Story27Text[]; +extern const u8 gTextStoryteller_Story28Title[]; +extern const u8 gTextStoryteller_Story28Action[]; +extern const u8 gTextStoryteller_Story28Text[]; +extern const u8 gTextStoryteller_Story29Title[]; +extern const u8 gTextStoryteller_Story29Action[]; +extern const u8 gTextStoryteller_Story29Text[]; +extern const u8 gTextStoryteller_Story30Title[]; +extern const u8 gTextStoryteller_Story30Action[]; +extern const u8 gTextStoryteller_Story30Text[]; +extern const u8 gTextStoryteller_Story31Title[]; +extern const u8 gTextStoryteller_Story31Action[]; +extern const u8 gTextStoryteller_Story31Text[]; +extern const u8 gTextStoryteller_Story32Title[]; +extern const u8 gTextStoryteller_Story32Action[]; +extern const u8 gTextStoryteller_Story32Text[]; +extern const u8 gTextStoryteller_Story33Title[]; +extern const u8 gTextStoryteller_Story33Action[]; +extern const u8 gTextStoryteller_Story33Text[]; +extern const u8 gTextStoryteller_Story34Title[]; +extern const u8 gTextStoryteller_Story34Action[]; +extern const u8 gTextStoryteller_Story34Text[]; +extern const u8 gTextStoryteller_Story35Title[]; +extern const u8 gTextStoryteller_Story35Action[]; +extern const u8 gTextStoryteller_Story35Text[]; +extern const u8 gTextStoryteller_Story36Title[]; +extern const u8 gTextStoryteller_Story36Action[]; +extern const u8 gTextStoryteller_Story36Text[]; extern struct UnkBard2 gUnknown_03005DA0; @@ -248,7 +248,7 @@ void SetupMauvilleOldMan(void) sub_80F83D0(); } -//#define TEST MAUVILLE_MAN_BARD +//#define TEST MAUVILLE_MAN_STORYTELLER #ifdef TEST // Safely changes man to test functionality @@ -376,7 +376,7 @@ void ScrSpecial_PlayBardSong(void) ScriptContext1_Stop(); } -void sub_80F7C70(void) +void ScrSpecial_GetHipsterSpokenFlag(void) { u16 *scriptResult = &gScriptResult; // again?? struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; @@ -391,7 +391,7 @@ void ScrSpecial_SetHipsterSpokenFlag(void) hipster->unk1 = 1; } -void sub_80F7C90(void) +void ScrSpecial_HipsterTeachWord(void) { u16 var = sub_80EB8EC(); @@ -1001,53 +1001,53 @@ void sub_80F83D0(void) VarSet(0x4010, 0x45 + GetCurrentMauvilleOldMan()); } -struct UnknownStruct1 +struct Story { u8 unk0; u8 unk1; - const u8 *unk4; - const u8 *unk8; - const u8 *unkC; + const u8 *title; + const u8 *action; + const u8 *fullText; }; -static const struct UnknownStruct1 gUnknown_083E53E0[] = +static const struct Story sStorytellerStories[] = { - {0x32, 1, UnknownString_81AEFFC, UnknownString_81AF013, UnknownString_81AF022}, - {0x02, 1, UnknownString_81AF0A3, UnknownString_81AF0BB, UnknownString_81AF0CA}, - {0x03, 1, UnknownString_81AF149, UnknownString_81AF164, UnknownString_81AF174}, - {0x04, 1, UnknownString_81AF1E5, UnknownString_81AF1FD, UnknownString_81AF20A}, - {0x06, 1, UnknownString_81AF281, UnknownString_81AF299, UnknownString_81AF2A9}, - {0x09, 1, UnknownString_81AF32C, UnknownString_81AF345, UnknownString_81AF34D}, - {0x0B, 1, UnknownString_81AF3D0, UnknownString_81AF3ED, UnknownString_81AF3FC}, - {0x0C, 1, UnknownString_81AF46D, UnknownString_81AF481, UnknownString_81AF49B}, - {0x0D, 1, UnknownString_81AF511, UnknownString_81AF529, UnknownString_81AF536}, - {0x0E, 1, UnknownString_81AF5A9, UnknownString_81AF5BD, UnknownString_81AF5CD}, - {0x0F, 1, UnknownString_81AF63F, UnknownString_81AF661, UnknownString_81AF676}, - {0x10, 1, UnknownString_81AF711, UnknownString_81AF726, UnknownString_81AF73D}, - {0x11, 1, UnknownString_81AF7BF, UnknownString_81AF7D9, UnknownString_81AF7F1}, - {0x12, 1, UnknownString_81AF88A, UnknownString_81AF8A1, UnknownString_81AF8AA}, - {0x13, 1, UnknownString_81AF91B, UnknownString_81AF935, UnknownString_81AF943}, - {0x14, 1, UnknownString_81AF9C8, UnknownString_81AF9E0, UnknownString_81AF9F6}, - {0x1A, 1, UnknownString_81AFA79, UnknownString_81AFA92, UnknownString_81AFA9E}, - {0x1B, 1, UnknownString_81AFB17, UnknownString_81AFB2D, UnknownString_81AFB48}, - {0x1C, 1, UnknownString_81AFBD8, UnknownString_81AFBE7, UnknownString_81AFC04}, - {0x1D, 2, UnknownString_81AFC8A, UnknownString_81AFC9D, UnknownString_81AFCBE}, - {0x1E, 1, UnknownString_81AFD44, UnknownString_81AFD60, UnknownString_81AFD80}, - {0x21, 1, UnknownString_81AFE1D, UnknownString_81AFE36, UnknownString_81AFE42}, - {0x24, 1, UnknownString_81AFEC2, UnknownString_81AFEDD, UnknownString_81AFEEE}, - {0x25, 1, UnknownString_81AFF68, UnknownString_81AFF7B, UnknownString_81AFF88}, - {0x26, 1, UnknownString_81AFFFB, UnknownString_81B000D, UnknownString_81B0015}, - {0x27, 1, UnknownString_81B009D, UnknownString_81B00B6, UnknownString_81B00C9}, - {0x28, 1, UnknownString_81B014D, UnknownString_81B0165, UnknownString_81B0173}, - {0x29, 1, UnknownString_81B01E9, UnknownString_81B0201, UnknownString_81B0213}, - {0x2A, 1, UnknownString_81B0290, UnknownString_81B02A5, UnknownString_81B02B6}, - {0x2B, 1, UnknownString_81B0337, UnknownString_81B0351, UnknownString_81B0364}, - {0x2C, 1, UnknownString_81B03E9, UnknownString_81B0401, UnknownString_81B040C}, - {0x2D, 1, UnknownString_81B046E, UnknownString_81B0489, UnknownString_81B049A}, - {0x2E, 1, UnknownString_81B0523, UnknownString_81B053E, UnknownString_81B0554}, - {0x2F, 1, UnknownString_81B05D8, UnknownString_81B05F3, UnknownString_81B0610}, - {0x30, 1, UnknownString_81B06A9, UnknownString_81B06C6, UnknownString_81B06D9}, - {0x31, 1, UnknownString_81B0763, UnknownString_81B0781, UnknownString_81B0797}, + {0x32, 1, gTextStoryteller_Story1Title, gTextStoryteller_Story1Action, gTextStoryteller_Story1Text}, + {0x02, 1, gTextStoryteller_Story2Title, gTextStoryteller_Story2Action, gTextStoryteller_Story2Text}, + {0x03, 1, gTextStoryteller_Story3Title, gTextStoryteller_Story3Action, gTextStoryteller_Story3Text}, + {0x04, 1, gTextStoryteller_Story4Title, gTextStoryteller_Story4Action, gTextStoryteller_Story4Text}, + {0x06, 1, gTextStoryteller_Story5Title, gTextStoryteller_Story5Action, gTextStoryteller_Story5Text}, + {0x09, 1, gTextStoryteller_Story6Title, gTextStoryteller_Story6Action, gTextStoryteller_Story6Text}, + {0x0B, 1, gTextStoryteller_Story7Title, gTextStoryteller_Story7Action, gTextStoryteller_Story7Text}, + {0x0C, 1, gTextStoryteller_Story8Title, gTextStoryteller_Story8Action, gTextStoryteller_Story8Text}, + {0x0D, 1, gTextStoryteller_Story9Title, gTextStoryteller_Story9Action, gTextStoryteller_Story9Text}, + {0x0E, 1, gTextStoryteller_Story10Title, gTextStoryteller_Story10Action, gTextStoryteller_Story10Text}, + {0x0F, 1, gTextStoryteller_Story11Title, gTextStoryteller_Story11Action, gTextStoryteller_Story11Text}, + {0x10, 1, gTextStoryteller_Story12Title, gTextStoryteller_Story12Action, gTextStoryteller_Story12Text}, + {0x11, 1, gTextStoryteller_Story13Title, gTextStoryteller_Story13Action, gTextStoryteller_Story13Text}, + {0x12, 1, gTextStoryteller_Story14Title, gTextStoryteller_Story14Action, gTextStoryteller_Story14Text}, + {0x13, 1, gTextStoryteller_Story15Title, gTextStoryteller_Story15Action, gTextStoryteller_Story15Text}, + {0x14, 1, gTextStoryteller_Story16Title, gTextStoryteller_Story16Action, gTextStoryteller_Story16Text}, + {0x1A, 1, gTextStoryteller_Story17Title, gTextStoryteller_Story17Action, gTextStoryteller_Story17Text}, + {0x1B, 1, gTextStoryteller_Story18Title, gTextStoryteller_Story18Action, gTextStoryteller_Story18Text}, + {0x1C, 1, gTextStoryteller_Story19Title, gTextStoryteller_Story19Action, gTextStoryteller_Story19Text}, + {0x1D, 2, gTextStoryteller_Story20Title, gTextStoryteller_Story20Action, gTextStoryteller_Story20Text}, + {0x1E, 1, gTextStoryteller_Story21Title, gTextStoryteller_Story21Action, gTextStoryteller_Story21Text}, + {0x21, 1, gTextStoryteller_Story22Title, gTextStoryteller_Story22Action, gTextStoryteller_Story22Text}, + {0x24, 1, gTextStoryteller_Story23Title, gTextStoryteller_Story23Action, gTextStoryteller_Story23Text}, + {0x25, 1, gTextStoryteller_Story24Title, gTextStoryteller_Story24Action, gTextStoryteller_Story24Text}, + {0x26, 1, gTextStoryteller_Story25Title, gTextStoryteller_Story25Action, gTextStoryteller_Story25Text}, + {0x27, 1, gTextStoryteller_Story26Title, gTextStoryteller_Story26Action, gTextStoryteller_Story26Text}, + {0x28, 1, gTextStoryteller_Story27Title, gTextStoryteller_Story27Action, gTextStoryteller_Story27Text}, + {0x29, 1, gTextStoryteller_Story28Title, gTextStoryteller_Story28Action, gTextStoryteller_Story28Text}, + {0x2A, 1, gTextStoryteller_Story29Title, gTextStoryteller_Story29Action, gTextStoryteller_Story29Text}, + {0x2B, 1, gTextStoryteller_Story30Title, gTextStoryteller_Story30Action, gTextStoryteller_Story30Text}, + {0x2C, 1, gTextStoryteller_Story31Title, gTextStoryteller_Story31Action, gTextStoryteller_Story31Text}, + {0x2D, 1, gTextStoryteller_Story32Title, gTextStoryteller_Story32Action, gTextStoryteller_Story32Text}, + {0x2E, 1, gTextStoryteller_Story33Title, gTextStoryteller_Story33Action, gTextStoryteller_Story33Text}, + {0x2F, 1, gTextStoryteller_Story34Title, gTextStoryteller_Story34Action, gTextStoryteller_Story34Text}, + {0x30, 1, gTextStoryteller_Story35Title, gTextStoryteller_Story35Action, gTextStoryteller_Story35Text}, + {0x31, 1, gTextStoryteller_Story36Title, gTextStoryteller_Story36Action, gTextStoryteller_Story36Text}, }; void StorytellerSetup(void) @@ -1060,7 +1060,7 @@ void StorytellerSetup(void) for (i = 0; i < 4; i++) { storyteller->unk4[i] = 0; - storyteller->unk8[0][i] = EOS; // Maybe they meant storyteller->unk8[i][0] instead? + storyteller->playerNames[0][i] = EOS; // Maybe they meant storyteller->playerNames[i][0] instead? } } @@ -1076,34 +1076,34 @@ u32 sub_80F8438(u8 stat) { if (stat == 50) stat = 0; - GetGameStat(stat); + return GetGameStat(stat); } -const struct UnknownStruct1 *sub_80F844C(u32 a) +const struct Story *GetStory(u32 a) { s32 i; for (i = 0; i < 36; i++) { - if (gUnknown_083E53E0[i].unk0 == a) - return &gUnknown_083E53E0[i]; + if (sStorytellerStories[i].unk0 == a) + return &sStorytellerStories[i]; } - return &gUnknown_083E53E0[35]; + return &sStorytellerStories[35]; } const u8 *sub_80F8478(u32 a) { - return sub_80F844C(a)->unk4; + return GetStory(a)->title; } const u8 *sub_80F8484(u32 a) { - return sub_80F844C(a)->unkC; + return GetStory(a)->fullText; } const u8 *sub_80F8490(u32 a) { - return sub_80F844C(a)->unk8; + return GetStory(a)->action; } u8 sub_80F849C(void) @@ -1147,30 +1147,30 @@ bool32 sub_80F8508(u32 a) return FALSE; } -void sub_80F8534(u32 a, void *b) +void GetStorytellerPlayerName(u32 player, void *dst) { - u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk8[a]; + u8 *name = gSaveBlock1.mauvilleMan.storyteller.playerNames[player]; - memset(b, 0xFF, 8); - memcpy(b, ptr, 7); + memset(dst, EOS, 8); + memcpy(dst, name, 7); } -void sub_80F8560(u32 a, const u8 *b) +void SetStorytellerPlayerName(u32 player, const u8 *dst) { - u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk8[a]; - u8 len = StringLength(b); + u8 *name = gSaveBlock1.mauvilleMan.storyteller.playerNames[player]; + u8 len = StringLength(dst); - memset(ptr, 0xFF, 7); - StringCopyN(ptr, b, len); + memset(name, EOS, 7); + StringCopyN(name, dst, len); } -void sub_80F8598(u32 a, u32 b) +void sub_80F8598(u32 player, u32 b) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - storyteller->unk4[a] = b; - sub_80F8560(a, gSaveBlock2.playerName); - sub_80F84EC(a, sub_80F8438(b)); + storyteller->unk4[player] = b; + SetStorytellerPlayerName(player, gSaveBlock2.playerName); + sub_80F84EC(player, sub_80F8438(b)); ConvertIntToDecimalStringN(gStringVar1, sub_80F8438(b), 0, 10); StringCopy(gStringVar2, sub_80F8490(b)); } @@ -1207,8 +1207,8 @@ bool8 sub_80F8650(void) sub_80F85FC(arr, 36); for (i = 0; i < 36; i++) { - u8 r4 = gUnknown_083E53E0[arr[i]].unk0; - u8 r6 = gUnknown_083E53E0[arr[i]].unk1; + u8 r4 = sStorytellerStories[arr[i]].unk0; + u8 r6 = sStorytellerStories[arr[i]].unk1; struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; for (j = 0; j < 4; j++) @@ -1226,14 +1226,14 @@ bool8 sub_80F8650(void) return FALSE; } -void sub_80F8700(u32 a) +void sub_80F8700(u32 player) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - u8 r6 = storyteller->unk4[a]; + u8 r6 = storyteller->unk4[player]; - ConvertIntToDecimalStringN(gStringVar1, sub_80F84C8(a), 0, 10); + ConvertIntToDecimalStringN(gStringVar1, sub_80F84C8(player), 0, 10); StringCopy(gStringVar2, sub_80F8490(r6)); - sub_80F8534(a, gStringVar3); + GetStorytellerPlayerName(player, gStringVar3); ShowFieldMessage(sub_80F8484(r6)); } diff --git a/src/trader.c b/src/trader.c index d289f72a8..4274d38de 100644 --- a/src/trader.c +++ b/src/trader.c @@ -62,7 +62,7 @@ void TraderSetup(void) struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; trader->id = MAUVILLE_MAN_TRADER; - trader->unk31 = 0; + trader->alreadyTraded = FALSE; for (i = 0; i < 4; i++) { @@ -76,7 +76,7 @@ void TraderSetup(void) void sub_8109A20(void) { struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; - trader->unk31 = 0; + trader->alreadyTraded = FALSE; } void sub_8109A30(u8 value) @@ -84,7 +84,7 @@ void sub_8109A30(u8 value) VarSet(VAR_RECYCLE_GOODS, value); } -void sub_8109A48(u8 taskId) +void CreateAvailableDecorationsMenu(u8 taskId) { u8 i; u8 numChoices = 1; @@ -140,7 +140,7 @@ void sub_8109B34(u8 taskId, u8 decorationId) EnableBothScriptContexts(); } -void sub_8109B7C(u8 taskId) +void Task_HandleGetDecorationMenuInput(u8 taskId) { struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; @@ -175,13 +175,13 @@ void sub_8109B7C(u8 taskId) } } -void sub_8109C44(void) +void ScrSpecial_GetTraderTradedFlag(void) { struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; - gScriptResult = trader->unk31; + gScriptResult = trader->alreadyTraded; } -void sub_8109C58(void) +void ScrSpecial_DoesPlayerHaveNoDecorations(void) { u8 i; @@ -196,7 +196,7 @@ void sub_8109C58(void) gScriptResult = TRUE; } -void sub_8109C90(void) +void ScrSpecial_IsDecorationFull(void) { gScriptResult = FALSE; if (gDecorations[gSpecialVar_0x8004].category != gDecorations[gSpecialVar_0x8006].category @@ -207,7 +207,7 @@ void sub_8109C90(void) } } -void sub_8109CF0(void) +void ScrSpecial_TraderMenuGiveDecoration(void) { CreateTask(sub_80FE7A8, 0); } @@ -243,7 +243,7 @@ void sub_8109DAC(u8 taskId) EnableBothScriptContexts(); } -void sub_8109DE0(void) +void ScrSpecial_TraderDoDecorationTrade(void) { struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; @@ -252,11 +252,11 @@ void sub_8109DE0(void) StringCopy(trader->unk5[gSpecialVar_0x8005], gSaveBlock2.playerName); trader->unk1[gSpecialVar_0x8005] = gSpecialVar_0x8006; sub_810993C(); - trader->unk31 = 1; + trader->alreadyTraded = TRUE; } -void sub_8109E34(void) +void ScrSpecial_TraderMenuGetDecoration(void) { - u8 taskId = CreateTask(sub_8109B7C, 0); - sub_8109A48(taskId); + u8 taskId = CreateTask(Task_HandleGetDecorationMenuInput, 0); + CreateAvailableDecorationsMenu(taskId); } -- cgit v1.2.3 From ded9b4a8d0a59dab3882ab3fe43817bc38bca834 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 19:13:29 -0500 Subject: more labeling --- src/bard_music.c | 47 +++++------ src/easy_chat.c | 25 +++--- src/mail.c | 2 +- src/mauville_old_man.c | 214 ++++++++++++++++++++++++++----------------------- src/trainer_card.c | 2 +- src/tv.c | 22 ++--- 6 files changed, 160 insertions(+), 152 deletions(-) (limited to 'src') diff --git a/src/bard_music.c b/src/bard_music.c index ce2a1e9ec..593376f35 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -2,36 +2,33 @@ #include "bard_music.h" #include "easy_chat.h" -extern struct BardSound *gBardMusicTable[]; +extern struct UnkBard (*gBardMusicTable[])[][6]; extern s16 *gUnknown_08417068[]; extern u32 gUnknown_084170F4[]; -static s16 sub_814A2B8(u32 arg0, u32 arg1) +static s16 CalcWordPitch(u32 arg0, u32 songPos) { - return gUnknown_08417068[arg0][arg1]; + return gUnknown_08417068[arg0][songPos]; } #if ENGLISH -struct BardSound *sub_814A2D0(u16 arg0, u16 arg1) +struct UnkBard *GetWordSoundInfo(u16 group, u16 word) { - struct BardSound *sounds = gBardMusicTable[arg0]; + struct UnkBard (*sounds)[][6] = gBardMusicTable[group]; - return &sounds[arg1]; + return (*sounds)[word]; } #elif GERMAN -struct BardSound *sub_814A2D0(u16 arg0, u16 arg1) +struct UnkBard *GetWordSoundInfo(u16 group, u16 word) { - u32 index; - struct BardSound *sounds; + struct UnkBard (*sounds)[][6] = gBardMusicTable[group]; + u32 index = de_sub_80EB748(group, word); - sounds = gBardMusicTable[arg0]; - index = de_sub_80EB748(arg0, arg1); - - return &sounds[index]; + return (*sounds)[index]; } #endif -s32 sub_814A2EC(struct UnkBard2 *dest, struct UnkBard *src, u16 arg2) +s32 GetWordPhonemes(struct BardSong *song, struct UnkBard *src, u16 arg2) { s32 i; s32 j; @@ -39,25 +36,25 @@ s32 sub_814A2EC(struct UnkBard2 *dest, struct UnkBard *src, u16 arg2) for (i = 0; i < 6; i++) { - dest->var18[i].var00 = src[i].var00; + song->phonemes[i].sound = src[i].var00; if (src[i].var00 != 0xFF) { - s32 r1 = src[i].var01 +gUnknown_084170F4[src[i].var00]; + s32 r1 = src[i].var01 + gUnknown_084170F4[src[i].var00]; - dest->var18[i].var02 = r1; - dest->var18[i].var06 = src[i].var04; - dest->var04 += r1; + song->phonemes[i].length = r1; + song->phonemes[i].volume = src[i].volume; + song->var04 += r1; } } for (j = 0, thirty = 30; j < i; j++) - dest->var18[j].var04 = sub_814A2B8(thirty + arg2, j); + song->phonemes[j].pitch = CalcWordPitch(thirty + arg2, j); - dest->var00++; - dest->var01 = 0; - dest->var02 = 0; - dest->var03 = 0; - dest->var0A = 0; + song->currWord++; + song->currPhoneme = 0; + song->phonemeTimer = 0; + song->state = 0; + song->voiceInflection = 0; //warning: no return statement in function returning non-void } diff --git a/src/easy_chat.c b/src/easy_chat.c index e0073d8d8..8fae62872 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -19,7 +19,8 @@ extern const u8 gEasyChatGroupSizes[]; extern u16 gSpecialVar_0x8004; -u8 *sub_80EB3FC(u8 *dst, u16 word) +// returns the end of the destination buffer text +u8 *EasyChat_GetWordText(u8 *dst, u16 word) { u16 group; u16 wordIndex; @@ -31,13 +32,13 @@ u8 *sub_80EB3FC(u8 *dst, u16 word) if (word == 0xFFFF) { - dst[0] = EOS; + *dst = EOS; return dst; } else { - group = word >> 9; - wordIndex = word & 0x1FF; + group = EC_GROUP(word); + wordIndex = EC_INDEX(word); switch (group) { case EC_GROUP_POKEMON: // 0 @@ -58,7 +59,7 @@ u8 *sub_80EB3FC(u8 *dst, u16 word) dst = StringCopy(dst, src); break; } - dst[0] = EOS; + *dst = EOS; return dst; } } @@ -76,7 +77,7 @@ u8 *ConvertEasyChatWordsToString(u8 *dst, u16 *words, u16 arg2, u16 arg3) for (n = 0; n < i1; n++) { - dst = sub_80EB3FC(dst, words[0]); + dst = EasyChat_GetWordText(dst, words[0]); if (words[0] != 0xFFFF) { @@ -89,7 +90,7 @@ u8 *ConvertEasyChatWordsToString(u8 *dst, u16 *words, u16 arg2, u16 arg3) word = words[0]; words++; - dst = sub_80EB3FC(dst, word); + dst = EasyChat_GetWordText(dst, word); dst[0] = CHAR_NEWLINE; dst++; @@ -114,7 +115,7 @@ u8 *sub_80EB544(u8 *dst, u16 *words, u16 arg2, u16 arg3) for (n = 0; n < i1; n++) { - dst = sub_80EB3FC(dst, words[0]); + dst = EasyChat_GetWordText(dst, words[0]); if (words[0] != 0xFFFF) { @@ -127,7 +128,7 @@ u8 *sub_80EB544(u8 *dst, u16 *words, u16 arg2, u16 arg3) word = words[0]; words++; - dst = sub_80EB3FC(dst, word); + dst = EasyChat_GetWordText(dst, word); // Only difference with ConvertEasyChatWordsToString dst[0] = (i == 0) ? CHAR_NEWLINE : CHAR_PROMPT_SCROLL; @@ -152,8 +153,8 @@ u16 unref_sub_80EB5E0(u16 arg0) if (arg0 == 0xFFFF) return 0; - group = arg0 >> 9; - word = arg0 & 0x1FF; + group = EC_GROUP(arg0); + word = EC_INDEX(arg0); switch (group) { case EC_GROUP_POKEMON: // 0 @@ -320,7 +321,7 @@ void sub_80EB83C(void) group = EC_GROUP_LIFESTYLE; local2 = sub_80EB784(group); - sub_80EB3FC(gStringVar2, local2); + EasyChat_GetWordText(gStringVar2, local2); } u8 sub_80EB868(u8 arg0) diff --git a/src/mail.c b/src/mail.c index 658d37976..fb9251a5d 100644 --- a/src/mail.c +++ b/src/mail.c @@ -92,7 +92,7 @@ void HandleReadMail(struct MailStruct *arg0, MainCallback arg1, bool8 arg2) ewram0.varFF = GAME_LANGUAGE; ewram0.var100 = 1; - ewram0.var104 = (MainCallback)sub_80EB3FC; + ewram0.var104 = (MainCallback)EasyChat_GetWordText; ewram0.var108 = (MainCallback)ConvertEasyChatWordsToString; mailDesign = arg0->itemId - ITEM_ORANGE_MAIL; diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index e5d661e4a..3cf5265c0 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -133,7 +133,7 @@ extern const u8 gTextStoryteller_Story36Title[]; extern const u8 gTextStoryteller_Story36Action[]; extern const u8 gTextStoryteller_Story36Text[]; -extern struct UnkBard2 gUnknown_03005DA0; +extern struct BardSong gUnknown_03005DA0; extern u16 gUnknown_020388BC; // set but not used? @@ -248,7 +248,7 @@ void SetupMauvilleOldMan(void) sub_80F83D0(); } -//#define TEST MAUVILLE_MAN_STORYTELLER +//#define TEST MAUVILLE_MAN_BARD #ifdef TEST // Safely changes man to test functionality @@ -319,52 +319,58 @@ void ScrSpecial_SaveBardSongLyrics(void) bard->hasChangedSong = TRUE; } -// prepare song? -void sub_80F7BA0(void) +// Copies lyrics into gStringVar4 +void PrepareSongText(void) { struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; u16 specialVar = gSpecialVar_0x8004; // It's a bit odd to use this temp variable, but it seems needed to match. u16 *lyrics; - u16 i; - u8 *ptr; - u8 *r4; + u16 lineNum; + u8 *wordEnd; + u8 *str; lyrics = bard->temporaryLyrics; if (specialVar == 0) lyrics = bard->songLyrics; - ptr = gStringVar4; - r4 = ptr; - for (i = 0; i < 2; i++) + wordEnd = gStringVar4; + str = wordEnd; + // Put three words on each line + for (lineNum = 0; lineNum < 2; lineNum++) { - ptr = sub_80EB3FC(ptr, *(lyrics++)); - while (ptr != r4) + wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); + while (wordEnd != str) { - if (*r4 == 0) - *r4 = 0x37; - r4++; + if (*str == CHAR_SPACE) + *str = CHAR_SONG_WORD_SEPARATOR; + str++; } - r4++; - *(ptr++) = CHAR_SPACE; - ptr = sub_80EB3FC(ptr, *(lyrics++)); - while (ptr != r4) + + str++; + *(wordEnd++) = CHAR_SPACE; + + wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); + while (wordEnd != str) { - if (*r4 == 0) - *r4 = 0x37; - r4++; + if (*str == CHAR_SPACE) + *str = CHAR_SONG_WORD_SEPARATOR; + str++; } - r4++; - *(ptr++) = CHAR_NEWLINE; - ptr = sub_80EB3FC(ptr, *(lyrics++)); - while (ptr != r4) + + str++; + *(wordEnd++) = CHAR_NEWLINE; + + wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); + while (wordEnd != str) { - if (*r4 == 0) - *r4 = 0x37; - r4++; + if (*str == CHAR_SPACE) + *str = CHAR_SONG_WORD_SEPARATOR; + str++; } - if (i == 0) + + if (lineNum == 0) { - *(ptr++) = EXT_CTRL_CODE_BEGIN; - *(ptr++) = 0xF; + *(wordEnd++) = EXT_CTRL_CODE_BEGIN; + *(wordEnd++) = 15; } } } @@ -401,7 +407,7 @@ void ScrSpecial_HipsterTeachWord(void) } else { - sub_80EB3FC(gStringVar1, var); + EasyChat_GetWordText(gStringVar1, var); gScriptResult = TRUE; } } @@ -434,7 +440,7 @@ void ScrSpecial_GenerateGiddyLine(void) u32 adjective = Random(); adjective %= 8; - stringPtr = sub_80EB3FC(gStringVar4, giddy->mauvilleOldMan_ecArray[giddy->unk1]); + stringPtr = EasyChat_GetWordText(gStringVar4, giddy->mauvilleOldMan_ecArray[giddy->unk1]); stringPtr = StringCopy(stringPtr, gOtherText_Is); stringPtr = StringCopy(stringPtr, gGiddyAdjectives[adjective]); StringCopy(stringPtr, gOtherText_DontYouAgree); @@ -761,105 +767,112 @@ void sub_80F7F30(void) sub_80F83D0(); } -void StartBardSong(u8 a) +#define tState data[0] +#define tCharIndex data[3] +#define tCurrWord data[4] +#define tUseTemporaryLyrics data[5] + +void StartBardSong(bool8 useTemporaryLyrics) { u8 taskId = CreateTask(Task_BardSong, 0x50); - gTasks[taskId].data[5] = a; + gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics; } -void BardSingWord(struct Task *task, struct UnkBard2 *b) +void BardSingWord(struct Task *task, struct BardSong *song) { - switch (task->data[0]) + switch (task->tState) { - case 0: + case 0: // Initialize song { struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - u16 *r2; + u16 *lyrics; s32 i; + // Copy lyrics if (gSpecialVar_0x8004 == 0) - r2 = bard->songLyrics; + lyrics = bard->songLyrics; else - r2 = bard->temporaryLyrics; + lyrics = bard->temporaryLyrics; for (i = 0; i < 6; i++) - b->var0C[i] = r2[i]; + song->lyrics[i] = lyrics[i]; + for (i = 0; i < 6; i++) { - b->var18[i].var00 = 0xFFFF; - b->var18[i].var02 = 0; - b->var18[i].var04 = 0; - b->var18[i].var06 = 0; + song->phonemes[i].sound = 0xFFFF; + song->phonemes[i].length = 0; + song->phonemes[i].pitch = 0; + song->phonemes[i].volume = 0; } - b->var00 = 0; - b->var01 = 0; - b->var04 = 0; + song->currWord = 0; + song->currPhoneme = 0; + song->var04 = 0; } break; - case 1: + case 1: // Wait for BGM to end break; - case 2: + case 2: // Initialize word { - u16 r4 = b->var0C[b->var00]; + u16 word = song->lyrics[song->currWord]; // TODO: fix this return type - struct UnkBard *r1 = (struct UnkBard *)sub_814A2D0(r4 / 0x200, r4 % 0x200); + struct UnkBard *sounds = GetWordSoundInfo(EC_GROUP(word), EC_INDEX(word)); - b->var04 = 0; - sub_814A2EC(b, r1, (r4 % 4) + ((r4 / 8) & 1)); + song->var04 = 0; + GetWordPhonemes(song, r1, MACRO1(word)); } break; case 3: case 4: { - struct UnkBard3 *r7 = &b->var18[b->var01]; + struct BardPhoneme *phoneme = &song->phonemes[song->currPhoneme]; - switch (b->var03) + switch (song->state) { case 0: - if (b->var02 == 0) + if (song->phonemeTimer == 0) // Timer has expired. Move to next phoneme { - if (b->var01 == 6 || r7->var00 == 0xFF) + if (song->currPhoneme == 6 || phoneme->sound == 0xFF) { - b->var03 = 0xFE; + song->state = 0xFE; break; } - b->var02 = r7->var02; - if (r7->var00 <= 50) + song->phonemeTimer = phoneme->length; + if (phoneme->sound <= 50) { - u16 r1 = r7->var00 / 3; + u16 num = phoneme->sound / 3; - m4aSongNumStart(249 + r1 * 3); + m4aSongNumStart(249 + num * 3); } - b->var03 = 1; + song->state = 1; } else { - if (b->var0A > 10) - b->volume -= 2; - if (b->var0A & 1) - b->pitch += 64; + if (song->voiceInflection > 10) + song->volume -= 2; + if (song->voiceInflection & 1) + song->pitch += 64; else - b->pitch -= 64; - m4aMPlayVolumeControl(&gMPlay_SE2, 0xFFFF, b->volume); - m4aMPlayPitchControl(&gMPlay_SE2, 0xFFFF, b->pitch); - b->var0A++; + song->pitch -= 64; + m4aMPlayVolumeControl(&gMPlay_SE2, 0xFFFF, song->volume); + m4aMPlayPitchControl(&gMPlay_SE2, 0xFFFF, song->pitch); + song->voiceInflection++; } - b->var02--; + song->phonemeTimer--; break; case 1: - b->var01++; - b->var03 = 0; - if (r7->var00 <= 50) + song->currPhoneme++; + song->state = 0; + if (phoneme->sound <= 50) { - b->volume = 0x100 + r7->var06 * 16; - m4aMPlayVolumeControl(&gMPlay_SE2, 0xFFFF, b->volume); - b->pitch = 0x200 + r7->var04; - m4aMPlayPitchControl(&gMPlay_SE2, 0xFFFF, b->pitch); + song->volume = 0x100 + phoneme->volume * 16; + m4aMPlayVolumeControl(&gMPlay_SE2, 0xFFFF, song->volume); + song->pitch = 0x200 + phoneme->pitch; + m4aMPlayPitchControl(&gMPlay_SE2, 0xFFFF, song->pitch); } break; case 0xFE: m4aMPlayStop(&gMPlay_SE2); - b->var03 = 0xFF; + song->state = 0xFF; break; } } @@ -869,9 +882,6 @@ void BardSingWord(struct Task *task, struct UnkBard2 *b) } } -#define tState data[0] -#define tCharIndex data[3] - void Task_BardSong(u8 taskId) { struct Task *task = &gTasks[taskId]; // r5 @@ -879,48 +889,48 @@ void Task_BardSong(u8 taskId) BardSingWord(task, &gUnknown_03005DA0); switch (task->tState) { - case 0: - sub_80F7BA0(); + case 0: // Initialize song + PrepareSongText(); InitWindowFromConfig(gMenuWindowPtr, &gWindowConfig_81E6CE4); sub_8002EB0(gMenuWindowPtr, gStringVar4, 2, 4, 15); task->data[1] = 0; task->data[2] = 0; task->tCharIndex = 0; - task->data[4] = 0; + task->tCurrWord = 0; FadeOutBGMTemporarily(4); task->tState = 1; break; - case 1: + case 1: // Wait for BGM to end if (IsBGMPausedOrStopped()) task->tState = 2; break; - case 2: + case 2: // Initialize word { struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - u8 *string = gStringVar4 + task->tCharIndex; + u8 *str = gStringVar4 + task->tCharIndex; u16 wordLen = 0; // Can't get it to match without hacking u32 temp; register s16 zero asm("r1"); - while (*string != CHAR_SPACE - && *string != CHAR_NEWLINE - && *string != EXT_CTRL_CODE_BEGIN - && *string != EOS) + while (*str != CHAR_SPACE + && *str != CHAR_NEWLINE + && *str != EXT_CTRL_CODE_BEGIN + && *str != EOS) { - string++; + str++; wordLen++; } - if (task->data[5] == 0) - gUnknown_020388BC = MACRO1(bard->songLyrics[task->data[4]]); + if (!task->tUseTemporaryLyrics) + gUnknown_020388BC = MACRO1(bard->songLyrics[task->tCurrWord]); else - gUnknown_020388BC = MACRO1(bard->temporaryLyrics[task->data[4]]); + gUnknown_020388BC = MACRO1(bard->temporaryLyrics[task->tCurrWord]); temp = gUnknown_03005DA0.var04 / wordLen; zero = 0; gUnknown_03005DA0.var04 = temp; if (gUnknown_03005DA0.var04 <= 0) gUnknown_03005DA0.var04 = 1; - task->data[4]++; + task->tCurrWord++; if (task->data[2] == 0) task->tState = 3; else @@ -961,7 +971,7 @@ void Task_BardSong(u8 taskId) task->tState = 2; task->data[2] = 8; } - else if (gStringVar4[task->tCharIndex] == 0x37) // What is 0x37 supposed to be? + else if (gStringVar4[task->tCharIndex] == CHAR_SONG_WORD_SEPARATOR) { gStringVar4[task->tCharIndex] = CHAR_SPACE; sub_8003418(gMenuWindowPtr); diff --git a/src/trainer_card.c b/src/trainer_card.c index 626c5a7bf..e64ec1c86 100644 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -509,7 +509,7 @@ static void sub_8093688(void) ewram0.var_5 = 0; ewram0.var_6 = 0; for (i = 0; i < 4; i++) - sub_80EB3FC(ewram0.var_20[i], ewram0.var_64.var_28[i]); + EasyChat_GetWordText(ewram0.var_20[i], ewram0.var_64.var_28[i]); sub_80936D4(); } diff --git a/src/tv.c b/src/tv.c index a254bcd5f..996709209 100644 --- a/src/tv.c +++ b/src/tv.c @@ -388,7 +388,7 @@ bool8 GabbyAndTyGetLastQuote(void) if (gSaveBlock1.gabbyAndTyData.quote == 0xffff) return FALSE; - sub_80EB3FC(gStringVar1, gSaveBlock1.gabbyAndTyData.quote); + EasyChat_GetWordText(gStringVar1, gSaveBlock1.gabbyAndTyData.quote); gSaveBlock1.gabbyAndTyData.quote |= 0xffff; return TRUE; } @@ -1624,7 +1624,7 @@ void sub_80BF79C(TVShow *arg0) break; i++; } - sub_80EB3FC(gStringVar3, arg0->recentHappenings.var04[i]); + EasyChat_GetWordText(gStringVar3, arg0->recentHappenings.var04[i]); } u8 sub_80BF7E8(struct TVShowNameRaterShow *arg0) @@ -2575,20 +2575,20 @@ void DoTVShowBravoTrainerPokemonProfile(void) break; case 3: TVShowConvertInternationalString(gStringVar1, bravoTrainer->playerName, bravoTrainer->language); - sub_80EB3FC(gStringVar2, bravoTrainer->var04[0]); + EasyChat_GetWordText(gStringVar2, bravoTrainer->var04[0]); sub_80BF088(2, bravoTrainer->contestResult + 1); gUnknown_020387E8 = 5; break; case 4: TVShowConvertInternationalString(gStringVar1, bravoTrainer->playerName, bravoTrainer->language); - sub_80EB3FC(gStringVar2, bravoTrainer->var04[0]); + EasyChat_GetWordText(gStringVar2, bravoTrainer->var04[0]); sub_80BF088(2, bravoTrainer->contestResult + 1); gUnknown_020387E8 = 5; break; case 5: TVShowConvertInternationalString(gStringVar1, bravoTrainer->playerName, bravoTrainer->language); CopyContestCategoryToStringVar(1, bravoTrainer->contestCategory); - sub_80EB3FC(gStringVar3, bravoTrainer->var04[1]); + EasyChat_GetWordText(gStringVar3, bravoTrainer->var04[1]); if (bravoTrainer->var14) gUnknown_020387E8 = 6; else @@ -2597,7 +2597,7 @@ void DoTVShowBravoTrainerPokemonProfile(void) case 6: StringCopy(gStringVar1, gSpeciesNames[bravoTrainer->species]); StringCopy(gStringVar2, gMoveNames[bravoTrainer->var14]); - sub_80EB3FC(gStringVar3, bravoTrainer->var04[1]); + EasyChat_GetWordText(gStringVar3, bravoTrainer->var04[1]); gUnknown_020387E8 = 7; break; case 7: @@ -2680,7 +2680,7 @@ void DoTVShowBravoTrainerBattleTowerProfile(void) gUnknown_020387E8 = 11; break; case 11: - sub_80EB3FC(gStringVar1, bravoTrainerTower->var18[0]); + EasyChat_GetWordText(gStringVar1, bravoTrainerTower->var18[0]); if (bravoTrainerTower->var1b == 0) gUnknown_020387E8 = 12; else @@ -2688,7 +2688,7 @@ void DoTVShowBravoTrainerBattleTowerProfile(void) break; case 12: case 13: - sub_80EB3FC(gStringVar1, bravoTrainerTower->var18[0]); + EasyChat_GetWordText(gStringVar1, bravoTrainerTower->var18[0]); TVShowConvertInternationalString(gStringVar2, bravoTrainerTower->trainerName, bravoTrainerTower->language); TVShowConvertInternationalString(gStringVar3, bravoTrainerTower->pokemonName, bravoTrainerTower->language); gUnknown_020387E8 = 14; @@ -3106,12 +3106,12 @@ void DoTVShowPokemonFanClubOpinions(void) case 3: TVShowConvertInternationalString(gStringVar1, fanclubOpinions->playerName, fanclubOpinions->language); StringCopy(gStringVar2, gSpeciesNames[fanclubOpinions->var02]); - sub_80EB3FC(gStringVar3, fanclubOpinions->var1C[0]); + EasyChat_GetWordText(gStringVar3, fanclubOpinions->var1C[0]); gUnknown_020387E8 = 4; break; case 4: TVShowConvertInternationalString(gStringVar1, fanclubOpinions->playerName, fanclubOpinions->language); - sub_80EB3FC(gStringVar3, fanclubOpinions->var1C[1]); + EasyChat_GetWordText(gStringVar3, fanclubOpinions->var1C[1]); TVShowDone(); break; } @@ -3176,7 +3176,7 @@ void DoTVShowInSearchOfTrainers(void) gUnknown_020387E8 = 8; break; case 8: - sub_80EB3FC(gStringVar1, gSaveBlock1.gabbyAndTyData.quote); + EasyChat_GetWordText(gStringVar1, gSaveBlock1.gabbyAndTyData.quote); StringCopy(gStringVar2, gSpeciesNames[gSaveBlock1.gabbyAndTyData.mon1]); StringCopy(gStringVar3, gSpeciesNames[gSaveBlock1.gabbyAndTyData.mon2]); gScriptResult = 1; -- cgit v1.2.3 From df6720ea01ab251c3d90885d75847fc39cc862c9 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 19:26:19 -0500 Subject: fix build --- src/bard_music.c | 27 ++++++++++++++++++--------- src/mauville_old_man.c | 4 ++-- 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/bard_music.c b/src/bard_music.c index 593376f35..5b7419735 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -2,7 +2,16 @@ #include "bard_music.h" #include "easy_chat.h" -extern struct UnkBard (*gBardMusicTable[])[][6]; +struct BardSound +{ + /*0x00*/ u8 var00; + /*0x01*/ s8 var01; + /*0x02*/ u16 var02; + /*0x04*/ u16 volume; + /*0x06*/ u16 var06; +}; + +extern const struct BardSound (*const gBardMusicTable[])[][6]; extern s16 *gUnknown_08417068[]; extern u32 gUnknown_084170F4[]; @@ -12,23 +21,23 @@ static s16 CalcWordPitch(u32 arg0, u32 songPos) } #if ENGLISH -struct UnkBard *GetWordSoundInfo(u16 group, u16 word) +const struct BardSound *GetWordSounds(u16 group, u16 word) { - struct UnkBard (*sounds)[][6] = gBardMusicTable[group]; + const struct BardSound (*sounds)[][6] = gBardMusicTable[group]; return (*sounds)[word]; } #elif GERMAN -struct UnkBard *GetWordSoundInfo(u16 group, u16 word) +struct BardSound *GetWordSounds(u16 group, u16 word) { - struct UnkBard (*sounds)[][6] = gBardMusicTable[group]; + struct BardSound (*sounds)[][6] = gBardMusicTable[group]; u32 index = de_sub_80EB748(group, word); return (*sounds)[index]; } #endif -s32 GetWordPhonemes(struct BardSong *song, struct UnkBard *src, u16 arg2) +s32 GetWordPhonemes(struct BardSong *song, struct BardSound *src, u16 arg2) { s32 i; s32 j; @@ -39,11 +48,11 @@ s32 GetWordPhonemes(struct BardSong *song, struct UnkBard *src, u16 arg2) song->phonemes[i].sound = src[i].var00; if (src[i].var00 != 0xFF) { - s32 r1 = src[i].var01 + gUnknown_084170F4[src[i].var00]; + s32 length = src[i].var01 + gUnknown_084170F4[src[i].var00]; - song->phonemes[i].length = r1; + song->phonemes[i].length = length; song->phonemes[i].volume = src[i].volume; - song->var04 += r1; + song->var04 += length; } } diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 3cf5265c0..c8bbf8c86 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -815,10 +815,10 @@ void BardSingWord(struct Task *task, struct BardSong *song) { u16 word = song->lyrics[song->currWord]; // TODO: fix this return type - struct UnkBard *sounds = GetWordSoundInfo(EC_GROUP(word), EC_INDEX(word)); + const struct BardSound *sounds = GetWordSounds(EC_GROUP(word), EC_INDEX(word)); song->var04 = 0; - GetWordPhonemes(song, r1, MACRO1(word)); + GetWordPhonemes(song, sounds, MACRO1(word)); } break; case 3: -- cgit v1.2.3 From 19e06e09c9579c8230c66d6d0d267c5b722637e5 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 19:37:36 -0500 Subject: actually fix build --- src/bard_music.c | 2 +- src/mauville_old_man.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/bard_music.c b/src/bard_music.c index 5b7419735..da628867b 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -37,7 +37,7 @@ struct BardSound *GetWordSounds(u16 group, u16 word) } #endif -s32 GetWordPhonemes(struct BardSong *song, struct BardSound *src, u16 arg2) +s32 GetWordPhonemes(struct BardSong *song, const struct BardSound *src, u16 arg2) { s32 i; s32 j; diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index c8bbf8c86..9e392a65a 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -797,6 +797,7 @@ void BardSingWord(struct Task *task, struct BardSong *song) for (i = 0; i < 6; i++) song->lyrics[i] = lyrics[i]; + // Clear phonemes for (i = 0; i < 6; i++) { song->phonemes[i].sound = 0xFFFF; @@ -814,7 +815,6 @@ void BardSingWord(struct Task *task, struct BardSong *song) case 2: // Initialize word { u16 word = song->lyrics[song->currWord]; - // TODO: fix this return type const struct BardSound *sounds = GetWordSounds(EC_GROUP(word), EC_INDEX(word)); song->var04 = 0; @@ -973,7 +973,7 @@ void Task_BardSong(u8 taskId) } else if (gStringVar4[task->tCharIndex] == CHAR_SONG_WORD_SEPARATOR) { - gStringVar4[task->tCharIndex] = CHAR_SPACE; + gStringVar4[task->tCharIndex] = CHAR_SPACE; // restore it back to a space sub_8003418(gMenuWindowPtr); task->tCharIndex++; task->data[2] = 0; -- cgit v1.2.3 From 670255f950a98f8a5cc636a20682b9ed42a31b21 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 19:54:39 -0500 Subject: fix build for real this time --- src/bard_music.c | 4 +-- src/mauville_old_man.c | 82 +++++++++++++++++++++++++------------------------- 2 files changed, 43 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/bard_music.c b/src/bard_music.c index da628867b..daf003233 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -28,9 +28,9 @@ const struct BardSound *GetWordSounds(u16 group, u16 word) return (*sounds)[word]; } #elif GERMAN -struct BardSound *GetWordSounds(u16 group, u16 word) +const struct BardSound *GetWordSounds(u16 group, u16 word) { - struct BardSound (*sounds)[][6] = gBardMusicTable[group]; + const struct BardSound (*sounds)[][6] = gBardMusicTable[group]; u32 index = de_sub_80EB748(group, word); return (*sounds)[index]; diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 9e392a65a..a5b5cb914 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -1013,8 +1013,8 @@ void sub_80F83D0(void) struct Story { - u8 unk0; - u8 unk1; + u8 stat; + u8 minVal; const u8 *title; const u8 *action; const u8 *fullText; @@ -1069,8 +1069,8 @@ void StorytellerSetup(void) storyteller->unk1 = FALSE; for (i = 0; i < 4; i++) { - storyteller->unk4[i] = 0; - storyteller->playerNames[0][i] = EOS; // Maybe they meant storyteller->playerNames[i][0] instead? + storyteller->gameStatIDs[i] = 0; + storyteller->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead? } } @@ -1082,36 +1082,36 @@ void sub_80F8428(void) storyteller->unk1 = FALSE; } -u32 sub_80F8438(u8 stat) +u32 StorytellerGetGameStat(u8 stat) { - if (stat == 50) + if (stat == NUM_GAME_STATS) stat = 0; return GetGameStat(stat); } -const struct Story *GetStory(u32 a) +const struct Story *GetStory(u32 stat) { s32 i; for (i = 0; i < 36; i++) { - if (sStorytellerStories[i].unk0 == a) + if (sStorytellerStories[i].stat == stat) return &sStorytellerStories[i]; } return &sStorytellerStories[35]; } -const u8 *sub_80F8478(u32 a) +const u8 *GetStoryTitle(u32 a) { return GetStory(a)->title; } -const u8 *sub_80F8484(u32 a) +const u8 *GetStoryText(u32 a) { return GetStory(a)->fullText; } -const u8 *sub_80F8490(u32 a) +const u8 *GetStoryAction(u32 a) { return GetStory(a)->action; } @@ -1124,34 +1124,34 @@ u8 sub_80F849C(void) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - if (storyteller->unk4[i] == 0) + if (storyteller->gameStatIDs[i] == 0) break; } return i; } -u32 sub_80F84C8(u32 a) +u32 StorytellerGetRecordedTrainerStat(u32 trainer) { - u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk24[a]; + u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk24[trainer]; return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); } -void sub_80F84EC(u32 a, u32 b) +void StorytellerSetRecordedTrainerStat(u32 trainer, u32 val) { - u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk24[a]; + u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk24[trainer]; - ptr[0] = b; - ptr[1] = b >> 8; - ptr[2] = b >> 16; - ptr[3] = b >> 24; + ptr[0] = val; + ptr[1] = val >> 8; + ptr[2] = val >> 16; + ptr[3] = val >> 24; } -bool32 sub_80F8508(u32 a) +bool32 sub_80F8508(u32 trainer) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - if (sub_80F8438(storyteller->unk4[a]) > sub_80F84C8(a)) + if (StorytellerGetGameStat(storyteller->gameStatIDs[trainer]) > StorytellerGetRecordedTrainerStat(trainer)) return TRUE; else return FALSE; @@ -1159,7 +1159,7 @@ bool32 sub_80F8508(u32 a) void GetStorytellerPlayerName(u32 player, void *dst) { - u8 *name = gSaveBlock1.mauvilleMan.storyteller.playerNames[player]; + u8 *name = gSaveBlock1.mauvilleMan.storyteller.trainerNames[player]; memset(dst, EOS, 8); memcpy(dst, name, 7); @@ -1167,22 +1167,22 @@ void GetStorytellerPlayerName(u32 player, void *dst) void SetStorytellerPlayerName(u32 player, const u8 *dst) { - u8 *name = gSaveBlock1.mauvilleMan.storyteller.playerNames[player]; + u8 *name = gSaveBlock1.mauvilleMan.storyteller.trainerNames[player]; u8 len = StringLength(dst); memset(name, EOS, 7); StringCopyN(name, dst, len); } -void sub_80F8598(u32 player, u32 b) +void sub_80F8598(u32 player, u32 stat) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - storyteller->unk4[player] = b; + storyteller->gameStatIDs[player] = stat; SetStorytellerPlayerName(player, gSaveBlock2.playerName); - sub_80F84EC(player, sub_80F8438(b)); - ConvertIntToDecimalStringN(gStringVar1, sub_80F8438(b), 0, 10); - StringCopy(gStringVar2, sub_80F8490(b)); + StorytellerSetRecordedTrainerStat(player, StorytellerGetGameStat(stat)); + ConvertIntToDecimalStringN(gStringVar1, StorytellerGetGameStat(stat), 0, 10); + StringCopy(gStringVar2, GetStoryAction(stat)); } void sub_80F85FC(u8 *arr, s32 count) @@ -1217,19 +1217,19 @@ bool8 sub_80F8650(void) sub_80F85FC(arr, 36); for (i = 0; i < 36; i++) { - u8 r4 = sStorytellerStories[arr[i]].unk0; - u8 r6 = sStorytellerStories[arr[i]].unk1; + u8 stat = sStorytellerStories[arr[i]].stat; + u8 minVal = sStorytellerStories[arr[i]].minVal; struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; for (j = 0; j < 4; j++) { - if (gSaveBlock1.mauvilleMan.storyteller.unk4[j] == r4) + if (gSaveBlock1.mauvilleMan.storyteller.gameStatIDs[j] == stat) break; } - if (j == 4 && sub_80F8438(r4) >= r6) + if (j == 4 && StorytellerGetGameStat(stat) >= minVal) { storyteller->unk1 = TRUE; - sub_80F8598(sub_80F849C(), r4); + sub_80F8598(sub_80F849C(), stat); return TRUE; } } @@ -1239,12 +1239,12 @@ bool8 sub_80F8650(void) void sub_80F8700(u32 player) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - u8 r6 = storyteller->unk4[player]; + u8 r6 = storyteller->gameStatIDs[player]; - ConvertIntToDecimalStringN(gStringVar1, sub_80F84C8(player), 0, 10); - StringCopy(gStringVar2, sub_80F8490(r6)); + ConvertIntToDecimalStringN(gStringVar1, StorytellerGetRecordedTrainerStat(player), 0, 10); + StringCopy(gStringVar2, GetStoryAction(r6)); GetStorytellerPlayerName(player, gStringVar3); - ShowFieldMessage(sub_80F8484(r6)); + ShowFieldMessage(GetStoryText(r6)); } void sub_80F8758(void) @@ -1255,11 +1255,11 @@ void sub_80F8758(void) for (i = 0; i < 4; i++) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - u8 r0 = storyteller->unk4[i]; + u8 r0 = storyteller->gameStatIDs[i]; if (r0 == 0) break; - MenuPrint(sub_80F8478(r0), 1, 2 + i * 2); + MenuPrint(GetStoryTitle(r0), 1, 2 + i * 2); } MenuPrint(gPCText_Cancel, 1, 2 + i * 2); } @@ -1317,7 +1317,7 @@ u8 sub_80F889C(void) bool8 sub_80F88AC(void) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - u8 r4 = storyteller->unk4[gUnknown_03000748]; + u8 r4 = storyteller->gameStatIDs[gUnknown_03000748]; if (sub_80F8508(gUnknown_03000748) == TRUE) { -- cgit v1.2.3 From 8c57ef0fad270bc795d0b64a75d96fafc0f63513 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 20:50:39 -0500 Subject: finish labeling script --- src/mauville_old_man.c | 143 +++++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index a5b5cb914..6feee5184 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -214,7 +214,7 @@ void SetupGiddy(void) struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; giddy->id = MAUVILLE_MAN_GIDDY; - giddy->unk1 = 0; + giddy->taleCounter = 0; } void SetupTrader(void) @@ -248,7 +248,7 @@ void SetupMauvilleOldMan(void) sub_80F83D0(); } -//#define TEST MAUVILLE_MAN_BARD +//#define TEST MAUVILLE_MAN_STORYTELLER #ifdef TEST // Safely changes man to test functionality @@ -344,10 +344,10 @@ void PrepareSongText(void) *str = CHAR_SONG_WORD_SEPARATOR; str++; } - + str++; *(wordEnd++) = CHAR_SPACE; - + wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); while (wordEnd != str) { @@ -355,10 +355,10 @@ void PrepareSongText(void) *str = CHAR_SONG_WORD_SEPARATOR; str++; } - + str++; *(wordEnd++) = CHAR_NEWLINE; - + wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); while (wordEnd != str) { @@ -366,7 +366,7 @@ void PrepareSongText(void) *str = CHAR_SONG_WORD_SEPARATOR; str++; } - + if (lineNum == 0) { *(wordEnd++) = EXT_CTRL_CODE_BEGIN; @@ -412,14 +412,14 @@ void ScrSpecial_HipsterTeachWord(void) } } -void sub_80F7CC8(void) +void ScrSpecial_GiddyShouldTellAnotherTale(void) { - struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; - if (bard->unk_2D95 == 10) + if (giddy->taleCounter == 10) { gScriptResult = FALSE; - bard->unk_2D95 = 0; + giddy->taleCounter = 0; } else { @@ -431,16 +431,16 @@ void ScrSpecial_GenerateGiddyLine(void) { struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; - if (giddy->unk1 == 0) + if (giddy->taleCounter == 0) sub_80F7DC0(); - if (giddy->mauvilleOldMan_ecArray[giddy->unk1] != 0xFFFF) // is not the last element of the array? + if (giddy->randomWords[giddy->taleCounter] != 0xFFFF) // is not the last element of the array? { u8 *stringPtr; u32 adjective = Random(); adjective %= 8; - stringPtr = EasyChat_GetWordText(gStringVar4, giddy->mauvilleOldMan_ecArray[giddy->unk1]); + stringPtr = EasyChat_GetWordText(gStringVar4, giddy->randomWords[giddy->taleCounter]); stringPtr = StringCopy(stringPtr, gOtherText_Is); stringPtr = StringCopy(stringPtr, gGiddyAdjectives[adjective]); StringCopy(stringPtr, gOtherText_DontYouAgree); @@ -451,9 +451,9 @@ void ScrSpecial_GenerateGiddyLine(void) } if (!(Random() % 10)) - giddy->unk1 = 10; + giddy->taleCounter = 10; else - giddy->unk1++; + giddy->taleCounter++; gScriptResult = TRUE; } @@ -520,8 +520,8 @@ void sub_80F7DC0(void) u16 var = Random() % 10; if (var < 3 && r7 < 8) { - //gSaveBlock1.mauvilleMan.giddy.mauvilleOldMan_ecArray[i] = 0xFFFF; - giddy->mauvilleOldMan_ecArray[i] = 0xFFFF; + //gSaveBlock1.mauvilleMan.giddy.randomWords[i] = 0xFFFF; + giddy->randomWords[i] = 0xFFFF; r7++; } //_080F7E90 @@ -541,8 +541,8 @@ void sub_80F7DC0(void) if (r1 == 6) r1 = 0; - //gSaveBlock1.mauvilleMan.giddy.mauvilleOldMan_ecArray[i] = sub_80EB784(arr[r1][0]); - giddy->mauvilleOldMan_ecArray[i] = sub_80EB784(arr[r1][0]); + //gSaveBlock1.mauvilleMan.giddy.randomWords[i] = sub_80EB784(arr[r1][0]); + giddy->randomWords[i] = sub_80EB784(arr[r1][0]); } } } @@ -796,7 +796,7 @@ void BardSingWord(struct Task *task, struct BardSong *song) lyrics = bard->temporaryLyrics; for (i = 0; i < 6; i++) song->lyrics[i] = lyrics[i]; - + // Clear phonemes for (i = 0; i < 6; i++) { @@ -1089,7 +1089,7 @@ u32 StorytellerGetGameStat(u8 stat) return GetGameStat(stat); } -const struct Story *GetStory(u32 stat) +const struct Story *GetStoryByStat(u32 stat) { s32 i; @@ -1101,22 +1101,22 @@ const struct Story *GetStory(u32 stat) return &sStorytellerStories[35]; } -const u8 *GetStoryTitle(u32 a) +const u8 *GetStoryTitleByStat(u32 stat) { - return GetStory(a)->title; + return GetStoryByStat(stat)->title; } -const u8 *GetStoryText(u32 a) +const u8 *GetStoryTextByStat(u32 stat) { - return GetStory(a)->fullText; + return GetStoryByStat(stat)->fullText; } -const u8 *GetStoryAction(u32 a) +const u8 *GetStoryActionByStat(u32 stat) { - return GetStory(a)->action; + return GetStoryByStat(stat)->action; } -u8 sub_80F849C(void) +u8 GetFreeStorySlot(void) { u8 i; @@ -1147,7 +1147,7 @@ void StorytellerSetRecordedTrainerStat(u32 trainer, u32 val) ptr[3] = val >> 24; } -bool32 sub_80F8508(u32 trainer) +bool32 HasTrainerStatIncreased(u32 trainer) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; @@ -1157,7 +1157,7 @@ bool32 sub_80F8508(u32 trainer) return FALSE; } -void GetStorytellerPlayerName(u32 player, void *dst) +void GetStoryByStattellerPlayerName(u32 player, void *dst) { u8 *name = gSaveBlock1.mauvilleMan.storyteller.trainerNames[player]; @@ -1165,27 +1165,27 @@ void GetStorytellerPlayerName(u32 player, void *dst) memcpy(dst, name, 7); } -void SetStorytellerPlayerName(u32 player, const u8 *dst) +void StorytellerSetPlayerName(u32 player, const u8 *src) { u8 *name = gSaveBlock1.mauvilleMan.storyteller.trainerNames[player]; - u8 len = StringLength(dst); + u8 len = StringLength(src); memset(name, EOS, 7); - StringCopyN(name, dst, len); + StringCopyN(name, src, len); } -void sub_80F8598(u32 player, u32 stat) +void StorytellerRecordNewStat(u32 player, u32 stat) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; storyteller->gameStatIDs[player] = stat; - SetStorytellerPlayerName(player, gSaveBlock2.playerName); + StorytellerSetPlayerName(player, gSaveBlock2.playerName); StorytellerSetRecordedTrainerStat(player, StorytellerGetGameStat(stat)); ConvertIntToDecimalStringN(gStringVar1, StorytellerGetGameStat(stat), 0, 10); - StringCopy(gStringVar2, GetStoryAction(stat)); + StringCopy(gStringVar2, GetStoryActionByStat(stat)); } -void sub_80F85FC(u8 *arr, s32 count) +void ScrambleStatList(u8 *arr, s32 count) { s32 i; @@ -1201,20 +1201,21 @@ void sub_80F85FC(u8 *arr, s32 count) } } -static const struct {u32 length; struct MauvilleManStoryteller *unused1; u32 unused2;} gUnknown_083E5620 = +// What purpose does this struct even serve? Only the length field is used. +static const struct {u32 length; struct MauvilleManStoryteller *unused1; u32 unused2;} sStorytellerStuff = { 36, &gSaveBlock1.mauvilleMan.storyteller, // unused - 12, // unused + 12, // unused }; -bool8 sub_80F8650(void) +bool8 StorytellerInitializeRandomStat(void) { - u8 arr[gUnknown_083E5620.length]; + u8 arr[sStorytellerStuff.length]; s32 i; s32 j; - sub_80F85FC(arr, 36); + ScrambleStatList(arr, 36); for (i = 0; i < 36; i++) { u8 stat = sStorytellerStories[arr[i]].stat; @@ -1229,44 +1230,44 @@ bool8 sub_80F8650(void) if (j == 4 && StorytellerGetGameStat(stat) >= minVal) { storyteller->unk1 = TRUE; - sub_80F8598(sub_80F849C(), stat); + StorytellerRecordNewStat(GetFreeStorySlot(), stat); return TRUE; } } return FALSE; } -void sub_80F8700(u32 player) +void StorytellerDisplayStory(u32 player) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - u8 r6 = storyteller->gameStatIDs[player]; + u8 stat = storyteller->gameStatIDs[player]; ConvertIntToDecimalStringN(gStringVar1, StorytellerGetRecordedTrainerStat(player), 0, 10); - StringCopy(gStringVar2, GetStoryAction(r6)); - GetStorytellerPlayerName(player, gStringVar3); - ShowFieldMessage(GetStoryText(r6)); + StringCopy(gStringVar2, GetStoryActionByStat(stat)); + GetStoryByStattellerPlayerName(player, gStringVar3); + ShowFieldMessage(GetStoryTextByStat(stat)); } -void sub_80F8758(void) +void PrintStoryList(void) { s32 i; - MenuDrawTextWindow(0, 0, 25, 4 + sub_80F849C() * 2); + MenuDrawTextWindow(0, 0, 25, 4 + GetFreeStorySlot() * 2); for (i = 0; i < 4; i++) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - u8 r0 = storyteller->gameStatIDs[i]; + u8 stat = storyteller->gameStatIDs[i]; - if (r0 == 0) + if (stat == 0) break; - MenuPrint(GetStoryTitle(r0), 1, 2 + i * 2); + MenuPrint(GetStoryTitleByStat(stat), 1, 2 + i * 2); } MenuPrint(gPCText_Cancel, 1, 2 + i * 2); } extern u8 gUnknown_03000748; -void sub_80F87C4(u8 taskId) +void Task_StoryListMenu(u8 taskId) { struct Task *task = &gTasks[taskId]; s32 selection; @@ -1274,15 +1275,15 @@ void sub_80F87C4(u8 taskId) switch (task->data[0]) { case 0: - sub_80F8758(); - InitMenu(0, 1, 2, sub_80F849C() + 1, 0, 24); + PrintStoryList(); + InitMenu(0, 1, 2, GetFreeStorySlot() + 1, 0, 24); task->data[0]++; break; case 1: selection = ProcessMenuInput(); if (selection == -2) break; - if (selection == -1 || selection == sub_80F849C()) + if (selection == -1 || selection == GetFreeStorySlot()) { gScriptResult = 0; } @@ -1299,35 +1300,37 @@ void sub_80F87C4(u8 taskId) } } -void sub_80F8874(void) +// Sets gScriptResult to TRUE if player selected a story +void ScrSpecial_StorytellerStoryListMenu(void) { - CreateTask(sub_80F87C4, 0x50); + CreateTask(Task_StoryListMenu, 0x50); } -void sub_80F8888(void) +void ScrSpecial_StorytellerDisplayStory(void) { - sub_80F8700(gUnknown_03000748); + StorytellerDisplayStory(gUnknown_03000748); } -u8 sub_80F889C(void) +u8 ScrSpecial_StorytellerGetFreeStorySlot(void) { - return sub_80F849C(); + return GetFreeStorySlot(); } -bool8 sub_80F88AC(void) +// Returns TRUE if stat has increased +bool8 ScrSpecial_StorytellerUpdateStat(void) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; u8 r4 = storyteller->gameStatIDs[gUnknown_03000748]; - if (sub_80F8508(gUnknown_03000748) == TRUE) + if (HasTrainerStatIncreased(gUnknown_03000748) == TRUE) { - sub_80F8598(gUnknown_03000748, r4); + StorytellerRecordNewStat(gUnknown_03000748, r4); return TRUE; } return FALSE; } -bool8 sub_80F88E0(void) +bool8 ScrSpecial_HasStorytellerAlreadyRecorded(void) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; @@ -1337,7 +1340,7 @@ bool8 sub_80F88E0(void) return TRUE; } -bool8 sub_80F88FC(void) +bool8 ScrSpecial_StorytellerInitializeRandomStat(void) { - return sub_80F8650(); + return StorytellerInitializeRandomStat(); } -- cgit v1.2.3 From b6ea4d9a77cdb6b416d3dd94eef68ce8a56cd4eb Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 24 Aug 2017 21:18:07 -0500 Subject: label more stuff in mauville_old_man.c --- src/mauville_old_man.c | 150 +++++++++++++++++++------------------------------ 1 file changed, 58 insertions(+), 92 deletions(-) (limited to 'src') diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 6feee5184..2f58e65fc 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -135,9 +135,9 @@ extern const u8 gTextStoryteller_Story36Text[]; extern struct BardSong gUnknown_03005DA0; -extern u16 gUnknown_020388BC; // set but not used? +EWRAM_DATA static u16 gUnknown_020388BC = 0; // set but not used? -static const u16 gDefaultBardSongLyrics[] = +static const u16 sDefaultBardSongLyrics[] = { #ifdef ENGLISH EC_WORD_SISTER, @@ -156,7 +156,7 @@ static const u16 gDefaultBardSongLyrics[] = #endif }; -static const u8 *const gGiddyAdjectives[] = +static const u8 *const sGiddyAdjectives[] = { OtherText_SoPretty, OtherText_SoDarling, @@ -168,7 +168,7 @@ static const u8 *const gGiddyAdjectives[] = OtherText_SoMagical, }; -static const u8 *const gGiddyQuestions[] = +static const u8 *const sGiddyQuestions[] = { OtherText_WantVacationNicePlace, OtherText_BoughtCrayonsIsNice, @@ -180,12 +180,13 @@ static const u8 *const gGiddyQuestions[] = OtherText_SecretBasesWonderful, }; -void Task_BardSong(u8); -void StartBardSong(u8); -void StorytellerSetup(void); -void sub_80F8428(void); +static void sub_80F7DC0(void); +static void Task_BardSong(u8); +static void StartBardSong(u8); +static void StorytellerSetup(void); +static void sub_80F8428(void); -void SetupBard(void) +static void SetupBard(void) { u16 i; struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; @@ -193,23 +194,23 @@ void SetupBard(void) bard->id = MAUVILLE_MAN_BARD; bard->hasChangedSong = FALSE; for (i = 0; i < 6; i++) - bard->songLyrics[i] = gDefaultBardSongLyrics[i]; + bard->songLyrics[i] = sDefaultBardSongLyrics[i]; } -void SetupHipster(void) +static void SetupHipster(void) { struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; hipster->id = MAUVILLE_MAN_HIPSTER; - hipster->unk1 = 0; + hipster->alreadySpoken = FALSE; } -void SetupStoryteller(void) +static void SetupStoryteller(void) { StorytellerSetup(); } -void SetupGiddy(void) +static void SetupGiddy(void) { struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; @@ -217,7 +218,7 @@ void SetupGiddy(void) giddy->taleCounter = 0; } -void SetupTrader(void) +static void SetupTrader(void) { TraderSetup(); } @@ -248,47 +249,12 @@ void SetupMauvilleOldMan(void) sub_80F83D0(); } -//#define TEST MAUVILLE_MAN_STORYTELLER - -#ifdef TEST -// Safely changes man to test functionality -u8 GetCurrentMauvilleOldMan(void) -{ - u8 newMan = TEST; - struct MauvilleManCommon *common = &gSaveBlock1.mauvilleMan.common; - - if (common->id != newMan) - { - switch (newMan) - { - case MAUVILLE_MAN_BARD: - SetupBard(); - break; - case MAUVILLE_MAN_HIPSTER: - SetupHipster(); - break; - case MAUVILLE_MAN_TRADER: - SetupTrader(); - break; - case MAUVILLE_MAN_STORYTELLER: - SetupStoryteller(); - break; - case MAUVILLE_MAN_GIDDY: - SetupGiddy(); - break; - } - sub_80F83D0(); - } - return common->id; -} -#else -u8 GetCurrentMauvilleOldMan(void) +static u8 GetCurrentMauvilleOldMan(void) { struct MauvilleManCommon *common = &gSaveBlock1.mauvilleMan.common; return common->id; } -#endif void ScrSpecial_GetCurrentMauvilleMan(void) { @@ -387,14 +353,14 @@ void ScrSpecial_GetHipsterSpokenFlag(void) u16 *scriptResult = &gScriptResult; // again?? struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; - *scriptResult = hipster->unk1; + *scriptResult = hipster->alreadySpoken; } void ScrSpecial_SetHipsterSpokenFlag(void) { struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; - hipster->unk1 = 1; + hipster->alreadySpoken = TRUE; } void ScrSpecial_HipsterTeachWord(void) @@ -442,12 +408,12 @@ void ScrSpecial_GenerateGiddyLine(void) adjective %= 8; stringPtr = EasyChat_GetWordText(gStringVar4, giddy->randomWords[giddy->taleCounter]); stringPtr = StringCopy(stringPtr, gOtherText_Is); - stringPtr = StringCopy(stringPtr, gGiddyAdjectives[adjective]); + stringPtr = StringCopy(stringPtr, sGiddyAdjectives[adjective]); StringCopy(stringPtr, gOtherText_DontYouAgree); } else { - StringCopy(gStringVar4, gGiddyQuestions[giddy->questionList[giddy->questionNum++]]); + StringCopy(gStringVar4, sGiddyQuestions[giddy->questionList[giddy->questionNum++]]); } if (!(Random() % 10)) @@ -459,7 +425,7 @@ void ScrSpecial_GenerateGiddyLine(void) } #ifdef NONMATCHING -void sub_80F7DC0(void) +static void sub_80F7DC0(void) { u16 arr[][2] = { @@ -548,7 +514,7 @@ void sub_80F7DC0(void) } #else -const u16 gUnknown_083E53C8[][2] = +static const u16 gUnknown_083E53C8[][2] = { { 0x0, 0}, { 0xC, 0}, @@ -559,7 +525,7 @@ const u16 gUnknown_083E53C8[][2] = }; __attribute__((naked)) -void sub_80F7DC0(void) +static void sub_80F7DC0(void) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ @@ -721,26 +687,26 @@ _080F7EE2:\n\ } #endif -void sub_80F7EFC(void) +static void sub_80F7EFC(void) { struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; bard->hasChangedSong = FALSE; } -void sub_80F7F0C(void) +static void sub_80F7F0C(void) { struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; - hipster->unk1 = 0; + hipster->alreadySpoken = FALSE; } -void sub_80F7F18(void) +static void sub_80F7F18(void) { sub_8109A20(); } -void sub_80F7F24(void) +static void sub_80F7F24(void) { sub_80F8428(); } @@ -772,14 +738,14 @@ void sub_80F7F30(void) #define tCurrWord data[4] #define tUseTemporaryLyrics data[5] -void StartBardSong(bool8 useTemporaryLyrics) +static void StartBardSong(bool8 useTemporaryLyrics) { u8 taskId = CreateTask(Task_BardSong, 0x50); gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics; } -void BardSingWord(struct Task *task, struct BardSong *song) +static void BardSing(struct Task *task, struct BardSong *song) { switch (task->tState) { @@ -882,11 +848,11 @@ void BardSingWord(struct Task *task, struct BardSong *song) } } -void Task_BardSong(u8 taskId) +static void Task_BardSong(u8 taskId) { struct Task *task = &gTasks[taskId]; // r5 - BardSingWord(task, &gUnknown_03005DA0); + BardSing(task, &gUnknown_03005DA0); switch (task->tState) { case 0: // Initialize song @@ -1060,13 +1026,13 @@ static const struct Story sStorytellerStories[] = {0x31, 1, gTextStoryteller_Story36Title, gTextStoryteller_Story36Action, gTextStoryteller_Story36Text}, }; -void StorytellerSetup(void) +static void StorytellerSetup(void) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; s32 i; storyteller->id = MAUVILLE_MAN_STORYTELLER; - storyteller->unk1 = FALSE; + storyteller->alreadyRecorded = FALSE; for (i = 0; i < 4; i++) { storyteller->gameStatIDs[i] = 0; @@ -1074,22 +1040,22 @@ void StorytellerSetup(void) } } -void sub_80F8428(void) +static void sub_80F8428(void) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; storyteller->id = MAUVILLE_MAN_STORYTELLER; - storyteller->unk1 = FALSE; + storyteller->alreadyRecorded = FALSE; } -u32 StorytellerGetGameStat(u8 stat) +static u32 StorytellerGetGameStat(u8 stat) { if (stat == NUM_GAME_STATS) stat = 0; return GetGameStat(stat); } -const struct Story *GetStoryByStat(u32 stat) +static const struct Story *GetStoryByStat(u32 stat) { s32 i; @@ -1101,22 +1067,22 @@ const struct Story *GetStoryByStat(u32 stat) return &sStorytellerStories[35]; } -const u8 *GetStoryTitleByStat(u32 stat) +static const u8 *GetStoryTitleByStat(u32 stat) { return GetStoryByStat(stat)->title; } -const u8 *GetStoryTextByStat(u32 stat) +static const u8 *GetStoryTextByStat(u32 stat) { return GetStoryByStat(stat)->fullText; } -const u8 *GetStoryActionByStat(u32 stat) +static const u8 *GetStoryActionByStat(u32 stat) { return GetStoryByStat(stat)->action; } -u8 GetFreeStorySlot(void) +static u8 GetFreeStorySlot(void) { u8 i; @@ -1130,16 +1096,16 @@ u8 GetFreeStorySlot(void) return i; } -u32 StorytellerGetRecordedTrainerStat(u32 trainer) +static u32 StorytellerGetRecordedTrainerStat(u32 trainer) { - u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk24[trainer]; + u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.statValues[trainer]; return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); } -void StorytellerSetRecordedTrainerStat(u32 trainer, u32 val) +static void StorytellerSetRecordedTrainerStat(u32 trainer, u32 val) { - u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.unk24[trainer]; + u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.statValues[trainer]; ptr[0] = val; ptr[1] = val >> 8; @@ -1147,7 +1113,7 @@ void StorytellerSetRecordedTrainerStat(u32 trainer, u32 val) ptr[3] = val >> 24; } -bool32 HasTrainerStatIncreased(u32 trainer) +static bool32 HasTrainerStatIncreased(u32 trainer) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; @@ -1157,7 +1123,7 @@ bool32 HasTrainerStatIncreased(u32 trainer) return FALSE; } -void GetStoryByStattellerPlayerName(u32 player, void *dst) +static void GetStoryByStattellerPlayerName(u32 player, void *dst) { u8 *name = gSaveBlock1.mauvilleMan.storyteller.trainerNames[player]; @@ -1165,7 +1131,7 @@ void GetStoryByStattellerPlayerName(u32 player, void *dst) memcpy(dst, name, 7); } -void StorytellerSetPlayerName(u32 player, const u8 *src) +static void StorytellerSetPlayerName(u32 player, const u8 *src) { u8 *name = gSaveBlock1.mauvilleMan.storyteller.trainerNames[player]; u8 len = StringLength(src); @@ -1174,7 +1140,7 @@ void StorytellerSetPlayerName(u32 player, const u8 *src) StringCopyN(name, src, len); } -void StorytellerRecordNewStat(u32 player, u32 stat) +static void StorytellerRecordNewStat(u32 player, u32 stat) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; @@ -1185,7 +1151,7 @@ void StorytellerRecordNewStat(u32 player, u32 stat) StringCopy(gStringVar2, GetStoryActionByStat(stat)); } -void ScrambleStatList(u8 *arr, s32 count) +static void ScrambleStatList(u8 *arr, s32 count) { s32 i; @@ -1209,7 +1175,7 @@ static const struct {u32 length; struct MauvilleManStoryteller *unused1; u32 unu 12, // unused }; -bool8 StorytellerInitializeRandomStat(void) +static bool8 StorytellerInitializeRandomStat(void) { u8 arr[sStorytellerStuff.length]; s32 i; @@ -1229,7 +1195,7 @@ bool8 StorytellerInitializeRandomStat(void) } if (j == 4 && StorytellerGetGameStat(stat) >= minVal) { - storyteller->unk1 = TRUE; + storyteller->alreadyRecorded = TRUE; StorytellerRecordNewStat(GetFreeStorySlot(), stat); return TRUE; } @@ -1237,7 +1203,7 @@ bool8 StorytellerInitializeRandomStat(void) return FALSE; } -void StorytellerDisplayStory(u32 player) +static void StorytellerDisplayStory(u32 player) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; u8 stat = storyteller->gameStatIDs[player]; @@ -1248,7 +1214,7 @@ void StorytellerDisplayStory(u32 player) ShowFieldMessage(GetStoryTextByStat(stat)); } -void PrintStoryList(void) +static void PrintStoryList(void) { s32 i; @@ -1267,7 +1233,7 @@ void PrintStoryList(void) extern u8 gUnknown_03000748; -void Task_StoryListMenu(u8 taskId) +static void Task_StoryListMenu(u8 taskId) { struct Task *task = &gTasks[taskId]; s32 selection; @@ -1334,7 +1300,7 @@ bool8 ScrSpecial_HasStorytellerAlreadyRecorded(void) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - if (storyteller->unk1 == FALSE) + if (storyteller->alreadyRecorded == FALSE) return FALSE; else return TRUE; -- cgit v1.2.3 From a9fa94206520cfde8a7f66bc078b0955e415d5d2 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Mon, 28 Aug 2017 21:08:09 -0500 Subject: oops --- src/mauville_old_man.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 2f58e65fc..50a6756f9 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -2,7 +2,6 @@ #include "bard_music.h" #include "mauville_old_man.h" #include "easy_chat.h" -#include "easy_chat_constants.h" #include "event_data.h" #include "field_message_box.h" #include "m4a.h" -- cgit v1.2.3 From 7f9ea1cd6df4c55bf2c198e40bc8634db8480412 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Tue, 29 Aug 2017 11:14:58 -0500 Subject: tabs to spaces --- src/mauville_old_man.c | 354 ++++++++++++++++++++++++------------------------- 1 file changed, 177 insertions(+), 177 deletions(-) (limited to 'src') diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 50a6756f9..d54e017f7 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -527,161 +527,161 @@ __attribute__((naked)) static void sub_80F7DC0(void) { asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x18\n\ - ldr r1, _080F7E84 @ =gUnknown_083E53C8\n\ - mov r0, sp\n\ - movs r2, 0x18\n\ - bl memcpy\n\ - movs r5, 0\n\ - movs r0, 0x2\n\ - add r0, sp\n\ - mov r8, r0\n\ - ldr r1, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ - adds r1, 0x18\n\ - adds r3, r1, 0\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x18\n\ + ldr r1, _080F7E84 @ =gUnknown_083E53C8\n\ + mov r0, sp\n\ + movs r2, 0x18\n\ + bl memcpy\n\ + movs r5, 0\n\ + movs r0, 0x2\n\ + add r0, sp\n\ + mov r8, r0\n\ + ldr r1, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ + adds r1, 0x18\n\ + adds r3, r1, 0\n\ _080F7DE4:\n\ - adds r0, r3, r5\n\ - strb r5, [r0]\n\ - adds r0, r5, 0x1\n\ - lsls r0, 16\n\ - lsrs r5, r0, 16\n\ - cmp r5, 0x7\n\ - bls _080F7DE4\n\ - movs r5, 0\n\ - ldr r2, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ - adds r2, 0x4\n\ - mov r9, r2\n\ - adds r6, r1, 0\n\ + adds r0, r3, r5\n\ + strb r5, [r0]\n\ + adds r0, r5, 0x1\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + cmp r5, 0x7\n\ + bls _080F7DE4\n\ + movs r5, 0\n\ + ldr r2, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ + adds r2, 0x4\n\ + mov r9, r2\n\ + adds r6, r1, 0\n\ _080F7DFC:\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - adds r4, r5, 0x1\n\ - adds r1, r4, 0\n\ - bl __modsi3\n\ - lsls r0, 16\n\ - lsrs r1, r0, 16\n\ - adds r2, r6, r5\n\ - ldrb r7, [r2]\n\ - adds r1, r6, r1\n\ - ldrb r0, [r1]\n\ - strb r0, [r2]\n\ - strb r7, [r1]\n\ - lsls r4, 16\n\ - lsrs r5, r4, 16\n\ - cmp r5, 0x7\n\ - bls _080F7DFC\n\ - movs r3, 0\n\ - mov r10, r3\n\ - movs r5, 0\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + adds r4, r5, 0x1\n\ + adds r1, r4, 0\n\ + bl __modsi3\n\ + lsls r0, 16\n\ + lsrs r1, r0, 16\n\ + adds r2, r6, r5\n\ + ldrb r7, [r2]\n\ + adds r1, r6, r1\n\ + ldrb r0, [r1]\n\ + strb r0, [r2]\n\ + strb r7, [r1]\n\ + lsls r4, 16\n\ + lsrs r5, r4, 16\n\ + cmp r5, 0x7\n\ + bls _080F7DFC\n\ + movs r3, 0\n\ + mov r10, r3\n\ + movs r5, 0\n\ _080F7E2A:\n\ - lsls r4, r5, 2\n\ - mov r1, sp\n\ - adds r0, r1, r4\n\ - ldrb r0, [r0]\n\ - bl sub_80EAE88\n\ - add r4, r8\n\ - strh r0, [r4]\n\ - add r0, r10\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r10, r0\n\ - adds r0, r5, 0x1\n\ - lsls r0, 16\n\ - lsrs r5, r0, 16\n\ - cmp r5, 0x5\n\ - bls _080F7E2A\n\ - movs r0, 0\n\ - ldr r2, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ - strb r0, [r2, 0x2]\n\ - movs r7, 0\n\ - movs r5, 0\n\ + lsls r4, r5, 2\n\ + mov r1, sp\n\ + adds r0, r1, r4\n\ + ldrb r0, [r0]\n\ + bl sub_80EAE88\n\ + add r4, r8\n\ + strh r0, [r4]\n\ + add r0, r10\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r10, r0\n\ + adds r0, r5, 0x1\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + cmp r5, 0x5\n\ + bls _080F7E2A\n\ + movs r0, 0\n\ + ldr r2, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ + strb r0, [r2, 0x2]\n\ + movs r7, 0\n\ + movs r5, 0\n\ _080F7E56:\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - movs r1, 0xA\n\ - bl __umodsi3\n\ - lsls r0, 16\n\ - lsrs r1, r0, 16\n\ - cmp r1, 0x2\n\ - bhi _080F7E90\n\ - cmp r7, 0x7\n\ - bhi _080F7E90\n\ - lsls r0, r5, 1\n\ - add r0, r9\n\ - ldr r1, _080F7E8C @ =0x0000ffff\n\ - strh r1, [r0]\n\ - adds r0, r7, 0x1\n\ - lsls r0, 16\n\ - lsrs r7, r0, 16\n\ - adds r4, r5, 0x1\n\ - b _080F7EE2\n\ - .align 2, 0\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0xA\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + lsrs r1, r0, 16\n\ + cmp r1, 0x2\n\ + bhi _080F7E90\n\ + cmp r7, 0x7\n\ + bhi _080F7E90\n\ + lsls r0, r5, 1\n\ + add r0, r9\n\ + ldr r1, _080F7E8C @ =0x0000ffff\n\ + strh r1, [r0]\n\ + adds r0, r7, 0x1\n\ + lsls r0, 16\n\ + lsrs r7, r0, 16\n\ + adds r4, r5, 0x1\n\ + b _080F7EE2\n\ + .align 2, 0\n\ _080F7E84: .4byte gUnknown_083E53C8\n\ _080F7E88: .4byte gSaveBlock1 + 0x2D94\n\ _080F7E8C: .4byte 0x0000ffff\n\ _080F7E90:\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r1, r10\n\ - bl __umodsi3\n\ - lsls r0, 16\n\ - lsrs r2, r0, 16\n\ - movs r1, 0\n\ - adds r4, r5, 0x1\n\ - lsls r6, r5, 1\n\ - cmp r5, 0x5\n\ - bhi _080F7ECC\n\ - mov r3, r8\n\ - ldrh r0, [r3]\n\ - b _080F7EC2\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r1, r10\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + lsrs r2, r0, 16\n\ + movs r1, 0\n\ + adds r4, r5, 0x1\n\ + lsls r6, r5, 1\n\ + cmp r5, 0x5\n\ + bhi _080F7ECC\n\ + mov r3, r8\n\ + ldrh r0, [r3]\n\ + b _080F7EC2\n\ _080F7EB2:\n\ - adds r0, r1, 0x1\n\ - lsls r0, 16\n\ - lsrs r1, r0, 16\n\ - cmp r5, 0x5\n\ - bhi _080F7ECC\n\ - lsls r0, r1, 2\n\ - adds r0, r3, r0\n\ - ldrh r0, [r0]\n\ + adds r0, r1, 0x1\n\ + lsls r0, 16\n\ + lsrs r1, r0, 16\n\ + cmp r5, 0x5\n\ + bhi _080F7ECC\n\ + lsls r0, r1, 2\n\ + adds r0, r3, r0\n\ + ldrh r0, [r0]\n\ _080F7EC2:\n\ - subs r0, r2, r0\n\ - lsls r0, 16\n\ - lsrs r2, r0, 16\n\ - cmp r0, 0\n\ - bgt _080F7EB2\n\ + subs r0, r2, r0\n\ + lsls r0, 16\n\ + lsrs r2, r0, 16\n\ + cmp r0, 0\n\ + bgt _080F7EB2\n\ _080F7ECC:\n\ - cmp r1, 0x6\n\ - bne _080F7ED2\n\ - movs r1, 0\n\ + cmp r1, 0x6\n\ + bne _080F7ED2\n\ + movs r1, 0\n\ _080F7ED2:\n\ - lsls r0, r1, 2\n\ - add r0, sp\n\ - ldrh r0, [r0]\n\ - bl sub_80EB784\n\ - mov r2, r9\n\ - adds r1, r2, r6\n\ - strh r0, [r1]\n\ + lsls r0, r1, 2\n\ + add r0, sp\n\ + ldrh r0, [r0]\n\ + bl sub_80EB784\n\ + mov r2, r9\n\ + adds r1, r2, r6\n\ + strh r0, [r1]\n\ _080F7EE2:\n\ - lsls r0, r4, 16\n\ - lsrs r5, r0, 16\n\ - cmp r5, 0x9\n\ - bls _080F7E56\n\ - add sp, 0x18\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ + lsls r0, r4, 16\n\ + lsrs r5, r0, 16\n\ + cmp r5, 0x9\n\ + bls _080F7E56\n\ + add sp, 0x18\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ .syntax divided\n"); } #endif @@ -987,41 +987,41 @@ struct Story static const struct Story sStorytellerStories[] = { - {0x32, 1, gTextStoryteller_Story1Title, gTextStoryteller_Story1Action, gTextStoryteller_Story1Text}, - {0x02, 1, gTextStoryteller_Story2Title, gTextStoryteller_Story2Action, gTextStoryteller_Story2Text}, - {0x03, 1, gTextStoryteller_Story3Title, gTextStoryteller_Story3Action, gTextStoryteller_Story3Text}, - {0x04, 1, gTextStoryteller_Story4Title, gTextStoryteller_Story4Action, gTextStoryteller_Story4Text}, - {0x06, 1, gTextStoryteller_Story5Title, gTextStoryteller_Story5Action, gTextStoryteller_Story5Text}, - {0x09, 1, gTextStoryteller_Story6Title, gTextStoryteller_Story6Action, gTextStoryteller_Story6Text}, - {0x0B, 1, gTextStoryteller_Story7Title, gTextStoryteller_Story7Action, gTextStoryteller_Story7Text}, - {0x0C, 1, gTextStoryteller_Story8Title, gTextStoryteller_Story8Action, gTextStoryteller_Story8Text}, - {0x0D, 1, gTextStoryteller_Story9Title, gTextStoryteller_Story9Action, gTextStoryteller_Story9Text}, - {0x0E, 1, gTextStoryteller_Story10Title, gTextStoryteller_Story10Action, gTextStoryteller_Story10Text}, - {0x0F, 1, gTextStoryteller_Story11Title, gTextStoryteller_Story11Action, gTextStoryteller_Story11Text}, - {0x10, 1, gTextStoryteller_Story12Title, gTextStoryteller_Story12Action, gTextStoryteller_Story12Text}, - {0x11, 1, gTextStoryteller_Story13Title, gTextStoryteller_Story13Action, gTextStoryteller_Story13Text}, - {0x12, 1, gTextStoryteller_Story14Title, gTextStoryteller_Story14Action, gTextStoryteller_Story14Text}, - {0x13, 1, gTextStoryteller_Story15Title, gTextStoryteller_Story15Action, gTextStoryteller_Story15Text}, - {0x14, 1, gTextStoryteller_Story16Title, gTextStoryteller_Story16Action, gTextStoryteller_Story16Text}, - {0x1A, 1, gTextStoryteller_Story17Title, gTextStoryteller_Story17Action, gTextStoryteller_Story17Text}, - {0x1B, 1, gTextStoryteller_Story18Title, gTextStoryteller_Story18Action, gTextStoryteller_Story18Text}, - {0x1C, 1, gTextStoryteller_Story19Title, gTextStoryteller_Story19Action, gTextStoryteller_Story19Text}, - {0x1D, 2, gTextStoryteller_Story20Title, gTextStoryteller_Story20Action, gTextStoryteller_Story20Text}, - {0x1E, 1, gTextStoryteller_Story21Title, gTextStoryteller_Story21Action, gTextStoryteller_Story21Text}, - {0x21, 1, gTextStoryteller_Story22Title, gTextStoryteller_Story22Action, gTextStoryteller_Story22Text}, - {0x24, 1, gTextStoryteller_Story23Title, gTextStoryteller_Story23Action, gTextStoryteller_Story23Text}, - {0x25, 1, gTextStoryteller_Story24Title, gTextStoryteller_Story24Action, gTextStoryteller_Story24Text}, - {0x26, 1, gTextStoryteller_Story25Title, gTextStoryteller_Story25Action, gTextStoryteller_Story25Text}, - {0x27, 1, gTextStoryteller_Story26Title, gTextStoryteller_Story26Action, gTextStoryteller_Story26Text}, - {0x28, 1, gTextStoryteller_Story27Title, gTextStoryteller_Story27Action, gTextStoryteller_Story27Text}, - {0x29, 1, gTextStoryteller_Story28Title, gTextStoryteller_Story28Action, gTextStoryteller_Story28Text}, - {0x2A, 1, gTextStoryteller_Story29Title, gTextStoryteller_Story29Action, gTextStoryteller_Story29Text}, - {0x2B, 1, gTextStoryteller_Story30Title, gTextStoryteller_Story30Action, gTextStoryteller_Story30Text}, - {0x2C, 1, gTextStoryteller_Story31Title, gTextStoryteller_Story31Action, gTextStoryteller_Story31Text}, - {0x2D, 1, gTextStoryteller_Story32Title, gTextStoryteller_Story32Action, gTextStoryteller_Story32Text}, - {0x2E, 1, gTextStoryteller_Story33Title, gTextStoryteller_Story33Action, gTextStoryteller_Story33Text}, - {0x2F, 1, gTextStoryteller_Story34Title, gTextStoryteller_Story34Action, gTextStoryteller_Story34Text}, - {0x30, 1, gTextStoryteller_Story35Title, gTextStoryteller_Story35Action, gTextStoryteller_Story35Text}, + {0x32, 1, gTextStoryteller_Story1Title, gTextStoryteller_Story1Action, gTextStoryteller_Story1Text}, + {0x02, 1, gTextStoryteller_Story2Title, gTextStoryteller_Story2Action, gTextStoryteller_Story2Text}, + {0x03, 1, gTextStoryteller_Story3Title, gTextStoryteller_Story3Action, gTextStoryteller_Story3Text}, + {0x04, 1, gTextStoryteller_Story4Title, gTextStoryteller_Story4Action, gTextStoryteller_Story4Text}, + {0x06, 1, gTextStoryteller_Story5Title, gTextStoryteller_Story5Action, gTextStoryteller_Story5Text}, + {0x09, 1, gTextStoryteller_Story6Title, gTextStoryteller_Story6Action, gTextStoryteller_Story6Text}, + {0x0B, 1, gTextStoryteller_Story7Title, gTextStoryteller_Story7Action, gTextStoryteller_Story7Text}, + {0x0C, 1, gTextStoryteller_Story8Title, gTextStoryteller_Story8Action, gTextStoryteller_Story8Text}, + {0x0D, 1, gTextStoryteller_Story9Title, gTextStoryteller_Story9Action, gTextStoryteller_Story9Text}, + {0x0E, 1, gTextStoryteller_Story10Title, gTextStoryteller_Story10Action, gTextStoryteller_Story10Text}, + {0x0F, 1, gTextStoryteller_Story11Title, gTextStoryteller_Story11Action, gTextStoryteller_Story11Text}, + {0x10, 1, gTextStoryteller_Story12Title, gTextStoryteller_Story12Action, gTextStoryteller_Story12Text}, + {0x11, 1, gTextStoryteller_Story13Title, gTextStoryteller_Story13Action, gTextStoryteller_Story13Text}, + {0x12, 1, gTextStoryteller_Story14Title, gTextStoryteller_Story14Action, gTextStoryteller_Story14Text}, + {0x13, 1, gTextStoryteller_Story15Title, gTextStoryteller_Story15Action, gTextStoryteller_Story15Text}, + {0x14, 1, gTextStoryteller_Story16Title, gTextStoryteller_Story16Action, gTextStoryteller_Story16Text}, + {0x1A, 1, gTextStoryteller_Story17Title, gTextStoryteller_Story17Action, gTextStoryteller_Story17Text}, + {0x1B, 1, gTextStoryteller_Story18Title, gTextStoryteller_Story18Action, gTextStoryteller_Story18Text}, + {0x1C, 1, gTextStoryteller_Story19Title, gTextStoryteller_Story19Action, gTextStoryteller_Story19Text}, + {0x1D, 2, gTextStoryteller_Story20Title, gTextStoryteller_Story20Action, gTextStoryteller_Story20Text}, + {0x1E, 1, gTextStoryteller_Story21Title, gTextStoryteller_Story21Action, gTextStoryteller_Story21Text}, + {0x21, 1, gTextStoryteller_Story22Title, gTextStoryteller_Story22Action, gTextStoryteller_Story22Text}, + {0x24, 1, gTextStoryteller_Story23Title, gTextStoryteller_Story23Action, gTextStoryteller_Story23Text}, + {0x25, 1, gTextStoryteller_Story24Title, gTextStoryteller_Story24Action, gTextStoryteller_Story24Text}, + {0x26, 1, gTextStoryteller_Story25Title, gTextStoryteller_Story25Action, gTextStoryteller_Story25Text}, + {0x27, 1, gTextStoryteller_Story26Title, gTextStoryteller_Story26Action, gTextStoryteller_Story26Text}, + {0x28, 1, gTextStoryteller_Story27Title, gTextStoryteller_Story27Action, gTextStoryteller_Story27Text}, + {0x29, 1, gTextStoryteller_Story28Title, gTextStoryteller_Story28Action, gTextStoryteller_Story28Text}, + {0x2A, 1, gTextStoryteller_Story29Title, gTextStoryteller_Story29Action, gTextStoryteller_Story29Text}, + {0x2B, 1, gTextStoryteller_Story30Title, gTextStoryteller_Story30Action, gTextStoryteller_Story30Text}, + {0x2C, 1, gTextStoryteller_Story31Title, gTextStoryteller_Story31Action, gTextStoryteller_Story31Text}, + {0x2D, 1, gTextStoryteller_Story32Title, gTextStoryteller_Story32Action, gTextStoryteller_Story32Text}, + {0x2E, 1, gTextStoryteller_Story33Title, gTextStoryteller_Story33Action, gTextStoryteller_Story33Text}, + {0x2F, 1, gTextStoryteller_Story34Title, gTextStoryteller_Story34Action, gTextStoryteller_Story34Text}, + {0x30, 1, gTextStoryteller_Story35Title, gTextStoryteller_Story35Action, gTextStoryteller_Story35Text}, {0x31, 1, gTextStoryteller_Story36Title, gTextStoryteller_Story36Action, gTextStoryteller_Story36Text}, }; -- cgit v1.2.3 From 3e68cbc51f867e507644c1c19bb3be7a89fcd3e4 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Fri, 8 Sep 2017 22:02:20 -0500 Subject: mauville_old_man -> mauville_man --- src/mauville_man.c | 1311 ++++++++++++++++++++++++++++++++++++++++++++++++ src/mauville_old_man.c | 1311 ------------------------------------------------ src/new_game.c | 2 +- src/record_mixing.c | 2 +- src/strings.c | 4 +- src/trader.c | 2 +- 6 files changed, 1316 insertions(+), 1316 deletions(-) create mode 100644 src/mauville_man.c delete mode 100644 src/mauville_old_man.c (limited to 'src') diff --git a/src/mauville_man.c b/src/mauville_man.c new file mode 100644 index 000000000..4a77717f1 --- /dev/null +++ b/src/mauville_man.c @@ -0,0 +1,1311 @@ +#include "global.h" +#include "bard_music.h" +#include "mauville_man.h" +#include "easy_chat.h" +#include "event_data.h" +#include "field_message_box.h" +#include "m4a.h" +#include "menu.h" +#include "rom4.h" +#include "rng.h" +#include "script.h" +#include "songs.h" +#include "sound.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "trader.h" + +#define MACRO1(a) (((a) % 4) + (((a) / 8) & 1)) + +extern struct MusicPlayerInfo gMPlay_SE2; + +extern u16 gScriptResult; +extern u16 gSpecialVar_0x8004; + +extern const u8 gTextStoryteller_Story1Title[]; +extern const u8 gTextStoryteller_Story1Action[]; +extern const u8 gTextStoryteller_Story1Text[]; +extern const u8 gTextStoryteller_Story2Title[]; +extern const u8 gTextStoryteller_Story2Action[]; +extern const u8 gTextStoryteller_Story2Text[]; +extern const u8 gTextStoryteller_Story3Title[]; +extern const u8 gTextStoryteller_Story3Action[]; +extern const u8 gTextStoryteller_Story3Text[]; +extern const u8 gTextStoryteller_Story4Title[]; +extern const u8 gTextStoryteller_Story4Action[]; +extern const u8 gTextStoryteller_Story4Text[]; +extern const u8 gTextStoryteller_Story5Title[]; +extern const u8 gTextStoryteller_Story5Action[]; +extern const u8 gTextStoryteller_Story5Text[]; +extern const u8 gTextStoryteller_Story6Title[]; +extern const u8 gTextStoryteller_Story6Action[]; +extern const u8 gTextStoryteller_Story6Text[]; +extern const u8 gTextStoryteller_Story7Title[]; +extern const u8 gTextStoryteller_Story7Action[]; +extern const u8 gTextStoryteller_Story7Text[]; +extern const u8 gTextStoryteller_Story8Title[]; +extern const u8 gTextStoryteller_Story8Action[]; +extern const u8 gTextStoryteller_Story8Text[]; +extern const u8 gTextStoryteller_Story9Title[]; +extern const u8 gTextStoryteller_Story9Action[]; +extern const u8 gTextStoryteller_Story9Text[]; +extern const u8 gTextStoryteller_Story10Title[]; +extern const u8 gTextStoryteller_Story10Action[]; +extern const u8 gTextStoryteller_Story10Text[]; +extern const u8 gTextStoryteller_Story11Title[]; +extern const u8 gTextStoryteller_Story11Action[]; +extern const u8 gTextStoryteller_Story11Text[]; +extern const u8 gTextStoryteller_Story12Title[]; +extern const u8 gTextStoryteller_Story12Action[]; +extern const u8 gTextStoryteller_Story12Text[]; +extern const u8 gTextStoryteller_Story13Title[]; +extern const u8 gTextStoryteller_Story13Action[]; +extern const u8 gTextStoryteller_Story13Text[]; +extern const u8 gTextStoryteller_Story14Title[]; +extern const u8 gTextStoryteller_Story14Action[]; +extern const u8 gTextStoryteller_Story14Text[]; +extern const u8 gTextStoryteller_Story15Title[]; +extern const u8 gTextStoryteller_Story15Action[]; +extern const u8 gTextStoryteller_Story15Text[]; +extern const u8 gTextStoryteller_Story16Title[]; +extern const u8 gTextStoryteller_Story16Action[]; +extern const u8 gTextStoryteller_Story16Text[]; +extern const u8 gTextStoryteller_Story17Title[]; +extern const u8 gTextStoryteller_Story17Action[]; +extern const u8 gTextStoryteller_Story17Text[]; +extern const u8 gTextStoryteller_Story18Title[]; +extern const u8 gTextStoryteller_Story18Action[]; +extern const u8 gTextStoryteller_Story18Text[]; +extern const u8 gTextStoryteller_Story19Title[]; +extern const u8 gTextStoryteller_Story19Action[]; +extern const u8 gTextStoryteller_Story19Text[]; +extern const u8 gTextStoryteller_Story20Title[]; +extern const u8 gTextStoryteller_Story20Action[]; +extern const u8 gTextStoryteller_Story20Text[]; +extern const u8 gTextStoryteller_Story21Title[]; +extern const u8 gTextStoryteller_Story21Action[]; +extern const u8 gTextStoryteller_Story21Text[]; +extern const u8 gTextStoryteller_Story22Title[]; +extern const u8 gTextStoryteller_Story22Action[]; +extern const u8 gTextStoryteller_Story22Text[]; +extern const u8 gTextStoryteller_Story23Title[]; +extern const u8 gTextStoryteller_Story23Action[]; +extern const u8 gTextStoryteller_Story23Text[]; +extern const u8 gTextStoryteller_Story24Title[]; +extern const u8 gTextStoryteller_Story24Action[]; +extern const u8 gTextStoryteller_Story24Text[]; +extern const u8 gTextStoryteller_Story25Title[]; +extern const u8 gTextStoryteller_Story25Action[]; +extern const u8 gTextStoryteller_Story25Text[]; +extern const u8 gTextStoryteller_Story26Title[]; +extern const u8 gTextStoryteller_Story26Action[]; +extern const u8 gTextStoryteller_Story26Text[]; +extern const u8 gTextStoryteller_Story27Title[]; +extern const u8 gTextStoryteller_Story27Action[]; +extern const u8 gTextStoryteller_Story27Text[]; +extern const u8 gTextStoryteller_Story28Title[]; +extern const u8 gTextStoryteller_Story28Action[]; +extern const u8 gTextStoryteller_Story28Text[]; +extern const u8 gTextStoryteller_Story29Title[]; +extern const u8 gTextStoryteller_Story29Action[]; +extern const u8 gTextStoryteller_Story29Text[]; +extern const u8 gTextStoryteller_Story30Title[]; +extern const u8 gTextStoryteller_Story30Action[]; +extern const u8 gTextStoryteller_Story30Text[]; +extern const u8 gTextStoryteller_Story31Title[]; +extern const u8 gTextStoryteller_Story31Action[]; +extern const u8 gTextStoryteller_Story31Text[]; +extern const u8 gTextStoryteller_Story32Title[]; +extern const u8 gTextStoryteller_Story32Action[]; +extern const u8 gTextStoryteller_Story32Text[]; +extern const u8 gTextStoryteller_Story33Title[]; +extern const u8 gTextStoryteller_Story33Action[]; +extern const u8 gTextStoryteller_Story33Text[]; +extern const u8 gTextStoryteller_Story34Title[]; +extern const u8 gTextStoryteller_Story34Action[]; +extern const u8 gTextStoryteller_Story34Text[]; +extern const u8 gTextStoryteller_Story35Title[]; +extern const u8 gTextStoryteller_Story35Action[]; +extern const u8 gTextStoryteller_Story35Text[]; +extern const u8 gTextStoryteller_Story36Title[]; +extern const u8 gTextStoryteller_Story36Action[]; +extern const u8 gTextStoryteller_Story36Text[]; + +extern struct BardSong gUnknown_03005DA0; + +EWRAM_DATA static u16 gUnknown_020388BC = 0; // set but not used? + +static const u16 sDefaultBardSongLyrics[] = +{ +#ifdef ENGLISH + EC_WORD_SISTER, + EC_WORD_EATS, + EC_WORD_SWEETS, + EC_WORD_VORACIOUS, + EC_WORD_AND, + EC_WORD_DROOLING, +#else + EC_WORD_SISTER, + EC_WORD_MUST_BE, + EC_WORD_SWEETS, + EC_WORD_VORACIOUS, + EC_WORD_DROOLING, + EC_WORD_THICK, +#endif +}; + +static const u8 *const sGiddyAdjectives[] = +{ + OtherText_SoPretty, + OtherText_SoDarling, + OtherText_SoRelaxed, + OtherText_SoSunny, + OtherText_SoDesirable, + OtherText_SoExciting, + OtherText_SoAmusing, + OtherText_SoMagical, +}; + +static const u8 *const sGiddyQuestions[] = +{ + OtherText_WantVacationNicePlace, + OtherText_BoughtCrayonsIsNice, + OtherText_IfWeCouldFloat, + OtherText_SandWashesAwayMakeSad, + OtherText_WhatsBottomSeaLike, + OtherText_SeeSettingSun, + OtherText_LyingInGreenGrass, + OtherText_SecretBasesWonderful, +}; + +static void sub_80F7DC0(void); +static void Task_BardSong(u8); +static void StartBardSong(u8); +static void StorytellerSetup(void); +static void sub_80F8428(void); + +static void SetupBard(void) +{ + u16 i; + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; + + bard->id = MAUVILLE_MAN_BARD; + bard->hasChangedSong = FALSE; + for (i = 0; i < 6; i++) + bard->songLyrics[i] = sDefaultBardSongLyrics[i]; +} + +static void SetupHipster(void) +{ + struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; + + hipster->id = MAUVILLE_MAN_HIPSTER; + hipster->alreadySpoken = FALSE; +} + +static void SetupStoryteller(void) +{ + StorytellerSetup(); +} + +static void SetupGiddy(void) +{ + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; + + giddy->id = MAUVILLE_MAN_GIDDY; + giddy->taleCounter = 0; +} + +static void SetupTrader(void) +{ + TraderSetup(); +} + +void SetupMauvilleOldMan(void) +{ + u16 trainerId = (gSaveBlock2.playerTrainerId[1] << 8) | gSaveBlock2.playerTrainerId[0]; + + // Determine man based on the last digit of the player's trainer ID. + switch ((trainerId % 10) / 2) + { + case MAUVILLE_MAN_BARD: + SetupBard(); + break; + case MAUVILLE_MAN_HIPSTER: + SetupHipster(); + break; + case MAUVILLE_MAN_TRADER: + SetupTrader(); + break; + case MAUVILLE_MAN_STORYTELLER: + SetupStoryteller(); + break; + case MAUVILLE_MAN_GIDDY: + SetupGiddy(); + break; + } + sub_80F83D0(); +} + +static u8 GetCurrentMauvilleOldMan(void) +{ + struct MauvilleManCommon *common = &gSaveBlock1.mauvilleMan.common; + + return common->id; +} + +void ScrSpecial_GetCurrentMauvilleMan(void) +{ + gScriptResult = GetCurrentMauvilleOldMan(); +} + +void ScrSpecial_HasBardSongBeenChanged(void) +{ + u16 *scriptResult = &gScriptResult; // why?? + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; + + *scriptResult = bard->hasChangedSong; +} + +void ScrSpecial_SaveBardSongLyrics(void) +{ + u16 i; + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; + + StringCopy(bard->playerName, gSaveBlock2.playerName); + + for (i = 0; i < 4; i++) + bard->playerTrainerId[i] = gSaveBlock2.playerTrainerId[i]; + + for (i = 0; i < 6; i++) + bard->songLyrics[i] = bard->temporaryLyrics[i]; + + bard->hasChangedSong = TRUE; +} + +// Copies lyrics into gStringVar4 +void PrepareSongText(void) +{ + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; + u16 specialVar = gSpecialVar_0x8004; // It's a bit odd to use this temp variable, but it seems needed to match. + u16 *lyrics; + 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 + for (lineNum = 0; lineNum < 2; lineNum++) + { + wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); + while (wordEnd != str) + { + if (*str == CHAR_SPACE) + *str = CHAR_SONG_WORD_SEPARATOR; + str++; + } + + str++; + *(wordEnd++) = CHAR_SPACE; + + wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); + while (wordEnd != str) + { + if (*str == CHAR_SPACE) + *str = CHAR_SONG_WORD_SEPARATOR; + str++; + } + + str++; + *(wordEnd++) = CHAR_NEWLINE; + + wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); + while (wordEnd != str) + { + if (*str == CHAR_SPACE) + *str = CHAR_SONG_WORD_SEPARATOR; + str++; + } + + if (lineNum == 0) + { + *(wordEnd++) = EXT_CTRL_CODE_BEGIN; + *(wordEnd++) = 15; + } + } +} + +void ScrSpecial_PlayBardSong(void) +{ + StartBardSong(gSpecialVar_0x8004); + MenuDisplayMessageBox(); + ScriptContext1_Stop(); +} + +void ScrSpecial_GetHipsterSpokenFlag(void) +{ + u16 *scriptResult = &gScriptResult; // again?? + struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; + + *scriptResult = hipster->alreadySpoken; +} + +void ScrSpecial_SetHipsterSpokenFlag(void) +{ + struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; + + hipster->alreadySpoken = TRUE; +} + +void ScrSpecial_HipsterTeachWord(void) +{ + u16 var = sub_80EB8EC(); + + if (var == 0xFFFF) + { + gScriptResult = FALSE; + } + else + { + EasyChat_GetWordText(gStringVar1, var); + gScriptResult = TRUE; + } +} + +void ScrSpecial_GiddyShouldTellAnotherTale(void) +{ + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; + + if (giddy->taleCounter == 10) + { + gScriptResult = FALSE; + giddy->taleCounter = 0; + } + else + { + gScriptResult = TRUE; + } +} + +void ScrSpecial_GenerateGiddyLine(void) +{ + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; + + if (giddy->taleCounter == 0) + sub_80F7DC0(); + + if (giddy->randomWords[giddy->taleCounter] != 0xFFFF) // is not the last element of the array? + { + u8 *stringPtr; + u32 adjective = Random(); + + adjective %= 8; + stringPtr = EasyChat_GetWordText(gStringVar4, giddy->randomWords[giddy->taleCounter]); + stringPtr = StringCopy(stringPtr, gOtherText_Is); + stringPtr = StringCopy(stringPtr, sGiddyAdjectives[adjective]); + StringCopy(stringPtr, gOtherText_DontYouAgree); + } + else + { + StringCopy(gStringVar4, sGiddyQuestions[giddy->questionList[giddy->questionNum++]]); + } + + if (!(Random() % 10)) + giddy->taleCounter = 10; + else + giddy->taleCounter++; + + gScriptResult = TRUE; +} + +#ifdef NONMATCHING +static void sub_80F7DC0(void) +{ + u16 arr[][2] = + { + { 0x0, 0}, + { 0xC, 0}, + { 0xD, 0}, + {0x12, 0}, + {0x13, 0}, + {0x15, 0}, + }; + u16 i; + u16 r10; + u16 r7; + + for (i = 0; i < 8; i++) + { + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; + + //gSaveBlock1.mauvilleMan.giddy.questionList[i] = i; + giddy->questionList[i] = i; + } + + // Scramble questions + for (i = 0; i < 8; i++) + { + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; + + /* + u16 r1 = Random() % (i + 1); + u8 r7 = gSaveBlock1.mauvilleMan.giddy.questionList[i]; + gSaveBlock1.mauvilleMan.giddy.questionList[i] = gSaveBlock1.mauvilleMan.giddy.questionList[r1]; + gSaveBlock1.mauvilleMan.giddy.questionList[r1] = r7; + */ + u16 r1 = Random() % (i + 1); + u8 r7 = giddy->questionList[i]; + giddy->questionList[i] = giddy->questionList[r1]; + giddy->questionList[r1] = r7; + } + + r10 = 0; + for (i = 0; i < 6; i++) + { + arr[i][1] = sub_80EAE88(arr[i][0]); + r10 += arr[i][1]; + } + + { + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; + giddy->questionNum = 0; + } + //gSaveBlock1.mauvilleMan.giddy.questionNum = 0; + + r7 = 0; + for (i = 0; i < 10; i++) + { + struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; + + u16 var = Random() % 10; + if (var < 3 && r7 < 8) + { + //gSaveBlock1.mauvilleMan.giddy.randomWords[i] = 0xFFFF; + giddy->randomWords[i] = 0xFFFF; + r7++; + } + //_080F7E90 + else + { + s16 r2 = Random() % r10; + + u16 r1 = 0; + + while (i < 6) // comparing the wrong variable + { + r2 = arr[r1][1] - r2; + if (r2 <= 0) + break; + r1++; + } + + if (r1 == 6) + r1 = 0; + //gSaveBlock1.mauvilleMan.giddy.randomWords[i] = sub_80EB784(arr[r1][0]); + giddy->randomWords[i] = sub_80EB784(arr[r1][0]); + } + } +} +#else + +static const u16 gUnknown_083E53C8[][2] = +{ + { 0x0, 0}, + { 0xC, 0}, + { 0xD, 0}, + {0x12, 0}, + {0x13, 0}, + {0x15, 0}, +}; + +__attribute__((naked)) +static void sub_80F7DC0(void) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x18\n\ + ldr r1, _080F7E84 @ =gUnknown_083E53C8\n\ + mov r0, sp\n\ + movs r2, 0x18\n\ + bl memcpy\n\ + movs r5, 0\n\ + movs r0, 0x2\n\ + add r0, sp\n\ + mov r8, r0\n\ + ldr r1, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ + adds r1, 0x18\n\ + adds r3, r1, 0\n\ +_080F7DE4:\n\ + adds r0, r3, r5\n\ + strb r5, [r0]\n\ + adds r0, r5, 0x1\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + cmp r5, 0x7\n\ + bls _080F7DE4\n\ + movs r5, 0\n\ + ldr r2, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ + adds r2, 0x4\n\ + mov r9, r2\n\ + adds r6, r1, 0\n\ +_080F7DFC:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + adds r4, r5, 0x1\n\ + adds r1, r4, 0\n\ + bl __modsi3\n\ + lsls r0, 16\n\ + lsrs r1, r0, 16\n\ + adds r2, r6, r5\n\ + ldrb r7, [r2]\n\ + adds r1, r6, r1\n\ + ldrb r0, [r1]\n\ + strb r0, [r2]\n\ + strb r7, [r1]\n\ + lsls r4, 16\n\ + lsrs r5, r4, 16\n\ + cmp r5, 0x7\n\ + bls _080F7DFC\n\ + movs r3, 0\n\ + mov r10, r3\n\ + movs r5, 0\n\ +_080F7E2A:\n\ + lsls r4, r5, 2\n\ + mov r1, sp\n\ + adds r0, r1, r4\n\ + ldrb r0, [r0]\n\ + bl sub_80EAE88\n\ + add r4, r8\n\ + strh r0, [r4]\n\ + add r0, r10\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r10, r0\n\ + adds r0, r5, 0x1\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + cmp r5, 0x5\n\ + bls _080F7E2A\n\ + movs r0, 0\n\ + ldr r2, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ + strb r0, [r2, 0x2]\n\ + movs r7, 0\n\ + movs r5, 0\n\ +_080F7E56:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0xA\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + lsrs r1, r0, 16\n\ + cmp r1, 0x2\n\ + bhi _080F7E90\n\ + cmp r7, 0x7\n\ + bhi _080F7E90\n\ + lsls r0, r5, 1\n\ + add r0, r9\n\ + ldr r1, _080F7E8C @ =0x0000ffff\n\ + strh r1, [r0]\n\ + adds r0, r7, 0x1\n\ + lsls r0, 16\n\ + lsrs r7, r0, 16\n\ + adds r4, r5, 0x1\n\ + b _080F7EE2\n\ + .align 2, 0\n\ +_080F7E84: .4byte gUnknown_083E53C8\n\ +_080F7E88: .4byte gSaveBlock1 + 0x2D94\n\ +_080F7E8C: .4byte 0x0000ffff\n\ +_080F7E90:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r1, r10\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + lsrs r2, r0, 16\n\ + movs r1, 0\n\ + adds r4, r5, 0x1\n\ + lsls r6, r5, 1\n\ + cmp r5, 0x5\n\ + bhi _080F7ECC\n\ + mov r3, r8\n\ + ldrh r0, [r3]\n\ + b _080F7EC2\n\ +_080F7EB2:\n\ + adds r0, r1, 0x1\n\ + lsls r0, 16\n\ + lsrs r1, r0, 16\n\ + cmp r5, 0x5\n\ + bhi _080F7ECC\n\ + lsls r0, r1, 2\n\ + adds r0, r3, r0\n\ + ldrh r0, [r0]\n\ +_080F7EC2:\n\ + subs r0, r2, r0\n\ + lsls r0, 16\n\ + lsrs r2, r0, 16\n\ + cmp r0, 0\n\ + bgt _080F7EB2\n\ +_080F7ECC:\n\ + cmp r1, 0x6\n\ + bne _080F7ED2\n\ + movs r1, 0\n\ +_080F7ED2:\n\ + lsls r0, r1, 2\n\ + add r0, sp\n\ + ldrh r0, [r0]\n\ + bl sub_80EB784\n\ + mov r2, r9\n\ + adds r1, r2, r6\n\ + strh r0, [r1]\n\ +_080F7EE2:\n\ + lsls r0, r4, 16\n\ + lsrs r5, r0, 16\n\ + cmp r5, 0x9\n\ + bls _080F7E56\n\ + add sp, 0x18\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided\n"); +} +#endif + +static void sub_80F7EFC(void) +{ + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; + + bard->hasChangedSong = FALSE; +} + +static void sub_80F7F0C(void) +{ + struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; + + hipster->alreadySpoken = FALSE; +} + +static void sub_80F7F18(void) +{ + sub_8109A20(); +} + +static void sub_80F7F24(void) +{ + sub_80F8428(); +} + +void sub_80F7F30(void) +{ + switch (GetCurrentMauvilleOldMan()) + { + case MAUVILLE_MAN_BARD: + sub_80F7EFC(); + break; + case MAUVILLE_MAN_HIPSTER: + sub_80F7F0C(); + break; + case MAUVILLE_MAN_STORYTELLER: + sub_80F7F24(); + break; + case MAUVILLE_MAN_TRADER: + sub_80F7F18(); + break; + case MAUVILLE_MAN_GIDDY: + break; + } + sub_80F83D0(); +} + +#define tState data[0] +#define tCharIndex data[3] +#define tCurrWord data[4] +#define tUseTemporaryLyrics data[5] + +static void StartBardSong(bool8 useTemporaryLyrics) +{ + u8 taskId = CreateTask(Task_BardSong, 0x50); + + gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics; +} + +static void BardSing(struct Task *task, struct BardSong *song) +{ + switch (task->tState) + { + case 0: // Initialize song + { + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; + u16 *lyrics; + s32 i; + + // Copy lyrics + if (gSpecialVar_0x8004 == 0) + lyrics = bard->songLyrics; + else + lyrics = bard->temporaryLyrics; + for (i = 0; i < 6; i++) + song->lyrics[i] = lyrics[i]; + + // Clear phonemes + for (i = 0; i < 6; i++) + { + song->phonemes[i].sound = 0xFFFF; + song->phonemes[i].length = 0; + song->phonemes[i].pitch = 0; + song->phonemes[i].volume = 0; + } + song->currWord = 0; + song->currPhoneme = 0; + song->var04 = 0; + } + break; + case 1: // Wait for BGM to end + break; + case 2: // Initialize word + { + u16 word = song->lyrics[song->currWord]; + const struct BardSound *sounds = GetWordSounds(EC_GROUP(word), EC_INDEX(word)); + + song->var04 = 0; + GetWordPhonemes(song, sounds, MACRO1(word)); + } + break; + case 3: + case 4: + { + struct BardPhoneme *phoneme = &song->phonemes[song->currPhoneme]; + + switch (song->state) + { + case 0: + if (song->phonemeTimer == 0) // Timer has expired. Move to next phoneme + { + if (song->currPhoneme == 6 || phoneme->sound == 0xFF) + { + song->state = 0xFE; + break; + } + song->phonemeTimer = phoneme->length; + if (phoneme->sound <= 50) + { + u16 num = phoneme->sound / 3; + + m4aSongNumStart(249 + num * 3); + } + song->state = 1; + } + else + { + if (song->voiceInflection > 10) + song->volume -= 2; + if (song->voiceInflection & 1) + song->pitch += 64; + else + song->pitch -= 64; + m4aMPlayVolumeControl(&gMPlay_SE2, 0xFFFF, song->volume); + m4aMPlayPitchControl(&gMPlay_SE2, 0xFFFF, song->pitch); + song->voiceInflection++; + } + song->phonemeTimer--; + break; + case 1: + song->currPhoneme++; + song->state = 0; + if (phoneme->sound <= 50) + { + song->volume = 0x100 + phoneme->volume * 16; + m4aMPlayVolumeControl(&gMPlay_SE2, 0xFFFF, song->volume); + song->pitch = 0x200 + phoneme->pitch; + m4aMPlayPitchControl(&gMPlay_SE2, 0xFFFF, song->pitch); + } + break; + case 0xFE: + m4aMPlayStop(&gMPlay_SE2); + song->state = 0xFF; + break; + } + } + break; + case 5: + break; + } +} + +static void Task_BardSong(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; // r5 + + BardSing(task, &gUnknown_03005DA0); + switch (task->tState) + { + case 0: // Initialize song + PrepareSongText(); + InitWindowFromConfig(gMenuWindowPtr, &gWindowConfig_81E6CE4); + sub_8002EB0(gMenuWindowPtr, gStringVar4, 2, 4, 15); + task->data[1] = 0; + task->data[2] = 0; + task->tCharIndex = 0; + task->tCurrWord = 0; + FadeOutBGMTemporarily(4); + task->tState = 1; + break; + case 1: // Wait for BGM to end + if (IsBGMPausedOrStopped()) + task->tState = 2; + break; + case 2: // Initialize word + { + struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; + u8 *str = gStringVar4 + task->tCharIndex; + u16 wordLen = 0; + // Can't get it to match without hacking + u32 temp; + register s16 zero asm("r1"); + + while (*str != CHAR_SPACE + && *str != CHAR_NEWLINE + && *str != EXT_CTRL_CODE_BEGIN + && *str != EOS) + { + str++; + wordLen++; + } + if (!task->tUseTemporaryLyrics) + gUnknown_020388BC = MACRO1(bard->songLyrics[task->tCurrWord]); + else + gUnknown_020388BC = MACRO1(bard->temporaryLyrics[task->tCurrWord]); + temp = gUnknown_03005DA0.var04 / wordLen; + zero = 0; + gUnknown_03005DA0.var04 = temp; + if (gUnknown_03005DA0.var04 <= 0) + gUnknown_03005DA0.var04 = 1; + task->tCurrWord++; + if (task->data[2] == 0) + task->tState = 3; + else + task->tState = 5; + task->data[1] = zero; + } + break; + case 5: + if (task->data[2] == 0) + task->tState = 3; + else + task->data[2]--; + break; + case 3: + if (gStringVar4[task->tCharIndex] == EOS) + { + FadeInNewBGM(BGM_POKECEN, 6); + m4aMPlayFadeOutTemporarily(&gMPlay_SE2, 2); + EnableBothScriptContexts(); + DestroyTask(taskId); + } + else if (gStringVar4[task->tCharIndex] == CHAR_SPACE) + { + sub_8003418(gMenuWindowPtr); + task->tCharIndex++; + task->tState = 2; + task->data[2] = 0; + } + else if (gStringVar4[task->tCharIndex] == CHAR_NEWLINE) + { + task->tCharIndex++; + task->tState = 2; + task->data[2] = 0; + } + else if (gStringVar4[task->tCharIndex] == EXT_CTRL_CODE_BEGIN) + { + task->tCharIndex += 2; // skip over control codes + task->tState = 2; + task->data[2] = 8; + } + else if (gStringVar4[task->tCharIndex] == CHAR_SONG_WORD_SEPARATOR) + { + gStringVar4[task->tCharIndex] = CHAR_SPACE; // restore it back to a space + sub_8003418(gMenuWindowPtr); + task->tCharIndex++; + task->data[2] = 0; + } + else + { + switch (task->data[1]) + { + case 0: + sub_8003418(gMenuWindowPtr); + task->data[1]++; + break; + case 1: + task->data[1]++; + break; + case 2: + task->tCharIndex++; + task->data[1] = 0; + task->data[2] = gUnknown_03005DA0.var04; + task->tState = 4; + break; + } + } + break; + case 4: + task->data[2]--; + if (task->data[2] == 0) + task->tState = 3; + break; + } +} + +void sub_80F83D0(void) +{ + VarSet(0x4010, 0x45 + GetCurrentMauvilleOldMan()); +} + +struct Story +{ + u8 stat; + u8 minVal; + const u8 *title; + const u8 *action; + const u8 *fullText; +}; + +static const struct Story sStorytellerStories[] = +{ + {0x32, 1, gTextStoryteller_Story1Title, gTextStoryteller_Story1Action, gTextStoryteller_Story1Text}, + {0x02, 1, gTextStoryteller_Story2Title, gTextStoryteller_Story2Action, gTextStoryteller_Story2Text}, + {0x03, 1, gTextStoryteller_Story3Title, gTextStoryteller_Story3Action, gTextStoryteller_Story3Text}, + {0x04, 1, gTextStoryteller_Story4Title, gTextStoryteller_Story4Action, gTextStoryteller_Story4Text}, + {0x06, 1, gTextStoryteller_Story5Title, gTextStoryteller_Story5Action, gTextStoryteller_Story5Text}, + {0x09, 1, gTextStoryteller_Story6Title, gTextStoryteller_Story6Action, gTextStoryteller_Story6Text}, + {0x0B, 1, gTextStoryteller_Story7Title, gTextStoryteller_Story7Action, gTextStoryteller_Story7Text}, + {0x0C, 1, gTextStoryteller_Story8Title, gTextStoryteller_Story8Action, gTextStoryteller_Story8Text}, + {0x0D, 1, gTextStoryteller_Story9Title, gTextStoryteller_Story9Action, gTextStoryteller_Story9Text}, + {0x0E, 1, gTextStoryteller_Story10Title, gTextStoryteller_Story10Action, gTextStoryteller_Story10Text}, + {0x0F, 1, gTextStoryteller_Story11Title, gTextStoryteller_Story11Action, gTextStoryteller_Story11Text}, + {0x10, 1, gTextStoryteller_Story12Title, gTextStoryteller_Story12Action, gTextStoryteller_Story12Text}, + {0x11, 1, gTextStoryteller_Story13Title, gTextStoryteller_Story13Action, gTextStoryteller_Story13Text}, + {0x12, 1, gTextStoryteller_Story14Title, gTextStoryteller_Story14Action, gTextStoryteller_Story14Text}, + {0x13, 1, gTextStoryteller_Story15Title, gTextStoryteller_Story15Action, gTextStoryteller_Story15Text}, + {0x14, 1, gTextStoryteller_Story16Title, gTextStoryteller_Story16Action, gTextStoryteller_Story16Text}, + {0x1A, 1, gTextStoryteller_Story17Title, gTextStoryteller_Story17Action, gTextStoryteller_Story17Text}, + {0x1B, 1, gTextStoryteller_Story18Title, gTextStoryteller_Story18Action, gTextStoryteller_Story18Text}, + {0x1C, 1, gTextStoryteller_Story19Title, gTextStoryteller_Story19Action, gTextStoryteller_Story19Text}, + {0x1D, 2, gTextStoryteller_Story20Title, gTextStoryteller_Story20Action, gTextStoryteller_Story20Text}, + {0x1E, 1, gTextStoryteller_Story21Title, gTextStoryteller_Story21Action, gTextStoryteller_Story21Text}, + {0x21, 1, gTextStoryteller_Story22Title, gTextStoryteller_Story22Action, gTextStoryteller_Story22Text}, + {0x24, 1, gTextStoryteller_Story23Title, gTextStoryteller_Story23Action, gTextStoryteller_Story23Text}, + {0x25, 1, gTextStoryteller_Story24Title, gTextStoryteller_Story24Action, gTextStoryteller_Story24Text}, + {0x26, 1, gTextStoryteller_Story25Title, gTextStoryteller_Story25Action, gTextStoryteller_Story25Text}, + {0x27, 1, gTextStoryteller_Story26Title, gTextStoryteller_Story26Action, gTextStoryteller_Story26Text}, + {0x28, 1, gTextStoryteller_Story27Title, gTextStoryteller_Story27Action, gTextStoryteller_Story27Text}, + {0x29, 1, gTextStoryteller_Story28Title, gTextStoryteller_Story28Action, gTextStoryteller_Story28Text}, + {0x2A, 1, gTextStoryteller_Story29Title, gTextStoryteller_Story29Action, gTextStoryteller_Story29Text}, + {0x2B, 1, gTextStoryteller_Story30Title, gTextStoryteller_Story30Action, gTextStoryteller_Story30Text}, + {0x2C, 1, gTextStoryteller_Story31Title, gTextStoryteller_Story31Action, gTextStoryteller_Story31Text}, + {0x2D, 1, gTextStoryteller_Story32Title, gTextStoryteller_Story32Action, gTextStoryteller_Story32Text}, + {0x2E, 1, gTextStoryteller_Story33Title, gTextStoryteller_Story33Action, gTextStoryteller_Story33Text}, + {0x2F, 1, gTextStoryteller_Story34Title, gTextStoryteller_Story34Action, gTextStoryteller_Story34Text}, + {0x30, 1, gTextStoryteller_Story35Title, gTextStoryteller_Story35Action, gTextStoryteller_Story35Text}, + {0x31, 1, gTextStoryteller_Story36Title, gTextStoryteller_Story36Action, gTextStoryteller_Story36Text}, +}; + +static void StorytellerSetup(void) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; + s32 i; + + storyteller->id = MAUVILLE_MAN_STORYTELLER; + storyteller->alreadyRecorded = FALSE; + for (i = 0; i < 4; i++) + { + storyteller->gameStatIDs[i] = 0; + storyteller->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead? + } +} + +static void sub_80F8428(void) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; + + storyteller->id = MAUVILLE_MAN_STORYTELLER; + storyteller->alreadyRecorded = FALSE; +} + +static u32 StorytellerGetGameStat(u8 stat) +{ + if (stat == NUM_GAME_STATS) + stat = 0; + return GetGameStat(stat); +} + +static const struct Story *GetStoryByStat(u32 stat) +{ + s32 i; + + for (i = 0; i < 36; i++) + { + if (sStorytellerStories[i].stat == stat) + return &sStorytellerStories[i]; + } + return &sStorytellerStories[35]; +} + +static const u8 *GetStoryTitleByStat(u32 stat) +{ + return GetStoryByStat(stat)->title; +} + +static const u8 *GetStoryTextByStat(u32 stat) +{ + return GetStoryByStat(stat)->fullText; +} + +static const u8 *GetStoryActionByStat(u32 stat) +{ + return GetStoryByStat(stat)->action; +} + +static u8 GetFreeStorySlot(void) +{ + u8 i; + + for (i = 0; i < 4; i++) + { + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; + + if (storyteller->gameStatIDs[i] == 0) + break; + } + return i; +} + +static u32 StorytellerGetRecordedTrainerStat(u32 trainer) +{ + u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.statValues[trainer]; + + return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); +} + +static void StorytellerSetRecordedTrainerStat(u32 trainer, u32 val) +{ + u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.statValues[trainer]; + + ptr[0] = val; + ptr[1] = val >> 8; + ptr[2] = val >> 16; + ptr[3] = val >> 24; +} + +static bool32 HasTrainerStatIncreased(u32 trainer) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; + + if (StorytellerGetGameStat(storyteller->gameStatIDs[trainer]) > StorytellerGetRecordedTrainerStat(trainer)) + return TRUE; + else + return FALSE; +} + +static void GetStoryByStattellerPlayerName(u32 player, void *dst) +{ + u8 *name = gSaveBlock1.mauvilleMan.storyteller.trainerNames[player]; + + memset(dst, EOS, 8); + memcpy(dst, name, 7); +} + +static void StorytellerSetPlayerName(u32 player, const u8 *src) +{ + u8 *name = gSaveBlock1.mauvilleMan.storyteller.trainerNames[player]; + u8 len = StringLength(src); + + memset(name, EOS, 7); + StringCopyN(name, src, len); +} + +static void StorytellerRecordNewStat(u32 player, u32 stat) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; + + storyteller->gameStatIDs[player] = stat; + StorytellerSetPlayerName(player, gSaveBlock2.playerName); + StorytellerSetRecordedTrainerStat(player, StorytellerGetGameStat(stat)); + ConvertIntToDecimalStringN(gStringVar1, StorytellerGetGameStat(stat), 0, 10); + StringCopy(gStringVar2, GetStoryActionByStat(stat)); +} + +static void ScrambleStatList(u8 *arr, s32 count) +{ + s32 i; + + for (i = 0; i < count; i++) + arr[i] = i; + for (i = 0; i < count; i++) + { + u32 a = Random() % count; + u32 b = Random() % count; + u8 temp = arr[a]; + arr[a] = arr[b]; + arr[b] = temp; + } +} + +// What purpose does this struct even serve? Only the length field is used. +static const struct {u32 length; struct MauvilleManStoryteller *unused1; u32 unused2;} sStorytellerStuff = +{ + 36, + &gSaveBlock1.mauvilleMan.storyteller, // unused + 12, // unused +}; + +static bool8 StorytellerInitializeRandomStat(void) +{ + u8 arr[sStorytellerStuff.length]; + s32 i; + s32 j; + + ScrambleStatList(arr, 36); + for (i = 0; i < 36; i++) + { + u8 stat = sStorytellerStories[arr[i]].stat; + u8 minVal = sStorytellerStories[arr[i]].minVal; + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; + + for (j = 0; j < 4; j++) + { + if (gSaveBlock1.mauvilleMan.storyteller.gameStatIDs[j] == stat) + break; + } + if (j == 4 && StorytellerGetGameStat(stat) >= minVal) + { + storyteller->alreadyRecorded = TRUE; + StorytellerRecordNewStat(GetFreeStorySlot(), stat); + return TRUE; + } + } + return FALSE; +} + +static void StorytellerDisplayStory(u32 player) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; + u8 stat = storyteller->gameStatIDs[player]; + + ConvertIntToDecimalStringN(gStringVar1, StorytellerGetRecordedTrainerStat(player), 0, 10); + StringCopy(gStringVar2, GetStoryActionByStat(stat)); + GetStoryByStattellerPlayerName(player, gStringVar3); + ShowFieldMessage(GetStoryTextByStat(stat)); +} + +static void PrintStoryList(void) +{ + s32 i; + + MenuDrawTextWindow(0, 0, 25, 4 + GetFreeStorySlot() * 2); + for (i = 0; i < 4; i++) + { + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; + u8 stat = storyteller->gameStatIDs[i]; + + if (stat == 0) + break; + MenuPrint(GetStoryTitleByStat(stat), 1, 2 + i * 2); + } + MenuPrint(gPCText_Cancel, 1, 2 + i * 2); +} + +static u8 gUnknown_03000748; + +static void Task_StoryListMenu(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + s32 selection; + + switch (task->data[0]) + { + case 0: + PrintStoryList(); + InitMenu(0, 1, 2, GetFreeStorySlot() + 1, 0, 24); + task->data[0]++; + break; + case 1: + selection = ProcessMenuInput(); + if (selection == -2) + break; + if (selection == -1 || selection == GetFreeStorySlot()) + { + gScriptResult = 0; + } + else + { + gScriptResult = 1; + gUnknown_03000748 = selection; + } + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 25, 12); + DestroyTask(taskId); + EnableBothScriptContexts(); + break; + } +} + +// Sets gScriptResult to TRUE if player selected a story +void ScrSpecial_StorytellerStoryListMenu(void) +{ + CreateTask(Task_StoryListMenu, 0x50); +} + +void ScrSpecial_StorytellerDisplayStory(void) +{ + StorytellerDisplayStory(gUnknown_03000748); +} + +u8 ScrSpecial_StorytellerGetFreeStorySlot(void) +{ + return GetFreeStorySlot(); +} + +// Returns TRUE if stat has increased +bool8 ScrSpecial_StorytellerUpdateStat(void) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; + u8 r4 = storyteller->gameStatIDs[gUnknown_03000748]; + + if (HasTrainerStatIncreased(gUnknown_03000748) == TRUE) + { + StorytellerRecordNewStat(gUnknown_03000748, r4); + return TRUE; + } + return FALSE; +} + +bool8 ScrSpecial_HasStorytellerAlreadyRecorded(void) +{ + struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; + + if (storyteller->alreadyRecorded == FALSE) + return FALSE; + else + return TRUE; +} + +bool8 ScrSpecial_StorytellerInitializeRandomStat(void) +{ + return StorytellerInitializeRandomStat(); +} diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c deleted file mode 100644 index d54e017f7..000000000 --- a/src/mauville_old_man.c +++ /dev/null @@ -1,1311 +0,0 @@ -#include "global.h" -#include "bard_music.h" -#include "mauville_old_man.h" -#include "easy_chat.h" -#include "event_data.h" -#include "field_message_box.h" -#include "m4a.h" -#include "menu.h" -#include "rom4.h" -#include "rng.h" -#include "script.h" -#include "songs.h" -#include "sound.h" -#include "string_util.h" -#include "strings.h" -#include "task.h" -#include "trader.h" - -#define MACRO1(a) (((a) % 4) + (((a) / 8) & 1)) - -extern struct MusicPlayerInfo gMPlay_SE2; - -extern u16 gScriptResult; -extern u16 gSpecialVar_0x8004; - -extern const u8 gTextStoryteller_Story1Title[]; -extern const u8 gTextStoryteller_Story1Action[]; -extern const u8 gTextStoryteller_Story1Text[]; -extern const u8 gTextStoryteller_Story2Title[]; -extern const u8 gTextStoryteller_Story2Action[]; -extern const u8 gTextStoryteller_Story2Text[]; -extern const u8 gTextStoryteller_Story3Title[]; -extern const u8 gTextStoryteller_Story3Action[]; -extern const u8 gTextStoryteller_Story3Text[]; -extern const u8 gTextStoryteller_Story4Title[]; -extern const u8 gTextStoryteller_Story4Action[]; -extern const u8 gTextStoryteller_Story4Text[]; -extern const u8 gTextStoryteller_Story5Title[]; -extern const u8 gTextStoryteller_Story5Action[]; -extern const u8 gTextStoryteller_Story5Text[]; -extern const u8 gTextStoryteller_Story6Title[]; -extern const u8 gTextStoryteller_Story6Action[]; -extern const u8 gTextStoryteller_Story6Text[]; -extern const u8 gTextStoryteller_Story7Title[]; -extern const u8 gTextStoryteller_Story7Action[]; -extern const u8 gTextStoryteller_Story7Text[]; -extern const u8 gTextStoryteller_Story8Title[]; -extern const u8 gTextStoryteller_Story8Action[]; -extern const u8 gTextStoryteller_Story8Text[]; -extern const u8 gTextStoryteller_Story9Title[]; -extern const u8 gTextStoryteller_Story9Action[]; -extern const u8 gTextStoryteller_Story9Text[]; -extern const u8 gTextStoryteller_Story10Title[]; -extern const u8 gTextStoryteller_Story10Action[]; -extern const u8 gTextStoryteller_Story10Text[]; -extern const u8 gTextStoryteller_Story11Title[]; -extern const u8 gTextStoryteller_Story11Action[]; -extern const u8 gTextStoryteller_Story11Text[]; -extern const u8 gTextStoryteller_Story12Title[]; -extern const u8 gTextStoryteller_Story12Action[]; -extern const u8 gTextStoryteller_Story12Text[]; -extern const u8 gTextStoryteller_Story13Title[]; -extern const u8 gTextStoryteller_Story13Action[]; -extern const u8 gTextStoryteller_Story13Text[]; -extern const u8 gTextStoryteller_Story14Title[]; -extern const u8 gTextStoryteller_Story14Action[]; -extern const u8 gTextStoryteller_Story14Text[]; -extern const u8 gTextStoryteller_Story15Title[]; -extern const u8 gTextStoryteller_Story15Action[]; -extern const u8 gTextStoryteller_Story15Text[]; -extern const u8 gTextStoryteller_Story16Title[]; -extern const u8 gTextStoryteller_Story16Action[]; -extern const u8 gTextStoryteller_Story16Text[]; -extern const u8 gTextStoryteller_Story17Title[]; -extern const u8 gTextStoryteller_Story17Action[]; -extern const u8 gTextStoryteller_Story17Text[]; -extern const u8 gTextStoryteller_Story18Title[]; -extern const u8 gTextStoryteller_Story18Action[]; -extern const u8 gTextStoryteller_Story18Text[]; -extern const u8 gTextStoryteller_Story19Title[]; -extern const u8 gTextStoryteller_Story19Action[]; -extern const u8 gTextStoryteller_Story19Text[]; -extern const u8 gTextStoryteller_Story20Title[]; -extern const u8 gTextStoryteller_Story20Action[]; -extern const u8 gTextStoryteller_Story20Text[]; -extern const u8 gTextStoryteller_Story21Title[]; -extern const u8 gTextStoryteller_Story21Action[]; -extern const u8 gTextStoryteller_Story21Text[]; -extern const u8 gTextStoryteller_Story22Title[]; -extern const u8 gTextStoryteller_Story22Action[]; -extern const u8 gTextStoryteller_Story22Text[]; -extern const u8 gTextStoryteller_Story23Title[]; -extern const u8 gTextStoryteller_Story23Action[]; -extern const u8 gTextStoryteller_Story23Text[]; -extern const u8 gTextStoryteller_Story24Title[]; -extern const u8 gTextStoryteller_Story24Action[]; -extern const u8 gTextStoryteller_Story24Text[]; -extern const u8 gTextStoryteller_Story25Title[]; -extern const u8 gTextStoryteller_Story25Action[]; -extern const u8 gTextStoryteller_Story25Text[]; -extern const u8 gTextStoryteller_Story26Title[]; -extern const u8 gTextStoryteller_Story26Action[]; -extern const u8 gTextStoryteller_Story26Text[]; -extern const u8 gTextStoryteller_Story27Title[]; -extern const u8 gTextStoryteller_Story27Action[]; -extern const u8 gTextStoryteller_Story27Text[]; -extern const u8 gTextStoryteller_Story28Title[]; -extern const u8 gTextStoryteller_Story28Action[]; -extern const u8 gTextStoryteller_Story28Text[]; -extern const u8 gTextStoryteller_Story29Title[]; -extern const u8 gTextStoryteller_Story29Action[]; -extern const u8 gTextStoryteller_Story29Text[]; -extern const u8 gTextStoryteller_Story30Title[]; -extern const u8 gTextStoryteller_Story30Action[]; -extern const u8 gTextStoryteller_Story30Text[]; -extern const u8 gTextStoryteller_Story31Title[]; -extern const u8 gTextStoryteller_Story31Action[]; -extern const u8 gTextStoryteller_Story31Text[]; -extern const u8 gTextStoryteller_Story32Title[]; -extern const u8 gTextStoryteller_Story32Action[]; -extern const u8 gTextStoryteller_Story32Text[]; -extern const u8 gTextStoryteller_Story33Title[]; -extern const u8 gTextStoryteller_Story33Action[]; -extern const u8 gTextStoryteller_Story33Text[]; -extern const u8 gTextStoryteller_Story34Title[]; -extern const u8 gTextStoryteller_Story34Action[]; -extern const u8 gTextStoryteller_Story34Text[]; -extern const u8 gTextStoryteller_Story35Title[]; -extern const u8 gTextStoryteller_Story35Action[]; -extern const u8 gTextStoryteller_Story35Text[]; -extern const u8 gTextStoryteller_Story36Title[]; -extern const u8 gTextStoryteller_Story36Action[]; -extern const u8 gTextStoryteller_Story36Text[]; - -extern struct BardSong gUnknown_03005DA0; - -EWRAM_DATA static u16 gUnknown_020388BC = 0; // set but not used? - -static const u16 sDefaultBardSongLyrics[] = -{ -#ifdef ENGLISH - EC_WORD_SISTER, - EC_WORD_EATS, - EC_WORD_SWEETS, - EC_WORD_VORACIOUS, - EC_WORD_AND, - EC_WORD_DROOLING, -#else - EC_WORD_SISTER, - EC_WORD_MUST_BE, - EC_WORD_SWEETS, - EC_WORD_VORACIOUS, - EC_WORD_DROOLING, - EC_WORD_THICK, -#endif -}; - -static const u8 *const sGiddyAdjectives[] = -{ - OtherText_SoPretty, - OtherText_SoDarling, - OtherText_SoRelaxed, - OtherText_SoSunny, - OtherText_SoDesirable, - OtherText_SoExciting, - OtherText_SoAmusing, - OtherText_SoMagical, -}; - -static const u8 *const sGiddyQuestions[] = -{ - OtherText_WantVacationNicePlace, - OtherText_BoughtCrayonsIsNice, - OtherText_IfWeCouldFloat, - OtherText_SandWashesAwayMakeSad, - OtherText_WhatsBottomSeaLike, - OtherText_SeeSettingSun, - OtherText_LyingInGreenGrass, - OtherText_SecretBasesWonderful, -}; - -static void sub_80F7DC0(void); -static void Task_BardSong(u8); -static void StartBardSong(u8); -static void StorytellerSetup(void); -static void sub_80F8428(void); - -static void SetupBard(void) -{ - u16 i; - struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - - bard->id = MAUVILLE_MAN_BARD; - bard->hasChangedSong = FALSE; - for (i = 0; i < 6; i++) - bard->songLyrics[i] = sDefaultBardSongLyrics[i]; -} - -static void SetupHipster(void) -{ - struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; - - hipster->id = MAUVILLE_MAN_HIPSTER; - hipster->alreadySpoken = FALSE; -} - -static void SetupStoryteller(void) -{ - StorytellerSetup(); -} - -static void SetupGiddy(void) -{ - struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; - - giddy->id = MAUVILLE_MAN_GIDDY; - giddy->taleCounter = 0; -} - -static void SetupTrader(void) -{ - TraderSetup(); -} - -void SetupMauvilleOldMan(void) -{ - u16 trainerId = (gSaveBlock2.playerTrainerId[1] << 8) | gSaveBlock2.playerTrainerId[0]; - - // Determine man based on the last digit of the player's trainer ID. - switch ((trainerId % 10) / 2) - { - case MAUVILLE_MAN_BARD: - SetupBard(); - break; - case MAUVILLE_MAN_HIPSTER: - SetupHipster(); - break; - case MAUVILLE_MAN_TRADER: - SetupTrader(); - break; - case MAUVILLE_MAN_STORYTELLER: - SetupStoryteller(); - break; - case MAUVILLE_MAN_GIDDY: - SetupGiddy(); - break; - } - sub_80F83D0(); -} - -static u8 GetCurrentMauvilleOldMan(void) -{ - struct MauvilleManCommon *common = &gSaveBlock1.mauvilleMan.common; - - return common->id; -} - -void ScrSpecial_GetCurrentMauvilleMan(void) -{ - gScriptResult = GetCurrentMauvilleOldMan(); -} - -void ScrSpecial_HasBardSongBeenChanged(void) -{ - u16 *scriptResult = &gScriptResult; // why?? - struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - - *scriptResult = bard->hasChangedSong; -} - -void ScrSpecial_SaveBardSongLyrics(void) -{ - u16 i; - struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - - StringCopy(bard->playerName, gSaveBlock2.playerName); - - for (i = 0; i < 4; i++) - bard->playerTrainerId[i] = gSaveBlock2.playerTrainerId[i]; - - for (i = 0; i < 6; i++) - bard->songLyrics[i] = bard->temporaryLyrics[i]; - - bard->hasChangedSong = TRUE; -} - -// Copies lyrics into gStringVar4 -void PrepareSongText(void) -{ - struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - u16 specialVar = gSpecialVar_0x8004; // It's a bit odd to use this temp variable, but it seems needed to match. - u16 *lyrics; - 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 - for (lineNum = 0; lineNum < 2; lineNum++) - { - wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); - while (wordEnd != str) - { - if (*str == CHAR_SPACE) - *str = CHAR_SONG_WORD_SEPARATOR; - str++; - } - - str++; - *(wordEnd++) = CHAR_SPACE; - - wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); - while (wordEnd != str) - { - if (*str == CHAR_SPACE) - *str = CHAR_SONG_WORD_SEPARATOR; - str++; - } - - str++; - *(wordEnd++) = CHAR_NEWLINE; - - wordEnd = EasyChat_GetWordText(wordEnd, *(lyrics++)); - while (wordEnd != str) - { - if (*str == CHAR_SPACE) - *str = CHAR_SONG_WORD_SEPARATOR; - str++; - } - - if (lineNum == 0) - { - *(wordEnd++) = EXT_CTRL_CODE_BEGIN; - *(wordEnd++) = 15; - } - } -} - -void ScrSpecial_PlayBardSong(void) -{ - StartBardSong(gSpecialVar_0x8004); - MenuDisplayMessageBox(); - ScriptContext1_Stop(); -} - -void ScrSpecial_GetHipsterSpokenFlag(void) -{ - u16 *scriptResult = &gScriptResult; // again?? - struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; - - *scriptResult = hipster->alreadySpoken; -} - -void ScrSpecial_SetHipsterSpokenFlag(void) -{ - struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; - - hipster->alreadySpoken = TRUE; -} - -void ScrSpecial_HipsterTeachWord(void) -{ - u16 var = sub_80EB8EC(); - - if (var == 0xFFFF) - { - gScriptResult = FALSE; - } - else - { - EasyChat_GetWordText(gStringVar1, var); - gScriptResult = TRUE; - } -} - -void ScrSpecial_GiddyShouldTellAnotherTale(void) -{ - struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; - - if (giddy->taleCounter == 10) - { - gScriptResult = FALSE; - giddy->taleCounter = 0; - } - else - { - gScriptResult = TRUE; - } -} - -void ScrSpecial_GenerateGiddyLine(void) -{ - struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; - - if (giddy->taleCounter == 0) - sub_80F7DC0(); - - if (giddy->randomWords[giddy->taleCounter] != 0xFFFF) // is not the last element of the array? - { - u8 *stringPtr; - u32 adjective = Random(); - - adjective %= 8; - stringPtr = EasyChat_GetWordText(gStringVar4, giddy->randomWords[giddy->taleCounter]); - stringPtr = StringCopy(stringPtr, gOtherText_Is); - stringPtr = StringCopy(stringPtr, sGiddyAdjectives[adjective]); - StringCopy(stringPtr, gOtherText_DontYouAgree); - } - else - { - StringCopy(gStringVar4, sGiddyQuestions[giddy->questionList[giddy->questionNum++]]); - } - - if (!(Random() % 10)) - giddy->taleCounter = 10; - else - giddy->taleCounter++; - - gScriptResult = TRUE; -} - -#ifdef NONMATCHING -static void sub_80F7DC0(void) -{ - u16 arr[][2] = - { - { 0x0, 0}, - { 0xC, 0}, - { 0xD, 0}, - {0x12, 0}, - {0x13, 0}, - {0x15, 0}, - }; - u16 i; - u16 r10; - u16 r7; - - for (i = 0; i < 8; i++) - { - struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; - - //gSaveBlock1.mauvilleMan.giddy.questionList[i] = i; - giddy->questionList[i] = i; - } - - // Scramble questions - for (i = 0; i < 8; i++) - { - struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; - - /* - u16 r1 = Random() % (i + 1); - u8 r7 = gSaveBlock1.mauvilleMan.giddy.questionList[i]; - gSaveBlock1.mauvilleMan.giddy.questionList[i] = gSaveBlock1.mauvilleMan.giddy.questionList[r1]; - gSaveBlock1.mauvilleMan.giddy.questionList[r1] = r7; - */ - u16 r1 = Random() % (i + 1); - u8 r7 = giddy->questionList[i]; - giddy->questionList[i] = giddy->questionList[r1]; - giddy->questionList[r1] = r7; - } - - r10 = 0; - for (i = 0; i < 6; i++) - { - arr[i][1] = sub_80EAE88(arr[i][0]); - r10 += arr[i][1]; - } - - { - struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; - giddy->questionNum = 0; - } - //gSaveBlock1.mauvilleMan.giddy.questionNum = 0; - - r7 = 0; - for (i = 0; i < 10; i++) - { - struct MauvilleManGiddy *giddy = &gSaveBlock1.mauvilleMan.giddy; - - u16 var = Random() % 10; - if (var < 3 && r7 < 8) - { - //gSaveBlock1.mauvilleMan.giddy.randomWords[i] = 0xFFFF; - giddy->randomWords[i] = 0xFFFF; - r7++; - } - //_080F7E90 - else - { - s16 r2 = Random() % r10; - - u16 r1 = 0; - - while (i < 6) // comparing the wrong variable - { - r2 = arr[r1][1] - r2; - if (r2 <= 0) - break; - r1++; - } - - if (r1 == 6) - r1 = 0; - //gSaveBlock1.mauvilleMan.giddy.randomWords[i] = sub_80EB784(arr[r1][0]); - giddy->randomWords[i] = sub_80EB784(arr[r1][0]); - } - } -} -#else - -static const u16 gUnknown_083E53C8[][2] = -{ - { 0x0, 0}, - { 0xC, 0}, - { 0xD, 0}, - {0x12, 0}, - {0x13, 0}, - {0x15, 0}, -}; - -__attribute__((naked)) -static void sub_80F7DC0(void) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x18\n\ - ldr r1, _080F7E84 @ =gUnknown_083E53C8\n\ - mov r0, sp\n\ - movs r2, 0x18\n\ - bl memcpy\n\ - movs r5, 0\n\ - movs r0, 0x2\n\ - add r0, sp\n\ - mov r8, r0\n\ - ldr r1, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ - adds r1, 0x18\n\ - adds r3, r1, 0\n\ -_080F7DE4:\n\ - adds r0, r3, r5\n\ - strb r5, [r0]\n\ - adds r0, r5, 0x1\n\ - lsls r0, 16\n\ - lsrs r5, r0, 16\n\ - cmp r5, 0x7\n\ - bls _080F7DE4\n\ - movs r5, 0\n\ - ldr r2, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ - adds r2, 0x4\n\ - mov r9, r2\n\ - adds r6, r1, 0\n\ -_080F7DFC:\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - adds r4, r5, 0x1\n\ - adds r1, r4, 0\n\ - bl __modsi3\n\ - lsls r0, 16\n\ - lsrs r1, r0, 16\n\ - adds r2, r6, r5\n\ - ldrb r7, [r2]\n\ - adds r1, r6, r1\n\ - ldrb r0, [r1]\n\ - strb r0, [r2]\n\ - strb r7, [r1]\n\ - lsls r4, 16\n\ - lsrs r5, r4, 16\n\ - cmp r5, 0x7\n\ - bls _080F7DFC\n\ - movs r3, 0\n\ - mov r10, r3\n\ - movs r5, 0\n\ -_080F7E2A:\n\ - lsls r4, r5, 2\n\ - mov r1, sp\n\ - adds r0, r1, r4\n\ - ldrb r0, [r0]\n\ - bl sub_80EAE88\n\ - add r4, r8\n\ - strh r0, [r4]\n\ - add r0, r10\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r10, r0\n\ - adds r0, r5, 0x1\n\ - lsls r0, 16\n\ - lsrs r5, r0, 16\n\ - cmp r5, 0x5\n\ - bls _080F7E2A\n\ - movs r0, 0\n\ - ldr r2, _080F7E88 @ =gSaveBlock1 + 0x2D94\n\ - strb r0, [r2, 0x2]\n\ - movs r7, 0\n\ - movs r5, 0\n\ -_080F7E56:\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - movs r1, 0xA\n\ - bl __umodsi3\n\ - lsls r0, 16\n\ - lsrs r1, r0, 16\n\ - cmp r1, 0x2\n\ - bhi _080F7E90\n\ - cmp r7, 0x7\n\ - bhi _080F7E90\n\ - lsls r0, r5, 1\n\ - add r0, r9\n\ - ldr r1, _080F7E8C @ =0x0000ffff\n\ - strh r1, [r0]\n\ - adds r0, r7, 0x1\n\ - lsls r0, 16\n\ - lsrs r7, r0, 16\n\ - adds r4, r5, 0x1\n\ - b _080F7EE2\n\ - .align 2, 0\n\ -_080F7E84: .4byte gUnknown_083E53C8\n\ -_080F7E88: .4byte gSaveBlock1 + 0x2D94\n\ -_080F7E8C: .4byte 0x0000ffff\n\ -_080F7E90:\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r1, r10\n\ - bl __umodsi3\n\ - lsls r0, 16\n\ - lsrs r2, r0, 16\n\ - movs r1, 0\n\ - adds r4, r5, 0x1\n\ - lsls r6, r5, 1\n\ - cmp r5, 0x5\n\ - bhi _080F7ECC\n\ - mov r3, r8\n\ - ldrh r0, [r3]\n\ - b _080F7EC2\n\ -_080F7EB2:\n\ - adds r0, r1, 0x1\n\ - lsls r0, 16\n\ - lsrs r1, r0, 16\n\ - cmp r5, 0x5\n\ - bhi _080F7ECC\n\ - lsls r0, r1, 2\n\ - adds r0, r3, r0\n\ - ldrh r0, [r0]\n\ -_080F7EC2:\n\ - subs r0, r2, r0\n\ - lsls r0, 16\n\ - lsrs r2, r0, 16\n\ - cmp r0, 0\n\ - bgt _080F7EB2\n\ -_080F7ECC:\n\ - cmp r1, 0x6\n\ - bne _080F7ED2\n\ - movs r1, 0\n\ -_080F7ED2:\n\ - lsls r0, r1, 2\n\ - add r0, sp\n\ - ldrh r0, [r0]\n\ - bl sub_80EB784\n\ - mov r2, r9\n\ - adds r1, r2, r6\n\ - strh r0, [r1]\n\ -_080F7EE2:\n\ - lsls r0, r4, 16\n\ - lsrs r5, r0, 16\n\ - cmp r5, 0x9\n\ - bls _080F7E56\n\ - add sp, 0x18\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); -} -#endif - -static void sub_80F7EFC(void) -{ - struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - - bard->hasChangedSong = FALSE; -} - -static void sub_80F7F0C(void) -{ - struct MauvilleManHipster *hipster = &gSaveBlock1.mauvilleMan.hipster; - - hipster->alreadySpoken = FALSE; -} - -static void sub_80F7F18(void) -{ - sub_8109A20(); -} - -static void sub_80F7F24(void) -{ - sub_80F8428(); -} - -void sub_80F7F30(void) -{ - switch (GetCurrentMauvilleOldMan()) - { - case MAUVILLE_MAN_BARD: - sub_80F7EFC(); - break; - case MAUVILLE_MAN_HIPSTER: - sub_80F7F0C(); - break; - case MAUVILLE_MAN_STORYTELLER: - sub_80F7F24(); - break; - case MAUVILLE_MAN_TRADER: - sub_80F7F18(); - break; - case MAUVILLE_MAN_GIDDY: - break; - } - sub_80F83D0(); -} - -#define tState data[0] -#define tCharIndex data[3] -#define tCurrWord data[4] -#define tUseTemporaryLyrics data[5] - -static void StartBardSong(bool8 useTemporaryLyrics) -{ - u8 taskId = CreateTask(Task_BardSong, 0x50); - - gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics; -} - -static void BardSing(struct Task *task, struct BardSong *song) -{ - switch (task->tState) - { - case 0: // Initialize song - { - struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - u16 *lyrics; - s32 i; - - // Copy lyrics - if (gSpecialVar_0x8004 == 0) - lyrics = bard->songLyrics; - else - lyrics = bard->temporaryLyrics; - for (i = 0; i < 6; i++) - song->lyrics[i] = lyrics[i]; - - // Clear phonemes - for (i = 0; i < 6; i++) - { - song->phonemes[i].sound = 0xFFFF; - song->phonemes[i].length = 0; - song->phonemes[i].pitch = 0; - song->phonemes[i].volume = 0; - } - song->currWord = 0; - song->currPhoneme = 0; - song->var04 = 0; - } - break; - case 1: // Wait for BGM to end - break; - case 2: // Initialize word - { - u16 word = song->lyrics[song->currWord]; - const struct BardSound *sounds = GetWordSounds(EC_GROUP(word), EC_INDEX(word)); - - song->var04 = 0; - GetWordPhonemes(song, sounds, MACRO1(word)); - } - break; - case 3: - case 4: - { - struct BardPhoneme *phoneme = &song->phonemes[song->currPhoneme]; - - switch (song->state) - { - case 0: - if (song->phonemeTimer == 0) // Timer has expired. Move to next phoneme - { - if (song->currPhoneme == 6 || phoneme->sound == 0xFF) - { - song->state = 0xFE; - break; - } - song->phonemeTimer = phoneme->length; - if (phoneme->sound <= 50) - { - u16 num = phoneme->sound / 3; - - m4aSongNumStart(249 + num * 3); - } - song->state = 1; - } - else - { - if (song->voiceInflection > 10) - song->volume -= 2; - if (song->voiceInflection & 1) - song->pitch += 64; - else - song->pitch -= 64; - m4aMPlayVolumeControl(&gMPlay_SE2, 0xFFFF, song->volume); - m4aMPlayPitchControl(&gMPlay_SE2, 0xFFFF, song->pitch); - song->voiceInflection++; - } - song->phonemeTimer--; - break; - case 1: - song->currPhoneme++; - song->state = 0; - if (phoneme->sound <= 50) - { - song->volume = 0x100 + phoneme->volume * 16; - m4aMPlayVolumeControl(&gMPlay_SE2, 0xFFFF, song->volume); - song->pitch = 0x200 + phoneme->pitch; - m4aMPlayPitchControl(&gMPlay_SE2, 0xFFFF, song->pitch); - } - break; - case 0xFE: - m4aMPlayStop(&gMPlay_SE2); - song->state = 0xFF; - break; - } - } - break; - case 5: - break; - } -} - -static void Task_BardSong(u8 taskId) -{ - struct Task *task = &gTasks[taskId]; // r5 - - BardSing(task, &gUnknown_03005DA0); - switch (task->tState) - { - case 0: // Initialize song - PrepareSongText(); - InitWindowFromConfig(gMenuWindowPtr, &gWindowConfig_81E6CE4); - sub_8002EB0(gMenuWindowPtr, gStringVar4, 2, 4, 15); - task->data[1] = 0; - task->data[2] = 0; - task->tCharIndex = 0; - task->tCurrWord = 0; - FadeOutBGMTemporarily(4); - task->tState = 1; - break; - case 1: // Wait for BGM to end - if (IsBGMPausedOrStopped()) - task->tState = 2; - break; - case 2: // Initialize word - { - struct MauvilleManBard *bard = &gSaveBlock1.mauvilleMan.bard; - u8 *str = gStringVar4 + task->tCharIndex; - u16 wordLen = 0; - // Can't get it to match without hacking - u32 temp; - register s16 zero asm("r1"); - - while (*str != CHAR_SPACE - && *str != CHAR_NEWLINE - && *str != EXT_CTRL_CODE_BEGIN - && *str != EOS) - { - str++; - wordLen++; - } - if (!task->tUseTemporaryLyrics) - gUnknown_020388BC = MACRO1(bard->songLyrics[task->tCurrWord]); - else - gUnknown_020388BC = MACRO1(bard->temporaryLyrics[task->tCurrWord]); - temp = gUnknown_03005DA0.var04 / wordLen; - zero = 0; - gUnknown_03005DA0.var04 = temp; - if (gUnknown_03005DA0.var04 <= 0) - gUnknown_03005DA0.var04 = 1; - task->tCurrWord++; - if (task->data[2] == 0) - task->tState = 3; - else - task->tState = 5; - task->data[1] = zero; - } - break; - case 5: - if (task->data[2] == 0) - task->tState = 3; - else - task->data[2]--; - break; - case 3: - if (gStringVar4[task->tCharIndex] == EOS) - { - FadeInNewBGM(BGM_POKECEN, 6); - m4aMPlayFadeOutTemporarily(&gMPlay_SE2, 2); - EnableBothScriptContexts(); - DestroyTask(taskId); - } - else if (gStringVar4[task->tCharIndex] == CHAR_SPACE) - { - sub_8003418(gMenuWindowPtr); - task->tCharIndex++; - task->tState = 2; - task->data[2] = 0; - } - else if (gStringVar4[task->tCharIndex] == CHAR_NEWLINE) - { - task->tCharIndex++; - task->tState = 2; - task->data[2] = 0; - } - else if (gStringVar4[task->tCharIndex] == EXT_CTRL_CODE_BEGIN) - { - task->tCharIndex += 2; // skip over control codes - task->tState = 2; - task->data[2] = 8; - } - else if (gStringVar4[task->tCharIndex] == CHAR_SONG_WORD_SEPARATOR) - { - gStringVar4[task->tCharIndex] = CHAR_SPACE; // restore it back to a space - sub_8003418(gMenuWindowPtr); - task->tCharIndex++; - task->data[2] = 0; - } - else - { - switch (task->data[1]) - { - case 0: - sub_8003418(gMenuWindowPtr); - task->data[1]++; - break; - case 1: - task->data[1]++; - break; - case 2: - task->tCharIndex++; - task->data[1] = 0; - task->data[2] = gUnknown_03005DA0.var04; - task->tState = 4; - break; - } - } - break; - case 4: - task->data[2]--; - if (task->data[2] == 0) - task->tState = 3; - break; - } -} - -void sub_80F83D0(void) -{ - VarSet(0x4010, 0x45 + GetCurrentMauvilleOldMan()); -} - -struct Story -{ - u8 stat; - u8 minVal; - const u8 *title; - const u8 *action; - const u8 *fullText; -}; - -static const struct Story sStorytellerStories[] = -{ - {0x32, 1, gTextStoryteller_Story1Title, gTextStoryteller_Story1Action, gTextStoryteller_Story1Text}, - {0x02, 1, gTextStoryteller_Story2Title, gTextStoryteller_Story2Action, gTextStoryteller_Story2Text}, - {0x03, 1, gTextStoryteller_Story3Title, gTextStoryteller_Story3Action, gTextStoryteller_Story3Text}, - {0x04, 1, gTextStoryteller_Story4Title, gTextStoryteller_Story4Action, gTextStoryteller_Story4Text}, - {0x06, 1, gTextStoryteller_Story5Title, gTextStoryteller_Story5Action, gTextStoryteller_Story5Text}, - {0x09, 1, gTextStoryteller_Story6Title, gTextStoryteller_Story6Action, gTextStoryteller_Story6Text}, - {0x0B, 1, gTextStoryteller_Story7Title, gTextStoryteller_Story7Action, gTextStoryteller_Story7Text}, - {0x0C, 1, gTextStoryteller_Story8Title, gTextStoryteller_Story8Action, gTextStoryteller_Story8Text}, - {0x0D, 1, gTextStoryteller_Story9Title, gTextStoryteller_Story9Action, gTextStoryteller_Story9Text}, - {0x0E, 1, gTextStoryteller_Story10Title, gTextStoryteller_Story10Action, gTextStoryteller_Story10Text}, - {0x0F, 1, gTextStoryteller_Story11Title, gTextStoryteller_Story11Action, gTextStoryteller_Story11Text}, - {0x10, 1, gTextStoryteller_Story12Title, gTextStoryteller_Story12Action, gTextStoryteller_Story12Text}, - {0x11, 1, gTextStoryteller_Story13Title, gTextStoryteller_Story13Action, gTextStoryteller_Story13Text}, - {0x12, 1, gTextStoryteller_Story14Title, gTextStoryteller_Story14Action, gTextStoryteller_Story14Text}, - {0x13, 1, gTextStoryteller_Story15Title, gTextStoryteller_Story15Action, gTextStoryteller_Story15Text}, - {0x14, 1, gTextStoryteller_Story16Title, gTextStoryteller_Story16Action, gTextStoryteller_Story16Text}, - {0x1A, 1, gTextStoryteller_Story17Title, gTextStoryteller_Story17Action, gTextStoryteller_Story17Text}, - {0x1B, 1, gTextStoryteller_Story18Title, gTextStoryteller_Story18Action, gTextStoryteller_Story18Text}, - {0x1C, 1, gTextStoryteller_Story19Title, gTextStoryteller_Story19Action, gTextStoryteller_Story19Text}, - {0x1D, 2, gTextStoryteller_Story20Title, gTextStoryteller_Story20Action, gTextStoryteller_Story20Text}, - {0x1E, 1, gTextStoryteller_Story21Title, gTextStoryteller_Story21Action, gTextStoryteller_Story21Text}, - {0x21, 1, gTextStoryteller_Story22Title, gTextStoryteller_Story22Action, gTextStoryteller_Story22Text}, - {0x24, 1, gTextStoryteller_Story23Title, gTextStoryteller_Story23Action, gTextStoryteller_Story23Text}, - {0x25, 1, gTextStoryteller_Story24Title, gTextStoryteller_Story24Action, gTextStoryteller_Story24Text}, - {0x26, 1, gTextStoryteller_Story25Title, gTextStoryteller_Story25Action, gTextStoryteller_Story25Text}, - {0x27, 1, gTextStoryteller_Story26Title, gTextStoryteller_Story26Action, gTextStoryteller_Story26Text}, - {0x28, 1, gTextStoryteller_Story27Title, gTextStoryteller_Story27Action, gTextStoryteller_Story27Text}, - {0x29, 1, gTextStoryteller_Story28Title, gTextStoryteller_Story28Action, gTextStoryteller_Story28Text}, - {0x2A, 1, gTextStoryteller_Story29Title, gTextStoryteller_Story29Action, gTextStoryteller_Story29Text}, - {0x2B, 1, gTextStoryteller_Story30Title, gTextStoryteller_Story30Action, gTextStoryteller_Story30Text}, - {0x2C, 1, gTextStoryteller_Story31Title, gTextStoryteller_Story31Action, gTextStoryteller_Story31Text}, - {0x2D, 1, gTextStoryteller_Story32Title, gTextStoryteller_Story32Action, gTextStoryteller_Story32Text}, - {0x2E, 1, gTextStoryteller_Story33Title, gTextStoryteller_Story33Action, gTextStoryteller_Story33Text}, - {0x2F, 1, gTextStoryteller_Story34Title, gTextStoryteller_Story34Action, gTextStoryteller_Story34Text}, - {0x30, 1, gTextStoryteller_Story35Title, gTextStoryteller_Story35Action, gTextStoryteller_Story35Text}, - {0x31, 1, gTextStoryteller_Story36Title, gTextStoryteller_Story36Action, gTextStoryteller_Story36Text}, -}; - -static void StorytellerSetup(void) -{ - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - s32 i; - - storyteller->id = MAUVILLE_MAN_STORYTELLER; - storyteller->alreadyRecorded = FALSE; - for (i = 0; i < 4; i++) - { - storyteller->gameStatIDs[i] = 0; - storyteller->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead? - } -} - -static void sub_80F8428(void) -{ - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - - storyteller->id = MAUVILLE_MAN_STORYTELLER; - storyteller->alreadyRecorded = FALSE; -} - -static u32 StorytellerGetGameStat(u8 stat) -{ - if (stat == NUM_GAME_STATS) - stat = 0; - return GetGameStat(stat); -} - -static const struct Story *GetStoryByStat(u32 stat) -{ - s32 i; - - for (i = 0; i < 36; i++) - { - if (sStorytellerStories[i].stat == stat) - return &sStorytellerStories[i]; - } - return &sStorytellerStories[35]; -} - -static const u8 *GetStoryTitleByStat(u32 stat) -{ - return GetStoryByStat(stat)->title; -} - -static const u8 *GetStoryTextByStat(u32 stat) -{ - return GetStoryByStat(stat)->fullText; -} - -static const u8 *GetStoryActionByStat(u32 stat) -{ - return GetStoryByStat(stat)->action; -} - -static u8 GetFreeStorySlot(void) -{ - u8 i; - - for (i = 0; i < 4; i++) - { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - - if (storyteller->gameStatIDs[i] == 0) - break; - } - return i; -} - -static u32 StorytellerGetRecordedTrainerStat(u32 trainer) -{ - u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.statValues[trainer]; - - return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); -} - -static void StorytellerSetRecordedTrainerStat(u32 trainer, u32 val) -{ - u8 *ptr = gSaveBlock1.mauvilleMan.storyteller.statValues[trainer]; - - ptr[0] = val; - ptr[1] = val >> 8; - ptr[2] = val >> 16; - ptr[3] = val >> 24; -} - -static bool32 HasTrainerStatIncreased(u32 trainer) -{ - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - - if (StorytellerGetGameStat(storyteller->gameStatIDs[trainer]) > StorytellerGetRecordedTrainerStat(trainer)) - return TRUE; - else - return FALSE; -} - -static void GetStoryByStattellerPlayerName(u32 player, void *dst) -{ - u8 *name = gSaveBlock1.mauvilleMan.storyteller.trainerNames[player]; - - memset(dst, EOS, 8); - memcpy(dst, name, 7); -} - -static void StorytellerSetPlayerName(u32 player, const u8 *src) -{ - u8 *name = gSaveBlock1.mauvilleMan.storyteller.trainerNames[player]; - u8 len = StringLength(src); - - memset(name, EOS, 7); - StringCopyN(name, src, len); -} - -static void StorytellerRecordNewStat(u32 player, u32 stat) -{ - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - - storyteller->gameStatIDs[player] = stat; - StorytellerSetPlayerName(player, gSaveBlock2.playerName); - StorytellerSetRecordedTrainerStat(player, StorytellerGetGameStat(stat)); - ConvertIntToDecimalStringN(gStringVar1, StorytellerGetGameStat(stat), 0, 10); - StringCopy(gStringVar2, GetStoryActionByStat(stat)); -} - -static void ScrambleStatList(u8 *arr, s32 count) -{ - s32 i; - - for (i = 0; i < count; i++) - arr[i] = i; - for (i = 0; i < count; i++) - { - u32 a = Random() % count; - u32 b = Random() % count; - u8 temp = arr[a]; - arr[a] = arr[b]; - arr[b] = temp; - } -} - -// What purpose does this struct even serve? Only the length field is used. -static const struct {u32 length; struct MauvilleManStoryteller *unused1; u32 unused2;} sStorytellerStuff = -{ - 36, - &gSaveBlock1.mauvilleMan.storyteller, // unused - 12, // unused -}; - -static bool8 StorytellerInitializeRandomStat(void) -{ - u8 arr[sStorytellerStuff.length]; - s32 i; - s32 j; - - ScrambleStatList(arr, 36); - for (i = 0; i < 36; i++) - { - u8 stat = sStorytellerStories[arr[i]].stat; - u8 minVal = sStorytellerStories[arr[i]].minVal; - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - - for (j = 0; j < 4; j++) - { - if (gSaveBlock1.mauvilleMan.storyteller.gameStatIDs[j] == stat) - break; - } - if (j == 4 && StorytellerGetGameStat(stat) >= minVal) - { - storyteller->alreadyRecorded = TRUE; - StorytellerRecordNewStat(GetFreeStorySlot(), stat); - return TRUE; - } - } - return FALSE; -} - -static void StorytellerDisplayStory(u32 player) -{ - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - u8 stat = storyteller->gameStatIDs[player]; - - ConvertIntToDecimalStringN(gStringVar1, StorytellerGetRecordedTrainerStat(player), 0, 10); - StringCopy(gStringVar2, GetStoryActionByStat(stat)); - GetStoryByStattellerPlayerName(player, gStringVar3); - ShowFieldMessage(GetStoryTextByStat(stat)); -} - -static void PrintStoryList(void) -{ - s32 i; - - MenuDrawTextWindow(0, 0, 25, 4 + GetFreeStorySlot() * 2); - for (i = 0; i < 4; i++) - { - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - u8 stat = storyteller->gameStatIDs[i]; - - if (stat == 0) - break; - MenuPrint(GetStoryTitleByStat(stat), 1, 2 + i * 2); - } - MenuPrint(gPCText_Cancel, 1, 2 + i * 2); -} - -extern u8 gUnknown_03000748; - -static void Task_StoryListMenu(u8 taskId) -{ - struct Task *task = &gTasks[taskId]; - s32 selection; - - switch (task->data[0]) - { - case 0: - PrintStoryList(); - InitMenu(0, 1, 2, GetFreeStorySlot() + 1, 0, 24); - task->data[0]++; - break; - case 1: - selection = ProcessMenuInput(); - if (selection == -2) - break; - if (selection == -1 || selection == GetFreeStorySlot()) - { - gScriptResult = 0; - } - else - { - gScriptResult = 1; - gUnknown_03000748 = selection; - } - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 25, 12); - DestroyTask(taskId); - EnableBothScriptContexts(); - break; - } -} - -// Sets gScriptResult to TRUE if player selected a story -void ScrSpecial_StorytellerStoryListMenu(void) -{ - CreateTask(Task_StoryListMenu, 0x50); -} - -void ScrSpecial_StorytellerDisplayStory(void) -{ - StorytellerDisplayStory(gUnknown_03000748); -} - -u8 ScrSpecial_StorytellerGetFreeStorySlot(void) -{ - return GetFreeStorySlot(); -} - -// Returns TRUE if stat has increased -bool8 ScrSpecial_StorytellerUpdateStat(void) -{ - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - u8 r4 = storyteller->gameStatIDs[gUnknown_03000748]; - - if (HasTrainerStatIncreased(gUnknown_03000748) == TRUE) - { - StorytellerRecordNewStat(gUnknown_03000748, r4); - return TRUE; - } - return FALSE; -} - -bool8 ScrSpecial_HasStorytellerAlreadyRecorded(void) -{ - struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; - - if (storyteller->alreadyRecorded == FALSE) - return FALSE; - else - return TRUE; -} - -bool8 ScrSpecial_StorytellerInitializeRandomStat(void) -{ - return StorytellerInitializeRandomStat(); -} diff --git a/src/new_game.c b/src/new_game.c index 1ef19bd00..46df14acd 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -11,7 +11,7 @@ #include "item_menu.h" #include "lottery_corner.h" #include "mail_data.h" -#include "mauville_old_man.h" +#include "mauville_man.h" #include "play_time.h" #include "player_pc.h" #include "pokeblock.h" diff --git a/src/record_mixing.c b/src/record_mixing.c index e5f892d20..30bcb29d1 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -10,7 +10,7 @@ #include "items.h" #include "load_save.h" #include "link.h" -#include "mauville_old_man.h" +#include "mauville_man.h" #include "menu.h" #include "mystery_event_script.h" #include "rng.h" diff --git a/src/strings.c b/src/strings.c index 219c5bec1..6c8dce9d6 100644 --- a/src/strings.c +++ b/src/strings.c @@ -861,7 +861,7 @@ const u8 gOtherText_AtBattleStart[] = _("At the battle’s start."); const u8 gOtherText_UponWinningBattle[] = _("Upon winning a battle."); const u8 gOtherText_UponLosingBattle[] = _("Upon losing a battle."); -// mauville_old_man? +// mauville_man? const u8 gOtherText_TheBardsSong[] = _("The BARD’s Song"); const u8 gOtherText_WhatsHipHappening[] = _("What’s hip and happening?"); const u8 gOtherText_Interview[] = _("Interview"); @@ -1781,7 +1781,7 @@ const u8 gOtherText_AtBattleStart[] = _("Zum Kampfbeginn"); const u8 gOtherText_UponWinningBattle[] = _("Über den Sieg"); const u8 gOtherText_UponLosingBattle[] = _("Über die Niederlage"); -// mauville_old_man? +// mauville_man? const u8 gOtherText_TheBardsSong[] = _("Das BARDEN-Lied"); const u8 gOtherText_WhatsHipHappening[] = _("Was ist hip? Was ist top?"); const u8 gOtherText_Interview[] = _("Interview"); diff --git a/src/trader.c b/src/trader.c index 4274d38de..61f48fad8 100644 --- a/src/trader.c +++ b/src/trader.c @@ -3,7 +3,7 @@ #include "decoration_inventory.h" #include "event_data.h" #include "main.h" -#include "mauville_old_man.h" +#include "mauville_man.h" #include "menu.h" #include "menu_helpers.h" #include "script.h" -- cgit v1.2.3