summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2Tie <foxman95@ymail.com>2018-11-29 01:50:18 -0700
committer2Tie <foxman95@ymail.com>2018-11-29 01:50:18 -0700
commit7564f1a7c2a24d4c0c03c7910378adc7cec73749 (patch)
tree86b741b87c60758a83c7713890d1d0fbcf73ba71
parente32b8420675450097b25078612235de3d2635ea7 (diff)
Disassembled the rest of the code in bank 4 as far as i can tell. Lines 899, 1538, and 1631 in engine/menu/start_menu.asm have hardcoded jumps that i couldn't figure out how to make work myself.
-rw-r--r--README.md2
-rw-r--r--data/predef_pointers.inc6
-rw-r--r--data/text/text_input_chars.asm27
-rw-r--r--engine/Intro.asm6
-rwxr-xr-xengine/dumps/bank01.asm8
-rwxr-xr-xengine/dumps/bank03.asm54
-rw-r--r--engine/gfx.asm1
-rw-r--r--engine/items/tmhm.asm50
-rw-r--r--engine/menu/main_menu.asm2
-rw-r--r--engine/menu/start_menu.asm2258
-rw-r--r--engine/menu/text_entry.asm1050
-rw-r--r--engine/unknown11d32.asm92
-rw-r--r--engine/unknown_boxes.asm83
-rw-r--r--gfx.asm14
-rw-r--r--gfx/font/text_entry_end.1bpp.pngbin0 -> 154 bytes
-rw-r--r--gfx/font/text_entry_hyphen.1bpp.pngbin0 -> 136 bytes
-rw-r--r--gfx/font/text_entry_underscore.1bpp.pngbin0 -> 134 bytes
-rw-r--r--gfx/pokedex/border.pngbin0 -> 142 bytes
-rw-r--r--gfx/pokedex/cursor.pngbin0 -> 218 bytes
-rw-r--r--gfx/pokedex/cursors.pngbin113 -> 0 bytes
-rw-r--r--macros.asm2
-rw-r--r--pokegold-spaceworld.link15
-rwxr-xr-xshim.sym25
-rw-r--r--wram.asm48
24 files changed, 3680 insertions, 63 deletions
diff --git a/README.md b/README.md
index fd57fb2..bcd5001 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-WIP disassembly of the Spaceworld 1997 Gold proto
+WIP disassembly of the Space World 1997 Gold proto
It attempts to build the following ROMs:
diff --git a/data/predef_pointers.inc b/data/predef_pointers.inc
index edb6a77..1c551fe 100644
--- a/data/predef_pointers.inc
+++ b/data/predef_pointers.inc
@@ -38,8 +38,8 @@ GiveItemPredef::
add_predef UpdateHPBar
add_predef Functiondf7d ; 18
add_predef Functiondf91
- add_predef Function1128f
- add_predef Function112c1
+ add_predef CanLearnTMHMMove
+ add_predef GetTMHMMove
add_predef LinkTextboxAtHL
add_predef Function2d663
add_predef Function3d5ce
@@ -97,5 +97,5 @@ GiveItemPredef::
add_predef Functioncc000
add_predef Functioncc000_2
add_predef Functionfdb66
- add_predef Function1240b
+ add_predef LoadItemData
dbw $ff, InexplicablyEmptyFunction ; 56
diff --git a/data/text/text_input_chars.asm b/data/text/text_input_chars.asm
new file mode 100644
index 0000000..f6798a3
--- /dev/null
+++ b/data/text/text_input_chars.asm
@@ -0,0 +1,27 @@
+INCLUDE "constants.asm"
+
+SECTION "data/text/text_input_chars.asm", ROMX
+
+TextEntryChars: ; 04:58B3
+ db "あいうえお かきくけこ さしすせそ"
+ db "たちつてと なにぬねの はひふへほ"
+ db "まみむめも やゆよわん らりるれろ"
+ db "アイウエオ カキクケコ サシスセソ"
+ db "タチツテト ナニヌネノ ハヒフへホ"
+ db "マミムメモ ヤユヨワン ラりルレロ"
+ db "ゃゅょっを ャュョッヲ ゙゚ ー。"
+ db "12345 67890 ?!×.円"
+
+TextEntryHiragana: ; 04:593B
+ db "あいうえお かきくけこ さしすせそ"
+ db "たちつてと なにぬねの はひふへほ"
+ db "まみむめも やゆよわん らりるれろ"
+ db "ゃゅょっを 12345 67890"
+ db " ゙゚ ー?!円"
+
+TextEntryKatakana: ; 04:5987
+ db "アイウエオ カキクケコ サシスセソ"
+ db "タチツテト ナニヌネノ ハヒフへホ"
+ db "マミムメモ ヤユヨワン ラりルレロ"
+ db "ャュョッヲ 12345 67890"
+ db " ゙゚ ー?!円" \ No newline at end of file
diff --git a/engine/Intro.asm b/engine/Intro.asm
index 04497e4..55f8c3f 100644
--- a/engine/Intro.asm
+++ b/engine/Intro.asm
@@ -494,7 +494,7 @@ ChoosePlayerName:: ; 5B25
.loop
ld b, $01
ld de, wPlayerName
- callba Function113f4
+ callba NamingScreen
ld a, [wPlayerName]
cp "@"
jr z, .loop
@@ -547,7 +547,7 @@ ChooseRivalName:: ; 5BA9
.loop
ld b, $02
ld de, wRivalName
- callba Function113f4 ; manual text entry box?
+ callba NamingScreen
ld a, [wRivalName]
cp "@"
jr z, .loop
@@ -599,7 +599,7 @@ MomNamePrompt:: ; 5C31
.loop
ld b, $03
ld de, wMomsName
- callba Function113f4
+ callba NamingScreen
ld a, [wMomsName]
cp "@"
jr z, .loop
diff --git a/engine/dumps/bank01.asm b/engine/dumps/bank01.asm
index 0ae1ffe..fd57ba1 100755
--- a/engine/dumps/bank01.asm
+++ b/engine/dumps/bank01.asm
@@ -3374,9 +3374,9 @@ Function6713: ; 01:6713
push hl
ld e, l
ld d, h
- ld a, BANK(Function113f4)
+ ld a, BANK(NamingScreen)
ld b, $00
- ld hl, Function113f4
+ ld hl, NamingScreen
call FarCall_hl
call ClearBGPalettes
call ClearTileMap
@@ -3417,9 +3417,9 @@ Text6788: ; 01:6788
Function679d: ; 01:679d
ld de, wFieldMoveScriptID
push de
- ld hl, Function113f4
+ ld hl, NamingScreen
ld b, $00
- ld a, BANK(Function113f4)
+ ld a, BANK(NamingScreen)
call FarCall_hl
call ClearBGPalettes
call Function360b
diff --git a/engine/dumps/bank03.asm b/engine/dumps/bank03.asm
index 860996e..5657d36 100755
--- a/engine/dumps/bank03.asm
+++ b/engine/dumps/bank03.asm
@@ -1256,7 +1256,7 @@ Functiondac8: ; 03:5ac8
cp $03
ld hl, wd882
jr z, .sub_db1f
- ld hl, wUnknownListLengthda83
+ ld hl, wBoxListLength
ld a, [hl]
cp $1e
jr nz, .sub_daed
@@ -1291,7 +1291,7 @@ Functiondac8: ; 03:5ac8
jr nz, .sub_db1b
ld hl, wdaa3
ld bc, $0020
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
.sub_db1b
dec a
call AddNTimes
@@ -1324,7 +1324,7 @@ Functiondac8: ; 03:5ac8
ld a, [wPartyCount]
jr nz, .sub_db60
ld hl, wde63
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
.sub_db60
dec a
call SkipNames
@@ -1354,7 +1354,7 @@ Functiondac8: ; 03:5ac8
ld a, [wPartyCount]
jr nz, .sub_db9e
ld hl, wdf17
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
.sub_db9e
dec a
call SkipNames
@@ -1432,7 +1432,7 @@ Functiondc16: ; 03:5c16
cp $06
push af
jr nz, .sub_dc2a
- ld hl, wUnknownListLengthda83
+ ld hl, wBoxListLength
ld a, [hl]
cp $1e
jr nz, .sub_dc2a
@@ -1516,7 +1516,7 @@ Functiondc16: ; 03:5c16
jr .sub_dce9
.sub_dcad
ld hl, wdf17
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
ld bc, $0006
call AddNTimes
push hl
@@ -1526,7 +1526,7 @@ Functiondc16: ; 03:5c16
call CopyBytes
push hl
ld hl, wde63
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
ld bc, $0006
call AddNTimes
ld d, h
@@ -1535,7 +1535,7 @@ Functiondc16: ; 03:5c16
call CopyBytes
push hl
ld hl, wdaa3
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
ld bc, $0030
call AddNTimes
ld d, h
@@ -1591,7 +1591,7 @@ Functiondcfc: ; 03:5cfc
jp CopyBytes
Functiondd5c: ; 03:5d5c
- ld de, wUnknownListLengthda83
+ ld de, wBoxListLength
ld a, [de]
cp $1e
ret nc
@@ -1612,7 +1612,7 @@ Functiondd5c: ; 03:5d5c
call GetMonHeader
ld hl, wde63
ld bc, $0006
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
dec a
jr z, .sub_dda9
dec a
@@ -1623,7 +1623,7 @@ Functiondd5c: ; 03:5d5c
ld d, h
ld e, l
pop hl
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
dec a
ld b, a
.sub_dd96
@@ -1644,7 +1644,7 @@ Functiondd5c: ; 03:5d5c
ld de, wde63
ld bc, $0006
call CopyBytes
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
dec a
jr z, .sub_dde5
ld hl, wdf17
@@ -1657,7 +1657,7 @@ Functiondd5c: ; 03:5d5c
ld d, h
ld e, l
pop hl
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
dec a
ld b, a
.sub_ddd2
@@ -1681,7 +1681,7 @@ Functiondd5c: ; 03:5d5c
ld hl, wStringBuffer1
ld bc, $0006
call CopyBytes
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
dec a
jr z, .sub_de2a
ld hl, wdaa3
@@ -1694,7 +1694,7 @@ Functiondd5c: ; 03:5d5c
ld d, h
ld e, l
pop hl
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
dec a
ld b, a
.sub_de17
@@ -1774,7 +1774,7 @@ Functionde79: ; 03:5e79
ld hl, wPartyCount
jr .sub_dead
.sub_de8b
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
cp $1e
scf
ret z
@@ -1787,7 +1787,7 @@ Functionde79: ; 03:5e79
call FarCall_hl
call Functiondd5c
ld de, wdf17
- ld hl, wUnknownListLengthda83
+ ld hl, wBoxListLength
.sub_dead
ld a, [hl]
push af
@@ -1817,7 +1817,7 @@ Functiondecd: ; 03:5ecd
ld a, [wcd7c]
and a
jr z, .sub_ded9
- ld hl, wUnknownListLengthda83
+ ld hl, wBoxListLength
.sub_ded9
ld a, [hl]
dec a
@@ -2174,8 +2174,8 @@ Function60a0: ; 03:60a0
jr c, .sub_e155
push de
ld b, $00
- ld a, BANK(Function113f4)
- ld hl, Function113f4
+ ld a, BANK(NamingScreen)
+ ld hl, NamingScreen
call FarCall_hl
pop de
ld a, [de]
@@ -2655,8 +2655,8 @@ Texte551: ; 03:6551
Functione57e: ; 03:657e
ld b, $04
ld de, wMovementBufferCount
- ld a, BANK(Function113f4)
- ld hl, Function113f4
+ ld a, BANK(NamingScreen)
+ ld hl, NamingScreen
call FarCall_hl
ld a, [wMovementBufferCount]
cp $50
@@ -3079,7 +3079,7 @@ Functione8f9: ; 03:68f9
ld a, [wPartyCount]
cp $06
jr nz, .sub_e913
- ld a, [wUnknownListLengthda83]
+ ld a, [wBoxListLength]
cp $1e
jp z, Functionf7d8
.sub_e913
@@ -3340,8 +3340,8 @@ Functione8f9: ; 03:68f9
ld d, h
ld e, l
ld b, $00
- ld a, BANK(Function113f4)
- ld hl, Function113f4
+ ld a, BANK(NamingScreen)
+ ld hl, NamingScreen
push de
call FarCall_hl
call RotateThreePalettesRight
@@ -3363,8 +3363,8 @@ Functione8f9: ; 03:68f9
jr c, .sub_eb47
ld de, wdf17
ld b, $00
- ld a, BANK(Function113f4)
- ld hl, Function113f4
+ ld a, BANK(NamingScreen)
+ ld hl, NamingScreen
call FarCall_hl
call RotateThreePalettesRight
ld de, wdf17
diff --git a/engine/gfx.asm b/engine/gfx.asm
index 7ab0071..9a917ce 100644
--- a/engine/gfx.asm
+++ b/engine/gfx.asm
@@ -117,6 +117,7 @@ LoadPokemonStatsGraphics:: ; f80fb (3e:40fb)
ld hl, $9550
lb bc, BANK(ExpBarGFX), ((ExpBarGFXEnd - ExpBarGFX) / LEN_2BPP_TILE)
call Get2bpp
+LoadOnlyPokemonStatsGraphics:: ; 3E:412E
ld de, StatsGFX
ld hl, $9310
lb bc, BANK(StatsGFX), ((StatsGFXEnd - StatsGFX) / LEN_2BPP_TILE)
diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm
new file mode 100644
index 0000000..d2c4872
--- /dev/null
+++ b/engine/items/tmhm.asm
@@ -0,0 +1,50 @@
+INCLUDE "constants.asm"
+
+SECTION "engine/items/tmhm.asm", ROMX
+
+CanLearnTMHMMove: ; 04:528f
+; Gets the index of TM or HM with move ID wce32,
+; then checks the corresponding flag in wMonDexIndex's learnset.
+; Sets register c to 1 if TM/HM is in learnset OR if debug is enabled.
+ ld a, [wDebugFlags]
+ ld c, 01
+ bit 1, a
+ ret nz
+
+ ld a, [wMonDexIndex]
+ ld [wCurSpecies], a
+ call GetMonHeader
+ ld hl, wMonHLearnset
+ push hl
+
+ ld a, [wce32]
+ ld b, a
+ ld c, 0
+ ld hl, TMHMMoves
+.loop
+ ld a, [hli]
+ cp b
+ jr z, .jump
+ inc c
+ jr .loop
+
+.jump
+ pop hl
+ ld b, 2 ;CHECK_FLAG
+ push de
+ ld d, 0
+ predef SmallFarFlagAction
+ pop de
+ ret
+
+GetTMHMMove: ; 04:52C1
+; converts TM/HM list index to TM/HM move ID
+ ld a, [wNamedObjectIndexBuffer]
+ dec a
+ ld hl, TMHMMoves
+ ld b, 0
+ ld c, a
+ add hl, bc
+ ld a, [hl]
+ ld [wNamedObjectIndexBuffer], a
+ ret \ No newline at end of file
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index e32aa3d..42bc2ca 100644
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -39,7 +39,7 @@ InitializeNewGameWRAM:
ld hl, wPartyCount
call InitializeByteList
- ld hl, wUnknownListLengthda83
+ ld hl, wBoxListLength
call InitializeByteList
ld hl, wNumBagItems
call InitializeByteList
diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm
new file mode 100644
index 0000000..aa6f717
--- /dev/null
+++ b/engine/menu/start_menu.asm
@@ -0,0 +1,2258 @@
+INCLUDE "constants.asm"
+
+SECTION "engine/menu/start_menu.asm", ROMX
+
+DisplayStartMenu: ; 04:5DBE
+ call RefreshScreen
+ ld de, $0003
+ call PlaySFX
+ ld hl, .StartMenuHeader
+ call LoadMenuHeader
+.prelabel
+ call UpdateTimePals
+ call UpdateSprites
+ call ClearJoypad
+ call GetStartMenuState
+ ld a, [wStartmenuCursor]
+ ld [wMenuCursorBuffer], a
+ call OpenMenu
+ jr c, .bigjump
+ ld a, [wMenuCursorBuffer]
+ ld [wStartmenuCursor], a
+ call PlaceHollowCursor
+ ld a, [wMenuSelection]
+ ld hl, StartMenuJumpTable
+ call CallJumptable
+ ld hl, .StartMenuEntriesReturnTable
+ jp CallJumptable
+
+.StartMenuEntriesReturnTable: ; 04:5DFC
+ dw .prelabel
+ dw .bigjump
+ dw .label
+ dw .label2
+ dw .ExitAndLoadBankFF
+
+.bigjump
+ call .label3
+ call LoadFontExtra
+.label
+ call ExitMenu
+.label2
+ call Function1fea
+ call UpdateTimePals
+ ret
+
+; 04:5E16
+ call .label3
+ call LoadFontExtra
+ call CloseWindow
+ jr .label2
+.label3
+ call GetJoypad
+ ldh a, [hJoyDown]
+ bit 0, a
+ jr nz, .label3
+ ret
+
+.ExitAndLoadBankFF: ; 04:5E2B
+ call ExitMenu
+ ld a, $FF
+ ldh [hStartmenuCloseAndSelectHookEnable], a
+ jr .label2
+
+.StartMenuHeader: ; 04:5E34
+ db MENU_BACKUP_TILES
+ menu_coords $0C, 00, $13, $11
+ dw .MenuData
+ db 1 ; default option
+
+.MenuData: ; 04:5E3C
+ db $A8
+ db 0 ; items
+ dw StartMenuItems
+ db $8A, $1F
+ dw .Strings
+
+.Strings: ; 04:5E44
+ db "ずかん@"
+ db "ポケモン@"
+ db "りュック@"
+ db "<PLAYER>@"
+ db "レポート@"
+ db "せってい@"
+ db "とじる@"
+ db "わくせん@"
+ db "りセット@"
+
+StartMenuJumpTable: ; 04:5E6C
+ dw StartMenu_Pokedex
+ dw StartMenu_Party
+ dw StartMenu_Backpack
+ dw StartMenu_TrainerCard
+ dw StartMenu_Save
+ dw StartMenu_Settings
+ dw StartMenu_Exit
+ dw StartMenu_Pokegear
+ dw StartMenu_Reset
+
+StartMenuItems: ; 04:5E7E
+ db 04
+ db 04
+ db 05
+ db 03
+ db 06
+ db -1
+
+ db 05
+ db 01
+ db 03
+ db 04
+ db 05
+ db 06
+ db -1
+
+ db 06
+ db 00
+ db 01
+ db 03
+ db 04
+ db 05
+ db 06
+ db -1
+
+ db 07
+ db 00
+ db 01
+ db 02
+ db 03
+ db 04
+ db 05
+ db 06
+ db -1
+
+ db 6
+ db 00
+ db 01
+ db 02
+ db 03
+ db 05
+ db 06
+ db -1
+
+GetStartMenuState: ; 04:5EA4
+; Stores one of four values to wActiveBackpackPocket
+; based on story flags and debug mode.
+; 4 = debug, 3 = starting, 2 = D2 is on, 1 = pokedex recieved, 0 = chose starter
+ ld b, 4
+ ld hl, wDebugFlags
+ bit 1, [hl]
+ jr z, .leap
+ ld b, 0
+ ld hl, wd41b
+ bit 2, [hl]
+ jr z, .leap
+ ld b, 1
+ ld hl, wd41c
+ bit 4, [hl]
+ jr z, .leap
+ ld b, 2
+ ld hl, wd41d
+ bit 2, [hl]
+ jr z, .leap
+ ld b, 3
+.leap
+ ld a, b
+ ld [wActiveBackpackPocket], a
+ ret
+
+StartMenu_Exit: ; 04:5ECF
+; Exits the menu
+ ld a, 1
+ ret
+
+StartMenu_Pokegear: ; 04:5ED2
+ callab PokeGear
+ ld a, 0
+ ret
+
+StartMenu_Reset: ; 04:5EDD
+ ld hl, DisplayResetDialog
+ ld a, BANK(DisplayResetDialog)
+ call DisplayResetDialog ; should be farcall
+ ld a, 0
+ ret
+
+StartMenu_Save: ; 04:5EE8
+ predef Function143e0
+ call UpdateSprites
+ ld a, 0
+ ret
+
+StartMenu_Settings: ; 04:5EF3
+ call LoadStandardMenuHeader
+ xor a
+ ldh [hBGMapMode], a
+ call ClearTileMap
+ call UpdateSprites
+ callab MenuCallSettings
+ call ClearPalettes
+ call Call_ExitMenu
+ call LoadTilesetGFX
+ call LoadFontExtra
+ call UpdateSprites
+ call WaitBGMap
+ call UpdateTimePals
+ ld a, 0
+ ret
+
+StartMenu_TrainerCard ; 04:5F1F
+ call _TrainerCard
+ ld a, 0
+ ret
+
+_TrainerCard: ; 04:5F25
+ call LoadStandardMenuHeader
+ ldh a, [hMapAnims]
+ push af
+ xor a
+ ldh [hMapAnims], a
+ callab TrainerCardLoop
+ call ClearPalettes
+ call LoadFont
+ call ReloadFontAndTileset
+ call Call_ExitMenu
+ call GetMemSGBLayout
+ call WaitBGMap
+ call UpdateTimePals
+ pop af
+ ldh [hMapAnims], a
+ ret
+
+StartMenu_Pokedex: ; 04:5F4F
+ call LoadStandardMenuHeader
+ predef Function40000
+ call ClearPalettes
+ call Function360b
+ call ReloadFontAndTileset
+ call Call_ExitMenu
+ call GetMemSGBLayout
+ call WaitBGMap
+ call UpdateTimePals
+ ld a, 0
+ ret
+
+; 04:5F6F
+ dw ToolsPocketHeader
+ dw wRegularItemsCursor
+ dw wRegularItemsScrollPosition
+
+ToolsPocketHeader: ; 04:5F75
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 03, 03, $11, $0A
+ dw .toolspocketdata
+ db 1
+
+.toolspocketdata ; 04:5F7D
+ db $AD
+ db 4, 9, 2, 0
+ dw wNumBagItems
+
+ dbw BANK(Function2473b), Function2473b
+ dbw BANK(Function24783), Function24783
+ dbw BANK(Function241ef), Function241ef
+
+ dw KeyItemsPocketHeader
+ dw wBackpackAndKeyItemsCursor
+ dw wBackpackAndKeyItemsScrollPosition
+
+KeyItemsPocketHeader: ; 04:5F93
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 03, 03, $11, $0A
+ dw .keypocketdata
+ db 1
+
+.keypocketdata ; 04:5F9B
+ db $AD
+ db 4, 9, 1, 0
+ dw wNumKeyItems
+
+ dbw BANK(Function2473b), Function2473b
+ dbw BANK(Function24783), Function24783
+ dbw BANK(Function241ef), Function241ef
+
+BackpackMenuHeader: ; 04:5FAB
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 03, 03, $11, $0A
+ dw .backpackdata
+ db 01
+
+.backpackdata ; 04:5FB3
+ db $A1
+ db 4, 9, 2, 0
+ dw wNumBagItems
+
+ dbw BANK(Function2473b), Function2473b
+ dbw BANK(Function24783), Function24783
+ dbw BANK(Function241ef), Function241ef
+
+GetPocket2Status: ; 04:5FC3
+; puts 2 in wActiveBackpackPocket if pocket 2 has items
+; otherwise puts 1 in
+ ld a, 2
+ ld [wActiveBackpackPocket], a
+ ld a, [wNumBagItems]
+ and a
+ ret nz
+ ld a, 1
+ ld [wActiveBackpackPocket], a
+ ret
+
+FlipPocket2Status: ; 04:5FD3
+; stores 1 in wactivebackpocket if it's currently 2
+; and vice versa
+ ld a, [wActiveBackpackPocket]
+ cp 2
+ ld a, 1
+ jr z, .skip
+ ld a, 2
+.skip
+ ld [wActiveBackpackPocket], a
+ ret
+
+CheckItemsQuantity: ; 04:5FE2
+; sets clear flag if you have no items
+ ld a, [wNumBagItems]
+ and a
+ ret nz
+ ld a, [wNumKeyItems]
+ and a
+ ret nz
+ scf
+ ret
+
+DrawBackpack: ; 04:5FEE
+ ld hl, wVramState
+ res 0, [hl]
+ call ClearSprites
+ call ClearTileMap
+ callab LoadBackpackGraphics
+ hlcoord 2, 2
+ ld b, 08
+ ld c, $0F
+ call DrawTextBox
+ ret
+
+; 04:600C
+ ld hl, wVramState
+ set 0, [hl]
+ call ExitMenu
+ ret
+
+StartMenu_Backpack: ; 04:6015
+ call CheckItemsQuantity
+ jr c, .noitems
+ call LoadStandardMenuHeader
+ ld hl, wVramState
+ res 0, [hl]
+ call DrawBackpack
+ xor a
+ ld [wSelectedSwapPosition], a
+ call GetPocket2Status
+.loop
+ call DebugBackpackLoop
+ jr c, .jump
+ call BackpackSelected
+ jr nc, .loop
+ jr .skip
+.jump
+ ld a, 0
+.skip
+ push af
+ ld hl, wVramState
+ set 0, [hl]
+ xor a
+ ld [wSelectedSwapPosition], a
+ call ClearPalettes
+ call CloseWindow
+ call LoadFontExtra
+ pop af
+ ret
+
+.noitems
+ call DrawNoItemsText ; 6371
+ scf
+ ld a, 0
+ ret
+
+DebugBackpackLoop: ; 04:6056
+; checks the field debug flag, if set this runs
+; otherwise NondebugBackpackLoop runs
+; if wactivebackpackpocket is 1 (doesn't have key items) then jumps below
+ ld a, [wDebugFlags]
+ bit 1, a
+ jp z, NondebugBackpackLoop
+ ld a, [wActiveBackpackPocket]
+ cp 2
+ jr nz, .notools
+ ld hl, ToolsPocketHeader
+ call CopyMenuHeader
+ ld de, .ToolsPocketText
+ call DrawBackpackTitleRow
+ ld a, [wRegularItemsCursor]
+ ld [wMenuCursorBuffer], a
+ ld a, [wRegularItemsScrollPosition]
+ ld [wMenuScrollPosition], a
+ call ScrollingMenu
+
+ ld a, [wMenuScrollPosition]
+ ld [wRegularItemsScrollPosition], a
+ ld a, [wMenuCursorY]
+ ld [wRegularItemsCursor], a
+ jp HandleBackpackInput
+
+.ToolsPocketText ; 04:608F
+ db "      ふつうの どうぐ      @"
+
+.notools
+ ld hl, KeyItemsPocketHeader
+ call CopyMenuHeader
+ ld de, KeyItemsPocketText
+ call DrawBackpackTitleRow
+ ld a, [wBackpackAndKeyItemsCursor]
+ ld [wMenuCursorBuffer], a
+ ld a, [wBackpackAndKeyItemsScrollPosition]
+ ld [wMenuScrollPosition], a
+ call ScrollingMenu
+
+ ld a, [wMenuScrollPosition]
+ ld [wBackpackAndKeyItemsScrollPosition], a
+ ld a, [wMenuCursorY]
+ ld [wBackpackAndKeyItemsCursor], a
+ jr HandleBackpackInput
+
+KeyItemsPocketText: ; 04:60CD
+ db "      だいじな もの       @"
+
+NondebugBackpackLoop: ; 04:60E2
+ ld hl, BackpackMenuHeader
+ call CopyMenuHeader
+ ld de, BackpackHeaderText
+ call DrawBackpackTitleRow
+ ld a, [wBackpackAndKeyItemsCursor]
+ ld [wMenuCursorBuffer], a
+ ld a, [wBackpackAndKeyItemsScrollPosition]
+ ld [wMenuScrollPosition], a
+ call ScrollingMenu
+
+ ld a, [wMenuScrollPosition]
+ ld [wBackpackAndKeyItemsScrollPosition], a
+ ld a, [wMenuCursorY]
+ ld [wBackpackAndKeyItemsCursor], a
+ jr HandleBackpackInput
+
+BackpackHeaderText: ; 04:610B
+ db "      りュックの なか     @"
+
+HandleBackpackInput: ; 04:611F
+ ld a, [wMenuJoypad]
+ cp A_BUTTON
+ jp z, .backpacka
+ cp B_BUTTON
+ jp z, .backpackback
+ cp D_LEFT
+ jp z, .backpackswappocket
+ cp D_RIGHT
+ jp z, .backpackswappocket
+ cp SELECT
+ jp z, .backpackselect
+ jp .exit
+
+.backpackswappocket ; 04:613E
+ call FlipPocket2Status
+ xor a
+ ld [wSelectedSwapPosition], a
+ jp .exit
+
+.backpackselect ; 04:6148
+ callab Function245c5
+ jp .exit
+
+.exit ; 04:6153
+ jp DebugBackpackLoop
+
+.unusedNoItems ; 04:6156
+ call DrawNoItemsText
+ scf
+ ret
+
+.backpackback ; 04:615B
+ scf
+ ret
+
+.backpacka ; 04:615D
+ and a
+ ret
+
+BackpackSelected: ; 04:615F
+ callab Function243af
+ call PlaceHollowCursor
+ call LoadItemData
+ callab CheckItemMenu
+ ld a, [wItemAttributeParamBuffer]
+ ld hl, .BagSelectJumptable
+ jp CallJumptable
+
+.BagSelectJumptable: ; 04:617E
+ dw SelectItem
+ dw .unknownSelection
+ dw BallPocketLoop
+ dw .swappocket
+ dw SelectItem
+ dw SelectItem
+ dw SelectItem
+
+.swappocket ; 04:618C
+ call FlipPocket2Status
+ xor a
+ ld [wSelectedSwapPosition], a
+ and a
+ ret
+
+.unknownSelection ; 04:6195
+ call LoadStandardMenuHeader
+ callab Function2d2fc
+ call ExitMenu
+ call DrawBackpack
+ and a
+ ret
+
+BallPocketLoop: ; 04:61A8
+ call BallPocket
+ jr c, .exit
+ call SelectItem
+ ret c
+ jr BallPocketLoop
+.exit
+ and a
+ ret
+
+SelectItem: ; 04:61B5
+ call ItemUseMenu
+ jr c, .skip1
+ ld a, [wMenuCursorY]
+ cp 1
+ jp z, UseItemSelection
+ cp 2
+ jp z, TossItemSelection
+ cp 3
+ jp z, RegisterItemSelection
+.skip1
+ and a
+ ret
+
+ItemUseMenu: ; 04:61CE
+; loads SelectedItemMenu if not debug,
+; DebugSelectedItemMenu if debug
+ ld a, [wDebugFlags]
+ bit 1, a
+ jr nz, .jump
+ ld hl, SelectedItemMenu
+ call LoadMenuHeader
+ call VerticalMenu
+ call CloseWindow
+ ret
+.jump
+ ld hl, DebugSelectedItemMenu
+ call LoadMenuHeader
+ call VerticalMenu
+ call CloseWindow
+ ret
+
+DebugSelectedItemMenu: ; 04:61EF
+ db MENU_BACKUP_TILES
+ menu_coords $0D, $0A, $13, $10
+ dw .debugselecteditemmenutext
+ db 01
+
+.debugselecteditemmenutext
+ db $C0
+ db 3
+ db "つかう@" ; use
+ db "すてる@" ; toss
+ db "とうろく@" ; register
+
+SelectedItemMenu: ; 04:6206
+ db MENU_BACKUP_TILES
+ menu_coords $0E, $0A, $13, $0E
+ dw .selecteditemmenutext
+ db 01
+
+.selecteditemmenutext
+ db $C0
+ db 2
+ db "つかう@" ; use
+ db "すてる@" ; toss
+
+TossItemSelection: ; 04:6218
+ ld de, wNumBagItems
+ call TryTossItem
+ and a
+ ret
+
+RegisterItemSelection: ; 04:6220
+ call TryRegisterItem
+ and a
+ ret
+
+UseItemSelection: ; 04:6225
+ callab CheckItemMenu
+ ld a, [wItemAttributeParamBuffer]
+ ld hl, .UseItemJumptable
+ jp CallJumptable
+
+.UseItemJumptable: ; 04:6236 ; jumptable
+ dw .failedmove
+ dw .unusable
+ dw .unusable
+ dw .unusable
+ dw .SimpleItem
+ dw .SpriteItem
+ dw .FieldMove
+
+.unusable ; 04:6244
+ call PrintCantUseText
+ and a
+ ret
+
+.SimpleItem: ; 04:6249
+ call UseItem
+ and a
+ ret
+
+.SpriteItem: ; 04:624E
+; might be a better name for this once
+; bank 5 gets sorted out
+ call UseItem
+ call ClearBGPalettes
+ call StartMenuLoadSprites
+ call DrawBackpack
+ and a
+ ret
+
+.FieldMove: ; 04:625C
+ call UseItem
+ ld a, [wFieldMoveSucceeded]
+ and a
+ jr z, .failedmove
+ scf
+ ld a, 4
+ ret
+
+.failedmove ; 04:6269
+ call PrintCantUseText
+ and a
+ ret
+
+TryTossItem: ; 04:626E
+ push de
+ call LoadItemData
+ callab _CheckTossableItem
+ ld a, [wItemAttributeParamBuffer]
+ and a
+ jr nz, .tossfail
+ ld hl, .TossedText
+ call MenuTextBox
+ callab Function24c60
+ push af
+ call CloseWindow
+ call ExitMenu
+ pop af
+ jr c, .tossreturn
+ ld hl, .TossVerifyText
+ call MenuTextBox
+ call YesNoBox
+ push af
+ call ExitMenu
+ pop af
+ jr c, .tossreturn
+ pop hl
+ ld a, [wItemIndex]
+ call TossItem
+ call LoadItemData
+ ld hl, .TossedTextCopy
+ call MenuTextBox
+ call ExitMenu
+ and a
+ ret
+
+.tossfail ; 04:62BD ;25
+ call CantDropItem
+.tossreturn
+ pop hl
+ scf
+ ret
+
+.TossedText: ; 04:62C3
+ db 1
+ dw wStringBuffer2
+ text "を "
+ line "いくつ すてますか?"
+ done
+
+.TossVerifyText: ; 04:62D5
+ db 1
+ dw wStringBuffer2
+ text "を @"
+ db 9
+ dw wItemQuantity
+ db $12
+ text "こ"
+ line "すててもよろしいですか?"
+ done
+
+.TossedTextCopy: ; 04:62F0
+ db 1
+ dw wStringBuffer1
+ text "を"
+ line "すてました!<PROMPT>"
+
+CantDropItem: ; 04:62FD
+ ld hl, .CantDropItemText
+ call MenuTextBoxBackup
+ ret
+
+.CantDropItemText: ; 04:6304
+ text "それは とても たいせつなモノです"
+ line "すてることは できません!<PROMPT>"
+
+PrintCantUseHM: ; 04:6325
+ ld hl, .CantUseHMText
+ call MenuTextBoxBackup
+ ret
+
+.CantUseHMText: ; 04:632C
+ text "かいはつちゅう です"
+ line "いまは つかえません<PROMPT>"
+
+PrintCantUseText: ; 04:6343
+ ld hl, .CantUseHereText
+ call MenuTextBoxBackup
+ ret
+
+.CantUseHereText: ; 04:634A
+ text "オーキドの ことば<⋯⋯>"
+ line "<PLAYER>よ! こういうものには"
+ cont "つかいどきが あるのじゃ!<PROMPT>"
+
+DrawNoItemsText: ; 04:6371
+ ld hl, .NoItemsText
+ call MenuTextBoxBackup
+ ret
+
+.NoItemsText: ; 04:6378
+ text "どうぐ をひとつも<NEXT>もっていません!<PROMPT>"
+
+BallPocket: ; 04:638C
+ xor a
+ ldh [hBGMapMode], a
+ ld hl, .BallPocketHeader
+ call CopyMenuHeader
+ ld de, .BallHolderText
+ call DrawBackpackTitleRow
+ hlcoord 2, 2
+ ld b, 8
+ ld c, $F
+ call DrawTextBox
+ call ScrollingMenu
+ ld a, [wMenuJoypad]
+ cp 1
+ jr z, .jmp1
+ cp 2
+ jr z, .jmp2
+ jr BallPocket
+.jmp1
+ and a
+ ret
+.jmp2
+ scf
+ ret
+
+.BallHolderText: ; 04:63B9
+ db "     ボール ホルダ      @"
+
+.BallPocketHeader: ; 04:63CC
+ db MENU_BACKUP_TILES
+ menu_coords 03, 03, $11, $0A
+ dw .MenuData
+ db 1
+
+.MenuData: ; 04:63D4
+ db SCROLLINGMENU_ENABLE_FUNCTION3 ; flags
+ db 4, 8 ; rows, columns
+ db $80 ; horizontal spacing?
+ dbw 0, wNumBallItems
+ dba Function24774
+ dba Function24783
+ dba Function241ef
+
+DrawBackpackTitleRow: ; 04:63E4
+ push de
+ hlcoord 0, 0
+ ld de, .BlankLine
+ call PlaceString
+ pop de
+ hlcoord 0, 1
+ call PlaceString
+ ret
+
+.BlankLine: ; 04:63F6
+ db "                    @"
+
+LoadItemData: ; 04:640B
+ ld a, [wCurItem]
+ ld [wce37], a
+ call GetItemName
+ call CopyStringToStringBuffer2
+ ret
+
+StartMenuLoadSprites: ; 04:6418
+ call DisableLCD
+ ld a, 6
+ call UpdateSoundNTimes
+ callab Function140d9
+ call LoadTilesetGFX
+ call LoadFontExtra
+ call ClearSprites
+ ld hl, wVramState
+ set 0, [hl]
+ call UpdateSprites
+ call EnableLCD
+ call GetMemSGBLayout
+ ret
+
+TryRegisterItem: ; 04:6440
+ callab CheckItemMenu
+ ld a, [wItemAttributeParamBuffer]
+ ld hl, .RegisterItemJumptable
+ jp CallJumptable
+
+.RegisterItemJumptable ; 04:6451
+ dw PrintCantRegisterToolText
+ dw PrintCantRegisterToolText
+ dw PrintCantRegisterToolText
+ dw PrintCantRegisterToolText
+ dw RegisterItem
+ dw RegisterItem
+ dw RegisterItem
+
+RegisterItem: ; 04:645F
+ ld a, [wItemIndex]
+ inc a
+ ld b, a
+ ld a, [wActiveBackpackPocket]
+ cp 2
+ jr z, .skip
+ set 7, b
+.skip
+ ld a, b
+ ld [wRegisteredItem], a
+ ld a, [wCurItem]
+ ld [wRegisteredItemQuantity], a
+ call LoadItemData
+ ld de, $0002
+ call WaitPlaySFX
+ ld hl, .RegisteredItemText
+ call MenuTextBoxBackup
+ ret
+
+.RegisteredItemText: ; 04:6487
+ db 1
+ dw wStringBuffer2
+ text "を "
+ line "べんりボタンに とうろくした!<PROMPT>"
+
+PrintCantRegisterToolText: ; 04:649E
+ ld hl, .CantRegisterToolText
+ call MenuTextBoxBackup
+ ret
+
+.CantRegisterToolText: ; 04:64A5
+ text "そのどうぐは "
+ line "とうろくできません!<PROMPT>"
+
+StartMenu_Party: ; 04:64B9
+ ld a, [wPartyCount]
+ and a
+ jr nz, .partynonzero
+ ld a, 0
+ ret
+.partynonzero
+ call LoadStandardMenuHeader
+ callab Function50756
+
+HandleSelectedPokemon: ; 04:64CD
+ xor a
+ ld [wcdb9], a
+ ld [wSelectedSwapPosition], a
+ predef Function50774
+ db $18, $19 ; jr .partypromptreturn
+
+PartyPrompt: ; 04:64DB
+ ld a, [wWhichPokemon]
+ inc a
+ ld [wSelectedSwapPosition], a
+ callab Function8f1f2
+ ld a, 4
+ ld [wcdb9], a
+ predef Function50774
+.partypromptreturn
+ jr c, .return
+ jp SelectedPokemonSubmenu
+.return
+ ld a, 0
+PartyPromptExit: ; 04:64FB
+ push af
+ call ClearBGPalettes
+ call StartMenuLoadSprites
+ nop
+ nop
+ nop
+ ld hl, 0000
+ call Call_ExitMenu
+ call WaitBGMap
+ call UpdateTimePals
+ pop af
+ ret
+
+SelectedPokemonSubmenu: ; 04:6513
+ hlcoord 1, 13
+ lb bc, 4, $12
+ call ClearBox
+ callab Function24955
+ call GetCurNick
+ ld a, [wMenuSelection]
+ ld hl, PartyJumpTable
+ ld de, $3
+ call FindItemInTable
+ jp nc, HandleSelectedPokemon
+ inc hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wd163]
+ jp hl
+
+PartyJumpTable: ; 04:653E
+ dbw 1, PartyTryCut
+ dbw 2, PartyTryFly
+ dbw 3, PartyTrySurf
+ dbw 4, PartyCantUseMove
+ dbw 5, PartyCantUseMove
+ dbw 6, PartyCantUseMove
+ dbw 7, PartyCantUseMove
+ dbw 8, PartyTryDig
+ dbw 9, PartyTryTeleport
+ dbw 10, PartyCalculateHealth
+ dbw 11, PartyPokemonSummary
+ dbw 12, PartyCheckLessThanTwo
+ dbw 13, PartyHeldItem
+ dbw 14, HandleSelectedPokemon
+ dbw 15, PartyPokemonSummary2
+ dbw 16, PartyMailMenu
+
+PartyCheckLessThanTwo: ; 04:656E
+; might have to do with switch?
+ ld a, [wPartyCount]
+ cp 2
+ jp c, HandleSelectedPokemon
+ jp PartyPrompt
+
+PartyHeldItem: ; 04:6579
+ callab Function_8f1cb
+ ld hl, .HoldItemMenu
+ call LoadMenuHeader
+ call VerticalMenu
+ jp c, .closewindow
+ call GetCurNick
+ ld hl, wStringBuffer1
+ ld de, wcd11
+ ld bc, $0006
+ call CopyBytes
+ ld a, [wMenuCursorY]
+ cp 1
+ jr nz, .skip
+ call CloseWindow
+ call .PartyGiveHeldItem
+ jr .jump
+.skip
+ call .PartyTryRecieveItem
+ call CloseWindow
+ jr .jump
+.closewindow; 04:65B3
+ call CloseWindow
+.jump
+ jp HandleSelectedPokemon
+
+.PartyGiveHeldItem ; 04:65B9
+ call LoadStandardMenuHeader
+ call ClearPalettes
+ call GetPocket2Status
+ call DrawBackpack
+ call DebugBackpackLoop
+ ld a, [wMenuJoypad]
+ cp 2
+ jp z, .exitgiveitem
+ call SpeechTextBox
+ call LoadItemData
+ call CheckTossableItem
+ ld a, [wItemAttributeParamBuffer]
+ and a
+ jp nz, .cantgive
+ call GetPartyItemOffset
+ ld a, [hl]
+ and a
+ jr z, .bigleap
+ ld [wce37], a
+ call GetItemName
+ ld hl, ItemPrompt6753
+ call MenuTextBox
+ call YesNoBox
+ call ExitMenu
+ jp c, .exitgiveitem
+ ld a, 1
+ ld [wItemQuantity], a
+ ld hl, wNumBagItems
+ call TossItem
+ ld a, [wce37]
+ ld b, a
+ ld a, [wCurItem]
+ ld [wce37], a
+ ld a, b
+ ld [wCurItem], a
+ call PartyRecieveItem
+ jp nc, .label2
+ ld a, [wce37]
+ ld [wCurItem], a
+ ld hl, ItemWasEquippedText
+ call MenuTextBoxBackup
+ jr .yump
+.bigleap
+ ld a, 1
+ ld [wItemQuantity], a
+ ld hl, wNumBagItems
+ call TossItem
+ ld hl, ItemPrompt66FA
+ call MenuTextBoxBackup
+.yump
+ call GetPartyItemOffset
+ ld a, [wCurItem]
+ ld [hl], a
+ ld a, [wCurItem]
+ cp ITEM_MAIL
+ call z, PartyGiveMail
+ jr .exitgiveitem
+.label2 ; 04:664B
+ ld a, [wce37]
+ ld [wCurItem], a
+ call PartyRecieveItem
+ ld hl, PartyItemRecieveBagFullText
+ call MenuTextBoxBackup
+ jr .exitgiveitem
+.cantgive ; 04:665C
+ ld hl, .CantBeEquippedText
+ call MenuTextBoxBackup
+.exitgiveitem ;04:6662
+ call ClearPalettes
+ call LoadFontsBattleExtra
+ call ExitMenu
+ ret
+
+.PartyTryRecieveItem ; 04:666C
+ call SpeechTextBox
+ call GetPartyItemOffset
+ ld a, [hl]
+ and a
+ jr z, .noitem
+ ld [wCurItem], a
+ call PartyRecieveItem
+ jr nc, .jump2
+ call GetPartyItemOffset
+ ld a, [hl]
+ ld [wce37], a
+ ld [hl], 0
+ call GetItemName
+ ld hl, ItemPrompt673D
+ call MenuTextBoxBackup
+ jr .escape
+.noitem
+ ld hl, PartyNoItemToRecieveText
+ call MenuTextBoxBackup
+ jr .escape
+.jump2
+ ld hl, PartyItemRecieveBagFullText
+ call MenuTextBoxBackup
+.escape
+ ret
+
+.HoldItemMenu ; 04:66A1 ; verticalmenu
+ db STATICMENU_NO_TOP_SPACING | STATICMENU_PLACE_TITLE
+ menu_coords 4, 4, $e, 9
+ dw .HoldItemMenuText
+ db 1
+
+.HoldItemMenuText ;04:66A9
+ db $80
+
+ db 2
+ db "そうびを する@"
+ db "そうびを はずす@"
+
+.CantBeEquippedText ; 04:66BC
+ db 1
+ dw wStringBuffer1
+ text "を そうびすることは"
+ line "できません<PROMPT>"
+
+ItemWasEquippedText ; 04:66D1
+ db 1
+ dw wcd11
+ text "は そうび していた"
+ line "@"
+
+; 04:66E1
+ db 1
+ dw wStringBuffer1
+ text "を はずして"
+ para "@"
+
+; 04:66ED
+ db 1
+ dw wStringBuffer2
+ text "を そうびした!<PROMPT>"
+
+ItemPrompt66FA: ; 04:66FA
+ db 1
+ dw wcd11
+ text "は @"
+
+; 04:6701
+ db 1
+ dw wStringBuffer2
+ text "を"
+ line "そうびした!<PROMPT>"
+
+PartyNoItemToRecieveText: ; 04:670E
+ db 1
+ dw wcd11
+ text "は なにも"
+ line "そうび していません!<PROMPT>"
+
+PartyItemRecieveBagFullText: ; 04:6724
+ text "どうぐが いっぱいで"
+ line "そうびを はずせません!<PROMPT>"
+
+ItemPrompt673D: ; 04:673D
+ db 1
+ dw wcd11
+ text "から @"
+
+; 04:6745
+ db 1
+ dw wStringBuffer1
+ text "を"
+ line "はずしました!<PROMPT>"
+
+ItemPrompt6753: ; 04:6753
+ db 1
+ dw wcd11
+ text "は @"
+
+; 04:675A
+ db 1
+ dw wStringBuffer1
+ text "を"
+ line "すでに そうび しています"
+ para "そうびしている どうぐを"
+ line "とりかえますか?"
+ done
+
+GetPartyItemOffset: ; 04:6784
+ push af
+ ld a, 1
+ call GetPartyParamLocation
+ pop af
+ ret
+
+PartyRecieveItem: ; 04:678C
+ ld a, 1
+ ld [wItemQuantity], a
+ ld hl, wNumBagItems
+ call ReceiveItem
+ ret
+
+UnusedHandleItemJumptable; 04:6798
+ callab CheckItemMenu
+ ld a, [wItemAttributeParamBuffer]
+ ld hl, UnusedItemJumptable
+ jp CallJumptable
+
+UnusedItemJumptable: ; 04:67A9
+ dw EmptyFunction127b7
+ dw PartyGiveMail
+ dw PartyBallPocket
+ dw ChangeBackpackPocket
+ dw EmptyFunction127b7
+ dw EmptyFunction127b7
+ dw EmptyFunction127b7
+
+EmptyFunction127b7: ; 04:67B7
+ ret
+
+ChangeBackpackPocket: ; 04:67B8
+ call FlipPocket2Status
+ xor a
+ ld [wSelectedSwapPosition], a
+ ret
+
+PartyBallPocket: ; 04:67C0
+ call BallPocket
+ jr c, .exit
+ call SelectItem
+ ret c
+ jr PartyBallPocket
+.exit
+ ret
+
+PartyGiveMail: ; 04:67CC
+ call LoadStandardMenuHeader
+ ld de, wMovementBufferCount
+ callab ComposeMailMessage
+ xor a
+ ldh [hBGMapMode], a
+ call LoadFontsBattleExtra
+ call Call_ExitMenu
+ call WaitBGMap
+ ld a, [wWhichPokemon]
+ ld hl, $BA68
+ ld bc, $0028
+ call AddNTimes
+ ld d, h
+ ld e, l
+ ld hl, wMovementBufferCount
+ ld bc, $0028
+ ld a, 2
+ call OpenSRAM
+ call CopyBytes
+ call CloseSRAM
+ ret
+
+PartyMailMenu: ; 04:6806
+ ld hl, .MailMenu
+ call LoadMenuHeader
+ call VerticalMenu
+ call PlaceHollowCursor
+ jp c, .exit
+ ld a, [wMenuCursorY]
+ cp 3
+ jp z, .exit
+ cp 1
+ jr z, .giveMail
+ ld hl, .MessageRemoveMail
+ call MenuTextBox
+ call YesNoBox
+ call CloseWindow
+ jp c, .exit
+ ld a, [wWhichPokemon]
+ ld hl, wPartyMon1 + MON_ITEM
+ ld bc, $0030
+ call AddNTimes
+ ld a, [hl]
+ ld [wCurItem], a
+ ld a, 1
+ ld [wItemQuantity], a
+ push hl
+ ld hl, wNumBagItems
+ call ReceiveItem
+ pop hl
+ jr nc, .escapeyump
+ xor a
+ ld [hl], a
+ call GetCurNick
+ ld hl, .drawNick
+ call MenuTextBoxBackup
+ jr .exit
+.giveMail
+ ld a, [wWhichPokemon]
+ ld hl, $BA68
+ ld bc, $0028
+ call AddNTimes
+ ld bc, $0028
+ ld de, wMovementBufferCount
+ ld a, 2
+ call OpenSRAM
+ call CopyBytes
+ call CloseSRAM
+ hlcoord 0, 12
+ ld b, 4
+ ld c, $12
+ call DrawTextBox
+ ld de, wMovementBufferCount
+ hlcoord 1, 14
+ call PlaceString
+ ld c, 5
+ call DelayFrames
+ xor a
+ ldh [hJoyState], a
+ call TextboxWaitPressAorB_BlinkCursor
+.exit
+ call CloseWindow
+ jp HandleSelectedPokemon
+
+.escapeyump ; 04:689D
+ ld hl, .MailFullText
+ call MenuTextBoxBackup
+ jr .exit
+
+.MailMenu ; 04:68A5
+ db MENU_BACKUP_TILES
+ menu_coords 04, 04, $0E, $0B
+ dw .MailMenuStrings
+ db 01
+
+.MailMenuStrings ; 04:68AD
+
+ db $80
+ db 3
+ db "メールを よむ@"
+ db "メールを はずす@"
+ db "やめる@"
+
+.MessageRemoveMail ; 04:68C4
+ text "メールを はずすと メッセージが"
+ line "きえてしまいますが いいですか?"
+ done
+
+.drawNick ; 04:68E7
+ db 1
+ dw wStringBuffer1
+ text "から @"
+
+.DeleteMailText ; 04:68EF
+ text "メールを"
+ line "はずしました!<PROMPT>"
+
+.MailFullText ; 04:68FD
+ text "どうぐが いっぱいで"
+ line "メールを はずせません!<PROMPT>"
+
+PartyPokemonSummary: ; 04:6916
+ call LoadStandardMenuHeader
+ call ClearSprites
+ xor a
+ ld [wMonType], a
+ call LowVolume
+ predef Function502b5
+ call MaxVolume
+ call ReloadFontAndTileset
+ call Call_ExitMenu
+ jp HandleSelectedPokemon
+
+PartyTryCut: ; 04:6934
+ callab CutFunction
+ ld a, [wFieldMoveSucceeded]
+ cp $F
+ jp nz, HandleSelectedPokemon
+ ld a, 4
+ jp PartyPromptExit
+
+PartyTryFly: ; 04:6949
+ bit 2, a
+ jp z, PrintNeedNewBadgeText
+ callab FlyFunction
+ ld a, [wFieldMoveSucceeded]
+ cp $F
+ jp nz, HandleSelectedPokemon
+ ld a, 4
+ jp PartyPromptExit
+
+PartyCantUseMove: ; 04:6963
+ call PrintCantUseHM
+ jp HandleSelectedPokemon
+
+PartyTryTeleport: ; 04:6969
+ callab TeleportFunction
+ ld a, [wFieldMoveSucceeded]
+ and a
+ jp z, HandleSelectedPokemon
+ ld a, 4
+ jp PartyPromptExit
+
+PartyTrySurf: ; 04:697D
+ bit 4, a
+ jp z, PrintNeedNewBadgeText
+ callab SurfFunction
+ ld a, [wFieldMoveSucceeded]
+ and a
+ jp z, HandleSelectedPokemon
+ ld a, 4
+ jp PartyPromptExit
+
+PartyTryDig: ; 04:6996
+ callab DigFunction
+ ld a, [wFieldMoveSucceeded]
+ cp $F
+ jp nz, HandleSelectedPokemon
+ ld a, 4
+ jp PartyPromptExit
+
+PartyCalculateHealth: ; 04:69AB
+ ld a, MON_MAXHP ; might be wrong, was $24
+ call GetPartyParamLocation
+ ld a, [hli]
+ ldh [hDividend], a
+ ld a, [hl]
+ ldh [hQuotient], a
+ ld a, 5
+ ldh [hDivisor], a
+ ld b, 2
+ call Divide
+ ld a, MON_HP + 1 ; might be wrong, was $23
+ call GetPartyParamLocation
+ ldh a, [hQuotient + 2]
+ sub [hl]
+ dec hl
+ ldh a, [hQuotient + 1]
+ sbc a, [hl]
+ jp nc, PrintNotHealthyEnoughText
+ callab Functionf218
+ jp HandleSelectedPokemon
+
+PrintNotHealthyEnoughText: ; 04:69D9
+ ld hl, NotHealthyEnoughText
+ call PrintText
+ jp HandleSelectedPokemon
+
+NotHealthyEnoughText: ; 04:69E2
+ text "たいりょくが たりません!<PROMPT>"
+
+PrintNeedNewBadgeText: ; 04:69F1
+ ld hl, NeedNewBadgeText
+ call PrintText
+ jp HandleSelectedPokemon
+
+NeedNewBadgeText: ; 04:69FA
+ text "あたらしい バッジを てにするまで"
+ line "まだ つかえません!<PROMPT>"
+
+PartyPokemonSummary2: ; 04:6A18
+ ld hl, wce5f
+ ld a, [hl]
+ push af
+ set 4, [hl]
+ call PokeSummary
+ pop af
+ ld [wce5f], a
+ call ClearBGPalettes
+ jp HandleSelectedPokemon
+
+PokeSummary: ; 04:6A2C
+ call ClearBGPalettes
+ call ClearTileMap
+ call ClearSprites
+ xor a
+ ldh [hBGMapMode], a
+ callab LoadOnlyPokemonStatsGraphics
+ callab Function8f0cc
+ ld a, [wWhichPokemon]
+ ld e, a
+ ld d, 0
+ ld hl, wPartySpecies
+ add hl, de
+ ld a, [hl]
+ ld [wce37], a
+ ld hl, Function8f0e3
+ ld a, BANK(Function8f0e3)
+ ld e, 2
+ call FarCall_hl
+ hlcoord 0, 1
+ ld b, 8
+ ld c, $12
+ call DrawTextBox
+ hlcoord 1, 1
+ lb bc, 2, $12
+ call ClearBox
+ hlcoord 3, 1
+ predef Function508c4
+ ld hl, wccd1
+ call SetHPPal
+ ld b, $0E
+ call GetSGBLayout
+ hlcoord 11, 0
+ lb bc, 1, 9
+ call ClearBox
+ hlcoord 16, 0
+ ld a, [wWhichPokemon]
+ and a
+ jr z, .firstpokechosen
+ ld [hl], "」"
+.firstpokechosen
+ inc a
+ ld b, a
+ ld a, [wPartyCount]
+ cp b
+ jr z, .lastpokechosen
+ inc hl
+ inc hl
+ ld [hl], "▶" ; right filled arrow
+.lastpokechosen
+ ld de, PartyMenuAttributes
+ call SetMenuAttributes
+SummaryDrawPoke: ; 04:6AAC
+ xor a
+ ldh [hBGMapMode], a
+ ld [wSelectedSwapPosition], a
+ ld [wMonType], a
+ predef Function50000
+ ld hl, wcd81
+ ld de, wce2e
+ ld bc, $0004
+ call CopyBytes
+ ld a, $28
+ ld [wHPBarMaxHP], a
+ hlcoord 2, 3
+ predef Function50bfe
+ hlcoord 11, 3
+ predef Function506d4
+ call WaitBGMap
+ call SetPalettes
+ ld a, [wcd57]
+ inc a
+ ld [w2DMenuNumRows], a
+ hlcoord 0, 10
+ ld b, 6
+ ld c, $12
+ call DrawTextBox
+ ld hl, w2DMenuFlags
+ set 6, [hl]
+ db $18, $17 ; jr z, PartySelectSkipInputs
+PartySelectionInputs: ; 04:6AF9
+ call Get2DMenuJoypad + 3
+ bit B_BUTTON_F, a
+ jp nz, PartySelectionBackOut
+ bit A_BUTTON_F, a
+ jp nz, .PartyPokeSelect
+.PartySelectionRLInputs
+ bit D_RIGHT_F, a
+ jp nz, .PartyPokeDetailsAdvancePage
+ bit D_LEFT_F, a
+ jp nz, .PartyPokeDetailsBackPage
+.PartySelectSkipInputs
+ ld hl, wPartyMon1 + MON_MOVES
+ lb bc, 0, $30
+ ld a, [wWhichPokemon]
+ call AddNTimes
+ ld a, [wMenuCursorY]
+ dec a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [hl]
+ ld [wCurSpecies], a
+ hlcoord 1, 11
+ lb bc, $06, $12
+ call ClearBox
+ hlcoord 1, 12
+ ld a, [wSelectedSwapPosition]
+ and a
+ jr nz, .DrawMovePokeText
+ ld de, PartyTypeText
+ call PlaceString
+ ld a, [wCurSpecies]
+ ld b, a
+ hlcoord 5, 12
+ predef Function500a0
+ ld a, [wCurSpecies]
+ dec a
+ ld hl, Data4a8b8
+ ld bc, $0007
+ call AddNTimes
+ ld a, BANK(Data4a8b8)
+ call GetFarByte
+ hlcoord 15, 12
+ cp 2
+ jr c, .notamove
+ ld [wce37], a
+ ld de, wce37
+ lb bc, 1, 3
+ call PrintNumber
+ jr .step
+.notamove
+ ld de, PartyPokeDivider
+ call PlaceString
+.step
+ hlcoord 1, 14
+ predef Function2d663
+ jp PartySelectionInputs
+
+.DrawMovePokeText ; 04:6B84
+ hlcoord 1, 11
+ lb bc, 6, $12
+ call ClearBox
+ hlcoord 1, 12
+ ld de, PartyMoveText
+ call PlaceString
+ jp PartySelectionInputs
+
+.PartyPokeDetailsAdvancePage ; 04:6B99
+ ld hl, wWhichPokemon
+ inc [hl]
+ ld a, [wPartyCount]
+ cp [hl]
+ jp nz, PokeSummary
+ dec [hl]
+ jp PartySelectionInputs
+
+.PartyPokeDetailsBackPage ; 04:6BA8
+ ld hl, wWhichPokemon
+ ld a, [hl]
+ and a
+ jp z, PartySelectionInputs
+ dec [hl]
+ jp PokeSummary
+
+.PartyPokeSelect ; 04:6BB4
+ ld a, [wSelectedSwapPosition]
+ and a
+ jr nz, .swap
+ ld a, [wMenuCursorY]
+ ld [wSelectedSwapPosition], a
+ call PlaceHollowCursor
+ db $18, $bf ; jr .PartySelectionRLInputs
+.swap
+ ld hl, wPartyMon1 + MON_MOVES
+ ld bc, $0030
+ ld a, [wWhichPokemon]
+ call AddNTimes
+ push hl
+ call SwapEntries
+ pop hl
+ ld bc, $0015
+ add hl, bc
+ call SwapEntries
+ ld a, [wBattleMode]
+ jr z, .notinbattle
+ ld hl, wca04
+ ld bc, $0020
+ ld a, [wWhichPokemon]
+ call AddNTimes
+ push hl
+ call SwapEntries
+ pop hl
+ ld bc, $0006
+ add hl, bc
+ call SwapEntries
+.notinbattle
+ hlcoord 1, 2
+ lb bc, 8, $12
+ call ClearBox
+ jp SummaryDrawPoke
+
+SwapEntries: ; 04:6C06
+; values at (hl + [cursor place]-1)
+; and (hl + [wSelectedSwapPosition] -1) get swapped
+ push hl ; saves hl
+ ld a, [wMenuCursorY]
+ dec a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld d, h
+ ld e, l
+ pop hl ; hl is same as start
+ ld a, [wSelectedSwapPosition]
+ dec a
+ ld c, a
+ ld b, 0
+ add hl, bc ; hl is now hl + bc
+ ld a, [de]
+ ld b, [hl]
+ ld [hl], a
+ ld a, b
+ ld [de], a
+ ret
+
+PartySelectionBackOut: ; 04:6C20
+ xor a
+ ld [wSelectedSwapPosition], a
+ ld hl, w2DMenuFlags
+ res 6, [hl]
+ call ClearSprites
+ call ClearTileMap
+ ret
+
+PartyMenuAttributes: ; 04:6C30
+; cursor y
+; cursor y
+; num rows
+; num cols
+; bit 6: animate sprites bit 5: wrap around
+; ?
+; distance between items (hi: y, lo: x)
+; allowed buttons (mask)
+ db 3, 1
+ db 3, 1
+ db $40, $00
+ dn 2, 0
+ db $F3
+
+PartyTypeText: ; 04:6C38
+ db "タイプ/     いりょく/@"
+
+PartyPokeDivider: ; 04:6C47
+ db "ーーー@"
+
+PartyMoveText: ; 04:6C4B
+ db "どこに いどうしますか?@"
+
+CheckRegisteredItem: ; 04:6C58
+ call .registereditem
+ ret
+
+.registereditem ; 04:6C5C
+ call GetRegisteredItemID
+ jr c, .notregistered
+ call UseRegisteredItem
+ ret
+
+.notregistered ; 04:6C65
+ call RefreshScreen
+ ld hl, .NothingRegisteredText
+ call MenuTextBoxBackup
+ call Function1fea
+ ret
+
+.NothingRegisteredText: ; 04:6C72
+ text "べんりボタンを おした!"
+ line "⋯しかしなにもおきない!<PROMPT>"
+
+GetRegisteredItemID: ; 04:6C8D
+; if you can use the registered item, sets the ID to a
+; otherwise sets 0 to a and sets the carry flag
+ ld a, [wRegisteredItem]
+ and a
+ jr z, .cantuse
+ bit 7, a
+ jr nz, .isKey
+ dec a
+ ld hl, wNumBagItems
+ cp [hl]
+ jr nc, .cantuse
+ inc hl
+ ld [wItemIndex], a
+ ld e, a
+ ld d, 0
+ add hl, de
+ add hl, de
+ ld a, [wRegisteredItemQuantity]
+ cp [hl]
+ jr nz, .cantuse
+ ld a, [hl]
+ ld [wCurItem], a
+ and a
+ ret
+.isKey
+ and $7F
+ dec a
+ ld hl, wNumKeyItems
+ cp [hl]
+ jr nc, .cantuse
+ ld [wItemIndex], a
+ ld e, a
+ ld d, 0
+ inc hl
+ add hl, de
+ ld a, [wRegisteredItemQuantity]
+ cp [hl]
+ jr nz, .cantuse
+ ld a, [hl]
+ ld [wCurItem], a
+ and a
+ ret
+.cantuse
+ xor a
+ ld [wRegisteredItem], a
+ ld [wRegisteredItemQuantity], a
+ scf
+ ret
+
+UseRegisteredItem: ; 04:6CD9
+ callab CheckItemMenu
+ ld a, [wItemAttributeParamBuffer]
+ ld hl, .RegisteredItemJumptable
+ jp CallJumptable
+
+.RegisteredItemJumptable ; 04:6CEA
+ dw .cantuse2
+ dw .cantuse
+ dw .cantuse
+ dw .cantuse
+ dw .overworld
+ dw .fieldmove
+
+.cantuse ; 04:6CF6
+ call RefreshScreen
+ call PrintCantUseText
+ call Function1fea
+ and a
+ ret
+
+.simpleuse ; 04:6D01
+ call RefreshScreen
+ call UseItem
+ call Function1fea
+ and a
+ ret
+
+.overworld ; 04:6D0C
+ call RefreshScreen
+ ld hl, wVramState
+ res 0, [hl]
+ call UseItem
+ call ClearPalettes
+ call StartMenuLoadSprites
+ call UpdateTimePals
+ call Function1fea
+ and a
+ ret
+
+.fieldmove ; 04:6D25
+ call UseItem
+ ld a, [wFieldMoveSucceeded]
+ and a
+ jr z, .cantuse2
+ scf
+ ld a, -1
+ ldh [hStartmenuCloseAndSelectHookEnable], a
+ ld a, 4
+ ret
+
+.cantuse2
+ call RefreshScreen
+ call PrintCantUseText
+ call Function1fea
+ and a
+ ret
+
+TrainerCardLoop: ; 04:6D41
+ ld a, [wVramState]
+ push af
+ xor a
+ ld [wVramState], a
+ call ClearTrainerCardJumptable
+.loop
+ call UpdateTime
+ call HandleTrainerCardJumptable
+ jr c, .escape
+ call DelayFrame
+ jr .loop
+.escape
+ pop af
+ ld [wVramState], a
+ ret
+
+ClearTrainerCardJumptable; 04:6D5E
+; sets four bytes at wJumpTableIndex to 0
+ call ClearPalettes
+ ld hl, wJumptableIndex
+ xor a
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ call ClearTileMap
+ call ClearSprites
+ ld b, $0D
+ call GetSGBLayout
+ ret
+
+HandleTrainerCardJumptable: ; 04:6D75
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, 0
+ ld hl, .TrainerCardJumptable
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+.TrainerCardJumptable: ; 04:6D84
+ dw TrainerCardMainPage
+ dw .IncreaseJumpTableIndex
+ dw .IncreaseJumpTableIndex
+ dw .SetPalAndIncJumpTable
+ dw TrainerCardMainInputs
+ dw TrainerCardScroll
+ dw .IncreaseJumpTableIndex
+ dw .IncreaseJumpTableIndex
+ dw TrainerCardClearTileMap
+ dw .IncreaseJumpTableIndex
+ dw .IncreaseJumpTableIndex
+ dw TrainerCardSetWindowY
+ dw TrainerCardBadgePage
+ dw .IncreaseJumpTableIndex
+ dw .IncreaseJumpTableIndex
+ dw .SetPalAndIncJumpTable
+ dw TrainerCardBadgeInput
+ dw TrainerCardSetClearFlag
+
+.SetPalAndIncJumpTable: ; 04:6DA8
+ call SetPalettes
+.IncreaseJumpTableIndex: ; 04:6DAB
+ ld a, [wJumptableIndex]
+ inc a
+ ld [wJumptableIndex], a
+ ret
+
+TrainerCardMainPage: ; 04:6DB3
+ call ClearPalettes
+ call ClearTileMap
+ call TrainerCardDrawProtag
+ call DisableLCD
+ call PlaceMiscTilesTrainerCard
+ ld hl, TrainerCardBorderGFX
+ ld de, vTileset
+ ld bc, $0240
+ ld a, BANK(TrainerCardBorderGFX)
+ call FarCopyData
+ call DrawTrainerCardMainPage
+ call EnableLCD
+ ld a, [wJumptableIndex]
+ inc a
+ ld [wJumptableIndex], a
+ xor a
+ ld [wFlyDestination], a
+ and a
+ ret
+
+TrainerCardMainInputs: ; 04:6DE3
+ call EmptyFunction12e37
+ call GetJoypad
+ ld hl, hJoyDown
+ ld a, [hl]
+ and D_LEFT
+ jr nz, .left
+ ld a, [hl]
+ and D_RIGHT
+ jr nz, .right
+ ld a, [hl]
+ and A_BUTTON
+ jr nz, .apress
+ ld a, [hl]
+ and B_BUTTON
+ jr nz, .exit
+ and a
+ ret
+.apress
+ ld a, [wFlyDestination]
+ and a
+ jr z, .exit
+ ld a, 5
+ ld [wJumptableIndex], a
+ and a
+ ret
+.exit
+ ld a, $11
+ ld [wJumptableIndex], a
+ and a
+ ret
+.left
+ hlcoord 4, 16
+ ld [hl], "▶"
+ hlcoord 11, 16
+ ld [hl], " "
+ xor a
+ ld [wFlyDestination], a
+ and a
+ ret
+.right
+ hlcoord 4, 16
+ ld [hl], " "
+ hlcoord 11, 16
+ ld [hl], "▶"
+ ld a, 1
+ ld [wFlyDestination], a
+ and a
+ ret
+
+EmptyFunction12e37: ; 04:6E37
+ ret
+
+TrainerCardScroll: ; 04:6E38
+ ld a, $90
+ ldh [hWY], a
+ ld a, $9C
+ ldh [hBGMapAddress +1], a
+ ld a, [wJumptableIndex]
+ inc a
+ ld [wJumptableIndex], a
+ and a
+ ret
+
+TrainerCardClearTileMap: ; 04:6E49
+ xor a
+ ldh [hWY], a
+ ld a, $98
+ ldh [hBGMapAddress +1], a
+ call ClearTileMap
+ ld a, [wJumptableIndex]
+ inc a
+ ld [wJumptableIndex], a
+ and a
+ ret
+
+TrainerCardSetWindowY: ; 04:6E5C
+ ldh a, [hWY]
+ cp $90
+ jr nc, TrainerCardClearPals
+ add a, 4
+ ldh [hWY], a
+ and a
+ ret
+
+TrainerCardClearPals: ; 04:6E68
+ call ClearPalettes
+ ld a, $90
+ ldh [hWY], a
+ ld a, [wJumptableIndex]
+ inc a
+ ld [wJumptableIndex], a
+ and a
+ ret
+
+TrainerCardBadgePage: ; 04:6E78
+ call ClearPalettes
+ call DisableLCD
+ ld hl, TrainerCardLeadersGFX
+ ld de, vTileset
+ ld bc, $07F0
+ ld a, BANK(TrainerCardLeadersGFX)
+ call FarCopyData
+ call ClearTileMap
+ call DrawTrainerCaseBadgePage
+ call EnableLCD
+ ld a, [wJumptableIndex]
+ inc a
+ ld [wJumptableIndex], a
+ and a
+ ret
+
+TrainerCardBadgeInput: ; 04:6E9E
+ call GetJoypad
+ ld hl, hJoyDown
+ ld a, [hl]
+ and 3
+ jr z, .skip
+ ld a, $11
+ ld [wJumptableIndex], a
+.skip
+ and a
+ ret
+
+TrainerCardSetClearFlag: ; 04:6EB0
+ scf
+ ret
+
+TrainerCardDrawProtag: ; 04:6EB2
+ ld de, ProtagonistPic
+ ld a, BANK(ProtagonistPic)
+ call UncompressSpriteFromDE
+ ld a, 0
+ call OpenSRAM
+ ld hl, sSpriteBuffer1
+ ld de, sSpriteBuffer0
+ ld bc, $0310
+ call CopyBytes
+ call CloseSRAM
+ ld de, vChars2 tile $30
+ call InterlaceMergeSpriteBuffers
+ ret
+
+PlaceMiscTilesTrainerCard: ; 04:6ED5
+ ld a, $30
+ ldh [hGraphicStartTile], a
+ hlcoord 13, 1
+ lb bc, 7, 7
+ predef PlaceGraphic
+ ret
+
+DrawTrainerCardMainPage: ; 04:6EE5
+ hlcoord 0, 0
+ ld d, 5
+ call PlaceTrainerCardBGTile
+ hlcoord 0, 8
+ ld d, 6
+ call PlaceTrainerCardBGTile
+ hlcoord 2, 2
+ ld de, TrainerCardText
+ call PlaceString
+ hlcoord 16, 10
+ ld de, TrainerCardDexEntriesText
+ call PlaceString
+ hlcoord 6, 2
+ ld de, wPlayerName
+ call PlaceString
+ hlcoord 5, 4
+ ld de, wce73
+ lb bc, 2, 5
+ call PrintNumber
+ hlcoord 7, 6
+ ld de, wd15d
+ lb bc, 3, 6
+ call PrintNumber
+ ld [hl], $F0
+ ld hl, wPokedexOwned
+ ld b, $1C
+ call CountSetBits
+ ld de, wce37
+ hlcoord 13, 10
+ lb bc, 1, 3
+ call PrintNumber
+ hlcoord 1, 0
+ ld de, TrainerCardNameTiles
+ call PlaceTrainerCardTiles
+ hlcoord 2, 4
+ ld de, TrainerCardIDNoTiles
+ call PlaceTrainerCardTiles
+ hlcoord 1, 3
+ ld de, TrainerCardNameUnderlineTiles
+ call PlaceTrainerCardTiles
+ hlcoord 1, 8
+ ld de, TrainerCardStatusTiles
+ call PlaceTrainerCardTiles
+ hlcoord 0, 13
+ ld de, TrainerCardBadgesOutlineTiles
+ call PlaceTrainerCardTiles
+ hlcoord 5, 16
+ ld de, TrainerCardBadgesTextTiles
+ call PlaceTrainerCardTiles
+ hlcoord 4, 16
+ ld [hl], "▶"
+ ret
+
+TrainerCardText: ; 04:6F7A
+ db "なまえ/<NEXT><NEXT>おこづかい<NEXT><NEXT>#ずかん@"
+
+TrainerCardDexEntriesText: ; 04:6F8C
+ db "ひき@"
+
+TrainerCardNameTiles: ; 04:6F8F
+ db $0A, $0C, $0D, $0E, $0F, $FF
+
+TrainerCardIDNoTiles: ; 04:6F95
+ db $22, $23, $FF
+
+TrainerCardNameUnderlineTiles: ; 04:6F98
+ db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $0B, $FF
+
+TrainerCardStatusTiles: ; 04:6FA6
+ db $0A, $10, $11, $12, $13, $FF
+
+TrainerCardBadgesOutlineTiles: ; 04:6FAC
+ db $03, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $02, $7F, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $7F, $7F, $7F, $FE, $BA, $7F, $7F, $7F, $05, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $FF
+
+TrainerCardBadgesTextTiles: ; 04:6FE9
+ db $1E, $1F, $20, $7F, $7F, $7F, $7F, $1B, $1C, $1D, $FF
+
+DrawTrainerCaseBadgePage: ; 04:6FF4
+ hlcoord 0, 0
+ ld d, $0E
+ call PlaceTrainerCardBGTile
+ hlcoord 5, 2
+ ld de, TrainerCardLeagueBadgesTextTiles
+ call PlaceString
+ hlcoord 1, 0
+ ld de, TrainerCardBadgesTiles
+ call PlaceTrainerCardTiles
+ hlcoord 0, 3
+ ld de, TrainerCardBadgeSilhouettesTiles
+ call PlaceTrainerCardTiles
+ ret
+
+TrainerCardLeagueBadgesTextTiles: ; 04:7018
+ db "#りーグバッジ@"
+
+TrainerCardBadgesTiles: ; 04:7020
+ db $0A, $0B, $0C, $0D, $0E, $FF
+
+TrainerCardBadgeSilhouettesTiles: ; 04:7026
+ db $07, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $07, $07, $02, $18, $58, $59, $5A, $19, $5B, $5C, $5D, $1A, $6B, $6C, $6D, $1B, $78, $79, $7A, $7F, $07, $07, $02, $7F, $20, $21, $22, $7F, $23, $24, $25, $7F, $26, $27, $28, $7F, $29, $2A, $2B, $7F, $07, $07, $02, $7F, $30, $31, $32, $7F, $33, $34, $35, $7F, $36, $37, $38, $7F, $39, $3A, $3B, $7F, $07, $07, $02, $7F, $40, $41, $42, $7F, $43, $44, $45, $7F, $46, $47, $48, $7F, $49, $4A, $4B, $7F, $07, $07, $05, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $04, $07, $07, $7F, $1C, $68, $69, $6A, $1D, $7E, $6F, $6F, $1E, $5E, $5F, $6E, $1F, $7B, $7C, $7D, $02, $07, $07, $7F, $7F, $2C, $2D, $2E, $7F, $2F, $50, $51, $7F, $52, $53, $54, $7F, $55, $56, $57, $02, $07, $07, $7F, $7F, $3C, $3D, $3E, $7F, $3F, $60, $61, $7F, $62, $63, $64, $7F, $65, $66, $67, $02, $07, $07, $7F, $7F, $4C, $4D, $4E, $7F, $4F, $70, $71, $7F, $72, $73, $74, $7F, $75, $76, $77, $02, $07, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $02, $07, $7F, $7F, $10, $7F, $11, $7F, $12, $7F, $13, $7F, $14, $7F, $15, $7F, $16, $7F, $17, $7F, $02, $07, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $06, $07, $FF
+
+PlaceTrainerCardTiles: ; 04:712B
+; takes the tiles from de and places them at hl until FF is found.
+ ld a, [de]
+ cp $FF
+ ret z
+ ld [hli], a
+ inc de
+ jr PlaceTrainerCardTiles
+
+PlaceTrainerCardBGTile: ; 04:7133
+; puts tile $07 (chequered background) at coord hl.
+; d controls how many times biggerloop loops.
+ ld e, $14
+.loop
+ ld a, $07
+ ld [hli], a
+ dec e
+ jr nz, .loop
+
+ ld a, $07
+ ld [hli], a
+ ld e, $11
+.scanloop
+ inc hl
+ dec e
+ jr nz, .scanloop
+
+ ld a, 9
+ ld [hli], a
+ ld a, 7
+ ld [hli], a
+.biggerloop
+ ld a, 7
+ ld [hli], a
+ ld e, $12
+.anotherloop
+ inc hl
+ dec e
+ jr nz, .anotherloop
+
+ ld a, 7
+ ld [hli], a
+ dec d
+ jr nz, .biggerloop
+
+ ld a, 7
+ ld [hli], a
+ ld a, 8
+ ld [hli], a
+ ld e, $11
+.panandscan
+ inc hl
+ dec e
+ jr nz, .panandscan
+
+ ld a, 7
+ ld [hli], a
+ ld e, $14
+.lastloop
+ ld a, 7
+ ld [hli], a
+ dec e
+ jr nz, .lastloop
+ ret
+
+; end of section \ No newline at end of file
diff --git a/engine/menu/text_entry.asm b/engine/menu/text_entry.asm
new file mode 100644
index 0000000..3cd8f6c
--- /dev/null
+++ b/engine/menu/text_entry.asm
@@ -0,0 +1,1050 @@
+INCLUDE "constants.asm"
+
+SECTION "engine/menu/text_entry.asm@naming", ROMX
+
+NAMINGSCREEN_UNDERSCORE EQU "♀" ; $F5
+NAMINGSCREEN_HYPHEN EQU "♂"; $EF
+NAMINGSCREEN_END EQU "円" ; $F0
+
+NamingScreen: ; 04:53F4
+ ld hl, wNamingScreenDestinationPointer
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ ld hl, wNamingScreenType
+ ld [hl], b
+ ld hl, wce5f
+ ld a, [hl]
+ push af
+ set 4, [hl]
+ ldh a, [hMapAnims]
+ push af
+ xor a
+ ldh [hMapAnims], a
+ ldh a, [hJoyDebounceSrc]
+ push af
+ ld a, $01
+ ldh [hJoyDebounceSrc], a
+ call .SetUpNamingScreen
+ call DelayFrame
+.loop
+ call NamingScreenJoypadLoop
+ jr nc, .loop
+
+ pop af
+ ldh [hJoyDebounceSrc], a
+ pop af
+ ldh [hMapAnims], a
+ pop af
+ ld [wce5f], a
+ call ClearJoypad
+ ret
+
+.SetUpNamingScreen: ; 04:542B
+ call ClearBGPalettes
+ ld b, SGB_DIPLOMA
+ call GetSGBLayout
+ call DisableLCD
+ call LoadNamingScreenGFX
+ call NamingScreen_InitText
+ ld a, $E3
+ ldh [rLCDC], a
+ call GetNamingScreenSetup
+ call WaitBGMap
+ call WaitForAutoBgMapTransfer
+ ld a, $90
+ ldh [rBGP], a
+ ld a, $D0
+ ldh [rOBP0], a
+ call NamingScreenInitNameEntry
+ ret
+
+GetNamingScreenSetup: ; 04:5455
+; wNamingScreenType selects which entry in the table below to jump to
+ ld a, [wNamingScreenType]
+ and $07
+ ld e, a
+ ld d, 0
+ ld hl, .Jumptable
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+.Jumptable: ; 04:5466
+ dw .Pokemon
+ dw .Player
+ dw .Rival
+ dw .Mom
+ dw .Box
+ dw .Pokemon
+ dw .Pokemon
+ dw .Pokemon
+
+.Pokemon: ; 04:5476
+ ld hl, Function8f0e3
+ ld a, BANK(Function8f0e3)
+ ld e, 1
+ call FarCall_hl
+ call GetPokemonName
+ hlcoord 5, 2
+ call PlaceString
+ ld l, c
+ ld h, b
+ ld de, .NicknameText
+ call PlaceString
+ call .StoreSpriteIconParams
+ ret
+
+.NicknameText ; 04:5495
+ db "のニックネームは?@"
+
+.Player: ; 04:549F
+ ld de, GoldSpriteGFX
+ call .LoadSprite
+ hlcoord 5, 2
+ ld de, .NameText
+ call PlaceString
+ call .StoreSpriteIconParams
+ ret
+
+.NameText: ; 04:54B2
+ db "あなた の なまえは?@"
+
+.Rival: ; 04:54BE
+ ld de, SilverSpriteGFX
+ call .LoadSprite
+ hlcoord 5, 2
+ ld de, .RivalText
+ call PlaceString
+ call .StoreSpriteIconParams
+ ret
+
+.RivalText: ; 04:54D1
+; the ret just preceeding this would make the first word Rival.
+ db "ライバル の なまえは?@"
+
+.Mom: ; 04:54DE
+ ld de, MomSpriteGFX
+ call .LoadSprite
+ hlcoord 5, 2
+ ld de, .MomText
+ call PlaceString
+ call .StoreSpriteIconParams
+ ret
+
+.MomText: ; 04:54F1
+ db "ははおや の なまえは?@"
+
+.Box: ; 04:54FE
+ ld de, PokeBallSpriteGFX
+ ld hl, vChars0
+ lb bc, BANK(PokeBallSpriteGFX), $04
+ call Request2bpp
+ ld a, $08
+ ld hl, wTileMapBackup
+ ld [hl+], a
+ ld [hl], $00
+ ld de, $2420
+ ld a, $41
+ call InitSpriteAnimStruct
+ ld hl, $0001
+ add hl, bc
+ ld [hl], $00
+ hlcoord 5, 2
+ ld de, .BoxText
+ call PlaceString
+ call .StoreBoxIconParams
+ ret
+
+.BoxText: ; 04:552D
+ db "バンク の なまえは?@"
+
+.LoadSprite: ; 04:5539
+; copies the sprite at de into the top of VRAM, as well as the sprite $C0 after de
+ push de
+ ld hl, vChars0
+ lb bc, BANK(GoldSpriteGFX), $04
+ call Request2bpp
+ pop de
+ ld hl, $00C0
+ add hl, de
+ ld e, l
+ ld d, h
+ ld hl, vChars0 tile 4
+ lb bc, BANK(GoldSpriteGFX), $04
+ call Request2bpp
+ ld a, $08
+ ld hl, wTileMapBackup
+ ld [hli], a
+ ld [hl], $00
+ ld de, $2420
+ ld a, $41
+ call InitSpriteAnimStruct
+ ret
+
+.StoreSpriteIconParams: ; 04:5564
+ ld a, $05
+ ld [wNamingScreenMaxNameLength], a
+ hlcoord 6, 5
+ ld a, l
+ ld [wNamingScreenStringEntryCoordY], a
+ ld a, h
+ ld [wNamingScreenStringEntryCoordX], a
+ ret
+
+.StoreBoxIconParams: ; 04:5575
+ ld a, $08
+ ld [wNamingScreenMaxNameLength], a
+ hlcoord 5, 5
+ ld a, l
+ ld [wNamingScreenStringEntryCoordY], a
+ ld a, h
+ ld [wNamingScreenStringEntryCoordX], a
+ ret
+
+NamingScreen_InitText: ; 04:5586
+; fills the tilemap with ■, then clears a 12x17 box at 1,1
+; next it places the tiles at 04:58B3 onto the screen at 2,9 (tiles form an 11x8 box)
+ call WaitForAutoBgMapTransfer
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, "■"
+ call ByteFill
+ hlcoord 1, 1
+ lb bc, $07, $12
+ call ClearBox
+ hlcoord 1, 9
+ lb bc, $08, $12
+ call ClearBox
+ hlcoord 2, 9
+ ld de, TextEntryChars
+ ld b, $08
+
+.outerloop
+ ld c, $11
+
+.innerloop
+ ld a, [de]
+ ld [hl+], a
+ inc de
+ dec c
+ jr nz, .innerloop
+
+ inc hl
+ inc hl
+ inc hl
+ dec b
+ jr nz, .outerloop
+ ret
+
+
+NamingScreenJoypadLoop: ; 04:55BD
+ call GetJoypadDebounced
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .leap
+ call .RunJumpTable
+ callba PlaySpriteAnimationsAndDelayFrame
+ call .UpdateStringEntry
+ call DelayFrame
+ and a
+ ret
+
+.leap ; 04:55DA
+; kills sprites and resets screen position
+ callab InitEffectObject
+ call ClearSprites
+ xor a
+ ldh [hSCX], a
+ ldh [hSCY], a
+ scf
+ ret
+
+.UpdateStringEntry: ; 04:55EC
+; sets BGMapMode to 0, then loads a string and coords out of a buffer and displays it.
+; BGMapMode is then set to 1.
+ xor a
+ ldh [hBGMapMode], a
+ hlcoord 1, 3
+ lb bc, $05, $12
+ call ClearBox
+ ld hl, wNamingScreenDestinationPointer
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld hl, wNamingScreenStringEntryCoordY
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call PlaceString
+ ld a, $01
+ ldh [hBGMapMode], a
+ ret
+
+.RunJumpTable: ; 04:560C
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, $00
+ ld hl, .JumpTable
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+.JumpTable: ; 04:561B
+ dw .InitCursor
+ dw .ReadButtons
+
+.InitCursor: ; 04:561F
+ ld de, $5818
+ ld a, $39
+ call InitSpriteAnimStruct
+ ld a, c
+ ld [wNamingScreenCursorObjectPointer], a
+ ld a, b
+ ld [wNamingScreenCursorObjectPointer + 1], a
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+
+.ReadButtons: ; 04:5634
+; if A or B were pressed, clear hJoypadSum after calling functions; if start, set 7 in the jumptable??
+ ld hl, hJoypadSum
+ ld a, [hl]
+ and A_BUTTON
+ jr nz, .jumpa
+ ld a, [hl]
+ and B_BUTTON
+ jr nz, .jumpb
+ ld a, [hl]
+ and START
+ jr nz, .jumpstart
+ ret
+
+.jumpa ; 04:5647
+ call NamingScreenGetLastCharacter
+ cp NAMINGSCREEN_END
+ jr z, .jumpstart
+ call NamingScreenTryAddCharacter
+ xor a
+ ldh [hJoypadSum], a
+ ret
+
+.jumpb ; 04:5655
+ call NamingScreenDeleteCharacter
+ xor a
+ ldh [hJoypadSum], a
+ ret
+
+.jumpstart ; 04:565C
+ call NamingScreenStoreEntry
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+.GetDPad: ; 04:5665
+ ld hl, hJoySum
+ ld a, [hl]
+ and D_UP
+ jr nz, .upjump
+ ld a, [hl]
+ and D_DOWN
+ jr nz, .downjump
+ ld a, [hl]
+ and D_LEFT
+ jr nz, .leftjump
+ ld a, [hl]
+ and D_RIGHT
+ jr nz, .rightjump
+ ret
+
+.rightjump ; 04:567D
+ ld hl, $000C
+ add hl, bc
+ ld a, [hl]
+ cp $0E
+ jr nc, .skip1
+ inc [hl]
+ jr .escape
+
+.skip1
+ ld [hl], $00
+ jr .escape
+
+.leftjump
+ ld hl, $000C
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .skip2
+ dec [hl]
+ jr .escape
+.skip2
+ ld [hl], $0E
+ jr .escape
+
+.downjump
+ ld hl, $000D
+ add hl, bc
+ ld a, [hl]
+ cp $07
+ jr nc, .skip3
+ inc [hl]
+ jr .escape
+.skip3
+ ld [hl], $00
+ jr .escape
+
+.upjump ; 04:56AC :24
+ ld hl, $000D
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .skip4
+ dec [hl]
+ jr .escape
+.skip4
+ ld [hl], $07
+ jr .escape
+.escape
+ ld hl, $000C
+ add hl, bc
+ ld e, [hl]
+ ld d, $00
+ ld hl, LetterOffsetsTable1
+ add hl, de
+ ld a, [hl]
+ ld hl, $0006
+ add hl, bc
+ ld [hl], a
+ ld hl, $000D
+ add hl, bc
+ ld e, [hl]
+ ld d, $00
+ ld hl, LetterOffsetsTable2
+ add hl, de
+ ld a, [hl]
+ ld hl, $0007
+ add hl, bc
+ ld [hl], a
+ ret
+
+LetterOffsetsTable1: ; 04:56DE
+ db $00, $08, $10, $18, $20, $30, $38, $40, $48, $50, $60, $68, $70, $78, $80
+
+LetterOffsetsTable2:; 04:56ED
+ db $00, $08, $10, $18, $20, $28, $30, $38
+
+NamingScreenTryAddCharacter: ; 04:56F5
+ ld a, [wNamingScreenLastCharacter]
+ ld hl, Dakutens
+ cp "゙"
+ jr z, .jump
+ ld hl, Handakutens
+ cp "゚"
+ jr z, .jump
+ ld a, [wNamingScreenMaxNameLength]
+ ld c, a
+ ld a, [wNamingScreenCurNameLength]
+ cp c
+ ret nc
+ ld a, [wNamingScreenLastCharacter]
+ call NamingScreenGetTextCursorPosition
+ ld [hl], a
+ ld hl, wNamingScreenCurNameLength
+ inc [hl]
+ call NamingScreenGetTextCursorPosition
+ ld a, [hl]
+ cp "@"
+ ret z
+ ld [hl], NAMINGSCREEN_UNDERSCORE
+ ret
+
+.jump ; 04:5724
+ ld a, [wNamingScreenCurNameLength]
+ and a
+ ret z
+ push hl
+ ld hl, wNamingScreenCurNameLength
+ dec [hl]
+ call NamingScreenGetTextCursorPosition
+ ld c, [hl]
+ pop hl
+.loop
+ ld a, [hli]
+ cp $FF
+ jr z, .notherjump
+ cp c
+ jr z, .skip
+ inc hl
+ jr .loop
+.skip
+ ld a, [hl]
+ call NamingScreenGetTextCursorPosition
+ ld [hl], a
+.notherjump
+ ld hl, wNamingScreenCurNameLength
+ inc [hl]
+ ret
+
+Dakutens: ; 04:5748
+ db "かがきぎくぐけげこご"
+ db "さざしじすずせぜそぞ"
+ db "ただちぢつづてでとど"
+ db "はばひびふぶへべほぼ"
+ db "カガキギクグケゲコゴ"
+ db "サザシジスズセゼソゾ"
+ db "タダチヂツヅテデトド"
+ db "ハバヒビフブへべホボ"
+ db $FF
+
+Handakutens: ; 04:5799
+ db "はぱひぴふぷへぺほぽ"
+ db "ハパヒピフプへぺホポ"
+ db $FF
+
+NamingScreenDeleteCharacter: ; 04:57AE
+ ld hl, wNamingScreenCurNameLength
+ ld a, [hl]
+ and a
+ ret z
+ dec [hl]
+ call NamingScreenGetTextCursorPosition
+ ld [hl], NAMINGSCREEN_UNDERSCORE
+ inc hl
+ ld a, [hl]
+ cp NAMINGSCREEN_UNDERSCORE
+ ret nz
+ ld [hl], NAMINGSCREEN_HYPHEN
+ ret
+
+NamingScreenGetTextCursorPosition: ; 04:57C2
+ push af
+ ld hl, wNamingScreenDestinationPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wNamingScreenCurNameLength]
+ ld e, a
+ ld d, $00
+ add hl, de
+ pop af
+ ret
+
+NamingScreenInitNameEntry: ; 04:57D2
+ ld hl, wNamingScreenDestinationPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld [hl], NAMINGSCREEN_UNDERSCORE
+ inc hl
+ ld a, [wNamingScreenMaxNameLength]
+ dec a
+ ld c, a
+ ld a, NAMINGSCREEN_HYPHEN
+.loop
+ ld [hli], a
+ dec c
+ jr nz, .loop
+ ld [hl], "@"
+ ret
+
+NamingScreenStoreEntry: ; 04:57E9
+ ld hl, wNamingScreenDestinationPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wNamingScreenMaxNameLength]
+ ld c, a
+.loop
+ ld a, [hl]
+ cp NAMINGSCREEN_HYPHEN
+ jr z, .terminator
+ cp NAMINGSCREEN_UNDERSCORE
+ jr nz, .notterminator
+.terminator
+ ld [hl], "@"
+.notterminator
+ inc hl
+ dec c
+ jr nz, .loop
+ ret
+
+NamingScreenGetLastCharacter: ; 04:5803
+ ld hl, wNamingScreenCursorObjectPointer
+ ld c, [hl]
+ inc hl
+ ld b, [hl]
+ ld hl, $0006
+ add hl, bc
+ ld a, [hl]
+ ld hl, $0004
+ add hl, bc
+ add a, [hl]
+ sub $08
+ srl a
+ srl a
+ srl a
+ ld e, a
+ ld hl, $0007
+ add hl, bc
+ ld a, [hl]
+ ld hl, $0005
+ add hl, bc
+ add a, [hl]
+ sub $10
+ srl a
+ srl a
+ srl a
+ ld d, a
+ hlcoord 0, 0
+ ld bc, $0014
+.loop
+ ld a, d
+ and a
+ jr z, .done
+ add hl, bc
+ dec d
+ jr .loop
+
+.done
+ add hl, de
+ ld a, [hl]
+ ld [wNamingScreenLastCharacter], a
+ ret
+
+LoadNamingScreenGFX: ; 04:5843
+ call ClearSprites
+ callab InitEffectObject
+ call LoadFont
+
+ ld de, TextScreenGFX_End
+ ld hl, vChars1 tile $70
+ lb bc, BANK(TextScreenGFX_End), 1
+ call Get1bpp
+
+ ld de, TextScreenGFX_Hyphen
+ ld hl, vChars1 tile $6F
+ lb bc, BANK(TextScreenGFX_Hyphen), 1
+ call Get1bpp
+
+ ld de, TextScreenGFX_Underscore
+ ld hl, vChars1 tile $75
+ lb bc, BANK(TextScreenGFX_Underscore), 1
+ call Get1bpp
+
+ ld de, vChars2 tile $60
+ ld hl, TrainerCardGFX
+ ld bc, $10
+ ld a, BANK(TrainerCardGFX)
+ call FarCopyData
+
+ ld de, vChars0 tile $7f
+ ld hl, PokedexBorderGFX
+ ld bc, $10
+ ld a, BANK(PokedexBorderGFX)
+ call FarCopyData
+
+ ld a, $26
+ ld hl, wc41a
+ ld [hli], a
+ ld [hl], $7F
+ xor a
+ ldh [hSCY], a
+ ld [wc4c7], a
+ ldh [hSCX], a
+ ld [wc4c8], a
+ ld [wJumptableIndex], a
+ ldh [hBGMapMode], a
+ ld [wNamingScreenCurNameLength], a
+ ldh [hJoypadSum], a
+ ld a, $07
+ ldh [hWX], a
+ ret
+
+SECTION "engine/menu/text_entry.asm@mail", ROMX
+
+ComposeMailMessage: ; 04:59EB
+ ld hl, wNamingScreenDestinationPointer
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ ldh a, [hMapAnims]
+ push af
+ xor a
+ ldh [hMapAnims], a
+ ldh a, [hJoyDebounceSrc]
+ push af
+ ld a, 1
+ ldh [hJoyDebounceSrc], a
+ xor a
+ ld [wFlyDestination], a
+.outerloop
+ call .firstruncheck
+ call DelayFrame
+.innerloop
+ call DoMailEntry
+ jr nc, .innerloop
+
+ ld a, [wFlyDestination]
+ bit 7, a
+ jr nz, .outerloop
+
+ pop af
+ ldh [hJoyDebounceSrc], a
+ pop af
+ ldh [hMapAnims], a
+ ret
+
+.firstruncheck; 04:5A1B
+ ld hl, wFlyDestination
+ ld a, [hl]
+ and 1
+ ld [hl], a
+ jr z, .skip
+ call SetupMail
+ ret
+.skip
+ call .InitBlankMail
+ ret
+
+.InitBlankMail: ; 04:5A2C
+ call ClearBGPalettes
+ ld b, 8 ;diploma?
+ call GetSGBLayout
+ call DisableLCD
+ call LoadNamingScreenGFX
+ ld de, vChars0
+ ld hl, MailIconGFX
+ ld bc, $0080
+ ld a, BANK(MailIconGFX)
+ call FarCopyData
+ ld a, 8
+ ld hl, wTileMapBackup
+ ld [hli], a
+ ld [hl], 0
+ ld de, $2420
+ ld a, 8
+ call InitSpriteAnimStruct
+ ld hl, $0002
+ add hl, bc
+ ld [hl], 0
+ ld de, $5818
+ ld a, $39
+ call InitSpriteAnimStruct
+ ld a, c
+ ld [wNamingScreenCursorObjectPointer], a
+ ld a, b
+ ld [wNamingScreenCursorObjectPointer + 1], a
+ call InitCharSet
+ ld a, $E3
+ ldh [rLCDC], a
+ call InitMailText
+ call WaitBGMap
+ call WaitForAutoBgMapTransfer
+ ld a, $90
+ ldh [rBGP], a
+ ld a, $E4
+ ldh [rOBP0], a
+ call NamingScreenInitNameEntry
+ ld hl, wNamingScreenDestinationPointer
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld hl, $0010
+ add hl, de
+ ld [hl], "<NEXT>"
+ ret
+
+InitMailText: ; 04:5A96
+ hlcoord 5, 2
+ ld de, MailPromptText
+ call PlaceString
+ ld a, $21
+ ld [wNamingScreenMaxNameLength], a
+ ret
+
+MailPromptText: ; 04:5AA5
+ db "メールを かいてね@"
+
+InitCharSet: ; 04:5AAF
+ call WaitForAutoBgMapTransfer
+ ld hl, wTileMap
+ lb bc, $01, $68
+ ld a, $60
+ call ByteFill
+ hlcoord 1, 1
+ lb bc, $07, $12
+ call ClearBox
+ hlcoord 1, 9
+ lb bc, $08, $12
+ call ClearBox
+ hlcoord 2, 9
+ ld de, TextEntryChars
+ ld b, $8
+.outerloop
+ ld c, $11
+.innerloop
+ ld a, [de]
+ ld [hli], a
+ inc de
+ dec c
+ jr nz, .innerloop
+ inc hl
+ inc hl
+ inc hl
+ dec b
+ jr nz, .outerloop
+ ret
+
+DoMailEntry: ; 04:5AE6
+ call GetJoypadDebounced
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .exit_mail
+ ld a, [wFlyDestination]
+ bit 7, a
+ jr nz, .exit_mail
+ call .DoJumpTable
+ callba PlaySpriteAnimationsAndDelayFrame
+ call .Update
+ call DelayFrame
+ and a
+ ret
+
+.exit_mail ; 04:5B0A
+ callab InitEffectObject
+ call ClearSprites
+ xor a
+ ldh [hSCX], a
+ ldh [hSCY], a
+ scf
+ ret
+
+.Update: ; 04:5B1C
+ xor a
+ ldh [hBGMapMode], a
+ hlcoord 1, 3
+ lb bc, $04, $12
+ call ClearBox
+ ld hl, wNamingScreenDestinationPointer
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ hlcoord 2, 4
+ call PlaceString
+ ld a, 1
+ ldh [hBGMapMode], a
+ ret
+
+.DoJumpTable: ; 04:5B39
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, 0
+ ld hl, .Jumptable
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+.Jumptable: ; 04:5B48
+ dw .blinkcursor
+ dw .processjoypad
+
+.blinkcursor ; 04:5B4C
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+
+.processjoypad; 04:5B51
+ ld hl, hJoypadSum
+ ld a, [hl]
+ and A_BUTTON
+ jr nz, .ajump
+ ld a, [hl]
+ and B_BUTTON
+ jr nz, .bjump
+ ld a, [hl]
+ and START
+ jr nz, .startjump
+ ld a, [hl]
+ and SELECT
+ jr nz, .selectjump
+ ret
+
+.ajump ; 04:5B69
+ call NamingScreenGetLastCharacter
+ cp "円"
+ jr z, .startjump
+ call NamingScreenTryAddCharacter
+ xor a
+ ldh [hJoypadSum], a
+ ld hl, wNamingScreenCurNameLength
+ ld a, [hl]
+ cp $10 ; mail line length?
+ ret nz
+ inc [hl]
+ call NamingScreenGetTextCursorPosition
+ ld [hl], "♀"
+ dec hl
+ ld [hl], "<NEXT>"
+ ret
+.bjump
+ call NamingScreenDeleteCharacter
+ xor a
+ ldh [hJoypadSum], a
+ ld hl, wNamingScreenCurNameLength
+ ld a, [hl]
+ cp $10
+ ret nz
+ dec [hl]
+ call NamingScreenGetTextCursorPosition
+ ld [hl], "♀"
+ inc hl
+ ld [hl], "<NEXT>"
+ ret
+.startjump
+ call NamingScreenStoreEntry
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+.selectjump
+ ld hl, wFlyDestination
+ ld a, [hl]
+ xor 01
+ ld [hl], a
+ set 7, [hl]
+ ret
+
+SECTION "engine/menu/text_entry.asm@mail2", ROMX
+
+SetupMail: ; 04:5C31
+ call ClearBGPalettes
+ ld b, 8
+ call GetSGBLayout
+ call DisableLCD
+ call LoadNamingScreenGFX
+ ld de, vChars1
+ ld hl, BoldAlphabetGFX
+ lb bc, $02, $E0
+ ld a, BANK(BoldAlphabetGFX)
+ call FarCopyDataDouble
+ ld de, vChars0
+ ld hl, MailIconGFX
+ lb bc, $00, $80
+ ld a, BANK(MailIconGFX)
+ call FarCopyData
+ ld a, 8
+ ld hl, wTileMapBackup
+ ld [hli], a
+ ld [hl], 0
+ ld de, $2420
+ ld a, 8
+ call InitSpriteAnimStruct
+ ld hl, $0002
+ add hl, bc
+ ld [hl], 0
+ ld de, $6018
+ ld a, $40
+ call InitSpriteAnimStruct
+ ld a, c
+ ld [wNamingScreenCursorObjectPointer], a
+ ld a, b
+ ld [wNamingScreenCursorObjectPointer + 1], a
+ call DrawMail
+ ld a, $E3
+ ldh [rLCDC], a
+ call DrawMailLoadedText
+ call WaitBGMap
+ call WaitForAutoBgMapTransfer
+ ld a, $90
+ ldh [rBGP], a
+ ld a, $E4
+ ldh [rOBP0], a
+ call NamingScreenInitNameEntry
+ ld hl, wNamingScreenDestinationPointer
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld hl, $0010
+ add hl, de
+ ld [hl], "<NEXT>"
+ ret
+
+DrawMailLoadedText: ; 04:5CA9
+ hlcoord 5, 2
+ ld de, MailLoadedText
+ call PlaceString
+ ld a, $21
+ ld [wNamingScreenMaxNameLength], a
+ ret
+
+MailLoadedText: ; 04:5CB8
+ db "スアケシ!!!@" ; should be "MAIL!!!" since the bold english font is loaded into vChars1
+
+DrawMail: ; 04:5CC0
+ call WaitForAutoBgMapTransfer
+ hlcoord 0, 0
+ lb bc, $01, $68
+ ld a, "■"
+ call ByteFill
+ hlcoord 1, 1
+ lb bc, $07, $12
+ call ClearBox
+ hlcoord 1, 9
+ lb bc, $08, $12
+ call ClearBox
+ hlcoord 2, 10
+ ld a, $80
+ call DrawMailRow
+ hlcoord 2, 13
+ ld a, $A0
+ call DrawMailRow
+ hlcoord 2, 16
+ ld de, MailTextExtra
+ ld c, $10
+ call DrawMailTextExtra
+ ret
+
+DrawMailRow: ; 04:5CFC
+ ld c, $07
+ call .loop
+ inc hl
+ inc hl
+ ld c, $07
+ call .loop
+ inc hl
+ inc hl
+ inc hl
+ inc hl
+ ld c, $07
+ call .loop
+ inc hl
+ inc hl
+ ld c, $05
+
+.loop ; 04:5D15
+ ld [hli], a
+ inc a
+ dec c
+ jr nz, .loop
+ ret
+
+DrawMailTextExtra: ; 04:5D1B
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec c
+ jr nz, DrawMailTextExtra
+ ret
+
+MailTextExtra: ; 04:5D22
+ db "?!12345  67890ー円"
+ \ No newline at end of file
diff --git a/engine/unknown11d32.asm b/engine/unknown11d32.asm
new file mode 100644
index 0000000..d7e40d9
--- /dev/null
+++ b/engine/unknown11d32.asm
@@ -0,0 +1,92 @@
+INCLUDE "constants.asm"
+
+SECTION "engine/unknown11d32.asm", ROMX
+
+Unknown11d32: ; 04:5D32
+ ld hl, hJoySum
+ ld a, [hl]
+ and D_UP
+ jr nz, .upJump
+ ld a, [hl]
+ and D_DOWN
+ jr nz, .downJump
+ ld a, [hl]
+ and D_LEFT
+ jr nz, .leftJump
+ ld a, [hl]
+ and D_RIGHT
+ jr nz, .rightJump
+ ret
+
+.rightJump; 04:5D4A
+ ld hl, $000C
+ add hl, bc
+ ld a, [hl]
+ cp $0D
+ jr nc, .skip
+ inc [hl]
+ jr .escape
+.skip
+ ld [hl], 0
+ jr .escape
+.leftJump
+ ld hl, $000C
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .skip2
+ dec [hl]
+ jr .escape
+.skip2
+ ld [hl], $0D
+ jr .escape
+.downJump
+ ld hl, $000D
+ add hl, bc
+ ld a, [hl]
+ cp 4
+ jr nc, .skip3
+ inc [hl]
+ jr .escape
+.skip3
+ ld [hl], 00
+ jr .escape
+.upJump
+ ld hl, $000D
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .skip4
+ dec [hl]
+ jr .escape
+.skip4
+ ld [hl], 4
+ jr .escape
+.escape
+ ld hl, $000C
+ add hl, bc
+ ld e, [hl]
+ ld d, 0
+ ld hl, .Offsets1
+ add hl, de
+ ld a, [hl]
+ ld hl, $0006
+ add hl, bc
+ ld [hl], a
+ ld hl, $000D
+ add hl, bc
+ ld e, [hl]
+ ld d, 0
+ ld hl, .Offsets2
+ add hl, de
+ ld a, [hl]
+ ld hl, $0007
+ add hl, bc
+ ld [hl], a
+ ret
+
+.Offsets1: ; 04:5DAB
+ db $00, $08, $10, $18, $20, $28, $30, $48, $50, $58, $60, $68, $70, $78
+
+.Offsets2: ; 04:5DB9
+ db $00, $08, $18, $20, $30 \ No newline at end of file
diff --git a/engine/unknown_boxes.asm b/engine/unknown_boxes.asm
new file mode 100644
index 0000000..648d5cb
--- /dev/null
+++ b/engine/unknown_boxes.asm
@@ -0,0 +1,83 @@
+INCLUDE "constants.asm"
+
+SECTION "engine/unknown_boxes.asm", ROMX
+
+Function1130a: ; 04:530A
+ ret
+
+Function1130b: ; 04:530B
+ ld a, [wPartyCount]
+ cp PARTY_LENGTH
+ jr c, .bigjump
+ ld a, [wBoxListLength]
+ cp $1E
+ jr nc, .fullbox
+ xor a
+ ld [wca44], a
+ ld a, [wMonDexIndex]
+ ld [wcdd7], a
+ callab AddPokemonToBox
+ call RecievePokemon
+ predef Functiondd5c
+ and $7F
+ add a, $F7
+ ld hl, wStringBuffer2
+ ld [hli], a
+ ld [hl], "@"
+ ld hl, BoxCantHoldText
+ call PrintText
+ scf
+ ret
+.fullbox
+ ld hl, BoxFullText
+ call PrintText
+ and a
+ ret
+.bigjump
+ call RecievePokemon
+ predef Functiond886
+ scf
+ ret
+
+RecievePokemon: ; 04:5357
+ ld a, [wMonDexIndex]
+ push af
+ ld [wNamedObjectIndexBuffer], a
+ dec a
+ ld c, a
+ ld hl, wPokedexOwned
+ ld b, 01 ;SET_FLAG
+ predef SmallFarFlagAction
+ pop af
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld hl, RecievePokemonText
+ jp PrintText
+
+RecievePokemonText: ; 04:5377
+ text "<PLAYER>は"
+ line "@"
+
+ db $01, $26, $CD
+
+ text "を てにいれた!@"
+
+ db $0B, "@"
+
+BoxCantHoldText: ; 04:538B
+ text "#を もちきれないので"
+ line "<PC>の ボックス@"
+ db $01, $31, $CD
+ text " に"
+ cont "@"
+ db $01, $17, $DF
+ text "を てんそうした!"
+ done
+
+BoxFullText: ; 04:53B6
+ text "#を もちきれません!"
+ para "ボックスも いっぱいで"
+ line "てんそうできません!"
+ para "#センターなどで"
+ line "ボックスを かえてきて ください"
+ done \ No newline at end of file
diff --git a/gfx.asm b/gfx.asm
index b6135ff..24d39b7 100644
--- a/gfx.asm
+++ b/gfx.asm
@@ -80,6 +80,14 @@ TitleScreenLogoGFX:: INCBIN "gfx/title/title_logo.2bpp"
TitleScreenGoldLogoGFX:: INCBIN "gfx/title/title_silverlogo.2bpp"
endc
+SECTION "gfx.asm@Name Entry Extra Tiles", ROMX
+TextScreenGFX_End::
+INCBIN "gfx/font/text_entry_end.1bpp"
+TextScreenGFX_Hyphen::
+INCBIN "gfx/font/text_entry_hyphen.1bpp"
+TextScreenGFX_Underscore::
+INCBIN "gfx/font/text_entry_underscore.1bpp"
+
SECTION "gfx.asm@Mail Icon GFX", ROMX
MailIconGFX::
INCBIN "gfx/icons/mail.2bpp"
@@ -195,8 +203,10 @@ PokedexButtonsGFX::
INCBIN "gfx/pokedex/buttons.2bpp"
PokedexPokeBallGFX::
INCBIN "gfx/pokedex/poke_ball.2bpp"
-PokedexCursorsGFX::
-INCBIN "gfx/pokedex/cursors.2bpp"
+PokedexCursorGFX::
+INCBIN "gfx/pokedex/cursor.2bpp"
+PokedexBorderGFX::
+INCBIN "gfx/pokedex/border.2bpp"
PokedexSearchGFX::
INCBIN "gfx/pokedex/search.2bpp"
diff --git a/gfx/font/text_entry_end.1bpp.png b/gfx/font/text_entry_end.1bpp.png
new file mode 100644
index 0000000..e7f113a
--- /dev/null
+++ b/gfx/font/text_entry_end.1bpp.png
Binary files differ
diff --git a/gfx/font/text_entry_hyphen.1bpp.png b/gfx/font/text_entry_hyphen.1bpp.png
new file mode 100644
index 0000000..1e3122b
--- /dev/null
+++ b/gfx/font/text_entry_hyphen.1bpp.png
Binary files differ
diff --git a/gfx/font/text_entry_underscore.1bpp.png b/gfx/font/text_entry_underscore.1bpp.png
new file mode 100644
index 0000000..57ac286
--- /dev/null
+++ b/gfx/font/text_entry_underscore.1bpp.png
Binary files differ
diff --git a/gfx/pokedex/border.png b/gfx/pokedex/border.png
new file mode 100644
index 0000000..29fd92a
--- /dev/null
+++ b/gfx/pokedex/border.png
Binary files differ
diff --git a/gfx/pokedex/cursor.png b/gfx/pokedex/cursor.png
new file mode 100644
index 0000000..0cff55f
--- /dev/null
+++ b/gfx/pokedex/cursor.png
Binary files differ
diff --git a/gfx/pokedex/cursors.png b/gfx/pokedex/cursors.png
deleted file mode 100644
index 265a41f..0000000
--- a/gfx/pokedex/cursors.png
+++ /dev/null
Binary files differ
diff --git a/macros.asm b/macros.asm
index c18995a..3c59d83 100644
--- a/macros.asm
+++ b/macros.asm
@@ -11,4 +11,4 @@ INCLUDE "macros/wram.asm"
INCLUDE "macros/audio.asm"
INCLUDE "macros/scripts.asm"
INCLUDE "macros/queue.asm"
-INCLUDE "macros/maps.asm"
+INCLUDE "macros/maps.asm" \ No newline at end of file
diff --git a/pokegold-spaceworld.link b/pokegold-spaceworld.link
index 2628575..3abbc3c 100644
--- a/pokegold-spaceworld.link
+++ b/pokegold-spaceworld.link
@@ -166,15 +166,22 @@ ROMX $03
ROMX $04
org $4000
"data/maps/maps.asm"
+ ; $4743
org $47cf
"gfx.asm@Title Screen GFX"
- org $52d1
+ "engine/items/tmhm.asm"
"data/moves/tmhm_moves.asm"
- org $5bb1
+ "engine/unknown_boxes.asm"
+ "engine/menu/text_entry.asm@naming"
+ "data/text/text_input_chars.asm"
+ "gfx.asm@Name Entry Extra Tiles"
+ "engine/menu/text_entry.asm@mail"
"gfx.asm@Mail Icon GFX"
- ; $5c31
- org $7171
+ "engine/menu/text_entry.asm@mail2"
+ "engine/unknown11d32.asm"
+ "engine/menu/start_menu.asm"
"gfx.asm@Trainer Card GFX"
+ ; $7be3
ROMX $05
org $4000
"engine/overworld/player_movement.asm@_RedrawPlayerSprite"
diff --git a/shim.sym b/shim.sym
index 612195b..6e7f115 100755
--- a/shim.sym
+++ b/shim.sym
@@ -1,13 +1,5 @@
04:4743 ShrinkPic1
04:479D ShrinkPic2
-04:528F Function1128f
-04:52C1 Function112c1
-04:530A Function1130a
-04:53F4 Function113f4
-04:5677 DoPlayerMovement
-04:5DBE DisplayStartMenu
-04:640B Function1240b
-04:6C58 CheckRegisteredItem
05:4036 RefreshSprites
05:404C CheckInteriorMap
@@ -44,13 +36,22 @@
09:412C _ExitMenu
09:4185 Function24185
09:4199 _InitVerticalMenuCursor
+09:41EF Function241ef
09:426A _InitScrollingMenu
09:4287 _ScrollingMenu
+09:43AF Function243af
+09:45C5 Function245c5
+09:473B Function2473b
+09:4774 Function24774
+09:4783 Function24783
+09:4955 Function24955
+09:4C60 Function24c60
0A:4C98 LinkTextboxAtHL
0A:4D6E Function28d6e
0A:4DA4 Function28da4
+0B:52FC Function2d2fc
0B:5663 Function2d663
0E:4B78 LoadTrainerClassName
@@ -85,6 +86,7 @@
10:4B07 Function40b07
10:4B45 Function40b45
10:4B5C Function40b5c
+10:58B8 Data4a8b8
10:58BB Moves
10:5F93 Function4af93
10:5FA1 Function41fa1
@@ -97,10 +99,11 @@
14:40C6 Function500c6
14:4244 Function50244
14:4248 Function50248
-14:42B5 Function502b5
+14:42B5 Function502b5 ; Pokemon Summary routine?
14:4628 Function50628
14:469E Function5069e
14:46D4 Function506d4
+14:4756 Function50756
14:4771 Function50771
14:4774 Function50774
14:481F Function5081f
@@ -127,7 +130,10 @@
23:4d13 EffectObjectJumpNoDelay
23:4d52 _InitSpriteAnimStruct
23:60cc MenuMonIconGfx
+23:70CC Function8f0cc
+23:70E3 Function8f0e3
23:71CB Function_8f1cb
+23:71F2 Function8f1f2
24:4000 SetClockDialog
24:4239 SlotMachineGame
@@ -161,6 +167,7 @@
3A:52C7 Music
3F:40E9 InGameDebugMenu
+3F:4305 PokeGear
3F:4C24 Functionfcc24
3F:4E3E Functionfce3e
3F:5B66 Functionfdb66
diff --git a/wram.asm b/wram.asm
index e976452..1a0990c 100644
--- a/wram.asm
+++ b/wram.asm
@@ -106,11 +106,31 @@ wc40c:: ds 1 ; c40c
wc40d:: ds 1 ; c40d
wc40e:: ds 1 ; c40e
- ds 177
+ ds 11
+
+wc41a:: db ; c41a
+
+ ds 165
wSpriteAnimIDBuffer:: db ; c4c0
- ds 89
+ ds 6
+
+wc4c7:: db ; c4c7
+wc4c8:: db ; c4c8
+
+ ds 7
+
+wNamingScreenDestinationPointer:: dw ; c4d0
+wNamingScreenCurNameLength:: db ; c4d2
+wNamingScreenMaxNameLength:: db ; c4d3
+wNamingScreenType:: db ; c4d4
+wNamingScreenCursorObjectPointer:: dw ; c4d5
+wNamingScreenLastCharacter:: db ; c4d7
+wNamingScreenStringEntryCoordY:: db ; c4d8
+wNamingScreenStringEntryCoordX:: db ; c4d9
+
+ ds 64
wc51a:: ds 1 ; c51a
@@ -545,7 +565,7 @@ wRegularItemsScrollPosition:: db ; cd44
wBackpackAndKeyItemsScrollPosition:: db ; cd45
wcd46:: ds 1 ; cd46
wcd47:: ds 1 ; cd47
-wcd48:: ds 1 ; cd48
+wSelectedSwapPosition:: db ; cd48
wMenuScrollPosition:: db ; cd49
wTextDest:: ds 2; cd4a
@@ -595,6 +615,8 @@ wcd7c:: ds 1 ; cd7c
wItemQuantity:: db ; cd7d
wItemQuantityBuffer:: db ; cd7e
wcd7f:: db ; cd7f
+wcd80:: db ; cd80
+wcd81:: db ; cd81
SECTION "CD9E", WRAM0 [$CD9E]
wcd9e:: db ; cd9e
@@ -940,7 +962,9 @@ wBallQuantities:: db ; d1df
wUnknownListLengthd1ea:: db ; d1ea
wUnknownListd1eb:: db ; d1eb
-SECTION "Rival's Name", WRAM0[$D258]
+SECTION "Rival's Name", WRAM0[$D256]
+wRegisteredItem:: db ; d256
+wRegisteredItemQuantity:: db ; d257
wRivalName:: ds 6 ; d258
ds 6
@@ -971,8 +995,16 @@ wd39d:: db
SECTION "Game Event Flags", WRAM0[$D41A]
wd41a:: db
+; 76543210
+; | \- read email?
+; \-------- talked to Blue, triggers Oak
wd41b:: db
+; 76543210
+; |\-- followed Oak to his back room
+; \--- chose a starter
wd41c:: db
+; 76543210
+; \----- recieved pokedexes
wd41d:: db
wd41e:: db
@@ -1112,8 +1144,8 @@ wTilesetCollisionAddress:: ; d6a4
wTilesetEnd:: ; d6aa
wPartyCount:: db
-wPartySpecies:: ds PARTY_LENGTH
-wPartyEnd:: db
+wPartySpecies:: ds PARTY_LENGTH ; d6ab - d6b0
+wPartyEnd:: db ; d6b1
wPartyMons::
wPartyMon1:: party_struct wPartyMon1 ; d6b2
@@ -1224,8 +1256,8 @@ wda5f:: db ; da5f
SECTION "DA83", WRAM0[$DA83]
-wUnknownListLengthda83:: db ; da83
-wUnknownListda84:: db ; da84
+wBoxListLength:: db ; da83
+wBoxList:: ds $1E ; da84
SECTION "DAA3", WRAM0[$DAA3]