Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion src/system/hamobj/ClipPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,22 @@ void ClipPlayer::PlayAnims(HamCharacter *c, float f1, float f2, int x) {
}

namespace {
float ClipStart(CharClip *, float, float &, float &);
float ClipStart(CharClip *clip, float beat, float &start, float &end) {
if (fmodf(beat, 1.0) != 0.0f && ceilf(beat) - beat < 0.0001f) {
beat = ceil(beat);
}
float offset = 0.0f;
float period = (clip->PlayFlags() >> 12) & 0xF;

if (period != 0.0f) {
offset = Mod(beat - clip->StartBeat(), period);
}

start = beat - offset;
end = clip->EndBeat() - clip->StartBeat() + start;

return clip->StartBeat() + offset;
}
}

void ClipPlayer::PlayClip(CharClip *clip, float f1, float f2, HamDriver::LayerArray *arr) {
Expand Down Expand Up @@ -215,3 +230,28 @@ void ClipPlayer::PlayNormal(float f1, HamDriver::LayerArray *arr, const char *cc
}
}
}

float ClipPlayer::ClipLength(CharClip *clip) {
float end = floor(clip->EndBeat());
float start = ceil(clip->StartBeat());
return end - start;
}

bool ClipPlayer::GetClipRange(
const char *c1, const char *c2, float f1, float &f2, float &f3, float &f4
) {
auto clip = mClipDir->Find<CharClip>(c1, false);
if (clip) {
float clipStart = ClipStart(clip, f1, f2, f3);
f4 = 1e+30;
auto clip2 = mClipDir->Find<CharClip>(c2, false);
if (clip2 != nullptr) {
auto node = clip->FindLastNode(clip2, clipStart);
if (node != nullptr) {
f4 = (node->curBeat - clip->StartBeat()) + f2;
}
}
return true;
}
return false;
}
1 change: 1 addition & 0 deletions src/system/hamobj/ClipPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ClipPlayer {
void GetRoutineCrossoverClips(float, const char *, CharClip **, CharClip **);
bool PushRoutineBuilderClip(int, HamDriver::LayerArray *);
void PushClip(int, HamDriver::LayerArray *);
bool GetClipRange(const char *, const char *, float, float &, float &, float &);

Keys<Symbol, Symbol> *mClipKeys; // 0x0
Keys<Symbol, Symbol> *mClipCrossoverKeys; // 0x4
Expand Down
46 changes: 45 additions & 1 deletion src/system/rndobj/PostProc_NG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ Hmx::Color NgPostProc::s_prevBloomColor(-1, -1, -1, -1);
float NgPostProc::s_prevBloomIntensity = -1;
NgPostProc::BloomTextures<3> NgPostProc::sBloom;

NgPostProc::BloomTextureSet::BloomTextureSet() : mBloomTexture() {}
NgPostProc::BloomTextureSet::BloomTextureSet() {
for (int i = 0; i < 2; i++) {
mBloomTexture[i] = nullptr;
}
}

NgPostProc::BloomTextureSet::~BloomTextureSet() { FreeTextures(); }

Expand Down Expand Up @@ -172,4 +176,44 @@ void NgPostProc::CheckNoise() {
TheRenderState.SetTextureFilter(13, (RndRenderState::FilterMode)1, false);
TheRenderState.SetTextureClamp(13, (RndRenderState::ClampMode)0);
}
}

void NgPostProc::CheckHallOfTime() {
if (HallOfTime() && !unk250) {
Vector4 c1(mHallOfTimeRate, mHallOfTimeMix, 0.0f, 0.0f);
TheShaderMgr.SetPConstant((PShaderConstant)0x73, c1);

Vector4 c2(
mHallOfTimeColor.red, mHallOfTimeColor.green, mHallOfTimeColor.blue, 1.0f
);
TheShaderMgr.SetPConstant((PShaderConstant)0x74, c2);

TheShaderMgr.SetUnk34(mHallOfTimeType + 1);
}
}

void NgPostProc::DoPost() {
RndPostProc::DoPost();
DoVelocity();
DoBloom();
ModulateColorXfm();
CheckNoise();
CheckBlendPrevious();
CheckHallOfTime();
CheckMotionBlur();
CheckGradientMap();
CheckHueConverge();
CheckRefract();
CheckChromaticAberration();
CheckPosterizeAndKaleidoscope();
CheckVignette();
TheShaderMgr.SetUnk29(ColorXfmEnabled());
TheShaderMgr.SetUnk2f(BlendPrevious());
mBlendAmount = 0.0f;
}

void NgPostProc::QueueMotionBlurObject(RndDrawable *drawable) {
if (FindInList(unk23c, drawable) == unk23c.end()) {
unk23c.push_back(drawable);
}
}
17 changes: 17 additions & 0 deletions src/system/rndobj/PostProc_NG.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ class NgPostProc : public RndPostProc {
void CheckBlendPrevious();
void DoVelocity();
void CheckNoise();
void CheckHueConverge();
void CheckHallOfTime();
void DoBloom();
void ModulateColorXfm();
void CheckRefract();
void CheckChromaticAberration();
void CheckPosterizeAndKaleidoscope();

ObjPtrList<RndDrawable, ObjectDir>::iterator
FindInList(ObjPtrList<RndDrawable, ObjectDir> &list, Object *o) {
FOREACH (it, list) {
if ((Object *)*it == o) {
return it;
}
}
return list.end();
}

float unk22c; // 0x22c
float unk230; // 0x230
Expand Down
3 changes: 3 additions & 0 deletions src/system/rndobj/ShaderMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class RndShaderMgr {
void SetUnk3e(bool b) { unk3e = b; }
void SetUnk38(bool b) { unk38 = b; }
void SetUnk39(bool b) { unk39 = b; }
void SetUnk34(int i) { unk34 = i; }
void SetUnk29(bool b) { unk29 = b; }
void SetUnk2f(bool b) { unk2f = b; }

protected:
virtual void LoadShaders(const char *);
Expand Down
91 changes: 90 additions & 1 deletion src/system/utl/DebugGraph.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "DebugGraph.h"
#include "rndobj/Graph.h"

void DebugGraph::AddData(float data, bool b) {
void DebugGraph::AddData(float data, bool b) {
Sample sample;
sample.data = data;
sample.b = b;
Expand All @@ -9,4 +10,92 @@ void DebugGraph::AddData(float data, bool b) {
if (mSamples.size() == unk38 + 1) {
mSamples.pop_back();
}
}

inline float clamp(float val) {
float c = -val >= 0.0f ? 0.0f : val;
return c - 1.0f >= 0.0f ? 1.0f : c;
}

void DebugGraph::Draw() {
RndGraph *rnd = RndGraph::GetOneFrame();

Hmx::Rect rect(mRect.x, mRect.y, mRect.w, mRect.h);
rnd->AddRectFilled2D(rect, mColorB);

if (unk50) {
Vector2 minPos(mRect.x, mRect.y + mRect.h - 0.02f);
rnd->AddScreenString(MakeString("%.3f", unk3c), minPos, mColorA);

Vector2 maxPos(mRect.x, mRect.y);
rnd->AddScreenString(MakeString("%.3f", unk40), maxPos, mColorA);
}

if (unk44 != FLT_MAX) {
Hmx::Color color(1.0f, 1.0f, 1.0f, 1.0f);

Vector2 p2(
mRect.w + mRect.x,
mRect.y + mRect.h * (1.0f - clamp((unk44 - unk3c) / (unk40 - unk3c)))
);

Vector2 p1(
mRect.x, mRect.y + mRect.h * (1.0f - clamp((unk44 - unk3c) / (unk40 - unk3c)))
);

rnd->AddScreenLine(p1, p2, color, false);

Vector2 textPos(
mRect.x, mRect.y + mRect.h * (1.0f - clamp((unk44 - unk3c) / (unk40 - unk3c)))
);

rnd->AddScreenString(
MakeString("%.3f", unk44), textPos, Hmx::Color(1.0f, 1.0f, 1.0f, 1.0f)
);
}

Vector2 titlePos;

titlePos.y = mRect.y;
Hmx::Color color(1.0f, 1.0f, 1.0f, 1.0f);
titlePos.x = mRect.x + 0.1f;

rnd->AddScreenString(unk48.c_str(), titlePos, color);

if (!mSamples.empty()) {
auto it = mSamples.begin();
int idx = 1;
Vector2 prevPos(
mRect.x + mRect.w * (1.0f - clamp(0.0f / (float)(unk38 - 1))),
mRect.y + mRect.h * (1.0f - clamp((it->data - unk3c) / (unk40 - unk3c)))
);

++it;

for (; it != mSamples.end(); ++it) {
Vector2 curPos(
mRect.x + mRect.w * (1.0f - clamp((float)idx / (float)(unk38 - 1))),
mRect.y + mRect.h * (1.0f - clamp((it->data - unk3c) / (unk40 - unk3c)))
);

if (it->b) {
Vector2 hl_p1(
mRect.x + mRect.w * (1.0f - clamp((float)idx / (float)(unk38 - 1))),
mRect.y + mRect.h
);

Vector2 hl_p2(
mRect.x + mRect.w * (1.0f - clamp((float)idx / (float)(unk38 - 1))),
mRect.y
);

rnd->AddScreenLine(
hl_p2, hl_p1, Hmx::Color(1.0f, 1.0f, 1.0f, 1.0f), false
);
}
rnd->AddScreenLine(curPos, prevPos, mColorA, false);
prevPos = curPos;
idx++;
}
}
}
Loading
Loading