From 07e0ba4bdb5230ef20b7b5968a3fb60a138f6a42 Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 16:51:25 -0500 Subject: [PATCH 01/12] Implement ScreenEffect::DrawSquare --- config/implemented.csv | 1 + config/stubbed.csv | 1 - src/ScreenEffect.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++ src/ScreenEffect.hpp | 1 + 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/config/implemented.csv b/config/implemented.csv index 3480b5d6..68f7d410 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -315,6 +315,7 @@ th06::GameWindow::InitD3dDevice th06::GameWindow::InitD3dRendering th06::ScreenEffect::Clear th06::ScreenEffect::SetViewport +th06::ScreenEffect::DrawSquare th06::utils::AddNormalizeAngle th06::utils::Rotate th06::SoundPlayer::SoundPlayer diff --git a/config/stubbed.csv b/config/stubbed.csv index e8818656..7f033ab2 100644 --- a/config/stubbed.csv +++ b/config/stubbed.csv @@ -12,6 +12,5 @@ th06::MusicRoom::RegisterChain th06::ResultScreen::ReleaseScoreDat th06::ScreenEffect::RegisterChain th06::MainMenu::SelectRelated -th06::ScreenEffect::DrawSquare th06::TextHelper::ReleaseTextBuffer th06::Pbg3Archive::Pbg3Archive diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index 2f5674fc..50c92f91 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -1,4 +1,5 @@ #include "ScreenEffect.hpp" +#include "AnmManager.hpp" #include "GameWindow.hpp" #include "Supervisor.hpp" @@ -32,4 +33,49 @@ void ScreenEffect::SetViewport(D3DCOLOR color) g_Supervisor.d3dDevice->SetViewport(&g_Supervisor.viewport); ScreenEffect::Clear(color); } + +void ScreenEffect::DrawSquare(ZunRect *rect, D3DCOLOR rectColor) +{ + VertexDiffuseXyzrwh vertices[4]; + + // In the original code, VertexDiffuseXyzrwh almost certainly is a vec3 with a trailing w, which would make these simple vec3 assigns + memcpy(&vertices[0].position, &D3DXVECTOR3(rect->left, rect->top, 0.0f), sizeof(D3DXVECTOR3)); + memcpy(&vertices[1].position, &D3DXVECTOR3(rect->right, rect->top, 0.0f), sizeof(D3DXVECTOR3)); + memcpy(&vertices[2].position, &D3DXVECTOR3(rect->left, rect->bottom, 0.0f), sizeof(D3DXVECTOR3)); + memcpy(&vertices[3].position, &D3DXVECTOR3(rect->right, rect->bottom, 0.0f), sizeof(D3DXVECTOR3)); + vertices[0].position.w = vertices[1].position.w = vertices[2].position.w = vertices[3].position.w = 1.00f; + vertices[0].diffuse = vertices[1].diffuse = vertices[2].diffuse = vertices[3].diffuse = rectColor; + + if (((g_Supervisor.cfg.opts >> GCOS_NO_COLOR_COMP) & 0x01) == 0) + { + g_Supervisor.d3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + g_Supervisor.d3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + } + g_Supervisor.d3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); + g_Supervisor.d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE); + if (((g_Supervisor.cfg.opts >> GCOS_TURN_OFF_DEPTH_TEST) & 0x01) == 0) + { + g_Supervisor.d3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS); + g_Supervisor.d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); + } + + g_Supervisor.d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + g_Supervisor.d3dDevice->SetVertexShader(D3DFVF_DIFFUSE | D3DFVF_XYZRHW); + g_Supervisor.d3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertices, sizeof(*vertices)); + g_AnmManager->SetCurrentVertexShader(0xff); + g_AnmManager->SetCurrentSprite(NULL); + g_AnmManager->SetCurrentTexture(NULL); + g_AnmManager->SetCurrentColorOp(0xff); + g_AnmManager->SetCurrentBlendMode(0xff); + g_AnmManager->SetCurrentZWriteDisable(0xff); + + if (((g_Supervisor.cfg.opts >> GCOS_NO_COLOR_COMP) & 0x01) == 0) + { + g_Supervisor.d3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); + g_Supervisor.d3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); + } + g_Supervisor.d3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); + g_Supervisor.d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + g_Supervisor.d3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); +} }; // namespace th06 diff --git a/src/ScreenEffect.hpp b/src/ScreenEffect.hpp index 68c0c7b1..6101e7c5 100644 --- a/src/ScreenEffect.hpp +++ b/src/ScreenEffect.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "ZunResult.hpp" #include "inttypes.hpp" From b7bebb2054048f4cc5806c6f8d4416526c0a8618 Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 17:28:05 -0500 Subject: [PATCH 02/12] Add ScreenEffect member fields and stubs --- config/stubbed.csv | 7 +++++++ src/BombData.cpp | 12 ++++++------ src/GameManager.cpp | 2 +- src/MainMenu.cpp | 4 ++-- src/ScreenEffect.hpp | 32 ++++++++++++++++++++++++++++---- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/config/stubbed.csv b/config/stubbed.csv index 7f033ab2..96e28449 100644 --- a/config/stubbed.csv +++ b/config/stubbed.csv @@ -12,5 +12,12 @@ th06::MusicRoom::RegisterChain th06::ResultScreen::ReleaseScoreDat th06::ScreenEffect::RegisterChain th06::MainMenu::SelectRelated +th06::ScreenEffect::CalcFadeIn +th06::ScreenEffect::CalcFadeOut +th06::ScreenEffect::DrawFadeIn +th06::ScreenEffect::DrawFadeOut +th06::ScreenEffect::ShakeScreen +th06::ScreenEffect::AddedCallback +th06::ScreenEffect::DeletedCallback th06::TextHelper::ReleaseTextBuffer th06::Pbg3Archive::Pbg3Archive diff --git a/src/BombData.cpp b/src/BombData.cpp index 853e88a9..49e7e20f 100644 --- a/src/BombData.cpp +++ b/src/BombData.cpp @@ -167,7 +167,7 @@ void BombData::BombReimuACalc(Player *player) player->bombInfo.bombRegionVelocities[i] / 100.0f; // ZUN moment g_SoundPlayer.PlaySoundByIdx(SOUND_F, 0); - ScreenEffect::RegisterChain(SCREEN_EFFECT_UNK_1, 16, 8, 0, 0); + ScreenEffect::RegisterChain(SCREEN_EFFECT_SHAKE, 16, 8, 0, 0); } } } @@ -274,13 +274,13 @@ void BombData::BombReimuBCalc(Player *player) player->bombInfo.bombRegionPositions[3].x = 192.0f; player->bombInfo.bombRegionPositions[3].y = player->positionCenter.y; player->bombInfo.bombRegionPositions[3].z = 0.405f; - ScreenEffect::RegisterChain(SCREEN_EFFECT_UNK_1, 60, 2, 6, 0); + ScreenEffect::RegisterChain(SCREEN_EFFECT_SHAKE, 60, 2, 6, 0); } else { if (player->bombInfo.timer == 60) { - ScreenEffect::RegisterChain(SCREEN_EFFECT_UNK_1, 80, 20, 0, 0); + ScreenEffect::RegisterChain(SCREEN_EFFECT_SHAKE, 80, 20, 0, 0); } player->bombProjectiles[0].size.x = 62.0f; @@ -372,7 +372,7 @@ void BombData::BombMarisaACalc(Player *player) player->bombInfo.bombRegionVelocities[i].z = 0.0f; } g_SoundPlayer.PlaySoundByIdx(SOUND_BOMB_REIMARI, 0); - ScreenEffect::RegisterChain(SCREEN_EFFECT_UNK_1, 0x78, 4, 1, 0); + ScreenEffect::RegisterChain(SCREEN_EFFECT_SHAKE, 120, 4, 1, 0); } else { @@ -485,11 +485,11 @@ void BombData::BombMarisaBCalc(Player *player) if (player->bombInfo.timer == 60) { - ScreenEffect::RegisterChain(SCREEN_EFFECT_UNK_1, 60, 1, 7, 0); + ScreenEffect::RegisterChain(SCREEN_EFFECT_SHAKE, 60, 1, 7, 0); } else if (player->bombInfo.timer == 120) { - ScreenEffect::RegisterChain(SCREEN_EFFECT_UNK_1, 200, 24, 0, 0); + ScreenEffect::RegisterChain(SCREEN_EFFECT_SHAKE, 200, 24, 0, 0); } if (player->bombInfo.timer.HasTicked() && player->bombInfo.timer.AsFrames() % 4 != 0) diff --git a/src/GameManager.cpp b/src/GameManager.cpp index f73097a5..2bb6b730 100644 --- a/src/GameManager.cpp +++ b/src/GameManager.cpp @@ -443,7 +443,7 @@ ChainCallbackResult GameManager::OnUpdate(GameManager *gameManager) gameManager->demoFrames++; if (gameManager->demoFrames == DEMO_FADEOUT_FRAMES) { - ScreenEffect::RegisterChain(SCREEN_EFFECT_FADE_OUT, 0x78, 0, 0, 0); + ScreenEffect::RegisterChain(SCREEN_EFFECT_FADE_OUT, 120, 0x000000, 0, 0); } if (gameManager->demoFrames >= DEMO_FRAMES) { diff --git a/src/MainMenu.cpp b/src/MainMenu.cpp index 64f2efdd..fd3af9cb 100644 --- a/src/MainMenu.cpp +++ b/src/MainMenu.cpp @@ -680,11 +680,11 @@ ZunResult MainMenu::AddedCallback(MainMenu *m) if (g_Supervisor.startupTimeBeforeMenuMusic == 0) { g_Supervisor.PlayAudio("bgm/th06_01.mid"); - ScreenEffect::RegisterChain(SCREEN_EFFECT_UNK_0, 0x78, 0xffffff, 0, 0); + ScreenEffect::RegisterChain(SCREEN_EFFECT_FADE_IN, 120, 0xffffff, 0, 0); } else { - ScreenEffect::RegisterChain(SCREEN_EFFECT_UNK_0, 200, 0xffffff, 0, 0); + ScreenEffect::RegisterChain(SCREEN_EFFECT_FADE_IN, 200, 0xffffff, 0, 0); } } g_GameManager.demoMode = 0; diff --git a/src/ScreenEffect.hpp b/src/ScreenEffect.hpp index 6101e7c5..61d5585d 100644 --- a/src/ScreenEffect.hpp +++ b/src/ScreenEffect.hpp @@ -6,6 +6,8 @@ #include "ZunResult.hpp" #include "inttypes.hpp" +#include "Chain.hpp" +#include "ZunTimer.hpp" namespace th06 { @@ -19,16 +21,38 @@ struct ZunRect enum ScreenEffects { - SCREEN_EFFECT_UNK_0, - SCREEN_EFFECT_UNK_1, + SCREEN_EFFECT_FADE_IN, + SCREEN_EFFECT_SHAKE, SCREEN_EFFECT_FADE_OUT, }; struct ScreenEffect { - static ScreenEffect *RegisterChain(i32 screenEffect, u32 param1, u32 param2, u32 param3, u32 param4); + // In fade effects, effectParam1 is an RGB color to fade to. In the shake effect, params 1 and 2 control shakiness + static ScreenEffect *RegisterChain(i32 effect, u32 ticks, u32 effectParam1, u32 effectParam2, + u32 unusedEffectParam); + + ZunResult AddedCallback(ScreenEffect *effect); + ZunResult DeletedCallback(ScreenEffect *effect); + + ChainCallbackResult DrawFadeIn(ScreenEffect *effect); + ChainCallbackResult CalcFadeIn(ScreenEffect *effect); + ChainCallbackResult ShakeScreen(ScreenEffect *effect); + ChainCallbackResult DrawFadeOut(ScreenEffect *effect); + ChainCallbackResult CalcFadeOut(ScreenEffect *effect); + static void DrawSquare(ZunRect *rect, D3DCOLOR rectColor); - static void SetViewport(D3DCOLOR color); static void Clear(D3DCOLOR color); + static void SetViewport(D3DCOLOR color); + + enum ScreenEffects usedEffect; + ChainElem *calcChainElement; + ChainElem *drawChainElement; + u32 unused; + i32 fadeAlpha; + i32 effectLength; + i32 genericParam; // effectParam1 + i32 shakinessParam; // effectParam2 + ZunTimer timer; }; }; // namespace th06 From ccfa23ead50c26c12281a6d26c90dc2c8111d106 Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 17:44:00 -0500 Subject: [PATCH 03/12] Implement ScreenEffect::CalcFadeIn --- config/implemented.csv | 1 + src/ScreenEffect.cpp | 20 ++++++++++++++++++++ src/ScreenEffect.hpp | 15 ++++++++------- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/config/implemented.csv b/config/implemented.csv index 68f7d410..1f76181e 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -315,6 +315,7 @@ th06::GameWindow::InitD3dDevice th06::GameWindow::InitD3dRendering th06::ScreenEffect::Clear th06::ScreenEffect::SetViewport +th06::ScreenEffect::CalcFadeIn th06::ScreenEffect::DrawSquare th06::utils::AddNormalizeAngle th06::utils::Rotate diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index 50c92f91..93241f1c 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -34,6 +34,26 @@ void ScreenEffect::SetViewport(D3DCOLOR color) ScreenEffect::Clear(color); } +ChainCallbackResult ScreenEffect::CalcFadeIn(ScreenEffect *effect) +{ + if (effect->effectLength != 0) + { + effect->fadeAlpha = (255.0f - ((effect->timer.AsFramesFloat() * 255.0f)) / effect->effectLength); + if (effect->fadeAlpha < 0) + { + effect->fadeAlpha = 0; + } + } + + if (effect->timer >= effect->effectLength) + { + return CHAIN_CALLBACK_RESULT_CONTINUE_AND_REMOVE_JOB; + } + + effect->timer.Tick(); + return CHAIN_CALLBACK_RESULT_CONTINUE; +} + void ScreenEffect::DrawSquare(ZunRect *rect, D3DCOLOR rectColor) { VertexDiffuseXyzrwh vertices[4]; diff --git a/src/ScreenEffect.hpp b/src/ScreenEffect.hpp index 61d5585d..9161d04a 100644 --- a/src/ScreenEffect.hpp +++ b/src/ScreenEffect.hpp @@ -32,14 +32,14 @@ struct ScreenEffect static ScreenEffect *RegisterChain(i32 effect, u32 ticks, u32 effectParam1, u32 effectParam2, u32 unusedEffectParam); - ZunResult AddedCallback(ScreenEffect *effect); - ZunResult DeletedCallback(ScreenEffect *effect); + static ZunResult AddedCallback(ScreenEffect *effect); + static ZunResult DeletedCallback(ScreenEffect *effect); - ChainCallbackResult DrawFadeIn(ScreenEffect *effect); - ChainCallbackResult CalcFadeIn(ScreenEffect *effect); - ChainCallbackResult ShakeScreen(ScreenEffect *effect); - ChainCallbackResult DrawFadeOut(ScreenEffect *effect); - ChainCallbackResult CalcFadeOut(ScreenEffect *effect); + static ChainCallbackResult DrawFadeIn(ScreenEffect *effect); + static ChainCallbackResult CalcFadeIn(ScreenEffect *effect); + static ChainCallbackResult ShakeScreen(ScreenEffect *effect); + static ChainCallbackResult DrawFadeOut(ScreenEffect *effect); + static ChainCallbackResult CalcFadeOut(ScreenEffect *effect); static void DrawSquare(ZunRect *rect, D3DCOLOR rectColor); static void Clear(D3DCOLOR color); @@ -53,6 +53,7 @@ struct ScreenEffect i32 effectLength; i32 genericParam; // effectParam1 i32 shakinessParam; // effectParam2 + i32 unusedParam; ZunTimer timer; }; }; // namespace th06 From 468c7bc95a9155e25238995378a65f4e5076ab48 Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 17:49:11 -0500 Subject: [PATCH 04/12] Implement ScreenEffect::CalcFadeOut --- config/implemented.csv | 1 + config/stubbed.csv | 2 -- src/ScreenEffect.cpp | 22 +++++++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/config/implemented.csv b/config/implemented.csv index 1f76181e..16780ef6 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -317,6 +317,7 @@ th06::ScreenEffect::Clear th06::ScreenEffect::SetViewport th06::ScreenEffect::CalcFadeIn th06::ScreenEffect::DrawSquare +th06::ScreenEffect::CalcFadeOut th06::utils::AddNormalizeAngle th06::utils::Rotate th06::SoundPlayer::SoundPlayer diff --git a/config/stubbed.csv b/config/stubbed.csv index 96e28449..4c8a2f86 100644 --- a/config/stubbed.csv +++ b/config/stubbed.csv @@ -12,8 +12,6 @@ th06::MusicRoom::RegisterChain th06::ResultScreen::ReleaseScoreDat th06::ScreenEffect::RegisterChain th06::MainMenu::SelectRelated -th06::ScreenEffect::CalcFadeIn -th06::ScreenEffect::CalcFadeOut th06::ScreenEffect::DrawFadeIn th06::ScreenEffect::DrawFadeOut th06::ScreenEffect::ShakeScreen diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index 93241f1c..e399400b 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -38,7 +38,7 @@ ChainCallbackResult ScreenEffect::CalcFadeIn(ScreenEffect *effect) { if (effect->effectLength != 0) { - effect->fadeAlpha = (255.0f - ((effect->timer.AsFramesFloat() * 255.0f)) / effect->effectLength); + effect->fadeAlpha = 255.0f - ((effect->timer.AsFramesFloat() * 255.0f) / effect->effectLength); if (effect->fadeAlpha < 0) { effect->fadeAlpha = 0; @@ -98,4 +98,24 @@ void ScreenEffect::DrawSquare(ZunRect *rect, D3DCOLOR rectColor) g_Supervisor.d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); g_Supervisor.d3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); } + +ChainCallbackResult ScreenEffect::CalcFadeOut(ScreenEffect *effect) +{ + if (effect->effectLength != 0) + { + effect->fadeAlpha = (effect->timer.AsFramesFloat() * 255.0f) / effect->effectLength; + if (effect->fadeAlpha < 0) + { + effect->fadeAlpha = 0; + } + } + + if (effect->timer >= effect->effectLength) + { + return CHAIN_CALLBACK_RESULT_CONTINUE_AND_REMOVE_JOB; + } + + effect->timer.Tick(); + return CHAIN_CALLBACK_RESULT_CONTINUE; +} }; // namespace th06 From 5108c789f7f8d98875851d46d448227253daaaf4 Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 22:06:28 -0500 Subject: [PATCH 05/12] Implement ScreenEffect::RegisterChain --- config/implemented.csv | 1 + config/stubbed.csv | 1 - src/ChainPriorities.hpp | 2 ++ src/ScreenEffect.cpp | 59 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/config/implemented.csv b/config/implemented.csv index 16780ef6..881f70c6 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -318,6 +318,7 @@ th06::ScreenEffect::SetViewport th06::ScreenEffect::CalcFadeIn th06::ScreenEffect::DrawSquare th06::ScreenEffect::CalcFadeOut +th06::ScreenEffect::RegisterChain th06::utils::AddNormalizeAngle th06::utils::Rotate th06::SoundPlayer::SoundPlayer diff --git a/config/stubbed.csv b/config/stubbed.csv index 4c8a2f86..b75c4091 100644 --- a/config/stubbed.csv +++ b/config/stubbed.csv @@ -10,7 +10,6 @@ th06::ResultScreen::HandleReplaySaveKeyboard th06::ResultScreen::GetHighScore th06::MusicRoom::RegisterChain th06::ResultScreen::ReleaseScoreDat -th06::ScreenEffect::RegisterChain th06::MainMenu::SelectRelated th06::ScreenEffect::DrawFadeIn th06::ScreenEffect::DrawFadeOut diff --git a/src/ChainPriorities.hpp b/src/ChainPriorities.hpp index f50022e6..3ec5bd8d 100644 --- a/src/ChainPriorities.hpp +++ b/src/ChainPriorities.hpp @@ -13,6 +13,7 @@ #define TH_CHAIN_PRIO_CALC_BULLETMANAGER 11 #define TH_CHAIN_PRIO_CALC_GUI 12 #define TH_CHAIN_PRIO_CALC_RESULTSCREEN 13 +#define TH_CHAIN_PRIO_CALC_SCREENEFFECT 14 #define TH_CHAIN_PRIO_CALC_REPLAYMANAGER 15 #define TH_CHAIN_PRIO_CALC_HIGH_PRIO_REPLAYMANAGER_DEMO 16 @@ -32,3 +33,4 @@ #define TH_CHAIN_PRIO_DRAW_REPLAYMANAGER 13 #define TH_CHAIN_PRIO_DRAW_SUPERVISOR 14 #define TH_CHAIN_PRIO_DRAW_ASCIIMANAGER_MENUS 15 +#define TH_CHAIN_PRIO_DRAW_SCREENEFFECT 16 diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index e399400b..477dcf9c 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -1,5 +1,6 @@ #include "ScreenEffect.hpp" #include "AnmManager.hpp" +#include "ChainPriorities.hpp" #include "GameWindow.hpp" #include "Supervisor.hpp" @@ -118,4 +119,62 @@ ChainCallbackResult ScreenEffect::CalcFadeOut(ScreenEffect *effect) effect->timer.Tick(); return CHAIN_CALLBACK_RESULT_CONTINUE; } + +#pragma var_order(calcChainElem, drawChainElem, createdEffect) +ScreenEffect *ScreenEffect::RegisterChain(i32 effect, u32 ticks, u32 effectParam1, u32 effectParam2, u32 unusedEffectParam) +{ + ChainElem *calcChainElem; + ScreenEffect *createdEffect; + ChainElem *drawChainElem; + + calcChainElem = NULL; + drawChainElem = NULL; + + createdEffect = new ScreenEffect; + + if (createdEffect == NULL) + { + return NULL; + } + + memset(createdEffect, 0, sizeof(*createdEffect)); + + switch (effect) + { + case SCREEN_EFFECT_FADE_IN: + calcChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::CalcFadeIn); + drawChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::CalcFadeIn); + break; + case SCREEN_EFFECT_SHAKE: + calcChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::ShakeScreen); + break; + case SCREEN_EFFECT_FADE_OUT: + calcChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::CalcFadeOut); + drawChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::DrawFadeOut); + } + + calcChainElem->addedCallback = (ChainAddedCallback) ScreenEffect::AddedCallback; + calcChainElem->deletedCallback = (ChainAddedCallback) ScreenEffect::DeletedCallback; + calcChainElem->arg = createdEffect; + createdEffect->usedEffect = (ScreenEffects) effect; + createdEffect->effectLength = ticks; + createdEffect->genericParam = effectParam1; + createdEffect->shakinessParam = effectParam2; + createdEffect->unusedParam = unusedEffectParam; + + if (g_Chain.AddToCalcChain(calcChainElem, TH_CHAIN_PRIO_CALC_SCREENEFFECT) != 0) + { + return NULL; + } + + if (drawChainElem != NULL) + { + drawChainElem->arg = createdEffect; + g_Chain.AddToDrawChain(drawChainElem, TH_CHAIN_PRIO_DRAW_SCREENEFFECT); + } + + createdEffect->calcChainElement = calcChainElem; + createdEffect->drawChainElement = drawChainElem; + return createdEffect; +} }; // namespace th06 From 6d53f56e07eb95d152b4254ec83d313531cd0c32 Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 22:13:20 -0500 Subject: [PATCH 06/12] Implement ScreenEffect::DrawFadeIn --- config/implemented.csv | 1 + config/stubbed.csv | 1 - src/ScreenEffect.cpp | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config/implemented.csv b/config/implemented.csv index 881f70c6..f6ace702 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -319,6 +319,7 @@ th06::ScreenEffect::CalcFadeIn th06::ScreenEffect::DrawSquare th06::ScreenEffect::CalcFadeOut th06::ScreenEffect::RegisterChain +th06::ScreenEffect::DrawFadeIn th06::utils::AddNormalizeAngle th06::utils::Rotate th06::SoundPlayer::SoundPlayer diff --git a/config/stubbed.csv b/config/stubbed.csv index b75c4091..e362aecd 100644 --- a/config/stubbed.csv +++ b/config/stubbed.csv @@ -11,7 +11,6 @@ th06::ResultScreen::GetHighScore th06::MusicRoom::RegisterChain th06::ResultScreen::ReleaseScoreDat th06::MainMenu::SelectRelated -th06::ScreenEffect::DrawFadeIn th06::ScreenEffect::DrawFadeOut th06::ScreenEffect::ShakeScreen th06::ScreenEffect::AddedCallback diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index 477dcf9c..1bea9962 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -177,4 +177,21 @@ ScreenEffect *ScreenEffect::RegisterChain(i32 effect, u32 ticks, u32 effectParam createdEffect->drawChainElement = drawChainElem; return createdEffect; } + +ChainCallbackResult ScreenEffect::DrawFadeIn(ScreenEffect *effect) +{ + ZunRect fadeRect; + + fadeRect.left = 0.0f; + fadeRect.top = 0.0f; + fadeRect.right = 640.0f; + fadeRect.bottom = 480.0f; + g_Supervisor.viewport.X = 0; + g_Supervisor.viewport.Y = 0; + g_Supervisor.viewport.Width = 640; + g_Supervisor.viewport.Height = 480; + g_Supervisor.d3dDevice->SetViewport(&g_Supervisor.viewport); + ScreenEffect::DrawSquare(&fadeRect, (effect->fadeAlpha << 24) | effect->genericParam); + return CHAIN_CALLBACK_RESULT_CONTINUE; +} }; // namespace th06 From 8d8cceb16c0f9933861046dfbaf9a01993e7d364 Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 22:14:43 -0500 Subject: [PATCH 07/12] Implement ScreenEffect::DrawFadeOut --- config/implemented.csv | 1 + config/stubbed.csv | 1 - src/ScreenEffect.cpp | 12 ++++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config/implemented.csv b/config/implemented.csv index f6ace702..e9b4a67f 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -320,6 +320,7 @@ th06::ScreenEffect::DrawSquare th06::ScreenEffect::CalcFadeOut th06::ScreenEffect::RegisterChain th06::ScreenEffect::DrawFadeIn +th06::ScreenEffect::DrawFadeOut th06::utils::AddNormalizeAngle th06::utils::Rotate th06::SoundPlayer::SoundPlayer diff --git a/config/stubbed.csv b/config/stubbed.csv index e362aecd..a3e4a53e 100644 --- a/config/stubbed.csv +++ b/config/stubbed.csv @@ -11,7 +11,6 @@ th06::ResultScreen::GetHighScore th06::MusicRoom::RegisterChain th06::ResultScreen::ReleaseScoreDat th06::MainMenu::SelectRelated -th06::ScreenEffect::DrawFadeOut th06::ScreenEffect::ShakeScreen th06::ScreenEffect::AddedCallback th06::ScreenEffect::DeletedCallback diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index 1bea9962..b2935f03 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -194,4 +194,16 @@ ChainCallbackResult ScreenEffect::DrawFadeIn(ScreenEffect *effect) ScreenEffect::DrawSquare(&fadeRect, (effect->fadeAlpha << 24) | effect->genericParam); return CHAIN_CALLBACK_RESULT_CONTINUE; } + +ChainCallbackResult ScreenEffect::DrawFadeOut(ScreenEffect *effect) +{ + ZunRect fadeRect; + + fadeRect.left = 32.0f; + fadeRect.top = 16.0f; + fadeRect.right = 416.0f; + fadeRect.bottom = 464.0f; + ScreenEffect::DrawSquare(&fadeRect, (effect->fadeAlpha << 24) | effect->genericParam); + return CHAIN_CALLBACK_RESULT_CONTINUE; +} }; // namespace th06 From d398d5666caf5748065dc3f4de320578fd2df65f Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 22:39:08 -0500 Subject: [PATCH 08/12] Implement ScreenEffect::ShakeScreen --- config/implemented.csv | 1 + config/stubbed.csv | 1 - src/ScreenEffect.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++ src/ScreenEffect.hpp | 3 ++- 4 files changed, 64 insertions(+), 2 deletions(-) diff --git a/config/implemented.csv b/config/implemented.csv index e9b4a67f..1742922d 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -321,6 +321,7 @@ th06::ScreenEffect::CalcFadeOut th06::ScreenEffect::RegisterChain th06::ScreenEffect::DrawFadeIn th06::ScreenEffect::DrawFadeOut +th06::ScreenEffect::ShakeScreen th06::utils::AddNormalizeAngle th06::utils::Rotate th06::SoundPlayer::SoundPlayer diff --git a/config/stubbed.csv b/config/stubbed.csv index a3e4a53e..3580917f 100644 --- a/config/stubbed.csv +++ b/config/stubbed.csv @@ -11,7 +11,6 @@ th06::ResultScreen::GetHighScore th06::MusicRoom::RegisterChain th06::ResultScreen::ReleaseScoreDat th06::MainMenu::SelectRelated -th06::ScreenEffect::ShakeScreen th06::ScreenEffect::AddedCallback th06::ScreenEffect::DeletedCallback th06::TextHelper::ReleaseTextBuffer diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index b2935f03..2ad9d3fb 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -2,6 +2,7 @@ #include "AnmManager.hpp" #include "ChainPriorities.hpp" #include "GameWindow.hpp" +#include "Rng.hpp" #include "Supervisor.hpp" namespace th06 @@ -206,4 +207,64 @@ ChainCallbackResult ScreenEffect::DrawFadeOut(ScreenEffect *effect) ScreenEffect::DrawSquare(&fadeRect, (effect->fadeAlpha << 24) | effect->genericParam); return CHAIN_CALLBACK_RESULT_CONTINUE; } + +ChainCallbackResult ScreenEffect::ShakeScreen(ScreenEffect *effect) +{ + f32 screenOffset; + + if (g_GameManager.isTimeStopped) + { + g_GameManager.arcadeRegionTopLeftPos.x = 32.0f; + g_GameManager.arcadeRegionTopLeftPos.y = 16.0f; + g_GameManager.arcadeRegionSize.x = 384.0f; + g_GameManager.arcadeRegionSize.y = 448.0f; + return CHAIN_CALLBACK_RESULT_CONTINUE; + } + + effect->timer.Tick(); + if (effect->timer >= effect->effectLength) + { + g_GameManager.arcadeRegionTopLeftPos.x = 32.0f; + g_GameManager.arcadeRegionTopLeftPos.y = 16.0f; + g_GameManager.arcadeRegionSize.x = 384.0f; + g_GameManager.arcadeRegionSize.y = 448.0f; + return CHAIN_CALLBACK_RESULT_CONTINUE_AND_REMOVE_JOB; + } + + screenOffset = ((effect->timer.AsFramesFloat() * (effect->shakinessParam - effect->genericParam)) / effect->effectLength) + effect->genericParam; + + switch (g_Rng.GetRandomU32InRange(3)) + { + case 0: + g_GameManager.arcadeRegionTopLeftPos.x = 32.0f; + g_GameManager.arcadeRegionSize.x = 384.0f; + break; + case 1: + g_GameManager.arcadeRegionTopLeftPos.x = 32.0f + screenOffset; + g_GameManager.arcadeRegionSize.x = 384.0f - screenOffset; + break; + case 2: + g_GameManager.arcadeRegionTopLeftPos.x = 32.0f; + g_GameManager.arcadeRegionSize.x = 384.0f - screenOffset; + break; + } + + switch (g_Rng.GetRandomU32InRange(3)) + { + case 0: + g_GameManager.arcadeRegionTopLeftPos.y = 16.0f; + g_GameManager.arcadeRegionSize.y = 448.0f; + break; + case 1: + g_GameManager.arcadeRegionTopLeftPos.x = 16.0f + screenOffset; + g_GameManager.arcadeRegionSize.x = 448.0f - screenOffset; + break; + case 2: + g_GameManager.arcadeRegionTopLeftPos.x = 16.0f; + g_GameManager.arcadeRegionSize.x = 448.0f - screenOffset; + break; + } + + return CHAIN_CALLBACK_RESULT_CONTINUE; +} }; // namespace th06 diff --git a/src/ScreenEffect.hpp b/src/ScreenEffect.hpp index 9161d04a..7063e201 100644 --- a/src/ScreenEffect.hpp +++ b/src/ScreenEffect.hpp @@ -28,7 +28,8 @@ enum ScreenEffects struct ScreenEffect { - // In fade effects, effectParam1 is an RGB color to fade to. In the shake effect, params 1 and 2 control shakiness + // In fade effects, effectParam1 is an RGB color to fade to + // In shake effects, effectParam1 controls the "base" view offset, and effectParam2 controls the shakiness multiplier over time static ScreenEffect *RegisterChain(i32 effect, u32 ticks, u32 effectParam1, u32 effectParam2, u32 unusedEffectParam); From 6cdec138d66363daf8d002bfdb69a1fd66305a82 Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 22:40:10 -0500 Subject: [PATCH 09/12] Implement ScreenEffect::AddedCallback --- config/implemented.csv | 1 + config/stubbed.csv | 1 - src/ScreenEffect.cpp | 6 ++++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/implemented.csv b/config/implemented.csv index 1742922d..08336d44 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -322,6 +322,7 @@ th06::ScreenEffect::RegisterChain th06::ScreenEffect::DrawFadeIn th06::ScreenEffect::DrawFadeOut th06::ScreenEffect::ShakeScreen +th06::ScreenEffect::AddedCallback th06::utils::AddNormalizeAngle th06::utils::Rotate th06::SoundPlayer::SoundPlayer diff --git a/config/stubbed.csv b/config/stubbed.csv index 3580917f..ecc94d0e 100644 --- a/config/stubbed.csv +++ b/config/stubbed.csv @@ -11,7 +11,6 @@ th06::ResultScreen::GetHighScore th06::MusicRoom::RegisterChain th06::ResultScreen::ReleaseScoreDat th06::MainMenu::SelectRelated -th06::ScreenEffect::AddedCallback th06::ScreenEffect::DeletedCallback th06::TextHelper::ReleaseTextBuffer th06::Pbg3Archive::Pbg3Archive diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index 2ad9d3fb..b56a7716 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -267,4 +267,10 @@ ChainCallbackResult ScreenEffect::ShakeScreen(ScreenEffect *effect) return CHAIN_CALLBACK_RESULT_CONTINUE; } + +ZunResult ScreenEffect::AddedCallback(ScreenEffect *effect) +{ + effect->timer.InitializeForPopup(); + return ZUN_SUCCESS; +} }; // namespace th06 From fdfa96a911be7b0b84d930a4abcb7a530c16e086 Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 22:48:24 -0500 Subject: [PATCH 10/12] Implement ScreenEffect::DeletedCallback --- config/implemented.csv | 1 + config/stubbed.csv | 1 - src/ScreenEffect.cpp | 11 +++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config/implemented.csv b/config/implemented.csv index 08336d44..a55b6281 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -323,6 +323,7 @@ th06::ScreenEffect::DrawFadeIn th06::ScreenEffect::DrawFadeOut th06::ScreenEffect::ShakeScreen th06::ScreenEffect::AddedCallback +th06::ScreenEffect::DeletedCallback th06::utils::AddNormalizeAngle th06::utils::Rotate th06::SoundPlayer::SoundPlayer diff --git a/config/stubbed.csv b/config/stubbed.csv index ecc94d0e..b559c470 100644 --- a/config/stubbed.csv +++ b/config/stubbed.csv @@ -11,6 +11,5 @@ th06::ResultScreen::GetHighScore th06::MusicRoom::RegisterChain th06::ResultScreen::ReleaseScoreDat th06::MainMenu::SelectRelated -th06::ScreenEffect::DeletedCallback th06::TextHelper::ReleaseTextBuffer th06::Pbg3Archive::Pbg3Archive diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index b56a7716..b33b5ea4 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -273,4 +273,15 @@ ZunResult ScreenEffect::AddedCallback(ScreenEffect *effect) effect->timer.InitializeForPopup(); return ZUN_SUCCESS; } + +ZunResult ScreenEffect::DeletedCallback(ScreenEffect *effect) +{ + effect->calcChainElement->deletedCallback = NULL; + g_Chain.Cut(effect->drawChainElement); + effect->drawChainElement = NULL; + delete effect; + effect = NULL; + + return ZUN_SUCCESS; +} }; // namespace th06 From 147d0412c1ac3efaecd352046810c3d0f0e75f96 Mon Sep 17 00:00:00 2001 From: toadster172 Date: Sat, 2 Nov 2024 22:58:01 -0500 Subject: [PATCH 11/12] ScreenEffect: Correct typos --- src/ScreenEffect.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index b33b5ea4..0c4fec3c 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -144,7 +144,7 @@ ScreenEffect *ScreenEffect::RegisterChain(i32 effect, u32 ticks, u32 effectParam { case SCREEN_EFFECT_FADE_IN: calcChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::CalcFadeIn); - drawChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::CalcFadeIn); + drawChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::DrawFadeIn); break; case SCREEN_EFFECT_SHAKE: calcChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::ShakeScreen); @@ -256,12 +256,12 @@ ChainCallbackResult ScreenEffect::ShakeScreen(ScreenEffect *effect) g_GameManager.arcadeRegionSize.y = 448.0f; break; case 1: - g_GameManager.arcadeRegionTopLeftPos.x = 16.0f + screenOffset; - g_GameManager.arcadeRegionSize.x = 448.0f - screenOffset; + g_GameManager.arcadeRegionTopLeftPos.y = 16.0f + screenOffset; + g_GameManager.arcadeRegionSize.y = 448.0f - screenOffset; break; case 2: - g_GameManager.arcadeRegionTopLeftPos.x = 16.0f; - g_GameManager.arcadeRegionSize.x = 448.0f - screenOffset; + g_GameManager.arcadeRegionTopLeftPos.y = 16.0f; + g_GameManager.arcadeRegionSize.y = 448.0f - screenOffset; break; } From c2c93eaa597aac310f13b7cce84f2a1314c48948 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 3 Nov 2024 04:08:35 +0000 Subject: [PATCH 12/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/ScreenEffect.cpp | 30 +++++++++++++++++------------- src/ScreenEffect.hpp | 9 +++++---- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/ScreenEffect.cpp b/src/ScreenEffect.cpp index 0c4fec3c..660d90bc 100644 --- a/src/ScreenEffect.cpp +++ b/src/ScreenEffect.cpp @@ -60,7 +60,8 @@ void ScreenEffect::DrawSquare(ZunRect *rect, D3DCOLOR rectColor) { VertexDiffuseXyzrwh vertices[4]; - // In the original code, VertexDiffuseXyzrwh almost certainly is a vec3 with a trailing w, which would make these simple vec3 assigns + // In the original code, VertexDiffuseXyzrwh almost certainly is a vec3 with a trailing w, which would make these + // simple vec3 assigns memcpy(&vertices[0].position, &D3DXVECTOR3(rect->left, rect->top, 0.0f), sizeof(D3DXVECTOR3)); memcpy(&vertices[1].position, &D3DXVECTOR3(rect->right, rect->top, 0.0f), sizeof(D3DXVECTOR3)); memcpy(&vertices[2].position, &D3DXVECTOR3(rect->left, rect->bottom, 0.0f), sizeof(D3DXVECTOR3)); @@ -80,7 +81,7 @@ void ScreenEffect::DrawSquare(ZunRect *rect, D3DCOLOR rectColor) g_Supervisor.d3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS); g_Supervisor.d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); } - + g_Supervisor.d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); g_Supervisor.d3dDevice->SetVertexShader(D3DFVF_DIFFUSE | D3DFVF_XYZRHW); g_Supervisor.d3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertices, sizeof(*vertices)); @@ -122,7 +123,8 @@ ChainCallbackResult ScreenEffect::CalcFadeOut(ScreenEffect *effect) } #pragma var_order(calcChainElem, drawChainElem, createdEffect) -ScreenEffect *ScreenEffect::RegisterChain(i32 effect, u32 ticks, u32 effectParam1, u32 effectParam2, u32 unusedEffectParam) +ScreenEffect *ScreenEffect::RegisterChain(i32 effect, u32 ticks, u32 effectParam1, u32 effectParam2, + u32 unusedEffectParam) { ChainElem *calcChainElem; ScreenEffect *createdEffect; @@ -143,21 +145,21 @@ ScreenEffect *ScreenEffect::RegisterChain(i32 effect, u32 ticks, u32 effectParam switch (effect) { case SCREEN_EFFECT_FADE_IN: - calcChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::CalcFadeIn); - drawChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::DrawFadeIn); + calcChainElem = g_Chain.CreateElem((ChainCallback)ScreenEffect::CalcFadeIn); + drawChainElem = g_Chain.CreateElem((ChainCallback)ScreenEffect::DrawFadeIn); break; case SCREEN_EFFECT_SHAKE: - calcChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::ShakeScreen); + calcChainElem = g_Chain.CreateElem((ChainCallback)ScreenEffect::ShakeScreen); break; case SCREEN_EFFECT_FADE_OUT: - calcChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::CalcFadeOut); - drawChainElem = g_Chain.CreateElem((ChainCallback) ScreenEffect::DrawFadeOut); + calcChainElem = g_Chain.CreateElem((ChainCallback)ScreenEffect::CalcFadeOut); + drawChainElem = g_Chain.CreateElem((ChainCallback)ScreenEffect::DrawFadeOut); } - calcChainElem->addedCallback = (ChainAddedCallback) ScreenEffect::AddedCallback; - calcChainElem->deletedCallback = (ChainAddedCallback) ScreenEffect::DeletedCallback; + calcChainElem->addedCallback = (ChainAddedCallback)ScreenEffect::AddedCallback; + calcChainElem->deletedCallback = (ChainAddedCallback)ScreenEffect::DeletedCallback; calcChainElem->arg = createdEffect; - createdEffect->usedEffect = (ScreenEffects) effect; + createdEffect->usedEffect = (ScreenEffects)effect; createdEffect->effectLength = ticks; createdEffect->genericParam = effectParam1; createdEffect->shakinessParam = effectParam2; @@ -167,7 +169,7 @@ ScreenEffect *ScreenEffect::RegisterChain(i32 effect, u32 ticks, u32 effectParam { return NULL; } - + if (drawChainElem != NULL) { drawChainElem->arg = createdEffect; @@ -231,7 +233,9 @@ ChainCallbackResult ScreenEffect::ShakeScreen(ScreenEffect *effect) return CHAIN_CALLBACK_RESULT_CONTINUE_AND_REMOVE_JOB; } - screenOffset = ((effect->timer.AsFramesFloat() * (effect->shakinessParam - effect->genericParam)) / effect->effectLength) + effect->genericParam; + screenOffset = + ((effect->timer.AsFramesFloat() * (effect->shakinessParam - effect->genericParam)) / effect->effectLength) + + effect->genericParam; switch (g_Rng.GetRandomU32InRange(3)) { diff --git a/src/ScreenEffect.hpp b/src/ScreenEffect.hpp index 7063e201..eb16fa90 100644 --- a/src/ScreenEffect.hpp +++ b/src/ScreenEffect.hpp @@ -4,10 +4,10 @@ #include #include -#include "ZunResult.hpp" -#include "inttypes.hpp" #include "Chain.hpp" +#include "ZunResult.hpp" #include "ZunTimer.hpp" +#include "inttypes.hpp" namespace th06 { @@ -29,7 +29,8 @@ enum ScreenEffects struct ScreenEffect { // In fade effects, effectParam1 is an RGB color to fade to - // In shake effects, effectParam1 controls the "base" view offset, and effectParam2 controls the shakiness multiplier over time + // In shake effects, effectParam1 controls the "base" view offset, and effectParam2 controls the shakiness + // multiplier over time static ScreenEffect *RegisterChain(i32 effect, u32 ticks, u32 effectParam1, u32 effectParam2, u32 unusedEffectParam); @@ -52,7 +53,7 @@ struct ScreenEffect u32 unused; i32 fadeAlpha; i32 effectLength; - i32 genericParam; // effectParam1 + i32 genericParam; // effectParam1 i32 shakinessParam; // effectParam2 i32 unusedParam; ZunTimer timer;