Render original lab and Jimmy with native Vulkan and SDL3 on .NET 10

This commit is contained in:
UnixNight committed 2026-10-23 17:36:04 -04:00
1 parent 3df20ac19a
commit 008c0e16da
41 files changed
+2125 -68

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
using System.Numerics;
namespace GamePort.Game;
/// <summary>
/// Recovered arithmetic fragments, not a complete controller or collision system.
/// Addresses and remaining call/gating questions are in docs/analysis/binary.md.
/// </summary>
public static class RecoveredMotion
{
public const float SpeedIncrement = 30f; // ctor +0x6BC; EXE 0x4392ED
public const float SpeedDecay = 35f; // ctor +0x6C0; EXE 0x439433
public const float MaximumSpeed = 600f; // ctor +0x6C4
public const float JumpImpulse = 550f; // EXE 0x4383B3, subject to original jump state gating
public static readonly Vector3 Gravity = new(0f, -800f, 0f); // EXE 0x44D414
public static readonly Vector3 CameraFollowOffset = new(0f, 200f, -350f);
public static readonly Vector3 CameraTargetOffset = new(0f, 80f, 0f);
// Deliberately per invocation: original increments omit dt. Call cadence is
// not yet verified. Rendering must not directly choose simulation cadence.
public static float AddSpeed(float speed) => MathF.Min(speed + SpeedIncrement, MaximumSpeed);
public static float ReleaseSpeed(float speed) => speed > 0
? MathF.Max(0, speed - SpeedDecay) : MathF.Min(0, speed + SpeedDecay);
/// <summary>
/// EXE 0x479EBB..0x479FC0: consume impulse, acceleration, gravity, then
/// integrate displacement using updated velocity. Collision is applied later
/// by original code and must be supplied by the caller after recovery. Player
/// airborne states add their own acceleration, e.g. gravity*1.33-gravity in
/// states below 3 at EXE 0x438148; gravity alone is not the full jump model.
/// </summary>
public static Vector3 Integrate(ref Vector3 velocity, ref Vector3 impulse,
Vector3 acceleration, Vector3 gravity, float seconds)
{
if (!float.IsFinite(seconds) || seconds <= 0 || seconds >= 1)
throw new ArgumentOutOfRangeException(nameof(seconds), "Original frame accepts 0 < dt < 1");
velocity += impulse;
impulse = Vector3.Zero;
velocity += acceleration * seconds;
velocity += gravity * seconds;
return velocity * seconds;
}
}
/// <summary>Wrapping original LCG at EXE 0x438D52; unrelated to System.Random.</summary>
public struct OriginalRandom(uint seed)
{
public uint State { get; private set; } = seed;
public uint Next()
{
State = unchecked(State * 1664525u + 32767u);
return State >> 16;
}
}