diff options
| author | libjet <libj3t@gmail.com> | 2020-05-21 02:47:21 +0100 | 
|---|---|---|
| committer | libjet <libj3t@gmail.com> | 2020-05-21 02:47:21 +0100 | 
| commit | b2eabaf767c3bf327e55ed4f528a0bd99418f56f (patch) | |
| tree | 778e18a8f468a3cb8dbce25de1fa9cbddc32ec3b | |
| parent | 3d99b8e8596b508621df807928a46e88b7afe3d1 (diff) | |
Add start_battle.asm
| -rwxr-xr-x | engine/battle/start_battle.asm | 144 | ||||
| -rw-r--r-- | main.asm | 7 | ||||
| -rw-r--r-- | wram.asm | 2 | 
3 files changed, 146 insertions, 7 deletions
| diff --git a/engine/battle/start_battle.asm b/engine/battle/start_battle.asm new file mode 100755 index 00000000..7627a100 --- /dev/null +++ b/engine/battle/start_battle.asm @@ -0,0 +1,144 @@ +PlayBattleMusic: +	push hl +	push de +	push bc + +	xor a +	ld [wMusicFade], a +	ld de, MUSIC_NONE +	call PlayMusic +	call DelayFrame +	call MaxVolume + +	; Are we fighting a trainer? +	ld a, [wOtherTrainerClass] +	and a +	jr nz, .trainermusic + +	farcall RegionCheck +	ld a, e +	and a +	jr nz, .kantowild + +	ld de, MUSIC_JOHTO_WILD_BATTLE +	ld a, [wTimeOfDay] +	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 + +	; They should have included EXECUTIVEM, EXECUTIVEF, and SCIENTIST too... +	ld de, MUSIC_ROCKET_BATTLE +	cp GRUNTM +	jr z, .done +	cp GRUNTF +	jr z, .done + +	ld de, MUSIC_KANTO_GYM_LEADER_BATTLE +	farcall IsKantoGymLeader +	jr c, .done + +	; IsGymLeader also counts CHAMPION, RED, and the Kanto gym leaders +	; but they have been taken care of before this +	ld de, MUSIC_JOHTO_GYM_LEADER_BATTLE +	farcall IsGymLeader +	jr c, .done + +	ld de, MUSIC_RIVAL_BATTLE +	ld a, [wOtherTrainerClass] +	cp RIVAL1 +	jr z, .done +	cp RIVAL2 +	jr nz, .othertrainer + +	ld a, [wOtherTrainerID] +	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 + +	farcall RegionCheck +	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: +	xor a +	ld [wBattlePlayerAction], a +	ld [wBattleResult], a + +	ld hl, wPartyMenuCursor +	ld [hli], a +	ld [hli], a +	ld [hli], a +	ld [hl], a + +	ld [wMenuScrollPosition], a +	ld [wCriticalHit], a +	ld [wBattleMonSpecies], a +	ld [wBattleParticipantsNotFainted], a +	ld [wCurBattleMon], a +	ld [wForcedSwitch], a +	ld [wTimeOfDayPal], a +	ld [wPlayerTurnsTaken], a +	ld [wEnemyTurnsTaken], a +	ld [wEvolvableFlags], a + +	ld hl, wPlayerHPPal +	ld [hli], a +	ld [hl], a + +	ld hl, wBattleMonDVs +	ld [hli], a +	ld [hl], a + +	ld hl, wEnemyMonDVs +	ld [hli], a +	ld [hl], a + +; Clear the entire BattleMons area +	ld hl, wBattle +	ld bc, wBattleEnd - wBattle +	xor a +	call ByteFill + +	callfar ResetEnemyStatLevels + +	call ClearWindowData + +	ld hl, hBGMapAddress +	xor a ; LOW(vBGMap0) +	ld [hli], a +	ld [hl], HIGH(vBGMap0) +	ret @@ -349,12 +349,7 @@ SECTION "bank11", ROMX  INCLUDE "engine/events/fruit_trees.asm"  INCLUDE "engine/battle/ai/move.asm"  INCLUDE "engine/pokedex/pokedex_2.asm" - -PlayBattleMusic:: -	dr $44556, $445f2 -ClearBattleRAM:: -	dr $445f2, $44648 - +INCLUDE "engine/battle/start_battle.asm"  INCLUDE "engine/gfx/place_graphic.asm"  INCLUDE "engine/pokemon/mail.asm" @@ -599,7 +599,7 @@ wBattleAnimOAMPointerLo:: db ; ca18  	ds 207 -wBattle: ; cae8 +wBattle:: ; cae8  wEnemyMoveStruct:: move_struct wEnemyMoveStruct  wPlayerMoveStruct:: move_struct wPlayerMoveStruct | 
