summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--battle/core.asm172
-rw-r--r--battle/effect_commands.asm30
-rw-r--r--battle/effects/curse.asm4
-rw-r--r--battle/effects/rollout.asm13
-rw-r--r--constants/battle_constants.asm1
-rw-r--r--engine/scripting.asm6
-rw-r--r--main.asm46
-rw-r--r--maps/Route29.asm6
8 files changed, 147 insertions, 131 deletions
diff --git a/battle/core.asm b/battle/core.asm
index 1801434db..0c3cb5594 100644
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -57,9 +57,9 @@ Function3c000: ; 3c000
call Function30b4
ld a, [BattleType]
cp $2
- jp z, Function3c0e2
+ jp z, .asm_3c0e2
cp BATTLETYPE_TUTORIAL
- jp z, Function3c0e2
+ jp z, .asm_3c0e2
xor a
ld [CurPartyMon], a
.asm_3c06b
@@ -114,10 +114,9 @@ Function3c000: ; 3c000
.asm_3c0df
jp Function3c12f
-; 3c0e2
-Function3c0e2: ; 3c0e2
- jp Function3e139
+.asm_3c0e2
+ jp BattleMenu
; 3c0e5
@@ -162,9 +161,11 @@ Function3c0e5: ; 3c0e5
; 3c12f
Function3c12f: ; 3c12f
+.loop
call Function3c1bf
call Function3c3f5
- jp c, .asm_3c1be
+ jp c, .quit
+
xor a
ld [wPlayerIsSwitching], a
ld [wEnemyIsSwitching], a
@@ -173,58 +174,62 @@ Function3c12f: ; 3c12f
ld [$c740], a
ld [CurDamage], a
ld [CurDamage + 1], a
+
call Function3c27c
call UpdateBattleMonInParty
callba AIChooseMove
- call Function3d2f1
- jr nz, .asm_3c174
+
+ call IsMobileBattle
+ jr nz, .not_disconnected
callba Function100da5
callba Function100641
callba Function100dd8
- jp c, .asm_3c1be
+ jp c, .quit
+.not_disconnected
-.asm_3c174
call Function3c410
jr c, .asm_3c18a
.asm_3c179
- call Function3e139
- jr c, .asm_3c1be
+ call BattleMenu
+ jr c, .quit
ld a, [BattleEnded]
and a
- jr nz, .asm_3c1be
- ld a, [$d232]
+ jr nz, .quit
+ ld a, [$d232] ; roared/whirlwinded/teleported
and a
- jr nz, .asm_3c1be
-
+ jr nz, .quit
.asm_3c18a
call Function3c434
jr nz, .asm_3c179
+
call Function3c300
- jr c, .asm_3c1be
+ jr c, .quit
+
call Function3c314
jr c, .asm_3c19e
call Function3c5fe
jr .asm_3c1a1
-
.asm_3c19e
call Function3c664
-
.asm_3c1a1
call Function3d2e0
- jr c, .asm_3c1be
+ jr c, .quit
+
ld a, [$d232]
and a
- jr nz, .asm_3c1be
+ jr nz, .quit
+
ld a, [BattleEnded]
and a
- jr nz, .asm_3c1be
+ jr nz, .quit
+
call Function3c1d6
ld a, [BattleEnded]
and a
- jr nz, .asm_3c1be
- jp Function3c12f
+ jr nz, .quit
+ jp .loop
-.asm_3c1be
+.quit
ret
; 3c1bf
@@ -570,7 +575,7 @@ Function3c3f3: ; 3c3f3
Function3c3f5: ; 3c3f5
ld a, [BattleType]
- cp $6
+ cp BATTLETYPE_CONTEST
jr nz, .asm_3c40e
ld a, [$dc79]
and a
@@ -591,16 +596,20 @@ Function3c410: ; 3c410
ld a, [PlayerSubStatus4]
and 1 << SUBSTATUS_RECHARGE
jp nz, .quit
+
ld hl, EnemySubStatus3
res SUBSTATUS_FLINCHED, [hl]
ld hl, PlayerSubStatus3
res SUBSTATUS_FLINCHED, [hl]
+
ld a, [hl]
and 1 << SUBSTATUS_CHARGED | 1 << SUBSTATUS_ROLLOUT
jp nz, .quit
+
ld hl, PlayerSubStatus1
bit SUBSTATUS_ENCORED, [hl]
jp nz, .quit
+
and a
ret
@@ -2445,7 +2454,7 @@ Function3cfa4: ; 3cfa4
callab Function39939
ld hl, BattleText_0x809da
call StdBattleTextBox
- call Function3d2f1
+ call IsMobileBattle
jr z, .asm_3cff5
ld a, [InLinkBattle]
and a
@@ -2945,7 +2954,7 @@ Function3d2e0: ; 3d2e0
ret
; 3d2f1
-Function3d2f1: ; 3d2f1
+IsMobileBattle: ; 3d2f1
ld a, [InLinkBattle]
cp $4
ret
@@ -2971,25 +2980,25 @@ Function3d313: ; 3d313
; 3d329
Function3d329: ; 3d329
- call Function3d2f1
- jr z, .asm_3d335
+ call IsMobileBattle
+ jr z, .mobile
callba PartyMenuSelect
ret
-.asm_3d335
+.mobile
callba Function100cb5
ret
; 3d33c
PickPartyMonInBattle: ; 3d33c
-.asm_3d33c
+.loop
ld a, $2 ; Which PKMN?
ld [PartyMenuActionText], a
call Function3d313
call Function3d329
ret c
call Function3d887
- jr z, .asm_3d33c
+ jr z, .loop
xor a
ret
; 3d34f
@@ -3121,7 +3130,7 @@ LostBattle: ; 3d38e
.asm_3d40a
ld hl, LostAgainstText
- call Function3d2f1
+ call IsMobileBattle
jr z, .asm_3d417
.asm_3d412
@@ -3830,7 +3839,7 @@ Function3d8b3: ; 3d8b3
ld a, [BattleType]
cp $2
jp z, .asm_3d9a2
- cp $6
+ cp BATTLETYPE_CONTEST
jp z, .asm_3d9a2
cp BATTLETYPE_TRAP
jp z, .asm_3d98d
@@ -5075,54 +5084,56 @@ Function3e138: ; 3e138
ret
; 3e139
-Function3e139: ; 3e139
+BattleMenu: ; 3e139
xor a
ld [hBGMapMode], a
call Function30bf
ld a, [BattleType]
cp $2
- jr z, .asm_3e156
+ jr z, .ok
cp BATTLETYPE_TUTORIAL
- jr z, .asm_3e156
+ jr z, .ok
call EmptyBattleTextBox
call UpdateBattleHuds
call EmptyBattleTextBox
call Function309d
-.asm_3e156
+.ok
+.loop
ld a, [BattleType]
- cp $6
- jr nz, .asm_3e165
- callba Function24f13
- jr .asm_3e175
-.asm_3e165
+ cp BATTLETYPE_CONTEST
+ jr nz, .not_contest
+ callba ContestBattleMenu
+ jr .next
+.not_contest
+ ; Auto input: choose "ITEM"
ld a, [InputType]
or a
jr z, .asm_3e171
callba Function1de294
.asm_3e171
- call Function3e19b
+ call LoadBattleMenu2
ret c
-.asm_3e175
+.next
ld a, $1
ld [hBGMapMode], a
ld a, [$d0d2]
cp $1
- jp z, Function3e192
+ jp z, BattleMenu_Fight
cp $3
- jp z, Function3e1c7
+ jp z, BattleMenu_Pack
cp $2
- jp z, Function3e28d
+ jp z, BattleMenu_PKMN
cp $4
- jp z, Function3e489
- jr .asm_3e156
+ jp z, BattleMenu_Run
+ jr .loop
; 3e192
-Function3e192: ; 3e192
+BattleMenu_Fight: ; 3e192
xor a
ld [$d267], a
call Function30b4
@@ -5130,15 +5141,15 @@ Function3e192: ; 3e192
ret
; 3e19b
-Function3e19b: ; 3e19b
- call Function3d2f1
- jr z, .asm_3e1a8
+LoadBattleMenu2: ; 3e19b
+ call IsMobileBattle
+ jr z, .mobile
- callba LoadBattleMenuDataHeader
+ callba LoadBattleMenu
and a
ret
-.asm_3e1a8
+.mobile
callba Function100b12
ld a, [$cd2b]
and a
@@ -5146,44 +5157,47 @@ Function3e19b: ; 3e19b
ld hl, $cd2a
bit 4, [hl]
- jr nz, .asm_3e1c5
+ jr nz, .error
ld hl, BattleText_0x81863
call StdBattleTextBox
ld c, 60
call DelayFrames
-.asm_3e1c5
-
+.error
scf
ret
; 3e1c7
-Function3e1c7: ; 3e1c7
+BattleMenu_Pack: ; 3e1c7
ld a, [InLinkBattle]
and a
- jp nz, Function3e22b
+ jp nz, ItemsCantBeUsed
+
ld a, [$cfc0]
and a
- jp nz, Function3e22b
+ jp nz, ItemsCantBeUsed
+
call Function1d6e
+
ld a, [BattleType]
cp BATTLETYPE_TUTORIAL
- jr z, .asm_3e1f1
- cp $6
- jr z, .asm_3e201
- callba Function10493
+ jr z, .tutorial
+ cp BATTLETYPE_CONTEST
+ jr z, .contest
+
+ callba BattlePack
ld a, [$d0ec]
and a
jr z, .asm_3e20d
jr .asm_3e209
-.asm_3e1f1
+.tutorial
callba Function107bb
ld a, POKE_BALL
ld [CurItem], a
call DoItemEffect
jr .asm_3e209
-.asm_3e201
+.contest
ld a, PARK_BALL
ld [CurItem], a
call DoItemEffect
@@ -5202,13 +5216,13 @@ Function3e1c7: ; 3e1c7
call WaitBGMap
call Function3ee27
call Function309d
- jp Function3e139
+ jp BattleMenu
; 3e22b
-Function3e22b: ; 3e22b
+ItemsCantBeUsed: ; 3e22b
ld hl, BattleText_0x80bf3
call StdBattleTextBox
- jp Function3e139
+ jp BattleMenu
; 3e234
Function3e234: ; 3e234
@@ -5256,7 +5270,7 @@ Function3e234: ; 3e234
ret
; 3e28d
-Function3e28d: ; 3e28d
+BattleMenu_PKMN: ; 3e28d
call Function1d6e
Function3e290:
call Function1c07
@@ -5303,11 +5317,11 @@ Function3e299:
call Function309d
call ClearSGB
call Function32f9
- jp Function3e139
+ jp BattleMenu
; 3e2f5
Function3e2f5: ; 3e2f5
- call Function3d2f1
+ call IsMobileBattle
jr z, .asm_3e301
callba Function24e99
ret
@@ -5506,8 +5520,7 @@ PassedBattleMonEntrance: ; 3e459
; 3e489
-
-Function3e489: ; 3e489
+BattleMenu_Run: ; 3e489
call Function30b4
ld a, $3
ld [$cfa9], a
@@ -5520,11 +5533,10 @@ Function3e489: ; 3e489
ld a, [$d0ec]
and a
ret nz
- jp Function3e139
+ jp BattleMenu
; 3e4a8
-
CheckAmuletCoin: ; 3e4a8
ld a, [BattleMonItem]
ld b, a
@@ -5538,7 +5550,7 @@ CheckAmuletCoin: ; 3e4a8
; 3e4bc
Function3e4bc: ; 3e4bc
- call Function3d2f1
+ call IsMobileBattle
jr nz, .asm_3e4c8
callba Function100b9f
ret
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm
index 616c22a42..aae82eb96 100644
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -6753,7 +6753,7 @@ BattleCommandaf: ; 365a7
; curl
ld a, BATTLE_VARS_SUBSTATUS2
call GetBattleVarAddr
- set 0, [hl]
+ set SUBSTATUS_CURLED, [hl]
ret
; 365af
@@ -7046,20 +7046,20 @@ BattleCommand3d: ; 36751
; No rampage during Sleep Talk.
ld a, BATTLE_VARS_STATUS
call GetBattleVar
- and 7
+ and SLP
ret nz
ld de, PlayerRolloutCount
ld a, [hBattleTurn]
and a
- jr z, .asm_36764 ; 3675f $3
+ jr z, .ok
ld de, EnemyRolloutCount
-.asm_36764
+.ok
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarAddr
- set 1, [hl]
+ set SUBSTATUS_ROLLOUT, [hl]
call BattleRandom
- and $1
+ and 1
inc a
ld [de], a
ld a, 1
@@ -7073,24 +7073,24 @@ BattleCommanda0: ; 36778
ld a, [BattleType]
cp BATTLETYPE_SHINY
- jr z, .asm_367b9
- cp $9
- jr z, .asm_367b9
+ jr z, .failed
+ cp BATTLETYPE_TRAP
+ jr z, .failed
cp BATTLETYPE_CELEBI
- jr z, .asm_367b9
+ jr z, .failed
cp BATTLETYPE_SUICUNE
- jr z, .asm_367b9
+ jr z, .failed
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call GetBattleVar
bit SUBSTATUS_CANT_RUN, a
- jr nz, .asm_367b9
+ jr nz, .failed
ld a, [hBattleTurn]
and a
jr nz, .asm_367bf
ld a, [IsInBattle]
dec a
- jr nz, .asm_367b9
+ jr nz, .failed
ld a, [$d143]
ld b, a
ld a, [BattleMonLevel]
@@ -7108,14 +7108,14 @@ BattleCommanda0: ; 36778
cp b
jr nc, .asm_367df ; 367b7 $26
-.asm_367b9
+.failed
call AnimateFailedMove
jp PrintButItFailed
.asm_367bf
ld a, [IsInBattle]
dec a
- jr nz, .asm_367b9 ; 367c3 $f4
+ jr nz, .failed
ld a, [BattleMonLevel]
ld b, a
ld a, [$d143]
diff --git a/battle/effects/curse.asm b/battle/effects/curse.asm
index f82ed97c5..27f821ffc 100644
--- a/battle/effects/curse.asm
+++ b/battle/effects/curse.asm
@@ -67,10 +67,10 @@ BattleCommand54: ; 37588
ld a, BATTLE_VARS_SUBSTATUS1_OPP
call GetBattleVarAddr
- bit 1, [hl]
+ bit SUBSTATUS_CURSE, [hl]
jr nz, .failed
- set 1, [hl]
+ set SUBSTATUS_CURSE, [hl]
call AnimateCurrentMove
ld hl, GetHalfMaxHP
call CallBattleCore
diff --git a/battle/effects/rollout.asm b/battle/effects/rollout.asm
index 748736fef..f108a9062 100644
--- a/battle/effects/rollout.asm
+++ b/battle/effects/rollout.asm
@@ -1,3 +1,6 @@
+MAX_ROLLOUT_COUNT EQU 5
+
+
BattleCommand5b: ; 37718
; checkcurl
@@ -28,7 +31,7 @@ BattleCommand5c: ; 37734
ld a, BATTLE_VARS_STATUS
call GetBattleVar
- and 7
+ and SLP
ret nz
ld hl, PlayerRolloutCount
@@ -58,23 +61,23 @@ BattleCommand5c: ; 37734
inc [hl]
ld a, [hl]
ld b, a
- cp $5
+ cp MAX_ROLLOUT_COUNT
jr c, .asm_3776e
ld a, BATTLE_VARS_SUBSTATUS1
call GetBattleVarAddr
- res 6, [hl]
+ res SUBSTATUS_ENCORED, [hl]
jr .asm_37775
.asm_3776e
ld a, BATTLE_VARS_SUBSTATUS1
call GetBattleVarAddr
- set 6, [hl]
+ set SUBSTATUS_ENCORED, [hl]
.asm_37775
ld a, BATTLE_VARS_SUBSTATUS2
call GetBattleVar
- bit 0, a
+ bit SUBSTATUS_CURLED, a
jr z, .asm_3777f
inc b
.asm_3777f
diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm
index 289731c1b..373277dcf 100644
--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -46,6 +46,7 @@ BATTLETYPE_CANLOSE EQU $01
BATTLETYPE_TUTORIAL EQU $03
BATTLETYPE_FISH EQU $04
BATTLETYPE_ROAMING EQU $05
+BATTLETYPE_CONTEST EQU $06
BATTLETYPE_SHINY EQU $07
BATTLETYPE_TREE EQU $08
BATTLETYPE_TRAP EQU $09
diff --git a/engine/scripting.asm b/engine/scripting.asm
index 2a978e0ea..756192a0d 100644
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -1544,7 +1544,7 @@ Script_catchtutorial: ; 0x97447
; byte (SingleByteParam)
call GetScriptByte
- ld [$d230], a
+ ld [BattleType], a
call Function2879
callba Function4e554
jp Script_reloadmap
@@ -1572,8 +1572,8 @@ Script_returnafterbattle: ; 0x97459
ld a, [$d0ee]
bit 7, a
jr z, .asm_9748e ; 0x97481 $b
- ld b, $24
- ld de, $4255
+ ld b, BANK(UnknownScript_0x90255)
+ ld de, UnknownScript_0x90255
callba Function97c4f
.asm_9748e
jp Script_reloadmap
diff --git a/main.asm b/main.asm
index f942e0315..e03d4f335 100644
--- a/main.asm
+++ b/main.asm
@@ -14669,7 +14669,7 @@ UnknownText_0xfa06: ; 0xfa06
SECTION "bank4", ROMX, BANK[$4]
-Function10000: ; 10000
+Pack: ; 10000
ld hl, Options
set 4, [hl]
call Function1068a
@@ -15333,7 +15333,7 @@ Function10492: ; 10492
; 10493
-Function10493: ; 10493
+BattlePack: ; 10493
ld hl, Options
set 4, [hl]
call Function1068a
@@ -19499,7 +19499,7 @@ StartMenu_Pokegear: ; 1294c
StartMenu_Pack: ; 1295b
call FadeToMenu
- callba Function10000
+ callba Pack
ld a, [$cf66]
and a
jr nz, .asm_12970
@@ -21441,7 +21441,7 @@ Function135db: ; 135db
; 135eb
UnknownScript_0x135eb:: ; 0x135eb
- writecode $3, $6
+ writecode $3, BATTLETYPE_CONTEST
battlecheck
startbattle
returnafterbattle
@@ -33442,7 +33442,7 @@ MenuData2_0x24edc: ; 24edc
; 24ef2
-LoadBattleMenuDataHeader: ; 24ef2
+LoadBattleMenu: ; 24ef2
ld hl, BattleMenuDataHeader
call LoadMenuDataHeader
ld a, [$d0d2]
@@ -33455,15 +33455,14 @@ LoadBattleMenuDataHeader: ; 24ef2
; 24f0b
-Function24f0b: ; 24f0b
-; Safari battle menu (untranslated).
+SafariBattleMenu: ; 24f0b
+; untranslated
ld hl, MenuDataHeader_0x24f4e
call LoadMenuDataHeader
jr Function24f19
; 24f13
-Function24f13: ; 24f13
-; Park battle menu.
+ContestBattleMenu: ; 24f13
ld hl, MenuDataHeader_0x24f89
call LoadMenuDataHeader
; 24f19
@@ -57309,6 +57308,7 @@ Function4e53f: ; 4e53f
ret
; 4e554
+
Function4e554:: ; 4e554
ld a, [BattleType]
dec a
@@ -57323,39 +57323,39 @@ Function4e554:: ; 4e554
jp [hl]
; 4e564
-
-; no known jump sources
Jumptable_4e564: ; 4e564 (13:6564)
dw Function4e56a
dw Function4e56a
dw Function4e56a
-
-; no known jump sources
Function4e56a: ; 4e56a (13:656a)
ld hl, PlayerName ; $d47d
ld de, MomsName ; $d488
ld bc, NAME_LENGTH
call CopyBytes
- ld hl, String_4e5da
+
+ ld hl, DudeString
ld de, PlayerName ; $d47d
ld bc, NAME_LENGTH
call CopyBytes
+
call Function4e5b7
+
xor a
- ld [hJoyDown], a ; $ff00+$a8
- ld [hJoyPressed], a ; $ff00+$a7
- ld a, [Options] ; $cfcc
+ ld [hJoyDown], a
+ ld [hJoyPressed], a
+ ld a, [Options]
push af
and $f8
add $3
- ld [Options], a ; $cfcc
+ ld [Options], a
ld hl, AutoInput_4e5df
ld a, BANK(AutoInput_4e5df)
call StartAutoInput
callab StartBattle
call StopAutoInput
pop af
+
ld [Options], a ; $cfcc
ld hl, MomsName ; $d488
ld de, PlayerName ; $d47d
@@ -57387,7 +57387,7 @@ Function4e5b7: ; 4e5b7 (13:65b7)
ret
; 4e5da (13:65da)
-String_4e5da: ; 4e5da
+DudeString: ; 4e5da
db "DUDE@"
; 4e5df
@@ -79440,7 +79440,7 @@ UnknownScript_0x90241: ; 0x90241
end
; 0x90255
-UnknownScript_0x90255: ; 0x90255
+UnknownScript_0x90255:: ; 0x90255
3callasm Function9025c
2jump UnknownScript_0x90241
; 0x9025c
@@ -102924,11 +102924,11 @@ INCBIN "baserom.gbc",$100b0a,$100b12 - $100b0a
Function100b12: ; 100b12
call Function100dd8
ret c
- ld hl, $4f2c
- ld a, $9
+ ld hl, BattleMenuDataHeader
+ ld a, BANK(BattleMenuDataHeader)
ld de, LoadMenuDataHeader
call FarCall_de
- ld a, $9
+ ld a, BANK(BattleMenuDataHeader)
ld [$cf94], a
ld a, [$d0d2]
ld [$cf88], a
diff --git a/maps/Route29.asm b/maps/Route29.asm
index 2dbe28d1c..f3b95ae7c 100644
--- a/maps/Route29.asm
+++ b/maps/Route29.asm
@@ -52,7 +52,7 @@ UnknownScript_0x1a0f6d: ; 0x1a0f6d
applymovement $2, MovementData_0x1a109a
stopfollow
loadpokedata RATTATA, 5
- catchtutorial $3
+ catchtutorial BATTLETYPE_TUTORIAL
spriteface $2, $1
loadfont
2writetext UnknownText_0x1a114d
@@ -78,7 +78,7 @@ UnknownScript_0x1a0fa3: ; 0x1a0fa3
applymovement $2, MovementData_0x1a10a1
stopfollow
loadpokedata RATTATA, 5
- catchtutorial $3
+ catchtutorial BATTLETYPE_TUTORIAL
spriteface $2, $1
loadfont
2writetext UnknownText_0x1a114d
@@ -121,7 +121,7 @@ CooltrainerMScript_0x1a0ff1: ; 0x1a0ff1
iffalse UnknownScript_0x1a1022
loadmovesprites
loadpokedata RATTATA, 5
- catchtutorial $3
+ catchtutorial BATTLETYPE_TUTORIAL
loadfont
2writetext UnknownText_0x1a114d
closetext