Decompile manager2E

This commit is contained in:
octorock 2021-08-30 17:55:34 +02:00
parent 3f247035d0
commit 14323b92be
12 changed files with 211 additions and 246 deletions

View File

@ -1,12 +0,0 @@
.syntax unified
push {lr}
ldr r2, _0805D028 @ =gUnk_08108D30
ldrb r1, [r0, #0xc]
lsls r1, r1, #2
adds r1, r1, r2
ldr r1, [r1]
bl _call_via_r1
pop {pc}
.align 2, 0
_0805D028: .4byte gUnk_08108D30
.syntax divided

View File

@ -1,30 +0,0 @@
.syntax unified
push {r4, r5, lr}
adds r4, r0, #0
ldrb r0, [r4, #0xf]
subs r0, #1
strb r0, [r4, #0xf]
lsls r0, r0, #0x18
cmp r0, #0
bne _0805D0D8
movs r0, #0xb4
strb r0, [r4, #0xf]
_0805D0D8:
adds r5, r4, #0
adds r5, #0x36
ldrb r0, [r5]
cmp r0, #0xf
bne _0805D0F6
movs r0, #2
strb r0, [r4, #0xc]
movs r0, #8
strb r0, [r4, #0xe]
movs r0, #0x72
bl SoundReq
adds r0, r4, #0
bl sub_0805D11C
_0805D0F6:
movs r0, #0
strb r0, [r5]
pop {r4, r5, pc}
.syntax divided

View File

@ -1,17 +0,0 @@
.syntax unified
push {r4, lr}
adds r4, r0, #0
ldrb r0, [r4, #0xe]
subs r0, #1
strb r0, [r4, #0xe]
lsls r0, r0, #0x18
cmp r0, #0
bne _0805D118
ldrh r0, [r4, #0x3e]
bl SetFlag
adds r0, r4, #0
bl DeleteManager
_0805D118:
pop {r4, pc}
.align 2, 0
.syntax divided

View File

@ -1,31 +0,0 @@
.syntax unified
push {r4, lr}
adds r4, r0, #0
ldrh r0, [r4, #0x3c]
bl CheckFlags
cmp r0, #0
beq _0805D292
bl DeleteThisEntity
_0805D292:
ldrh r0, [r4, #0x3e]
bl CheckFlags
cmp r0, #0
beq _0805D2A6
ldrh r0, [r4, #0x3c]
bl SetFlag
bl DeleteThisEntity
_0805D2A6:
movs r0, #1
strb r0, [r4, #0xc]
ldrb r0, [r4, #0xe]
cmp r0, #0
bne _0805D2B4
movs r0, #0x1e
strb r0, [r4, #0xe]
_0805D2B4:
adds r0, r4, #0
movs r1, #6
bl sub_0805E3A0
pop {r4, pc}
.align 2, 0
.syntax divided

View File

@ -1,27 +0,0 @@
.syntax unified
push {r4, lr}
adds r4, r0, #0
ldrh r0, [r4, #0x3e]
bl CheckFlags
cmp r0, #0
beq _0805D2EE
ldr r0, _0805D2F0 @ =gUnk_03003DC0
ldrh r0, [r0, #8]
cmp r0, #1
bhi _0805D2EE
movs r0, #2
strb r0, [r4, #0xc]
ldrb r0, [r4, #0xe]
cmp r0, #1
bne _0805D2E6
adds r0, r4, #0
bl sub_0805D2F4
_0805D2E6:
ldrb r1, [r4, #0xe]
adds r0, r4, #0
bl sub_0805E4E0
_0805D2EE:
pop {r4, pc}
.align 2, 0
_0805D2F0: .4byte gUnk_03003DC0
.syntax divided

View File

@ -1,29 +0,0 @@
.syntax unified
push {r4, lr}
adds r4, r0, #0
ldr r0, _0805D310 @ =gUnk_03003DC0
ldrh r0, [r0, #8]
cmp r0, #0
bne _0805D328
movs r1, #0x38
ldrsh r0, [r4, r1]
cmp r0, #0
beq _0805D314
bl SoundReq
b _0805D31A
.align 2, 0
_0805D310: .4byte gUnk_03003DC0
_0805D314:
movs r0, #0x72
bl SoundReq
_0805D31A:
ldrh r0, [r4, #0x3c]
cmp r0, #0
beq _0805D324
bl SetFlag
_0805D324:
bl DeleteThisEntity
_0805D328:
pop {r4, pc}
.align 2, 0
.syntax divided

View File

@ -1,12 +0,0 @@
.syntax unified
push {lr}
ldr r2, _0805D340 @ =gUnk_08108D50
ldrb r1, [r0, #0xc]
lsls r1, r1, #2
adds r1, r1, r2
ldr r1, [r1]
bl _call_via_r1
pop {pc}
.align 2, 0
_0805D340: .4byte gUnk_08108D50
.syntax divided

View File

@ -1,21 +0,0 @@
.syntax unified
push {r4, lr}
adds r4, r0, #0
ldrh r0, [r4, #0x3e]
bl CheckFlags
movs r0, #1
strb r0, [r4, #0xc]
ldrb r0, [r4, #0xe]
cmp r0, #0
bne _0805D35C
movs r0, #0x1e
strb r0, [r4, #0xe]
_0805D35C:
ldrb r0, [r4, #0xe]
strb r0, [r4, #0xf]
adds r0, r4, #0
movs r1, #6
bl sub_0805E3A0
pop {r4, pc}
.align 2, 0
.syntax divided

View File

@ -1,14 +0,0 @@
.syntax unified
push {r4, lr}
adds r4, r0, #0
ldrh r0, [r4, #0x3e]
bl CheckFlags
cmp r0, #0
beq _0805D382
movs r0, #2
strb r0, [r4, #0xc]
ldrb r0, [r4, #0xf]
strb r0, [r4, #0xe]
_0805D382:
pop {r4, pc}
.syntax divided

View File

@ -1,35 +0,0 @@
.syntax unified
push {r4, lr}
adds r4, r0, #0
ldrb r0, [r4, #0xe]
cmp r0, #0
beq _0805D3B2
subs r0, #1
strb r0, [r4, #0xe]
lsls r0, r0, #0x18
cmp r0, #0
bne _0805D3C6
movs r1, #0x38
ldrsh r0, [r4, r1]
movs r1, #0x72
cmp r0, #0
beq _0805D3A4
adds r1, r0, #0
_0805D3A4:
adds r0, r1, #0
bl SoundReq
ldrh r0, [r4, #0x3c]
bl SetFlag
b _0805D3C6
_0805D3B2:
ldrh r0, [r4, #0x3e]
bl CheckFlags
cmp r0, #0
bne _0805D3C6
movs r0, #1
strb r0, [r4, #0xc]
ldrh r0, [r4, #0x3c]
bl ClearFlag
_0805D3C6:
pop {r4, pc}
.syntax divided

View File

@ -1,11 +1,119 @@
#include "manager.h"
#include "flags.h"
#include "room.h"
#include "functions.h"
#include "object.h"
#include "audio.h"
ASM_FUNC("asm/non_matching/manager2B/Manager2B_Main.inc", void Manager2B_Main())
typedef struct {
Manager manager;
Entity * field_0x20;
u8 field_0x24;
u8 field_0x25;
u8 field_0x26;
u8 field_0x27;
u8 field_0x28;
u8 field_0x29;
u8 field_0x2a;
u8 field_0x2b;
u8 field_0x2c;
u8 field_0x2d;
u8 field_0x2e;
u8 field_0x2f;
u8 field_0x30;
u8 field_0x31;
u8 field_0x32;
u8 field_0x33;
u8 field_0x34;
u8 field_0x35;
u8 field_0x36;
u8 field_0x37;
u8 field_0x38;
u8 field_0x39;
u8 field_0x3a;
u8 field_0x3b;
u8 field_0x3c;
u8 field_0x3d;
u16 field_0x3e;
} Manager2B;
ASM_FUNC("asm/non_matching/manager2B/sub_0805D02C.inc", void sub_0805D02C())
ASM_FUNC("asm/non_matching/manager2B/sub_0805D0C4.inc", void sub_0805D0C4())
ASM_FUNC("asm/non_matching/manager2B/sub_0805D0FC.inc", void sub_0805D0FC())
extern void (*const gUnk_08108D30[])(Entity*);
ASM_FUNC("asm/non_matching/manager2B/sub_0805D11C.inc", void sub_0805D11C())
extern u8 gEntCount;
void sub_0805D11C(Manager2B*);
void Manager2B_Main(Manager2B* this) {
gUnk_08108D30[this->manager.action](this);
}
NONMATCH("asm/non_matching/manager2B/sub_0805D02C.inc", void sub_0805D02C(Manager2B* this)) {
u32 counter;
u16* objectData;
Entity* object;
Entity** createdObjects;
if (CheckFlags((u32)this->field_0x3e) != 0) {
DeleteThisEntity();
}
if (gEntCount < 0x44) {
objectData = GetCurrentRoomProperty(this->manager.unk_0a);
counter = 0;
createdObjects = &this->field_0x20;
while(counter < 4) {
object = CreateObject(OBJECT_A0, objectData[2], counter);
object->x.HALF.HI = objectData[0] + gRoomControls.roomOriginX;
object->y.HALF.HI = objectData[1] + gRoomControls.roomOriginY;
object->parent = (Entity*)this;
sub_08016A30(object);
*createdObjects = object;
counter += 1;
objectData += 3;
createdObjects += 1;
}
this->manager.action = 1;
this->manager.unk_0f = 0x3c;
this->field_0x36 = 0;
}
}
END_NONMATCH
void sub_0805D0C4(Manager2B* this) {
if (--this->manager.unk_0f == 0) {
this->manager.unk_0f = 0xb4;
}
if (this->field_0x36 == 0xf) {
this->manager.action = 2;
this->manager.unk_0e = 8;
SoundReq(SFX_SECRET);
sub_0805D11C(this);
}
this->field_0x36 = 0;
}
void sub_0805D0FC(Manager2B* this) {
if (--this->manager.unk_0e == 0) {
SetFlag(this->field_0x3e);
DeleteManager(&this->manager);
}
}
NONMATCH("asm/non_matching/manager2B/sub_0805D11C.inc", void sub_0805D11C(Manager2B* this)) {
Entity* entity;
Entity** createdObjects;
u32 counter;
counter = 0;
createdObjects = &this->field_0x20;
while (counter < 4) {
entity = *createdObjects;
*createdObjects = NULL;
sub_0807BA8C(TILE(entity->x.HALF.HI, entity->y.HALF.HI), entity->collisionLayer);
DeleteEntity(entity);
createdObjects += 1;
counter += 1;
}
}
END_NONMATCH

View File

@ -1,27 +1,112 @@
#include "global.h"
#include "entity.h"
#include "manager.h"
#include "flags.h"
#include "functions.h"
#include "audio.h"
extern void (*const gUnk_08108D3C[])(Entity*);
extern void (*const gUnk_08108D44[])(Entity*);
typedef struct {
Manager manager;
u8 field_0x20[0x18];
s16 field_0x38;
u8 field_0x3a;
u8 field_0x3b;
u16 field_0x3c;
u16 field_0x3e;
} Manager2E;
void Manager2E_Main(Entity* this) {
gUnk_08108D3C[this->type](this);
extern void (*const gUnk_08108D3C[])(Manager2E*);
extern void (*const gUnk_08108D44[])(Manager2E*);
void sub_0805D2F4(Manager2E*);
extern void sub_0805E4E0(void*, u32);
extern void (*const gUnk_08108D50[])(Manager2E*);
void Manager2E_Main(Manager2E* this) {
gUnk_08108D3C[this->manager.unk_0a](this);
}
void sub_0805D268(Entity* this) {
gUnk_08108D44[this->action](this);
void sub_0805D268(Manager2E* this) {
gUnk_08108D44[this->manager.action](this);
}
ASM_FUNC("asm/non_matching/manager2E/sub_0805D280.inc", void sub_0805D280())
void sub_0805D280(Manager2E* this) {
if (CheckFlags(this->field_0x3c) != 0) {
DeleteThisEntity();
}
if (CheckFlags(this->field_0x3e) != 0) {
SetFlag(this->field_0x3c);
DeleteThisEntity();
}
this->manager.action = 1;
if (this->manager.unk_0e == 0) {
this->manager.unk_0e = 0x1e;
}
sub_0805E3A0(this, 6);
}
ASM_FUNC("asm/non_matching/manager2E/sub_0805D2C0.inc", void sub_0805D2C0())
void sub_0805D2C0(Manager2E* this) {
if ((CheckFlags(this->field_0x3e) != 0) && (gUnk_03003DC0.unk_0xc < 2)) {
this->manager.action = 2;
if (this->manager.unk_0e == 1) {
sub_0805D2F4(this);
}
sub_0805E4E0(this, this->manager.unk_0e);
}
}
ASM_FUNC("asm/non_matching/manager2E/sub_0805D2F4.inc", void sub_0805D2F4())
void sub_0805D2F4(Manager2E* this) {
if (gUnk_03003DC0.unk_0xc == 0) {
if (this->field_0x38 != SFX_NONE) {
SoundReq(this->field_0x38);
} else {
SoundReq(SFX_SECRET);
}
if (this->field_0x3c != 0) {
SetFlag(this->field_0x3c);
}
DeleteThisEntity();
}
}
ASM_FUNC("asm/non_matching/manager2E/sub_0805D32C.inc", void sub_0805D32C())
void sub_0805D32C(Manager2E* this) {
gUnk_08108D50[this->manager.action](this);
}
ASM_FUNC("asm/non_matching/manager2E/sub_0805D344.inc", void sub_0805D344())
void sub_0805D344(Manager2E* this) {
CheckFlags(this->field_0x3e);
this->manager.action = 1;
if (this->manager.unk_0e == 0) {
this->manager.unk_0e = 0x1e;
}
this->manager.unk_0f = this->manager.unk_0e;
sub_0805E3A0(this, 6);
}
ASM_FUNC("asm/non_matching/manager2E/sub_0805D36C.inc", void sub_0805D36C())
void sub_0805D36C(Manager2E* this) {
if (CheckFlags(this->field_0x3e) != 0) {
this->manager.action = 2;
this->manager.unk_0e = this->manager.unk_0f;
}
}
ASM_FUNC("asm/non_matching/manager2E/sub_0805D384.inc", void sub_0805D384())
void sub_0805D384(Manager2E* this) {
if (this->manager.unk_0e != 0) {
if (--this->manager.unk_0e == 0) {
Sound sound;
if (this->field_0x38 != SFX_NONE) {
sound = this->field_0x38;
} else {
sound = SFX_SECRET;
}
SoundReq(sound);
SetFlag(this->field_0x3c);
}
} else {
if (CheckFlags(this->field_0x3e) == 0) {
this->manager.action = 1;
ClearFlag(this->field_0x3c);
}
}
}