Path: blob/master/SonicMania/Objects/MSZ/MSZSetup.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: MSZSetup Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectMSZSetup *MSZSetup;1011void MSZSetup_Update(void)12{13RSDK_THIS(MSZSetup);14StateMachine_Run(self->state);15}1617void MSZSetup_LateUpdate(void) {}1819void MSZSetup_StaticUpdate(void)20{21if (MSZSetup->usingRegularPalette) {22if (!(Zone->timer & 3))23++MSZSetup->background1->deformationOffset;2425MSZSetup->fadeTimer += 6;26if (MSZSetup->fadeTimer > 255) {27MSZSetup->fadeTimer -= 256;28RSDK.RotatePalette(1, 204, 207, false);29RSDK.RotatePalette(2, 204, 207, false);30}3132RSDK.SetLimitedFade(0, 1, 2, MSZSetup->fadeTimer, 204, 207);33}3435if (!(Zone->timer & 3))36RSDK.RotatePalette(0, 240, 243, false);3738--MSZSetup->bladeCactusFlowerAniTimer;39if (MSZSetup->bladeCactusFlowerAniTimer < 1) {40++MSZSetup->bladeCactusFlowerAniFrame;41MSZSetup->bladeCactusFlowerAniFrame %= 13;42MSZSetup->bladeCactusFlowerAniTimer = MSZSetup->bladeCactusFlowerAniDuration[MSZSetup->bladeCactusFlowerAniFrame];4344RSDK.DrawAniTiles(MSZSetup->aniTiles, 720, 16 * ((MSZSetup->bladeCactusFlowerAniSprPos[MSZSetup->bladeCactusFlowerAniFrame] & 0xFFFC) + 8),4532 * (MSZSetup->bladeCactusFlowerAniSprPos[MSZSetup->bladeCactusFlowerAniFrame] & 3), 64, 32);46}4748--MSZSetup->bobbingCactusFlowerAniTimer;49if (MSZSetup->bobbingCactusFlowerAniTimer < 1) {50++MSZSetup->bobbingCactusFlowerAniFrame;51MSZSetup->bobbingCactusFlowerAniFrame &= 7;52MSZSetup->bobbingCactusFlowerAniTimer = MSZSetup->bobbingCactusFlowerAniDuration[MSZSetup->bobbingCactusFlowerAniFrame];53RSDK.DrawAniTiles(MSZSetup->aniTiles, 74, 0, 16 * (MSZSetup->bobbingCactusFlowerAniFrame + 8), 80, 16);54}5556if (!(Zone->timer & 3)) {57MSZSetup->spinningCactusFlowerAniFrame += 16;58MSZSetup->spinningCactusFlowerAniFrame &= 0x7F;59RSDK.DrawAniTiles(MSZSetup->aniTiles, 89, MSZSetup->spinningCactusFlowerAniFrame, 96, 16, 32);60}6162MSZSetup->parallaxPos += MSZSetup->parallaxMult;63globals->tempFlags = MSZSetup->usingRegularPalette;6465if (MSZSetup->starPostID != StarPost->postIDs[0]) {66MSZSetup->starPostID = StarPost->postIDs[0];67globals->restartFlags = MSZSetup->usingRegularPalette;68}69}7071void MSZSetup_Draw(void) {}7273void MSZSetup_Create(void *data)74{75RSDK_THIS(MSZSetup);7677self->active = ACTIVE_NORMAL;78if (data)79self->state = (Type_StateMachine)data;8081if (SceneInfo->minutes || SceneInfo->seconds || SceneInfo->milliseconds) {82if (SceneInfo->minutes == globals->tempMinutes && SceneInfo->seconds == globals->tempSeconds83&& SceneInfo->milliseconds == globals->tempMilliseconds)84MSZSetup->usingRegularPalette = globals->tempFlags;85else86MSZSetup->usingRegularPalette = globals->restartFlags;87}88else {89globals->restartFlags = 0;90globals->tempFlags = 0;91MSZSetup->usingRegularPalette = false;92}9394if (MSZSetup->usingRegularPalette) {95#if MANIA_USE_PLUS96if (SceneInfo->filter & FILTER_ENCORE) {97RSDK.LoadPalette(0, "EncoreMSZ2.act", 0b0000000011111111);98self->state = MSZSetup_State_CheckTrainStart;99}100else {101#endif102for (int32 i = 0; i < 0x400; ++i) MSZSetup->background1->deformationData[i] = MSZSetup->deformData[i & 0x1F];103RSDK.CopyPalette(4, 128, 0, 128, 128);104destroyEntity(self);105#if MANIA_USE_PLUS106}107108RSDK.CopyPalette(0, 128, 1, 128, 128);109RSDK.CopyPalette(0, 128, 2, 128, 128);110RSDK.RotatePalette(2, 204, 207, false);111#endif112}113#if MANIA_USE_PLUS114else if (SceneInfo->filter & FILTER_ENCORE) {115RSDK.LoadPalette(0, "EncoreMSZ1.act", 0b0000000011111111);116RSDK.CopyPalette(0, 128, 3, 128, 80);117RSDK.LoadPalette(4, "EncoreMSZ2.act", 0b0000000011111111);118}119#endif120else {121#if !MANIA_USE_PLUS122RSDK.CopyPalette(0, 204, 4, 204, 4);123#endif124RSDK.CopyPalette(3, 128, 0, 128, 128);125}126}127128void MSZSetup_StageLoad(void)129{130MSZSetup->aniTiles = RSDK.LoadSpriteSheet("MSZ/AniTiles.gif", SCOPE_STAGE);131MSZSetup->background1 = RSDK.GetTileLayer(0);132133if (RSDK.CheckSceneFolder("MSZCutscene")) {134RSDK.CopyPalette(0, 204, 4, 204, 4);135RSDK.CopyPalette(3, 128, 0, 128, 128);136137MSZSetup_StoreBGParallax();138MSZSetup_ReloadBGParallax_Multiply(0x400);139}140else {141#if MANIA_USE_PLUS142GiantPistol->inCutscene = false;143MSZSetup->chuggaVolume = 0;144#endif145146if (Zone->actID) {147MSZSetup->usingRegularPalette = true;148RSDK.CopyPalette(4, 128, 0, 128, 128);149#if MANIA_USE_PLUS150if (SceneInfo->filter & FILTER_ENCORE) {151RSDK.CopyPalette(0, 128, 5, 128, 128);152RSDK.LoadPalette(0, "EncoreMSZ2.act", 0b0000000011111111);153RSDK.CopyPalette(0, 128, 1, 128, 128);154RSDK.CopyPalette(0, 128, 2, 128, 128);155RSDK.RotatePalette(2, 204, 207, false);156}157else {158for (int32 i = 0; i < 0x400; ++i) MSZSetup->background1->deformationData[i] = MSZSetup->deformData[i & 0x1F];159}160#else161for (int32 i = 0; i < 0x400; ++i) MSZSetup->background1->deformationData[i] = MSZSetup->deformData[i & 0x1F];162#endif163164#if MANIA_USE_PLUS165if (!(SceneInfo->filter & FILTER_ENCORE) && GET_CHARACTER_ID(1) == ID_KNUCKLES) {166#else167if (GET_CHARACTER_ID(1) == ID_KNUCKLES) {168#endif169Zone->cameraBoundsL[0] = 0;170Zone->cameraBoundsL[1] = 0;171Zone->cameraBoundsL[2] = 0;172Zone->cameraBoundsL[3] = 0;173174if (!CutsceneRules_CheckStageReload() && CutsceneRules_CheckPlayerPos(TO_FIXED(76), TO_FIXED(324), TO_FIXED(500), TO_FIXED(564))) {175Zone->cameraBoundsB[0] = 564;176Zone->cameraBoundsB[1] = 564;177Zone->cameraBoundsB[2] = 564;178Zone->cameraBoundsB[3] = 564;179}180181if (isMainGameMode() && globals->atlEnabled && !CutsceneRules_CheckStageReload()) {182Zone_ReloadStoredEntities(TO_FIXED(288), TO_FIXED(560), true);183}184}185else if (isMainGameMode() && globals->atlEnabled) {186if (!CutsceneRules_CheckStageReload()) {187MSZSetup_HandleRestart();188}189else {190globals->parallaxOffset[0] = 0;191globals->parallaxOffset[1] = 0;192}193}194else {195globals->parallaxOffset[0] = 0;196globals->parallaxOffset[1] = 0;197}198199if (isMainGameMode() && CutsceneRules_IsAct2()) {200foreach_all(MSZ2Cutscene, cutscene)201{202MSZSetup->msz2Cutscene = cutscene;203foreach_break;204}205206Zone->stageFinishCallback = MSZSetup_StageFinish_EndAct2;207}208209GenericTrigger->callbacks[MSZ_GENERICTRIGGER_ACHIEVEMENT] = MSZSetup_Trigger_AwardAchievement;210}211else {212#if MANIA_USE_PLUS213if ((SceneInfo->filter & FILTER_ENCORE)) {214RSDK.ResetEntitySlot(32, MSZSetup->classID, MSZSetup_State_ManageFade_E);215216if (isMainGameMode()) {217if (CutsceneRules_IsAct1())218Zone->stageFinishCallback = MSZSetup_StageFinish_EndAct1E;219}220}221else {222if (RSDK.GetEntityCount(Tornado->classID, false) <= 0) {223RSDK.ResetEntitySlot(32, MSZSetup->classID, MSZSetup_State_ManageFade_K);224225if (!CutsceneRules_IsIntroEnabled())226FXFade_StopAll();227228if (CutsceneRules_IsAct1Regular()) {229Zone->shouldRecoverPlayers = true;230Zone->stageFinishCallback = MSZSetup_StageFinish_EndAct1K;231}232}233else {234MSZSetup_StoreBGParallax();235MSZSetup_ReloadBGParallax_Multiply(0x400);236RSDK.ResetEntitySlot(32, MSZSetup->classID, MSZSetup_State_ManageFade_ST);237238if (CutsceneRules_IsAct1Regular())239Zone->stageFinishCallback = MSZSetup_StageFinish_EndAct1ST;240GiantPistol->inCutscene = true;241}242}243#else244if (CHECK_CHARACTER_ID(ID_KNUCKLES, 1)) {245RSDK.ResetEntitySlot(17, MSZSetup->classID, MSZSetup_State_ManageFade_K);246if (!CutsceneRules_IsIntroEnabled())247FXFade_StopAll();248249if (CutsceneRules_IsAct1Regular()) {250Zone->shouldRecoverPlayers = true;251Zone->stageFinishCallback = MSZSetup_StageFinish_EndAct1K;252}253}254else {255MSZSetup_StoreBGParallax();256MSZSetup_ReloadBGParallax_Multiply(0x400);257RSDK.ResetEntitySlot(17, MSZSetup->classID, MSZSetup_State_ManageFade_ST);258259if (CutsceneRules_IsAct1Regular())260Zone->stageFinishCallback = MSZSetup_StageFinish_EndAct1ST;261}262#endif263}264}265266#if MANIA_USE_PLUS267MSZSetup->sfxLocoChugga = RSDK.GetSfx("MSZ/LocoChugga.wav");268#endif269270Animals->animalTypes[0] = ANIMAL_LOCKY;271Animals->animalTypes[1] = ANIMAL_POCKY;272}273274void MSZSetup_SetBGScrollOrigin(int32 x, int32 y)275{276int32 posX = x >> 8;277278TileLayer *background1 = RSDK.GetTileLayer(0);279background1->scrollPos += (y >> 8) * background1->parallaxFactor;280for (int32 i = 0; i < background1->scrollInfoCount; ++i) {281background1->scrollInfo[i].scrollPos = posX * background1->scrollInfo[i].parallaxFactor;282}283284TileLayer *background2 = RSDK.GetTileLayer(1);285background2->scrollPos += (y >> 8) * background2->parallaxFactor;286for (int32 i = 0; i < background2->scrollInfoCount; ++i) {287background2->scrollInfo[i].scrollPos = posX * background2->scrollInfo[i].parallaxFactor;288}289290foreach_all(ParallaxSprite, sprite)291{292if (sprite->aniID < MSZ_PARALLAXSPRITE_OOZPEEK)293sprite->scrollPos.x += posX * (sprite->parallaxFactor.x >> 16);294}295}296297void MSZSetup_StoreBGParallax(void)298{299int32 id = 0;300301TileLayer *background1 = RSDK.GetTileLayer(0);302for (int32 i = 0; i < background1->scrollInfoCount; ++i) {303MSZSetup->storedParallax[id++] = background1->scrollInfo[i].parallaxFactor;304#if MANIA_USE_PLUS305if (SceneInfo->filter == (FILTER_BOTH | FILTER_MANIA))306#endif307background1->scrollInfo[i].parallaxFactor = 0;308}309310TileLayer *background2 = RSDK.GetTileLayer(1);311for (int32 i = 0; i < background2->scrollInfoCount; ++i) {312MSZSetup->storedParallax[id++] = background2->scrollInfo[i].parallaxFactor;313#if MANIA_USE_PLUS314if (SceneInfo->filter == (FILTER_BOTH | FILTER_MANIA))315#endif316background2->scrollInfo[i].parallaxFactor = 0;317}318319foreach_all(ParallaxSprite, parallaxSprite)320{321MSZSetup->storedParallax[id++] = (parallaxSprite->parallaxFactor.x >> 8);322#if MANIA_USE_PLUS323if (SceneInfo->filter == (FILTER_BOTH | FILTER_MANIA))324#endif325parallaxSprite->parallaxFactor.x = 0;326}327}328329void MSZSetup_ReloadBGParallax(void)330{331int32 id = 0;332TileLayer *background1 = RSDK.GetTileLayer(0);333for (int32 i = 0; i < background1->scrollInfoCount; ++i) background1->scrollInfo[i].scrollSpeed = MSZSetup->storedParallax[id++];334335TileLayer *background2 = RSDK.GetTileLayer(1);336for (int32 i = 0; i < background2->scrollInfoCount; ++i) background2->scrollInfo[i].scrollSpeed = MSZSetup->storedParallax[id++];337338foreach_all(ParallaxSprite, parallaxSprite) { parallaxSprite->scrollSpeed.x = MSZSetup->storedParallax[id++] << 8; }339}340341void MSZSetup_ReloadBGParallax_Multiply(int32 parallaxMultiplier)342{343int32 id = 0;344TileLayer *background1 = RSDK.GetTileLayer(0);345for (int32 i = 0; i < background1->scrollInfoCount; ++i)346background1->scrollInfo[i].scrollSpeed = parallaxMultiplier * MSZSetup->storedParallax[id++];347348TileLayer *background2 = RSDK.GetTileLayer(1);349for (int32 i = 0; i < background2->scrollInfoCount; ++i)350background2->scrollInfo[i].scrollSpeed = parallaxMultiplier * MSZSetup->storedParallax[id++];351352foreach_all(ParallaxSprite, parallaxSprite)353{354parallaxSprite->scrollSpeed.x = parallaxMultiplier * MSZSetup->storedParallax[id++];355#if MANIA_USE_PLUS356if (!(SceneInfo->filter & FILTER_ENCORE))357#endif358parallaxSprite->scrollSpeed.x >>= 8;359}360361MSZSetup->parallaxMult = parallaxMultiplier << 8;362}363364void MSZSetup_State_ManageFade_ST(void)365{366RSDK_THIS(MSZSetup);367368#if GAME_VERSION == VER_100369EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);370if (player1->position.x > TO_FIXED(6528)) {371#else372if (ScreenInfo->position.x + ScreenInfo->center.x > 6528) {373#endif374self->state = MSZSetup_State_SwitchPalettes;375}376}377378void MSZSetup_State_ManageFade_K(void)379{380RSDK_THIS(MSZSetup);381382EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);383if (player1->position.x < TO_FIXED(8448) && player1->position.y < TO_FIXED(1600))384self->state = MSZSetup_State_SwitchPalettes;385}386387#if MANIA_USE_PLUS388void MSZSetup_State_ManageFade_E(void)389{390RSDK_THIS(MSZSetup);391392foreach_all(Decoration, decoration)393{394if (decoration->animator.animationID == 2 || decoration->animator.animationID == 3)395decoration->animator.speed = 0;396}397398self->state = MSZSetup_State_CheckFadeTrigger_E;399}400#endif401402void MSZSetup_StageFinish_EndAct1ST(void) { MSZCutsceneST->finishedAct = true; }403404void MSZSetup_StageFinish_EndAct1K(void)405{406Zone_StoreEntities((Zone->cameraBoundsL[0] + ScreenInfo->center.x) << 16, Zone->cameraBoundsB[0] << 16);407RSDK.LoadScene();408}409410#if MANIA_USE_PLUS411void MSZSetup_StageFinish_EndAct1E(void) {}412#endif413414void MSZSetup_StageFinish_EndAct2(void) { MSZSetup->msz2Cutscene->active = ACTIVE_NORMAL; }415416void MSZSetup_Trigger_AwardAchievement(void)417{418if (!MSZSetup->hasAchievement) {419API_UnlockAchievement(&achievementList[ACH_MSZ]);420MSZSetup->hasAchievement = true;421}422}423424void MSZSetup_State_SwitchPalettes(void)425{426RSDK_THIS(MSZSetup);427428self->timer += 4;429RSDK.SetLimitedFade(0, 3, 4, self->timer, 128, 255);430431if (self->timer >= 256) {432#if MANIA_USE_PLUS433if (!(SceneInfo->filter & FILTER_ENCORE)) {434#endif435for (int32 i = 0; i < 0x400; ++i) MSZSetup->background1->deformationData[i] = MSZSetup->deformData[i & 0x1F];436#if MANIA_USE_PLUS437}438#endif439MSZSetup->usingRegularPalette = true;440441RSDK.CopyPalette(4, 128, 0, 128, 128);442#if MANIA_USE_PLUS443RSDK.CopyPalette(4, 128, 1, 128, 128);444RSDK.CopyPalette(4, 128, 2, 128, 128);445RSDK.RotatePalette(2, 204, 207, false);446447if ((SceneInfo->filter & FILTER_ENCORE))448self->state = MSZSetup_State_CheckTrainStart;449else450#endif451destroyEntity(self);452}453}454455void MSZSetup_HandleRestart(void)456{457Zone_ReloadStoredEntities(WIDE_SCR_XCENTER << 16, 1440 << 16, true);458459int32 id = 0;460TileLayer *background1 = RSDK.GetTileLayer(0);461for (int32 i = 0; i < background1->scrollInfoCount; ++i) background1->scrollInfo[i].scrollPos = globals->parallaxOffset[id++];462463TileLayer *background2 = RSDK.GetTileLayer(1);464for (int32 i = 0; i < background2->scrollInfoCount; ++i) background2->scrollInfo[i].scrollPos = globals->parallaxOffset[id++];465466foreach_all(ParallaxSprite, parallaxSprite) { parallaxSprite->scrollPos.x = globals->parallaxOffset[id++]; }467}468469#if MANIA_USE_PLUS470void MSZSetup_State_CheckFadeTrigger_E(void)471{472RSDK_THIS(MSZSetup);473474EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);475if (player1->position.x > 0x29800000) {476if (player1->position.y > 0x4200000 && player1->position.y < 0x6800000)477self->state = MSZSetup_State_SwitchPalettes;478}479}480481void MSZSetup_State_CheckTrainStart(void)482{483RSDK_THIS(MSZSetup);484485EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);486if (player1->position.x > 0x2B600000) {487foreach_all(Decoration, decoration)488{489if (decoration->animator.animationID == 2 || decoration->animator.animationID == 3)490decoration->animator.speed = 1;491}492493Zone->cameraBoundsL[0] = 10624;494Zone->playerBoundsL[0] = 10624 << 16;495496MSZSetup->chuggaChannel = RSDK.PlaySfx(MSZSetup->sfxLocoChugga, 1, 255);497RSDK.SetChannelAttributes(MSZSetup->chuggaChannel, 0.0, 0.0, 1.0);498499MSZSetup_StoreBGParallax();500MSZSetup_ReloadBGParallax_Multiply(0x000);501Camera_ShakeScreen(0, 4, 4);502503RSDK.CopyTileLayer(4, 640, 94, 5, 0, 0, 62, 16);504RSDK.CopyTileLayer(4, 655, 0, 5, 0, 0, 17, 70);505RSDK.CopyTileLayer(3, 655, 0, 5, 0, 0, 17, 70);506RSDK.CopyTileLayer(2, 655, 0, 5, 0, 0, 17, 70);507508self->state = MSZSetup_State_TrainStarting;509}510}511512void MSZSetup_State_TrainStarting(void)513{514RSDK_THIS(MSZSetup);515516RSDK.SetChannelAttributes(MSZSetup->chuggaChannel, ++MSZSetup->chuggaVolume * (1 / 256.0f), 0.0, 1.0);517MSZSetup_ReloadBGParallax_Multiply(8 * MSZSetup->chuggaVolume);518519if (MSZSetup->chuggaVolume >= 256)520self->state = MSZSetup_State_TrainSequence_MSZ1E;521522RSDK.GetTileLayer(3)->scrollInfo[1].scrollSpeed = 0x600 * MSZSetup->chuggaVolume;523}524525void MSZSetup_State_TrainSequence_MSZ1E(void)526{527RSDK_THIS(MSZSetup);528529EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);530TileLayer *fgSupaLow = RSDK.GetTileLayer(3);531fgSupaLow->scrollInfo[1].scrollPos &= 0x00FFFFFF;532fgSupaLow->scrollInfo[1].scrollSpeed = 0x600 * MSZSetup->chuggaVolume;533534if (player1->position.x > 0x360C0000) {535GiantPistol->inCutscene = true;536self->state = MSZSetup_State_Boss_MSZ1E;537}538}539540void MSZSetup_State_Boss_MSZ1E(void)541{542RSDK_THIS(MSZSetup);543544TileLayer *fgSupaLow = RSDK.GetTileLayer(3);545fgSupaLow->scrollInfo[1].scrollPos &= 0x00FFFFFF;546fgSupaLow->scrollInfo[1].scrollSpeed = 0x600 * MSZSetup->chuggaVolume;547548if (!MSZSetup->parallaxMult) {549MSZSetup->chuggaVolume -= 4;550RSDK.SetChannelAttributes(MSZSetup->chuggaChannel, MSZSetup->chuggaVolume * (1 / 256.0f), 0.0, 1.0);551552if (MSZSetup->chuggaVolume <= 0) {553fgSupaLow->scrollInfo[1].scrollSpeed = 0;554fgSupaLow->scrollInfo[1].scrollPos = 0;555MSZSetup->chuggaVolume = 0;556self->state = MSZSetup_State_AwaitActClearStart;557}558}559}560561void MSZSetup_State_AwaitActClearStart(void)562{563RSDK_THIS(MSZSetup);564565if (RSDK_GET_ENTITY(SLOT_ACTCLEAR, ActClear)->classID == ActClear->classID)566self->state = MSZSetup_State_AwaitActClearFinish;567}568569void MSZSetup_State_AwaitActClearFinish(void)570{571RSDK_THIS(MSZSetup);572573if (RSDK_GET_ENTITY(SLOT_ACTCLEAR, ActClear)->classID != ActClear->classID) {574self->timer = 0;575Zone->cameraBoundsR[0] = 17064;576Zone->playerBoundActiveR[0] = false;577578EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);579player1->stateInput = StateMachine_None;580581foreach_active(Player, player)582{583RSDK.SetSpriteAnimation(player->aniFrames, ANI_IDLE, &player->animator, true, 0);584player->up = false;585player->down = false;586player->left = false;587player->right = false;588player->jumpPress = false;589player->jumpHold = false;590player->state = Player_State_Ground;591}592593self->state = MSZSetup_State_MoveToMSZ2Start;594}595}596597void MSZSetup_State_MoveToMSZ2Start(void)598{599RSDK_THIS(MSZSetup);600601EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);602player1->right = true;603604if (player1->position.x < (Zone->cameraBoundsR[0] - ScreenInfo->center.x) << 16) {605foreach_active(Player, player)606{607if (player->groundVel > 0x30000)608player->groundVel = 0x30000;609}610}611else {612player1->right = false;613player1->left = true;614self->state = MSZSetup_State_AwaitPlayerStopped;615}616}617618void MSZSetup_State_AwaitPlayerStopped(void)619{620RSDK_THIS(MSZSetup);621622EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);623if (player1->groundVel <= 0) {624player1->groundVel = 0;625player1->left = false;626player1->direction = FLIP_NONE;627self->timer = 0;628self->state = MSZSetup_State_StoreMSZ1ScrollPos_E;629}630}631632void MSZSetup_State_StoreMSZ1ScrollPos_E(void)633{634RSDK_THIS(MSZSetup);635636EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);637player1->direction = FLIP_NONE;638639if (++self->timer >= 90) {640int32 id = 0;641642TileLayer *background1 = RSDK.GetTileLayer(0);643for (int32 i = 0; i < background1->scrollInfoCount; ++i) {644globals->parallaxOffset[id++] = background1->scrollInfo[i].tilePos;645}646647TileLayer *background2 = RSDK.GetTileLayer(1);648for (int32 i = 0; i < background2->scrollInfoCount; ++i) {649globals->parallaxOffset[id++] = background2->scrollInfo[i].tilePos;650}651652foreach_all(ParallaxSprite, sprite)653{654globals->parallaxOffset[id++] =655((sprite->scrollPos.x + sprite->parallaxFactor.x * ScreenInfo->position.x) & 0x7FFF0000) % sprite->loopPoint.x;656}657658Zone_StoreEntities((ScreenInfo->center.x + 16640) << 16, 1440 << 16);659globals->atlEnabled = true;660RSDK.LoadScene();661662destroyEntity(self);663}664}665#endif666667void MSZSetup_State_StoreMSZ1ScrollPos_ST(void)668{669int32 id = 0;670671TileLayer *background1 = RSDK.GetTileLayer(0);672for (int32 i = 0; i < background1->scrollInfoCount; ++i) {673globals->parallaxOffset[id++] = background1->scrollInfo[i].scrollPos;674}675676TileLayer *background2 = RSDK.GetTileLayer(1);677for (int32 i = 0; i < background2->scrollInfoCount; ++i) {678globals->parallaxOffset[id++] = background2->scrollInfo[i].scrollPos;679}680681foreach_all(ParallaxSprite, sprite) { globals->parallaxOffset[id++] = sprite->scrollPos.x; }682683Zone_StoreEntities((Zone->cameraBoundsL[0] + ScreenInfo->center.x) << 16, 1440 << 16);684++SceneInfo->listPos;685globals->atlEnabled = true;686RSDK.LoadScene();687}688689void MSZSetup_PlayerState_Pilot(void)690{691RSDK_THIS(Player);692693self->position.x = 0;694self->position.y = 0;695self->active = ACTIVE_NEVER;696self->visible = false;697self->stateInput = StateMachine_None;698self->position.x = ScreenInfo->position.x << 16;699self->position.y = ScreenInfo->position.y << 16;700Player->respawnTimer = 0;701}702703void MSZSetup_PlayerState_PostCrashJumpIn(void)704{705RSDK_THIS(Player);706707self->active = ACTIVE_NORMAL;708self->visible = true;709self->stateInput = Player_Input_P2_AI;710Player->respawnTimer = 240;711712Player_HandleSidekickRespawn();713}714715#if GAME_INCLUDE_EDITOR716void MSZSetup_EditorDraw(void) {}717718void MSZSetup_EditorLoad(void)719{720RSDK_ACTIVE_VAR(GenericTrigger, triggerID);721RSDK_ENUM_VAR("Award Achievement", MSZ_GENERICTRIGGER_ACHIEVEMENT);722723RSDK_ACTIVE_VAR(Decoration, type);724RSDK_ENUM_VAR("Main", MSZ_DECORATION_MAIN);725RSDK_ENUM_VAR("Tanker Rail", MSZ_DECORATION_TANKERRAIL);726RSDK_ENUM_VAR("Tanker Wheel", MSZ_DECORATION_TANKERWHEEL);727RSDK_ENUM_VAR("Carriage Wheel", MSZ_DECORATION_CARRIAGEWHEEL);728RSDK_ENUM_VAR("Connector 1", MSZ_DECORATION_CONNECTOR1);729RSDK_ENUM_VAR("Connector 2", MSZ_DECORATION_CONNECTOR2);730731RSDK_ACTIVE_VAR(ParallaxSprite, aniID);732RSDK_ENUM_VAR("Cactus 1", MSZ_PARALLAXSPRITE_CACTUS1);733RSDK_ENUM_VAR("Cactus 2", MSZ_PARALLAXSPRITE_CACTUS2);734RSDK_ENUM_VAR("Cactus 3", MSZ_PARALLAXSPRITE_CACTUS3);735RSDK_ENUM_VAR("Cactus 4", MSZ_PARALLAXSPRITE_CACTUS4);736RSDK_ENUM_VAR("Cactus 5", MSZ_PARALLAXSPRITE_CACTUS5);737RSDK_ENUM_VAR("Cactus 6", MSZ_PARALLAXSPRITE_CACTUS6);738RSDK_ENUM_VAR("Cactus 7", MSZ_PARALLAXSPRITE_CACTUS7);739RSDK_ENUM_VAR("OOZ Peek", MSZ_PARALLAXSPRITE_OOZPEEK);740}741#endif742743void MSZSetup_Serialize(void) {}744745746