Skip to content

Commit

Permalink
Interpol is coming! 🚔
Browse files Browse the repository at this point in the history
  • Loading branch information
im-tem committed May 10, 2024
1 parent a134b00 commit 6c1395f
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libzhl/functions/AnimationState.zhl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ __thiscall int AnimationState::NextEventTrigger(const char* eventName);
"558bec83ec0c568bf15783ec08":
__thiscall void AnimationState::AdvancePosition(int amount);

"558bec51568b75??0f28ca578bf9f30f114d??8b57??85d274??85f678??3b72??7c??68????????6a03e8????????8b57??83c408f30f104d??8b47??8b0c??8d3c??c1e6040372??85c978??6bd16c":
__thiscall void AnimationState::AdvanceLayerPosition(int layerID, float frame<xmm2>);

"568bf1c746??00000000c746??00000000":
__thiscall void AnimationState::Rewind();

Expand Down
3 changes: 3 additions & 0 deletions libzhl/functions/LuaEngine.zhl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ __thiscall char* LuaEngine::LuamodCMD(char * modname);
"558bec6aff68????????64a1????????5083ec20535657a1????????33c5508d45??64a3????????8965??8b0d????????c745??0f000000":
static __stdcall void LuaEngine::PostGameStart(unsigned int state);

"558bec6aff68????????64a1????????5083ec1c535657a1????????33c5508d45??64a3????????8965??8b0d????????c745??02000000":
static __stdcall void LuaEngine::PostRender();

"558bec83e4f8a1????????83ec10803d????????00":
static __cdecl Vector* LuaEngine::GetMousePosition(Vector* buffer,bool gamecoords);

Expand Down
5 changes: 5 additions & 0 deletions repentogon/ImGuiFeatures/GameOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ struct GameOptionsWindow : ImGuiWindowObject {
ImGui::SameLine();
HelpMarker(LANG.OPT_REPENTOGON_FAST_LASERS_MARK);
AddResetButton(++resetCounter, repentogonOptions.fastLasers, false);
AddNewTableRow();
ImGui::Checkbox(LANG.OPT_REPENTOGON_INTERPOLV2, &repentogonOptions.interpolV2);
ImGui::SameLine();
HelpMarker(LANG.OPT_REPENTOGON_INTERPOLV2_MARK);
AddResetButton(++resetCounter, repentogonOptions.interpolV2, false);

ImGui::EndTable();
}
Expand Down
2 changes: 2 additions & 0 deletions repentogon/ImGuiFeatures/Localization/en_us.inl
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ I(OPT_REPENTOGON_STAT_HUD_PLANETARIUM, u8"Planetarium Chance in Stat HUD")
I(OPT_REPENTOGON_STAT_HUD_PLANETARIUM_MARK, u8"Adds Planetarium chance generation on the stat HUD. Doesn't have any effect if Planetariums aren't unlocked.")
I(OPT_REPENTOGON_SKIP_INTRO, u8"Skip Intro Cutscene")
I(OPT_REPENTOGON_SKIP_INTRO_MARK, u8"Prevents the intro cutscene from playing altogether, no more \"Isaac and his mother\".")
I(OPT_REPENTOGON_INTERPOLV2, u8"60FPS Interpolation")
I(OPT_REPENTOGON_INTERPOLV2_MARK, u8"Interpolates animation frames during render, resulting in utterly, egregiously smooth animations. I am sorry for unleashing this to the world.")
I(OPT_REPENTOGON_FAST_LASERS, u8"Fast Lasers (less accuracy)")
I(OPT_REPENTOGON_FAST_LASERS_MARK, u8"Improves the game's performance by sacrificing laser precision, may slightly alter the hit area (this option reduces the number of lasers' sampling points).")
I(OPT_REPENTOGON_QUICKER_ROOM_CLEAR, u8"Quicker Room Clear")
Expand Down
1 change: 1 addition & 0 deletions repentogon/Patches/CutsceneSkip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "../REPENTOGONOptions.h"


namespace SkipIntro {
bool IsIntroSkip = false;
};
Expand Down
97 changes: 97 additions & 0 deletions repentogon/Patches/InterpolV2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#include "IsaacRepentance.h"
#include "HookSystem.h"

#include "../REPENTOGONOptions.h"

bool _interpol_isgamerender = false;
AnimationState* _interpol_state = 0x0;

HOOK_STATIC(LuaEngine, PostRender, (void)->void,_stdcall) {
_interpol_isgamerender = false;
super();
_interpol_isgamerender = true;
};

HOOK_METHOD(Game, Render, (void)->void) {
_interpol_isgamerender = true;
super();
_interpol_isgamerender = false;
};

inline float _interpol_short_angle_dis(float from, float to) {
float maxAngle = 360.0f;
float disAngle = fmod((to - from),maxAngle);

return fmod((2 * disAngle), maxAngle) - disAngle;
};

inline float _interpol_angle_lerp(float from, float to, float perc) {
return from + _interpol_short_angle_dis(from, to) * perc;
};

HOOK_METHOD(AnimationLayer, RenderFrame, (const Vector& position, int unk, const Vector& topLeftClamp, const Vector& BottomRightClamp, ANM2* animation)->void) {
if (!repentogonOptions.interpolV2 || !this->_animFrames || !_interpol_isgamerender || !_interpol_state) {
return super(position, unk, topLeftClamp, BottomRightClamp, animation);
};
AnimationFrame* ourframe = this->_animFrames;
AnimationFrame* nextframe = 0x0;
if (unk < this->_numFrames) {
ourframe = ourframe + unk;
};
if (!ourframe->interpolated) {
return super(position, unk, topLeftClamp, BottomRightClamp, animation);
};
if (unk + 1 < this->_numFrames) {
nextframe = ourframe + 1;
};
if (nextframe == 0x0) {
return super(position, unk, topLeftClamp, BottomRightClamp, animation);
};
float lerpappend = 0.5f;
if (g_Manager->_framecount % 2 != 0) {
lerpappend = 0.0f;
};
lerpappend *= (animation->_playbackSpeed);
float lerpperc;
lerpperc = (lerpappend+(float)(_interpol_state->_animFrame)-(float)ourframe->startFrame)/(float)(ourframe->duration);
float lerpbegin = (1.0f - lerpperc);

Vector oldscale = ourframe->scale;
Vector oldpos = ourframe->pos;
float oldrot = ourframe->rotation;

ColorMod oldc;
for (int i = 0; i < 3; i++) {
oldc._offset[i] = ourframe->color._offset[i];
ourframe->color._offset[i] = ourframe->color._offset[i] * lerpbegin + nextframe->color._offset[i] * lerpperc;
};
for (int i = 0; i < 4; i++) {
oldc._tint[i] = ourframe->color._tint[i];
ourframe->color._tint[i] = ourframe->color._tint[i] * lerpbegin + nextframe->color._tint[i] * lerpperc;
};

ourframe->scale.x = ourframe->scale.x * lerpbegin + nextframe->scale.x * lerpperc;
ourframe->scale.y = ourframe->scale.y * lerpbegin + nextframe->scale.y * lerpperc;
ourframe->pos.x = ourframe->pos.x * lerpbegin + nextframe->pos.x * lerpperc;
ourframe->pos.y = ourframe->pos.y * lerpbegin + nextframe->pos.y * lerpperc;
ourframe->rotation = _interpol_angle_lerp(ourframe->rotation, nextframe->rotation, lerpperc);

super(position, unk, topLeftClamp, BottomRightClamp,animation);

for (int i = 0; i < 3; i++) {
ourframe->color._offset[i]=oldc._offset[i];
};
for (int i = 0; i < 4; i++) {
ourframe->color._tint[i] = oldc._tint[i];
};

ourframe->scale = oldscale;
ourframe->pos = oldpos;
ourframe->rotation = oldrot;
};

HOOK_METHOD(AnimationState, Render, (const Vector& position, const Vector& topLeftClamp, const Vector& bottomRightClamp)->void) {
_interpol_state = this;
super(position, topLeftClamp, bottomRightClamp);
_interpol_state = 0x0;
};
4 changes: 4 additions & 0 deletions repentogon/REPENTOGONOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct REPENTOGONOptions {
ini["VanillaTweaks"]["SkipIntro"] = "0";
ini["VanillaTweaks"]["PreventModUpdates"] = "0";
ini["VanillaTweaks"]["FastLasers"] = "0";
ini["VanillaTweaks"]["InterpolV2"] = "0";
ini["internal"]["DidModReset"] = "0";
ini["internal"]["EnableUnifont"] = "1";
ini["internal"]["UnifontRenderMode"] = "0";
Expand All @@ -52,6 +53,7 @@ struct REPENTOGONOptions {
skipIntro = defstoi(ini["VanillaTweaks"]["SkipIntro"], 0);
preventModUpdates = defstoi(ini["VanillaTweaks"]["PreventModUpdates"], 0);
fastLasers = defstoi(ini["VanillaTweaks"]["FastLasers"], 0);
interpolV2 = defstoi(ini["VanillaTweaks"]["InterpolV2"], 0);
enableUnifont = defstoi(ini["internal"]["EnableUnifont"], 1);
unifontRenderMode = defstoi(ini["internal"]["UnifontRenderMode"], 0);
lastSaveFile = defstoi(ini["internal"]["LastSaveFile"], 0);
Expand Down Expand Up @@ -92,6 +94,7 @@ struct REPENTOGONOptions {
Write("VanillaTweaks", "StatHUDPlanetarium", statHUDPlanetarium);
Write("VanillaTweaks", "SkipIntro", skipIntro);
Write("VanillaTweaks", "FastLasers", fastLasers);
Write("VanillaTweaks", "InterpolV2", interpolV2);
Write("internal", "EnableUnifont", enableUnifont);
Write("internal", "UnifontRenderMode", unifontRenderMode);
Write("internal", "LastSaveFile", lastSaveFile);
Expand All @@ -109,6 +112,7 @@ struct REPENTOGONOptions {
bool fastLasers;
int lastSaveFile;
bool skipIntro;
bool interpolV2;
std::string optionsPath;
};

Expand Down

0 comments on commit 6c1395f

Please sign in to comment.