2018-06-24 07:09:41 -07:00
|
|
|
ShowLinkBattleParticipants:
|
2017-12-15 17:10:54 -08:00
|
|
|
; If we're not in a communications room,
|
|
|
|
; we don't need to be here.
|
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _ShowLinkBattleParticipants
|
2017-12-15 17:10:54 -08:00
|
|
|
ld c, 150
|
|
|
|
call DelayFrames
|
2020-02-13 09:30:13 -08:00
|
|
|
call ClearTilemap
|
2017-12-15 17:10:54 -08:00
|
|
|
call ClearSprites
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FindFirstAliveMonAndStartBattle:
|
2017-12-15 17:10:54 -08:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapAnims], a
|
2017-12-15 17:10:54 -08:00
|
|
|
call DelayFrame
|
2018-07-03 23:42:11 -07:00
|
|
|
ld b, PARTY_LENGTH
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1HP
|
2017-12-15 17:10:54 -08:00
|
|
|
ld de, PARTYMON_STRUCT_LENGTH - 1
|
|
|
|
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
jr nz, .okay
|
|
|
|
add hl, de
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
.okay
|
|
|
|
ld de, MON_LEVEL - MON_HP
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleMonLevel], a
|
2018-01-16 11:30:10 -08:00
|
|
|
predef DoBattleTransition
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _LoadBattleFontsHPBar
|
2017-12-15 17:10:54 -08:00
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2017-12-15 17:10:54 -08:00
|
|
|
call ClearSprites
|
2020-02-13 09:30:13 -08:00
|
|
|
call ClearTilemap
|
2017-12-15 17:10:54 -08:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
|
|
|
ldh [hWY], a
|
|
|
|
ldh [rWY], a
|
|
|
|
ldh [hMapAnims], a
|
2017-12-15 17:10:54 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayBattleMusic:
|
2017-12-15 17:10:54 -08:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMusicFade], a
|
2017-12-15 17:10:54 -08:00
|
|
|
ld de, MUSIC_NONE
|
|
|
|
call PlayMusic
|
|
|
|
call DelayFrame
|
|
|
|
call MaxVolume
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleType]
|
2017-12-15 17:10:54 -08:00
|
|
|
cp BATTLETYPE_SUICUNE
|
|
|
|
ld de, MUSIC_SUICUNE_BATTLE
|
|
|
|
jp z, .done
|
|
|
|
cp BATTLETYPE_ROAMING
|
|
|
|
jp z, .done
|
|
|
|
|
|
|
|
; Are we fighting a trainer?
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wOtherTrainerClass]
|
2017-12-15 17:10:54 -08:00
|
|
|
and a
|
|
|
|
jr nz, .trainermusic
|
|
|
|
|
|
|
|
ld de, MUSIC_JOHTO_WILD_BATTLE
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTimeOfDay]
|
2017-12-15 17:10:54 -08:00
|
|
|
cp NITE_F
|
2023-07-31 03:27:53 -07:00
|
|
|
jr c, .done ; not NITE_F or EVE_F
|
2017-12-15 17:10:54 -08:00
|
|
|
ld de, MUSIC_JOHTO_WILD_BATTLE_NIGHT
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.trainermusic
|
|
|
|
ld de, MUSIC_CHAMPION_BATTLE
|
|
|
|
cp CHAMPION
|
|
|
|
jr z, .done
|
|
|
|
cp RED
|
|
|
|
jr z, .done
|
|
|
|
|
2022-07-09 14:12:02 -07:00
|
|
|
; BUG: Team Rocket battle music is not used for Executives or Scientists (see docs/bugs_and_glitches.md)
|
2017-12-15 17:10:54 -08:00
|
|
|
ld de, MUSIC_ROCKET_BATTLE
|
|
|
|
cp GRUNTM
|
|
|
|
jr z, .done
|
|
|
|
cp GRUNTF
|
|
|
|
jr z, .done
|
|
|
|
|
|
|
|
ld de, MUSIC_KANTO_GYM_LEADER_BATTLE
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall IsKantoGymLeader
|
2017-12-15 17:10:54 -08:00
|
|
|
jr c, .done
|
|
|
|
|
2018-01-09 12:12:49 -08:00
|
|
|
; IsGymLeader also counts CHAMPION, RED, and the Kanto gym leaders
|
|
|
|
; but they have been taken care of before this
|
2017-12-15 17:10:54 -08:00
|
|
|
ld de, MUSIC_JOHTO_GYM_LEADER_BATTLE
|
2018-01-09 12:12:49 -08:00
|
|
|
farcall IsGymLeader
|
2017-12-15 17:10:54 -08:00
|
|
|
jr c, .done
|
|
|
|
|
|
|
|
ld de, MUSIC_RIVAL_BATTLE
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wOtherTrainerClass]
|
2017-12-15 17:10:54 -08:00
|
|
|
cp RIVAL1
|
|
|
|
jr z, .done
|
|
|
|
cp RIVAL2
|
|
|
|
jr nz, .othertrainer
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wOtherTrainerID]
|
2017-12-15 17:10:54 -08:00
|
|
|
cp RIVAL2_2_CHIKORITA ; Rival in Indigo Plateau
|
|
|
|
jr c, .done
|
|
|
|
ld de, MUSIC_CHAMPION_BATTLE
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.othertrainer
|
|
|
|
ld de, MUSIC_JOHTO_TRAINER_BATTLE
|
|
|
|
|
|
|
|
.done
|
|
|
|
call PlayMusic
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ClearBattleRAM:
|
2017-12-15 17:10:54 -08:00
|
|
|
xor a
|
2018-01-23 13:45:34 -08:00
|
|
|
ld [wBattlePlayerAction], a
|
2017-12-15 17:10:54 -08:00
|
|
|
ld [wBattleResult], a
|
|
|
|
|
|
|
|
ld hl, wPartyMenuCursor
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
ld [wMenuScrollPosition], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
|
|
|
ld [wBattleMonSpecies], a
|
2017-12-15 17:10:54 -08:00
|
|
|
ld [wBattleParticipantsNotFainted], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurBattleMon], a
|
2017-12-15 17:10:54 -08:00
|
|
|
ld [wForcedSwitch], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTimeOfDayPal], a
|
|
|
|
ld [wPlayerTurnsTaken], a
|
|
|
|
ld [wEnemyTurnsTaken], a
|
|
|
|
ld [wEvolvableFlags], a
|
2017-12-15 17:10:54 -08:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerHPPal
|
2017-12-15 17:10:54 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonDVs
|
2017-12-15 17:10:54 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonDVs
|
2017-12-15 17:10:54 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
; Clear the entire BattleMons area
|
|
|
|
ld hl, wBattle
|
|
|
|
ld bc, wBattleEnd - wBattle
|
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar ResetEnemyStatLevels
|
2017-12-15 17:10:54 -08:00
|
|
|
|
2023-08-11 03:28:14 -07:00
|
|
|
call ClearMenuAndWindowData
|
2017-12-15 17:10:54 -08:00
|
|
|
|
|
|
|
ld hl, hBGMapAddress
|
2017-12-28 04:32:33 -08:00
|
|
|
xor a ; LOW(vBGMap0)
|
2017-12-15 17:10:54 -08:00
|
|
|
ld [hli], a
|
2017-12-28 04:32:33 -08:00
|
|
|
ld [hl], HIGH(vBGMap0)
|
2017-12-15 17:10:54 -08:00
|
|
|
ret
|