Start EnterTourianUpdateMetroid

This commit is contained in:
YohannDR 2023-04-03 15:56:44 +02:00
parent b6feeb96cb
commit 356576bf26
13 changed files with 164 additions and 16 deletions

View File

@ -766,7 +766,7 @@ sub_08063670: @ 0x08063670
ldrb r0, [r0, #4]
adds r1, #0xf0
ldr r2, lbl_080636a4 @ =0x08375d4c
bl process_cutscene_oam
bl ProcessCutsceneOam
bl ResetFreeOAM
pop {r0}
bx r0

View File

@ -1631,7 +1631,7 @@ sub_08067d40: @ 0x08067d40
ldrb r0, [r0, #4]
adds r1, #0xf0
ldr r2, lbl_08067d80 @ =0x083f03b0
bl process_cutscene_oam
bl ProcessCutsceneOam
bl ResetFreeOAM
ldr r0, lbl_08067d84 @ =gCurrentOamRotation
ldrh r0, [r0]
@ -2079,7 +2079,7 @@ sub_080680f0: @ 0x080680f0
ldrb r0, [r0, #4]
adds r1, #0xf0
ldr r2, lbl_08068124 @ =0x083f6c18
bl process_cutscene_oam
bl ProcessCutsceneOam
bl ResetFreeOAM
pop {r0}
bx r0
@ -5798,8 +5798,8 @@ lbl_08069dbc: .4byte 0x000001ff
lbl_08069dc0: .4byte 0xfffffe00
lbl_08069dc4: .4byte gNextOamSlot
thumb_func_start process_cutscene_oam
process_cutscene_oam: @ 0x08069dc8
thumb_func_start ProcessCutsceneOam
ProcessCutsceneOam: @ 0x08069dc8
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, sb

View File

@ -4,7 +4,8 @@
#include "types.h"
#include "structs/cutscene.h"
extern const u16 sEnterTourian_760090[13][2];
extern const u16 sEnterTourian_760090[9][2];
extern const u16 sEnterTourian_7600b4[4][2];
extern const struct CutsceneSubroutineData sEnterTourianSubroutineData[3];
#endif /* INTERNAL_ENTER_TOURIAN_DATA_H */

View File

@ -191,7 +191,153 @@ void EnterTourianScrollBackground(void)
void EnterTourianUpdateMetroid(struct CutsceneOamData* pOam, u8 metroidId)
{
// https://decomp.me/scratch/jYvuj
u32 position;
u32 notDrawn;
struct CutsceneOamData* pShell;
u32 var_0;
i32 var_1;
i32 var_2;
pShell = pOam - 1;
if (pOam->actions & 2)
{
UpdateCutsceneOamDataID(pOam, 3);
pOam->actions &= ~1;
pOam->actions ^= 2;
pOam->actions |= 4;
pOam->timer = 0;
}
if (pOam->actions & 1)
{
if (pOam->timer != USHORT_MAX)
pOam->timer++;
if (pOam->unk_16 != 0)
{
pOam->unk_16--;
}
else
{
if (pOam->unk_E != 0)
{
pOam->xPosition -= pOam->unk_E;
pOam->unk_E = 0;
pOam->unk_16 = (sRandomNumberTable[(pOam->timer - metroidId) & 0xFF] & 0x1F) + 8;
}
else
{
pOam->unk_E = ((sRandomNumberTable[(pOam->timer + metroidId) & 0xFF] & 0x1F) + 8) & 1 ? -4 : 4;
pOam->xPosition += pOam->unk_E;
}
}
if (pOam->unk_18 != 0)
{
pOam->unk_18--;
}
else
{
if (pOam->unk_10 != 0)
{
pOam->yPosition -= pOam->unk_10;
pOam->unk_10 = 0;
pOam->unk_18 = (sRandomNumberTable[(pOam->timer - metroidId) & 0xFF] & 0x3F) + 8;
}
else
{
pOam->unk_10 = sRandomNumberTable[(pOam->timer + metroidId) & 0xFF] & 2 ? -4 : 4;
pOam->yPosition += pOam->unk_10;
}
if (pOam->unk_18 == pOam->unk_16)
pOam->unk_18 += 16;
}
}
else if (pOam->actions & 4)
{
if (pOam->timer != USHORT_MAX)
pOam->timer++;
if (metroidId == 0)
var_0 = 0xB4;
else
var_0 = 0x3C;
if (pOam->timer < var_0)
{
var_1 = 1;
var_0 = 2;
}
else
{
var_1 = 2;
var_0 = 1;
}
pOam->unk_16++;
if (pOam->unk_E == 0)
{
pOam->unk_E = sEnterTourian_7600b4[metroidId][0] - pOam->xPosition;
var_2 = sRandomNumberTable[(metroidId * pOam->timer) & 0xFF] & 1 ? 1 : -1;
var_2 *= sRandomNumberTable[(metroidId + pOam->timer) & 0xFF] & 3;
if (var_1 > 0)
pOam->unk_E = var_2 * 4 + 0x20;
else
pOam->unk_E = var_2 * 4 - 0x20;
}
else if (pOam->unk_E > 0)
{
if (sEnterTourian_7600b4[metroidId][0] <= pOam->yPosition)
pOam->unk_E -= 2;
var_2 = pOam->unk_E / 12 + 1;
if (var_2 > var_1)
var_2 = var_1;
pOam->xPosition += var_2;
}
else
{
if (sEnterTourian_7600b4[metroidId][0] >= pOam->yPosition)
pOam->unk_E += 2;
var_2 = pOam->unk_E / 12 - 1;
if (var_2 > -var_1)
var_2 = -var_1;
pOam->xPosition += var_2;
}
pOam->unk_18++;
if (pOam->unk_10 == 0)
{
var_2 = sRandomNumberTable[(pOam->animationDurationCounter + pOam->currentAnimationFrame) & 0xFF] & 2 ? 1 : -1;
var_2 *= sRandomNumberTable[(pOam->timer + metroidId) & 0xFF] & 1;
}
}
pShell->yPosition = pOam->yPosition;
pShell->xPosition = pOam->xPosition;
position = *CutsceneGetBGHOFSPointer(sEnterTourianPageData[0].bg);
notDrawn = position - pOam->xPosition;
position = notDrawn + 0x7DF;
if (position < 0xBDF)
notDrawn = FALSE;
else
notDrawn = TRUE;
pOam->notDrawn = notDrawn;
pShell->notDrawn = notDrawn;
}
/**
@ -430,7 +576,8 @@ u8 EnterTourianSubroutine(void)
void EnterTourianProcessOAM(void)
{
gNextOamSlot = 0;
process_cutscene_oam(sEnterTourianSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sEnterTourianOam);
ProcessCutsceneOam(sEnterTourianSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength,
CUTSCENE_DATA.oam, sEnterTourianOam);
ResetFreeOAM();
CalculateOamPart4(gCurrentOamRotation, gCurrentOamScaling, 0);
}

View File

@ -363,6 +363,6 @@ u8 GettingFullyPoweredSuitSubroutine(void)
void GettingFullyPoweredSuitProcessOAM(void)
{
gNextOamSlot = 0;
process_cutscene_oam(sGettingFullyPoweredSuitSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sGettingFullyPoweredSuitCutsceneOAM);
ProcessCutsceneOam(sGettingFullyPoweredSuitSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sGettingFullyPoweredSuitCutsceneOAM);
ResetFreeOAM();
}

View File

@ -326,6 +326,6 @@ void KraidRisingProcessOAM(void)
{
gNextOamSlot = 0;
process_cutscene_oam(sKraidRisingSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sKraidRisingCutsceneOAM); // Undefined
ProcessCutsceneOam(sKraidRisingSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sKraidRisingCutsceneOAM); // Undefined
ResetFreeOAM();
}

View File

@ -146,6 +146,6 @@ u8 MechaRidleySeesSamusSubroutine(void)
void MechaRidleySeesSamusProcessOAM(void)
{
gNextOamSlot = 0;
process_cutscene_oam(sMechaSeesSamusSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sMechaSeesSamusCutsceneOAM); // Undefined
ProcessCutsceneOam(sMechaSeesSamusSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sMechaSeesSamusCutsceneOAM); // Undefined
ResetFreeOAM();
}

View File

@ -381,7 +381,7 @@ u8 MotherBrainCloseUpSubroutine(void)
void MotherBrainCloseUpProcessOAM(void)
{
gNextOamSlot = 0;
process_cutscene_oam(sMotherBrainCloseUpSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sMotherBrainCloseUpCutsceneOAM);
ProcessCutsceneOam(sMotherBrainCloseUpSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sMotherBrainCloseUpCutsceneOAM);
ResetFreeOAM();
}

View File

@ -605,7 +605,7 @@ u8 RidleyInSpaceSubroutine(void)
void RidleyInSpaceProcessOAM(void)
{
gNextOamSlot = 0;
process_cutscene_oam(sRidleyInSpaceSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sRidleyInSpaceCutsceneOAM);
ProcessCutsceneOam(sRidleyInSpaceSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sRidleyInSpaceCutsceneOAM);
ResetFreeOAM();
CalculateOamPart4(gCurrentOamRotation, gCurrentOamScaling, 0);

View File

@ -468,7 +468,7 @@ void RidleyLandingProcessOAM(void)
{
gNextOamSlot = 0;
process_cutscene_oam(sRidleyLandingSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sRidleyLandingCutsceneOAM);
ProcessCutsceneOam(sRidleyLandingSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sRidleyLandingCutsceneOAM);
ResetFreeOAM();
CalculateOamPart4(gCurrentOamRotation, gCurrentOamScaling, 0);
}

View File

@ -302,7 +302,7 @@ u8 RidleySpawnSubroutine(void)
void RidleySpawnProcessOAM(void)
{
gNextOamSlot = 0;
process_cutscene_oam(sRidleySpawnSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sRidleySpawnOam);
ProcessCutsceneOam(sRidleySpawnSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sRidleySpawnOam);
ResetFreeOAM();
CalculateOamPart4(gCurrentOamRotation, gCurrentOamScaling, 0);
}

View File

@ -215,6 +215,6 @@ u8 SamusInBlueShipSubroutine(void)
void SamusInBlueShipProcessOAM(void)
{
gNextOamSlot = 0;
process_cutscene_oam(sSamusInBlueShipSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sSamusInBlueShipOam);
ProcessCutsceneOam(sSamusInBlueShipSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sSamusInBlueShipOam);
ResetFreeOAM();
}

View File

@ -221,6 +221,6 @@ u8 StatueOpeningSubroutine(void)
void StatueOpeningProcessOAM(void)
{
gNextOamSlot = 0;
process_cutscene_oam(sStatueOpeningSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sStatueOpeningOam);
ProcessCutsceneOam(sStatueOpeningSubroutineData[CUTSCENE_DATA.timeInfo.stage].oamLength, CUTSCENE_DATA.oam, sStatueOpeningOam);
ResetFreeOAM();
}