Decompile the rest of minecart

This commit is contained in:
Tal Hayon 2022-03-20 02:50:21 +02:00
parent 60db1d0cd1
commit d7a794a9d2
6 changed files with 224 additions and 447 deletions

View File

@ -1,322 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_08091C0C
sub_08091C0C: @ 0x08091C0C
push {r4, lr}
adds r4, r0, #0
bl sub_08004168
ldr r1, _08091C30 @ =gPlayerEntity
adds r0, r4, #0
bl CopyPosition
adds r0, r4, #0
bl GetTileUnderEntity
cmp r0, #0x68
beq _08091C46
cmp r0, #0x68
bhi _08091C34
cmp r0, #0x67
beq _08091C3E
b _08091C80
.align 2, 0
_08091C30: .4byte gPlayerEntity
_08091C34:
cmp r0, #0x69
beq _08091C4E
cmp r0, #0x6a
beq _08091C66
b _08091C80
_08091C3E:
ldrb r0, [r4, #0x15]
cmp r0, #0x18
beq _08091C54
b _08091C76
_08091C46:
ldrb r0, [r4, #0x15]
cmp r0, #8
beq _08091C6C
b _08091C5C
_08091C4E:
ldrb r0, [r4, #0x15]
cmp r0, #8
bne _08091C5C
_08091C54:
movs r0, #0
strb r0, [r4, #0x15]
strb r0, [r4, #0x14]
b _08091C86
_08091C5C:
movs r0, #0x18
strb r0, [r4, #0x15]
movs r0, #3
strb r0, [r4, #0x14]
b _08091C86
_08091C66:
ldrb r0, [r4, #0x15]
cmp r0, #0x18
bne _08091C76
_08091C6C:
movs r0, #0x10
strb r0, [r4, #0x15]
movs r0, #2
strb r0, [r4, #0x14]
b _08091C86
_08091C76:
movs r0, #8
strb r0, [r4, #0x15]
movs r0, #1
strb r0, [r4, #0x14]
b _08091C86
_08091C80:
movs r0, #3
strb r0, [r4, #0xc]
b _08091C92
_08091C86:
movs r0, #3
strb r0, [r4, #0xc]
ldr r1, _08091C94 @ =gPlayerEntity
ldrb r0, [r4, #0x14]
lsls r0, r0, #1
strb r0, [r1, #0x14]
_08091C92:
pop {r4, pc}
.align 2, 0
_08091C94: .4byte gPlayerEntity
thumb_func_start sub_08091C98
sub_08091C98: @ 0x08091C98
push {r4, r5, lr}
adds r4, r0, #0
bl LinearMoveUpdate
ldr r5, _08091CC0 @ =gPlayerEntity
adds r0, r4, #0
adds r1, r5, #0
bl CopyPosition
ldr r1, _08091CC4 @ =gRoomControls
ldrh r0, [r1]
cmp r0, #0
bne _08091CBE
movs r0, #3
strb r0, [r4, #0xc]
movs r0, #0xe0
lsls r0, r0, #3
strh r0, [r4, #0x24]
str r5, [r1, #0x30]
_08091CBE:
pop {r4, r5, pc}
.align 2, 0
_08091CC0: .4byte gPlayerEntity
_08091CC4: .4byte gRoomControls
thumb_func_start sub_08091CC8
sub_08091CC8: @ 0x08091CC8
push {r4, r5, r6, lr}
adds r6, r0, #0
ldr r2, _08091D58 @ =gPlayerState
ldrb r0, [r2, #2]
cmp r0, #0
bne _08091D64
movs r0, #1
strb r0, [r6, #0xc]
ldrb r0, [r6, #0x15]
movs r1, #0x10
eors r0, r1
strb r0, [r6, #0x15]
ldrb r0, [r6, #0x14]
movs r1, #2
eors r0, r1
strb r0, [r6, #0x14]
ldr r0, [r2, #0x30]
movs r1, #0x80
lsls r1, r1, #0x13
eors r0, r1
str r0, [r2, #0x30]
adds r0, r6, #0
adds r0, #0x84
ldr r4, [r0]
movs r0, #0x2e
ldrsh r1, [r6, r0]
ldr r5, _08091D5C @ =gRoomControls
ldrh r0, [r5, #6]
subs r1, r1, r0
asrs r1, r1, #4
movs r3, #0x3f
ands r1, r3
movs r2, #0x32
ldrsh r0, [r6, r2]
ldrh r2, [r5, #8]
subs r0, r0, r2
asrs r0, r0, #4
ands r0, r3
lsls r0, r0, #6
orrs r1, r0
strh r1, [r4]
ldrb r0, [r5, #5]
strb r0, [r4, #4]
ldrb r0, [r6, #0x14]
strb r0, [r4, #5]
ldrb r1, [r6, #0x14]
adds r1, #0x10
adds r0, r6, #0
bl InitAnimationForceUpdate
ldr r0, _08091D60 @ =0x00004022
movs r3, #0x2e
ldrsh r1, [r6, r3]
ldrh r2, [r5, #6]
subs r1, r1, r2
asrs r1, r1, #4
movs r4, #0x3f
ands r1, r4
movs r3, #0x32
ldrsh r2, [r6, r3]
ldrh r3, [r5, #8]
subs r2, r2, r3
asrs r2, r2, #4
ands r2, r4
lsls r2, r2, #6
orrs r1, r2
adds r2, r6, #0
adds r2, #0x38
ldrb r2, [r2]
bl SetTile
b _08091D8A
.align 2, 0
_08091D58: .4byte gPlayerState
_08091D5C: .4byte gRoomControls
_08091D60: .4byte 0x00004022
_08091D64:
adds r0, r6, #0
bl UpdateAnimationSingleFrame
ldr r3, _08091D8C @ =gPlayerEntity
adds r0, r6, #0
adds r0, #0x29
ldrb r1, [r0]
lsls r1, r1, #0x1d
lsrs r1, r1, #0x1d
subs r1, #1
adds r3, #0x29
movs r0, #7
ands r1, r0
ldrb r2, [r3]
movs r0, #8
rsbs r0, r0, #0
ands r0, r2
orrs r0, r1
strb r0, [r3]
_08091D8A:
pop {r4, r5, r6, pc}
.align 2, 0
_08091D8C: .4byte gPlayerEntity
thumb_func_start sub_08091D90
sub_08091D90: @ 0x08091D90
push {r4, lr}
adds r4, r0, #0
ldr r0, [r4, #0x20]
cmp r0, #0
bge _08091DA0
adds r0, r4, #0
bl UpdateAnimationSingleFrame
_08091DA0:
adds r0, r4, #0
adds r0, #0x5a
ldrb r1, [r0]
movs r0, #0x7f
ands r0, r1
cmp r0, #0
bne _08091DD8
movs r1, #0x80
lsls r1, r1, #6
adds r0, r4, #0
bl GravityUpdate
cmp r0, #0
bne _08091DD8
ldrb r1, [r4, #0xb]
movs r0, #4
eors r1, r0
strb r1, [r4, #0xb]
movs r0, #1
strb r0, [r4, #0xc]
adds r0, r4, #0
adds r0, #0x84
ldr r0, [r0]
strb r1, [r0, #6]
movs r0, #0x9e
lsls r0, r0, #1
bl SoundReq
_08091DD8:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08091DDC
sub_08091DDC: @ 0x08091DDC
push {r4, lr}
adds r4, r0, #0
ldr r2, _08091E30 @ =gUnk_081223D0
ldrb r0, [r4, #0x14]
lsls r0, r0, #1
adds r1, r0, r2
ldrb r1, [r1]
lsls r1, r1, #0x18
asrs r1, r1, #0x18
adds r0, #1
adds r0, r0, r2
movs r2, #0
ldrsb r2, [r0, r2]
adds r0, r4, #0
bl sub_080B1AF0
cmp r0, #0xff
bne _08091E5C
ldr r0, _08091E34 @ =gPlayerEntity
ldrb r1, [r4, #0x14]
bl sub_0807BD14
cmp r0, #0
beq _08091E5C
ldrb r1, [r4, #0x11]
movs r0, #0x10
rsbs r0, r0, #0
ands r0, r1
movs r1, #6
orrs r0, r1
strb r0, [r4, #0x11]
movs r0, #5
strb r0, [r4, #0xc]
ldrb r0, [r4, #0x15]
cmp r0, #8
beq _08091E40
cmp r0, #8
bgt _08091E38
cmp r0, #0
beq _08091E40
b _08091E44
.align 2, 0
_08091E30: .4byte gUnk_081223D0
_08091E34: .4byte gPlayerEntity
_08091E38:
cmp r0, #0x10
beq _08091E40
cmp r0, #0x18
bne _08091E44
_08091E40:
movs r0, #0xa0
strh r0, [r4, #0x24]
_08091E44:
ldr r0, _08091E54 @ =gPlayerEntity
ldrb r1, [r4, #0x15]
strb r1, [r0, #0x15]
ldr r0, _08091E58 @ =gRoomControls
str r4, [r0, #0x30]
movs r0, #1
b _08091E5E
.align 2, 0
_08091E54: .4byte gPlayerEntity
_08091E58: .4byte gRoomControls
_08091E5C:
movs r0, #0
_08091E5E:
pop {r4, pc}

View File

@ -43795,16 +43795,6 @@
"size": 8, "size": 8,
"type": "animation" "type": "animation"
}, },
{
"path": "minecart/gUnk_081223C8.bin",
"start": 1188808,
"size": 8
},
{
"path": "minecart/gUnk_081223D0.bin",
"start": 1188816,
"size": 8
},
{ {
"path": "animations/gSpriteAnimations_ThoughtBubble_0.bin", "path": "animations/gSpriteAnimations_ThoughtBubble_0.bin",
"start": 1189280, "start": 1189280,

View File

@ -1,21 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_081223A8:: @ 081223A8
.4byte sub_080916EC
.4byte sub_080917DC
.4byte sub_080918A4
.4byte sub_080919AC
.4byte sub_08091C0C
.4byte sub_08091C98
.4byte sub_08091CC8
.4byte sub_08091D90
gUnk_081223C8:: @ 081223C8
.incbin "minecart/gUnk_081223C8.bin"
gUnk_081223D0:: @ 081223D0
.incbin "minecart/gUnk_081223D0.bin"

View File

@ -96,10 +96,10 @@ typedef struct {
} EntityData; } EntityData;
typedef struct { typedef struct {
u16 field_0x0; u16 tilePos;
u16 field_0x2; u16 field_0x2;
u8 field_0x4; u8 room;
u8 field_0x5; u8 animationState;
u8 field_0x6; u8 field_0x6;
u8 field_0x7; u8 field_0x7;
} struct_030010EC; } struct_030010EC;

View File

@ -711,7 +711,6 @@ SECTIONS {
src/object/object53.o(.text); src/object/object53.o(.text);
src/object/pullableLever.o(.text); src/object/pullableLever.o(.text);
src/object/minecart.o(.text); src/object/minecart.o(.text);
asm/object/minecart.o(.text);
src/object/thoughtBubble.o(.text); src/object/thoughtBubble.o(.text);
src/object/hiddenLadderDown.o(.text); src/object/hiddenLadderDown.o(.text);
src/object/gentariCurtains.o(.text); src/object/gentariCurtains.o(.text);
@ -1446,7 +1445,7 @@ SECTIONS {
src/object/object53.o(.rodata); src/object/object53.o(.rodata);
src/object/pullableLever.o(.rodata); src/object/pullableLever.o(.rodata);
data/animations/object/pullableLever.o(.rodata); data/animations/object/pullableLever.o(.rodata);
data/const/object/minecart.o(.rodata); src/object/minecart.o(.rodata);
data/animations/object/minecart.o(.rodata); data/animations/object/minecart.o(.rodata);
data/const/object/thoughtBubble.o(.rodata); data/const/object/thoughtBubble.o(.rodata);
data/animations/object/thoughtBubble.o(.rodata); data/animations/object/thoughtBubble.o(.rodata);

View File

@ -1,67 +1,82 @@
#define NENT_DEPRECATED
#include "object.h" #include "object.h"
#include "functions.h" #include "functions.h"
#include "hitbox.h" #include "hitbox.h"
extern u32 sub_08091DDC(Entity*); typedef struct {
Entity base;
u8 filler[0x1C];
struct_030010EC* minecartData;
} MinecartEntity;
extern u32 sub_08007DD6(u32, u32); extern u32 sub_08007DD6(u32, u32);
extern void sub_08017744(Entity*); extern void sub_08017744(Entity*);
extern void sub_08091C0C(Entity*);
extern void (*const gUnk_081223A8[])(Entity*); u32 sub_08091DDC(MinecartEntity*);
void sub_080916EC(MinecartEntity*);
void sub_080917DC(MinecartEntity*);
void sub_080918A4(MinecartEntity*);
void sub_080919AC(MinecartEntity*);
void sub_08091C0C(MinecartEntity*);
void sub_08091C98(MinecartEntity*);
void sub_08091CC8(MinecartEntity*);
void sub_08091D90(MinecartEntity*);
extern const s8 gUnk_081223C8[];
extern const u32 gUnk_081223D8[]; extern const u32 gUnk_081223D8[];
void Minecart(Entity* this) { void Minecart(Entity* this) {
gUnk_081223A8[this->action](this); static void (*const actionFuncs[])(MinecartEntity*) = {
sub_080916EC, sub_080917DC, sub_080918A4, sub_080919AC, sub_08091C0C, sub_08091C98, sub_08091CC8, sub_08091D90,
};
actionFuncs[this->action]((MinecartEntity*)this);
this->bitfield = 0; this->bitfield = 0;
} }
void sub_080916EC(Entity* this) { void sub_080916EC(MinecartEntity* this) {
struct_030010EC* unk = &gRoomTransition.minecart_data[this->actionDelay]; struct_030010EC* unk = &gRoomTransition.minecart_data[super->actionDelay];
*(struct_030010EC**)&this->cutsceneBeh.HWORD = unk; this->minecartData = unk;
if ((gRoomControls.room != unk->field_0x4) || (gPlayerState.flags & PL_IN_MINECART) != 0) { if ((gRoomControls.room != unk->room) || (gPlayerState.flags & PL_IN_MINECART) != 0) {
DeleteThisEntity(); DeleteThisEntity();
} }
this->x.HALF.HI = gRoomControls.origin_x + ((unk->field_0x0 & 0x3f) << 4) + 8; super->x.HALF.HI = gRoomControls.origin_x + ((unk->tilePos & 0x3f) << 4) + 8;
this->y.HALF.HI = gRoomControls.origin_y + ((unk->field_0x0 & 0xfc << 4) >> 2) + 8; super->y.HALF.HI = gRoomControls.origin_y + ((unk->tilePos & 0xfc << 4) >> 2) + 8;
this->animationState = unk->field_0x5; super->animationState = unk->animationState;
this->type2 = unk->field_0x6; super->type2 = unk->field_0x6;
this->action = 1; super->action = 1;
this->hitbox = (Hitbox*)&gUnk_080FD310; super->hitbox = (Hitbox*)&gUnk_080FD310;
COLLISION_ON(this); COLLISION_ON(super);
this->hitType = 1; super->hitType = 1;
this->field_0x3c = 0x47; super->field_0x3c = 0x47;
this->hurtType = 0x44; super->hurtType = 0x44;
this->flags2 = 0x80; super->flags2 = 0x80;
this->direction = DirectionFromAnimationState(this->animationState); super->direction = DirectionFromAnimationState(super->animationState);
this->speed = 0x700; super->speed = 0x700;
this->spritePriority.b1 = 3; super->spritePriority.b1 = 3;
InitAnimationForceUpdate(this, this->type2 + 4 + this->animationState); InitAnimationForceUpdate(super, super->type2 + 4 + super->animationState);
SetTile(0x4022, COORD_TO_TILE(this), this->collisionLayer); SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer);
} }
void sub_080917DC(Entity* this) { void sub_080917DC(MinecartEntity* this) {
if ((this->bitfield & 0x7f) == 0x1d) { if ((super->bitfield & 0x7f) == 0x1d) {
this->zVelocity = Q_16_16(2.625); super->zVelocity = Q_16_16(2.625);
this->action = 7; super->action = 7;
InitAnimationForceUpdate(this, this->type2 + 4 + this->animationState); InitAnimationForceUpdate(super, super->type2 + 4 + super->animationState);
SoundReq(SFX_13B); SoundReq(SFX_13B);
} else { } else {
if (sub_0800445C(this) != 0) { if (sub_0800445C(super) != 0) {
if (!((gPlayerState.flags & (PL_MINISH | PL_ROLLING)) || gPlayerState.field_0x1c || if (!((gPlayerState.flags & (PL_MINISH | PL_ROLLING)) || gPlayerState.field_0x1c ||
gPlayerState.heldObject || gPlayerState.jump_status)) { gPlayerState.heldObject || gPlayerState.jump_status)) {
this->actionDelay++; super->actionDelay++;
} else { } else {
this->actionDelay = 0; super->actionDelay = 0;
} }
} else { } else {
this->actionDelay = 0; super->actionDelay = 0;
} }
if (this->type2 == 0) { if (super->type2 == 0) {
if (this->actionDelay > 8) { if (super->actionDelay > 8) {
this->action++; super->action++;
gPlayerState.jump_status = 0x81; gPlayerState.jump_status = 0x81;
gPlayerState.flags |= PL_ENTER_MINECART; gPlayerState.flags |= PL_ENTER_MINECART;
gPlayerEntity.zVelocity = Q_16_16(2.0); gPlayerEntity.zVelocity = Q_16_16(2.0);
@ -72,100 +87,102 @@ void sub_080917DC(Entity* this) {
SoundReq(SFX_PLY_JUMP); SoundReq(SFX_PLY_JUMP);
} }
} else { } else {
this->actionDelay = 0; super->actionDelay = 0;
} }
} }
} }
void sub_080918A4(Entity* this) { void sub_080918A4(MinecartEntity* this) {
if (EntityInRectRadius(this, &gPlayerEntity, 2, 2) != 0) { if (EntityInRectRadius(super, &gPlayerEntity, 2, 2) != 0) {
gPlayerEntity.x.HALF.HI = this->x.HALF.HI; gPlayerEntity.x.HALF.HI = super->x.HALF.HI;
gPlayerEntity.y.HALF.HI = this->y.HALF.HI; gPlayerEntity.y.HALF.HI = super->y.HALF.HI;
if (gPlayerEntity.z.HALF.HI > -0x10) { if (gPlayerEntity.z.HALF.HI > -0x10) {
if (gPlayerEntity.zVelocity >= 0) { if (gPlayerEntity.zVelocity >= 0) {
return; return;
} }
gPlayerEntity.animationState = this->animationState << 1; gPlayerEntity.animationState = super->animationState << 1;
gPlayerState.flags = (gPlayerState.flags ^ PL_ENTER_MINECART) | PL_IN_MINECART; gPlayerState.flags = (gPlayerState.flags ^ PL_ENTER_MINECART) | PL_IN_MINECART;
this->action++; super->action++;
this->field_0xf = 1; super->field_0xf = 1;
this->flags |= ENT_PERSIST; super->flags |= ENT_PERSIST;
this->hitType = 0x97; super->hitType = 0x97;
this->field_0x3c = (gPlayerEntity.field_0x3c + 1) | 0x20; super->field_0x3c = (gPlayerEntity.field_0x3c + 1) | 0x20;
this->flags2 = gPlayerEntity.flags2; super->flags2 = gPlayerEntity.flags2;
this->hurtType = 0x18; super->hurtType = 0x18;
this->damage = 8; super->damage = 8;
sub_0801766C(this); sub_0801766C(super);
sub_0807BA8C(COORD_TO_TILE(this), this->collisionLayer); sub_0807BA8C(COORD_TO_TILE(super), super->collisionLayer);
SoundReq(SFX_137); SoundReq(SFX_137);
} }
} else { } else {
gPlayerEntity.direction = GetFacingDirection(&gPlayerEntity, this); gPlayerEntity.direction = GetFacingDirection(&gPlayerEntity, super);
} }
if (gPlayerEntity.zVelocity < 0) { if (gPlayerEntity.zVelocity < 0) {
gPlayerEntity.spritePriority.b0 = this->spritePriority.b0 - 1; gPlayerEntity.spritePriority.b0 = super->spritePriority.b0 - 1;
} }
} }
void sub_080919AC(Entity* this) { void sub_080919AC(MinecartEntity* this) {
static const s8 gUnk_081223C8[] = { 0, -7, 7, 0, 0, 7, -7, 0 };
u32 iVar2; u32 iVar2;
u32 uVar3; u32 uVar3;
gRoomControls.unk5 = 7; gRoomControls.unk5 = 7;
if ((gPlayerState.flags & PL_IN_MINECART) == 0) { if ((gPlayerState.flags & PL_IN_MINECART) == 0) {
this->action = 1; super->action = 1;
return; return;
} }
if ((gPlayerEntity.frame & 0xf) == 0) { if ((gPlayerEntity.frame & 0xf) == 0) {
COLLISION_OFF(this); COLLISION_OFF(super);
CopyPosition(this, &gPlayerEntity); CopyPosition(super, &gPlayerEntity);
if ((gPlayerEntity.frame & 0xf0) == 0x10) { if ((gPlayerEntity.frame & 0xf0) == 0x10) {
this->spriteOffsetY = 1; super->spriteOffsetY = 1;
} else { } else {
this->spriteOffsetY = 0; super->spriteOffsetY = 0;
} }
} else { } else {
COLLISION_ON(this); COLLISION_ON(super);
gPlayerEntity.speed = 0; gPlayerEntity.speed = 0;
LinearMoveUpdate(this); LinearMoveUpdate(super);
CopyPosition(this, &gPlayerEntity); CopyPosition(super, &gPlayerEntity);
gPlayerEntity.spritePriority.b0 = this->spritePriority.b0 - 1; gPlayerEntity.spritePriority.b0 = super->spritePriority.b0 - 1;
if (!sub_08091DDC(this)) { if (!sub_08091DDC(this)) {
if ((gRoomTransition.frameCount & 0xf) == 0) { if ((gRoomTransition.frameCount & 0xf) == 0) {
SoundReq(SFX_138); SoundReq(SFX_138);
} }
if (--this->field_0xf == 0xff) { if (--super->field_0xf == 0xff) {
SoundReq(SFX_PLY_VO7); SoundReq(SFX_PLY_VO7);
this->field_0xf = 0x3c; super->field_0xf = 0x3c;
} }
uVar3 = sub_080B1A8C(this, gUnk_081223C8[this->animationState * 2], uVar3 = sub_080B1A8C(super, gUnk_081223C8[super->animationState * 2],
gUnk_081223C8[this->animationState * 2 + 1]); gUnk_081223C8[super->animationState * 2 + 1]);
iVar2 = sub_08007DD6(uVar3, gUnk_081223D8[this->animationState]); iVar2 = sub_08007DD6(uVar3, gUnk_081223D8[super->animationState]);
if (iVar2 == 0) { if (iVar2 == 0) {
this->direction = DirectionTurnAround(this->direction); super->direction = DirectionTurnAround(super->direction);
this->animationState = AnimationStateFlip90(this->animationState); super->animationState = AnimationStateFlip90(super->animationState);
} else { } else {
switch (uVar3) { switch (uVar3) {
case 0x64: case 0x64:
this->flags &= ~ENT_PERSIST; super->flags &= ~ENT_PERSIST;
this->hitType = 1; super->hitType = 1;
this->field_0x3c = 0x47; super->field_0x3c = 0x47;
this->hurtType = 0x44; super->hurtType = 0x44;
this->flags2 = 0x80; super->flags2 = 0x80;
this->action = 6; super->action = 6;
sub_08017744(this); sub_08017744(super);
gPlayerState.jump_status = 0x41; gPlayerState.jump_status = 0x41;
gPlayerState.flags = (gPlayerState.flags ^ PL_IN_MINECART) | PL_ENTER_MINECART; gPlayerState.flags = (gPlayerState.flags ^ PL_IN_MINECART) | PL_ENTER_MINECART;
gPlayerEntity.zVelocity = Q_16_16(2.0); gPlayerEntity.zVelocity = Q_16_16(2.0);
gPlayerEntity.speed = 0x200; gPlayerEntity.speed = 0x200;
gPlayerEntity.animationState = this->animationState << 1; gPlayerEntity.animationState = super->animationState << 1;
gPlayerEntity.direction = this->direction; gPlayerEntity.direction = super->direction;
gPlayerEntity.flags |= PL_MINISH; gPlayerEntity.flags |= PL_MINISH;
sub_08004168(this); sub_08004168(super);
InitAnimationForceUpdate(this, this->animationState + 0xc); InitAnimationForceUpdate(super, super->animationState + 0xc);
SoundReq(SFX_PLY_VO4); SoundReq(SFX_PLY_VO4);
SoundReq(SFX_139); SoundReq(SFX_139);
return; return;
@ -177,21 +194,135 @@ void sub_080919AC(Entity* this) {
case 0x6d: case 0x6d:
case 0x6e: case 0x6e:
case 0x6f: case 0x6f:
if (uVar3 == GetTileUnderEntity(this)) { if (uVar3 == GetTileUnderEntity(super)) {
sub_08091C0C(this); sub_08091C0C(this);
gPlayerEntity.animationState = this->animationState << 1; gPlayerEntity.animationState = super->animationState << 1;
return; return;
} }
break; break;
} }
} }
gPlayerEntity.animationState = this->animationState << 1; gPlayerEntity.animationState = super->animationState << 1;
if (this->animIndex == this->animationState) { if (super->animIndex == super->animationState) {
UpdateAnimationSingleFrame(this); UpdateAnimationSingleFrame(super);
} else { } else {
InitAnimationForceUpdate(this, this->animationState); InitAnimationForceUpdate(super, super->animationState);
} }
} }
} }
} }
void sub_08091C0C(MinecartEntity* this) {
sub_08004168(super);
CopyPosition(super, &gPlayerEntity);
switch (GetTileUnderEntity(super)) {
case 0x67:
if (super->direction == DirectionWest) {
super->direction = DirectionNorth;
super->animationState = 0;
} else {
super->direction = DirectionEast;
super->animationState = 1;
}
break;
case 0x68:
if (super->direction == DirectionEast) {
super->direction = DirectionSouth;
super->animationState = 2;
} else {
super->direction = DirectionWest;
super->animationState = 3;
}
break;
case 0x69:
if (super->direction == DirectionEast) {
super->direction = DirectionNorth;
super->animationState = 0;
} else {
super->direction = DirectionWest;
super->animationState = 3;
}
break;
case 0x6a:
if (super->direction == DirectionWest) {
super->direction = DirectionSouth;
super->animationState = 2;
} else {
super->direction = DirectionEast;
super->animationState = 1;
}
break;
default:
super->action = 3;
return;
}
super->action = 3;
gPlayerEntity.animationState = super->animationState << 1;
}
void sub_08091C98(MinecartEntity* this) {
LinearMoveUpdate(super);
CopyPosition(super, &gPlayerEntity);
if (gRoomControls.reload_flags == 0) {
super->action = 3;
super->speed = 0x700;
gRoomControls.camera_target = &gPlayerEntity;
}
}
void sub_08091CC8(MinecartEntity* this) {
struct_030010EC* minecartData;
if (gPlayerState.jump_status == 0) {
super->action = 1;
super->direction = DirectionTurnAround(super->direction);
super->animationState ^= 2;
gPlayerState.flags ^= PL_ENTER_MINECART;
minecartData = this->minecartData;
minecartData->tilePos = COORD_TO_TILE(super);
minecartData->room = gRoomControls.room;
minecartData->animationState = super->animationState;
InitAnimationForceUpdate(super, super->animationState + 0x10);
SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer);
} else {
UpdateAnimationSingleFrame(super);
gPlayerEntity.spritePriority.b0 = super->spritePriority.b0 - 1;
}
}
void sub_08091D90(MinecartEntity* this) {
if (super->zVelocity < 0) {
UpdateAnimationSingleFrame(super);
}
if (((super->frame & 0x7f) == 0) && GravityUpdate(super, 0x2000) == 0) {
super->type2 ^= 4;
super->action = 1;
this->minecartData->field_0x6 = super->type2;
SoundReq(SFX_13C);
}
}
bool32 sub_08091DDC(MinecartEntity* this) {
static const s8 gUnk_081223D0[] = { 0, -8, 8, 0, 0, 8, -8, 0 };
if ((sub_080B1AF0(super, gUnk_081223D0[super->animationState * 2], gUnk_081223D0[super->animationState * 2 + 1]) ==
0xff) &&
(sub_0807BD14(&gPlayerEntity, super->animationState))) {
super->updatePriority = 6;
super->action = 5;
switch (super->direction) {
case 0:
case 8:
case 0x10:
case 0x18:
super->speed = 0xa0;
break;
}
gPlayerEntity.direction = super->direction;
gRoomControls.camera_target = super;
return 1;
} else {
return 0;
}
}