merge changes from master

This commit is contained in:
Henny022p
2021-10-22 23:30:04 +02:00
883 changed files with 73179 additions and 49474 deletions
+235
View File
@@ -0,0 +1,235 @@
#include "entity.h"
#include "functions.h"
#include "player.h"
#include "script.h"
#include "flags.h"
#include "room.h"
#include "textbox.h"
extern void (*const BookActionFuncs[])(Entity*);
extern s8 const gUnk_08123D94[];
u32 sub_0809B688(Entity*);
void sub_0809B6B0(Entity*, Entity*);
void Book(Entity* this) {
BookActionFuncs[this->action](this);
}
void sub_0809B3C4(Entity* this) {
u32 obtained;
obtained = GetInventoryValue(this->type + 0x39);
if (this->type2 != 3) {
if (obtained) {
DeleteThisEntity();
}
} else {
if (CheckLocalFlag(0x73)) {
DeleteThisEntity();
}
if (obtained != 2) {
this->spriteSettings.b.draw = 0;
}
}
this->spriteOffsetY = 3;
if (CheckFlags(this->field_0x86.HWORD)) {
if (this->type2 == 0) {
this->y.HALF.HI += 48;
}
this->type2 = 2;
}
UpdateSpriteForCollisionLayer(this);
InitAnimationForceUpdate(this, this->type + 0x39);
switch (this->type2) {
case 0:
this->action = 1;
this->actionDelay = 22;
this->field_0xf = 2;
this->field_0x80.HALF.LO = 0;
this->spritePriority.b0 = 3;
break;
case 1: {
u32 scroll;
u32 height;
this->action = 3;
scroll = (u16)gRoomControls.roomScrollY - 0x10;
height = (u16)this->y.HALF.HI - scroll;
this->height.HALF.HI -= height;
return;
}
case 2:
this->action = 4;
return;
case 3:
this->action = 5;
this->subAction = 0;
this->spritePriority.b0 = 3;
break;
default:
return;
}
}
void sub_0809B4A8(Entity* this) {
sub_0800445C(this);
if (this->field_0x80.HALF.LO != 0) {
this->field_0x80.HALF.LO--;
return;
}
if (sub_0809B688(this)) {
if (--this->actionDelay) {
return;
}
this->action = 2;
this->actionDelay = 30;
this->speed = 64;
this->direction = 16;
gPlayerState.pushedObject = 0x9e;
gPlayerState.playerAction = 5;
gPlayerState.flags.all |= 1;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
EnqueueSFX(0x10f);
} else {
this->actionDelay = 0x16;
}
}
void sub_0809B524(Entity* this) {
if (--this->actionDelay == 0) {
if (--this->field_0xf == 0) {
this->action = 3;
this->y.HALF.HI += 32;
this->height.HALF.HI -= 32;
} else {
this->action = 1;
this->actionDelay = 22;
this->field_0x80.HALF.LO = 24;
}
}
sub_0806F69C(this);
}
void sub_0809B56C(Entity* this) {
Entity* fx;
if (sub_080044EC(this, 0x2800) != 1) {
return;
}
this->action = 4;
this->spritePriority.b0 = 4;
SetFlag(this->field_0x86.HWORD);
fx = CreateFx(this, 2, 0);
if (fx) {
ResolveEntityOnTop(this, fx);
}
}
void sub_0809B5B4(Entity* this) {
if (gPlayerState.flags.all & 0x80) {
sub_0800445C(this);
} else if (sub_08017850(this)) {
CreateItemEntity(this->type + 0x39, 0, 0);
DeleteThisEntity();
}
}
void sub_0809B5EC(Entity* this) {
if (this->spriteSettings.b.draw == 1) {
switch (this->subAction) {
case 0: {
Entity* parent;
parent = FindEntityByID(7, 26, 7);
if (!parent) {
return;
}
if (parent->x.HALF.HI < this->x.HALF.HI) {
return;
}
if (parent->animationState != 4) {
return;
}
this->parent = parent;
this->subAction = 1;
sub_0809B6B0(this->parent, this);
break;
}
case 1: {
if (!this->parent || !this->parent->next) {
DeleteThisEntity();
return;
}
sub_0809B6B0(this->parent, this);
break;
}
default:
return;
}
} else {
switch (this->subAction) {
default: {
DeleteThisEntity();
break;
}
case 0: {
if (GetInventoryValue(this->type + 0x39) == 2) {
this->subAction = 1;
}
break;
}
case 1: {
u8 doTextBox = gTextBox.doTextBox & 0x7f;
if (!doTextBox) {
this->spriteSettings.b.draw = 1;
this->subAction = doTextBox;
}
break;
}
}
}
}
u32 sub_0809B688(Entity* this) {
u32 ret;
ret = sub_080041A0(this, &gPlayerEntity, 6, 12);
if (ret == 1 && gPlayerState.field_0xd != 16) {
ret = 0;
}
return ret;
}
void sub_0809B6B0(Entity* parent, Entity* this) {
s32 offset;
offset = (s32)gUnk_08123D94[parent->animationState >> 1] << 16;
PositionRelative(parent, this, 0, offset);
this->height.HALF.HI = -(this->type << 2);
this->spritePriority.b0 = 3 - this->type;
}
void (*const BookActionFuncs[])(Entity*) = {
sub_0809B3C4, sub_0809B4A8, sub_0809B524, sub_0809B56C, sub_0809B5B4, sub_0809B5EC,
};
const s8 gUnk_08123D94[] = { -22, -20, -20, -20 };
+6 -10
View File
@@ -197,11 +197,12 @@ u32 sub_08081F00(u32*, u32*);
extern u16 gMapDataTopSpecial[0x2000];
#ifdef NON_MATCHING
void sub_08081E6C(Entity* this) {
extern u16* GetLayerByIndex(u32);
extern u16 gUnk_02019EE0[];
NONMATCH("asm/non_matching/button/sub_08081E6C.inc", void sub_08081E6C(Entity* this)) {
u32 r4;
u16 *tmp, *r1;
u8* tmp2;
u16* tmp2;
u32 r6 = this->field_0x74.HWORD;
u32 r5 = this->collisionLayer;
u32 tile = GetTileType(r6, r5);
@@ -212,19 +213,14 @@ void sub_08081E6C(Entity* this) {
tmp = r1 + 0x3802;
r1 += 0x3002 + r4;
tmp = tmp + (*r1 << 2);
tmp2 = (r5 == 2 ? gMapDataTopSpecial : (u8*)&gUnk_02019EE0);
tmp2 = (r5 == 2 ? gMapDataTopSpecial : gUnk_02019EE0);
tmp2 += (((0x3f & r6) << 1) + ((0xfc0 & r6) << 2)) << 1;
if (sub_08081F00((u32*)tmp2, (u32*)tmp))
return;
SetTileType(r4, r6, r5);
SetTile(tile, r6, r5);
}
#else
NAKED
void sub_08081E6C(Entity* this) {
asm(".include \"asm/non_matching/button/sub_08081E6C.s\"");
}
#endif
END_NONMATCH
u32 sub_08081F00(u32* unk1, u32* unk2) {
if (*unk1 != *unk2)
+4
View File
@@ -139,7 +139,11 @@ static bool32 sub_0808E950(void) {
void sub_0808E988(Entity* this) {
if (this->action == 0) {
this->action = 1;
#ifdef EU
this->spriteIndex = 0x141;
#else
this->spriteIndex = 0x142;
#endif
this->type2 = 0xFF;
sub_080AE008(this, 1, 3);
}
+18
View File
@@ -0,0 +1,18 @@
#include "global.h"
#include "entity.h"
extern void (*const gUnk_0812119C[])(Entity*);
void FrozenFlower(Entity* this) {
gUnk_0812119C[this->action](this);
}
void sub_0808A9DC(Entity* this) {
this->action = 1;
this->frameIndex = this->type;
this->spriteRendering.b3 = 3;
this->spritePriority.b0 = 7;
}
void nullsub_519(Entity* this) {
}
+6 -9
View File
@@ -370,20 +370,17 @@ void sub_08087114(Entity* this) {
}
}
NONMATCH("asm/greatFairy/sub_08087150.inc", void sub_08087150(Entity* this)) {
u32 temp;
void sub_08087150(Entity* this) {
GreatFairy_InitializeAnimation(this);
this->spriteSettings.b.draw = TRUE;
this->spriteSettings.b.draw = 1;
this->spriteOrientation.flipY = 0;
this->spriteRendering.b0 = 0;
this->spriteRendering.b3 = 0;
this->spritePriority.b0 = 3;
this->speed = 128;
this->speed = 0x80;
this->direction = 0x10;
temp = gUnk_0812079C[0];
this->palette.raw = ((temp & 0xf) << 4) | 0xf;
this->palette.b.b4 = gUnk_0812079C[0];
this->palette.b.b0 = gUnk_0812079C[0];
}
END_NONMATCH
void nullsub_516(Entity* this) {
}
+4
View File
@@ -270,7 +270,11 @@ void sub_080812A8(Entity* this) {
void sub_080812E8(Entity* this) {
PlayerState* playerState = &gPlayerState;
#ifdef EU
if ((playerState->swimState & 0x80) && sub_080177A0(this, &gPlayerEntity)) {
#else
if ((playerState->swimState & 0x80) && !(playerState->flags.all & 0x80) && sub_080177A0(this, &gPlayerEntity)) {
#endif
sub_080810FC(this);
}
}
+1 -3
View File
@@ -4,8 +4,6 @@
#include "player.h"
#include "functions.h"
extern void DoExitTransition(void*);
extern void (*const gUnk_08122254[])(Entity*);
extern u16 gUnk_0812225C[];
@@ -35,6 +33,6 @@ void sub_08090F00(Entity* this) {
}
if ((gPlayerState.flags.all & 0x80) && sub_080041A0(this, &gPlayerEntity, 4, 4) &&
(gPlayerEntity.height.HALF.HI == 0) && (((u16)gPlayerState.field_0x90.HALF.LO) & gUnk_0812225C[this->type2])) {
DoExitTransition((Entity*)GetCurrentRoomProperty(this->actionDelay));
DoExitTransition(GetCurrentRoomProperty(this->actionDelay));
}
}
+6 -4
View File
@@ -3,14 +3,16 @@
extern u32 CheckRectOnScreen(s16, s16, u32, u32);
/*
This object is created by Manager13.
It checks whether the 0x10 x 0x10 rect at field_0x80, field_0x82 is still on the screen.
If not, then it deletes itselfs and unsets the this->type2 bit in the managers field_0x20 bitfield.
*/
void Object1C(Entity* this) {
s32 iVar1;
if (this->action == 0) {
this->action = 1;
}
iVar1 = CheckRectOnScreen(this->field_0x80.HWORD, this->field_0x82.HWORD, 0x10, 0x10);
if (iVar1 == 0) {
if (CheckRectOnScreen(this->field_0x80.HWORD, this->field_0x82.HWORD, 0x10, 0x10) == 0) {
this->parent->field_0x20 &= ~(1 << this->type2);
DeleteThisEntity();
}
+4
View File
@@ -44,6 +44,7 @@ void sub_0809F318(Entity* this) {
void sub_0809F374(Entity* this) {
sub_0806F69C(this);
#ifndef EU
if (gUnk_02000000->gameLanguage < 2) {
if (sub_080044EC(this, 0x2000) < 2) {
this->height.WORD = 0;
@@ -54,6 +55,7 @@ void sub_0809F374(Entity* this) {
this->actionDelay++;
}
} else {
#endif
switch (sub_080044EC(this, 0x2000)) {
default:
this->actionDelay++;
@@ -67,7 +69,9 @@ void sub_0809F374(Entity* this) {
sub_0809F448(this);
SoundReq(SFX_186);
}
#ifndef EU
}
#endif
}
void sub_0809F3E8(Entity* this) {
+2
View File
@@ -7,6 +7,8 @@ void ObjectB5(Entity* this) {
if (this->action == 0) {
this->action = 1;
}
#ifndef EU
gRoomControls.cameraTarget = this;
#endif
PositionRelative(&gPlayerEntity, this, 0, -0x280000);
}
+230
View File
@@ -0,0 +1,230 @@
#include "global.h"
#include "object.h"
#include "player.h"
#include "flags.h"
#include "game.h"
#include "audio.h"
#include "functions.h"
extern Hitbox gUnk_080FD168;
void WarpPoint(Entity*);
void sub_0808B474(Entity*);
void sub_0808B530(Entity*);
void sub_0808B564(Entity*);
void sub_0808B590(Entity*);
void sub_0808B5E8(Entity*);
void sub_0808B684(Entity*);
void sub_0808B73C(Entity*);
u32 sub_0808B7C8(Entity*);
void sub_0808B830(Entity*);
void (*const gUnk_08121368[])(Entity*) = {
sub_0808B474, sub_0808B530, sub_0808B564, sub_0808B590, sub_0808B5E8, sub_0808B684,
};
const u8 gUnk_08121380[3] = { 1, 0, 2 };
void WarpPoint(Entity* this) {
if (!this->field_0x70.BYTES.byte0) {
gUnk_08121368[this->action](this);
} else {
sub_0808B73C(this);
}
}
void sub_0808B474(Entity* this) {
u32 tmp;
this->action = 1;
this->field_0xf = 0;
tmp = gUnk_08121380[this->type];
this->palette.b.b0 = tmp;
this->spritePriority.b0 = 6;
this->hitbox = &gUnk_080FD168;
this->scriptedScene = 3;
InitializeAnimation(this, 0);
if (CheckFlags(this->field_0x86.HWORD)) {
sub_0808B830(this);
} else {
if (CheckIsDungeon() && sub_0807CAEC(this->type)) {
sub_0808B830(this);
}
}
if (!sub_0808B7C8(this))
return;
this->action = 4;
this->field_0xf = 0x60;
gPlayerEntity.x.HALF.HI = this->x.HALF.HI;
gPlayerEntity.y.HALF.HI = this->y.HALF.HI;
gPlayerEntity.animationState = 4;
EnqueueSFX(0x112);
sub_0805E4E0(this, this->field_0xf + 0x10);
}
void sub_0808B530(Entity* this) {
if (CheckFlags(this->field_0x86.HWORD)) {
sub_0808B830(this);
if (CheckIsDungeon()) {
sub_0807CAC8(this->type);
}
this->action = 2;
this->field_0xf = 60;
EnqueueSFX(0x112);
}
}
void sub_0808B564(Entity* this) {
if (!--this->field_0xf) {
this->action = 3;
} else {
this->spriteSettings.b.draw = this->field_0xf & 2 ? 0 : 1;
}
}
void sub_0808B590(Entity* this) {
GetNextFrame(this);
if (sub_0808B7C8(this)) {
if (this->actionDelay)
return;
this->action = 5;
this->field_0xf = 0x60;
sub_08077B20();
gPlayerEntity.x.HALF.HI = this->x.HALF.HI;
gPlayerEntity.y.HALF.HI = this->y.HALF.HI;
gPlayerEntity.animationState = 4;
gPlayerEntity.flags &= ~0x80;
sub_0805E4E0(this, this->field_0xf + 0x10);
SoundReq(0x113);
} else {
this->actionDelay = 0;
}
}
void sub_0808B5E8(Entity* this) {
u32 tmp;
if (!--this->field_0xf) {
this->action = 3;
this->actionDelay = 1;
gPlayerEntity.animationState = 4;
gPlayerEntity.direction = DirectionSouth;
return;
}
tmp = 0;
switch (this->field_0xf & 0x60) {
case 0x40:
if (this->field_0xf == 0x58) {
SoundReq(0x114);
}
if (!(this->field_0xf & 1)) {
tmp = 1;
}
break;
case 0x20:
if (!(this->field_0xf & 3)) {
tmp = 1;
}
break;
case 0:
if (!(this->field_0xf & 7)) {
if (gPlayerEntity.animationState == 4) {
if (this->field_0xf > 0x18) {
tmp = 1;
}
} else {
tmp = 1;
}
}
break;
}
if (tmp) {
gPlayerEntity.animationState += 2;
gPlayerEntity.animationState &= 6;
}
}
void sub_0808B684(Entity* this) {
u32 tmp;
if (!--this->field_0xf) {
gScreenTransition.transitioningOut = 1;
gScreenTransition.transitionType = 0;
gScreenTransition.areaID = this->field_0x7c.BYTES.byte0;
gScreenTransition.roomID = this->field_0x7c.BYTES.byte1;
gScreenTransition.playerStartPos.HALF.x = ((this->cutsceneBeh.HWORD & 0x3f) << 4) + 8;
gScreenTransition.playerStartPos.HALF.y = ((this->cutsceneBeh.HWORD & 0xfc0) >> 2) + 8;
gScreenTransition.playerLayer = 0;
gScreenTransition.playerState = 4;
gScreenTransition.field_0xf = 0;
if (this->type == 2) {
gScreenTransition.transitionType = 2;
}
return;
}
tmp = 0;
switch (this->field_0xf & 0x60) {
case 0x40:
if (!(this->field_0xf & 7)) {
tmp = 1;
}
break;
case 0x20:
if (!(this->field_0xf & 3)) {
tmp = 1;
}
break;
case 0:
if (this->field_0xf > 0x10) {
if (!(this->field_0xf & 1)) {
tmp = 1;
}
} else {
gPlayerEntity.spriteSettings.b.draw = 0;
}
break;
}
if (tmp) {
gPlayerEntity.animationState += 2;
gPlayerEntity.animationState &= 6;
}
}
void sub_0808B73C(Entity* this) {
if (this->action == 0) {
this->action = 1;
this->palette.b.b0 = this->parent->palette.b.b0;
InitializeAnimation(this, 1);
}
if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28)) {
this->spriteSettings.b.draw = 1;
} else {
if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x2e)) {
this->spriteSettings.b.draw ^= 1;
} else {
this->spriteSettings.b.draw = 0;
}
}
GetNextFrame(this);
}
u32 sub_0808B7C8(Entity* this) {
if (!(gPlayerState.flags.all & 0x80) && gPlayerState.field_0xa8 != 0x12 && gPlayerEntity.currentHealth != 0 &&
sub_08079F8C() && sub_080041A0(this, &gPlayerEntity, 5, 5) && gPlayerEntity.height.HALF.HI == 0) {
if (this->actionDelay == 0 && gPlayerEntity.action == 0x1b) {
sub_080791D0();
}
return 1;
}
return 0;
}
void sub_0808B830(Entity* this) {
Entity* tmp;
this->action = 3;
this->actionDelay = 0;
this->spriteSettings.b.draw = 1;
tmp = CreateObject(0x34, 0, 0);
if (tmp) {
tmp->field_0x70.BYTES.byte0 = 1;
tmp->parent = this;
CopyPosition(this, tmp);
}
}