Merge pull request #307 from hatal175/enemy49

Decompile Enemy49
This commit is contained in:
notyourav 2022-01-20 22:06:06 -08:00 committed by GitHub
commit 5244e059ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 161 additions and 349 deletions

View File

@ -1,317 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start Enemy49
Enemy49: @ 0x0803CE80
push {lr}
ldr r2, _0803CE94 @ =gUnk_080D0448
ldrb r1, [r0, #0xc]
lsls r1, r1, #2
adds r1, r1, r2
ldr r1, [r1]
bl _call_via_r1
pop {pc}
.align 2, 0
_0803CE94: .4byte gUnk_080D0448
thumb_func_start sub_0803CE98
sub_0803CE98: @ 0x0803CE98
push {r4, r5, r6, lr}
adds r6, r0, #0
adds r1, r6, #0
adds r1, #0x84
ldrh r2, [r1]
movs r5, #0xf0
lsls r5, r5, #8
adds r0, r5, #0
ands r0, r2
lsrs r0, r0, #5
strh r0, [r6, #0x24]
ldrh r2, [r1]
ldr r4, _0803CF1C @ =0x00000FFF
adds r0, r4, #0
ands r0, r2
strh r0, [r1]
adds r0, r6, #0
bl sub_0804A720
movs r0, #1
strb r0, [r6, #0xc]
adds r3, r6, #0
adds r3, #0x82
ldrh r0, [r3]
ands r4, r0
adds r0, r6, #0
adds r0, #0x74
strh r4, [r0]
ldrh r0, [r3]
movs r1, #0x3f
ands r1, r0
lsls r1, r1, #4
ldr r2, _0803CF20 @ =gRoomControls
ldrh r0, [r2, #6]
adds r0, #8
adds r1, r1, r0
strh r1, [r6, #0x2e]
ldrh r1, [r3]
movs r0, #0xfc
lsls r0, r0, #4
ands r0, r1
lsrs r0, r0, #2
ldrh r1, [r2, #8]
adds r1, #8
adds r0, r0, r1
strh r0, [r6, #0x32]
movs r1, #0
ldrsh r0, [r3, r1]
ands r0, r5
asrs r0, r0, #0xa
strb r0, [r6, #0x15]
ldrb r0, [r6, #0xa]
lsls r0, r0, #2
adds r1, r6, #0
adds r1, #0x78
strh r0, [r1]
adds r0, r6, #0
bl sub_0803CFF0
cmp r0, #0
beq _0803CF18
adds r0, r6, #0
bl sub_0803D0B0
_0803CF18:
pop {r4, r5, r6, pc}
.align 2, 0
_0803CF1C: .4byte 0x00000FFF
_0803CF20: .4byte gRoomControls
thumb_func_start sub_0803CF24
sub_0803CF24: @ 0x0803CF24
push {r4, lr}
adds r4, r0, #0
bl sub_0803CFD8
cmp r0, #0
beq _0803CF36
adds r0, r4, #0
bl sub_0803D024
_0803CF36:
pop {r4, pc}
thumb_func_start sub_0803CF38
sub_0803CF38: @ 0x0803CF38
push {r4, lr}
adds r4, r0, #0
bl sub_0803CFF0
cmp r0, #0
beq _0803CF4C
adds r0, r4, #0
bl sub_0803D0B0
b _0803CF8C
_0803CF4C:
adds r0, r4, #0
movs r1, #0
bl sub_08049FDC
cmp r0, #0
beq _0803CF8C
ldr r0, _0803CF90 @ =gUnk_020000B0
ldr r0, [r0]
movs r2, #0x2e
ldrsh r1, [r0, r2]
movs r3, #0x32
ldrsh r2, [r0, r3]
adds r0, r4, #0
movs r3, #0x20
bl sub_0806FCB8
cmp r0, #0
bne _0803CF8C
adds r1, r4, #0
adds r1, #0x7a
ldrh r0, [r1]
subs r0, #1
strh r0, [r1]
lsls r0, r0, #0x10
cmp r0, #0
bne _0803CF8C
adds r0, r4, #0
bl sub_0803D058
adds r0, r4, #0
bl sub_0803D024
_0803CF8C:
pop {r4, pc}
.align 2, 0
_0803CF90: .4byte gUnk_020000B0
thumb_func_start sub_0803CF94
sub_0803CF94: @ 0x0803CF94
push {r4, lr}
adds r4, r0, #0
adds r0, #0x74
ldrh r0, [r0]
adds r1, r4, #0
adds r1, #0x38
ldrb r1, [r1]
bl GetTileType
cmp r0, #0x76
bne _0803CFBA
adds r1, r4, #0
adds r1, #0x80
movs r0, #0
strh r0, [r1]
adds r0, r4, #0
bl sub_0803D024
b _0803CFD4
_0803CFBA:
adds r0, r4, #0
adds r0, #0x7c
ldrh r0, [r0]
cmp r0, #0
beq _0803CFD4
adds r0, r4, #0
bl sub_0803CFD8
cmp r0, #0
beq _0803CFD4
adds r0, r4, #0
bl sub_0803D024
_0803CFD4:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_0803CFD8
sub_0803CFD8: @ 0x0803CFD8
push {lr}
adds r1, r0, #0
adds r1, #0x7c
ldrh r0, [r1]
cmp r0, #0
bne _0803CFE8
movs r0, #1
b _0803CFEE
_0803CFE8:
ldrh r0, [r1]
bl CheckFlags
_0803CFEE:
pop {pc}
thumb_func_start sub_0803CFF0
sub_0803CFF0: @ 0x0803CFF0
push {lr}
adds r1, r0, #0
adds r1, #0x80
ldrh r2, [r1]
cmp r2, #0
beq _0803D01E
adds r0, #0x7c
ldrh r0, [r0]
cmp r2, r0
bne _0803D016
adds r0, r2, #0
bl CheckFlags
movs r1, #0
cmp r0, #0
bne _0803D012
movs r1, #1
_0803D012:
adds r0, r1, #0
b _0803D020
_0803D016:
ldrh r0, [r1]
bl CheckFlags
b _0803D020
_0803D01E:
movs r0, #0
_0803D020:
pop {pc}
.align 2, 0
thumb_func_start sub_0803D024
sub_0803D024: @ 0x0803D024
push {r4, lr}
adds r4, r0, #0
movs r0, #2
strb r0, [r4, #0xc]
adds r0, r4, #0
adds r0, #0x78
ldrh r1, [r0]
cmp r1, #0
beq _0803D03A
adds r0, #2
b _0803D04E
_0803D03A:
bl Random
ldr r2, _0803D054 @ =gUnk_080D0458
movs r1, #7
ands r1, r0
lsls r1, r1, #1
adds r1, r1, r2
ldrh r1, [r1]
adds r0, r4, #0
adds r0, #0x7a
_0803D04E:
strh r1, [r0]
pop {r4, pc}
.align 2, 0
_0803D054: .4byte gUnk_080D0458
thumb_func_start sub_0803D058
sub_0803D058: @ 0x0803D058
push {r4, r5, lr}
adds r4, r0, #0
movs r1, #0x16
movs r2, #0
bl CreateProjectileWithParent
adds r5, r0, #0
cmp r5, #0
beq _0803D0AE
ldrh r1, [r4, #0x24]
movs r2, #0x24
ldrsh r0, [r4, r2]
cmp r0, #0
beq _0803D078
strh r1, [r5, #0x24]
b _0803D08A
_0803D078:
bl Random
ldr r2, _0803D0A4 @ =gUnk_080D0468
movs r1, #3
ands r1, r0
lsls r1, r1, #1
adds r1, r1, r2
ldrh r0, [r1]
strh r0, [r5, #0x24]
_0803D08A:
ldrb r1, [r4, #0x15]
movs r0, #0x20
ands r0, r1
cmp r0, #0
beq _0803D0AC
ldr r0, _0803D0A8 @ =gUnk_020000B0
ldr r1, [r0]
adds r0, r4, #0
bl GetFacingDirection
strb r0, [r5, #0x15]
b _0803D0AE
.align 2, 0
_0803D0A4: .4byte gUnk_080D0468
_0803D0A8: .4byte gUnk_020000B0
_0803D0AC:
strb r1, [r5, #0x15]
_0803D0AE:
pop {r4, r5, pc}
thumb_func_start sub_0803D0B0
sub_0803D0B0: @ 0x0803D0B0
push {lr}
movs r1, #3
strb r1, [r0, #0xc]
adds r1, r0, #0
adds r1, #0x74
ldrh r1, [r1]
adds r0, #0x38
ldrb r2, [r0]
movs r0, #0x75
bl sub_0807B7D8
pop {pc}

View File

@ -27475,16 +27475,6 @@
"start": 852899,
"size": 17
},
{
"path": "enemy49/gUnk_080D0458.bin",
"start": 853080,
"size": 16
},
{
"path": "enemy49/gUnk_080D0468.bin",
"start": 853096,
"size": 8
},
{
"path": "animations/gSpriteAnimations_VaatiRebornEnemy_0_0.bin",
"start": 853207,

View File

@ -1,17 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_080D0448:: @ 080D0448
.4byte sub_0803CE98
.4byte sub_0803CF24
.4byte sub_0803CF38
.4byte sub_0803CF94
gUnk_080D0458:: @ 080D0458
.incbin "enemy49/gUnk_080D0458.bin"
gUnk_080D0468:: @ 080D0468
.incbin "enemy49/gUnk_080D0468.bin"

View File

@ -100,7 +100,7 @@ typedef enum {
/*0x46*/ BOW_MOBLIN,
/*0x47*/ LAKITU,
/*0x48*/ LAKITU_CLOUD,
/*0x49*/ ENEMY_49,
/*0x49*/ TORCH_TRAP,
/*0x4a*/ VAATI_REBORN_ENEMY,
/*0x4b*/ VAATI_PROJECTILE,
/*0x4c*/ BALL_CHAIN_SOLIDER,
@ -205,7 +205,7 @@ void Takkuri(Entity*);
void BowMoblin(Entity*);
void Lakitu(Entity*);
void LakituCloud(Entity*);
void Enemy49(Entity*);
void TorchTrap(Entity*);
void VaatiRebornEnemy(Entity*);
void VaatiProjectile(Entity*);
void BallChainSoldier(Entity*);

View File

@ -394,7 +394,7 @@ SECTIONS {
src/enemy/bowMoblin.o(.text);
src/enemy/lakitu.o(.text);
src/enemy/lakituCloud.o(.text);
asm/enemy/enemy49.o(.text);
src/enemy/torchTrap.o(.text);
src/enemy/vaatiRebornEnemy.o(.text);
src/enemy/vaatiProjectile.o(.text);
asm/enemy/ballChainSoldier.o(.text);
@ -1069,7 +1069,7 @@ SECTIONS {
src/enemy/lakitu.o(.rodata);
data/animations/enemy/lakitu.o(.rodata);
src/enemy/lakituCloud.o(.rodata);
data/const/enemy/enemy49.o(.rodata);
src/enemy/torchTrap.o(.rodata);
src/enemy/vaatiRebornEnemy.o(.rodata);
data/animations/enemy/vaatiRebornEnemy.o(.rodata);
src/enemy/vaatiProjectile.o(.rodata);

View File

@ -505,7 +505,7 @@ void (*const gEnemyFunctions[])(Entity* ent) = {
[BOW_MOBLIN] = BowMoblin,
[LAKITU] = Lakitu,
[LAKITU_CLOUD] = LakituCloud,
[ENEMY_49] = Enemy49,
[TORCH_TRAP] = TorchTrap,
[VAATI_REBORN_ENEMY] = VaatiRebornEnemy,
[VAATI_PROJECTILE] = VaatiProjectile,
[BALL_CHAIN_SOLIDER] = BallChainSoldier,

156
src/enemy/torchTrap.c Normal file
View File

@ -0,0 +1,156 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "functions.h"
typedef struct {
Entity base;
u8 filler[0xc];
u16 unk_74;
u16 filler2;
u16 unk_78;
u16 projectileTimer;
u16 unk_7c;
u8 filler3[0x2];
u16 unk_80;
u16 unk_82;
u16 unk_84;
} TorchTrapEntity;
void (*const gTorchTrapActions[])(TorchTrapEntity*);
const u16 gTorchTrapTimerLengths[];
const u16 gTorchTrapProjectileSpeeds[];
extern Entity* gUnk_020000B0;
bool32 sub_0803CFF0(TorchTrapEntity*);
bool32 sub_0803CFD8(TorchTrapEntity*);
void sub_0803D0B0(TorchTrapEntity*);
void TorchTrap_Reset(TorchTrapEntity*);
void TorchTrap_CreateProjectile(TorchTrapEntity*);
void TorchTrap(Entity* this) {
gTorchTrapActions[this->action]((TorchTrapEntity*)this);
}
void TorchTrap_Init(TorchTrapEntity* this) {
super->speed = (this->unk_84 & 0xf000) >> 5;
this->unk_84 &= 0xfff;
sub_0804A720(super);
super->action = 1;
this->unk_74 = this->unk_82 & 0xfff;
super->x.HALF.HI = ((this->unk_82 & 0x3f) << 4) + 8 + gRoomControls.origin_x;
super->y.HALF.HI = ((this->unk_82 & 0xfc0) >> 2) + (gRoomControls.origin_y + 8);
super->direction = ((s16)this->unk_82 & 0xf000) >> 10;
this->unk_78 = super->type << 2;
if (sub_0803CFF0(this)) {
sub_0803D0B0(this);
}
}
void sub_0803CF24(TorchTrapEntity* this) {
if (sub_0803CFD8(this)) {
TorchTrap_Reset(this);
}
}
void sub_0803CF38(TorchTrapEntity* this) {
if (sub_0803CFF0(this)) {
sub_0803D0B0(this);
} else if (sub_08049FDC(super, 0)) {
if (sub_0806FCB8(super, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI, 0x20) == 0) {
if (--this->projectileTimer == 0) {
TorchTrap_CreateProjectile(this);
TorchTrap_Reset(this);
}
}
}
}
void sub_0803CF94(TorchTrapEntity* this) {
if (GetTileType(this->unk_74, super->collisionLayer) == 0x76) {
this->unk_80 = 0;
TorchTrap_Reset(this);
} else if (this->unk_7c && sub_0803CFD8(this)) {
TorchTrap_Reset(this);
}
}
bool32 sub_0803CFD8(TorchTrapEntity* this) {
u32 rv;
if (this->unk_7c == 0) {
rv = 1;
} else {
rv = CheckFlags(this->unk_7c);
}
return rv;
}
bool32 sub_0803CFF0(TorchTrapEntity* this) {
u32 rv;
if (this->unk_80 != 0) {
if (this->unk_80 == this->unk_7c) {
u32 val = CheckFlags(this->unk_80);
rv = 0;
if (val == 0) {
rv = 1;
}
return rv;
} else {
return CheckFlags(this->unk_80);
}
}
return 0;
}
void TorchTrap_Reset(TorchTrapEntity* this) {
u32 val;
super->action = 2;
if (this->unk_78) {
this->projectileTimer = this->unk_78;
} else {
this->projectileTimer = gTorchTrapTimerLengths[Random() & 7];
}
}
void TorchTrap_CreateProjectile(TorchTrapEntity* this) {
Entity* proj = CreateProjectileWithParent(super, TORCH_TRAP_PROJECTILE, 0);
if (proj) {
u16 speed = super->speed;
if (super->speed) {
proj->speed = speed;
} else {
proj->speed = gTorchTrapProjectileSpeeds[Random() & 3];
}
if (super->direction & 0x20) {
proj->direction = GetFacingDirection(super, gUnk_020000B0);
} else {
proj->direction = super->direction;
}
}
}
void sub_0803D0B0(TorchTrapEntity* this) {
super->action = 3;
sub_0807B7D8(0x75, this->unk_74, super->collisionLayer);
}
void (*const gTorchTrapActions[])(TorchTrapEntity*) = {
TorchTrap_Init,
sub_0803CF24,
sub_0803CF38,
sub_0803CF94,
};
const u16 gTorchTrapTimerLengths[] = {
0x3c, 0x3c, 0x5a, 0x5a, 0x5a, 0x78, 0x78, 0x96,
};
const u16 gTorchTrapProjectileSpeeds[] = {
0x80,
0x100,
0x180,
0x200,
};