Merge pull request #253 from hatal175/castorwild

This commit is contained in:
notyourav 2022-01-08 01:18:16 -08:00 committed by GitHub
commit 1dacfa1745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 91 additions and 84 deletions

View File

@ -1,63 +0,0 @@
.syntax unified
push {lr}
adds r3, r0, #0
adds r2, r1, #0
ldrb r0, [r2, #0x18]
cmp r0, #1
beq _08067706
cmp r0, #1
bgt _080676F6
cmp r0, #0
beq _080676FC
b _08067734
_080676F6:
cmp r0, #2
beq _08067722
b _08067734
_080676FC:
movs r0, #1
strb r0, [r2, #0x18]
movs r0, #0x20
strb r0, [r2, #0x19]
b _08067742
_08067706:
ldrb r1, [r2, #0x19]
lsrs r0, r1, #1
subs r0, #0x10
strh r0, [r3, #0x36]
subs r1, #1
strb r1, [r2, #0x19]
lsls r1, r1, #0x18
cmp r1, #0
bne _08067742
movs r0, #2
strb r0, [r2, #0x18]
movs r0, #0x24
strb r0, [r2, #0x19]
b _08067742
_08067722:
ldrb r0, [r2, #0x19]
subs r0, #1
strb r0, [r2, #0x19]
lsls r0, r0, #0x18
cmp r0, #0
bne _08067742
movs r0, #3
strb r0, [r2, #0x18]
b _08067742
_08067734:
movs r1, #0xc0
lsls r1, r1, #5
adds r0, r3, #0
bl GravityUpdate
cmp r0, #0
beq _08067748
_08067742:
ldr r1, _0806774C @ =gActiveScriptInfo
movs r0, #0
strb r0, [r1, #6]
_08067748:
pop {pc}
.align 2, 0
_0806774C: .4byte gActiveScriptInfo
.syntax divided

View File

@ -4,28 +4,28 @@
#include "entity.h"
typedef struct ScriptExecutionContext {
u16* scriptInstructionPointer;
u32 intVariable;
u32 postScriptActions;
u8 unk_0C[0x4]; // unused
u16 wait;
u16 unk_12;
u32 condition;
u8 unk_18;
u8 unk_19;
u8 unk_1A;
u8 unk_1B; // unused
union SplitWord x;
union SplitWord y;
/*0x00*/ u16* scriptInstructionPointer;
/*0x03*/ u32 intVariable;
/*0x08*/ u32 postScriptActions;
/*0x0C*/ u8 unk_0C[0x4]; // unused
/*0x10*/ u16 wait;
/*0x12*/ u16 unk_12;
/*0x14*/ u32 condition;
/*0x18*/ u8 unk_18;
/*0x19*/ u8 unk_19;
/*0x1A*/ u8 unk_1A;
/*0x1B*/ u8 unk_1B; // unused
/*0x1C*/ union SplitWord x;
/*0x20*/ union SplitWord y;
} ScriptExecutionContext;
typedef struct {
// Sync flags are used to synchronize scripts running on different entities
u32 syncFlags;
u16 commandIndex;
u8 commandSize;
u8 flags;
u8 unk_08;
/*0x0*/ u32 syncFlags;
/*0x4*/ u16 commandIndex;
/*0x6*/ u8 commandSize;
/*0x7*/ u8 flags;
/*0x8*/ u8 unk_08;
} ActiveScriptInfo;
extern ActiveScriptInfo gActiveScriptInfo;

View File

@ -15,6 +15,13 @@ extern s8 gUnk_08110E64[];
extern u32 gUnk_08110E68[];
typedef struct {
s8 x;
s8 y;
} PACKED PosOffset;
extern PosOffset gUnk_08110E78[];
extern PosOffset gUnk_08110E8A[];
void CastorWildsStatue(Entity* this) {
if ((this->flags & 2) != 0) {
gUnk_08110E5C[this->action](this);
@ -113,14 +120,77 @@ void sub_0806757C(Entity* this) {
}
}
ASM_FUNC("asm/non_matching/castorWildsStatue/sub_080675D4.inc", void sub_080675D4(Entity* this))
void sub_080675D4(Entity* this) {
PosOffset* gUnk = gUnk_08110E78;
u32 subAction = (this->subAction << 2) - 0xc;
s32 i;
for (i = 0; i < 9; i++, gUnk++) {
Entity* ent = CreateFx(this, 2, 0);
if (ent) {
ent->x.HALF.HI += gUnk->x;
ent->y.HALF.HI += gUnk->y;
ent->z.HALF.HI = subAction;
ent->collisionLayer = this->collisionLayer;
ent->spriteOrientation.flipY = this->spriteOrientation.flipY;
ent->spriteRendering.b3 = this->spriteRendering.b3;
ResolveEntityOnTop(this, ent);
}
};
gUnk = gUnk_08110E8A;
for (i = 0; i < 4; i++, gUnk++) {
Entity* ent = CreateFx(this, 4, 0);
if (ent) {
ent->x.HALF.HI = gUnk->x + ent->x.HALF.HI;
ent->y.HALF.HI = gUnk->y + ent->y.HALF.HI;
ent->z.HALF.HI = subAction;
ent->collisionLayer = this->collisionLayer;
ent->spriteOrientation.flipY = this->spriteOrientation.flipY;
ent->spriteRendering.b3 = this->spriteRendering.b3;
ResolveEntityOnTop(this, ent);
}
};
if (this->subAction > 2) {
this->spriteSettings.draw = 0;
}
}
void sub_080676D8(Entity* this) {
this->subAction += 1;
}
ASM_FUNC("asm/non_matching/castorWildsStatue/sub_080676E0.inc",
void sub_080676E0(Entity* this, ScriptExecutionContext* context))
void sub_080676E0(Entity* this, ScriptExecutionContext* context) {
switch (context->unk_18) {
case 0: {
context->unk_18 = 1;
context->unk_19 = 0x20;
break;
}
case 1: {
this->z.HALF.HI = (context->unk_19 >> 1) - 0x10;
if (--context->unk_19 == 0) {
context->unk_18 = 2;
context->unk_19 = 0x24;
}
break;
}
case 2: {
if (--context->unk_19 == 0) {
context->unk_18 = 3;
}
break;
}
default: {
if (GravityUpdate(this, 0x1800) == 0) {
return;
}
break;
}
}
gActiveScriptInfo.commandSize = 0;
}
void CastorWildsStatue_Fusion(Entity* this) {
if (this->action == 0) {