Level selection menu: entry transition events (#12) (#35) [commit 4/4]

This commit is contained in:
xCrystal 2024-02-04 14:23:58 +01:00
parent d3b397fd37
commit 5005ca7bd0
7 changed files with 185 additions and 12 deletions

View File

@ -29,7 +29,7 @@
const CGB_PLAYER_OR_MON_FRONTPIC_PALS const CGB_PLAYER_OR_MON_FRONTPIC_PALS
const CGB_TRADE_TUBE const CGB_TRADE_TUBE
const CGB_TRAINER_OR_MON_FRONTPIC_PALS const CGB_TRAINER_OR_MON_FRONTPIC_PALS
const CGB_1D const CGB_LEVEL_SELECTION_MENU_TOD_CHANGE
DEF NUM_CGB_LAYOUTS EQU const_value DEF NUM_CGB_LAYOUTS EQU const_value
DEF CGB_PARTY_MENU_HP_BARS EQU $fc DEF CGB_PARTY_MENU_HP_BARS EQU $fc

View File

@ -55,7 +55,7 @@ CGBLayoutJumptable:
dw _CGB_PlayerOrMonFrontpicPals dw _CGB_PlayerOrMonFrontpicPals
dw _CGB_TradeTube dw _CGB_TradeTube
dw _CGB_TrainerOrMonFrontpicPals dw _CGB_TrainerOrMonFrontpicPals
dw _CGB_Unused1D dw _CGB_LevelSelectionMenuToDChange
assert_table_length NUM_CGB_LAYOUTS assert_table_length NUM_CGB_LAYOUTS
_CGB_BattleGrayscale: _CGB_BattleGrayscale:
@ -585,7 +585,7 @@ _CGB_LevelSelectionMenu:
ld bc, 1 palettes ld bc, 1 palettes
ld a, BANK(wOBPals1) ld a, BANK(wOBPals1)
call FarCopyWRAM call FarCopyWRAM
; load daytime-based ToD symbol pals (pal1) ; load daytime-based ToD symbol pals (pal1)
ld a, [wTimeOfDay] ld a, [wTimeOfDay]
maskbits NUM_DAYTIMES maskbits NUM_DAYTIMES
ld bc, 1 palettes ld bc, 1 palettes
@ -624,6 +624,86 @@ _CGB_LevelSelectionMenu:
ldh [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB_LevelSelectionMenuToDChange:
; load daytime-based ToD symbol pals (pal1)
ld a, [wTimeOfDay]
maskbits NUM_DAYTIMES
ld bc, 1 palettes
ld hl, LevelSelectionMenuTimeOfDaySymbolsPals
call AddNTimes
ld de, wOBPals1 + 1 palettes
ld bc, 1 palettes
ld a, BANK(wOBPals1)
call FarCopyWRAM
; load fading background pals
ld hl, .PalsOffsets
ld a, [wLevelSelectionMenuStartingToD]
maskbits NUM_DAYTIMES
ld d, a
ld a, [wLevelSelectionMenuToDFadeStep]
ld e, a
.loop
ld a, [hli]
cp d
jr nz, .next1
inc a ; cp $ff
jr z, .done
ld a, [hli]
cp e
jr z, .match
jr .next2
.next1
inc hl
.next2
inc hl
jr .loop
.match
ld e, [hl]
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .male
ld hl, LevelSelectionMenuFemalePals
jr .got_pals
.male
ld hl, LevelSelectionMenuMalePals
.got_pals
ld a, e
ld bc, 6 palettes
call AddNTimes
ld de, wBGPals1
ld bc, 6 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
.done
; apply and commit pals
call ApplyPals
ld a, TRUE
ldh [hCGBPalUpdate], a
ret
.PalsOffsets:
; wLevelSelectionMenuStartingToD, wLevelSelectionMenuToDFadeStep, offset from LevelSelectionMenu*Pals
db MORN_F, 0, 0
db DAY_F, 0, 1
db NITE_F, 0, 2
db EVE_F, 0, 3
db MORN_F, 1, 4
db MORN_F, 2, 5
db MORN_F, 3, 1
db DAY_F, 1, 6
db DAY_F, 2, 7
db DAY_F, 3, 3
db EVE_F, 1, 8
db EVE_F, 2, 9
db EVE_F, 3, 2
db NITE_F, 1, 10
db NITE_F, 2, 11
db NITE_F, 3, 0
db $ff
_CGB_UnownPuzzle: _CGB_UnownPuzzle:
ld hl, FourPals_UnownPuzzle ld hl, FourPals_UnownPuzzle
call CopyFourPalettes call CopyFourPalettes

View File

@ -155,9 +155,8 @@ GameMenu_WorldMap:
cp CLEARED_LEVEL cp CLEARED_LEVEL
jr nz, .save_and_return jr nz, .save_and_return
; if CLEARED_LEVEL: ; if CLEARED_LEVEL:
; show post-level screen, clear level, unlock levels, advance ToD, request appropriate LSM events ; show post-level screen, clear level, unlock levels, request appropriate LSM events
farcall ClearedLevelScreen farcall ClearedLevelScreen
call AdvanceTimeOfDay
ld hl, wLevelSelectionMenuEntryEventQueue ld hl, wLevelSelectionMenuEntryEventQueue
set LSMEVENT_ANIMATE_TIME_OF_DAY, [hl] set LSMEVENT_ANIMATE_TIME_OF_DAY, [hl]
ld a, [wLastUnlockedLevelsCount] ld a, [wLastUnlockedLevelsCount]

View File

@ -118,6 +118,89 @@ LevelSelectionMenu::
call LevelSelectionMenu_DrawStageTrophies call LevelSelectionMenu_DrawStageTrophies
call LevelSelectionMenu_RefreshTextboxAttrs call LevelSelectionMenu_RefreshTextboxAttrs
ld a, [wLevelSelectionMenuEntryEventQueue]
bit LSMEVENT_ANIMATE_TIME_OF_DAY, a
jp z, .main_loop
call LevelSelectionMenu_Delay10Frames
ld bc, SPRITEOAMSTRUCT_LENGTH
ld e, 3 * TILE_WIDTH
.tod_symbol_upwards_loop
farcall PlaySpriteAnimationsAndDelayFrame
ld hl, wShadowOAM + $4 * SPRITEOAMSTRUCT_LENGTH + SPRITEOAMSTRUCT_YCOORD
dec [hl]
add hl, bc
dec [hl]
add hl, bc
dec [hl]
add hl, bc
dec [hl]
dec e
jr nz, .tod_symbol_upwards_loop
ld a, [wTimeOfDay]
ld [wLevelSelectionMenuStartingToD], a
cp NITE_F
ld e, -4
jr z, .change_tod_symbol
cp EVE_F
ld e, -2
jr z, .change_tod_symbol
cp DAY_F
ld e, 4
jr z, .change_tod_symbol
ld e, 2
.change_tod_symbol
ld hl, wShadowOAM + $4 * SPRITEOAMSTRUCT_LENGTH + SPRITEOAMSTRUCT_TILE_ID
ld bc, SPRITEOAMSTRUCT_LENGTH
ld d, 2 * 2
.change_tod_symbol_loop
ld a, [hl]
add e
ld [hl], a
add hl, bc
dec d
jr nz, .change_tod_symbol_loop
call AdvanceTimeOfDay
xor a
ld [wLevelSelectionMenuToDFadeStep], a
ld b, CGB_LEVEL_SELECTION_MENU_TOD_CHANGE
call GetCGBLayout
call LevelSelectionMenu_Delay4Frames
ld a, 1
ld [wLevelSelectionMenuToDFadeStep], a
ld b, CGB_LEVEL_SELECTION_MENU_TOD_CHANGE
call GetCGBLayout
call LevelSelectionMenu_Delay4Frames
ld a, 2
ld [wLevelSelectionMenuToDFadeStep], a
ld b, CGB_LEVEL_SELECTION_MENU_TOD_CHANGE
call GetCGBLayout
call LevelSelectionMenu_Delay4Frames
ld a, 3
ld [wLevelSelectionMenuToDFadeStep], a
ld b, CGB_LEVEL_SELECTION_MENU_TOD_CHANGE
call GetCGBLayout
ld bc, SPRITEOAMSTRUCT_LENGTH
ld e, 3 * TILE_WIDTH
.tod_symbol_downwards_loop
farcall PlaySpriteAnimationsAndDelayFrame
ld hl, wShadowOAM + $4 * SPRITEOAMSTRUCT_LENGTH + SPRITEOAMSTRUCT_YCOORD
inc [hl]
add hl, bc
inc [hl]
add hl, bc
inc [hl]
add hl, bc
inc [hl]
dec e
jr nz, .tod_symbol_downwards_loop
.main_loop .main_loop
farcall PlaySpriteAnimations farcall PlaySpriteAnimations
call DelayFrame call DelayFrame
@ -1030,13 +1113,16 @@ LevelSelectionMenu_GetNewPage:
ld a, 1 ld a, 1
ret ret
LevelSelectionMenu_Delay4Frames:
ld a, 4
jr LevelSelectionMenu_Delay10Frames.loop
LevelSelectionMenu_Delay10Frames: LevelSelectionMenu_Delay10Frames:
; Delay 10 frames while playing sprite anims ; Delay 10 frames while playing sprite anims
ld a, 10 ld a, 10
.loop .loop
push af push af
farcall PlaySpriteAnimations farcall PlaySpriteAnimationsAndDelayFrame
call DelayFrame
pop af pop af
dec a dec a
jr nz, .loop jr nz, .loop

View File

@ -35,7 +35,7 @@ AdvanceTimeOfDay::
.set_days .set_days
ld [wCurDay], a ld [wCurDay], a
call ClearDailyTimers farcall ClearDailyTimers
ret ret

View File

@ -41,14 +41,14 @@ MACRO rgbpals_fade_apply
DEF fade_from EQUS \1 DEF fade_from EQUS \1
DEF fade_to EQUS \2 DEF fade_to EQUS \2
assert {fade_from}_len == {fade_to}_len, "fade_from pals and fade_to pals must be same length" assert {fade_from}_len == {fade_to}_len, "fade_from pals and fade_to pals must be same length"
for i, \3 for i, 0, \3
for j, 0, {fade_from}_len, 3 for j, 0, {fade_from}_len, 3
DEF rgbch_red = {j} + 0 DEF rgbch_red = {j} + 0
DEF rgbch_green = {j} + 1 DEF rgbch_green = {j} + 1
DEF rgbch_blue = {j} + 2 DEF rgbch_blue = {j} + 2
DEF palred_value = {fade_from}_{d:rgbch_red} + ({fade_to}_{d:rgbch_red} - {fade_from}_{d:rgbch_red}) * i / \3 DEF palred_value = {fade_from}_{d:rgbch_red} + ({fade_to}_{d:rgbch_red} - {fade_from}_{d:rgbch_red}) * (i + 1) / (\3 + 1)
DEF palgreen_value = {fade_from}_{d:rgbch_green} + ({fade_to}_{d:rgbch_green} - {fade_from}_{d:rgbch_green}) * i / \3 DEF palgreen_value = {fade_from}_{d:rgbch_green} + ({fade_to}_{d:rgbch_green} - {fade_from}_{d:rgbch_green}) * (i + 1) / (\3 + 1)
DEF palblue_value = {fade_from}_{d:rgbch_blue} + ({fade_to}_{d:rgbch_blue} - {fade_from}_{d:rgbch_blue}) * i / \3 DEF palblue_value = {fade_from}_{d:rgbch_blue} + ({fade_to}_{d:rgbch_blue} - {fade_from}_{d:rgbch_blue}) * (i + 1) / (\3 + 1)
dw palred (palred_value) + palgreen (palgreen_value) + palblue (palblue_value) dw palred (palred_value) + palgreen (palgreen_value) + palblue (palblue_value)
endr endr
endr endr

View File

@ -947,6 +947,8 @@ ENDU
wDefaultCGBLayout:: db wDefaultCGBLayout:: db
UNION
wPlayerHPPal:: db wPlayerHPPal:: db
wEnemyHPPal:: db wEnemyHPPal:: db
@ -955,6 +957,12 @@ wCurHPPal:: db
wWhichPartyMonHPPal:: db wWhichPartyMonHPPal:: db
NEXTU
wLevelSelectionMenuStartingToD:: db
wLevelSelectionMenuToDFadeStep:: db
ENDU
wAttrmap:: wAttrmap::
; 20x18 grid of bg tile attributes for 8x8 tiles ; 20x18 grid of bg tile attributes for 8x8 tiles
; read horizontally from the top row ; read horizontally from the top row