summaryrefslogtreecommitdiff
path: root/src/common.c
diff options
context:
space:
mode:
authorKEKW555 <152369890+KEKW555@users.noreply.github.com>2023-12-04 03:36:21 +0530
committerGitHub <noreply@github.com>2023-12-03 14:06:21 -0800
commita8d19c09fc37335b73b24cb5eac0c27a403762a9 (patch)
tree76c2e13317dd6ced07dcc61c54c624dd4e626a23 /src/common.c
parentd0a8433e2cede945fccace6f169b48865817f808 (diff)
Match sub_0801E49C (#638)
* Nuke sub_0801E49C.inc * Match sub_0801E49C * Fix data types * Match signature * Add typecast and referring function signature * Fix lint issue
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/src/common.c b/src/common.c
index 3b661be7..60461523 100644
--- a/src/common.c
+++ b/src/common.c
@@ -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);
@@ -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;