From 2e9e298d6419fe2c4c580946bcb18ace7290dfe6 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 23 Jan 2024 17:42:24 +0100 Subject: [PATCH] Level selection menu: draw level cleared indicators [Commit 2/2] (#12) --- constants/landmark_constants.asm | 12 ++--- engine/gfx/cgb_layouts.asm | 5 ++ engine/gfx/color.asm | 3 ++ engine/menus/level_selection_menu.asm | 49 ++++++++++++++++---- gfx/level_selection_menu/attrmap.asm | 11 ++++- gfx/level_selection_menu/stage_trophies.pal | 20 ++++++++ gfx/level_selection_menu/stage_trophies.png | Bin 0 -> 206 bytes 7 files changed, 83 insertions(+), 17 deletions(-) create mode 100755 gfx/level_selection_menu/stage_trophies.pal create mode 100755 gfx/level_selection_menu/stage_trophies.png diff --git a/constants/landmark_constants.asm b/constants/landmark_constants.asm index 5c9ae9d2a..77816024f 100644 --- a/constants/landmark_constants.asm +++ b/constants/landmark_constants.asm @@ -18,14 +18,14 @@ DEF LSMTEXTBOX_X_COORD EQU 1 DEF LSMTEXTBOX_Y_COORD EQU 15 DEF LSMTEXTBOX_MAX_TEXT_ROW_LENGTH EQU LSMTEXTBOX_WIDTH - 5 DEF LSMTEXTBOX_BLACK_TILE EQU "" -DEF LSMTEXTBOX_LEVEL_INDICATOR_TILE EQU $30 -DEF LSMTEXTBOX_LEVEL_NUMBERS_FIRST_TILE EQU $31 +DEF LSMTEXTBOX_LEVEL_INDICATOR_TILE EQU $30 ; and $40 +DEF LSMTEXTBOX_LEVEL_NUMBERS_FIRST_TILE EQU $31 ; and $41 const_def $3b ; $31 + 10 ; these must be consecutive - const LSMTEXTBOX_STAGE_1_INDICATOR_TILE ; $3b - const LSMTEXTBOX_STAGE_2_INDICATOR_TILE ; $3c - const LSMTEXTBOX_STAGE_3_INDICATOR_TILE ; $3d - const LSMTEXTBOX_STAGE_4_INDICATOR_TILE ; $3e + const LSMTEXTBOX_STAGE_1_INDICATOR_TILE ; $3b (and $4b) + const LSMTEXTBOX_STAGE_2_INDICATOR_TILE ; $3c (and $4c) + const LSMTEXTBOX_STAGE_3_INDICATOR_TILE ; $3d (and $4d) + const LSMTEXTBOX_STAGE_4_INDICATOR_TILE ; $3e (and $4e) ; used in CaughtData (legacy) const_def $7f, -1 diff --git a/engine/gfx/cgb_layouts.asm b/engine/gfx/cgb_layouts.asm index 91d14f40d..835beccfa 100644 --- a/engine/gfx/cgb_layouts.asm +++ b/engine/gfx/cgb_layouts.asm @@ -582,6 +582,11 @@ _CGB_LevelSelectionMenu: ld bc, 2 palettes ld a, BANK(wOBPals1) call FarCopyWRAM +; load stage trophy pals (pal2 to pal5) + ld hl, LevelSelectionMenuStageTrophyPals + ld bc, 4 palettes + ld a, BANK(wOBPals1) + call FarCopyWRAM ; load daytime and gender-based background pals ld a, [wPlayerGender] diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index e5023c92b..3aa9c101a 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -880,4 +880,7 @@ LevelSelectionMenuFemalePals: INCLUDE "gfx/level_selection_menu/background_female.pal" assert_table_length NUM_DAYTIMES +LevelSelectionMenuStageTrophyPals: +INCLUDE "gfx/level_selection_menu/stage_trophies.pal" + INCLUDE "engine/gfx/rgb_fade.asm" diff --git a/engine/menus/level_selection_menu.asm b/engine/menus/level_selection_menu.asm index c5d9865d8..4b03ce1c1 100755 --- a/engine/menus/level_selection_menu.asm +++ b/engine/menus/level_selection_menu.asm @@ -43,6 +43,7 @@ LevelSelectionMenu:: call LevelSelectionMenu_PrintLevelAndLandmarkNameAndStageIndicators call LevelSelectionMenu_DrawDirectionalArrows call LevelSelectionMenu_DrawStageTrophies + call LevelSelectionMenu_RefreshTextboxAttrs .main_loop farcall PlaySpriteAnimations @@ -97,8 +98,9 @@ LevelSelectionMenu:: ; clear textbox and non-player sprites, as we are about to move out of current landmark call LevelSelectionMenu_Delay10Frames - call LevelSelectionMenu_ClearTextbox ; preserves e call LevelSelectionMenu_ClearNonPlayerSpriteOAM ; preserves e + call LevelSelectionMenu_ClearTextbox ; preserves e + call LevelSelectionMenu_RefreshTextboxAttrs ; preserves e ; begin transition xor a ; FALSE ld [wLevelSelectionMenuStandingStill], a @@ -121,6 +123,7 @@ LevelSelectionMenu:: call LevelSelectionMenu_PrintLevelAndLandmarkNameAndStageIndicators call LevelSelectionMenu_DrawDirectionalArrows call LevelSelectionMenu_DrawStageTrophies + call LevelSelectionMenu_RefreshTextboxAttrs jp .main_loop .enter_level @@ -342,7 +345,11 @@ LevelSelectionMenu_PrintLevelAndLandmarkNameAndStageIndicators: ld a, LSMTEXTBOX_STAGE_1_INDICATOR_TILE call nz, .PrintStageTile - call WaitBGMap + ld a, 2 + ld [hBGMapThird], a + dec a ; ld a ,1 + ld [hBGMapMode], a + call DelayFrame xor a ld [hBGMapMode], a ret @@ -363,11 +370,33 @@ LevelSelectionMenu_ClearTextbox: ld a, LSMTEXTBOX_BLACK_TILE lb bc, LSMTEXTBOX_HEIGHT, LSMTEXTBOX_WIDTH call FillBoxWithByte - call WaitBGMap + ld a, 2 + ld [hBGMapThird], a + dec a ; ld a, 1 + ld [hBGMapMode], a + call DelayFrame xor a ld [hBGMapMode], a ret +LevelSelectionMenu_RefreshTextboxAttrs: +; OAM priority changes in the textbox depending on whether a landmark is shown +; (stage trophies OAM has priority) or player is moving (all BG has priority). +; Assumes affected tiles are only in the textbox, which is in the bottom third of screen. + push de + hlcoord LSMTEXTBOX_X_COORD, LSMTEXTBOX_Y_COORD + decoord LSMTEXTBOX_X_COORD, LSMTEXTBOX_Y_COORD, wAttrmap + ld bc, SCREEN_WIDTH * (SCREEN_HEIGHT - LSMTEXTBOX_Y_COORD) + call LevelSelectionMenu_InitAttrmap.loop + ld a, 2 + ld [hBGMapThird], a + ld [hBGMapMode], a + call DelayFrame + xor a + ld [hBGMapMode], a + pop de + ret + 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. @@ -534,12 +563,12 @@ LevelSelectionMenu_DrawStageTrophies: .BaseOAMTilesAttrs: db 24 + NUM_DIRECTIONS + 0, 2 - db 24 + NUM_DIRECTIONS + 1, 2 - db 24 + NUM_DIRECTIONS + 2, 3 - db 24 + NUM_DIRECTIONS + 3, 3 - db 24 + NUM_DIRECTIONS + 4, 4 - db 24 + NUM_DIRECTIONS + 5, 4 - db 24 + NUM_DIRECTIONS + 6, 5 + 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 LevelSelectionMenu_ClearNonPlayerSpriteOAM: @@ -1013,4 +1042,4 @@ LevelSelectionMenuDirectionalArrowsGFX: INCBIN "gfx/level_selection_menu/directional_arrows.2bpp" LevelSelectionMenuStageTrophiesGFX: -;INCBIN "gfx/level_selection_menu/stage_trophies.2bpp" +INCBIN "gfx/level_selection_menu/stage_trophies.2bpp" diff --git a/gfx/level_selection_menu/attrmap.asm b/gfx/level_selection_menu/attrmap.asm index 1654e47a1..e837c559f 100755 --- a/gfx/level_selection_menu/attrmap.asm +++ b/gfx/level_selection_menu/attrmap.asm @@ -1,5 +1,6 @@ DEF PAL_LEVELSELECTIONMENU_BORDER EQU 0 | 1 << OAM_PRIORITY - const_def 1 + const_def 0 + const PAL_LEVELSELECTIONMENU_STAGES ; 0 const PAL_LEVELSELECTIONMENU_EARTH ; 1 const PAL_LEVELSELECTIONMENU_MOUNTAIN ; 2 const PAL_LEVELSELECTIONMENU_CITY ; 3 @@ -14,9 +15,17 @@ endr ENDM ; gfx/level_selection_menu/background.png +; some are aligned to specific LSMTEXTBOX_* tile constants (constants/landmark_constants.asm) levelselectionmenupals EARTH, EARTH, EARTH, MOUNTAIN, MOUNTAIN, MOUNTAIN, BORDER, BORDER levelselectionmenupals EARTH, EARTH, CITY, EARTH, POI, POI_MTN, POI, POI_MTN levelselectionmenupals EARTH, EARTH, EARTH, MOUNTAIN, MOUNTAIN, MOUNTAIN, BORDER, BORDER levelselectionmenupals EARTH, EARTH, EARTH, EARTH, EARTH, BORDER, BORDER, BORDER levelselectionmenupals EARTH, EARTH, EARTH, MOUNTAIN, MOUNTAIN, MOUNTAIN, BORDER, BORDER levelselectionmenupals BORDER, BORDER, BORDER, BORDER, BORDER, BORDER, BORDER, BORDER + levelselectionmenupals BORDER, BORDER, BORDER, BORDER, BORDER, BORDER, BORDER, BORDER + levelselectionmenupals BORDER, BORDER, BORDER, STAGES, STAGES, STAGES, STAGES, BORDER + levelselectionmenupals BORDER, BORDER, BORDER, BORDER, BORDER, BORDER, BORDER, BORDER + levelselectionmenupals BORDER, BORDER, BORDER, STAGES, STAGES, STAGES, STAGES, BORDER +rept 22 + levelselectionmenupals BORDER, BORDER, BORDER, BORDER, BORDER, BORDER, BORDER, BORDER +endr diff --git a/gfx/level_selection_menu/stage_trophies.pal b/gfx/level_selection_menu/stage_trophies.pal new file mode 100755 index 000000000..dcff0d394 --- /dev/null +++ b/gfx/level_selection_menu/stage_trophies.pal @@ -0,0 +1,20 @@ +; STAGE_1 + RGB 31, 31, 31 + RGB 21, 21, 23 + RGB 10, 10, 12 + RGB 00, 00, 00 +; STAGE_2 + RGB 31, 31, 31 + RGB 31, 13, 13 + RGB 18, 00, 00 + RGB 00, 00, 00 +; STAGE_3 + RGB 31, 31, 31 + RGB 11, 29, 15 + RGB 02, 17, 05 + RGB 00, 00, 00 +; STAGE_4 + RGB 31, 31, 31 + RGB 05, 25, 31 + RGB 01, 08, 22 + RGB 00, 00, 00 diff --git a/gfx/level_selection_menu/stage_trophies.png b/gfx/level_selection_menu/stage_trophies.png new file mode 100755 index 0000000000000000000000000000000000000000..bd3bb1027151443d1ddf1c6530d70e665f2f8289 GIT binary patch literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Et!3HGD8EPYe6id3JuOkD)#(wTUiL5|AXMsm# zF$0582?#UZOOvkv3Kn>}IEHw5zwLA6I-tPA^4Zh=rMj-Phe6rx+mpJPyAO5rtWC>v z;FL)Iu`l2UPs5DjUpLgX-ZSn_>7VjXw4quj;FnOt literal 0 HcmV?d00001