summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorobskyr <powpowd@gmail.com>2018-07-07 07:08:26 +0200
committerobskyr <powpowd@gmail.com>2018-07-07 07:08:26 +0200
commit5ec276e7c77244befe0b6c9931cda191aa3818b6 (patch)
tree55873c573ca6cf2a486d4f2759e68bb7c6dda9c1
parentd4bb6b990a94de27f58d2c92fad5888017d3bb9d (diff)
Disassemble new game WRAM initialization
With a lot of unknowns still there, of course.
-rw-r--r--engine/menu/main_menu.asm87
-rw-r--r--shim.sym22
-rw-r--r--wram.asm14
3 files changed, 112 insertions, 11 deletions
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index 432570a..2fc0d31 100644
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -1,5 +1,90 @@
INCLUDE "constants.asm"
+SECTION "Initialize new game WRAM", ROMX[$52F9], BANK[$01]
+; TODO: Move this to another file when surrounding
+; functions have been disassembled.
+InitializeNewGameWRAM:
+ ld a, [wSGB]
+ push af
+
+ ; Clear a lot of in-game WRAM.
+
+ ld hl, wVirtualOAM
+ ld bc, (wcd3f + 1) - wVirtualOAM
+ xor a
+ call ByteFill
+
+ ld hl, wPlayerName
+ ld bc, $1164
+ xor a
+ call ByteFill
+
+ ; Lots of other setup.
+
+ pop af
+ ld [wSGB], a
+
+ ldh a, [rLY]
+ ldh [hRTCRandom], a
+ call DelayFrame
+
+ ldh a, [hRandomSub]
+ ld [wce73], a
+ ldh a, [rLY]
+ ldh [hRTCRandom], a
+ call DelayFrame
+
+ ldh a, [hRandomAdd]
+ ld [wce74], a
+
+ ld hl, wPartyCount
+ call InitializeByteList
+ ld hl, wUnknownListLengthda83
+ call InitializeByteList
+ ld hl, wNumBagItems
+ call InitializeByteList
+ ld hl, wNumKeyItems
+ call InitializeByteList
+ ld hl, wUnknownListLengthd1ea
+ call InitializeByteList
+
+ xor a
+ ld [wMonType], a
+ ld [wd163], a
+ ld [wd164], a
+ ld [wd15b], a
+ ld [wd15c], a
+ ld [wd15d], a
+
+ ld a, $0B
+ ld [wd15e], a
+
+ ld a, $B8
+ ld [wd15f], a
+
+ ld hl, wUnknownListLengthd1ea
+ ld a, ITEM_REPEL
+ ld [wCurItem], a
+ ld a, 1
+ ld [wItemQuantity], a
+ call ReceiveItem
+
+ ld a, MAP_SILENT_HILL
+ ld [wMapId], a
+ ld a, GROUP_SILENT_HILL
+ ld [wMapGroup], a
+
+ ret
+
+; Initializes a 0xFF-terminated list preceded by a length to
+; length 0, with an immediate terminator.
+InitializeByteList:
+ xor a
+ ld [hli], a
+ dec a
+ ld [hl], a
+ ret
+
SECTION "Main Menu", ROMX[$53CC], BANK[$01]
MainMenu:: ; 01:53CC
@@ -197,7 +282,7 @@ StartNewGame:: ; 555C
call LoadFontExtra
xor a
ldh [hBGMapMode], a
- callba Function52f9
+ callba InitializeNewGameWRAM
call ClearTileMap
call ClearWindowData
xor a
diff --git a/shim.sym b/shim.sym
index f972019..51b25f8 100644
--- a/shim.sym
+++ b/shim.sym
@@ -1,3 +1,17 @@
+; WRAM0
+
+00:CB6F wPlayerStepDirection
+
+01:D19E wItems
+; The starting house's map script number is stored at d29a. Others are probably nearby.
+01:D1EA wUnknownListLengthd1ea
+01:D1EB wUnknownListd1eb
+01:D35F wOptions
+01:D513 wWarpNumber
+01:DA3B wOTPartyMonOT
+01:DA83 wUnknownListLengthda83
+01:DA84 wUnknownListda84
+
; ROM0
00:3C43 GetPartyParamLocation
00:3CA8 InitSpriteAnimStruct
@@ -218,14 +232,6 @@
3F:6755 PicTestMenu.loop
3F:67A1 CallSubGameMenu
-00:CB6F wPlayerStepDirection
-
-01:D19E wItems
-; The starting house's map script number is stored at d29a. Others are probably nearby.
-01:D35F wOptions
-01:D513 wWarpNumber
-01:DA3B wOTPartyMonOT
-
; Maps
25:404D Route2Gate1F_Blocks
25:4062 Route2Gate1F_Unk
diff --git a/wram.asm b/wram.asm
index c11d342..c1eec05 100644
--- a/wram.asm
+++ b/wram.asm
@@ -622,6 +622,8 @@ wTimeOfDay:: db ; ce3d
; 02 - Cave 35--50s
; 03 - Morning 06--09h 50--59s
+wcd3f: ds 1
+
SECTION "CE5F", WRAM0[$CE5F]
wce5f:: ; ce5f ; debug menu writes $41 to it
@@ -645,7 +647,11 @@ wPlayerName:: ds 6 ; ce67
wMomsName:: ds 6 ; ce6d
-SECTION "CE7F", WRAM0[$CE76]
+SECTION "CE73", WRAM0[$CE73]
+
+wce73: ds 1 ; ce73
+wce74: ds 1 ; ce74
+wce75: ds 1 ; ce75
wObjectFollow_Leader:: ; ce76
db
@@ -730,7 +736,11 @@ wTimeOfDayPalset:: db ; d158
wCurTimeOfDay:: db ; d159
-SECTION "D15D", WRAM0[$D15D]
+SECTION "D15B", WRAM0[$D15B]
+
+wd15b:: db ; d15b
+
+wd15c:: db ; d15c
wd15d:: db ; d15d