summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorultima-soul <akshayjhanji@hotmail.com>2019-10-06 00:48:48 -0700
committerultima-soul <akshayjhanji@hotmail.com>2019-10-06 00:48:48 -0700
commitd84e9bed58db84bbb7db568c366bfa803be87139 (patch)
tree13a924bbf40b3a0ab38d915ef6349f8a4bd60c15
parentb4b509f68477068ae111cc5a6094d858d396c4bb (diff)
Decompile/port new_game
-rw-r--r--asm/battle_tower.s4
-rw-r--r--asm/hall_of_fame.s2
-rw-r--r--asm/link_rfu_3.s4
-rw-r--r--asm/new_game.s340
-rw-r--r--asm/overworld.s18
-rw-r--r--asm/start_menu.s12
-rw-r--r--data/map_event_scripts.inc2
-rw-r--r--include/battle_records.h13
-rw-r--r--include/berry.h1
-rw-r--r--include/berry_pouch.h1
-rw-r--r--include/berry_powder.h1
-rw-r--r--include/easy_chat.h1
-rw-r--r--include/event_data.h2
-rw-r--r--include/global.h10
-rw-r--r--include/item_menu.h1
-rw-r--r--include/main.h1
-rw-r--r--include/mevent.h1
-rw-r--r--include/new_game.h14
-rw-r--r--include/overworld.h3
-rw-r--r--include/player_pc.h1
-rw-r--r--include/pokemon_jump.h14
-rw-r--r--include/pokemon_size_record.h3
-rw-r--r--include/pokemon_storage_system.h1
-rw-r--r--include/quest_log.h2
-rw-r--r--include/trainer_tower.h2
-rw-r--r--include/union_room_chat.h7
-rw-r--r--include/wild_encounter.h1
-rw-r--r--ld_script.txt2
-rw-r--r--src/berry_powder.c10
-rw-r--r--src/mevent.c2
-rw-r--r--src/new_game.c168
-rw-r--r--src/scrcmd.c14
-rw-r--r--src/seagallop.c2
-rw-r--r--sym_ewram.txt2
34 files changed, 272 insertions, 390 deletions
diff --git a/asm/battle_tower.s b/asm/battle_tower.s
index abb47aba9..08fefffbc 100644
--- a/asm/battle_tower.s
+++ b/asm/battle_tower.s
@@ -2799,7 +2799,7 @@ _080E6F0E:
ldr r4, _080E6FA4 @ =gSaveBlock2Ptr
ldr r1, [r4]
adds r1, 0xA
- bl CopyUnalignedWord
+ bl CopyTrainerId
adds r0, r5, 0x4
ldr r1, [r4]
bl StringCopy7
@@ -3369,7 +3369,7 @@ _080E7372:
adds r0, 0xC
ldr r1, [r5]
adds r1, 0xA
- bl CopyUnalignedWord
+ bl CopyTrainerId
adds r0, r7, 0x4
ldr r1, [r5]
bl StringCopy7
diff --git a/asm/hall_of_fame.s b/asm/hall_of_fame.s
index 5b28e21d5..75475b667 100644
--- a/asm/hall_of_fame.s
+++ b/asm/hall_of_fame.s
@@ -1458,7 +1458,7 @@ sub_80F2934: @ 80F2934
movs r0, 0x3 @ MAP_GROUP(INDIGO_PLATEAU_EXTERIOR)
movs r1, 0x9 @ MAP_NUM(INDIGO_PLATEAU_EXTERIOR)
movs r3, 0xB
- bl Overworld_SetWarpDestination
+ bl SetWarpDestination
bl DoWarp
bl ResetInitialPlayerAvatarState
add sp, 0x4
diff --git a/asm/link_rfu_3.s b/asm/link_rfu_3.s
index f65efc5f7..4ddbed23a 100644
--- a/asm/link_rfu_3.s
+++ b/asm/link_rfu_3.s
@@ -3356,7 +3356,7 @@ sub_8117440: @ 8117440
asrs r5, 24
str r5, [sp]
adds r3, r4, 0
- bl Overworld_SetWarpDestination
+ bl SetWarpDestination
ldr r0, [r6]
movs r1, 0x4
ldrsb r1, [r0, r1]
@@ -3423,7 +3423,7 @@ sub_81174B4: @ 81174B4
adds r0, r4, 0
adds r1, r5, 0
mov r3, r8
- bl Overworld_SetWarpDestination
+ bl SetWarpDestination
bl WarpIntoMap
add sp, 0x4
pop {r3}
diff --git a/asm/new_game.s b/asm/new_game.s
deleted file mode 100644
index 15c06e8eb..000000000
--- a/asm/new_game.s
+++ /dev/null
@@ -1,340 +0,0 @@
- .include "asm/macros.inc"
- .include "constants/constants.inc"
-
- .syntax unified
-
- .text
-
- thumb_func_start WriteUnalignedWord
-WriteUnalignedWord: @ 80548FC
- strb r0, [r1]
- lsrs r2, r0, 8
- strb r2, [r1, 0x1]
- lsrs r2, r0, 16
- strb r2, [r1, 0x2]
- lsrs r0, 24
- strb r0, [r1, 0x3]
- bx lr
- thumb_func_end WriteUnalignedWord
-
- thumb_func_start CopyUnalignedWord
-CopyUnalignedWord: @ 805490C
- push {r4,lr}
- adds r4, r0, 0
- adds r3, r1, 0
- movs r2, 0
-_08054914:
- adds r0, r4, r2
- adds r1, r3, r2
- ldrb r1, [r1]
- strb r1, [r0]
- adds r2, 0x1
- cmp r2, 0x3
- ble _08054914
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end CopyUnalignedWord
-
- thumb_func_start InitPlayerTrainerId
-InitPlayerTrainerId: @ 8054928
- push {r4,lr}
- bl Random
- adds r4, r0, 0
- bl GetGeneratedTrainerIdLower
- lsls r4, 16
- lsls r0, 16
- lsrs r0, 16
- orrs r4, r0
- ldr r0, _08054950 @ =gSaveBlock2Ptr
- ldr r1, [r0]
- adds r1, 0xA
- adds r0, r4, 0
- bl WriteUnalignedWord
- pop {r4}
- pop {r0}
- bx r0
- .align 2, 0
-_08054950: .4byte gSaveBlock2Ptr
- thumb_func_end InitPlayerTrainerId
-
- thumb_func_start SetDefaultOptions
-SetDefaultOptions: @ 8054954
- ldr r3, _080549A8 @ =gSaveBlock2Ptr
- ldr r2, [r3]
- ldrb r1, [r2, 0x14]
- movs r0, 0x8
- negs r0, r0
- ands r0, r1
- movs r1, 0x1
- orrs r0, r1
- strb r0, [r2, 0x14]
- ldr r2, [r3]
- ldrb r1, [r2, 0x14]
- movs r0, 0x7
- ands r0, r1
- strb r0, [r2, 0x14]
- ldr r2, [r3]
- ldrb r1, [r2, 0x15]
- movs r0, 0x2
- negs r0, r0
- ands r0, r1
- strb r0, [r2, 0x15]
- ldr r2, [r3]
- ldrb r1, [r2, 0x15]
- movs r0, 0x3
- negs r0, r0
- ands r0, r1
- strb r0, [r2, 0x15]
- ldr r2, [r3]
- ldrb r1, [r2, 0x15]
- movs r0, 0x5
- negs r0, r0
- ands r0, r1
- strb r0, [r2, 0x15]
- ldr r2, [r3]
- ldrb r1, [r2, 0x15]
- movs r0, 0x9
- negs r0, r0
- ands r0, r1
- strb r0, [r2, 0x15]
- ldr r1, [r3]
- movs r0, 0
- strb r0, [r1, 0x13]
- bx lr
- .align 2, 0
-_080549A8: .4byte gSaveBlock2Ptr
- thumb_func_end SetDefaultOptions
-
- thumb_func_start sub_80549AC
-sub_80549AC: @ 80549AC
- push {r4,lr}
- ldr r4, _080549D0 @ =gSaveBlock2Ptr
- ldr r0, [r4]
- adds r0, 0x28
- movs r1, 0
- movs r2, 0x34
- bl memset
- ldr r0, [r4]
- adds r0, 0x5C
- movs r1, 0
- movs r2, 0x34
- bl memset
- pop {r4}
- pop {r0}
- bx r0
- .align 2, 0
-_080549D0: .4byte gSaveBlock2Ptr
- thumb_func_end sub_80549AC
-
- thumb_func_start sub_80549D4
-sub_80549D4: @ 80549D4
- push {lr}
- sub sp, 0x4
- movs r0, 0
- str r0, [sp]
- ldr r0, _080549F0 @ =gSaveBlock2Ptr
- ldr r1, [r0]
- adds r1, 0xB0
- ldr r2, _080549F4 @ =0x050001fa
- mov r0, sp
- bl CpuSet
- add sp, 0x4
- pop {r0}
- bx r0
- .align 2, 0
-_080549F0: .4byte gSaveBlock2Ptr
-_080549F4: .4byte 0x050001fa
- thumb_func_end sub_80549D4
-
- thumb_func_start sub_80549F8
-sub_80549F8: @ 80549F8
- push {lr}
- sub sp, 0x4
- movs r2, 0x1
- negs r2, r2
- movs r0, 0x6
- str r0, [sp]
- movs r0, 0x4
- movs r1, 0x1
- movs r3, 0x6
- bl Overworld_SetWarpDestination
- bl WarpIntoMap
- add sp, 0x4
- pop {r0}
- bx r0
- thumb_func_end sub_80549F8
-
- thumb_func_start Sav2_ClearSetDefault
-Sav2_ClearSetDefault: @ 8054A18
- push {lr}
- bl ClearSav2
- bl SetDefaultOptions
- pop {r0}
- bx r0
- thumb_func_end Sav2_ClearSetDefault
-
- thumb_func_start ResetMenuAndMonGlobals
-ResetMenuAndMonGlobals: @ 8054A28
- push {lr}
- ldr r1, _08054A5C @ =gUnknown_2031DB0
- movs r0, 0
- strb r0, [r1]
- bl ZeroPlayerPartyMons
- bl ZeroEnemyPartyMons
- bl sub_81089BC
- bl ResetTMCaseCursorPos
- bl BerryPouch_CursorResetToTop
- bl sub_811089C
- bl Random
- lsls r0, 16
- lsrs r0, 16
- bl sub_8083214
- bl sub_806E6FC
- pop {r0}
- bx r0
- .align 2, 0
-_08054A5C: .4byte gUnknown_2031DB0
- thumb_func_end ResetMenuAndMonGlobals
-
- thumb_func_start sub_8054A60
-sub_8054A60: @ 8054A60
- push {r4-r6,lr}
- mov r6, r8
- push {r6}
- sub sp, 0x8
- ldr r6, _08054B50 @ =gSaveBlock1Ptr
- ldr r1, [r6]
- ldr r0, _08054B54 @ =0x00003a4c
- mov r8, r0
- add r1, r8
- mov r0, sp
- bl StringCopy
- ldr r1, _08054B58 @ =gUnknown_2031DB0
- movs r0, 0x1
- strb r0, [r1]
- ldr r4, _08054B5C @ =gSaveBlock2Ptr
- ldr r0, [r4]
- movs r1, 0xF2
- lsls r1, 4
- adds r0, r1
- movs r5, 0
- str r5, [r0]
- bl ZeroPlayerPartyMons
- bl ZeroEnemyPartyMons
- bl sub_80549D4
- bl ClearSav1
- bl ClearMailData
- ldr r0, [r4]
- strb r5, [r0, 0x9]
- ldr r0, [r4]
- adds r1, r0, 0
- adds r1, 0xA8
- str r5, [r1]
- adds r0, 0xAC
- movs r1, 0x1
- strb r1, [r0]
- ldr r0, [r4]
- adds r0, 0xAD
- strb r5, [r0]
- bl InitPlayerTrainerId
- bl PlayTimeCounter_Reset
- bl sub_80549AC
- bl sub_806E0D0
- bl ResetFameChecker
- ldr r0, [r6]
- movs r1, 0xA4
- lsls r1, 2
- adds r0, r1
- ldr r1, _08054B60 @ =0x00000bb8
- bl SetMoney
- bl sub_8054E68
- bl InitLinkBattleRecords
- bl sub_80A0904
- bl sub_80A0958
- bl sub_806E190
- ldr r0, _08054B64 @ =gPlayerPartyCount
- strb r5, [r0]
- bl ZeroPlayerPartyMons
- bl sub_808C7E0
- bl ClearRoamerData
- ldr r0, [r6]
- ldr r1, _08054B68 @ =0x00000296
- adds r0, r1
- strh r5, [r0]
- bl ClearItemSlotsInAllBagPockets
- bl sub_80EB658
- bl sub_809C794
- bl sub_80BDD34
- bl sub_8113044
- bl copy_strings_to_sav1
- bl sub_8054B70
- bl sub_8143D24
- bl sub_815D838
- bl sub_80549F8
- ldr r0, _08054B6C @ =gUnknown_81A6481
- bl ScriptContext2_RunNewScript
- ldr r0, [r6]
- add r0, r8
- mov r1, sp
- bl StringCopy
- bl sub_815EE0C
- add sp, 0x8
- pop {r3}
- mov r8, r3
- pop {r4-r6}
- pop {r0}
- bx r0
- .align 2, 0
-_08054B50: .4byte gSaveBlock1Ptr
-_08054B54: .4byte 0x00003a4c
-_08054B58: .4byte gUnknown_2031DB0
-_08054B5C: .4byte gSaveBlock2Ptr
-_08054B60: .4byte 0x00000bb8
-_08054B64: .4byte gPlayerPartyCount
-_08054B68: .4byte 0x00000296
-_08054B6C: .4byte gUnknown_81A6481
- thumb_func_end sub_8054A60
-
- thumb_func_start sub_8054B70
-sub_8054B70: @ 8054B70
- push {r4-r6,lr}
- sub sp, 0x4
- mov r0, sp
- movs r5, 0
- strh r5, [r0]
- ldr r4, _08054BBC @ =gSaveBlock2Ptr
- ldr r1, [r4]
- movs r0, 0xAF
- lsls r0, 4
- adds r1, r0
- ldr r6, _08054BC0 @ =0x01000008
- mov r0, sp
- adds r2, r6, 0
- bl CpuSet
- ldr r0, [r4]
- ldr r1, _08054BC4 @ =0x00000af8
- adds r0, r1
- movs r1, 0
- bl sub_815EE54
- bl ResetPokeJumpResults
- mov r0, sp
- adds r0, 0x2
- strh r5, [r0]
- ldr r1, [r4]
- movs r2, 0xB1
- lsls r2, 4
- adds r1, r2
- adds r2, r6, 0
- bl CpuSet
- add sp, 0x4
- pop {r4-r6}
- pop {r0}
- bx r0
- .align 2, 0
-_08054BBC: .4byte gSaveBlock2Ptr
-_08054BC0: .4byte 0x01000008
-_08054BC4: .4byte 0x00000af8
- thumb_func_end sub_8054B70
-
- .align 2, 0 @ Don't pad with nop.
diff --git a/asm/overworld.s b/asm/overworld.s
index 5cc051c8a..a443a0d10 100644
--- a/asm/overworld.s
+++ b/asm/overworld.s
@@ -1003,8 +1003,8 @@ WarpIntoMap: @ 8055378
bx r0
thumb_func_end WarpIntoMap
- thumb_func_start Overworld_SetWarpDestination
-Overworld_SetWarpDestination: @ 805538C
+ thumb_func_start SetWarpDestination
+SetWarpDestination: @ 805538C
push {r4-r6,lr}
sub sp, 0x8
adds r4, r0, 0
@@ -1034,7 +1034,7 @@ Overworld_SetWarpDestination: @ 805538C
bx r0
.align 2, 0
_080553C4: .4byte gUnknown_2031DBC
- thumb_func_end Overworld_SetWarpDestination
+ thumb_func_end SetWarpDestination
thumb_func_start warp1_set_2
warp1_set_2: @ 80553C8
@@ -1049,7 +1049,7 @@ warp1_set_2: @ 80553C8
movs r3, 0x1
negs r3, r3
str r3, [sp]
- bl Overworld_SetWarpDestination
+ bl SetWarpDestination
add sp, 0x4
pop {r0}
bx r0
@@ -1151,7 +1151,7 @@ sub_805546C: @ 805546C
lsls r4, 24
asrs r4, 24
str r4, [sp]
- bl Overworld_SetWarpDestination
+ bl SetWarpDestination
_0805549A:
add sp, 0x4
pop {r4}
@@ -1458,7 +1458,7 @@ _080556BC:
lsls r4, r6, 24
asrs r4, 24
str r4, [sp]
- bl Overworld_SetWarpDestination
+ bl SetWarpDestination
_080556D6:
add sp, 0x4
pop {r4-r6}
@@ -1627,7 +1627,7 @@ sub_80557C4: @ 80557C4
lsls r4, r5, 24
asrs r4, 24
str r4, [sp]
- bl Overworld_SetWarpDestination
+ bl SetWarpDestination
b _08055818
_080557FC:
bl mapheader_run_script_with_tag_x6
@@ -1700,7 +1700,7 @@ sub_8055864: @ 8055864
negs r3, r3
str r3, [sp]
adds r2, r3, 0
- bl Overworld_SetWarpDestination
+ bl SetWarpDestination
bl sub_8055E94
bl warp_shift
bl set_current_map_header_from_sav1_save_old_name
@@ -3493,7 +3493,7 @@ CB2_NewGame: @ 8056644
bl sub_80569BC
bl StopMapMusic
bl sub_8056420
- bl sub_8054A60
+ bl NewGameInitData
bl ResetInitialPlayerAvatarState
bl PlayTimeCounter_Start
bl ScriptContext1_Init
diff --git a/asm/start_menu.s b/asm/start_menu.s
index 40a678a01..7ab76140f 100644
--- a/asm/start_menu.s
+++ b/asm/start_menu.s
@@ -1386,7 +1386,7 @@ _0806F81A:
cmp r0, 0x2
bne _0806F82E
_0806F826:
- ldr r0, _0806F83C @ =gUnknown_2031DB0
+ ldr r0, _0806F83C @ =gDifferentSaveFile
ldrb r0, [r0]
cmp r0, 0
bne _0806F848
@@ -1397,7 +1397,7 @@ _0806F82E:
b _0806F864
.align 2, 0
_0806F838: .4byte gSaveFileStatus
-_0806F83C: .4byte gUnknown_2031DB0
+_0806F83C: .4byte gDifferentSaveFile
_0806F840: .4byte gUnknown_3000FA4
_0806F844: .4byte sub_806F86C
_0806F848:
@@ -1423,7 +1423,7 @@ _0806F866:
thumb_func_start sub_806F86C
sub_806F86C: @ 806F86C
push {lr}
- ldr r0, _0806F880 @ =gUnknown_2031DB0
+ ldr r0, _0806F880 @ =gDifferentSaveFile
ldrb r0, [r0]
cmp r0, 0x1
bne _0806F88C
@@ -1432,7 +1432,7 @@ sub_806F86C: @ 806F86C
bl sub_806F69C
b _0806F894
.align 2, 0
-_0806F880: .4byte gUnknown_2031DB0
+_0806F880: .4byte gDifferentSaveFile
_0806F884: .4byte gUnknown_81C566A
_0806F888: .4byte sub_806F8C0
_0806F88C:
@@ -1537,7 +1537,7 @@ sub_806F940: @ 806F940
push {r4,lr}
movs r0, 0
bl IncrementGameStat
- ldr r4, _0806F95C @ =gUnknown_2031DB0
+ ldr r4, _0806F95C @ =gDifferentSaveFile
ldrb r0, [r4]
cmp r0, 0x1
bne _0806F960
@@ -1547,7 +1547,7 @@ sub_806F940: @ 806F940
strb r0, [r4]
b _0806F966
.align 2, 0
-_0806F95C: .4byte gUnknown_2031DB0
+_0806F95C: .4byte gDifferentSaveFile
_0806F960:
movs r0, 0
bl TrySavingData
diff --git a/data/map_event_scripts.inc b/data/map_event_scripts.inc
index c333c6336..44861f91f 100644
--- a/data/map_event_scripts.inc
+++ b/data/map_event_scripts.inc
@@ -1435,7 +1435,7 @@ Text_1A644F:: @ 81A644F
.string "once. Is that okay?$"
-gUnknown_81A6481:: @ 81A6481
+EventScript_ResetAllMapFlags:: @ 81A6481
setflag FLAG_0x02B
setflag FLAG_0x02C
setflag FLAG_0x033
diff --git a/include/battle_records.h b/include/battle_records.h
new file mode 100644
index 000000000..55e969b50
--- /dev/null
+++ b/include/battle_records.h
@@ -0,0 +1,13 @@
+#ifndef GUARD_BATTLE_RECORDS_H
+#define GUARD_BATTLE_RECORDS_H
+
+extern u8 gRecordsWindowId;
+
+void ClearPlayerLinkBattleRecords(void);
+void InitLinkBattleRecords(void);
+void UpdatePlayerLinkBattleRecords(s32 battlerId);
+void ShowLinkBattleRecords(void);
+void RemoveRecordsWindow(void);
+void ShowTrainerHillRecords(void);
+
+#endif // GUARD_BATTLE_RECORDS_H \ No newline at end of file
diff --git a/include/berry.h b/include/berry.h
index c5a132ccb..0e554a789 100644
--- a/include/berry.h
+++ b/include/berry.h
@@ -62,6 +62,7 @@ void FieldObjectInteractionPickBerryTree(void);
void FieldObjectInteractionRemoveBerryTree(void);
u8 PlayerHasBerries(void);
void ResetBerryTreeSparkleFlags(void);
+void sub_809C794(void);
const struct Berry * sub_809C8A0(u8 berryIdx);
extern const struct Berry gBerries[];
diff --git a/include/berry_pouch.h b/include/berry_pouch.h
index cd9866d81..f478ff194 100644
--- a/include/berry_pouch.h
+++ b/include/berry_pouch.h
@@ -19,5 +19,6 @@ void BerryPouch_SetExitCallback(void (*exitCallback)(void));
void InitBerryPouch(u8 type, void (*savedCallback)(void), u8 allowSelect);
void DisplayItemMessageInBerryPouch(u8 taskId, u8 fontId, const u8 * str, TaskFunc followUpFunc);
void Task_BerryPouch_DestroyDialogueWindowAndRefreshListMenu(u8 taskId);
+void BerryPouch_CursorResetToTop(void);
#endif //GUARD_BERRY_POUCH_H
diff --git a/include/berry_powder.h b/include/berry_powder.h
index 89582aacc..f0e77c44b 100644
--- a/include/berry_powder.h
+++ b/include/berry_powder.h
@@ -2,5 +2,6 @@
#define GUARD_BERRY_POWDER_H
u32 GetBerryPowder(void);
+void SetBerryPowder(u32 *powder, u32 amount);
#endif //GUARD_BERRY_POWDER_H
diff --git a/include/easy_chat.h b/include/easy_chat.h
index bd5c9a026..e6a48fccc 100644
--- a/include/easy_chat.h
+++ b/include/easy_chat.h
@@ -38,6 +38,7 @@ void InitializeEasyChatWordArray(u16 *words, u16 length);
void ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 length1, u16 length2);
bool8 ECWord_CheckIfOutsideOfValidRange(u16 word);
void sub_80BDE28(void);
+void sub_80BDD34(void);
void EnableRareWord(u8);
#endif // GUARD_EASYCHAT_H
diff --git a/include/event_data.h b/include/event_data.h
index 013579ab5..c461c1d55 100644
--- a/include/event_data.h
+++ b/include/event_data.h
@@ -37,6 +37,8 @@ void sub_806E6FC(void);
void sub_806E2D0(void);
void sub_806E370(void);
bool32 sub_806E25C(void);
+void sub_806E0D0(void);
+void sub_806E190(void);
extern u16 gSpecialVar_0x8000;
extern u16 gSpecialVar_0x8001;
diff --git a/include/global.h b/include/global.h
index 55233a340..2af9bbc94 100644
--- a/include/global.h
+++ b/include/global.h
@@ -227,14 +227,20 @@ struct SaveBlock2
/*0x098*/ struct Time localTimeOffset;
/*0x0A0*/ struct Time lastBerryTreeUpdate;
/*0x0A8*/ u32 field_A8;
- /*0x0AC*/ u8 filler_AC[0x3F4];
+ /*0x0AC*/ u8 field_AC;
+ /*0x0AD*/ u8 field_AD;
+ /*0x0AE*/ u8 filler_AE[0x2];
+ /*0x0B0*/ u8 field_B0;
+ /*0x0B1*/ u8 filler_B1[0x3EF];
/*0x4A0*/ u32 unk_4A0[0x2F];
/*0x55c*/ struct UnkSaveBlock2Substruct_55C unk_55C;
/*0x574*/ u8 filler_574[0x324];
/*0x898*/ u16 mapView[0x100];
/*0xA98*/ struct LinkBattleRecords linkBattleRecords;
/*0xAF0*/ struct BerryCrush berryCrush;
- /*0xB00*/ u8 filler_B00[0x420];
+ /*0xB00*/ struct PokemonJumpResults pokeJump;
+ /*0xB10*/ struct BerryPickingResults berryPick;
+ /*0xB20*/ u8 filler_B20[0x400];
/*0xF20*/ u32 encryptionKey;
};
diff --git a/include/item_menu.h b/include/item_menu.h
index 2e83ed1f4..ceaf277a3 100644
--- a/include/item_menu.h
+++ b/include/item_menu.h
@@ -26,6 +26,7 @@ extern u16 gSpecialVar_ItemId;
void sub_81AAC50(void);
void sub_81AAC70(void);
void sub_8108CF0(void);
+void sub_81089BC(void);
void sub_810B108(u8);
void ReturnToBagFromKeyItem(void);
void ItemMenu_MoveItemSlotToNewPositionInArray(struct ItemSlot * slots, int pos1, int pos2);
diff --git a/include/main.h b/include/main.h
index d326909ff..589709436 100644
--- a/include/main.h
+++ b/include/main.h
@@ -67,6 +67,7 @@ void SetVBlankCounter1Ptr(u32 *ptr);
void DisableVBlankCounter1(void);
void StartTimer1(void);
void SeedRngAndSetTrainerId(void);
+u16 GetGeneratedTrainerIdLower(void);
extern const char RomHeaderGameCode[4];
extern const char RomHeaderSoftwareVersion;
diff --git a/include/mevent.h b/include/mevent.h
index b61fa732d..cee88e403 100644
--- a/include/mevent.h
+++ b/include/mevent.h
@@ -66,5 +66,6 @@ void MENews_RemoveScrollIndicatorArrowPair(void);
bool32 WonderNews_Test_Unk_02(void);
bool32 WonderCard_Test_Unk_08_6(void);
u32 MENews_GetInput(u16 input);
+void sub_8143D24(void);
#endif //GUARD_MEVENT_H
diff --git a/include/new_game.h b/include/new_game.h
index a45b090c8..346e7aff3 100644
--- a/include/new_game.h
+++ b/include/new_game.h
@@ -1,19 +1,13 @@
#ifndef GUARD_NEW_GAME_H
#define GUARD_NEW_GAME_H
-#include "global.h"
-
-void WriteUnalignedWord(u32 var, u8 *dataPtr);
+void SetTrainerId(u32 trainerId, u8 *dst);
u32 ReadUnalignedWord(u8* dataPtr);
-void CopyUnalignedWord(u8 *copyTo, u8 *copyFrom);
-void InitPlayerTrainerId(void);
-void SetDefaultOptions(void);
-void ClearPokedexFlags(void);
-void WarpToTruck(void);
+void CopyTrainerId(u8 *dst, u8 *src);
void NewGameInitData(void);
+void ResetMenuAndMonGlobals(void);
+void Sav2_ClearSetDefault(void);
void ResetMiniGamesResults(void);
void sub_808447C(void);
-void Sav2_ClearSetDefault(void);
-void ResetMenuAndMonGlobals(void);
#endif // GUARD_NEW_GAME_H
diff --git a/include/overworld.h b/include/overworld.h
index 92b0f6001..52f292357 100644
--- a/include/overworld.h
+++ b/include/overworld.h
@@ -49,7 +49,7 @@ void IncrementGameStat(u8 index);
void Overworld_SetMapObjTemplateCoords(u8, s16, s16);
void Overworld_SetMapObjTemplateMovementType(u8, u8);
-void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
+void SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId);
void SetDynamicWarpWithCoords(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
@@ -137,6 +137,7 @@ u8 get_map_light_from_warp0(void);
const struct MapHeader *warp1_get_mapheader(void);
void sub_8055F88(void);
void sub_8056788(void);
+void sub_8054E68(void);
void Overworld_CreditsMainCB(void);
bool32 Overworld_DoScrollSceneForCredits(u8 *, const struct CreditsOverworldCmd *, u8);
diff --git a/include/player_pc.h b/include/player_pc.h
index f527ec9f5..ff1c33d1a 100644
--- a/include/player_pc.h
+++ b/include/player_pc.h
@@ -21,5 +21,6 @@ struct PlayerPC_Unk_203AAC4
// Exported ROM declarations
void sub_816B060(u8 taskId);
+void sub_80EB658(void);
#endif //GUARD_PLAYER_PC_H
diff --git a/include/pokemon_jump.h b/include/pokemon_jump.h
new file mode 100644
index 000000000..28b19f9b1
--- /dev/null
+++ b/include/pokemon_jump.h
@@ -0,0 +1,14 @@
+#ifndef GUARD_POKEMON_JUMP_H
+#define GUARD_POKEMON_JUMP_H
+
+#include "main.h"
+
+void sub_802A9A8(u16 monId, MainCallback callback);
+bool32 sub_802C908(u16 species);
+void sub_802C920(void);
+void ResetPokeJumpResults(void);
+void sub_802E3C4(void);
+void sub_802EB24(s16 tileTag, s16 palTag, s16 x, s16 y, u8 subpriority);
+bool32 sub_802EB84(void);
+
+#endif // GUARD_POKEMON_JUMP_H
diff --git a/include/pokemon_size_record.h b/include/pokemon_size_record.h
index 3fa448cbb..d62ced51d 100644
--- a/include/pokemon_size_record.h
+++ b/include/pokemon_size_record.h
@@ -11,6 +11,9 @@ void InitLotadSizeRecord(void);
void GetLotadSizeRecordInfo(void);
void CompareLotadSize(void);
+void sub_80A0904(void);
+void sub_80A0958(void);
+
void GiveGiftRibbonToParty(u8 index, u8 ribbonId);
#endif // GUARD_POKEMON_SIZE_RECORD_H
diff --git a/include/pokemon_storage_system.h b/include/pokemon_storage_system.h
index 8ab9e5f0e..e6d7c5018 100644
--- a/include/pokemon_storage_system.h
+++ b/include/pokemon_storage_system.h
@@ -14,6 +14,7 @@ u32 GetBoxMonDataFromAnyBox(u8 boxId, u8 monPosition, u32 request);
void sub_808BCB4(u8 boxId, u8 monPosition);
u8 * GetBoxNamePtr(u8 boxId);
void sub_808CE60(void);
+void sub_808C7E0(void);
u8 StorageGetCurrentBox(void);
#endif // GUARD_POKEMON_STORAGE_SYSTEM_H
diff --git a/include/quest_log.h b/include/quest_log.h
index 0690dd282..7e86e7c2f 100644
--- a/include/quest_log.h
+++ b/include/quest_log.h
@@ -33,6 +33,8 @@ u8 sub_8112EB4(void);
void sub_8113018(const u8 * text, u8 mode);
void MapNamePopupWindowIdSetDummy(void);
void sub_8111CF0(void);
+void sub_811089C(void);
+void sub_8113044(void);
extern u8 gUnknown_203ADFA;
diff --git a/include/trainer_tower.h b/include/trainer_tower.h
index 9cca2ea76..d7fde9362 100644
--- a/include/trainer_tower.h
+++ b/include/trainer_tower.h
@@ -5,5 +5,7 @@ void PrintTrainerTowerRecords(void);
void InitTrainerTowerBattleStruct(void);
void FreeTrainerTowerBattleStruct(void);
u8 GetTrainerTowerTrainerFrontSpriteId(void);
+void sub_815D838(void);
+void sub_815EE0C(void);
#endif //GUARD_TRAINER_TOWER_H
diff --git a/include/union_room_chat.h b/include/union_room_chat.h
new file mode 100644
index 000000000..027a2e20c
--- /dev/null
+++ b/include/union_room_chat.h
@@ -0,0 +1,7 @@
+#ifndef GUARD_UNION_ROOM_CHAT_H
+#define GUARD_UNION_ROOM_CHAT_H
+
+void sub_801DD98(void);
+void copy_strings_to_sav1(void);
+
+#endif // GUARD_UNION_ROOM_CHAT_H \ No newline at end of file
diff --git a/include/wild_encounter.h b/include/wild_encounter.h
index bf53ed6ee..5bcab1249 100644
--- a/include/wild_encounter.h
+++ b/include/wild_encounter.h
@@ -45,5 +45,6 @@ bool8 UpdateRepelCounter(void);
void sub_8082740(u8);
u8 GetUnownLetterByPersonalityLoByte(u32 personality);
bool8 SweetScentWildEncounter(void);
+void sub_8083214(u16 randVal);
#endif // GUARD_WILD_ENCOUNTER_H
diff --git a/ld_script.txt b/ld_script.txt
index a65474cd5..7dbe59085 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -87,7 +87,7 @@ SECTIONS {
src/load_save.o(.text);
asm/trade.o(.text);
src/play_time.o(.text);
- asm/new_game.o(.text);
+ src/new_game.o(.text);
asm/overworld.o(.text);
src/fieldmap.o(.text);
src/metatile_behavior.o(.text);
diff --git a/src/berry_powder.c b/src/berry_powder.c
index 9b3bbc17f..ad824b24b 100644
--- a/src/berry_powder.c
+++ b/src/berry_powder.c
@@ -16,7 +16,7 @@ u32 sub_815EE3C(u32 * a0)
return *a0 ^ gSaveBlock2Ptr->encryptionKey;
}
-void sub_815EE54(u32 * a0, u32 a1)
+void SetBerryPowder(u32 * a0, u32 a1)
{
*a0 = gSaveBlock2Ptr->encryptionKey ^ a1;
}
@@ -48,12 +48,12 @@ bool8 sub_815EEE0(u32 a0)
u32 amount = sub_815EE3C(ptr) + a0;
if (amount > 99999)
{
- sub_815EE54(ptr, 99999);
+ SetBerryPowder(ptr, 99999);
return FALSE;
}
else
{
- sub_815EE54(ptr, amount);
+ SetBerryPowder(ptr, amount);
return TRUE;
}
}
@@ -66,7 +66,7 @@ bool8 sub_815EF20(u32 a0)
else
{
u32 amount = sub_815EE3C(ptr);
- sub_815EE54(ptr, amount - a0);
+ SetBerryPowder(ptr, amount - a0);
return TRUE;
}
}
@@ -79,7 +79,7 @@ bool8 sub_815EF5C(void)
else
{
u32 amount = sub_815EE3C(ptr);
- sub_815EE54(ptr, amount - gSpecialVar_0x8004);
+ SetBerryPowder(ptr, amount - gSpecialVar_0x8004);
return TRUE;
}
}
diff --git a/src/mevent.c b/src/mevent.c
index d0d7f59aa..b03f1ffe9 100644
--- a/src/mevent.c
+++ b/src/mevent.c
@@ -769,7 +769,7 @@ void sub_81442CC(struct MEventStruct_Unk1442CC * data)
data->unk_14 = 0;
for (i = 0; i < 4; i++)
data->unk_16[i] = gSaveBlock1Ptr->unk_3120.unk_338[i];
- CopyUnalignedWord(data->unk_4C, gSaveBlock2Ptr->playerTrainerId);
+ CopyTrainerId(data->unk_4C, gSaveBlock2Ptr->playerTrainerId);
StringCopy(data->unk_45, gSaveBlock2Ptr->playerName);
for (i = 0; i < 6; i++)
data->unk_50[i] = gSaveBlock1Ptr->unk2CA0[i];
diff --git a/src/new_game.c b/src/new_game.c
new file mode 100644
index 000000000..d3463f80b
--- /dev/null
+++ b/src/new_game.c
@@ -0,0 +1,168 @@
+#include "global.h"
+#include "new_game.h"
+#include "random.h"
+#include "main.h"
+#include "overworld.h"
+#include "constants/maps.h"
+#include "load_save.h"
+#include "item_menu.h"
+#include "tm_case.h"
+#include "berry_pouch.h"
+#include "quest_log.h"
+#include "wild_encounter.h"
+#include "event_data.h"
+#include "string_util.h"
+#include "mail_data.h"
+#include "play_time.h"
+#include "money.h"
+#include "battle_records.h"
+#include "pokemon_size_record.h"
+#include "pokemon_storage_system.h"
+#include "roamer.h"
+#include "item.h"
+#include "player_pc.h"
+#include "berry.h"
+#include "easy_chat.h"
+#include "union_room_chat.h"
+#include "mevent.h"
+#include "trainer_tower.h"
+#include "script.h"
+#include "berry_powder.h"
+#include "pokemon_jump.h"
+
+extern const u8 EventScript_ResetAllMapFlags[];
+
+// this file's functions
+void ResetMiniGamesResults(void);
+
+// EWRAM vars
+EWRAM_DATA bool8 gDifferentSaveFile = FALSE;
+
+void SetTrainerId(u32 trainerId, u8 *dst)
+{
+ dst[0] = trainerId;
+ dst[1] = trainerId >> 8;
+ dst[2] = trainerId >> 16;
+ dst[3] = trainerId >> 24;
+}
+
+void CopyTrainerId(u8 *dst, u8 *src)
+{
+ s32 i;
+ for (i = 0; i < 4; i++)
+ dst[i] = src[i];
+}
+
+/*static*/ void InitPlayerTrainerId(void)
+{
+ u32 trainerId = (Random() << 0x10) | GetGeneratedTrainerIdLower();
+ SetTrainerId(trainerId, gSaveBlock2Ptr->playerTrainerId);
+}
+
+/*static*/ void SetDefaultOptions(void)
+{
+ gSaveBlock2Ptr->optionsTextSpeed = OPTIONS_TEXT_SPEED_MID;
+ gSaveBlock2Ptr->optionsWindowFrameType = 0;
+ gSaveBlock2Ptr->optionsSound = OPTIONS_SOUND_MONO;
+ gSaveBlock2Ptr->optionsBattleStyle = OPTIONS_BATTLE_STYLE_SHIFT;
+ gSaveBlock2Ptr->optionsBattleSceneOff = FALSE;
+ gSaveBlock2Ptr->regionMapZoom = FALSE;
+ gSaveBlock2Ptr->optionsButtonMode = OPTIONS_BUTTON_MODE_NORMAL;
+}
+
+/*static*/ void ClearPokedexFlags(void)
+{
+ memset(&gSaveBlock2Ptr->pokedex.owned, 0, sizeof(gSaveBlock2Ptr->pokedex.owned));
+ memset(&gSaveBlock2Ptr->pokedex.seen, 0, sizeof(gSaveBlock2Ptr->pokedex.seen));
+}
+
+/*static*/ void sub_80549D4(void)
+{
+ CpuFill32(0, &gSaveBlock2Ptr->field_B0, (u32) &gSaveBlock2Ptr->mapView - (u32) &gSaveBlock2Ptr->field_B0);
+}
+
+/*static*/ void WarpToPlayersRoom(void)
+{
+ SetWarpDestination(MAP_GROUP(PALLET_TOWN_PLAYERS_HOUSE_2F), MAP_NUM(PALLET_TOWN_PLAYERS_HOUSE_2F), -1, 6, 6);
+ WarpIntoMap();
+}
+
+void Sav2_ClearSetDefault(void)
+{
+ ClearSav2();
+ SetDefaultOptions();
+}
+
+void ResetMenuAndMonGlobals(void)
+{
+ gDifferentSaveFile = 0;
+ ZeroPlayerPartyMons();
+ ZeroEnemyPartyMons();
+ sub_81089BC();
+ ResetTMCaseCursorPos();
+ BerryPouch_CursorResetToTop();
+ sub_811089C();
+ sub_8083214(Random());
+ sub_806E6FC();
+}
+
+void NewGameInitData(void)
+{
+ u8 rivalName[PLAYER_NAME_LENGTH];
+ StringCopy(rivalName, gSaveBlock1Ptr->rivalName);
+ gDifferentSaveFile = 1;
+ gSaveBlock2Ptr->encryptionKey = 0;
+ ZeroPlayerPartyMons();
+ ZeroEnemyPartyMons();
+ sub_80549D4();
+ ClearSav1();
+ ClearMailData();
+ gSaveBlock2Ptr->specialSaveWarpFlags = 0;
+ gSaveBlock2Ptr->field_A8 = 0;
+ gSaveBlock2Ptr->field_AC = 1;
+ gSaveBlock2Ptr->field_AD = 0;
+ InitPlayerTrainerId();
+ PlayTimeCounter_Reset();
+ ClearPokedexFlags();
+ sub_806E0D0();
+ ResetFameChecker();
+ SetMoney(&gSaveBlock1Ptr->money, 3000);
+ sub_8054E68();
+ InitLinkBattleRecords();
+ sub_80A0904();
+ sub_80A0958();
+ sub_806E190();
+ gPlayerPartyCount = 0;
+ ZeroPlayerPartyMons();
+ sub_808C7E0();
+ ClearRoamerData();
+ gSaveBlock1Ptr->registeredItem = 0;
+ ClearItemSlotsInAllBagPockets();
+ sub_80EB658();
+ sub_809C794();
+ sub_80BDD34();
+ sub_8113044();
+ copy_strings_to_sav1();
+ ResetMiniGamesResults();
+ sub_8143D24();
+ sub_815D838();
+ WarpToPlayersRoom();
+ ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags);
+ StringCopy(gSaveBlock1Ptr->rivalName, rivalName);
+ sub_815EE0C();
+}
+
+/*static*/ void ResetMiniGamesResults(void)
+{
+ CpuFill16(0, &gSaveBlock2Ptr->berryCrush, sizeof(struct BerryCrush));
+ SetBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount, 0);
+ ResetPokeJumpResults();
+ CpuFill16(0, &gSaveBlock2Ptr->berryPick, sizeof(struct BerryPickingResults));
+}
+
+
+
+
+
+
+ \ No newline at end of file
diff --git a/src/scrcmd.c b/src/scrcmd.c
index bcf8c231d..85059691f 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -733,7 +733,7 @@ bool8 ScrCmd_warp(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
+ SetWarpDestination(mapGroup, mapNum, warpId, x, y);
DoWarp();
ResetInitialPlayerAvatarState();
return TRUE;
@@ -747,7 +747,7 @@ bool8 ScrCmd_warpsilent(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
+ SetWarpDestination(mapGroup, mapNum, warpId, x, y);
DoDiveWarp();
ResetInitialPlayerAvatarState();
return TRUE;
@@ -761,7 +761,7 @@ bool8 ScrCmd_warpdoor(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
+ SetWarpDestination(mapGroup, mapNum, warpId, x, y);
DoDoorWarp();
ResetInitialPlayerAvatarState();
return TRUE;
@@ -778,7 +778,7 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx)
if (mapGroup == 0xFF && mapNum == 0xFF)
SetWarpDestinationToFixedHoleWarp(x - 7, y - 7);
else
- Overworld_SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7);
+ SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7);
DoFallWarp();
ResetInitialPlayerAvatarState();
return TRUE;
@@ -792,7 +792,7 @@ bool8 ScrCmd_warpteleport(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
+ SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_807E59C();
ResetInitialPlayerAvatarState();
return TRUE;
@@ -806,7 +806,7 @@ bool8 ScrCmd_warpteleport2(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
+ SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_805DAE4(GetPlayerFacingDirection());
sub_807E500();
ResetInitialPlayerAvatarState();
@@ -821,7 +821,7 @@ bool8 ScrCmd_setwarp(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
+ SetWarpDestination(mapGroup, mapNum, warpId, x, y);
return FALSE;
}
diff --git a/src/seagallop.c b/src/seagallop.c
index e3333ef32..5374f7bac 100644
--- a/src/seagallop.c
+++ b/src/seagallop.c
@@ -319,7 +319,7 @@ static void Task_SeaGallop_3(void)
gSpecialVar_0x8006 = 0;
warpInfo = sSeaGallopSpawnTable[gSpecialVar_0x8006];
- Overworld_SetWarpDestination(warpInfo[0], warpInfo[1], -1, warpInfo[2], warpInfo[3]);
+ SetWarpDestination(warpInfo[0], warpInfo[1], -1, warpInfo[2], warpInfo[3]);
PlayRainStoppingSoundEffect();
PlaySE(SE_KAIDAN);
gFieldCallback = sub_807DF64;
diff --git a/sym_ewram.txt b/sym_ewram.txt
index 194f7fe5d..109f4d89a 100644
--- a/sym_ewram.txt
+++ b/sym_ewram.txt
@@ -485,7 +485,7 @@ gUnknown_2031DA8: @ 2031DA8
gUnknown_2031DAC: @ 2031DAC
.space 0x4
-gUnknown_2031DB0: @ 2031DB0
+gDifferentSaveFile: @ 2031DB0
.space 0x4
gUnknown_2031DB4: @ 2031DB4