-
Notifications
You must be signed in to change notification settings - Fork 2
/
blackcat.cpp
191 lines (153 loc) · 3.33 KB
/
blackcat.cpp
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
#include "blackcat.h"
#include "validate.h"
#include "trig.h"
extern u8 submarinerDieRelated;
extern CBaddy* BaddyList;
// @Ok
void BlackCat_RelocatableModuleClear(void)
{
for (CBody* cur = BaddyList; cur; )
{
CBody* next = reinterpret_cast<CBody*>(cur->field_20);
if (cur->field_38 == 319)
{
delete cur;
}
cur = next;
}
}
// @MEDIUMTODO
void CBlackCat::AI(void)
{
printf("CBlackCat::AI(void)");
}
// @MEDIUMTODO
void CBlackCat::DoMGSShadow(void)
{
printf("CBlackCat::DoMGSShadow(void)");
}
// @Ok
i32* CBlackCat::GetNewCommandBlock(u32 a1)
{
i32* res = static_cast<i32*>(DCMem_New(4 * a1, 0, 1, 0, 1));
res[a1 - 1] = 0;
if (!this->field_350)
{
this->field_350 = res;
}
else
{
i32* it = this->field_350;
while (1)
{
if (!it[it[1] - 1])
break;
it = reinterpret_cast<i32*>(it[it[1] - 1]);
}
it[it[1] - 1] = reinterpret_cast<i32>(res);
}
return res;
}
// @SMALLTODO
void CBlackCat::KillCommandBlockByID(i32)
{
printf("CBlackCat::KillCommandBlockByID(i32)");
}
// @MEDIUMTODO
void CBlackCat::SynthesizeAnalogueInput(void)
{
printf("CBlackCat::SynthesizeAnalogueInput(void)");
}
// @NotOk
// guess type of 33C
CBlackCat::~CBlackCat(void)
{
this->DeleteFrom(reinterpret_cast<CBody**>(&BaddyList));
delete reinterpret_cast<CClass*>(this->field_33C);
this->KillAllCommandBlocks();
}
// @NotOk
// globals
CBlackCat::CBlackCat(int* a2, int a3)
{
if (Trig_GetLevelId() != 2051)
{
this->InitItem("blackcat");
}
else
{
this->InitItem("bc2");
}
i16 *v5 = this->SquirtAngles(reinterpret_cast<i16*>(this->SquirtPos(a2)));
this->field_21E = 100;
this->RunAnim(0xC, 0, -1);
this->mFlags |= 0x480;
this->field_3C = 0x548728;
this->AttachTo(reinterpret_cast<CBody**>(0x56E9900));
this->field_38 = 319;
this->field_31C.bothFlags = 1;
this->field_DE = a3;
this->field_DC = 0;
this->field_34C = reinterpret_cast<int>(v5);
if (submarinerDieRelated && Trig_GetLevelId() != 2051)
this->Die(0);
}
// @Ok
void BlackCat_CreateBlackCat(const unsigned int *stack, unsigned int *result)
{
int* v2 = reinterpret_cast<int*>(*stack);
int v3 = static_cast<int>(stack[1]);
*result = reinterpret_cast<unsigned int>(new CBlackCat(v2, v3));
}
// @Ok
void CBlackCat::Shouldnt_DoPhysics_Be_Virtual(void)
{
this->DoPhysics();
}
// @BIGTODO
void CBlackCat::DoPhysics(void)
{}
// @Ok
// @Matching
i32* CBlackCat::KillCommandBlock(i32* a1)
{
i32* res = reinterpret_cast<i32*>(a1[a1[1]-1]);
if (this->field_350 == a1)
{
this->field_350 = res;
}
else
{
i32* it = this->field_350;
while (it)
{
if (a1 == reinterpret_cast<i32*>(it[it[1]-1]))
{
it[it[1]-1] = reinterpret_cast<i32>(res);
break;
}
it = reinterpret_cast<i32*>(it[it[1]-1]);
}
}
Mem_Delete(reinterpret_cast<void*>(a1));
return res;
}
// @NotOk
// Revisit
void CBlackCat::KillAllCommandBlocks(void)
{
for (i32* cur = this->field_350; cur; cur = this->KillCommandBlock(cur));
this->field_350 = 0;
}
void validate_CBlackCat(void){
VALIDATE_SIZE(CBlackCat, 0x354);
VALIDATE(CBlackCat, field_324, 0x324);
VALIDATE(CBlackCat, field_328, 0x328);
VALIDATE(CBlackCat, field_32C, 0x32C);
VALIDATE(CBlackCat, field_33C, 0x33C);
VALIDATE(CBlackCat, field_340, 0x340);
VALIDATE(CBlackCat, field_344, 0x344);
VALIDATE(CBlackCat, field_348, 0x348);
VALIDATE(CBlackCat, field_34C, 0x34C);
VALIDATE(CBlackCat, field_350, 0x350);
}