summaryrefslogtreecommitdiff
path: root/src/friend_area_1.c
blob: ae04cdf0710e626e18890fdf3d46e78a7364d078 (plain)
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
#include "global.h"
#include "constants/friend_area.h"

extern bool8 *gFriendAreas;
extern void sub_809485C(u32 *r0, u32 r1, u32 r2);
extern void sub_8094924(u32 *r0, u32 *r1, u32);
extern void nullsub_102(u32 *r0);
extern void sub_809488C(u32 *r0, u32 *r1, u32 r2);
extern void sub_809486C(u32 *r0, u32 r1, u32 r2);

#ifdef NONMATCHING
u32 sub_80927A8(u32 r0, u32 r1)
{
    u32 temp[5];
    s32 counter;

    sub_809486C(temp, r0, r1);
    for(counter = 0; counter < NUM_FRIEND_AREAS; counter++)
    {
        // TODO moves into R1 for the load else it matches
        if(!gFriendAreas[counter])
            temp[4] = gFriendAreas[counter];
        else
            temp[4] = -1;
        sub_809488C(temp, &(temp[4]), 1);
    }
    nullsub_102(temp);
    return temp[2];
}
#else
NAKED u32 sub_80927A8(u32 r0, u32 r1)
{
	asm_unified("\tpush {r4,r5,lr}\n"
	"\tsub sp, 0x14\n"
	"\tadds r3, r0, 0\n"
	"\tadds r2, r1, 0\n"
	"\tmov r0, sp\n"
	"\tadds r1, r3, 0\n"
	"\tbl sub_809486C\n"
	"\tmovs r4, 0\n"
	"\tadd r5, sp, 0x10\n"
"_080927BC:\n"
	"\tldr r0, _080927F0\n"
	"\tldr r0, [r0]\n"
	"\tadds r0, r4\n"
	"\tldrb r0, [r0]\n"
	"\tcmp r0, 0\n"
	"\tbeq _080927CC\n"
	"\tmovs r0, 0x1\n"
	"\tnegs r0, r0\n"
"_080927CC:\n"
	"\tstr r0, [sp, 0x10]\n"
	"\tmov r0, sp\n"
	"\tadds r1, r5, 0\n"
	"\tmovs r2, 0x1\n"
	"\tbl sub_809488C\n"
	"\tadds r4, 0x1\n"
	"\tcmp r4, 0x39\n"
	"\tble _080927BC\n"
	"\tmov r0, sp\n"
	"\tbl nullsub_102\n"
	"\tldr r0, [sp, 0x8]\n"
	"\tadd sp, 0x14\n"
	"\tpop {r4,r5}\n"
	"\tpop {r1}\n"
	"\tbx r1\n"
	"\t.align 2, 0\n"
"_080927F0: .4byte gFriendAreas");
}
#endif

u32 sub_80927F4(u32 r0, u32 r1)
{
    u32 temp[5];
    s32 counter;

    sub_809485C(temp, r0, r1);
    for(counter = 0; counter < NUM_FRIEND_AREAS; counter++)
    {
        sub_8094924(temp, &(temp[4]), 1);
        // It's setting whether we have the friend area or not
        if((temp[4] & 1))
            gFriendAreas[counter] = TRUE;
        else
            gFriendAreas[counter] = FALSE;
    }
    nullsub_102(temp);
    return temp[2];
}