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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
InitMovementBuffer:: ; 1b1e
ld [wMovementBufferPerson], a
xor a
ld [wMovementBufferCount], a
ld a, $0 ; useless
ld [wd004], a
ld a, MovementBuffer % $100
ld [wd005], a
ld a, MovementBuffer / $100
ld [wd006], a
ret
; 1b35
DecrementMovementBufferCount:: ; 1b35
ld a, [wMovementBufferCount]
and a
ret z
dec a
ld [wMovementBufferCount], a
ret
; 1b3f
AppendToMovementBuffer:: ; 1b3f
push hl
push de
ld hl, wMovementBufferCount
ld e, [hl]
inc [hl]
ld d, 0
ld hl, MovementBuffer
add hl, de
ld [hl], a
pop de
pop hl
ret
; 1b50
AppendToMovementBufferNTimes:: ; 1b50
push af
ld a, c
and a
jr nz, .okay
pop af
ret
.okay
pop af
.loop
call AppendToMovementBuffer
dec c
jr nz, .loop
ret
; 1b5f
ComputePathToWalkToPlayer:: ; 1b5f
push af
; compare x coords, load left/right into h, and x distance into d
ld a, b
sub d
ld h, LEFT
jr nc, .got_x_distance
dec a
cpl
ld h, RIGHT
.got_x_distance
ld d, a
; compare y coords, load up/down into l, and y distance into e
ld a, c
sub e
ld l, UP
jr nc, .got_y_distance
dec a
cpl
ld l, DOWN
.got_y_distance
ld e, a
; if the x distance is less than the y distance, swap h and l, and swap d and e
cp d
jr nc, .done
ld a, h
ld h, l
ld l, a
ld a, d
ld d, e
ld e, a
.done
pop af
ld b, a
; Add movement in the longer direction first...
ld a, h
call .GetMovementData
ld c, d
call AppendToMovementBufferNTimes
; ... then add the shorter direction.
ld a, l
call .GetMovementData
ld c, e
call AppendToMovementBufferNTimes
ret
; 1b92
.GetMovementData: ; 1b92
push de
push hl
ld l, b
ld h, 0
rept 2
add hl, hl
endr
ld e, a
ld d, 0
add hl, de
ld de, .MovementData
add hl, de
ld a, [hl]
pop hl
pop de
ret
; 1ba5
.MovementData:
slow_step_down
slow_step_up
slow_step_left
slow_step_right
step_down
step_up
step_left
step_right
big_step_down
big_step_up
big_step_left
big_step_right
; 1bb1
SetMenuAttributes:: ; 1bb1
push hl
push bc
ld hl, w2DMenuCursorInitY
ld b, $8
.loop
ld a, [de]
inc de
ld [hli], a
dec b
jr nz, .loop
ld a, $1
rept 2
ld [hli], a
endr
xor a
rept 3
ld [hli], a
endr
pop bc
pop hl
ret
; 1bc9
StaticMenuJoypad:: ; 1bc9
callab _StaticMenuJoypad
call GetMenuJoypad
ret
; 1bd3
ScrollingMenuJoypad:: ; 1bd3
callab _ScrollingMenuJoypad
call GetMenuJoypad
ret
; 1bdd
GetMenuJoypad:: ; 1bdd
push bc
push af
ld a, [hJoyLast]
and D_PAD
ld b, a
ld a, [hJoyPressed]
and BUTTONS
or b
ld b, a
pop af
ld a, b
pop bc
ret
; 1bee
PlaceHollowCursor:: ; 1bee
ld hl, wCursorCurrentTile
ld a, [hli]
ld h, [hl]
ld l, a
ld [hl], "▷"
ret
; 1bf7
HideCursor:: ; 1bf7
ld hl, wCursorCurrentTile
ld a, [hli]
ld h, [hl]
ld l, a
ld [hl], " "
ret
; 1c00
|