diff --git a/README.md b/README.md index f36c6ca1..44ec0a63 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is a work in progress decompilation of Metroid - Zero Mission. Progress can be seen here : https://docs.google.com/spreadsheets/d/1X8XarD5evY8ZI7r_GQqh1pYmdVMbBcINYfRBUlogmKY/edit#gid=0 -**This decomp is not yet matching, it's also not shiftable, don't use it as a base to work on anything** +**This decomp not shiftable, don't use it as a base to work on anything** This produces the following ROMs: diff --git a/include/color_effects.h b/include/color_effects.h index 314d2749..6c0b841d 100644 --- a/include/color_effects.h +++ b/include/color_effects.h @@ -3,6 +3,11 @@ #include "types.h" +#define FADING_TYPE_IN 0 +#define FADING_TYPE_FLASH 1 +#define FADING_TYPE_OUT 2 +#define FADING_TYPE_UNK 3 + // Functions void unk_5b24c(void); @@ -21,6 +26,6 @@ void ApplySmoothPaletteTransition(u16* srcStart, u16* srcEnd, u16* dst, u8 stage void ApplySpecialBackgroundEffectColorOnBG(u16 mask, u16 color, u8 stage); void ApplySpecialBackgroundEffectColorOnOBJ(u16 mask, u16 color, u8 stage); void ApplySpecialBackgroundFadingColor(u8 type, u8 color, u16** ppSrc, u16** ppDst, u16 mask); -u16 ApplyFadeOnColor(u8 type, u16 color, u16 currentColor); +u16 ApplyFadeOnColor(u8 type, u16 color, u8 currentColor); #endif /* COLOR_EFFECTS_H */ \ No newline at end of file diff --git a/include/data/empty_datatypes.h b/include/data/empty_datatypes.h index 124391a4..267c3fba 100644 --- a/include/data/empty_datatypes.h +++ b/include/data/empty_datatypes.h @@ -8,6 +8,7 @@ #include "structs/scroll.h" #include "structs/room.h" #include "structs/power_bomb_explosion.h" +#include "structs/visual_effects.h" // 345868 @@ -17,7 +18,7 @@ extern const struct RawCoordsX sCoordsX_Empty; extern const struct LockScreen sLockScreen_Empty; -// Empty special background effect +extern const struct BackgroundEffect sBackgroundEffect_Empty; extern const struct BrokenBlock sBrokenBlock_Empty; @@ -31,7 +32,7 @@ extern const struct BG0Movement sBg0Movement_Empty; extern const struct BG3Movement sBg3Movement_Empty; -extern const u32 sUnusedStruct_3005504_Empty[2]; +extern const struct Unused_3005504 sUnusedStruct_3005504_Empty; extern const struct WaterMovement sWaterMovement_Empty; diff --git a/include/macros.h b/include/macros.h index fd80c864..334bffbe 100644 --- a/include/macros.h +++ b/include/macros.h @@ -10,10 +10,11 @@ #define check_samus_turning() ((pData->direction ^ (KEY_RIGHT | KEY_LEFT)) & gButtonInput) #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) -#define RED(c) ((c) & 0x1F) -#define GREEN(c) (((c) & 0x3E0) >> 5) -#define BLUE(c) do{b=((c) & 0x7C00) >> 10;}while(0) +#define RED(c) ((c) & COLOR_MASK) +#define GREEN(c) (((c) & (COLOR_MASK << 5)) >> 5) +#define BLUE(c) do{b=((c) & (COLOR_MASK << 10)) >> 10;}while(0) #define COLOR(r, g, b) (((b) << 10) | ((g) << 5) | (r)) +#define COLOR_MASK 0x1F #define PI 128 #define sin(a) (sSineTable[(a)]) diff --git a/include/structs/clipdata.h b/include/structs/clipdata.h index 52c86fcb..5b6e6056 100644 --- a/include/structs/clipdata.h +++ b/include/structs/clipdata.h @@ -51,4 +51,4 @@ extern struct TilemapAndClipPointers gTilemapAndClipPointers; extern u16 gEffectYPosition; extern i16 gEffectYPositionOffset; -#endif \ No newline at end of file +#endif diff --git a/include/structs/color_effects.h b/include/structs/color_effects.h index db8af230..fe4efd0d 100644 --- a/include/structs/color_effects.h +++ b/include/structs/color_effects.h @@ -9,9 +9,10 @@ struct ColorFading { u8 type; u8 stage; u8 timer; - u8 unk; + u8 unk_3; u8 status; - u8 unk_flag; + u8 unk_5; + u16 unk_6; }; // Typedef diff --git a/include/structs/demo.h b/include/structs/demo.h index 0e7fe88d..d7cee0e7 100644 --- a/include/structs/demo.h +++ b/include/structs/demo.h @@ -3,7 +3,14 @@ #include "types.h" -extern u8 gDemoState; -extern u32 gCurrentDemo; /* XXX: type */ +struct Demo { + u8 number; + u8 playing; + u8 status; + u8 unk_3; +}; -#endif \ No newline at end of file +extern u8 gDemoState; +extern struct Demo gCurrentDemo; /* XXX: type */ + +#endif diff --git a/include/structs/display.h b/include/structs/display.h index 915e6122..54f108d1 100644 --- a/include/structs/display.h +++ b/include/structs/display.h @@ -43,6 +43,9 @@ extern struct SuitFlashEffect gSuitFlashEffect; extern u16 gWrittenToWIN1H; extern u16 gWrittenToWIN1V; extern u16 gWrittenToBLDCNT; +extern u16 gWrittenToBLDCNT_Internal; + +extern u16 gWrittenTo0x05000000; extern u16 gWrittenToBLDALPHA; extern u16 gWrittenToBLDALPHA_H; diff --git a/include/structs/room.h b/include/structs/room.h index 2d198cfa..74653faf 100644 --- a/include/structs/room.h +++ b/include/structs/room.h @@ -93,6 +93,11 @@ struct BG3Movement { u16 xOffset; }; +struct Unused_3005504 { + u32 field_0; + u32 field_4; +}; + extern u16 gDecompClipdataMap[1024]; extern u16 gDecompBG0Map[1024]; @@ -110,4 +115,9 @@ extern u8 gScrollCounter; extern struct RoomEntry gCurrentRoomEntry; extern struct BackgroundPositions gBackgroundPositions; -#endif \ No newline at end of file +extern struct Unused_3005504 gUnusedStruct_3005504; + +// Temp +extern i8 gCurrentItemBeingAcquired; + +#endif diff --git a/include/structs/text.h b/include/structs/text.h new file mode 100644 index 00000000..c1fe610c --- /dev/null +++ b/include/structs/text.h @@ -0,0 +1,26 @@ +#ifndef TEXT_STRUCT_H +#define TEXT_STRUCT_H + +#include "types.h" + +struct Message { + u16 textIndex; + u16 indent; + u16 delay; + u8 color; + u8 line; + + u8 unk_8; + u8 unk_9; + + u8 messageID; + u8 gfxSlot; + u8 stage; + u8 isMessage; + u8 messageEnded; + u8 unk_F; +}; + +extern struct Message gCurrentMessage; + +#endif /* TEXT_STRUCT_H */ diff --git a/include/structs/visual_effects.h b/include/structs/visual_effects.h index 9f9dd2ba..3ddb881d 100644 --- a/include/structs/visual_effects.h +++ b/include/structs/visual_effects.h @@ -3,7 +3,19 @@ #include "types.h" +struct BackgroundEffect { + u8 unused; + u16 timer; + u8 colorStage; + u8 type; + u8 stage; + u8 unk_7; +}; + +extern struct BackgroundEffect gBackgroundEffect; + extern u8 gMonochromeBGFading; extern i8 gDisableAnimatedPalette; +extern i8 gDisableAnimatedGraphicsTimer; -#endif \ No newline at end of file +#endif diff --git a/src/bg_clip.c b/src/bg_clip.c index 1f360d42..00fa63d4 100644 --- a/src/bg_clip.c +++ b/src/bg_clip.c @@ -1,5 +1,6 @@ #include "gba.h" #include "bg_clip.h" +#include "transparency.h" #include "sprites_AI/item_banner.h" #include "data/block_data.h" @@ -14,6 +15,7 @@ #include "structs/bg_clip.h" #include "structs/clipdata.h" #include "structs/connection.h" +#include "structs/transparency.h" #include "structs/game_state.h" #include "structs/samus.h" @@ -103,7 +105,45 @@ void BGClipCheckTouchingSpecialClipdata(void) void BGClipApplyClipdataChangingTransparency(void) { + // https://decomp.me/scratch/qCOUj + u32 bldalpha; + u16 clipdata; + i32 xPosition; + i32 yPosition; + i32 clipLimit; + + xPosition = gSamusData.xPosition; + clipLimit = gBGPointersAndDimensions.clipdataWidth * BLOCK_SIZE; + if (xPosition > clipLimit) + xPosition = clipLimit; + + xPosition >>= 6; + + yPosition = gSamusData.yPosition + (gSamusPhysics.drawDistanceTopOffset >> 1); + if (yPosition < 0) + yPosition = 0; + else + { + clipLimit = gBGPointersAndDimensions.clipdataHeight * BLOCK_SIZE; + if (yPosition > clipLimit) + yPosition = clipLimit; + } + + yPosition >>= 6; + + clipdata = gTilemapAndClipPointers.pClipBehaviors[gBGPointersAndDimensions.pClipDecomp[yPosition * gBGPointersAndDimensions.clipdataWidth + xPosition]]; + if (clipdata == CLIP_BEHAVIOR_AIR_SOLID) + return; + + bldalpha = BGClipGetNewBLDALPHAValue(clipdata); + if (bldalpha == 0) + return; + + if (bldalpha == USHORT_MAX) + TransparencyUpdateBLDALPHA(gDefaultTransparency.evaCoef, gDefaultTransparency.evbCoef, 1, 1); + else + TransparencyUpdateBLDALPHA(bldalpha & UCHAR_MAX, bldalpha >> 8, 1, 1); } u16 BGClipGetNewBLDALPHAValue(u16 clip) diff --git a/src/color_effects.c b/src/color_effects.c index bf08b6c7..c5ba0439 100644 --- a/src/color_effects.c +++ b/src/color_effects.c @@ -81,8 +81,8 @@ void ApplyMonochromeToPalette(u16* src, u16* dst, i8 additionalValue) if (result < 0) result = 0; - else if (result > 0x1F) - result = 0x1F; + else if (result > COLOR_MASK) + result = COLOR_MASK; // Create grey color *dst = COLOR(result, result, result); @@ -124,13 +124,13 @@ void ApplySmoothMonochromeToPalette(u16* srcBase, u16* srcMonochrome, u16* dst, { colorMono = *srcMonochrome; monoR = RED(colorMono); - monoG = (colorMono >> 5) & 0x1F; - monoB = (colorMono >> 10) & 0x1F; + monoG = (colorMono >> 5) & COLOR_MASK; + monoB = (colorMono >> 10) & COLOR_MASK; colorBase = *srcBase; baseR = RED(colorBase); - baseG = (colorBase >> 5) & 0x1F; - baseB = (colorBase >> 10) & 0x1F; + baseG = (colorBase >> 5) & COLOR_MASK; + baseB = (colorBase >> 10) & COLOR_MASK; newR = (stage * (monoR - baseR) / 32); newG = (stage * (monoG - baseG) / 32); @@ -166,7 +166,44 @@ void ApplySpecialBackgroundFadingColor(u8 type, u8 color, u16** ppSrc, u16** ppD } -u16 ApplyFadeOnColor(u8 type, u16 color, u16 currentColor) +u16 ApplyFadeOnColor(u8 type, u16 color, u8 currentColor) { + // https://decomp.me/scratch/RdwBt + i32 red; + i32 green; + i32 b; + + red = RED(color); + green = GREEN(color); + BLUE(color); + + switch (type) + { + case FADING_TYPE_IN: + red = (currentColor * red) >> 5 & COLOR_MASK; + green = (currentColor * green) >> 5 & COLOR_MASK; + b = (currentColor * b) >> 5 & COLOR_MASK; + break; + + case FADING_TYPE_FLASH: + red = (COLOR_MASK - ((currentColor * (COLOR_MASK - red)) >> 5)) & COLOR_MASK; + green = (COLOR_MASK - ((currentColor * (COLOR_MASK - green)) >> 5)) & COLOR_MASK; + b = (COLOR_MASK - ((currentColor * (COLOR_MASK - b)) >> 5)) & COLOR_MASK; + break; + + case FADING_TYPE_OUT: + red = (red - ((currentColor * red) >> 5)) & COLOR_MASK; + green = (green - ((currentColor * green) >> 5)) & COLOR_MASK; + b =( b - ((currentColor * b) >> 5) )& COLOR_MASK; + break; + + case FADING_TYPE_UNK: + red = (red + ((currentColor * (COLOR_MASK - red)) >> 5)) & COLOR_MASK; + green = (green + ((currentColor * (COLOR_MASK - green)) >> 5)) & COLOR_MASK; + b = (b + ((currentColor * (COLOR_MASK - b)) >> 5)) & COLOR_MASK; + break; + } + + return COLOR(red, green, b); } diff --git a/src/data/empty_datatypes.c b/src/data/empty_datatypes.c index 49d55a65..c1bfa712 100644 --- a/src/data/empty_datatypes.c +++ b/src/data/empty_datatypes.c @@ -34,8 +34,14 @@ const struct LockScreen sLockScreen_Empty = { .yPositionCenter = USHORT_MAX, }; -// Empty special background effect -const u8 sTempArray_34587c[8] = {0}; +const struct BackgroundEffect sBackgroundEffect_Empty = { + .unused = 0, + .timer = 0, + .colorStage = 0, + .type = 0, + .stage = 0, + .unk_7 = 0 +}; const struct BrokenBlock sBrokenBlock_Empty = { .broken = FALSE, @@ -94,8 +100,9 @@ const struct BG3Movement sBg3Movement_Empty = { .undefined = 0 }; -const u32 sUnusedStruct_3005504_Empty[2] = { - 0, 0 +const struct Unused_3005504 sUnusedStruct_3005504_Empty = { + .field_0 = 0, + .field_4 = 0 }; const struct WaterMovement sWaterMovement_Empty = { diff --git a/src/room.c b/src/room.c index 7a3b8852..795c15f9 100644 --- a/src/room.c +++ b/src/room.c @@ -2,51 +2,95 @@ #include "gba.h" #include "data/engine_pointers.h" +#include "data/empty_datatypes.h" +#include "constants/audio.h" +#include "constants/clipdata.h" #include "constants/event.h" #include "constants/game_state.h" #include "constants/samus.h" #include "constants/room.h" -#include "structs/game_state.h" -#include "structs/color_effects.h" +#include "structs/audio.h" #include "structs/bg_clip.h" +#include "structs/color_effects.h" +#include "structs/clipdata.h" +#include "structs/cutscene.h" +#include "structs/display.h" +#include "structs/demo.h" +#include "structs/game_state.h" #include "structs/scroll.h" #include "structs/room.h" #include "structs/samus.h" #include "structs/screen_shake.h" #include "structs/visual_effects.h" - +/** + * @brief 55f7c | 26c | Loads the current room + * + */ void RoomLoad(void) { - /*ClipdataSetupCode(); + ClipdataSetupCode(); RoomReset(); + // Check for PSF if (gPauseScreenFlag == PAUSE_SCREEN_NONE) { + // No PSF, fully load room RoomLoadEntry(); ScrollLoad(); RoomSetBackgroundScrolling(); } + // Getting an item, init cutscene else if (gPauseScreenFlag == PAUSE_SCREEN_ITEM_ACQUISITION) { + // Varia + if (gCurrentItemBeingAcquired == 0xE) + { + gEquipment.suitMiscActivation &= ~SMF_VARIA_SUIT; + SamusSetPose(SPOSE_FACING_THE_FOREGROUND); + gSamusData.xPosition = 0x278; + gSamusData.yPosition = 0x1FF; + + gInGameCutscene.stage = 0; + gInGameCutscene.cutsceneNumber_Copy = 0x9; + start_in_game_cutscene(9); // Undefined + + gDisablePause = TRUE; + gSamusWeaponInfo.chargeCounter = 0; + gSamusData.lastWallTouchedMidAir = TRUE; + } } else if (gPauseScreenFlag == PAUSE_SCREEN_FULLY_POWERED_SUIT_ITEMS) { + gEquipment.suitMiscActivation &= ~SMF_GRAVITY_SUIT; + SamusSetPose(SPOSE_FACING_THE_FOREGROUND); + gSamusData.xPosition = 0x620; + gSamusData.yPosition = 0x7BF; + + gInGameCutscene.stage = 0; + gInGameCutscene.cutsceneNumber_Copy = 0xA; + start_in_game_cutscene(10); // Undefined + + gDisablePause = TRUE; + gSamusData.lastWallTouchedMidAir = TRUE; + gCurrentItemBeingAcquired = 0xF; // Gravity + gSamusWeaponInfo.chargeCounter = 0; } else if (gPauseScreenFlag == PAUSE_SCREEN_SUITLESS_ITEMS) PlayMusic(MUSIC_CHOZO_RUINS, 0x10); + // Load graphics RoomLoadTileset(); RoomLoadBackgrounds(); RoomRemoveNeverReformBlocksAndCollectedTanks(); gPreviousXPosition = gSamusData.xPosition; gPreviousYPosition = gSamusData.yPosition; TransparencySetRoomEffectsTransparency(); - LoadFirstRoom(); // Undefined + load_first_room(); // Undefined if (gPauseScreenFlag == PAUSE_SCREEN_NONE && !gIsLoadingFile) { @@ -57,6 +101,7 @@ void RoomLoad(void) ScrollProcessGeneral(); } + // Load states, entities check_play_lightning_effect(); // Undefined RoomUpdateBackgroundsPosition(); ConnectionLoadDoors(); @@ -65,22 +110,24 @@ void RoomLoad(void) RoomSetInitialTilemap(0x1); RoomSetInitialTilemap(0x2); load_animated_graphics(); // Undefined - ResetTanksAnimation(); // Undefined - SetBGHazeEffect(); // Undefined - ProcessHaze(); // Undefined - MinimapCheckOnTransition(); // Undefined + reset_tanks_animation(); // Undefined + set_bg_haze_effect(); // Undefined + process_haze(); // Undefined + MinimapCheckOnTransition(); + // Check using elevator if (!gIsLoadingFile && gGameModeSub3 != 0x0 && gPauseScreenFlag == PAUSE_SCREEN_NONE && gSamusData.pose == SPOSE_USING_AN_ELEVATOR) { if (gSamusData.elevatorDirection == KEY_UP) - gSamusData.yPosition += 0xC0; + gSamusData.yPosition += BLOCK_SIZE * 3; else - gSamusData.yPosition -= 0xC0; + gSamusData.yPosition -= BLOCK_SIZE * 3; gPreviousYPosition = gSamusData.yPosition; } sub_08060800(); // Undefined + // Update rain sound effect if (gRainSoundEffect != RAIN_SOUND_NONE) { if (gPauseScreenFlag == PAUSE_SCREEN_NONE) @@ -88,8 +135,10 @@ void RoomLoad(void) if (gRainSoundEffect & RAIN_SOUND_PLAYING) { if (!(gRainSoundEffect & RAIN_SOUND_ENABLED)) + { SoundFade(0x121, 0xA); // Rain gRainSoundEffect &= ~RAIN_SOUND_PLAYING; + } } else if (gRainSoundEffect & RAIN_SOUND_ENABLED) { @@ -98,7 +147,7 @@ void RoomLoad(void) } } gRainSoundEffect &= ~RAIN_SOUND_ENABLED; - }*/ + } } void RoomLoadTileset(void) @@ -259,12 +308,199 @@ void RoomRemoveNeverReformBlocksAndCollectedTanks(void) void RoomReset(void) { + // https://decomp.me/scratch/TZ1cZ + + const struct Door* pDoor; + i32 i; + i32 yOffset; + i32 xOffset; + u16 count; + u16* ptr; + u16 temp; + + gColorFading.unk_3 = 0; + gColorFading.timer = 0; + gColorFading.status = 0; + gColorFading.stage = 0; + gColorFading.unk_6 = 0; + if (gCurrentPowerBomb.animationState != 0) + gScreenShakeX = sScreenShake_Empty; + + gCurrentPowerBomb = sPowerBomb_Empty; + gWrittenToBLDCNT_Internal = 0; + gScrollCounter = 0; + gMusicTrackInfo.takingNormalTransition = FALSE; + + if (gGameModeSub3 == 0) + { + gMusicTrackInfo.currentRoomTrack = MUSIC_NONE; + gMusicTrackInfo.unk = 0; + gMusicTrackInfo.pauseScreenFlag = PAUSE_SCREEN_NONE; + + gCurrentClipdataAffectingAction = CAA_NONE; + gAreaBeforeTransition = UCHAR_MAX; + gDisableDoorAndTanks = FALSE; + gCurrentCutscene = 0; + + gLastElevatorUsed = sLastElevatorUsed_Empty; + gRainSoundEffect = RAIN_SOUND_NONE; + + if (!gIsLoadingFile && gCurrentDemo.status & 0xF0) + init_demo_related(FALSE); + + gDoorPositionStart.x = 0; + gDoorPositionStart.y = 0; + gCurrentItemBeingAcquired = 0; + + save_most_recent_file_to_sram(); // Undefined + } + + unk_5c158(); // Undefined + + if (gPauseScreenFlag != PAUSE_SCREEN_NONE) + return; + + gDisableScrolling = FALSE; + gSlowScrollingTimer = 0; + gCollectingTank = FALSE; + + gScreenShakeRelated = 0; + gDisablePause = FALSE; + gDisableClipdataChangingTransparency = FALSE; + + gWrittenTo0x05000000 = 0; + gScreenYOffset = 0; + gScreenXOffset = 0; + + gDISPCNTBackup = 0; + gInGameCutscene.cutsceneNumber = 0; + gInGameCutscene.cutsceneNumber_Copy = 0; + + gEffectYPosition = 0; + gHatchesState.unlocking = FALSE; + gHatchesState.hatchesLockedWithTimer = 0; + gHatchesState.unk = FALSE; + gHatchesState.hatchesLockedWithEvent = 0; + gHatchesState.unk2 = FALSE; + gDoorUnlockTimer = 0; + + pDoor = &sAreaDoorsPointers[gCurrentArea][0]; + pDoor += gLastDoorUsed; + gCurrentRoom = pDoor->sourceRoom; + gLastDoorProperties = pDoor->type; + gDisplayLocationText = (pDoor->type >> 6) & 1; + + gDoorPositionStart.x = pDoor->xStart; + gDoorPositionStart.y = pDoor->yStart; + + gWaitingSpacePiratesPosition = sCoordsX_Empty; + gLockScreen = sLockScreen_Empty; + gBackgroundEffect = sBackgroundEffect_Empty; + gWaterMovement = sWaterMovement_Empty; + + gEffectYPositionOffset = 0; + gUnusedStruct_3005504 = sUnusedStruct_3005504_Empty; + + gBG0Movement = sBg0Movement_Empty; + gBG2Movement.xOffset = 0; + gBG2Movement.yOffset = 0; + + for (i = 0; i < MAX_AMOUNT_OF_BROKEN_BLOCKS; i++) + gBrokenBlocks[i] = sBrokenBlock_Empty; + + for (i = 0; i < MAX_AMOUNT_OF_BOMB_CHAINS; i++) + gBombChains[i] = sBombChain_Empty; + + gActiveBombChainTypes = 0; + gDisableAnimatedGraphicsTimer = 0; + + count = 64; + while (count != 0) + { + ptr = &gMakeSolidBlocks[count]; + *--ptr = 0; + count--; + } + + gScreenShakeY = sScreenShake_Empty; + gScreenShakeX = sScreenShake_Empty; + gScreenShakeXOffset = 0; + gScreenShakeYOffset = 0; + + if (gIsLoadingFile) + return; + + gCamera.xPosition = 0; + gCamera.yPosition = 0; + gCamera.xVelocity = 0; + gCamera.yVelocity = 0; + + xOffset = pDoor->xStart; + yOffset = pDoor->yEnd + 1; + gSamusData.xPosition = xOffset * BLOCK_SIZE + (pDoor->xExit + 8) * 4; + gSamusData.yPosition = (yOffset) * BLOCK_SIZE + pDoor->yExit * 4 - 1; + + if (gCurrentDemo.status & 0xF0) + init_demo_related(TRUE); + + gWaitingSpacePiratesPosition.x = gSamusData.xPosition; + gWaitingSpacePiratesPosition.y = gSamusData.yPosition; + + if (pDoor->xExit > 0) + gWaitingSpacePiratesPosition.x -= HALF_BLOCK_SIZE; + else if (pDoor->xExit < 0) + gWaitingSpacePiratesPosition.x += HALF_BLOCK_SIZE; + + if (gSamusDoorPositionOffset != 0) + { + if (gSamusDoorPositionOffset < 0) + gSamusDoorPositionOffset = 0; + else + { + yOffset = -gSamusPhysics.drawDistanceTopOffset; + temp = (u16)yOffset; + if (temp + gSamusDoorPositionOffset > UCHAR_MAX) + gSamusDoorPositionOffset = UCHAR_MAX - temp; + } + + gSamusData.yPosition -= gSamusDoorPositionOffset; + gSamusDoorPositionOffset = 0; + } + + if (gSamusData.standingStatus == STANDING_ENEMY) + gSamusData.standingStatus = STANDING_MIDAIR; + + gBG1XPosition = 0; + gBG1YPosition = 0; + gBG0XPosition = 0; + gBG0YPosition = 0; } +/** + * @brief 56ac8 | 60 | Sets the automatic background scrolling (BG0 and BG3) + * + */ void RoomSetBackgroundScrolling(void) { + gBG3Movement = sBg3Movement_Empty; + switch (gCurrentRoomEntry.BG3Scrolling) + { + case 0x7: + case 0x8: + case 0xA: + gBG3Movement.direction = TRUE; + } + + if (gCurrentRoomEntry.visualEffect == EFFECT_WATER) + gBG0Movement.type = BG0_MOVEMENT_WATER_CLOUDS; + else if (gCurrentRoomEntry.visualEffect == EFFECT_SNOWFLAKES_COLD_KNOCKBACK) + gBG0Movement.type = BG0_MOVEMENT_SNOWFLAKES; + else if (gCurrentRoomEntry.visualEffect == EFFECT_SNOWFLAKES_COLD) + gBG0Movement.type = BG0_MOVEMENT_SNOWFLAKES; + + gInGameCutscene.cutsceneNumber_Copy = 0; } void RoomSetInitialTilemap(u8 bgNumber)