ref: f2efda1f68230ec917cd148759bb9798a75a8f60
parent: 022f9e6af1570f071eaf85cf65d50cb29ddc34f2
author: Rangi <[email protected]>
date: Mon Jun 29 08:25:58 EDT 2020
Identify more unnamed labels
--- a/audio/cries.asm
+++ b/audio/cries.asm
@@ -221,9 +221,9 @@
Cry_Magcargo_Ch8:
noise_note 2, 14, 8, 59
-Cry_Magcargo_branch_f2ef5:
+.loop:
noise_note 1, 15, 1, 78
- sound_loop 5, Cry_Magcargo_branch_f2ef5
+ sound_loop 5, .loop
noise_note 2, 13, 8, 63
noise_note 20, 12, 2, 95
sound_ret
@@ -348,7 +348,6 @@
Cry_Togepi_Ch5:
pitch_offset 2
Cry_Togepi_Ch6:
-Cry_Togetic_branch_f3022:
duty_cycle_pattern 1, 1, 0, 2
square_note 4, 15, 1, 1942
square_note 4, 15, 1, 1837
@@ -359,7 +358,7 @@
Cry_Togetic_Ch5:
pitch_offset 2
Cry_Togetic_Ch6:
- sound_call Cry_Togetic_branch_f3022
+ sound_call Cry_Togepi_Ch6
sound_loop 2, Cry_Togetic_Ch6
square_note 14, 0, 0, 0
square_note 8, 15, 2, 1986
@@ -436,12 +435,12 @@
Cry_Hoothoot_Ch6:
duty_cycle_pattern 0, 2, 0, 2
-Cry_Hoothoot_branch_f30fb:
+.loop1:
square_note 2, 10, 1, 1536
- sound_loop 3, Cry_Hoothoot_branch_f30fb
-Cry_Hoothoot_branch_f3103:
+ sound_loop 3, .loop1
+.loop2:
square_note 2, 10, 1, 1584
- sound_loop 4, Cry_Hoothoot_branch_f3103
+ sound_loop 4, .loop2
square_note 4, 10, 2, 1588
square_note 4, 9, 1, 1592
sound_ret
@@ -456,11 +455,11 @@
Cry_Sentret_Ch5:
pitch_offset 32
duty_cycle 0
- sound_jump Cry_Sentret_branch_f312b
+ sound_jump Cry_Sentret_Ch6.body
Cry_Sentret_Ch6:
duty_cycle_pattern 0, 1, 2, 3
-Cry_Sentret_branch_f312b:
+.body:
square_note 8, 3, -1, 1837
square_note 8, 15, 1, 1824
sound_ret
@@ -473,12 +472,11 @@
Cry_Mareep_Ch5:
pitch_offset 32
duty_cycle 0
- sound_jump Cry_Mareep_branch_f3145
+ sound_jump Cry_Mareep_Ch6.body
Cry_Mareep_Ch6:
duty_cycle_pattern 0, 0, 0, 1
-Cry_Mareep_branch_f3145:
-Cry_Gligar_branch_f3145:
+.body:
square_note 4, 3, -2, 1853
square_note 6, 15, 8, 1890
square_note 6, 15, 8, 1888
@@ -490,14 +488,14 @@
Cry_Cyndaquil_Ch6:
duty_cycle 2
square_note 8, 2, -7, 263
-Cry_Cyndaquil_branch_f315f:
+.loop1:
square_note 0, 14, 1, 1155
square_note 0, 5, 1, 1102
- sound_loop 4, Cry_Cyndaquil_branch_f315f
-Cry_Cyndaquil_branch_f316b:
+ sound_loop 4, .loop1
+.loop2:
square_note 0, 14, 1, 986
square_note 1, 5, 1, 786
- sound_loop 4, Cry_Cyndaquil_branch_f316b
+ sound_loop 4, .loop2
sound_ret
Cry_Gligar_Ch8:
@@ -524,16 +522,16 @@
Cry_Gligar_Ch5:
duty_cycle_pattern 2, 2, 0, 2
- sound_jump Cry_Gligar_branch_f3145
+ sound_jump Cry_Mareep_Ch6.body
Cry_Girafarig_Ch5:
duty_cycle 1
pitch_offset 4
- sound_jump Cry_Girafarig_branch_f31af
+ sound_jump Cry_Girafarig_Ch6.body
Cry_Girafarig_Ch6:
duty_cycle_pattern 1, 0, 0, 1
-Cry_Girafarig_branch_f31af:
+.body:
square_note 4, 6, 8, 1880
square_note 2, 14, 8, 1888
square_note 2, 14, 8, 1895
@@ -568,11 +566,11 @@
Cry_Ledyba_Ch5:
pitch_offset 2
duty_cycle 2
- sound_jump Cry_Ledyba_branch_f3202
+ sound_jump Cry_Ledyba_Ch6.body
Cry_Ledyba_Ch6:
duty_cycle_pattern 0, 0, 0, 1
-Cry_Ledyba_branch_f3202:
+.body:
square_note 3, 15, 8, 1937
square_note 3, 13, 8, 1933
square_note 2, 0, 0, 0
@@ -631,24 +629,24 @@
Cry_Teddiursa_Ch5:
Cry_Typhlosion_Ch5:
duty_cycle_pattern 0, 1, 0, 2
-Cry_Teddiursa_branch_f3286:
+.loop1:
square_note 3, 12, 1, 1937
- sound_loop 3, Cry_Teddiursa_branch_f3286
-Cry_Teddiursa_branch_f328e:
+ sound_loop 3, .loop1
+.loop2:
square_note 3, 13, 1, 1201
- sound_loop 6, Cry_Teddiursa_branch_f328e
-Cry_Teddiursa_branch_f3296:
+ sound_loop 6, .loop2
+.loop3:
square_note 1, 13, 1, 1169
square_note 1, 11, 1, 1105
- sound_loop 6, Cry_Teddiursa_branch_f3296
-Cry_Teddiursa_branch_f32a2:
+ sound_loop 6, .loop3
+.loop4:
square_note 1, 10, 3, 1137
square_note 1, 8, 1, 1089
- sound_loop 6, Cry_Teddiursa_branch_f32a2
-Cry_Teddiursa_branch_f32ae:
+ sound_loop 6, .loop4
+.loop5:
square_note 1, 4, 1, 1057
square_note 1, 2, 1, 1025
- sound_loop 4, Cry_Teddiursa_branch_f32ae
+ sound_loop 4, .loop5
sound_ret
Cry_Teddiursa_Ch6:
@@ -672,12 +670,11 @@
Cry_Natu_Ch5:
duty_cycle_pattern 3, 1, 3, 2
-Cry_Mantine_branch_f32e9:
-Cry_Sunflora_branch_f32e9:
+.body1:
square_note 4, 15, 8, 1969
square_note 4, 15, 8, 1968
square_note 4, 4, 8, 1967
-Cry_Mantine_branch_f32f5:
+.body2:
square_note 4, 15, 8, 1970
square_note 4, 15, 8, 1971
square_note 4, 4, 8, 1972
@@ -685,12 +682,12 @@
Cry_Natu_Ch6:
Cry_Sunflora_Ch6:
-Cry_Mantine_branch_f3302:
+.body1:
duty_cycle_pattern 3, 3, 0, 2
square_note 4, 15, 8, 1970
square_note 4, 15, 8, 1969
square_note 4, 2, 8, 1968
-Cry_Mantine_branch_f3310:
+.body2:
square_note 4, 15, 8, 1972
square_note 4, 15, 8, 1974
square_note 4, 4, 8, 1976
@@ -698,11 +695,11 @@
Cry_Natu_Ch8:
Cry_Sunflora_Ch8:
-Cry_Mantine_branch_f331d:
+.body1:
noise_note 4, 8, 8, 5
noise_note 4, 8, 8, 4
noise_note 4, 3, 8, 3
-Cry_Mantine_branch_f3326:
+.body2:
noise_note 4, 8, 8, 5
noise_note 4, 8, 8, 4
noise_note 4, 8, 7, 4
@@ -715,30 +712,30 @@
Cry_Sunflora_Ch5:
duty_cycle 0
- sound_jump Cry_Sunflora_branch_f32e9
+ sound_jump Cry_Natu_Ch5.body1
Cry_Mantine_Ch5:
duty_cycle 0
- sound_call Cry_Mantine_branch_f32e9
- sound_call Cry_Mantine_branch_f32f5
+ sound_call Cry_Natu_Ch5.body1
+ sound_call Cry_Natu_Ch5.body2
sound_ret
Cry_Mantine_Ch6:
- sound_call Cry_Mantine_branch_f3302
- sound_call Cry_Mantine_branch_f3310
+ sound_call Cry_Sunflora_Ch6.body1
+ sound_call Cry_Sunflora_Ch6.body2
sound_ret
Cry_Mantine_Ch8:
- sound_call Cry_Mantine_branch_f331d
- sound_call Cry_Mantine_branch_f3326
+ sound_call Cry_Sunflora_Ch8.body1
+ sound_call Cry_Sunflora_Ch8.body2
sound_ret
Cry_Ampharos_Ch5:
duty_cycle_pattern 3, 1, 3, 2
-Cry_Ampharos_branch_f3355:
+.loop:
square_note 1, 12, 1, 1312
square_note 1, 10, 1, 1056
- sound_loop 4, Cry_Ampharos_branch_f3355
+ sound_loop 4, .loop
duty_cycle 0
square_note 4, 7, 8, 1888
square_note 4, 7, 8, 1840
@@ -833,15 +830,15 @@
Cry_Aipom_Ch6:
duty_cycle_pattern 0, 2, 1, 3
-Cry_Aipom_branch_f3443:
+.loop1:
square_note 1, 15, 1, 1972
- sound_loop 8, Cry_Aipom_branch_f3443
-Cry_Aipom_branch_f344b:
+ sound_loop 8, .loop1
+.loop2:
square_note 1, 12, 1, 1936
- sound_loop 3, Cry_Aipom_branch_f344b
-Cry_Aipom_branch_f3453:
+ sound_loop 3, .loop2
+.loop3:
square_note 1, 11, 1, 1933
- sound_loop 2, Cry_Aipom_branch_f3453
+ sound_loop 2, .loop3
square_note 16, 9, 2, 1941
sound_ret
--- a/audio/sfx.asm
+++ b/audio/sfx.asm
@@ -4496,9 +4496,9 @@
Sfx_Supersonic_Ch5:
duty_cycle 2
square_note 15, 3, -7, 1984
-Sfx_Supersonic_branch_f21ef:
+.loop:
square_note 15, 13, -7, 1984
- sound_loop 4, Sfx_Supersonic_branch_f21ef
+ sound_loop 4, .loop
square_note 15, 13, 1, 1984
sound_ret
@@ -4505,9 +4505,9 @@
Sfx_Supersonic_Ch6:
duty_cycle_pattern 2, 3, 0, 3
square_note 15, 2, -7, 1992
-Sfx_Supersonic_branch_f2202:
+.loop:
square_note 15, 12, -7, 1991
- sound_loop 4, Sfx_Supersonic_branch_f2202
+ sound_loop 4, .loop
square_note 15, 12, 1, 1992
sound_ret
@@ -4839,10 +4839,10 @@
square_note 2, 15, 1, 1984
square_note 2, 15, 1, 1792
square_note 2, 15, 1, 2000
-Sfx_HyperBeam_branch_f24f8:
+.loop:
square_note 2, 15, 1, 1792
square_note 2, 15, 1, 2016
- sound_loop 12, Sfx_HyperBeam_branch_f24f8
+ sound_loop 12, .loop
square_note 15, 15, 1, 1792
sound_ret
@@ -4859,10 +4859,10 @@
square_note 2, 15, 1, 1985
square_note 2, 15, 1, 1793
square_note 2, 15, 1, 2001
-Sfx_HyperBeam_branch_f2537:
+.loop:
square_note 2, 15, 1, 1793
square_note 2, 15, 1, 2017
- sound_loop 12, Sfx_HyperBeam_branch_f2537
+ sound_loop 12, .loop
square_note 15, 15, 1, 1793
sound_ret
@@ -4966,10 +4966,10 @@
sound_ret
Sfx_Unknown5F_Ch5:
-Sfx_Unknown5F_branch_f2617:
+.loop:
square_note 2, 15, 7, 1537
square_note 2, 15, 7, 1793
- sound_loop 8, Sfx_Unknown5F_Ch5
+ sound_loop 8, .loop
sound_ret
Sfx_Unknown5F_Ch6:
@@ -4976,7 +4976,7 @@
square_note 1, 15, 7, 65535
square_note 2, 15, 7, 1538
square_note 2, 15, 7, 1794
- sound_loop 8, Sfx_Unknown5F_branch_f2617
+ sound_loop 8, Sfx_Unknown5F_Ch5.loop
sound_ret
Sfx_Fanfare2_Ch5:
@@ -5160,9 +5160,9 @@
Sfx_Elevator_Ch5:
duty_cycle 2
pitch_sweep 5, -2
-Sfx_Elevator_branch_f2726:
+.loop:
square_note 2, 15, 1, 768
- sound_loop 48, Sfx_Elevator_branch_f2726
+ sound_loop 48, .loop
pitch_sweep 0, 8
duty_cycle 2
square_note 15, 15, 3, 1840
--- a/constants/pokemon_data_constants.asm
+++ b/constants/pokemon_data_constants.asm
@@ -96,8 +96,8 @@
MON_SPD EQUS "(wPartyMon1Speed - wPartyMon1)"
MON_SAT EQUS "(wPartyMon1SpclAtk - wPartyMon1)"
MON_SDF EQUS "(wPartyMon1SpclDef - wPartyMon1)"
-BOXMON_STRUCT_LENGTH EQUS "(wPartyMon1End - wPartyMon1)"
-PARTYMON_STRUCT_LENGTH EQUS "(wPartyMon1StatsEnd - wPartyMon1)"
+BOXMON_STRUCT_LENGTH EQUS "(wPartyMon1BoxEnd - wPartyMon1)"
+PARTYMON_STRUCT_LENGTH EQUS "(wPartyMon1StructEnd - wPartyMon1)"
NICKNAMED_MON_STRUCT_LENGTH EQUS "(PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH)"
REDMON_STRUCT_LENGTH EQU 44
--- a/engine/battle/ai/items.asm
+++ b/engine/battle/ai/items.asm
@@ -711,7 +711,7 @@
text_far _EnemyWithdrewText
text_end
-Function384d5: ; This appears to be unused
+EnemyUsedFullHealRed: ; unreferenced
call AIUsedItemSound
call AI_HealStatus
ld a, FULL_HEAL_RED ; X_SPEED
@@ -758,7 +758,7 @@
ld a, DIRE_HIT
jp PrintText_UsedItemOn_AND_AIUpdateHUD
-Function3851e: ; This appears to be unused
+Function3851e: ; unreferenced
ldh [hDivisor], a
ld hl, wEnemyMonMaxHP
ld a, [hli]
--- a/engine/battle/ai/move.asm
+++ b/engine/battle/ai/move.asm
@@ -50,7 +50,7 @@
.CheckMovePP:
inc b
ld a, b
- cp wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ cp NUM_MOVES + 1
jr z, .ApplyLayers
inc hl
ld a, [de]
@@ -119,7 +119,7 @@
.DecrementScores:
ld hl, wBuffer1
ld de, wEnemyMonMoves
- ld c, wEnemyMonMovesEnd - wEnemyMonMoves
+ ld c, NUM_MOVES
.DecrementNextScore:
; If the enemy has no moves, this will infinite.
--- a/engine/battle/ai/scoring.asm
+++ b/engine/battle/ai/scoring.asm
@@ -8,7 +8,7 @@
ld hl, wBuffer1 - 1
ld de, wEnemyMonMoves
- ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld b, NUM_MOVES + 1
.checkmove
dec b
ret z
@@ -75,7 +75,7 @@
ld hl, wBuffer1 - 1
ld de, wEnemyMonMoves
- ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld b, NUM_MOVES + 1
.checkmove
dec b
ret z
@@ -149,7 +149,7 @@
ld hl, wBuffer1 - 1
ld de, wEnemyMonMoves
- ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld b, NUM_MOVES + 1
.checkmove
dec b
ret z
@@ -195,15 +195,15 @@
ld a, [wEnemyMoveStruct + MOVE_TYPE]
ld d, a
ld hl, wEnemyMonMoves
- ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld b, NUM_MOVES + 1
ld c, 0
.checkmove2
dec b
- jr z, .asm_38693
+ jr z, .movesdone
ld a, [hli]
and a
- jr z, .asm_38693
+ jr z, .movesdone
call AIGetEnemyMove
ld a, [wEnemyMoveStruct + MOVE_TYPE]
@@ -211,12 +211,12 @@
jr z, .checkmove2
ld a, [wEnemyMoveStruct + MOVE_POWER]
and a
- jr nz, .asm_38692
+ jr nz, .damaging
jr .checkmove2
-.asm_38692
+.damaging
ld c, a
-.asm_38693
+.movesdone
ld a, c
pop bc
pop de
@@ -236,7 +236,7 @@
ld hl, wBuffer1 - 1
ld de, wEnemyMonMoves
- ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld b, NUM_MOVES + 1
.checkmove
dec b
ret z
@@ -263,7 +263,7 @@
ld hl, wBuffer1
ld de, wEnemyMonMoves
- ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld b, NUM_MOVES + 1
.checkmove
dec b
ret z
@@ -279,7 +279,7 @@
call AIGetEnemyMove
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
- ld hl, .table_386f2
+ ld hl, AI_Smart_EffectHandlers
ld de, 3
call IsInArray
@@ -306,7 +306,7 @@
inc hl
jr .checkmove
-.table_386f2
+AI_Smart_EffectHandlers:
dbw EFFECT_SLEEP, AI_Smart_Sleep
dbw EFFECT_LEECH_HIT, AI_Smart_LeechHit
dbw EFFECT_SELFDESTRUCT, AI_Smart_Selfdestruct
@@ -395,13 +395,13 @@
ld b, EFFECT_DREAM_EATER
call AIHasMoveEffect
- jr c, .asm_387f0
+ jr c, .encourage
ld b, EFFECT_NIGHTMARE
call AIHasMoveEffect
ret nc
-.asm_387f0
+.encourage
call AI_50_50
ret c
dec [hl]
@@ -418,7 +418,7 @@
; 60% chance to discourage this move if not very effective.
ld a, [wTypeMatchup]
cp EFFECTIVE
- jr c, .asm_38815
+ jr c, .discourage
; Do nothing if effectiveness is neutral.
ret z
@@ -434,7 +434,7 @@
dec [hl]
ret
-.asm_38815
+.discourage
call Random
cp 39 percent + 1
ret c
@@ -471,7 +471,7 @@
jr c, .asm_38875
ld hl, wEnemyMonMoves
- ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld c, NUM_MOVES + 1
.asm_3884f
dec c
jr z, .asm_38877
@@ -520,7 +520,7 @@
push hl
ld hl, wBuffer1 - 1
ld de, wEnemyMonMoves
- ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld c, NUM_MOVES + 1
.asm_3888b
inc hl
@@ -553,18 +553,18 @@
push hl
farcall FindAliveEnemyMons
pop hl
- jr nc, .asm_388b7
+ jr nc, .notlastmon
; ...greatly discourage this move unless this is the player's last Pokemon too.
push hl
call AICheckLastPlayerMon
pop hl
- jr nz, .asm_388c6
+ jr nz, .discourage
-.asm_388b7
+.notlastmon
; Greatly discourage this move if enemy's HP is above 50%.
call AICheckEnemyHalfHP
- jr c, .asm_388c6
+ jr c, .discourage
; Do nothing if enemy's HP is below 25%.
call AICheckEnemyQuarterHP
@@ -576,7 +576,7 @@
cp 8 percent
ret c
-.asm_388c6
+.discourage
inc [hl]
inc [hl]
inc [hl]
@@ -607,7 +607,7 @@
; ...greatly encourage this move if player is badly poisoned.
ld a, [wPlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
- jr nz, .asm_388ef
+ jr nz, .encourage
; ...70% chance to greatly encourage this move if player is not badly poisoned.
call Random
@@ -614,7 +614,7 @@
cp 70 percent
jr nc, .asm_38911
-.asm_388ef
+.encourage
dec [hl]
dec [hl]
ret
@@ -628,7 +628,7 @@
; If enemy's HP is above 25% but not full, 4% chance to greatly encourage this move.
call Random
cp 4 percent
- jr c, .asm_388ef
+ jr c, .encourage
; If enemy's HP is between 25% and 50%,...
call AICheckEnemyHalfHP
@@ -636,7 +636,7 @@
; If enemy's HP is above 50% but not full, 20% chance to greatly encourage this move.
call AI_80_20
- jr c, .asm_388ef
+ jr c, .encourage
jr .asm_38911
.asm_3890a
@@ -672,11 +672,11 @@
; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout.
ld a, [wPlayerFuryCutterCount]
and a
- jr nz, .asm_388ef
+ jr nz, .encourage
ld a, [wPlayerSubStatus1]
bit SUBSTATUS_ROLLOUT, a
- jr nz, .asm_388ef
+ jr nz, .encourage
.asm_38936
inc [hl]
@@ -709,7 +709,7 @@
; ...enemy's accuracy level has been lowered three or more stages
ld a, [wEnemyAccLevel]
cp BASE_STAT_LEVEL - 2
- jr c, .asm_38954
+ jr c, .encourage
; ...or player's evasion level has been raised three or more stages.
ld a, [wPlayerEvaLevel]
@@ -716,7 +716,7 @@
cp BASE_STAT_LEVEL + 3
ret c
-.asm_38954
+.encourage
call AI_80_20
ret c
@@ -728,7 +728,7 @@
; If the player did not use any move last turn...
ld a, [wLastPlayerCounterMove]
and a
- jr nz, .asm_38968
+ jr nz, .usedmove
; ...do nothing if enemy is slower than player
call AICompareSpeed
@@ -738,7 +738,7 @@
jp AIDiscourageMove
; If the player did use a move last turn...
-.asm_38968
+.usedmove
push hl
ld hl, UsefulMoves
ld de, 1
@@ -777,7 +777,7 @@
; ...greatly encourage this move if player is badly poisoned.
ld a, [wPlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
- jr nz, .asm_3899d
+ jr nz, .encourage
; ...70% chance to greatly encourage this move if player is not badly poisoned.
call Random
@@ -784,7 +784,7 @@
cp 70 percent
jr nc, .asm_389bf
-.asm_3899d
+.encourage
dec [hl]
dec [hl]
ret
@@ -798,7 +798,7 @@
; If player's HP is above 25% but not full, 4% chance to greatly encourage this move.
call Random
cp 4 percent
- jr c, .asm_3899d
+ jr c, .encourage
; If player's HP is between 25% and 50%,...
call AICheckPlayerHalfHP
@@ -806,7 +806,7 @@
; If player's HP is above 50% but not full, 20% chance to greatly encourage this move.
call AI_80_20
- jr c, .asm_3899d
+ jr c, .encourage
jr .asm_389bf
; ...50% chance to greatly discourage this move.
@@ -838,11 +838,11 @@
; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout.
ld a, [wPlayerFuryCutterCount]
and a
- jr nz, .asm_3899d
+ jr nz, .encourage
ld a, [wPlayerSubStatus1]
bit SUBSTATUS_ROLLOUT, a
- jr nz, .asm_3899d
+ jr nz, .encourage
.asm_389e4
inc [hl]
@@ -874,26 +874,26 @@
push hl
ld hl, wEnemyAtkLevel
ld c, NUM_LEVEL_STATS
-.asm_389fb
+.enemystatsloop
dec c
- jr z, .asm_38a05
+ jr z, .enemystatsdone
ld a, [hli]
cp BASE_STAT_LEVEL - 2
- jr c, .asm_38a12
- jr .asm_389fb
+ jr c, .encourage
+ jr .enemystatsloop
; 85% chance to encourage this move if any of player's stat levels is higher than +2.
-.asm_38a05
+.enemystatsdone
ld hl, wPlayerAtkLevel
- ld c, $8
-.asm_38a0a
+ ld c, NUM_LEVEL_STATS
+.playerstatsloop
dec c
- jr z, .asm_38a1b
+ jr z, .discourage
ld a, [hli]
cp BASE_STAT_LEVEL + 3
- jr c, .asm_38a0a
+ jr c, .playerstatsloop
-.asm_38a12
+.encourage
pop hl
call Random
cp 16 percent
@@ -904,7 +904,7 @@
; Discourage this move if neither:
; Any of enemy's stat levels is lower than -2.
; Any of player's stat levels is higher than +2.
-.asm_38a1b
+.discourage
pop hl
inc [hl]
ret
@@ -945,13 +945,13 @@
; Do nothing otherwise.
call AICheckEnemyQuarterHP
- jr nc, .asm_38a45
+ jr nc, .encourage
call AICheckEnemyHalfHP
ret nc
inc [hl]
ret
-.asm_38a45
+.encourage
call Random
cp 10 percent
ret c
@@ -1000,31 +1000,31 @@
; 50% chance to discourage this move if the player is already trapped.
ld a, [wPlayerWrapCount]
and a
- jr nz, .asm_38a8b
+ jr nz, .discourage
; 50% chance to greatly encourage this move if player is either
; badly poisoned, in love, identified, stuck in Rollout, or has a Nightmare.
ld a, [wPlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
- jr nz, .asm_38a91
+ jr nz, .encourage
ld a, [wPlayerSubStatus1]
and 1 << SUBSTATUS_IN_LOVE | 1 << SUBSTATUS_ROLLOUT | 1 << SUBSTATUS_IDENTIFIED | 1 << SUBSTATUS_NIGHTMARE
- jr nz, .asm_38a91
+ jr nz, .encourage
; Else, 50% chance to greatly encourage this move if it's the player's Pokemon first turn.
ld a, [wPlayerTurnsTaken]
and a
- jr z, .asm_38a91
+ jr z, .encourage
; 50% chance to discourage this move otherwise.
-.asm_38a8b
+.discourage
call AI_50_50
ret c
inc [hl]
ret
-.asm_38a91
+.encourage
call AICheckEnemyQuarterHP
ret nc
call AI_50_50
@@ -1092,10 +1092,10 @@
ret c
call Random
cp 10 percent
- jr c, .asm_38ae7
+ jr c, .skipdiscourage
inc [hl]
-.asm_38ae7
+.skipdiscourage
; Discourage again if player's HP is below 25%.
call AICheckPlayerQuarterHP
ret c
@@ -1105,12 +1105,12 @@
AI_Smart_SpDefenseUp2:
; Discourage this move if enemy's HP is lower than 50%.
call AICheckEnemyHalfHP
- jr nc, .asm_38b10
+ jr nc, .discourage
; Discourage this move if enemy's special defense level is higher than +3.
ld a, [wEnemySDefLevel]
cp BASE_STAT_LEVEL + 4
- jr nc, .asm_38b10
+ jr nc, .discourage
; 80% chance to greatly encourage this move if
; enemy's Special Defense level is lower than +2, and the player is of a special type.
@@ -1119,12 +1119,12 @@
ld a, [wBattleMonType1]
cp SPECIAL
- jr nc, .asm_38b09
+ jr nc, .encourage
ld a, [wBattleMonType2]
cp SPECIAL
ret c
-.asm_38b09
+.encourage
call AI_80_20
ret c
dec [hl]
@@ -1131,7 +1131,7 @@
dec [hl]
ret
-.asm_38b10
+.discourage
inc [hl]
ret
@@ -1164,7 +1164,7 @@
AI_Smart_Paralyze:
; 50% chance to discourage this move if player's HP is below 25%.
call AICheckPlayerQuarterHP
- jr nc, .asm_38b3a
+ jr nc, .discourage
; 80% chance to greatly encourage this move
; if enemy is slower than player and its HP is above 25%.
@@ -1178,7 +1178,7 @@
dec [hl]
ret
-.asm_38b3a
+.discourage
call AI_50_50
ret c
inc [hl]
@@ -1218,7 +1218,7 @@
AI_Smart_HyperBeam:
call AICheckEnemyHalfHP
- jr c, .asm_38b72
+ jr c, .discourage
; 50% chance to encourage this move if enemy's HP is below 25%.
call AICheckEnemyQuarterHP
@@ -1228,7 +1228,7 @@
dec [hl]
ret
-.asm_38b72
+.discourage
; If enemy's HP is above 50%, discourage this move at random
call Random
cp 16 percent
@@ -1242,16 +1242,16 @@
AI_Smart_Rage:
ld a, [wEnemySubStatus4]
bit SUBSTATUS_RAGE, a
- jr z, .asm_38b9b
+ jr z, .notbuilding
; If enemy's Rage is building, 50% chance to encourage this move.
call AI_50_50
- jr c, .asm_38b8c
+ jr c, .skipencourage
dec [hl]
; Encourage this move based on Rage's counter.
-.asm_38b8c
+.skipencourage
ld a, [wEnemyRageCounter]
cp 2
ret c
@@ -1262,10 +1262,10 @@
dec [hl]
ret
-.asm_38b9b
+.notbuilding
; If enemy's Rage is not building, discourage this move if enemy's HP is below 50%.
call AICheckEnemyHalfHP
- jr nc, .asm_38ba6
+ jr nc, .discourage
; 50% chance to encourage this move otherwise.
call AI_80_20
@@ -1273,7 +1273,7 @@
dec [hl]
ret
-.asm_38ba6
+.discourage
inc [hl]
ret
@@ -1332,66 +1332,66 @@
ld c, NUM_MOVES
ld b, 0
-.asm_38bf9
+.playermoveloop
ld a, [hli]
and a
- jr z, .asm_38c0e
+ jr z, .skipmove
call AIGetEnemyMove
ld a, [wEnemyMoveStruct + MOVE_POWER]
and a
- jr z, .asm_38c0e
+ jr z, .skipmove
ld a, [wEnemyMoveStruct + MOVE_TYPE]
cp SPECIAL
- jr nc, .asm_38c0e
+ jr nc, .skipmove
inc b
-.asm_38c0e
+.skipmove
dec c
- jr nz, .asm_38bf9
+ jr nz, .playermoveloop
pop hl
ld a, b
and a
- jr z, .asm_38c39
+ jr z, .discourage
- cp $3
- jr nc, .asm_38c30
+ cp 3
+ jr nc, .encourage
ld a, [wLastPlayerCounterMove]
and a
- jr z, .asm_38c38
+ jr z, .done
call AIGetEnemyMove
ld a, [wEnemyMoveStruct + MOVE_POWER]
and a
- jr z, .asm_38c38
+ jr z, .done
ld a, [wEnemyMoveStruct + MOVE_TYPE]
cp SPECIAL
- jr nc, .asm_38c38
+ jr nc, .done
-.asm_38c30
+.encourage
call Random
cp 39 percent + 1
- jr c, .asm_38c38
+ jr c, .done
dec [hl]
-.asm_38c38
+.done
ret
-.asm_38c39
+.discourage
inc [hl]
ret
AI_Smart_Encore:
call AICompareSpeed
- jr nc, .asm_38c81
+ jr nc, .discourage
ld a, [wLastPlayerMove]
and a
@@ -1401,7 +1401,7 @@
ld a, [wEnemyMoveStruct + MOVE_POWER]
and a
- jr z, .asm_38c68
+ jr z, .weakmove
push hl
ld a, [wEnemyMoveStruct + MOVE_TYPE]
@@ -1411,13 +1411,13 @@
pop hl
ld a, [wTypeMatchup]
cp EFFECTIVE
- jr nc, .asm_38c68
+ jr nc, .weakmove
and a
ret nz
- jr .asm_38c78
+ jr .encourage
-.asm_38c68
+.weakmove
push hl
ld a, [wLastPlayerCounterMove]
ld hl, EncoreMoves
@@ -1424,9 +1424,9 @@
ld de, 1
call IsInArray
pop hl
- jr nc, .asm_38c81
+ jr nc, .discourage
-.asm_38c78
+.encourage
call Random
cp 28 percent - 1
ret c
@@ -1434,7 +1434,7 @@
dec [hl]
ret
-.asm_38c81
+.discourage
inc [hl]
inc [hl]
inc [hl]
@@ -1470,7 +1470,7 @@
ld a, [wEnemyMonStatus]
and SLP
cp 1
- jr z, .asm_38cc7
+ jr z, .discourage
dec [hl]
dec [hl]
@@ -1477,7 +1477,7 @@
dec [hl]
ret
-.asm_38cc7
+.discourage
inc [hl]
inc [hl]
inc [hl]
@@ -1498,7 +1498,7 @@
AI_Smart_Spite:
ld a, [wLastPlayerCounterMove]
and a
- jr nz, .asm_38ce7
+ jr nz, .usedmove
call AICompareSpeed
jp c, AIDiscourageMove
@@ -1508,7 +1508,7 @@
inc [hl]
ret
-.asm_38ce7
+.usedmove
push hl
ld b, a
ld c, NUM_MOVES
@@ -1515,35 +1515,35 @@
ld hl, wBattleMonMoves
ld de, wBattleMonPP
-.asm_38cf1
+.moveloop
ld a, [hli]
cp b
- jr z, .asm_38cfb
+ jr z, .foundmove
inc de
dec c
- jr nz, .asm_38cf1
+ jr nz, .moveloop
pop hl
ret
-.asm_38cfb
+.foundmove
pop hl
ld a, [de]
cp 6
- jr c, .asm_38d0d
+ jr c, .encourage
cp 15
- jr nc, .asm_38d0b
+ jr nc, .discourage
call Random
cp 39 percent + 1
ret nc
-.asm_38d0b
+.discourage
inc [hl]
ret
-.asm_38d0d
+.encourage
call Random
cp 39 percent + 1
ret c
@@ -1551,7 +1551,7 @@
dec [hl]
ret
-Function_0x38d16:
+CallAIDiscourageMove: ; unreferenced
jp AIDiscourageMove
AI_Smart_DestinyBond:
@@ -1663,7 +1663,7 @@
AI_Smart_Conversion2:
ld a, [wLastPlayerMove]
and a
- jr nz, .asm_38dc9
+ jr nz, .discourage
push hl
dec a
@@ -1683,7 +1683,7 @@
ld a, [wTypeMatchup]
cp EFFECTIVE
pop hl
- jr c, .asm_38dc9
+ jr c, .discourage
ret z
call AI_50_50
@@ -1692,7 +1692,7 @@
dec [hl]
ret
-.asm_38dc9
+.discourage
call Random
cp 10 percent
ret c
@@ -1701,7 +1701,7 @@
AI_Smart_Disable:
call AICompareSpeed
- jr nc, .asm_38df3
+ jr nc, .discourage
push hl
ld a, [wLastPlayerCounterMove]
@@ -1710,7 +1710,7 @@
call IsInArray
pop hl
- jr nc, .asm_38dee
+ jr nc, .notencourage
call Random
cp 39 percent + 1
@@ -1718,12 +1718,12 @@
dec [hl]
ret
-.asm_38dee
+.notencourage
ld a, [wEnemyMoveStruct + MOVE_POWER]
and a
ret nz
-.asm_38df3
+.discourage
call Random
cp 8 percent
ret c
@@ -1732,7 +1732,7 @@
AI_Smart_MeanLook:
call AICheckEnemyHalfHP
- jr nc, .asm_38e24
+ jr nc, .discourage
push hl
call AICheckLastPlayerMon
@@ -1743,13 +1743,13 @@
; Should check wPlayerSubStatus5 instead.
ld a, [wEnemySubStatus5]
bit SUBSTATUS_TOXIC, a
- jr nz, .asm_38e26
+ jr nz, .encourage
; 80% chance to greatly encourage this move if the player is either
; in love, identified, stuck in Rollout, or has a Nightmare.
ld a, [wPlayerSubStatus1]
and 1 << SUBSTATUS_IN_LOVE | 1 << SUBSTATUS_ROLLOUT | 1 << SUBSTATUS_IDENTIFIED | 1 << SUBSTATUS_NIGHTMARE
- jr nz, .asm_38e26
+ jr nz, .encourage
; Otherwise, discourage this move unless the player only has not very effective moves against the enemy.
push hl
@@ -1759,11 +1759,11 @@
pop hl
ret nc
-.asm_38e24
+.discourage
inc [hl]
ret
-.asm_38e26
+.encourage
call AI_80_20
ret c
dec [hl]
@@ -1781,7 +1781,7 @@
.loop
ld a, [wCurBattleMon]
cp c
- jr z, .asm_38e44
+ jr z, .skip
ld a, [hli]
or [hl]
@@ -1788,7 +1788,7 @@
ret nz
dec hl
-.asm_38e44
+.skip
add hl, de
inc c
dec b
@@ -2246,13 +2246,13 @@
; 80% chance to discourage this move otherwise.
call AICheckPlayerQuarterHP
- jr nc, .asm_3907d
+ jr nc, .encourage
call AI_80_20
ret c
inc [hl]
ret
-.asm_3907d
+.encourage
call AI_50_50
ret c
dec [hl]
@@ -2265,17 +2265,17 @@
ld a, [wEnemyWrapCount]
and a
- jr nz, .asm_39097
+ jr nz, .encourage
ld a, [wEnemySubStatus4]
bit SUBSTATUS_LEECH_SEED, a
- jr nz, .asm_39097
+ jr nz, .encourage
ld a, [wEnemyScreens]
bit SCREENS_SPIKES, a
ret z
-.asm_39097
+.encourage
call AI_80_20
ret c
@@ -2419,7 +2419,7 @@
ld a, [wEnemyAtkLevel]
cp BASE_STAT_LEVEL + 3
- jr nc, .asm_3914d
+ jr nc, .discourage
call AICheckEnemyMaxHP
ret c
@@ -2429,9 +2429,9 @@
call AICheckEnemyHalfHP
ret c
-.asm_3914d
+.discourage
ld a, [hl]
- add $5
+ add 5
ld [hl], a
ret
@@ -2498,59 +2498,59 @@
ld c, NUM_MOVES
ld b, 0
-.asm_39193
+.playermoveloop
ld a, [hli]
and a
- jr z, .asm_391a8
+ jr z, .skipmove
call AIGetEnemyMove
ld a, [wEnemyMoveStruct + MOVE_POWER]
and a
- jr z, .asm_391a8
+ jr z, .skipmove
ld a, [wEnemyMoveStruct + MOVE_TYPE]
cp SPECIAL
- jr c, .asm_391a8
+ jr c, .skipmove
inc b
-.asm_391a8
+.skipmove
dec c
- jr nz, .asm_39193
+ jr nz, .playermoveloop
pop hl
ld a, b
and a
- jr z, .asm_391d3
+ jr z, .discourage
- cp $3
- jr nc, .asm_391ca
+ cp 3
+ jr nc, .encourage
ld a, [wLastPlayerCounterMove]
and a
- jr z, .asm_391d2
+ jr z, .done
call AIGetEnemyMove
ld a, [wEnemyMoveStruct + MOVE_POWER]
and a
- jr z, .asm_391d2
+ jr z, .done
ld a, [wEnemyMoveStruct + MOVE_TYPE]
cp SPECIAL
- jr c, .asm_391d2
+ jr c, .done
-.asm_391ca
+.encourage
call Random
- cp 100
- jr c, .asm_391d2
+ cp 39 percent + 1
+ jr c, .done
dec [hl]
-.asm_391d2
+.done
ret
-.asm_391d3
+.discourage
inc [hl]
ret
@@ -2617,7 +2617,7 @@
ld a, [wBattleWeather]
cp WEATHER_SUN
- jr z, .asm_3921e
+ jr z, .encourage
cp WEATHER_RAIN
ret nz
@@ -2630,7 +2630,7 @@
inc [hl]
ret
-.asm_3921e
+.encourage
call AI_80_20
ret c
@@ -2689,12 +2689,12 @@
ld a, [de]
inc de
cp [hl]
- jr nz, .asm_39269
+ jr nz, .not_max
inc hl
ld a, [de]
cp [hl]
- jr nz, .asm_39269
+ jr nz, .not_max
pop bc
pop de
@@ -2702,7 +2702,7 @@
scf
ret
-.asm_39269
+.not_max
pop bc
pop de
pop hl
@@ -2794,7 +2794,7 @@
push hl
ld hl, wEnemyMonMoves
- ld c, wEnemyMonMovesEnd - wEnemyMonMoves
+ ld c, NUM_MOVES
.checkmove
ld a, [hli]
@@ -2833,7 +2833,7 @@
jr z, .done
ld b, a
- ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld c, NUM_MOVES + 1
ld de, wEnemyMonMoves
.check
@@ -2864,25 +2864,25 @@
; Discourage stall moves if enemy's HP is below 25%.
call AICheckEnemyQuarterHP
- jr nc, .asm_39322
+ jr nc, .lowhp
; 50% chance to discourage stall moves if enemy's HP is between 25% and 50%.
call AI_50_50
ret c
-.asm_39322
+.lowhp
ld hl, wBuffer1 - 1
ld de, wEnemyMonMoves
- ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld c, NUM_MOVES + 1
.checkmove
inc hl
dec c
- jr z, .asm_39347
+ jr z, .done
ld a, [de]
inc de
and a
- jr z, .asm_39347
+ jr z, .done
push hl
push de
@@ -2899,7 +2899,7 @@
inc [hl]
jr .checkmove
-.asm_39347
+.done
ret
INCLUDE "data/battle/ai/stall_moves.asm"
@@ -2919,7 +2919,7 @@
.checkmove
inc b
ld a, b
- cp wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ cp NUM_MOVES + 1
jr z, .gotstrongestmove
ld a, [hli]
@@ -2971,7 +2971,7 @@
.checkmove2
inc b
ld a, b
- cp wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ cp NUM_MOVES + 1
jr z, .done
; Ignore this move if it is the highest damaging one.
@@ -3019,11 +3019,11 @@
ld de, 1
ld hl, ConstantDamageEffects
call IsInArray
- jr nc, .asm_39400
+ jr nc, .notconstant
callfar BattleCommand_ConstantDamage
ret
-.asm_39400
+.notconstant
callfar EnemyAttackDamage
callfar BattleCommand_DamageCalc
callfar BattleCommand_Stab
@@ -3040,8 +3040,8 @@
ld hl, wBuffer1 - 1
ld de, wEnemyMonMoves
- ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
-.asm_39425
+ ld c, NUM_MOVES + 1
+.loop
inc hl
dec c
ret z
@@ -3061,7 +3061,7 @@
pop bc
pop de
pop hl
- jr nc, .asm_39425
+ jr nc, .loop
call Random
cp 90 percent + 1
@@ -3068,7 +3068,7 @@
ret nc
inc [hl]
- jr .asm_39425
+ jr .loop
INCLUDE "data/battle/ai/residual_moves.asm"
@@ -3078,7 +3078,7 @@
ld hl, wBuffer1 - 1
ld de, wEnemyMonMoves
- ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld b, NUM_MOVES + 1
.checkmove
dec b
ret z
@@ -3141,7 +3141,7 @@
ld hl, wBuffer1 - 1
ld de, wEnemyMonMoves
- ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld c, NUM_MOVES + 1
.checkmove
inc hl
dec c
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -6403,7 +6403,7 @@
ld hl, wEnemyMonStats
ld de, wEnemyStats
- ld bc, wEnemyMonStatsEnd - wEnemyMonStats
+ ld bc, NUM_EXP_STATS * 2
call CopyBytes
ret
--- a/engine/events/daycare.asm
+++ b/engine/events/daycare.asm
@@ -480,7 +480,7 @@
ld bc, PARTYMON_STRUCT_LENGTH
call DayCare_GetCurrentPartyMember
ld hl, wEggMon
- ld bc, wEggMonEnd - wEggMon
+ ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
call GetBaseData
@@ -548,7 +548,7 @@
.UselessJump:
xor a
ld hl, wEggMon
- ld bc, wEggMonEnd - wEggMon
+ ld bc, BOXMON_STRUCT_LENGTH
call ByteFill
ld hl, wEggNick
ld bc, MON_NAME_LENGTH
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -26,7 +26,7 @@
\1CaughtGender::
\1CaughtLocation:: db
\1Level:: db
-\1End::
+\1BoxEnd::
ENDM
party_struct: MACRO
@@ -41,7 +41,7 @@
\1Speed:: dw
\1SpclAtk:: dw
\1SpclDef:: dw
-\1StatsEnd::
+\1StructEnd::
ENDM
red_box_struct: MACRO
@@ -80,7 +80,6 @@
\1Species:: db
\1Item:: db
\1Moves:: ds NUM_MOVES
-\1MovesEnd::
\1DVs:: dw
\1PP:: ds NUM_MOVES
\1Happiness:: db
@@ -94,7 +93,6 @@
\1Speed:: dw
\1SpclAtk:: dw
\1SpclDef:: dw
-\1StatsEnd::
\1Type::
\1Type1:: db
\1Type2:: db