Skip to content
Draft
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
1 change: 1 addition & 0 deletions KAMI/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static IGame GetGame(IntPtr ipc, string id)
case "BLES02247":
case "NPUB31848":
case "NPEB02436": return new Persona5PS3(ipc);
case "BLUS31197": return new Drakengard3PS3(ipc);
case "BLUS30481": return new NierPS3(ipc);
case "BCES00052": return new RatchetToD(ipc);
case "BCES01503": return new Ratchet3PS3(ipc);
Expand Down
37 changes: 37 additions & 0 deletions KAMI/Games/Drakengard3PS3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using KAMI.Cameras;
using KAMI.Utilities;

namespace KAMI.Games
{
class Drakengard3PS3 : Game<HAVACamera>
{
const uint BaseAddress = 0x019D2414;

DerefChain m_hor;
DerefChain m_vert;

public Drakengard3PS3(IntPtr ipc) : base(ipc)
{
var baseChain = DerefChain.CreateDerefChain(ipc, BaseAddress);
m_vert = baseChain.Chain(0x9E0);
m_hor = baseChain.Chain(0x9E4);
}

public override void UpdateCamera(int diffX, int diffY)
{
if (DerefChain.VerifyChains(m_hor, m_vert))
{
// the game uses a signed integer based camera system, with a 65536 resolution
m_camera.Hor = ((int)(IPCUtils.ReadU32(m_ipc, (uint)m_hor.Value)) / 65536f) * (float)(2 * Math.PI);
m_camera.Vert = ((int)(IPCUtils.ReadU32(m_ipc, (uint)m_vert.Value)) / 65536f) * (float)(2 * Math.PI);

// the vertical value is clamped automagically by the game, min is -20°, max is 85°
m_camera.Update(diffX * SensModifier, -diffY * SensModifier);

IPCUtils.WriteU32(m_ipc, (uint)m_hor.Value, (uint)Math.Round(m_camera.Hor / (float)(2 * Math.PI) * 65536f));
IPCUtils.WriteU32(m_ipc, (uint)m_vert.Value, (uint)Math.Round(m_camera.Vert / (float)(2 * Math.PI) * 65536f));
}
}
}
}