summaryrefslogtreecommitdiff
path: root/engine/battle/battle_transition.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/battle_transition.asm')
-rw-r--r--engine/battle/battle_transition.asm224
1 files changed, 93 insertions, 131 deletions
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm
index 29b2d8663..8747f46a6 100644
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -1,4 +1,14 @@
-DoBattleTransition: ; 8c20f
+; BattleTransitionJumptable.Jumptable indexes
+BATTLETRANSITION_CAVE EQU $01
+BATTLETRANSITION_CAVE_STRONGER EQU $09
+BATTLETRANSITION_NO_CAVE EQU $10
+BATTLETRANSITION_NO_CAVE_STRONGER EQU $18
+BATTLETRANSITION_FINISH EQU $20
+BATTLETRANSITION_END EQU $80
+
+BATTLETRANSITION_SQUARE EQUS "\"8\"" ; $fe
+
+DoBattleTransition:
call .InitGFX
ld a, [rBGP]
ld [wBGP], a
@@ -14,7 +24,7 @@ DoBattleTransition: ; 8c20f
.loop
ld a, [wJumptableIndex]
- bit 7, a
+ bit 7, a ; BATTLETRANSITION_END?
jr nz, .done
call BattleTransitionJumptable
call DelayFrame
@@ -50,9 +60,8 @@ DoBattleTransition: ; 8c20f
ld [hVBlank], a
call DelayFrame
ret
-; 8c26d
-.InitGFX: ; 8c26d
+.InitGFX:
ld a, [wLinkMode]
cp LINK_MOBILE
jr z, .mobile
@@ -79,20 +88,18 @@ DoBattleTransition: ; 8c20f
ld [hl], a
call WipeLYOverrides
ret
-; 8c2a0
-.NonMobile_LoadPokeballTiles: ; 8c2a0
+.NonMobile_LoadPokeballTiles:
call LoadTrainerBattlePokeballTiles
hlbgcoord 0, 0
call ConvertTrainerBattlePokeballTilesTo2bpp
ret
-; 8c2aa
LoadTrainerBattlePokeballTiles:
; Load the tiles used in the Pokeball Graphic that fills the screen
; at the start of every Trainer battle.
ld de, TrainerBattlePokeballTiles
- ld hl, vTiles1 tile $7e
+ ld hl, vTiles0 tile BATTLETRANSITION_SQUARE
ld b, BANK(TrainerBattlePokeballTiles)
ld c, 2
call Request2bpp
@@ -103,7 +110,7 @@ LoadTrainerBattlePokeballTiles:
ld [rVBK], a
ld de, TrainerBattlePokeballTiles
- ld hl, vTiles4 tile $7e
+ ld hl, vTiles3 tile BATTLETRANSITION_SQUARE
ld b, BANK(TrainerBattlePokeballTiles)
ld c, 2
call Request2bpp
@@ -111,9 +118,8 @@ LoadTrainerBattlePokeballTiles:
pop af
ld [rVBK], a
ret
-; 8c2cf
-ConvertTrainerBattlePokeballTilesTo2bpp: ; 8c2cf
+ConvertTrainerBattlePokeballTilesTo2bpp:
ld a, [rSVBK]
push af
ld a, BANK(wDecompressScratch)
@@ -138,20 +144,17 @@ ConvertTrainerBattlePokeballTilesTo2bpp: ; 8c2cf
pop af
ld [rSVBK], a
ret
-; 8c2f4
-TrainerBattlePokeballTiles: ; 8c2f4
+TrainerBattlePokeballTiles:
INCBIN "gfx/overworld/trainer_battle_pokeball_tiles.2bpp"
+BattleTransitionJumptable:
+ jumptable .Jumptable, wJumptableIndex
-BattleTransitionJumptable: ; 8c314
- jumptable .dw, wJumptableIndex
-; 8c323
-
-.dw ; 8c323 (23:4323)
+.Jumptable
dw StartTrainerBattle_DetermineWhichAnimation ; 00
- ; Animation 1: cave
+ ; BATTLETRANSITION_CAVE
dw StartTrainerBattle_LoadPokeBallGraphics ; 01
dw StartTrainerBattle_SetUpBGMap ; 02
dw StartTrainerBattle_Flash ; 03
@@ -161,7 +164,7 @@ BattleTransitionJumptable: ; 8c314
dw StartTrainerBattle_SetUpForWavyOutro ; 07
dw StartTrainerBattle_SineWave ; 08
- ; Animation 2: cave, stronger
+ ; BATTLETRANSITION_CAVE_STRONGER
dw StartTrainerBattle_LoadPokeBallGraphics ; 09
dw StartTrainerBattle_SetUpBGMap ; 0a
dw StartTrainerBattle_Flash ; 0b
@@ -171,7 +174,7 @@ BattleTransitionJumptable: ; 8c314
; There is no setup for this one
dw StartTrainerBattle_ZoomToBlack ; 0f
- ; Animation 3: no cave
+ ; BATTLETRANSITION_NO_CAVE
dw StartTrainerBattle_LoadPokeBallGraphics ; 10
dw StartTrainerBattle_SetUpBGMap ; 11
dw StartTrainerBattle_Flash ; 12
@@ -181,7 +184,7 @@ BattleTransitionJumptable: ; 8c314
dw StartTrainerBattle_SetUpForSpinOutro ; 16
dw StartTrainerBattle_SpinToBlack ; 17
- ; Animation 4: no cave, stronger
+ ; BATTLETRANSITION_NO_CAVE_STRONGER
dw StartTrainerBattle_LoadPokeBallGraphics ; 18
dw StartTrainerBattle_SetUpBGMap ; 19
dw StartTrainerBattle_Flash ; 1a
@@ -191,11 +194,21 @@ BattleTransitionJumptable: ; 8c314
dw StartTrainerBattle_SetUpForRandomScatterOutro ; 1e
dw StartTrainerBattle_SpeckleToBlack ; 1f
- ; All animations jump to here.
+ ; BATTLETRANSITION_FINISH
dw StartTrainerBattle_Finish ; 20
+; transition animations
+ const_def
+ const TRANS_CAVE
+ const TRANS_CAVE_STRONGER
+ const TRANS_NO_CAVE
+ const TRANS_NO_CAVE_STRONGER
+
+; transition animation bits
+TRANS_STRONGER_F EQU 0 ; bit set in TRANS_CAVE_STRONGER and TRANS_NO_CAVE_STRONGER
+TRANS_NO_CAVE_F EQU 1 ; bit set in TRANS_NO_CAVE and TRANS_NO_CAVE_STRONGER
-StartTrainerBattle_DetermineWhichAnimation: ; 8c365 (23:4365)
+StartTrainerBattle_DetermineWhichAnimation:
; The screen flashes a different number of times depending on the level of
; your lead Pokemon relative to the opponent's.
; BUG: wBattleMonLevel and wEnemyMonLevel are not set at this point, so whatever
@@ -205,55 +218,56 @@ StartTrainerBattle_DetermineWhichAnimation: ; 8c365 (23:4365)
add 3
ld hl, wEnemyMonLevel
cp [hl]
- jr nc, .okay
- set 0, e
-.okay
+ jr nc, .not_stronger
+ set TRANS_STRONGER_F, e
+.not_stronger
ld a, [wEnvironment]
cp CAVE
- jr z, .okay2
+ jr z, .cave
cp ENVIRONMENT_5
- jr z, .okay2
+ jr z, .cave
cp DUNGEON
- jr z, .okay2
- set 1, e
-.okay2
+ jr z, .cave
+ set TRANS_NO_CAVE_F, e
+.cave
ld hl, .StartingPoints
add hl, de
ld a, [hl]
ld [wJumptableIndex], a
ret
-; 8c38f (23:438f)
-.StartingPoints: ; 8c38f
- db 1, 9
- db 16, 24
-; 8c393
+.StartingPoints:
+; entries correspond to TRANS_* constants
+ db BATTLETRANSITION_CAVE
+ db BATTLETRANSITION_CAVE_STRONGER
+ db BATTLETRANSITION_NO_CAVE
+ db BATTLETRANSITION_NO_CAVE_STRONGER
-StartTrainerBattle_Finish: ; 8c393 (23:4393)
+StartTrainerBattle_Finish:
call ClearSprites
- ld a, $80
+ ld a, BATTLETRANSITION_END
ld [wJumptableIndex], a
ret
-StartTrainerBattle_NextScene: ; 8c39c (23:439c)
+StartTrainerBattle_NextScene:
ld hl, wJumptableIndex
inc [hl]
ret
-StartTrainerBattle_SetUpBGMap: ; 8c3a1 (23:43a1)
+StartTrainerBattle_SetUpBGMap:
call StartTrainerBattle_NextScene
xor a
ld [wcf64], a
ld [hBGMapMode], a
ret
-StartTrainerBattle_Flash: ; 8c3ab (23:43ab)
+StartTrainerBattle_Flash:
call .DoFlashAnimation
ret nc
call StartTrainerBattle_NextScene
ret
-.DoFlashAnimation: ; 8c3b3 (23:43b3)
+.DoFlashAnimation:
ld a, [wTimeOfDayPalset]
cp %11111111 ; dark cave
jr z, .done
@@ -278,9 +292,8 @@ StartTrainerBattle_Flash: ; 8c3ab (23:43ab)
ld [wcf64], a
scf
ret
-; 8c3db (23:43db)
-.pals ; 8c3db
+.pals
db %11111001 ; 3321
db %11111110 ; 3332
db %11111111 ; 3333
@@ -294,9 +307,8 @@ StartTrainerBattle_Flash: ; 8c3ab (23:43ab)
db %10010000 ; 2100
db %11100100 ; 3210
db %00000001 ; 0001
-; 8c3e8
-StartTrainerBattle_SetUpForWavyOutro: ; 8c3e8 (23:43e8)
+StartTrainerBattle_SetUpForWavyOutro:
farcall Function5602
ld a, BANK(wLYOverrides)
ld [rSVBK], a
@@ -314,7 +326,7 @@ StartTrainerBattle_SetUpForWavyOutro: ; 8c3e8 (23:43e8)
ld [wcf65], a
ret
-StartTrainerBattle_SineWave: ; 8c408 (23:4408)
+StartTrainerBattle_SineWave:
ld a, [wcf64]
cp $60
jr nc, .end
@@ -322,11 +334,11 @@ StartTrainerBattle_SineWave: ; 8c408 (23:4408)
ret
.end
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
-.DoSineWave: ; 8c419 (23:4419)
+.DoSineWave:
ld hl, wcf65
ld a, [hl]
inc [hl]
@@ -354,7 +366,7 @@ StartTrainerBattle_SineWave: ; 8c408 (23:4408)
jr nz, .loop
ret
-StartTrainerBattle_SetUpForSpinOutro: ; 8c43d (23:443d)
+StartTrainerBattle_SetUpForSpinOutro:
farcall Function5602
ld a, BANK(wLYOverrides)
ld [rSVBK], a
@@ -363,7 +375,7 @@ StartTrainerBattle_SetUpForSpinOutro: ; 8c43d (23:443d)
ld [wcf64], a
ret
-StartTrainerBattle_SpinToBlack: ; 8c44f (23:444f)
+StartTrainerBattle_SpinToBlack:
xor a
ld [hBGMapMode], a
ld a, [wcf64]
@@ -394,10 +406,9 @@ endr
call DelayFrame
xor a
ld [hBGMapMode], a
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
-; 8c490 (23:4490)
; quadrants
const_def
@@ -406,7 +417,11 @@ endr
const LOWER_LEFT
const LOWER_RIGHT
-.spintable ; 8c490
+; quadrant bits
+RIGHT_QUADRANT_F EQU 0 ; bit set in UPPER_RIGHT and LOWER_RIGHT
+LOWER_QUADRANT_F EQU 1 ; bit set in LOWER_LEFT and LOWER_RIGHT
+
+.spintable
spintable_entry: MACRO
db \1
dw .wedge\2
@@ -433,9 +448,8 @@ ENDM
spintable_entry LOWER_LEFT, 2, 0, 14
spintable_entry LOWER_LEFT, 1, 1, 11
db -1
-; 8c4f5
-.load ; 8c4f5 (23:44f5)
+.load
ld a, [hli]
ld e, a
ld a, [hli]
@@ -451,7 +465,7 @@ ENDM
.loop1
ld [hl], $ff
ld a, [wcf65]
- bit 0, a
+ bit RIGHT_QUADRANT_F, a
jr z, .leftside
inc hl
jr .okay1
@@ -462,7 +476,7 @@ ENDM
jr nz, .loop1
pop hl
ld a, [wcf65]
- bit 1, a
+ bit LOWER_QUADRANT_F, a
ld bc, SCREEN_WIDTH
jr z, .upper
ld bc, -SCREEN_WIDTH
@@ -477,7 +491,7 @@ ENDM
ld c, a
.loop2
ld a, [wcf65]
- bit 0, a
+ bit RIGHT_QUADRANT_F, a
jr z, .leftside2
dec hl
jr .okay2
@@ -487,16 +501,14 @@ ENDM
dec c
jr nz, .loop2
jr .loop
-; 8c538 (23:4538)
.wedge1 db 2, 3, 5, 4, 9, -1
.wedge2 db 1, 1, 2, 2, 4, 2, 4, 2, 3, -1
.wedge3 db 2, 1, 3, 1, 4, 1, 4, 1, 4, 1, 3, 1, 2, 1, 1, 1, 1, -1
.wedge4 db 4, 1, 4, 0, 3, 1, 3, 0, 2, 1, 2, 0, 1, -1
.wedge5 db 4, 0, 3, 0, 3, 0, 2, 0, 2, 0, 1, 0, 1, 0, 1, -1
-; 8c578
-StartTrainerBattle_SetUpForRandomScatterOutro: ; 8c578 (23:4578)
+StartTrainerBattle_SetUpForRandomScatterOutro:
farcall Function5602
ld a, BANK(wLYOverrides)
ld [rSVBK], a
@@ -507,7 +519,7 @@ StartTrainerBattle_SetUpForRandomScatterOutro: ; 8c578 (23:4578)
ld [hBGMapMode], a
ret
-StartTrainerBattle_SpeckleToBlack: ; 8c58f (23:458f)
+StartTrainerBattle_SpeckleToBlack:
ld hl, wcf64
ld a, [hl]
and a
@@ -530,11 +542,11 @@ StartTrainerBattle_SpeckleToBlack: ; 8c58f (23:458f)
call DelayFrame
xor a
ld [hBGMapMode], a
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
-.BlackOutRandomTile: ; 8c5b8 (23:45b8)
+.BlackOutRandomTile:
.y_loop
call Random
cp SCREEN_HEIGHT
@@ -565,7 +577,7 @@ StartTrainerBattle_SpeckleToBlack: ; 8c58f (23:458f)
ld [hl], $ff
ret
-StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc)
+StartTrainerBattle_LoadPokeBallGraphics:
ld a, [wOtherTrainerClass]
and a
jp z, .nextscene ; don't need to be here if wild
@@ -606,7 +618,7 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc)
jr z, .done
sla a
jr nc, .no_load
- ld [hl], $fe
+ ld [hl], BATTLETRANSITION_SQUARE
.no_load
inc hl
jr .loop4
@@ -665,11 +677,11 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc)
call DelayFrame
call BattleStart_CopyTilemapAtOnce
-.nextscene ; 8c673 (23:4673)
+.nextscene
call StartTrainerBattle_NextScene
ret
-.copypals ; 8c677 (23:4677)
+.copypals
ld de, wBGPals1 palette PAL_BG_TEXT
call .copy
ld de, wBGPals2 palette PAL_BG_TEXT
@@ -682,21 +694,18 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc)
call .copy
ld de, wOBPals2 palette PAL_OW_ROCK
-.copy ; 8c698 (23:4698)
+.copy
push hl
ld bc, 1 palettes
call CopyBytes
pop hl
ret
-; 8c6a1 (23:46a1)
-.daypals ; 8c6a1
+.daypals
INCLUDE "gfx/overworld/trainer_battle_day.pal"
-; 8c6a9
-.nightpals ; 8c6a9
+.nightpals
INCLUDE "gfx/overworld/trainer_battle_nite.pal"
-; 8c6b1
.loadpokeballgfx
ld a, [wOtherTrainerClass]
@@ -721,7 +730,7 @@ PokeBallTransition:
db %00001111, %11110000
db %00000011, %11000000
-WipeLYOverrides: ; 8c6d8
+WipeLYOverrides:
ld a, [rSVBK]
push af
ld a, BANK(wLYOverrides)
@@ -735,9 +744,8 @@ WipeLYOverrides: ; 8c6d8
pop af
ld [rSVBK], a
ret
-; 8c6ef
-.wipe ; 8c6ef
+.wipe
xor a
ld c, SCREEN_HEIGHT_PX
.loop
@@ -745,54 +753,11 @@ WipeLYOverrides: ; 8c6d8
dec c
jr nz, .loop
ret
-; 8c6f7
-
-
-StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7)
-; a = d * sin(a * pi/32)
- and %111111
- cp %100000
- jr nc, .negative
- call .ApplySineWave
- ld a, h
- ret
-
-.negative
- and %011111
- call .ApplySineWave
- ld a, h
- xor $ff
- inc a
- ret
-
-.ApplySineWave: ; 8c70c (23:470c)
- ld e, a
- ld a, d
- ld d, 0
- ld hl, .sinewave
- add hl, de
- add hl, de
- ld e, [hl]
- inc hl
- ld d, [hl]
- ld hl, 0
-.multiply
- srl a
- jr nc, .even
- add hl, de
-.even
- sla e
- rl d
- and a
- jr nz, .multiply
- ret
-; 8c728 (23:4728)
-.sinewave ; 8c728
- sine_wave $100
-; 8c768
+StartTrainerBattle_DrawSineWave:
+ calc_sine_wave
-StartTrainerBattle_ZoomToBlack: ; 8c768 (23:4768)
+StartTrainerBattle_ZoomToBlack:
farcall Function5602
ld de, .boxes
@@ -818,12 +783,11 @@ StartTrainerBattle_ZoomToBlack: ; 8c768 (23:4768)
jr .loop
.done
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
-; 8c792 (23:4792)
-.boxes ; 8c792
+.boxes
zoombox: MACRO
; width, height, start y, start x
db \1, \2
@@ -839,9 +803,8 @@ ENDM
zoombox 18, 16, 1, 1
zoombox 20, 18, 0, 0
db -1
-; 8c7b7
-.Copy: ; 8c7b7 (23:47b7)
+.Copy:
ld a, $ff
.row
push bc
@@ -857,7 +820,6 @@ ENDM
dec b
jr nz, .row
ret
-; 8c7c9 (23:47c9)
Unreferenced_Function8c7c9:
ld a, $1