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 pathPS1.cs
69 lines (56 loc) · 2 KB
/
PS1.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.Collections.Generic;
using System.Runtime.InteropServices;
using LiveSplit.EMUHELP;
using LiveSplit.EMUHELP.PS1;
public class Playstation : PS1 { }
public class Playstation1 : PS1 { }
public class PS1 : HelperBase
{
public PS1(bool generateCode) : base(generateCode)
{
List<string> processNames = new List<string>
{
"ePSXe",
"psxfin",
"duckstation-qt-x64-ReleaseLTCG",
"duckstation-nogui-x64-ReleaseLTCG",
"retroarch",
"pcsx-redux.main",
"xebra",
"mednafen"
};
GameProcess = new ProcessHook(processNames);
Debugs.Info(" => PS1 Helper started");
}
public PS1()
: this(true) { }
protected override void InitActions()
{
Emu = Game.ProcessName.ToLower() switch {
"epsxe" => new ePSXe(this),
"duckstation-qt-x64-releaseltcg" or "duckstation-nogui-x64-releaseltcg" => new Duckstation(this),
"psxfin" => new pSX(this),
"xebra" => new Xebra(this),
"retroarch" => new Retroarch(this),
"pcsx-redux.main" => new PcsxRedux(this),
"mednafen" => new Mednafen(this),
_ => throw new NotImplementedException(),
};
}
public override bool TryGetAddress(ulong address, out IntPtr realAddress)
{
realAddress = default;
if (Emu.GetMemoryAddress(0) == null)
return false;
var defOffset = address;
if (defOffset >= 0x80000000 && defOffset < 0x80200000)
defOffset -= 0x80000000;
else
return false;
realAddress = (IntPtr)((ulong)Emu.GetMemoryAddress(0) + defOffset);
return true;
}
internal override bool IsAddressInBounds<T>(ulong address) => address + (ulong)Marshal.SizeOf(typeof(T)) <= 0x80200000;
internal override bool IsStringAddressInBounds(ulong address, int stringLength) => address + (ulong)stringLength <= 0x80200000;
}