Board menu (#11) [Commit 1]

This commit is contained in:
xCrystal 2023-08-14 20:09:23 +02:00
parent c405c955ba
commit 1f33436a64
18 changed files with 179 additions and 8 deletions

View File

@ -111,3 +111,12 @@ DEF NUM_PARTYMENUACTIONS EQU const_value
const NAME_6 ; duplicate of NAME_MON
const NAME_7 ; duplicate of NAME_MON
DEF NUM_NAME_TYPES EQU const_value
; Board menu items (see engine/board/menu.asm)
const_def
const BOARDMENUITEM_DIE
const BOARDMENUITEM_POKEMON
const BOARDMENUITEM_BAG
const BOARDMENUITEM_POKEGEAR
const BOARDMENUITEM_EXIT
DEF NUM_BOARD_MENU_ITEMS EQU const_value

View File

@ -19,7 +19,7 @@ DEF NUM_SPRITEDATA_FIELDS EQU _RS
const PAL_OW_BLUE ; 1
const PAL_OW_GREEN ; 2
const PAL_OW_BROWN ; 3
const PAL_OW_PINK ; 4
const PAL_OW_MISC ; 4
const PAL_OW_EMOTE ; 5
const PAL_OW_TREE ; 6
const PAL_OW_ROCK ; 7

74
engine/board/menu.asm Executable file
View 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
View 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

View File

@ -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.

View File

@ -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

29
gfx/board/menu.pal Executable file
View File

@ -0,0 +1,29 @@
; item 1 (BOARDMENUITEM_DIE)
RGB 31, 31, 31
RGB 10, 10, 31
RGB 00, 00, 21
RGB 00, 00, 00
; item 2 (BOARDMENUITEM_POKEMON)
RGB 31, 31, 31
RGB 31, 26, 26
RGB 30, 00, 00
RGB 00, 00, 00
; item 3 (BOARDMENUITEM_BAG)
RGB 31, 31, 31
RGB 10, 31, 10
RGB 00, 21, 10
RGB 00, 00, 00
; item 4 (BOARDMENUITEM_POKEGEAR)
RGB 31, 31, 31
RGB 21, 21, 09
RGB 11, 11, 00
RGB 00, 00, 00
; item 5 (BOARDMENUITEM_EXIT)
RGB 31, 31, 31
RGB 20, 20, 00
RGB 10, 10, 00
RGB 00, 00, 00

BIN
gfx/board/menu.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

BIN
gfx/board/menu_bag.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

BIN
gfx/board/menu_die.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

BIN
gfx/board/menu_exit.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

BIN
gfx/board/menu_pokegear.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

BIN
gfx/board/menu_pokemon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

View File

@ -19,6 +19,23 @@ FillBoxWithByte::
jr nz, .row
ret
FillBoxWithConsecutiveBytes::
.row
push bc
push hl
.col
ld [hli], a
inc a
dec c
jr nz, .col
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
pop bc
dec b
jr nz, .row
ret
ClearTilemap::
; Fill wTilemap with blank tiles.

View File

@ -79,6 +79,8 @@ ROMX $14
"Unused Egg Pic"
ROMX $15
"Map Scripts 1"
ROMX $1e
"Board 1"
ROMX $20
"bank20"
ROMX $21

View File

@ -232,6 +232,10 @@ INCLUDE "data/pokemon/base_stats.asm"
INCLUDE "data/pokemon/names.asm"
INCLUDE "data/pokemon/unused_pic_banks.asm"
SECTION "Board 1", ROMX
INCLUDE "engine/board/menu.asm"
SECTION "bank20", ROMX
@ -386,6 +390,7 @@ INCLUDE "engine/overworld/warp_connection.asm"
INCLUDE "engine/battle/used_move_text.asm"
INCLUDE "engine/gfx/load_overworld_font.asm"
INCLUDE "engine/gfx/overworld_textbox.asm"
INCLUDE "engine/gfx/load_board_gfx.asm"
SECTION "Title", ROMX

View File

@ -12,9 +12,14 @@ Level1_Map1_MapScripts:
PlayersHouseDoll1Script::
opentext
callasm .BoardMenu
waitbutton
pokemart MARTTYPE_STANDARD, MART_AZALEA
closetext
end
.BoardMenu:
farcall BoardMenu
ret
; describedecoration DECODESC_LEFT_DOLL
PlayersHouseDoll2Script:

View File

@ -1160,6 +1160,11 @@ wMenuData_ItemsPointerAddr:: dw
wMenuData_ScrollingMenuFunction1:: ds 3
wMenuData_ScrollingMenuFunction2:: ds 3
wMenuData_ScrollingMenuFunction3:: ds 3
NEXTU
; Board Menu
wBoardMenuCursorPosition:: db
ENDU
wMenuDataEnd::
@ -1663,7 +1668,10 @@ wStringBuffer3:: ds STRING_BUFFER_LENGTH
wStringBuffer4:: ds STRING_BUFFER_LENGTH
wStringBuffer5:: ds STRING_BUFFER_LENGTH
wBattleMenuCursorPosition:: db
wBattleMenuCursorPosition::
wStartMenuLastCursorPosition::
wBoardMenuLastCursorPosition::
db
wCurBattleMon::
; index of the player's mon currently in battle (0-5)