Level selection menu: init screen and bg layout, and preliminary landmarks data (#12)

This commit is contained in:
xCrystal 2023-08-19 19:45:43 +02:00
parent fe4b54cece
commit 222b46896c
3 changed files with 143 additions and 0 deletions

31
data/level_selection_menu.asm Executable file
View File

@ -0,0 +1,31 @@
; TILE_WIDTH represents the top/left border tile, $8/$10 represent the OAM screen position offsets, and 10 are custom offsets
DEF LEVELSELECTIONMENU_LANDMARK_OFFSET_X EQU TILE_WIDTH + $8 + 10
DEF LEVELSELECTIONMENU_LANDMARK_OFFSET_Y EQU TILE_WIDTH + $10 + 10
MACRO level_selection_menu_landmark
; page number, xcoord (in tiles), ycoord (in tiles), ptr to name, spawn point (SPAWN_*)
db \1
db LEVELSELECTIONMENU_LANDMARK_OFFSET_X + \2 * TILE_WIDTH
db LEVELSELECTIONMENU_LANDMARK_OFFSET_Y + \3 * TILE_WIDTH
dw \4
db \5
ENDM
LevelSelectionMenu_Landmarks:
.landmark1
level_selection_menu_landmark 0, 16, 11, DefaultLandmarkName, SPAWN_LEVEL_1
.landmark2
level_selection_menu_landmark 0, 11, 9, DefaultLandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 0, 9, 11, DefaultLandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 1, 16, 11, DefaultLandmarkName, SPAWN_LEVEL_1
level_selection_menu_landmark 2, 9, 5, DefaultLandmarkName, SPAWN_LEVEL_1
LevelSelectionMenu_PageGrid:
db -1, -1, -1, -1
db -1, 2, 3, -1
db -1, 0, 1, -1
db -1, -1, -1, -1
DEF LEVELSELECTIONMENU_PAGE_GRID_WIDTH EQU 4
DefaultLandmarkName: db "LANDMARK NAME@"

View File

@ -1,3 +1,108 @@
LevelSelectionMenu::
ldh a, [hInMenu]
push af
xor a
ldh [hInMenu], a
xor a
ld [wVramState], a
call ClearBGPalettes
call ClearTilemap
call ClearSprites
ld de, MUSIC_NONE
call PlayMusic
call DelayFrame
call DisableLCD
call LevelSelectionMenu_LoadGFX
farcall ClearSpriteAnims
ld a, LCDC_DEFAULT
ldh [rLCDC], a
xor a
ld [wLevelSelectionMenuCurrentLandmark], a
call LevelSelectionMenu_GetLandmarkPage
ld [wLevelSelectionMenuCurrentPage], a
call LevelSelectionMenu_InitTilemap
ld b, CGB_LEVEL_SELECTION_MENU
call GetCGBLayout
call SetPalettes
ld de, MUSIC_GAME_CORNER
call PlayMusic
.loop
call DelayFrame
jr .loop
pop af
ldh [hInMenu], a
ret
LevelSelectionMenu_LoadGFX:
ld hl, LevelSelectionMenuGFX
ld de, vTiles2
call Decompress
farcall GetPlayerIcon
ld h, d
ld l, e
ld a, b
ld de, vTiles0
ld bc, 24 tiles
call FarCopyBytes
ret
LevelSelectionMenu_InitTilemap:
; init tilemap of page at wLevelSelectionMenuCurrentPage
ld hl, .Tilemaps
ld bc, 2
ld a, [wLevelSelectionMenuCurrentPage]
call AddNTimes
ld e, [hl]
inc hl
ld d, [hl]
hlcoord 0, 0
.loop
ld a, [de]
cp $ff ; tilemaps are $ff-terminated
jp z, WaitBGMap2 ; takes 8 frames to commit tilemap and attrmap
ld a, [de]
ld [hli], a
inc de
jr .loop
.Tilemaps:
dw LevelSelectionMenuPage1Tilemap
dw LevelSelectionMenuPage2Tilemap
dw LevelSelectionMenuPage3Tilemap
dw LevelSelectionMenuPage4Tilemap
LevelSelectionMenu_GetLandmarkPage:
; Return page number (a) of landmark a.
push hl
ld hl, LevelSelectionMenu_Landmarks
ld bc, LevelSelectionMenu_Landmarks.landmark2 - LevelSelectionMenu_Landmarks.landmark1
call AddNTimes
ld a, [hl]
pop hl
ret
LevelSelectionMenu_GetLandmarkCoords:
; Return coordinates (d, e) of landmark e.
push hl
push bc
ld hl, LevelSelectionMenu_Landmarks + $1
ld bc, LevelSelectionMenu_Landmarks.landmark2 - LevelSelectionMenu_Landmarks.landmark1
ld a, e
call AddNTimes
ld a, [hli]
ld e, a
ld d, [hl]
pop bc
pop hl
ret
INCLUDE "data/level_selection_menu.asm"
LevelSelectionMenuGFX:
INCBIN "gfx/level_selection_menu/background.2bpp.lz"

View File

@ -1531,6 +1531,13 @@ wDebugColorIsShiny:: db
wDebugColorCurTMHM:: db
SECTION UNION "Miscellaneous WRAM 1", WRAMX
; level selection menu
wLevelSelectionMenuCurrentPage:: db
wLevelSelectionMenuCurrentLandmark:: db
SECTION UNION "Miscellaneous WRAM 1", WRAMX
; Every previous SECTION UNION takes up 60 or fewer bytes,