Skip to content

Commit

Permalink
Match sub_0801E49C (#638)
Browse files Browse the repository at this point in the history
* Nuke sub_0801E49C.inc

* Match sub_0801E49C

* Fix data types

* Match signature

* Add typecast and referring function signature

* Fix lint issue
  • Loading branch information
KEKW555 authored Dec 3, 2023
1 parent d0a8433 commit a8d19c0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 213 deletions.
211 changes: 0 additions & 211 deletions asm/non_matching/common/sub_0801E49C.inc

This file was deleted.

57 changes: 56 additions & 1 deletion src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ bool32 IsRoomVisited(TileEntity* tileEntity, u32 bank);
u32 sub_0801DF60(u32 a1, u8* p);
u32 sub_0801DF78(u32 a1, u32 a2);
void sub_0801DF28(u32 x, u32 y, s32 color);
void sub_0801E64C(s32 param_1, s32 param_2, s32 param_3, s32 param_4, s32 param_5);

extern void* GetRoomProperty(u32, u32, u32);

Expand Down Expand Up @@ -794,7 +795,61 @@ void sub_0801E290(u32 param_1, u32 param_2, u32 count) {

ASM_FUNC("asm/non_matching/common/sub_0801E31C.inc", void sub_0801E31C(u32 a1, u32 a2, u32 a3, u32 a4));

ASM_FUNC("asm/non_matching/common/sub_0801E49C.inc", void sub_0801E49C(u32 a1, u32 a2, u32 a3, u32 a4));
void sub_0801E49C(s32 baseX, s32 baseY, s32 radius, u32 baseAngle) {
u8* ptr2;
u32* ptr1;
u32 angle;
s32 x1, x2, x3, y1, y2, y3;

MemFill16(0xffff, gUnk_02018EE0, 0x780);
angle = (baseAngle - 0x40) & 0xff;
x1 = baseX + (gSineTable[angle + 0x40] * radius >> 8);
y1 = baseY + (gSineTable[angle] * radius >> 8);
angle = (baseAngle + 0x68) & 0xff;
x2 = baseX + (gSineTable[angle + 0x40] * radius >> 8);
y2 = baseY + (gSineTable[angle] * radius >> 8);
angle = (baseAngle - 0xe8) & 0xff;
x3 = baseX + (gSineTable[angle + 0x40] * radius >> 8);
y3 = baseY + (gSineTable[angle] * radius >> 8);
sub_0801E64C(x1, y1, x2, y2, 0);
sub_0801E64C(x1, y1, x3, y3, 1);
sub_0801E64C(x2, y2, x3, y3, 2);
MemClear(gUnk_02017AA0[gUnk_03003DE4[0]].filler, 0xa00);
ptr1 = (u32*)gUnk_02018EE0;
ptr2 = gUnk_02017AA0[gUnk_03003DE4[0]].filler;
for (y1 = 0xa0; y1 > 0; y1--, ptr2 += 2) {
x1 = ptr1[0];
x2 = ptr1[1];
x3 = ptr1[2];
ptr1 += 3;
if (x1 > x2) {
SWAP(x1, x2, y2);
}
if (x1 > x3) {
SWAP(x1, x3, y2);
}
if (x2 > x3) {
SWAP(x2, x3, y2);
}
if (x1 != 0xffffffff) {
ptr2[0] = x3;
ptr2[1] = x1;
} else {
if (x2 != x1) {
ptr2[0] = x3;
ptr2[1] = x2;
} else {
if (x3 != x1) {
ptr2[1] = x1;
ptr2[0] = x1;
}
}
}
}
SetVBlankDMA((u16*)(gUnk_02017AA0[gUnk_03003DE4[0]].filler), (u16*)REG_ADDR_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_16BIT | DMA_REPEAT | DMA_SRC_INC | DMA_DEST_RELOAD) << 16) +
0x1);
}

void sub_0801E64C(s32 param_1, s32 param_2, s32 param_3, s32 param_4, s32 param_5) {
s32 sVar1;
Expand Down
2 changes: 1 addition & 1 deletion src/object/whiteTriangleEffect.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef struct {
u16 unk_9;
} struct_081215E8;

extern void sub_0801E49C(u32, u32, u32, u32);
extern void sub_0801E49C(s32 baseX, s32 baseY, s32 radius, u32 baseAngle);
extern bool32 gUnk_02036BB8;

void sub_0808C6D4(WhiteTriangleEffectEntity*);
Expand Down

0 comments on commit a8d19c0

Please sign in to comment.