Path: blob/master/SonicMania/Objects/LRZ/LRZ1Setup.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: LRZ1Setup Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectLRZ1Setup *LRZ1Setup;1011void LRZ1Setup_Update(void) {}1213void LRZ1Setup_LateUpdate(void) {}1415void LRZ1Setup_StaticUpdate(void)16{17LRZ1Setup->palTimer += 24;18if (LRZ1Setup->palTimer >= 256) {19LRZ1Setup->palTimer -= 256;2021RSDK.RotatePalette(1, 208, 211, true);22RSDK.RotatePalette(2, 208, 211, true);23RSDK.RotatePalette(3, 208, 211, true);24RSDK.RotatePalette(4, 208, 211, true);25}2627if (LRZ1Setup->fadeTimer <= 0) {28int32 blend = RSDK.Cos1024(2 * (Zone->timer & 0x1FF)) >> 3;29RSDK.SetLimitedFade(5, 1, blend >= 0 ? 4 : 3, abs(blend), 208, 211);30RSDK.RotatePalette(3, 208, 211, true);31RSDK.RotatePalette(4, 208, 211, true);3233RSDK.SetLimitedFade(6, 2, blend >= 0 ? 4 : 3, abs(blend), 208, 211);34RSDK.RotatePalette(3, 208, 211, false);35RSDK.RotatePalette(4, 208, 211, false);3637RSDK.SetLimitedFade(0, 5, 6, LRZ1Setup->palTimer, 208, 211);38}39else {40if (LRZ1Setup->fadeTimer == 1)41RSDK.CopyPalette(0, 208, 1, 208, 5);4243RSDK.SetLimitedFade(0, 1, 7, LRZ1Setup->fadeTimer, 208, 212);4445if (LRZ1Setup->fadeTimer < 256)46LRZ1Setup->fadeTimer += 2;47}4849RSDK.SetLimitedFade(0, 1, 2, (RSDK.Sin256(2 * Zone->timer) >> 1) + 128, 140, 141);50RSDK.SetLimitedFade(0, 1, 2, (RSDK.Sin256(2 * Zone->timer + 128) >> 1) + 128, 142, 143);51RSDK.SetLimitedFade(0, 1, 2, (RSDK.Sin256(Zone->timer) >> 1) + 128, 156, 158);5253foreach_active(Player, player)54{55if (player->onGround) {56Hitbox *hitbox = Player_GetHitbox(player);5758int32 tileInfo = 0;59uint8 behaviour = LRZ1_TFLAGS_NORMAL;60LRZ2Setup_GetTileInfo(player->position.x, (hitbox->bottom << 16) + player->position.y, player->moveLayerPosition.x,61player->moveLayerPosition.y, player->collisionPlane, &tileInfo, &behaviour);6263if (behaviour == LRZ1_TFLAGS_LAVA && player->shield != SHIELD_FIRE && !LRZ1Setup->fadeTimer) {64Player_HurtFlip(player);65}66}67}6869#if MANIA_USE_PLUS70if (!(Zone->timer & 3)) {71++LRZ1Setup->background1->deformationOffset;72++LRZ1Setup->background2->deformationOffset;73}7475if (!(Zone->timer & 1)) {76++LRZ1Setup->fgLow->deformationOffset;77++LRZ1Setup->fgHigh->deformationOffset;78}79#endif80}8182void LRZ1Setup_Draw(void) {}8384void LRZ1Setup_Create(void *data) {}8586void LRZ1Setup_StageLoad(void)87{88LRZ1Setup->fadeTimer = 0;8990LRZ1Setup->background1 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 1"));91LRZ1Setup->background2 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 2"));9293#if MANIA_USE_PLUS94LRZ1Setup->fgLow = RSDK.GetTileLayer(Zone->fgLayer[0]);95LRZ1Setup->fgHigh = RSDK.GetTileLayer(Zone->fgLayer[1]);96#endif9798// Slows the vScroll of the BG when the lava lake is visible to give a nicer effect :]99RSDK.SetDrawGroupProperties(0, false, LRZ1Setup_DrawHook_ApplyBGSmoothing);100101Animals->animalTypes[0] = ANIMAL_FLICKY;102#if MANIA_USE_PLUS103Animals->animalTypes[1] = ANIMAL_CUCKY;104#else105Animals->animalTypes[1] = ANIMAL_RICKY;106#endif107108if (isMainGameMode() && CutsceneRules_IsAct1())109Zone->stageFinishCallback = LRZ1Setup_StageFinish_EndAct1;110111#if MANIA_USE_PLUS112if (SceneInfo->filter & FILTER_ENCORE) {113RSDK.LoadPalette(0, "EncoreLRZ1.act", 0b0000000011111111);114115for (int32 i = 0; i < 0x400; ++i) LRZ1Setup->fgLow->deformationData[i] = LRZ1Setup->deformFG[i & 0x1F];116for (int32 i = 0; i < 0x400; ++i) LRZ1Setup->fgHigh->deformationData[i] = LRZ1Setup->deformFG[i & 0x1F];117for (int32 i = 0; i < 0x400; ++i) LRZ1Setup->background1->deformationData[i] = LRZ1Setup->deformBG[i & 0x1F];118for (int32 i = 0; i < 0x400; ++i) LRZ1Setup->background2->deformationData[i] = LRZ1Setup->deformBG[i & 0x1F];119}120121if (!isMainGameMode() || !globals->enableIntro || CutsceneRules_CheckStageReload()) {122Zone->cameraBoundsL[0] = 2732;123Zone->cameraBoundsL[1] = 2732;124Zone->cameraBoundsL[2] = 2732;125Zone->cameraBoundsL[3] = 2732;126foreach_all(LRZ1Intro, intro) { destroyEntity(intro); }127}128#else129Zone->cameraBoundsL[0] = 648;130Zone->cameraBoundsL[1] = 648;131Zone->cameraBoundsL[2] = 648;132Zone->cameraBoundsL[3] = 648;133#endif134}135136void LRZ1Setup_StageFinish_EndAct1(void) { CREATE_ENTITY(LRZ1Outro, NULL, 0, 0); }137138void LRZ1Setup_DrawHook_ApplyBGSmoothing(void)139{140int32 scroll = MIN(0x800000 - 8 * ScreenInfo->position.y * ScreenInfo->position.y, 0);141142LRZ1Setup->background1->scrollPos = scroll;143LRZ1Setup->background2->scrollPos = scroll;144}145146#if GAME_INCLUDE_EDITOR147void LRZ1Setup_EditorDraw(void) {}148149void LRZ1Setup_EditorLoad(void) {}150#endif151152void LRZ1Setup_Serialize(void) {}153154155