Match BgClipCheckWalkingOnCrumbleBlock

This commit is contained in:
y.demaisonregne 2023-06-23 15:36:42 +02:00
parent 8eb9584822
commit 40b625f5da
4 changed files with 72 additions and 49 deletions

View File

@ -2,7 +2,7 @@
This is a work in progress decompilation of Metroid - Zero Mission.
2644/2721 functions decompiled (97.17%, 77 left)
2645/2721 functions decompiled (97.21%, 76 left)
0x350b6c/0x76b014 bytes of data not in blobs (44.69%, 0x41a4a8 left)

View File

@ -19,7 +19,7 @@
#define SRAM_TEXT_SIZE 16
#define SRAM_GET_CHECKSUM_SIZE(type, iteration, checksumType) (sizeof(type) / sizeof(checksumType) / iteration - 1)
#define SRAM_GET_CHECKSUM_SIZE(type, iteration, checksumType) (sizeof(type) / iteration / sizeof(checksumType))
struct StartingInfo {
u8 startingArea;

View File

@ -1,6 +1,7 @@
#include "gba.h"
#include "bg_clip.h"
#include "transparency.h"
#include "block.h"
#include "macros.h"
#include "data/block_data.h"
@ -226,60 +227,78 @@ u16 BgClipGetNewBldalphaValue(u16 clip, u16 unused)
return bldalpha;
}
void BGClipCheckWalkingOnCrumbleBlock(void)
/**
* @brief 5a7a0 | 108 | Checks if samus is walking on a crumble block
*
*/
void BgClipCheckWalkingOnCrumbleBlock(void)
{
// https://decomp.me/scratch/agN3y
u32 ignoreBlock;
s32 xOffsetLeft;
u16 xOffsetRight;
u16 checkPos;
u16 xPosition;
u16 yPosition;
s32 behavior;
u32 stopSamus;
u16 i;
behavior = (u32)gSamusData.yVelocity >> 0x1F;
// Check falling
if (gSamusData.yVelocity < 0)
behavior = TRUE;
else
behavior = FALSE;
if (gSamusPhysics.standingStatus == STANDING_NOT_IN_CONTROL)
behavior++;
if (!behavior)
if (behavior)
return;
// Get max position to check for crumble blocks
behavior = gSamusData.xPosition + gSamusPhysics.drawDistanceRightOffset;
checkPos = (u32)behavior / BLOCK_SIZE;
if (checkPos > gBGPointersAndDimensions.clipdataWidth)
checkPos = gBGPointersAndDimensions.clipdataWidth;
// Get positions
behavior = gSamusData.xPosition + gSamusPhysics.drawDistanceLeftOffset;
if (behavior < 0)
behavior = 0;
xPosition = (u32)behavior / BLOCK_SIZE;
behavior = gSamusData.yPosition + gSamusPhysics.drawDistanceBottomOffset;
yPosition = (u32)(behavior + 2) / BLOCK_SIZE;
if (yPosition > gBGPointersAndDimensions.clipdataHeight)
yPosition = gBGPointersAndDimensions.clipdataHeight;
// Loop from current position to the check position
for (i = xPosition; i <= checkPos; i++)
{
behavior = gSamusData.xPosition + gSamusPhysics.drawDistanceRightOffset;
xOffsetRight = (behavior) >> 0x6;
if (xOffsetRight > gBGPointersAndDimensions.clipdataWidth)
xOffsetRight = gBGPointersAndDimensions.clipdataWidth;
// Get clipdata behavior
behavior = gTilemapAndClipPointers.pClipBehaviors[gBGPointersAndDimensions.
pClipDecomp[yPosition * gBGPointersAndDimensions.clipdataWidth + i]];
behavior = gSamusData.xPosition + gSamusPhysics.drawDistanceLeftOffset;
if (behavior < 0x0)
behavior = 0x0;
xPosition = behavior >> 0x6;
behavior = gSamusData.yPosition + gSamusPhysics.drawDistanceBottomOffset;
yPosition = (behavior + 0x2) >> 0x6;
if (yPosition > gBGPointersAndDimensions.clipdataHeight)
yPosition = gBGPointersAndDimensions.clipdataHeight;
for (; xPosition <= xOffsetRight; xPosition++)
if (behavior == CLIP_BEHAVIOR_CRUMBLE_BLOCK)
{
behavior = gTilemapAndClipPointers.pClipBehaviors[gBGPointersAndDimensions.
pClipDecomp[yPosition * gBGPointersAndDimensions.clipdataWidth + xPosition]];
// Check if speedboosting to not directly destroy the floor under samus, allows to run over crumble blocks
behavior = FALSE;
if ((gSamusData.pose == SPOSE_RUNNING || gSamusData.pose == SPOSE_ROLLING) && gSamusData.speedboostingShinesparking)
behavior = TRUE;
if (behavior == CLIP_BEHAVIOR_CRUMBLE_BLOCK)
// Store block
BlockStoreBrokenReformBlock(BLOCK_TYPE_CRUMBLE, i, yPosition, behavior);
}
else if (behavior == CLIP_BEHAVIOR_SLOW_CRUMBLE_BLOCK)
{
// Store block
if (BlockStoreBrokenReformBlock(BLOCK_TYPE_SLOW_CRUMBLE, i, yPosition, TRUE))
{
behavior = FALSE;
if ((gSamusData.pose == SPOSE_RUNNING || gSamusData.pose == SPOSE_ROLLING) && gSamusData.speedboostingShinesparking)
behavior = TRUE;
BlockStoreBrokenReformBlock(BLOCK_TYPE_CRUMBLE, xPosition, yPosition, (u8)behavior);
}
else if (behavior == CLIP_BEHAVIOR_SLOW_CRUMBLE_BLOCK)
{
if (BlockStoreBrokenReformBlock(BLOCK_TYPE_SLOW_CRUMBLE, xPosition, yPosition, TRUE))
{
BGClipSetBG1BlockValue(0x401, yPosition, xPosition);
BGClipSetClipdataBlockValue(0x401, yPosition, xPosition);
}
// Set "crumbling" graphics for the block
BgClipSetBG1BlockValue(CLIPDATA_TILEMAP_FLAG | CLIPDATA_TILEMAP_SOLID, yPosition, i);
BgClipSetClipdataBlockValue(CLIPDATA_TILEMAP_FLAG | CLIPDATA_TILEMAP_SOLID, yPosition, i);
}
}
}

View File

@ -1137,15 +1137,20 @@ u32 FileSelectEraseFileSubroutine(void)
{
action = 1;
}
else if (gChangedInput & KEY_B)
else
{
goto lbl;
//FILE_SELECT_DATA.subroutineStage = 10;
//break;
}
else if (gChangedInput & KEY_A)
{
action = (FILE_SELECT_DATA.enabledMenus >> FILE_SELECT_DATA.eraseFile) & 1 ? 2 : 0;
if (!(gChangedInput & KEY_B))
{
if (gChangedInput & KEY_A)
{
action = (FILE_SELECT_DATA.enabledMenus >> FILE_SELECT_DATA.eraseFile) & 1 ? 2 : 0;
}
}
else
{
FILE_SELECT_DATA.subroutineStage = 10;
action = 0;
}
}
}
@ -1251,7 +1256,6 @@ u32 FileSelectEraseFileSubroutine(void)
case 9:
if (FileSelectUpdateTilemap(TILEMAP_REQUEST_ERASE_YES_NO_DESPAWN))
{
lbl:
FILE_SELECT_DATA.subroutineStage = 10;
}
break;