2017-12-16 01:10:54 +00:00
|
|
|
ShowLinkBattleParticipants: ; 2ee18
|
|
|
|
; 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 17:47:30 +00:00
|
|
|
farcall _ShowLinkBattleParticipants
|
2017-12-16 01:10:54 +00:00
|
|
|
ld c, 150
|
|
|
|
call DelayFrames
|
|
|
|
call ClearTileMap
|
|
|
|
call ClearSprites
|
|
|
|
ret
|
|
|
|
|
|
|
|
FindFirstAliveMonAndStartBattle: ; 2ee2f
|
|
|
|
xor a
|
|
|
|
ld [hMapAnims], a
|
|
|
|
call DelayFrame
|
|
|
|
ld b, 6
|
|
|
|
ld hl, PartyMon1HP
|
|
|
|
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]
|
|
|
|
ld [BattleMonLevel], a
|
2018-01-16 19:30:10 +00:00
|
|
|
predef DoBattleTransition
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall _LoadBattleFontsHPBar
|
2017-12-16 01:10:54 +00:00
|
|
|
ld a, 1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
call ClearSprites
|
|
|
|
call ClearTileMap
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld [hWY], a
|
|
|
|
ld [rWY], a
|
|
|
|
ld [hMapAnims], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
PlayBattleMusic: ; 2ee6c
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ld [MusicFade], a
|
|
|
|
ld de, MUSIC_NONE
|
|
|
|
call PlayMusic
|
|
|
|
call DelayFrame
|
|
|
|
call MaxVolume
|
|
|
|
|
|
|
|
ld a, [BattleType]
|
|
|
|
cp BATTLETYPE_SUICUNE
|
|
|
|
ld de, MUSIC_SUICUNE_BATTLE
|
|
|
|
jp z, .done
|
|
|
|
cp BATTLETYPE_ROAMING
|
|
|
|
jp z, .done
|
|
|
|
|
|
|
|
; Are we fighting a trainer?
|
|
|
|
ld a, [OtherTrainerClass]
|
|
|
|
and a
|
|
|
|
jr nz, .trainermusic
|
|
|
|
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall RegionCheck
|
2017-12-16 01:10:54 +00:00
|
|
|
ld a, e
|
|
|
|
and a
|
|
|
|
jr nz, .kantowild
|
|
|
|
|
|
|
|
ld de, MUSIC_JOHTO_WILD_BATTLE
|
|
|
|
ld a, [TimeOfDay]
|
|
|
|
cp NITE_F
|
|
|
|
jr nz, .done
|
|
|
|
ld de, MUSIC_JOHTO_WILD_BATTLE_NIGHT
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.kantowild
|
|
|
|
ld de, MUSIC_KANTO_WILD_BATTLE
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.trainermusic
|
|
|
|
ld de, MUSIC_CHAMPION_BATTLE
|
|
|
|
cp CHAMPION
|
|
|
|
jr z, .done
|
|
|
|
cp RED
|
|
|
|
jr z, .done
|
|
|
|
|
2018-01-09 20:12:49 +00:00
|
|
|
; They should have included EXECUTIVEM, EXECUTIVEF, and SCIENTIST too...
|
2017-12-16 01:10:54 +00: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 17:47:30 +00:00
|
|
|
farcall IsKantoGymLeader
|
2017-12-16 01:10:54 +00:00
|
|
|
jr c, .done
|
|
|
|
|
2018-01-09 20:12:49 +00:00
|
|
|
; IsGymLeader also counts CHAMPION, RED, and the Kanto gym leaders
|
|
|
|
; but they have been taken care of before this
|
2017-12-16 01:10:54 +00:00
|
|
|
ld de, MUSIC_JOHTO_GYM_LEADER_BATTLE
|
2018-01-09 20:12:49 +00:00
|
|
|
farcall IsGymLeader
|
2017-12-16 01:10:54 +00:00
|
|
|
jr c, .done
|
|
|
|
|
|
|
|
ld de, MUSIC_RIVAL_BATTLE
|
|
|
|
ld a, [OtherTrainerClass]
|
|
|
|
cp RIVAL1
|
|
|
|
jr z, .done
|
|
|
|
cp RIVAL2
|
|
|
|
jr nz, .othertrainer
|
|
|
|
|
|
|
|
ld a, [OtherTrainerID]
|
|
|
|
cp RIVAL2_2_CHIKORITA ; Rival in Indigo Plateau
|
|
|
|
jr c, .done
|
|
|
|
ld de, MUSIC_CHAMPION_BATTLE
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.othertrainer
|
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
|
|
|
jr nz, .johtotrainer
|
|
|
|
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall RegionCheck
|
2017-12-16 01:10:54 +00:00
|
|
|
ld a, e
|
|
|
|
and a
|
|
|
|
jr nz, .kantotrainer
|
|
|
|
|
|
|
|
.johtotrainer
|
|
|
|
ld de, MUSIC_JOHTO_TRAINER_BATTLE
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.kantotrainer
|
|
|
|
ld de, MUSIC_KANTO_TRAINER_BATTLE
|
|
|
|
|
|
|
|
.done
|
|
|
|
call PlayMusic
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
ClearBattleRAM: ; 2ef18
|
|
|
|
xor a
|
2018-01-23 21:45:34 +00:00
|
|
|
ld [wBattlePlayerAction], a
|
2017-12-16 01:10:54 +00:00
|
|
|
ld [wBattleResult], a
|
|
|
|
|
|
|
|
ld hl, wPartyMenuCursor
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
ld [wMenuScrollPosition], a
|
|
|
|
ld [CriticalHit], a
|
|
|
|
ld [BattleMonSpecies], a
|
|
|
|
ld [wBattleParticipantsNotFainted], a
|
|
|
|
ld [CurBattleMon], a
|
|
|
|
ld [wForcedSwitch], a
|
|
|
|
ld [TimeOfDayPal], a
|
|
|
|
ld [PlayerTurnsTaken], a
|
|
|
|
ld [EnemyTurnsTaken], a
|
|
|
|
ld [EvolvableFlags], a
|
|
|
|
|
|
|
|
ld hl, PlayerHPPal
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
ld hl, BattleMonDVs
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
ld hl, EnemyMonDVs
|
|
|
|
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 17:47:30 +00:00
|
|
|
callfar ResetEnemyStatLevels
|
2017-12-16 01:10:54 +00:00
|
|
|
|
|
|
|
call ClearWindowData
|
|
|
|
|
|
|
|
ld hl, hBGMapAddress
|
2017-12-28 12:32:33 +00:00
|
|
|
xor a ; LOW(vBGMap0)
|
2017-12-16 01:10:54 +00:00
|
|
|
ld [hli], a
|
2017-12-28 12:32:33 +00:00
|
|
|
ld [hl], HIGH(vBGMap0)
|
2017-12-16 01:10:54 +00:00
|
|
|
ret
|