pokered/engine/battle/battle_transitions.asm

746 lines
14 KiB
NASM
Raw Normal View History

2016-06-12 00:24:04 +00:00
BattleTransition:
2015-07-23 13:07:12 +00:00
ld a, 1
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
call Delay3
xor a
ldh [hWY], a
2014-05-22 22:13:20 +00:00
dec a
2014-09-13 07:50:56 +00:00
ld [wUpdateSpritesEnabled], a
2014-05-22 22:13:20 +00:00
call DelayFrame
2015-07-23 13:07:12 +00:00
; Determine which OAM block is being used by the enemy trainer sprite (if there
; is one).
ld hl, wSpritePlayerStateData1ImageIndex
ldh a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle)
2014-05-22 22:13:20 +00:00
ld c, a
2015-07-23 13:07:12 +00:00
ld b, 0
2014-05-22 22:13:20 +00:00
ld de, $10
2014-05-29 18:21:41 +00:00
.loop1
2014-05-22 22:13:20 +00:00
ld a, [hl]
cp $ff
2014-05-29 18:21:41 +00:00
jr z, .skip1
2014-05-22 22:13:20 +00:00
inc b
2014-05-29 18:21:41 +00:00
.skip1
2014-05-22 22:13:20 +00:00
add hl, de
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop1
2015-07-23 13:07:12 +00:00
; Clear OAM except for the blocks used by the player and enemy trainer sprites.
2022-07-09 21:18:18 +00:00
ld hl, wShadowOAMSprite04
2015-07-23 13:07:12 +00:00
ld c, 9
2014-05-29 18:21:41 +00:00
.loop2
2014-05-22 22:13:20 +00:00
ld a, b
swap a
cp l
2015-07-23 13:07:12 +00:00
jr z, .skip2 ; skip clearing the block if the enemy trainer is using it
2014-05-22 22:13:20 +00:00
push hl
push bc
ld bc, $10
xor a
call FillMemory
pop bc
pop hl
2014-05-29 18:21:41 +00:00
.skip2
2014-05-22 22:13:20 +00:00
ld de, $10
add hl, de
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop2
2015-07-23 13:07:12 +00:00
2014-05-22 22:13:20 +00:00
call Delay3
call LoadBattleTransitionTile
2015-07-23 13:07:12 +00:00
ld bc, 0
2015-02-07 10:43:08 +00:00
ld a, [wLinkState]
cp LINK_STATE_BATTLING
2014-05-29 18:21:41 +00:00
jr z, .linkBattle
call GetBattleTransitionID_WildOrTrainer
call GetBattleTransitionID_CompareLevels
call GetBattleTransitionID_IsDungeonMap
.linkBattle
ld hl, BattleTransitions
2014-05-22 22:13:20 +00:00
add hl, bc
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2014-05-22 22:13:20 +00:00
2014-05-29 18:21:41 +00:00
; the three GetBattleTransitionID functions set the first
; three bits of c, which determines what transition animation
; to play at the beginning of a battle
; bit 0: set if trainer battle
; bit 1: set if enemy is at least 3 levels higher than player
; bit 2: set if dungeon map
2016-06-12 00:24:04 +00:00
BattleTransitions:
2014-05-29 18:21:41 +00:00
dw BattleTransition_DoubleCircle ; %000
dw BattleTransition_Spiral ; %001
dw BattleTransition_Circle ; %010
dw BattleTransition_Spiral ; %011
dw BattleTransition_HorizontalStripes ; %100
dw BattleTransition_Shrink ; %101
dw BattleTransition_VerticalStripes ; %110
dw BattleTransition_Split ; %111
2016-06-12 00:24:04 +00:00
GetBattleTransitionID_WildOrTrainer:
2015-08-31 02:38:41 +00:00
ld a, [wCurOpponent]
cp OPP_ID_OFFSET
2014-05-29 18:21:41 +00:00
jr nc, .trainer
2014-05-22 22:13:20 +00:00
res 0, c
ret
2014-05-29 18:21:41 +00:00
.trainer
2014-05-22 22:13:20 +00:00
set 0, c
ret
2016-06-12 00:24:04 +00:00
GetBattleTransitionID_CompareLevels:
ld hl, wPartyMon1HP
2014-05-29 18:21:41 +00:00
.faintedLoop
2014-05-22 22:13:20 +00:00
ld a, [hli]
or [hl]
2014-05-29 18:21:41 +00:00
jr nz, .notFainted
ld de, wPartyMon2 - (wPartyMon1 + 1)
2014-05-22 22:13:20 +00:00
add hl, de
2014-05-29 18:21:41 +00:00
jr .faintedLoop
.notFainted
ld de, wPartyMon1Level - (wPartyMon1HP + 1)
2014-05-22 22:13:20 +00:00
add hl, de
ld a, [hl]
add $3
ld e, a
ld a, [wCurEnemyLevel]
2014-05-22 22:13:20 +00:00
sub e
2014-05-29 18:21:41 +00:00
jr nc, .highLevelEnemy
2014-05-22 22:13:20 +00:00
res 1, c
2015-07-23 13:07:12 +00:00
ld a, 1
ld [wBattleTransitionSpiralDirection], a
2014-05-22 22:13:20 +00:00
ret
2014-05-29 18:21:41 +00:00
.highLevelEnemy
2014-05-22 22:13:20 +00:00
set 1, c
xor a
ld [wBattleTransitionSpiralDirection], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
GetBattleTransitionID_IsDungeonMap:
2015-08-31 02:38:41 +00:00
ld a, [wCurMap]
2014-05-22 22:13:20 +00:00
ld e, a
2014-05-29 18:21:41 +00:00
ld hl, DungeonMaps1
.loop1
2014-05-22 22:13:20 +00:00
ld a, [hli]
cp $ff
2014-05-29 18:21:41 +00:00
jr z, .noMatch1
2014-05-22 22:13:20 +00:00
cp e
2014-05-29 18:21:41 +00:00
jr nz, .loop1
.match
2014-05-22 22:13:20 +00:00
set 2, c
ret
2014-05-29 18:21:41 +00:00
.noMatch1
ld hl, DungeonMaps2
.loop2
2014-05-22 22:13:20 +00:00
ld a, [hli]
cp $ff
2014-05-29 18:21:41 +00:00
jr z, .noMatch2
2014-05-22 22:13:20 +00:00
ld d, a
ld a, [hli]
cp e
2014-05-29 18:21:41 +00:00
jr c, .loop2
2014-05-22 22:13:20 +00:00
ld a, e
cp d
2014-05-29 18:21:41 +00:00
jr nc, .match
.noMatch2
2014-05-22 22:13:20 +00:00
res 2, c
ret
INCLUDE "data/maps/dungeon_maps.asm"
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
LoadBattleTransitionTile:
2020-07-07 19:09:54 +00:00
ld hl, vChars1 tile $7f
2014-05-29 18:21:41 +00:00
ld de, BattleTransitionTile
2020-07-07 19:09:54 +00:00
lb bc, BANK(BattleTransitionTile), 1
2014-05-22 22:13:20 +00:00
jp CopyVideoData
2020-07-07 19:09:54 +00:00
BattleTransitionTile: INCBIN "gfx/overworld/battle_transition.2bpp"
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
BattleTransition_BlackScreen:
2014-05-22 22:13:20 +00:00
ld a, $ff
ldh [rBGP], a
ldh [rOBP0], a
ldh [rOBP1], a
2014-05-22 22:13:20 +00:00
ret
2014-05-29 18:21:41 +00:00
; for non-dungeon trainer battles
; called regardless of mon levels, but does an
; outward spiral if enemy is at least 3 levels
; higher than player and does an inward spiral otherwise
2016-06-12 00:24:04 +00:00
BattleTransition_Spiral:
ld a, [wBattleTransitionSpiralDirection]
2014-05-22 22:13:20 +00:00
and a
2014-05-29 18:21:41 +00:00
jr z, .outwardSpiral
call BattleTransition_InwardSpiral
jr .done
.outwardSpiral
hlcoord 10, 10
2014-05-22 22:13:20 +00:00
ld a, $3
2015-07-24 21:39:45 +00:00
ld [wOutwardSpiralCurrentDirection], a
2014-05-22 22:13:20 +00:00
ld a, l
2015-07-24 21:39:45 +00:00
ld [wOutwardSpiralTileMapPointer + 1], a
2014-05-22 22:13:20 +00:00
ld a, h
2015-07-24 21:39:45 +00:00
ld [wOutwardSpiralTileMapPointer], a
ld b, 120
.loop
ld c, 3
.innerLoop
2014-05-22 22:13:20 +00:00
push bc
2014-05-29 18:21:41 +00:00
call BattleTransition_OutwardSpiral_
2014-05-22 22:13:20 +00:00
pop bc
dec c
2015-07-24 21:39:45 +00:00
jr nz, .innerLoop
2014-05-22 22:13:20 +00:00
call DelayFrame
dec b
2015-07-24 21:39:45 +00:00
jr nz, .loop
2014-05-29 18:21:41 +00:00
.done
call BattleTransition_BlackScreen
2014-05-22 22:13:20 +00:00
xor a
2015-07-24 21:39:45 +00:00
ld [wOutwardSpiralTileMapPointer + 1], a
ld [wOutwardSpiralTileMapPointer], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
BattleTransition_InwardSpiral:
2015-07-23 13:07:12 +00:00
ld a, 7
ld [wInwardSpiralUpdateScreenCounter], a
hlcoord 0, 0
2015-07-23 13:07:12 +00:00
ld c, SCREEN_HEIGHT - 1
2015-07-14 07:16:19 +00:00
ld de, SCREEN_WIDTH
2014-05-29 18:21:41 +00:00
call BattleTransition_InwardSpiral_
2014-05-22 22:13:20 +00:00
inc c
2014-05-29 18:21:41 +00:00
jr .skip
.loop
2015-07-14 07:16:19 +00:00
ld de, SCREEN_WIDTH
2014-05-29 18:21:41 +00:00
call BattleTransition_InwardSpiral_
.skip
2014-05-22 22:13:20 +00:00
inc c
2015-07-23 13:07:12 +00:00
ld de, 1
2014-05-29 18:21:41 +00:00
call BattleTransition_InwardSpiral_
2014-05-22 22:13:20 +00:00
dec c
dec c
2015-07-14 07:16:19 +00:00
ld de, -SCREEN_WIDTH
2014-05-29 18:21:41 +00:00
call BattleTransition_InwardSpiral_
2014-05-22 22:13:20 +00:00
inc c
2015-07-14 07:16:19 +00:00
ld de, -1
2014-05-29 18:21:41 +00:00
call BattleTransition_InwardSpiral_
2014-05-22 22:13:20 +00:00
dec c
dec c
ld a, c
and a
2014-05-29 18:21:41 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
BattleTransition_InwardSpiral_:
2014-05-22 22:13:20 +00:00
push bc
2014-05-29 18:21:41 +00:00
.loop
2014-05-22 22:13:20 +00:00
ld [hl], $ff
add hl, de
push bc
2015-07-23 13:07:12 +00:00
ld a, [wInwardSpiralUpdateScreenCounter]
2014-05-22 22:13:20 +00:00
dec a
2014-05-29 18:21:41 +00:00
jr nz, .skip
call BattleTransition_TransferDelay3
2015-07-23 13:07:12 +00:00
ld a, 7
2014-05-29 18:21:41 +00:00
.skip
2015-07-23 13:07:12 +00:00
ld [wInwardSpiralUpdateScreenCounter], a
2014-05-22 22:13:20 +00:00
pop bc
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
pop bc
ret
2016-06-12 00:24:04 +00:00
BattleTransition_OutwardSpiral_:
2015-07-14 07:16:19 +00:00
ld bc, -SCREEN_WIDTH
ld de, SCREEN_WIDTH
2015-07-24 21:39:45 +00:00
ld a, [wOutwardSpiralTileMapPointer + 1]
2014-05-22 22:13:20 +00:00
ld l, a
2015-07-24 21:39:45 +00:00
ld a, [wOutwardSpiralTileMapPointer]
2014-05-22 22:13:20 +00:00
ld h, a
2015-07-24 21:39:45 +00:00
ld a, [wOutwardSpiralCurrentDirection]
2014-05-22 22:13:20 +00:00
cp $0
2015-07-24 21:39:45 +00:00
jr z, .up
2014-05-22 22:13:20 +00:00
cp $1
2015-07-24 21:39:45 +00:00
jr z, .left
2014-05-22 22:13:20 +00:00
cp $2
2015-07-24 21:39:45 +00:00
jr z, .down
2014-05-22 22:13:20 +00:00
cp $3
2015-07-24 21:39:45 +00:00
jr z, .right
.keepSameDirection
2014-05-22 22:13:20 +00:00
ld [hl], $ff
2015-07-24 21:39:45 +00:00
.done
2014-05-22 22:13:20 +00:00
ld a, l
2015-07-24 21:39:45 +00:00
ld [wOutwardSpiralTileMapPointer + 1], a
2014-05-22 22:13:20 +00:00
ld a, h
2015-07-24 21:39:45 +00:00
ld [wOutwardSpiralTileMapPointer], a
2014-05-22 22:13:20 +00:00
ret
2015-07-24 21:39:45 +00:00
.up
2014-05-22 22:13:20 +00:00
dec hl
ld a, [hl]
cp $ff
2015-07-24 21:39:45 +00:00
jr nz, .changeDirection
2014-05-22 22:13:20 +00:00
inc hl
add hl, bc
2015-07-24 21:39:45 +00:00
jr .keepSameDirection
.left
2014-05-22 22:13:20 +00:00
add hl, de
ld a, [hl]
cp $ff
2015-07-24 21:39:45 +00:00
jr nz, .changeDirection
2014-05-22 22:13:20 +00:00
add hl, bc
dec hl
2015-07-24 21:39:45 +00:00
jr .keepSameDirection
.down
2014-05-22 22:13:20 +00:00
inc hl
ld a, [hl]
cp $ff
2015-07-24 21:39:45 +00:00
jr nz, .changeDirection
2014-05-22 22:13:20 +00:00
dec hl
add hl, de
2015-07-24 21:39:45 +00:00
jr .keepSameDirection
.right
2014-05-22 22:13:20 +00:00
add hl, bc
ld a, [hl]
cp $ff
2015-07-24 21:39:45 +00:00
jr nz, .changeDirection
2014-05-22 22:13:20 +00:00
add hl, de
inc hl
2015-07-24 21:39:45 +00:00
jr .keepSameDirection
.changeDirection
2014-05-22 22:13:20 +00:00
ld [hl], $ff
2015-07-24 21:39:45 +00:00
ld a, [wOutwardSpiralCurrentDirection]
2014-05-22 22:13:20 +00:00
inc a
cp $4
2014-05-29 18:21:41 +00:00
jr nz, .skip
2014-05-22 22:13:20 +00:00
xor a
2014-05-29 18:21:41 +00:00
.skip
2015-07-24 21:39:45 +00:00
ld [wOutwardSpiralCurrentDirection], a
jr .done
2014-05-22 22:13:20 +00:00
FlashScreen:
2016-06-12 00:24:04 +00:00
BattleTransition_FlashScreen_:
2014-05-29 18:21:41 +00:00
ld hl, BattleTransition_FlashScreenPalettes
.loop
2014-05-22 22:13:20 +00:00
ld a, [hli]
cp 1
2014-05-29 18:21:41 +00:00
jr z, .done
ldh [rBGP], a
ld c, 2
2014-05-22 22:13:20 +00:00
call DelayFrames
2014-05-29 18:21:41 +00:00
jr .loop
.done
2014-05-22 22:13:20 +00:00
dec b
2014-05-29 18:21:41 +00:00
jr nz, BattleTransition_FlashScreen_
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
BattleTransition_FlashScreenPalettes:
2023-11-20 22:53:19 +00:00
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
db 1 ; end
2014-05-22 22:13:20 +00:00
2014-05-29 18:21:41 +00:00
; used for low level trainer dungeon battles
2016-06-12 00:24:04 +00:00
BattleTransition_Shrink:
2015-07-14 07:16:19 +00:00
ld c, SCREEN_HEIGHT / 2
2014-05-29 18:21:41 +00:00
.loop
2014-05-22 22:13:20 +00:00
push bc
xor a
ldh [hAutoBGTransferEnabled], a
hlcoord 0, 7
decoord 0, 8
2015-07-14 07:16:19 +00:00
ld bc, -SCREEN_WIDTH * 2
2014-05-29 18:21:41 +00:00
call BattleTransition_CopyTiles1
hlcoord 0, 10
decoord 0, 9
2015-07-14 07:16:19 +00:00
ld bc, SCREEN_WIDTH * 2
2014-05-29 18:21:41 +00:00
call BattleTransition_CopyTiles1
hlcoord 8, 0
decoord 9, 0
2015-07-14 07:16:19 +00:00
ld bc, -2
2014-05-29 18:21:41 +00:00
call BattleTransition_CopyTiles2
hlcoord 11, 0
decoord 10, 0
2015-07-23 13:07:12 +00:00
ld bc, 2
2014-05-29 18:21:41 +00:00
call BattleTransition_CopyTiles2
2014-05-22 22:13:20 +00:00
ld a, $1
ldh [hAutoBGTransferEnabled], a
ld c, 6
2014-05-22 22:13:20 +00:00
call DelayFrames
pop bc
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop
call BattleTransition_BlackScreen
ld c, 10
2014-05-22 22:13:20 +00:00
jp DelayFrames
2014-05-29 18:21:41 +00:00
; used for high level trainer dungeon battles
2016-06-12 00:24:04 +00:00
BattleTransition_Split:
2015-07-14 07:16:19 +00:00
ld c, SCREEN_HEIGHT / 2
2014-05-22 22:13:20 +00:00
xor a
ldh [hAutoBGTransferEnabled], a
2014-05-29 18:21:41 +00:00
.loop
2014-05-22 22:13:20 +00:00
push bc
hlcoord 0, 16
decoord 0, 17
2015-07-14 07:16:19 +00:00
ld bc, -SCREEN_WIDTH * 2
2014-05-29 18:21:41 +00:00
call BattleTransition_CopyTiles1
hlcoord 0, 1
decoord 0, 0
2015-07-14 07:16:19 +00:00
ld bc, SCREEN_WIDTH * 2
2014-05-29 18:21:41 +00:00
call BattleTransition_CopyTiles1
hlcoord 18, 0
decoord 19, 0
2015-07-14 07:16:19 +00:00
ld bc, -2
2014-05-29 18:21:41 +00:00
call BattleTransition_CopyTiles2
hlcoord 1, 0
decoord 0, 0
2015-07-23 13:07:12 +00:00
ld bc, 2
2014-05-29 18:21:41 +00:00
call BattleTransition_CopyTiles2
call BattleTransition_TransferDelay3
2014-05-22 22:13:20 +00:00
call Delay3
pop bc
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop
call BattleTransition_BlackScreen
ld c, 10
2014-05-22 22:13:20 +00:00
jp DelayFrames
2016-06-12 00:24:04 +00:00
BattleTransition_CopyTiles1:
2014-05-22 22:13:20 +00:00
ld a, c
2015-07-23 13:07:12 +00:00
ld [wBattleTransitionCopyTilesOffset], a
2014-05-22 22:13:20 +00:00
ld a, b
2015-07-23 13:07:12 +00:00
ld [wBattleTransitionCopyTilesOffset + 1], a
ld c, 8
2014-05-29 18:21:41 +00:00
.loop1
2014-05-22 22:13:20 +00:00
push bc
push hl
push de
2015-07-14 07:16:19 +00:00
ld bc, SCREEN_WIDTH
2014-05-22 22:13:20 +00:00
call CopyData
pop hl
pop de
2015-07-23 13:07:12 +00:00
ld a, [wBattleTransitionCopyTilesOffset]
2014-05-22 22:13:20 +00:00
ld c, a
2015-07-23 13:07:12 +00:00
ld a, [wBattleTransitionCopyTilesOffset + 1]
2014-05-22 22:13:20 +00:00
ld b, a
add hl, bc
pop bc
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop1
2014-05-22 22:13:20 +00:00
ld l, e
ld h, d
ld a, $ff
2015-07-14 07:16:19 +00:00
ld c, SCREEN_WIDTH
2014-05-29 18:21:41 +00:00
.loop2
2014-05-22 22:13:20 +00:00
ld [hli], a
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop2
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
BattleTransition_CopyTiles2:
2014-05-22 22:13:20 +00:00
ld a, c
2015-07-23 13:07:12 +00:00
ld [wBattleTransitionCopyTilesOffset], a
2014-05-22 22:13:20 +00:00
ld a, b
2015-07-23 13:07:12 +00:00
ld [wBattleTransitionCopyTilesOffset + 1], a
2015-07-14 07:16:19 +00:00
ld c, SCREEN_HEIGHT / 2
2014-05-29 18:21:41 +00:00
.loop1
2014-05-22 22:13:20 +00:00
push bc
push hl
push de
2015-07-14 07:16:19 +00:00
ld c, SCREEN_HEIGHT
2014-05-29 18:21:41 +00:00
.loop2
2014-05-22 22:13:20 +00:00
ld a, [hl]
ld [de], a
ld a, e
2015-07-14 07:16:19 +00:00
add SCREEN_WIDTH
2014-05-29 18:21:41 +00:00
jr nc, .noCarry1
2014-05-22 22:13:20 +00:00
inc d
2014-05-29 18:21:41 +00:00
.noCarry1
2014-05-22 22:13:20 +00:00
ld e, a
ld a, l
2015-07-14 07:16:19 +00:00
add SCREEN_WIDTH
2014-05-29 18:21:41 +00:00
jr nc, .noCarry2
2014-05-22 22:13:20 +00:00
inc h
2014-05-29 18:21:41 +00:00
.noCarry2
2014-05-22 22:13:20 +00:00
ld l, a
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop2
2014-05-22 22:13:20 +00:00
pop hl
pop de
2015-07-23 13:07:12 +00:00
ld a, [wBattleTransitionCopyTilesOffset]
2014-05-22 22:13:20 +00:00
ld c, a
2015-07-23 13:07:12 +00:00
ld a, [wBattleTransitionCopyTilesOffset + 1]
2014-05-22 22:13:20 +00:00
ld b, a
add hl, bc
pop bc
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop1
2014-05-22 22:13:20 +00:00
ld l, e
ld h, d
2015-07-14 07:16:19 +00:00
ld de, SCREEN_WIDTH
ld c, SCREEN_HEIGHT
2014-05-29 18:21:41 +00:00
.loop3
2014-05-22 22:13:20 +00:00
ld [hl], $ff
add hl, de
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop3
2014-05-22 22:13:20 +00:00
ret
2014-05-29 18:21:41 +00:00
; used for high level wild dungeon battles
2016-06-12 00:24:04 +00:00
BattleTransition_VerticalStripes:
2015-07-14 07:16:19 +00:00
ld c, SCREEN_HEIGHT
hlcoord 0, 0
decoord 1, 17
2014-05-22 22:13:20 +00:00
xor a
ldh [hAutoBGTransferEnabled], a
2014-05-29 18:21:41 +00:00
.loop
2014-05-22 22:13:20 +00:00
push bc
push hl
push de
push de
2014-05-29 18:21:41 +00:00
call BattleTransition_VerticalStripes_
2014-05-22 22:13:20 +00:00
pop hl
2014-05-29 18:21:41 +00:00
call BattleTransition_VerticalStripes_
call BattleTransition_TransferDelay3
2014-05-22 22:13:20 +00:00
pop hl
2015-07-14 07:16:19 +00:00
ld bc, -SCREEN_WIDTH
2014-05-22 22:13:20 +00:00
add hl, bc
ld e, l
ld d, h
pop hl
2015-07-14 07:16:19 +00:00
ld bc, SCREEN_WIDTH
2014-05-22 22:13:20 +00:00
add hl, bc
pop bc
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop
jp BattleTransition_BlackScreen
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
BattleTransition_VerticalStripes_:
2015-07-14 07:16:19 +00:00
ld c, SCREEN_WIDTH / 2
2014-05-29 18:21:41 +00:00
.loop
2014-05-22 22:13:20 +00:00
ld [hl], $ff
inc hl
inc hl
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
2014-05-29 18:21:41 +00:00
; used for low level wild dungeon battles
2016-06-12 00:24:04 +00:00
BattleTransition_HorizontalStripes:
2015-07-14 07:16:19 +00:00
ld c, SCREEN_WIDTH
hlcoord 0, 0
decoord 19, 1
2014-05-22 22:13:20 +00:00
xor a
ldh [hAutoBGTransferEnabled], a
2014-05-29 18:21:41 +00:00
.loop
2014-05-22 22:13:20 +00:00
push bc
push hl
push de
push de
2014-05-29 18:21:41 +00:00
call BattleTransition_HorizontalStripes_
2014-05-22 22:13:20 +00:00
pop hl
2014-05-29 18:21:41 +00:00
call BattleTransition_HorizontalStripes_
call BattleTransition_TransferDelay3
2014-05-22 22:13:20 +00:00
pop de
pop hl
pop bc
inc hl
dec de
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop
jp BattleTransition_BlackScreen
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
BattleTransition_HorizontalStripes_:
2015-07-14 07:16:19 +00:00
ld c, SCREEN_HEIGHT / 2
ld de, SCREEN_WIDTH * 2
2014-05-29 18:21:41 +00:00
.loop
2014-05-22 22:13:20 +00:00
ld [hl], $ff
add hl, de
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
2014-05-29 18:21:41 +00:00
; used for high level wild non-dungeon battles
; makes one full circle around the screen
; by animating each half circle one at a time
2016-06-12 00:24:04 +00:00
BattleTransition_Circle:
2014-05-29 18:21:41 +00:00
call BattleTransition_FlashScreen
2015-07-23 13:07:12 +00:00
lb bc, 0, SCREEN_WIDTH / 2
2014-05-29 18:21:41 +00:00
ld hl, BattleTransition_HalfCircle1
call BattleTransition_Circle_Sub1
2015-07-14 07:16:19 +00:00
ld c, SCREEN_WIDTH / 2
2015-07-23 13:07:12 +00:00
ld b, 1
2014-05-29 18:21:41 +00:00
ld hl, BattleTransition_HalfCircle2
call BattleTransition_Circle_Sub1
jp BattleTransition_BlackScreen
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
BattleTransition_FlashScreen:
2014-05-22 22:13:20 +00:00
ld b, $3
2014-05-29 18:21:41 +00:00
call BattleTransition_FlashScreen_
2014-05-22 22:13:20 +00:00
xor a
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
BattleTransition_Circle_Sub1:
2014-05-22 22:13:20 +00:00
push bc
push hl
ld a, b
2014-05-29 18:21:41 +00:00
call BattleTransition_Circle_Sub2
2014-05-22 22:13:20 +00:00
pop hl
2015-07-23 13:07:12 +00:00
ld bc, 5
2014-05-22 22:13:20 +00:00
add hl, bc
2014-05-29 18:21:41 +00:00
call BattleTransition_TransferDelay3
2014-05-22 22:13:20 +00:00
pop bc
dec c
2014-05-29 18:21:41 +00:00
jr nz, BattleTransition_Circle_Sub1
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
BattleTransition_TransferDelay3:
2015-07-23 13:07:12 +00:00
ld a, 1
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
call Delay3
xor a
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
ret
2014-05-29 18:21:41 +00:00
; used for low level wild non-dungeon battles
; makes two half circles around the screen
; by animating both half circles at the same time
2016-06-12 00:24:04 +00:00
BattleTransition_DoubleCircle:
2014-05-29 18:21:41 +00:00
call BattleTransition_FlashScreen
2015-07-14 07:16:19 +00:00
ld c, SCREEN_WIDTH / 2
2014-05-29 18:21:41 +00:00
ld hl, BattleTransition_HalfCircle1
ld de, BattleTransition_HalfCircle2
.loop
2014-05-22 22:13:20 +00:00
push bc
push hl
push de
push de
xor a
2014-05-29 18:21:41 +00:00
call BattleTransition_Circle_Sub2
2014-05-22 22:13:20 +00:00
pop hl
ld a, $1
2014-05-29 18:21:41 +00:00
call BattleTransition_Circle_Sub2
2014-05-22 22:13:20 +00:00
pop hl
2015-07-23 13:07:12 +00:00
ld bc, 5
2014-05-22 22:13:20 +00:00
add hl, bc
ld e, l
ld d, h
pop hl
add hl, bc
2014-05-29 18:21:41 +00:00
call BattleTransition_TransferDelay3
2014-05-22 22:13:20 +00:00
pop bc
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop
jp BattleTransition_BlackScreen
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
BattleTransition_Circle_Sub2:
2015-07-23 13:07:12 +00:00
ld [wBattleTransitionCircleScreenQuadrantY], a
2014-05-22 22:13:20 +00:00
ld a, [hli]
2015-07-23 13:07:12 +00:00
ld [wBattleTransitionCircleScreenQuadrantX], a
2014-05-22 22:13:20 +00:00
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld h, [hl]
ld l, a
2014-05-29 18:21:41 +00:00
jp BattleTransition_Circle_Sub3
2014-05-22 22:13:20 +00:00
2020-10-20 00:26:35 +00:00
; halves
const_def
const CIRCLE_LEFT
const CIRCLE_RIGHT
MACRO half_circle
; quadrant x, circle data, target coord
db \1
dw \2
dwcoord \3, \4
ENDM
2014-05-22 22:13:20 +00:00
BattleTransition_HalfCircle1:
2020-10-20 00:26:35 +00:00
half_circle CIRCLE_RIGHT, BattleTransition_CircleData1, 18, 6
half_circle CIRCLE_RIGHT, BattleTransition_CircleData2, 19, 3
half_circle CIRCLE_RIGHT, BattleTransition_CircleData3, 18, 0
half_circle CIRCLE_RIGHT, BattleTransition_CircleData4, 14, 0
half_circle CIRCLE_RIGHT, BattleTransition_CircleData5, 10, 0
half_circle CIRCLE_LEFT, BattleTransition_CircleData5, 9, 0
half_circle CIRCLE_LEFT, BattleTransition_CircleData4, 5, 0
half_circle CIRCLE_LEFT, BattleTransition_CircleData3, 1, 0
half_circle CIRCLE_LEFT, BattleTransition_CircleData2, 0, 3
half_circle CIRCLE_LEFT, BattleTransition_CircleData1, 1, 6
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
BattleTransition_HalfCircle2:
2020-10-20 00:26:35 +00:00
half_circle CIRCLE_LEFT, BattleTransition_CircleData1, 1, 11
half_circle CIRCLE_LEFT, BattleTransition_CircleData2, 0, 14
half_circle CIRCLE_LEFT, BattleTransition_CircleData3, 1, 17
half_circle CIRCLE_LEFT, BattleTransition_CircleData4, 5, 17
half_circle CIRCLE_LEFT, BattleTransition_CircleData5, 9, 17
half_circle CIRCLE_RIGHT, BattleTransition_CircleData5, 10, 17
half_circle CIRCLE_RIGHT, BattleTransition_CircleData4, 14, 17
half_circle CIRCLE_RIGHT, BattleTransition_CircleData3, 18, 17
half_circle CIRCLE_RIGHT, BattleTransition_CircleData2, 19, 14
half_circle CIRCLE_RIGHT, BattleTransition_CircleData1, 18, 11
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
BattleTransition_Circle_Sub3:
2014-05-22 22:13:20 +00:00
push hl
ld a, [de]
ld c, a
inc de
2014-05-29 18:21:41 +00:00
.loop1
2014-05-22 22:13:20 +00:00
ld [hl], $ff
2015-07-23 13:07:12 +00:00
ld a, [wBattleTransitionCircleScreenQuadrantX]
2014-05-22 22:13:20 +00:00
and a
2014-05-29 18:21:41 +00:00
jr z, .skip1
2014-05-22 22:13:20 +00:00
inc hl
2014-05-29 18:21:41 +00:00
jr .skip2
.skip1
2014-05-22 22:13:20 +00:00
dec hl
2014-05-29 18:21:41 +00:00
.skip2
2014-05-22 22:13:20 +00:00
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop1
2014-05-22 22:13:20 +00:00
pop hl
2015-07-23 13:07:12 +00:00
ld a, [wBattleTransitionCircleScreenQuadrantY]
2014-05-22 22:13:20 +00:00
and a
2015-07-14 07:16:19 +00:00
ld bc, SCREEN_WIDTH
2014-05-29 18:21:41 +00:00
jr z, .skip3
2015-07-14 07:16:19 +00:00
ld bc, -SCREEN_WIDTH
2014-05-29 18:21:41 +00:00
.skip3
2014-05-22 22:13:20 +00:00
add hl, bc
ld a, [de]
inc de
2020-10-20 00:26:35 +00:00
cp -1
2014-05-22 22:13:20 +00:00
ret z
and a
2014-05-29 18:21:41 +00:00
jr z, BattleTransition_Circle_Sub3
2014-05-22 22:13:20 +00:00
ld c, a
2014-05-29 18:21:41 +00:00
.loop2
2015-07-23 13:07:12 +00:00
ld a, [wBattleTransitionCircleScreenQuadrantX]
2014-05-22 22:13:20 +00:00
and a
2014-05-29 18:21:41 +00:00
jr z, .skip4
2014-05-22 22:13:20 +00:00
dec hl
2014-05-29 18:21:41 +00:00
jr .skip5
.skip4
2014-05-22 22:13:20 +00:00
inc hl
2014-05-29 18:21:41 +00:00
.skip5
2014-05-22 22:13:20 +00:00
dec c
2014-05-29 18:21:41 +00:00
jr nz, .loop2
jr BattleTransition_Circle_Sub3
2014-05-22 22:13:20 +00:00
2020-10-20 00:26:35 +00:00
BattleTransition_CircleData1: db 2, 3, 5, 4, 9, -1
BattleTransition_CircleData2: db 1, 1, 2, 2, 4, 2, 4, 2, 3, -1
BattleTransition_CircleData3: db 2, 1, 3, 1, 4, 1, 4, 1, 4, 1, 3, 1, 2, 1, 1, 1, 1, -1
BattleTransition_CircleData4: db 4, 1, 4, 0, 3, 1, 3, 0, 2, 1, 2, 0, 1, -1
BattleTransition_CircleData5: db 4, 0, 3, 0, 3, 0, 2, 0, 2, 0, 1, 0, 1, 0, 1, -1