Level selection menu: draw ToD symbol (#12)

This commit is contained in:
xCrystal 2024-01-25 18:57:56 +01:00
parent c6ed364122
commit 0d85313c54
4 changed files with 128 additions and 37 deletions

View File

@ -129,6 +129,8 @@ DEF NUM_PREDEF_PALS EQU const_value
const_def
const RGBFADE_TO_BLACK_6BGP
const RGBFADE_TO_LIGHTER_6BGP
const RGBFADE_TO_WHITE_6BGP_2OBP
const RGBFADE_TO_WHITE_6BGP_3OBP
const RGBFADE_TO_WHITE_8BGP_8OBP
const RGBFADE_TO_BLACK_6BGP_1OBP2
const RGBFADE_TO_LIGHTER_6BGP_1OBP2
DEF NUM_RGB_FADE_EFFECTS EQU const_value

View File

@ -582,12 +582,7 @@ _CGB_LevelSelectionMenu:
ld bc, 2 palettes
ld a, BANK(wOBPals1)
call FarCopyWRAM
; load stage trophy pals (pal2 to pal5)
ld hl, LevelSelectionMenuStageTrophiesPals
ld bc, 4 palettes
ld a, BANK(wOBPals1)
call FarCopyWRAM
; load daytime-based ToD symbol pals (pal 6)
; load daytime-based ToD symbol pals (pal2)
ld a, [wTimeOfDay]
maskbits NUM_DAYTIMES
ld bc, 1 palettes
@ -596,6 +591,11 @@ _CGB_LevelSelectionMenu:
ld bc, 1 palettes
ld a, BANK(wOBPals1)
call FarCopyWRAM
; load stage trophy pals (pal3 to pal6)
ld hl, LevelSelectionMenuStageTrophiesPals
ld bc, 4 palettes
ld a, BANK(wOBPals1)
call FarCopyWRAM
; load daytime and gender-based background pals
ld a, [wPlayerGender]

View File

@ -275,10 +275,12 @@ _DoRGBFadeEffect::
RGBFadeEffectJumptable:
; entries correspond to RGBFADE_* constants (see constants/cgb_pal_constants.asm)
table_width 2, RGBFadeEffectJumptable
dw _RGBFadeToBlack_6BGP ; RGBFADE_TO_BLACK_6BGP
dw _RGBFadeToLighter_6BGP ; RGBFADE_TO_LIGHTER_6BGP
dw _RGBFadeToWhite_6BGP_2OBP ; RGBFADE_TO_WHITE_6BGP_2OBP
dw _RGBFadeToWhite_8BGP_8OBP ; RGBFADE_TO_WHITE_8BGP_8OBP
dw _RGBFadeToBlack_6BGP ; RGBFADE_TO_BLACK_6BGP
dw _RGBFadeToLighter_6BGP ; RGBFADE_TO_LIGHTER_6BGP
dw _RGBFadeToWhite_6BGP_3OBP ; RGBFADE_TO_WHITE_6BGP_3OBP
dw _RGBFadeToWhite_8BGP_8OBP ; RGBFADE_TO_WHITE_8BGP_8OBP
dw _RGBFadeToBlack_6BGP_1OBP2 ; RGBFADE_TO_BLACK_6BGP_1OBP2
dw _RGBFadeToLighter_6BGP_1OBP2 ; RGBFADE_TO_LIGHTER_6BGP_1OBP2
assert_table_length NUM_RGB_FADE_EFFECTS
_RGBFadeToBlack_6BGP:
@ -301,6 +303,31 @@ _RGBFadeToBlack_6BGP:
jr nz, .loop
ret
_RGBFadeToBlack_6BGP_1OBP2:
ld c, 32 / 2
.loop
push bc
; fade BGP to black
ld de, wBGPals2
ld c, 6 * NUM_PAL_COLORS
call FadeStepColorsToBlack
; fade OBP to black
ld de, wOBPals2 + 2 palettes
ld c, 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
@ -322,7 +349,34 @@ _RGBFadeToLighter_6BGP:
jr nz, .loop
ret
_RGBFadeToWhite_6BGP_2OBP:
_RGBFadeToLighter_6BGP_1OBP2:
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
; fade OBP to lighter (towards wOBPals1)
ld de, wOBPals2 + 2 palettes
ld hl, wOBPals1 + 2 palettes
ld c, 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_3OBP:
ld c, 32 / 2
.loop
push bc
@ -334,7 +388,7 @@ _RGBFadeToWhite_6BGP_2OBP:
; fade OBP to white
ld de, wOBPals2
ld c, 2 * NUM_PAL_COLORS
ld c, 3 * NUM_PAL_COLORS
call FadeStepColorsToWhite
; commit pals

View File

@ -29,6 +29,7 @@ LevelSelectionMenu::
call WaitBGMap2
xor a
ldh [hBGMapMode], a
call LevelSelectionMenu_DrawTimeOfDaySymbol
ld b, CGB_LEVEL_SELECTION_MENU
call GetCGBLayout ; apply and commit pals
call SetPalettes
@ -98,7 +99,7 @@ LevelSelectionMenu::
; clear textbox and non-player sprites, as we are about to move out of current landmark
call LevelSelectionMenu_Delay10Frames
call LevelSelectionMenu_ClearNonPlayerSpriteOAM ; preserves e
call LevelSelectionMenu_ClearTextboxOAM ; preserves e
call LevelSelectionMenu_ClearTextbox ; preserves e
call LevelSelectionMenu_RefreshTextboxAttrs ; preserves e
; begin transition
@ -139,7 +140,7 @@ LevelSelectionMenu::
ret
.EnterLevelFadeOut:
ld b, RGBFADE_TO_WHITE_6BGP_2OBP
ld b, RGBFADE_TO_WHITE_6BGP_3OBP
jp DoRGBFadeEffect
.exit
@ -401,13 +402,47 @@ LevelSelectionMenu_RefreshTextboxAttrs:
pop de
ret
LevelSelectionMenu_DrawTimeOfDaySymbol:
ld hl, .OAM
ld de, wShadowOAM + $4 * SPRITEOAMSTRUCT_LENGTH ; always goes after player sprite
ld a, [wTimeOfDay]
add a
ld c, a
call .CopyObject
call .CopyObject
call .CopyObject
call .CopyObject
ret
.CopyObject:
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
add c
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
ret
.OAM:
db 3 * TILE_WIDTH, 2 * TILE_WIDTH, 24 + NUM_DIRECTIONS + NUM_LEVEL_STAGES * 2 + 0, 2
db 3 * TILE_WIDTH, 3 * TILE_WIDTH, 24 + NUM_DIRECTIONS + NUM_LEVEL_STAGES * 2 + 1, 2
db 4 * TILE_WIDTH, 2 * TILE_WIDTH, 24 + NUM_DIRECTIONS + NUM_LEVEL_STAGES * 2 + 8, 2
db 4 * TILE_WIDTH, 3 * TILE_WIDTH, 24 + NUM_DIRECTIONS + NUM_LEVEL_STAGES * 2 + 9, 2
LevelSelectionMenu_DrawDirectionalArrows:
; Draw directional arrows OAM around player sprite for the valid directions.
; Objects are drawn in OAM after player sprite objects in wWalkingDirection order.
; Depends on wLevelSelectionMenuLandmarkTransitionsPointer being initialized.
call LevelSelectionMenu_GetValidDirections
ld hl, .OAM
ld de, wShadowOAM + $4 * SPRITEOAMSTRUCT_LENGTH ; always goes after player sprite
ld de, wShadowOAM + ($4 + $4) * SPRITEOAMSTRUCT_LENGTH ; always goes after player sprite and ToD symbol
bit D_DOWN_F, c
jr z, .next1
call .DrawArrow
@ -456,23 +491,23 @@ LevelSelectionMenu_DrawDirectionalArrows:
LevelSelectionMenu_DrawStageTrophies:
; Draw stage trophies OAM of cleared level stages.
; These objects go after player sprite and arrows in OAM.
ld de, wShadowOAM + ($4 + NUM_DIRECTIONS + $0) * SPRITEOAMSTRUCT_LENGTH
; These objects go after player sprite, ToD symbol, and arrows in OAM.
ld de, wShadowOAM + ($4 + $4 + NUM_DIRECTIONS + $0) * SPRITEOAMSTRUCT_LENGTH
bccoord LSMTEXTBOX_X_COORD + (LSMTEXTBOX_WIDTH - 1), LSMTEXTBOX_Y_COORD
ld a, 6
call .draw_stage_trophy
ret c
ld de, wShadowOAM + ($4 + NUM_DIRECTIONS + $2) * SPRITEOAMSTRUCT_LENGTH
ld de, wShadowOAM + ($4 + $4 + NUM_DIRECTIONS + $2) * SPRITEOAMSTRUCT_LENGTH
bccoord LSMTEXTBOX_X_COORD + (LSMTEXTBOX_WIDTH - 2), LSMTEXTBOX_Y_COORD
ld a, 4
call .draw_stage_trophy
ret c
ld de, wShadowOAM + ($4 + NUM_DIRECTIONS + $4) * SPRITEOAMSTRUCT_LENGTH
ld de, wShadowOAM + ($4 + $4 + NUM_DIRECTIONS + $4) * SPRITEOAMSTRUCT_LENGTH
bccoord LSMTEXTBOX_X_COORD + (LSMTEXTBOX_WIDTH - 3), LSMTEXTBOX_Y_COORD
ld a, 2
call .draw_stage_trophy
ret c
ld de, wShadowOAM + ($4 + NUM_DIRECTIONS + $6) * SPRITEOAMSTRUCT_LENGTH
ld de, wShadowOAM + ($4 + $4 + NUM_DIRECTIONS + $6) * SPRITEOAMSTRUCT_LENGTH
bccoord LSMTEXTBOX_X_COORD + (LSMTEXTBOX_WIDTH - 4), LSMTEXTBOX_Y_COORD
xor a
call .draw_stage_trophy
@ -506,8 +541,8 @@ LevelSelectionMenu_DrawStageTrophies:
ld hl, .BaseOAMCoords
add hl, bc
pop bc
call .CopyOAM
call .CopyOAM
call .CopyObject
call .CopyObject
xor a
ret ; nc
@ -538,7 +573,7 @@ LevelSelectionMenu_DrawStageTrophies:
ld a, c
ret
.CopyOAM:
.CopyObject:
ld a, [hli]
ld [de], a
inc de
@ -566,18 +601,18 @@ LevelSelectionMenu_DrawStageTrophies:
db 18 * TILE_WIDTH, 19 * TILE_WIDTH
.BaseOAMTilesAttrs:
db 24 + NUM_DIRECTIONS + 0, 2
db 24 + NUM_DIRECTIONS + 4, 2
db 24 + NUM_DIRECTIONS + 1, 3
db 24 + NUM_DIRECTIONS + 5, 3
db 24 + NUM_DIRECTIONS + 2, 4
db 24 + NUM_DIRECTIONS + 6, 4
db 24 + NUM_DIRECTIONS + 3, 5
db 24 + NUM_DIRECTIONS + 7, 5
db 24 + NUM_DIRECTIONS + 0, 3
db 24 + NUM_DIRECTIONS + 4, 3
db 24 + NUM_DIRECTIONS + 1, 4
db 24 + NUM_DIRECTIONS + 5, 4
db 24 + NUM_DIRECTIONS + 2, 5
db 24 + NUM_DIRECTIONS + 6, 5
db 24 + NUM_DIRECTIONS + 3, 6
db 24 + NUM_DIRECTIONS + 7, 6
LevelSelectionMenu_ClearNonPlayerSpriteOAM:
ld hl, wShadowOAM + $4 * SPRITEOAMSTRUCT_LENGTH
ld bc, wShadowOAMEnd - (wShadowOAM + $4 * SPRITEOAMSTRUCT_LENGTH)
LevelSelectionMenu_ClearTextboxOAM:
ld hl, wShadowOAM + $8 * SPRITEOAMSTRUCT_LENGTH
ld bc, wShadowOAMEnd - (wShadowOAM + $8 * SPRITEOAMSTRUCT_LENGTH)
xor a
jp ByteFill
@ -726,11 +761,11 @@ ENDM
ret
.PageChangeFadeOut:
ld b, RGBFADE_TO_BLACK_6BGP
ld b, RGBFADE_TO_BLACK_6BGP_1OBP2
jp DoRGBFadeEffect
.PageChangeFadeIn:
ld b, RGBFADE_TO_LIGHTER_6BGP
ld b, RGBFADE_TO_LIGHTER_6BGP_1OBP2
jp DoRGBFadeEffect
LevelSelectionMenu_GetLandmarkPage: