Merge branch 'master' into tilemap-docs

This commit is contained in:
octorock
2023-12-28 14:59:23 +01:00
495 changed files with 14619 additions and 16191 deletions
+40 -33
View File
@@ -1,3 +1,10 @@
/**
* @file playerItemCellOverwriteSet.c
* @ingroup Items
*
* @brief Cell Overwrite Set Player Item
*/
#define NENT_DEPRECATED
#include "asm.h"
#include "common.h"
#include "entity.h"
@@ -5,6 +12,12 @@
#include "room.h"
#include "tiles.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused[4];
/*0x6c*/ u16 tileType;
} PlayerItemCellOverwriteSetEntity;
// vvv for specialMetaTile
const u8 gMapSpecialMetaTileToVvv[] = {
0, // SPECIAL_META_TILE_0
@@ -324,70 +337,64 @@ const u16 gUnk_080B7A3E[] = {
}; // TODO no need to store this in an u16?
// TODO figure out type from arm_sub_080B1B84 and arm_sub_080B1BA4, also related to specialMetaTiles
void PlayerItemCellOverwriteSet(Entity* this) {
void PlayerItemCellOverwriteSet(PlayerItemCellOverwriteSetEntity* this) {
static const s8 offsetByDirection[] = { 0, -16, 16, 0, 0, 16, -16, 0 };
u32 tmp;
Entity* player = &gPlayerEntity;
if (this->action == 0) {
this->field_0x6c.HWORD =
GetMetaTileType(TILE(player->x.HALF.HI + offsetByDirection[player->animationState & 0xe],
player->y.HALF.HI + offsetByDirection[(player->animationState & 0xe) + 1]),
this->collisionLayer);
this->action++;
if (super->action == 0) {
this->tileType = GetMetaTileType(TILE(player->x.HALF.HI + offsetByDirection[player->animationState & 0xe],
player->y.HALF.HI + offsetByDirection[(player->animationState & 0xe) + 1]),
super->collisionLayer);
super->action++;
}
gPlayerState.mobility |= 0x80;
tmp = gInput.heldKeys & R_BUTTON;
if ((gInput.heldKeys & A_BUTTON) != 0) {
if ((R_BUTTON & gInput.newKeys) != 0) {
this->field_0x6c.HWORD =
GetMetaTileType(TILE(player->x.HALF.HI + offsetByDirection[player->animationState & 0xe],
player->y.HALF.HI + offsetByDirection[(player->animationState & 0xe) + 1]),
this->collisionLayer);
if ((gInput.newKeys & R_BUTTON) != 0) {
this->tileType = GetMetaTileType(TILE(player->x.HALF.HI + offsetByDirection[player->animationState & 0xe],
player->y.HALF.HI + offsetByDirection[(player->animationState & 0xe) + 1]),
super->collisionLayer);
}
if ((gInput.heldKeys & R_BUTTON) != 0) {
player->iframes = 2;
} else {
if ((gInput.newKeys & DPAD_RIGHT) != 0) {
this->field_0x6c.HWORD--;
this->tileType--;
}
if ((gInput.newKeys & DPAD_LEFT) != 0) {
this->field_0x6c.HWORD++;
this->tileType++;
}
if ((gInput.heldKeys & (DPAD_LEFT | DPAD_RIGHT)) != 0) {
if (++this->subtimer > 0x1e) {
this->subtimer = 30;
if (++super->subtimer > 0x1e) {
super->subtimer = 30;
if ((gInput.heldKeys & DPAD_RIGHT) != 0) {
this->field_0x6c.HWORD--;
this->tileType--;
}
if ((gInput.heldKeys & DPAD_LEFT) != 0) {
this->field_0x6c.HWORD++;
this->tileType++;
}
}
} else {
this->subtimer = 0;
super->subtimer = 0;
}
}
} else {
sub_0807B7D8(this->field_0x6c.HWORD,
sub_0807B7D8(this->tileType,
TILE(player->x.HALF.HI + offsetByDirection[player->animationState & 0xe],
player->y.HALF.HI + offsetByDirection[(player->animationState & 0xe) + 1]),
this->collisionLayer);
super->collisionLayer);
gPlayerState.mobility &= ~0x80;
DeleteThisEntity();
}
if ((gInput.heldKeys & B_BUTTON) != 0) {
sub_0807B7D8(this->field_0x6c.HWORD,
TILE(player->x.HALF.HI + offsetByDirection[0], player->y.HALF.HI + offsetByDirection[1]),
this->collisionLayer);
sub_0807B7D8(this->field_0x6c.HWORD,
TILE(player->x.HALF.HI + offsetByDirection[2], player->y.HALF.HI + offsetByDirection[3]),
this->collisionLayer);
sub_0807B7D8(this->field_0x6c.HWORD,
TILE(player->x.HALF.HI + offsetByDirection[4], player->y.HALF.HI + offsetByDirection[5]),
this->collisionLayer);
sub_0807B7D8(this->field_0x6c.HWORD,
TILE(player->x.HALF.HI + offsetByDirection[6], player->y.HALF.HI + offsetByDirection[7]),
this->collisionLayer);
sub_0807B7D8(this->tileType, TILE(player->x.HALF.HI + offsetByDirection[0], player->y.HALF.HI + offsetByDirection[1]),
super->collisionLayer);
sub_0807B7D8(this->tileType, TILE(player->x.HALF.HI + offsetByDirection[2], player->y.HALF.HI + offsetByDirection[3]),
super->collisionLayer);
sub_0807B7D8(this->tileType, TILE(player->x.HALF.HI + offsetByDirection[4], player->y.HALF.HI + offsetByDirection[5]),
super->collisionLayer);
sub_0807B7D8(this->tileType, TILE(player->x.HALF.HI + offsetByDirection[6], player->y.HALF.HI + offsetByDirection[7]),
super->collisionLayer);
}
}