Widescreen experiment: native render size via dxwrapper, classic menus

- mods/widescreen: redirect the world view's reads of the 1024.0/768.0
  constants and the 3D ortho extents to our variables; render size =
  monitor; relocate the world view's tile draw list (1750 entries, no
  bounds check) into an enlarged object (16384 entries).
- mods/dxwrapper: route DirectDraw through dxwrapper (Dd7to9, D3D9) since
  Windows' D3D7 cannot render to targets larger than 2048; fix the game's
  device info GUID pointer that dxwrapper's enumeration leaves invalid.
  Pinned release fetched by CMake (hash-checked), installed next to the DLL.
- Main menu (UI thread) and loading screen render in a 1024x768 viewport
  and are presented scaled ("classic" layout); in-game uses the full size.
- re/patch: verified code patches (operand redirect, push immediates,
  displacements) and startup hooks; build.ps1/CMake download fixes.

In-game view untested yet; HUD still at the top-left.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
khallaandClaude Opus 5.5 committed 2026-10-14 00:47:03 +02:00
1 parent c8dc689bc6
commit 795fe8f087
19 files changed
+860 -28

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
#pragma once
// Verified in-place patches of sacred.exe code. Every function checks that the
// bytes it expects are present before writing, logs and refuses otherwise.
#include <cstddef>
#include <cstdint>
namespace re {
bool WriteCode(uint32_t address, const void* bytes, size_t size);
// The instruction at `instruction` has the absolute memory operand `from`
// (e.g. `fmul st, dword ptr [from]`); make it read `to` instead.
bool RedirectOperand(uint32_t instruction, uint32_t from, const void* to);
// Replace a 32-bit displacement/immediate `from` inside the instruction at
// `instruction` by `to` (e.g. a struct field offset in `[ebp+ecx*8+3FF2Ch]`).
bool PatchInstructionDword(uint32_t instruction, uint32_t from, uint32_t to);
// `push imm32` (68 xx xx xx xx) at `instruction`: replace `expected` by `value`.
bool PatchPushImm32(uint32_t instruction, uint32_t expected, uint32_t value);
// Code that must run once at startup, after the hooks are installed.
class StartupRegistration {
public:
StartupRegistration(const char* name, void (*function)());
};
void RunStartupFunctions();
} // namespace re
#define RE_STARTUP(name, function) \
static ::re::StartupRegistration name##_startup(#name, &function)