2018-01-16 11:30:10 -08:00
|
|
|
DoBattleTransition: ; 8c20f
|
2016-03-01 19:31:21 -08:00
|
|
|
call .InitGFX
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [rBGP]
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wBGP], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [rOBP0]
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wOBP0], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [rOBP1]
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wOBP1], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call DelayFrame
|
|
|
|
ld hl, hVBlank
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
ld [hl], $1
|
|
|
|
|
|
|
|
.loop
|
2015-10-24 16:49:19 -07:00
|
|
|
ld a, [wJumptableIndex]
|
2015-10-19 07:23:58 -07:00
|
|
|
bit 7, a
|
|
|
|
jr nz, .done
|
2018-01-02 06:05:14 -08:00
|
|
|
call BattleTransitionJumptable
|
2015-10-19 07:23:58 -07:00
|
|
|
call DelayFrame
|
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wBGPals1)
|
2015-10-19 07:23:58 -07:00
|
|
|
ld [rSVBK], a
|
|
|
|
|
2018-01-01 06:08:21 -08:00
|
|
|
ld hl, wBGPals1
|
2015-11-16 08:53:26 -08:00
|
|
|
ld bc, 8 palettes
|
2015-10-19 07:23:58 -07:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
|
|
|
|
ld a, %11111111
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wBGP], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call DmgToCgbBGPals
|
|
|
|
call DelayFrame
|
|
|
|
xor a
|
2016-06-13 19:53:33 -07:00
|
|
|
ld [hLCDCPointer], a
|
2016-05-05 12:07:37 -07:00
|
|
|
ld [hLYOverrideStart], a
|
|
|
|
ld [hLYOverrideEnd], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld [hSCY], a
|
|
|
|
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, 1 ; unnecessary bankswitch?
|
2015-10-19 07:23:58 -07:00
|
|
|
ld [rSVBK], a
|
|
|
|
pop af
|
|
|
|
ld [hVBlank], a
|
|
|
|
call DelayFrame
|
|
|
|
ret
|
|
|
|
; 8c26d
|
|
|
|
|
2016-03-01 19:31:21 -08:00
|
|
|
.InitGFX: ; 8c26d
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
|
|
|
cp LINK_MOBILE
|
|
|
|
jr z, .mobile
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall ReanchorBGMap_NoOAMUpdate
|
2015-10-19 07:23:58 -07:00
|
|
|
call UpdateSprites
|
|
|
|
call DelayFrame
|
2016-03-01 19:31:21 -08:00
|
|
|
call .NonMobile_LoadPokeballTiles
|
2017-12-24 15:11:17 -08:00
|
|
|
call BattleStart_CopyTilemapAtOnce
|
2015-10-19 07:23:58 -07:00
|
|
|
jr .resume
|
|
|
|
|
|
|
|
.mobile
|
|
|
|
call LoadTrainerBattlePokeballTiles
|
|
|
|
|
|
|
|
.resume
|
|
|
|
ld a, SCREEN_HEIGHT_PX
|
|
|
|
ld [hWY], a
|
|
|
|
call DelayFrame
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
2015-10-24 16:49:19 -07:00
|
|
|
ld hl, wJumptableIndex
|
2015-10-19 07:23:58 -07:00
|
|
|
xor a
|
|
|
|
ld [hli], a
|
2015-12-26 18:59:03 -08:00
|
|
|
ld [hli], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld [hl], a
|
|
|
|
call WipeLYOverrides
|
|
|
|
ret
|
|
|
|
; 8c2a0
|
|
|
|
|
2016-03-01 19:31:21 -08:00
|
|
|
.NonMobile_LoadPokeballTiles: ; 8c2a0
|
2015-10-19 07:23:58 -07:00
|
|
|
call LoadTrainerBattlePokeballTiles
|
2015-11-20 08:47:52 -08:00
|
|
|
hlbgcoord 0, 0
|
2016-05-11 06:49:03 -07:00
|
|
|
call ConvertTrainerBattlePokeballTilesTo2bpp
|
2015-10-19 07:23:58 -07:00
|
|
|
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
|
2017-12-28 04:32:33 -08:00
|
|
|
ld hl, vTiles1 tile $7e
|
2015-10-19 07:23:58 -07:00
|
|
|
ld b, BANK(TrainerBattlePokeballTiles)
|
|
|
|
ld c, 2
|
|
|
|
call Request2bpp
|
|
|
|
|
|
|
|
ld a, [rVBK]
|
|
|
|
push af
|
|
|
|
ld a, $1
|
|
|
|
ld [rVBK], a
|
|
|
|
|
|
|
|
ld de, TrainerBattlePokeballTiles
|
2017-12-28 04:32:33 -08:00
|
|
|
ld hl, vTiles4 tile $7e
|
2015-10-19 07:23:58 -07:00
|
|
|
ld b, BANK(TrainerBattlePokeballTiles)
|
|
|
|
ld c, 2
|
|
|
|
call Request2bpp
|
|
|
|
|
|
|
|
pop af
|
|
|
|
ld [rVBK], a
|
|
|
|
ret
|
|
|
|
; 8c2cf
|
|
|
|
|
2016-05-11 06:49:03 -07:00
|
|
|
ConvertTrainerBattlePokeballTilesTo2bpp: ; 8c2cf
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wDecompressScratch)
|
2015-10-19 07:23:58 -07:00
|
|
|
ld [rSVBK], a
|
|
|
|
push hl
|
2015-12-19 11:48:30 -08:00
|
|
|
ld hl, wDecompressScratch
|
2016-01-27 09:25:12 -08:00
|
|
|
ld bc, $28 tiles
|
2015-10-19 07:23:58 -07:00
|
|
|
|
|
|
|
.loop
|
|
|
|
ld [hl], -1
|
|
|
|
inc hl
|
|
|
|
dec bc
|
|
|
|
ld a, c
|
|
|
|
or b
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
pop hl
|
2015-12-19 11:48:30 -08:00
|
|
|
ld de, wDecompressScratch
|
2016-05-11 06:49:03 -07:00
|
|
|
ld b, BANK(ConvertTrainerBattlePokeballTilesTo2bpp) ; BANK(@)
|
2015-10-19 07:23:58 -07:00
|
|
|
ld c, $28
|
|
|
|
call Request2bpp
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 8c2f4
|
|
|
|
|
|
|
|
TrainerBattlePokeballTiles: ; 8c2f4
|
2017-12-10 21:17:39 -08:00
|
|
|
INCBIN "gfx/overworld/trainer_battle_pokeball_tiles.2bpp"
|
2015-10-19 07:23:58 -07:00
|
|
|
|
|
|
|
|
2018-01-02 06:05:14 -08:00
|
|
|
BattleTransitionJumptable: ; 8c314
|
2015-12-26 18:59:03 -08:00
|
|
|
jumptable .dw, wJumptableIndex
|
2015-10-19 07:23:58 -07:00
|
|
|
; 8c323
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.dw ; 8c323 (23:4323)
|
2015-10-19 07:23:58 -07:00
|
|
|
dw StartTrainerBattle_DetermineWhichAnimation ; 00
|
|
|
|
|
|
|
|
; Animation 1: cave
|
|
|
|
dw StartTrainerBattle_LoadPokeBallGraphics ; 01
|
|
|
|
dw StartTrainerBattle_SetUpBGMap ; 02
|
|
|
|
dw StartTrainerBattle_Flash ; 03
|
|
|
|
dw StartTrainerBattle_Flash ; 04
|
|
|
|
dw StartTrainerBattle_Flash ; 05
|
|
|
|
dw StartTrainerBattle_NextScene ; 06
|
|
|
|
dw StartTrainerBattle_SetUpForWavyOutro ; 07
|
|
|
|
dw StartTrainerBattle_SineWave ; 08
|
|
|
|
|
|
|
|
; Animation 2: cave, stronger
|
|
|
|
dw StartTrainerBattle_LoadPokeBallGraphics ; 09
|
|
|
|
dw StartTrainerBattle_SetUpBGMap ; 0a
|
|
|
|
dw StartTrainerBattle_Flash ; 0b
|
|
|
|
dw StartTrainerBattle_Flash ; 0c
|
|
|
|
dw StartTrainerBattle_Flash ; 0d
|
|
|
|
dw StartTrainerBattle_NextScene ; 0e
|
|
|
|
; There is no setup for this one
|
|
|
|
dw StartTrainerBattle_ZoomToBlack ; 0f
|
|
|
|
|
|
|
|
; Animation 3: no cave
|
|
|
|
dw StartTrainerBattle_LoadPokeBallGraphics ; 10
|
|
|
|
dw StartTrainerBattle_SetUpBGMap ; 11
|
|
|
|
dw StartTrainerBattle_Flash ; 12
|
|
|
|
dw StartTrainerBattle_Flash ; 13
|
|
|
|
dw StartTrainerBattle_Flash ; 14
|
|
|
|
dw StartTrainerBattle_NextScene ; 15
|
|
|
|
dw StartTrainerBattle_SetUpForSpinOutro ; 16
|
|
|
|
dw StartTrainerBattle_SpinToBlack ; 17
|
|
|
|
|
|
|
|
; Animation 4: no cave, stronger
|
|
|
|
dw StartTrainerBattle_LoadPokeBallGraphics ; 18
|
|
|
|
dw StartTrainerBattle_SetUpBGMap ; 19
|
|
|
|
dw StartTrainerBattle_Flash ; 1a
|
|
|
|
dw StartTrainerBattle_Flash ; 1b
|
|
|
|
dw StartTrainerBattle_Flash ; 1c
|
|
|
|
dw StartTrainerBattle_NextScene ; 1d
|
|
|
|
dw StartTrainerBattle_SetUpForRandomScatterOutro ; 1e
|
|
|
|
dw StartTrainerBattle_SpeckleToBlack ; 1f
|
|
|
|
|
|
|
|
; All animations jump to here.
|
|
|
|
dw StartTrainerBattle_Finish ; 20
|
|
|
|
|
|
|
|
|
|
|
|
StartTrainerBattle_DetermineWhichAnimation: ; 8c365 (23:4365)
|
2017-12-12 19:58:20 -08:00
|
|
|
; The screen flashes a different number of times depending on the level of
|
|
|
|
; your lead Pokemon relative to the opponent's.
|
|
|
|
; BUG: BattleMonLevel and EnemyMonLevel are not set at this point, so whatever
|
|
|
|
; values happen to be there will determine the animation.
|
2015-10-19 07:23:58 -07:00
|
|
|
ld de, 0
|
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
add 3
|
|
|
|
ld hl, EnemyMonLevel
|
|
|
|
cp [hl]
|
|
|
|
jr nc, .okay
|
|
|
|
set 0, e
|
|
|
|
.okay
|
2017-12-24 10:08:38 -08:00
|
|
|
ld a, [wEnvironment]
|
2015-10-19 07:23:58 -07:00
|
|
|
cp CAVE
|
|
|
|
jr z, .okay2
|
2017-12-24 10:08:38 -08:00
|
|
|
cp ENVIRONMENT_5
|
2015-10-19 07:23:58 -07:00
|
|
|
jr z, .okay2
|
|
|
|
cp DUNGEON
|
|
|
|
jr z, .okay2
|
|
|
|
set 1, e
|
|
|
|
.okay2
|
|
|
|
ld hl, .StartingPoints
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2015-10-24 16:49:19 -07:00
|
|
|
ld [wJumptableIndex], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ret
|
|
|
|
; 8c38f (23:438f)
|
|
|
|
|
|
|
|
.StartingPoints: ; 8c38f
|
|
|
|
db 1, 9
|
|
|
|
db 16, 24
|
|
|
|
; 8c393
|
|
|
|
|
|
|
|
StartTrainerBattle_Finish: ; 8c393 (23:4393)
|
|
|
|
call ClearSprites
|
|
|
|
ld a, $80
|
2015-10-24 16:49:19 -07:00
|
|
|
ld [wJumptableIndex], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
StartTrainerBattle_NextScene: ; 8c39c (23:439c)
|
2015-10-24 16:49:19 -07:00
|
|
|
ld hl, wJumptableIndex
|
2015-10-19 07:23:58 -07:00
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
StartTrainerBattle_SetUpBGMap: ; 8c3a1 (23:43a1)
|
|
|
|
call StartTrainerBattle_NextScene
|
|
|
|
xor a
|
|
|
|
ld [wcf64], a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
StartTrainerBattle_Flash: ; 8c3ab (23:43ab)
|
|
|
|
call .DoFlashAnimation
|
|
|
|
ret nc
|
|
|
|
call StartTrainerBattle_NextScene
|
|
|
|
ret
|
|
|
|
|
|
|
|
.DoFlashAnimation: ; 8c3b3 (23:43b3)
|
2015-12-14 08:12:18 -08:00
|
|
|
ld a, [wTimeOfDayPalset]
|
|
|
|
cp %11111111 ; dark cave
|
2015-10-19 07:23:58 -07:00
|
|
|
jr z, .done
|
|
|
|
ld hl, wcf64
|
|
|
|
ld a, [hl]
|
|
|
|
inc [hl]
|
|
|
|
srl a
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, .pals
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
cp %00000001
|
|
|
|
jr z, .done
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wBGP], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call DmgToCgbBGPals
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.done
|
|
|
|
xor a
|
|
|
|
ld [wcf64], a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 8c3db (23:43db)
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.pals ; 8c3db
|
2015-10-19 07:23:58 -07:00
|
|
|
db %11111001 ; 3321
|
|
|
|
db %11111110 ; 3332
|
|
|
|
db %11111111 ; 3333
|
|
|
|
db %11111110 ; 3332
|
|
|
|
db %11111001 ; 3321
|
|
|
|
db %11100100 ; 3210
|
|
|
|
db %10010000 ; 2100
|
|
|
|
db %01000000 ; 1000
|
|
|
|
db %00000000 ; 0000
|
|
|
|
db %01000000 ; 1000
|
|
|
|
db %10010000 ; 2100
|
|
|
|
db %11100100 ; 3210
|
|
|
|
db %00000001 ; 0001
|
|
|
|
; 8c3e8
|
|
|
|
|
|
|
|
StartTrainerBattle_SetUpForWavyOutro: ; 8c3e8 (23:43e8)
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall Function5602
|
2018-01-02 13:46:40 -08:00
|
|
|
ld a, BANK(LYOverrides)
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [rSVBK], a
|
2015-11-16 08:53:26 -08:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
call StartTrainerBattle_NextScene
|
2015-11-16 08:53:26 -08:00
|
|
|
|
2016-06-13 19:53:33 -07:00
|
|
|
ld a, rSCX - $ff00
|
|
|
|
ld [hLCDCPointer], a
|
2015-10-19 07:23:58 -07:00
|
|
|
xor a
|
2016-05-05 12:07:37 -07:00
|
|
|
ld [hLYOverrideStart], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, $90
|
2016-05-05 12:07:37 -07:00
|
|
|
ld [hLYOverrideEnd], a
|
2015-10-19 07:23:58 -07:00
|
|
|
xor a
|
|
|
|
ld [wcf64], a
|
|
|
|
ld [wcf65], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
StartTrainerBattle_SineWave: ; 8c408 (23:4408)
|
|
|
|
ld a, [wcf64]
|
|
|
|
cp $60
|
|
|
|
jr nc, .end
|
|
|
|
call .DoSineWave
|
|
|
|
ret
|
|
|
|
|
|
|
|
.end
|
|
|
|
ld a, $20
|
2015-10-24 16:49:19 -07:00
|
|
|
ld [wJumptableIndex], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.DoSineWave: ; 8c419 (23:4419)
|
|
|
|
ld hl, wcf65
|
|
|
|
ld a, [hl]
|
|
|
|
inc [hl]
|
|
|
|
ld hl, wcf64
|
|
|
|
ld d, [hl]
|
|
|
|
add [hl]
|
|
|
|
ld [hl], a
|
2015-11-16 08:53:26 -08:00
|
|
|
ld a, LYOverridesEnd - LYOverrides
|
|
|
|
ld bc, LYOverrides
|
2015-10-19 07:23:58 -07:00
|
|
|
ld e, $0
|
|
|
|
|
|
|
|
.loop
|
|
|
|
push af
|
|
|
|
push de
|
|
|
|
ld a, e
|
|
|
|
call StartTrainerBattle_DrawSineWave
|
|
|
|
ld [bc], a
|
|
|
|
inc bc
|
|
|
|
pop de
|
|
|
|
ld a, e
|
|
|
|
add $2
|
|
|
|
ld e, a
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
|
|
|
StartTrainerBattle_SetUpForSpinOutro: ; 8c43d (23:443d)
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall Function5602
|
2018-01-02 13:46:40 -08:00
|
|
|
ld a, BANK(LYOverrides)
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [rSVBK], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call StartTrainerBattle_NextScene
|
|
|
|
xor a
|
|
|
|
ld [wcf64], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
StartTrainerBattle_SpinToBlack: ; 8c44f (23:444f)
|
|
|
|
xor a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wcf64]
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, .spintable
|
|
|
|
rept 5
|
|
|
|
add hl, de
|
|
|
|
endr
|
|
|
|
ld a, [hli]
|
|
|
|
cp -1
|
|
|
|
jr z, .end
|
|
|
|
ld [wcf65], a
|
|
|
|
call .load
|
|
|
|
ld a, $1
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call DelayFrame
|
|
|
|
call DelayFrame
|
|
|
|
ld hl, wcf64
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.end
|
|
|
|
ld a, $1
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call DelayFrame
|
|
|
|
call DelayFrame
|
|
|
|
call DelayFrame
|
|
|
|
xor a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, $20
|
2015-10-24 16:49:19 -07:00
|
|
|
ld [wJumptableIndex], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ret
|
|
|
|
; 8c490 (23:4490)
|
|
|
|
|
2017-12-13 21:36:24 -08:00
|
|
|
; quadrants
|
|
|
|
const_def
|
|
|
|
const UPPER_LEFT
|
|
|
|
const UPPER_RIGHT
|
|
|
|
const LOWER_LEFT
|
|
|
|
const LOWER_RIGHT
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.spintable ; 8c490
|
2017-12-13 21:36:24 -08:00
|
|
|
spintable_entry: MACRO
|
|
|
|
db \1
|
|
|
|
dw .wedge\2
|
|
|
|
dwcoord \3, \4
|
|
|
|
ENDM
|
2015-10-19 07:23:58 -07:00
|
|
|
spintable_entry UPPER_LEFT, 1, 1, 6
|
|
|
|
spintable_entry UPPER_LEFT, 2, 0, 3
|
|
|
|
spintable_entry UPPER_LEFT, 3, 1, 0
|
|
|
|
spintable_entry UPPER_LEFT, 4, 5, 0
|
|
|
|
spintable_entry UPPER_LEFT, 5, 9, 0
|
|
|
|
spintable_entry UPPER_RIGHT, 5, 10, 0
|
|
|
|
spintable_entry UPPER_RIGHT, 4, 14, 0
|
|
|
|
spintable_entry UPPER_RIGHT, 3, 18, 0
|
|
|
|
spintable_entry UPPER_RIGHT, 2, 19, 3
|
|
|
|
spintable_entry UPPER_RIGHT, 1, 18, 6
|
|
|
|
spintable_entry LOWER_RIGHT, 1, 18, 11
|
|
|
|
spintable_entry LOWER_RIGHT, 2, 19, 14
|
|
|
|
spintable_entry LOWER_RIGHT, 3, 18, 17
|
|
|
|
spintable_entry LOWER_RIGHT, 4, 14, 17
|
|
|
|
spintable_entry LOWER_RIGHT, 5, 10, 17
|
|
|
|
spintable_entry LOWER_LEFT, 5, 9, 17
|
|
|
|
spintable_entry LOWER_LEFT, 4, 5, 17
|
|
|
|
spintable_entry LOWER_LEFT, 3, 1, 17
|
|
|
|
spintable_entry LOWER_LEFT, 2, 0, 14
|
|
|
|
spintable_entry LOWER_LEFT, 1, 1, 11
|
|
|
|
db -1
|
|
|
|
; 8c4f5
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.load ; 8c4f5 (23:44f5)
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
.loop
|
|
|
|
push hl
|
|
|
|
ld a, [de]
|
|
|
|
ld c, a
|
|
|
|
inc de
|
|
|
|
.loop1
|
|
|
|
ld [hl], $ff
|
|
|
|
ld a, [wcf65]
|
|
|
|
bit 0, a
|
|
|
|
jr z, .leftside
|
|
|
|
inc hl
|
|
|
|
jr .okay1
|
|
|
|
.leftside
|
|
|
|
dec hl
|
|
|
|
.okay1
|
|
|
|
dec c
|
|
|
|
jr nz, .loop1
|
|
|
|
pop hl
|
|
|
|
ld a, [wcf65]
|
|
|
|
bit 1, a
|
|
|
|
ld bc, SCREEN_WIDTH
|
|
|
|
jr z, .upper
|
|
|
|
ld bc, -SCREEN_WIDTH
|
|
|
|
.upper
|
|
|
|
add hl, bc
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
cp -1
|
|
|
|
ret z
|
|
|
|
and a
|
|
|
|
jr z, .loop
|
|
|
|
ld c, a
|
|
|
|
.loop2
|
|
|
|
ld a, [wcf65]
|
|
|
|
bit 0, a
|
|
|
|
jr z, .leftside2
|
|
|
|
dec hl
|
|
|
|
jr .okay2
|
|
|
|
.leftside2
|
|
|
|
inc hl
|
|
|
|
.okay2
|
|
|
|
dec c
|
|
|
|
jr nz, .loop2
|
|
|
|
jr .loop
|
|
|
|
; 8c538 (23:4538)
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.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
|
2015-10-19 07:23:58 -07:00
|
|
|
; 8c578
|
|
|
|
|
|
|
|
StartTrainerBattle_SetUpForRandomScatterOutro: ; 8c578 (23:4578)
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall Function5602
|
2018-01-02 13:46:40 -08:00
|
|
|
ld a, BANK(LYOverrides)
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [rSVBK], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call StartTrainerBattle_NextScene
|
|
|
|
ld a, $10
|
|
|
|
ld [wcf64], a
|
|
|
|
ld a, $1
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
StartTrainerBattle_SpeckleToBlack: ; 8c58f (23:458f)
|
|
|
|
ld hl, wcf64
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr z, .done
|
|
|
|
dec [hl]
|
|
|
|
ld c, $c
|
|
|
|
.loop
|
|
|
|
push bc
|
|
|
|
call .BlackOutRandomTile
|
|
|
|
pop bc
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
|
|
|
.done
|
|
|
|
ld a, $1
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call DelayFrame
|
|
|
|
call DelayFrame
|
|
|
|
call DelayFrame
|
|
|
|
xor a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, $20
|
2015-10-24 16:49:19 -07:00
|
|
|
ld [wJumptableIndex], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.BlackOutRandomTile: ; 8c5b8 (23:45b8)
|
|
|
|
.y_loop
|
|
|
|
call Random
|
|
|
|
cp SCREEN_HEIGHT
|
|
|
|
jr nc, .y_loop
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
.x_loop
|
|
|
|
call Random
|
|
|
|
cp SCREEN_WIDTH
|
|
|
|
jr nc, .x_loop
|
|
|
|
ld c, a
|
|
|
|
|
|
|
|
hlcoord 0, -1
|
|
|
|
ld de, SCREEN_WIDTH
|
|
|
|
inc b
|
|
|
|
|
|
|
|
.row_loop
|
|
|
|
add hl, de
|
|
|
|
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 $ff
|
|
|
|
jr z, .y_loop
|
|
|
|
ld [hl], $ff
|
|
|
|
ret
|
|
|
|
|
|
|
|
StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc)
|
|
|
|
ld a, [OtherTrainerClass]
|
|
|
|
and a
|
2016-01-27 09:25:12 -08:00
|
|
|
jp z, .nextscene ; don't need to be here if wild
|
2015-10-19 07:23:58 -07:00
|
|
|
|
|
|
|
xor a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
hlcoord 0, 0, AttrMap
|
|
|
|
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
|
|
|
|
inc b
|
|
|
|
inc c
|
|
|
|
jr .enter_loop_midway
|
|
|
|
|
|
|
|
.loop
|
2016-01-27 09:25:12 -08:00
|
|
|
; set all pals to 7
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [hl]
|
|
|
|
or %00000111
|
|
|
|
ld [hli], a
|
|
|
|
.enter_loop_midway
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
|
2018-01-09 23:30:17 -08:00
|
|
|
call .loadpokeballgfx
|
2015-10-19 07:23:58 -07:00
|
|
|
hlcoord 2, 1
|
|
|
|
|
|
|
|
ld b, SCREEN_WIDTH - 4
|
|
|
|
.loop2
|
|
|
|
push hl
|
|
|
|
ld c, 2
|
|
|
|
.loop3
|
|
|
|
push hl
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
.loop4
|
|
|
|
; Loading is done bit by bit
|
|
|
|
and a
|
|
|
|
jr z, .done
|
|
|
|
sla a
|
|
|
|
jr nc, .no_load
|
2016-01-27 09:25:12 -08:00
|
|
|
ld [hl], $fe
|
2015-10-19 07:23:58 -07:00
|
|
|
.no_load
|
|
|
|
inc hl
|
|
|
|
jr .loop4
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop hl
|
|
|
|
push bc
|
|
|
|
ld bc, (SCREEN_WIDTH - 4) / 2
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec c
|
|
|
|
jr nz, .loop3
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
push bc
|
|
|
|
ld bc, SCREEN_WIDTH
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz, .loop2
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
ld a, [hCGB]
|
2015-10-19 07:23:58 -07:00
|
|
|
and a
|
|
|
|
jr nz, .cgb
|
|
|
|
ld a, $1
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call DelayFrame
|
|
|
|
call DelayFrame
|
|
|
|
jr .nextscene
|
|
|
|
|
|
|
|
.cgb
|
|
|
|
ld hl, .daypals
|
|
|
|
ld a, [TimeOfDayPal]
|
2018-01-16 14:27:50 -08:00
|
|
|
maskbits NUM_DAYTIMES
|
2018-01-11 09:00:01 -08:00
|
|
|
cp DARKNESS_F
|
2015-10-19 07:23:58 -07:00
|
|
|
jr nz, .daytime
|
|
|
|
ld hl, .nightpals
|
|
|
|
.daytime
|
2015-11-10 13:53:37 -08:00
|
|
|
ld a, [rSVBK]
|
2015-10-19 07:23:58 -07:00
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wBGPals1)
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [rSVBK], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call .copypals
|
|
|
|
push hl
|
2018-01-01 06:08:21 -08:00
|
|
|
ld de, wBGPals1 palette PAL_BG_TEXT
|
2016-01-27 09:25:12 -08:00
|
|
|
ld bc, 1 palettes
|
2015-10-19 07:23:58 -07:00
|
|
|
call CopyBytes
|
|
|
|
pop hl
|
2018-01-01 06:08:21 -08:00
|
|
|
ld de, wBGPals2 palette PAL_BG_TEXT
|
2016-01-27 09:25:12 -08:00
|
|
|
ld bc, 1 palettes
|
2015-10-19 07:23:58 -07:00
|
|
|
call CopyBytes
|
|
|
|
pop af
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [rSVBK], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, $1
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hCGBPalUpdate], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call DelayFrame
|
2017-12-24 15:11:17 -08:00
|
|
|
call BattleStart_CopyTilemapAtOnce
|
2015-10-19 07:23:58 -07:00
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.nextscene ; 8c673 (23:4673)
|
2015-10-19 07:23:58 -07:00
|
|
|
call StartTrainerBattle_NextScene
|
|
|
|
ret
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.copypals ; 8c677 (23:4677)
|
2018-01-01 06:08:21 -08:00
|
|
|
ld de, wBGPals1 palette PAL_BG_TEXT
|
2015-10-19 07:23:58 -07:00
|
|
|
call .copy
|
2018-01-01 06:08:21 -08:00
|
|
|
ld de, wBGPals2 palette PAL_BG_TEXT
|
2015-10-19 07:23:58 -07:00
|
|
|
call .copy
|
2018-01-01 06:08:21 -08:00
|
|
|
ld de, wOBPals1 palette PAL_OW_TREE
|
2015-10-19 07:23:58 -07:00
|
|
|
call .copy
|
2018-01-01 06:08:21 -08:00
|
|
|
ld de, wOBPals2 palette PAL_OW_TREE
|
2015-10-19 07:23:58 -07:00
|
|
|
call .copy
|
2018-01-01 06:08:21 -08:00
|
|
|
ld de, wOBPals1 palette PAL_OW_ROCK
|
2015-10-19 07:23:58 -07:00
|
|
|
call .copy
|
2018-01-01 06:08:21 -08:00
|
|
|
ld de, wOBPals2 palette PAL_OW_ROCK
|
2015-10-19 07:23:58 -07:00
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.copy ; 8c698 (23:4698)
|
2015-10-19 07:23:58 -07:00
|
|
|
push hl
|
2016-01-27 09:25:12 -08:00
|
|
|
ld bc, 1 palettes
|
2015-10-19 07:23:58 -07:00
|
|
|
call CopyBytes
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 8c6a1 (23:46a1)
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.daypals ; 8c6a1
|
2018-01-12 11:54:00 -08:00
|
|
|
INCLUDE "gfx/overworld/trainer_battle_day.pal"
|
2015-10-19 07:23:58 -07:00
|
|
|
; 8c6a9
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.nightpals ; 8c6a9
|
2018-01-12 11:54:00 -08:00
|
|
|
INCLUDE "gfx/overworld/trainer_battle_nite.pal"
|
|
|
|
; 8c6b1
|
2015-10-19 07:23:58 -07:00
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.loadpokeballgfx
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [OtherTrainerClass]
|
|
|
|
ld de, PokeBallTransition
|
|
|
|
ret
|
|
|
|
|
|
|
|
PokeBallTransition:
|
|
|
|
db %00000011, %11000000
|
|
|
|
db %00001111, %11110000
|
|
|
|
db %00111100, %00111100
|
|
|
|
db %00110000, %00001100
|
|
|
|
db %01100000, %00000110
|
|
|
|
db %01100011, %11000110
|
|
|
|
db %11000110, %01100011
|
|
|
|
db %11111100, %00111111
|
|
|
|
db %11111100, %00111111
|
|
|
|
db %11000110, %01100011
|
|
|
|
db %01100011, %11000110
|
|
|
|
db %01100000, %00000110
|
|
|
|
db %00110000, %00001100
|
|
|
|
db %00111100, %00111100
|
|
|
|
db %00001111, %11110000
|
|
|
|
db %00000011, %11000000
|
|
|
|
|
|
|
|
WipeLYOverrides: ; 8c6d8
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(LYOverrides)
|
2015-10-19 07:23:58 -07:00
|
|
|
ld [rSVBK], a
|
2015-11-16 08:53:26 -08:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld hl, LYOverrides
|
|
|
|
call .wipe
|
|
|
|
ld hl, LYOverridesBackup
|
|
|
|
call .wipe
|
2015-11-16 08:53:26 -08:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 8c6ef
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.wipe ; 8c6ef
|
2015-10-19 07:23:58 -07:00
|
|
|
xor a
|
|
|
|
ld c, SCREEN_HEIGHT_PX
|
|
|
|
.loop
|
|
|
|
ld [hli], a
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
; 8c6f7
|
|
|
|
|
|
|
|
|
|
|
|
StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7)
|
2018-01-09 13:39:36 -08:00
|
|
|
; a = d * sin(a * pi/32)
|
|
|
|
and %111111
|
|
|
|
cp %100000
|
|
|
|
jr nc, .negative
|
|
|
|
call .ApplySineWave
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, h
|
|
|
|
ret
|
|
|
|
|
2018-01-09 13:39:36 -08:00
|
|
|
.negative
|
|
|
|
and %011111
|
|
|
|
call .ApplySineWave
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, h
|
2018-01-09 13:39:36 -08:00
|
|
|
xor $ff
|
2015-10-19 07:23:58 -07:00
|
|
|
inc a
|
|
|
|
ret
|
|
|
|
|
2018-01-09 13:39:36 -08:00
|
|
|
.ApplySineWave: ; 8c70c (23:470c)
|
2015-10-19 07:23:58 -07:00
|
|
|
ld e, a
|
|
|
|
ld a, d
|
|
|
|
ld d, 0
|
|
|
|
ld hl, .sinewave
|
|
|
|
add hl, de
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, de
|
2015-10-19 07:23:58 -07:00
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
ld hl, 0
|
2018-01-09 13:39:36 -08:00
|
|
|
.multiply
|
2015-10-19 07:23:58 -07:00
|
|
|
srl a
|
2018-01-09 13:39:36 -08:00
|
|
|
jr nc, .even
|
2015-10-19 07:23:58 -07:00
|
|
|
add hl, de
|
2018-01-09 13:39:36 -08:00
|
|
|
.even
|
2015-10-19 07:23:58 -07:00
|
|
|
sla e
|
|
|
|
rl d
|
|
|
|
and a
|
2018-01-09 13:39:36 -08:00
|
|
|
jr nz, .multiply
|
2015-10-19 07:23:58 -07:00
|
|
|
ret
|
|
|
|
; 8c728 (23:4728)
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.sinewave ; 8c728
|
2015-10-19 07:23:58 -07:00
|
|
|
sine_wave $100
|
|
|
|
; 8c768
|
|
|
|
|
|
|
|
StartTrainerBattle_ZoomToBlack: ; 8c768 (23:4768)
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall Function5602
|
2015-10-19 07:23:58 -07:00
|
|
|
ld de, .boxes
|
|
|
|
|
|
|
|
.loop
|
|
|
|
ld a, [de]
|
|
|
|
cp -1
|
|
|
|
jr z, .done
|
|
|
|
inc de
|
|
|
|
ld c, a
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld l, a
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld h, a
|
|
|
|
xor a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hBGMapMode], a
|
2015-10-19 07:23:58 -07:00
|
|
|
call .Copy
|
|
|
|
call WaitBGMap
|
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
ld a, $20
|
2015-10-24 16:49:19 -07:00
|
|
|
ld [wJumptableIndex], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ret
|
|
|
|
; 8c792 (23:4792)
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.boxes ; 8c792
|
2017-12-28 04:23:44 -08:00
|
|
|
zoombox: MACRO
|
2017-12-13 21:36:24 -08:00
|
|
|
; width, height, start y, start x
|
|
|
|
db \1, \2
|
|
|
|
dwcoord \3, \4
|
2017-12-28 13:31:16 -08:00
|
|
|
ENDM
|
2015-10-19 07:23:58 -07:00
|
|
|
zoombox 4, 2, 8, 8
|
|
|
|
zoombox 6, 4, 7, 7
|
|
|
|
zoombox 8, 6, 6, 6
|
|
|
|
zoombox 10, 8, 5, 5
|
|
|
|
zoombox 12, 10, 4, 4
|
|
|
|
zoombox 14, 12, 3, 3
|
|
|
|
zoombox 16, 14, 2, 2
|
|
|
|
zoombox 18, 16, 1, 1
|
|
|
|
zoombox 20, 18, 0, 0
|
|
|
|
db -1
|
|
|
|
; 8c7b7
|
|
|
|
|
|
|
|
.Copy: ; 8c7b7 (23:47b7)
|
|
|
|
ld a, $ff
|
|
|
|
.row
|
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
.col
|
|
|
|
ld [hli], a
|
|
|
|
dec c
|
|
|
|
jr nz, .col
|
|
|
|
pop hl
|
|
|
|
ld bc, SCREEN_WIDTH
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz, .row
|
|
|
|
ret
|
|
|
|
; 8c7c9 (23:47c9)
|
2017-12-15 17:10:54 -08:00
|
|
|
|
2018-01-02 04:24:05 -08:00
|
|
|
Unreferenced_Function8c7c9:
|
2017-12-15 17:10:54 -08:00
|
|
|
ld a, $1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
call WaitBGMap
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ret
|