Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Pick graphics for HashLink and XNA games

Leonardo Lobato2421f978c182
diff --git a/src/runtime/game_probe.cpp b/src/runtime/game_probe.cpp
index 8c8a804..a43e063 100644
--- a/src/runtime/game_probe.cpp
+++ b/src/runtime/game_probe.cpp
@@ -177,7 +177,10 @@ void AddImports(const PeFacts& facts, std::set<std::string>* apis) {
}
// Engines known only by a name inside the program: SIL (FTL) reads SIL_WINDOWS_* settings.
-constexpr std::pair<const char*, const char*> kEngineMarks[] = {{"sil_windows_use_", "sil"}};
+// An XNA game names the framework among its .NET assembly references; Wine Mono runs it on FNA, which draws
+// through SDL and OpenGL (Celeste).
+constexpr std::pair<const char*, const char*> kEngineMarks[] = {{"sil_windows_use_", "sil"},
+ {"microsoft.xna.framework", "xna"}};
void ScanNames(const std::string& path, std::set<std::string>* apis, std::string* engine = nullptr) {
Program program(path);
@@ -293,6 +296,11 @@ GameProbe ProbeGame(const std::string& install_root, const std::string& executab
probe.engine = "gamemaker";
} else if (Find(here, Lower(stem) + ".pck", false)) {
probe.engine = "godot";
+ } else if (Find(here, "libhl.dll", false) || Find(here, "hlboot.dat", false)) {
+ // HashLink (Heaps: Dead Cells) loads its graphics library at run time, from a .hdll next to the program.
+ probe.engine = "hashlink";
+ if (Find(here, "directx.hdll", false)) probe.apis.insert("d3d11");
+ if (Find(here, "sdl.hdll", false)) probe.apis.insert("opengl");
} else if (Find(here, "love.dll", false)) {
probe.engine = "love"; // LÖVE draws with OpenGL through SDL, which it loads at run time
} else if (Find(here, "nw.dll", false)) {
@@ -344,6 +352,12 @@ GameDefaults DefaultsFor(const GameProbe& probe, const RuntimeAbilities& runtime
out.graphics = "dxvk";
out.arguments = "{resolution}";
out.resolution_arguments = "-w {w} -h {h}";
+ } else if (probe.engine == "hashlink") {
+ // Dead Cells: Automatic graphics stopped with "Failed to initialize DirectX driver"; DXVK draws it.
+ out.graphics = has("d3d11") ? "dxvk" : "opengl";
+ } else if (probe.engine == "xna") {
+ // Automatic graphics leave FNA without a GL pixel format ("No matching GL pixel format available").
+ out.graphics = "opengl";
} else if (probe.engine == "love" || probe.engine == "sil") {
// SIL (FTL) draws with OpenGL though its program also names Direct3D 11; under DXVK it
// quits right after setting up video.
@@ -397,7 +411,7 @@ std::string DetectedLabel(const std::string& summary) {
for (const auto& [id, name] : std::initializer_list<std::pair<const char*, const char*>>{
{"unity", "Unity"}, {"unity-il2cpp", "Unity"}, {"unity-legacy", "Unity"}, {"unreal", "Unreal Engine"}, {"source", "Source"},
{"gamemaker", "GameMaker"}, {"godot", "Godot"}, {"love", "L\xC3\x96VE"}, {"nwjs", "NW.js"}, {"sil", "SIL"},
- {"idtech3", "id Tech 3"}})
+ {"idtech3", "id Tech 3"}, {"hashlink", "HashLink"}, {"xna", "XNA"}})
if (facts.count(id)) engine = name;
std::string api;
if (graphics == "opengl") api = "OpenGL";
diff --git a/src/runtime/game_probe.h b/src/runtime/game_probe.h
index cce50d3..a525f5c 100644
--- a/src/runtime/game_probe.h
+++ b/src/runtime/game_probe.h
@@ -9,7 +9,8 @@ namespace playden::runtime {
// bounded: symbolic links are never followed, folders are walked a few levels deep and at
// most kProbeScanBytes of a program are scanned.
struct GameProbe {
- std::string engine; // "unity", "unreal", "source", "gamemaker", "godot", "love", "nwjs", "sil", "idtech3", or empty
+ std::string engine; // "unity", "unreal", "source", "gamemaker", "godot", "love", "nwjs", "sil", "idtech3",
+ // "hashlink", "xna", or empty
bool il2cpp = false; // Unity with GameAssembly.dll
bool legacy_unity = false; // Unity before 2017.2: the player is built into the program
// Graphics libraries the program or its engine imports or names: "d3d8", "d3d9", "d3d10",
diff --git a/tests/game_probe_test.cpp b/tests/game_probe_test.cpp
index 68e173c..aed3a2f 100644
--- a/tests/game_probe_test.cpp
+++ b/tests/game_probe_test.cpp
@@ -254,6 +254,26 @@ int main() {
const auto source = DefaultsFor(ProbeGame(root.string(), "hl2.exe"));
CHECK(source.graphics == "dxvk" && source.resolution_arguments == "-w {w} -h {h}");
}
+ { // HashLink (Dead Cells): the graphics library is a .hdll beside the program, loaded at run time.
+ const auto root = fresh();
+ WritePe(root / "deadcells.exe", {true, {"libhl.dll", "KERNEL32.dll"}});
+ Touch(root / "libhl.dll");
+ Touch(root / "directx.hdll");
+ Touch(root / "sdl.hdll");
+ const auto hashlink = DefaultsFor(ProbeGame(root.string(), "deadcells.exe"));
+ CHECK(hashlink.graphics == "dxvk" && hashlink.summary == "hashlink,d3d11,opengl graphics=dxvk");
+ CHECK(DetectedLabel(hashlink.summary) == "HashLink \xC2\xB7 Direct3D 11");
+ fs::remove(root / "directx.hdll");
+ CHECK(DefaultsFor(ProbeGame(root.string(), "deadcells.exe")).graphics == "opengl");
+ }
+ { // XNA (Celeste): a .NET program naming the framework runs on Wine Mono's FNA, which draws with OpenGL.
+ const auto root = fresh();
+ WritePe(root / "Celeste.exe", {false, {"mscoree.dll"}, true, false, "Microsoft.Xna.Framework.Game"});
+ RuntimeAbilities mono;
+ mono.wine_mono = true;
+ const auto xna = DefaultsFor(ProbeGame(root.string(), "Celeste.exe"), mono);
+ CHECK(xna.refusal.empty() && xna.graphics == "opengl" && DetectedLabel(xna.summary) == "XNA \xC2\xB7 OpenGL");
+ }
{ // LÖVE (Balatro): OpenGL, found through love.dll beside the program.
const auto root = fresh();
WritePe(root / "Balatro.exe", {true, {"love.dll", "lua51.dll", "KERNEL32.dll"}});