diff options
Diffstat (limited to 'runtime/src/main.cpp')
| -rw-r--r-- | runtime/src/main.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index fbb4b3043..098a8ee40 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | 29 | ||
| 30 | #include "base_reservation.h" | 30 | #include "base_reservation.h" |
| 31 | #include "code_hooks.h" | 31 | #include "code_hooks.h" |
| 32 | #include "cpu_emulation.h" | ||
| 32 | #include "host_cpu.h" | 33 | #include "host_cpu.h" |
| 33 | #include "mods.h" | 34 | #include "mods.h" |
| 34 | #include "pe_loader.h" | 35 | #include "pe_loader.h" |
| @@ -172,6 +173,15 @@ int wmain(int argc, wchar_t** argv) { | |||
| 172 | : "error: cannot create the trace file\n"); | 173 | : "error: cannot create the trace file\n"); |
| 173 | return 2; | 174 | return 2; |
| 174 | } | 175 | } |
| 176 | // The console's Zen 2 instructions this CPU may lack (docs/cpu_features.md): emulated on #UD. Installed after the | ||
| 177 | // trace's handler so it runs first, and an emulated instruction is not recorded as an exception. | ||
| 178 | if (const auto host = rt::cpu_emulation::detect_host(); !host.sse4a || !host.clzero || !host.monitorx || !host.clwb) | ||
| 179 | std::fprintf(stderr, "[rt] cpu: this CPU lacks%s%s%s%s; the game's uses are emulated (docs/cpu_features.md)\n", | ||
| 180 | host.sse4a ? "" : " SSE4a", host.clzero ? "" : " CLZERO", host.monitorx ? "" : " MONITORX", | ||
| 181 | host.clwb ? "" : " CLWB"); | ||
| 182 | if (!rt::cpu_emulation::install()) | ||
| 183 | std::fprintf(stderr, "[rt] cpu: AddVectoredExceptionHandler failed (error %lu); instructions this CPU lacks " | ||
| 184 | "will stop the game\n", GetLastError()); | ||
| 175 | 185 | ||
| 176 | try { | 186 | try { |
| 177 | rt::Loader loader(game_dir); | 187 | rt::Loader loader(game_dir); |