Merge pull request #535 from hatal175/sub_080878CC

This commit is contained in:
notyourav
2022-07-22 11:18:11 -07:00
committed by GitHub
6 changed files with 176 additions and 557 deletions
+148 -1
View File
@@ -82,6 +82,7 @@ extern u8 gUpdateVisibleTiles;
extern u16 gUnk_020178E0[];
extern u8 gUnk_02024090[];
extern const u16 gUnk_080FD5A8[];
extern void** gAreaTilesets[];
extern void** gAreaRoomMaps[];
@@ -157,6 +158,9 @@ static void InitAllRoomResInfo(void);
static void InitRoomResInfo(RoomResInfo* info, RoomHeader* hdr, u32 area, u32 room);
static void sub_080532E4(void);
static void ResetTimerFlags(void);
bool32 ItemIsBottle(u32);
void ModArrows(s32);
void ModShells(s32);
typedef struct {
u8 dest_off[8];
@@ -2249,7 +2253,150 @@ s32 GetItemPrice(u32 item) {
return ptr[0];
}
ASM_FUNC("asm/non_matching/game/GiveItem.inc", u32 GiveItem(u32 a, u32 b))
u32 GiveItem(Item item, u32 param_2) {
u32 uVar4;
u32 result;
u32 uVar9;
const ItemMetaData* metaData;
uVar4 = GetInventoryValue(item);
metaData = &gItemMetaData[item];
if (uVar4 == 0) {
result = *(u16*)&metaData->textId;
} else {
result = *(u16*)&metaData->unk6;
}
if (!ItemIsBottle(item)) {
PutItemOnSlot(item);
if (uVar4 == 0) {
SetInventoryValue(item, 1);
}
}
switch (metaData->unk1) {
case 0:
default:
break;
case 1:
ModHealth(metaData->unk2);
SoundReq(SFX_HEART_GET);
break;
case 2:
ModRupees((u32)gUnk_080FD5A8[metaData->unk2]);
SoundReq(SFX_RUPEE_GET);
break;
case 3:
uVar9 = 0;
while (TRUE) {
if (3 < uVar9) {
return result;
}
if (GetInventoryValue(ITEM_BOTTLE1 + uVar9) == 0)
break;
uVar9++;
}
item = ITEM_BOTTLE1 + uVar9;
if (gSave.stats.bottles[uVar9] == 0) {
gSave.stats.bottles[uVar9] = 0x20;
}
SetInventoryValue(item, 1);
PutItemOnSlot(item);
break;
case 4:
uVar9 = 0;
while (gSave.stats.bottles[uVar9] != 0x20) {
uVar9++;
if (3 < uVar9) {
return result;
}
}
if (3 < uVar9) {
break;
}
gSave.stats.bottles[uVar9] = (u8)item;
SetInventoryValue(item, 1);
SoundReq(SFX_ITEM_GET);
break;
case 5:
sub_080526F8(1);
SoundReq(SFX_103);
break;
case 6:
gSave.unk46C[gArea.dungeon_idx] |= metaData->unk2;
break;
case 0xd:
sub_0801E738(0x72);
break;
case 0x12:
if (item == ITEM_BOOMERANG) {
SetInventoryValue(ITEM_MAGIC_BOOMERANG, 0);
} else {
SetInventoryValue(ITEM_BOOMERANG, 0);
}
case 0x11:
LoadItemGfx();
break;
case 7:
if (item == ITEM_BOMBS) {
SetInventoryValue(ITEM_REMOTE_BOMBS, 0);
} else {
SetInventoryValue(ITEM_BOMBS, 0);
}
ModBombs(99);
LoadItemGfx();
break;
case 8:
if (uVar4 == 0) {
SetInventoryValue(ITEM_BOMBS, 1);
PutItemOnSlot(7);
} else {
gSave.stats.bombBagType++;
if (3 < gSave.stats.bombBagType) {
gSave.stats.bombBagType = 3;
}
}
ModBombs(99);
break;
case 9:
ModBombs(metaData->unk2);
SoundReq(SFX_103);
break;
case 0xb:
if (GetInventoryValue(ITEM_LARGE_QUIVER) == 0) {
SetInventoryValue(ITEM_LARGE_QUIVER, 1);
}
ModArrows(99);
LoadItemGfx();
break;
case 0xa:
gSave.stats.quiverType++;
if (3 < gSave.stats.quiverType) {
gSave.stats.quiverType = 3;
}
ModArrows(99);
break;
case 0xc:
ModArrows(metaData->unk2);
SoundReq(SFX_103);
break;
case 0x0e:
SetInventoryValue(ITEM_SHELLS, 1);
ModShells(param_2);
SoundReq(SFX_103);
break;
case 0x0f:
sub_0801E738(param_2);
break;
case 0x10:
gSave.stats.walletType++;
if (gSave.stats.walletType < 4) {
break;
}
gSave.stats.walletType = 3;
break;
}
return result;
}
// TODO Adapt ItemMetaData struct
void sub_08054288(s32 param_1) {
+10 -10
View File
@@ -59,13 +59,12 @@ void sub_08087888(Entity* this) {
}
}
NONMATCH("asm/non_matching/object20/sub_080878CC.inc", void sub_080878CC(Entity* this)) {
void sub_080878CC(Entity* this) {
s32 x;
s32 y;
s32 itX;
s32 itY;
u32 layer;
u32 tileType;
u32 pos;
x = this->x.HALF.HI;
@@ -74,13 +73,15 @@ NONMATCH("asm/non_matching/object20/sub_080878CC.inc", void sub_080878CC(Entity*
for (itX = -0x10; itX < 0x11; itX += 0x10) {
for (itY = -0x10; itY < 0x11; itY += 0x10) {
pos = TILE((u32)x + itX, (u32)y + itY);
if (sub_080B1AE0(pos, layer) == 0x2e) {
tileType = GetTileType(pos, layer);
if (tileType == 0x368 || tileType == 0x367
/*(tileType < 0x369) && (0x366 < tileType)*/) {
sub_08008796(this, 3, x + itX, y + itY);
} else {
SetTile(0x4022, pos, layer);
if (sub_080B1AE0(pos, (u8)layer) == 0x2e) {
switch (GetTileType(pos, layer)) {
case 0x368:
case 0x367:
sub_08008796(this, 3, x + itX, y + itY);
break;
default:
SetTile(0x4022, pos, layer);
break;
}
} else {
sub_08008796(this, 3, x + itX, y + itY);
@@ -88,4 +89,3 @@ NONMATCH("asm/non_matching/object20/sub_080878CC.inc", void sub_080878CC(Entity*
}
}
}
END_NONMATCH
+18 -18
View File
@@ -1185,7 +1185,7 @@ void ClearPlayerState(void) {
gPlayerState.field_0xe = 0;
gPlayerState.field_0x11 = 0;
gPlayerState.floor_type = SURFACE_NORMAL;
gPlayerState.floor_type_last = 0;
gPlayerState.floor_type_last = SURFACE_NORMAL;
gPlayerState.field_0x14 = 0;
gPlayerState.sword_state = 0;
gPlayerState.dash_state = 0;
@@ -1610,34 +1610,34 @@ void sub_08079BD8(Entity* this) {
this->spritePriority.b0 = gPlayerEntity.spritePriority.b0;
}
NONMATCH("asm/non_matching/playerUtils/sub_08079C30.inc", bool32 sub_08079C30(Entity* this)) {
if ((gPlayerState.field_0x14 == 0) && ((gPlayerState.flags & PL_FLAGS2) == 0)) {
bool32 sub_08079C30(Entity* param_1) {
if (gPlayerState.field_0x14 == 0 && (gPlayerState.flags & PL_FLAGS2) == 0) {
if ((gPlayerState.flags & PL_MINISH) != 0) {
return TRUE;
}
switch (gPlayerState.floor_type_last) {
case 0xd:
case 0x0e:
case 0x0f:
case 0x10:
case 0x14:
case 0x17:
case 0x2a:
case SURFACE_D:
case SURFACE_E:
case SURFACE_F:
case SURFACE_10:
case SURFACE_14:
case SURFACE_ICE:
case SURFACE_AUTO_LADDER:
return TRUE;
}
if (gPlayerState.floor_type == sub_08007DD6(GetRelativeCollisionTile(this, 0, -1), (u16*)gUnk_08007CAC)) {
if (gPlayerState.floor_type == sub_08007DD6(GetRelativeCollisionTile(this, 2, 0), (u16*)gUnk_08007CAC)) {
if (gPlayerState.floor_type ==
sub_08007DD6(GetRelativeCollisionTile(this, -2, 0), (u16*)gUnk_08007CAC)) {
return TRUE;
}
}
if (gPlayerState.floor_type != sub_08007DD6(GetRelativeCollisionTile(param_1, 0, -1), (u16*)gUnk_08007CAC))
return FALSE;
if (gPlayerState.floor_type != sub_08007DD6(GetRelativeCollisionTile(param_1, 2, 0), (u16*)gUnk_08007CAC))
return FALSE;
if (gPlayerState.floor_type == sub_08007DD6(GetRelativeCollisionTile(param_1, -2, 0), (u16*)gUnk_08007CAC)) {
return TRUE;
}
}
return FALSE;
}
END_NONMATCH
bool32 sub_08079D48(void) {
if (!sub_08079C30(&gPlayerEntity)) {