Discover how the object AI is loaded

This commit is contained in:
Luciano Ciccariello 2022-02-05 21:07:33 +00:00
parent 34347d33fc
commit aba37decb5
7 changed files with 118 additions and 53 deletions

View File

@ -3,7 +3,7 @@ D_80180040 = 0x80180040;
D_801800B4 = 0x801800B4;
D_801801F8 = 0x801801F8;
g_pStTileset = 0x801802A4;
D_80180498 = 0x80180498;
PfnEntityUpdates = 0x80180498;
D_801809EC = 0x801809EC;
func_8018EC90 = 0x8018EC90;
func_8018E1D4 = 0x8018E1D4;
@ -32,7 +32,10 @@ g_pStrObjLayout18 = 0x80181AF8;
g_pStrObjLayout19 = 0x80181BA2;
g_pStrObjLayout20 = 0x80181C4C;
g_pStrObjLayout21 = 0x80181CF6;
EntityCandle = 0x8018E830;
func_8018E994 = 0x8018E994;
func_8018EDB8 = 0x8018EDB8;
InitializeEntity = 0x80190544;
func_80190F04 = 0x80190F04;
LoadObjLayout = 0x80190D8C;
LoadObjLayout = 0x80190D8C;
DestroyEntity = 0x80191D3C;

View File

@ -1,2 +1,16 @@
PfnEntityUpdates = 0x80180920;
InitializeEntity = 0x801C343C;
DestroyEntity = 0x801C4C64;
LoadObjLayout = 0x801C3C98;
g_pStObjLayout = 0x8018077C;
g_pStObjLayout = 0x8018077C;
EntityCandle = 0x801B7A64;
EntityDamage = 0x801C2D98;
EntityCandleDrop = 0x801C6684;
EntityAreaTitlePopup = 0x801CAFF0;
EntityAbsorbOrb = 0x801CBC74;
EntityWarg = 0x801CF740;
EntityMerman2 = 0x801D49C4;
EntityMerman = 0x801D4B20;
EntityBat = 0x801D6264;
EntityZombie = 0x801D64B0;
EntityBoneScimitar = 0x801D5AAC;

View File

@ -1,2 +1,15 @@
PfnEntityUpdates = 0x801808CC;
LoadObjLayout = 0x801BB508;
g_pStObjLayout = 0x80180728;
g_pStObjLayout = 0x80180728;
EntityCandle = 0x801B26FC;
EntityDamage = 0x801BA608;
InitializeEntity = 0x801BACAC;
DestroyEntity = 0x801BC4D4;
EntityCandleDrop = 0x801BDEF4;
EntityAreaTitlePopup = 0x801C2860;
EntityAbsorbOrb = 0x801C34E4;
EntityMerman2 = 0x801C80DC;
EntityMerman = 0x801C8238;
EntityBat = 0x801C997C;
EntityZombie = 0x801C9BC8;
EntityBoneScimitar = 0x801C91C4;

View File

@ -2,6 +2,8 @@
#define DRA_H
#include "main.h"
typedef void (*PfnEntityUpdate)(struct Entity*);
typedef struct
{
unsigned char width;
@ -70,12 +72,15 @@ typedef struct
s32 accelerationY;
s16 unk10;
s16 unk12;
s32 unk14[3];
s16 unk14;
s16 palette;
s32 unk18;
s32 unk1C;
s16 unk20;
s16 unk22;
s16 unk24;
u16 unk26;
s32 unk28;
s16 zPriority;
u16 objectId;
PfnEntityUpdate pfnUpdate;
u16 unk2C;
s16 unk2E;
s16 unk30;
@ -164,6 +169,8 @@ extern s16 D_80072E8E;
extern s32 D_80072F2C;
extern s32 D_80073060;
extern s32 D_80073080;
extern u16 D_8007308E;
extern u16 D_80073092;
extern s32 g_CurrentRoomHSize;
extern s32 g_CurrentRoomVSize;
extern s32 D_800730AC;

View File

@ -73,7 +73,7 @@ extern s16 D_801809EC[];
extern RoomHeader g_rooms[];
extern ObjectInit* g_pStObjLayout[];
extern ObjectInit** D_801803C8[];
extern s32 D_80180498[];
extern PfnEntityUpdate PfnEntityUpdates[];
extern ObjectInit *D_801997D8;
extern ObjectInit* D_801997DC;
@ -84,7 +84,7 @@ void func_801908DC(s16);
void func_801909D8(s16);
void func_80190B7C(s16);
void func_80190C78(s16);
void func_80191D3C(Entity*);
void DestroyEntity(Entity*);
s32 func_80192914(s16 arg0, s16 arg1);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_8018D8C8);
@ -196,7 +196,7 @@ INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_8018E5AC);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_8018E674);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_8018E830);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", EntityCandle);
u32 func_8018E964(void) {
D_80097364 = (D_80097364 * 0x01010101) + 1;
@ -212,12 +212,12 @@ INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_8018EDB8);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_8018FEA0);
#ifndef NON_MATCHING
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_80190544);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", InitializeEntity);
#else
void func_80190544(Entity* entity, ObjectInit* initDesc) {
func_80191D3C(entity);
entity->unk26 = initDesc->unk4 & 0x3FF;
entity->unk28 = D_80180498[entity->unk26];
void InitializeEntity(Entity* entity, ObjectInit* initDesc) {
DestroyEntity(entity);
entity->objectId = initDesc->unk4 & 0x3FF;
entity->pfnUpdate = PfnEntityUpdates[entity->objectId];
entity->posX.Data.high = initDesc->posX - D_80072B3E;
entity->posY.Data.high = initDesc->posY - D_80072B42;
entity->unk30 = initDesc->unk8;
@ -246,13 +246,13 @@ void func_80190608(ObjectInit* initDesc) {
switch (initDesc->unk4 & 0xE000) {
case 0x0:
entity = &D_80075D88[*(u8*)&initDesc->unk6];
if (entity->unk26 != 0) {
if (entity->objectId != 0) {
break;
}
func_80190544(entity, initDesc);
InitializeEntity(entity, initDesc);
break;
case 0xA000:
func_80190544(&D_80075D88[initDesc->unk6], initDesc);
InitializeEntity(&D_80075D88[initDesc->unk6], initDesc);
break;
}
}
@ -417,7 +417,7 @@ INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_801910A8);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_80191120);
void func_80191D3C(Entity* item) {
void DestroyEntity(Entity* item) {
int i, length;
u32* ptr;
@ -498,9 +498,9 @@ INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_80192618);
Entity* func_80192800(Entity* arg0, Entity* arg1) {
while (arg0 < arg1)
{
if (arg0->unk26 == 0)
if (arg0->objectId == 0)
{
func_80191D3C(arg0);
DestroyEntity(arg0);
return arg0;
}
@ -667,7 +667,7 @@ void func_801937BC(void) {
}
void func_801937C4(void) {
func_80191D3C(D_8006C26C);
DestroyEntity(D_8006C26C);
}
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_801937EC);
@ -675,17 +675,17 @@ INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_801937EC);
void func_801938FC(void) {
D_8003C6D8(0x670);
D_8003C744(5, 0x4000);
func_80191D3C(D_8006C26C);
DestroyEntity(D_8006C26C);
}
void func_8019394C(void) {
D_8003C6D8(0x670);
D_8003C744(5, 0x8000);
func_80191D3C(D_8006C26C);
DestroyEntity(D_8006C26C);
}
void func_8019399C(void) {
func_80191D3C(D_8006C26C);
DestroyEntity(D_8006C26C);
}
Entity* func_801939C4(void) {

View File

@ -1,13 +1,14 @@
#include "common.h"
#include "dra.h"
extern PfnEntityUpdate PfnEntityUpdates[];
extern s16 D_801820C4[];
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801B77D4);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801B78A8);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801B7A64);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityCandle);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801B7B98);
@ -131,9 +132,22 @@ INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C1B78);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C1C80);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C2D98);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityDamage);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C343C);
#ifndef NON_MATCHING
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", InitializeEntity);
#else
void InitializeEntity(Entity* entity, ObjectInit* initDesc) {
DestroyEntity(entity);
entity->objectId = initDesc->unk4 & 0x3FF;
entity->pfnUpdate = PfnEntityUpdates[entity->objectId];
entity->posX.Data.high = initDesc->posX - D_8007308E;
entity->posY.Data.high = initDesc->posY - D_80073092;
entity->unk30 = initDesc->unk8;
entity->unk32 = initDesc->unk6 >> 8;
entity->unk68 = initDesc->unk4 >> 0xA & 7;
}
#endif
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C3500);
@ -167,7 +181,7 @@ INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C3FB4);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C402C);
void func_801C4C64(Entity* item) {
void DestroyEntity(Entity* item) {
int i, length;
u32* ptr;
@ -285,10 +299,10 @@ INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C6568);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C660C);
void func_801C665C(void) {
func_801C4C64(D_8006C3B8);
DestroyEntity(D_8006C3B8);
}
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C6684);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityCandleDrop);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801C6EF8);
@ -342,9 +356,9 @@ INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801CAD28);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801CAE20);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801CAFF0);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityAreaTitlePopup);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801CBC74);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityAbsorbOrb);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801CC008);
@ -382,7 +396,7 @@ INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801CF5E0);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801CF6D8);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801CF740);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityWarg);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D04A4);
@ -420,9 +434,9 @@ INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D4700);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D48F8);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D49C4);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityMerman2);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D4B20);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityMerman);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D56D8);
@ -432,13 +446,13 @@ INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D58D4);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D59D0);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D5AAC);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityBoneScimitar);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D615C);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D6264);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityBat);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D64B0);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", EntityZombie);
INCLUDE_ASM("asm/st/no3/nonmatchings/377D4", func_801D6710);

View File

@ -1,13 +1,14 @@
#include "common.h"
#include "dra.h"
extern PfnEntityUpdate PfnEntityUpdates[];
extern s16 D_80181A50[];
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801B246C);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801B2540);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801B26FC);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", EntityCandle);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801B2830);
@ -89,9 +90,22 @@ INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801B93E8);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801B94F0);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801BA608);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", EntityDamage);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801BACAC);
#ifndef NON_MATCHING
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", InitializeEntity);
#else
void InitializeEntity(Entity* entity, ObjectInit* initDesc) {
DestroyEntity(entity);
entity->objectId = initDesc->unk4 & 0x3FF;
entity->pfnUpdate = PfnEntityUpdates[entity->objectId];
entity->posX.Data.high = initDesc->posX - D_8007308E;
entity->posY.Data.high = initDesc->posY - D_80073092;
entity->unk30 = initDesc->unk8;
entity->unk32 = initDesc->unk6 >> 8;
entity->unk68 = initDesc->unk4 >> 0xA & 7;
}
#endif
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801BAD70);
@ -125,7 +139,7 @@ INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801BB824);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801BB89C);
void func_801BC4D4(Entity* item) {
void DestroyEntity(Entity* item) {
int i, length;
u32* ptr;
@ -243,10 +257,10 @@ INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801BDDD8);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801BDE7C);
void func_801BDECC(void) {
func_801BC4D4(D_8006C3B8);
DestroyEntity(D_8006C3B8);
}
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801BDEF4);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", EntityCandleDrop);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801BE768);
@ -300,9 +314,9 @@ INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C2598);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C2690);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C2860);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", EntityAreaTitlePopup);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C34E4);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", EntityAbsorbOrb);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C3878);
@ -340,9 +354,9 @@ INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C7E18);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C8010);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C80DC);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", EntityMerman2);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C8238);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", EntityMerman);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C8DF0);
@ -352,13 +366,13 @@ INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C8FEC);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C90E8);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C91C4);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", EntityBoneScimitar);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C9874);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C997C);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", EntityBat);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C9BC8);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", EntityZombie);
INCLUDE_ASM("asm/st/np3/nonmatchings/3246C", func_801C9E28);