diff --git a/constants/menu_constants.asm b/constants/menu_constants.asm index 954a3783a..a037e2861 100644 --- a/constants/menu_constants.asm +++ b/constants/menu_constants.asm @@ -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 \ No newline at end of file diff --git a/constants/sprite_data_constants.asm b/constants/sprite_data_constants.asm index a7dc809b5..2bab7abf3 100644 --- a/constants/sprite_data_constants.asm +++ b/constants/sprite_data_constants.asm @@ -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 diff --git a/engine/board/menu.asm b/engine/board/menu.asm new file mode 100755 index 000000000..81e2e3b8e --- /dev/null +++ b/engine/board/menu.asm @@ -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" diff --git a/engine/gfx/load_board_gfx.asm b/engine/gfx/load_board_gfx.asm new file mode 100755 index 000000000..c932a53b3 --- /dev/null +++ b/engine/gfx/load_board_gfx.asm @@ -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 diff --git a/engine/gfx/overworld_textbox.asm b/engine/gfx/overworld_textbox.asm index f513af646..5f27386a2 100755 --- a/engine/gfx/overworld_textbox.asm +++ b/engine/gfx/overworld_textbox.asm @@ -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. diff --git a/engine/menus/start_menu.asm b/engine/menus/start_menu.asm index 6d9ceb60e..30339c5c6 100644 --- a/engine/menus/start_menu.asm +++ b/engine/menus/start_menu.asm @@ -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 diff --git a/gfx/board/menu.pal b/gfx/board/menu.pal new file mode 100755 index 000000000..980d2d7dd --- /dev/null +++ b/gfx/board/menu.pal @@ -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 diff --git a/gfx/board/menu.png b/gfx/board/menu.png new file mode 100755 index 000000000..1f6f71c1f Binary files /dev/null and b/gfx/board/menu.png differ diff --git a/gfx/board/menu_bag.png b/gfx/board/menu_bag.png new file mode 100755 index 000000000..2bc7bce7e Binary files /dev/null and b/gfx/board/menu_bag.png differ diff --git a/gfx/board/menu_die.png b/gfx/board/menu_die.png new file mode 100755 index 000000000..2b8e797c9 Binary files /dev/null and b/gfx/board/menu_die.png differ diff --git a/gfx/board/menu_exit.png b/gfx/board/menu_exit.png new file mode 100755 index 000000000..30c2e8497 Binary files /dev/null and b/gfx/board/menu_exit.png differ diff --git a/gfx/board/menu_pokegear.png b/gfx/board/menu_pokegear.png new file mode 100755 index 000000000..e428af416 Binary files /dev/null and b/gfx/board/menu_pokegear.png differ diff --git a/gfx/board/menu_pokemon.png b/gfx/board/menu_pokemon.png new file mode 100755 index 000000000..274bd846d Binary files /dev/null and b/gfx/board/menu_pokemon.png differ diff --git a/home/text.asm b/home/text.asm index 7c7dfa466..56e1e9373 100644 --- a/home/text.asm +++ b/home/text.asm @@ -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. diff --git a/layout.link b/layout.link index 804d10b6b..f0a726790 100644 --- a/layout.link +++ b/layout.link @@ -79,6 +79,8 @@ ROMX $14 "Unused Egg Pic" ROMX $15 "Map Scripts 1" +ROMX $1e + "Board 1" ROMX $20 "bank20" ROMX $21 diff --git a/main.asm b/main.asm index 9cb58308a..e69442495 100644 --- a/main.asm +++ b/main.asm @@ -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 diff --git a/maps/Level1_Map1.asm b/maps/Level1_Map1.asm index 031de2b3d..abb98a08b 100755 --- a/maps/Level1_Map1.asm +++ b/maps/Level1_Map1.asm @@ -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: @@ -132,4 +137,4 @@ Level1_Map1_MapEvents: object_event 4, 4, SPRITE_DOLL_1, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, PlayersHouseDoll1Script, -1 object_event 5, 4, SPRITE_DOLL_2, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, PlayersHouseDoll2Script, -1 object_event 0, 1, SPRITE_BIG_DOLL, SPRITEMOVEDATA_BIGDOLL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, PlayersHouseBigDollScript, -1 - object_event 6, 6, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 1, TrainerYoungsterMikey, -1 \ No newline at end of file + object_event 6, 6, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 1, TrainerYoungsterMikey, -1 diff --git a/ram/wram.asm b/ram/wram.asm index d119f78db..f877c4730 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -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)