mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Finish and polish new_game.c
Only one function is left undocumented. I tried to go into the assembly to at least name it, but it clears fields in the save block that aren't even documented yet.
This commit is contained in:
parent
e95140270b
commit
986d3d8b2f
@ -9869,10 +9869,18 @@ _0811F8AE:
|
|||||||
.pool
|
.pool
|
||||||
thumb_func_end InitializeEasyChatWordArray
|
thumb_func_end InitializeEasyChatWordArray
|
||||||
|
|
||||||
|
@void sub_811F8BC() {
|
||||||
|
@ s16* v;
|
||||||
|
@ s16* ptr;
|
||||||
|
@ v = GetSaveBlock1Field3564();
|
||||||
|
@ for (ptr = v + 3; ptr >= v; ptr--) {
|
||||||
|
@ *ptr = -1;
|
||||||
|
@ }
|
||||||
|
@}
|
||||||
thumb_func_start sub_811F8BC
|
thumb_func_start sub_811F8BC
|
||||||
sub_811F8BC: @ 811F8BC
|
sub_811F8BC: @ 811F8BC
|
||||||
push {lr}
|
push {lr}
|
||||||
bl sub_801B058
|
bl GetSaveBlock1Field3564
|
||||||
ldr r1, =0x0000ffff
|
ldr r1, =0x0000ffff
|
||||||
adds r2, r1, 0
|
adds r2, r1, 0
|
||||||
adds r1, r0, 0x6
|
adds r1, r0, 0x6
|
||||||
|
@ -8315,6 +8315,11 @@ _0801AFC2:
|
|||||||
.pool
|
.pool
|
||||||
thumb_func_end sub_801AC54
|
thumb_func_end sub_801AC54
|
||||||
|
|
||||||
|
@void sub_801AFD8() {
|
||||||
|
@ CpuFill32(0, &gSaveBlock1Ptr->field_322C, 219);
|
||||||
|
@ sub_801B180();
|
||||||
|
@ sub_811F8BC();
|
||||||
|
@}
|
||||||
thumb_func_start sub_801AFD8
|
thumb_func_start sub_801AFD8
|
||||||
sub_801AFD8: @ 801AFD8
|
sub_801AFD8: @ 801AFD8
|
||||||
push {lr}
|
push {lr}
|
||||||
@ -8367,25 +8372,25 @@ sav1_get_mevent_buffer_2: @ 801B034
|
|||||||
.pool
|
.pool
|
||||||
thumb_func_end sav1_get_mevent_buffer_2
|
thumb_func_end sav1_get_mevent_buffer_2
|
||||||
|
|
||||||
thumb_func_start sub_801B044
|
thumb_func_start GetSaveBlock1Field356C
|
||||||
sub_801B044: @ 801B044
|
GetSaveBlock1Field356C: @ 801B044
|
||||||
ldr r0, =gSaveBlock1Ptr
|
ldr r0, =gSaveBlock1Ptr
|
||||||
ldr r0, [r0]
|
ldr r0, [r0]
|
||||||
ldr r1, =0x0000356c
|
ldr r1, =0x0000356c
|
||||||
adds r0, r1
|
adds r0, r1
|
||||||
bx lr
|
bx lr
|
||||||
.pool
|
.pool
|
||||||
thumb_func_end sub_801B044
|
thumb_func_end GetSaveBlock1Field356C
|
||||||
|
|
||||||
thumb_func_start sub_801B058
|
thumb_func_start GetSaveBlock1Field3564
|
||||||
sub_801B058: @ 801B058
|
GetSaveBlock1Field3564: @ 801B058
|
||||||
ldr r0, =gSaveBlock1Ptr
|
ldr r0, =gSaveBlock1Ptr
|
||||||
ldr r0, [r0]
|
ldr r0, [r0]
|
||||||
ldr r1, =0x00003564
|
ldr r1, =0x00003564
|
||||||
adds r0, r1
|
adds r0, r1
|
||||||
bx lr
|
bx lr
|
||||||
.pool
|
.pool
|
||||||
thumb_func_end sub_801B058
|
thumb_func_end GetSaveBlock1Field3564
|
||||||
|
|
||||||
thumb_func_start sub_801B06C
|
thumb_func_start sub_801B06C
|
||||||
sub_801B06C: @ 801B06C
|
sub_801B06C: @ 801B06C
|
||||||
@ -8531,7 +8536,7 @@ sub_801B180: @ 801B180
|
|||||||
sub sp, 0x4
|
sub sp, 0x4
|
||||||
movs r0, 0
|
movs r0, 0
|
||||||
str r0, [sp]
|
str r0, [sp]
|
||||||
bl sub_801B044
|
bl GetSaveBlock1Field356C
|
||||||
adds r1, r0, 0
|
adds r1, r0, 0
|
||||||
ldr r2, =0x05000001
|
ldr r2, =0x05000001
|
||||||
mov r0, sp
|
mov r0, sp
|
||||||
@ -13795,7 +13800,7 @@ _0801DB60:
|
|||||||
sub_801DB68: @ 801DB68
|
sub_801DB68: @ 801DB68
|
||||||
push {r4,r5,lr}
|
push {r4,r5,lr}
|
||||||
adds r4, r0, 0
|
adds r4, r0, 0
|
||||||
bl sub_801B044
|
bl GetSaveBlock1Field356C
|
||||||
adds r5, r0, 0
|
adds r5, r0, 0
|
||||||
movs r0, 0x3
|
movs r0, 0x3
|
||||||
adds r1, r4, 0
|
adds r1, r4, 0
|
||||||
@ -13841,7 +13846,7 @@ _0801DBB8:
|
|||||||
thumb_func_start sub_801DBC0
|
thumb_func_start sub_801DBC0
|
||||||
sub_801DBC0: @ 801DBC0
|
sub_801DBC0: @ 801DBC0
|
||||||
push {lr}
|
push {lr}
|
||||||
bl sub_801B044
|
bl GetSaveBlock1Field356C
|
||||||
movs r1, 0
|
movs r1, 0
|
||||||
strb r1, [r0]
|
strb r1, [r0]
|
||||||
strb r1, [r0, 0x1]
|
strb r1, [r0, 0x1]
|
||||||
@ -13858,7 +13863,7 @@ sub_801DBDC: @ 801DBDC
|
|||||||
ldr r0, =0x0000402e
|
ldr r0, =0x0000402e
|
||||||
bl GetVarPointer
|
bl GetVarPointer
|
||||||
adds r4, r0, 0
|
adds r4, r0, 0
|
||||||
bl sub_801B044
|
bl GetSaveBlock1Field356C
|
||||||
adds r2, r0, 0
|
adds r2, r0, 0
|
||||||
ldr r0, [r2]
|
ldr r0, [r2]
|
||||||
lsls r0, 24
|
lsls r0, 24
|
||||||
@ -13889,7 +13894,7 @@ _0801DC10:
|
|||||||
sub_801DC20: @ 801DC20
|
sub_801DC20: @ 801DC20
|
||||||
push {r4-r6,lr}
|
push {r4-r6,lr}
|
||||||
ldr r6, =gSpecialVar_Result
|
ldr r6, =gSpecialVar_Result
|
||||||
bl sub_801B044
|
bl GetSaveBlock1Field356C
|
||||||
adds r4, r0, 0
|
adds r4, r0, 0
|
||||||
bl IsMysteryEventEnabled
|
bl IsMysteryEventEnabled
|
||||||
cmp r0, 0
|
cmp r0, 0
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
gUnknown_030060B0
|
gUnusedU8
|
||||||
gUnknown_030060B4
|
gUnknown_030060B4
|
||||||
|
@ -940,7 +940,7 @@ EventScript_27149D:: @ 827149D
|
|||||||
setberrytree 82, 36, 5
|
setberrytree 82, 36, 5
|
||||||
return
|
return
|
||||||
|
|
||||||
EventScript_2715DE:: @ 82715DE
|
EventScript_ResetAllMapFlags:: @ 82715DE
|
||||||
setflag FLAG_LINK_CONTEST_POKE_BALL
|
setflag FLAG_LINK_CONTEST_POKE_BALL
|
||||||
setflag FLAG_HIDE_ROUTE_111_VICTORIA_WINSTRATE
|
setflag FLAG_HIDE_ROUTE_111_VICTORIA_WINSTRATE
|
||||||
setflag FLAG_HIDE_ROUTE_111_VIVI_WINSTRATE
|
setflag FLAG_HIDE_ROUTE_111_VIVI_WINSTRATE
|
||||||
|
@ -25,5 +25,7 @@ void UpdateFrontierManiac(u16 a0);
|
|||||||
void UpdateFrontierGambler(u16 a0);
|
void UpdateFrontierGambler(u16 a0);
|
||||||
void ResetCyclingRoadChallengeData(void);
|
void ResetCyclingRoadChallengeData(void);
|
||||||
bool8 warp0_in_pokecenter(void);
|
bool8 warp0_in_pokecenter(void);
|
||||||
|
void ResetFanClub(void);
|
||||||
|
|
||||||
|
|
||||||
#endif // GUARD_FIELD_SPECIALS_H
|
#endif // GUARD_FIELD_SPECIALS_H
|
||||||
|
@ -376,7 +376,7 @@ struct BattleFrontier
|
|||||||
/*0xEBC*/ u32 battlesCount;
|
/*0xEBC*/ u32 battlesCount;
|
||||||
/*0xEC0*/ u16 field_EC0[16];
|
/*0xEC0*/ u16 field_EC0[16];
|
||||||
/*0xEE0*/ u8 field_EE0;
|
/*0xEE0*/ u8 field_EE0;
|
||||||
/*0xEE1*/ u8 field_EE1[2][PLAYER_NAME_LENGTH + 1];
|
/*0xEE1*/ u8 opponentName[2][PLAYER_NAME_LENGTH + 1];
|
||||||
/*0xEF1*/ u8 field_EF1[2][4];
|
/*0xEF1*/ u8 field_EF1[2][4];
|
||||||
/*0xEF9*/ u8 field_EF9_0:7;
|
/*0xEF9*/ u8 field_EF9_0:7;
|
||||||
/*0xEF9*/ u8 field_EF9_1:1;
|
/*0xEF9*/ u8 field_EF9_1:1;
|
||||||
@ -446,7 +446,7 @@ struct SaveBlock2
|
|||||||
/*0x90*/ u8 filler_90[0x8];
|
/*0x90*/ u8 filler_90[0x8];
|
||||||
/*0x98*/ struct Time localTimeOffset;
|
/*0x98*/ struct Time localTimeOffset;
|
||||||
/*0xA0*/ struct Time lastBerryTreeUpdate;
|
/*0xA0*/ struct Time lastBerryTreeUpdate;
|
||||||
/*0xA8*/ u32 field_A8;
|
/*0xA8*/ u32 unusedFlagField; // Written to, but never read.
|
||||||
/*0xAC*/ u32 encryptionKey;
|
/*0xAC*/ u32 encryptionKey;
|
||||||
/*0xB0*/ struct PlayersApprentice playerApprentice;
|
/*0xB0*/ struct PlayersApprentice playerApprentice;
|
||||||
/*0xDC*/ struct Apprentice apprentices[4]; // From record mixing.
|
/*0xDC*/ struct Apprentice apprentices[4]; // From record mixing.
|
||||||
@ -787,7 +787,7 @@ struct WaldaPhrase
|
|||||||
bool8 patternUnlocked;
|
bool8 patternUnlocked;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UnkSaveSubstruct_3b98
|
struct TrainerNameRecord
|
||||||
{
|
{
|
||||||
u32 trainerId;
|
u32 trainerId;
|
||||||
u8 trainerName[PLAYER_NAME_LENGTH + 1];
|
u8 trainerName[PLAYER_NAME_LENGTH + 1];
|
||||||
@ -891,7 +891,7 @@ struct SaveBlock1
|
|||||||
/*0x3B14*/ struct RecordMixingGift recordMixingGift;
|
/*0x3B14*/ struct RecordMixingGift recordMixingGift;
|
||||||
/*0x3B24*/ u8 seen2[DEX_FLAGS_NO];
|
/*0x3B24*/ u8 seen2[DEX_FLAGS_NO];
|
||||||
/*0x3B58*/ LilycoveLady lilycoveLady;
|
/*0x3B58*/ LilycoveLady lilycoveLady;
|
||||||
/*0x3B98*/ struct UnkSaveSubstruct_3b98 unk_3B98[20];
|
/*0x3B98*/ struct TrainerNameRecord trainerNameRecords[20];
|
||||||
/*0x3C88*/ u8 filler_3C88[0xDC];
|
/*0x3C88*/ u8 filler_3C88[0xDC];
|
||||||
/*0x3D64*/ struct SaveTrainerHill trainerHill;
|
/*0x3D64*/ struct SaveTrainerHill trainerHill;
|
||||||
/*0x3D70*/ struct WaldaPhrase waldaPhrase;
|
/*0x3D70*/ struct WaldaPhrase waldaPhrase;
|
||||||
|
@ -79,5 +79,7 @@ bool8 UseRegisteredKeyItemOnField(void);
|
|||||||
void CB2_GoToSellMenu(void);
|
void CB2_GoToSellMenu(void);
|
||||||
void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)());
|
void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)());
|
||||||
void DoWallyTutorialBagMenu(void);
|
void DoWallyTutorialBagMenu(void);
|
||||||
|
void ResetBagScrollPositions(void);
|
||||||
|
|
||||||
|
|
||||||
#endif //GUARD_item_menu_H
|
#endif //GUARD_item_menu_H
|
||||||
|
@ -305,7 +305,7 @@ void sub_8009FAC(void);
|
|||||||
bool8 sub_800A4D8(u8 a0);
|
bool8 sub_800A4D8(u8 a0);
|
||||||
u8 sub_800A9D8(void);
|
u8 sub_800A9D8(void);
|
||||||
u8 sub_800A0C8(s32, s32);
|
u8 sub_800A0C8(s32, s32);
|
||||||
u16 *sub_801B058(void);
|
u16 *GetSaveBlock1Field3564(void);
|
||||||
u8 sub_800A9A8(void);
|
u8 sub_800A9A8(void);
|
||||||
void sub_800AD10(void);
|
void sub_800AD10(void);
|
||||||
void sub_800AB18(void);
|
void sub_800AB18(void);
|
||||||
|
@ -213,6 +213,7 @@ extern struct UnkRfuStruct_2 gUnknown_03005000;
|
|||||||
extern u8 gWirelessStatusIndicatorSpriteId;
|
extern u8 gWirelessStatusIndicatorSpriteId;
|
||||||
|
|
||||||
// Exported ROM declarations
|
// Exported ROM declarations
|
||||||
|
void WipeTrainerNameRecords(void);
|
||||||
u32 sub_800BEC0(void);
|
u32 sub_800BEC0(void);
|
||||||
void sub_800E700(void);
|
void sub_800E700(void);
|
||||||
void sub_800EDD4(void);
|
void sub_800EDD4(void);
|
||||||
@ -263,7 +264,7 @@ void sub_800E084(void);
|
|||||||
void sub_801103C(void);
|
void sub_801103C(void);
|
||||||
void sub_8011C5C(void);
|
void sub_8011C5C(void);
|
||||||
void sub_80106D4(void);
|
void sub_80106D4(void);
|
||||||
void sub_800E3A8(void);
|
void RecordMixTrainerNames(void);
|
||||||
void sub_800ED10(void);
|
void sub_800ED10(void);
|
||||||
void sub_800ED28(void);
|
void sub_800ED28(void);
|
||||||
void sub_8011090(u8 a0, u32 a1, u32 a2);
|
void sub_8011090(u8 a0, u32 a1, u32 a2);
|
||||||
|
@ -68,5 +68,7 @@ void ClearPokemonCrySongs(void);
|
|||||||
void RestoreSerialTimer3IntrHandlers(void);
|
void RestoreSerialTimer3IntrHandlers(void);
|
||||||
void StartTimer1(void);
|
void StartTimer1(void);
|
||||||
void SeedRngAndSetTrainerId(void);
|
void SeedRngAndSetTrainerId(void);
|
||||||
|
extern u16 GetGeneratedTrainerIdLower(void);
|
||||||
|
|
||||||
|
|
||||||
#endif // GUARD_MAIN_H
|
#endif // GUARD_MAIN_H
|
||||||
|
@ -85,5 +85,7 @@ extern const struct MenuAction gMailboxMailOptions[];
|
|||||||
void ReshowPlayerPC(u8 taskId);
|
void ReshowPlayerPC(u8 taskId);
|
||||||
void sub_816B31C(void);
|
void sub_816B31C(void);
|
||||||
void Mailbox_ReturnToMailListAfterDeposit(void);
|
void Mailbox_ReturnToMailListAfterDeposit(void);
|
||||||
|
void NewGameInitPCItems(void);
|
||||||
|
|
||||||
|
|
||||||
#endif //GUARD_PLAYER_PC_H
|
#endif //GUARD_PLAYER_PC_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef GUARD_POKEDEX_H
|
#ifndef GUARD_POKEDEX_H
|
||||||
#define GUARD_POKEDEX_H
|
#define GUARD_POKEDEX_H
|
||||||
|
|
||||||
extern u8 gUnknown_030060B0;
|
extern u8 gUnusedU8;
|
||||||
extern void (*gUnknown_030060B4)(void);
|
extern void (*gUnknown_030060B4)(void);
|
||||||
|
|
||||||
#define HOENN_DEX_COUNT 202
|
#define HOENN_DEX_COUNT 202
|
||||||
@ -42,5 +42,6 @@ u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 trainerId, u32 personality);
|
|||||||
s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId);
|
s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId);
|
||||||
u16 CreateMonSpriteFromNationalDexNumber(u16, s16, s16, u16);
|
u16 CreateMonSpriteFromNationalDexNumber(u16, s16, s16, u16);
|
||||||
bool16 HasAllHoennMons(void);
|
bool16 HasAllHoennMons(void);
|
||||||
|
void ResetPokedexScrollPositions(void);
|
||||||
|
|
||||||
#endif // GUARD_POKEDEX_H
|
#endif // GUARD_POKEDEX_H
|
||||||
|
@ -24,6 +24,7 @@ void sub_80EBB28(void);
|
|||||||
void WarpIntoSecretBase(const struct MapPosition *position, const struct MapEvents *events);
|
void WarpIntoSecretBase(const struct MapPosition *position, const struct MapEvents *events);
|
||||||
bool8 sub_80E909C(void);
|
bool8 sub_80E909C(void);
|
||||||
void sub_80EB218(void);
|
void sub_80EB218(void);
|
||||||
|
void ResetSecretBases(void);
|
||||||
|
|
||||||
// SetCurrentSecretBaseFromPosition
|
// SetCurrentSecretBaseFromPosition
|
||||||
void sub_80E9608(const struct MapPosition *position, const struct MapEvents *events);
|
void sub_80E9608(const struct MapPosition *position, const struct MapEvents *events);
|
||||||
@ -33,4 +34,5 @@ void sub_80E8BC8(void);
|
|||||||
void sub_80E8D4C(void);
|
void sub_80E8D4C(void);
|
||||||
void EnableBothScriptContexts(void);
|
void EnableBothScriptContexts(void);
|
||||||
|
|
||||||
|
|
||||||
#endif //GUARD_SECRET_BASE_H
|
#endif //GUARD_SECRET_BASE_H
|
||||||
|
@ -61,5 +61,6 @@ void ContestLiveUpdates_BeforeInterview_2(u8 a0);
|
|||||||
void ContestLiveUpdates_BeforeInterview_3(u8 a0);
|
void ContestLiveUpdates_BeforeInterview_3(u8 a0);
|
||||||
void ContestLiveUpdates_BeforeInterview_4(u16 a0);
|
void ContestLiveUpdates_BeforeInterview_4(u16 a0);
|
||||||
void ContestLiveUpdates_BeforeInterview_5(u8 a0, u8 a1);
|
void ContestLiveUpdates_BeforeInterview_5(u8 a0, u8 a1);
|
||||||
|
void ResetGabbyAndTy(void);
|
||||||
|
|
||||||
#endif //GUARD_TV_H
|
#endif //GUARD_TV_H
|
||||||
|
@ -359,7 +359,7 @@ void easy_chat_input_maybe(void)
|
|||||||
words = gSaveBlock2Ptr->apprentices[0].easyChatWords;
|
words = gSaveBlock2Ptr->apprentices[0].easyChatWords;
|
||||||
break;
|
break;
|
||||||
case 20:
|
case 20:
|
||||||
words = sub_801B058();
|
words = GetSaveBlock1Field3564();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -28,8 +28,6 @@ EWRAM_DATA static u8 gUnknown_020375FC[16] = {0};
|
|||||||
|
|
||||||
extern u16 *const gSpecialVars[];
|
extern u16 *const gSpecialVars[];
|
||||||
|
|
||||||
extern void sub_80BB358(void);
|
|
||||||
|
|
||||||
void InitEventData(void)
|
void InitEventData(void)
|
||||||
{
|
{
|
||||||
memset(gSaveBlock1Ptr->flags, 0, sizeof(gSaveBlock1Ptr->flags));
|
memset(gSaveBlock1Ptr->flags, 0, sizeof(gSaveBlock1Ptr->flags));
|
||||||
@ -69,7 +67,7 @@ void EnableNationalPokedex(void)
|
|||||||
FlagSet(FLAG_SYS_NATIONAL_DEX);
|
FlagSet(FLAG_SYS_NATIONAL_DEX);
|
||||||
gSaveBlock2Ptr->pokedex.mode = DEX_MODE_NATIONAL;
|
gSaveBlock2Ptr->pokedex.mode = DEX_MODE_NATIONAL;
|
||||||
gSaveBlock2Ptr->pokedex.order = 0;
|
gSaveBlock2Ptr->pokedex.order = 0;
|
||||||
sub_80BB358();
|
ResetPokedexScrollPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool32 IsNationalPokedexEnabled(void)
|
bool32 IsNationalPokedexEnabled(void)
|
||||||
|
@ -1528,7 +1528,7 @@ static void ShowLinkContestResultsWindow(void)
|
|||||||
|
|
||||||
static void sub_81A31FC(void)
|
static void sub_81A31FC(void)
|
||||||
{
|
{
|
||||||
u8 text[32];
|
u8 name[32];
|
||||||
s32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
s32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
||||||
s32 facility = VarGet(VAR_FRONTIER_FACILITY);
|
s32 facility = VarGet(VAR_FRONTIER_FACILITY);
|
||||||
s32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
|
s32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
|
||||||
@ -1541,9 +1541,9 @@ static void sub_81A31FC(void)
|
|||||||
gSaveBlock2Ptr->frontier.towerRecordWinStreaks[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode];
|
gSaveBlock2Ptr->frontier.towerRecordWinStreaks[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode];
|
||||||
if (battleMode == FRONTIER_MODE_LINK_MULTIS)
|
if (battleMode == FRONTIER_MODE_LINK_MULTIS)
|
||||||
{
|
{
|
||||||
StringCopy(text, gLinkPlayers[gBattleScripting.multiplayerId ^ 1].name);
|
StringCopy(name, gLinkPlayers[gBattleScripting.multiplayerId ^ 1].name);
|
||||||
StripExtCtrlCodes(text);
|
StripExtCtrlCodes(name);
|
||||||
StringCopy(gSaveBlock2Ptr->frontier.field_EE1[lvlMode], text);
|
StringCopy(gSaveBlock2Ptr->frontier.opponentName[lvlMode], name);
|
||||||
SetTrainerId(gLinkPlayers[gBattleScripting.multiplayerId ^ 1].trainerId, gSaveBlock2Ptr->frontier.field_EF1[lvlMode]);
|
SetTrainerId(gLinkPlayers[gBattleScripting.multiplayerId ^ 1].trainerId, gSaveBlock2Ptr->frontier.field_EF1[lvlMode]);
|
||||||
}
|
}
|
||||||
if (gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] > 1
|
if (gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] > 1
|
||||||
@ -2336,8 +2336,8 @@ static void PrintHallRecords(s32 hallFacilityId, s32 lvlMode)
|
|||||||
AddTextPrinterParameterized(gRecordsWindowId, 1, gLevelModeText[lvlMode], x, 1, TEXT_SPEED_FF, NULL);
|
AddTextPrinterParameterized(gRecordsWindowId, 1, gLevelModeText[lvlMode], x, 1, TEXT_SPEED_FF, NULL);
|
||||||
if (hallFacilityId == HALL_FACILITIES_COUNT)
|
if (hallFacilityId == HALL_FACILITIES_COUNT)
|
||||||
{
|
{
|
||||||
gSaveBlock2Ptr->frontier.field_EE1[0][PLAYER_NAME_LENGTH] = EOS;
|
gSaveBlock2Ptr->frontier.opponentName[0][PLAYER_NAME_LENGTH] = EOS;
|
||||||
gSaveBlock2Ptr->frontier.field_EE1[1][PLAYER_NAME_LENGTH] = EOS;
|
gSaveBlock2Ptr->frontier.opponentName[1][PLAYER_NAME_LENGTH] = EOS;
|
||||||
Fill2PRecords(records2P, lvlMode);
|
Fill2PRecords(records2P, lvlMode);
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
Print2PRecord(i, 1, 4, &records2P[i]);
|
Print2PRecord(i, 1, 4, &records2P[i]);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "constants/species.h"
|
#include "constants/species.h"
|
||||||
|
#include "save.h"
|
||||||
|
|
||||||
extern u16 gUnknown_03005DA8;
|
extern u16 gUnknown_03005DA8;
|
||||||
extern void nullsub_89(u8 taskId);
|
extern void nullsub_89(u8 taskId);
|
||||||
@ -2347,17 +2348,17 @@ void sub_800E174(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_800E378(struct UnkSaveSubstruct_3b98 *dest, u32 trainerId, const u8 *name)
|
void CopyTrainerRecord(struct TrainerNameRecord *dest, u32 trainerId, const u8 *name)
|
||||||
{
|
{
|
||||||
dest->trainerId = trainerId;
|
dest->trainerId = trainerId;
|
||||||
StringCopy(dest->trainerName, name);
|
StringCopy(dest->trainerName, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool32 sub_800E388(const u8 *name)
|
bool32 NameIsNotEmpty(const u8 *name)
|
||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
|
||||||
{
|
{
|
||||||
if (name[i] != 0)
|
if (name[i] != 0)
|
||||||
{
|
{
|
||||||
@ -2367,52 +2368,64 @@ bool32 sub_800E388(const u8 *name)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_800E3A8(void)
|
// Save the currently connected players into the trainer records, shifting all previous records down.
|
||||||
|
void RecordMixTrainerNames(void)
|
||||||
{
|
{
|
||||||
if (gWirelessCommType != 0)
|
if (gWirelessCommType != 0)
|
||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
s32 j;
|
s32 j;
|
||||||
s32 cnt;
|
s32 nextSpace;
|
||||||
s32 sp0[5];
|
s32 connectedTrainerRecordIndecies[5];
|
||||||
struct UnkSaveSubstruct_3b98 *sp14 = calloc(20, sizeof(struct UnkSaveSubstruct_3b98));
|
struct TrainerNameRecord *newRecords = calloc(20, sizeof(struct TrainerNameRecord));
|
||||||
|
|
||||||
|
// Check if we already have a record saved for connected trainers.
|
||||||
for (i = 0; i < GetLinkPlayerCount(); i++)
|
for (i = 0; i < GetLinkPlayerCount(); i++)
|
||||||
{
|
{
|
||||||
sp0[i] = -1;
|
connectedTrainerRecordIndecies[i] = -1;
|
||||||
for (j = 0; j < 20; j++)
|
for (j = 0; j < 20; j++)
|
||||||
{
|
{
|
||||||
if ((u16)gLinkPlayers[i].trainerId == gSaveBlock1Ptr->unk_3B98[j].trainerId && StringCompare(gLinkPlayers[i].name, gSaveBlock1Ptr->unk_3B98[j].trainerName) == 0)
|
if ((u16)gLinkPlayers[i].trainerId == gSaveBlock1Ptr->trainerNameRecords[j].trainerId && StringCompare(gLinkPlayers[i].name, gSaveBlock1Ptr->trainerNameRecords[j].trainerName) == 0)
|
||||||
{
|
{
|
||||||
sp0[i] = j;
|
connectedTrainerRecordIndecies[i] = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cnt = 0;
|
|
||||||
|
// Save the connected trainers first, at the top of the list.
|
||||||
|
nextSpace = 0;
|
||||||
for (i = 0; i < GetLinkPlayerCount(); i++)
|
for (i = 0; i < GetLinkPlayerCount(); i++)
|
||||||
{
|
{
|
||||||
if (i != GetMultiplayerId() && gLinkPlayers[i].language != LANGUAGE_JAPANESE)
|
if (i != GetMultiplayerId() && gLinkPlayers[i].language != LANGUAGE_JAPANESE)
|
||||||
{
|
{
|
||||||
sub_800E378(&sp14[cnt], (u16)gLinkPlayers[i].trainerId, gLinkPlayers[i].name);
|
CopyTrainerRecord(&newRecords[nextSpace], (u16)gLinkPlayers[i].trainerId, gLinkPlayers[i].name);
|
||||||
if (sp0[i] >= 0)
|
|
||||||
|
// If we already had a record for this trainer, wipe it so that the next step doesn't duplicate it.
|
||||||
|
if (connectedTrainerRecordIndecies[i] >= 0)
|
||||||
{
|
{
|
||||||
memset(gSaveBlock1Ptr->unk_3B98[sp0[i]].trainerName, 0, 8);
|
memset(gSaveBlock1Ptr->trainerNameRecords[connectedTrainerRecordIndecies[i]].trainerName, 0, 8);
|
||||||
}
|
}
|
||||||
cnt++;
|
nextSpace++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy all non-empty records to the new list, in the order they appear on the old list. If the list is full,
|
||||||
|
// the last (oldest) records will be dropped.
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
if (sub_800E388(gSaveBlock1Ptr->unk_3B98[i].trainerName))
|
if (NameIsNotEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName))
|
||||||
{
|
{
|
||||||
sub_800E378(&sp14[cnt], gSaveBlock1Ptr->unk_3B98[i].trainerId, gSaveBlock1Ptr->unk_3B98[i].trainerName);
|
CopyTrainerRecord(&newRecords[nextSpace], gSaveBlock1Ptr->trainerNameRecords[i].trainerId, gSaveBlock1Ptr->trainerNameRecords[i].trainerName);
|
||||||
if (++cnt >= 20)
|
if (++nextSpace >= 20)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(gSaveBlock1Ptr->unk_3B98, sp14, 20 * sizeof(struct UnkSaveSubstruct_3b98));
|
|
||||||
free(sp14);
|
// Finalize the new list, and clean up.
|
||||||
|
memcpy(gSaveBlock1Ptr->trainerNameRecords, newRecords, 20 * sizeof(struct TrainerNameRecord));
|
||||||
|
free(newRecords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2422,11 +2435,11 @@ bool32 sub_800E540(u16 id, u8 *name)
|
|||||||
|
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
if (StringCompare(gSaveBlock1Ptr->unk_3B98[i].trainerName, name) == 0 && gSaveBlock1Ptr->unk_3B98[i].trainerId == id)
|
if (StringCompare(gSaveBlock1Ptr->trainerNameRecords[i].trainerName, name) == 0 && gSaveBlock1Ptr->trainerNameRecords[i].trainerId == id)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (!sub_800E388(gSaveBlock1Ptr->unk_3B98[i].trainerName))
|
if (!NameIsNotEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -2434,14 +2447,14 @@ bool32 sub_800E540(u16 id, u8 *name)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_800E5AC(void)
|
void WipeTrainerNameRecords(void)
|
||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
gSaveBlock1Ptr->unk_3B98[i].trainerId = 0;
|
gSaveBlock1Ptr->trainerNameRecords[i].trainerId = 0;
|
||||||
CpuFill16(0, gSaveBlock1Ptr->unk_3B98[i].trainerName, 8);
|
CpuFill16(0, gSaveBlock1Ptr->trainerNameRecords[i].trainerName, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,31 +30,25 @@
|
|||||||
#include "apprentice.h"
|
#include "apprentice.h"
|
||||||
#include "frontier_util.h"
|
#include "frontier_util.h"
|
||||||
#include "constants/maps.h"
|
#include "constants/maps.h"
|
||||||
|
#include "pokedex.h"
|
||||||
|
#include "save.h"
|
||||||
|
#include "link_rfu.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "contest.h"
|
||||||
|
#include "item_menu.h"
|
||||||
|
#include "pokemon_storage_system.h"
|
||||||
|
#include "decoration_inventory.h"
|
||||||
|
#include "secret_base.h"
|
||||||
|
#include "player_pc.h"
|
||||||
|
#include "field_specials.h"
|
||||||
|
|
||||||
extern u16 gSaveFileStatus;
|
|
||||||
extern u8 gUnknown_030060B0;
|
|
||||||
|
|
||||||
// TODO: replace those declarations with file headers
|
|
||||||
extern u16 GetGeneratedTrainerIdLower(void);
|
|
||||||
extern void ClearContestWinnerPicsInContestHall(void);
|
|
||||||
extern void sub_80BB358(void);
|
|
||||||
extern void ResetBagScrollPositions(void);
|
|
||||||
extern void ResetGabbyAndTy(void);
|
|
||||||
extern void ResetSecretBases(void);
|
|
||||||
extern void ResetLinkContestBoolean(void);
|
|
||||||
extern void sub_8052DA8(void);
|
|
||||||
extern void ResetPokemonStorageSystem(void);
|
|
||||||
extern void NewGameInitPCItems(void);
|
|
||||||
extern void ClearDecorationInventories(void);
|
|
||||||
extern void ResetFanClub(void);
|
|
||||||
extern void copy_strings_to_sav1(void);
|
extern void copy_strings_to_sav1(void);
|
||||||
extern void sub_801AFD8(void);
|
extern void sub_801AFD8(void);
|
||||||
extern void sub_800E5AC(void);
|
|
||||||
extern void ResetContestLinkResults(void);
|
|
||||||
extern void ResetPokeJumpResults(void);
|
extern void ResetPokeJumpResults(void);
|
||||||
extern void SetBerryPowder(u32* powder, u32 newValue);
|
extern void SetBerryPowder(u32* powder, u32 newValue);
|
||||||
|
|
||||||
extern const u8 EventScript_2715DE[];
|
extern const u8 EventScript_ResetAllMapFlags[];
|
||||||
|
|
||||||
// this file's functions
|
// this file's functions
|
||||||
static void ClearFrontierRecord(void);
|
static void ClearFrontierRecord(void);
|
||||||
@ -112,7 +106,7 @@ static void SetDefaultOptions(void)
|
|||||||
|
|
||||||
static void ClearPokedexFlags(void)
|
static void ClearPokedexFlags(void)
|
||||||
{
|
{
|
||||||
gUnknown_030060B0 = 0;
|
gUnusedU8 = 0;
|
||||||
memset(&gSaveBlock2Ptr->pokedex.owned, 0, sizeof(gSaveBlock2Ptr->pokedex.owned));
|
memset(&gSaveBlock2Ptr->pokedex.owned, 0, sizeof(gSaveBlock2Ptr->pokedex.owned));
|
||||||
memset(&gSaveBlock2Ptr->pokedex.seen, 0, sizeof(gSaveBlock2Ptr->pokedex.seen));
|
memset(&gSaveBlock2Ptr->pokedex.seen, 0, sizeof(gSaveBlock2Ptr->pokedex.seen));
|
||||||
}
|
}
|
||||||
@ -130,8 +124,8 @@ static void ClearFrontierRecord(void)
|
|||||||
{
|
{
|
||||||
CpuFill32(0, &gSaveBlock2Ptr->frontier, sizeof(gSaveBlock2Ptr->frontier));
|
CpuFill32(0, &gSaveBlock2Ptr->frontier, sizeof(gSaveBlock2Ptr->frontier));
|
||||||
|
|
||||||
gSaveBlock2Ptr->frontier.field_EE1[0][0] = EOS;
|
gSaveBlock2Ptr->frontier.opponentName[0][0] = EOS;
|
||||||
gSaveBlock2Ptr->frontier.field_EE1[1][0] = EOS;
|
gSaveBlock2Ptr->frontier.opponentName[1][0] = EOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WarpToTruck(void)
|
static void WarpToTruck(void)
|
||||||
@ -149,7 +143,7 @@ void Sav2_ClearSetDefault(void)
|
|||||||
void ResetMenuAndMonGlobals(void)
|
void ResetMenuAndMonGlobals(void)
|
||||||
{
|
{
|
||||||
gDifferentSaveFile = 0;
|
gDifferentSaveFile = 0;
|
||||||
sub_80BB358();
|
ResetPokedexScrollPositions();
|
||||||
ZeroPlayerPartyMons();
|
ZeroPlayerPartyMons();
|
||||||
ZeroEnemyPartyMons();
|
ZeroEnemyPartyMons();
|
||||||
ResetBagScrollPositions();
|
ResetBagScrollPositions();
|
||||||
@ -170,7 +164,7 @@ void NewGameInitData(void)
|
|||||||
ClearSav1();
|
ClearSav1();
|
||||||
ClearMailData();
|
ClearMailData();
|
||||||
gSaveBlock2Ptr->specialSaveWarpFlags = 0;
|
gSaveBlock2Ptr->specialSaveWarpFlags = 0;
|
||||||
gSaveBlock2Ptr->field_A8 = 0;
|
gSaveBlock2Ptr->unusedFlagField = 0;
|
||||||
InitPlayerTrainerId();
|
InitPlayerTrainerId();
|
||||||
PlayTimeCounter_Reset();
|
PlayTimeCounter_Reset();
|
||||||
ClearPokedexFlags();
|
ClearPokedexFlags();
|
||||||
@ -203,7 +197,7 @@ void NewGameInitData(void)
|
|||||||
ResetFanClub();
|
ResetFanClub();
|
||||||
ResetLotteryCorner();
|
ResetLotteryCorner();
|
||||||
WarpToTruck();
|
WarpToTruck();
|
||||||
ScriptContext2_RunNewScript(EventScript_2715DE);
|
ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags);
|
||||||
ResetMiniGamesResults();
|
ResetMiniGamesResults();
|
||||||
copy_strings_to_sav1();
|
copy_strings_to_sav1();
|
||||||
SetLilycoveLady();
|
SetLilycoveLady();
|
||||||
@ -211,7 +205,7 @@ void NewGameInitData(void)
|
|||||||
ClearRankingHallRecords();
|
ClearRankingHallRecords();
|
||||||
InitMatchCallCounters();
|
InitMatchCallCounters();
|
||||||
sub_801AFD8();
|
sub_801AFD8();
|
||||||
sub_800E5AC();
|
WipeTrainerNameRecords();
|
||||||
ResetTrainerHillResults();
|
ResetTrainerHillResults();
|
||||||
ResetContestLinkResults();
|
ResetContestLinkResults();
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,8 @@ static EWRAM_DATA u8 gUnknown_02039B52 = 0;
|
|||||||
static EWRAM_DATA struct PokedexListItem *sPokedexListItem = NULL;
|
static EWRAM_DATA struct PokedexListItem *sPokedexListItem = NULL;
|
||||||
|
|
||||||
// IWRAM common
|
// IWRAM common
|
||||||
u8 gUnknown_030060B0;
|
// This is written to, but never read.
|
||||||
|
u8 gUnusedU8;
|
||||||
void (*gUnknown_030060B4)(void);
|
void (*gUnknown_030060B4)(void);
|
||||||
|
|
||||||
struct PokedexOption
|
struct PokedexOption
|
||||||
@ -1225,7 +1226,7 @@ void ResetPokedex(void)
|
|||||||
|
|
||||||
gUnknown_02039B50 = 0;
|
gUnknown_02039B50 = 0;
|
||||||
gUnknown_02039B52 = 64;
|
gUnknown_02039B52 = 64;
|
||||||
gUnknown_030060B0 = 0;
|
gUnusedU8 = 0;
|
||||||
gSaveBlock2Ptr->pokedex.mode = DEX_MODE_HOENN;
|
gSaveBlock2Ptr->pokedex.mode = DEX_MODE_HOENN;
|
||||||
gSaveBlock2Ptr->pokedex.order = 0;
|
gSaveBlock2Ptr->pokedex.order = 0;
|
||||||
gSaveBlock2Ptr->pokedex.nationalMagic = 0;
|
gSaveBlock2Ptr->pokedex.nationalMagic = 0;
|
||||||
@ -1243,7 +1244,7 @@ void ResetPokedex(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_80BB358(void)
|
void ResetPokedexScrollPositions(void)
|
||||||
{
|
{
|
||||||
gUnknown_02039B50 = 0;
|
gUnknown_02039B50 = 0;
|
||||||
gUnknown_02039B52 = 64;
|
gUnknown_02039B52 = 64;
|
||||||
|
@ -1087,7 +1087,7 @@ void GetPlayerHallRecords(struct PlayerHallRecords *dst)
|
|||||||
CopyTrainerId(dst->twoPlayers[j].id1, gSaveBlock2Ptr->playerTrainerId);
|
CopyTrainerId(dst->twoPlayers[j].id1, gSaveBlock2Ptr->playerTrainerId);
|
||||||
CopyTrainerId(dst->twoPlayers[j].id2, gSaveBlock2Ptr->frontier.field_EF1[j]);
|
CopyTrainerId(dst->twoPlayers[j].id2, gSaveBlock2Ptr->frontier.field_EF1[j]);
|
||||||
StringCopy(dst->twoPlayers[j].name1, gSaveBlock2Ptr->playerName);
|
StringCopy(dst->twoPlayers[j].name1, gSaveBlock2Ptr->playerName);
|
||||||
StringCopy(dst->twoPlayers[j].name2, gSaveBlock2Ptr->frontier.field_EE1[j]);
|
StringCopy(dst->twoPlayers[j].name2, gSaveBlock2Ptr->frontier.opponentName[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
|
@ -1687,7 +1687,7 @@ void sub_801440C(u8 taskId)
|
|||||||
case 9 ... 11:
|
case 9 ... 11:
|
||||||
case 13:
|
case 13:
|
||||||
case 15:
|
case 15:
|
||||||
sub_800E3A8();
|
RecordMixTrainerNames();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1800,12 +1800,12 @@ void sub_8014790(u8 taskId)
|
|||||||
sendBuff[1] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[1] - 1], MON_DATA_SPECIES, NULL);
|
sendBuff[1] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[1] - 1], MON_DATA_SPECIES, NULL);
|
||||||
gMain.savedCallback = NULL;
|
gMain.savedCallback = NULL;
|
||||||
data[0] = 4;
|
data[0] = 4;
|
||||||
sub_800E3A8();
|
RecordMixTrainerNames();
|
||||||
ResetBlockReceivedFlags();
|
ResetBlockReceivedFlags();
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
case 23 ... 27:
|
case 23 ... 27:
|
||||||
sub_800E3A8();
|
RecordMixTrainerNames();
|
||||||
DestroyTask(taskId);
|
DestroyTask(taskId);
|
||||||
default:
|
default:
|
||||||
EnableBothScriptContexts();
|
EnableBothScriptContexts();
|
||||||
|
@ -120,13 +120,13 @@ void TrySetMapSaveWarpStatus(void)
|
|||||||
|
|
||||||
void sub_81AFDA0(void)
|
void sub_81AFDA0(void)
|
||||||
{
|
{
|
||||||
gSaveBlock2Ptr->field_A8 |= 0x8000;
|
gSaveBlock2Ptr->unusedFlagField |= 0x8000;
|
||||||
gSaveBlock2Ptr->field_A8 |= 0x1;
|
gSaveBlock2Ptr->unusedFlagField |= 0x1;
|
||||||
gSaveBlock2Ptr->field_A8 |= 0x2;
|
gSaveBlock2Ptr->unusedFlagField |= 0x2;
|
||||||
gSaveBlock2Ptr->field_A8 |= 0x4;
|
gSaveBlock2Ptr->unusedFlagField |= 0x4;
|
||||||
gSaveBlock2Ptr->field_A8 |= 0x10;
|
gSaveBlock2Ptr->unusedFlagField |= 0x10;
|
||||||
gSaveBlock2Ptr->field_A8 |= 0x20;
|
gSaveBlock2Ptr->unusedFlagField |= 0x20;
|
||||||
gSaveBlock2Ptr->field_A8 |= 0x8;
|
gSaveBlock2Ptr->unusedFlagField |= 0x8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_81AFDD0(void)
|
void sub_81AFDD0(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user