summaryrefslogtreecommitdiff
path: root/src/code_08077B98.c
blob: 856dc44b44eac72638af2a2fe1407b4cbd7ad0ba (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
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
#include "global.h"
#include "entity.h"
#include "player.h"
#include "functions.h"

typedef struct {
    u8 unk[12];
} struct_0811BE48;

typedef struct {
    u8 field_0x0;
    u8 field_0x1;
} UnkItemStruct;

Entity* sub_08077C94(ItemBehavior*, u32);
void* sub_08077C54(UnkItemStruct* unk);
Entity* CreatePlayerBomb(ItemBehavior*, u32);
extern Entity* sub_0805E744();

extern struct_0811BE48 gUnk_0811BE48[];

void sub_08077B98(UnkItemStruct* unk) {
    if ((gPlayerState.field_0x2c == NULL) || (gPlayerState.field_0x2c[9] != 1)) {
        gPlayerState.field_0x2c = sub_08077C54(unk);
    }
}

void sub_08077BB8(UnkItemStruct* unk) {
    u8* temp = sub_08077C54(unk);
    if (temp != NULL) {
        temp[0x10] = 0x20;
    }
    gPlayerState.field_0x2c = temp;
}

Entity* sub_08077BD4(ItemBehavior* beh) {
    if (sub_08077C94(beh, gUnk_0811BE48[beh->behaviorID].unk[3]) != 0) {
        return NULL;
    } else {
        return CreatePlayerBomb(beh, gUnk_0811BE48[beh->behaviorID].unk[3]);
    }
}

Entity* sub_08077C0C(ItemBehavior* beh, u32 arg1) {
    u8 bVar1;
    Entity* pEVar3;

    bVar1 = gUnk_0811BE48[arg1].unk[3];

    if (sub_08077C94(beh, bVar1) != 0) {
        return NULL;
    } else {
        return CreatePlayerBomb(beh, bVar1);
    }
}

Entity* CreatePlayerBomb(ItemBehavior* beh, u32 subtype) {
    Entity* pEVar1;

    pEVar1 = CreatePlayerItem(subtype, 0, 0, beh->behaviorID);
    if (pEVar1 != NULL) {
        *(ItemBehavior**)&pEVar1->parent = beh;
    }
    return pEVar1;
}

void* sub_08077C54(UnkItemStruct* unk) {
    Entity* item;

    item = sub_0805E744();
    if (item != NULL) {
        item->id = gUnk_0811BE48[unk->field_0x1].unk[3];
        item->kind = 8;
        item->flags = 0xa0;
        item->parent = (Entity*)unk;
        item->field_0x68.HALF.LO = unk->field_0x1;
        AppendEntityToList(item, 2);
    }
    return item;
}

Entity* sub_08077C94(ItemBehavior* arg0, u32 arg1) {
    Entity* iVar1;

    iVar1 = FindEntityByID(8, gUnk_0811BE48[arg1].unk[3], 2);
    if (iVar1 == NULL) {
        return NULL;
    }
    return iVar1;
}

Entity* CreatePlayerItem(u32 subtype, u32 form, u32 parameter, u32 unk) {
    Entity* ent;

    ent = GetEmptyEntity();
    if (ent != NULL) {
        ent->flags = 0x80;
        ent->kind = 8;
        ent->id = subtype;
        ent->type = form;
        ent->type2 = parameter;
        ent->field_0x68.HALF.LO = unk;
        AppendEntityToList(ent, 2);
    }
    return ent;
}

Entity* sub_08077CF8(u32 subtype, u32 form, u32 parameter, u32 unk) {
    Entity* ent;

    ent = sub_0805E744();
    if (ent != NULL) {
        ent->flags = 0x80;
        ent->kind = 8;
        ent->id = subtype;
        ent->type = form;
        ent->type2 = parameter;
        ent->field_0x68.HALF.LO = unk;
        AppendEntityToList(ent, 2);
    }
    return ent;
}

NAKED
void sub_08077D38(ItemBehavior* beh, u32 arg1) {
    asm(".include \"asm/non_matching/sub_08077D38.inc\"");
}