diff --git a/charmap.asm b/charmap.asm index 7cbf2bc49..75572a61c 100644 --- a/charmap.asm +++ b/charmap.asm @@ -175,6 +175,9 @@ charmap "└", $f4 charmap "┘", $f5 +; level selection menu + charmap "", $1f + ; ASCII charmap, for mobile functions pushc newcharmap ascii diff --git a/constants/landmark_constants.asm b/constants/landmark_constants.asm index c52907099..5637c3084 100644 --- a/constants/landmark_constants.asm +++ b/constants/landmark_constants.asm @@ -11,6 +11,16 @@ endc DEF NUM_LANDMARKS EQU const_value assert NUM_LANDMARKS <= 254 +; constants used in Level Selection Menu +DEF LSMTEXTBOX_WIDTH EQU 18 +DEF LSMTEXTBOX_HEIGHT EQU 2 +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 + ; used in CaughtData (legacy) const_def $7f, -1 const LANDMARK_EVENT ; $7f diff --git a/data/levels/level_selection_menu.asm b/data/levels/level_selection_menu.asm index 320738026..e66c09e1e 100755 --- a/data/levels/level_selection_menu.asm +++ b/data/levels/level_selection_menu.asm @@ -16,6 +16,12 @@ MACRO level_selection_menu_landmark db \5 ENDM +MACRO level_selection_menu_landmark_name + assert STRLEN(\1) == LSMTEXTBOX_MAX_TEXT_ROW_LENGTH + assert STRLEN(\2) == LSMTEXTBOX_MAX_TEXT_ROW_LENGTH + db STRRPL(\1, " ", ""), STRRPL(\2, " ", ""), +ENDM + LevelSelectionMenu_Landmarks: table_width 6, LevelSelectionMenu_Landmarks .landmark1 @@ -30,13 +36,13 @@ if DEF(_DEBUG) endc assert_table_length NUM_LANDMARKS -.Level1LandmarkName: db "LEVEL 1@" +.Level1LandmarkName: level_selection_menu_landmark_name " THE FIRST ", " LEVEL " if DEF(_DEBUG) -.DebugLevel1LandmarkName: db "DEBUG LEVEL 1@" -.DebugLevel2LandmarkName: db "DEBUG LEVEL 2@" -.DebugLevel3LandmarkName: db "DEBUG LEVEL 3@" -.DebugLevel4LandmarkName: db "DEBUG LEVEL 4@" -.DebugLevel5LandmarkName: db "DEBUG LEVEL 5@" +.DebugLevel1LandmarkName: level_selection_menu_landmark_name " DEBUG ", " DUMMY " +.DebugLevel2LandmarkName: level_selection_menu_landmark_name " DEBUG ", " CAVE " +.DebugLevel3LandmarkName: level_selection_menu_landmark_name " DEBUG ", " FOREST " +.DebugLevel4LandmarkName: level_selection_menu_landmark_name " DEBUG ", " TEST2 " +.DebugLevel5LandmarkName: level_selection_menu_landmark_name " DEBUG ", " TEST1 " endc MACRO level_selection_menu_landmark_transition diff --git a/engine/gfx/load_font.asm b/engine/gfx/load_font.asm index 1cad06e1d..e3201fad3 100644 --- a/engine/gfx/load_font.asm +++ b/engine/gfx/load_font.asm @@ -100,3 +100,29 @@ LoadStatsScreenPageTilesGFX: lb bc, BANK(StatsScreenPageTilesGFX), 17 call Get2bppViaHDMA ret + +LoadInversedFont:: + ld de, FontInversed + ld hl, vTiles1 + lb bc, BANK(FontInversed), 112 ; "A" to "9" + ldh a, [rLCDC] + bit rLCDC_ENABLE, a + jp z, Copy1bpp + + ld de, FontInversed + ld hl, vTiles1 + lb bc, BANK(FontInversed), 32 ; "A" to... + call Get1bppViaHDMA + ld de, FontInversed + 32 * LEN_1BPP_TILE + ld hl, vTiles1 tile $20 + lb bc, BANK(FontInversed), 32 + call Get1bppViaHDMA + ld de, FontInversed + 64 * LEN_1BPP_TILE + ld hl, vTiles1 tile $40 + lb bc, BANK(FontInversed), 32 + call Get1bppViaHDMA + ld de, FontInversed + 96 * LEN_1BPP_TILE + ld hl, vTiles1 tile $60 + lb bc, BANK(FontInversed), 16 ; ..."9" + call Get1bppViaHDMA + ret diff --git a/engine/menus/level_selection_menu.asm b/engine/menus/level_selection_menu.asm index a45a2837c..89e1df98e 100755 --- a/engine/menus/level_selection_menu.asm +++ b/engine/menus/level_selection_menu.asm @@ -40,6 +40,7 @@ LevelSelectionMenu:: ld a, [wLevelSelectionMenuCurrentLandmark] call LevelSelectionMenu_InitPlayerSprite call LevelSelectionMenu_InitLandmark + call LevelSelectionMenu_PrintLevelAndLandmarkName call LevelSelectionMenu_DrawDirectionalArrows .main_loop @@ -78,8 +79,8 @@ LevelSelectionMenu:: jr .start_movement .start_movement + ld e, c ; copy direction to e for later (for LevelSelectionMenu_SetAnimSeqAndFrameset) ; make hl point to the beginning of the transition data for the chosen direction at c - ld e, c ; also copy direction to e for later ld hl, wLevelSelectionMenuLandmarkTransitionsPointer ld a, [hli] ld h, [hl] @@ -93,8 +94,10 @@ LevelSelectionMenu:: ld a, h ld [bc], a -; begin transition +; clear textbox as we are about to move out of current landmark call LevelSelectionMenu_Delay10Frames + call LevelSelectionMenu_ClearTextbox ; preserves e +; begin transition xor a ; FALSE ld [wLevelSelectionMenuStandingStill], a ld a, 1 << 7 ; "first step of movement" flag @@ -114,8 +117,9 @@ LevelSelectionMenu:: jr z, .wait_transition_loop call LevelSelectionMenu_InitLandmark + call LevelSelectionMenu_PrintLevelAndLandmarkName call LevelSelectionMenu_DrawDirectionalArrows - jr .main_loop + jp .main_loop .enter_level ld a, [wLevelSelectionMenuCurrentLandmark] @@ -151,6 +155,8 @@ LevelSelectionMenu:: ret ; nc LevelSelectionMenu_LoadGFX: +; load inverted font + farcall LoadInversedFont ; load gfx for the background tiles, and for the player and directional arrow sprites ld hl, LevelSelectionMenuGFX ld de, vTiles2 @@ -262,6 +268,71 @@ endr ld [de], a ret +LevelSelectionMenu_PrintLevelAndLandmarkName: +; level indicator and level numbers are 8x16. +; botton half of their graphics are $10 tiles after the top half. + hlcoord LSMTEXTBOX_X_COORD, LSMTEXTBOX_Y_COORD + ld a, LSMTEXTBOX_LEVEL_INDICATOR_TILE + ld [hl], a + add $10 + ld bc, SCREEN_WIDTH + add hl, bc + ld [hl], a + ld a, [wLevelSelectionMenuCurrentLandmark] + ld e, a + ld d, 0 + ld hl, LandmarkToLevelTable + add hl, de + ld a, [hl] + ld c, 0 +.loop1 + ld e, a + sub 10 + jr c, .next1 + inc c + jr .loop1 +.next1 + ; c = first digit ; e = second digit + hlcoord LSMTEXTBOX_X_COORD + 1, LSMTEXTBOX_Y_COORD + ld a, LSMTEXTBOX_LEVEL_NUMBERS_FIRST_TILE + add c + ld [hli], a + ld a, LSMTEXTBOX_LEVEL_NUMBERS_FIRST_TILE + add e + ld [hl], a + hlcoord LSMTEXTBOX_X_COORD + 1, LSMTEXTBOX_Y_COORD + 1 + ld a, LSMTEXTBOX_LEVEL_NUMBERS_FIRST_TILE + $10 + add c + ld [hli], a + ld a, LSMTEXTBOX_LEVEL_NUMBERS_FIRST_TILE + $10 + add e + ld [hl], a + + call LevelSelectionMenu_GetLandmarkName + ld hl, wStringBuffer1 + decoord LSMTEXTBOX_X_COORD + 4, LSMTEXTBOX_Y_COORD + ld bc, LSMTEXTBOX_MAX_TEXT_ROW_LENGTH + call CopyBytes + ld hl, wStringBuffer2 + decoord LSMTEXTBOX_X_COORD + 4, LSMTEXTBOX_Y_COORD + 1 + ld bc, LSMTEXTBOX_MAX_TEXT_ROW_LENGTH + call CopyBytes + + call WaitBGMap + xor a + ld [hBGMapMode], a + ret + +LevelSelectionMenu_ClearTextbox: + hlcoord LSMTEXTBOX_X_COORD, LSMTEXTBOX_Y_COORD + ld a, LSMTEXTBOX_BLACK_TILE + lb bc, LSMTEXTBOX_HEIGHT, LSMTEXTBOX_WIDTH + call FillBoxWithByte + call WaitBGMap + xor a + ld [hBGMapMode], a + 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. @@ -499,7 +570,7 @@ LevelSelectionMenu_GetLandmarkCoords:: ret LevelSelectionMenu_GetLandmarkName:: -; Copy the name of landmark e to wStringBuffer1. +; Copy the name of landmark e to wStringBuffer1 (tow row) and wStringBuffer2 (bottom row). push hl push de push bc @@ -513,19 +584,25 @@ LevelSelectionMenu_GetLandmarkName:: ld l, a ld de, wStringBuffer1 - ld c, 18 -.copy - ld a, [hli] - ld [de], a - inc de - dec c - jr nz, .copy + call .copy + ld de, wStringBuffer2 + call .copy pop bc pop de pop hl ret +.copy + ld c, LSMTEXTBOX_MAX_TEXT_ROW_LENGTH +.copy_loop + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .copy_loop + ret + LevelSelectionMenu_GetLandmarkSpawnPoint: ; Return SPAWN_* (a) of landmark a. ld hl, LevelSelectionMenu_Landmarks + $5 diff --git a/gfx/level_selection_menu/background.png b/gfx/level_selection_menu/background.png index a73d71d6b..d78327d9f 100755 Binary files a/gfx/level_selection_menu/background.png and b/gfx/level_selection_menu/background.png differ diff --git a/gfx/level_selection_menu/page_1.tilemap b/gfx/level_selection_menu/page_1.tilemap index 6ac788b50..981f19111 100755 Binary files a/gfx/level_selection_menu/page_1.tilemap and b/gfx/level_selection_menu/page_1.tilemap differ diff --git a/gfx/level_selection_menu/page_2.tilemap b/gfx/level_selection_menu/page_2.tilemap index e9cec72a5..4f55ae9b9 100755 Binary files a/gfx/level_selection_menu/page_2.tilemap and b/gfx/level_selection_menu/page_2.tilemap differ diff --git a/gfx/level_selection_menu/page_3.tilemap b/gfx/level_selection_menu/page_3.tilemap index e9cec72a5..4f55ae9b9 100755 Binary files a/gfx/level_selection_menu/page_3.tilemap and b/gfx/level_selection_menu/page_3.tilemap differ diff --git a/gfx/level_selection_menu/page_4.tilemap b/gfx/level_selection_menu/page_4.tilemap index e9cec72a5..4f55ae9b9 100755 Binary files a/gfx/level_selection_menu/page_4.tilemap and b/gfx/level_selection_menu/page_4.tilemap differ