Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/menus/draw_start_menu.asm
1271 views
1
; function that displays the start menu
2
DrawStartMenu::
3
CheckEvent EVENT_GOT_POKEDEX
4
; menu with pokedex
5
hlcoord 10, 0
6
ld b, $0e
7
ld c, $08
8
jr nz, .drawTextBoxBorder
9
; shorter menu if the player doesn't have the pokedex
10
hlcoord 10, 0
11
ld b, $0c
12
ld c, $08
13
.drawTextBoxBorder
14
call TextBoxBorder
15
ld a, PAD_DOWN | PAD_UP | PAD_START | PAD_B | PAD_A
16
ld [wMenuWatchedKeys], a
17
ld a, $02
18
ld [wTopMenuItemY], a ; Y position of first menu choice
19
ld a, $0b
20
ld [wTopMenuItemX], a ; X position of first menu choice
21
ld a, [wBattleAndStartSavedMenuItem] ; remembered menu selection from last time
22
ld [wCurrentMenuItem], a
23
ld [wLastMenuItem], a
24
xor a
25
ld [wMenuWatchMovingOutOfBounds], a
26
ld hl, wStatusFlags5
27
set BIT_NO_TEXT_DELAY, [hl]
28
hlcoord 12, 2
29
CheckEvent EVENT_GOT_POKEDEX
30
; case for not having pokedex
31
ld a, $06
32
jr z, .storeMenuItemCount
33
; case for having pokedex
34
ld de, StartMenuPokedexText
35
call PrintStartMenuItem
36
ld a, $07
37
.storeMenuItemCount
38
ld [wMaxMenuItem], a ; number of menu items
39
ld de, StartMenuPokemonText
40
call PrintStartMenuItem
41
ld de, StartMenuItemText
42
call PrintStartMenuItem
43
ld de, wPlayerName ; player's name
44
call PrintStartMenuItem
45
ld a, [wStatusFlags4]
46
bit BIT_LINK_CONNECTED, a
47
; case for not using link feature
48
ld de, StartMenuSaveText
49
jr z, .printSaveOrResetText
50
; case for using link feature
51
ld de, StartMenuResetText
52
.printSaveOrResetText
53
call PrintStartMenuItem
54
ld de, StartMenuOptionText
55
call PrintStartMenuItem
56
ld de, StartMenuExitText
57
call PlaceString
58
ld hl, wStatusFlags5
59
res BIT_NO_TEXT_DELAY, [hl]
60
ret
61
62
StartMenuPokedexText:
63
db "POKéDEX@"
64
65
StartMenuPokemonText:
66
db "POKéMON@"
67
68
StartMenuItemText:
69
db "ITEM@"
70
71
StartMenuSaveText:
72
db "SAVE@"
73
74
StartMenuResetText:
75
db "RESET@"
76
77
StartMenuExitText:
78
db "EXIT@"
79
80
StartMenuOptionText:
81
db "OPTION@"
82
83
PrintStartMenuItem:
84
push hl
85
call PlaceString
86
pop hl
87
ld de, SCREEN_WIDTH * 2
88
add hl, de
89
ret
90
91