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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
#include "global.h"
#include "asm.h"
#include "field_player_avatar.h"
#include "metatile_behavior.h"
#include "rom4.h"
#include "script.h"
#include "sound.h"
#include "trainer_see.h"
extern u8 gUnknown_0815281E[];
extern u8 gUnknown_08152C39[];
extern u8 gUnknown_0815F36C[];
extern u8 gUnknown_0815F43A[];
extern u8 gUnknown_081A0009[];
__attribute__((naked))
void sub_8067EEC(struct UnkInputStruct *s)
{
asm(".syntax unified\n\
push {r4,r5,lr}\n\
movs r1, 0x2\n\
negs r1, r1\n\
movs r3, 0x3\n\
negs r3, r3\n\
movs r4, 0x5\n\
negs r4, r4\n\
movs r5, 0x9\n\
negs r5, r5\n\
movs r2, 0\n\
strb r2, [r0]\n\
ldrb r2, [r0, 0x1]\n\
ands r1, r2\n\
ands r1, r3\n\
ands r1, r4\n\
ands r1, r5\n\
strb r1, [r0, 0x1]\n\
movs r1, 0\n\
strb r1, [r0, 0x2]\n\
pop {r4,r5}\n\
pop {r0}\n\
bx r0\n\
.syntax divided\n");
}
extern u16 cur_mapdata_block_role_at_player_pos(int);
void process_overworld_input(struct UnkInputStruct *pStruct, u16 keys, u16 heldKeys)
{
u8 r6 = gPlayerAvatar.running1;
u8 r9 = gPlayerAvatar.running2;
bool8 r7 = MetatileBehavior_IsMoveTile(cur_mapdata_block_role_at_player_pos(r9));
if ((r6 == 2 && r7 == FALSE) || r6 == 0)
{
if (sub_80E6034() != 4)
{
if (keys & START_BUTTON)
pStruct->input_field_0_2 = TRUE;
if (keys & SELECT_BUTTON)
pStruct->input_field_0_3 = TRUE;
if (keys & A_BUTTON)
pStruct->input_field_0_0 = TRUE;
if (keys & B_BUTTON)
pStruct->input_field_0_7 = TRUE;
}
if (heldKeys & (DPAD_UP | DPAD_DOWN | DPAD_LEFT | DPAD_RIGHT))
{
pStruct->input_field_0_4 = TRUE;
pStruct->input_field_0_5 = TRUE;
}
}
if (r7 == FALSE)
{
if (r6 == 2 && r9 == 2)
pStruct->input_field_0_6 = TRUE;
if (r7 == FALSE && r6 == 2)
pStruct->input_field_0_1 = TRUE;
}
if (heldKeys & DPAD_UP)
pStruct->input_field_2 = 2;
else if (heldKeys & DPAD_DOWN)
pStruct->input_field_2 = 1;
else if (heldKeys & DPAD_LEFT)
pStruct->input_field_2 = 3;
else if (heldKeys & DPAD_RIGHT)
pStruct->input_field_2 = 4;
}
struct MapPosition
{
s16 x;
s16 y;
u8 height;
};
void player_get_pos_to_and_height(struct MapPosition *);
extern u8 mapheader_run_first_tag2_script_list_match(void);
extern int sub_80687A4(void);
extern u8 sub_80687E4();
extern u8 is_it_battle_time_3();
extern u8 mapheader_run_first_tag2_script_list_match_conditionally();
void player_get_next_pos_and_height(struct MapPosition *);
u8 sub_80681F0(struct MapPosition *position, u16 b, u8 c);
extern u8 map_warp_consider_2_to_inside();
extern int sub_8068770(void);
extern void sub_8071310(void);
extern int sub_80A6D1C(void);
int sub_8068024(struct UnkInputStruct *s)
{
struct MapPosition position;
u8 r6;
u16 r4;
r6 = player_get_direction_lower_nybble();
player_get_pos_to_and_height(&position);
r4 = MapGridGetMetatileBehaviorAt(position.x, position.y);
if (CheckTrainers() == TRUE)
return 1;
if (mapheader_run_first_tag2_script_list_match() == 1)
return 1;
if (s->input_field_0_7 && sub_80687A4() == 1)
return 1;
if (s->input_field_0_6)
{
IncrementGameStat(5);
if (sub_80687E4(&position, r4, r6) == 1)
return 1;
}
if (s->input_field_0_1 && is_it_battle_time_3(r4) == 1)
return 1;
if (s->input_field_0_4 && s->input_field_2 == r6)
{
if (mapheader_run_first_tag2_script_list_match_conditionally(&position, r4, r6) == 1)
return 1;
}
player_get_next_pos_and_height(&position);
r4 = MapGridGetMetatileBehaviorAt(position.x, position.y);
if (s->input_field_0_0 && sub_80681F0(&position, r4, r6) == 1)
return 1;
if (s->input_field_0_5 && s->input_field_2 == r6)
{
if (map_warp_consider_2_to_inside(&position, r4, r6) == 1)
return 1;
}
if (s->input_field_0_0 && sub_8068770() == 1)
return 1;
if (s->input_field_0_2)
{
PlaySE(6);
sub_8071310();
return 1;
}
//_08068154
if (s->input_field_0_3 && sub_80A6D1C() == 1)
return 1;
return FALSE;
}
void player_get_pos_to_and_height(struct MapPosition *position)
{
PlayerGetDestCoords(&position->x, &position->y);
position->height = PlayerGetZCoord();
}
void player_get_next_pos_and_height(struct MapPosition *position)
{
s16 x, y;
GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y);
PlayerGetDestCoords(&x, &y);
if (MapGridGetZCoordAt(x, y) != 0)
position->height = PlayerGetZCoord();
else
position->height = 0;
}
u16 cur_mapdata_block_role_at_player_pos(int unused)
{
s16 x, y;
PlayerGetDestCoords(&x, &y);
return MapGridGetMetatileBehaviorAt(x, y);
}
u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c);
u8 sub_80681F0(struct MapPosition *position, u16 b, u8 c)
{
u8 *script = TryGetScriptOnPressingA(position, b, c);
if (script == NULL)
return FALSE;
if (script != gUnknown_0815281E
&& script != gUnknown_08152C39
&& script != gUnknown_0815F36C
&& script != gUnknown_0815F43A
&& script != gUnknown_081A0009)
PlaySE(5);
ScriptContext1_SetupScript(script);
return TRUE;
}
u8 *sub_8068364();
u8 *TryGetInvisibleMapObjectScript();
u8 *sub_8068500();
u8 *TryGetFieldMoveScript();
u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c)
{
u8 *script;
script = sub_8068364(position, b, c);
if (script != NULL)
return script;
script = TryGetInvisibleMapObjectScript(position, b, c);
if (script != NULL)
return script;
script = sub_8068500(position, b, c);
if (script != NULL)
return script;
script = TryGetFieldMoveScript(position, b, c);
if (script != NULL)
return script;
return NULL;
}
|