mirror of https://github.com/zeldaret/tmc.git
Merge pull request #547 from hatal175/DelayedEntityLoadManager_Main
This commit is contained in:
commit
bbcea04f9e
|
@ -1,184 +0,0 @@
|
|||
.syntax unified
|
||||
push {r4, r5, r6, r7, lr}
|
||||
mov r7, sl
|
||||
mov r6, sb
|
||||
mov r5, r8
|
||||
push {r5, r6, r7}
|
||||
adds r6, r0, #0
|
||||
ldrb r0, [r6, #0xa]
|
||||
bl GetCurrentRoomProperty
|
||||
adds r4, r0, #0
|
||||
cmp r4, #0
|
||||
bne _0805AB68
|
||||
bl DeleteThisEntity
|
||||
_0805AB68:
|
||||
ldrb r0, [r6, #0xc]
|
||||
movs r1, #0x20
|
||||
adds r1, r1, r6
|
||||
mov r8, r1
|
||||
cmp r0, #0
|
||||
bne _0805ABC8
|
||||
adds r0, #1
|
||||
strb r0, [r6, #0xc]
|
||||
ldr r0, _0805ABF0 @ =gArea
|
||||
ldrb r0, [r0, #8]
|
||||
strb r0, [r1]
|
||||
adds r0, r6, #0
|
||||
movs r1, #6
|
||||
bl SetDefaultPriority
|
||||
ldr r2, _0805ABF4 @ =gNPCData
|
||||
ldrb r0, [r6, #0xb]
|
||||
mov r3, r8
|
||||
ldrb r1, [r3]
|
||||
adds r0, r0, r1
|
||||
lsls r0, r0, #4
|
||||
adds r2, r0, r2
|
||||
movs r5, #0
|
||||
mov sl, r5
|
||||
ldrb r0, [r4]
|
||||
movs r7, #0x21
|
||||
adds r7, r7, r6
|
||||
mov ip, r7
|
||||
cmp r0, #0xff
|
||||
beq _0805ABBE
|
||||
_0805ABA4:
|
||||
adds r1, r2, #0
|
||||
adds r0, r4, #0
|
||||
ldm r0!, {r3, r5, r7}
|
||||
stm r1!, {r3, r5, r7}
|
||||
ldr r0, [r0]
|
||||
str r0, [r1]
|
||||
movs r0, #1
|
||||
add sl, r0
|
||||
adds r4, #0x10
|
||||
adds r2, #0x10
|
||||
ldrb r0, [r4]
|
||||
cmp r0, #0xff
|
||||
bne _0805ABA4
|
||||
_0805ABBE:
|
||||
movs r0, #0xff
|
||||
strb r0, [r2]
|
||||
mov r2, sl
|
||||
mov r1, ip
|
||||
strb r2, [r1]
|
||||
_0805ABC8:
|
||||
ldr r4, _0805ABF4 @ =gNPCData
|
||||
ldrb r2, [r6, #0xb]
|
||||
mov r3, r8
|
||||
ldrb r1, [r3]
|
||||
adds r0, r2, r1
|
||||
lsls r0, r0, #4
|
||||
adds r4, r0, r4
|
||||
ldr r0, _0805ABF8 @ =gSave
|
||||
movs r5, #1
|
||||
mov sl, r5
|
||||
mov r7, sl
|
||||
ldrb r0, [r0, #8]
|
||||
lsls r7, r0
|
||||
mov sl, r7
|
||||
adds r0, r1, #7
|
||||
asrs r0, r0, #3
|
||||
ldr r1, _0805ABFC @ =gUnk_020342F8
|
||||
adds r7, r0, r1
|
||||
adds r5, r2, #0
|
||||
b _0805ACAA
|
||||
.align 2, 0
|
||||
_0805ABF0: .4byte gArea
|
||||
_0805ABF4: .4byte gNPCData
|
||||
_0805ABF8: .4byte gSave
|
||||
_0805ABFC: .4byte gUnk_020342F8
|
||||
_0805AC00:
|
||||
ldrh r0, [r4, #4]
|
||||
ldrh r1, [r4, #6]
|
||||
movs r2, #0x18
|
||||
movs r3, #0x20
|
||||
bl CheckRectOnScreen
|
||||
cmp r0, #0
|
||||
bne _0805AC1A
|
||||
adds r0, r7, #0
|
||||
adds r1, r5, #0
|
||||
bl ClearBit
|
||||
b _0805ACA6
|
||||
_0805AC1A:
|
||||
ldrh r0, [r4, #0xe]
|
||||
mov r1, sl
|
||||
ands r0, r1
|
||||
cmp r0, #0
|
||||
beq _0805ACA6
|
||||
ldr r0, _0805AC5C @ =gEntCount
|
||||
ldrb r0, [r0]
|
||||
cmp r0, #0x46
|
||||
bhi _0805ACA6
|
||||
adds r0, r7, #0
|
||||
adds r1, r5, #0
|
||||
bl WriteBit
|
||||
cmp r0, #0
|
||||
bne _0805ACA6
|
||||
ldr r0, [r4, #8]
|
||||
cmp r0, #0
|
||||
beq _0805AC48
|
||||
bl CreateScriptExecutionContext
|
||||
mov sb, r0
|
||||
cmp r0, #0
|
||||
beq _0805ACA6
|
||||
_0805AC48:
|
||||
ldrb r0, [r6, #0xe]
|
||||
cmp r0, #0
|
||||
bne _0805AC60
|
||||
ldrb r0, [r4]
|
||||
ldrb r1, [r4, #1]
|
||||
ldrb r2, [r4, #2]
|
||||
bl CreateNPC
|
||||
b _0805AC6A
|
||||
.align 2, 0
|
||||
_0805AC5C: .4byte gEntCount
|
||||
_0805AC60:
|
||||
ldrb r0, [r4]
|
||||
ldrb r1, [r4, #1]
|
||||
ldrb r2, [r4, #2]
|
||||
bl CreateObject
|
||||
_0805AC6A:
|
||||
adds r3, r0, #0
|
||||
mov r2, r8
|
||||
ldrb r0, [r2]
|
||||
adds r0, #1
|
||||
adds r0, r5, r0
|
||||
adds r1, r3, #0
|
||||
adds r1, #0x45
|
||||
strb r0, [r1]
|
||||
ldrh r0, [r4, #0xc]
|
||||
strb r0, [r3, #0xe]
|
||||
ldr r1, _0805ACBC @ =gRoomControls
|
||||
ldrh r0, [r1, #6]
|
||||
ldrh r2, [r4, #4]
|
||||
adds r0, r0, r2
|
||||
strh r0, [r3, #0x2e]
|
||||
ldrh r0, [r1, #8]
|
||||
ldrh r1, [r4, #6]
|
||||
adds r0, r0, r1
|
||||
strh r0, [r3, #0x32]
|
||||
ldrb r1, [r4, #3]
|
||||
adds r0, r3, #0
|
||||
adds r0, #0x38
|
||||
strb r1, [r0]
|
||||
ldr r2, [r4, #8]
|
||||
cmp r2, #0
|
||||
beq _0805ACA6
|
||||
adds r0, r3, #0
|
||||
mov r1, sb
|
||||
bl InitScriptForEntity
|
||||
_0805ACA6:
|
||||
adds r4, #0x10
|
||||
adds r5, #1
|
||||
_0805ACAA:
|
||||
ldrb r0, [r4]
|
||||
cmp r0, #0xff
|
||||
bne _0805AC00
|
||||
pop {r3, r4, r5}
|
||||
mov r8, r3
|
||||
mov sb, r4
|
||||
mov sl, r5
|
||||
pop {r4, r5, r6, r7, pc}
|
||||
.align 2, 0
|
||||
_0805ACBC: .4byte gRoomControls
|
||||
.syntax divided
|
|
@ -46,5 +46,6 @@ extern u32 sub_0800445C(struct Entity_*);
|
|||
extern u32 sub_080B1AF0(struct Entity_*, s32, s32);
|
||||
extern u32 GetRelativeCollisionTile(struct Entity_*, u32, u32);
|
||||
extern bool32 sub_080B1B54(u32);
|
||||
extern u32 CheckRectOnScreen(s32, s32, u32, u32);
|
||||
|
||||
#endif // ASM_H
|
||||
|
|
|
@ -51,6 +51,19 @@ typedef struct {
|
|||
} data;
|
||||
} Dialog;
|
||||
|
||||
typedef struct {
|
||||
/*0x00*/ u8 id;
|
||||
/*0x01*/ u8 type;
|
||||
/*0x02*/ u8 type2;
|
||||
/*0x03*/ u8 collisionLayer;
|
||||
/*0x04*/ u16 x;
|
||||
/*0x06*/ u16 y;
|
||||
/*0x08*/ u16* script;
|
||||
/*0x0c*/ u16 timer;
|
||||
/*0x0e*/ u16 progressBitfield; /**< For which gSave.global_process this NPC should appear. */
|
||||
} NPCStruct;
|
||||
extern NPCStruct gNPCData[50];
|
||||
|
||||
void sub_0806EC20(Entity* ent);
|
||||
void sub_0806EC38(void);
|
||||
u32 sub_0806ED78(Entity* ent);
|
||||
|
|
|
@ -29,6 +29,8 @@ typedef struct {
|
|||
} ActiveScriptInfo;
|
||||
extern ActiveScriptInfo gActiveScriptInfo;
|
||||
|
||||
ScriptExecutionContext* CreateScriptExecutionContext(void);
|
||||
void InitScriptForEntity(Entity*, ScriptExecutionContext*, u16*);
|
||||
void ExecuteScript(Entity* entity, ScriptExecutionContext* context);
|
||||
|
||||
extern u32 GetNextScriptCommandHalfword(u16*);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue