diff --git a/Makefile b/Makefile index 130f29325b..43344a9b01 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ build/src/boot_O2_g3_trapuv/%: OPTIMIZATION := -O2 -g3 build/src/code/%: CFLAGS := $(CFLAGS) -Wab,-r4300_mul build/src/actors/%: CFLAGS := $(CFLAGS) -Wab,-r4300_mul build/src/boot_O2_g3_trapuv/%: CFLAGS := $(CFLAGS) -trapuv -test.txt: OPTIMIZATION := -O2 +test.txt: OPTIMIZATION := -O2 -g3 test.txt: CC := $(QEMU_IRIX) -L $(IRIX_71_ROOT) $(IRIX_71_ROOT)/usr/bin/cc test.txt: CFLAGS := $(CFLAGS) -Wab,-r4300_mul diff --git a/include/functions.h b/include/functions.h index 152ed3015e..0a28e0fc98 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1113,9 +1113,9 @@ void BgCheck3_LoadMesh(GlobalContext* ctxt, BgActor* actor, BgMeshHeader* meshHe void BgCheck3_ResetFlags(BgActor* actor); // func_800CAE7C void func_800CAE88(BgActor* actor); // func_800CAE88 void func_800CAE9C(BgActor* actor); // func_800CAE9C -void func_800CAEB0(void); // func_800CAEB0 +void func_800CAEB0(BgCheckContext* bgCtxt, s32 index); // func_800CAEB0 void func_800CAEE0(BgActor* actor); // func_800CAEE0 -void func_800CAEF4(void); // func_800CAEF4 +void func_800CAEF4(BgCheckContext* bgCtxt, s32 index); // func_800CAEF4 void func_800CAF24(BgActor* actor); // func_800CAF24 void func_800CAF38(BgActor* actor); // func_800CAF38 s32 func_800CAF4C(BgActor* actor); // func_800CAF4C diff --git a/include/structs.h b/include/structs.h index 6a5e4a98b8..d2b335fa35 100644 --- a/include/structs.h +++ b/include/structs.h @@ -2428,7 +2428,9 @@ struct ActorPlayer { struct BgActor { /* 0x000 */ Actor base; /* 0x144 */ s32 bgActorId; -/* 0x148 */ UNK_TYPE1 pad148[0xC]; +/* 0x148 */ f32 unk148; +/* 0x14C */ f32 unk14C; +/* 0x150 */ UNK_TYPE4 unk150; /* 0x154 */ u32 unk154; /* 0x158 */ u8 bgFlags; /* 0x159 */ UNK_TYPE1 pad159[0x3]; diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index 52fc0d4cfb..385c423023 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -322,7 +322,8 @@ SECTIONS build/asm/code_0x800BF9A0.o(.text) build/asm/z_bgcheck.o(.text) build/src/code/code_0x800CAAD0.o(.text) - build/asm/code_0x800CAE10.o(.text) + build/src/code/code_0x800CAE10.o(.text) + build/asm/code_0x800CB000.o(.text) build/asm/z_camera.o(.text) build/src/code/code_0x800E03A0.o(.text) . += 0x10; /* XXX pad with NOPs*/ @@ -459,7 +460,7 @@ SECTIONS build/asm/code_rodata_z_actor.o(.text) build/asm/code_rodata_0x800BF9A0.o(.text) build/asm/code_rodata_z_bgcheck.o(.text) - build/asm/code_rodata_0x800CAE10.o(.text) + build/asm/code_rodata_0x800CB000.o(.text) build/asm/code_rodata_z_camera.o(.text) build/asm/code_rodata_z_collision_check.o(.text) build/asm/code_rodata_0x800E8EA0.o(.text) diff --git a/src/code/code_0x800CAE10.c b/src/code/code_0x800CAE10.c new file mode 100644 index 0000000000..e53b4f6f8b --- /dev/null +++ b/src/code/code_0x800CAE10.c @@ -0,0 +1,100 @@ +#include +#include + +void BcCheck3_BgActorInit(BgActor* actor, UNK_TYPE4 param_2) { + actor->bgActorId = -1; + actor->unk148 = 0; + actor->unk14C = 0; + actor->unk154 = param_2; + actor->bgFlags = 0; +} + +void BgCheck3_LoadMesh(GlobalContext* ctxt, BgActor* actor, BgMeshHeader* meshHeader) { + BgMeshHeader* header; + + header = NULL; + BgCheck_RelocateMeshHeader(meshHeader, &header); + actor->bgActorId = BgCheck_AddActorMesh(ctxt, &ctxt->bgCheckContext.dyna, actor, header); +} + +void BgCheck3_ResetFlags(BgActor* actor) { + actor->bgFlags = 0; +} + +void func_800CAE88(BgActor* actor) { + actor->bgFlags |= 1; +} + +void func_800CAE9C(BgActor* actor) { + actor->bgFlags |= 2; +} + +void func_800CAEB0(BgCheckContext* bgCtxt, s32 index) { + BgActor* actor; + + actor = BgCheck_GetActorOfMesh(bgCtxt, index); + if (actor != (BgActor *)0x0) { + func_800CAE9C(actor); + } +} + +void func_800CAEE0(BgActor* actor) { + actor->bgFlags |= 4; +} + +void func_800CAEF4(BgCheckContext* bgCtxt, s32 index) { + BgActor* actor; + + actor = BgCheck_GetActorOfMesh(bgCtxt, index); + if (actor != (BgActor *)0x0) { + func_800CAEE0(actor); + } +} + +void func_800CAF24(BgActor* actor) { + actor->bgFlags |= 8; +} + +void func_800CAF38(BgActor* actor) { + actor->bgFlags |= 0x10; +} + +s32 func_800CAF4C(BgActor* actor) { + if (actor->bgFlags & 1) { + return 1; + } else { + return 0; + } +} + +s32 func_800CAF70(BgActor* actor) { + if (actor->bgFlags & 2) { + return 1; + } else { + return 0; + } +} + +s32 func_800CAF94(BgActor* actor) { + if (actor->bgFlags & 4) { + return 1; + } else { + return 0; + } +} + +s32 func_800CAFB8(BgActor* actor) { + if (actor->bgFlags & 8) { + return 1; + } else { + return 0; + } +} + +s32 func_800CAFDC(BgActor* actor) { + if (actor->bgFlags & 0x10) { + return 1; + } else { + return 0; + } +} diff --git a/tables/functions.txt b/tables/functions.txt index f6c84c4633..3702b5f4a4 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -1110,9 +1110,9 @@ 0x800CAE7C:("BgCheck3_ResetFlags","void","BgActor* actor"), 0x800CAE88:("func_800CAE88","void","BgActor* actor"), 0x800CAE9C:("func_800CAE9C","void","BgActor* actor"), - 0x800CAEB0:("func_800CAEB0","void","void"), + 0x800CAEB0:("func_800CAEB0","void","BgCheckContext* bgCtxt, s32 index"), 0x800CAEE0:("func_800CAEE0","void","BgActor* actor"), - 0x800CAEF4:("func_800CAEF4","void","void"), + 0x800CAEF4:("func_800CAEF4","void","BgCheckContext* bgCtxt, s32 index"), 0x800CAF24:("func_800CAF24","void","BgActor* actor"), 0x800CAF38:("func_800CAF38","void","BgActor* actor"), 0x800CAF4C:("func_800CAF4C","s32","BgActor* actor"), diff --git a/tables/objects.txt b/tables/objects.txt index 828efa00e9..91e39d7c94 100644 --- a/tables/objects.txt +++ b/tables/objects.txt @@ -272,6 +272,7 @@ 0x800BFB80:"z_bgcheck", 0x800CAAD0:"", 0x800CAE10:"", + 0x800CB000:"", 0x800CB210:"z_camera", 0x800E03A0:"", 0x800E0410:"z_collision_check", @@ -401,7 +402,7 @@ 0x801DC9D0:"code_rodata_z_actor", 0x801DCBB0:"code_rodata_0x800BF9A0", 0x801DCC00:"code_rodata_z_bgcheck", - 0x801DCDB0:"code_rodata_0x800CAE10", + 0x801DCDB0:"code_rodata_0x800CB000", 0x801DCDC0:"code_rodata_z_camera", 0x801DD5C0:"code_rodata_z_collision_check", 0x801DD600:"code_rodata_0x800E8EA0",