shithub: pokecrystal

Download patch

ref: 8a6a1a7d77fdcd1f8468f0c411795a8f039d4bd8
parent: 91f749101724a17398363745d8ac95cd4feeb1c1
author: PikalaxALT <[email protected]>
date: Wed Nov 18 18:16:25 EST 2015

CmdQueues

--- a/battle/core.asm
+++ b/battle/core.asm
@@ -2997,10 +2997,10 @@
 Function3d2f7: ; 3d2f7
 	call ClearBGPalettes
 Function3d2fa: ; switch to fullscreen menu?
-	callba Function5004f
-	callba Function50405
+	callba LoadPartyMenuGFX
+	callba InitPartyMenuWithCancel
 	callba Function8e85
-	callba Function503e0
+	callba InitPartyMenuGFX
 	ret
 ; 3d313
 
@@ -5719,7 +5719,7 @@
 
 .asm_3e58e
 	call MoveInfoBox
-	ld a, [wd0e3]
+	ld a, [wSwitchMon]
 	and a
 	jr z, .asm_3e5a3
 	hlcoord 5, 13
@@ -5742,7 +5742,7 @@
 	push af
 
 	xor a
-	ld [wd0e3], a
+	ld [wSwitchMon], a
 	ld a, [MenuSelection2]
 	dec a
 	ld [MenuSelection2], a
@@ -5838,7 +5838,7 @@
 ; 3e643
 
 .asm_3e643 ; 3e643
-	ld a, [wd0e3]
+	ld a, [wSwitchMon]
 	and a
 	jr z, .asm_3e6bf
 	ld hl, BattleMonMoves
@@ -5856,7 +5856,7 @@
 	ld a, [hl]
 	and $f
 	ld b, a
-	ld a, [wd0e3]
+	ld a, [wSwitchMon]
 	swap a
 	add b
 	ld [hl], a
@@ -5863,7 +5863,7 @@
 	jr .asm_3e682
 
 .asm_3e671
-	ld a, [wd0e3]
+	ld a, [wSwitchMon]
 	cp b
 	jr nz, .asm_3e682
 	ld a, [hl]
@@ -5890,12 +5890,12 @@
 
 .asm_3e69e
 	xor a
-	ld [wd0e3], a
+	ld [wSwitchMon], a
 	jp MoveSelectionScreen
 
 .asm_3e6a5
 	push hl
-	ld a, [wd0e3]
+	ld a, [wSwitchMon]
 	dec a
 	ld c, a
 	ld b, 0
@@ -5917,7 +5917,7 @@
 
 .asm_3e6bf
 	ld a, [MenuSelection2]
-	ld [wd0e3], a
+	ld [wSwitchMon], a
 	jp MoveSelectionScreen
 ; 3e6c8
 
--- a/constants/map_constants.asm
+++ b/constants/map_constants.asm
@@ -698,3 +698,11 @@
 	const FRUITTREE_PEWTER_CITY_1
 	const FRUITTREE_PEWTER_CITY_2
 	const FRUITTREE_FUCHSIA_CITY
+
+CMDQUEUE_TYPE  EQU 0
+CMDQUEUE_ADDR  EQU 1
+CMDQUEUE_03    EQU 3
+CMDQUEUE_04    EQU 4
+CMDQUEUE_05    EQU 5
+CMDQUEUE_ENTRY_SIZE EQU 6
+CMDQUEUE_CAPACITY EQU 4
--- a/engine/events.asm
+++ b/engine/events.asm
@@ -168,7 +168,7 @@
 HandleMap: ; 96773
 	call ResetOverworldDelay
 	call Function967c1
-	callba Function97e08
+	callba HandleCmdQueue ; no need to farcall
 	call MapEvents
 
 ; Not immediately entering a connected map will cause problems.
--- a/engine/events_2.asm
+++ b/engine/events_2.asm
@@ -335,8 +335,8 @@
 	ret
 ; 97df9
 
-Function97df9:: ; 97df9
-	ld hl, wd6de
+ClearCmdQueue:: ; 97df9
+	ld hl, wCmdQueue
 	ld de, 6
 	ld c, 4
 	xor a
@@ -348,8 +348,8 @@
 	ret
 ; 97e08
 
-Function97e08:: ; 97e08
-	ld hl, wd6de
+HandleCmdQueue:: ; 97e08
+	ld hl, wCmdQueue
 	xor a
 .loop
 	ld [hMapObjectIndexBuffer], a
@@ -359,22 +359,22 @@
 	push hl
 	ld b, h
 	ld c, l
-	call Function97e79
+	call HandleQueuedCommand
 	pop hl
 
 .skip
-	ld de, $0006
+	ld de, CMDQUEUE_ENTRY_SIZE
 	add hl, de
 	ld a, [hMapObjectIndexBuffer]
 	inc a
-	cp $4
+	cp CMDQUEUE_CAPACITY
 	jr nz, .loop
 	ret
 ; 97e25
 
-Function97e25: ; 97e25
-	ld hl, wd6de
-	ld bc, 6
+GetNthCmdQueueEntry: ; 97e25 unreferenced
+	ld hl, wCmdQueue
+	ld bc, CMDQUEUE_ENTRY_SIZE
 	call AddNTimes
 	ld b, h
 	ld c, l
@@ -381,10 +381,10 @@
 	ret
 ; 97e31
 
-Function97e31:: ; 97e31
+WriteCmdQueue:: ; 97e31
 	push bc
 	push de
-	call Function97e45
+	call .GetNextEmptyEntry
 	ld d, h
 	ld e, l
 	pop hl
@@ -391,7 +391,7 @@
 	pop bc
 	ret c
 	ld a, b
-	ld bc, $0005
+	ld bc, CMDQUEUE_ENTRY_SIZE - 1
 	call FarCopyBytes
 	xor a
 	ld [hl], a
@@ -398,42 +398,42 @@
 	ret
 ; 97e45
 
-Function97e45: ; 97e45
-	ld hl, wd6de
-	ld de, $0006
-	ld c, $4
-.asm_97e4d
+.GetNextEmptyEntry: ; 97e45
+	ld hl, wCmdQueue
+	ld de, CMDQUEUE_ENTRY_SIZE
+	ld c, CMDQUEUE_CAPACITY
+.loop
 	ld a, [hl]
 	and a
-	jr z, .asm_97e57
+	jr z, .done
 	add hl, de
 	dec c
-	jr nz, .asm_97e4d
+	jr nz, .loop
 	scf
 	ret
 
-.asm_97e57
-	ld a, $4
+.done
+	ld a, CMDQUEUE_CAPACITY
 	sub c
 	and a
 	ret
 ; 97e5c
 
-Function97e5c:: ; 97e5c
-	ld hl, wd6de
-	ld de, $0006
-	ld c, $4
-.asm_97e64
+DelCmdQueue:: ; 97e5c
+	ld hl, wCmdQueue
+	ld de, CMDQUEUE_ENTRY_SIZE
+	ld c, CMDQUEUE_CAPACITY
+.loop
 	ld a, [hl]
 	cp b
-	jr z, .asm_97e6e
+	jr z, .done
 	add hl, de
 	dec c
-	jr nz, .asm_97e64
+	jr nz, .loop
 	and a
 	ret
 
-.asm_97e6e
+.done
 	xor a
 	ld [hl], a
 	scf
@@ -440,25 +440,25 @@
 	ret
 ; 97e72
 
-Function97e72: ; 97e72
-	ld hl, 0
+_DelCmdQueue: ; 97e72
+	ld hl, CMDQUEUE_TYPE
 	add hl, bc
 	ld [hl], 0
 	ret
 ; 97e79
 
-Function97e79: ; 97e79
-	ld hl, 0
+HandleQueuedCommand: ; 97e79
+	ld hl, CMDQUEUE_TYPE
 	add hl, bc
 	ld a, [hl]
 	cp 5
-	jr c, .asm_97e83
+	jr c, .okay
 	xor a
 
-.asm_97e83
+.okay
 	ld e, a
 	ld d, 0
-	ld hl, Table97e94
+	ld hl, .Jumptable_ba
 rept 3
 	add hl, de
 endr
@@ -472,16 +472,16 @@
 	ret
 ; 97e94
 
-Table97e94: ; 97e94
-	dba Function97eb7
-	dba Function97eb8
-	dba Function97f42
-	dba Function97ef9
-	dba Function97ebc
+.Jumptable_ba: ; 97e94
+	dba CmdQueue_Null
+	dba CmdQueue_Null2
+	dba CmdQueue_StoneTable
+	dba CmdQueue_Type3
+	dba CmdQueue_Type4
 ; 97ea3
 
-Function97ea3: ; 97ea3
-	ld hl, $0005
+CmdQueueAnonymousJumptable: ; 97ea3
+	ld hl, CMDQUEUE_05
 	add hl, bc
 	ld a, [hl]
 	pop hl
@@ -489,45 +489,44 @@
 	ret
 ; 97eab
 
-Function97eab: ; 97eab
-	ld hl, $0005
+CmdQueueAnonJT_Increment: ; 97eab
+	ld hl, CMDQUEUE_05
 	add hl, bc
 	inc [hl]
 	ret
 ; 97eb1
 
-Function97eb1: ; 97eb1
-	ld hl, $0005
+CmdQueueAnonJT_Decrement: ; 97eb1
+	ld hl, CMDQUEUE_05
 	add hl, bc
 	dec [hl]
 	ret
 ; 97eb7
 
-Function97eb7: ; 97eb7
+CmdQueue_Null: ; 97eb7
 	ret
 ; 97eb8
 
-Function97eb8: ; 97eb8
+CmdQueue_Null2: ; 97eb8
 	call ret_2f3e
 	ret
 ; 97ebc
 
-Function97ebc: ; 97ebc
-	call Function97ea3
-	dw Function97ec3
-	dw Function97ecd
+CmdQueue_Type4: ; 97ebc
+	call CmdQueueAnonymousJumptable
+	; anonymous jumptable
+	dw .zero
+	dw .one
 ; 97ec3
 
-Function97ec3: ; 97ec3
+.zero: ; 97ec3
 	ld a, [hSCY]
-	ld hl, $0004
+	ld hl, 4
 	add hl, bc
 	ld [hl], a
-	call Function97eab
-; 97ecd
-
-Function97ecd: ; 97ecd
-	ld hl, $0001
+	call CmdQueueAnonJT_Increment
+.one: ; 97ecd
+	ld hl, 1
 	add hl, bc
 	ld a, [hl]
 	dec a
@@ -535,7 +534,7 @@
 	jr z, .asm_97eee
 	and $1
 	jr z, .asm_97ee4
-	ld hl, $0002
+	ld hl, 2
 	add hl, bc
 	ld a, [hSCY]
 	sub [hl]
@@ -543,7 +542,7 @@
 	ret
 
 .asm_97ee4
-	ld hl, $0002
+	ld hl, 2
 	add hl, bc
 	ld a, [hSCY]
 	add [hl]
@@ -551,33 +550,32 @@
 	ret
 
 .asm_97eee
-	ld hl, $0004
+	ld hl, 4
 	add hl, bc
 	ld a, [hl]
 	ld [hSCY], a
-	call Function97e72
+	call _DelCmdQueue
 	ret
 ; 97ef9
 
-Function97ef9: ; 97ef9
-	call Function97ea3
-	dw Function97f02
-	dw Function97f0a
-	dw Function97f1b
+CmdQueue_Type3: ; 97ef9
+	call CmdQueueAnonymousJumptable
+	; anonymous jumptable
+	dw .zero
+	dw .one
+	dw .two
 ; 97f02
 
-Function97f02: ; 97f02
-	call Function97f38
-	jr z, Function97f2c
-	call Function97eab
-; 97f0a
+.zero: ; 97f02
+	call .IsPlayerFacingDown
+	jr z, .PlayerNotFacingDown
+	call CmdQueueAnonJT_Increment
+.one: ; 97f0a
+	call .IsPlayerFacingDown
+	jr z, .PlayerNotFacingDown
+	call CmdQueueAnonJT_Increment
 
-Function97f0a: ; 97f0a
-	call Function97f38
-	jr z, Function97f2c
-	call Function97eab
-
-	ld hl, $0002
+	ld hl, 2
 	add hl, bc
 	ld a, [hl]
 	ld [wd173], a
@@ -584,12 +582,12 @@
 	ret
 ; 97f1b
 
-Function97f1b: ; 97f1b
-	call Function97f38
-	jr z, Function97f2c
-	call Function97eb1
+.two: ; 97f1b
+	call .IsPlayerFacingDown
+	jr z, .PlayerNotFacingDown
+	call CmdQueueAnonJT_Decrement
 
-	ld hl, $0003
+	ld hl, 3
 	add hl, bc
 	ld a, [hl]
 	ld [wd173], a
@@ -596,16 +594,16 @@
 	ret
 ; 97f2c
 
-Function97f2c: ; 97f2c
+.PlayerNotFacingDown: ; 97f2c
 	ld a, $7f
 	ld [wd173], a
-	ld hl, $0005
+	ld hl, 5
 	add hl, bc
 	ld [hl], 0
 	ret
 ; 97f38
 
-Function97f38: ; 97f38
+.IsPlayerFacingDown: ; 97f38
 	push bc
 	ld bc, PlayerStruct
 	call GetSpriteDirection
@@ -614,40 +612,40 @@
 	ret
 ; 97f42
 
-Function97f42: ; 97f42
+CmdQueue_StoneTable: ; 97f42
 	ld de, PlayerStruct
-	ld a, $d
-.asm_97f47
+	ld a, NUM_OBJECT_STRUCTS
+.loop
 	push af
 
-	ld hl, 0
+	ld hl, OBJECT_SPRITE
 	add hl, de
 	ld a, [hl]
 	and a
-	jr z, .asm_97f71
+	jr z, .next
 
-	ld hl, $0003
+	ld hl, OBJECT_MOVEMENTTYPE
 	add hl, de
 	ld a, [hl]
-	cp $19
-	jr nz, .asm_97f71
+	cp STEP_TYPE_19
+	jr nz, .next
 
-	ld hl, $000e
+	ld hl, OBJECT_NEXT_TILE
 	add hl, de
 	ld a, [hl]
 	call CheckPitTile
-	jr nz, .asm_97f71
+	jr nz, .next
 
-	ld hl, $0007
+	ld hl, OBJECT_DIRECTION_WALKING
 	add hl, de
 	ld a, [hl]
-	cp $ff
-	jr nz, .asm_97f71
-	call Function3567
-	jr c, .asm_97f7c
+	cp STANDING
+	jr nz, .next
+	call HandleStoneQueue
+	jr c, .fall_down_hole
 
-.asm_97f71
-	ld hl, $0028
+.next
+	ld hl, OBJECT_STRUCT_LENGTH
 	add hl, de
 	ld d, h
 	ld e, l
@@ -654,10 +652,10 @@
 
 	pop af
 	dec a
-	jr nz, .asm_97f47
+	jr nz, .loop
 	ret
 
-.asm_97f7c
+.fall_down_hole
 	pop af
 	ret
 ; 97f7e
--- a/engine/mail.asm
+++ b/engine/mail.asm
@@ -503,9 +503,9 @@
 	ld [PartyMenuActionText], a
 	call ClearBGPalettes
 .try_again
-	callba Function5004f
-	callba Function50405
-	callba Function503e0
+	callba LoadPartyMenuGFX
+	callba InitPartyMenuWithCancel
+	callba InitPartyMenuGFX
 	callba WritePartyMenuTilemap
 	callba PrintPartyMenuText
 	call WaitBGMap
--- a/engine/pack.asm
+++ b/engine/pack.asm
@@ -595,9 +595,9 @@
 	ld a, $8
 	ld [PartyMenuActionText], a
 	call ClearBGPalettes
-	callba Function5004f
-	callba Function50405
-	callba Function503e0
+	callba LoadPartyMenuGFX
+	callba InitPartyMenuWithCancel
+	callba InitPartyMenuGFX
 .asm_10427
 	callba WritePartyMenuTilemap
 	callba PrintPartyMenuText
--- a/engine/party_menu.asm
+++ b/engine/party_menu.asm
@@ -30,15 +30,15 @@
 ; 5003f
 
 Function5003f: ; 5003f
-	call Function5004f
-	call Function50405
-	call Function503e0
+	call LoadPartyMenuGFX
+	call InitPartyMenuWithCancel
+	call InitPartyMenuGFX
 	call WritePartyMenuTilemap
 	call PrintPartyMenuText
 	ret
 ; 5004f
 
-Function5004f: ; 5004f
+LoadPartyMenuGFX: ; 5004f
 	call LoadFontsBattleExtra
 	callab Function8ad1 ; engine/color.asm
 	callab InefficientlyClear121BytesAtwc300
@@ -648,7 +648,7 @@
 ; 503e0
 
 
-Function503e0: ; 503e0
+InitPartyMenuGFX: ; 503e0
 	ld hl, PartyCount
 	ld a, [hli]
 	and a
@@ -656,7 +656,7 @@
 	ld c, a
 	xor a
 	ld [hObjectStructIndexBuffer], a
-.asm_503ea
+.loop
 	push bc
 	push hl
 	ld hl, Function8e83f
@@ -669,60 +669,62 @@
 	pop hl
 	pop bc
 	dec c
-	jr nz, .asm_503ea
+	jr nz, .loop
 	callab Function8cf69
 	ret
 ; 50405
 
-Function50405: ; 50405
+InitPartyMenuWithCancel: ; 50405
+; with cancel
 	xor a
-	ld [wd0e3], a
-	ld de, Unknown_5044f
-	call Function1bb1
+	ld [wSwitchMon], a
+	ld de, PartyMenuAttributes
+	call InitMenu3
 	ld a, [PartyCount]
 	inc a
-	ld [wcfa3], a
+	ld [wcfa3], a ; list length
 	dec a
 	ld b, a
-	ld a, [wd0d8]
+	ld a, [wPartyMenuCursor]
 	and a
-	jr z, .asm_50422
+	jr z, .skip
 	inc b
 	cp b
-	jr c, .asm_50424
+	jr c, .done
 
-.asm_50422
+.skip
 	ld a, $1
 
-.asm_50424
+.done
 	ld [MenuSelection2], a
-	ld a, $3
+	ld a, A_BUTTON | B_BUTTON
 	ld [wcfa8], a
 	ret
 ; 5042d
 
-Function5042d: ; 0x5042d
-	ld de, Unknown_5044f
-	call Function1bb1
+InitPartyMenuNoCancel: ; 0x5042d
+; no cancel
+	ld de, PartyMenuAttributes
+	call InitMenu3
 	ld a, [PartyCount]
-	ld [wcfa3], a
+	ld [wcfa3], a ; list length
 	ld b, a
-	ld a, [wd0d8]
+	ld a, [wPartyMenuCursor]
 	and a
-	jr z, .asm_50444
+	jr z, .skip
 	inc b
 	cp b
-	jr c, .asm_50446
-.asm_50444
+	jr c, .done
+.skip
 	ld a, $1
-.asm_50446
+.done
 	ld [MenuSelection2], a
-	ld a, $3
+	ld a, A_BUTTON | B_BUTTON
 	ld [wcfa8], a
 	ret
 ; 5044f (14:444f)
 
-Unknown_5044f: ; 5044f
+PartyMenuAttributes: ; 5044f
 ; cursor y
 ; cursor x
 ; list length
@@ -744,7 +746,7 @@
 	ld a, [MenuSelection2] ; menu selection?
 	cp b
 	jr z, .exitmenu ; CANCEL
-	ld [wd0d8], a
+	ld [wPartyMenuCursor], a
 	ld a, [hJoyLast]
 	ld b, a
 	bit 1, b
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -2153,7 +2153,7 @@
 Script_itemtotext: ; 976d5
 ; script command 0x41
 ; parameters:
-;     item (ItemLabelByte)
+;     item (ItemLabelByte); use 0 to draw from ScriptVar
 ;     memory (SingleByteParam)
 
 	call GetScriptByte
@@ -2923,7 +2923,7 @@
 	ld d, a
 	ld a, [ScriptBank]
 	ld b, a
-	callba Function97e31
+	callba WriteCmdQueue ; no need to farcall
 	ret
 ; 97a9e
 
@@ -2936,7 +2936,7 @@
 	ld [ScriptVar], a
 	call GetScriptByte
 	ld b, a
-	callba Function97e5c
+	callba DelCmdQueue ; no need to farcall
 	ret c
 	ld a, 1
 	ld [ScriptVar], a
--- a/engine/startmenu.asm
+++ b/engine/startmenu.asm
@@ -533,9 +533,9 @@
 	call ClearBGPalettes
 
 .menu
-	callba Function5004f
-	callba Function50405
-	callba Function503e0
+	callba LoadPartyMenuGFX
+	callba InitPartyMenuWithCancel
+	callba InitPartyMenuGFX
 
 .menunoreload
 	callba WritePartyMenuTilemap
@@ -684,7 +684,7 @@
 
 
 CancelPokemonAction: ; 12a79
-	callba Function50405
+	callba InitPartyMenuWithCancel
 	callba Function8ea71
 	ld a, 1
 	ret
@@ -746,10 +746,10 @@
 
 	ld a, [CurPartyMon]
 	inc a
-	ld [wd0e3], a
+	ld [wSwitchMon], a
 
 	callba Function8ea8c
-	callba Function5042d
+	callba InitPartyMenuNoCancel
 
 	ld a, 4
 	ld [PartyMenuActionText], a
@@ -758,7 +758,7 @@
 
 	hlcoord 0, 1
 	ld bc, 20 * 2
-	ld a, [wd0e3]
+	ld a, [wSwitchMon]
 	dec a
 	call AddNTimes
 	ld [hl], "▷"
@@ -775,9 +775,9 @@
 	xor a
 	ld [PartyMenuActionText], a
 
-	callba Function5004f
-	callba Function50405
-	callba Function503e0
+	callba LoadPartyMenuGFX
+	callba InitPartyMenuWithCancel
+	callba InitPartyMenuGFX
 
 	ld a, 1
 	ret
@@ -1476,7 +1476,7 @@
 Function12f73: ; 12f73
 	call SetUpMoveScreenBG
 	ld de, Unknown_12fb2
-	call Function1bb1
+	call InitMenu3
 	call Function131ef
 	ld hl, wcfa5
 	set 6, [hl]
@@ -1505,7 +1505,7 @@
 Function12fa0: ; 12fa0
 	push af
 	xor a
-	ld [wd0e3], a
+	ld [wSwitchMon], a
 	ld hl, wcfa5
 	res 6, [hl]
 	call ClearSprites
@@ -1543,7 +1543,7 @@
 	call SetUpMoveScreenBG
 	call Function132d3
 	ld de, Unknown_13163
-	call Function1bb1
+	call InitMenu3
 .loop
 	call Function131ef
 	ld hl, wcfa5
--- a/home.asm
+++ b/home.asm
@@ -1214,12 +1214,12 @@
 ; 3567
 
 
-Function3567:: ; 3567
+HandleStoneQueue:: ; 3567
 	ld a, [hROMBank]
 	push af
 
 	call SwitchToMapScriptHeaderBank
-	call Function3574
+	call .WarpAction
 
 	pop bc
 	ld a, b
@@ -1227,39 +1227,39 @@
 	ret
 ; 3574
 
-Function3574:: ; 3574
-	ld hl, $0001
+.WarpAction ; 3574
+	ld hl, OBJECT_MAP_OBJECT_INDEX
 	add hl, de
 	ld a, [hl]
 	cp $ff
-	jr z, .asm_3597
+	jr z, .nope
 
 	ld l, a
 	push hl
-	call Function3599
+	call .IsPersonOnWarp
 	pop hl
-	jr nc, .asm_3597
+	jr nc, .nope
 	ld d, a
 	ld e, l
-	call Function35de
-	jr nc, .asm_3597
+	call .IsObjectInStoneTable
+	jr nc, .nope
 	call CallMapScript
 	callba EnableScriptMode
 	scf
 	ret
 
-.asm_3597
+.nope
 	and a
 	ret
 ; 3599
 
-Function3599:: ; 3599
+.IsPersonOnWarp ; 3599
 	push de
 
-	ld hl, $0010
+	ld hl, OBJECT_NEXT_MAP_X
 	add hl, de
 	ld a, [hl]
-	ld hl, $0011
+	ld hl, OBJECT_NEXT_MAP_Y
 	add hl, de
 	ld e, [hl]
 
@@ -1268,52 +1268,52 @@
 	ld a, e
 	sub 4
 	ld e, a
-	call Function35b0
+	call .check_on_warp
 
 	pop de
 	ret
 ; 35b0
 
-Function35b0:: ; 35b0
-	ld hl, wCurrentCaller + 3
+.check_on_warp ; 35b0
+	ld hl, wCurrMapWarpHeaderPointer
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-	ld a, [wCurrentCaller + 2]
+	ld a, [wCurrMapWarpCount]
 	and a
-	jr z, .asm_35d3
+	jr z, .nope2
 
 .loop
 	push af
 	ld a, [hl]
 	cp e
-	jr nz, .asm_35c8
+	jr nz, .not_on_warp
 	inc hl
 	ld a, [hld]
 	cp d
-	jr nz, .asm_35c8
-	jr .asm_35d5
+	jr nz, .not_on_warp
+	jr .found_warp
 
-.asm_35c8
-	ld a, $5
+.not_on_warp
+	ld a, 5
 	add l
 	ld l, a
-	jr nc, .asm_35cf
+	jr nc, .no_carry
 	inc h
-.asm_35cf
+.no_carry
 
 	pop af
 	dec a
 	jr nz, .loop
 
-.asm_35d3
+.nope2
 	and a
 	ret
 
-.asm_35d5
+.found_warp
 	pop af
 	ld d, a
-	ld a, [wCurrentCaller + 2]
+	ld a, [wCurrMapWarpCount]
 	sub d
 	inc a
 	scf
@@ -1320,41 +1320,41 @@
 	ret
 ; 35de
 
-Function35de:: ; 35de
+.IsObjectInStoneTable ; 35de
 	inc e
-	ld hl, $0001
+	ld hl, CMDQUEUE_ADDR
 	add hl, bc
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-.asm_35e6
+.loop2
 	ld a, [hli]
 	cp $ff
-	jr z, .asm_35fc
+	jr z, .nope3
 	cp d
-	jr nz, .asm_35f7
+	jr nz, .next_inc3
 	ld a, [hli]
 	cp e
-	jr nz, .asm_35f8
+	jr nz, .next_inc2
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-	jr .asm_35fe
+	jr .yes
 
-.asm_35f7
+.next_inc3
 	inc hl
 
-.asm_35f8
+.next_inc2
 rept 2
 	inc hl
 endr
-	jr .asm_35e6
+	jr .loop2
 
-.asm_35fc
+.nope3
 	and a
 	ret
 
-.asm_35fe
+.yes
 	scf
 	ret
 ; 3600
--- a/home/movement.asm
+++ b/home/movement.asm
@@ -136,17 +136,17 @@
 	big_step_right
 ; 1bb1
 
-Function1bb1:: ; 1bb1
+InitMenu3:: ; 1bb1
 	push hl
 	push bc
 	ld hl, wcfa1
 	ld b, $8
-.asm_1bb8
+.loop
 	ld a, [de]
 	inc de
 	ld [hli], a
 	dec b
-	jr nz, .asm_1bb8
+	jr nz, .loop
 	ld a, $1
 rept 2
 	ld [hli], a
--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -1875,9 +1875,9 @@
 	ret
 
 ChoosePkmnToUseItemOn: ; f21c (3:721c)
-	callba Function5004f
-	callba Function50405
-	callba Function503e0
+	callba LoadPartyMenuGFX
+	callba InitPartyMenuWithCancel
+	callba InitPartyMenuGFX
 	callba WritePartyMenuTilemap
 	callba PrintPartyMenuText
 	call WaitBGMap
--- a/main.asm
+++ b/main.asm
@@ -14741,9 +14741,9 @@
 	call ClearBGPalettes
 
 Function2c80a: ; 2c80a
-	callba Function5004f
-	callba Function50405
-	callba Function503e0
+	callba LoadPartyMenuGFX
+	callba InitPartyMenuWithCancel
+	callba InitPartyMenuGFX
 	ld a, $3
 	ld [PartyMenuActionText], a
 .loopback
@@ -18255,8 +18255,8 @@
 	call ClearBGPalettes
 
 Function4aa25: ; 4aa25
-	callba Function5004f
-	callba Function50405
+	callba LoadPartyMenuGFX
+	callba InitPartyMenuWithCancel
 	call Function4aad3
 
 Function4aa34: ; 4aa34
@@ -36275,7 +36275,7 @@
 	call RunMapCallback
 
 RunCallback_03: ; 1045c4
-	callba Function97df9
+	callba ClearCmdQueue
 	ld a, $3
 	call RunMapCallback
 	call GetMapHeaderTimeOfDayNybble
--- a/maps/IcePathB1F.asm
+++ b/maps/IcePathB1F.asm
@@ -7,54 +7,54 @@
 
 	; callbacks
 
-	dbw 3, UnknownScript_0x7e4be
+	dbw 3, .SetUpStoneTable
 
-UnknownScript_0x7e4be:
-	writecmdqueue CmdQueue_0x7e4c2
+.SetUpStoneTable:
+	writecmdqueue .CommandQueue
 	return
 
-CmdQueue_0x7e4c2:
-	dbw 2, StoneTable_0x7e4c7 ; check if any stones are sitting on a warp
+.CommandQueue:
+	dbw 2, .StoneTable ; check if any stones are sitting on a warp
 	db 0, 0 ; filler
 
-StoneTable_0x7e4c7:
+.StoneTable:
 	db 3, 2 ; warp, person
-	dw UnknownScript_0x7e4d8
+	dw .Boulder1
 
 	db 4, 3 ; warp, person
-	dw UnknownScript_0x7e4e0
+	dw .Boulder2
 
 	db 5, 4 ; warp, person
-	dw UnknownScript_0x7e4e8
+	dw .Boulder3
 
 	db 6, 5 ; warp, person
-	dw UnknownScript_0x7e4f0
+	dw .Boulder4
 
-	db $ff ; end
+	db -1 ; end
 
-UnknownScript_0x7e4d8:
+.Boulder1:
 	disappear 2
 	clearevent EVENT_BOULDER_IN_ICE_PATH_1A
-	jump UnknownScript_0x7e4f8
+	jump .FinishBoulder
 
-UnknownScript_0x7e4e0:
+.Boulder2:
 	disappear 3
 	clearevent EVENT_BOULDER_IN_ICE_PATH_2A
-	jump UnknownScript_0x7e4f8
+	jump .FinishBoulder
 
-UnknownScript_0x7e4e8:
+.Boulder3:
 	disappear 4
 	clearevent EVENT_BOULDER_IN_ICE_PATH_3A
-	jump UnknownScript_0x7e4f8
+	jump .FinishBoulder
 
-UnknownScript_0x7e4f0:
+.Boulder4:
 	disappear 5
 	clearevent EVENT_BOULDER_IN_ICE_PATH_4A
-	jump UnknownScript_0x7e4f8
+	jump .FinishBoulder
 
-UnknownScript_0x7e4f8:
+.FinishBoulder:
 	pause 30
-	scall UnknownScript_0x7e504
+	scall .BoulderFallsThrough
 	loadfont
 	writetext UnknownText_0x7e512
 	closetext
@@ -61,7 +61,7 @@
 	loadmovesprites
 	end
 
-UnknownScript_0x7e504:
+.BoulderFallsThrough:
 	playsound SFX_STRENGTH
 	earthquake 80
 	end
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -1984,7 +1984,7 @@
 
 Function100c98: ; 100c98
 	ld de, Unknown_100cad
-	call Function1bb1
+	call InitMenu3
 	ld a, [wd0eb]
 	inc a
 	ld [wcfa3], a
@@ -6305,7 +6305,7 @@
 	ld hl, wcd4b
 	set 1, [hl]
 	ld de, Unknown_102a33
-	call Function1bb1
+	call InitMenu3
 	ld a, [wcd4a]
 	inc a
 	ld [wcd4a], a
@@ -6478,7 +6478,7 @@
 	ld a, [MenuSelection2]
 	push af
 	ld de, Unknown_102b73
-	call Function1bb1
+	call InitMenu3
 	pop af
 	ld [MenuSelection2], a
 	ld a, [OTPartyCount]
@@ -6503,7 +6503,7 @@
 	ld a, [MenuSelection2]
 	push af
 	ld de, Unknown_102b94
-	call Function1bb1
+	call InitMenu3
 	pop af
 	ld [MenuSelection2], a
 	ld a, [PartyCount]
--- a/wram.asm
+++ b/wram.asm
@@ -1357,8 +1357,8 @@
 wcf9b:: ds 3
 wcf9e:: ds 3
 wMenuData2End::
+wMenuData3::
 wcfa1:: ds 1
-
 wcfa2:: ds 1
 wcfa3:: ds 1
 wcfa4:: ds 1
@@ -1366,6 +1366,7 @@
 wcfa6:: ds 1 ; dynamic menu flags?
 wcfa7:: ds 1
 wcfa8:: ds 1
+wMenuData3End::
 MenuSelection2:: ds 1
 wcfaa:: ds 1
 wcfab:: ds 1
@@ -1648,6 +1649,7 @@
 
 wd0d6:: ds 1
 wd0d7:: ds 1
+wPartyMenuCursor::
 wd0d8:: ds 1
 wItemsPocketCursor:: ds 1
 wKeyItemsPocketCursor:: ds 1
@@ -1659,6 +1661,7 @@
 wd0e1:: ds 1
 wd0e2:: ds 1
 wMoveSwapBuffer::
+wSwitchMon::
 wd0e3:: ds 1
 wd0e4:: ds 4
 wQueuedScriptBank:: ds 1
@@ -2284,10 +2287,10 @@
 	object_struct Object10
 	object_struct Object11
 	object_struct Object12
-ObjectStructsEnd::
+ObjectStructsEnd:: ; d6de
 
-wd6de::
-	ds $40
+wCmdQueue:: ds CMDQUEUE_CAPACITY * CMDQUEUE_ENTRY_SIZE
+	ds $28
 
 MapObjects:: ; d71e
 map_object: MACRO