diff --git a/docs/installer.md b/docs/installer.md index fa4318f3..58fb469e 100644 --- a/docs/installer.md +++ b/docs/installer.md @@ -45,7 +45,8 @@ keeps `profile/`. Saves carry over both ways: 1.4.3 converts a 1.2.1 save on loa 2. **Extract** ExeFS and RomFS into the install folder and verify the hashes. 3. **Lift** the ExeFS to C (`recomp/gen.py`, `recomp/patches-v121.txt` or `patches-v143.txt`) into a temp folder next to the installer. -4. **Compile** the generated C, `modules.c` and `romfs.c` (they bake per-install layout and RomFS hashes) and link +4. **Compile** the generated C, `modules.c`, `romfs.c` and `patches.c` (they bake the per-install layout, RomFS + hashes and the game version's patch page) and link them with the prebuilt runtime library into `totk.exe` (`build_game.py --runtime-lib`; about 3 min on 24 cores). 5. **Prepare** the RomFS patches and the shaders (`tools/make_romfs_patches.py`, `tools/prepare_shaders.py`, `totk.exe --prepare-shaders`) in the install folder. @@ -91,7 +92,7 @@ installer/ the installer: steps, CLI, window, en/ru text catalog python/ Python 3.14.9 embeddable + numpy, lz4, cryptography, cffi, pycparser (+ tkinter for the window) recomp/, tools/ the lifter and the build, extraction and shader scripts the steps run (copied from the repo) llvm/ llvm-mingw, x86_64-only subset (Apache-2.0 with LLVM exception; mingw-w64 parts permissive) -runtime/ libtotkrt.a and the headers the generated code and modules.c/romfs.c include +runtime/ libtotkrt.a and the headers the generated code and modules.c/romfs.c/patches.c include bin/ totk_xlate.exe, hactool.exe, SDL3.dll, libopus-0.dll, ninja.exe data/ shader_list.tsv (MacNativeGames, MIT) THIRD_PARTY_NOTICES.md diff --git a/installer/layout.py b/installer/layout.py index 31f2fe1c..34a30422 100644 --- a/installer/layout.py +++ b/installer/layout.py @@ -7,7 +7,7 @@ Release (docs/installer.md "Release layout"), root = the unpacked folder: recomp/, tools/ the lifter and the scripts; recomp/patches-.txt, tools/data/expected-v.json for each supported update (SUPPORTED) llvm/ llvm-mingw (bin/clang.exe) - runtime/ libtotkrt.a, the headers, install-side sources (romfs.c) and totk.ico; runtime/deps/ holds + runtime/ libtotkrt.a, the headers, install-side sources (romfs.c, patches.c) and totk.ico; runtime/deps/ holds include/ + lib/ of Vulkan, SDL3, Opus, libvpx and VMA (build_game.py --deps) bin/ totk_xlate.exe (+ totk_xlate.id), hactool.exe, ninja.exe, SDL3.dll, libopus-0.dll data/shader_list.tsv the MacNativeGames shader list diff --git a/runtime/gfx_window.c b/runtime/gfx_window.c index 691b99e0..eb01ea28 100644 --- a/runtime/gfx_window.c +++ b/runtime/gfx_window.c @@ -46,6 +46,7 @@ static volatile LONG g_focus_msgs; static CRITICAL_SECTION g_start_lock; // gfx_window_start / vsync start static int g_started, g_wnd_failed; static int g_background; // TOTK_BACKGROUND_WINDOW: the window stays behind the user's windows +static int g_fs_pending; // window thread: TOTK_FULLSCREEN waits for the first activation // ---- swapchain and present state (g_pl) static CRITICAL_SECTION g_pl; @@ -180,6 +181,7 @@ HWND gfx_window_handle(void) { return g_hwnd; } // ---- window thread #define WND_STYLE WS_OVERLAPPEDWINDOW #define WM_APP_SETTINGS (WM_APP + 1) +#define WM_APP_FULLSCREEN (WM_APP + 2) // the fullscreen setting, held back until the window is first activated static WINDOWPLACEMENT g_saved_place = {sizeof g_saved_place}; // the window behind fullscreen (window thread) @@ -360,6 +362,13 @@ static LRESULT CALLBACK wnd_proc(HWND h, UINT m, WPARAM w, LPARAM l) { case WM_APP_SETTINGS: apply_settings(h); return 0; + case WM_APP_FULLSCREEN: + if (cfg_fullscreen() && !is_fullscreen(h)) { + input_cursor_suspend(1); + toggle_fullscreen(h); + input_cursor_suspend(0); + } + return 0; case WM_SIZE: if (w != SIZE_MINIMIZED) InterlockedExchange(&g_dirty, 1); refresh_rate_update(h, 0); @@ -376,6 +385,10 @@ static LRESULT CALLBACK wnd_proc(HWND h, UINT m, WPARAM w, LPARAM l) { oe_set_focus(in); // pinned to 1 by TOTK_ASSUME_FOCUS inside oe_push_message(OE_MSG_FOCUS_STATE_CHANGED); InterlockedIncrement(&g_focus_msgs); + if (in && g_fs_pending) { + g_fs_pending = 0; + PostMessageW(h, WM_APP_FULLSCREEN, 0, 0); + } return 0; } case WM_CLOSE: @@ -405,8 +418,11 @@ static DWORD WINAPI window_main(void *arg) { cfg_window_size(&cw, &ch); RECT r = {0, 0, cw, ch}; AdjustWindowRect(&r, WND_STYLE, FALSE); - // TOTK_BACKGROUND_WINDOW=1 (test runs): the window opens behind the user's windows without taking focus; it keeps its - // taskbar button and can be brought up by hand. It never goes fullscreen at start. + // The window opens behind the user's windows without taking focus: it shows the game's blank loading frames for a + // while, and must not cover what the player works on meanwhile. The game still counts itself in focus until the + // first WM_ACTIVATEAPP, so loading goes on, and keyboard input waits for the foreground (input_win.c). Its taskbar + // button flashes until it is brought up, and TOTK_FULLSCREEN waits for that first activation. + // TOTK_BACKGROUND_WINDOW=1 (test runs): no flashing, never fullscreen at start, and F11 keeps the window's place. int background = g_background = cfg_get("TOTK_BACKGROUND_WINDOW") && atoi(cfg_get("TOTK_BACKGROUND_WINDOW")); g_hwnd = CreateWindowExW(0, wc.lpszClassName, L"TotK Recomp", WND_STYLE, CW_USEDEFAULT, CW_USEDEFAULT, r.right - r.left, r.bottom - r.top, NULL, NULL, inst, NULL); @@ -414,11 +430,12 @@ static DWORD WINAPI window_main(void *arg) { rt_log("gfx: CreateWindowEx failed (%lu)", GetLastError()); g_wnd_failed = 1; } else { - if (background) - SetWindowPos(g_hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW); - else - ShowWindow(g_hwnd, cfg_get("TOTK_ASSUME_FOCUS") ? SW_SHOWNOACTIVATE : SW_SHOW); // scripted runs leave focus alone - if (!background && cfg_fullscreen()) toggle_fullscreen(g_hwnd); + SetWindowPos(g_hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW); + if (!background) { + FLASHWINFO fw = {.cbSize = sizeof fw, .hwnd = g_hwnd, .dwFlags = FLASHW_TRAY | FLASHW_TIMERNOFG}; + FlashWindowEx(&fw); + g_fs_pending = cfg_fullscreen(); + } note_applied(); refresh_rate_update(g_hwnd, 1); } diff --git a/tools/build_game.py b/tools/build_game.py index 026149a9..17719e5d 100644 --- a/tools/build_game.py +++ b/tools/build_game.py @@ -44,7 +44,7 @@ runtime is libc++ from llvm-mingw. Such a build never reuses another build's gen Split build. --make-runtime-lib compiles only runtime/ into /libtotkrt.a (what CI prebuilds). --runtime-lib PATH then compiles only the generated C and the install-time files (modules.c and INSTALL_SIDE, which bake the player's -game hashes in) and links them with that library. The library holds no game-derived data. +game hashes and version in) and links them with that library. The library holds no game-derived data. Standard library only. """ @@ -84,7 +84,9 @@ VMA_INCLUDE = UCRT.parent / 'include' / 'vma' # vk_mem_alloc.h; MSYS2 package LLVM_LINK_LIBS = ['-lpsapi', '-lbcrypt', '-luser32', '-lgdi32', '-ldwmapi', '-lwinmm', '-lvulkan-1', '-lSDL3', '-lopus', '-l:libvpx.a', '-l:libc++.a', '-l:libc++abi.a', '-l:libunwind.a', '-l:libwinpthread.a'] DEFAULT_DEPS = ROOT / 'toolchain' / 'deps-mingw' -INSTALL_SIDE = {'romfs.c'} # runtime sources that include romfs_config.h: compiled per install, not in the library +# Runtime sources compiled per install, not in the library: romfs.c includes romfs_config.h, patches.c the patches.h +# of the player's game version (its patch page is the page after that version's main). +INSTALL_SIDE = {'romfs.c', 'patches.c'} LIB_NAME = 'libtotkrt.a' AR = UCRT / 'llvm-ar.exe' WINDRES = UCRT / 'windres.exe' # runtime/totk.rc: the manifest of totk.exe diff --git a/tools/make_release.py b/tools/make_release.py index 9ef9b91e..50e5be90 100644 --- a/tools/make_release.py +++ b/tools/make_release.py @@ -10,8 +10,8 @@ cached in toolchain/release-dl/ and checked against the sha256 in PINS; a mismat files come out of the python.org installer's own component MSI, unpacked with msiexec /a and expand.exe; the installer is never run) llvm/ llvm-mingw, x86_64 only, the files clang and lld need to compile and link totk.exe - runtime/ libtotkrt.a (build_game.py --make-runtime-lib with llvm/), the runtime headers, romfs.c (compiled per - install), deps/ (headers and import libraries of SDL3, Opus, libvpx, Vulkan and VMA) + runtime/ libtotkrt.a (build_game.py --make-runtime-lib with llvm/), the runtime headers, romfs.c and patches.c + (compiled per install), deps/ (headers and import libraries of SDL3, Opus, libvpx, Vulkan and VMA) bin/ totk_xlate.exe (+ .id), hactool.exe, SDL3.dll (upstream), libopus-0.dll, ninja.exe recomp/, tools/, data/, installer/, licenses/, THIRD_PARTY_NOTICES.md, totk.ini.example VERSION git describe of the checkout (else the short hash); the installer's release string @@ -321,7 +321,7 @@ def collect_licenses(out): # ---- runtime/, recomp/, tools/, data/ --------------------------------------------------------------------------------- def runtime_lib(out, llvm): - """Build libtotkrt.a with the folder's llvm/ and copy it, the headers and romfs.c into runtime/.""" + """Build libtotkrt.a with the folder's llvm/ and copy it, the headers and the install-side sources into runtime/.""" build = MAIN_ROOT / 'build' / 'release-check' / 'rtlib' gen = MAIN_ROOT / 'generated' / 'v121' run([sys.executable, ROOT / 'tools' / 'build_game.py', '--make-runtime-lib', '--toolchain', llvm, @@ -333,7 +333,8 @@ def runtime_lib(out, llvm): if p.suffix in RUNTIME_SUFFIXES and p.is_file(): (rt / p.relative_to(ROOT / 'runtime')).parent.mkdir(parents=True, exist_ok=True) shutil.copy2(p, rt / p.relative_to(ROOT / 'runtime')) - shutil.copy2(ROOT / 'runtime' / 'romfs.c', rt / 'romfs.c') # build_game.py INSTALL_SIDE + for name in ('romfs.c', 'patches.c'): # build_game.py INSTALL_SIDE + shutil.copy2(ROOT / 'runtime' / name, rt / name) def build_sources(out):