summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/copyright_screen.asm2
-rw-r--r--engine/erase_all_data_menu.asm2
-rw-r--r--engine/field_select_screen.asm2
-rw-r--r--engine/high_scores_screen.asm2
-rw-r--r--engine/options_screen.asm2
-rw-r--r--engine/pinball_game.asm2
-rw-r--r--engine/pinball_game/billboard_tiledata.asm4
-rw-r--r--engine/pinball_game/catchem_mode.asm24
-rw-r--r--engine/pinball_game/draw_sprites/draw_red_field_sprites.asm2
-rwxr-xr-xengine/pinball_game/evolution_mode.asm8
-rwxr-xr-xengine/pinball_game/map_move.asm12
-rw-r--r--engine/pinball_game/object_collision/blue_stage_resolve_collision.asm58
-rw-r--r--engine/pinball_game/object_collision/diglett_bonus_resolve_collision.asm4
-rw-r--r--engine/pinball_game/object_collision/gengar_bonus_resolve_collision.asm4
-rw-r--r--engine/pinball_game/object_collision/meowth_bonus_resolve_collision.asm4
-rw-r--r--engine/pinball_game/object_collision/mewtwo_bonus_resolve_collision.asm2
-rw-r--r--engine/pinball_game/object_collision/red_stage_resolve_collision.asm42
-rw-r--r--engine/pinball_game/object_collision/seel_bonus_resolve_collision.asm4
-rw-r--r--engine/pinball_game/stage_init/init_blue_field.asm4
-rw-r--r--engine/pokedex.asm2
-rw-r--r--engine/select_gameboy_target_menu.asm8
-rw-r--r--engine/titlescreen.asm2
-rw-r--r--home.asm512
-rw-r--r--home/copy.asm26
-rwxr-xr-xhome/palettes.asm466
-rw-r--r--wram.asm4
26 files changed, 608 insertions, 596 deletions
diff --git a/engine/copyright_screen.asm b/engine/copyright_screen.asm
index c749043..f3d6a44 100644
--- a/engine/copyright_screen.asm
+++ b/engine/copyright_screen.asm
@@ -20,7 +20,7 @@ FadeInCopyrightScreen: ; 0x8228
ld hl, CopyrightTextGfxPointers
call LoadVideoData
call ClearOAMBuffer
- call Func_b66
+ call SetAllPalettesWhite
call EnableLCD
call SGBNormal
ld bc, $0050
diff --git a/engine/erase_all_data_menu.asm b/engine/erase_all_data_menu.asm
index 6ef174f..e81a768 100644
--- a/engine/erase_all_data_menu.asm
+++ b/engine/erase_all_data_menu.asm
@@ -28,7 +28,7 @@ CheckForResetButtonCombo: ; 0x8167
ld hl, EraseAllDataGfxPointers
call LoadVideoData
call ClearOAMBuffer
- call Func_b66
+ call SetAllPalettesWhite
call EnableLCD
call SGBNormal
call FadeIn
diff --git a/engine/field_select_screen.asm b/engine/field_select_screen.asm
index 26dfc47..f785989 100644
--- a/engine/field_select_screen.asm
+++ b/engine/field_select_screen.asm
@@ -23,7 +23,7 @@ LoadFieldSelectScreen: ; 0xd6dd
call ClearOAMBuffer
ld a, $8
ld [wFieldSelectBlinkingBorderFrame], a
- call Func_b66
+ call SetAllPalettesWhite
ld a, $12
call SetSongBank
ld de, $0003
diff --git a/engine/high_scores_screen.asm b/engine/high_scores_screen.asm
index 09b16d6..1aa3bb2 100644
--- a/engine/high_scores_screen.asm
+++ b/engine/high_scores_screen.asm
@@ -145,7 +145,7 @@ Func_cb14: ; 0xcb14
ld hl, hLCDC
set 3, [hl]
.asm_cb7f
- call Func_b66
+ call SetAllPalettesWhite
ld a, [wda7f]
and a
jr z, .asm_cbbd
diff --git a/engine/options_screen.asm b/engine/options_screen.asm
index 64f0f43..a5e4958 100644
--- a/engine/options_screen.asm
+++ b/engine/options_screen.asm
@@ -31,7 +31,7 @@ Func_c35a: ; 0xc35a
ld [wd91f], a
call Func_c43a
call Func_c948
- call Func_b66
+ call SetAllPalettesWhite
ld a, $12
call SetSongBank
ld de, $0002
diff --git a/engine/pinball_game.asm b/engine/pinball_game.asm
index d4148ff..81fdde7 100644
--- a/engine/pinball_game.asm
+++ b/engine/pinball_game.asm
@@ -59,7 +59,7 @@ GameScreenFunction_StartBall: ; 0xd87f
ld [wDrawBottomMessageBox], a
xor a
ld [wd7c1], a
- call Func_b66
+ call SetAllPalettesWhite
call EnableLCD
call FadeIn
ld hl, wScreenState
diff --git a/engine/pinball_game/billboard_tiledata.asm b/engine/pinball_game/billboard_tiledata.asm
index 8af3568..5cc0960 100644
--- a/engine/pinball_game/billboard_tiledata.asm
+++ b/engine/pinball_game/billboard_tiledata.asm
@@ -14,7 +14,7 @@ LoadBillboardTileData: ; 0x30256
ld h, [hl]
ld l, a
ld a, Bank(BillboardTileDataPointers)
- call Func_10aa
+ call QueueGraphicsToLoad
pop bc
ld a, [hGameBoyColorFlag]
and a
@@ -25,7 +25,7 @@ LoadBillboardTileData: ; 0x30256
ld h, [hl]
ld l, a
ld a, Bank(BillboardPaletteDataPointers)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
BillboardTileDataPointers: ; 0x3027a
diff --git a/engine/pinball_game/catchem_mode.asm b/engine/pinball_game/catchem_mode.asm
index 559bf31..f556c2d 100644
--- a/engine/pinball_game/catchem_mode.asm
+++ b/engine/pinball_game/catchem_mode.asm
@@ -291,7 +291,7 @@ Func_101d9: ; 0x101d9
push de
xor a
ld de, Func_11d2
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
pop de
pop hl
pop bc
@@ -342,7 +342,7 @@ Func_10230: ; 0x10230
push de
xor a
ld de, LoadTileListsBank1
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
pop de
pop hl
pop bc
@@ -420,7 +420,7 @@ Func_102bc: ; 0x102bc
xor a
ld bc, wc1b8
ld de, LoadPalettes
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
Func_10301: ; 0x10301
@@ -487,7 +487,7 @@ Func_10301: ; 0x10301
xor a
ld bc, wc1b8
ld de, LoadPalettes
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
Func_10362: ; 0x10362
@@ -560,7 +560,7 @@ Func_1038e: ; 0x1038e
push de
xor a
ld de, Func_11d2
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
pop de
pop bc
ret
@@ -585,7 +585,7 @@ Func_10414: ; 0x10414
ld a, BANK(Data_10420)
ld bc, Data_10420
ld de, Func_11b5
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
Data_10420:
@@ -608,7 +608,7 @@ Func_10432: ; 0x10432
ld a, BANK(Data_1043e)
ld bc, Data_1043e
ld de, LoadTileLists
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
Data_1043e:
@@ -852,7 +852,7 @@ Func_10611: ; 0x10611
ld b, a
ld a, BANK(Data_1062a)
ld de, Func_11d2
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
Data_1062a:
@@ -1266,12 +1266,12 @@ Func_108f5: ; 0x108f5
call LoadVRAMData
ld hl, BlankSaverSpaceTileDataRedField
ld a, BANK(BlankSaverSpaceTileDataRedField)
- call Func_10aa
+ call QueueGraphicsToLoad
ld a, [wPreviousNumPokeballs]
callba LoadPokeballsGraphics_RedField
ld hl, CaughtPokeballTileDataPointers
ld a, BANK(CaughtPokeballTileDataPointers)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
BlankSaverSpaceTileDataRedField:
@@ -1396,12 +1396,12 @@ Func_109fc: ; 0x109fc
call LoadVRAMData
ld hl, BlankSaverSpaceTileDataBlueField
ld a, BANK(BlankSaverSpaceTileDataBlueField)
- call Func_10aa
+ call QueueGraphicsToLoad
ld a, [wPreviousNumPokeballs]
callba LoadPokeballsGraphics_RedField
ld hl, Data_10a88
ld a, BANK(Data_10a88)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
BlankSaverSpaceTileDataBlueField:
diff --git a/engine/pinball_game/draw_sprites/draw_red_field_sprites.asm b/engine/pinball_game/draw_sprites/draw_red_field_sprites.asm
index ee25c7c..cc57f8d 100644
--- a/engine/pinball_game/draw_sprites/draw_red_field_sprites.asm
+++ b/engine/pinball_game/draw_sprites/draw_red_field_sprites.asm
@@ -149,7 +149,7 @@ Func_17665: ; 0x17665
ld h, [hl]
ld l, a
ld a, Bank(TimerDigitsTileData)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
INCLUDE "data/timer_digits_tiledata.asm"
diff --git a/engine/pinball_game/evolution_mode.asm b/engine/pinball_game/evolution_mode.asm
index 19cf595..a6c594b 100755
--- a/engine/pinball_game/evolution_mode.asm
+++ b/engine/pinball_game/evolution_mode.asm
@@ -719,12 +719,12 @@ ConcludeEvolutionMode_RedField: ; 0x10fe3
.asm_11036
ld hl, BlankSaverSpaceTileDataRedField
ld a, BANK(BlankSaverSpaceTileDataRedField)
- call Func_10aa
+ call QueueGraphicsToLoad
ld a, [wPreviousNumPokeballs]
callba LoadPokeballsGraphics_RedField
ld hl, CaughtPokeballTileDataPointers
ld a, BANK(CaughtPokeballTileDataPointers)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
StartEvolutionMode_UnusedField: ; 0x11054
@@ -856,12 +856,12 @@ ConcludeEvolutionMode_BlueField: ; 0x11195
.asm_111f0
ld hl, BlankSaverSpaceTileDataBlueField
ld a, BANK(BlankSaverSpaceTileDataBlueField)
- call Func_10aa
+ call QueueGraphicsToLoad
ld a, [wPreviousNumPokeballs]
callba LoadPokeballsGraphics_RedField
ld hl, Data_10a88
ld a, BANK(Data_10a88)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
LoadBlueFieldTopGraphics: ; 0x1120e
diff --git a/engine/pinball_game/map_move.asm b/engine/pinball_game/map_move.asm
index a639108..ebd26e1 100755
--- a/engine/pinball_game/map_move.asm
+++ b/engine/pinball_game/map_move.asm
@@ -596,7 +596,7 @@ Func_3161b: ; 0x3161b
ret
.asm_31643
- call Func_3168c
+ call UpdateMapMove_BlueField
ld a, [wd54d]
call CallInFollowingTable
PointerTable_3164c: ; 0x3164c
@@ -631,14 +631,14 @@ Func_31672: ; 0x31672
scf
ret
-Func_3168c: ; 0x3168c
+UpdateMapMove_BlueField: ; 0x3168c
ld a, $50
- ld [wLeftMapMoveDiglettAnimationCounter], a
- ld [wRightMapMoveDiglettFrame], a
+ ld [wLeftMapMovePoliwagAnimationCounter], a
+ ld [wRightMapMovePsyduckFrame], a
ld a, $3
- ld [wd645], a
+ ld [wPsyduckState], a
ld a, $1
- ld [wd646], a
+ ld [wPoliwagState], a
callba PlayLowTimeSfx
ld a, [wd57e]
and a
diff --git a/engine/pinball_game/object_collision/blue_stage_resolve_collision.asm b/engine/pinball_game/object_collision/blue_stage_resolve_collision.asm
index 835cf57..fd5992c 100644
--- a/engine/pinball_game/object_collision/blue_stage_resolve_collision.asm
+++ b/engine/pinball_game/object_collision/blue_stage_resolve_collision.asm
@@ -521,7 +521,7 @@ UpdateSpinnerChargeGraphics_BlueField: ; 0x1cb43
ld h, [hl]
ld l, a
ld a, Bank(TileDataPointers_1cb60)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
INCLUDE "data/queued_tiledata/blue_field/spinner.asm"
@@ -577,7 +577,7 @@ LoadBumperGraphics_BlueField: ; 0x1ce7a
ld h, [hl]
ld l, a
ld a, Bank(TileDataPointers_1ceca)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
ApplyBumperCollision_BlueField: ; 0x1ce94
@@ -1395,7 +1395,7 @@ LoadBonusMultiplierRailingGraphics_BlueField_Gameboy: ; 0x1d602
ld h, [hl]
ld l, a
ld a, Bank(BonusMultiplierRailingTileDataPointers_1d6be)
- call Func_10aa
+ call QueueGraphicsToLoad
.asm_1d626
pop af
ld bc, $0000
@@ -1414,7 +1414,7 @@ LoadBonusMultiplierRailingGraphics_BlueField_Gameboy: ; 0x1d602
ld h, [hl]
ld l, a
ld a, Bank(BonusMultiplierRailingTileDataPointers_1d946)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
LoadBonusMultiplierRailingGraphics_BlueField_GameboyColor: ; 0x1d645
@@ -1432,7 +1432,7 @@ LoadBonusMultiplierRailingGraphics_BlueField_GameboyColor: ; 0x1d645
ld h, [hl]
ld l, a
ld a, Bank(BonusMultiplierRailingTileDataPointers_1d97a)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
GetBCDForNextBonusMultiplier_BlueField: ; 0x1d65f
@@ -1541,7 +1541,7 @@ ResolvePsyduckPoliwagCollision: ; 0x1dbd2
ld a, $7
callba Func_10000
ld a, $2
- ld [wd646], a
+ ld [wPoliwagState], a
ld a, $78
ld [wLeftMapMovePoliwagAnimationCounter], a
ld a, $14
@@ -1582,7 +1582,7 @@ ResolvePsyduckPoliwagCollision: ; 0x1dbd2
ccf
call z, HitPsyduck3Times
ld a, $2
- ld [wd645], a
+ ld [wPsyduckState], a
ld a, $28
ld [wRightMapMovePsyduckAnimationCounter], a
ld a, $78
@@ -1597,7 +1597,7 @@ UpdatePsyduckAndPoliwag: ; 0x1dc8e
ret
UpdatePoliwag: ; 0x1dc95
- ld a, [wd646]
+ ld a, [wPoliwagState]
cp $0
ret z
ld a, [wLeftMapMovePoliwagAnimationCounter]
@@ -1618,7 +1618,7 @@ UpdatePoliwag: ; 0x1dc95
ret
.asm_1dcb9
- ld a, [wd646]
+ ld a, [wPoliwagState]
cp $2
ret nz
call Func_1130
@@ -1646,11 +1646,11 @@ UpdatePoliwag: ; 0x1dc95
ccf
call z, HitPoliwag3Times
ld a, $1
- ld [wd646], a
+ ld [wPoliwagState], a
ret
.asm_1dceb
- ld a, [wd646]
+ ld a, [wPoliwagState]
cp $1
ret nz
ld a, [wLeftMapMovePoliwagAnimationCounter]
@@ -1667,7 +1667,7 @@ UpdatePoliwag: ; 0x1dc95
ld [wStageCollisionMap + $103], a
.asm_1dd0c
ld a, $0
- ld [wd646], a
+ ld [wPoliwagState], a
ld a, [wLeftMapMoveCounter]
sub $3
ret nz
@@ -1678,14 +1678,14 @@ UpdatePoliwag: ; 0x1dc95
ld a, $0
call LoadPsyduckOrPoliwagGraphics
ld a, $0
- ld [wd646], a
+ ld [wPoliwagState], a
ret
; XXX
ret
UpdatePsyduck: ; 0x1dd2e
- ld a, [wd645]
+ ld a, [wPsyduckState]
cp $0
ret z
cp $1
@@ -1703,7 +1703,7 @@ UpdatePsyduck: ; 0x1dd2e
ld a, $2
call LoadPsyduckOrPoliwagGraphics
ld a, $1
- ld [wd645], a
+ ld [wPsyduckState], a
ret
.asm_1dd53
@@ -1714,7 +1714,7 @@ UpdatePsyduck: ; 0x1dd2e
add $3
call LoadPsyduckOrPoliwagGraphics
ld a, $3
- ld [wd645], a
+ ld [wPsyduckState], a
ret
.asm_1dd69
@@ -1754,7 +1754,7 @@ UpdatePsyduck: ; 0x1dd2e
ld a, $25
ld [wStageCollisionMap + $110], a
ld a, $0
- ld [wd645], a
+ ld [wPsyduckState], a
.asm_1dda9
ld a, [wRightMapMoveCounter]
sub $3
@@ -1767,7 +1767,7 @@ UpdatePsyduck: ; 0x1dd2e
ld a, $2
call LoadPsyduckOrPoliwagGraphics
ld a, $0
- ld [wd645], a
+ ld [wPsyduckState], a
ret
HitPoliwag3Times: ; 0x1ddc7
@@ -1840,7 +1840,7 @@ LoadPsyduckOrPoliwagGraphics: ; 0x1de4b
or h
ret z
ld a, Bank(TileDataPointers_1df66)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
LoadPsyduckOrPoliwagNumberGraphics: ; 0x1de6f
@@ -1866,7 +1866,7 @@ LoadPsyduckOrPoliwagNumberGraphics: ; 0x1de6f
or h
ret z
ld a, Bank(TileDataPointers_1e0a4)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
UpdateMapMoveCounters_BlueFieldBottom: ; 0x1de93
@@ -2175,9 +2175,9 @@ LoadPinballUpgradeTriggerGraphics_BlueField: ; 0x1e484
ld c, [hl]
inc hl
ld b, [hl]
- ld a, $7
+ ld a, Bank(TileDataPointers_1e520)
ld de, LoadTileLists
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
pop bc
ret
@@ -2402,9 +2402,9 @@ LoadCAVELightGraphics_BlueField: ; 0x1e636
ld c, [hl]
inc hl
ld b, [hl]
- ld a, $7
+ ld a, Bank(TileDataPointers_1e6d7)
ld de, LoadTileLists
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
pop bc
ret
@@ -2708,7 +2708,7 @@ LoadSlotCaveCoverGraphics_BlueField: ; 0x1e8f6
or h
ret z
ld a, Bank(TileDataPointers_1e91e)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
INCLUDE "data/queued_tiledata/blue_field/slot_cave.asm"
@@ -2986,7 +2986,7 @@ LoadArrowIndicatorGraphics_BlueStage: ; 0x1eb41
ld h, [hl]
ld l, a
ld a, Bank(TileDataPointers_1eb61)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
INCLUDE "data/queued_tiledata/blue_field/arrow_indicators.asm"
@@ -3454,7 +3454,7 @@ UpdateForceFieldGraphics: ; 0x1f18a
or h
ret z
ld a, Bank(TileDataPointers_1f1b5)
- call Func_10aa
+ call QueueGraphicsToLoad
ld a, $0
ld [wBlueStageForceFieldGfxNeedsLoading], a
.done
@@ -3479,9 +3479,9 @@ LoadPokeballsGraphics_BlueField: ; 0x1f265
ld c, a
ld a, [hli]
ld b, a
- ld a, $7
+ ld a, Bank(TileDataPointers_1f2b9)
ld de, LoadTileLists
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
UpdateBlinkingPokeballs_BlueField: ; 0x1f27b
diff --git a/engine/pinball_game/object_collision/diglett_bonus_resolve_collision.asm b/engine/pinball_game/object_collision/diglett_bonus_resolve_collision.asm
index 4bfbba4..738010d 100644
--- a/engine/pinball_game/object_collision/diglett_bonus_resolve_collision.asm
+++ b/engine/pinball_game/object_collision/diglett_bonus_resolve_collision.asm
@@ -41,7 +41,7 @@ Func_19bbd: ; 0x19bbd
ld h, [hl]
ld l, a
ld a, Bank(Data_19bda)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
Data_19bda:
@@ -355,7 +355,7 @@ Func_19da8: ; 0x19da8
ld h, [hl]
ld l, a
ld a, Bank(DiglettTileDataPointers)
- call Func_10aa
+ call QueueGraphicsToLoad
pop bc
ret
diff --git a/engine/pinball_game/object_collision/gengar_bonus_resolve_collision.asm b/engine/pinball_game/object_collision/gengar_bonus_resolve_collision.asm
index b89c105..a343bf4 100644
--- a/engine/pinball_game/object_collision/gengar_bonus_resolve_collision.asm
+++ b/engine/pinball_game/object_collision/gengar_bonus_resolve_collision.asm
@@ -52,7 +52,7 @@ Func_183db: ; 0x183db
ld h, [hl]
ld l, a
ld a, BANK(TileDataPointers_183f8)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
TileDataPointers_183f8:
@@ -1462,7 +1462,7 @@ Func_18d72: ; 0x18d72
or h
ret z
ld a, Bank(TileDataPointers_18ddb)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
Func_18d91: ; 0x18d91
diff --git a/engine/pinball_game/object_collision/meowth_bonus_resolve_collision.asm b/engine/pinball_game/object_collision/meowth_bonus_resolve_collision.asm
index 730eeaf..8f0766d 100644
--- a/engine/pinball_game/object_collision/meowth_bonus_resolve_collision.asm
+++ b/engine/pinball_game/object_collision/meowth_bonus_resolve_collision.asm
@@ -274,7 +274,7 @@ Func_24516: ; 0x24516
ld h, [hl]
ld l, a
ld a, Bank(TileDataPointers_24533)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
TileDataPointers_24533: ; 0x24533
@@ -1894,7 +1894,7 @@ Func_24fa3: ; 0x24fa3
ld h, [hl]
ld l, a
ld a, Bank(TileDataPointers_25007)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
TileDataPointers_25007:
diff --git a/engine/pinball_game/object_collision/mewtwo_bonus_resolve_collision.asm b/engine/pinball_game/object_collision/mewtwo_bonus_resolve_collision.asm
index 2b6229e..0a2192b 100644
--- a/engine/pinball_game/object_collision/mewtwo_bonus_resolve_collision.asm
+++ b/engine/pinball_game/object_collision/mewtwo_bonus_resolve_collision.asm
@@ -49,7 +49,7 @@ Func_194ac: ; 0x194ac
ld h, [hl]
ld l, a
ld a, Bank(Data_194c9)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
Data_194c9:
diff --git a/engine/pinball_game/object_collision/red_stage_resolve_collision.asm b/engine/pinball_game/object_collision/red_stage_resolve_collision.asm
index 3f9a248..6679037 100644
--- a/engine/pinball_game/object_collision/red_stage_resolve_collision.asm
+++ b/engine/pinball_game/object_collision/red_stage_resolve_collision.asm
@@ -160,7 +160,7 @@ LoadAgainTextGraphics: ; 0x14746
ld h, [hl]
ld l, a
ld a, BANK(AgainTextTileData)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
AgainTextTileData:
@@ -528,7 +528,7 @@ LoadDiglettGraphics: ; 0x149d9
or h
ret z
ld a, BANK(TileListDataPointers_14a11)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
LoadDiglettNumberGraphics: ; 0x149f5
@@ -548,7 +548,7 @@ LoadDiglettNumberGraphics: ; 0x149f5
or h
ret z
ld a, BANK(Data_14af5)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
INCLUDE "data/queued_tiledata/red_field/diglett.asm"
@@ -736,7 +736,7 @@ UpdateSpinnerChargeGraphics_RedField: ; 0x14ece
ld h, [hl]
ld l, a
ld a, BANK(TileDataPointers_14eeb)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
INCLUDE "data/queued_tiledata/red_field/spinner.asm"
@@ -834,9 +834,9 @@ LoadCAVELightGraphics_RedField: ; 0x1523c
ld c, [hl]
inc hl
ld b, [hl]
- ld a, $5
+ ld a, Bank(TileDataPointers_152dd)
ld de, LoadTileLists
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
pop bc
ret
@@ -1070,9 +1070,9 @@ LoadPinballUpgradeTriggerGraphics_RedField: ; 0x15465
ld c, [hl]
inc hl
ld b, [hl]
- ld a, $5
+ ld a, Bank(TileDataPointers_15511)
ld de, LoadTileLists
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
pop bc
ret
@@ -1224,7 +1224,7 @@ TransitionPinballUpgrade: ; 0x155a7
ld h, [hl]
ld l, a
ld a, Bank(PinballUpgradeTransition_TileDataPointers)
- call Func_10aa
+ call QueueGraphicsToLoad
; fall through
TransitionPinballUpgradePalette: ; 0x155bb
@@ -1243,7 +1243,7 @@ TransitionPinballUpgradePalette: ; 0x155bb
ld b, [hl]
ld a, BANK(PinballUpgradeTransitionPalettes)
ld de, LoadPalettes
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
INCLUDE "data/queued_tiledata/ball_upgrade.asm"
@@ -1512,7 +1512,7 @@ LoadFieldStructureGraphics_RedField: ; 0x159f4
or h
ret z
ld a, Bank(TileDataPointers_15a3f)
- call Func_10aa
+ call QueueGraphicsToLoad
ld a, [wStageCollisionState]
ld [wd7f2], a
ret
@@ -1678,7 +1678,7 @@ LoadBumperGraphics_RedField: ; 0x15fc0
ld h, [hl]
ld l, a
ld a, Bank(TileDataPointers_16010)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
ApplyBumperCollision_RedField: ; 0x15fda
@@ -2160,7 +2160,7 @@ LoadSlotCaveCoverGraphics_RedField: ; 0x16425
or h
ret z
ld a, Bank(TileDataPointers_1644d)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
INCLUDE "data/queued_tiledata/red_field/slot_cave.asm"
@@ -2602,7 +2602,7 @@ LoadStaryuGraphics_Top: ; 0x16859
or h
ret z
ld a, Bank(TileDataPointers_16899)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
LoadStaryuGraphics_Bottom: ; 0x16878
@@ -2624,7 +2624,7 @@ LoadStaryuGraphics_Bottom: ; 0x16878
or h
ret z
ld a, Bank(TileDataPointers_1695a)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
INCLUDE "data/queued_tiledata/red_field/staryu_bumper.asm"
@@ -2678,7 +2678,7 @@ LoadArrowIndicatorGraphics_RedField: ; 0x169cd
ld h, [hl]
ld l, a
ld a, Bank(TileDataPointers_169ed)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
INCLUDE "data/queued_tiledata/red_field/arrow_indicators.asm"
@@ -2900,7 +2900,7 @@ LoadBonusMultiplierRailingGraphics_RedField_Gameboy: ; 0x16f38
ld h, [hl]
ld l, a
ld a, Bank(BonusMultiplierRailingTileDataPointers_16fc8)
- call Func_10aa
+ call QueueGraphicsToLoad
.asm_16f5c
pop af
ld bc, $0000
@@ -2919,7 +2919,7 @@ LoadBonusMultiplierRailingGraphics_RedField_Gameboy: ; 0x16f38
ld h, [hl]
ld l, a
ld a, Bank(BonusMultiplierRailingTileData_171e4)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
LoadBonusMultiplierRailingGraphics_RedField_GameboyColor: ; 0x16f7b
@@ -2937,7 +2937,7 @@ LoadBonusMultiplierRailingGraphics_RedField_GameboyColor: ; 0x16f7b
ld h, [hl]
ld l, a
ld a, Bank(BonusMultiplierRailingTileDataPointers_17228)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
GetBCDForNextBonusMultiplier_RedField: ; 0x16f95
@@ -3002,9 +3002,9 @@ LoadPokeballsGraphics_RedField: ; 0x174d4
ld c, a
ld a, [hli]
ld b, a
- ld a, $5
+ ld a, Bank(TileDataPointers_17528)
ld de, LoadTileLists
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
UpdateBlinkingPokeballs_RedField: ; 0x174ea
diff --git a/engine/pinball_game/object_collision/seel_bonus_resolve_collision.asm b/engine/pinball_game/object_collision/seel_bonus_resolve_collision.asm
index e169524..83d48db 100644
--- a/engine/pinball_game/object_collision/seel_bonus_resolve_collision.asm
+++ b/engine/pinball_game/object_collision/seel_bonus_resolve_collision.asm
@@ -87,7 +87,7 @@ Func_25d0e: ; 0x25d0e
ld h, [hl]
ld l, a
ld a, Bank(TileDataPointers_25d2b)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
TileDataPointers_25d2b:
@@ -1161,7 +1161,7 @@ Func_262f4: ; 0x262f4
ld h, [hl]
ld l, a
ld a, Bank(TileDataPointers_2634a)
- call Func_10aa
+ call QueueGraphicsToLoad
ret
TileDataPointers_2634a:
diff --git a/engine/pinball_game/stage_init/init_blue_field.asm b/engine/pinball_game/stage_init/init_blue_field.asm
index 03a93d6..0200f2d 100644
--- a/engine/pinball_game/stage_init/init_blue_field.asm
+++ b/engine/pinball_game/stage_init/init_blue_field.asm
@@ -44,8 +44,8 @@ InitBlueField: ; 0x1c000
ld [wd64a], a
ld [wd643], a
ld [wd644], a
- ld [wd645], a
- ld [wd646], a
+ ld [wPsyduckState], a
+ ld [wPoliwagState], a
callba Start20SecondSaverTimer
callba GetBCDForNextBonusMultiplier_BlueField
ld a, $10
diff --git a/engine/pokedex.asm b/engine/pokedex.asm
index e903bb8..be3c15f 100644
--- a/engine/pokedex.asm
+++ b/engine/pokedex.asm
@@ -59,7 +59,7 @@ LoadPokedexScreen: ; 0x2800e
call Func_28ad1
call Func_28add
call CountNumSeenOwnedMons
- call Func_b66
+ call SetAllPalettesWhite
ld a, $f
call SetSongBank
ld de, $0004
diff --git a/engine/select_gameboy_target_menu.asm b/engine/select_gameboy_target_menu.asm
index 339bc55..17fecaa 100644
--- a/engine/select_gameboy_target_menu.asm
+++ b/engine/select_gameboy_target_menu.asm
@@ -39,7 +39,7 @@ InitSelectGameboyTargetMenu: ; 0x800a
ld [hSCY], a
call LoadGameboyTargetMenuGfx
call ClearOAMBuffer
- call Func_b66
+ call SetAllPalettesWhite
call EnableLCD
call FadeIn
ld hl, wScreenState
@@ -73,7 +73,7 @@ LoadGameboyTargetMenuGfx: ; 0x8049
ld a, Bank(SelectGameboyTarget_TileData)
ld bc, SelectGameboyTarget_TileData
ld de, LoadTileLists
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
SelectGameboyTargetGfxPointers: ; 0x8089
@@ -202,14 +202,14 @@ SelectCGBOrDMG: ; 0x8104
ld a, Bank(DMGSelected_TileData)
ld bc, DMGSelected_TileData
ld de, LoadTileLists
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
.cgb
ld a, Bank(CGBSelected_TileData)
ld bc, CGBSelected_TileData
ld de, LoadTileLists
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
ret
DMGSelected_TileData: ; 0x813a
diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm
index 641b0cd..01a1aac 100644
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -29,7 +29,7 @@ FadeInTitlescreen: ; 0xc00e
ld a, $2
ld [wTitleScreenPokeballAnimationCounter], a
call HandleTitlescreenAnimations
- call Func_b66
+ call SetAllPalettesWhite
ld a, $11
call SetSongBank
ld de, $0004
diff --git a/home.asm b/home.asm
index 817de2d..1f1e6fa 100644
--- a/home.asm
+++ b/home.asm
@@ -720,32 +720,6 @@ WaitForLCD: ; 0x60f
jr nz, .delay40Cycles
ret
-Func_61b: ; 0x61b
- ld a, [rLY] ; LY register (LCDC Y-Coordinate)
- cp $40
- jr c, .asm_625
- cp $80
- jr c, .asm_63d
-.asm_625
- ld a, [rLY] ; LY register (LCDC Y-Coordinate)
- cp $40
- jr c, .asm_625
- cp $80
- jr nc, .asm_625
-.asm_62f
- ld a, [rSTAT]
- and $3
- jr nz, .asm_62f ; wait for lcd controller to finish transferring data
- ld a, $15
-.wait
- dec a
- jr nz, .wait
- nop
- nop
- nop
-.asm_63d
- ret
-
INCLUDE "home/copy.asm"
ClearOAMBuffer: ; 0x916
@@ -809,472 +783,7 @@ SGBWait1750: ; 0x948
INCLUDE "home/random.asm"
INCLUDE "home/joypad.asm"
-
-Func_b66: ; 0xb66
- ld a, [hGameBoyColorFlag]
- and a
- jr nz, .asm_b73
- xor a
- ld [hBGP], a
- ld [hOBP0], a
- ld [hOBP1], a
- ret
-
-.asm_b73
- ld de, rBGPI
- ld hl, wPaletteData
- ld b, $0
- ld c, $20
-.asm_b7d
- ld a, b
- ld [rBGPI], a
- inc b
- ld a, [rBGPD]
- ld [hli], a
- ld a, b
- ld [rBGPI], a
- inc b
- ld a, [rBGPD]
- ld [hli], a
- dec c
- jr nz, .asm_b7d
- ld b, $0
- ld c, $20
-.asm_b92
- ld a, b
- ld [rOBPI], a
- inc b
- ld a, [rOBPD]
- ld [hli], a
- ld a, b
- ld [rOBPI], a
- inc b
- ld a, [rOBPD]
- ld [hli], a
- dec c
- jr nz, .asm_b92
- ld de, rBGPI
- ld b, $2
-.asm_ba8
- ld a, $80
- ld [de], a
- inc de
- ld c, $20
-.asm_bae
- ld a, $ff
- ld [de], a
- ld [hli], a
- ld a, $7f
- ld [de], a
- ld [hli], a
- dec c
- jr nz, .asm_bae
- inc de
- dec b
- jr nz, .asm_ba8
- ret
-
-FadeIn: ; 0xbbe
-; Fades palettes in from white screen.
- ld a, [hGameBoyColorFlag]
- and a
- jp nz, FadeIn_GameboyColor
- ; Regular Gameboy
- ld hl, hBGP
- ld de, wBGP
- ld b, $3
-.loop
- ld a, [de]
- and $55
- ld c, a
- ld a, [de]
- and $aa
- srl a
- and c
- ld [hli], a
- inc de
- dec b
- jr nz, .loop
- ld bc, $0002
- call AdvanceFrames
- ld hl, hBGP
- ld de, wBGP
- ld b, $3
-.loop2
- ld a, [de]
- and $aa
- srl a
- add [hl]
- ld [hli], a
- inc de
- dec b
- jr nz, .loop2
- ld bc, $0002
- call AdvanceFrames
- ld hl, hBGP
- ld de, wBGP
- ld b, $3
-.loop3
- ld a, [de]
- and $55
- ld c, a
- ld a, [de]
- and $aa
- srl a
- or c
- add [hl]
- ld [hli], a
- inc de
- dec b
- jr nz, .loop3
- ld bc, $0002
- call AdvanceFrames
- ret
-
-FadeIn_GameboyColor: ; 0xc19
-; Fades in to the target palette data in wPaletteData from wFadeBGPaletteData and wFadeOBJPaletteData
-; Fade is completed after 16 frames of incrementally updating the palettes.
- ld b, 16 ; fade takes 16 frames to complete
-.loop
- push bc
- ld de, wPaletteData
- ld hl, wFadeBGPaletteData
- call FadeInStep
- call SetFadedPalettes
- pop bc
- dec b
- jr nz, .loop
- ret
-
-FadeInStep: ; 0xc2d
-; de = base palette data
-; hl = faded palette data
- ld a, b
- cp $1
- jr z, .lastStep
- ld c, $40 ; total number of colors in BG and OBJ palettes
-.loop
- push bc
- ld a, [hli]
- sub $42
- ld c, a
- ld a, [hld]
- sbc $8
- ld b, a ; subtracted 2 from each RGB value of the color
- call GetNextFadedPalette
- ld a, c
- ld [hli], a
- ld a, b
- ld [hli], a
- pop bc
- dec c
- jr nz, .loop
- ret
-
-.lastStep
- ld c, $40 ; total number of colors in BG and OBJ palettes
-.loop2
- push bc
- ld a, [hli]
- sub $21
- ld c, a
- ld a, [hld]
- sbc $4
- ld b, a
- call GetNextFadedPalette
- ld a, c
- ld [hli], a
- ld a, b
- ld [hli], a
- pop bc
- dec c
- jr nz, .loop2
- ret
-
-GetNextFadedPalette: ; 0xc60
-; de = source palette data
-; bc = target palette RGB - 2
-; Places the resulting palette RGB into bc
- push hl
- ld a, [de]
- and %00011111 ; Target RGB Blue value
- ld l, a
- ld a, c
- and %00011111 ; Current faded RBG Blue value - 2
- cp l
- jr nc, .brighter
- ; set the current faded Blue value to the target blue value.
- ld a, c
- and %11100000
- or l
- ld c, a
-.brighter
- ld a, [de]
- and %11100000
- ld l, a
- inc de
- ld a, [de]
- srl a
- rr l
- srl a
- rr l
- ld a, c
- and %11100000
- ld h, a
- ld a, b
- srl a
- rr h
- srl a
- rr h
- ld a, h
- cp l
- jr nc, .asm_ca3
- ld h, $0
- sla l
- rl h
- sla l
- rl h
- ld a, c
- and $1f
- or l
- ld c, a
- ld a, b
- and $7c
- or h
- ld b, a
-.asm_ca3
- ld a, [de]
- and $7c
- ld l, a
- ld a, b
- and $7c
- cp l
- jr nc, .asm_cb2
- ld a, b
- and $3
- or l
- ld b, a
-.asm_cb2
- inc de
- pop hl
- ret
-
-FadeOut: ; 0xcb5
-; Fades palettes out to a white screen.
- ld a, [hGameBoyColorFlag]
- and a
- jp nz, FadeOut_GameboyColor
- ; Regular Gameboy
- ld hl, hBGP
- ld b, $3
-.loop
- push bc
- push hl
- ld b, $3
-.loop2
- ld a, [hl]
- and $55
- ld c, a
- ld a, [hl]
- and $aa
- srl a
- or c
- cpl
- inc a
- add [hl]
- ld [hli], a
- dec b
- jr nz, .loop2
- ld bc, $0002
- call AdvanceFrames
- pop hl
- pop bc
- dec b
- jr nz, .loop
- xor a
- ld hl, hBGP
- ld [hli], a
- ld [hli], a
- ld [hl], a
- ld bc, $0002
- call AdvanceFrames
- ret
-
-FadeOut_GameboyColor: ; 0xcee
-; Fades out to white RGB colors from the currently-loaded palettes.
-; Fade is completed after 16 frames of incrementally updating the palettes.
- ld hl, wFadeBGPaletteData
- ld de, rBGPI
- call LoadCurrentPalettesIntoFadePalettes
- ld hl, wFadeOBJPaletteData
- ld de, rOBPI
- call LoadCurrentPalettesIntoFadePalettes
- ld b, 16 ; fade takes 16 frames to complete
-.loop
- push bc
- ld hl, wFadeBGPaletteData
- call FadeOutStep
- call SetFadedPalettes
- pop bc
- dec b
- jr nz, .loop
- ret
-
-FadeOutStep: ; 0xd11
-; hl = faded palette data
- ld b, $40
-.asm_d13
- ld a, [hl]
- and $1f
- add $2
- ld e, a
- cp $1f
- jr c, .asm_d1f
- ld e, $1f
-.asm_d1f
- ld a, [hl]
- and $e0
- or e
- ld [hl], a
- ld a, [hli]
- and $e0
- ld e, [hl]
- dec hl
- srl e
- rr a
- srl e
- rr a
- add $10
- ld e, a
- jr nc, .asm_d38
- ld e, $f8
-.asm_d38
- ld d, $0
- sla e
- rl d
- sla e
- rl d
- ld a, [hl]
- and $1f
- or e
- ld [hli], a
- ld a, [hl]
- and $7c
- or d
- ld [hl], a
- ld a, [hl]
- and $7c
- add $8
- ld e, a
- cp $7c
- jr c, .asm_d58
- ld e, $7c
-.asm_d58
- ld a, [hl]
- and $3
- or e
- ld [hli], a
- dec b
- jr nz, .asm_d13
- ret
-
-SetFadedPalettes: ; 0d61
-; Sets the current palette data to the faded palettes.
- ld a, [rIE]
- res 0, a
- ld [rIE], a
- ld hl, wFadeBGPaletteData
- ld de, rBGPI
- ld a, $80
- ld [de], a
- inc de
-.waitForVBlank
- ld a, [rLY]
- cp $90
- jr c, .waitForVBlank
- ld b, $10
-.loadBGColorsLoop
- ld a, [hli]
- ld [de], a
- ld a, [hli]
- ld [de], a
- ld a, [hli]
- ld [de], a
- ld a, [hli]
- ld [de], a
- dec b
- jr nz, .loadBGColorsLoop
- inc de
- ld a, $80
- ld [de], a
- inc de
- ld b, $10
-.loadOBJColorsLoop
- ld a, [hli]
- ld [de], a
- ld a, [hli]
- ld [de], a
- ld a, [hli]
- ld [de], a
- ld a, [hli]
- ld [de], a
- dec b
- jr nz, .loadOBJColorsLoop
- ld a, [rIE]
- set 0, a
- ld [rIE], a
- ret
-
-LoadCurrentPalettesIntoFadePalettes: ; 0xd9d
-; hl = destination for palette data
-; de = source of palettes (rBGPI or rOBPI)
- ld b, $0
- ld c, e
- inc c
- call WaitForLCD
-.asm_da4
- call Func_61b
-.asm_da7
- ld a, [rSTAT]
- and $3
- jr nz, .asm_da7 ; wait for lcd controller to finish transferring data
- ld a, b
- ld [de], a
- ld a, [$ff00+c]
- ld [hli], a
- inc b
- ld a, b
- ld [de], a
- ld a, [$ff00+c]
- ld [hli], a
- inc b
- ld a, b
- ld [de], a
- ld a, [$ff00+c]
- ld [hli], a
- inc b
- ld a, b
- ld [de], a
- ld a, [$ff00+c]
- ld [hli], a
- inc b
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- ld a, b
- cp $40
- jr nz, .asm_da4
- ret
+INCLUDE "home/palettes.asm"
Func_dd4: ; 0xdd4
; Return a * l to hl
@@ -1664,10 +1173,16 @@ Func_10a4: ; 0x10a4
Func_10a7: ; 0x10a7
jp Func_3ff
-Func_10aa: ; 0x10aa
+QueueGraphicsToLoad: ; 0x10aa
+; Queues graphics data to be loaded into VRAM at the next available time.
+; See the data/queued_tiledata/ directory to view the data that is loaded by this function.
+; Input: hl = pointer to async tile data header
+; byte 1 = number of chunks to load
+; 2*(byte 1) = list of pointers to chunks
+; a = bank of async tile data
ld c, a
ld a, [hli]
- ld b, a ;bc = [hl]a
+ ld b, a
.loop
push bc
ld a, c
@@ -1684,14 +1199,19 @@ Func_10aa: ; 0x10aa
inc bc
pop af
push hl
- call Func_10c5
+ call QueueGraphicsToLoadWithFunc
pop hl
pop bc
dec b
jr nz, .loop
ret
-Func_10c5: ; 0x10c5
+QueueGraphicsToLoadWithFunc: ; 0x10c5
+; Queues graphics data to be loaded into VRAM with the given function at the next available time.
+; See the data/queued_tiledata/ directory to view the data that is loaded by this function.
+; Input: de: function that is responsible for loading the chunk of VRAM data
+; hl: pointer to data
+; a: bank of data
push af
ld a, [rLCDC]
bit 7, a
diff --git a/home/copy.asm b/home/copy.asm
index d8f2a74..79d156b 100644
--- a/home/copy.asm
+++ b/home/copy.asm
@@ -1,3 +1,29 @@
+Func_61b: ; 0x61b
+ ld a, [rLY] ; LY register (LCDC Y-Coordinate)
+ cp $40
+ jr c, .asm_625
+ cp $80
+ jr c, .asm_63d
+.asm_625
+ ld a, [rLY] ; LY register (LCDC Y-Coordinate)
+ cp $40
+ jr c, .asm_625
+ cp $80
+ jr nc, .asm_625
+.asm_62f
+ ld a, [rSTAT]
+ and $3
+ jr nz, .asm_62f ; wait for lcd controller to finish transferring data
+ ld a, $15
+.wait
+ dec a
+ jr nz, .wait
+ nop
+ nop
+ nop
+.asm_63d
+ ret
+
__memset_8: ; 0xc3e
dec bc
.asm_63f
diff --git a/home/palettes.asm b/home/palettes.asm
new file mode 100755
index 0000000..a038527
--- /dev/null
+++ b/home/palettes.asm
@@ -0,0 +1,466 @@
+SetAllPalettesWhite: ; 0xb66
+; Sets all BG and OBJ palettes to white.
+ ld a, [hGameBoyColorFlag]
+ and a
+ jr nz, .gameboyColor
+ xor a
+ ld [hBGP], a
+ ld [hOBP0], a
+ ld [hOBP1], a
+ ret
+
+.gameboyColor
+ ld de, rBGPI
+ ld hl, wPaletteData
+ ld b, $0
+ ld c, $20
+.asm_b7d
+ ld a, b
+ ld [rBGPI], a
+ inc b
+ ld a, [rBGPD]
+ ld [hli], a
+ ld a, b
+ ld [rBGPI], a
+ inc b
+ ld a, [rBGPD]
+ ld [hli], a
+ dec c
+ jr nz, .asm_b7d
+ ld b, $0
+ ld c, $20
+.asm_b92
+ ld a, b
+ ld [rOBPI], a
+ inc b
+ ld a, [rOBPD]
+ ld [hli], a
+ ld a, b
+ ld [rOBPI], a
+ inc b
+ ld a, [rOBPD]
+ ld [hli], a
+ dec c
+ jr nz, .asm_b92
+ ld de, rBGPI
+ ld b, $2
+.asm_ba8
+ ld a, $80
+ ld [de], a
+ inc de
+ ld c, $20
+.asm_bae
+ ld a, $ff
+ ld [de], a
+ ld [hli], a
+ ld a, $7f
+ ld [de], a
+ ld [hli], a
+ dec c
+ jr nz, .asm_bae
+ inc de
+ dec b
+ jr nz, .asm_ba8
+ ret
+
+FadeIn: ; 0xbbe
+; Fades palettes in from white screen.
+ ld a, [hGameBoyColorFlag]
+ and a
+ jp nz, FadeIn_GameboyColor
+ ; Regular Gameboy
+ ld hl, hBGP
+ ld de, wBGP
+ ld b, $3
+.loop
+ ld a, [de]
+ and $55
+ ld c, a
+ ld a, [de]
+ and $aa
+ srl a
+ and c
+ ld [hli], a
+ inc de
+ dec b
+ jr nz, .loop
+ ld bc, $0002
+ call AdvanceFrames
+ ld hl, hBGP
+ ld de, wBGP
+ ld b, $3
+.loop2
+ ld a, [de]
+ and $aa
+ srl a
+ add [hl]
+ ld [hli], a
+ inc de
+ dec b
+ jr nz, .loop2
+ ld bc, $0002
+ call AdvanceFrames
+ ld hl, hBGP
+ ld de, wBGP
+ ld b, $3
+.loop3
+ ld a, [de]
+ and $55
+ ld c, a
+ ld a, [de]
+ and $aa
+ srl a
+ or c
+ add [hl]
+ ld [hli], a
+ inc de
+ dec b
+ jr nz, .loop3
+ ld bc, $0002
+ call AdvanceFrames
+ ret
+
+FadeIn_GameboyColor: ; 0xc19
+; Fades in to the target palette data in wPaletteData from wFadeBGPaletteData and wFadeOBJPaletteData
+; Fade is completed after 16 frames of incrementally updating the palettes.
+ ld b, 16 ; fade takes 16 frames to complete
+.loop
+ push bc
+ ld de, wPaletteData
+ ld hl, wFadeBGPaletteData
+ call FadeInStep
+ call SetFadedPalettes
+ pop bc
+ dec b
+ jr nz, .loop
+ ret
+
+FadeInStep: ; 0xc2d
+; de = base palette data
+; hl = faded palette data
+ ld a, b
+ cp $1
+ jr z, .lastStep
+ ld c, $40 ; total number of colors in BG and OBJ palettes
+.loop
+ push bc
+ ld a, [hli]
+ sub $42
+ ld c, a
+ ld a, [hld]
+ sbc $8
+ ld b, a ; subtracted 2 from each RGB value of the color
+ call GetNextFadedPalette
+ ld a, c
+ ld [hli], a
+ ld a, b
+ ld [hli], a
+ pop bc
+ dec c
+ jr nz, .loop
+ ret
+
+.lastStep
+ ld c, $40 ; total number of colors in BG and OBJ palettes
+.loop2
+ push bc
+ ld a, [hli]
+ sub $21
+ ld c, a
+ ld a, [hld]
+ sbc $4
+ ld b, a
+ call GetNextFadedPalette
+ ld a, c
+ ld [hli], a
+ ld a, b
+ ld [hli], a
+ pop bc
+ dec c
+ jr nz, .loop2
+ ret
+
+GetNextFadedPalette: ; 0xc60
+; de = source palette data
+; bc = target palette RGB - 2
+; Places the resulting palette RGB into bc
+ push hl
+ ld a, [de]
+ and %00011111 ; Target RGB Blue value
+ ld l, a
+ ld a, c
+ and %00011111 ; Current faded RBG Blue value - 2
+ cp l
+ jr nc, .brighter
+ ; set the current faded Blue value to the target blue value.
+ ld a, c
+ and %11100000
+ or l
+ ld c, a
+.brighter
+ ld a, [de]
+ and %11100000
+ ld l, a
+ inc de
+ ld a, [de]
+ srl a
+ rr l
+ srl a
+ rr l
+ ld a, c
+ and %11100000
+ ld h, a
+ ld a, b
+ srl a
+ rr h
+ srl a
+ rr h
+ ld a, h
+ cp l
+ jr nc, .asm_ca3
+ ld h, $0
+ sla l
+ rl h
+ sla l
+ rl h
+ ld a, c
+ and $1f
+ or l
+ ld c, a
+ ld a, b
+ and $7c
+ or h
+ ld b, a
+.asm_ca3
+ ld a, [de]
+ and $7c
+ ld l, a
+ ld a, b
+ and $7c
+ cp l
+ jr nc, .asm_cb2
+ ld a, b
+ and $3
+ or l
+ ld b, a
+.asm_cb2
+ inc de
+ pop hl
+ ret
+
+FadeOut: ; 0xcb5
+; Fades palettes out to a white screen.
+ ld a, [hGameBoyColorFlag]
+ and a
+ jp nz, FadeOut_GameboyColor
+ ; Regular Gameboy
+ ld hl, hBGP
+ ld b, $3
+.loop
+ push bc
+ push hl
+ ld b, $3
+.loop2
+ ld a, [hl]
+ and $55
+ ld c, a
+ ld a, [hl]
+ and $aa
+ srl a
+ or c
+ cpl
+ inc a
+ add [hl]
+ ld [hli], a
+ dec b
+ jr nz, .loop2
+ ld bc, $0002
+ call AdvanceFrames
+ pop hl
+ pop bc
+ dec b
+ jr nz, .loop
+ xor a
+ ld hl, hBGP
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ld bc, $0002
+ call AdvanceFrames
+ ret
+
+FadeOut_GameboyColor: ; 0xcee
+; Fades out to white RGB colors from the currently-loaded palettes.
+; Fade is completed after 16 frames of incrementally updating the palettes.
+ ld hl, wFadeBGPaletteData
+ ld de, rBGPI
+ call LoadCurrentPalettesIntoFadePalettes
+ ld hl, wFadeOBJPaletteData
+ ld de, rOBPI
+ call LoadCurrentPalettesIntoFadePalettes
+ ld b, 16 ; fade takes 16 frames to complete
+.loop
+ push bc
+ ld hl, wFadeBGPaletteData
+ call FadeOutStep
+ call SetFadedPalettes
+ pop bc
+ dec b
+ jr nz, .loop
+ ret
+
+FadeOutStep: ; 0xd11
+; hl = faded palette data
+ ld b, $40
+.asm_d13
+ ld a, [hl]
+ and $1f
+ add $2
+ ld e, a
+ cp $1f
+ jr c, .asm_d1f
+ ld e, $1f
+.asm_d1f
+ ld a, [hl]
+ and $e0
+ or e
+ ld [hl], a
+ ld a, [hli]
+ and $e0
+ ld e, [hl]
+ dec hl
+ srl e
+ rr a
+ srl e
+ rr a
+ add $10
+ ld e, a
+ jr nc, .asm_d38
+ ld e, $f8
+.asm_d38
+ ld d, $0
+ sla e
+ rl d
+ sla e
+ rl d
+ ld a, [hl]
+ and $1f
+ or e
+ ld [hli], a
+ ld a, [hl]
+ and $7c
+ or d
+ ld [hl], a
+ ld a, [hl]
+ and $7c
+ add $8
+ ld e, a
+ cp $7c
+ jr c, .asm_d58
+ ld e, $7c
+.asm_d58
+ ld a, [hl]
+ and $3
+ or e
+ ld [hli], a
+ dec b
+ jr nz, .asm_d13
+ ret
+
+SetFadedPalettes: ; 0d61
+; Sets the current palette data to the faded palettes.
+ ld a, [rIE]
+ res 0, a
+ ld [rIE], a
+ ld hl, wFadeBGPaletteData
+ ld de, rBGPI
+ ld a, $80
+ ld [de], a
+ inc de
+.waitForVBlank
+ ld a, [rLY]
+ cp $90
+ jr c, .waitForVBlank
+ ld b, $10
+.loadBGColorsLoop
+ ld a, [hli]
+ ld [de], a
+ ld a, [hli]
+ ld [de], a
+ ld a, [hli]
+ ld [de], a
+ ld a, [hli]
+ ld [de], a
+ dec b
+ jr nz, .loadBGColorsLoop
+ inc de
+ ld a, $80
+ ld [de], a
+ inc de
+ ld b, $10
+.loadOBJColorsLoop
+ ld a, [hli]
+ ld [de], a
+ ld a, [hli]
+ ld [de], a
+ ld a, [hli]
+ ld [de], a
+ ld a, [hli]
+ ld [de], a
+ dec b
+ jr nz, .loadOBJColorsLoop
+ ld a, [rIE]
+ set 0, a
+ ld [rIE], a
+ ret
+
+LoadCurrentPalettesIntoFadePalettes: ; 0xd9d
+; hl = destination for palette data
+; de = source of palettes (rBGPI or rOBPI)
+ ld b, $0
+ ld c, e
+ inc c
+ call WaitForLCD
+.asm_da4
+ call Func_61b
+.asm_da7
+ ld a, [rSTAT]
+ and $3
+ jr nz, .asm_da7 ; wait for lcd controller to finish transferring data
+ ld a, b
+ ld [de], a
+ ld a, [$ff00+c]
+ ld [hli], a
+ inc b
+ ld a, b
+ ld [de], a
+ ld a, [$ff00+c]
+ ld [hli], a
+ inc b
+ ld a, b
+ ld [de], a
+ ld a, [$ff00+c]
+ ld [hli], a
+ inc b
+ ld a, b
+ ld [de], a
+ ld a, [$ff00+c]
+ ld [hli], a
+ inc b
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ ld a, b
+ cp $40
+ jr nz, .asm_da4
+ ret
diff --git a/wram.asm b/wram.asm
index 062907a..1f8ef3e 100644
--- a/wram.asm
+++ b/wram.asm
@@ -1036,10 +1036,10 @@ wd643:: ; 0xd643
wd644:: ; 0xd644
ds $1
-wd645:: ; 0xd645
+wPsyduckState:: ; 0xd645
ds $1
-wd646:: ; 0xd646
+wPoliwagState:: ; 0xd646
ds $1
wBonusMultiplierRailingEndLightDuration:: ; 0xd647