Level selection menu: fading animations (#12) (#14)

This commit is contained in:
xCrystal
2023-08-27 13:11:42 +02:00
parent 4855dd9b70
commit 4dec74b770
8 changed files with 161 additions and 54 deletions

View File

@@ -4,7 +4,7 @@ LoadCGBLayout:
ld a, b
cp CGB_DEFAULT
jr nz, .not_default
ld a, [wDefaultSGBLayout]
ld a, [wDefaultCGBLayout]
.not_default
cp CGB_PARTY_MENU_HP_BARS
jp z, CGB_ApplyPartyMenuHPPals
@@ -24,6 +24,7 @@ LoadCGBLayout:
ret
CGBLayoutJumptable:
; entries correspond to CGB_* constants (see constants/cgb_pal_constants.asm)
table_width 2, CGBLayoutJumptable
dw _CGB_BattleGrayscale
dw _CGB_BattleColors
@@ -104,7 +105,7 @@ _CGB_BattleColors:
pop hl
call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_OB_PLAYER
ld a, CGB_BATTLE_COLORS
ld [wDefaultSGBLayout], a
ld [wDefaultCGBLayout], a
call ApplyPals
_CGB_FinishBattleScreenLayout:
call InitPartyMenuBGPal7
@@ -506,7 +507,7 @@ _CGB_Diploma:
_CGB_MapPals:
call LoadMapPals
ld a, CGB_MAPPALS
ld [wDefaultSGBLayout], a
ld [wDefaultCGBLayout], a
ret
_CGB_PartyMenu:
@@ -564,7 +565,7 @@ _CGB_GSTitleScreen:
ld a, BANK(wOBPals1)
call FarCopyWRAM
ld a, CGB_DIPLOMA
ld [wDefaultSGBLayout], a
ld [wDefaultCGBLayout], a
call ApplyPals
ld a, TRUE
ldh [hCGBPalUpdate], a
@@ -581,6 +582,7 @@ _CGB_LevelSelectionMenu:
ld bc, 2 palettes
ld a, BANK(wOBPals1)
call FarCopyWRAM
; load daytime and gender-based background pals
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
@@ -598,30 +600,8 @@ _CGB_LevelSelectionMenu:
ld bc, 6 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
; assign attrs based on tile ids according to LevelSelectionMenuAttrmap
hlcoord 0, 0
decoord 0, 0, wAttrmap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
.loop
push hl
ld a, [hl] ; tile id
ld hl, LevelSelectionMenuAttrmap
add l
ld l, a
ld a, h
adc 0
ld h, a
ld a, [hl] ; attr value
ld [de], a
pop hl
inc hl
inc de
dec bc
ld a, b
or c
jr nz, .loop
; apply and commit pals and attrmap
call ApplyAttrmap
; apply and commit pals
call ApplyPals
ld a, TRUE
ldh [hCGBPalUpdate], a

View File

@@ -822,5 +822,4 @@ LevelSelectionMenuFemalePals:
INCLUDE "gfx/level_selection_menu/background_female.pal"
assert_table_length NUM_DAYTIMES
LevelSelectionMenuAttrmap:
INCLUDE "gfx/level_selection_menu/attrmap.asm"
INCLUDE "engine/gfx/rgb_fade.asm"

View File

@@ -247,4 +247,101 @@ BlackRGB:
RGB 00, 00, 00
WhiteRGB:
RGB 31, 31, 31
RGB 31, 31, 31
_DoRGBFadeEffect::
ldh a, [rSVBK]
push af
ld a, BANK(wBGPals2) ; BANK(wOBPals2)
ldh [rSVBK], a
ld l, b
ld h, 0
add hl, hl
ld de, RGBFadeEffectJumptable
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .done
push de
jp hl
.done:
pop af
ldh [rSVBK], a
ret
RGBFadeEffectJumptable:
; entries correspond to RGBFADE_* constants (see constants/cgb_pal_constants.asm)
table_width 2, RGBFadeEffectJumptable
dw _RGBFadeToBlack_6BGP
dw _RGBFadeToLighter_6BGP
dw _RGBFadeToWhite_6BGP_2OBP
assert_table_length NUM_RGB_FADE_EFFECTS
_RGBFadeToBlack_6BGP:
ld c, 32 / 2
.loop
push bc
; fade BGP to black
ld de, wBGPals2
ld c, 6 * NUM_PAL_COLORS
call FadeStepColorsToBlack
; commit pals
ld a, TRUE
ldh [hCGBPalUpdate], a
call DelayFrame
pop bc
dec c
jr nz, .loop
ret
_RGBFadeToLighter_6BGP:
ld c, 32 / 2
.loop
push bc
; fade BGP to lighter (towards wBGPals1)
ld de, wBGPals2
ld hl, wBGPals1
ld c, 6 * NUM_PAL_COLORS
call FadeStepColorsToLighter
; commit pals
ld a, TRUE
ldh [hCGBPalUpdate], a
call DelayFrame
pop bc
dec c
jr nz, .loop
ret
_RGBFadeToWhite_6BGP_2OBP:
ld c, 32 / 2
.loop
push bc
; fade BGP to white
ld de, wBGPals2
ld c, 6 * NUM_PAL_COLORS
call FadeStepColorsToWhite
; fade OBP to white
ld de, wOBPals2
ld c, 2 * NUM_PAL_COLORS
call FadeStepColorsToWhite
; commit pals
ld a, TRUE
ldh [hCGBPalUpdate], a
call DelayFrame
pop bc
dec c
jr nz, .loop
ret