Merge pull request #547 from hatal175/DelayedEntityLoadManager_Main

This commit is contained in:
notyourav
2022-08-04 11:44:01 -07:00
committed by GitHub
11 changed files with 94 additions and 203 deletions
+72 -2
View File
@@ -6,9 +6,79 @@
*/
#include "manager/delayedEntityLoadManager.h"
#include "room.h"
#include "npc.h"
#include "area.h"
#include "asm.h"
ASM_FUNC("asm/non_matching/delayedEntityLoadManager/DelayedEntityLoadManager_Main.inc",
void DelayedEntityLoadManager_Main())
typedef struct {
Manager base;
u8 unk_20;
u8 spawnedCount; /**< Count of entities spawned by this manager */
} DelayedEntityLoadManager;
extern u8 gUnk_020342F8[];
void DelayedEntityLoadManager_Main(DelayedEntityLoadManager* this) {
NPCStruct* properties;
NPCStruct* npcPtr;
NPCStruct* npcPtr2;
Entity* entity;
u32 index1;
u32 index2;
u32 tmp;
u32 progressMask;
u8* bitfield;
ScriptExecutionContext* context;
properties = GetCurrentRoomProperty(super->type);
if (properties == NULL) {
DeleteThisEntity();
}
if (super->action == 0) {
super->action++;
this->unk_20 = gArea.filler[2];
SetDefaultPriority((Entity*)this, 6);
npcPtr = gNPCData;
npcPtr += (super->type2 + this->unk_20);
index1 = 0;
while (properties->id != 0xff) {
*npcPtr = *properties;
index1++;
properties++;
npcPtr++;
}
npcPtr->id = 0xff;
this->spawnedCount = index1;
}
npcPtr2 = gNPCData;
npcPtr2 = &npcPtr2[(super->type2 + this->unk_20)];
progressMask = 1 << gSave.global_progress;
bitfield = &gUnk_020342F8[(this->unk_20 + 7) / 8];
index2 = super->type2;
while (npcPtr2->id != 0xff) {
if (!CheckRectOnScreen(npcPtr2->x, npcPtr2->y, 0x18, 0x20)) {
ClearBit(bitfield, index2);
} else if ((npcPtr2->progressBitfield & progressMask) && gEntCount < 0x47 && !WriteBit(bitfield, index2) &&
(npcPtr2->script == NULL || (context = CreateScriptExecutionContext(), context != NULL))) {
if (super->timer == 0) {
entity = CreateNPC(npcPtr2->id, npcPtr2->type, npcPtr2->type2);
} else {
entity = CreateObject(npcPtr2->id, npcPtr2->type, npcPtr2->type2);
}
tmp = this->unk_20 + 1;
entity->health = index2 + tmp;
entity->timer = npcPtr2->timer;
entity->x.HALF.HI = npcPtr2->x + gRoomControls.origin_x;
entity->y.HALF.HI = npcPtr2->y + gRoomControls.origin_y;
entity->collisionLayer = npcPtr2->collisionLayer;
if (npcPtr2->script != NULL) {
InitScriptForEntity(entity, context, npcPtr2->script);
}
}
npcPtr2++;
index2++;
}
}
u32 sub_0805ACC0(Entity* param_1) {
u16* ptr;
+1 -2
View File
@@ -11,6 +11,7 @@
#include "area.h"
#include "object.h"
#include "room.h"
#include "asm.h"
typedef struct {
u16 x;
@@ -21,8 +22,6 @@ typedef struct {
u8 _padding;
} SpawnData;
extern u32 CheckRectOnScreen(u16, u16, u32, u32);
void HouseSignManager_Main(HouseSignManager* this) {
static const SpawnData gUnk_081084C8[] = {
{ 0x48, 0x90, 0x0, 0x0, 0x2, 0x0 }, { 0x138, 0x30, 0x1, 0x1, 0x2, 0x0 },
+1 -1
View File
@@ -14,10 +14,10 @@
#include "player.h"
#include "room.h"
#include "screen.h"
#include "asm.h"
extern void sub_0801E120(void);
extern void sub_0801E154(u32);
extern u32 CheckRectOnScreen(s32, s32, u32, u32);
extern void sub_0801E160(u32, u32, u32);
bool32 sub_0805BA78();
+1 -2
View File
@@ -9,8 +9,7 @@
#include "functions.h"
#include "object.h"
#include "room.h"
extern bool32 CheckRectOnScreen(u16, u16, u32, u32);
#include "asm.h"
typedef struct {
u16 x;
+1 -8
View File
@@ -4,13 +4,6 @@
#include "npc.h"
extern u32 gUnk_020342F8;
typedef struct {
u16 unk0;
u16 unk1;
u16 x;
u16 y;
} NPCStruct;
extern NPCStruct gNPCData[100];
extern void InitNPC(Entity*);
@@ -29,7 +22,7 @@ void NPCUpdate(Entity* this) {
if (this->health % 0x80) {
NPCStruct* npc = gNPCData;
npc += (this->health * 2 - 2);
npc += (this->health - 1);
npc->x = this->x.HALF.HI - gRoomControls.origin_x;
npc->y = this->y.HALF.HI - gRoomControls.origin_y;
}
+2 -3
View File
@@ -5,8 +5,7 @@
* @brief HouseSign object
*/
#include "entity.h"
extern u32 CheckRectOnScreen(s16, s16, u32, u32);
#include "asm.h"
/*
This object is created by HouseSignManager.
@@ -17,7 +16,7 @@ void HouseSign(Entity* this) {
if (this->action == 0) {
this->action = 1;
}
if (CheckRectOnScreen(this->field_0x80.HWORD, this->field_0x82.HWORD, 0x10, 0x10) == 0) {
if (CheckRectOnScreen((s16)this->field_0x80.HWORD, (s16)this->field_0x82.HWORD, 0x10, 0x10) == 0) {
this->parent->zVelocity &= ~(1 << this->type2);
DeleteThisEntity();
}
-1
View File
@@ -10,7 +10,6 @@
#include "item.h"
#include "ui.h"
void InitScriptForEntity(Entity*, ScriptExecutionContext*, u16*);
void InitScriptExecutionContext(ScriptExecutionContext* context, u16* script);
void sub_0807DE80(Entity*);
void DisablePauseMenu(void);