loadRoom.c

This commit is contained in:
theo3
2020-07-17 19:00:04 -07:00
parent db02fad00a
commit 6328c148d2
9 changed files with 107 additions and 168 deletions
+81 -15
View File
@@ -1,27 +1,93 @@
#include "global.h"
/* called when loading any room */
#include "room.h"
void LoadRoomEntityList();
void LoadRoomEntityList(EntityData* dat);
s32 CheckGlobalFlag(u32 flag);
extern s32* GetCurrentRoomProperty(u8 unk);
extern void sub_0804B058(s32* unk);
extern void sub_0804B1AC();
extern EntityData* GetCurrentRoomProperty(u32 unk);
extern void sub_0804B058(EntityData* dat);
extern void sub_0804B1AC(EntityData* dat);
extern void sub_0801AC98();
extern u32 sub_08049D1C(u32);
extern Entity* CreateEntity(EntityData*);
extern void* GetRoomProperty(u32, u32, u32);
void LoadRoom(void)
{
extern u32 gUnk_02017654;
extern u32* gUnk_080D50FC;
void LoadRoom(void) {
s32 iVar1;
s32* dat;
GetCurrentRoomProperty(1);
LoadRoomEntityList();
GetCurrentRoomProperty(0);
LoadRoomEntityList();
LoadRoomEntityList(GetCurrentRoomProperty(1));
LoadRoomEntityList(GetCurrentRoomProperty(0));
if (CheckGlobalFlag(21)) sub_0804B058(GetCurrentRoomProperty(2));
GetCurrentRoomProperty(3);
sub_0804B1AC();
if (CheckGlobalFlag(21))
sub_0804B058(GetCurrentRoomProperty(2));
sub_0804B1AC(GetCurrentRoomProperty(3));
sub_0801AC98();
}
void sub_0804B058(EntityData* dat) {
Entity* ent;
u32 uVar2;
if ((dat != NULL) && (dat->entityType != 0xff)) {
uVar2 = 0;
do {
if ((uVar2 < 0x20) && ((dat->entityType & 0xf) == 3)) {
if (sub_08049D1C(uVar2) != 0) {
ent = CreateEntity(dat);
if ((ent != NULL) && ((ent->entityType).type == 3)) {
ent->field_0x6c = uVar2 | 0x80;
}
}
} else {
CreateEntity(dat);
}
uVar2++;
dat++;
} while (dat->entityType != 0xff);
}
}
void sub_0804B0B0(u32 arg0, u32 arg1)
{
LoadRoomEntityList(GetRoomProperty(arg0, arg1, 1));
}
void SetCurrentRoomPropertyList(u32 arg0, u32 arg1)
{
u32** arr;
gUnk_02017654 = 0;
arr = &gUnk_080D50FC;
if (arr[arg0] != 0) {
gUnk_02017654 = arr[arg0][arg1];
}
}
void sub_0804B0E8(u32 arg0, u32 arg1)
{
void (* func)();
func = (void (*)())GetRoomProperty(arg0, arg1, 4);
if (func != NULL) {
func();
}
}
// returns multiple types of data?
void* GetRoomProperty(u32 arg0, u32 arg1, u32 arg2)
{
u32 temp;
u32** arr;
temp = 0;
arr = &gUnk_080D50FC;
if (arr[arg0] != NULL) {
temp = arr[arg0][arg1];
if (temp != 0) {
temp = *(u32 *)(arg2 * 4 + temp);
}
}
return (void*)temp;
}
+17 -11
View File
@@ -1,20 +1,26 @@
#include "global.h"
#include "menu.h"
#include "functions.h"
extern void (*const gUnk_08128BF8[])(void);
extern u8 gUnk_02000090;
u32 sub_080A554C(u32 param_1)
u32 sub_080A554C(u32 arg0)
{
u32 uVar1;
u32 i;
if (param_1 != 0) {
uVar1 = 0;
do {
if (param_1 == (&gUnk_02000090)[uVar1]) {
return uVar1;
}
uVar1 = uVar1 + 1;
} while (uVar1 < 17);
if (arg0 != 0) {
for (i = 0; i < 17; i++) {
if (arg0 == (&gUnk_02000090)[i])
return i;
}
}
return 17;
}
void sub_080A5574(void)
{
gUnk_08128BF8[gMenu.secret]();
sub_080A57F4();
}