-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu_input.asm
146 lines (132 loc) · 2.53 KB
/
menu_input.asm
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
;Airaki! - FSE 2014
;Released under the GPL V3, see LICENSE.TXT
menu_input:
ld a,(JOYP_ACTIVE)
bit 0,a
jr z,+ ;Button A: go to next menu line
ld a,(MCURSOR_LINE)
cp 1
jp z,menu_exit
inc a
ld (MCURSOR_LINE),a
ld hl,sfxdata_menu
call sfx_play
+:
ld a,(JOYP_ACTIVE)
bit 1,a
jr z,+ ;Button B: go to previous menu line
ld a,(MCURSOR_LINE)
or a
jr z,+
dec a
ld (MCURSOR_LINE),a
ld hl,sfxdata_menu
call sfx_play
+:
ld a,(JOYP_ACTIVE)
bit 4,a ;Right
jr z,+
call mcur_getrange
ld b,a
call mcur_getvar
cp b
jr z,+
inc a
ld (hl),a
ld hl,sfxdata_menu
call sfx_play
+:
ld a,(JOYP_ACTIVE)
bit 5,a ;Left
jr z,+
call mcur_getvar
or a
jr z,+
dec a
ld (hl),a
ld hl,sfxdata_menu
call sfx_play
+:
ld a,(JOYP_ACTIVE)
bit 6,a ;Up
jr z,+
ld a,(MCURSOR_LINE)
or a
jr z,+
dec a
ld (MCURSOR_LINE),a
ld hl,sfxdata_menu
call sfx_play
+:
ld a,(JOYP_ACTIVE)
bit 7,a ;Down
jr z,+
ld a,(MCURSOR_LINE)
cp 1
jr z,+
inc a
ld (MCURSOR_LINE),a
ld hl,sfxdata_menu
call sfx_play
+:
ld a,(JOYP_ACTIVE) ;Start
bit 3,a
call nz,menu_exit
ret
mcur_getrange:
ld hl,mcur_range_lut
ld a,(MCURSOR_LINE)
ld c,a
sla a
add c ;*3
rst 0
ld a,(hl)
ret
mcur_getvar:
ld hl,mcur_range_lut+1
ld a,(MCURSOR_LINE)
ld c,a
sla a
add c ;*3
rst 0
ldi a,(hl)
ld h,(hl)
ld l,a
ld a,(hl)
ret
mcur_range_lut:
.db 1
.dw MCURSOR_PSEL
.db 2
.dw MCURSOR_SSEL
menu_exit:
;Copy special skill to game variable
ld a,(MCURSOR_SSEL)
ld (PLAYER_SS),a
xor a
ld (LINK_FIELD),a
ld a,(MCURSOR_PSEL)
sla a
sla a
ld hl,menu_gs_lut
ld d,0
ld e,a
add hl,de
ldi a,(hl)
ld (GAME_MODE),a
ldi a,(hl)
ld (GAME_LIVES),a
ldi a,(hl)
ld h,(hl)
ld l,a
jp hl
;PSEL MSEL GAME_MODE,Lives,jumpto
;00 1P 1life
;01 1P 3lives
;10 2P 1life
;11 2P 3lives
menu_gs_lut:
.db 0,4
.dw game_setup
.db 1,1
.dw link_setup