summaryrefslogtreecommitdiff
path: root/engine
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 /engine
parentd4bb6b990a94de27f58d2c92fad5888017d3bb9d (diff)
Disassemble new game WRAM initialization
With a lot of unknowns still there, of course.
Diffstat (limited to 'engine')
-rw-r--r--engine/menu/main_menu.asm87
1 files changed, 86 insertions, 1 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