aboutsummaryrefslogtreecommitdiffstats
path: root/engine/warp_menu.asm
blob: 1fcca73e01fc0f96945a44d7e5de1570712fcfc2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
; Quick-warp menu, opened with SELECT in the overworld (hooked in
; home/overworld.asm). Hides the overworld sprites, clears the screen, and draws
; a single-spaced destination list. On selection it reuses the fly-warp
; machinery (wDestinationMap + BIT_FLY_WARP) to warp in at the destination's
; fly coordinates. BIT_USED_FLY is deliberately NOT set, so arrival uses the
; teleport-in animation (the departure bird is redirected to a plain fade in
; engine/overworld/player_animations.asm).

DEF WARP_COUNT EQU 13

SECTION "Warp Menu", ROMX

WarpMenu::
; single-space the list text (<NEXT> = 1 row) and the menu cursor
	ldh a, [hUILayoutFlags]
	set BIT_SINGLE_SPACED_LINES, a
	set BIT_DOUBLE_SPACED_MENU, a
	ldh [hUILayoutFlags], a
; hide the overworld sprites so nothing shows behind the menu
	ld a, $ff
	ld [wUpdateSpritesEnabled], a
	call ClearSprites
	call ClearScreen
; banner, two centered lines above the box
	hlcoord 4, 0
	ld de, WarpTitleText1
	call PlaceString
	hlcoord 5, 1
	ld de, WarpTitleText2
	call PlaceString
; horizontally-centered menu box (screen is 20 wide; box is 13)
	hlcoord 3, 2
	lb bc, 13, 11
	call TextBoxBorder
	hlcoord 5, 3
	ld de, WarpMenuText
	call PlaceString
; push wTileMap to VRAM and switch on the menu display (mirrors the tail of
; DisplayTextIDInit); the overworld renders the scrolled map straight to VRAM,
; so our box drawn into wTileMap would otherwise be invisible.
	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
	ld a, 4
	ld [wTopMenuItemX], a              ; cursor column (text at column 5)
	ld a, 3
	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
	push af                            ; save pressed keys
	ldh a, [hUILayoutFlags]            ; restore default UI spacing
	res BIT_SINGLE_SPACED_LINES, a
	res BIT_DOUBLE_SPACED_MENU, a
	ldh [hUILayoutFlags], a
	pop af
	bit B_PAD_B, a
	jr nz, .cancel
; A pressed: look up the chosen map id and fire the fly-warp (no BIT_USED_FLY)
	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]
	ret                                ; overworld loop performs the warp
.cancel
	ld a, $01
	ld [wUpdateSpritesEnabled], a      ; re-enable overworld sprites
	call LoadScreenTilesFromBuffer2
	jp CloseTextDisplay                ; redraw the overworld and return

WarpMenuText:
	db   "PALLET"
	next "VIRIDIAN"
	next "PEWTER"
	next "CERULEAN"
	next "LAVENDER"
	next "VERMILION"
	next "CELADON"
	next "FUCHSIA"
	next "CINNABAR"
	next "INDIGO"
	next "SAFFRON"
	next "ROUTE 4"
	next "ROUTE 10@"

WarpMapTable:
	db PALLET_TOWN, VIRIDIAN_CITY, PEWTER_CITY, CERULEAN_CITY, LAVENDER_TOWN
	db VERMILION_CITY, CELADON_CITY, FUCHSIA_CITY, CINNABAR_ISLAND, INDIGO_PLATEAU
	db SAFFRON_CITY, ROUTE_4, ROUTE_10

WarpTitleText1:
	db "SECRET SL0P@"
WarpTitleText2:
	db "WARP MENU@"