summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi@gmail.com>2020-12-08 14:33:46 -0500
committerRangi <remy.oukaour+rangi@gmail.com>2020-12-08 14:33:46 -0500
commit43286f43737fbaf9032182b85638da59634e67e7 (patch)
treef0e2075bb1b6a1e67ec6250a40dfcd3980aa8267
parent2831f2e3fea69de9b19b4f7e9ecebac454614576 (diff)
Match pokegold's battle transition code more closely
-rwxr-xr-xconstants/palette_constants.asm4
-rw-r--r--constants/sgb_constants.asm4
-rwxr-xr-xdata/pokemon/palettes.inc62
-rw-r--r--data/super_palettes.inc4
-rw-r--r--engine/battle/battle_transitions.asm301
-rw-r--r--macros/data.asm2
-rw-r--r--ram/wram.asm19
7 files changed, 206 insertions, 190 deletions
diff --git a/constants/palette_constants.asm b/constants/palette_constants.asm
index e3a72ad..4453f18 100755
--- a/constants/palette_constants.asm
+++ b/constants/palette_constants.asm
@@ -23,7 +23,7 @@
const PAL_GREENMON ; 15
const PAL_PINKMON ; 16
const PAL_YELLOWMON ; 17
- const PAL_GREYMON ; 18
+ const PAL_GRAYMON ; 18
const PAL_SHINY_MEWMON ; 19
const PAL_SHINY_BLUEMON ; 1a
const PAL_SHINY_REDMON ; 1b
@@ -33,7 +33,7 @@
const PAL_SHINY_GREENMON ; 1f
const PAL_SHINY_PINKMON ; 20
const PAL_SHINY_YELLOWMON ; 21
- const PAL_SHINY_GREYMON ; 22
+ const PAL_SHINY_GRAYMON ; 22
const PAL_GREEN_BAR ; 23
const PAL_YELLOW_BAR ; 24
const PAL_RED_BAR ; 25
diff --git a/constants/sgb_constants.asm b/constants/sgb_constants.asm
index c3b53b5..73f65f8 100644
--- a/constants/sgb_constants.asm
+++ b/constants/sgb_constants.asm
@@ -74,7 +74,7 @@ SGB_RAM EQU -1
const PREDEFPAL_RB_GREENMON
const PREDEFPAL_RB_PINKMON
const PREDEFPAL_RB_YELLOWMON
- const PREDEFPAL_CGB_BADGE ; RB_GREYMON
+ const PREDEFPAL_CGB_BADGE ; RB_GRAYMON
const PREDEFPAL_BETA_SHINY_MEWMON
const PREDEFPAL_BETA_SHINY_BLUEMON
const PREDEFPAL_BETA_SHINY_REDMON
@@ -84,7 +84,7 @@ SGB_RAM EQU -1
const PREDEFPAL_BETA_SHINY_GREENMON
const PREDEFPAL_BETA_SHINY_PINKMON
const PREDEFPAL_BETA_SHINY_YELLOWMON
- const PREDEFPAL_PARTY_ICON ; BETA_SHINY_GREYMON
+ const PREDEFPAL_PARTY_ICON ; BETA_SHINY_GRAYMON
const PREDEFPAL_HP_GREEN
const PREDEFPAL_HP_YELLOW
const PREDEFPAL_HP_RED
diff --git a/data/pokemon/palettes.inc b/data/pokemon/palettes.inc
index 71a526d..8016446 100755
--- a/data/pokemon/palettes.inc
+++ b/data/pokemon/palettes.inc
@@ -18,8 +18,8 @@ PokemonPalettes:
db PAL_BROWNMON ; PIDGEY
db PAL_BROWNMON ; PIDGEOTTO
db PAL_BROWNMON ; PIDGEOT
- db PAL_GREYMON ; RATTATA
- db PAL_GREYMON ; RATICATE
+ db PAL_GRAYMON ; RATTATA
+ db PAL_GRAYMON ; RATICATE
db PAL_BROWNMON ; SPEAROW
db PAL_BROWNMON ; FEAROW
db PAL_PURPLEMON ; EKANS
@@ -65,23 +65,23 @@ PokemonPalettes:
db PAL_YELLOWMON ; ABRA
db PAL_YELLOWMON ; KADABRA
db PAL_YELLOWMON ; ALAKAZAM
- db PAL_GREYMON ; MACHOP
- db PAL_GREYMON ; MACHOKE
- db PAL_GREYMON ; MACHAMP
+ db PAL_GRAYMON ; MACHOP
+ db PAL_GRAYMON ; MACHOKE
+ db PAL_GRAYMON ; MACHAMP
db PAL_GREENMON ; BELLSPROUT
db PAL_GREENMON ; WEEPINBELL
db PAL_GREENMON ; VICTREEBEL
db PAL_CYANMON ; TENTACOOL
db PAL_CYANMON ; TENTACRUEL
- db PAL_GREYMON ; GEODUDE
- db PAL_GREYMON ; GRAVELER
- db PAL_GREYMON ; GOLEM
+ db PAL_GRAYMON ; GEODUDE
+ db PAL_GRAYMON ; GRAVELER
+ db PAL_GRAYMON ; GOLEM
db PAL_REDMON ; PONYTA
db PAL_REDMON ; RAPIDASH
db PAL_PINKMON ; SLOWPOKE
db PAL_PINKMON ; SLOWBRO
- db PAL_GREYMON ; MAGNEMITE
- db PAL_GREYMON ; MAGNETON
+ db PAL_GRAYMON ; MAGNEMITE
+ db PAL_GRAYMON ; MAGNETON
db PAL_BROWNMON ; FARFETCHD
db PAL_BROWNMON ; DODUO
db PAL_BROWNMON ; DODRIO
@@ -89,12 +89,12 @@ PokemonPalettes:
db PAL_BLUEMON ; DEWGONG
db PAL_PURPLEMON ; GRIMER
db PAL_PURPLEMON ; MUK
- db PAL_GREYMON ; SHELLDER
- db PAL_GREYMON ; CLOYSTER
+ db PAL_GRAYMON ; SHELLDER
+ db PAL_GRAYMON ; CLOYSTER
db PAL_PURPLEMON ; GASTLY
db PAL_PURPLEMON ; HAUNTER
db PAL_PURPLEMON ; GENGAR
- db PAL_GREYMON ; ONIX
+ db PAL_GRAYMON ; ONIX
db PAL_YELLOWMON ; DROWZEE
db PAL_YELLOWMON ; HYPNO
db PAL_REDMON ; KRABBY
@@ -103,15 +103,15 @@ PokemonPalettes:
db PAL_YELLOWMON ; ELECTRODE
db PAL_PINKMON ; EXEGGCUTE
db PAL_GREENMON ; EXEGGUTOR
- db PAL_GREYMON ; CUBONE
- db PAL_GREYMON ; MAROWAK
+ db PAL_GRAYMON ; CUBONE
+ db PAL_GRAYMON ; MAROWAK
db PAL_BROWNMON ; HITMONLEE
db PAL_BROWNMON ; HITMONCHAN
db PAL_PINKMON ; LICKITUNG
db PAL_PURPLEMON ; KOFFING
db PAL_PURPLEMON ; WEEZING
- db PAL_GREYMON ; RHYHORN
- db PAL_GREYMON ; RHYDON
+ db PAL_GRAYMON ; RHYHORN
+ db PAL_GRAYMON ; RHYDON
db PAL_PINKMON ; CHANSEY
db PAL_BLUEMON ; TANGELA
db PAL_BROWNMON ; KANGASKHAN
@@ -120,33 +120,33 @@ PokemonPalettes:
db PAL_REDMON ; GOLDEEN
db PAL_REDMON ; SEAKING
db PAL_REDMON ; STARYU
- db PAL_GREYMON ; STARMIE
+ db PAL_GRAYMON ; STARMIE
db PAL_PINKMON ; MRMIME
db PAL_GREENMON ; SCYTHER
db PAL_MEWMON ; JYNX
db PAL_YELLOWMON ; ELECTABUZZ
db PAL_REDMON ; MAGMAR
db PAL_BROWNMON ; PINSIR
- db PAL_GREYMON ; TAUROS
+ db PAL_GRAYMON ; TAUROS
db PAL_REDMON ; MAGIKARP
db PAL_BLUEMON ; GYARADOS
db PAL_CYANMON ; LAPRAS
- db PAL_GREYMON ; DITTO
- db PAL_GREYMON ; EEVEE
+ db PAL_GRAYMON ; DITTO
+ db PAL_GRAYMON ; EEVEE
db PAL_CYANMON ; VAPOREON
db PAL_YELLOWMON ; JOLTEON
db PAL_REDMON ; FLAREON
- db PAL_GREYMON ; PORYGON
+ db PAL_GRAYMON ; PORYGON
db PAL_BLUEMON ; OMANYTE
db PAL_BLUEMON ; OMASTAR
db PAL_BROWNMON ; KABUTO
db PAL_BROWNMON ; KABUTOPS
- db PAL_GREYMON ; AERODACTYL
+ db PAL_GRAYMON ; AERODACTYL
db PAL_PINKMON ; SNORLAX
db PAL_BLUEMON ; ARTICUNO
db PAL_YELLOWMON ; ZAPDOS
db PAL_REDMON ; MOLTRES
- db PAL_GREYMON ; DRATINI
+ db PAL_GRAYMON ; DRATINI
db PAL_BLUEMON ; DRAGONAIR
db PAL_BROWNMON ; DRAGONITE
db PAL_MEWMON ; MEWTWO
@@ -186,8 +186,8 @@ PokemonPalettes:
db PAL_REDMON ; PARA
db PAL_PURPLEMON ; KOKUMO
db PAL_PURPLEMON ; TWOHEAD
- db PAL_GREYMON ; YOROIDORI
- db PAL_GREYMON ; ANIMON
+ db PAL_GRAYMON ; YOROIDORI
+ db PAL_GRAYMON ; ANIMON
db PAL_BROWNMON ; HINAZU
db PAL_YELLOWMON ; SUNNY
db PAL_CYANMON ; PAON
@@ -205,9 +205,9 @@ PokemonPalettes:
db PAL_REDMON ; MITSUBOSHI
db PAL_REDMON ; PUCHICORN
db PAL_YELLOWMON ; EIFIE
- db PAL_GREYMON ; BLACKY
- db PAL_GREYMON ; TURBAN
- db PAL_GREYMON ; BETBABY
+ db PAL_GRAYMON ; BLACKY
+ db PAL_GRAYMON ; TURBAN
+ db PAL_GRAYMON ; BETBABY
db PAL_BLUEMON ; TEPPOUO
db PAL_REDMON ; OKUTANK
db PAL_BROWNMON ; GONGU
@@ -238,9 +238,9 @@ PokemonPalettes:
db PAL_REDMON ; HELGAA
db PAL_BROWNMON ; WOLFMAN
db PAL_BROWNMON ; WARWOLF
- db PAL_GREYMON ; PORYGON2
+ db PAL_GRAYMON ; PORYGON2
db PAL_PINKMON ; NAMEIL
- db PAL_GREYMON ; HAGANEIL
+ db PAL_GRAYMON ; HAGANEIL
db PAL_BLUEMON ; KINGDRA
db PAL_YELLOWMON ; RAI
db PAL_REDMON ; EN
diff --git a/data/super_palettes.inc b/data/super_palettes.inc
index 02fbed3..5dba6d8 100644
--- a/data/super_palettes.inc
+++ b/data/super_palettes.inc
@@ -23,7 +23,7 @@ SuperPalettes::
RGB 28,28,28, 20,26,16, 09,20,11, 04,04,04 ; GREENMON
RGB 28,28,28, 30,22,24, 28,15,21, 04,04,04 ; PINKMON
RGB 28,28,28, 31,28,14, 26,20,00, 04,04,04 ; YELLOWMON
- RGB 28,28,28, 26,21,22, 15,15,18, 04,04,04 ; GREYMON
+ RGB 28,28,28, 26,21,22, 15,15,18, 04,04,04 ; GRAYMON
RGB 28,28,28, 23,19,13, 14,12,17, 04,04,04 ; SHINY_MEWMON
RGB 28,28,28, 16,18,21, 10,12,18, 04,04,04 ; SHINY_BLUEMON
RGB 28,28,28, 22,15,16, 17,02,05, 04,04,04 ; SHINY_REDMON
@@ -33,7 +33,7 @@ SuperPalettes::
RGB 28,28,28, 23,21,16, 12,12,10, 04,04,04 ; SHINY_GREENMON
RGB 28,28,28, 21,25,29, 30,22,24, 04,04,04 ; SHINY_PINKMON
RGB 28,28,28, 26,23,16, 29,14,09, 04,04,04 ; SHINY_YELLOWMON
- RGB 28,28,28, 18,18,18, 10,10,10, 04,04,04 ; SHINY_GREYMON
+ RGB 28,28,28, 18,18,18, 10,10,10, 04,04,04 ; SHINY_GRAYMON
RGB 28,28,28, 30,26,15, 09,20,11, 04,04,04 ; GREEN_BAR
RGB 28,28,28, 30,26,15, 26,20,00, 04,04,04 ; YELLOW_BAR
RGB 28,28,28, 30,26,15, 26,10,06, 04,04,04 ; RED_BAR
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
diff --git a/macros/data.asm b/macros/data.asm
index 0c3723a..97eb568 100644
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -123,7 +123,7 @@ sine_table: MACRO
; \1 samples of sin(x) from x=0 to x<32768 (pi radians)
x = 0
rept \1
- dw HIGH(sin(x) + LOW(sin(x))) ; round up
+ dw (sin(x) + LOW(sin(x))) >> 8 ; round up
x = x + DIV(32768, \1) ; a circle has 65536 "degrees"
endr
ENDM
diff --git a/ram/wram.asm b/ram/wram.asm
index 4405a16..da6d364 100644
--- a/ram/wram.asm
+++ b/ram/wram.asm
@@ -154,10 +154,11 @@ wOverworldMapBlocksEnd::
NEXTU
-wLYOverrides::
- ds SCREEN_HEIGHT_PX
- ds $10
-wLYOverrides2::
+wLYOverrides:: ds SCREEN_HEIGHT_PX
+wLYOverridesEnd:: db
+ ds 15
+wLYOverrides2:: ds SCREEN_HEIGHT_PX
+wLYOverrides2End::
NEXTU
; Battle-related
@@ -329,13 +330,13 @@ wNamedObjectTypeBuffer:: db
SECTION "CB5E", WRAM0[$CB5E]
wJumptableIndex:: db
-UNION
-wcb5f:: db
-NEXTU
-wFlyDestination:: db
-ENDU
+wFlyDestination::
+wBattleTransitionCounter:: db
+wBattleTransitionSineWaveOffset::
+wBattleTransitionSpinQuadrant::
wcb60:: ds 1
+
wcb61:: ds 1
wVBCopySize:: ds 1