Remove boolcast uses from code

This commit is contained in:
Tal Hayon
2022-02-10 18:59:54 +02:00
parent 16d8e14488
commit ad2b1bc0c3
22 changed files with 91 additions and 72 deletions
+3 -2
View File
@@ -69,8 +69,9 @@ void sub_080672C8(Entity* this) {
u32 dialog = 0;
u32 tmp;
if (GetInventoryValue(0x11) == 0) {
tmp = CheckGlobalFlag(TABIDACHI);
dialog = BOOLCAST(tmp);
if (CheckGlobalFlag(TABIDACHI)) {
dialog = 1;
}
}
MessageNoOverlap(gUnk_08110CE8[(dialog * 2 + this->type * 6) / 2], this);
}
+7 -1
View File
@@ -49,13 +49,19 @@ void Maid_Head(Entity* this) {
void sub_08064570(Entity* this) {
u32 tmp;
u32 tmp2;
u32 tmp3;
SpriteLoadData* data;
switch (this->action) {
case 0:
tmp = this->id;
tmp ^= 0x16;
data = &gUnk_0810F874[BOOLCAST(tmp) * 3];
if (tmp) {
tmp3 = 1;
} else {
tmp3 = 0;
}
data = &gUnk_0810F874[tmp3 * 3];
if (LoadExtraSpriteData(this, data) == 0) {
return;
}
+4 -2
View File
@@ -13,8 +13,10 @@ void sub_0806DD90(Entity* this) {
u32 y;
this->action = 1;
uVar1 = CheckGlobalFlag(DRUG_1);
uVar2 = BOOLCAST(uVar1);
uVar2 = 0;
if (CheckGlobalFlag(DRUG_1)) {
uVar2 = 1;
}
if (CheckGlobalFlag(DRUG_2) != 0) {
uVar2 = 2;
}
+5 -2
View File
@@ -22,8 +22,11 @@ void Farmers_Head(Entity* this) {
}
void sub_0806BC94(Entity* this, ScriptExecutionContext* context) {
InitializeAnimation(this, context->intVariable + (BOOLCAST(this->spriteSettings.flipX) & 8U) +
(this->animationState >> 1));
u32 offset = 0;
if (this->spriteSettings.flipX) {
offset = 8;
}
InitializeAnimation(this, context->intVariable + offset + (this->animationState >> 1));
}
void sub_0806BCB8(Entity* this) {
+7 -7
View File
@@ -130,14 +130,14 @@ void sub_08060158(Entity* this) {
}
void sub_080601D4(Entity* this) {
u32 temp;
u32 uVar2;
if (CheckGlobalFlag(LV3_CLEAR) == 0) {
uVar2 = 2;
} else if (CheckKinstoneFused(0x17)) {
uVar2 = 1;
} else {
temp = CheckKinstoneFused(0x17);
uVar2 = BOOLCAST(temp);
uVar2 = 0;
}
MessageNoOverlap(gUnk_0810A354[uVar2], this);
}
@@ -147,12 +147,12 @@ void sub_08060208(Entity* this) {
}
void sub_0806021C(Entity* this) {
u32 uVar1;
u32 uVar2;
u32 uVar2 = 0;
// jabber nut
uVar1 = GetInventoryValue(0x5B);
uVar2 = BOOLCAST(uVar1);
if (GetInventoryValue(0x5B)) {
uVar2 = 1;
}
// earth element
if (GetInventoryValue(0x40)) {
+1 -2
View File
@@ -65,8 +65,7 @@ void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65);
void sub_080693D0(Entity* this) {
sub_0807DD94(this, NULL);
if (this->animIndex == 8) {
u32 var0 = this->field_0x82.HWORD & 0xF;
bool32 createFx65 = BOOLCAST(var0); // = !var0
bool32 createFx65 = (this->field_0x82.HWORD & 0xF) != 0;
if (this->frame == 1) {
this->frame = 0;
+4 -3
View File
@@ -99,7 +99,6 @@ void sub_080696B0(void) {
static u32 GoronMerchant_GetSalePrice(Entity* this) {
u32 restockCount;
u32 temp;
u32 kinstoneType;
s32 itemForSale;
@@ -113,8 +112,10 @@ static u32 GoronMerchant_GetSalePrice(Entity* this) {
kinstoneType = 2;
}
temp = CheckGlobalFlag(GORON_KAKERA_LV2);
restockCount = BOOLCAST(temp);
restockCount = 0;
if (CheckGlobalFlag(GORON_KAKERA_LV2)) {
restockCount = 1;
}
if (CheckGlobalFlag(GORON_KAKERA_LV3)) {
restockCount = 2;
+6 -10
View File
@@ -46,15 +46,13 @@ void sub_08063D24(Entity* this) {
void sub_08063D44(Entity* this) {
Entity* ent;
u32 temp, idx;
u32 idx;
if (gEntCount > 0x46)
return;
temp = this->id;
temp ^= 0x15;
idx = BOOLCAST(temp) * 4;
if (!LoadExtraSpriteData(this, &gUnk_0810F524[idx]))
idx = (this->id ^ 0x15) ? 1 : 0;
if (!LoadExtraSpriteData(this, &gUnk_0810F524[idx * 4]))
return;
InitializeAnimation(this, 4);
@@ -111,13 +109,11 @@ void sub_08063E6C(Entity* this) {
}
void sub_08063E90(Entity* this) {
u32 temp, idx;
u32 idx;
u32 unk;
temp = this->id;
temp ^= 0x15;
idx = BOOLCAST(temp) * 4;
if (!LoadExtraSpriteData(this, &gUnk_0810F524[idx]))
idx = (this->id ^ 0x15) ? 1 : 0;
if (!LoadExtraSpriteData(this, &gUnk_0810F524[idx * 4]))
return;
this->action++;
+5 -3
View File
@@ -48,12 +48,14 @@ void sub_0806BB7C(Entity* this, ScriptExecutionContext* context) {
}
void sub_0806BBB0(Entity* this) {
u32 flag;
u32 tmp;
if (GetInventoryValue(0x46) == 0) {
flag = CheckGlobalFlag(0x29);
tmp = BOOLCAST(flag);
if (CheckGlobalFlag(0x29)) {
tmp = 1;
} else {
tmp = 0;
}
} else {
tmp = 2;
}
+5 -3
View File
@@ -67,7 +67,6 @@ void sub_08068104(Entity* this) {
ASM_FUNC("asm/non_matching/mountainMinish/sub_0806811C.inc", void sub_0806811C(Entity* this))
NONMATCH("asm/non_matching/mountainMinish/sub_08068190.inc", void sub_08068190(Entity* this)) {
u32 uVar1;
u32 uVar2;
u32 uVar3;
@@ -75,8 +74,11 @@ NONMATCH("asm/non_matching/mountainMinish/sub_08068190.inc", void sub_08068190(E
if (uVar3 > 8) {
uVar3 = 8;
}
uVar1 = CheckLocalFlag(0x7e);
uVar2 = BOOLCAST(uVar1);
uVar2 = 0;
if (CheckLocalFlag(0x7e)) {
uVar2 = 1;
}
if (GetInventoryValue(0x41) != 0) {
uVar2 = 2;
}
+3 -3
View File
@@ -48,13 +48,13 @@ void Mutoh_Head(Entity* this) {
}
void sub_080670B4(Entity* this) {
u32 uVar1;
u32 uVar2;
uVar2 = 0;
if (GetInventoryValue(0x11) == 0) {
uVar1 = CheckGlobalFlag(TABIDACHI);
uVar2 = BOOLCAST(uVar1);
if (CheckGlobalFlag(TABIDACHI)) {
uVar2 = 1;
}
}
MessageNoOverlap(gUnk_08110C0C[uVar2], this);
}
+5 -2
View File
@@ -67,8 +67,11 @@ void sub_08063830(Entity* this) {
}
void sub_08063850(Entity* this, ScriptExecutionContext* context) {
InitializeAnimation(this, context->intVariable + (BOOLCAST(this->spriteSettings.flipX) & 4U) +
(this->animationState >> 1));
u32 offset = 0;
if (this->spriteSettings.flipX) {
offset = 4;
}
InitializeAnimation(this, context->intVariable + offset + (this->animationState >> 1));
}
void sub_08063874(Entity* this) {
+5 -2
View File
@@ -94,8 +94,11 @@ void sub_08064CD8(Entity* this) {
u32 flag;
u32 tmp = 2;
if (GetInventoryValue(0x46) == 0) {
flag = CheckLocalFlag(0x73);
tmp = BOOLCAST(flag);
if (CheckLocalFlag(0x73)) {
tmp = 1;
} else {
tmp = 0;
}
}
MessageNoOverlap(gUnk_0810FA54[tmp], this);
}
+3 -3
View File
@@ -282,14 +282,14 @@ void sub_0806B064(Entity* this) {
}
void sub_0806B098(Entity* this) {
u32 f;
int idx = 2;
if (GetInventoryValue(0x46) == 0) {
idx = 1;
if (CheckGlobalFlag(MIZUKAKI_START)) {
f = CheckGlobalFlag(MIZUKAKI_HARIFALL);
idx = BOOLCAST(f);
if (!CheckGlobalFlag(MIZUKAKI_HARIFALL)) {
idx = 0;
}
}
}
MessageNoOverlap(gUnk_08112C50[(this->type2 - 7) * 3 + idx], this);
+12 -12
View File
@@ -137,19 +137,19 @@ void sub_0806C944(Entity* this) {
}
void sub_0806C978(Entity* this) {
u32 flag;
u32 flagAsBool;
flag = CheckGlobalFlag(0x58);
flagAsBool = BOOLCAST(flag);
u32 flagAsBool = 0;
if (CheckGlobalFlag(0x58)) {
flagAsBool = 1;
}
MessageNoOverlap(gUnk_08113B12[flagAsBool], this);
}
void sub_0806C99C(Entity* this) {
s32 flag;
u32 flagAsBool;
u32 flagAsBool = 0;
flag = CheckGlobalFlag(0x58);
flagAsBool = BOOLCAST(flag) & 2;
if (CheckGlobalFlag(0x58)) {
flagAsBool = 2;
}
if (CheckLocalFlag(99) != 0) {
flagAsBool += 1;
}
@@ -165,10 +165,10 @@ void sub_0806C9D0(Entity* this) {
}
void sub_0806C9F8(Entity* this) {
u32 flag;
u32 flagAsBool;
flag = CheckGlobalFlag(0x58);
flagAsBool = BOOLCAST(flag);
u32 flagAsBool = 0;
if (CheckGlobalFlag(0x58)) {
flagAsBool = 1;
}
MessageNoOverlap(gUnk_08113B22[flagAsBool], this);
}