You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
Board menu (#11) [Commit 1]
This commit is contained in:
74
engine/board/menu.asm
Executable file
74
engine/board/menu.asm
Executable file
@@ -0,0 +1,74 @@
|
||||
DEF BOARD_MENU_BG_FIRST_TILE EQU "A"
|
||||
DEF BOARD_MENU_OAM_FIRST_TILE EQU BOARD_MENU_BG_FIRST_TILE + 18 * 3
|
||||
|
||||
BoardMenu::
|
||||
; returns the selected menu item (BOARDMENUITEM_*) in wScriptVar upon exit
|
||||
ld a, [wBoardMenuLastCursorPosition]
|
||||
ld [wBoardMenuCursorPosition], a
|
||||
farcall LoadBoardMenuGFX
|
||||
call DrawBoardMenuTiles
|
||||
call ApplyTilemap
|
||||
call UpdateSprites
|
||||
; draw board menu OAM after overworld sprites
|
||||
call DrawBoardMenuOAM
|
||||
|
||||
.loop
|
||||
call GetBoardMenuSelection
|
||||
jr c, .done
|
||||
ld hl, wBoardMenuCursorPosition
|
||||
ld a, [wBoardMenuLastCursorPosition]
|
||||
cp [hl]
|
||||
jr z, .loop
|
||||
|
||||
; menu item change: refresh board menu OAM and save cursor position
|
||||
call DrawBoardMenuOAM
|
||||
ld a, [wBoardMenuCursorPosition]
|
||||
ld [wBoardMenuLastCursorPosition], a
|
||||
jr .loop
|
||||
|
||||
.done
|
||||
ld a, [wBoardMenuCursorPosition]
|
||||
ld [wScriptVar], a
|
||||
ret
|
||||
|
||||
DrawBoardMenuTiles:
|
||||
hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY
|
||||
ld a, BOARD_MENU_BG_FIRST_TILE
|
||||
lb bc, 3, 18
|
||||
jp FillBoxWithConsecutiveBytes
|
||||
|
||||
DrawBoardMenuOAM:
|
||||
ld hl, BoardMenuItemPals
|
||||
ld a, [wBoardMenuLastCursorPosition]
|
||||
ld bc, PALETTE_SIZE
|
||||
call AddNTimes
|
||||
; set wOBPals2 directly rather than wOBPals1 to avoid calling ApplyPals and overwriting other overworld pals
|
||||
ld de, wOBPals2 palette PAL_OW_MISC
|
||||
ld bc, PALETTE_SIZE
|
||||
ld a, BANK(wOBPals2)
|
||||
call FarCopyWRAM
|
||||
|
||||
ld hl, .OAM
|
||||
ld a, [wBoardMenuCursorPosition]
|
||||
ld bc, 3 * 3 * SPRITEOAMSTRUCT_LENGTH
|
||||
call AddNTimes
|
||||
; find the beginning of free space in OAM, and assure there's space for 3 * 3 objects
|
||||
ldh a, [hUsedSpriteIndex]
|
||||
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (3 * 3 * SPRITEOAMSTRUCT_LENGTH)
|
||||
jr nc, .oam_full
|
||||
; copy the sprite data (3 * 3 objects) of that item to the available space in OAM
|
||||
ld e, a
|
||||
ld d, HIGH(wShadowOAM)
|
||||
ld bc, 3 * 3 * SPRITEOAMSTRUCT_LENGTH
|
||||
call CopyBytes
|
||||
.oam_full
|
||||
ret
|
||||
|
||||
.OAM:
|
||||
|
||||
GetBoardMenuSelection:
|
||||
scf
|
||||
ret
|
||||
|
||||
BoardMenuItemPals:
|
||||
INCLUDE "gfx/board/menu.pal"
|
22
engine/gfx/load_board_gfx.asm
Executable file
22
engine/gfx/load_board_gfx.asm
Executable file
@@ -0,0 +1,22 @@
|
||||
LoadBoardMenuGFX::
|
||||
ld de, .BoardMenuGFX
|
||||
ld hl, vTiles1
|
||||
lb bc, BANK(.BoardMenuGFX), 18 * 3
|
||||
call Get2bppViaHDMA
|
||||
ld de, .BoardMenuOAMGFX
|
||||
ld hl, vTiles1 + (18 * 3) * LEN_2BPP_TILE
|
||||
lb bc, BANK(.BoardMenuOAMGFX), 3 * 3 * NUM_BOARD_MENU_ITEMS
|
||||
call Get2bppViaHDMA
|
||||
ret
|
||||
|
||||
.BoardMenuGFX:
|
||||
INCBIN "gfx/board/menu.2bpp"
|
||||
|
||||
.BoardMenuOAMGFX:
|
||||
table_width 3 * 3 * LEN_2BPP_TILE, .BoardMenuOAMGFX
|
||||
INCBIN "gfx/board/menu_die.2bpp"
|
||||
INCBIN "gfx/board/menu_pokemon.2bpp"
|
||||
INCBIN "gfx/board/menu_bag.2bpp"
|
||||
INCBIN "gfx/board/menu_pokegear.2bpp"
|
||||
INCBIN "gfx/board/menu_exit.2bpp"
|
||||
assert_table_length NUM_BOARD_MENU_ITEMS
|
@@ -14,8 +14,8 @@
|
||||
const OW_TEXTBOX_FRAME_RIGHT_2
|
||||
const OW_TEXTBOX_FRAME_BACKGROUND
|
||||
|
||||
OW_TEXTBOX_FRAME_MIN_HEIGHT EQU 4
|
||||
OW_TEXTBOX_FRAME_MIN_WIDTH EQU 6
|
||||
DEF OW_TEXTBOX_FRAME_MIN_HEIGHT EQU 4
|
||||
DEF OW_TEXTBOX_FRAME_MIN_WIDTH EQU 6
|
||||
|
||||
_OverworldTextbox::
|
||||
; Draw a textbox at de with room for b rows and c columns using the 2bpp overworld frame tiles.
|
||||
|
@@ -27,7 +27,7 @@ StartMenu::
|
||||
.GotMenuData:
|
||||
call LoadMenuHeader
|
||||
call .SetUpMenuItems
|
||||
ld a, [wBattleMenuCursorPosition]
|
||||
ld a, [wStartMenuLastCursorPosition]
|
||||
ld [wMenuCursorPosition], a
|
||||
call .DrawMenuAccount
|
||||
call DrawVariableLengthMenuBox
|
||||
@@ -43,7 +43,7 @@ StartMenu::
|
||||
call UpdateSprites
|
||||
call UpdateTimePals
|
||||
call .SetUpMenuItems
|
||||
ld a, [wBattleMenuCursorPosition]
|
||||
ld a, [wStartMenuLastCursorPosition]
|
||||
ld [wMenuCursorPosition], a
|
||||
|
||||
.Select:
|
||||
@@ -51,7 +51,7 @@ StartMenu::
|
||||
jr c, .Exit
|
||||
call ._DrawMenuAccount
|
||||
ld a, [wMenuCursorPosition]
|
||||
ld [wBattleMenuCursorPosition], a
|
||||
ld [wStartMenuLastCursorPosition], a
|
||||
call PlayClickSFX
|
||||
call PlaceHollowCursor
|
||||
call .OpenMenu
|
||||
|
Reference in New Issue
Block a user