Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and roblabla committed Nov 4, 2024
1 parent 147d041 commit c2c93ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
30 changes: 17 additions & 13 deletions src/ScreenEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -167,7 +169,7 @@ ScreenEffect *ScreenEffect::RegisterChain(i32 effect, u32 ticks, u32 effectParam
{
return NULL;
}

if (drawChainElem != NULL)
{
drawChainElem->arg = createdEffect;
Expand Down Expand Up @@ -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))
{
Expand Down
9 changes: 5 additions & 4 deletions src/ScreenEffect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include <d3d8types.h>
#include <string.h>

#include "ZunResult.hpp"
#include "inttypes.hpp"
#include "Chain.hpp"
#include "ZunResult.hpp"
#include "ZunTimer.hpp"
#include "inttypes.hpp"

namespace th06
{
Expand All @@ -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);

Expand All @@ -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;
Expand Down

0 comments on commit c2c93ea

Please sign in to comment.