clang-format pass and workflow

This commit is contained in:
theo3
2021-02-19 15:03:20 -08:00
parent fd2a50eee4
commit 31f324e3a7
27 changed files with 461 additions and 790 deletions
+4 -10
View File
@@ -6,28 +6,22 @@
typedef struct {
Manager manager;
u8 unk_20[0x14];//unused
u8 unk_20[0x14]; // unused
u16 radiusX;
u16 radiusY;
s16 posX;
s16 posY;
u8 unk_3c[2];//unused
u8 unk_3c[2]; // unused
u16 playerInRegionFlag;
} Manager1E;
enum Manager1E_State {
Init,
ObserveRegion
};
enum Manager1E_State { Init, ObserveRegion };
void Manager1E_Handler(Manager1E*);
void Manager1E_Init(Manager1E*);
void Manager1E_ObserveRegion(Manager1E*);
void (* const Manager1E_ActionFuncs[2])(Manager1E*) = {
Manager1E_Init,
Manager1E_ObserveRegion
};
void (*const Manager1E_ActionFuncs[2])(Manager1E*) = { Manager1E_Init, Manager1E_ObserveRegion };
void Manager1E_Handler(Manager1E* this) {
Manager1E_ActionFuncs[this->manager.action](this);
+4 -8
View File
@@ -17,16 +17,12 @@ void sub_0805C6D0(Manager26*);
void sub_0805C7A0(Manager26*);
void sub_0805C7C4(Manager26*);
void (* const gUnk_08108D04[])(Manager26*) = {
sub_0805C6D0,
sub_0805C7A0,
sub_0805C7C4
};
void (*const gUnk_08108D04[])(Manager26*) = { sub_0805C6D0, sub_0805C7A0, sub_0805C7C4 };
void sub_0805C7CC(Manager26*);
void sub_0805C6B8(Manager26* this) {
gUnk_08108D04[this->manager.action](this);
gUnk_08108D04[this->manager.action](this);
}
void sub_0805C6D0(Manager26* this) {
@@ -46,7 +42,7 @@ void sub_0805C6D0(Manager26* this) {
obj->actionDelay = tmp->unk_03;
obj->x.HALF.HI = gRoomControls.roomOriginX + tmp->unk_04;
obj->y.HALF.HI = gRoomControls.roomOriginY + tmp->unk_06;
obj->parent = (Entity*) this;
obj->parent = (Entity*)this;
obj->collisionLayer = 1;
obj->field_0x82.HALF.HI = this->manager.unk_0e;
obj->field_0x82.HALF.LO = tmp->unk_00;
@@ -75,7 +71,7 @@ void sub_0805C7A0(Manager26* this) {
}
void sub_0805C7C4(Manager26* this) {
sub_0805C7CC(this);
sub_0805C7CC(this);
}
void sub_0805C7CC(Manager26* this) {
+2 -9
View File
@@ -11,16 +11,9 @@ void sub_0805C894(Entity*);
void sub_0805C8B4(Entity*);
void sub_0805C908(Entity*);
void (*const gUnk_08108D10[])(Entity*) = {
sub_0805C874,
sub_0805C894,
sub_0805C8B4,
sub_0805C908
};
void (*const gUnk_08108D10[])(Entity*) = { sub_0805C874, sub_0805C894, sub_0805C8B4, sub_0805C908 };
const u8 gUnk_08108D20[] = {
0x6F, 0x70, 0x71, 0x72, 0x71, 0x70
};
const u8 gUnk_08108D20[] = { 0x6F, 0x70, 0x71, 0x72, 0x71, 0x70 };
void Manager27(Entity* this) {
+28 -33
View File
@@ -18,20 +18,11 @@ u32 Manager28_FindMatchingEntities(Manager28*);
Entity* Manager28_FindMatchingEntity(EntityData*);
void Manager28_RemoveDeletedEntities(Manager28*);
void (* const Manager28_ActionFuncs[])(Manager28*) = {
Manager28_Init,
Manager28_Main
};
void (*const Manager28_ActionFuncs[])(Manager28*) = { Manager28_Init, Manager28_Main };
enum Manager28_Action {
Init = 0,
Main = 1
};
enum Manager28_Action { Init = 0, Main = 1 };
enum Manager28_InitState {
DoInit = 0,
DoNotInit = 1
};
enum Manager28_InitState { DoInit = 0, DoNotInit = 1 };
void Manager28_Entry(Manager28* this) {
Manager28_ActionFuncs[this->manager.action](this);
@@ -46,7 +37,7 @@ void Manager28_Init(Manager28* this) {
}
tmp2 = Manager28_FindMatchingEntities(this);
if (tmp2 > 1) {
Manager28* tmp3 = (Manager28*) GetEmptyManager();
Manager28* tmp3 = (Manager28*)GetEmptyManager();
if (tmp3) {
tmp3->manager.type = 9;
tmp3->manager.subtype = 0x28;
@@ -92,20 +83,26 @@ void Manager28_Main(Manager28* this) {
u32 Manager28_FindMatchingEntities(Manager28* this) {
u32 re = 0;
EntityData * tmp = GetCurrentRoomProperty(this->manager.unk_0b);
if (!tmp) return 0;
for (; *((u8*) tmp) != 0xFF && !(tmp->type == 9 && tmp->subtype == 0x28); tmp++) {
EntityData* tmp = GetCurrentRoomProperty(this->manager.unk_0b);
if (!tmp)
return 0;
for (; *((u8*)tmp) != 0xFF && !(tmp->type == 9 && tmp->subtype == 0x28); tmp++) {
Entity* tmp2;
u32 i;
if (tmp->type != 3) continue;
if (tmp->type != 3)
continue;
tmp2 = Manager28_FindMatchingEntity(tmp);
if (!tmp2) continue;
if (!tmp2)
continue;
for (i = 0; i < re; i++) {
if (this->d.enemies[i] == tmp2) break;
if (this->d.enemies[i] == tmp2)
break;
}
if (i != re) continue;
if (i != re)
continue;
this->d.enemies[re++] = tmp2;
if (re == 8) return 8;
if (re == 8)
return 8;
}
return re;
}
@@ -115,15 +112,12 @@ Entity* Manager28_FindMatchingEntity(EntityData* unk1) {
Entity* i;
LinkedList* tmp;
x = unk1->xPos + gRoomControls.roomOriginX;
y = unk1->yPos + gRoomControls.roomOriginY;
tmp = &gUnk_03003D90;
for (i = tmp->first; (u32) i != (u32) tmp; i = i->next) {
if (x == i->x.HALF.HI
&& y == i->y.HALF.HI
&& unk1->subtype == i->entityType.subtype
&& 3 == i->entityType.type
&& unk1->form == i->entityType.form) {
return i;
y = unk1->yPos + gRoomControls.roomOriginY;
tmp = &gUnk_03003D90;
for (i = tmp->first; (u32)i != (u32)tmp; i = i->next) {
if (x == i->x.HALF.HI && y == i->y.HALF.HI && unk1->subtype == i->entityType.subtype &&
3 == i->entityType.type && unk1->form == i->entityType.form) {
return i;
}
}
return 0;
@@ -133,13 +127,14 @@ void Manager28_RemoveDeletedEntities(Manager28* this) {
s32 i;
for (i = 0; i < this->manager.unk_0e; i++) {
if (this->d.enemies[i]->next == 0) {
if (this->manager.unk_0e-1 == i) {
if (this->manager.unk_0e - 1 == i) {
this->d.enemies[i] = 0;
} else {
this->d.enemies[i] = this->d.enemies[this->manager.unk_0e-1];
this->d.enemies[i] = this->d.enemies[this->manager.unk_0e - 1];
}
this->manager.unk_0e--;
}
}
if (this->manager.unk_0e <= 1) DeleteThisEntity();
if (this->manager.unk_0e <= 1)
DeleteThisEntity();
}
+18 -17
View File
@@ -7,20 +7,20 @@
typedef struct {
Manager manager;
u8 unk_20;//unused
u8 unk_21[0x13];//unused
u16 unk_34;//unused
u16 unk_36;//unused
s16 unk_38;//unused
s16 unk_3A;//unused
u16 unk_3C;//unused
u16 unk_3E;//unused
u8 unk_20; // unused
u8 unk_21[0x13]; // unused
u16 unk_34; // unused
u16 unk_36; // unused
s16 unk_38; // unused
s16 unk_3A; // unused
u16 unk_3C; // unused
u16 unk_3E; // unused
} Manager39;
extern u8 gUnk_02034DF0[0x2F2];
extern const u16 gUnk_08108DE8[];
extern void (* const gUnk_08108E28[])(Manager39*);
extern void (*const gUnk_08108E28[])(Manager39*);
extern const u8 gUnk_08108E30[0x18];
extern const u8 gUnk_08108E48[0x18];
extern const u8 gUnk_08108E60[];
@@ -31,14 +31,13 @@ extern u32 CheckIsDungeon(void);
extern void sub_0805E5B4(void);
void sub_0805E140(Manager39*);
void sub_0805E18C(Manager39*); //unused?
void sub_0805E18C(Manager39*); // unused?
void sub_0805E1D8(Manager39*);
void sub_0805E1F8(u32, u32);
void sub_0805E0FC(Manager39* this) {
gUnk_08108E28[this->manager.action](this);
if ((gRoomControls.roomID != this->unk_20)
|| (gTextBox.doTextBox & 0x7F)) {
if ((gRoomControls.roomID != this->unk_20) || (gTextBox.doTextBox & 0x7F)) {
sub_0805E1D8(this);
}
}
@@ -49,12 +48,13 @@ void sub_0805E140(Manager39* this) {
this->unk_20 = gRoomControls.roomID;
this->manager.unk_0e = 0x78;
this->manager.unk_0f = 0x3c;
sub_0805E3A0((Entity*) this, 7);
sub_0805E3A0((Entity*)this, 7);
sub_0805E1F8(gUnk_08108DE8[gArea.locationIndex], CheckIsDungeon());
}
void sub_0805E18C(Manager39* this) {
if (gFadeControl.active) return;
if (gFadeControl.active)
return;
if (this->manager.unk_0b) {
if (!--this->manager.unk_0f) {
this->manager.unk_0b = 0;
@@ -80,13 +80,14 @@ void sub_0805E1F8(u32 unk0, u32 unk1) {
u8 unk_05;
u8 unk_06[3];
} PACKED tmp;
const u8 * tmp2;
const u8* tmp2;
_DmaZero(&gUnk_02034DF0, 0x80);
_DmaCopy(gUnk_08108E60, &tmp, sizeof(tmp));
tmp.unk_04 = unk0>>8;
tmp.unk_04 = unk0 >> 8;
tmp.unk_05 = unk0;
tmp2 = gUnk_08108E48;
if (!unk1) tmp2 = gUnk_08108E30;
if (!unk1)
tmp2 = gUnk_08108E30;
sub_0805F46C(&tmp, tmp2);
gScreen.bg.bg3Control = 1;
}
+37 -69
View File
@@ -9,10 +9,9 @@
#include "functions.h"
#include "save.h"
typedef struct {
Manager manager;
s32 unk_20;
s32 unk_20;
union SplitWord unk_24;
u32 unk_28;
u32 unk_2c;
@@ -26,7 +25,7 @@ typedef struct {
u16 unk_6;
} struct_08108228;
void (* const gUnk_0810821C[])(ManagerC*);
void (*const gUnk_0810821C[])(ManagerC*);
const struct_08108228 gUnk_08108228[6];
const struct_08108228 gUnk_08108258[6];
const struct_08108228 gUnk_08108288[6];
@@ -60,11 +59,7 @@ void sub_08058894(ManagerC*);
void sub_080588CC(ManagerC*);
void nullsub_108(ManagerC*);
void (* const gUnk_0810821C[])(ManagerC*) = {
sub_08058894,
sub_080588CC,
nullsub_108
};
void (*const gUnk_0810821C[])(ManagerC*) = { sub_08058894, sub_080588CC, nullsub_108 };
void sub_0805884C(ManagerC* this) {
u32 tmp;
@@ -90,9 +85,10 @@ void sub_080588CC(ManagerC* this) {
}
}
void nullsub_108(ManagerC* this) {}
void nullsub_108(ManagerC* this) {
}
#define ABS_DIFF_GT(a, b, c) (signed) a - b >= 0 ? a - b > c : b - a > c
#define ABS_DIFF_GT(a, b, c) (signed)a - b >= 0 ? a - b > c : b - a > c
void sub_080588F8(ManagerC* this) {
if (this->manager.unk_0f == 0) {
@@ -126,8 +122,8 @@ void sub_080588F8(ManagerC* this) {
this->unk_24.WORD += tmp2;
}
if (ABS_DIFF_GT(this->unk_2c, this->unk_24.WORD, 0x100000)) {
this->unk_2c = this->unk_24.WORD;
PlaySFX(0x8b);
this->unk_2c = this->unk_24.WORD;
PlaySFX(0x8b);
}
}
}
@@ -140,50 +136,27 @@ void sub_080588F8(ManagerC* this) {
}
}
const struct_08108228 gUnk_08108228[6] = {
{0x40, 0x2A, 0x1C, 0x10},
{0x3C, 0x24, 0x1C, 0x12},
{0x3C, 0x1C, 0x1A, 0x18},
{0x38, 0x16, 0x1C, 0x16},
{0x34, 0x16, 0x1E, 0x0E},
{0x30, 0x16, 0x20, 0x0A}
};
const struct_08108228 gUnk_08108228[6] = { { 0x40, 0x2A, 0x1C, 0x10 }, { 0x3C, 0x24, 0x1C, 0x12 },
{ 0x3C, 0x1C, 0x1A, 0x18 }, { 0x38, 0x16, 0x1C, 0x16 },
{ 0x34, 0x16, 0x1E, 0x0E }, { 0x30, 0x16, 0x20, 0x0A } };
const struct_08108228 gUnk_08108258[6] = {
{0x30, 0x88, 0x20, 0x0A},
{0x34, 0x7E, 0x1E, 0x12},
{0x38, 0x78, 0x1A, 0x16},
{0x3A, 0x70, 0x1A, 0x18},
{0x3C, 0x64, 0x1E, 0x1E},
{0x3E, 0x6A, 0x1C, 0x10}
};
const struct_08108228 gUnk_08108258[6] = { { 0x30, 0x88, 0x20, 0x0A }, { 0x34, 0x7E, 0x1E, 0x12 },
{ 0x38, 0x78, 0x1A, 0x16 }, { 0x3A, 0x70, 0x1A, 0x18 },
{ 0x3C, 0x64, 0x1E, 0x1E }, { 0x3E, 0x6A, 0x1C, 0x10 } };
const struct_08108228 gUnk_08108288[6] = {
{0x98, 0x2A, 0x1C, 0x10},
{0x98, 0x24, 0x1C, 0x12},
{0x9C, 0x1C, 0x1A, 0x18},
{0x9C, 0x16, 0x1C, 0x16},
{0xA0, 0x16, 0x1E, 0x0E},
{0xA0, 0x16, 0x20, 0x0A}
};
const struct_08108228 gUnk_08108288[6] = { { 0x98, 0x2A, 0x1C, 0x10 }, { 0x98, 0x24, 0x1C, 0x12 },
{ 0x9C, 0x1C, 0x1A, 0x18 }, { 0x9C, 0x16, 0x1C, 0x16 },
{ 0xA0, 0x16, 0x1E, 0x0E }, { 0xA0, 0x16, 0x20, 0x0A } };
const struct_08108228 gUnk_081082B8[6] = {
{0xA0, 0x88, 0x20, 0x0A},
{0x9E, 0x7E, 0x1E, 0x12},
{0x9C, 0x78, 0x1A, 0x16},
{0x9A, 0x70, 0x1A, 0x18},
{0x98, 0x64, 0x1E, 0x1E},
{0x98, 0x6A, 0x1C, 0x10}
};
const struct_08108228 gUnk_081082B8[6] = { { 0xA0, 0x88, 0x20, 0x0A }, { 0x9E, 0x7E, 0x1E, 0x12 },
{ 0x9C, 0x78, 0x1A, 0x16 }, { 0x9A, 0x70, 0x1A, 0x18 },
{ 0x98, 0x64, 0x1E, 0x1E }, { 0x98, 0x6A, 0x1C, 0x10 } };
void sub_08058A04(ManagerC* this) {
s32 tmp = gPlayerEntity.x.HALF.HI - gRoomControls.roomOriginX;
s32 tmp2 = gPlayerEntity.y.HALF.HI - gRoomControls.roomOriginY;
if ((this->unk_20 - 0x118 < 0xDu) &&
CheckGlobalFlag(LV1TARU_OPEN) &&
(tmp - 0x6d < 0x17u) &&
(tmp2 - 0x45 < 0x17u) &&
(gPlayerEntity.height.HALF.HI == 0)) {
if ((this->unk_20 - 0x118 < 0xDu) && CheckGlobalFlag(LV1TARU_OPEN) && (tmp - 0x6d < 0x17u) &&
(tmp2 - 0x45 < 0x17u) && (gPlayerEntity.height.HALF.HI == 0)) {
gPlayerState.playerAction = 3;
gPlayerState.field_0x38 = 0;
gPlayerEntity.x.HALF.HI = gRoomControls.roomOriginX + 0x78;
@@ -228,12 +201,7 @@ u32 sub_08058B08(ManagerC* this, u32 unk1, u32 unk2, const struct_08108228* unk3
}
}
const u16 gUnk_081082E8[0xC] = {
0xB8, 0x80, 0x0,
0xB8, 0x110, 0x2,
0x118, 0x80, 0x2,
0x118, 0x110, 0x0
};
const u16 gUnk_081082E8[0xC] = { 0xB8, 0x80, 0x0, 0xB8, 0x110, 0x2, 0x118, 0x80, 0x2, 0x118, 0x110, 0x0 };
void sub_08058B5C(ManagerC* this, u32 unk1) {
gScreenTransition.transitioningOut = 1;
@@ -242,14 +210,14 @@ void sub_08058B5C(ManagerC* this, u32 unk1) {
gScreenTransition.areaID = gRoomControls.areaID;
gScreenTransition.roomID = 6;
gScreenTransition.playerState = unk1 & 1 ? 4 : 0;
gScreenTransition.playerStartPos.HALF.x = gUnk_081082E8[unk1*3];
gScreenTransition.playerStartPos.HALF.y = gUnk_081082E8[unk1*3+1];
gSave.unk7 = gUnk_081082E8[unk1*3+2];
gScreenTransition.playerStartPos.HALF.x = gUnk_081082E8[unk1 * 3];
gScreenTransition.playerStartPos.HALF.y = gUnk_081082E8[unk1 * 3 + 1];
gSave.unk7 = gUnk_081082E8[unk1 * 3 + 2];
PlaySFX(0x121);
}
void sub_08058BC8(ManagerC* this) {
struct BgAffineDstData * tmp = &gUnk_02017AA0[gUnk_03003DE4[0]*0xA0];
struct BgAffineDstData* tmp = &gUnk_02017AA0[gUnk_03003DE4[0] * 0xA0];
struct BgAffineSrcData tmp2;
s32 tmp3;
tmp2.texX = 0x10000;
@@ -262,25 +230,25 @@ void sub_08058BC8(ManagerC* this) {
do {
u32 indx = ((tmp3 << 7) / 0xA0) & 0xFF;
tmp2.sx = 0x100 + ((gSineTable[indx] * 3) >> 2);
tmp2.sy = 0x100 - ((gSineTable[indx * 2] * 2) >> 5);//yes, it makes no sense to multiply first and then shift right, but it's matching this way
tmp2.sy =
0x100 - ((gSineTable[indx * 2] * 2) >>
5); // yes, it makes no sense to multiply first and then shift right, but it's matching this way
tmp2.texY = (this->unk_20 + tmp3) << 8;
BgAffineSet(&tmp2, tmp, 1);
tmp++;
} while (++tmp3<0xA0u);
tmp = &gUnk_02017BA0[gUnk_03003DE4[0]*0xA0];
} while (++tmp3 < 0xA0u);
tmp = &gUnk_02017BA0[gUnk_03003DE4[0] * 0xA0];
gScreen.controls.bg2dx = tmp->pa;
gScreen.controls.bg2dmx = tmp->pb;
gScreen.controls.bg2dy = tmp->pc;
gScreen.controls.bg2dmy = tmp->pd;
gScreen.controls.bg2xPointLeastSig = ((union SplitWord *) &tmp->dx)->HALF.LO;
gScreen.controls.bg2xPointMostSig = ((union SplitWord *) &tmp->dx)->HALF.HI;
gScreen.controls.bg2yPointLeastSig = ((union SplitWord *) &tmp->dy)->HALF.LO;
gScreen.controls.bg2yPointMostSig = ((union SplitWord *) &tmp->dy)->HALF.HI;
gScreen.controls.bg2xPointLeastSig = ((union SplitWord*)&tmp->dx)->HALF.LO;
gScreen.controls.bg2xPointMostSig = ((union SplitWord*)&tmp->dx)->HALF.HI;
gScreen.controls.bg2yPointLeastSig = ((union SplitWord*)&tmp->dy)->HALF.LO;
gScreen.controls.bg2yPointMostSig = ((union SplitWord*)&tmp->dy)->HALF.HI;
}
const u16 gUnk_08108300[4] = {
0xA4, 0x4C, 0xF4, 0x9C
};
const u16 gUnk_08108300[4] = { 0xA4, 0x4C, 0xF4, 0x9C };
void sub_08058CB0(ManagerC* this) {
u32 tmp = gPlayerEntity.x.HALF.HI - gRoomControls.roomOriginX;