diff options
| author | notyourav <65437533+notyourav@users.noreply.github.com> | 2022-08-04 11:44:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-04 11:44:01 -0700 |
| commit | bbcea04f9ef17002bb98f1793ff058dc34b4f235 (patch) | |
| tree | daf0e58fe58d5f4d46d678ab044b5e1b80fefaad /src | |
| parent | 7f3bc829e91af0b15fd2d969bcc93b348931b92e (diff) | |
| parent | b20c9cb98c33feef7ec6c82c9231987ed238615e (diff) | |
Merge pull request #547 from hatal175/DelayedEntityLoadManager_Main
Diffstat (limited to 'src')
| -rw-r--r-- | src/manager/delayedEntityLoadManager.c | 74 | ||||
| -rw-r--r-- | src/manager/houseSignManager.c | 3 | ||||
| -rw-r--r-- | src/manager/lightManager.c | 2 | ||||
| -rw-r--r-- | src/manager/minishSizedEntranceManager.c | 3 | ||||
| -rw-r--r-- | src/npc.c | 9 | ||||
| -rw-r--r-- | src/object/houseSign.c | 5 | ||||
| -rw-r--r-- | src/script.c | 1 |
7 files changed, 78 insertions, 19 deletions
diff --git a/src/manager/delayedEntityLoadManager.c b/src/manager/delayedEntityLoadManager.c index a878d70e..f113330a 100644 --- a/src/manager/delayedEntityLoadManager.c +++ b/src/manager/delayedEntityLoadManager.c @@ -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; diff --git a/src/manager/houseSignManager.c b/src/manager/houseSignManager.c index 6478310e..8722de83 100644 --- a/src/manager/houseSignManager.c +++ b/src/manager/houseSignManager.c @@ -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 }, diff --git a/src/manager/lightManager.c b/src/manager/lightManager.c index 9aa3df2c..edad0b7d 100644 --- a/src/manager/lightManager.c +++ b/src/manager/lightManager.c @@ -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(); diff --git a/src/manager/minishSizedEntranceManager.c b/src/manager/minishSizedEntranceManager.c index de5a1969..3cac2f1f 100644 --- a/src/manager/minishSizedEntranceManager.c +++ b/src/manager/minishSizedEntranceManager.c @@ -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; @@ -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; } diff --git a/src/object/houseSign.c b/src/object/houseSign.c index 7e5413b0..b8972164 100644 --- a/src/object/houseSign.c +++ b/src/object/houseSign.c @@ -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(); } diff --git a/src/script.c b/src/script.c index ed3d67e4..a8725c7d 100644 --- a/src/script.c +++ b/src/script.c @@ -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); |
