-
Notifications
You must be signed in to change notification settings - Fork 1
/
GCN.cs
64 lines (51 loc) · 1.53 KB
/
GCN.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Runtime.InteropServices;
using LiveSplit.EMUHELP;
using LiveSplit.EMUHELP.GCN;
public class Gamecube : GCN { }
public class GameCube : GCN { }
public class GCN : HelperBase
{
public GCN(bool generateCode) : base(generateCode)
{
var ProcessNames = new string[]
{
"Dolphin",
"retroarch",
};
GameProcess = new ProcessHook(ProcessNames);
Debugs.Info(" => GCN Helper started");
}
public GCN()
: this(true) { }
protected override void InitActions()
{
Emu = Game.ProcessName switch
{
"Dolphin" => new Dolphin(this),
"retroarch" => new Retroarch(this),
_ => throw new NotImplementedException(),
};
}
internal override bool IsAddressInBounds<T>(ulong address)
{
return address + (ulong)Marshal.SizeOf<T>() <= 0x81800000;
}
internal override bool IsStringAddressInBounds(ulong address, int stringLength)
{
return address + (ulong)stringLength <= 0x81800000;
}
public override bool TryGetAddress(ulong address, out IntPtr realAddress)
{
realAddress = default;
if (Emu == null || Emu.GetMemoryAddress(0) == null)
return false;
ulong defOffset;
if (address >= 0x80000000 && address <= 0x81FFFFFF)
defOffset = address - 0x80000000;
else
return false;
realAddress = (IntPtr)((ulong)Emu.GetMemoryAddress(0) + defOffset);
return true;
}
}