diff options
| -rw-r--r-- | engine/warp_menu.asm | 70 |
1 files changed, 64 insertions, 6 deletions
diff --git a/engine/warp_menu.asm b/engine/warp_menu.asm index 17cc3904..d31aba45 100644 --- a/engine/warp_menu.asm +++ b/engine/warp_menu.asm @@ -1,17 +1,75 @@ ; Quick-warp menu, opened with SELECT in the overworld (hooked in -; home/overworld.asm). Reuses the game's fly-warp machinery: set the -; destination map and the fly-warp flags, then return to the overworld loop, -; which fades out and warps us in at the destination's fly coordinates. +; home/overworld.asm). Draws a town list, and on selection reuses the game's +; fly-warp machinery (wDestinationMap + BIT_FLY_WARP/BIT_USED_FLY); the +; overworld loop then fades out and warps us in at the destination fly coords. + +DEF WARP_COUNT EQU 10 SECTION "Warp Menu", ROMX WarpMenu:: -; B1 (pipeline validation): unconditionally warp to Pallet Town. - ld a, PALLET_TOWN + call SaveScreenTilesToBuffer2 ; stash the overworld so we can restore + hlcoord 0, 0 + lb bc, 11, 11 + call TextBoxBorder + hlcoord 2, 1 + ld de, WarpMenuText + call PlaceString +; push wTileMap to VRAM and switch on the menu/window display (the overworld +; renders the scrolled map straight to VRAM, so without this our box drawn into +; wTileMap would be invisible - mirrors the tail of DisplayTextIDInit) + ld b, HIGH(vBGMap1) + call CopyScreenTileBufferToVRAM + xor a + ldh [hWY], a + call LoadFontTilePatterns + ld a, $01 + ldh [hAutoBGTransferEnabled], a + xor a + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a + ld [wMenuWatchMovingOutOfBounds], a + ld [wMenuJoypadPollCount], a + inc a ; 1 + ld [wTopMenuItemX], a ; cursor column (text is at column 2) + ld [wTopMenuItemY], a ; first item row + ld a, PAD_A | PAD_B + ld [wMenuWatchedKeys], a + ld a, WARP_COUNT - 1 + ld [wMaxMenuItem], a + call HandleMenuInput + bit B_PAD_B, a + jr nz, .cancel +; A pressed: look up the chosen map id and fire the fly-warp + ld a, [wCurrentMenuItem] + ld e, a + ld d, 0 + ld hl, WarpMapTable + add hl, de + ld a, [hl] ld [wDestinationMap], a ld hl, wStatusFlags6 set BIT_FLY_WARP, [hl] ASSERT wStatusFlags6 + 1 == wStatusFlags7 inc hl set BIT_USED_FLY, [hl] - ret + ret ; overworld loop performs the warp +.cancel + call LoadScreenTilesFromBuffer2 + jp CloseTextDisplay ; redraw the overworld and return + +WarpMenuText: + db "PALLET" + next "VIRIDIAN" + next "PEWTER" + next "CERULEAN" + next "VERMILION" + next "CELADON" + next "FUCHSIA" + next "SAFFRON" + next "CINNABAR" + next "INDIGO@" + +WarpMapTable: + db PALLET_TOWN, VIRIDIAN_CITY, PEWTER_CITY, CERULEAN_CITY, VERMILION_CITY + db CELADON_CITY, FUCHSIA_CITY, SAFFRON_CITY, CINNABAR_ISLAND, INDIGO_PLATEAU |
