This repository has been archived by the owner on Jan 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWii.cs
69 lines (58 loc) · 2.05 KB
/
Wii.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
65
66
67
68
69
using System;
using System.Runtime.InteropServices;
using LiveSplit.EMUHELP;
using LiveSplit.EMUHELP.WII;
public class Wii : WII { }
public class WII : HelperBase
{
public WII(bool generateCode) : base(generateCode)
{
var ProcessNames = new string[]
{
"Dolphin",
"retroarch",
};
GameProcess = new ProcessHook(ProcessNames);
Debugs.Info(" => WII Helper started");
}
public WII()
: 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)
{
if (address >= 0x80000000 && address <= 0x817FFFFF)
return address + (ulong)Marshal.SizeOf<T>() <= 0x81800000;
else if (address >= 0x90000000 && address <= 0x93FFFFFF)
return address + (ulong)Marshal.SizeOf<T>() <= 0x94000000;
else
return false;
}
internal override bool IsStringAddressInBounds(ulong address, int stringLength)
{
if (address >= 0x80000000 && address <= 0x817FFFFF)
return address + (ulong)stringLength <= 0x81800000;
else if (address >= 0x90000000 && address <= 0x93FFFFFF)
return address + (ulong)stringLength <= 0x94000000;
else
return false;
}
public override bool TryGetAddress(ulong address, out IntPtr realAddress)
{
realAddress = default;
if (Emu.GetMemoryAddress(0) == null || Emu.GetMemoryAddress(1) == null)
return false;
if (address >= 0x80000000 && address <= 0x817FFFFF)
realAddress = (IntPtr)((ulong)Emu.GetMemoryAddress(0) + address - 0x80000000);
else if (address >= 0x90000000 && address <= 0x93FFFFFF)
realAddress = (IntPtr)((ulong)Emu.GetMemoryAddress(1) + address - 0x90000000);
return realAddress != default;
}
}