summaryrefslogtreecommitdiff
path: root/src/manager/manager29.c
blob: 133d3944f471ea593c40320e0d6ad2556a3c72e1 (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
 * @file manager29.c
 * @ingroup Managers
 *
 * @brief Unused? Not yet encountered.
 */
#include "manager/manager29.h"
#include "asm.h"
#include "flags.h"
#include "functions.h"

bool32 sub_0805CF80(Manager29* this);
void sub_0805CBD0(Manager29* this);
void sub_0805CC3C(Manager29* this);

void Manager29_Main(Manager29* this) {
    if (super->action == 0) {
        sub_0805CBD0(this);
        if (CheckFlags(this->unk_3e)) {
            sub_0805CC3C(this);
            DeleteManager(this);
        }
    } else if (sub_0805CF80(this)) {
        SetFlag(this->unk_3e);
        DeleteManager(this);
    }
}

void sub_0805CBD0(Manager29* this) {
    MapLayer* mapLayer;

    super->action = 1;
    this->unk_38 = (this->unk_38 >> 4 & 0x3fU) | (((this->unk_3a << 0x10) >> 0x14 & 0x3fU) << 6);
    this->unk_3a = (this->unk_3c >> 4 & 0x3f) | (((this->unk_36 + this->unk_37 * 0x100) >> 4 & 0x3fU) << 6);
    this->unk_3c = GetTileTypeAtTilePos(this->unk_38, this->layer);
    mapLayer = GetLayerByIndex(this->layer);
    this->unk_28 = (u16*)mapLayer->tileTypes;
    this->unk_2c = &mapLayer->mapData[(s16)this->unk_3a];
}

void sub_0805CC3C(Manager29* this) {
    s32 iVar2;
    u32 iVar3;
    u32 uVar4;

    iVar3 = this->unk_38;
    iVar2 = (short)this->unk_3a;

    if (this->layer == 1) {
        uVar4 = 0x321;
    } else {
        uVar4 = 0x322;
    }

    switch (super->type) {
        default:
            sub_0807B7D8(uVar4, iVar3, this->layer);
            sub_0807B7D8(0x365, iVar2, this->layer);
            break;
        case 1:
            sub_0807B7D8(uVar4, iVar3, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 1, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x40, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x41, this->layer);
            sub_0807B7D8(this->unk_3c, iVar2, this->layer);
            sub_0807B7D8(0x36f, iVar2 + 1, this->layer);
            sub_0807B7D8(0x370, iVar2 + 0x40, this->layer);
            sub_0807B7D8(0x371, iVar2 + 0x41, this->layer);
            break;

        case 2:
            sub_0807B7D8(uVar4, iVar3, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 1, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 2, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x40, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x41, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x42, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x80, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x81, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x82, this->layer);
            sub_0807B7D8(this->unk_3c, iVar2, this->layer);
            sub_0807B7D8(0x372, iVar2 + 1, this->layer);
            sub_0807B7D8(0x36f, iVar2 + 2, this->layer);
            sub_0807B7D8(0x374, iVar2 + 0x40, this->layer);
            sub_0807B7D8(0x376, iVar2 + 0x41, this->layer);
            sub_0807B7D8(0x375, iVar2 + 0x42, this->layer);
            sub_0807B7D8(0x370, iVar2 + 0x80, this->layer);
            sub_0807B7D8(0x373, iVar2 + 0x81, this->layer);
            sub_0807B7D8(0x371, iVar2 + 0x82, this->layer);
            break;

        case 3:
            sub_0807B7D8(uVar4, iVar3, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 1, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 2, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 3, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x40, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x41, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x42, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x43, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x80, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x81, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x82, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0x83, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0xc0, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0xc1, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0xc2, this->layer);
            sub_0807B7D8(uVar4, iVar3 + 0xc3, this->layer);
            sub_0807B7D8(this->unk_3c, iVar2, this->layer);
            sub_0807B7D8(0x372, iVar2 + 1, this->layer);
            sub_0807B7D8(0x372, iVar2 + 2, this->layer);
            sub_0807B7D8(0x36f, iVar2 + 3, this->layer);
            sub_0807B7D8(0x374, iVar2 + 0x40, this->layer);
            sub_0807B7D8(0x376, iVar2 + 0x41, this->layer);
            sub_0807B7D8(0x376, iVar2 + 0x42, this->layer);
            sub_0807B7D8(0x375, iVar2 + 0x43, this->layer);
            sub_0807B7D8(0x374, iVar2 + 0x80, this->layer);
            sub_0807B7D8(0x376, iVar2 + 0x81, this->layer);
            sub_0807B7D8(0x376, iVar2 + 0x82, this->layer);
            sub_0807B7D8(0x375, iVar2 + 0x83, this->layer);
            sub_0807B7D8(0x370, iVar2 + 0xc0, this->layer);
            sub_0807B7D8(0x373, iVar2 + 0xc1, this->layer);
            sub_0807B7D8(0x373, iVar2 + 0xc2, this->layer);
            sub_0807B7D8(0x371, iVar2 + 0xc3, this->layer);
            break;
    }
}

bool32 sub_0805CF80(Manager29* this) {
    s32 sVar1;
    u32 uVar2;

    sVar1 = this->unk_28[this->unk_2c[0]];
    uVar2 = 0;
    if ((((sVar1 == 0x365) || (sVar1 == 0x369)) || (sVar1 == 0x36a)) ||
        (((sVar1 == 0x36b || (sVar1 == 0x36d)) || (sVar1 == 0x36c)))) {
        uVar2 = 1;
    }

    return uVar2;
}