shithub: pokecrystal

Download patch

ref: 8bf255b9f84f7e4f93e85a75512a002ef240a10f
parent: 7cc2571529d6b3f5ffcbb71c62fab31b27ba224a
author: PikalaxALT <PikalaxALT@gmail.com>
date: Sun Jan 17 19:39:01 EST 2016

Prepare to merge

--- a/battle/core.asm
+++ b/battle/core.asm
@@ -1248,7 +1248,7 @@
 	res SUBSTATUS_PERISH, [hl]
 	ld a, [hBattleTurn]
 	and a
-	jr nz, .asm_3c85c
+	jr nz, .kill_enemy
 	ld hl, BattleMonHP
 	xor a
 	ld [hli], a
@@ -1261,7 +1261,7 @@
 	ld [hl], a
 	ret
 
-.asm_3c85c
+.kill_enemy
 	ld hl, EnemyMonHP
 	xor a
 	ld [hli], a
@@ -1334,12 +1334,12 @@
 	call GetSixteenthMaxHP
 	call SubtractHPFromUser
 	ld hl, BattleText_UsersHurtByStringBuffer1
-	jr .asm_3c8e1
+	jr .print_text
 
 .release_from_bounds
 	ld hl, BattleText_UserWasReleasedFromStringBuffer1
 
-.asm_3c8e1
+.print_text
 	jp StdBattleTextBox
 ; 3c8e4
 
@@ -1396,7 +1396,7 @@
 	call GetSixteenthMaxHP
 	call SwitchTurnCore
 	call RestoreHP
-	ld hl, BattleText_0x80880
+	ld hl, BattleText_TargetRecoveredWithItem
 	jp StdBattleTextBox
 ; 3c93c
 
@@ -1569,7 +1569,7 @@
 	cp $1
 	ret nz
 
-	ld hl, BattleText_0x808b6
+	ld hl, BattleText_TargetWasHitByFutureSight
 	call StdBattleTextBox
 
 	ld a, BATTLE_VARS_MOVE
@@ -1645,12 +1645,12 @@
 
 	ld a, [wBattleMode]
 	dec a
-	jr z, .asm_3caef
+	jr z, .wild
 	ld a, [CurOTMon]
 	ld hl, OTPartyMon1Status
 	call GetPartyLocation
 	ld [hl], 0
-.asm_3caef
+.wild
 
 	call UpdateBattleHuds
 	call SetPlayerTurn
@@ -1661,13 +1661,13 @@
 HandleSafeguard: ; 3cafb
 	ld a, [hLinkPlayerNumber]
 	cp $1
-	jr z, .asm_3cb06
-	call .asm_3cb09
-	jr .asm_3cb1c
+	jr z, .player1
+	call .CheckPlayer
+	jr .CheckEnemy
 
-.asm_3cb06
-	call .asm_3cb1c
-.asm_3cb09
+.player1
+	call .CheckEnemy
+.CheckPlayer
 	ld a, [PlayerScreens]
 	bit SCREENS_SAFEGUARD, a
 	ret z
@@ -1677,9 +1677,9 @@
 	res SCREENS_SAFEGUARD, a
 	ld [PlayerScreens], a
 	xor a
-	jr .asm_3cb2e
+	jr .print
 
-.asm_3cb1c
+.CheckEnemy
 	ld a, [EnemyScreens]
 	bit SCREENS_SAFEGUARD, a
 	ret z
@@ -1690,7 +1690,7 @@
 	ld [EnemyScreens], a
 	ld a, $1
 
-.asm_3cb2e
+.print
 	ld [hBattleTurn], a
 	ld hl, BattleText_SafeguardFaded
 	jp StdBattleTextBox
@@ -1712,7 +1712,7 @@
 	call .Copy
 	ld hl, PlayerScreens
 	ld de, PlayerLightScreenCount
-	jr .FadeScreens
+	jr .TickScreens
 
 .CheckEnemy
 	call SetEnemyTurn
@@ -1721,11 +1721,11 @@
 	ld hl, EnemyScreens
 	ld de, EnemyLightScreenCount
 
-.FadeScreens
+.TickScreens
 	bit SCREENS_LIGHT_SCREEN, [hl]
-	call nz, FadeLightScreen
+	call nz, .LightScreenTick
 	bit SCREENS_REFLECT, [hl]
-	call nz, FadeReflect
+	call nz, .ReflectTick
 	ret
 
 .Copy
@@ -1740,7 +1740,7 @@
 ; 3cb80
 
 
-FadeLightScreen: ; 3cb80
+.LightScreenTick: ; 3cb80
 	ld a, [de]
 	dec a
 	ld [de], a
@@ -1748,7 +1748,7 @@
 	res SCREENS_LIGHT_SCREEN, [hl]
 	push hl
 	push de
-	ld hl, BattleText_PkmnnLightScreenFell
+	ld hl, BattleText_PkmnLightScreenFell
 	call StdBattleTextBox
 	pop de
 	pop hl
@@ -1755,7 +1755,7 @@
 	ret
 ; 3cb91
 
-FadeReflect: ; 3cb91
+.ReflectTick: ; 3cb91
 	inc de
 	ld a, [de]
 	dec a
@@ -1762,7 +1762,7 @@
 	ld [de], a
 	ret nz
 	res SCREENS_REFLECT, [hl]
-	ld hl, BattleText_0x80905
+	ld hl, BattleText_PkmnReflectFaded
 	jp StdBattleTextBox
 ; 3cb9e
 
@@ -3969,7 +3969,7 @@
 	and a
 	jr z, .can_escape
 	ld [hDivisor], a
-	ld b, $2
+	ld b, 2
 	call Divide
 	ld a, [hQuotient + 1]
 	and a
@@ -4941,16 +4941,16 @@
 	ld [MonType], a
 	callab GetGender
 	ld a, " "
-	jr c, .asm_3e013
+	jr c, .got_gender_char
 	ld a, "♂"
-	jr nz, .asm_3e013
+	jr nz, .got_gender_char
 	ld a, "♀"
 
-.asm_3e013
+.got_gender_char
 	hlcoord 17, 8
 	ld [hl], a
 	hlcoord 14, 8
-	push af
+	push af ; back up gender
 	push hl
 	ld de, BattleMonStatus
 	predef PlaceNonFaintStatus
@@ -4959,10 +4959,10 @@
 	ret nz
 	ld a, b
 	cp " "
-	jr nz, .asm_3e02d
-	dec hl
+	jr nz, .copy_level ; male or female
+	dec hl ; genderless
 
-.asm_3e02d
+.copy_level
 	ld a, [BattleMonLevel]
 	ld [TempMonLevel], a
 	jp PrintLevel
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -1928,6 +1928,7 @@
 	ld a, [hBattleTurn]
 	and a
 
+	; load the user's accuracy into b and the opponent's evasion into c.
 	ld hl, wPlayerMoveStruct + MOVE_ACC
 	ld a, [PlayerAccLevel]
 	ld b, a
@@ -1944,17 +1945,21 @@
 
 .got_acc_eva
 	cp b
-	jr c, .eva_less_than_acc
+	jr c, .skip_foresight_check
 
+	; if the target's evasion is greater than the user's accuracy,
+	; check the target's foresight status
 	ld a, BATTLE_VARS_SUBSTATUS1_OPP
 	call GetBattleVar
 	bit SUBSTATUS_IDENTIFIED, a
 	ret nz
 
-.eva_less_than_acc
+.skip_foresight_check
+	; subtract evasion from 14
 	ld a, 14
 	sub c
 	ld c, a
+	; store the base move accuracy for math ops
 	xor a
 	ld [hMultiplicand + 0], a
 	ld [hMultiplicand + 1], a
@@ -1961,9 +1966,10 @@
 	ld a, [hl]
 	ld [hMultiplicand + 2], a
 	push hl
-	ld d, 2
+	ld d, 2 ; do this twice, once for the user's accuracy and once for the target's evasion
 
 .accuracy_loop
+	; look up the multiplier from the table
 	push bc
 	ld hl, .AccProb
 	dec b
@@ -1972,13 +1978,16 @@
 	ld b, 0
 	add hl, bc
 	pop bc
+	; multiply by the first byte in that row...
 	ld a, [hli]
 	ld [hMultiplier], a
 	call Multiply
+	; ... and divide by the second byte
 	ld a, [hl]
 	ld [hDivisor], a
 	ld b, 4
 	call Divide
+	; minimum accuracy is $0001
 	ld a, [hQuotient + 2]
 	ld b, a
 	ld a, [hQuotient + 1]
@@ -1985,14 +1994,16 @@
 	or b
 	jr nz, .min_accuracy
 	ld [hQuotient + 1], a
-	ld a, $1
+	ld a, 1
 	ld [hQuotient + 2], a
 
 .min_accuracy
+	; do the same thing to the target's evasion
 	ld b, c
 	dec d
 	jr nz, .accuracy_loop
 
+	; if the result is more than 2 bytes, max out at 100%
 	ld a, [hQuotient + 1]
 	and a
 	ld a, [hQuotient + 2]
@@ -8393,148 +8404,7 @@
 
 ; 371cd
 
-
-BattleCommand_Transform: ; 371cd
-; transform
-
-	call ClearLastMove
-	ld a, BATTLE_VARS_SUBSTATUS5_OPP
-	call GetBattleVarAddr
-	bit SUBSTATUS_TRANSFORMED, [hl]
-	jp nz, BattleEffect_ButItFailed
-	call CheckHiddenOpponent
-	jp nz, BattleEffect_ButItFailed
-	xor a
-	ld [wNumHits], a
-	ld [FXAnimIDHi], a
-	ld a, $1
-	ld [wKickCounter], a
-	ld a, BATTLE_VARS_SUBSTATUS4
-	call GetBattleVarAddr
-	bit SUBSTATUS_SUBSTITUTE, [hl]
-	push af
-	jr z, .mimic_substitute
-	call CheckUserIsCharging
-	jr nz, .mimic_substitute
-	ld a, SUBSTITUTE
-	call LoadAnim
-.mimic_substitute
-	ld a, BATTLE_VARS_SUBSTATUS5
-	call GetBattleVarAddr
-	set SUBSTATUS_TRANSFORMED, [hl]
-	call ResetActorDisable
-	ld hl, BattleMonSpecies
-	ld de, EnemyMonSpecies
-	ld a, [hBattleTurn]
-	and a
-	jr nz, .got_mon_species
-	ld hl, EnemyMonSpecies
-	ld de, BattleMonSpecies
-	xor a
-	ld [CurMoveNum], a
-.got_mon_species
-	push hl
-	ld a, [hli]
-	ld [de], a
-	inc hl
-	inc de
-	inc de
-	ld bc, NUM_MOVES
-	call CopyBytes
-	ld a, [hBattleTurn]
-	and a
-	jr z, .mimic_enemy_backup
-	ld a, [de]
-	ld [wEnemyBackupDVs], a
-	inc de
-	ld a, [de]
-	ld [wEnemyBackupDVs + 1], a
-	dec de
-.mimic_enemy_backup
-; copy DVs
-	ld a, [hli]
-	ld [de], a
-	inc de
-	ld a, [hli]
-	ld [de], a
-	inc de
-; move pointer to stats
-	ld bc, BattleMonStats - BattleMonPP
-	add hl, bc
-	push hl
-	ld h, d
-	ld l, e
-	add hl, bc
-	ld d, h
-	ld e, l
-	pop hl
-	ld bc, BattleMonStructEnd - BattleMonStats
-	call CopyBytes
-; init the power points
-	ld bc, BattleMonMoves - BattleMonStructEnd
-	add hl, bc
-	push de
-	ld d, h
-	ld e, l
-	pop hl
-	ld bc, BattleMonPP - BattleMonStructEnd
-	add hl, bc
-	ld b, NUM_MOVES
-.pp_loop
-	ld a, [de]
-	inc de
-	and a
-	jr z, .done_move
-	cp SKETCH
-	ld a, 1
-	jr z, .done_move
-	ld a, 5
-.done_move
-	ld [hli], a
-	dec b
-	jr nz, .pp_loop
-	pop hl
-	ld a, [hl]
-	ld [wNamedObjectIndexBuffer], a
-	call GetPokemonName
-	ld hl, EnemyStats
-	ld de, PlayerStats
-	ld bc, 2 * 5
-	call BattleSideCopy
-	ld hl, EnemyStatLevels
-	ld de, PlayerStatLevels
-	ld bc, 8
-	call BattleSideCopy
-	call _CheckBattleScene
-	jr c, .mimic_anims
-	ld a, [hBattleTurn]
-	and a
-	ld a, [wPlayerMinimized]
-	jr z, .got_byte
-	ld a, [wEnemyMinimized]
-.got_byte
-	and a
-	jr nz, .mimic_anims
-	call LoadMoveAnim
-	jr .after_anim
-
-.mimic_anims
-	call BattleCommand_MoveDelay
-	call BattleCommand_RaiseSubNoAnim
-.after_anim
-	xor a
-	ld [wNumHits], a
-	ld [FXAnimIDHi], a
-	ld a, $2
-	ld [wKickCounter], a
-	pop af
-	ld a, SUBSTITUTE
-	call nz, LoadAnim
-	ld hl, TransformedText
-	jp StdBattleTextBox
-
-; 372c6
-
+INCLUDE "battle/effects/transform.asm"
 
 BattleSideCopy: ; 372c6
 ; Copy bc bytes from hl to de if it's the player's turn.
--- /dev/null
+++ b/battle/effects/transform.asm
@@ -1,0 +1,141 @@
+
+BattleCommand_Transform: ; 371cd
+; transform
+
+	call ClearLastMove
+	ld a, BATTLE_VARS_SUBSTATUS5_OPP
+	call GetBattleVarAddr
+	bit SUBSTATUS_TRANSFORMED, [hl]
+	jp nz, BattleEffect_ButItFailed
+	call CheckHiddenOpponent
+	jp nz, BattleEffect_ButItFailed
+	xor a
+	ld [wNumHits], a
+	ld [FXAnimIDHi], a
+	ld a, $1
+	ld [wKickCounter], a
+	ld a, BATTLE_VARS_SUBSTATUS4
+	call GetBattleVarAddr
+	bit SUBSTATUS_SUBSTITUTE, [hl]
+	push af
+	jr z, .mimic_substitute
+	call CheckUserIsCharging
+	jr nz, .mimic_substitute
+	ld a, SUBSTITUTE
+	call LoadAnim
+.mimic_substitute
+	ld a, BATTLE_VARS_SUBSTATUS5
+	call GetBattleVarAddr
+	set SUBSTATUS_TRANSFORMED, [hl]
+	call ResetActorDisable
+	ld hl, BattleMonSpecies
+	ld de, EnemyMonSpecies
+	ld a, [hBattleTurn]
+	and a
+	jr nz, .got_mon_species
+	ld hl, EnemyMonSpecies
+	ld de, BattleMonSpecies
+	xor a
+	ld [CurMoveNum], a
+.got_mon_species
+	push hl
+	ld a, [hli]
+	ld [de], a
+	inc hl
+	inc de
+	inc de
+	ld bc, NUM_MOVES
+	call CopyBytes
+	ld a, [hBattleTurn]
+	and a
+	jr z, .mimic_enemy_backup
+	ld a, [de]
+	ld [wEnemyBackupDVs], a
+	inc de
+	ld a, [de]
+	ld [wEnemyBackupDVs + 1], a
+	dec de
+.mimic_enemy_backup
+; copy DVs
+	ld a, [hli]
+	ld [de], a
+	inc de
+	ld a, [hli]
+	ld [de], a
+	inc de
+; move pointer to stats
+	ld bc, BattleMonStats - BattleMonPP
+	add hl, bc
+	push hl
+	ld h, d
+	ld l, e
+	add hl, bc
+	ld d, h
+	ld e, l
+	pop hl
+	ld bc, BattleMonStructEnd - BattleMonStats
+	call CopyBytes
+; init the power points
+	ld bc, BattleMonMoves - BattleMonStructEnd
+	add hl, bc
+	push de
+	ld d, h
+	ld e, l
+	pop hl
+	ld bc, BattleMonPP - BattleMonStructEnd
+	add hl, bc
+	ld b, NUM_MOVES
+.pp_loop
+	ld a, [de]
+	inc de
+	and a
+	jr z, .done_move
+	cp SKETCH
+	ld a, 1
+	jr z, .done_move
+	ld a, 5
+.done_move
+	ld [hli], a
+	dec b
+	jr nz, .pp_loop
+	pop hl
+	ld a, [hl]
+	ld [wNamedObjectIndexBuffer], a
+	call GetPokemonName
+	ld hl, EnemyStats
+	ld de, PlayerStats
+	ld bc, 2 * 5
+	call BattleSideCopy
+	ld hl, EnemyStatLevels
+	ld de, PlayerStatLevels
+	ld bc, 8
+	call BattleSideCopy
+	call _CheckBattleScene
+	jr c, .mimic_anims
+	ld a, [hBattleTurn]
+	and a
+	ld a, [wPlayerMinimized]
+	jr z, .got_byte
+	ld a, [wEnemyMinimized]
+.got_byte
+	and a
+	jr nz, .mimic_anims
+	call LoadMoveAnim
+	jr .after_anim
+
+.mimic_anims
+	call BattleCommand_MoveDelay
+	call BattleCommand_RaiseSubNoAnim
+.after_anim
+	xor a
+	ld [wNumHits], a
+	ld [FXAnimIDHi], a
+	ld a, $2
+	ld [wKickCounter], a
+	pop af
+	ld a, SUBSTITUTE
+	call nz, LoadAnim
+	ld hl, TransformedText
+	jp StdBattleTextBox
+
+; 372c6
--- a/constants/sprite_constants.asm
+++ b/constants/sprite_constants.asm
@@ -193,44 +193,44 @@
 
 ; sprite movement data table indices
 	const_def
-	const SPRITEMOVEDATA_00
-	const SPRITEMOVEDATA_ITEM_TREE
-	const SPRITEMOVEDATA_WANDER
-	const SPRITEMOVEDATA_SPINRANDOM_SLOW
-	const SPRITEMOVEDATA_WALK_UP_DOWN
-	const SPRITEMOVEDATA_WALK_LEFT_RIGHT
-	const SPRITEMOVEDATA_STANDING_DOWN
-	const SPRITEMOVEDATA_STANDING_UP
-	const SPRITEMOVEDATA_STANDING_LEFT
-	const SPRITEMOVEDATA_STANDING_RIGHT
-	const SPRITEMOVEDATA_SPINRANDOM_FAST
-	const SPRITEMOVEDATA_PLAYER
-	const SPRITEMOVEDATA_0C
-	const SPRITEMOVEDATA_0D
-	const SPRITEMOVEDATA_0E
-	const SPRITEMOVEDATA_0F
-	const SPRITEMOVEDATA_10
-	const SPRITEMOVEDATA_11
-	const SPRITEMOVEDATA_12
-	const SPRITEMOVEDATA_FOLLOWING
-	const SPRITEMOVEDATA_SCRIPTED
-	const SPRITEMOVEDATA_SNORLAX
-	const SPRITEMOVEDATA_POKEMON
-	const SPRITEMOVEDATA_SUDOWOODO
-	const SPRITEMOVEDATA_SMASHABLE_ROCK
-	const SPRITEMOVEDATA_STRENGTH_BOULDER
-	const SPRITEMOVEDATA_FOLLOWNOTEXACT
-	const SPRITEMOVEDATA_SHADOW
-	const SPRITEMOVEDATA_EMOTE
-	const SPRITEMOVEDATA_SCREENSHAKE
-	const SPRITEMOVEDATA_SPINCOUNTERCLOCKWISE
-	const SPRITEMOVEDATA_SPINCLOCKWISE
-	const SPRITEMOVEDATA_20
-	const SPRITEMOVEDATA_BIGDOLL
-	const SPRITEMOVEDATA_BOULDERDUST
-	const SPRITEMOVEDATA_GRASS
-	const SPRITEMOVEDATA_LAPRAS
-	const SPRITEMOVEDATA_25
+	const SPRITEMOVEDATA_00                   ; 00
+	const SPRITEMOVEDATA_ITEM_TREE            ; 01
+	const SPRITEMOVEDATA_WANDER               ; 02
+	const SPRITEMOVEDATA_SPINRANDOM_SLOW      ; 03
+	const SPRITEMOVEDATA_WALK_UP_DOWN         ; 04
+	const SPRITEMOVEDATA_WALK_LEFT_RIGHT      ; 05
+	const SPRITEMOVEDATA_STANDING_DOWN        ; 06
+	const SPRITEMOVEDATA_STANDING_UP          ; 07
+	const SPRITEMOVEDATA_STANDING_LEFT        ; 08
+	const SPRITEMOVEDATA_STANDING_RIGHT       ; 09
+	const SPRITEMOVEDATA_SPINRANDOM_FAST      ; 0a
+	const SPRITEMOVEDATA_PLAYER               ; 0b
+	const SPRITEMOVEDATA_0C                   ; 0c
+	const SPRITEMOVEDATA_0D                   ; 0d
+	const SPRITEMOVEDATA_0E                   ; 0e
+	const SPRITEMOVEDATA_0F                   ; 0f
+	const SPRITEMOVEDATA_10                   ; 10
+	const SPRITEMOVEDATA_11                   ; 11
+	const SPRITEMOVEDATA_12                   ; 12
+	const SPRITEMOVEDATA_FOLLOWING            ; 13
+	const SPRITEMOVEDATA_SCRIPTED             ; 14
+	const SPRITEMOVEDATA_SNORLAX              ; 15
+	const SPRITEMOVEDATA_POKEMON              ; 16
+	const SPRITEMOVEDATA_SUDOWOODO            ; 17
+	const SPRITEMOVEDATA_SMASHABLE_ROCK       ; 18
+	const SPRITEMOVEDATA_STRENGTH_BOULDER     ; 19
+	const SPRITEMOVEDATA_FOLLOWNOTEXACT       ; 1a
+	const SPRITEMOVEDATA_SHADOW               ; 1b
+	const SPRITEMOVEDATA_EMOTE                ; 1c
+	const SPRITEMOVEDATA_SCREENSHAKE          ; 1d
+	const SPRITEMOVEDATA_SPINCOUNTERCLOCKWISE ; 1e
+	const SPRITEMOVEDATA_SPINCLOCKWISE        ; 1f
+	const SPRITEMOVEDATA_20                   ; 20
+	const SPRITEMOVEDATA_BIGDOLL              ; 21
+	const SPRITEMOVEDATA_BOULDERDUST          ; 22
+	const SPRITEMOVEDATA_GRASS                ; 23
+	const SPRITEMOVEDATA_LAPRAS               ; 24
+	const SPRITEMOVEDATA_25                   ; 25
 NUM_SPRITEMOVEDATA EQU const_value +- 1
 SPRITEMOVEDATA_FIELDS EQU 6
 
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -427,7 +427,7 @@
 	or $3
 	ld [hl], a
 	ld hl, OTPlayerName
-	ld de, OTName
+	ld de, OTClassName
 	ld bc, NAME_LENGTH
 	call CopyBytes
 	call ReturnToMapFromSubmenu
--- a/engine/player_movement.asm
+++ b/engine/player_movement.asm
@@ -136,7 +136,7 @@
 	jr z, .land2
 	cp $70 ; warps
 	jr z, .warps
-	jr .asm_8013c
+	jr .no_walk
 
 .water
 	ld a, c
@@ -147,7 +147,7 @@
 	add hl, bc
 	ld a, [hl]
 	ld [WalkingDirection], a
-	jr .asm_8013e
+	jr .continue_walk
 
 .water_table
 	db RIGHT
@@ -164,9 +164,9 @@
 	add hl, bc
 	ld a, [hl]
 	cp STANDING
-	jr z, .asm_8013c
+	jr z, .no_walk
 	ld [WalkingDirection], a
-	jr .asm_8013e
+	jr .continue_walk
 
 .land1_table
 	db STANDING
@@ -187,9 +187,9 @@
 	add hl, bc
 	ld a, [hl]
 	cp STANDING
-	jr z, .asm_8013c
+	jr z, .no_walk
 	ld [WalkingDirection], a
-	jr .asm_8013e
+	jr .continue_walk
 
 .land2_table
 	db RIGHT
@@ -210,18 +210,18 @@
 	cp $7a ; stairs
 	jr z, .down
 	cp $7b ; cave
-	jr nz, .asm_8013c
+	jr nz, .no_walk
 
 .down
 	ld a, DOWN
 	ld [WalkingDirection], a
-	jr .asm_8013e
+	jr .continue_walk
 
-.asm_8013c
+.no_walk
 	xor a
 	ret
 
-.asm_8013e
+.continue_walk
 	ld a, STEP_WALK
 	call .DoStep
 	ld a, 5
--- a/engine/time_capsule/conversion.asm
+++ b/engine/time_capsule/conversion.asm
@@ -367,13 +367,13 @@
 	ld a, [hSCX]
 	add -5 ; 251 ; NUM_POKEMON
 	ld [hSCX], a
-	call Functionfb8c8
+	call .ReturnFromDexRegistration
 	pop af
 	ld [hMapAnims], a
 	ret
 ; fb8c8
 
-Functionfb8c8: ; fb8c8
+.ReturnFromDexRegistration: ; fb8c8
 	call ClearTileMap
 	call LoadFontsExtra
 	call LoadStandardFont
--- a/engine/tmhm2.asm
+++ b/engine/tmhm2.asm
@@ -196,16 +196,16 @@
 	xor a
 	ld [hBGMapMode], a
 	call TMHM_DisplayPocketItems
-	ld a, $2
+	ld a, 2
 	ld [w2DMenuCursorInitY], a
-	ld a, $7
+	ld a, 7
 	ld [w2DMenuCursorInitX], a
-	ld a, $1
+	ld a, 1
 	ld [w2DMenuNumCols], a
-	ld a, $5
+	ld a, 5
 	sub d
 	inc a
-	cp $6
+	cp 6
 	jr nz, .okay
 	dec a
 .okay
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -506,18 +506,18 @@
 ; Places a BCD number at the
 ; upper center of the screen.
 ; Unreferenced.
-	ld a, $20
-	ld [Sprites + $98], a
-	ld [Sprites + $9c], a
-	ld a, $50
-	ld [Sprites + $99], a
-	ld a, $58
-	ld [Sprites + $9d], a
+	ld a, 4 * 8
+	ld [Sprites + 38 * 4], a
+	ld [Sprites + 39 * 4], a
+	ld a, 10 * 8
+	ld [Sprites + 38 * 4 + 1], a
+	ld a, 11 * 8
+	ld [Sprites + 39 * 4 + 1], a
 	xor a
-	ld [Sprites + $9b], a
-	ld [Sprites + $9f], a
+	ld [Sprites + 38 * 4 + 3], a
+	ld [Sprites + 39 * 4 + 3], a
 	ld a, [wc296]
-	cp $64
+	cp 100
 	jr nc, .max
 	add 1
 	daa
@@ -525,17 +525,17 @@
 	swap a
 	and $f
 	add "0"
-	ld [Sprites + $9a], a
+	ld [Sprites + 38 * 4 + 2], a
 	ld a, b
 	and $f
 	add "0"
-	ld [Sprites + $9e], a
+	ld [Sprites + 39 * 4 + 2], a
 	ret
 
 .max
 	ld a, "9"
-	ld [Sprites + $9a], a
-	ld [Sprites + $9e], a
+	ld [Sprites + 38 * 4 + 2], a
+	ld [Sprites + 39 * 4 + 2], a
 	ret
 ; 3dde
 
--- a/home/text.asm
+++ b/home/text.asm
@@ -399,7 +399,7 @@
 	cp RIVAL2
 	jr z, .rival
 
-	ld de, OTName
+	ld de, OTClassName
 	call PlaceString
 	ld h, b
 	ld l, c
@@ -416,7 +416,7 @@
 	jr PlaceCommandCharacter
 
 .linkbattle
-	ld de, OTName
+	ld de, OTClassName
 	jr PlaceCommandCharacter
 
 
--- a/main.asm
+++ b/main.asm
@@ -6621,7 +6621,7 @@
 
 .ok
 	ld bc, TRAINER_CLASS_NAME_LENGTH
-	ld de, OTName
+	ld de, OTClassName
 	push de
 	call CopyBytes
 	pop de
@@ -9154,50 +9154,50 @@
 	dw .Youngster
 	dw .BugCatcher
 	dw .Lass
-	dw OTName
+	dw OTClassName
 	dw .JrTrainerM
 	dw .JrTrainerF
 	dw .Pokemaniac
 	dw .SuperNerd
-	dw OTName
-	dw OTName
+	dw OTClassName
+	dw OTClassName
 	dw .Burglar
 	dw .Engineer
 	dw .Jack
-	dw OTName
+	dw OTClassName
 	dw .Swimmer
-	dw OTName
-	dw OTName
+	dw OTClassName
+	dw OTClassName
 	dw .Beauty
-	dw OTName
+	dw OTClassName
 	dw .Rocker
 	dw .Juggler
-	dw OTName
-	dw OTName
+	dw OTClassName
+	dw OTClassName
 	dw .Blackbelt
-	dw OTName
+	dw OTClassName
 	dw .ProfOak
 	dw .Chief
 	dw .Scientist
-	dw OTName
+	dw OTClassName
 	dw .Rocket
 	dw .CooltrainerM
 	dw .CooltrainerF
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
-	dw OTName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
+	dw OTClassName
 
 .Youngster    db "たんパン@"
 .BugCatcher   db "むしとり@"
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -2595,7 +2595,7 @@
 	ld bc, NAME_LENGTH
 	call .CopyAllFromOT
 	ld hl, OTPartyMonOT
-	ld de, OTName + 1
+	ld de, OTClassName + 1
 	ld bc, NAME_LENGTH
 	call .CopyAllFromOT
 	ld hl, OTPartyMon1Species
@@ -4039,7 +4039,7 @@
 	ld a, c
 	ld [OtherTrainerClass], a
 	ld hl, OTPlayerName
-	ld de, OTName
+	ld de, OTClassName
 	ld bc, NAME_LENGTH
 	call CopyBytes
 	ld a, [wcd2f]
--- a/text/battle.asm
+++ b/text/battle.asm
@@ -104,7 +104,7 @@
 	prompt
 ; 0x80880
 
-BattleText_0x80880: ; 0x80880
+BattleText_TargetRecoveredWithItem: ; 0x80880
 	text "<TARGET>"
 	line "recovered with"
 	cont "@"
@@ -122,7 +122,7 @@
 	prompt
 ; 0x808b6
 
-BattleText_0x808b6: ; 0x808b6
+BattleText_TargetWasHitByFutureSight: ; 0x808b6
 	text "<TARGET>"
 	line "was hit by FUTURE"
 	cont "SIGHT!"
@@ -135,7 +135,7 @@
 	prompt
 ; 0x808e7
 
-BattleText_PkmnnLightScreenFell: ; 0x808e7
+BattleText_PkmnLightScreenFell: ; 0x808e7
 	text_from_ram StringBuffer1
 	text " #MON's"
 	line "LIGHT SCREEN fell!"
@@ -142,7 +142,7 @@
 	prompt
 ; 0x80905
 
-BattleText_0x80905: ; 0x80905
+BattleText_PkmnReflectFaded: ; 0x80905
 	text_from_ram StringBuffer1
 	text " #MON's"
 	line "REFLECT faded!"
--- a/wram.asm
+++ b/wram.asm
@@ -12,7 +12,7 @@
 
 
 SECTION "Audio", WRAM0
-
+wMusic::
 MusicPlaying:: ; c100
 ; nonzero if playing
 	ds 1
@@ -33,7 +33,7 @@
 wCurTrackDuty:: ds 1
 wCurTrackIntensity:: ds 1
 wCurTrackFrequency:: dw
-wc296:: ds 1 ; used only in an unused script
+wc296:: ds 1 ; BCD value, dummied out
 wc297:: ds 1 ; used in MusicE0 and LoadNote
 
 CurMusicByte:: ; c298
@@ -132,8 +132,8 @@
 	ds 1
 
 wDontPlayMapMusicOnReload:: ds 1
+wMusicEnd::
 
-
 SECTION "WRAM", WRAM0
 
 wLZAddress:: dw ; c2c2
@@ -397,7 +397,7 @@
 wEnemyTrainerItem2:: ds 1
 wEnemyTrainerBaseReward:: ds 1
 wEnemyTrainerAIFlags:: ds 3
-OTName:: ds NAME_LENGTH ; c656
+OTClassName:: ds NAME_LENGTH ; c656
 
 	ds 2
 
@@ -1816,9 +1816,9 @@
 TempMon:: ; d10e
 	party_struct TempMon
 
-wSpriteFlags:: ds 1
+wSpriteFlags:: ds 1 ; d13e
 
-wHandlePlayerStep:: ds 2
+wHandlePlayerStep:: ds 2 ; d13f
 
 PartyMenuActionText:: ; d141
 	ds 1