Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

True match 0801A570 #660

Merged
merged 1 commit into from
Dec 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 30 additions & 50 deletions src/beanstalkSubtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ u32 sub_0801A570(Entity* this, u32 param_2) {
LayerStruct* layer;
u32 tileType;
u32 position;
s32 index1;
u32 index1;
u32 index2;
u16* metatileTypes;
u8* collisionData;
Expand Down Expand Up @@ -776,17 +776,15 @@ u32 sub_0801A570(Entity* this, u32 param_2) {
}

index1 = GetTileType(position, this->collisionLayer);
if ((u32)(index1 - 0x369) <= 1) {
if ((index1 - 0x369) > 1) {
position = 0xffff;
} else {
collisionData = layer->collisionData - 0x40 + position;
index1 = 0;

if (index1 < index2) {
while (collisionData[index1] == 0) {
if (++index1 >= index2)
goto end;
for (index1 = 0; index1 < index2; index1++) {
if (collisionData[index1] != 0) {
position = 0xffff;
break;
}
} else {
goto end;
}
}
break;
Expand All @@ -810,21 +808,17 @@ u32 sub_0801A570(Entity* this, u32 param_2) {
if (param_2 == 0) {
return position;
}
index1 = GetTileType(position, this->collisionLayer);

if ((index1 == 0x369) || (index1 == 0x36d)) {
index1 = GetTileType(position, this->collisionLayer);
if (!(index1 == 0x369) && !(index1 == 0x36d))
position = 0xffff;
else {
collisionData = layer->collisionData + (position + index2);
index1 = 0;

if (index1 < index2) {
u8* flagPtr = collisionData + index1;
while (*flagPtr == 0) {
if (++index1 >= index2)
goto end;
flagPtr = (u8*)((index1 << 6) + (u32)collisionData);
for (index1 = 0; index1 < index2; index1++) {
if (collisionData[index1 * 0x40] != 0) {
position = 0xffff;
break;
}
} else {
goto end;
}
}
break;
Expand All @@ -850,16 +844,15 @@ u32 sub_0801A570(Entity* this, u32 param_2) {
}

index1 = GetTileType(position, this->collisionLayer);
if ((index1 == 0x369) || (index1 == 0x36b)) {
if (!(index1 == 0x369) && !(index1 == 0x36b))
position = 0xffff;
else {
collisionData = layer->collisionData + (position + (index2 * 0x40));
index1 = 0;
if (index1 < index2) {
while (collisionData[index1] == 0) {
if (++index1 >= index2)
goto end;
for (index1 = 0; index1 < index2; index1++) {
if (collisionData[index1] != 0) {
position = 0xffff;
break;
}
} else {
goto end;
}
}
break;
Expand All @@ -885,31 +878,18 @@ u32 sub_0801A570(Entity* this, u32 param_2) {
}

index1 = GetTileType(position, this->collisionLayer);
if ((index1 == 0x369) || (index1 == 0x36c)) {
if (!(index1 == 0x369) && !(index1 == 0x36c))
position = 0xffff;
else {
collisionData = layer->collisionData - 1 + position;

// This loop is functionally equivalent to the one present in case 1
index1 = 0;
if (index1 < index2) {
u32 flag;
flag = collisionData[index1];
goto case3_flag_check;
case3_loop_back:
if (++index1 >= index2)
goto end;
flag = *(u8*)((index1 << 6) + (u32)collisionData);
case3_flag_check:
if (flag != 0)
for (index1 = 0; index1 < index2; index1++) {
if (collisionData[index1 * 0x40] != 0) {
position = 0xffff;
break;
goto case3_loop_back;
} else {
goto end;
}
}
}
break;
}
position = 0xffff;
end:
if (param_2 != 0) {
position |= index2 << 0xc;
}
Expand Down
Loading