From 21c3e7e8e5555af964f7419aa9213446eaa421d6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 2 May 2018 11:31:58 -0400 Subject: [PATCH 01/10] through SetMauvilleOldMan --- .../inspectionProfiles/profiles_settings.xml | 7 + asm/mauville_old_man.s | 138 ------------------ data/mauville_old_man.s | 3 - include/global.h | 60 +++++--- include/mauville_old_man.h | 9 ++ ld_script.txt | 2 + src/mauville_old_man.c | 84 +++++++++++ 7 files changed, 144 insertions(+), 159 deletions(-) create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 src/mauville_old_man.c diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 000000000..dd4c951ef --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s index af4764d76..b4302e5b1 100644 --- a/asm/mauville_old_man.s +++ b/asm/mauville_old_man.s @@ -5,144 +5,6 @@ .text - thumb_func_start sub_81200A0 -sub_81200A0: @ 81200A0 - push {r4,lr} - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldr r1, =0x00002e28 - adds r0, r2, r1 - movs r1, 0 - strb r1, [r0] - ldr r3, =0x00002e51 - adds r0, r2, r3 - strb r1, [r0] - ldr r0, =gGameLanguage - ldrb r1, [r0] - adds r3, 0x1 - adds r0, r2, r3 - strb r1, [r0] - movs r3, 0 - ldr r0, =0x00002e2a - adds r2, r0 - ldr r4, =gUnknown_0859EFE4 -_081200C6: - lsls r0, r3, 1 - adds r1, r2, r0 - adds r0, r4 - ldrh r0, [r0] - strh r0, [r1] - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x5 - bls _081200C6 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81200A0 - - thumb_func_start sub_81200F8 -sub_81200F8: @ 81200F8 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, =0x00002e28 - adds r1, r0 - movs r2, 0 - movs r0, 0x1 - strb r0, [r1] - strb r2, [r1, 0x1] - ldr r0, =gGameLanguage - ldrb r0, [r0] - strb r0, [r1, 0x2] - bx lr - .pool - thumb_func_end sub_81200F8 - - thumb_func_start sub_812011C -sub_812011C: @ 812011C - push {lr} - bl sub_8120E08 - pop {r0} - bx r0 - thumb_func_end sub_812011C - - thumb_func_start sub_8120128 -sub_8120128: @ 8120128 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, =0x00002e28 - adds r2, r1, r0 - movs r3, 0 - movs r0, 0x4 - strb r0, [r2] - strb r3, [r2, 0x1] - ldr r0, =gGameLanguage - ldrb r0, [r0] - ldr r2, =0x00002e48 - adds r1, r2 - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_8120128 - - thumb_func_start sub_8120154 -sub_8120154: @ 8120154 - push {lr} - bl sub_81339F8 - pop {r0} - bx r0 - thumb_func_end sub_8120154 - - thumb_func_start SetMauvilleOldMan -SetMauvilleOldMan: @ 8120160 - push {lr} - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r1, [r0, 0xB] - lsls r1, 8 - ldrb r0, [r0, 0xA] - orrs r0, r1 - movs r1, 0xA - bl __umodsi3 - lsls r0, 16 - lsrs r0, 17 - cmp r0, 0x4 - bhi _081201C0 - lsls r0, 2 - ldr r1, =_08120190 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08120190: - .4byte _081201A4 - .4byte _081201AA - .4byte _081201B0 - .4byte _081201B6 - .4byte _081201BC -_081201A4: - bl sub_81200A0 - b _081201C0 -_081201AA: - bl sub_81200F8 - b _081201C0 -_081201B0: - bl sub_8120154 - b _081201C0 -_081201B6: - bl sub_812011C - b _081201C0 -_081201BC: - bl sub_8120128 -_081201C0: - bl sub_8120B5C - pop {r0} - bx r0 - thumb_func_end SetMauvilleOldMan - thumb_func_start sub_81201C8 sub_81201C8: @ 81201C8 ldr r0, =gSaveBlock1Ptr diff --git a/data/mauville_old_man.s b/data/mauville_old_man.s index c1b4dd1be..0eee9698a 100644 --- a/data/mauville_old_man.s +++ b/data/mauville_old_man.s @@ -4,9 +4,6 @@ .section .rodata .align 2, 0 -gUnknown_0859EFE4:: @ 859EFE4 - .2byte 0x2811, 0x1029, 0x1018, 0xE0D, 0x1A1A, 0x1A1D - gUnknown_0859EFF0:: @ 859EFF0 .4byte gText_SoPretty .4byte gText_SoDarling diff --git a/include/global.h b/include/global.h index f88203c90..d3506d345 100644 --- a/include/global.h +++ b/include/global.h @@ -428,28 +428,50 @@ struct MailStruct /*0x20*/ u16 itemId; }; -struct UnkMauvilleOldManStruct +struct MauvilleManCommon { - u8 unk_2D94; - u8 unk_2D95; - /*0x2D96*/ u16 mauvilleOldMan_ecArray[6]; - /*0x2DA2*/ u16 mauvilleOldMan_ecArray2[6]; - /*0x2DAE*/ u8 playerName[8]; - /*0x2DB6*/ u8 filler_2DB6[0x3]; - /*0x2DB9*/ u8 playerTrainerId[4]; - u8 unk_2DBD; + u8 id; +}; + +struct MauvilleManBard +{ + /*0x00*/ u8 id; + /*0x02*/ u16 songLyrics[6]; + /*0x0E*/ u16 temporaryLyrics[6]; + /*0x1A*/ u8 playerName[8]; + /*0x22*/ u8 filler_2DB6[0x3]; + /*0x25*/ u8 playerTrainerId[4]; + /*0x29*/ bool8 hasChangedSong; + /*0x2A*/ u8 language; }; /*size = 0x2C*/ -struct UnkMauvilleOldManStruct2 +struct MauvilleManStoryteller { - u8 filler0; - u8 unk1; - u8 unk2; - u16 mauvilleOldMan_ecArray[10]; - u8 mauvilleOldMan_ecArray2[12]; - u8 fillerF[0x2]; + u8 id; + bool8 alreadyRecorded; + u8 filler2[2]; + u8 gameStatIDs[4]; + u8 trainerNames[4][7]; + u8 statValues[4][4]; +}; + +struct MauvilleManGiddy +{ + /*0x00*/ u8 id; + /*0x01*/ u8 taleCounter; + /*0x02*/ u8 questionNum; + /*0x04*/ u16 randomWords[10]; + /*0x18*/ u8 questionList[8]; + /*0x20*/ u8 language; }; /*size = 0x2C*/ +struct MauvilleManHipster +{ + u8 id; + bool8 alreadySpoken; + u8 language; +}; + struct MauvilleOldManTrader { u8 unk0; @@ -460,8 +482,10 @@ struct MauvilleOldManTrader typedef union OldMan { - struct UnkMauvilleOldManStruct oldMan1; - struct UnkMauvilleOldManStruct2 oldMan2; + struct MauvilleManCommon common; + struct MauvilleManBard bard; + struct MauvilleManGiddy giddy; + struct MauvilleManHipster hipster; struct MauvilleOldManTrader trader; u8 filler[0x40]; } OldMan; diff --git a/include/mauville_old_man.h b/include/mauville_old_man.h index aefc76083..0fc9fd6eb 100644 --- a/include/mauville_old_man.h +++ b/include/mauville_old_man.h @@ -2,6 +2,15 @@ #ifndef GUARD_MAUVILLE_OLD_MAN_H #define GUARD_MAUVILLE_OLD_MAN_H +enum MauvilleOldManType +{ + MAUVILLE_MAN_BARD, + MAUVILLE_MAN_HIPSTER, + MAUVILLE_MAN_TRADER, + MAUVILLE_MAN_STORYTELLER, + MAUVILLE_MAN_GIDDY +}; + void SetMauvilleOldMan(void); u8 sub_81201C8(void); diff --git a/ld_script.txt b/ld_script.txt index 2832bcada..c975586a6 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -162,6 +162,7 @@ SECTIONS { src/bike.o(.text); asm/easy_chat.o(.text); src/mon_markings.o(.text); + src/mauville_old_man.o(.text); asm/mauville_old_man.o(.text); src/mail.o(.text); asm/menu_helpers.o(.text); @@ -456,6 +457,7 @@ SECTIONS { src/bike.o(.rodata); data/easy_chat.o(.rodata); src/mon_markings.o(.rodata); + src/mauville_old_man.o(.rodata); data/mauville_old_man.o(.rodata); src/mail.o(.rodata); data/menu_helpers.o(.rodata); diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c new file mode 100644 index 000000000..592b5c4ce --- /dev/null +++ b/src/mauville_old_man.c @@ -0,0 +1,84 @@ +#include "global.h" +#include "main.h" +#include "constants/easy_chat.h" +#include "mauville_old_man.h" + +void sub_8120E08(void); // StorytellerSetup +void sub_81339F8(void); // TraderSetup +void sub_8120B5C(void); + +static const u16 sDefaultBardSongLyrics[6] = { + EC_WORD_SHAKE, + EC_WORD_IT, + EC_WORD_DO, + EC_WORD_THE, + EC_WORD_DIET, + EC_WORD_DANCE +}; + +static void SetupBard(void) +{ + u16 i; + struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; + + bard->id = MAUVILLE_MAN_BARD; + bard->hasChangedSong = FALSE; + bard->language = gGameLanguage; + for (i = 0; i < 6; i++) + bard->songLyrics[i] = sDefaultBardSongLyrics[i]; +} + +static void SetupHipster(void) +{ + struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; + + hipster->id = MAUVILLE_MAN_HIPSTER; + hipster->alreadySpoken = FALSE; + hipster->language = gGameLanguage; +} + +static void SetupStoryteller(void) +{ + sub_8120E08(); +} + +static void SetupGiddy(void) +{ + struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy; + + giddy->id = MAUVILLE_MAN_GIDDY; + giddy->taleCounter = 0; + giddy->language = gGameLanguage; +} + +static void SetupTrader(void) +{ + sub_81339F8(); +} + +void SetMauvilleOldMan(void) +{ + u16 trainerId = (gSaveBlock2Ptr->playerTrainerId[1] << 8) | gSaveBlock2Ptr->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_8120B5C(); +} From cae0fb8ec277adc4a7a6a27d1bbfa5aff8c49239 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 2 May 2018 16:57:34 -0400 Subject: [PATCH 02/10] through sub_81203FC --- asm/mauville_old_man.s | 369 ---------------------------------------- data/event_scripts.s | 4 +- data/mauville_old_man.s | 20 --- include/easy_chat.h | 30 +--- include/event_scripts.h | 20 +++ src/bard_music.c | 1 + src/mail.c | 2 +- src/mauville_old_man.c | 207 ++++++++++++++++++++++ 8 files changed, 233 insertions(+), 420 deletions(-) diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s index b4302e5b1..b8d7f5c72 100644 --- a/asm/mauville_old_man.s +++ b/asm/mauville_old_man.s @@ -5,375 +5,6 @@ .text - thumb_func_start sub_81201C8 -sub_81201C8: @ 81201C8 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002e28 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_81201C8 - - thumb_func_start sub_81201DC -sub_81201DC: @ 81201DC - push {r4,lr} - ldr r4, =gSpecialVar_Result - bl sub_81201C8 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81201DC - - thumb_func_start sub_81201F4 -sub_81201F4: @ 81201F4 - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00002e51 - adds r0, r2 - ldrb r0, [r0] - strh r0, [r1] - bx lr - .pool - thumb_func_end sub_81201F4 - - thumb_func_start sub_8120210 -sub_8120210: @ 8120210 - push {r4-r6,lr} - ldr r0, =gSaveBlock1Ptr - ldr r4, [r0] - ldr r0, =0x00002e28 - adds r6, r4, r0 - ldr r1, =0x00002e42 - adds r0, r4, r1 - ldr r5, =gSaveBlock2Ptr - ldr r1, [r5] - bl StringCopy - movs r2, 0 - ldr r0, =0x00002e4d - adds r4, r0 -_0812022C: - adds r1, r4, r2 - ldr r0, [r5] - adds r0, 0xA - adds r0, r2 - ldrb r0, [r0] - strb r0, [r1] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0x3 - bls _0812022C - movs r2, 0 - adds r5, r6, 0 - adds r5, 0x29 - adds r3, r6, 0x2 - adds r4, r6, 0 - adds r4, 0xE -_0812024E: - lsls r0, r2, 1 - adds r1, r3, r0 - adds r0, r4, r0 - ldrh r0, [r0] - strh r0, [r1] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0x5 - bls _0812024E - movs r0, 0x1 - strb r0, [r5] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120210 - - thumb_func_start sub_8120280 -sub_8120280: @ 8120280 - push {r4-r7,lr} - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - ldr r2, =0x00002e36 - adds r5, r1, r2 - cmp r0, 0 - bne _08120296 - ldr r0, =0x00002e2a - adds r5, r1, r0 -_08120296: - ldr r2, =gStringVar4 - adds r4, r2, 0 - movs r6, 0 -_0812029C: - ldrh r1, [r5] - adds r5, 0x2 - adds r0, r2, 0 - bl CopyEasyChatWord - adds r2, r0, 0 - adds r7, r6, 0x1 - cmp r2, r4 - beq _081202BE - movs r1, 0x37 -_081202B0: - ldrb r0, [r4] - cmp r0, 0 - bne _081202B8 - strb r1, [r4] -_081202B8: - adds r4, 0x1 - cmp r2, r4 - bne _081202B0 -_081202BE: - adds r4, 0x1 - movs r0, 0 - strb r0, [r2] - adds r2, 0x1 - ldrh r1, [r5] - adds r5, 0x2 - adds r0, r2, 0 - bl CopyEasyChatWord - adds r2, r0, 0 - cmp r2, r4 - beq _081202E6 - movs r1, 0x37 -_081202D8: - ldrb r0, [r4] - cmp r0, 0 - bne _081202E0 - strb r1, [r4] -_081202E0: - adds r4, 0x1 - cmp r2, r4 - bne _081202D8 -_081202E6: - adds r4, 0x1 - movs r0, 0xFE - strb r0, [r2] - adds r2, 0x1 - ldrh r1, [r5] - adds r5, 0x2 - adds r0, r2, 0 - bl CopyEasyChatWord - adds r2, r0, 0 - cmp r2, r4 - beq _0812030E - movs r1, 0x37 -_08120300: - ldrb r0, [r4] - cmp r0, 0 - bne _08120308 - strb r1, [r4] -_08120308: - adds r4, 0x1 - cmp r2, r4 - bne _08120300 -_0812030E: - cmp r6, 0 - bne _0812031E - movs r0, 0xFC - strb r0, [r2] - adds r2, 0x1 - movs r0, 0xF - strb r0, [r2] - adds r2, 0x1 -_0812031E: - lsls r0, r7, 16 - lsrs r6, r0, 16 - cmp r6, 0x1 - bls _0812029C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120280 - - thumb_func_start sub_8120340 -sub_8120340: @ 8120340 - push {lr} - ldr r0, =gSpecialVar_0x8004 - ldrb r0, [r0] - bl sub_81206C0 - bl ScriptContext1_Stop - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120340 - - thumb_func_start sub_8120358 -sub_8120358: @ 8120358 - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00002e28 - adds r0, r2 - ldrb r0, [r0, 0x1] - strh r0, [r1] - bx lr - .pool - thumb_func_end sub_8120358 - - thumb_func_start sub_8120374 -sub_8120374: @ 8120374 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002e28 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0, 0x1] - bx lr - .pool - thumb_func_end sub_8120374 - - thumb_func_start sub_812038C -sub_812038C: @ 812038C - push {lr} - bl sub_811F01C - lsls r0, 16 - lsrs r1, r0, 16 - ldr r0, =0x0000ffff - cmp r1, r0 - bne _081203AC - ldr r1, =gSpecialVar_Result - movs r0, 0 - b _081203B6 - .pool -_081203AC: - ldr r0, =gStringVar1 - bl CopyEasyChatWord - ldr r1, =gSpecialVar_Result - movs r0, 0x1 -_081203B6: - strh r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_812038C - - thumb_func_start sub_81203C4 -sub_81203C4: @ 81203C4 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002e28 - adds r2, r0, r1 - ldrb r0, [r2, 0x1] - cmp r0, 0xA - bne _081203EC - ldr r1, =gSpecialVar_Result - movs r0, 0 - strh r0, [r1] - strb r0, [r2, 0x1] - b _081203F2 - .pool -_081203EC: - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - strh r0, [r1] -_081203F2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81203C4 - - thumb_func_start sub_81203FC -sub_81203FC: @ 81203FC - push {r4-r6,lr} - ldr r0, =gSaveBlock1Ptr - ldr r4, [r0] - ldr r0, =0x00002e28 - adds r5, r4, r0 - ldrb r0, [r5, 0x1] - cmp r0, 0 - bne _08120410 - bl sub_81204DC -_08120410: - ldrb r0, [r5, 0x1] - lsls r0, 1 - ldr r1, =0x00002e2c - adds r6, r4, r1 - adds r0, r6, r0 - ldrh r1, [r0] - ldr r0, =0x0000ffff - cmp r1, r0 - beq _08120480 - bl Random - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - movs r0, 0x7 - ands r4, r0 - ldr r0, =gStringVar4 - ldrb r1, [r5, 0x1] - lsls r1, 1 - adds r1, r6, r1 - ldrh r1, [r1] - bl CopyEasyChatWord - adds r2, r0, 0 - ldr r1, =gUnknown_082942FD - bl StringCopy - adds r2, r0, 0 - ldr r0, =gUnknown_0859EFF0 - lsls r4, 2 - adds r4, r0 - ldr r1, [r4] - adds r0, r2, 0 - bl StringCopy - adds r2, r0, 0 - ldr r1, =gUnknown_08294301 - bl StringCopy - b _081204A2 - .pool -_08120480: - ldr r0, =gStringVar4 - ldr r3, =gUnknown_0859F010 - ldrb r2, [r5, 0x2] - adds r1, r2, 0x1 - strb r1, [r5, 0x2] - lsls r2, 24 - lsrs r2, 24 - movs r6, 0xB9 - lsls r6, 6 - adds r1, r4, r6 - adds r1, r2 - ldrb r1, [r1] - lsls r1, 2 - adds r1, r3 - ldr r1, [r1] - bl StringCopy -_081204A2: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xA - bl __umodsi3 - lsls r0, 16 - cmp r0, 0 - bne _081204C4 - movs r0, 0xA - b _081204C8 - .pool -_081204C4: - ldrb r0, [r5, 0x1] - adds r0, 0x1 -_081204C8: - strb r0, [r5, 0x1] - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - strh r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81203FC - thumb_func_start sub_81204DC sub_81204DC: @ 81204DC push {r4-r7,lr} diff --git a/data/event_scripts.s b/data/event_scripts.s index 25b0c7b52..c2906e649 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -5887,10 +5887,10 @@ gText_SoAmusing:: @ 82942E3 gText_SoMagical:: @ 82942F0 .string " so magical!$" -gUnknown_082942FD:: @ 82942FD +gOtherText_Is:: @ 82942FD .string " is$" -gUnknown_08294301:: @ 8294301 +gOtherText_DontYouAgree:: @ 8294301 .string "\n" .string "Don’t you agree?$" diff --git a/data/mauville_old_man.s b/data/mauville_old_man.s index 0eee9698a..ae39505ef 100644 --- a/data/mauville_old_man.s +++ b/data/mauville_old_man.s @@ -4,26 +4,6 @@ .section .rodata .align 2, 0 -gUnknown_0859EFF0:: @ 859EFF0 - .4byte gText_SoPretty - .4byte gText_SoDarling - .4byte gText_SoRelaxed - .4byte gText_SoSunny - .4byte gText_SoDesirable - .4byte gText_SoExciting - .4byte gText_SoAmusing - .4byte gText_SoMagical - -gUnknown_0859F010:: @ 859F010 - .4byte gUnknown_08294313 - .4byte gUnknown_08294359 - .4byte gUnknown_08294398 - .4byte gUnknown_082943DA - .4byte gUnknown_0829441C - .4byte gUnknown_08294460 - .4byte gUnknown_082944A0 - .4byte gUnknown_082944D5 - gUnknown_0859F030:: @ 859F030 .4byte 0, 12, 13, 18, 19, 21 diff --git a/include/easy_chat.h b/include/easy_chat.h index e5fdc8bea..ad586d697 100644 --- a/include/easy_chat.h +++ b/include/easy_chat.h @@ -1,40 +1,14 @@ #ifndef GUARD_EASYCHAT_H #define GUARD_EASYCHAT_H -// Taken from Pokeruby, check if it's correct -enum -{ - EC_GROUP_POKEMON, - EC_GROUP_TRAINER, - EC_GROUP_STATUS, - EC_GROUP_BATTLE, - EC_GROUP_GREETINGS, - EC_GROUP_PEOPLE, - EC_GROUP_VOICES, - EC_GROUP_SPEECH, - EC_GROUP_ENDINGS, - EC_GROUP_FEELINGS, - EC_GROUP_CONDITIONS, - EC_GROUP_ACTIONS, - EC_GROUP_LIFESTYLE, - EC_GROUP_HOBBIES, - EC_GROUP_TIME, - EC_GROUP_MISC, - EC_GROUP_ADJECTIVES, - EC_GROUP_EVENTS, - EC_GROUP_MOVE_1, - EC_GROUP_MOVE_2, - EC_GROUP_TRENDY_SAYING, - EC_GROUP_POKEMON_2, -}; - void InitEasyChatPhrases(void); void easy_chat_input_maybe(void); -void CopyEasyChatWord(u8 *dest, u16 word); +u8 * CopyEasyChatWord(u8 *dest, u16 word); bool32 sub_811F8D8(u16 word); void InitializeEasyChatWordArray(u16 *words, u16 length); void ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 length1, u16 length2); bool8 ECWord_CheckIfOutsideOfValidRange(u16 word); u16 sub_811EE38(u16 group); +u16 sub_811F01C(void); #endif // GUARD_EASYCHAT_H diff --git a/include/event_scripts.h b/include/event_scripts.h index eb523a487..a964b1a67 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -394,4 +394,24 @@ extern const u8 Route111_EventScript_2907F0[]; extern const u8 LittlerootTown_BrendansHouse_2F_EventScript_1F863F[]; extern const u8 LittlerootTown_MaysHouse_2F_EventScript_1F958F[]; +//mauville_old_man +extern const u8 gOtherText_Is[]; +extern const u8 gOtherText_DontYouAgree[]; +extern const u8 gText_SoPretty[]; +extern const u8 gText_SoDarling[]; +extern const u8 gText_SoRelaxed[]; +extern const u8 gText_SoSunny[]; +extern const u8 gText_SoDesirable[]; +extern const u8 gText_SoExciting[]; +extern const u8 gText_SoAmusing[]; +extern const u8 gText_SoMagical[]; +extern const u8 gUnknown_08294313[]; +extern const u8 gUnknown_08294359[]; +extern const u8 gUnknown_08294398[]; +extern const u8 gUnknown_082943DA[]; +extern const u8 gUnknown_0829441C[]; +extern const u8 gUnknown_08294460[]; +extern const u8 gUnknown_082944A0[]; +extern const u8 gUnknown_082944D5[]; + #endif //GUARD_EVENT_SCRIPTS_H diff --git a/src/bard_music.c b/src/bard_music.c index 6fb1496e5..6c2578071 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -2,6 +2,7 @@ // Includes #include "global.h" #include "bard_music.h" +#include "constants/easy_chat.h" #include "easy_chat.h" #include "data/bard_music/bard_sounds.h" diff --git a/src/mail.c b/src/mail.c index 85ba86974..8fddc7045 100644 --- a/src/mail.c +++ b/src/mail.c @@ -101,7 +101,7 @@ struct MailRead /*0x021c*/ u8 monIconSprite; /*0x021d*/ u8 language; /*0x021e*/ bool8 playerIsSender; - /*0x0220*/ void (*parserSingle)(u8 *dest, u16 word); + /*0x0220*/ u8 * (*parserSingle)(u8 *dest, u16 word); /*0x0224*/ void (*parserMultiple)(u8 *dest, const u16 *src, u16 length1, u16 length2); /*0x0228*/ const struct MailLayout *layout; /*0x022c*/ u8 bg1TilemapBuffer[0x1000]; diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 592b5c4ce..f39f80ab7 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -2,10 +2,21 @@ #include "main.h" #include "constants/easy_chat.h" #include "mauville_old_man.h" +#include "event_data.h" +#include "string_util.h" +#include "text.h" +#include "easy_chat.h" +#include "script.h" +#include "random.h" +#include "event_scripts.h" + +#define CHAR_SONG_WORD_SEPARATOR 0x37 void sub_8120E08(void); // StorytellerSetup void sub_81339F8(void); // TraderSetup void sub_8120B5C(void); +void sub_81206C0(u8 a0); // StartBardSong +void sub_81204DC(void); static const u16 sDefaultBardSongLyrics[6] = { EC_WORD_SHAKE, @@ -16,6 +27,28 @@ static const u16 sDefaultBardSongLyrics[6] = { EC_WORD_DANCE }; +static const u8 * const sGiddyAdjectives[] = { + gText_SoPretty, + gText_SoDarling, + gText_SoRelaxed, + gText_SoSunny, + gText_SoDesirable, + gText_SoExciting, + gText_SoAmusing, + gText_SoMagical +}; + +static const u8 * const sGiddyQuestions[] = { + gUnknown_08294313, + gUnknown_08294359, + gUnknown_08294398, + gUnknown_082943DA, + gUnknown_0829441C, + gUnknown_08294460, + gUnknown_082944A0, + gUnknown_082944D5 +}; + static void SetupBard(void) { u16 i; @@ -82,3 +115,177 @@ void SetMauvilleOldMan(void) } sub_8120B5C(); } + +u8 sub_81201C8(void) // GetCurrentMauvilleOldMan +{ + struct MauvilleManCommon *common = &gSaveBlock1Ptr->oldMan.common; + + return common->id; +} + +void sub_81201DC(void) // ScrSpecial_GetCurrentMauvilleMan +{ + gSpecialVar_Result = sub_81201C8(); +} + +void sub_81201F4(void) // ScrSpecial_HasBardSongBeenChanged +{ + u16 *scriptResult = &gSpecialVar_Result; // why?? + struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; + + *scriptResult = bard->hasChangedSong; +} + +void sub_8120210(void) // ScrSpecial_SaveBardSongLyrics +{ + u16 i; + struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; + + StringCopy(bard->playerName, gSaveBlock2Ptr->playerName); + + for (i = 0; i < 4; i++) + bard->playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i]; + + for (i = 0; i < 6; i++) + bard->songLyrics[i] = bard->temporaryLyrics[i]; + + bard->hasChangedSong = TRUE; +} + +// Copies lyrics into gStringVar4 +void sub_8120280(void) +{ + struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; + u16 specialVar = gSpecialVar_0x8004; // It's a bit odd to use this temp variable, but it seems needed to match. + u16 *lyrics; + 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 = CopyEasyChatWord(wordEnd, *(lyrics++)); + while (wordEnd != str) + { + if (*str == CHAR_SPACE) + *str = CHAR_SONG_WORD_SEPARATOR; + str++; + } + + str++; + *(wordEnd++) = CHAR_SPACE; + + wordEnd = CopyEasyChatWord(wordEnd, *(lyrics++)); + while (wordEnd != str) + { + if (*str == CHAR_SPACE) + *str = CHAR_SONG_WORD_SEPARATOR; + str++; + } + + str++; + *(wordEnd++) = CHAR_NEWLINE; + + wordEnd = CopyEasyChatWord(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 sub_8120340(void) // ScrSpecial_PlayBardSong +{ + sub_81206C0(gSpecialVar_0x8004); + ScriptContext1_Stop(); +} + +void sub_8120358(void) // ScrSpecial_GetHipsterSpokenFlag +{ + u16 *scriptResult = &gSpecialVar_Result; // again?? + struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; + + *scriptResult = hipster->alreadySpoken; +} + +void sub_8120374(void) // ScrSpecial_SetHipsterSpokenFlag +{ + struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; + + hipster->alreadySpoken = TRUE; +} + +void sub_812038C(void) // ScrSpecial_HipsterTeachWord +{ + u16 var = sub_811F01C(); + + if (var == 0xFFFF) + { + gSpecialVar_Result = FALSE; + } + else + { + CopyEasyChatWord(gStringVar1, var); + gSpecialVar_Result = TRUE; + } +} + +void sub_81203C4(void) // ScrSpecial_GiddyShouldTellAnotherTale +{ + struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy; + + if (giddy->taleCounter == 10) + { + gSpecialVar_Result = FALSE; + giddy->taleCounter = 0; + } + else + { + gSpecialVar_Result = TRUE; + } +} + +void sub_81203FC(void) // ScrSpecial_GenerateGiddyLine +{ + struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy; + + if (giddy->taleCounter == 0) + sub_81204DC(); + + if (giddy->randomWords[giddy->taleCounter] != 0xFFFF) // is not the last element of the array? + { + u8 *stringPtr; + u32 adjective = Random(); + + adjective %= 8; + stringPtr = CopyEasyChatWord(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++; + + gSpecialVar_Result = TRUE; +} From 0bc7759f9b2ee1e8b442d2b7cc9da44bb146e765 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 3 May 2018 13:40:08 -0400 Subject: [PATCH 03/10] through sub_8120748 --- asm/easy_chat.s | 8 +- asm/mauville_old_man.s | 559 ---------------------------------------- data/mauville_old_man.s | 3 - include/bard_music.h | 4 +- include/easy_chat.h | 2 + src/mauville_old_man.c | 256 +++++++++++++++++- 6 files changed, 261 insertions(+), 571 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 0cbe1f1ae..7f2a7ca88 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -9243,8 +9243,8 @@ _0811EA68: bx r1 thumb_func_end sub_811EA28 - thumb_func_start start_menu_is_selected_item_valid -start_menu_is_selected_item_valid: @ 811EA6C + thumb_func_start EasyChat_GetNumWordsInGroup +EasyChat_GetNumWordsInGroup: @ 811EA6C push {r4,lr} lsls r0, 24 lsrs r0, 24 @@ -9273,7 +9273,7 @@ _0811EA9A: pop {r1} bx r1 .pool - thumb_func_end start_menu_is_selected_item_valid + thumb_func_end EasyChat_GetNumWordsInGroup thumb_func_start sub_811EAA4 sub_811EAA4: @ 811EAA4 @@ -10145,7 +10145,7 @@ sub_811F0F8: @ 811F0F8 sub_811F108: @ 811F108 push {r4-r7,lr} movs r0, 0 - bl start_menu_is_selected_item_valid + bl EasyChat_GetNumWordsInGroup lsls r0, 16 lsrs r4, r0, 16 cmp r4, 0 diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s index b8d7f5c72..4ab632aff 100644 --- a/asm/mauville_old_man.s +++ b/asm/mauville_old_man.s @@ -5,565 +5,6 @@ .text - thumb_func_start sub_81204DC -sub_81204DC: @ 81204DC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - ldr r0, =gSaveBlock1Ptr - ldr r4, [r0] - ldr r0, =0x00002e28 - adds r0, r4, r0 - str r0, [sp, 0x18] - ldr r1, =gUnknown_0859F030 - mov r0, sp - movs r2, 0x18 - bl memcpy - movs r5, 0 - movs r1, 0x2 - add r1, sp - mov r8, r1 - movs r2, 0xB9 - lsls r2, 6 - adds r3, r4, r2 - adds r1, r3, 0 -_0812050C: - adds r0, r3, r5 - strb r5, [r0] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x7 - bls _0812050C - movs r5, 0 - ldr r3, [sp, 0x18] - adds r3, 0x4 - mov r9, r3 - adds r6, r1, 0 -_08120524: - bl Random - lsls r0, 16 - lsrs r0, 16 - adds r4, r5, 0x1 - adds r1, r4, 0 - bl __modsi3 - lsls r0, 16 - lsrs r1, r0, 16 - adds r2, r6, r5 - ldrb r7, [r2] - adds r1, r6, r1 - ldrb r0, [r1] - strb r0, [r2] - strb r7, [r1] - lsls r4, 16 - lsrs r5, r4, 16 - cmp r5, 0x7 - bls _08120524 - movs r0, 0 - mov r10, r0 - movs r5, 0 -_08120552: - lsls r4, r5, 2 - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - bl start_menu_is_selected_item_valid - add r4, r8 - strh r0, [r4] - add r0, r10 - lsls r0, 16 - lsrs r0, 16 - mov r10, r0 - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x5 - bls _08120552 - movs r0, 0 - ldr r2, [sp, 0x18] - strb r0, [r2, 0x2] - movs r7, 0 - movs r5, 0 -_0812057E: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xA - bl __umodsi3 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x2 - bhi _081205BC - cmp r7, 0x7 - bhi _081205BC - lsls r0, r5, 1 - add r0, r9 - ldr r1, =0x0000ffff - strh r1, [r0] - adds r0, r7, 0x1 - lsls r0, 16 - lsrs r7, r0, 16 - adds r4, r5, 0x1 - b _0812060E - .pool -_081205BC: - bl Random - lsls r0, 16 - lsrs r0, 16 - mov r1, r10 - bl __umodsi3 - lsls r0, 16 - lsrs r2, r0, 16 - movs r1, 0 - adds r4, r5, 0x1 - lsls r6, r5, 1 - cmp r5, 0x5 - bhi _081205F8 - mov r3, r8 - ldrh r0, [r3] - b _081205EE -_081205DE: - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r5, 0x5 - bhi _081205F8 - lsls r0, r1, 2 - adds r0, r3, r0 - ldrh r0, [r0] -_081205EE: - subs r0, r2, r0 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r0, 0 - bgt _081205DE -_081205F8: - cmp r1, 0x6 - bne _081205FE - movs r1, 0 -_081205FE: - lsls r0, r1, 2 - add r0, sp - ldrh r0, [r0] - bl sub_811EE90 - mov r2, r9 - adds r1, r2, r6 - strh r0, [r1] -_0812060E: - lsls r0, r4, 16 - lsrs r5, r0, 16 - cmp r5, 0x9 - bls _0812057E - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81204DC - - thumb_func_start sub_8120628 -sub_8120628: @ 8120628 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002e51 - adds r0, r1 - movs r1, 0 - strb r1, [r0] - bx lr - .pool - thumb_func_end sub_8120628 - - thumb_func_start sub_8120640 -sub_8120640: @ 8120640 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002e28 - adds r0, r1 - movs r1, 0 - strb r1, [r0, 0x1] - bx lr - .pool - thumb_func_end sub_8120640 - - thumb_func_start sub_8120658 -sub_8120658: @ 8120658 - push {lr} - bl sub_8133A60 - pop {r0} - bx r0 - thumb_func_end sub_8120658 - - thumb_func_start sub_8120664 -sub_8120664: @ 8120664 - push {lr} - bl sub_8120E50 - pop {r0} - bx r0 - thumb_func_end sub_8120664 - - thumb_func_start sub_8120670 -sub_8120670: @ 8120670 - push {lr} - bl sub_81201C8 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bhi _081206B6 - lsls r0, 2 - ldr r1, =_0812068C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0812068C: - .4byte _081206A0 - .4byte _081206A6 - .4byte _081206B2 - .4byte _081206AC - .4byte _081206B6 -_081206A0: - bl sub_8120628 - b _081206B6 -_081206A6: - bl sub_8120640 - b _081206B6 -_081206AC: - bl sub_8120664 - b _081206B6 -_081206B2: - bl sub_8120658 -_081206B6: - bl sub_8120B5C - pop {r0} - bx r0 - thumb_func_end sub_8120670 - - thumb_func_start sub_81206C0 -sub_81206C0: @ 81206C0 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =sub_8120944 - movs r1, 0x50 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - strh r4, [r1, 0x12] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81206C0 - - thumb_func_start sub_81206F0 -sub_81206F0: @ 81206F0 - ldr r1, =gUnknown_03002F84 - movs r0, 0 - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_81206F0 - - thumb_func_start sub_81206FC -sub_81206FC: @ 81206FC - ldr r1, =gUnknown_03002F84 - movs r0, 0x1 - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_81206FC - - thumb_func_start sub_8120708 -sub_8120708: @ 8120708 - push {r4,r5,lr} - sub sp, 0xC - adds r5, r0, 0 - movs r0, 0 - movs r1, 0 - bl NewMenuHelpers_DrawDialogueFrame - movs r4, 0x1 - str r4, [sp] - str r4, [sp, 0x4] - ldr r0, =sub_81206FC - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - adds r2, r5, 0 - movs r3, 0 - bl PrintTextOnWindow - ldr r0, =gUnknown_03002F84 - strb r4, [r0] - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120708 - - thumb_func_start sub_8120748 -sub_8120748: @ 8120748 - push {r4-r6,lr} - adds r6, r1, 0 - movs r1, 0x8 - ldrsh r0, [r0, r1] - cmp r0, 0x5 - bls _08120756 - b _08120938 -_08120756: - lsls r0, 2 - ldr r1, =_08120764 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08120764: - .4byte _0812077C - .4byte _08120938 - .4byte _081207BC - .4byte _081207F8 - .4byte _081207F8 - .4byte _08120938 -_0812077C: - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - ldr r3, =0x00002e36 - adds r1, r2, r3 - cmp r0, 0 - bne _08120790 - ldr r0, =0x00002e2a - adds r1, r2, r0 -_08120790: - adds r2, r1, 0 - adds r1, r6, 0 - adds r1, 0xC - movs r3, 0x5 -_08120798: - ldrh r0, [r2] - strh r0, [r1] - adds r2, 0x2 - adds r1, 0x2 - subs r3, 0x1 - cmp r3, 0 - bge _08120798 - movs r0, 0 - strb r0, [r6] - b _08120938 - .pool -_081207BC: - ldrb r1, [r6] - lsls r1, 1 - adds r0, r6, 0 - adds r0, 0xC - adds r0, r1 - ldrh r4, [r0] - adds r0, r4, 0 - bl GetWordSounds - str r0, [r6, 0x30] - movs r1, 0x3 - ands r1, r4 - lsrs r4, 3 - movs r0, 0x1 - ands r4, r0 - adds r1, r4 - adds r0, r6, 0 - bl GetWordPhonemes - ldrb r0, [r6] - adds r0, 0x1 - strb r0, [r6] - ldr r0, [r6, 0x30] - ldrb r0, [r0] - cmp r0, 0xFF - beq _081207F4 - movs r0, 0 - b _08120936 -_081207F4: - movs r0, 0x3 - b _0812091A -_081207F8: - ldrb r3, [r6, 0x1] - lsls r1, r3, 3 - ldr r0, [r6, 0x30] - adds r2, r0, r1 - ldrb r1, [r6, 0x3] - cmp r1, 0x1 - beq _081208A0 - cmp r1, 0x1 - bgt _08120810 - cmp r1, 0 - beq _0812081C - b _08120938 -_08120810: - cmp r1, 0x2 - beq _08120850 - cmp r1, 0x3 - bne _0812081A - b _08120922 -_0812081A: - b _08120938 -_0812081C: - lsls r0, r3, 2 - adds r0, r6, r0 - ldrh r0, [r0, 0x18] - strb r0, [r6, 0x2] - ldrb r0, [r2] - cmp r0, 0x32 - bhi _08120844 - movs r1, 0x3 - bl __udivsi3 - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 1 - adds r0, r1 - movs r1, 0x8C - lsls r1, 2 - adds r0, r1 - bl m4aSongNumStart -_08120844: - movs r0, 0x2 - strb r0, [r6, 0x3] - ldrb r0, [r6, 0x2] - subs r0, 0x1 - strb r0, [r6, 0x2] - b _08120938 -_08120850: - movs r0, 0x1 - strb r0, [r6, 0x3] - ldrb r0, [r2] - cmp r0, 0x32 - bhi _08120938 - movs r3, 0x4 - ldrsh r0, [r2, r3] - lsls r0, 4 - movs r1, 0x80 - lsls r1, 1 - adds r0, r1 - strh r0, [r6, 0x6] - ldr r4, =gMPlayInfo_SE2 - ldr r5, =0x0000ffff - ldrh r2, [r6, 0x6] - adds r0, r4, 0 - adds r1, r5, 0 - bl m4aMPlayVolumeControl - ldrb r1, [r6, 0x1] - lsls r1, 2 - adds r1, r6, r1 - movs r2, 0x80 - lsls r2, 2 - adds r0, r2, 0 - ldrh r1, [r1, 0x1A] - adds r0, r1 - strh r0, [r6, 0x8] - movs r3, 0x8 - ldrsh r2, [r6, r3] - adds r0, r4, 0 - adds r1, r5, 0 - bl m4aMPlayPitchControl - b _08120938 - .pool -_081208A0: - ldrh r2, [r6, 0xA] - movs r3, 0xA - ldrsh r0, [r6, r3] - cmp r0, 0xA - ble _081208B0 - ldrh r0, [r6, 0x6] - subs r0, 0x2 - strh r0, [r6, 0x6] -_081208B0: - ands r1, r2 - cmp r1, 0 - beq _081208BC - ldrh r0, [r6, 0x8] - adds r0, 0x40 - b _081208C0 -_081208BC: - ldrh r0, [r6, 0x8] - subs r0, 0x40 -_081208C0: - strh r0, [r6, 0x8] - ldr r4, =gMPlayInfo_SE2 - ldr r5, =0x0000ffff - ldrh r2, [r6, 0x6] - adds r0, r4, 0 - adds r1, r5, 0 - bl m4aMPlayVolumeControl - movs r0, 0x8 - ldrsh r2, [r6, r0] - adds r0, r4, 0 - adds r1, r5, 0 - bl m4aMPlayPitchControl - ldrh r0, [r6, 0xA] - adds r0, 0x1 - strh r0, [r6, 0xA] - ldrb r0, [r6, 0x2] - subs r0, 0x1 - strb r0, [r6, 0x2] - lsls r0, 24 - cmp r0, 0 - bne _08120938 - ldrb r0, [r6, 0x1] - adds r0, 0x1 - strb r0, [r6, 0x1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x6 - beq _08120918 - ldrb r0, [r6, 0x1] - ldr r1, [r6, 0x30] - lsls r0, 3 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0xFF - beq _08120918 - movs r0, 0 - b _08120936 - .pool -_08120918: - movs r0, 0x3 -_0812091A: - strb r0, [r6, 0x3] - movs r0, 0x2 - strb r0, [r6, 0x2] - b _08120938 -_08120922: - ldrb r0, [r6, 0x2] - subs r0, 0x1 - strb r0, [r6, 0x2] - lsls r0, 24 - cmp r0, 0 - bne _08120938 - ldr r0, =gMPlayInfo_SE2 - bl m4aMPlayStop - movs r0, 0x4 -_08120936: - strb r0, [r6, 0x3] -_08120938: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120748 - thumb_func_start sub_8120944 sub_8120944: @ 8120944 push {r4-r7,lr} diff --git a/data/mauville_old_man.s b/data/mauville_old_man.s index ae39505ef..f58909390 100644 --- a/data/mauville_old_man.s +++ b/data/mauville_old_man.s @@ -4,9 +4,6 @@ .section .rodata .align 2, 0 -gUnknown_0859F030:: @ 859F030 - .4byte 0, 12, 13, 18, 19, 21 - gUnknown_0859F048:: @ 859F048 .4byte 0x00000132, MauvilleCity_PokemonCenter_1F_Text_28E930, MauvilleCity_PokemonCenter_1F_Text_28E947, MauvilleCity_PokemonCenter_1F_Text_28E956, 0x00000102, MauvilleCity_PokemonCenter_1F_Text_28E9D7, MauvilleCity_PokemonCenter_1F_Text_28E9EF, MauvilleCity_PokemonCenter_1F_Text_28E9FE .4byte 0x00000103, MauvilleCity_PokemonCenter_1F_Text_28EA7D, MauvilleCity_PokemonCenter_1F_Text_28EA98, MauvilleCity_PokemonCenter_1F_Text_28EAA8, 0x00000104, MauvilleCity_PokemonCenter_1F_Text_28EB19, MauvilleCity_PokemonCenter_1F_Text_28EB31, MauvilleCity_PokemonCenter_1F_Text_28EB3E diff --git a/include/bard_music.h b/include/bard_music.h index 7d9ca633e..9d3d0ad22 100644 --- a/include/bard_music.h +++ b/include/bard_music.h @@ -9,7 +9,7 @@ struct BardSound /*0x00*/ u8 var00; /*0x01*/ s8 var01; /*0x02*/ u16 var02; - /*0x04*/ u16 volume; + /*0x04*/ s16 volume; /*0x06*/ u16 var06; }; @@ -39,5 +39,7 @@ struct BardSong // Exported ROM declarations extern const u16 gUnknown_085F5490; +const struct BardSound *GetWordSounds(u16 word); +void GetWordPhonemes(struct BardSong *song, u16 word); #endif //GUARD_BARD_MUSIC_H diff --git a/include/easy_chat.h b/include/easy_chat.h index ad586d697..541fa6c1b 100644 --- a/include/easy_chat.h +++ b/include/easy_chat.h @@ -10,5 +10,7 @@ void ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 length1, u16 len bool8 ECWord_CheckIfOutsideOfValidRange(u16 word); u16 sub_811EE38(u16 group); u16 sub_811F01C(void); +bool16 EasyChat_GetNumWordsInGroup(u8); +u16 sub_811EE90(u16); #endif // GUARD_EASYCHAT_H diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index f39f80ab7..fa486748b 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -9,14 +9,24 @@ #include "script.h" #include "random.h" #include "event_scripts.h" +#include "task.h" +#include "menu.h" +#include "m4a.h" +#include "bard_music.h" +#include "constants/songs.h" #define CHAR_SONG_WORD_SEPARATOR 0x37 -void sub_8120E08(void); // StorytellerSetup -void sub_81339F8(void); // TraderSetup -void sub_8120B5C(void); -void sub_81206C0(u8 a0); // StartBardSong +extern struct MusicPlayerInfo gMPlayInfo_SE2; + void sub_81204DC(void); +void sub_81206C0(bool8 useTemporaryLyrics); // StartBardSong +void sub_8120944(u8 taskId); +void sub_8120B5C(void); +void sub_8120E08(void); // StorytellerSetup +void sub_8120E50(void); +void sub_81339F8(void); // TraderSetup +void sub_8133A60(void); static const u16 sDefaultBardSongLyrics[6] = { EC_WORD_SHAKE, @@ -289,3 +299,241 @@ void sub_81203FC(void) // ScrSpecial_GenerateGiddyLine gSpecialVar_Result = TRUE; } + +void sub_81204DC(void) +{ + struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy; + u16 arr[][2] = { + {EC_GROUP_POKEMON, 0}, + {EC_GROUP_LIFESTYLE, 0}, + {EC_GROUP_HOBBIES, 0}, + {EC_GROUP_MOVE_1, 0}, + {EC_GROUP_MOVE_2, 0}, + {EC_GROUP_POKEMON_2, 0} + }; + u16 i; + u16 r10; + u16 r7; + u16 r1; + + for (i = 0; i < 8; i++) + giddy->questionList[i] = i; + + for (i = 0; i < 8; i++) + { + r1 = Random() % (i + 1); + 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] = EasyChat_GetNumWordsInGroup(arr[i][0]); + r10 += arr[i][1]; + } + + giddy->questionNum = 0; + r7 = 0; + for (i = 0; i < 10; i++) + { + r1 = Random() % 10; + if (r1 < 3 && r7 < 8) + { + giddy->randomWords[i] = 0xFFFF; + r7++; + } + else + { + s16 r2 = Random() % r10; + for (r1 = 0; i < 6; r1++) + if ((r2 -= arr[r1][1]) <= 0) + break; + if (r1 == 6) + r1 = 0; + giddy->randomWords[i] = sub_811EE90(arr[r1][0]); + } + } +} +void sub_8120628(void) +{ + struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; + + bard->hasChangedSong = FALSE; +} + +void sub_8120640(void) +{ + struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; + + hipster->alreadySpoken = FALSE; +} + +void sub_8120658(void) +{ + sub_8133A60(); +} + +void sub_8120664(void) +{ + sub_8120E50(); +} + +void sub_8120670(void) // ResetMauvilleOldManFlag +{ + switch (sub_81201C8()) + { + case MAUVILLE_MAN_BARD: + sub_8120628(); + break; + case MAUVILLE_MAN_HIPSTER: + sub_8120640(); + break; + case MAUVILLE_MAN_STORYTELLER: + sub_8120664(); + break; + case MAUVILLE_MAN_TRADER: + sub_8120658(); + break; + case MAUVILLE_MAN_GIDDY: + break; + } + sub_8120B5C(); +} + + +#define tState data[0] +#define tCharIndex data[3] +#define tCurrWord data[4] +#define tUseTemporaryLyrics data[5] + +#define MACRO1(a) (((a) & 3) + (((a) / 8) & 1)) + +void sub_81206C0(bool8 useTemporaryLyrics) +{ + u8 taskId = CreateTask(sub_8120944, 80); + + gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics; +} + +void sub_81206F0(struct TextSubPrinter * printer, u16 a1) +{ + gUnknown_03002F84 = FALSE; +} + +void sub_81206FC(struct TextSubPrinter * printer, u16 a1) +{ + gUnknown_03002F84 = TRUE; +} + +void sub_8120708(const u8 * src) +{ + NewMenuHelpers_DrawDialogueFrame(0, 0); + PrintTextOnWindow(0, 1, src, 0, 1, 1, sub_81206FC); + gUnknown_03002F84 = TRUE; + CopyWindowToVram(0, 3); +} + +void sub_8120748(struct Task *task, struct BardSong *song) +{ + switch (task->tState) + { + case 0: // Initialize song + { + struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.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]; + song->currWord = 0; + } + break; + case 1: // Wait for BGM to end + break; + case 2: // Initialize word + { + u16 word = song->lyrics[song->currWord]; + song->sound = GetWordSounds(word); + GetWordPhonemes(song, MACRO1(word)); + song->currWord++; + if (song->sound->var00 != 0xFF) + song->state = 0; + else + { + song->state = 3; + song->phonemeTimer = 2; + } + break; + } + case 3: + case 4: + { + const struct BardSound *sound = &song->sound[song->currPhoneme]; + + switch (song->state) + { + case 0: + song->phonemeTimer = song->phonemes[song->currPhoneme].length; + if (sound->var00 <= 50) + { + u8 num = sound->var00 / 3; + m4aSongNumStart(PH_TRAP_HELD + 3 * num); + } + song->state = 2; + song->phonemeTimer--; + break; + case 2: + song->state = 1; + if (sound->var00 <= 50) + { + song->volume = 0x100 + sound->volume * 16; + m4aMPlayVolumeControl(&gMPlayInfo_SE2, 0xFFFF, song->volume); + song->pitch = 0x200 + song->phonemes[song->currPhoneme].pitch; + m4aMPlayPitchControl(&gMPlayInfo_SE2, 0xFFFF, song->pitch); + } + break; + case 1: + if (song->voiceInflection > 10) + song->volume -= 2; + if (song->voiceInflection & 1) + song->pitch += 64; + else + song->pitch -= 64; + m4aMPlayVolumeControl(&gMPlayInfo_SE2, 0xFFFF, song->volume); + m4aMPlayPitchControl(&gMPlayInfo_SE2, 0xFFFF, song->pitch); + song->voiceInflection++; + song->phonemeTimer--; + if (song->phonemeTimer == 0) + { + song->currPhoneme++; + if (song->currPhoneme != 6 && song->sound[song->currPhoneme].var00 != 0xFF) + song->state = 0; + else + { + song->state = 3; + song->phonemeTimer = 2; + } + } + break; + case 3: + song->phonemeTimer--; + if (song->phonemeTimer == 0) + { + m4aMPlayStop(&gMPlayInfo_SE2); + song->state = 4; + } + break; + } + } + break; + case 5: + break; + } +} From c6115a2fec2955803e65eedf5e8de1b8a134c188 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 3 May 2018 17:03:52 -0400 Subject: [PATCH 04/10] through sub_8120C0C --- asm/mauville_old_man.s | 467 +------------------------------ common_syms/mauville_old_man.txt | 1 + data/mauville_old_man.s | 24 -- include/event_scripts.h | 110 ++++++++ include/global.h | 3 + include/mauville_old_man.h | 1 + include/strings.h | 2 + src/mauville_old_man.c | 310 +++++++++++++++++++- sym_common.txt | 4 +- sym_ewram.txt | 11 +- 10 files changed, 427 insertions(+), 506 deletions(-) create mode 100644 common_syms/mauville_old_man.txt diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s index 4ab632aff..e9f543fb0 100644 --- a/asm/mauville_old_man.s +++ b/asm/mauville_old_man.s @@ -5,471 +5,6 @@ .text - thumb_func_start sub_8120944 -sub_8120944: @ 8120944 - push {r4-r7,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks - adds r5, r0, r1 - ldr r1, =gUnknown_03006130 - adds r0, r5, 0 - bl sub_8120748 - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0x5 - bls _08120966 - b _08120B50 -_08120966: - lsls r0, 2 - ldr r1, =_0812097C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0812097C: - .4byte _08120994 - .4byte _081209B8 - .4byte _081209C8 - .4byte _08120A7E - .4byte _08120B40 - .4byte _08120A6E -_08120994: - bl sub_8120280 - ldr r0, =gStringVar4 - bl sub_8120708 - movs r0, 0 - strh r0, [r5, 0xA] - strh r0, [r5, 0xC] - strh r0, [r5, 0xE] - strh r0, [r5, 0x10] - movs r0, 0x4 - bl FadeOutBGMTemporarily - movs r0, 0x1 - b _08120B4E - .pool -_081209B8: - bl IsBGMPausedOrStopped - lsls r0, 24 - cmp r0, 0 - bne _081209C4 - b _08120B50 -_081209C4: - movs r0, 0x2 - b _08120B4E -_081209C8: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00002e28 - adds r4, r0, r2 - movs r0, 0xE - ldrsh r1, [r5, r0] - ldr r0, =gStringVar4 - adds r1, r0 - movs r3, 0 - ldrb r0, [r1] - ldr r7, =gUnknown_03006130 - ldrh r2, [r5, 0x12] - ldr r6, =gUnknown_0203A128 - b _08120A02 - .pool -_081209F8: - adds r1, 0x1 - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - ldrb r0, [r1] -_08120A02: - cmp r0, 0 - beq _08120A12 - cmp r0, 0xFE - beq _08120A12 - cmp r0, 0xFC - beq _08120A12 - cmp r0, 0xFF - bne _081209F8 -_08120A12: - cmp r2, 0 - bne _08120A20 - movs r2, 0x10 - ldrsh r1, [r5, r2] - lsls r1, 1 - adds r0, r4, 0x2 - b _08120A2A -_08120A20: - movs r0, 0x10 - ldrsh r1, [r5, r0] - lsls r1, 1 - adds r0, r4, 0 - adds r0, 0xE -_08120A2A: - adds r0, r1 - ldrh r0, [r0] - movs r1, 0x3 - ands r1, r0 - lsrs r0, 3 - movs r2, 0x1 - ands r0, r2 - adds r1, r0 - strh r1, [r6] - movs r1, 0x4 - ldrsh r0, [r7, r1] - adds r1, r3, 0 - bl __divsi3 - movs r1, 0 - strh r0, [r7, 0x4] - lsls r0, 16 - cmp r0, 0 - bgt _08120A54 - movs r0, 0x1 - strh r0, [r7, 0x4] -_08120A54: - ldrh r0, [r5, 0x10] - adds r0, 0x1 - strh r0, [r5, 0x10] - movs r2, 0xC - ldrsh r0, [r5, r2] - cmp r0, 0 - bne _08120A66 - movs r0, 0x3 - b _08120A68 -_08120A66: - movs r0, 0x5 -_08120A68: - strh r0, [r5, 0x8] - strh r1, [r5, 0xA] - b _08120B50 -_08120A6E: - ldrh r1, [r5, 0xC] - movs r2, 0xC - ldrsh r0, [r5, r2] - cmp r0, 0 - beq _08120B4C - subs r0, r1, 0x1 - strh r0, [r5, 0xC] - b _08120B50 -_08120A7E: - ldr r1, =gStringVar4 - movs r2, 0xE - ldrsh r0, [r5, r2] - adds r0, r1 - ldrb r4, [r0] - cmp r4, 0xFF - bne _08120AB0 - movs r0, 0x6 - bl FadeInBGM - ldr r0, =gMPlayInfo_SE2 - movs r1, 0x2 - bl m4aMPlayFadeOutTemporarily - bl EnableBothScriptContexts - adds r0, r6, 0 - bl DestroyTask - b _08120B50 - .pool -_08120AB0: - cmp r4, 0 - bne _08120AC6 - bl sub_81206F0 - ldrh r0, [r5, 0xE] - adds r0, 0x1 - strh r0, [r5, 0xE] - movs r0, 0x2 - strh r0, [r5, 0x8] - strh r4, [r5, 0xC] - b _08120B50 -_08120AC6: - cmp r4, 0xFE - bne _08120ADA - ldrh r0, [r5, 0xE] - adds r0, 0x1 - movs r1, 0 - strh r0, [r5, 0xE] - movs r0, 0x2 - strh r0, [r5, 0x8] - strh r1, [r5, 0xC] - b _08120B50 -_08120ADA: - cmp r4, 0xFC - bne _08120AEE - ldrh r0, [r5, 0xE] - adds r0, 0x2 - strh r0, [r5, 0xE] - movs r0, 0x2 - strh r0, [r5, 0x8] - movs r0, 0x8 - strh r0, [r5, 0xC] - b _08120B50 -_08120AEE: - cmp r4, 0x37 - bne _08120B04 - movs r4, 0 - strb r4, [r0] - bl sub_81206F0 - ldrh r0, [r5, 0xE] - adds r0, 0x1 - strh r0, [r5, 0xE] - strh r4, [r5, 0xC] - b _08120B50 -_08120B04: - movs r1, 0xA - ldrsh r0, [r5, r1] - cmp r0, 0x1 - beq _08120B20 - cmp r0, 0x1 - bgt _08120B16 - cmp r0, 0 - beq _08120B1C - b _08120B50 -_08120B16: - cmp r0, 0x2 - beq _08120B28 - b _08120B50 -_08120B1C: - bl sub_81206F0 -_08120B20: - ldrh r0, [r5, 0xA] - adds r0, 0x1 - strh r0, [r5, 0xA] - b _08120B50 -_08120B28: - ldrh r0, [r5, 0xE] - adds r0, 0x1 - movs r1, 0 - strh r0, [r5, 0xE] - strh r1, [r5, 0xA] - ldr r0, =gUnknown_03006130 - ldrh r0, [r0, 0x4] - strh r0, [r5, 0xC] - movs r0, 0x4 - b _08120B4E - .pool -_08120B40: - ldrh r0, [r5, 0xC] - subs r0, 0x1 - strh r0, [r5, 0xC] - lsls r0, 16 - cmp r0, 0 - bne _08120B50 -_08120B4C: - movs r0, 0x3 -_08120B4E: - strh r0, [r5, 0x8] -_08120B50: - bl sub_8197224 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8120944 - - thumb_func_start sub_8120B5C -sub_8120B5C: @ 8120B5C - push {lr} - ldr r0, =0x00004010 - movs r1, 0x45 - bl VarSet - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120B5C - - thumb_func_start sub_8120B70 -sub_8120B70: @ 8120B70 - push {r4-r7,lr} - sub sp, 0x8 - ldrb r1, [r0] - cmp r1, 0x2 - beq _08120B80 - cmp r1, 0x3 - beq _08120BA6 - b _08120C00 -_08120B80: - adds r5, r0, 0 - movs r4, 0 -_08120B84: - adds r0, r5, 0 - adds r0, 0x32 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0x1 - bne _08120B9E - movs r0, 0xB - muls r0, r4 - adds r0, 0x5 - adds r0, r5, r0 - movs r1, 0x1 - bl ConvertInternationalString -_08120B9E: - adds r4, 0x1 - cmp r4, 0x3 - ble _08120B84 - b _08120C00 -_08120BA6: - adds r6, r0, 0 - movs r4, 0 - mov r7, sp - adds r5, r6, 0 - adds r5, 0x8 -_08120BB0: - adds r0, r6, 0x4 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - beq _08120BF8 - mov r0, sp - adds r1, r5, 0 - movs r2, 0x7 - bl memcpy - movs r0, 0xFF - strb r0, [r7, 0x7] - mov r0, sp - bl IsStringJapanese - cmp r0, 0 - beq _08120BF8 - mov r0, sp - movs r1, 0 - movs r2, 0x8 - bl memset - mov r0, sp - ldr r1, =gText_Friend - bl StringCopy - adds r0, r5, 0 - mov r1, sp - movs r2, 0x7 - bl memcpy - adds r0, r6, 0 - adds r0, 0x34 - adds r0, r4 - movs r1, 0x2 - strb r1, [r0] -_08120BF8: - adds r5, 0x7 - adds r4, 0x1 - cmp r4, 0x3 - ble _08120BB0 -_08120C00: - add sp, 0x8 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120B70 - - thumb_func_start sub_8120C0C -sub_8120C0C: @ 8120C0C - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r0, 0 - mov r8, r1 - adds r7, r2, 0 - ldrb r0, [r5] - cmp r0, 0x4 - bhi _08120CC4 - lsls r0, 2 - ldr r1, =_08120C2C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08120C2C: - .4byte _08120C92 - .4byte _08120CA2 - .4byte _08120C40 - .4byte _08120C6A - .4byte _08120CB0 -_08120C40: - adds r6, r5, 0 - movs r5, 0 - adds r4, r6, 0 - adds r4, 0x32 -_08120C48: - movs r0, 0xB - muls r0, r5 - adds r0, 0x5 - adds r0, r6, r0 - bl IsStringJapanese - cmp r0, 0 - beq _08120C5E - mov r0, r8 - strb r0, [r4] - b _08120C60 -_08120C5E: - strb r7, [r4] -_08120C60: - adds r4, 0x1 - adds r5, 0x1 - cmp r5, 0x3 - ble _08120C48 - b _08120CC4 -_08120C6A: - adds r4, r5, 0 - adds r4, 0x34 - adds r6, r5, 0 - adds r6, 0x8 - movs r5, 0x3 -_08120C74: - adds r0, r6, 0 - bl IsStringJapanese - cmp r0, 0 - beq _08120C84 - mov r1, r8 - strb r1, [r4] - b _08120C86 -_08120C84: - strb r7, [r4] -_08120C86: - adds r4, 0x1 - adds r6, 0x7 - subs r5, 0x1 - cmp r5, 0 - bge _08120C74 - b _08120CC4 -_08120C92: - cmp r3, 0x1 - bne _08120C9C - adds r0, r5, 0 - adds r0, 0x2A - b _08120CB8 -_08120C9C: - adds r0, r5, 0 - adds r0, 0x2A - b _08120CC2 -_08120CA2: - cmp r3, 0x1 - bne _08120CAC - mov r0, r8 - strb r0, [r5, 0x2] - b _08120CC4 -_08120CAC: - strb r7, [r5, 0x2] - b _08120CC4 -_08120CB0: - cmp r3, 0x1 - bne _08120CBE - adds r0, r5, 0 - adds r0, 0x20 -_08120CB8: - mov r1, r8 - strb r1, [r0] - b _08120CC4 -_08120CBE: - adds r0, r5, 0 - adds r0, 0x20 -_08120CC2: - strb r7, [r0] -_08120CC4: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8120C0C - thumb_func_start sub_8120CD0 sub_8120CD0: @ 8120CD0 push {r4-r7,lr} @@ -732,7 +267,7 @@ _08120EA0: adds r2, 0x1 cmp r2, 0x23 ble _08120E90 - ldr r0, =gUnknown_0859F278 + ldr r0, =gUnknown_0859F048+0x230 _08120EAA: pop {r1} bx r1 diff --git a/common_syms/mauville_old_man.txt b/common_syms/mauville_old_man.txt new file mode 100644 index 000000000..cc2c037c3 --- /dev/null +++ b/common_syms/mauville_old_man.txt @@ -0,0 +1 @@ +gUnknown_03006130 \ No newline at end of file diff --git a/data/mauville_old_man.s b/data/mauville_old_man.s index f58909390..fe7056541 100644 --- a/data/mauville_old_man.s +++ b/data/mauville_old_man.s @@ -4,29 +4,5 @@ .section .rodata .align 2, 0 -gUnknown_0859F048:: @ 859F048 - .4byte 0x00000132, MauvilleCity_PokemonCenter_1F_Text_28E930, MauvilleCity_PokemonCenter_1F_Text_28E947, MauvilleCity_PokemonCenter_1F_Text_28E956, 0x00000102, MauvilleCity_PokemonCenter_1F_Text_28E9D7, MauvilleCity_PokemonCenter_1F_Text_28E9EF, MauvilleCity_PokemonCenter_1F_Text_28E9FE - .4byte 0x00000103, MauvilleCity_PokemonCenter_1F_Text_28EA7D, MauvilleCity_PokemonCenter_1F_Text_28EA98, MauvilleCity_PokemonCenter_1F_Text_28EAA8, 0x00000104, MauvilleCity_PokemonCenter_1F_Text_28EB19, MauvilleCity_PokemonCenter_1F_Text_28EB31, MauvilleCity_PokemonCenter_1F_Text_28EB3E - .4byte 0x00000106, MauvilleCity_PokemonCenter_1F_Text_28EBB5, MauvilleCity_PokemonCenter_1F_Text_28EBCD, MauvilleCity_PokemonCenter_1F_Text_28EBDD, 0x00000109, MauvilleCity_PokemonCenter_1F_Text_28EC60, MauvilleCity_PokemonCenter_1F_Text_28EC79, MauvilleCity_PokemonCenter_1F_Text_28EC81 - .4byte 0x0000010b, MauvilleCity_PokemonCenter_1F_Text_28ED04, MauvilleCity_PokemonCenter_1F_Text_28ED21, MauvilleCity_PokemonCenter_1F_Text_28ED30, 0x0000010c, MauvilleCity_PokemonCenter_1F_Text_28EDA1, MauvilleCity_PokemonCenter_1F_Text_28EDB5, MauvilleCity_PokemonCenter_1F_Text_28EDCF - .4byte 0x0000010d, MauvilleCity_PokemonCenter_1F_Text_28EE45, MauvilleCity_PokemonCenter_1F_Text_28EE5D, MauvilleCity_PokemonCenter_1F_Text_28EE6A, 0x0000010e, MauvilleCity_PokemonCenter_1F_Text_28EEDD, MauvilleCity_PokemonCenter_1F_Text_28EEF1, MauvilleCity_PokemonCenter_1F_Text_28EF01 - .4byte 0x0000010f, MauvilleCity_PokemonCenter_1F_Text_28EF73, MauvilleCity_PokemonCenter_1F_Text_28EF95, MauvilleCity_PokemonCenter_1F_Text_28EFAA, 0x00000110, MauvilleCity_PokemonCenter_1F_Text_28F045, MauvilleCity_PokemonCenter_1F_Text_28F05A, MauvilleCity_PokemonCenter_1F_Text_28F071 - .4byte 0x00000111, MauvilleCity_PokemonCenter_1F_Text_28F0F3, MauvilleCity_PokemonCenter_1F_Text_28F10D, MauvilleCity_PokemonCenter_1F_Text_28F125, 0x00000112, MauvilleCity_PokemonCenter_1F_Text_28F1BE, MauvilleCity_PokemonCenter_1F_Text_28F1D5, MauvilleCity_PokemonCenter_1F_Text_28F1DE - .4byte 0x00000113, MauvilleCity_PokemonCenter_1F_Text_28F24F, MauvilleCity_PokemonCenter_1F_Text_28F269, MauvilleCity_PokemonCenter_1F_Text_28F277, 0x00000114, MauvilleCity_PokemonCenter_1F_Text_28F2FC, MauvilleCity_PokemonCenter_1F_Text_28F314, MauvilleCity_PokemonCenter_1F_Text_28F32A - .4byte 0x0000011a, MauvilleCity_PokemonCenter_1F_Text_28F3AD, MauvilleCity_PokemonCenter_1F_Text_28F3C6, MauvilleCity_PokemonCenter_1F_Text_28F3D2, 0x0000011b, MauvilleCity_PokemonCenter_1F_Text_28F44B, MauvilleCity_PokemonCenter_1F_Text_28F461, MauvilleCity_PokemonCenter_1F_Text_28F47C - .4byte 0x0000011c, MauvilleCity_PokemonCenter_1F_Text_28F50C, MauvilleCity_PokemonCenter_1F_Text_28F51B, MauvilleCity_PokemonCenter_1F_Text_28F538, 0x0000021d, MauvilleCity_PokemonCenter_1F_Text_28F5BE, MauvilleCity_PokemonCenter_1F_Text_28F5D1, MauvilleCity_PokemonCenter_1F_Text_28F5F2 - .4byte 0x0000011e, MauvilleCity_PokemonCenter_1F_Text_28F678, MauvilleCity_PokemonCenter_1F_Text_28F694, MauvilleCity_PokemonCenter_1F_Text_28F6B4, 0x00000121, MauvilleCity_PokemonCenter_1F_Text_28F751, MauvilleCity_PokemonCenter_1F_Text_28F76A, MauvilleCity_PokemonCenter_1F_Text_28F776 - .4byte 0x00000124, MauvilleCity_PokemonCenter_1F_Text_28F7F6, MauvilleCity_PokemonCenter_1F_Text_28F811, MauvilleCity_PokemonCenter_1F_Text_28F822, 0x00000125, MauvilleCity_PokemonCenter_1F_Text_28F89C, MauvilleCity_PokemonCenter_1F_Text_28F8AF, MauvilleCity_PokemonCenter_1F_Text_28F8BC - .4byte 0x00000126, MauvilleCity_PokemonCenter_1F_Text_28F92F, MauvilleCity_PokemonCenter_1F_Text_28F941, MauvilleCity_PokemonCenter_1F_Text_28F949, 0x00000127, MauvilleCity_PokemonCenter_1F_Text_28F9D1, MauvilleCity_PokemonCenter_1F_Text_28F9EA, MauvilleCity_PokemonCenter_1F_Text_28F9FD - .4byte 0x00000128, MauvilleCity_PokemonCenter_1F_Text_28FA81, MauvilleCity_PokemonCenter_1F_Text_28FA99, MauvilleCity_PokemonCenter_1F_Text_28FAA7, 0x00000129, MauvilleCity_PokemonCenter_1F_Text_28FB1D, MauvilleCity_PokemonCenter_1F_Text_28FB35, MauvilleCity_PokemonCenter_1F_Text_28FB47 - .4byte 0x0000012a, MauvilleCity_PokemonCenter_1F_Text_28FBC4, MauvilleCity_PokemonCenter_1F_Text_28FBD9, MauvilleCity_PokemonCenter_1F_Text_28FBEA, 0x0000012b, MauvilleCity_PokemonCenter_1F_Text_28FC6B, MauvilleCity_PokemonCenter_1F_Text_28FC85, MauvilleCity_PokemonCenter_1F_Text_28FC98 - .4byte 0x0000012c, MauvilleCity_PokemonCenter_1F_Text_28FD1D, MauvilleCity_PokemonCenter_1F_Text_28FD35, MauvilleCity_PokemonCenter_1F_Text_28FD40, 0x0000012d, MauvilleCity_PokemonCenter_1F_Text_28FDA2, MauvilleCity_PokemonCenter_1F_Text_28FDBD, MauvilleCity_PokemonCenter_1F_Text_28FDCE - .4byte 0x0000012e, MauvilleCity_PokemonCenter_1F_Text_28FE57, MauvilleCity_PokemonCenter_1F_Text_28FE72, MauvilleCity_PokemonCenter_1F_Text_28FE88, 0x0000012f, MauvilleCity_PokemonCenter_1F_Text_28FF0C, MauvilleCity_PokemonCenter_1F_Text_28FF27, MauvilleCity_PokemonCenter_1F_Text_28FF44 - .4byte 0x00000130, MauvilleCity_PokemonCenter_1F_Text_28FFDD, MauvilleCity_PokemonCenter_1F_Text_28FFFA, MauvilleCity_PokemonCenter_1F_Text_29000D - - -gUnknown_0859F278:: @ 859F278 - .4byte 0x00000131, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB - gUnknown_0859F288:: @ 859F288 .4byte 0x00000024, 0x00000008 diff --git a/include/event_scripts.h b/include/event_scripts.h index a964b1a67..c187682b0 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -414,4 +414,114 @@ extern const u8 gUnknown_08294460[]; extern const u8 gUnknown_082944A0[]; extern const u8 gUnknown_082944D5[]; + +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28E930[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28E947[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28E956[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28E9D7[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28E9EF[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28E9FE[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EA7D[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EA98[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EAA8[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EB19[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EB31[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EB3E[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EBB5[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EBCD[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EBDD[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EC60[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EC79[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EC81[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28ED04[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28ED21[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28ED30[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EDA1[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EDB5[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EDCF[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EE45[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EE5D[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EE6A[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EEDD[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EEF1[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EF01[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EF73[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EF95[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28EFAA[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F045[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F05A[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F071[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F0F3[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F10D[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F125[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F1BE[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F1D5[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F1DE[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F24F[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F269[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F277[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F2FC[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F314[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F32A[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F3AD[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F3C6[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F3D2[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F44B[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F461[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F47C[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F50C[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F51B[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F538[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F5BE[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F5D1[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F5F2[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F678[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F694[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F6B4[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F751[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F76A[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F776[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F7F6[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F811[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F822[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F89C[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F8AF[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F8BC[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F92F[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F941[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F949[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F9D1[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F9EA[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28F9FD[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FA81[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FA99[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FAA7[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FB1D[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FB35[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FB47[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FBC4[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FBD9[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FBEA[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FC6B[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FC85[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FC98[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FD1D[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FD35[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FD40[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FDA2[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FDBD[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FDCE[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FE57[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FE72[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FE88[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FF0C[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FF27[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FF44[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FFDD[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_28FFFA[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_29000D[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_290097[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_2900B5[]; +extern const u8 MauvilleCity_PokemonCenter_1F_Text_2900CB[]; + #endif //GUARD_EVENT_SCRIPTS_H diff --git a/include/global.h b/include/global.h index d3506d345..083ed3e9f 100644 --- a/include/global.h +++ b/include/global.h @@ -453,6 +453,7 @@ struct MauvilleManStoryteller u8 gameStatIDs[4]; u8 trainerNames[4][7]; u8 statValues[4][4]; + u8 unk34[4]; }; struct MauvilleManGiddy @@ -478,6 +479,7 @@ struct MauvilleOldManTrader u8 unk1[4]; u8 unk5[4][11]; u8 unk31; + u8 unk32[4]; }; typedef union OldMan @@ -487,6 +489,7 @@ typedef union OldMan struct MauvilleManGiddy giddy; struct MauvilleManHipster hipster; struct MauvilleOldManTrader trader; + struct MauvilleManStoryteller storyteller; u8 filler[0x40]; } OldMan; diff --git a/include/mauville_old_man.h b/include/mauville_old_man.h index 0fc9fd6eb..28cd5589e 100644 --- a/include/mauville_old_man.h +++ b/include/mauville_old_man.h @@ -13,5 +13,6 @@ enum MauvilleOldManType void SetMauvilleOldMan(void); u8 sub_81201C8(void); +extern struct BardSong gUnknown_03006130; #endif // GUARD_MAUVILLE_OLD_MAN_H diff --git a/include/strings.h b/include/strings.h index 7c81dbcfb..604437d32 100644 --- a/include/strings.h +++ b/include/strings.h @@ -429,5 +429,7 @@ extern const u8 gText_TooImportantToToss[]; extern const u8 gText_ConfirmTossItems[]; extern const u8 gText_MoveVar1Where[]; +extern const u8 gText_Friend[]; + #endif //GUARD_STRINGS_H diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index fa486748b..b0e7fb491 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -1,6 +1,9 @@ #include "global.h" #include "main.h" +#include "constants/songs.h" #include "constants/easy_chat.h" +#include "constants/map_objects.h" +#include "constants/vars.h" #include "mauville_old_man.h" #include "event_data.h" #include "string_util.h" @@ -13,7 +16,8 @@ #include "menu.h" #include "m4a.h" #include "bard_music.h" -#include "constants/songs.h" +#include "sound.h" +#include "strings.h" #define CHAR_SONG_WORD_SEPARATOR 0x37 @@ -28,6 +32,12 @@ void sub_8120E50(void); void sub_81339F8(void); // TraderSetup void sub_8133A60(void); +struct BardSong gUnknown_03006130; + +EWRAM_DATA u16 gUnknown_0203A128 = 0; +EWRAM_DATA struct MauvilleOldMan * gUnknown_0203A12C = NULL; +EWRAM_DATA u8 gUnknown_0203A130 = 0; + static const u16 sDefaultBardSongLyrics[6] = { EC_WORD_SHAKE, EC_WORD_IT, @@ -409,6 +419,7 @@ void sub_8120670(void) // ResetMauvilleOldManFlag #define tUseTemporaryLyrics data[5] #define MACRO1(a) (((a) & 3) + (((a) / 8) & 1)) +#define MACRO2(a) (((a) % 4) + (((a) / 8) & 1)) void sub_81206C0(bool8 useTemporaryLyrics) { @@ -417,7 +428,7 @@ void sub_81206C0(bool8 useTemporaryLyrics) gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics; } -void sub_81206F0(struct TextSubPrinter * printer, u16 a1) +void sub_81206F0(void) { gUnknown_03002F84 = FALSE; } @@ -435,7 +446,7 @@ void sub_8120708(const u8 * src) CopyWindowToVram(0, 3); } -void sub_8120748(struct Task *task, struct BardSong *song) +void sub_8120748(struct Task *task, struct BardSong *song) // BardSing { switch (task->tState) { @@ -537,3 +548,296 @@ void sub_8120748(struct Task *task, struct BardSong *song) break; } } + +void sub_8120944(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; // r5 + + sub_8120748(task, &gUnknown_03006130); + switch (task->tState) + { + case 0: // Initialize song + sub_8120280(); + sub_8120708(gStringVar4); + 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 = &gSaveBlock1Ptr->oldMan.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_0203A128 = MACRO2(bard->songLyrics[task->tCurrWord]); + else + gUnknown_0203A128 = MACRO2(bard->temporaryLyrics[task->tCurrWord]); + temp = gUnknown_03006130.length / wordLen; + zero = 0; + gUnknown_03006130.length = temp; + if (gUnknown_03006130.length <= 0) + gUnknown_03006130.length = 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) + { + FadeInBGM(6); + m4aMPlayFadeOutTemporarily(&gMPlayInfo_SE2, 2); + EnableBothScriptContexts(); + DestroyTask(taskId); + } + else if (gStringVar4[task->tCharIndex] == CHAR_SPACE) + { + + sub_81206F0(); + 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_81206F0(); + task->tCharIndex++; + task->data[2] = 0; + } + else + { + switch (task->data[1]) + { + case 0: + sub_81206F0(); + task->data[1]++; + break; + case 1: + task->data[1]++; + break; + case 2: + task->tCharIndex++; + task->data[1] = 0; + task->data[2] = gUnknown_03006130.length; + task->tState = 4; + break; + } + } + break; + case 4: + task->data[2]--; + if (task->data[2] == 0) + task->tState = 3; + break; + } + sub_8197224(); +} + +void sub_8120B5C(void) +{ + VarSet(VAR_0x4010, MAP_OBJ_GFX_BARD); +} + +struct Story +{ + u8 stat; + u8 minVal; + const u8 *title; + const u8 *action; + const u8 *fullText; +}; + +const struct Story gUnknown_0859F048[] = { + {GAME_STAT_50, 1, MauvilleCity_PokemonCenter_1F_Text_28E930, MauvilleCity_PokemonCenter_1F_Text_28E947, MauvilleCity_PokemonCenter_1F_Text_28E956}, + {GAME_STAT_STARTED_TRENDS, 1, MauvilleCity_PokemonCenter_1F_Text_28E9D7, MauvilleCity_PokemonCenter_1F_Text_28E9EF, MauvilleCity_PokemonCenter_1F_Text_28E9FE}, + {GAME_STAT_PLANTED_BERRIES, 1, MauvilleCity_PokemonCenter_1F_Text_28EA7D, MauvilleCity_PokemonCenter_1F_Text_28EA98, MauvilleCity_PokemonCenter_1F_Text_28EAA8}, + {GAME_STAT_TRADED_BIKES, 1, MauvilleCity_PokemonCenter_1F_Text_28EB19, MauvilleCity_PokemonCenter_1F_Text_28EB31, MauvilleCity_PokemonCenter_1F_Text_28EB3E}, + {GAME_STAT_GOT_INTERVIEWED, 1, MauvilleCity_PokemonCenter_1F_Text_28EBB5, MauvilleCity_PokemonCenter_1F_Text_28EBCD, MauvilleCity_PokemonCenter_1F_Text_28EBDD}, + {GAME_STAT_TRAINER_BATTLES, 1, MauvilleCity_PokemonCenter_1F_Text_28EC60, MauvilleCity_PokemonCenter_1F_Text_28EC79, MauvilleCity_PokemonCenter_1F_Text_28EC81}, + {GAME_STAT_POKEMON_CAPTURES, 1, MauvilleCity_PokemonCenter_1F_Text_28ED04, MauvilleCity_PokemonCenter_1F_Text_28ED21, MauvilleCity_PokemonCenter_1F_Text_28ED30}, + {GAME_STAT_FISHING_CAPTURES, 1, MauvilleCity_PokemonCenter_1F_Text_28EDA1, MauvilleCity_PokemonCenter_1F_Text_28EDB5, MauvilleCity_PokemonCenter_1F_Text_28EDCF}, + {GAME_STAT_HATCHED_EGGS, 1, MauvilleCity_PokemonCenter_1F_Text_28EE45, MauvilleCity_PokemonCenter_1F_Text_28EE5D, MauvilleCity_PokemonCenter_1F_Text_28EE6A}, + {GAME_STAT_EVOLVED_POKEMON, 1, MauvilleCity_PokemonCenter_1F_Text_28EEDD, MauvilleCity_PokemonCenter_1F_Text_28EEF1, MauvilleCity_PokemonCenter_1F_Text_28EF01}, + {GAME_STAT_USED_POKECENTER, 1, MauvilleCity_PokemonCenter_1F_Text_28EF73, MauvilleCity_PokemonCenter_1F_Text_28EF95, MauvilleCity_PokemonCenter_1F_Text_28EFAA}, + {GAME_STAT_RESTED_AT_HOME, 1, MauvilleCity_PokemonCenter_1F_Text_28F045, MauvilleCity_PokemonCenter_1F_Text_28F05A, MauvilleCity_PokemonCenter_1F_Text_28F071}, + {GAME_STAT_ENTERED_SAFARI_ZONE, 1, MauvilleCity_PokemonCenter_1F_Text_28F0F3, MauvilleCity_PokemonCenter_1F_Text_28F10D, MauvilleCity_PokemonCenter_1F_Text_28F125}, + {GAME_STAT_USED_CUT, 1, MauvilleCity_PokemonCenter_1F_Text_28F1BE, MauvilleCity_PokemonCenter_1F_Text_28F1D5, MauvilleCity_PokemonCenter_1F_Text_28F1DE}, + {GAME_STAT_USED_ROCK_SMASH, 1, MauvilleCity_PokemonCenter_1F_Text_28F24F, MauvilleCity_PokemonCenter_1F_Text_28F269, MauvilleCity_PokemonCenter_1F_Text_28F277}, + {GAME_STAT_MOVED_SECRET_BASE, 1, MauvilleCity_PokemonCenter_1F_Text_28F2FC, MauvilleCity_PokemonCenter_1F_Text_28F314, MauvilleCity_PokemonCenter_1F_Text_28F32A}, + {GAME_STAT_USED_SPLASH, 1, MauvilleCity_PokemonCenter_1F_Text_28F3AD, MauvilleCity_PokemonCenter_1F_Text_28F3C6, MauvilleCity_PokemonCenter_1F_Text_28F3D2}, + {GAME_STAT_USED_STRUGGLE, 1, MauvilleCity_PokemonCenter_1F_Text_28F44B, MauvilleCity_PokemonCenter_1F_Text_28F461, MauvilleCity_PokemonCenter_1F_Text_28F47C}, + {GAME_STAT_SLOT_JACKPOTS, 1, MauvilleCity_PokemonCenter_1F_Text_28F50C, MauvilleCity_PokemonCenter_1F_Text_28F51B, MauvilleCity_PokemonCenter_1F_Text_28F538}, + {GAME_STAT_CONSECUTIVE_ROULETTE_WINS, 2, MauvilleCity_PokemonCenter_1F_Text_28F5BE, MauvilleCity_PokemonCenter_1F_Text_28F5D1, MauvilleCity_PokemonCenter_1F_Text_28F5F2}, + {GAME_STAT_ENTERED_BATTLE_TOWER, 1, MauvilleCity_PokemonCenter_1F_Text_28F678, MauvilleCity_PokemonCenter_1F_Text_28F694, MauvilleCity_PokemonCenter_1F_Text_28F6B4}, + {GAME_STAT_POKEBLOCKS, 1, MauvilleCity_PokemonCenter_1F_Text_28F751, MauvilleCity_PokemonCenter_1F_Text_28F76A, MauvilleCity_PokemonCenter_1F_Text_28F776}, + {GAME_STAT_ENTERED_CONTEST, 1, MauvilleCity_PokemonCenter_1F_Text_28F7F6, MauvilleCity_PokemonCenter_1F_Text_28F811, MauvilleCity_PokemonCenter_1F_Text_28F822}, + {GAME_STAT_WON_CONTEST, 1, MauvilleCity_PokemonCenter_1F_Text_28F89C, MauvilleCity_PokemonCenter_1F_Text_28F8AF, MauvilleCity_PokemonCenter_1F_Text_28F8BC}, + {GAME_STAT_SHOPPED, 1, MauvilleCity_PokemonCenter_1F_Text_28F92F, MauvilleCity_PokemonCenter_1F_Text_28F941, MauvilleCity_PokemonCenter_1F_Text_28F949}, + {GAME_STAT_USED_ITEMFINDER, 1, MauvilleCity_PokemonCenter_1F_Text_28F9D1, MauvilleCity_PokemonCenter_1F_Text_28F9EA, MauvilleCity_PokemonCenter_1F_Text_28F9FD}, + {GAME_STAT_GOT_RAINED_ON, 1, MauvilleCity_PokemonCenter_1F_Text_28FA81, MauvilleCity_PokemonCenter_1F_Text_28FA99, MauvilleCity_PokemonCenter_1F_Text_28FAA7}, + {GAME_STAT_CHECKED_POKEDEX, 1, MauvilleCity_PokemonCenter_1F_Text_28FB1D, MauvilleCity_PokemonCenter_1F_Text_28FB35, MauvilleCity_PokemonCenter_1F_Text_28FB47}, + {GAME_STAT_RECEIVED_RIBBONS, 1, MauvilleCity_PokemonCenter_1F_Text_28FBC4, MauvilleCity_PokemonCenter_1F_Text_28FBD9, MauvilleCity_PokemonCenter_1F_Text_28FBEA}, + {GAME_STAT_JUMPED_DOWN_LEDGES, 1, MauvilleCity_PokemonCenter_1F_Text_28FC6B, MauvilleCity_PokemonCenter_1F_Text_28FC85, MauvilleCity_PokemonCenter_1F_Text_28FC98}, + {GAME_STAT_WATCHED_TV, 1, MauvilleCity_PokemonCenter_1F_Text_28FD1D, MauvilleCity_PokemonCenter_1F_Text_28FD35, MauvilleCity_PokemonCenter_1F_Text_28FD40}, + {GAME_STAT_CHECKED_CLOCK, 1, MauvilleCity_PokemonCenter_1F_Text_28FDA2, MauvilleCity_PokemonCenter_1F_Text_28FDBD, MauvilleCity_PokemonCenter_1F_Text_28FDCE}, + {GAME_STAT_WON_POKEMON_LOTTERY, 1, MauvilleCity_PokemonCenter_1F_Text_28FE57, MauvilleCity_PokemonCenter_1F_Text_28FE72, MauvilleCity_PokemonCenter_1F_Text_28FE88}, + {GAME_STAT_USED_DAYCARE, 1, MauvilleCity_PokemonCenter_1F_Text_28FF0C, MauvilleCity_PokemonCenter_1F_Text_28FF27, MauvilleCity_PokemonCenter_1F_Text_28FF44}, + {GAME_STAT_RODE_CABLE_CAR, 1, MauvilleCity_PokemonCenter_1F_Text_28FFDD, MauvilleCity_PokemonCenter_1F_Text_28FFFA, MauvilleCity_PokemonCenter_1F_Text_29000D}, + {GAME_STAT_ENTERED_HOT_SPRINGS, 1, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB} +}; + +void sub_8120B70(union OldMan * oldMan) +{ + s32 i; + u8 sp00[8]; + + switch (oldMan->common.id) + { + case MAUVILLE_MAN_TRADER: + { + struct MauvilleOldManTrader * trader = &oldMan->trader; + for (i = 0; i < 4; i++) + { + if (trader->unk32[i] == LANGUAGE_JAPANESE) + { + ConvertInternationalString(trader->unk5[i], LANGUAGE_JAPANESE); + } + } + } + break; + case MAUVILLE_MAN_STORYTELLER: + { + struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; + for (i = 0; i < 4; i++) + { + if (storyteller->gameStatIDs[i] != 0) + { + memcpy(sp00, storyteller->trainerNames[i], 7); + sp00[7] = EOS; + if (IsStringJapanese(sp00)) + { + memset(sp00, CHAR_SPACE, 8); + StringCopy(sp00, gText_Friend); + memcpy(storyteller->trainerNames[i], sp00, 7); + storyteller->unk34[i] = GAME_LANGUAGE; + } + } + } + } + break; + } +} + +void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3) +{ + s32 i; + + switch (oldMan->common.id) + { + case MAUVILLE_MAN_TRADER: + { + struct MauvilleOldManTrader * trader = &oldMan->trader; + + for (i = 0; i < 4; i++) + { + if (IsStringJapanese(trader->unk5[i])) + { + trader->unk32[i] = r8; + } + else + { + trader->unk32[i] = r7; + } + } + } + break; + case MAUVILLE_MAN_STORYTELLER: + { + struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; + + for (i = 0; i < 4; i++) + { + if (IsStringJapanese(storyteller->trainerNames[i])) + { + storyteller->unk34[i] = r8; + } + else + { + storyteller->unk34[i] = r7; + } + } + } + break; + case MAUVILLE_MAN_BARD: + { + struct MauvilleManBard * bard = &oldMan->bard; + + if (r3 == LANGUAGE_JAPANESE) + bard->language = r8; + else + bard->language = r7; + } + break; + case MAUVILLE_MAN_HIPSTER: + { + struct MauvilleManHipster * hipster = &oldMan->hipster; + + if (r3 == LANGUAGE_JAPANESE) + hipster->language = r8; + else + hipster->language = r7; + } + break; + case MAUVILLE_MAN_GIDDY: + { + struct MauvilleManGiddy * giddy = &oldMan->giddy; + + if (r3 == LANGUAGE_JAPANESE) + giddy->language = r8; + else + giddy->language = r7; + } + break; + } +} diff --git a/sym_common.txt b/sym_common.txt index b0548a84c..a9987b0e6 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -87,9 +87,7 @@ gUnknown_030060B8: @ 30060B8 .space 0x4 .include "tv.o" - -gUnknown_03006130: @ 3006130 - .space 0x34 + .include "mauville_old_man.o" gUnknown_03006164: @ 3006164 .space 0x4 diff --git a/sym_ewram.txt b/sym_ewram.txt index 9bf04d201..a77825605 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -549,16 +549,7 @@ gUnknown_0203A11C: @ 203A11C gUnknown_0203A120: @ 203A120 .space 0x4 .include "src/mon_markings.o" - -gUnknown_0203A128: @ 203A128 - .space 0x4 - -gUnknown_0203A12C: @ 203A12C - .space 0x4 - -gUnknown_0203A130: @ 203A130 - .space 0x4 - + .include "src/mauville_old_man.o" .include "src/mail.o" gUnknown_0203A138: @ 203A138 From 1943118a1e0edcadcbf8c602aedb191f44b8b9f6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 3 May 2018 17:26:02 -0400 Subject: [PATCH 05/10] through sub_8120D34 --- asm/mauville_old_man.s | 177 ----------------------------------- src/mauville_old_man.c | 204 +++++++++++++++++++++++++++++++---------- 2 files changed, 156 insertions(+), 225 deletions(-) diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s index e9f543fb0..368dedf93 100644 --- a/asm/mauville_old_man.s +++ b/asm/mauville_old_man.s @@ -5,183 +5,6 @@ .text - thumb_func_start sub_8120CD0 -sub_8120CD0: @ 8120CD0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - adds r1, r0, 0 - ldrb r0, [r1] - cmp r0, 0x3 - bne _08120D28 - cmp r2, 0x1 - bne _08120D28 - adds r7, r1, 0 - movs r6, 0 - mov r8, sp - adds r4, r7, 0 - adds r4, 0x34 - adds r5, r7, 0 - adds r5, 0x8 -_08120CF2: - adds r0, r7, 0x4 - adds r0, r6 - ldrb r0, [r0] - cmp r0, 0 - beq _08120D1E - mov r0, sp - adds r1, r5, 0 - movs r2, 0x7 - bl memcpy - movs r0, 0xFF - mov r1, r8 - strb r0, [r1, 0x7] - mov r0, sp - bl IsStringJapanese - cmp r0, 0 - beq _08120D1A - movs r0, 0x1 - b _08120D1C -_08120D1A: - movs r0, 0x2 -_08120D1C: - strb r0, [r4] -_08120D1E: - adds r4, 0x1 - adds r5, 0x7 - adds r6, 0x1 - cmp r6, 0x3 - ble _08120CF2 -_08120D28: - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8120CD0 - - thumb_func_start sub_8120D34 -sub_8120D34: @ 8120D34 - push {r4-r7,lr} - adds r3, r0, 0 - adds r6, r2, 0 - movs r2, 0 - subs r1, 0x1 - cmp r1, 0x1 - bhi _08120D44 - movs r2, 0x1 -_08120D44: - ldrb r0, [r3] - cmp r0, 0x4 - bhi _08120E02 - lsls r0, 2 - ldr r1, =_08120D58 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08120D58: - .4byte _08120DE6 - .4byte _08120DF0 - .4byte _08120D6C - .4byte _08120DC6 - .4byte _08120DF8 -_08120D6C: - adds r7, r3, 0 - cmp r2, 0 - beq _08120DA4 - movs r5, 0 - adds r4, r3, 0 - adds r4, 0x32 -_08120D78: - movs r0, 0xB - muls r0, r5 - adds r0, 0x5 - adds r1, r7, r0 - ldrb r0, [r1] - cmp r0, 0xFC - bne _08120D98 - ldrb r0, [r1, 0x1] - cmp r0, 0x15 - bne _08120D98 - adds r0, r1, 0 - bl StripExtCtrlCodes - movs r0, 0x1 - strb r0, [r4] - b _08120D9A -_08120D98: - strb r6, [r4] -_08120D9A: - adds r4, 0x1 - adds r5, 0x1 - cmp r5, 0x3 - ble _08120D78 - b _08120E02 -_08120DA4: - movs r5, 0 - adds r4, r3, 0 - adds r4, 0x32 -_08120DAA: - adds r0, r4, r5 - ldrb r0, [r0] - cmp r0, 0x1 - bne _08120DBE - movs r0, 0xB - muls r0, r5 - adds r0, 0x5 - adds r0, r7, r0 - bl StripExtCtrlCodes -_08120DBE: - adds r5, 0x1 - cmp r5, 0x3 - ble _08120DAA - b _08120E02 -_08120DC6: - cmp r2, 0 - beq _08120E02 - movs r1, 0 - adds r4, r3, 0x4 - adds r2, r3, 0 - adds r2, 0x34 -_08120DD2: - adds r0, r4, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _08120DDE - adds r0, r2, r1 - strb r6, [r0] -_08120DDE: - adds r1, 0x1 - cmp r1, 0x3 - ble _08120DD2 - b _08120E02 -_08120DE6: - cmp r2, 0 - beq _08120E02 - adds r0, r3, 0 - adds r0, 0x2A - b _08120E00 -_08120DF0: - cmp r2, 0 - beq _08120E02 - strb r6, [r3, 0x2] - b _08120E02 -_08120DF8: - cmp r2, 0 - beq _08120E02 - adds r0, r3, 0 - adds r0, 0x20 -_08120E00: - strb r6, [r0] -_08120E02: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8120D34 - thumb_func_start sub_8120E08 sub_8120E08: @ 8120E08 push {r4,r5,lr} diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index b0e7fb491..1f398569c 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -679,54 +679,6 @@ void sub_8120B5C(void) VarSet(VAR_0x4010, MAP_OBJ_GFX_BARD); } -struct Story -{ - u8 stat; - u8 minVal; - const u8 *title; - const u8 *action; - const u8 *fullText; -}; - -const struct Story gUnknown_0859F048[] = { - {GAME_STAT_50, 1, MauvilleCity_PokemonCenter_1F_Text_28E930, MauvilleCity_PokemonCenter_1F_Text_28E947, MauvilleCity_PokemonCenter_1F_Text_28E956}, - {GAME_STAT_STARTED_TRENDS, 1, MauvilleCity_PokemonCenter_1F_Text_28E9D7, MauvilleCity_PokemonCenter_1F_Text_28E9EF, MauvilleCity_PokemonCenter_1F_Text_28E9FE}, - {GAME_STAT_PLANTED_BERRIES, 1, MauvilleCity_PokemonCenter_1F_Text_28EA7D, MauvilleCity_PokemonCenter_1F_Text_28EA98, MauvilleCity_PokemonCenter_1F_Text_28EAA8}, - {GAME_STAT_TRADED_BIKES, 1, MauvilleCity_PokemonCenter_1F_Text_28EB19, MauvilleCity_PokemonCenter_1F_Text_28EB31, MauvilleCity_PokemonCenter_1F_Text_28EB3E}, - {GAME_STAT_GOT_INTERVIEWED, 1, MauvilleCity_PokemonCenter_1F_Text_28EBB5, MauvilleCity_PokemonCenter_1F_Text_28EBCD, MauvilleCity_PokemonCenter_1F_Text_28EBDD}, - {GAME_STAT_TRAINER_BATTLES, 1, MauvilleCity_PokemonCenter_1F_Text_28EC60, MauvilleCity_PokemonCenter_1F_Text_28EC79, MauvilleCity_PokemonCenter_1F_Text_28EC81}, - {GAME_STAT_POKEMON_CAPTURES, 1, MauvilleCity_PokemonCenter_1F_Text_28ED04, MauvilleCity_PokemonCenter_1F_Text_28ED21, MauvilleCity_PokemonCenter_1F_Text_28ED30}, - {GAME_STAT_FISHING_CAPTURES, 1, MauvilleCity_PokemonCenter_1F_Text_28EDA1, MauvilleCity_PokemonCenter_1F_Text_28EDB5, MauvilleCity_PokemonCenter_1F_Text_28EDCF}, - {GAME_STAT_HATCHED_EGGS, 1, MauvilleCity_PokemonCenter_1F_Text_28EE45, MauvilleCity_PokemonCenter_1F_Text_28EE5D, MauvilleCity_PokemonCenter_1F_Text_28EE6A}, - {GAME_STAT_EVOLVED_POKEMON, 1, MauvilleCity_PokemonCenter_1F_Text_28EEDD, MauvilleCity_PokemonCenter_1F_Text_28EEF1, MauvilleCity_PokemonCenter_1F_Text_28EF01}, - {GAME_STAT_USED_POKECENTER, 1, MauvilleCity_PokemonCenter_1F_Text_28EF73, MauvilleCity_PokemonCenter_1F_Text_28EF95, MauvilleCity_PokemonCenter_1F_Text_28EFAA}, - {GAME_STAT_RESTED_AT_HOME, 1, MauvilleCity_PokemonCenter_1F_Text_28F045, MauvilleCity_PokemonCenter_1F_Text_28F05A, MauvilleCity_PokemonCenter_1F_Text_28F071}, - {GAME_STAT_ENTERED_SAFARI_ZONE, 1, MauvilleCity_PokemonCenter_1F_Text_28F0F3, MauvilleCity_PokemonCenter_1F_Text_28F10D, MauvilleCity_PokemonCenter_1F_Text_28F125}, - {GAME_STAT_USED_CUT, 1, MauvilleCity_PokemonCenter_1F_Text_28F1BE, MauvilleCity_PokemonCenter_1F_Text_28F1D5, MauvilleCity_PokemonCenter_1F_Text_28F1DE}, - {GAME_STAT_USED_ROCK_SMASH, 1, MauvilleCity_PokemonCenter_1F_Text_28F24F, MauvilleCity_PokemonCenter_1F_Text_28F269, MauvilleCity_PokemonCenter_1F_Text_28F277}, - {GAME_STAT_MOVED_SECRET_BASE, 1, MauvilleCity_PokemonCenter_1F_Text_28F2FC, MauvilleCity_PokemonCenter_1F_Text_28F314, MauvilleCity_PokemonCenter_1F_Text_28F32A}, - {GAME_STAT_USED_SPLASH, 1, MauvilleCity_PokemonCenter_1F_Text_28F3AD, MauvilleCity_PokemonCenter_1F_Text_28F3C6, MauvilleCity_PokemonCenter_1F_Text_28F3D2}, - {GAME_STAT_USED_STRUGGLE, 1, MauvilleCity_PokemonCenter_1F_Text_28F44B, MauvilleCity_PokemonCenter_1F_Text_28F461, MauvilleCity_PokemonCenter_1F_Text_28F47C}, - {GAME_STAT_SLOT_JACKPOTS, 1, MauvilleCity_PokemonCenter_1F_Text_28F50C, MauvilleCity_PokemonCenter_1F_Text_28F51B, MauvilleCity_PokemonCenter_1F_Text_28F538}, - {GAME_STAT_CONSECUTIVE_ROULETTE_WINS, 2, MauvilleCity_PokemonCenter_1F_Text_28F5BE, MauvilleCity_PokemonCenter_1F_Text_28F5D1, MauvilleCity_PokemonCenter_1F_Text_28F5F2}, - {GAME_STAT_ENTERED_BATTLE_TOWER, 1, MauvilleCity_PokemonCenter_1F_Text_28F678, MauvilleCity_PokemonCenter_1F_Text_28F694, MauvilleCity_PokemonCenter_1F_Text_28F6B4}, - {GAME_STAT_POKEBLOCKS, 1, MauvilleCity_PokemonCenter_1F_Text_28F751, MauvilleCity_PokemonCenter_1F_Text_28F76A, MauvilleCity_PokemonCenter_1F_Text_28F776}, - {GAME_STAT_ENTERED_CONTEST, 1, MauvilleCity_PokemonCenter_1F_Text_28F7F6, MauvilleCity_PokemonCenter_1F_Text_28F811, MauvilleCity_PokemonCenter_1F_Text_28F822}, - {GAME_STAT_WON_CONTEST, 1, MauvilleCity_PokemonCenter_1F_Text_28F89C, MauvilleCity_PokemonCenter_1F_Text_28F8AF, MauvilleCity_PokemonCenter_1F_Text_28F8BC}, - {GAME_STAT_SHOPPED, 1, MauvilleCity_PokemonCenter_1F_Text_28F92F, MauvilleCity_PokemonCenter_1F_Text_28F941, MauvilleCity_PokemonCenter_1F_Text_28F949}, - {GAME_STAT_USED_ITEMFINDER, 1, MauvilleCity_PokemonCenter_1F_Text_28F9D1, MauvilleCity_PokemonCenter_1F_Text_28F9EA, MauvilleCity_PokemonCenter_1F_Text_28F9FD}, - {GAME_STAT_GOT_RAINED_ON, 1, MauvilleCity_PokemonCenter_1F_Text_28FA81, MauvilleCity_PokemonCenter_1F_Text_28FA99, MauvilleCity_PokemonCenter_1F_Text_28FAA7}, - {GAME_STAT_CHECKED_POKEDEX, 1, MauvilleCity_PokemonCenter_1F_Text_28FB1D, MauvilleCity_PokemonCenter_1F_Text_28FB35, MauvilleCity_PokemonCenter_1F_Text_28FB47}, - {GAME_STAT_RECEIVED_RIBBONS, 1, MauvilleCity_PokemonCenter_1F_Text_28FBC4, MauvilleCity_PokemonCenter_1F_Text_28FBD9, MauvilleCity_PokemonCenter_1F_Text_28FBEA}, - {GAME_STAT_JUMPED_DOWN_LEDGES, 1, MauvilleCity_PokemonCenter_1F_Text_28FC6B, MauvilleCity_PokemonCenter_1F_Text_28FC85, MauvilleCity_PokemonCenter_1F_Text_28FC98}, - {GAME_STAT_WATCHED_TV, 1, MauvilleCity_PokemonCenter_1F_Text_28FD1D, MauvilleCity_PokemonCenter_1F_Text_28FD35, MauvilleCity_PokemonCenter_1F_Text_28FD40}, - {GAME_STAT_CHECKED_CLOCK, 1, MauvilleCity_PokemonCenter_1F_Text_28FDA2, MauvilleCity_PokemonCenter_1F_Text_28FDBD, MauvilleCity_PokemonCenter_1F_Text_28FDCE}, - {GAME_STAT_WON_POKEMON_LOTTERY, 1, MauvilleCity_PokemonCenter_1F_Text_28FE57, MauvilleCity_PokemonCenter_1F_Text_28FE72, MauvilleCity_PokemonCenter_1F_Text_28FE88}, - {GAME_STAT_USED_DAYCARE, 1, MauvilleCity_PokemonCenter_1F_Text_28FF0C, MauvilleCity_PokemonCenter_1F_Text_28FF27, MauvilleCity_PokemonCenter_1F_Text_28FF44}, - {GAME_STAT_RODE_CABLE_CAR, 1, MauvilleCity_PokemonCenter_1F_Text_28FFDD, MauvilleCity_PokemonCenter_1F_Text_28FFFA, MauvilleCity_PokemonCenter_1F_Text_29000D}, - {GAME_STAT_ENTERED_HOT_SPRINGS, 1, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB} -}; - void sub_8120B70(union OldMan * oldMan) { s32 i; @@ -841,3 +793,159 @@ void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3) break; } } + +void sub_8120CD0(union OldMan * oldMan, u32 unused, u32 a2) +{ + u8 sp00[8]; + s32 i; + if (oldMan->common.id == MAUVILLE_MAN_STORYTELLER && a2 == LANGUAGE_JAPANESE) + { + struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; + + for (i = 0; i < 4; i++) + { + if (storyteller->gameStatIDs[i] != 0) + { + memcpy(sp00, storyteller->trainerNames[i], 7); + sp00[7] = EOS; + if (IsStringJapanese(sp00)) + storyteller->unk34[i] = LANGUAGE_JAPANESE; + else + storyteller->unk34[i] = GAME_LANGUAGE; + } + } + } +} + +void sub_8120D34(union OldMan * oldMan, u32 r1, u32 r6) +{ + u32 r2 = (r1 == LANGUAGE_JAPANESE || r1 == LANGUAGE_ENGLISH) ? 1 : 0; + switch (oldMan->common.id) + { + case MAUVILLE_MAN_TRADER: + { + struct MauvilleOldManTrader * trader = &oldMan->trader; + s32 i; + + if (r2) + { + for (i = 0; i < 4; i++) + { + u8 * str = trader->unk5[i]; + if (str[0] == EXT_CTRL_CODE_BEGIN && str[1] == EXT_CTRL_CODE_JPN) + { + StripExtCtrlCodes(str); + trader->unk32[i] = LANGUAGE_JAPANESE; + } + else + trader->unk32[i] = r6; + } + } + else + { + for (i = 0; i < 4; i++) + { + if (trader->unk32[i] == LANGUAGE_JAPANESE) + { + StripExtCtrlCodes(trader->unk5[i]); + } + } + } + } + break; + case MAUVILLE_MAN_STORYTELLER: + { + + struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; + s32 i; + + if (r2) + { + for (i = 0; i < 4; i++) + { + if (storyteller->gameStatIDs[i] != 0) + storyteller->unk34[i] = r6; + } + } + } + break; + case MAUVILLE_MAN_BARD: + { + struct MauvilleManBard * bard = &oldMan->bard; + + if (r2) + { + bard->language = r6; + } + } + break; + case MAUVILLE_MAN_HIPSTER: + { + struct MauvilleManHipster * hipster = &oldMan->hipster; + + if (r2) + { + hipster->language = r6; + } + } + break; + case MAUVILLE_MAN_GIDDY: + { + struct MauvilleManGiddy * giddy = &oldMan->giddy; + + if (r2) + { + giddy->language = r6; + } + } + break; + } +} + +struct Story +{ + u8 stat; + u8 minVal; + const u8 *title; + const u8 *action; + const u8 *fullText; +}; + +const struct Story gUnknown_0859F048[] = { + {GAME_STAT_50, 1, MauvilleCity_PokemonCenter_1F_Text_28E930, MauvilleCity_PokemonCenter_1F_Text_28E947, MauvilleCity_PokemonCenter_1F_Text_28E956}, + {GAME_STAT_STARTED_TRENDS, 1, MauvilleCity_PokemonCenter_1F_Text_28E9D7, MauvilleCity_PokemonCenter_1F_Text_28E9EF, MauvilleCity_PokemonCenter_1F_Text_28E9FE}, + {GAME_STAT_PLANTED_BERRIES, 1, MauvilleCity_PokemonCenter_1F_Text_28EA7D, MauvilleCity_PokemonCenter_1F_Text_28EA98, MauvilleCity_PokemonCenter_1F_Text_28EAA8}, + {GAME_STAT_TRADED_BIKES, 1, MauvilleCity_PokemonCenter_1F_Text_28EB19, MauvilleCity_PokemonCenter_1F_Text_28EB31, MauvilleCity_PokemonCenter_1F_Text_28EB3E}, + {GAME_STAT_GOT_INTERVIEWED, 1, MauvilleCity_PokemonCenter_1F_Text_28EBB5, MauvilleCity_PokemonCenter_1F_Text_28EBCD, MauvilleCity_PokemonCenter_1F_Text_28EBDD}, + {GAME_STAT_TRAINER_BATTLES, 1, MauvilleCity_PokemonCenter_1F_Text_28EC60, MauvilleCity_PokemonCenter_1F_Text_28EC79, MauvilleCity_PokemonCenter_1F_Text_28EC81}, + {GAME_STAT_POKEMON_CAPTURES, 1, MauvilleCity_PokemonCenter_1F_Text_28ED04, MauvilleCity_PokemonCenter_1F_Text_28ED21, MauvilleCity_PokemonCenter_1F_Text_28ED30}, + {GAME_STAT_FISHING_CAPTURES, 1, MauvilleCity_PokemonCenter_1F_Text_28EDA1, MauvilleCity_PokemonCenter_1F_Text_28EDB5, MauvilleCity_PokemonCenter_1F_Text_28EDCF}, + {GAME_STAT_HATCHED_EGGS, 1, MauvilleCity_PokemonCenter_1F_Text_28EE45, MauvilleCity_PokemonCenter_1F_Text_28EE5D, MauvilleCity_PokemonCenter_1F_Text_28EE6A}, + {GAME_STAT_EVOLVED_POKEMON, 1, MauvilleCity_PokemonCenter_1F_Text_28EEDD, MauvilleCity_PokemonCenter_1F_Text_28EEF1, MauvilleCity_PokemonCenter_1F_Text_28EF01}, + {GAME_STAT_USED_POKECENTER, 1, MauvilleCity_PokemonCenter_1F_Text_28EF73, MauvilleCity_PokemonCenter_1F_Text_28EF95, MauvilleCity_PokemonCenter_1F_Text_28EFAA}, + {GAME_STAT_RESTED_AT_HOME, 1, MauvilleCity_PokemonCenter_1F_Text_28F045, MauvilleCity_PokemonCenter_1F_Text_28F05A, MauvilleCity_PokemonCenter_1F_Text_28F071}, + {GAME_STAT_ENTERED_SAFARI_ZONE, 1, MauvilleCity_PokemonCenter_1F_Text_28F0F3, MauvilleCity_PokemonCenter_1F_Text_28F10D, MauvilleCity_PokemonCenter_1F_Text_28F125}, + {GAME_STAT_USED_CUT, 1, MauvilleCity_PokemonCenter_1F_Text_28F1BE, MauvilleCity_PokemonCenter_1F_Text_28F1D5, MauvilleCity_PokemonCenter_1F_Text_28F1DE}, + {GAME_STAT_USED_ROCK_SMASH, 1, MauvilleCity_PokemonCenter_1F_Text_28F24F, MauvilleCity_PokemonCenter_1F_Text_28F269, MauvilleCity_PokemonCenter_1F_Text_28F277}, + {GAME_STAT_MOVED_SECRET_BASE, 1, MauvilleCity_PokemonCenter_1F_Text_28F2FC, MauvilleCity_PokemonCenter_1F_Text_28F314, MauvilleCity_PokemonCenter_1F_Text_28F32A}, + {GAME_STAT_USED_SPLASH, 1, MauvilleCity_PokemonCenter_1F_Text_28F3AD, MauvilleCity_PokemonCenter_1F_Text_28F3C6, MauvilleCity_PokemonCenter_1F_Text_28F3D2}, + {GAME_STAT_USED_STRUGGLE, 1, MauvilleCity_PokemonCenter_1F_Text_28F44B, MauvilleCity_PokemonCenter_1F_Text_28F461, MauvilleCity_PokemonCenter_1F_Text_28F47C}, + {GAME_STAT_SLOT_JACKPOTS, 1, MauvilleCity_PokemonCenter_1F_Text_28F50C, MauvilleCity_PokemonCenter_1F_Text_28F51B, MauvilleCity_PokemonCenter_1F_Text_28F538}, + {GAME_STAT_CONSECUTIVE_ROULETTE_WINS, 2, MauvilleCity_PokemonCenter_1F_Text_28F5BE, MauvilleCity_PokemonCenter_1F_Text_28F5D1, MauvilleCity_PokemonCenter_1F_Text_28F5F2}, + {GAME_STAT_ENTERED_BATTLE_TOWER, 1, MauvilleCity_PokemonCenter_1F_Text_28F678, MauvilleCity_PokemonCenter_1F_Text_28F694, MauvilleCity_PokemonCenter_1F_Text_28F6B4}, + {GAME_STAT_POKEBLOCKS, 1, MauvilleCity_PokemonCenter_1F_Text_28F751, MauvilleCity_PokemonCenter_1F_Text_28F76A, MauvilleCity_PokemonCenter_1F_Text_28F776}, + {GAME_STAT_ENTERED_CONTEST, 1, MauvilleCity_PokemonCenter_1F_Text_28F7F6, MauvilleCity_PokemonCenter_1F_Text_28F811, MauvilleCity_PokemonCenter_1F_Text_28F822}, + {GAME_STAT_WON_CONTEST, 1, MauvilleCity_PokemonCenter_1F_Text_28F89C, MauvilleCity_PokemonCenter_1F_Text_28F8AF, MauvilleCity_PokemonCenter_1F_Text_28F8BC}, + {GAME_STAT_SHOPPED, 1, MauvilleCity_PokemonCenter_1F_Text_28F92F, MauvilleCity_PokemonCenter_1F_Text_28F941, MauvilleCity_PokemonCenter_1F_Text_28F949}, + {GAME_STAT_USED_ITEMFINDER, 1, MauvilleCity_PokemonCenter_1F_Text_28F9D1, MauvilleCity_PokemonCenter_1F_Text_28F9EA, MauvilleCity_PokemonCenter_1F_Text_28F9FD}, + {GAME_STAT_GOT_RAINED_ON, 1, MauvilleCity_PokemonCenter_1F_Text_28FA81, MauvilleCity_PokemonCenter_1F_Text_28FA99, MauvilleCity_PokemonCenter_1F_Text_28FAA7}, + {GAME_STAT_CHECKED_POKEDEX, 1, MauvilleCity_PokemonCenter_1F_Text_28FB1D, MauvilleCity_PokemonCenter_1F_Text_28FB35, MauvilleCity_PokemonCenter_1F_Text_28FB47}, + {GAME_STAT_RECEIVED_RIBBONS, 1, MauvilleCity_PokemonCenter_1F_Text_28FBC4, MauvilleCity_PokemonCenter_1F_Text_28FBD9, MauvilleCity_PokemonCenter_1F_Text_28FBEA}, + {GAME_STAT_JUMPED_DOWN_LEDGES, 1, MauvilleCity_PokemonCenter_1F_Text_28FC6B, MauvilleCity_PokemonCenter_1F_Text_28FC85, MauvilleCity_PokemonCenter_1F_Text_28FC98}, + {GAME_STAT_WATCHED_TV, 1, MauvilleCity_PokemonCenter_1F_Text_28FD1D, MauvilleCity_PokemonCenter_1F_Text_28FD35, MauvilleCity_PokemonCenter_1F_Text_28FD40}, + {GAME_STAT_CHECKED_CLOCK, 1, MauvilleCity_PokemonCenter_1F_Text_28FDA2, MauvilleCity_PokemonCenter_1F_Text_28FDBD, MauvilleCity_PokemonCenter_1F_Text_28FDCE}, + {GAME_STAT_WON_POKEMON_LOTTERY, 1, MauvilleCity_PokemonCenter_1F_Text_28FE57, MauvilleCity_PokemonCenter_1F_Text_28FE72, MauvilleCity_PokemonCenter_1F_Text_28FE88}, + {GAME_STAT_USED_DAYCARE, 1, MauvilleCity_PokemonCenter_1F_Text_28FF0C, MauvilleCity_PokemonCenter_1F_Text_28FF27, MauvilleCity_PokemonCenter_1F_Text_28FF44}, + {GAME_STAT_RODE_CABLE_CAR, 1, MauvilleCity_PokemonCenter_1F_Text_28FFDD, MauvilleCity_PokemonCenter_1F_Text_28FFFA, MauvilleCity_PokemonCenter_1F_Text_29000D}, + {GAME_STAT_ENTERED_HOT_SPRINGS, 1, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB} +}; From 876e1eb7cccb729a801cfb2005f7b190955f9129 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 3 May 2018 17:51:14 -0400 Subject: [PATCH 06/10] through sub_8121064 --- asm/mauville_old_man.s | 360 ----------------------------------------- src/mauville_old_man.c | 138 +++++++++++++++- 2 files changed, 137 insertions(+), 361 deletions(-) diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s index 368dedf93..00f4192f8 100644 --- a/asm/mauville_old_man.s +++ b/asm/mauville_old_man.s @@ -5,366 +5,6 @@ .text - thumb_func_start sub_8120E08 -sub_8120E08: @ 8120E08 - push {r4,r5,lr} - ldr r2, =gUnknown_0203A12C - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002e28 - adds r0, r1 - str r0, [r2] - movs r3, 0 - movs r1, 0x3 - strb r1, [r0] - ldr r0, [r2] - strb r3, [r0, 0x1] - movs r5, 0 - movs r4, 0xFF -_08120E24: - ldr r0, [r2] - adds r0, 0x4 - adds r0, r3 - strb r5, [r0] - ldr r1, [r2] - adds r1, 0x8 - adds r1, r3 - ldrb r0, [r1] - orrs r0, r4 - strb r0, [r1] - adds r3, 0x1 - cmp r3, 0x3 - ble _08120E24 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120E08 - - thumb_func_start sub_8120E50 -sub_8120E50: @ 8120E50 - ldr r3, =gUnknown_0203A12C - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002e28 - adds r0, r1 - str r0, [r3] - movs r2, 0 - movs r1, 0x3 - strb r1, [r0] - ldr r0, [r3] - strb r2, [r0, 0x1] - bx lr - .pool - thumb_func_end sub_8120E50 - - thumb_func_start sub_8120E74 -sub_8120E74: @ 8120E74 - push {lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x32 - bne _08120E80 - movs r0, 0 -_08120E80: - bl GetGameStat - pop {r1} - bx r1 - thumb_func_end sub_8120E74 - - thumb_func_start sub_8120E88 -sub_8120E88: @ 8120E88 - push {lr} - adds r3, r0, 0 - movs r2, 0 - ldr r1, =gUnknown_0859F048 -_08120E90: - ldrb r0, [r1] - cmp r0, r3 - bne _08120EA0 - adds r0, r1, 0 - b _08120EAA - .pool -_08120EA0: - adds r1, 0x10 - adds r2, 0x1 - cmp r2, 0x23 - ble _08120E90 - ldr r0, =gUnknown_0859F048+0x230 -_08120EAA: - pop {r1} - bx r1 - .pool - thumb_func_end sub_8120E88 - - thumb_func_start sub_8120EB4 -sub_8120EB4: @ 8120EB4 - push {lr} - bl sub_8120E88 - ldr r0, [r0, 0x4] - pop {r1} - bx r1 - thumb_func_end sub_8120EB4 - - thumb_func_start sub_8120EC0 -sub_8120EC0: @ 8120EC0 - push {lr} - bl sub_8120E88 - ldr r0, [r0, 0xC] - pop {r1} - bx r1 - thumb_func_end sub_8120EC0 - - thumb_func_start sub_8120ECC -sub_8120ECC: @ 8120ECC - push {lr} - bl sub_8120E88 - ldr r0, [r0, 0x8] - pop {r1} - bx r1 - thumb_func_end sub_8120ECC - - thumb_func_start sub_8120ED8 -sub_8120ED8: @ 8120ED8 - push {lr} - movs r1, 0 - ldr r2, =gUnknown_0203A12C - ldr r0, [r2] - ldrb r0, [r0, 0x4] - cmp r0, 0 - beq _08120EFC -_08120EE6: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x3 - bhi _08120EFC - ldr r0, [r2] - adds r0, 0x4 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _08120EE6 -_08120EFC: - adds r0, r1, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8120ED8 - - thumb_func_start sub_8120F08 -sub_8120F08: @ 8120F08 - ldr r1, =gUnknown_0203A12C - lsls r0, 2 - adds r0, 0x24 - ldr r2, [r1] - adds r2, r0 - ldrb r0, [r2] - ldrb r1, [r2, 0x1] - lsls r1, 8 - orrs r0, r1 - ldrb r1, [r2, 0x2] - lsls r1, 16 - orrs r0, r1 - ldrb r1, [r2, 0x3] - lsls r1, 24 - orrs r0, r1 - bx lr - .pool - thumb_func_end sub_8120F08 - - thumb_func_start sub_8120F2C -sub_8120F2C: @ 8120F2C - ldr r2, =gUnknown_0203A12C - lsls r0, 2 - adds r0, 0x24 - ldr r2, [r2] - adds r2, r0 - strb r1, [r2] - lsrs r0, r1, 8 - strb r0, [r2, 0x1] - lsrs r0, r1, 16 - strb r0, [r2, 0x2] - lsrs r1, 24 - strb r1, [r2, 0x3] - bx lr - .pool - thumb_func_end sub_8120F2C - - thumb_func_start sub_8120F4C -sub_8120F4C: @ 8120F4C - push {r4,r5,lr} - adds r5, r0, 0 - ldr r0, =gUnknown_0203A12C - ldr r0, [r0] - adds r0, 0x4 - adds r0, r5 - ldrb r0, [r0] - bl sub_8120E74 - adds r4, r0, 0 - adds r0, r5, 0 - bl sub_8120F08 - cmp r4, r0 - bhi _08120F74 - movs r0, 0 - b _08120F76 - .pool -_08120F74: - movs r0, 0x1 -_08120F76: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8120F4C - - thumb_func_start sub_8120F7C -sub_8120F7C: @ 8120F7C - push {r4,r5,lr} - adds r5, r1, 0 - ldr r2, =gUnknown_0203A12C - lsls r1, r0, 3 - subs r1, r0 - adds r1, 0x8 - ldr r4, [r2] - adds r4, r1 - adds r0, r5, 0 - movs r1, 0xFF - movs r2, 0x8 - bl memset - adds r0, r5, 0 - adds r1, r4, 0 - movs r2, 0x7 - bl memcpy - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120F7C - - thumb_func_start sub_8120FAC -sub_8120FAC: @ 8120FAC - push {r4,r5,lr} - adds r5, r1, 0 - ldr r2, =gUnknown_0203A12C - lsls r1, r0, 3 - subs r1, r0 - adds r1, 0x8 - ldr r4, [r2] - adds r4, r1 - adds r0, r4, 0 - movs r1, 0xFF - movs r2, 0x7 - bl memset - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x7 - bl memcpy - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120FAC - - thumb_func_start sub_8120FDC -sub_8120FDC: @ 8120FDC - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - mov r8, r0 - adds r6, r1, 0 - ldr r0, =gUnknown_0203A12C - mov r9, r0 - ldr r0, [r0] - adds r0, 0x4 - add r0, r8 - strb r6, [r0] - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - mov r0, r8 - bl sub_8120FAC - lsls r4, r6, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl sub_8120E74 - adds r1, r0, 0 - mov r0, r8 - bl sub_8120F2C - ldr r5, =gStringVar1 - adds r0, r4, 0 - bl sub_8120E74 - adds r1, r0, 0 - adds r0, r5, 0 - movs r2, 0 - movs r3, 0xA - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar2 - adds r0, r6, 0 - bl sub_8120ECC - adds r1, r0, 0 - adds r0, r4, 0 - bl StringCopy - mov r1, r9 - ldr r0, [r1] - adds r0, 0x34 - add r0, r8 - ldr r1, =gGameLanguage - ldrb r1, [r1] - strb r1, [r0] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120FDC - - thumb_func_start sub_8121064 -sub_8121064: @ 8121064 - push {r4-r7,lr} - adds r7, r0, 0 - adds r6, r1, 0 - movs r5, 0 - cmp r5, r6 - bge _0812107A -_08121070: - adds r0, r7, r5 - strb r5, [r0] - adds r5, 0x1 - cmp r5, r6 - blt _08121070 -_0812107A: - cmp r6, 0 - ble _081210B0 - adds r5, r6, 0 -_08121080: - bl Random - lsls r0, 16 - lsrs r0, 16 - adds r1, r6, 0 - bl __modsi3 - adds r4, r0, 0 - bl Random - lsls r0, 16 - lsrs r0, 16 - adds r1, r6, 0 - bl __modsi3 - adds r4, r7, r4 - ldrb r2, [r4] - adds r0, r7, r0 - ldrb r1, [r0] - strb r1, [r4] - strb r2, [r0] - subs r5, 0x1 - cmp r5, 0 - bne _08121080 -_081210B0: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8121064 - thumb_func_start sub_81210B8 sub_81210B8: @ 81210B8 push {r4-r7,lr} diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 1f398569c..04af0e066 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -18,6 +18,7 @@ #include "bard_music.h" #include "sound.h" #include "strings.h" +#include "overworld.h" #define CHAR_SONG_WORD_SEPARATOR 0x37 @@ -35,7 +36,7 @@ void sub_8133A60(void); struct BardSong gUnknown_03006130; EWRAM_DATA u16 gUnknown_0203A128 = 0; -EWRAM_DATA struct MauvilleOldMan * gUnknown_0203A12C = NULL; +EWRAM_DATA struct MauvilleManStoryteller * gUnknown_0203A12C = NULL; EWRAM_DATA u8 gUnknown_0203A130 = 0; static const u16 sDefaultBardSongLyrics[6] = { @@ -949,3 +950,138 @@ const struct Story gUnknown_0859F048[] = { {GAME_STAT_RODE_CABLE_CAR, 1, MauvilleCity_PokemonCenter_1F_Text_28FFDD, MauvilleCity_PokemonCenter_1F_Text_28FFFA, MauvilleCity_PokemonCenter_1F_Text_29000D}, {GAME_STAT_ENTERED_HOT_SPRINGS, 1, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB} }; + +void sub_8120E08(void) // StorytellerSetup +{ + s32 i; + gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; + + gUnknown_0203A12C->id = MAUVILLE_MAN_STORYTELLER; + gUnknown_0203A12C->alreadyRecorded = FALSE; + for (i = 0; i < 4; i++) + { + gUnknown_0203A12C->gameStatIDs[i] = 0; + gUnknown_0203A12C->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead? + } +} + +void sub_8120E50(void) +{ + gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; + + gUnknown_0203A12C->id = MAUVILLE_MAN_STORYTELLER; + gUnknown_0203A12C->alreadyRecorded = FALSE; +} + +u32 sub_8120E74(u8 stat) // StorytellerGetGameStat +{ + if (stat == 50) + stat = 0; + return GetGameStat(stat); +} + +const struct Story *sub_8120E88(u32 stat) // GetStoryByStat +{ + s32 i; + + for (i = 0; i < 36; i++) + { + if (gUnknown_0859F048[i].stat == stat) + return &gUnknown_0859F048[i]; + } + return &gUnknown_0859F048[35]; +} + +const u8 *sub_8120EB4(u32 stat) // GetStoryTitleByStat +{ + return sub_8120E88(stat)->title; +} + +const u8 *sub_8120EC0(u32 stat) // GetStoryTextByStat +{ + return sub_8120E88(stat)->fullText; +} + +const u8 *sub_8120ECC(u32 stat) // GetStoryActionByStat +{ + return sub_8120E88(stat)->action; +} + +u8 sub_8120ED8(void) // GetFreeStorySlot +{ + u8 i; + + for (i = 0; i < 4; i++) + { + if (gUnknown_0203A12C->gameStatIDs[i] == 0) + break; + } + return i; +} + +u32 sub_8120F08(u32 trainer) // StorytellerGetRecordedTrainerStat +{ + u8 *ptr = gUnknown_0203A12C->statValues[trainer]; + + return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); +} + +void sub_8120F2C(u32 trainer, u32 val) // StorytellerSetRecordedTrainerStat +{ + u8 *ptr = gUnknown_0203A12C->statValues[trainer]; + + ptr[0] = val; + ptr[1] = val >> 8; + ptr[2] = val >> 16; + ptr[3] = val >> 24; +} + +bool32 sub_8120F4C(u32 trainer) // HasTrainerStatIncreased +{ + if (sub_8120E74(gUnknown_0203A12C->gameStatIDs[trainer]) > sub_8120F08(trainer)) + return TRUE; + else + return FALSE; +} + +void sub_8120F7C(u32 player, void *dst) // GetStoryByStattellerPlayerName +{ + u8 *name = gUnknown_0203A12C->trainerNames[player]; + + memset(dst, EOS, 8); + memcpy(dst, name, 7); +} + +void sub_8120FAC(u32 player, const u8 * src) // StorytellerSetPlayerName +{ + u8 * name = gUnknown_0203A12C->trainerNames[player]; + memset(name, EOS, 7); + memcpy(name, src, 7); +} + + +void sub_8120FDC(u32 player, u32 stat) // StorytellerRecordNewStat +{ + gUnknown_0203A12C->gameStatIDs[player] = stat; + sub_8120FAC(player, gSaveBlock2Ptr->playerName); + sub_8120F2C(player, sub_8120E74(stat)); + ConvertIntToDecimalStringN(gStringVar1, sub_8120E74(stat), STR_CONV_MODE_LEFT_ALIGN, 10); + StringCopy(gStringVar2, sub_8120ECC(stat)); + gUnknown_0203A12C->unk34[player] = gGameLanguage; +} + +void sub_8121064(u8 * arr, s32 count) // ScrambleStatList +{ + 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; + } +} From 8aa462cd747ab3c3127401aa8905d0bdd5e2a1f4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 3 May 2018 18:05:07 -0400 Subject: [PATCH 07/10] through sub_8121178 --- asm/mauville_old_man.s | 141 ---------------------------------------- data/mauville_old_man.s | 8 --- ld_script.txt | 1 - src/mauville_old_man.c | 55 ++++++++++++++++ sym_bss.txt | 6 +- 5 files changed, 57 insertions(+), 154 deletions(-) delete mode 100644 data/mauville_old_man.s diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s index 00f4192f8..950abfb64 100644 --- a/asm/mauville_old_man.s +++ b/asm/mauville_old_man.s @@ -5,147 +5,6 @@ .text - thumb_func_start sub_81210B8 -sub_81210B8: @ 81210B8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - mov r7, sp - mov r8, sp - ldr r0, =gUnknown_0859F288 - ldr r0, [r0] - lsls r0, 3 - lsrs r0, 3 - adds r0, 0x3 - lsrs r0, 2 - lsls r0, 2 - mov r1, sp - subs r1, r0 - mov sp, r1 - mov r9, sp - mov r0, sp - movs r1, 0x24 - bl sub_8121064 - movs r5, 0 -_081210E4: - ldr r1, =gUnknown_0859F048 - mov r2, r9 - adds r0, r2, r5 - ldrb r0, [r0] - lsls r0, 4 - adds r0, r1 - ldrb r4, [r0] - ldrb r6, [r0, 0x1] - movs r1, 0 - ldr r2, =gUnknown_0203A12C - ldr r0, [r2] - ldrb r0, [r0, 0x4] - cmp r0, r4 - beq _08121112 -_08121100: - adds r1, 0x1 - cmp r1, 0x3 - bgt _08121112 - ldr r0, [r2] - adds r0, 0x4 - adds r0, r1 - ldrb r0, [r0] - cmp r0, r4 - bne _08121100 -_08121112: - cmp r1, 0x4 - bne _08121162 - adds r0, r4, 0 - bl sub_8120E74 - cmp r0, r6 - bcc _08121162 - ldr r0, =gUnknown_0203A12C - ldr r1, [r0] - movs r0, 0x1 - strb r0, [r1, 0x1] - bl sub_8120ED8 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bne _08121150 - ldr r0, =gUnknown_03001178 - ldrb r0, [r0] - adds r1, r4, 0 - bl sub_8120FDC - b _0812115E - .pool -_08121150: - bl sub_8120ED8 - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - bl sub_8120FDC -_0812115E: - movs r0, 0x1 - b _0812116A -_08121162: - adds r5, 0x1 - cmp r5, 0x23 - ble _081210E4 - movs r0, 0 -_0812116A: - mov sp, r8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81210B8 - - thumb_func_start sub_8121178 -sub_8121178: @ 8121178 - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r5, r0, 0 - ldr r6, =gUnknown_0203A12C - ldr r0, [r6] - adds r0, 0x4 - adds r0, r5 - ldrb r0, [r0] - mov r8, r0 - ldr r4, =gStringVar1 - adds r0, r5, 0 - bl sub_8120F08 - adds r1, r0, 0 - adds r0, r4, 0 - movs r2, 0 - movs r3, 0xA - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar2 - mov r0, r8 - bl sub_8120ECC - adds r1, r0, 0 - adds r0, r4, 0 - bl StringCopy - ldr r4, =gStringVar3 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8120F7C - ldr r0, [r6] - adds r0, 0x34 - adds r0, r5 - ldrb r1, [r0] - adds r0, r4, 0 - bl ConvertInternationalString - mov r0, r8 - bl sub_8120EC0 - bl ShowFieldMessage - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8121178 - thumb_func_start sub_81211EC sub_81211EC: @ 81211EC push {r4,r5,lr} diff --git a/data/mauville_old_man.s b/data/mauville_old_man.s deleted file mode 100644 index fe7056541..000000000 --- a/data/mauville_old_man.s +++ /dev/null @@ -1,8 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - -gUnknown_0859F288:: @ 859F288 - .4byte 0x00000024, 0x00000008 diff --git a/ld_script.txt b/ld_script.txt index c975586a6..e1cc109a6 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -458,7 +458,6 @@ SECTIONS { data/easy_chat.o(.rodata); src/mon_markings.o(.rodata); src/mauville_old_man.o(.rodata); - data/mauville_old_man.o(.rodata); src/mail.o(.rodata); data/menu_helpers.o(.rodata); src/heal_location.o(.rodata); diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 04af0e066..4f85d4577 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -19,6 +19,7 @@ #include "sound.h" #include "strings.h" #include "overworld.h" +#include "field_message_box.h" #define CHAR_SONG_WORD_SEPARATOR 0x37 @@ -33,6 +34,8 @@ void sub_8120E50(void); void sub_81339F8(void); // TraderSetup void sub_8133A60(void); +IWRAM_DATA u8 gUnknown_03001178; + struct BardSong gUnknown_03006130; EWRAM_DATA u16 gUnknown_0203A128 = 0; @@ -1085,3 +1088,55 @@ void sub_8121064(u8 * arr, s32 count) // ScrambleStatList arr[b] = temp; } } + +struct UnknownStruct_0859F288 +{ + u32 length; + u32 unused2; +}; + +const struct UnknownStruct_0859F288 gUnknown_0859F288 = { + 36, + 8 +}; + +bool8 sub_81210B8(void) // StorytellerInitializeRandomStat +{ + u8 arr[gUnknown_0859F288.length]; + s32 i; + s32 j; + + sub_8121064(arr, 36); + for (i = 0; i < 36; i++) + { + u8 stat = gUnknown_0859F048[arr[i]].stat; + u8 minVal = gUnknown_0859F048[arr[i]].minVal; + + for (j = 0; j < 4; j++) + { + if (gUnknown_0203A12C->gameStatIDs[j] == stat) + break; + } + if (j == 4 && sub_8120E74(stat) >= minVal) + { + gUnknown_0203A12C->alreadyRecorded = TRUE; + if (sub_8120ED8() == 4) + sub_8120FDC(gUnknown_03001178, stat); + else + sub_8120FDC(sub_8120ED8(), stat); + return TRUE; + } + } + return FALSE; +} + +void sub_8121178(u32 player) // StorytellerDisplayStory +{ + u8 stat = gUnknown_0203A12C->gameStatIDs[player]; + + ConvertIntToDecimalStringN(gStringVar1, sub_8120F08(player), 0, 10); + StringCopy(gStringVar2, sub_8120ECC(stat)); + sub_8120F7C(player, gStringVar3); + ConvertInternationalString(gStringVar3, gUnknown_0203A12C->unk34[player]); + ShowFieldMessage(sub_8120EC0(stat)); +} diff --git a/sym_bss.txt b/sym_bss.txt index 24e6afa3b..186ff8ced 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -28,11 +28,9 @@ .include "src/script_menu.o" .include "src/record_mixing.o" .include "src/tv.o" + .include "src/mauville_old_man.o" - .space 1 @ TODO: define this u32 in mauville_old_man -gUnknown_03001178: @ 3001178 - .space 0x4 - + .align 2 gUnknown_0300117C: @ 300117C .space 0x4 From 0231ed13ee72e0ccb06319a439c04381ace4b1ef Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 7 May 2018 16:35:29 -0400 Subject: [PATCH 08/10] Remaining functions in mauville_old_man --- asm/mauville_old_man.s | 310 ----------------------------------------- include/script_menu.h | 3 + ld_script.txt | 1 - src/mauville_old_man.c | 112 +++++++++++++++ 4 files changed, 115 insertions(+), 311 deletions(-) delete mode 100644 asm/mauville_old_man.s diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s deleted file mode 100644 index 950abfb64..000000000 --- a/asm/mauville_old_man.s +++ /dev/null @@ -1,310 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_81211EC -sub_81211EC: @ 81211EC - push {r4,r5,lr} - sub sp, 0xC - ldr r1, =gText_Exit - movs r0, 0x1 - movs r2, 0 - bl GetStringWidth - adds r5, r0, 0 - movs r4, 0 - ldr r0, =gUnknown_0203A12C - ldr r0, [r0] - ldrb r0, [r0, 0x4] - cmp r0, 0 - beq _08121230 -_08121208: - bl sub_8120EB4 - adds r1, r0, 0 - movs r0, 0x1 - movs r2, 0 - bl GetStringWidth - cmp r0, r5 - ble _0812121C - adds r5, r0, 0 -_0812121C: - adds r4, 0x1 - cmp r4, 0x3 - bgt _08121230 - ldr r0, =gUnknown_0203A12C - ldr r0, [r0] - adds r0, 0x4 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - bne _08121208 -_08121230: - adds r0, r5, 0 - bl convert_pixel_width_to_tile_width - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl sub_8120ED8 - adds r3, r0, 0 - lsls r3, 25 - movs r0, 0x80 - lsls r0, 18 - adds r3, r0 - lsrs r3, 24 - movs r0, 0 - movs r1, 0 - adds r2, r4, 0 - bl CreateWindowFromRect - ldr r1, =gUnknown_0203A130 - strb r0, [r1] - ldrb r0, [r1] - movs r1, 0 - bl SetStandardWindowBorderStyle - movs r4, 0 - ldr r0, =gUnknown_0203A12C - ldr r0, [r0] - ldrb r0, [r0, 0x4] - cmp r0, 0 - beq _081212AA - movs r5, 0x80 - lsls r5, 17 -_08121272: - bl sub_8120EB4 - adds r2, r0, 0 - ldr r0, =gUnknown_0203A130 - ldrb r0, [r0] - lsrs r1, r5, 24 - str r1, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - movs r1, 0 - str r1, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x8 - bl PrintTextOnWindow - movs r0, 0x80 - lsls r0, 21 - adds r5, r0 - adds r4, 0x1 - cmp r4, 0x3 - bgt _081212AA - ldr r0, =gUnknown_0203A12C - ldr r0, [r0] - adds r0, 0x4 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - bne _08121272 -_081212AA: - ldr r5, =gUnknown_0203A130 - ldrb r0, [r5] - ldr r2, =gText_Exit - lsls r1, r4, 4 - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - movs r1, 0 - str r1, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x8 - bl PrintTextOnWindow - ldrb r4, [r5] - bl sub_8120ED8 - adds r1, r0, 0 - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - movs r2, 0 - bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed - ldrb r0, [r5] - movs r1, 0x3 - bl CopyWindowToVram - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81211EC - - thumb_func_start sub_81212FC -sub_81212FC: @ 81212FC - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r0, 0x8 - ldrsh r5, [r4, r0] - cmp r5, 0 - beq _08121320 - cmp r5, 0x1 - beq _0812132C - b _08121376 - .pool -_08121320: - bl sub_81211EC - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08121376 -_0812132C: - bl ProcessMenuInput - lsls r0, 24 - asrs r4, r0, 24 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _08121376 - adds r0, 0x1 - cmp r4, r0 - beq _0812134E - bl sub_8120ED8 - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bne _0812135C -_0812134E: - ldr r1, =gSpecialVar_Result - movs r0, 0 - strh r0, [r1] - b _08121364 - .pool -_0812135C: - ldr r0, =gSpecialVar_Result - strh r5, [r0] - ldr r0, =gUnknown_03001178 - strb r4, [r0] -_08121364: - ldr r0, =gUnknown_0203A130 - ldrb r0, [r0] - bl sub_80E2A78 - adds r0, r6, 0 - bl DestroyTask - bl EnableBothScriptContexts -_08121376: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81212FC - - thumb_func_start sub_8121388 -sub_8121388: @ 8121388 - push {lr} - ldr r0, =sub_81212FC - movs r1, 0x50 - bl CreateTask - pop {r0} - bx r0 - .pool - thumb_func_end sub_8121388 - - thumb_func_start sub_812139C -sub_812139C: @ 812139C - push {lr} - ldr r0, =gUnknown_03001178 - ldrb r0, [r0] - bl sub_8121178 - pop {r0} - bx r0 - .pool - thumb_func_end sub_812139C - - thumb_func_start sub_81213B0 -sub_81213B0: @ 81213B0 - push {lr} - ldr r1, =gUnknown_0203A12C - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00002e28 - adds r0, r2 - str r0, [r1] - bl sub_8120ED8 - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end sub_81213B0 - - thumb_func_start sub_81213D8 -sub_81213D8: @ 81213D8 - push {r4,r5,lr} - ldr r2, =gUnknown_0203A12C - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r3, =0x00002e28 - adds r0, r1, r3 - str r0, [r2] - ldr r5, =gUnknown_03001178 - ldrb r0, [r5] - ldr r2, =0x00002e2c - adds r1, r2 - adds r1, r0 - ldrb r4, [r1] - bl sub_8120F4C - cmp r0, 0x1 - beq _08121414 - movs r0, 0 - b _0812141E - .pool -_08121414: - ldrb r0, [r5] - adds r1, r4, 0 - bl sub_8120FDC - movs r0, 0x1 -_0812141E: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81213D8 - - thumb_func_start sub_8121424 -sub_8121424: @ 8121424 - push {lr} - ldr r1, =gUnknown_0203A12C - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00002e28 - adds r0, r2 - str r0, [r1] - ldrb r0, [r0, 0x1] - cmp r0, 0 - beq _08121448 - movs r0, 0x1 - b _0812144A - .pool -_08121448: - movs r0, 0 -_0812144A: - pop {r1} - bx r1 - thumb_func_end sub_8121424 - - thumb_func_start sub_8121450 -sub_8121450: @ 8121450 - push {lr} - ldr r1, =gUnknown_0203A12C - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00002e28 - adds r0, r2 - str r0, [r1] - bl sub_81210B8 - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8121450 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/script_menu.h b/include/script_menu.h index 717eda041..0555d0f78 100644 --- a/include/script_menu.h +++ b/include/script_menu.h @@ -9,5 +9,8 @@ bool8 ScriptMenu_YesNo(u8 var1, u8 var2); bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 a4, u8 columnCount); bool8 ScriptMenu_ShowPokemonPic(u16 var1, u8 var2, u8 var3); bool8 (*ScriptMenu_GetPicboxWaitFunc(void))(void); +u8 convert_pixel_width_to_tile_width(s32); +u8 CreateWindowFromRect(u8, u8, u8, u8); +void sub_80E2A78(u8); #endif //GUARD_SCRIPT_MENU_H diff --git a/ld_script.txt b/ld_script.txt index e1cc109a6..e961f4e3c 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -163,7 +163,6 @@ SECTIONS { asm/easy_chat.o(.text); src/mon_markings.o(.text); src/mauville_old_man.o(.text); - asm/mauville_old_man.o(.text); src/mail.o(.text); asm/menu_helpers.o(.text); src/dewford_trend.o(.text); diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 4f85d4577..a21af6f95 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -20,6 +20,7 @@ #include "strings.h" #include "overworld.h" #include "field_message_box.h" +#include "script_menu.h" #define CHAR_SONG_WORD_SEPARATOR 0x37 @@ -1140,3 +1141,114 @@ void sub_8121178(u32 player) // StorytellerDisplayStory ConvertInternationalString(gStringVar3, gUnknown_0203A12C->unk34[player]); ShowFieldMessage(sub_8120EC0(stat)); } + +void sub_81211EC(void) // PrintStoryList +{ + s32 i; + s32 width = GetStringWidth(1, gText_Exit, 0); + u8 tileWidth; + for (i = 0; i < 4; i++) + { + s32 curWidth; + u16 gameStatID = gUnknown_0203A12C->gameStatIDs[i]; + + if (gameStatID == 0) + break; + curWidth = GetStringWidth(1, sub_8120EB4(gameStatID), 0); + if (curWidth > width) + width = curWidth; + } + gUnknown_0203A130 = CreateWindowFromRect(0, 0, convert_pixel_width_to_tile_width(width), sub_8120ED8() * 2 + 2); + SetStandardWindowBorderStyle(gUnknown_0203A130, 0); + for (i = 0; i < 4; i++) + { + u16 gameStatID = gUnknown_0203A12C->gameStatIDs[i]; + if (gameStatID == 0) + break; + PrintTextOnWindow(gUnknown_0203A130, 1, sub_8120EB4(gameStatID), 8, 16 * i + 1, 0xFF, NULL); + } + PrintTextOnWindow(gUnknown_0203A130, 1, gText_Exit, 8, 16 * i + 1, 0xFF, NULL); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_0203A130, sub_8120ED8() + 1, 0); + CopyWindowToVram(gUnknown_0203A130, 3); +} + +void sub_81212FC(u8 taskId) // Task_StoryListMenu +{ + struct Task *task = &gTasks[taskId]; + s32 selection; + + switch (task->data[0]) + { + case 0: + sub_81211EC(); + task->data[0]++; + break; + case 1: + selection = ProcessMenuInput(); + if (selection == -2) + break; + if (selection == -1 || selection == sub_8120ED8()) + { + gSpecialVar_Result = 0; + } + else + { + gSpecialVar_Result = 1; + gUnknown_03001178 = selection; + } + sub_80E2A78(gUnknown_0203A130); + DestroyTask(taskId); + EnableBothScriptContexts(); + break; + } +} + +// Sets gSpecialVar_Result to TRUE if player selected a story +void sub_8121388(void) // ScrSpecial_StorytellerStoryListMenu +{ + CreateTask(sub_81212FC, 80); +} + +void sub_812139C(void) // ScrSpecial_StorytellerDisplayStory +{ + sub_8121178(gUnknown_03001178); +} + +u8 sub_81213B0(void) // ScrSpecial_StorytellerDisplayStory +{ + gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; + return sub_8120ED8(); +} + +// Returns TRUE if stat has increased +bool8 sub_81213D8(void) // ScrSpecial_StorytellerUpdateStat +{ + u8 r4; + gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; + r4 = gUnknown_0203A12C->gameStatIDs[gUnknown_03001178]; + + if (sub_8120F4C(gUnknown_03001178) == TRUE) + { + sub_8120FDC(gUnknown_03001178, r4); + return TRUE; + } + return FALSE; +} + + +bool8 sub_8121424(void) // ScrSpecial_HasStorytellerAlreadyRecorded +{ + gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; + + if (gUnknown_0203A12C->alreadyRecorded == FALSE) + return FALSE; + else + return TRUE; +} + +bool8 sub_8121450(void) // ScrSpecial_StorytellerInitializeRandomStat +{ + gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; + return sub_81210B8(); +} + From 61cc1d55743715a64e793187f63d0f1f7a80b0e0 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 7 May 2018 18:11:20 -0400 Subject: [PATCH 09/10] Rename symbols using Ruby as a reference --- asm/record_mixing.s | 2 +- asm/trader.s | 6 +- common_syms/mauville_old_man.txt | 2 +- .../maps/MauvilleCity_PokemonCenter_1F.inc | 2 +- data/scripts/mauville_man.inc | 34 +- data/specials.inc | 32 +- include/global.h | 6 +- include/mauville_old_man.h | 5 +- include/trader.h | 2 + src/field_map_obj.c | 2 +- src/mauville_old_man.c | 363 +++++++++--------- 11 files changed, 226 insertions(+), 230 deletions(-) diff --git a/asm/record_mixing.s b/asm/record_mixing.s index 2dab009a5..acfcf48ed 100644 --- a/asm/record_mixing.s +++ b/asm/record_mixing.s @@ -1438,7 +1438,7 @@ _080E791A: add r1, r9 movs r2, 0x40 bl memcpy - bl sub_8120670 + bl ResetMauvilleOldManFlag add sp, 0x10 pop {r3,r4} mov r8, r3 diff --git a/asm/trader.s b/asm/trader.s index a43f59402..3e4b1feda 100644 --- a/asm/trader.s +++ b/asm/trader.s @@ -51,8 +51,8 @@ _08133A12: .pool thumb_func_end sub_81339F8 - thumb_func_start sub_8133A60 -sub_8133A60: @ 8133A60 + thumb_func_start Trader_ResetFlag +Trader_ResetFlag: @ 8133A60 ldr r0, =gSaveBlock1Ptr ldr r0, [r0] ldr r1, =0x00002e59 @@ -61,7 +61,7 @@ sub_8133A60: @ 8133A60 strb r1, [r0] bx lr .pool - thumb_func_end sub_8133A60 + thumb_func_end Trader_ResetFlag thumb_func_start sub_8133A78 sub_8133A78: @ 8133A78 diff --git a/common_syms/mauville_old_man.txt b/common_syms/mauville_old_man.txt index cc2c037c3..edb40a31c 100644 --- a/common_syms/mauville_old_man.txt +++ b/common_syms/mauville_old_man.txt @@ -1 +1 @@ -gUnknown_03006130 \ No newline at end of file +gBardSong \ No newline at end of file diff --git a/data/scripts/maps/MauvilleCity_PokemonCenter_1F.inc b/data/scripts/maps/MauvilleCity_PokemonCenter_1F.inc index 9b8561873..03b7928aa 100644 --- a/data/scripts/maps/MauvilleCity_PokemonCenter_1F.inc +++ b/data/scripts/maps/MauvilleCity_PokemonCenter_1F.inc @@ -10,7 +10,7 @@ MauvilleCity_PokemonCenter_1F_MapScript1_210E66: @ 8210E66 end MauvilleCity_PokemonCenter_1F_EventScript_210E74:: @ 8210E74 - special sub_8120B5C + special ScrSpecial_SetMauvilleOldManMapObjGfx end MauvilleCity_PokemonCenter_1F_EventScript_210E78:: @ 8210E78 diff --git a/data/scripts/mauville_man.inc b/data/scripts/mauville_man.inc index 2e00ee702..e59d0e1e0 100644 --- a/data/scripts/mauville_man.inc +++ b/data/scripts/mauville_man.inc @@ -1,5 +1,5 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E066:: @ 828E066 - special sub_81201DC + special ScrSpecial_GetCurrentMauvilleMan switch VAR_RESULT case 0, MauvilleCity_PokemonCenter_1F_EventScript_28E0A6 case 1, MauvilleCity_PokemonCenter_1F_EventScript_28E167 @@ -20,9 +20,9 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E0A6:: @ 828E0A6 MauvilleCity_PokemonCenter_1F_EventScript_28E0C7:: @ 828E0C7 setvar VAR_0x8004, 0 - special sub_8120340 + special ScrSpecial_PlayBardSong delay 60 - special sub_81201F4 + special ScrSpecial_HasBardSongBeenChanged compare VAR_RESULT, 0 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E0F4 msgbox MauvilleCity_PokemonCenter_1F_Text_2903E6, 4 @@ -51,12 +51,12 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E113:: @ 828E113 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E15D msgbox MauvilleCity_PokemonCenter_1F_Text_2904C1, 4 setvar VAR_0x8004, 1 - special sub_8120340 + special ScrSpecial_PlayBardSong delay 60 msgbox MauvilleCity_PokemonCenter_1F_Text_2904EB, 5 compare VAR_RESULT, 0 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E113 - special sub_8120210 + special ScrSpecial_SaveBardSongLyrics msgbox MauvilleCity_PokemonCenter_1F_Text_290514, 4 release end @@ -71,7 +71,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E167:: @ 828E167 faceplayer setflag FLAG_SYS_HIPSTER_MEET msgbox MauvilleCity_PokemonCenter_1F_Text_29054C, 4 - special sub_8120358 + special ScrSpecial_GetHipsterSpokenFlag compare VAR_RESULT, 0 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E18C msgbox MauvilleCity_PokemonCenter_1F_Text_290598, 4 @@ -79,7 +79,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E167:: @ 828E167 end MauvilleCity_PokemonCenter_1F_EventScript_28E18C:: @ 828E18C - special sub_812038C + special ScrSpecial_HipsterTeachWord compare VAR_RESULT, 1 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_28E1A4 msgbox MauvilleCity_PokemonCenter_1F_Text_290602, 4 @@ -88,7 +88,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_28E18C:: @ 828E18C MauvilleCity_PokemonCenter_1F_EventScript_28E1A4:: @ 828E1A4 msgbox MauvilleCity_PokemonCenter_1F_Text_290666, 4 - special sub_8120374 + special ScrSpecial_SetHipsterSpokenFlag release end @@ -813,20 +813,20 @@ MauvilleCity_PokemonCenter_1F_EventScript_29014A:: @ 829014A msgbox MauvilleCity_PokemonCenter_1F_Text_28E5F6, 5 compare VAR_RESULT, 0 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_290219 - specialvar VAR_RESULT, sub_81213B0 + specialvar VAR_RESULT, ScrSpecial_StorytellerGetFreeStorySlot compare VAR_RESULT, 0 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_2901DA message MauvilleCity_PokemonCenter_1F_Text_28E673 waitmessage - special sub_8121388 + special ScrSpecial_StorytellerStoryListMenu waitstate compare VAR_RESULT, 0 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_2901B7 setvar VAR_0x8008, 1 - special sub_812139C + special ScrSpecial_StorytellerDisplayStory waitmessage waitbuttonpress - specialvar VAR_RESULT, sub_81213D8 + specialvar VAR_RESULT, ScrSpecial_StorytellerUpdateStat compare VAR_RESULT, 0 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_2901BD goto MauvilleCity_PokemonCenter_1F_EventScript_29020F @@ -837,7 +837,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_2901B7:: @ 82901B7 MauvilleCity_PokemonCenter_1F_EventScript_2901BD:: @ 82901BD msgbox MauvilleCity_PokemonCenter_1F_Text_28E78A, 4 - specialvar VAR_RESULT, sub_8121424 + specialvar VAR_RESULT, ScrSpecial_HasStorytellerAlreadyRecorded compare VAR_RESULT, 1 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_29022D goto MauvilleCity_PokemonCenter_1F_EventScript_2901E2 @@ -849,7 +849,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_2901E2:: @ 82901E2 msgbox MauvilleCity_PokemonCenter_1F_Text_28E7EE, 5 compare VAR_RESULT, 0 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_290219 - specialvar VAR_RESULT, sub_8121450 + specialvar VAR_RESULT, ScrSpecial_StorytellerInitializeRandomStat compare VAR_RESULT, 1 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_29020F msgbox MauvilleCity_PokemonCenter_1F_Text_28E881, 4 @@ -903,7 +903,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_2902F6:: @ 82902F6 end MauvilleCity_PokemonCenter_1F_EventScript_290317:: @ 8290317 - special sub_81203C4 + special ScrSpecial_GiddyShouldTellAnotherTale compare VAR_RESULT, 1 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_290359 compare VAR_RESULT, 0 @@ -911,7 +911,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_290317:: @ 8290317 end MauvilleCity_PokemonCenter_1F_EventScript_290331:: @ 8290331 - special sub_81203C4 + special ScrSpecial_GiddyShouldTellAnotherTale compare VAR_RESULT, 1 goto_eq MauvilleCity_PokemonCenter_1F_EventScript_29034B compare VAR_RESULT, 0 @@ -924,7 +924,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_29034B:: @ 829034B end MauvilleCity_PokemonCenter_1F_EventScript_290359:: @ 8290359 - special sub_81203FC + special ScrSpecial_GenerateGiddyLine special ShowFieldMessageStringVar4 waitmessage yesnobox 20, 8 diff --git a/data/specials.inc b/data/specials.inc index 2290c9d21..089d32d91 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -108,22 +108,22 @@ gSpecials:: @ 81DBA64 def_special sub_80FAFF8 def_special easy_chat_input_maybe def_special sub_811EECC - def_special sub_81201DC - def_special sub_81201F4 - def_special sub_8120210 - def_special sub_8120358 - def_special sub_8120374 - def_special sub_812038C - def_special sub_8120340 - def_special sub_8120B5C - def_special sub_81203FC - def_special sub_81203C4 - def_special sub_81213B0 - def_special sub_812139C - def_special sub_8121388 - def_special sub_81213D8 - def_special sub_8121450 - def_special sub_8121424 + def_special ScrSpecial_GetCurrentMauvilleMan + def_special ScrSpecial_HasBardSongBeenChanged + def_special ScrSpecial_SaveBardSongLyrics + def_special ScrSpecial_GetHipsterSpokenFlag + def_special ScrSpecial_SetHipsterSpokenFlag + def_special ScrSpecial_HipsterTeachWord + def_special ScrSpecial_PlayBardSong + def_special ScrSpecial_SetMauvilleOldManMapObjGfx + def_special ScrSpecial_GenerateGiddyLine + def_special ScrSpecial_GiddyShouldTellAnotherTale + def_special ScrSpecial_StorytellerGetFreeStorySlot + def_special ScrSpecial_StorytellerDisplayStory + def_special ScrSpecial_StorytellerStoryListMenu + def_special ScrSpecial_StorytellerUpdateStat + def_special ScrSpecial_StorytellerInitializeRandomStat + def_special ScrSpecial_HasStorytellerAlreadyRecorded def_special sub_8133EC0 def_special sub_8133CD8 def_special sub_8133CF4 diff --git a/include/global.h b/include/global.h index 083ed3e9f..0c50bf39c 100644 --- a/include/global.h +++ b/include/global.h @@ -453,7 +453,7 @@ struct MauvilleManStoryteller u8 gameStatIDs[4]; u8 trainerNames[4][7]; u8 statValues[4][4]; - u8 unk34[4]; + u8 language[4]; }; struct MauvilleManGiddy @@ -477,9 +477,9 @@ struct MauvilleOldManTrader { u8 unk0; u8 unk1[4]; - u8 unk5[4][11]; + u8 playerNames[4][11]; u8 unk31; - u8 unk32[4]; + u8 language[4]; }; typedef union OldMan diff --git a/include/mauville_old_man.h b/include/mauville_old_man.h index 28cd5589e..696f12cc7 100644 --- a/include/mauville_old_man.h +++ b/include/mauville_old_man.h @@ -12,7 +12,8 @@ enum MauvilleOldManType }; void SetMauvilleOldMan(void); -u8 sub_81201C8(void); -extern struct BardSong gUnknown_03006130; +u8 GetCurrentMauvilleOldMan(void); +extern struct BardSong gBardSong; +void ScrSpecial_SetMauvilleOldManMapObjGfx(void); #endif // GUARD_MAUVILLE_OLD_MAN_H diff --git a/include/trader.h b/include/trader.h index 71fd1f7c2..96eb024b1 100644 --- a/include/trader.h +++ b/include/trader.h @@ -7,5 +7,7 @@ void sub_8133DA0(u8 taskId); void sub_8133E1C(u8 taskId); +void sub_81339F8(void); +void Trader_ResetFlag(void); #endif //GUARD_TRADER_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index a5be62442..81cbe5210 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1146,7 +1146,7 @@ const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8 graphicsId) } if (graphicsId == 0x45) { - bard = sub_81201C8(); + bard = GetCurrentMauvilleOldMan(); return gMauvilleOldManGraphicsInfoPointers[bard]; } if (graphicsId >= NUM_OBJECT_GRAPHICS_INFO) diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index a21af6f95..4da9079ff 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -21,27 +21,25 @@ #include "overworld.h" #include "field_message_box.h" #include "script_menu.h" +#include "trader.h" #define CHAR_SONG_WORD_SEPARATOR 0x37 extern struct MusicPlayerInfo gMPlayInfo_SE2; -void sub_81204DC(void); -void sub_81206C0(bool8 useTemporaryLyrics); // StartBardSong -void sub_8120944(u8 taskId); -void sub_8120B5C(void); -void sub_8120E08(void); // StorytellerSetup -void sub_8120E50(void); -void sub_81339F8(void); // TraderSetup -void sub_8133A60(void); +static void InitGiddyTaleList(void); +static void StartBardSong(bool8 useTemporaryLyrics); +static void Task_BardSong(u8 taskId); +static void StorytellerSetup(void); +static void Storyteller_ResetFlag(void); -IWRAM_DATA u8 gUnknown_03001178; +IWRAM_DATA u8 sSelectedStory; -struct BardSong gUnknown_03006130; +struct BardSong gBardSong; -EWRAM_DATA u16 gUnknown_0203A128 = 0; -EWRAM_DATA struct MauvilleManStoryteller * gUnknown_0203A12C = NULL; -EWRAM_DATA u8 gUnknown_0203A130 = 0; +static EWRAM_DATA u16 sUnknownBardRelated = 0; +static EWRAM_DATA struct MauvilleManStoryteller * sStorytellerPtr = NULL; +static EWRAM_DATA u8 sStorytellerWindowId = 0; static const u16 sDefaultBardSongLyrics[6] = { EC_WORD_SHAKE, @@ -97,7 +95,7 @@ static void SetupHipster(void) static void SetupStoryteller(void) { - sub_8120E08(); + StorytellerSetup(); } static void SetupGiddy(void) @@ -138,22 +136,22 @@ void SetMauvilleOldMan(void) SetupGiddy(); break; } - sub_8120B5C(); + ScrSpecial_SetMauvilleOldManMapObjGfx(); } -u8 sub_81201C8(void) // GetCurrentMauvilleOldMan +u8 GetCurrentMauvilleOldMan(void) { struct MauvilleManCommon *common = &gSaveBlock1Ptr->oldMan.common; return common->id; } -void sub_81201DC(void) // ScrSpecial_GetCurrentMauvilleMan +void ScrSpecial_GetCurrentMauvilleMan(void) { - gSpecialVar_Result = sub_81201C8(); + gSpecialVar_Result = GetCurrentMauvilleOldMan(); } -void sub_81201F4(void) // ScrSpecial_HasBardSongBeenChanged +void ScrSpecial_HasBardSongBeenChanged(void) { u16 *scriptResult = &gSpecialVar_Result; // why?? struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; @@ -161,7 +159,7 @@ void sub_81201F4(void) // ScrSpecial_HasBardSongBeenChanged *scriptResult = bard->hasChangedSong; } -void sub_8120210(void) // ScrSpecial_SaveBardSongLyrics +void ScrSpecial_SaveBardSongLyrics(void) { u16 i; struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; @@ -178,20 +176,14 @@ void sub_8120210(void) // ScrSpecial_SaveBardSongLyrics } // Copies lyrics into gStringVar4 -void sub_8120280(void) +static void PrepareSongText(void) { struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; - u16 specialVar = gSpecialVar_0x8004; // It's a bit odd to use this temp variable, but it seems needed to match. - u16 *lyrics; + u16 * lyrics = gSpecialVar_0x8004 == 0 ? bard->songLyrics : bard->temporaryLyrics; + u8 * wordEnd = gStringVar4; + u8 * str = wordEnd; 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++) { @@ -233,13 +225,13 @@ void sub_8120280(void) } } -void sub_8120340(void) // ScrSpecial_PlayBardSong +void ScrSpecial_PlayBardSong(void) { - sub_81206C0(gSpecialVar_0x8004); + StartBardSong(gSpecialVar_0x8004); ScriptContext1_Stop(); } -void sub_8120358(void) // ScrSpecial_GetHipsterSpokenFlag +void ScrSpecial_GetHipsterSpokenFlag(void) { u16 *scriptResult = &gSpecialVar_Result; // again?? struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; @@ -247,14 +239,14 @@ void sub_8120358(void) // ScrSpecial_GetHipsterSpokenFlag *scriptResult = hipster->alreadySpoken; } -void sub_8120374(void) // ScrSpecial_SetHipsterSpokenFlag +void ScrSpecial_SetHipsterSpokenFlag(void) { struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; hipster->alreadySpoken = TRUE; } -void sub_812038C(void) // ScrSpecial_HipsterTeachWord +void ScrSpecial_HipsterTeachWord(void) { u16 var = sub_811F01C(); @@ -269,7 +261,7 @@ void sub_812038C(void) // ScrSpecial_HipsterTeachWord } } -void sub_81203C4(void) // ScrSpecial_GiddyShouldTellAnotherTale +void ScrSpecial_GiddyShouldTellAnotherTale(void) { struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy; @@ -284,12 +276,12 @@ void sub_81203C4(void) // ScrSpecial_GiddyShouldTellAnotherTale } } -void sub_81203FC(void) // ScrSpecial_GenerateGiddyLine +void ScrSpecial_GenerateGiddyLine(void) { struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy; if (giddy->taleCounter == 0) - sub_81204DC(); + InitGiddyTaleList(); if (giddy->randomWords[giddy->taleCounter] != 0xFFFF) // is not the last element of the array? { @@ -315,7 +307,7 @@ void sub_81203FC(void) // ScrSpecial_GenerateGiddyLine gSpecialVar_Result = TRUE; } -void sub_81204DC(void) +static void InitGiddyTaleList(void) { struct MauvilleManGiddy *giddy = &gSaveBlock1Ptr->oldMan.giddy; u16 arr[][2] = { @@ -371,50 +363,50 @@ void sub_81204DC(void) } } } -void sub_8120628(void) +static void ResetBardFlag(void) { struct MauvilleManBard *bard = &gSaveBlock1Ptr->oldMan.bard; bard->hasChangedSong = FALSE; } -void sub_8120640(void) +static void ResetHipsterFlag(void) { struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; hipster->alreadySpoken = FALSE; } -void sub_8120658(void) +static void ResetTraderFlag(void) { - sub_8133A60(); + Trader_ResetFlag(); } -void sub_8120664(void) +static void ResetStorytellerFlag(void) { - sub_8120E50(); + Storyteller_ResetFlag(); } -void sub_8120670(void) // ResetMauvilleOldManFlag +void ResetMauvilleOldManFlag(void) // ResetMauvilleOldManFlag { - switch (sub_81201C8()) + switch (GetCurrentMauvilleOldMan()) { case MAUVILLE_MAN_BARD: - sub_8120628(); + ResetBardFlag(); break; case MAUVILLE_MAN_HIPSTER: - sub_8120640(); + ResetHipsterFlag(); break; case MAUVILLE_MAN_STORYTELLER: - sub_8120664(); + ResetStorytellerFlag(); break; case MAUVILLE_MAN_TRADER: - sub_8120658(); + ResetTraderFlag(); break; case MAUVILLE_MAN_GIDDY: break; } - sub_8120B5C(); + ScrSpecial_SetMauvilleOldManMapObjGfx(); } @@ -426,32 +418,32 @@ void sub_8120670(void) // ResetMauvilleOldManFlag #define MACRO1(a) (((a) & 3) + (((a) / 8) & 1)) #define MACRO2(a) (((a) % 4) + (((a) / 8) & 1)) -void sub_81206C0(bool8 useTemporaryLyrics) +static void StartBardSong(bool8 useTemporaryLyrics) { - u8 taskId = CreateTask(sub_8120944, 80); + u8 taskId = CreateTask(Task_BardSong, 80); gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics; } -void sub_81206F0(void) +static void sub_81206F0(void) { gUnknown_03002F84 = FALSE; } -void sub_81206FC(struct TextSubPrinter * printer, u16 a1) +static void BardSong_TextSubPrinter(struct TextSubPrinter * printer, u16 a1) { gUnknown_03002F84 = TRUE; } -void sub_8120708(const u8 * src) +static void sub_8120708(const u8 * src) { NewMenuHelpers_DrawDialogueFrame(0, 0); - PrintTextOnWindow(0, 1, src, 0, 1, 1, sub_81206FC); + PrintTextOnWindow(0, 1, src, 0, 1, 1, BardSong_TextSubPrinter); gUnknown_03002F84 = TRUE; CopyWindowToVram(0, 3); } -void sub_8120748(struct Task *task, struct BardSong *song) // BardSing +static void BardSing(struct Task *task, struct BardSong *song) { switch (task->tState) { @@ -554,15 +546,15 @@ void sub_8120748(struct Task *task, struct BardSong *song) // BardSing } } -void sub_8120944(u8 taskId) +static void Task_BardSong(u8 taskId) { struct Task *task = &gTasks[taskId]; // r5 - sub_8120748(task, &gUnknown_03006130); + BardSing(task, &gBardSong); switch (task->tState) { case 0: // Initialize song - sub_8120280(); + PrepareSongText(); sub_8120708(gStringVar4); task->data[1] = 0; task->data[2] = 0; @@ -593,14 +585,14 @@ void sub_8120944(u8 taskId) wordLen++; } if (!task->tUseTemporaryLyrics) - gUnknown_0203A128 = MACRO2(bard->songLyrics[task->tCurrWord]); + sUnknownBardRelated = MACRO2(bard->songLyrics[task->tCurrWord]); else - gUnknown_0203A128 = MACRO2(bard->temporaryLyrics[task->tCurrWord]); - temp = gUnknown_03006130.length / wordLen; + sUnknownBardRelated = MACRO2(bard->temporaryLyrics[task->tCurrWord]); + temp = gBardSong.length / wordLen; zero = 0; - gUnknown_03006130.length = temp; - if (gUnknown_03006130.length <= 0) - gUnknown_03006130.length = 1; + gBardSong.length = temp; + if (gBardSong.length <= 0) + gBardSong.length = 1; task->tCurrWord++; if (task->data[2] == 0) task->tState = 3; @@ -664,7 +656,7 @@ void sub_8120944(u8 taskId) case 2: task->tCharIndex++; task->data[1] = 0; - task->data[2] = gUnknown_03006130.length; + task->data[2] = gBardSong.length; task->tState = 4; break; } @@ -679,11 +671,13 @@ void sub_8120944(u8 taskId) sub_8197224(); } -void sub_8120B5C(void) +void ScrSpecial_SetMauvilleOldManMapObjGfx(void) { VarSet(VAR_0x4010, MAP_OBJ_GFX_BARD); } +// Language fixers? + void sub_8120B70(union OldMan * oldMan) { s32 i; @@ -696,9 +690,9 @@ void sub_8120B70(union OldMan * oldMan) struct MauvilleOldManTrader * trader = &oldMan->trader; for (i = 0; i < 4; i++) { - if (trader->unk32[i] == LANGUAGE_JAPANESE) + if (trader->language[i] == LANGUAGE_JAPANESE) { - ConvertInternationalString(trader->unk5[i], LANGUAGE_JAPANESE); + ConvertInternationalString(trader->playerNames[i], LANGUAGE_JAPANESE); } } } @@ -717,7 +711,7 @@ void sub_8120B70(union OldMan * oldMan) memset(sp00, CHAR_SPACE, 8); StringCopy(sp00, gText_Friend); memcpy(storyteller->trainerNames[i], sp00, 7); - storyteller->unk34[i] = GAME_LANGUAGE; + storyteller->language[i] = GAME_LANGUAGE; } } } @@ -738,13 +732,13 @@ void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3) for (i = 0; i < 4; i++) { - if (IsStringJapanese(trader->unk5[i])) + if (IsStringJapanese(trader->playerNames[i])) { - trader->unk32[i] = r8; + trader->language[i] = r8; } else { - trader->unk32[i] = r7; + trader->language[i] = r7; } } } @@ -757,11 +751,11 @@ void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3) { if (IsStringJapanese(storyteller->trainerNames[i])) { - storyteller->unk34[i] = r8; + storyteller->language[i] = r8; } else { - storyteller->unk34[i] = r7; + storyteller->language[i] = r7; } } } @@ -814,9 +808,9 @@ void sub_8120CD0(union OldMan * oldMan, u32 unused, u32 a2) memcpy(sp00, storyteller->trainerNames[i], 7); sp00[7] = EOS; if (IsStringJapanese(sp00)) - storyteller->unk34[i] = LANGUAGE_JAPANESE; + storyteller->language[i] = LANGUAGE_JAPANESE; else - storyteller->unk34[i] = GAME_LANGUAGE; + storyteller->language[i] = GAME_LANGUAGE; } } } @@ -836,23 +830,23 @@ void sub_8120D34(union OldMan * oldMan, u32 r1, u32 r6) { for (i = 0; i < 4; i++) { - u8 * str = trader->unk5[i]; + u8 * str = trader->playerNames[i]; if (str[0] == EXT_CTRL_CODE_BEGIN && str[1] == EXT_CTRL_CODE_JPN) { StripExtCtrlCodes(str); - trader->unk32[i] = LANGUAGE_JAPANESE; + trader->language[i] = LANGUAGE_JAPANESE; } else - trader->unk32[i] = r6; + trader->language[i] = r6; } } else { for (i = 0; i < 4; i++) { - if (trader->unk32[i] == LANGUAGE_JAPANESE) + if (trader->language[i] == LANGUAGE_JAPANESE) { - StripExtCtrlCodes(trader->unk5[i]); + StripExtCtrlCodes(trader->playerNames[i]); } } } @@ -869,7 +863,7 @@ void sub_8120D34(union OldMan * oldMan, u32 r1, u32 r6) for (i = 0; i < 4; i++) { if (storyteller->gameStatIDs[i] != 0) - storyteller->unk34[i] = r6; + storyteller->language[i] = r6; } } } @@ -916,7 +910,7 @@ struct Story const u8 *fullText; }; -const struct Story gUnknown_0859F048[] = { +static const struct Story sStorytellerStories[] = { {GAME_STAT_50, 1, MauvilleCity_PokemonCenter_1F_Text_28E930, MauvilleCity_PokemonCenter_1F_Text_28E947, MauvilleCity_PokemonCenter_1F_Text_28E956}, {GAME_STAT_STARTED_TRENDS, 1, MauvilleCity_PokemonCenter_1F_Text_28E9D7, MauvilleCity_PokemonCenter_1F_Text_28E9EF, MauvilleCity_PokemonCenter_1F_Text_28E9FE}, {GAME_STAT_PLANTED_BERRIES, 1, MauvilleCity_PokemonCenter_1F_Text_28EA7D, MauvilleCity_PokemonCenter_1F_Text_28EA98, MauvilleCity_PokemonCenter_1F_Text_28EAA8}, @@ -955,84 +949,84 @@ const struct Story gUnknown_0859F048[] = { {GAME_STAT_ENTERED_HOT_SPRINGS, 1, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB} }; -void sub_8120E08(void) // StorytellerSetup +static void StorytellerSetup(void) { s32 i; - gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; + sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller; - gUnknown_0203A12C->id = MAUVILLE_MAN_STORYTELLER; - gUnknown_0203A12C->alreadyRecorded = FALSE; + sStorytellerPtr->id = MAUVILLE_MAN_STORYTELLER; + sStorytellerPtr->alreadyRecorded = FALSE; for (i = 0; i < 4; i++) { - gUnknown_0203A12C->gameStatIDs[i] = 0; - gUnknown_0203A12C->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead? + sStorytellerPtr->gameStatIDs[i] = 0; + sStorytellerPtr->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead? } } -void sub_8120E50(void) +static void Storyteller_ResetFlag(void) { - gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; + sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller; - gUnknown_0203A12C->id = MAUVILLE_MAN_STORYTELLER; - gUnknown_0203A12C->alreadyRecorded = FALSE; + sStorytellerPtr->id = MAUVILLE_MAN_STORYTELLER; + sStorytellerPtr->alreadyRecorded = FALSE; } -u32 sub_8120E74(u8 stat) // StorytellerGetGameStat +static u32 StorytellerGetGameStat(u8 stat) { if (stat == 50) stat = 0; return GetGameStat(stat); } -const struct Story *sub_8120E88(u32 stat) // GetStoryByStat +static const struct Story *GetStoryByStat(u32 stat) { s32 i; for (i = 0; i < 36; i++) { - if (gUnknown_0859F048[i].stat == stat) - return &gUnknown_0859F048[i]; + if (sStorytellerStories[i].stat == stat) + return &sStorytellerStories[i]; } - return &gUnknown_0859F048[35]; + return &sStorytellerStories[35]; } -const u8 *sub_8120EB4(u32 stat) // GetStoryTitleByStat +static const u8 *GetStoryTitleByStat(u32 stat) { - return sub_8120E88(stat)->title; + return GetStoryByStat(stat)->title; } -const u8 *sub_8120EC0(u32 stat) // GetStoryTextByStat +static const u8 *GetStoryTextByStat(u32 stat) { - return sub_8120E88(stat)->fullText; + return GetStoryByStat(stat)->fullText; } -const u8 *sub_8120ECC(u32 stat) // GetStoryActionByStat +static const u8 *GetStoryActionByStat(u32 stat) { - return sub_8120E88(stat)->action; + return GetStoryByStat(stat)->action; } -u8 sub_8120ED8(void) // GetFreeStorySlot +static u8 GetFreeStorySlot(void) { u8 i; for (i = 0; i < 4; i++) { - if (gUnknown_0203A12C->gameStatIDs[i] == 0) + if (sStorytellerPtr->gameStatIDs[i] == 0) break; } return i; } -u32 sub_8120F08(u32 trainer) // StorytellerGetRecordedTrainerStat +static u32 StorytellerGetRecordedTrainerStat(u32 trainer) { - u8 *ptr = gUnknown_0203A12C->statValues[trainer]; + u8 *ptr = sStorytellerPtr->statValues[trainer]; return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); } -void sub_8120F2C(u32 trainer, u32 val) // StorytellerSetRecordedTrainerStat +static void StorytellerSetRecordedTrainerStat(u32 trainer, u32 val) { - u8 *ptr = gUnknown_0203A12C->statValues[trainer]; + u8 *ptr = sStorytellerPtr->statValues[trainer]; ptr[0] = val; ptr[1] = val >> 8; @@ -1040,41 +1034,41 @@ void sub_8120F2C(u32 trainer, u32 val) // StorytellerSetRecordedTrainerStat ptr[3] = val >> 24; } -bool32 sub_8120F4C(u32 trainer) // HasTrainerStatIncreased +static bool32 HasTrainerStatIncreased(u32 trainer) { - if (sub_8120E74(gUnknown_0203A12C->gameStatIDs[trainer]) > sub_8120F08(trainer)) + if (StorytellerGetGameStat(sStorytellerPtr->gameStatIDs[trainer]) > StorytellerGetRecordedTrainerStat(trainer)) return TRUE; else return FALSE; } -void sub_8120F7C(u32 player, void *dst) // GetStoryByStattellerPlayerName +static void GetStoryByStattellerPlayerName(u32 player, void *dst) { - u8 *name = gUnknown_0203A12C->trainerNames[player]; + u8 *name = sStorytellerPtr->trainerNames[player]; memset(dst, EOS, 8); memcpy(dst, name, 7); } -void sub_8120FAC(u32 player, const u8 * src) // StorytellerSetPlayerName +static void StorytellerSetPlayerName(u32 player, const u8 * src) { - u8 * name = gUnknown_0203A12C->trainerNames[player]; + u8 * name = sStorytellerPtr->trainerNames[player]; memset(name, EOS, 7); memcpy(name, src, 7); } -void sub_8120FDC(u32 player, u32 stat) // StorytellerRecordNewStat +static void StorytellerRecordNewStat(u32 player, u32 stat) { - gUnknown_0203A12C->gameStatIDs[player] = stat; - sub_8120FAC(player, gSaveBlock2Ptr->playerName); - sub_8120F2C(player, sub_8120E74(stat)); - ConvertIntToDecimalStringN(gStringVar1, sub_8120E74(stat), STR_CONV_MODE_LEFT_ALIGN, 10); - StringCopy(gStringVar2, sub_8120ECC(stat)); - gUnknown_0203A12C->unk34[player] = gGameLanguage; + sStorytellerPtr->gameStatIDs[player] = stat; + StorytellerSetPlayerName(player, gSaveBlock2Ptr->playerName); + StorytellerSetRecordedTrainerStat(player, StorytellerGetGameStat(stat)); + ConvertIntToDecimalStringN(gStringVar1, StorytellerGetGameStat(stat), STR_CONV_MODE_LEFT_ALIGN, 10); + StringCopy(gStringVar2, GetStoryActionByStat(stat)); + sStorytellerPtr->language[player] = gGameLanguage; } -void sub_8121064(u8 * arr, s32 count) // ScrambleStatList +static void ScrambleStatList(u8 * arr, s32 count) { s32 i; @@ -1092,57 +1086,57 @@ void sub_8121064(u8 * arr, s32 count) // ScrambleStatList struct UnknownStruct_0859F288 { - u32 length; + s32 length; u32 unused2; }; -const struct UnknownStruct_0859F288 gUnknown_0859F288 = { - 36, - 8 +static const struct UnknownStruct_0859F288 sStorytellerStuff = { + ARRAY_COUNT(sStorytellerStories), + sizeof(sStorytellerStuff) }; -bool8 sub_81210B8(void) // StorytellerInitializeRandomStat +static bool8 StorytellerInitializeRandomStat(void) { - u8 arr[gUnknown_0859F288.length]; + u8 arr[sStorytellerStuff.length]; s32 i; s32 j; - sub_8121064(arr, 36); - for (i = 0; i < 36; i++) + ScrambleStatList(arr, ARRAY_COUNT(sStorytellerStories)); + for (i = 0; i < (s32)ARRAY_COUNT(sStorytellerStories); i++) { - u8 stat = gUnknown_0859F048[arr[i]].stat; - u8 minVal = gUnknown_0859F048[arr[i]].minVal; + u8 stat = sStorytellerStories[arr[i]].stat; + u8 minVal = sStorytellerStories[arr[i]].minVal; for (j = 0; j < 4; j++) { - if (gUnknown_0203A12C->gameStatIDs[j] == stat) + if (sStorytellerPtr->gameStatIDs[j] == stat) break; } - if (j == 4 && sub_8120E74(stat) >= minVal) + if (j == 4 && StorytellerGetGameStat(stat) >= minVal) { - gUnknown_0203A12C->alreadyRecorded = TRUE; - if (sub_8120ED8() == 4) - sub_8120FDC(gUnknown_03001178, stat); + sStorytellerPtr->alreadyRecorded = TRUE; + if (GetFreeStorySlot() == 4) + StorytellerRecordNewStat(sSelectedStory, stat); else - sub_8120FDC(sub_8120ED8(), stat); + StorytellerRecordNewStat(GetFreeStorySlot(), stat); return TRUE; } } return FALSE; } -void sub_8121178(u32 player) // StorytellerDisplayStory +static void StorytellerDisplayStory(u32 player) { - u8 stat = gUnknown_0203A12C->gameStatIDs[player]; + u8 stat = sStorytellerPtr->gameStatIDs[player]; - ConvertIntToDecimalStringN(gStringVar1, sub_8120F08(player), 0, 10); - StringCopy(gStringVar2, sub_8120ECC(stat)); - sub_8120F7C(player, gStringVar3); - ConvertInternationalString(gStringVar3, gUnknown_0203A12C->unk34[player]); - ShowFieldMessage(sub_8120EC0(stat)); + ConvertIntToDecimalStringN(gStringVar1, StorytellerGetRecordedTrainerStat(player), 0, 10); + StringCopy(gStringVar2, GetStoryActionByStat(stat)); + GetStoryByStattellerPlayerName(player, gStringVar3); + ConvertInternationalString(gStringVar3, sStorytellerPtr->language[player]); + ShowFieldMessage(GetStoryTextByStat(stat)); } -void sub_81211EC(void) // PrintStoryList +static void PrintStoryList(void) { s32 i; s32 width = GetStringWidth(1, gText_Exit, 0); @@ -1150,29 +1144,29 @@ void sub_81211EC(void) // PrintStoryList for (i = 0; i < 4; i++) { s32 curWidth; - u16 gameStatID = gUnknown_0203A12C->gameStatIDs[i]; + u16 gameStatID = sStorytellerPtr->gameStatIDs[i]; if (gameStatID == 0) break; - curWidth = GetStringWidth(1, sub_8120EB4(gameStatID), 0); + curWidth = GetStringWidth(1, GetStoryTitleByStat(gameStatID), 0); if (curWidth > width) width = curWidth; } - gUnknown_0203A130 = CreateWindowFromRect(0, 0, convert_pixel_width_to_tile_width(width), sub_8120ED8() * 2 + 2); - SetStandardWindowBorderStyle(gUnknown_0203A130, 0); + sStorytellerWindowId = CreateWindowFromRect(0, 0, convert_pixel_width_to_tile_width(width), GetFreeStorySlot() * 2 + 2); + SetStandardWindowBorderStyle(sStorytellerWindowId, 0); for (i = 0; i < 4; i++) { - u16 gameStatID = gUnknown_0203A12C->gameStatIDs[i]; + u16 gameStatID = sStorytellerPtr->gameStatIDs[i]; if (gameStatID == 0) break; - PrintTextOnWindow(gUnknown_0203A130, 1, sub_8120EB4(gameStatID), 8, 16 * i + 1, 0xFF, NULL); + PrintTextOnWindow(sStorytellerWindowId, 1, GetStoryTitleByStat(gameStatID), 8, 16 * i + 1, 0xFF, NULL); } - PrintTextOnWindow(gUnknown_0203A130, 1, gText_Exit, 8, 16 * i + 1, 0xFF, NULL); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_0203A130, sub_8120ED8() + 1, 0); - CopyWindowToVram(gUnknown_0203A130, 3); + PrintTextOnWindow(sStorytellerWindowId, 1, gText_Exit, 8, 16 * i + 1, 0xFF, NULL); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sStorytellerWindowId, GetFreeStorySlot() + 1, 0); + CopyWindowToVram(sStorytellerWindowId, 3); } -void sub_81212FC(u8 taskId) // Task_StoryListMenu +static void Task_StoryListMenu(u8 taskId) // Task_StoryListMenu { struct Task *task = &gTasks[taskId]; s32 selection; @@ -1180,23 +1174,23 @@ void sub_81212FC(u8 taskId) // Task_StoryListMenu switch (task->data[0]) { case 0: - sub_81211EC(); + PrintStoryList(); task->data[0]++; break; case 1: selection = ProcessMenuInput(); if (selection == -2) break; - if (selection == -1 || selection == sub_8120ED8()) + if (selection == -1 || selection == GetFreeStorySlot()) { gSpecialVar_Result = 0; } else { gSpecialVar_Result = 1; - gUnknown_03001178 = selection; + sSelectedStory = selection; } - sub_80E2A78(gUnknown_0203A130); + sub_80E2A78(sStorytellerWindowId); DestroyTask(taskId); EnableBothScriptContexts(); break; @@ -1204,51 +1198,50 @@ void sub_81212FC(u8 taskId) // Task_StoryListMenu } // Sets gSpecialVar_Result to TRUE if player selected a story -void sub_8121388(void) // ScrSpecial_StorytellerStoryListMenu +void ScrSpecial_StorytellerStoryListMenu(void) { - CreateTask(sub_81212FC, 80); + CreateTask(Task_StoryListMenu, 80); } -void sub_812139C(void) // ScrSpecial_StorytellerDisplayStory +void ScrSpecial_StorytellerDisplayStory(void) { - sub_8121178(gUnknown_03001178); + StorytellerDisplayStory(sSelectedStory); } -u8 sub_81213B0(void) // ScrSpecial_StorytellerDisplayStory +u8 ScrSpecial_StorytellerGetFreeStorySlot(void) { - gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; - return sub_8120ED8(); + sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller; + return GetFreeStorySlot(); } // Returns TRUE if stat has increased -bool8 sub_81213D8(void) // ScrSpecial_StorytellerUpdateStat +bool8 ScrSpecial_StorytellerUpdateStat(void) { u8 r4; - gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; - r4 = gUnknown_0203A12C->gameStatIDs[gUnknown_03001178]; + sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller; + r4 = sStorytellerPtr->gameStatIDs[sSelectedStory]; - if (sub_8120F4C(gUnknown_03001178) == TRUE) + if (HasTrainerStatIncreased(sSelectedStory) == TRUE) { - sub_8120FDC(gUnknown_03001178, r4); + StorytellerRecordNewStat(sSelectedStory, r4); return TRUE; } return FALSE; } - -bool8 sub_8121424(void) // ScrSpecial_HasStorytellerAlreadyRecorded +bool8 ScrSpecial_HasStorytellerAlreadyRecorded(void) { - gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; + sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller; - if (gUnknown_0203A12C->alreadyRecorded == FALSE) + if (sStorytellerPtr->alreadyRecorded == FALSE) return FALSE; else return TRUE; } -bool8 sub_8121450(void) // ScrSpecial_StorytellerInitializeRandomStat +bool8 ScrSpecial_StorytellerInitializeRandomStat(void) { - gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller; - return sub_81210B8(); + sStorytellerPtr = &gSaveBlock1Ptr->oldMan.storyteller; + return StorytellerInitializeRandomStat(); } From 1b525ba7f944055462442e37ff4a91c3d11b21b9 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 9 May 2018 15:28:51 -0400 Subject: [PATCH 10/10] Remove file that should have been ignored. WTF clion? --- .idea/inspectionProfiles/profiles_settings.xml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index dd4c951ef..000000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file