summaryrefslogtreecommitdiff
path: root/src/manager/manager37.c
blob: f7b56dfa0e3a0427870b51cd57e9182d36c6f0d9 (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
#include "manager.h"
#include "structures.h"
#include "functions.h"
#include "flags.h"
#include "textbox.h"
#include "audio.h"
#include "save.h"
#include "object.h"
#include "area.h"
#include "enemy.h"

extern ScreenTransitionData gUnk_0813AC34;

extern void (*const gUnk_08108DBC[])(Manager*);

extern void (*const gUnk_08108DC4[])(Manager*);

extern void (*const gUnk_08108DD8[])(Manager*);

void sub_0805E094(void);

extern Entity* CreateSpeechBubbleExclamationMark(Entity*, u32, u32);

void Manager37_Main(Manager* this) {
    gUnk_08108DBC[this->unk_0a](this);
}

void sub_0805DE50(Manager* this) {
    gUnk_08108DC4[this->action](this);
}

void sub_0805DE68(Manager* this) {
    if (CheckLocalFlag(0x7b) == 0) {
        DeleteThisEntity();
    }
    this->action = 1;
    gScreenTransition.field_0x38 = 0;
    gScreenTransition.field_0x39 = 0x0f;
    *(u8*)&gScreenTransition.field_0x3a = 0x20;
    *((u8*)&gScreenTransition.field_0x3a + 1) = 0x20;
#if !defined(EU) && !defined(JP) && !defined(DEMO_JP)
    gSave.unk498 = 0x1194;
#endif
}

void sub_0805DEB8(Manager* this) {
    s32 distX;
    s32 distY;
    Entity* object;

    distX = gPlayerEntity.x.HALF.HI - (gRoomControls.roomOriginX + 0x88);
    distY = gPlayerEntity.y.HALF.HI - (gRoomControls.roomOriginY + 0x40);
    if (distX * distX + distY * distY < 0x901) {
        this->action = 2;
        this->unk_0d = 0;
        this->unk_0e = 0x78;
        sub_08078A90(2);
        sub_08078B48();
        object = CreateObject(OBJECT_64, 0, 0);
        if (object != NULL) {
            object->x.HALF.HI = gRoomControls.roomOriginX + 0x88;
            object->y.HALF.HI = gRoomControls.roomOriginY + 0x48;
        }
        object = CreateSpeechBubbleExclamationMark(&gPlayerEntity, 8, 0xfffffff0);
        if (object != NULL) {
            object->spritePriority.b0 = 3;
        }
        SoundReq(BGM_VAATI_WRATH);
    }
}

void sub_0805DF4C(Manager* this) {
    gPlayerEntity.animationState = 0;
    if (gPlayerEntity.height.HALF.HI != 0) {
        if (gPlayerEntity.y.HALF.HI < (gRoomControls.roomOriginY + 0x48)) {
            gPlayerEntity.y.HALF.HI = gRoomControls.roomOriginY + 0x48;
        }
    } else {
        if (--this->unk_0e == 0) {
            this->action = 3;
            this->unk_0e = 0x1e;
            TextboxNoOverlapFollow(0x164f);
        }
    }
}

void sub_0805DF98(Manager* this) {
    if ((gTextBox.doTextBox & 0x7f) == 0) {
        if (this->unk_0e != 0) {
            this->unk_0e -= 1;
        } else {
            this->action = 4;
            DoFade(7, 4);
            SoundReq(SFX_EVAPORATE);
        }
    }
}

void sub_0805DFCC(void) {
    if (gFadeControl.active == 0) {
        ClearGlobalFlag(ZELDA_CHASE);
        sub_0805E094();
    }
}

void sub_0805DFE8(Manager* this) {
    gUnk_08108DD8[this->action](this);
}

void sub_0805E000(Manager* this) {
    Entity* enemy = CreateEnemy(VAATI_WRATH, 0);
    if (enemy != NULL) {
        enemy->x.HALF.HI = gRoomControls.roomOriginX + 0xb0;
        enemy->y.HALF.HI = gRoomControls.roomOriginY + 0x48;
        enemy->collisionLayer = 1;
        UpdateSpriteForCollisionLayer(enemy);
        if ((gScreenTransition.field_0x38 & 1) != 0) {
            DeleteThisEntity();
        }
        *(Entity**)this->unk_18 = enemy;
        this->action = 1;
        sub_08078A90(3);
        gArea.pMusicIndex = 0x80010000;
        DoFade(6, 4);
        SoundReq(SFX_APPARATE);
    }
}

void sub_0805E078(Manager* this) {
    if (gFadeControl.active == 0) {
        *(u8*)(((int*)this->unk_18)[0] + 0xd) = 1;
        DeleteThisEntity();
    }
}

void sub_0805E094(void) {
    sub_0805E5A8();
    sub_0808091C((ScreenTransitionData*)&gUnk_0813AC34, 7);
}