diff options
Diffstat (limited to 'engine/battle/battle_transitions.asm')
-rw-r--r-- | engine/battle/battle_transitions.asm | 301 |
1 files changed, 158 insertions, 143 deletions
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index 9a84387..e2db5f1 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -1,35 +1,35 @@ INCLUDE "constants.asm" ; BattleTransitionJumptable.Jumptable indexes -BATTLETRANSITION_WAVY EQU $01 -BATTLETRANSITION_WIPE EQU $08 -BATTLETRANSITION_SCANLINE EQU $0F -BATTLETRANSITION_SPIN EQU $16 -BATTLETRANSITION_SCATTER EQU $1D +BATTLETRANSITION_WAVY EQU $01 +BATTLETRANSITION_WIPE_UNUSED EQU $08 +BATTLETRANSITION_SCANLINE EQU $0f +BATTLETRANSITION_SPIN EQU $16 +BATTLETRANSITION_SCATTER EQU $1d +BATTLETRANSITION_FINISH EQU $24 +BATTLETRANSITION_END EQU $80 -BATTLETRANSITION_FINISH EQU $24 -BATTLETRANSITION_END EQU $80 +BATTLETRANSITION_BLACK EQU $ff -BATTLETRANSITION_BLACK EQU $ff SECTION "engine/battle/battle_transitions.asm", ROMX -DoBattleTransition: ; 23:44be +DoBattleTransition: ld a, %11100011 ldh [rLCDC], a call .InitGFX -.loop ; 44c5 +.loop ld a, [wJumptableIndex] - bit 7, a ; BATTLETRANSITION_END? + bit 7, a ; BATTLETRANSITION_END? jr nz, .done call BattleTransitionJumptable call DelayFrame jr .loop .done - ld a, $FF - ldh [rBGP], a ; cut to black + ld a, %11111111 + ldh [rBGP], a ; cut to black xor a ldh [hLCDCPointer], a ldh [hLYOverrideStart], a @@ -78,32 +78,32 @@ ConvertTrainerBattlePokeballTilesTo2bpp: ld de, .BlackTile ldh a, [hOverworldFlashlightEffect] and a - jr z, .skip - ld de, .GreyTile -.skip + jr z, .got_tile + ld de, .GrayTile +.got_tile ld hl, vChars0 tile BATTLETRANSITION_BLACK ld b, BANK(@) - ld c, $01 + ld c, 1 call Request2bpp ret .BlackTile: - rept 16 - db $ff - endr +rept 8 + dw `33333333 +endr -.GreyTile: - rept 8 - db $00, $ff - endr +.GrayTile: +rept 8 + dw `22222222 +endr BattleTransitionJumptable: jumptable .Jumptable, wJumptableIndex -.Jumptable ; 456c +.Jumptable: dw StartTrainerBattle_DetermineWhichAnimation ; 00 -; Wavy outro + ; BATTLETRANSITION_WAVY dw StartTrainerBattle_LoadPokeBallGraphics ; 01 dw StartTrainerBattle_SetUpBGMap ; 02 dw StartTrainerBattle_Flash ; 03 @@ -112,7 +112,7 @@ BattleTransitionJumptable: dw StartTrainerBattle_SetUpForWavyOutro ; 06 dw StartTrainerBattle_SineWave ; 07 -; Wipe outro - unused + ; BATTLETRANSITION_WIPE_UNUSED dw StartTrainerBattle_LoadPokeBallGraphics ; 08 dw StartTrainerBattle_SetUpBGMap ; 09 dw StartTrainerBattle_Flash ; 0a @@ -121,7 +121,7 @@ BattleTransitionJumptable: dw StartTrainerBattle_SetUpForWipeOutro ; 0d dw StartTrainerBattle_WipeOutro ; 0e -; Scanline outro + ; BATTLETRANSITION_SCANLINE dw StartTrainerBattle_LoadPokeBallGraphics ; 0f dw StartTrainerBattle_SetUpBGMap ; 10 dw StartTrainerBattle_Flash ; 11 @@ -130,7 +130,7 @@ BattleTransitionJumptable: dw StartTrainerBattle_SetUpForScanlineOutro ; 14 dw StartTrainerBattle_Scanlines ; 15 -; Spin clockwise + ; BATTLETRANSITION_SPIN dw StartTrainerBattle_LoadPokeBallGraphics ; 16 dw StartTrainerBattle_SetUpBGMap ; 17 dw StartTrainerBattle_Flash ; 18 @@ -139,7 +139,7 @@ BattleTransitionJumptable: dw StartTrainerBattle_SetUpForSpinOutro ; 1b dw StartTrainerBattle_SpinToBlack ; 1c -; Random scatter + ; BATTLETRANSITION_SCATTER dw StartTrainerBattle_LoadPokeBallGraphics ; 1d dw StartTrainerBattle_SetUpBGMap ; 1e dw StartTrainerBattle_Flash ; 1f @@ -148,11 +148,13 @@ BattleTransitionJumptable: dw StartTrainerBattle_SetUpForRandomScatterOutro ; 22 dw StartTrainerBattle_SpeckleToBlack ; 23 + ; BATTLETRANSITION_FINISH dw StartTrainerBattle_Finish ; 24 StartTrainerBattle_DetermineWhichAnimation: +; Picks an arbitrary animation depending on [hVBlankCounter] % 4. ldh a, [hVBlankCounter] - and a, %00000011 + and a, %11 ld e, a ld d, 0 ld hl, .StartingPoints @@ -161,7 +163,7 @@ StartTrainerBattle_DetermineWhichAnimation: ld [wJumptableIndex], a ret -.StartingPoints ;45c6 +.StartingPoints: db BATTLETRANSITION_WAVY db BATTLETRANSITION_SCATTER db BATTLETRANSITION_SCANLINE @@ -181,7 +183,7 @@ StartTrainerBattle_NextScene: StartTrainerBattle_SetUpBGMap: call StartTrainerBattle_NextScene xor a - ld [wcb5f], a + ld [wBattleTransitionCounter], a ldh [hBGMapMode], a ret @@ -192,12 +194,12 @@ StartTrainerBattle_Flash: ret .DoFlashAnimation: - ld hl, wcb5f + ld hl, wBattleTransitionCounter ld a, [hl] inc [hl] srl a ld e, a - ld d, $00 + ld d, 0 ld hl, .pals add hl, de ld a, [hl] @@ -206,13 +208,27 @@ StartTrainerBattle_Flash: ldh [rBGP], a and a ret + .done xor a - ld [wcb5f], a + ld [wBattleTransitionCounter], a scf ret -.pals - db $f9, $fe, $ff, $fe, $f9, $e4, $90, $40, $00, $40, $90, $e4, $01 + +.pals: + dc 3, 3, 2, 1 + dc 3, 3, 3, 2 + dc 3, 3, 3, 3 + dc 3, 3, 3, 2 + dc 3, 3, 2, 1 + dc 3, 2, 1, 0 + dc 2, 1, 0, 0 + dc 1, 0, 0, 0 + dc 0, 0, 0, 0 + dc 1, 0, 0, 0 + dc 2, 1, 0, 0 + dc 3, 2, 1, 0 + dc 0, 0, 0, 1 StartTrainerBattle_SetUpForWavyOutro: call StartTrainerBattle_NextScene @@ -223,31 +239,34 @@ StartTrainerBattle_SetUpForWavyOutro: ld a, SCREEN_HEIGHT_PX ldh [hLYOverrideEnd], a xor a - ld [wcb5f], a - ld [wcb60], a + ld [wBattleTransitionCounter], a + ld [wBattleTransitionSineWaveOffset], a ret + StartTrainerBattle_SineWave: - ld a, [wcb5f] + ld a, [wBattleTransitionCounter] cp $60 jr nc, .end call .DoSineWave ret + .end ld a, BATTLETRANSITION_FINISH ld [wJumptableIndex], a ret .DoSineWave: - ld hl, wcb60 + ld hl, wBattleTransitionSineWaveOffset ld a, [hl] inc [hl] - ld hl, wcb5f + ld hl, wBattleTransitionCounter ld d, [hl] add [hl] ld [hl], a - ld a, SCREEN_HEIGHT_PX + ld a, wLYOverridesEnd - wLYOverrides ld bc, wLYOverrides ld e, 0 + .loop push af push de @@ -257,7 +276,7 @@ StartTrainerBattle_SineWave: inc bc pop de ld a, e - add $02 + add 2 ld e, a pop af dec a @@ -273,33 +292,34 @@ StartTrainerBattle_SetUpForWipeOutro: ld a, SCREEN_HEIGHT_PX ldh [hLYOverrideEnd], a xor a - ld [wcb5f], a + ld [wBattleTransitionCounter], a ld a, SCREEN_HEIGHT_PX + 1 ldh [hSCY], a ret StartTrainerBattle_WipeOutro: - ld hl, wcb5f + ld hl, wBattleTransitionCounter ld a, [hl] cp $48 jr nc, .end inc [hl] srl a ld e, a - ld d, $00 + ld d, 0 ld hl, wLYOverrides add hl, de - call Func4692 + call .DoWipeOutro ret + .end ld a, BATTLETRANSITION_FINISH ld [wJumptableIndex], a ret -Func4692: - ld c, $04 - ld de, $0024 - ld b, $91 +.DoWipeOutro: + ld c, 4 + ld de, SCREEN_HEIGHT_PX / 4 + ld b, SCREEN_HEIGHT_PX + 1 .loop ld a, b sub l @@ -307,8 +327,8 @@ Func4692: add hl, de dec c jr nz, .loop - ld hl, $c691 - ld [hl], $91 + ld hl, wLYOverridesEnd + 1 + ld [hl], SCREEN_HEIGHT_PX + 1 ret StartTrainerBattle_SetUpForScanlineOutro: @@ -316,23 +336,24 @@ StartTrainerBattle_SetUpForScanlineOutro: ld a, LOW(rSCX) ldh [hLCDCPointer], a xor a - ld [wcb5f], a + ld [wBattleTransitionCounter], a call WipeLYOverrides ret StartTrainerBattle_Scanlines: - ld hl, wcb5f + ld hl, wBattleTransitionCounter ld a, [hl] cp $50 - jr nc, .finished + jr nc, .end inc [hl] ld e, a - xor -1 ; switch scroll direction + xor $ff ; switch scroll direction inc a ld d, a call .SplitEvenOdd ret -.finished + +.end ld a, BATTLETRANSITION_FINISH ld [wJumptableIndex], a ret @@ -352,33 +373,34 @@ StartTrainerBattle_Scanlines: StartTrainerBattle_SetUpForSpinOutro: call StartTrainerBattle_NextScene xor a - ld [wcb5f], a + ld [wBattleTransitionCounter], a ret StartTrainerBattle_SpinToBlack: xor a ldh [hBGMapMode], a - ld a, [wcb5f] + ld a, [wBattleTransitionCounter] ld e, a ld d, 0 - ld hl, .data4723 + ld hl, .spin_quadrants rept 5 add hl, de endr ld a, [hli] cp -1 jr z, .end - ld [wcb60], a + ld [wBattleTransitionSpinQuadrant], a call .load ld a, 1 ldh [hBGMapMode], a call DelayFrame call DelayFrame - ld hl, wcb5f + ld hl, wBattleTransitionCounter inc [hl] ret + .end - ld a, $01 + ld a, 1 ldh [hBGMapMode], a call DelayFrame call DelayFrame @@ -389,30 +411,46 @@ endr ld [wJumptableIndex], a ret -.data4723 - db $00, $cb, $47, $19, $c3 - db $00, $d1, $47, $dc, $c2 - db $00, $db, $47, $a1, $c2 - db $00, $ed, $47, $a5, $c2 - db $00, $fb, $47, $a9, $c2 - db $01, $fb, $47, $aa, $c2 - db $01, $ed, $47, $ae, $c2 - db $01, $db, $47, $b2, $c2 - db $01, $d1, $47, $ef, $c2 - db $01, $cb, $47, $2a, $c3 - db $03, $cb, $47, $8e, $c3 - db $03, $d1, $47, $cb, $c3 - db $03, $db, $47, $06, $c4 - db $03, $ed, $47, $02, $c4 - db $03, $fb, $47, $fe, $c3 - db $02, $fb, $47, $fd, $c3 - db $02, $ed, $47, $f9, $c3 - db $02, $db, $47, $f5, $c3 - db $02, $d1, $47, $b8, $c3 - db $02, $cb, $47, $7d, $c3 +; quadrants + const_def + const UPPER_LEFT + const UPPER_RIGHT + const LOWER_LEFT + const LOWER_RIGHT + +; 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 + +.spin_quadrants: +spin_quadrant: MACRO + db \1 + dw \2 + dwcoord \3, \4 +ENDM + spin_quadrant UPPER_LEFT, .wedge1, 1, 6 + spin_quadrant UPPER_LEFT, .wedge2, 0, 3 + spin_quadrant UPPER_LEFT, .wedge3, 1, 0 + spin_quadrant UPPER_LEFT, .wedge4, 5, 0 + spin_quadrant UPPER_LEFT, .wedge5, 9, 0 + spin_quadrant UPPER_RIGHT, .wedge5, 10, 0 + spin_quadrant UPPER_RIGHT, .wedge4, 14, 0 + spin_quadrant UPPER_RIGHT, .wedge3, 18, 0 + spin_quadrant UPPER_RIGHT, .wedge2, 19, 3 + spin_quadrant UPPER_RIGHT, .wedge1, 18, 6 + spin_quadrant LOWER_RIGHT, .wedge1, 18, 11 + spin_quadrant LOWER_RIGHT, .wedge2, 19, 14 + spin_quadrant LOWER_RIGHT, .wedge3, 18, 17 + spin_quadrant LOWER_RIGHT, .wedge4, 14, 17 + spin_quadrant LOWER_RIGHT, .wedge5, 10, 17 + spin_quadrant LOWER_LEFT, .wedge5, 9, 17 + spin_quadrant LOWER_LEFT, .wedge4, 5, 17 + spin_quadrant LOWER_LEFT, .wedge3, 1, 17 + spin_quadrant LOWER_LEFT, .wedge2, 0, 14 + spin_quadrant LOWER_LEFT, .wedge1, 1, 11 db -1 -.load +.load: ld a, [hli] ld e, a ld a, [hli] @@ -426,9 +464,9 @@ endr ld c, a inc de .loop1 - ld [hl], $ff - ld a, [wcb60] - bit 0, a + ld [hl], BATTLETRANSITION_BLACK + ld a, [wBattleTransitionSpinQuadrant] + bit RIGHT_QUADRANT_F, a jr z, .leftside inc hl jr .okay1 @@ -438,8 +476,8 @@ endr dec c jr nz, .loop1 pop hl - ld a, [wcb60] - bit 1, a + ld a, [wBattleTransitionSpinQuadrant] + bit LOWER_QUADRANT_F, a ld bc, SCREEN_WIDTH jr z, .upper ld bc, -SCREEN_WIDTH @@ -453,8 +491,8 @@ endr jr z, .loop ld c, a .loop2 - ld a, [wcb60] - bit 0, a + ld a, [wBattleTransitionSpinQuadrant] + bit RIGHT_QUADRANT_F, a jr z, .leftside2 dec hl jr .okay2 @@ -465,22 +503,22 @@ endr jr nz, .loop2 jr .loop -.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 +.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 StartTrainerBattle_SetUpForRandomScatterOutro: call StartTrainerBattle_NextScene ld a, $10 - ld [wcb5f], a + ld [wBattleTransitionCounter], a ld a, 1 ldh [hBGMapMode], a ret StartTrainerBattle_SpeckleToBlack: - ld hl, wcb5f + ld hl, wBattleTransitionCounter ld a, [hl] and a jr z, .done @@ -509,7 +547,7 @@ StartTrainerBattle_SpeckleToBlack: .BlackOutRandomTile: .y_loop call Random - cp $12 + cp SCREEN_HEIGHT jr nc, .y_loop ld b, a @@ -518,6 +556,7 @@ StartTrainerBattle_SpeckleToBlack: cp SCREEN_WIDTH jr nc, .x_loop ld c, a + hlcoord 0, -1 ld de, SCREEN_WIDTH inc b @@ -527,15 +566,19 @@ StartTrainerBattle_SpeckleToBlack: dec b jr nz, .row_loop add hl, bc + +; If the tile has already been blacked out, +; sample a new tile ld a, [hl] - cp -1 + cp BATTLETRANSITION_BLACK jr z, .y_loop - ld [hl], $ff + ld [hl], BATTLETRANSITION_BLACK ret StartTrainerBattle_LoadPokeBallGraphics: xor a ldh [hBGMapMode], a + hlcoord 2, 1 ld de, .PokeBallTransition ld b, SCREEN_WIDTH - 4 @@ -547,14 +590,16 @@ StartTrainerBattle_LoadPokeBallGraphics: ld a, [de] inc de .col_loop +; Loading is done bit by bit and a jr z, .done sla a jr nc, .no_load - ld [hl], $ff + ld [hl], BATTLETRANSITION_BLACK .no_load inc hl jr .col_loop + .done pop hl push bc @@ -563,6 +608,7 @@ StartTrainerBattle_LoadPokeBallGraphics: pop bc dec c jr nz, .row_loop + pop hl push bc ld bc, SCREEN_WIDTH @@ -570,12 +616,14 @@ StartTrainerBattle_LoadPokeBallGraphics: pop bc dec b jr nz, .tile_loop - ld a, $01 + + ld a, 1 ldh [hBGMapMode], a call DelayFrame call DelayFrame call StartTrainerBattle_NextScene ret + .PokeBallTransition: ; 16x16 overlay of a Poke Ball pusho @@ -602,44 +650,11 @@ WipeLYOverrides: ld hl, wLYOverrides xor a ld c, SCREEN_HEIGHT_PX -.wipe +.loop ld [hli], a dec c - jr nz, .wipe + jr nz, .loop ret StartTrainerBattle_DrawSineWave: - calc_sine_wave .sine_table -.sine_table - dw $0000 - dw $0019 - dw $0032 - dw $004A - dw $0062 - dw $0079 - dw $008E - dw $00A2 - dw $00B5 - dw $00C6 - dw $00D5 - dw $00E2 - dw $00ED - dw $00F5 - dw $00FB - dw $00FF - dw $0100 - dw $00FF - dw $00FB - dw $00F5 - dw $00ED - dw $00E2 - dw $00D5 - dw $00C6 - dw $00B5 - dw $00A2 - dw $008E - dw $0079 - dw $0062 - dw $004A - dw $0032 - dw $0019 + calc_sine_wave |