diff --git a/CMakeLists.txt b/CMakeLists.txt index 23f52855..369244d4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,6 +134,7 @@ add_executable(bbhost src/engine/auto_replenish.cpp src/engine/maiden_events.cpp src/engine/option_menu.cpp + src/engine/plugin_dialog.cpp src/engine/menu_assets.cpp src/engine/menu_pointer.cpp src/engine/menu_close.cpp @@ -142,9 +143,11 @@ add_executable(bbhost src/engine/yebis.cpp src/engine/yebis_bind.cpp src/engine/graphics_patch.cpp + src/engine/font_handle_set.cpp src/engine/live_resolution.cpp src/engine/render_scale.cpp src/engine/loading.cpp + src/engine/world_pause.cpp src/engine/camera.cpp src/engine/mouse_camera.cpp src/engine/mouse_camera_stubs.cpp @@ -173,6 +176,10 @@ add_executable(bbhost src/host/overlay.cpp src/host/present_pass.cpp src/host/ingame_menu.cpp + src/host/plugin_panel.cpp + src/host/plugin_menu.cpp + src/host/game_font.cpp + src/host/game_menu_art.cpp src/host/controls_page.cpp src/host/framegen.cpp src/host/options.cpp @@ -265,6 +272,11 @@ endif() add_library(bb_plugin_hello MODULE examples/plugins/hello/hello.c) target_include_directories(bb_plugin_hello PRIVATE include) set_target_properties(bb_plugin_hello PROPERTIES OUTPUT_NAME hello PREFIX "") +# The in-game menu example (plugin API 29, docs/plugins.md's In-game menus, +# which holds it whole - plugin_menu_docs_test checks they are the same). +add_library(bb_plugin_menu_example MODULE examples/plugins/menu/menu.c) +target_include_directories(bb_plugin_menu_example PRIVATE include) +set_target_properties(bb_plugin_menu_example PROPERTIES OUTPUT_NAME menu PREFIX "") # The shader overrides' example (plugin API 27, examples/plugins/shader_tint): # built only when asked for (and by its test). @@ -292,6 +304,7 @@ bb_plugin(quake plugins/quake/quake.cpp) bb_plugin(lohit plugins/lohit/lohit.cpp) bb_plugin(ps1 plugins/ps1/ps1.cpp) bb_plugin(iso plugins/iso/iso.cpp) +bb_plugin(hunter_cam plugins/hunter_cam/hunter_cam.cpp) # The Debug Menu plugin carries its glyphs (plugins/debug_menu/font14.bin, # tools/make_debug_font.py) as bytes: build/gen/debug_font14.inc, rewritten # only when the file changes. @@ -702,8 +715,9 @@ if(WIN32 AND CMAKE_CROSSCOMPILING AND NOT CMAKE_CROSSCOMPILING_EMULATOR) set_property(TARGET guest_console_test PROPERTY CROSSCOMPILING_EMULATOR wine) endif() add_test(NAME guest_console_test COMMAND guest_console_test) -# A save written whole or not at all: the commit at unmount, and on Linux a -# kill at each of its steps with the recovery after it (hle/save_commit.h). +# A save written whole or not at all: the commit at unmount, and a kill at +# each of its steps with the recovery after it (hle/save_commit.h; a child +# process forked on Linux, the test run again on Windows). add_executable(save_commit_test tests/save_commit_test.cpp src/hle/save_commit.cpp) target_include_directories(save_commit_test PRIVATE src) target_compile_features(save_commit_test PRIVATE cxx_std_17) @@ -750,6 +764,12 @@ if(UNIX) add_dependencies(mapval_probe_test mapval_probe) add_test(NAME mapval_probe_test COMMAND mapval_probe_test $) set_tests_properties(mapval_probe_test PROPERTIES SKIP_RETURN_CODE 77) + # Plugin API 29's world_pause, world_step, pad, pad_take and world_state in a + # running game, for a harness (tools/api29_probe.c). Built beside the tests, + # never into plugins/, where bbhost would load it. + add_library(api29_probe MODULE tools/api29_probe.c) + target_include_directories(api29_probe PRIVATE include) + set_target_properties(api29_probe PROPERTIES PREFIX "") # The boss rush plugin's travel and fog warp on a pretend host whose loads # are slow (plugins/boss_rush): nothing moves the player inside a loading # screen, and only a travel that truly fails stops the run. @@ -777,6 +797,20 @@ if(UNIX) target_link_libraries(ps1_plugin_test PRIVATE ${CMAKE_DL_LIBS}) add_dependencies(ps1_plugin_test bb_plugin_ps1) add_test(NAME ps1_plugin_test COMMAND ps1_plugin_test $) + # The in-game menus' test plugin (tests/plugins/menu_demo.cpp: every part of + # plugin API 29's menus) on a pretend host, and its menus in the host's panel + # through the world's states (the game's own interruptions). Built beside the + # tests, never into plugins/, where bbhost would load it. + add_library(menu_demo MODULE tests/plugins/menu_demo.cpp) + target_include_directories(menu_demo PRIVATE include) + target_compile_features(menu_demo PRIVATE cxx_std_17) + set_target_properties(menu_demo PROPERTIES PREFIX "") + add_executable(plugin_menus_test tests/plugin_menus_test.cpp src/host/plugin_menu.cpp src/host/plugin_panel.cpp) + target_include_directories(plugin_menus_test PRIVATE src include) + target_compile_features(plugin_menus_test PRIVATE cxx_std_17) + target_link_libraries(plugin_menus_test PRIVATE ${CMAKE_DL_LIBS}) + add_dependencies(plugin_menus_test menu_demo) + add_test(NAME plugin_menus_test COMMAND plugin_menus_test $) # The shader overrides' example on a pretend host (examples/plugins/shader_tint): # its own source asked for until met, patched, on and off by turns, its # strength in its shader data each frame; nothing asked of an older host. @@ -876,6 +910,17 @@ if(UNIX) add_executable(stun_test tests/stun_test.cpp src/net/stun.cpp) target_include_directories(stun_test PRIVATE src) add_test(NAME stun_test COMMAND stun_test) + # Datagrams between two P2P sockets through hle/net.cpp, directly and + # through the relay: the game's split into pieces of whole chunks, others + # whole up to the largest UDP carries; whole with + # BBHOST_NET_SPLIT_DATAGRAMS=0 (tests/net_p2p_test.cpp). + add_executable(net_p2p_test tests/net_p2p_test.cpp src/hle/net.cpp src/net/stun.cpp src/core/futex.cpp) + target_include_directories(net_p2p_test PRIVATE src) + target_link_libraries(net_p2p_test PRIVATE pthread) + add_test(NAME net_p2p_test COMMAND net_p2p_test) + add_test(NAME net_p2p_whole_test COMMAND net_p2p_test) + set_tests_properties(net_p2p_whole_test PROPERTIES ENVIRONMENT BBHOST_NET_SPLIT_DATAGRAMS=0) + set_tests_properties(net_p2p_test net_p2p_whole_test PROPERTIES TIMEOUT 60) # The event poller's long polls and generations (net/poll_pacing.h). add_executable(poll_pacing_test tests/poll_pacing_test.cpp) target_include_directories(poll_pacing_test PRIVATE src) @@ -887,19 +932,27 @@ if(UNIX) add_executable(np_score_test tests/np_score_test.cpp) target_include_directories(np_score_test PRIVATE src) add_test(NAME np_score_test COMMAND np_score_test) - # The setup window's sign-in check: the server's answers read (net/sign_in_check.h). + # The setup window's sign-in check and relay switch: the server's answers + # read (net/sign_in_check.h). add_executable(sign_in_check_test tests/sign_in_check_test.cpp src/replay/json.cpp) target_include_directories(sign_in_check_test PRIVATE src) add_test(NAME sign_in_check_test COMMAND sign_in_check_test) + # The setup window's links out (host/links.h): the addresses, and no browser + # from a test's window. + add_executable(launcher_links_test tests/launcher_links_test.cpp) + target_include_directories(launcher_links_test PRIVATE src) + add_test(NAME launcher_links_test COMMAND launcher_links_test) # The setup window's connection test (net/nat_check.h): the exchange from a # port against a test server of its own on loopback - a router that keeps - # one port, one that changes it, none answering, the port check open, closed - # and absent - and the server's answers read. + # one port, one that changes it, none answering, the first seconds held, + # every send refused, the port check open, closed and absent, this PC's own + # address - the server's answers read, and the card's words for each + # reading, the relay switch's and the P2P port's (~25 s of waits). add_executable(nat_check_test tests/nat_check_test.cpp src/net/nat_probe.cpp src/net/stun.cpp src/replay/json.cpp) target_include_directories(nat_check_test PRIVATE src) target_link_libraries(nat_check_test PRIVATE Threads::Threads) add_test(NAME nat_check_test COMMAND nat_check_test) - set_tests_properties(nat_check_test PROPERTIES TIMEOUT 60) + set_tests_properties(nat_check_test PROPERTIES TIMEOUT 120) add_executable(uncapped_limit_test tests/uncapped_limit_test.cpp) target_include_directories(uncapped_limit_test PRIVATE src) add_test(NAME uncapped_limit_test COMMAND uncapped_limit_test) @@ -988,7 +1041,13 @@ if(UNIX) # Stage 4b.3c: the index of live homes by address and its page filter, against a plain list (host/gxvk_homes_index.h). add_executable(gxvk_homes_test tests/gxvk_homes_test.cpp) target_include_directories(gxvk_homes_test PRIVATE src include) + target_link_libraries(gxvk_homes_test PRIVATE Threads::Threads) add_test(NAME gxvk_homes_test COMMAND gxvk_homes_test) + # GX's tables ring: the command processor's serial guard and the pool's arena (host/gx_tables_ring.h). + add_executable(gx_tables_ring_test tests/gx_tables_ring_test.cpp) + target_include_directories(gx_tables_ring_test PRIVATE src include) + target_link_libraries(gx_tables_ring_test PRIVATE Threads::Threads) + add_test(NAME gx_tables_ring_test COMMAND gx_tables_ring_test) add_executable(gxvk_rest_test tests/gxvk_rest_test.cpp) target_include_directories(gxvk_rest_test PRIVATE src include) add_test(NAME gxvk_rest_test COMMAND gxvk_rest_test) @@ -999,6 +1058,10 @@ if(UNIX) add_executable(list_cb_memo_test tests/list_cb_memo_test.cpp) target_include_directories(list_cb_memo_test PRIVATE src include) add_test(NAME list_cb_memo_test COMMAND list_cb_memo_test) + # The markers between the draws a device-loss report reads (host/gpu_markers.h). + add_executable(gpu_markers_test tests/gpu_markers_test.cpp) + target_include_directories(gpu_markers_test PRIVATE src include) + add_test(NAME gpu_markers_test COMMAND gpu_markers_test) # The draw pool's threads by default, counted from the process's affinity (host/gxvk_lists.h pool_threads_for). add_executable(pool_threads_test tests/pool_threads_test.cpp src/core/portable.cpp) target_include_directories(pool_threads_test PRIVATE src include) @@ -1020,6 +1083,15 @@ if(UNIX) add_executable(vertex_clamp_test tests/vertex_clamp_test.cpp) target_include_directories(vertex_clamp_test PRIVATE src) add_test(NAME vertex_clamp_test COMMAND vertex_clamp_test) + # The run's lookups answered from the last one while what it was made of is unchanged, with their mistakes (host/run_lookups.h). + add_executable(run_lookups_test tests/run_lookups_test.cpp) + target_include_directories(run_lookups_test PRIVATE src) + add_test(NAME run_lookups_test COMMAND run_lookups_test) + # The GX layer's catch-up: the flush's outcome with the GPU's time waited for outside the renderer's lock, with its + # mistakes (host/gpu_catch_up.h). + add_executable(gpu_catch_up_test tests/gpu_catch_up_test.cpp) + target_include_directories(gpu_catch_up_test PRIVATE src) + add_test(NAME gpu_catch_up_test COMMAND gpu_catch_up_test) # The render targets' sizes learned by their geometry, and the rule by the address alone failing (host/rt_extent.h). add_executable(rt_extent_test tests/rt_extent_test.cpp) target_include_directories(rt_extent_test PRIVATE src) @@ -1122,7 +1194,43 @@ if(UNIX) target_include_directories(camera_settings_test PRIVATE src) target_link_libraries(camera_settings_test PRIVATE Threads::Threads) add_test(NAME camera_settings_test COMMAND camera_settings_test) + # Scaleform's font-handle set removed by the handle's own pointer (engine/font_handle_set.h) + # against models of the game's add, lookup and removal: the stock game's tables the same, two + # handles of one name (a live Text scale change) without the use-after-free. + add_executable(font_handle_set_test tests/font_handle_set_test.cpp src/engine/font_handle_set.cpp) + target_include_directories(font_handle_set_test PRIVATE src) + add_test(NAME font_handle_set_test COMMAND font_handle_set_test) + set_tests_properties(font_handle_set_test PROPERTIES TIMEOUT 60) set_tests_properties(settings_store_test camera_settings_test PROPERTIES TIMEOUT 30) + # A plugin's look's arithmetic (engine/look_math.h): what apply_look writes + # into YEBIS's block for the motion blur's samples and the depth of field. + add_executable(look_math_test tests/look_math_test.cpp) + target_include_directories(look_math_test PRIVATE src) + add_test(NAME look_math_test COMMAND look_math_test) + # The game's menu font read from the dump and its glyphs rasterised + # (host/game_font.h); skipped without the dump (BBHOST_APP0). + add_executable(game_font_test tests/game_font_test.cpp src/host/game_font.cpp) + target_include_directories(game_font_test PRIVATE src) + target_compile_definitions(game_font_test PRIVATE BBHOST_GAME_FONT_NO_FS=1) + add_test(NAME game_font_test COMMAND game_font_test) + set_tests_properties(game_font_test PROPERTIES SKIP_RETURN_CODE 77) + # A plugin's in-game menus as the host keeps them (host/plugin_menu.h): the + # pages and menus a table declares, rows set at run time, the back stack. + add_executable(plugin_menu_test tests/plugin_menu_test.cpp src/host/plugin_menu.cpp) + target_include_directories(plugin_menu_test PRIVATE src include) + add_test(NAME plugin_menu_test COMMAND plugin_menu_test) + # docs/plugins.md's In-game menus example is examples/plugins/menu/menu.c as it is. + add_executable(plugin_menu_docs_test tests/plugin_menu_docs_test.cpp) + add_test(NAME plugin_menu_docs_test COMMAND plugin_menu_docs_test ${CMAKE_SOURCE_DIR}/docs/plugins.md + ${CMAKE_SOURCE_DIR}/examples/plugins/menu/menu.c) + # The game's menu art: its BC7 decoder against Pillow's, the tiling, the + # TPF, DCX, the five-part stretch and the packing (host/game_menu_art.h); with + # the dump (BBHOST_APP0) every piece of menu/common.tpf.dcx too. + add_executable(game_menu_art_test tests/game_menu_art_test.cpp src/host/game_menu_art.cpp) + target_include_directories(game_menu_art_test PRIVATE src) + target_compile_definitions(game_menu_art_test PRIVATE BBHOST_GAME_MENU_ART_NO_FS=1) + target_link_libraries(game_menu_art_test PRIVATE ZLIB::ZLIB) + add_test(NAME game_menu_art_test COMMAND game_menu_art_test) # Mouse sensitivity's scale and the old scale's settings read on it # (engine/mouse_camera_step.h). add_executable(mouse_sensitivity_test tests/mouse_sensitivity_test.cpp) @@ -1201,6 +1309,9 @@ if(UNIX) bbhost_decomp_test(item_lots SOURCES src/core/thunk.cpp src/core/portable.cpp src/hle/sysv_va.cpp src/host/main_wait.cpp) bbhost_decomp_test(talk_evaluator SOURCES src/engine/esd.cpp LIBS gcn) bbhost_decomp_test(chalice_ritual) + # Scaleform's font-handle set: the removal by pointer (engine/font_handle_set.h) against the game's + # HashSet RemoveAlt on sets its own add builds - the same bytes with one entry a key, the right entry with two. + bbhost_decomp_test(font_set_removal SOURCES src/engine/font_handle_set.cpp) bbhost_decomp_test(follow_camera SOURCES src/decomp/camera/follow_camera.cpp src/engine/mouse_camera_stubs.cpp ARGS 2000) bbhost_decomp_test(sfx_ribbons SOURCES src/core/write_watch.cpp) bbhost_decomp_test(sfx_step_gate SOURCES src/decomp/sfx/node_update.cpp src/decomp/sfx/node_emit.cpp) @@ -1506,7 +1617,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_CROSSCOMPILING) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} # The official plugins too: the package carries them, and a CI build makes # nothing it is not asked for (v0.2.0's Windows zip shipped without them). - DEPENDS bbhost bb_plugin_randomizer bb_plugin_boss_rush bb_plugin_mutators bb_plugin_quake bb_plugin_lohit bb_plugin_ps1 bb_plugin_iso bb_plugin_debug_menu + DEPENDS bbhost bb_plugin_randomizer bb_plugin_boss_rush bb_plugin_mutators bb_plugin_quake bb_plugin_lohit bb_plugin_ps1 bb_plugin_iso bb_plugin_hunter_cam bb_plugin_debug_menu USES_TERMINAL) else() add_custom_target(smoke diff --git a/README.md b/README.md index 9a345459..2d0698da 100755 --- a/README.md +++ b/README.md @@ -212,8 +212,10 @@ game's code or data. company logos); the shadPS4 patch list's patches - Kyo's graphics, physics and gameplay patches and his The Old Hunters patch, johnnycoax's Auto-Refill, Imedved's camera auto-rotation and Lance McDonald's region unlock (shipped as - patch files); and Kyo's 60 FPS++ timing list and yogesh1239's high-FPS fixes - (built into the frame-rate code). + patch files); Kyo's 60 FPS++ timing list and yogesh1239's high-FPS fixes + (built into the frame-rate code); and Nox-'s + [bbphoto](https://github.com/Noxde/bbhost-photo-mode-plugin), for which the + plugin API's camera, world, input and picture calls were made. - [shadPS4](https://github.com/shadps4-emu/shadPS4), a reference for the PS4's system behaviour and a working run to compare against. - SDL3, Vulkan, FFmpeg, SPIRV-Tools, the DirectX Shader Compiler (DXC), diff --git a/bbhost.example.toml b/bbhost.example.toml index 30e06287..224d1b07 100755 --- a/bbhost.example.toml +++ b/bbhost.example.toml @@ -29,6 +29,10 @@ online_id = "Hunter" # The server's two connection-test ports, at the STUN server's host (the # setup window's Connection card). Default: the server's own, 3479 and 3480. # nat_test_ports = "3479,3480" +# The UDP port other players reach this PC on (P2P): the port to forward on +# your router for direct connections (the setup window's Connection card sets +# it, 1024-65535). Two copies of bbhost on one PC need different ports. +# p2p_port = 9307 # true: the game is signed out until this PC is signed in on the F10 # screen (Account section), and the account's name is the online id. The # live server plays only with signed-in players. @@ -182,7 +186,7 @@ all_post_processors = false # [patches] # The patch manifests (patches/*.toml, a mod's /patches), by name: every # shipped one is off until true puts it in. The setup window's Patches tab -# writes these; a manifest tied to a setting (skip-intro, debug-camera, ...) +# writes these; a manifest tied to a setting (skip-intro, performance-mode, ...) # follows that setting instead. # fov-uncap = true diff --git a/docs/area-check.md b/docs/area-check.md index c9e6e79c..c017d8dd 100644 --- a/docs/area-check.md +++ b/docs/area-check.md @@ -149,8 +149,8 @@ a player has it: the swapchain, the window's size and the present's scaling. `bbhost-options.toml`, as the in-game PC menus write it). Together they act out a player's setup - for the render below the display that many players run, an Xvfb at 2560x1440 with `resolution = "1920x1080"` and `window_mode = -"Borderless"`: the scene in a target of its own, FSR 1 bringing it up at the -present (with Upscaling TAA, the render-scale path). A private Xvfb has no +"Borderless"`: the game at the screen's size and its 3D at the Resolution (the +render-scale path, with Upscaling Off as with TAA). A private Xvfb has no window manager to size a borderless or fullscreen window to the screen, so with `--display` and such a `window_mode` the harness does it with `xdotool` the moment the window is up (xdotool must be installed). diff --git a/docs/decomp.md b/docs/decomp.md index ab88f6ee..158b5877 100644 --- a/docs/decomp.md +++ b/docs/decomp.md @@ -176,7 +176,7 @@ the game's code turning it by the same counts as ours. | Function | Address | What it does | Checked | |---|---|---|---| | flush wait (`sub_15d7030`) | `0x15d7030` | the render thread's wait for the GPU to finish a flush | the same condition, yielding the core instead of spinning on it | -| GX table reclaim (`sub_2aaa860`) | `0x2aaa860` | frees the GX layer's blocks of draw resource tables once the GPU is done with them | the same walk as the game's, plus a wait when a pool runs empty (which used to fail an allocation and black out a frame) | +| GX table reclaim (`sub_2aaa860`) | `0x2aaa860` | frees the GX layer's blocks of draw resource tables once the GPU is done with them | the same walk as the game's, plus a wait when a pool runs empty (which used to fail an allocation and black out a frame); the wait for everything recorded is made outside the renderer's lock, so the command processor records on meanwhile (`BBHOST_GX_CATCH_UP=0`: under it, as a flush) | | GX discard rename (`sub_2ad0d30`) | `0x2ad0d30` | hands a discard Map of a dynamic buffer a renamed copy from GX's upload heap | the game's own function, run again after the GPU catches up when it found no room (which used to fail the Map and light a frame with another frame's constants: the warm-light drop and effect pops under GPU load); `BBHOST_GX_RENAME_WAIT=0` keeps the failure | | pipeline drain (`gx_command_buffer_wait_for_eop`) | `0x2ab09e0` | makes the GPU wait for the work before (a label, an end-of-pipe event and a wait) | written as a barrier token for the command processor instead, which orders its own writes behind it; the same command buffer read and refilled the same way as the game's version, beside it on test buffers (`decomp_gx_drain_token`) | | occlusion query (`gnm_write_occlusion_query`) | `0x1477660` | an occlusion query's begin or end: the block reset, a wait, the counter dumps | written as one query token instead, taken as the renderer's own query; checked in the game by the queries it makes | diff --git a/docs/list-resolve.md b/docs/list-resolve.md index daae9e0f..561376f4 100644 --- a/docs/list-resolve.md +++ b/docs/list-resolve.md @@ -449,6 +449,45 @@ hand-offs - every time another thread takes it while the command processor works costs one wake either way - and the vblank's flip waiter, which takes it some 2,000 times a second, would wait a run each time. +## The run's lookups (`BBHOST_RUN_LOOKUPS`) + +Two lookups the command processor repeats for the in-order draws of a run give +the same answer through the run (`src/host/run_lookups.h`): + +- **The run's publication.** With the pool's segments on, every batched + in-order draw asks `publish_run_targets_locked` to publish its run's targets + for the pool's draws: `names_of` builds a zeroed `GpuDrawInputs` from the + run's lookups, the names are hashed and the set's ways searched - and the way + already holds them. The run's answers (`RunTargets`) carry a version that + `run_targets` moves whenever it refills or drops them. While it stays, the + way the last call took keeps its sequence (only the command processor writes + a way, each write moving it, and one way of a set holds a run's names at + most), the erase generation is the one it was published or found at, and the + publication is no older than `kRtPubAge / 2` flips, the call returns at once: + the condition the full call checks, on the same values. +- **The GX buffer's extent.** Each vertex record whose extent decides something + (the buffer shadow, staging, the race census) asks `gx_buffer_end` for the + end of the GX buffer it starts in: the registry's lock, which every GX Map + takes, and its map walk. The answer is a function of the registry's shape - + its memory index, its holders, and each entry's memory, size, type and + liveness - and is the same over an interval of addresses. Each thread keeps + its last answer with that interval and the shape's generation, which the + registry moves under its lock right after each change of the shape, before + anything in the change that could release a lock or free memory (an erased + node is freed after the move). A thread that has synchronised with a change + reads the moved generation and looks up under the lock. + +`BBHOST_RUN_LOOKUPS=0` looks both up every time; `=compare` looks every memo +answer up as before, returns that, and counts and logs the differences (the +exit report's `run-lookups:` lines). On an RTX 4070 (the 16 places uncapped, +and Old Yharnam, the Nightmare of Mensis, Central Yharnam and Cainhurst's +courtyard held to a 4 GB card's 2,950 MiB) the memo answered 50% of 40.9 +million publications and 94% of 60.6 million extents. Compared there, on an +RTX 3070 Ti Laptop GPU under Windows (the homes on; then the run commit on, +its workers resolving 73% of the draws) and under lavapipe at the 12 places +(the homes off and on), none of 123 million memo answers differed. A Steam +Deck asks neither lookup (no pool, no buffer shadow, no staging). + ## The draw's own context (`BBHOST_DRAW_CONTEXT`) The first step of committing per run: what a draw allocates, taken through an @@ -733,6 +772,9 @@ on the live save), 182.4 and 177.4 off against 182.0 and 184.5, and 200.9 on. tracking (`list_resolve::run_serial`, which the per-run commit will start from). On by default (since 2026-11-11; before, only with the run commit - Windows' default - and the constant buffers' homes); `=0` off. +- `BBHOST_RUN_LOOKUPS=0|compare`: the run's lookups above - the publication and + the GX buffer's extent answered from the lookup before. On by default; `=0` + looks both up every time. - `BBHOST_DRAW_CONTEXT=chunks|compare`: the draw's own context above, with its census and checks. Off by default. - `BBHOST_RUN_COMMIT=fork|on|compare` (`BBHOST_RUN_COMMIT_THREADS`, diff --git a/docs/modding.md b/docs/modding.md index b9338b4e..84c9744e 100644 --- a/docs/modding.md +++ b/docs/modding.md @@ -343,11 +343,20 @@ the Intel SFX workaround, Disable HTTP Requests, Disable Facegen, Enable TAA, Bookmark and Capture outputs, the low-res motion blur buffers). A player who wants one keeps its file in their own patches folder. +The Performance patch (Kyo's Performance Patch v3, Velomap and Decals On) is +built in and always on (`performance = false` under `[patches]` leaves it +out, for a test). It writes the list's sites but five: its camera blur's +force and its Model detail force (the Motion blur and Model detail settings +decide those), and, since v0.2.35, the three that turned the scene +renderer's own depth and G-buffer copies into NOPs (`0x26a10c0`, +`0x26a2829`, `0x26a283f`): SSAO, the sun's shadows, the decals and depth of +field read what those copy, in the views drawn in the renderer's modes that +make them (the world's view fills the same targets with copies of its own). + | File | Patch | |---|---| | `disable-misc-renders.toml` | **Disable Misc. Renders**: Disable Misc. Renders - Kyo's patch: four of the scene's extra targets are not made, nor their passes drawn (off by default; at the next start) | | `fxaa2-gs-dlaa-gs.toml` | **Better AA**: FXAA2_GS + DLAA_GS - Kyo's patch: both anti-aliasing filters (off by default) | -| `text-scale-50.toml` | **50% Text scale**: Smaller text, which looks good at higher resolutions. (off by default) | | `ds1-physics.toml` | **DS1-like physics**: Corpses and objects can be flung around, as in Dark Souls. (off by default; one of object physics) | | `lower-object-physics.toml` | **Lower object/corpse physics**: Corpses resist being moved by the player or anything else. (off by default; one of object physics) | | `disable-camera-auto-rotation.toml` | **Disable Camera Auto Rotation via Movement**: The camera no longer turns by itself as the character moves; turning it by hand and lock-on still work. (off by default; at the next start) | diff --git a/docs/online.md b/docs/online.md index 10f71407..29542692 100644 --- a/docs/online.md +++ b/docs/online.md @@ -59,34 +59,80 @@ The setup window's Game page has a Connection card. **Test connection** checks whether other players can reach this PC directly, or whether its co-op and PvP go through the server's relay. It runs from the game's own P2P port, so it needs the game closed (Play waits for it), and it takes a few -seconds. - -- It sends STUN requests from the P2P port to the server's two test ports - (3479 and 3480 at the STUN server's host; `online.nat_test_ports` for a - server of your own) and reads the public address and port each one saw: - - **Direct connections: yes, your router keeps one port** - the same public - port at both: other players can connect to this PC directly. - - **You'll use the relay: your router changes ports per destination** - a - different port (or address) at each, as symmetric and many carrier-grade - NATs do: a direct connection fails, and the relay carries the session. - - **UDP is blocked on this network** - no answer at all: online play will - not work from this network (a firewall, a VPN, a school or work network). +seconds - up to about six when nothing comes back, sending again meanwhile +so that a security program holding the first packets while it asks about +bbhost.exe does not spoil the result. + +The card says the result in one headline with its status (a check, a +warning or a problem), one sentence on what it means for co-op and PvP, and +the one thing to do when there is something: + +| Headline | What it means | What to do | +|---|---|---| +| **Your network allows direct connections** | the same public port at both test ports, with the relay on (the default): co-op and PvP go through the relay all the same | to connect directly, turn the relay off (the switch under the result) - with incoming closed, after the steps to forward the port; signed out, sign in to play online | +| **Online play works directly** | the same, with the relay off (or on a server without the switch): other players connect to this PC without the relay | nothing; with incoming closed, the steps to forward the port (below) | +| **Online play works through the relay** | a different port (or address) at each, as symmetric and many carrier-grade NATs do: sessions go through the relay, with a little more delay | nothing (not signed in: sign in and test again, so the server knows to relay you) | +| **Something is blocking bbhost** | nothing came back: something on this PC (a firewall or antivirus) or the network stops bbhost's packets or the answers | sign in and test again to find out which - the server tells | +| **Online play is blocked** | signed in, the server saw none of bbhost's packets | allow bbhost.exe in the firewall or antivirus; if the website's test fails too, the network blocks online play (school and work networks can) | +| **Answers aren't reaching bbhost** | the server heard bbhost, but none of its answers came back - most likely a firewall or antivirus on this PC | allow bbhost.exe in the firewall or antivirus | +| **Something on this PC is blocking bbhost** | the system refused every packet bbhost tried to send (a permission error) | allow bbhost.exe in the firewall or antivirus | +| **This PC couldn't send anything** | the system refused every packet for another reason (no network) | check the internet connection, then the firewall | +| **A VPN or proxy may be in the way** | the test ports answered, but the server saw none of it from the address the sign-in came from (a VPN or a proxy for web traffic) | turn off the VPN or proxy | +| **The test was incomplete** | one test port answered: a lost packet, most likely | test again | +| **The game's port is in use** / **The test couldn't use UDP port ...** / **The test server wasn't found** | the test could not run | close the game, choose another P2P port, check the connection | + - **Incoming**, the port check: one more request asks the server to answer from a third port, which the game never sent anything to. When that answer arrives, the router and this PC's firewall let in a packet nobody asked for (a forwarded port, or a router that does not filter by port), so even - players whose routers change ports can connect directly. Closed is common - and fine: those players reach you through the relay instead. A server - without the check says so. + players whose routers change ports can connect directly. Closed, those + players reach you through the relay instead, and the card gives the steps + that let them in: forward the UDP port to this PC in the router's settings + - with the PC's address on its network, the one the test's requests left + from - allow bbhost.exe in Windows Firewall (Private and Public), and test + again. Behind a router that changes ports, forwarding does not help and + the card leaves it out. A server without the check says so. +- **Details** opens the technical lines: the port the test ran from and the + public port the server saw, the port check, when, whether the result was + kept for your account (or is this PC's own reading), the server's verdict + beside this PC's when they differ, refused sends, and the PC's address on + its network. - Signed in, the server classifies what it saw from your address and keeps the result for your account, as the website's account page test does, and a server that relays only the players who need it relays you when the result says so. Not signed in, the card shows this PC's own reading, not - saved. The server takes 10 tests an hour per account. -- The card says what the result means, the port the test ran from, and when - your account's last test ran (also one taken on the website). F10's Game - page repeats the verdict when the setup window opened before the game. The - log has one line per test (`connection test: ...`), with no addresses. + saved. The server takes 10 tests an hour per account. Before a test runs + in this window, the card shows your account's last one (also one taken on + the website). +- F10's Game page repeats the card's headline, in its colour, when the setup + window opened before the game. The log has one line per test + (`connection test: ...`): the result, how many requests went out and how + many the system refused (with its first error), and no addresses. + +### The P2P port + +Under the result, **P2P port** (`online.p2p_port`, 9307 by default) is the +UDP port other players reach this PC on: the one to forward on the router. +It takes 1024 to 65535, not the server's test ports, and not a port another +program has (two copies of bbhost on one PC need different ports). The next +test runs from it at once; Save or Play keeps it, and the game opens it as it +starts, so a change made while the game runs applies from its next start. + +### The relay switch + +Signed in, **Relay** is your account's own setting, the same as the +website's account page has: **On** (the default) works on every network, as +co-op and PvP go through the server's relay; **Off** connects directly, which +needs your router to let other players in. Players who keep the relay still +reach you through it, and everyone who plays from your connection (your home +network) needs it off for it to apply. Turning it off after a test that +showed a direct result with incoming open takes one click; otherwise the +card says why it may not work and gives the port-forwarding steps, and asks +again (**Turn it off anyway**, or **Keep the relay**). Turning it back on is +one click. The change goes to the server at once, and the card reads it back +from the server. With the relay off while other players cannot get in, the +card's headline says so - **Other hunters may not reach you with the relay +off** - with the steps and the switch. ## Beyond the console diff --git a/docs/plugins.md b/docs/plugins.md index 0f6f121b..ac3931e2 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -82,7 +82,7 @@ log line. Everything a plugin logs is prefixed with `plugin:`. The API only ever grows. A plugin checks that `api->version` is at least the version whose calls it makes, and `api->size` for fields a newer host -appended. The current version is 28 (`BB_PLUGIN_API_VERSION`). +appended. The current version is 29 (`BB_PLUGIN_API_VERSION`). ## Addresses @@ -162,12 +162,19 @@ gives the Binary Ninja address. Space, 224 Left Ctrl), the mouse's buttons held and pressed since the last read, its motion in its own counts and the wheel's notches - and `playing`, 1 while the mouse turns the camera (in the world, no menu up). One reader: - the motion, presses and notches are the caller's once read. + the motion, presses and notches are the caller's once read - since v29 + `input_as` gives a plugin reads of its own, and `input` is the read of the + plugins that do not name themselves. - `input_take(scancodes, n, buttons, wheel, motion)`: while the player is playing, those keys and mouse buttons stop pressing what they are bound to, the wheel's notches stay out of the game, and the mouse stops turning the game's camera - the plugin reads them all through `input`. The menus keep - every key. A call replaces the last; nothing taken gives everything back. + every key. A call replaces the last; nothing taken gives everything back, + but a key held then stays taken until it is let go (since v29), so the + game never sees it go down, while a key a call leaves out as it goes on + taking others is the game's again at once. Since v29 this is the take of + the plugins that do not name themselves: `input_take_as` gives a plugin a + take of its own, and the takes add up. - `on_camera(fn, user)`: each frame once the game has placed the player's camera - the follow camera's update and the camera manager's blend of the cameras it owns - and before the scene is drawn from it or a scripted camera @@ -180,7 +187,9 @@ gives the Binary Ninja address. into the scene's, before a scripted camera replaces it: what `fn` writes is drawn, while the game's own camera - which the follow camera keeps, the controls move by and the aim reads - stays as `on_camera` left it. The - Isometric plugin draws its view this way. + Isometric plugin draws its view this way. Since v29 it is not called during + a cutscene (`cutscene()`), and a view it changes is another camera's picture + to the other plugins (`world_state`'s `BB_WORLD_VIEW`). - `on_camera_target(fn, user)` (v28): the recompiled follow camera's target. Registered once, from `bb_plugin_image`; on the game thread at each of the camera's updates `fn` gets the character whose controls the camera uses and @@ -190,6 +199,155 @@ gives the Binary Ninja address. camera this way; where the game's own follow camera runs instead of the recompiled one, a plugin still needs its own camera hooks. One plugin owns it: 1 outside image setup, for NULL, or once taken; 0 otherwise. +- `cutscene()` (v29): 1 while one of the game's cutscenes is asked for or + playing. The cutscene places the hunter and the camera itself, so a plugin + that moves either, hides the body, holds its gravity or takes the controls + gives them back for its length and takes them up again from wherever the + cutscene leaves the hunter (Quake, Hunter Cam and Isometric do). `on_view` is + not called during one; `on_camera` still is. + +**The world held still, the controller, who else is in the world, the HUD, the look and a panel** (v29) + +What a photo mode needs: the world stopped while its own camera flies, the +controller read as the plugin's own while the game reads none of what it +takes, a way to know that nobody else is in the world, the HUD out of the +picture, a look of its own over the area's, and a panel of its settings +over the game. + +- `world_pause(name, paused)`: holds the world - its characters, physics, AI, + events, effects and cloth - while frames go on being drawn and `on_view` + goes on being called. It is the game's own pause, the one it holds while it + leaves a world, taken at the world's next update. `name` is the plugin's + `BbPluginInfo` name; the world is held while any plugin asks. A load lets + every hold go, so a world never starts held, and so does turning the plugin + off. `set_time_scale` cannot do this: it stops at 0.1, and at frame rates + above 30 what the game counts in frames keeps real time. +- `world_step(name, updates)`: while the plugin holds the world, that many + more updates run, one a frame, and then it is held again - a frame advance. +- `pad(&pad)`: the controller as `BbPad` (set `pad.size` first): its own + buttons as `BB_PAD_*` bits, whatever the player's bindings make of them in + play, the sticks from -1 to 1 with the player's dead zones applied, the + triggers from 0 to 1, and the presses since the last frame, latched so that + a press shorter than a frame still counts - the same for every plugin that + reads in that frame. `play` is the held buttons as what they press in play + under the player's bindings (Key Bindings' controller column), for controls + that follow the game's own: photo mode's L3 is whichever button presses the + game's L3. From the main thread (`on_frame`). While bbhost's own menus, a + binding being chosen or a text box have the controller, nothing reads as + held. A test's taps (`BBHOST_AUTOPRESS`, the `tap` request) count as the + controller's. +- `pad_take(name, buttons, axes)`: the game reads those buttons (the + controller's own) let go and those axes (`BB_PAD_LEFT_STICK`, + `BB_PAD_RIGHT_STICK`, `BB_PAD_TRIGGERS`) at rest - whatever they are bound + to in play is not pressed - while `pad` still reads them. Keys are + `input_take_as`'s. Each plugin's take is its own and the game loses what any + plugin takes; a call replaces the plugin's last. `0, 0` gives its buttons + back, but a button held then stays taken until it is let go, so the game + never sees it go down; a button a call leaves out as it goes on taking + others is the game's again at once. Turning the plugin off gives its take + back. +- `input_take_as(name, scancodes, n, buttons, wheel, motion)`: `input_take` + for the plugin named `name`. The plugins' takes add up, each call replacing + only that plugin's last, so a plugin giving its keys back leaves another's + taken - photo mode ending leaves the Quake plugin's movement keys and mouse + its own. `input_take` is the take of every plugin that does not name + itself. Nothing taken gives the plugin's back, but a key held then stays + taken until it is let go; a key a call leaves out as it goes on taking + others is the game's again at once (the Quake plugin's movement keys on a + ladder). Turning the plugin off gives its take back. +- `input_as(name, &in)`: `input` for the plugin named `name`: the presses, + motion and wheel since that plugin's own last read, so plugins reading every + frame never take them from one another - photo mode looking for P each frame + leaves the Quake plugin's mouse look whole. `input`'s are the read of every + plugin that does not name itself; a plugin's first read starts its count. +- `world_state(&state)`: `BbWorldState` (set `state.size` first). `flags`: + `BB_WORLD_IN` (a world is loaded and running, or held), `BB_WORLD_LOADING`, + `BB_WORLD_CUTSCENE` (one plays or is queued), `BB_WORLD_MENU` (one of the + game's menus or dialogs has the controls, its debug menu included), + `BB_WORLD_PAUSED` (a plugin holds + the world), `BB_WORLD_VISITING` (the player is in another player's world or + on the way there), `BB_WORLD_OPEN` (the world's own session is up: + players matched to it, or in it - a bell rung alone does not open it; the + game makes the session when matchmaking finds a player) and `BB_WORLD_VIEW` + (another camera has the picture: a plugin's `on_view` moved the view this + frame or the last - a plugin's free camera - so a plugin whose own camera + is not the one drawn can give the hunter back to the game meanwhile; a + plugin that moves the view itself sees its own). `others`: other + players' characters in this world now - co-operators, invaders, the host one + visits. `arriving`: players on their way in - members of the world's session + or of its matchmaking room who are not in the world yet, counted from the + server's word that one joined the room. `session`: the game's own session + role (`BB_SESSION_*`). +- `hud_hide(name, hidden)`: the game's HUD, menus and prompts left out of the + picture. The game draws them as always; they are left out where the + picture is put together for the screen - the point frame generation takes + its picture without the HUD from - so nothing of the game's own state + changes, and its HUD option keeps its value. bbhost's overlay and menus are + drawn as always, and so is a plugin's menu in the game's dialog: while one + is up, the game's HUD option is held off instead, and prompts may show. The HUD is left out while any plugin asks; turning the + plugin off lets go. It costs two copies of the picture a frame while on. + `hidden` -1 asks for the HUD shown instead, even where the player's own HUD + option hides it: the option is held on while any plugin asks so (and none + asks for the HUD left out) and is the player's again once none does. A + plugin's ask replaces its last. +- `post_look(name, &look, &available)`: the picture's look over the area's + own, as `BbLook` (set `look.size` first): the groups in `set` apply - tone + (exposure, gamma, saturation, brightness and contrast, each times the + area's; the exposure is the eye adaptation's target while it adapts, the + fixed exposure otherwise), the vignette's power, depth of field (off, or on + with a focus distance, an aperture and the blur's levels in front of and + behind the focus - the lens's blur, in place of the area's own distance + ramps while it is on; with `BB_LOOK_DOF_RANGE` as well, the blur placed by + distance instead, as the areas' own is: sharp from `dof_near_end` to + `dof_far_start` metres, the blur in front full `dof_near_fade` metres + nearer and the blur behind full `dof_far_fade` metres further, each as + strong as its levels say), chromatic aberration (off, or on with its + lateral and uniform dispersions), motion blur (off, or on with its times, scale and + samples - 2 to 8, the most the game's motion blur has shaders for, and 7 + where the area interleaves its samples, which makes 8 a 9) and the fog (its + distance, density and contrast times the area's, its distance and height + offsets added) - and the rest stay the area's. It is + written every view into the numbers the area gives the post-processing and + the fog, so nothing of the game's is kept or put back: `NULL` or `set` 0 is + the area's own from the next frame. One look for all plugins - the last + call's - and turning its plugin off takes it away. Depth of field and motion + blur show while the look sets them on whatever the Graphics settings say, + and are left out while it sets them off; Performance mode jumps past every + depth of field pass and leaves the scene's motion blur off, so `available` + (may be `NULL`) leaves those two out then. Values outside what the post + effect takes are clamped. +- `panel_show(name, &panel)`: the plugin's panel up (`BbPanel`) or down + (`NULL`). Its pages are the plugin's own options table: a `BB_OPT_HEADING` + with `BB_OPT_PANEL` or-ed in starts a page, the rows under it up to the next + heading are on it, and neither shows in the menus. It is an in-game menu + (see [In-game menus](#in-game-menus-v29)): pages of the game's own options + dialog - its rows, cursor, sounds, line help and key guide, read from the + player's dump (nothing of it is shipped) - at the dialog's place with the + screen dimmed behind it, or smaller at the bottom right with + `BB_PANEL_CORNER`. Its rows' changes go to `on_option` as the menus' do (so + its rows want `BB_OPT_LIVE`); the line help shows the first sentence of the + row's help, then `guide` or `guide_keys` - whichever device the player used + last. The controller drives it (the d-pad up and down to a row, left and + right to change it, Cross to set a switch or press a button, L1 and R1 the + pages, Circle goes back or closes it), as do the keyboard (the arrows, + Enter, Page Up and Page Down, Escape or Backspace) and the pointer. While a + centred menu is up neither the game's play nor the plugins read the + controller, the keyboard or the mouse; while a corner one is, only what the + dialog moves by, and everything else is as it was. Where the game cannot + open its dialog, the host draws the same pages in a panel of its own. + `BB_PANEL_DEFAULTS` ends each page with a Defaults row. One panel at a time; + turning the plugin off takes it down. +- `panel_state(name, &state)`: `BbPanelState` (set `state.size` first) - + whether the panel is up, whether the player closed it (Circle, Escape) since + the last call, and the page shown or shown last, by its heading's key. +- `option_set(name, key, value)`: one of the plugin's options set as the menus + set it - kept in the player's config, and handed to `on_option` from the + next frame - for a row the plugin changes itself (a mode it always starts + in). +- `panel_rows(name, page, rows, n)`, `panel_value(name, page, key, value)`, + `panel_open(name, page)`: a menu page's rows set at run time, one of their + values, and a page opened on top of the one shown - see + [In-game menus](#in-game-menus-v29). **Settings, UI and files** @@ -422,6 +580,190 @@ only meet others with the same rules. `set_rules` updates the plugin's entry plugin flagged `BB_PLUGIN_ADOPTS_RULES` play by a host's rules when summoned into another player's modded world. +## In-game menus (v29) + +A plugin can have menus that are the game's own: pages of its options dialog, +with its rows, cursor, scrolling, sounds, line help and key guide - the +machinery bbhost's PC Settings pages use, read from the player's dump +(nothing of the game's is shipped). A menu is pages of the plugin's options +table, and a page is a `BB_OPT_HEADING` with `BB_OPT_PANEL` or-ed in and the +rows under it, up to the next heading. Those rows are not in the settings of +the in-game plugin menu (F10); the menu shows them. + +**Declaring menus.** `BB_OPT_MENU` on a page's heading starts a menu, named +by the heading's `def` (its label when `NULL`); the pages after it, up to the +next `BB_OPT_MENU` heading, are that menu's, in L1/R1 order. For each named +menu the plugin's entry in F10 has an *Open* button, and the game's System +menu has a *Plugins* row (beside PC Settings) that lists every turned-on +plugin's named menus - so a plugin needs only its table to have a menu: no +input code. A plugin with no `BB_OPT_MENU` heading has one unnamed menu of +all its pages and no button; it shows it itself with `panel_show` (photo mode +does, on L3). `BB_OPT_SUBPAGE` on a page's heading keeps it out of the L1/R1 +order: it is opened on top of another page, by a row or by `panel_open`. + +**The rows.** Each row is one of the dialog's own: + +- `BB_OPT_BOOL`: the game's On/Off row. +- `BB_OPT_CHOICE`: of two choices, the game's left/right pair; of more, a row + whose value Left and Right step through (wrapping). +- `BB_OPT_INT`, `BB_OPT_FLOAT`: the game's slider. An INT from 0 to 10 is the + game's own slider; any other range has one position a step - 1 for an INT, + a hundredth of the range for a FLOAT - its bar at the value's share of the + range and its number the host's (a FLOAT to its step's decimals). Left and + Right step it, held they repeat. +- `BB_OPT_INFO`: a label and a value the player cannot change (`def`). +- `BB_OPT_ACTION`: a button; Cross presses it. +- `BB_OPT_ACTION | BB_OPT_OPEN`: the button opens the page named by its `def` + on top of the one shown and calls `on_action`, which can fill that page; + Circle there comes back to the button. +- `BB_OPT_ACTION | BB_OPT_CONFIRM`: the host asks first, in the game's yes/no + dialog ("*label*?", the first sentence of the row's help under it); + `on_action` comes only on Yes. +- `BB_OPT_TEXT`: Cross or Enter opens the host's text box (the one the game's + name and glyph dialogs use) with the row's label and value; Enter accepts and + Escape cancels. A keyboard types in it; a controller alone can only accept + or cancel it, as with the game's own name dialog. +- A row whose `BB_OPT_WHEN` is not met is shown dimmed and does nothing. + +A page of more than eight rows scrolls. The game's fields hold about 24 +characters of a label and 18 of a value; longer ones are set smaller to fit, +so keep them short. A row in the table is a setting: the config keeps it, and +its changes come to `on_option` with its key, as the F10 settings' do. + +**The help line.** The dialog's line help is one line under the rows: the +cursor's row's help, **its first sentence** (up to the first `.`, `!` or `?` +followed by a space), cut at a word with `...` when it does not fit, then the +menu's guide. The line holds about 68 characters inside the dialog's frame, +the guide's included, so give each row a short first sentence that says what +it does, and the details after it: F10 and the host's own panel show the +whole help. + +**Rows set at run time.** `panel_rows(name, page, rows, n)` gives `page` rows +of the plugin's own from then on - a list (lamps, items, saves), info, or +anything that is not a setting - copied by the host, strings too; `n` 0 +gives the page its table rows again. The page must be a page of the table, +which gives its title, help and menu. These rows are never in the config: a +change comes to `on_option`, and a press to `on_action`, with the key +`"/"`, so the plugin knows the page it came from. +`panel_value(name, page, key, value)` sets one of their values while the +menu is up or not. `panel_open(name, page)` opens a page on top of the one +shown - from `on_action`, say, after filling the page with one item's +details. + +**Showing a menu.** The System menu's *Plugins* row, F10's *Open* button, or +`panel_show(name, &panel)` from the plugin's own key or button, at the title +or in the world. `BbPanel.page` is the page to start at (`NULL`: the one shown +last); `pages` and `page_count` name the pages of the menu in L1/R1 order when +they are not the table's; `guide` and `guide_keys` the hint after the help on +the help line, for the controller and for the keyboard - keep them short +("L1 R1: page R3: show"); without them the host puts the menu's page keys +there when it has more than one page. Without `BB_PANEL_CORNER` the menu is +the game's dialog at its normal place, the screen dimmed behind it. With it, +the dialog is smaller at the bottom right and leaves the world in view (photo +mode's). `BB_PANEL_DEFAULTS` ends each page with a Defaults row. Where the +game cannot open its dialog - another eboot, a dump the options movie could +not be made from, a moment its menus stay locked - the host draws the same +menu in a panel of its own instead (logged once). + +**The rules.** + +- One menu at a time: a `panel_show` from another plugin replaces it, and a + new one starts its pages again. +- L1 and R1 (Page Up and Page Down, or the player's Menu Previous and Next + Page keys) turn the menu's pages; Circle (Backspace, Escape) goes back from + a page opened on top, and on a page of the menu closes it, which + `panel_state` reports as `closed`. +- Input: while a centred menu is up neither the game's play nor any plugin + reads the controller, the keyboard or the mouse, and what is held as it + closes stays out of both until let go. A corner menu takes only what the + dialog moves by - the d-pad, Cross, Circle, L1 and R1; the arrows, Enter, + Backspace, Escape and the page keys - and gets them even when the plugin + takes the controller from the game; the sticks, the triggers and the other + buttons and keys stay the plugin's (`pad`, `input`). The pointer works the + rows as it does the game's own settings. +- `world_state` does not count a plugin's menu as one of the game's. +- A menu shown over the title's holds that one - no input, out of view - + until it is gone, as the game does when it opens a menu from another. One + shown over a menu of the game's in the world takes that menu's place, as + the game's own menus do, and closing it leaves the player in the world. + The overlay (F9, F10) opens over a menu and hides it until it closes. +- The game's own interruptions close a centred menu: a loading screen coming + up (lamp travel, the one after a death), a cutscene starting, or the + player's character dying. `panel_state` then reads `shown` 0 and `closed` + 1, as when the player closes it, and a text box or a yes/no open on it goes + with it. One already under way when the menu opens (a load, a cutscene, the + death's screen) leaves it up. A corner menu stays: the plugin takes it + down when it should (photo mode ends itself at a load or a cutscene). + When the game closes its menus itself under a corner menu - a load, or + frame after frame while the hunter is dying - the host brings the corner + menu back as soon as the game lets it; where the game keeps closing them, + will not take one back within a second, or takes the menu a third time in + ten seconds, it draws the menu itself until it is next shown. The plugin + sees it up throughout. +- The world keeps running while a menu is up, unless the plugin holds it with + `world_pause`; the menu works either way. +- Turning the plugin off takes its menu down. + +The example below is `examples/plugins/menu/menu.c`, built with bbhost as +`build/menu.so` (`menu.dll`); copy it into a `plugins/` folder and open its +menu from F10: + +```c +/* An in-game menu (plugin API 29): a counter with two buttons, in the game's + * own look. Its table names the menu, so the in-game plugin menu (F10) has an + * "Open Counter" button for it: the plugin has no input code at all. */ +#include "bbhost_plugin.h" + +#include +#include + +static const BbHostApi* api; +static int count; + +/* The page's rows, set at run time: they are not settings, so the host keeps + * them for the menu and never writes them to the config. */ +static void fill(void) { + char text[16]; + snprintf(text, sizeof(text), "%d", count); + const BbOption rows[] = { + {BB_OPT_INFO, "count", "Count", "How many times Add one was pressed.", text}, + {BB_OPT_ACTION, "add", "Add one", "Adds one to the count."}, + {BB_OPT_ACTION | BB_OPT_CONFIRM, "reset", "Reset the count", "The count goes back to 0."}, + }; + api->panel_rows("menu", "counter", rows, sizeof(rows) / sizeof(rows[0])); +} + +/* A run-time row's button comes back as "/". */ +static void on_action(const char* action, void* user) { + char text[16]; + (void)user; + if (strcmp(action, "counter/add") == 0) count += 1; + else if (strcmp(action, "counter/reset") == 0) count = 0; + else return; + if (strcmp(api->config("menu.loud"), "true") == 0) api->log("menu: %s, the count %d", action, count); + snprintf(text, sizeof(text), "%d", count); + api->panel_value("menu", "counter", "count", text); +} + +BB_PLUGIN_EXPORT const BbPluginInfo bb_plugin_info = { + BB_PLUGIN_API_VERSION, 0, "menu", "Menu example", "1.0.0", "bbhost", "An in-game menu in the game's look."}; + +/* A setting, kept in the config and shown with the plugin in the overlay; then + * the menu: one page, named Counter, its rows filled at run time. */ +BB_PLUGIN_EXPORT const BbOption bb_plugin_options[] = { + {BB_OPT_BOOL | BB_OPT_LIVE, "loud", "Log each press", 0, "false"}, + {BB_OPT_HEADING | BB_OPT_PANEL | BB_OPT_MENU, "counter", "Counter", "Press Add one, or Reset.", "Counter"}, + {0}}; + +BB_PLUGIN_EXPORT int bb_plugin_image(const BbHostApi* host) { + if (host->version < 29 || host->size < sizeof(BbHostApi)) return 1; /* panel_rows arrived in 29 */ + api = host; + api->on_action("menu", on_action, 0); + fill(); + return 0; +} +``` + ## Rendering effects (v27) A plugin can draw effects of its own into the frame - ambient occlusion, @@ -670,9 +1012,11 @@ setup window can download the latest signed plugins from the newest release. | `randomizer` | Shuffles one-time pickups and shop stock from a seed, and optionally enemies: each regular enemy becomes another kind (model, AI and gear together), drawn from its own area or from the whole game, with optional roaming bosses. Writes a spoiler file. | | `boss_rush` | Fights the 19 story bosses back to back, optionally with the ten chalice-dungeon bosses, starting each round outside the boss's fog wall. Tracks time and deaths. Practice fights one boss, picked by name, again and again: once, N times, or until stopped, a death trying again from the fog wall and a win waking the boss for the next fight. Each fight that ends in a win or a death is an attempt, so Once and N times end after that many attempts; Restart starts the fight under way over from the fog wall without counting it. With Refill on, every attempt starts with the most blood vials and quicksilver bullets. A practice can start each fight at the boss's phase 2 or 3: once the fight begins, the boss is put just under the HP at which its own event script or AI changes phase, and the game plays the change itself (Ludwig's cutscene and Holy Blade, Gascoigne's beast, Lady Maria's blood and fire). Attempts, wins, deaths, the best and last clear times and, from phase 1, the time to phase 2 are shown after each fight and written to `results.txt`. Boss HP and Your HP are practice's cheats, for learning a fight: Can't die keeps hits taking HP down to 1 and no further (the debug menu's No Dead), and Infinite also puts the HP back after every hit, so the boss stays in the phase its fight began in and the player stays at full health. A boss that cannot die is not defeated, so its fights end in a death, a Restart or Stop. | | `mutators` | Switchable rules: gravity, game speed, bullet time at low HP, one-hit deaths, blood drain, enemy HP, echo rate, random effects. | -| `quake` | Off until turned on. First person with Quake 3's movement and view: strafe jumping, bunny hopping (hold jump to keep hopping), crouching, the walls only characters meet (the invisible ones along ledges) as solid as the rest, creatures as solid as Quake 3's players, and a choice of physics - Quake 3 (VQ3, the default), CPMA, Quake 1 + CPMA, QuakeWorld and DeFRaG's. Five guns made of Bloodborne's (Cannon, Church Cannon, Piercing Rifle, Blunderbuss, Gatling Gun), always +10, firing from the view with each gun's own flash and sound: rockets and grenades at Quake 3's speeds (the grenade bouncing until its fuse), the Blunderbuss's and the Gatling Gun's own bullets, and a plasma of A Call Beyond's star or Blacksky Eye's shard; their blasts throw the player (rocket and grenade jumps, plasma climbing), and the gun that is up is drawn at the lower right with Quake 3's bob and kick. Field of view, mouse sensitivity, gravity and knockback are settings. | +| `quake` | Off until turned on. First person with Quake 3's movement and view: strafe jumping, bunny hopping (hold jump to keep hopping), crouching, the walls only characters meet (the invisible ones along ledges) as solid as the rest, creatures as solid as Quake 3's players, and a choice of physics - Quake 3 (VQ3, the default), CPMA, Quake 1 + CPMA, QuakeWorld and DeFRaG's. Five guns made of Bloodborne's (Cannon, Church Cannon, Piercing Rifle, Blunderbuss, Gatling Gun), always +10, firing from the view with each gun's own flash and sound: rockets and grenades at Quake 3's speeds (the grenade bouncing until its fuse), the Blunderbuss's and the Gatling Gun's own bullets, and a plasma of A Call Beyond's star or Blacksky Eye's shard; their blasts throw the player (rocket and grenade jumps, plasma climbing), and the gun that is up is drawn at the lower right with Quake 3's bob and kick. Field of view, mouse sensitivity, gravity and knockback are settings. While another plugin holds the world, or its camera has the picture (a free camera's, the world held or running), Quake holds too: the player stays where they were and the view as it was, and the keys and the mouse fly that camera alone. | | `lohit` | Off until turned on. The map's lo-hit collision drawn in place of the map's own geometry (the game's own WorldHitMan debug draw, with GROUP MASK > Map off): every part loaded (Whole map, the default), or the part you stand on and the parts connected to it, one step out; Hi-hit shows the detailed collision characters and objects use instead. Each mesh is built once into a vertex buffer of its own and drawn with two draws a frame, where the game's debug draw rebuilt every triangle each frame and copied it twice (the triangles' edges the game drew over the faces, a second draw costing the GPU more than the faces, are left out). Its depth (plugin API 17) is drawn ahead of the scene's objects too, so the game's occlusion culling skips what is behind its walls, as the map's own geometry would. It is drawn inside the scene ahead of its effects so fire, sparks, blood and mist show over it, by default in the launcher's deep violet (walls) and dark blue (floors); the Colours sliders set both (0-255, as they come out on the screen) for the lo-hit and the hi-hit. Pair it with Performance mode (the setup window's main page) for the post-effects off. | | `ps1` | Off until turned on. Bloodborne PS1: the 3D drawn as the first PlayStation drew it, the HUD and the menus left sharp at the window's size: its vertices snapped to a grid of the screen as it moves (Vertex snap: 240p, the PS1's own screen, by default; 480p, 360p, 120p or off), its textures unfiltered (no bilinear, trilinear or anisotropic filtering), its colour targets 8 bits a channel (8-bit colour, as the rgba8f patch makes them; the colour grading then steps between its table's entries too, where it is smooth without it), and the 3D at its own Resolution - Native (the Resolution setting, at most the window's), 480p, 360p or 240p, each as wide as the window's shape gives - brought up to the window pixel for pixel, with no smoothing. Upscaling and the anti-aliasing stand aside while it is on. Old-hardware sound (off by default) makes everything the game plays sound like an old console's sound chip: PS1 (22050 Hz, 12 bits, muffled above 10 kHz), Crunchy (11025 Hz, 8 bits, no low-pass going in, so it aliases) or Custom (a rate and bits of its own). Each option changes in the game (F9). | +| `hunter_cam` | Off until turned on. Hunter Cam: the hunter from closer in. Over the shoulder: a close third-person camera over the right or left shoulder, as Silent Hill 2's remake frames its hero, pulled in at walls by the game's own sphere cast, with a key that swaps shoulders while playing (Tab by default), the wheel zooming it and the middle button resetting the zoom. First person (Z toggles it): the view from the hunter's eyes with only their gloves (the arm armour) and weapons drawn, Head bob riding the view on the head's bone, the mouse turning it and the view free to look 80 degrees up and down (the game's aim stops at 35 and 40; Look up/down limit sets it). Only where the camera stands moves: the stick, the lock-on and the aim keep the game's turning; Right stick speed multiplies it. Always face the camera keeps the hunter facing where the camera looks (the monocular's precision-shooting state) while the script is answered as locked on, so they strafe, run and sprint at full speed; X still opens, picks up and talks there, items (Blood Vials, papers, tools) take effect, the mouse turns the view (its own sensitivity and Y reverse), and Crosshair shows or hides the monocular's sight. Dodge is a slider: 0 always the roll, locked on too, and the stick's way while facing the camera or in first person; 1 a sidestep in the stick's direction (the omni-roll); the Modern Movement Lite patch keeps working beside it. Distance, side offset, height, eye height, fields of view (+% wider, as F10's Field of view) and swap time are settings, all live. During a cutscene, and while another plugin's camera has the picture (a free camera's), the camera, the facing and the body are the game's again - that camera's pictures show the whole hunter - and its keys and the mouse do nothing; Hunter Cam takes them up again after. | +| Photo mode | Not one of bbhost's plugins: Nox-'s [bbhost-photo-mode-plugin](https://github.com/Noxde/bbhost-photo-mode-plugin) carries on bbphoto, the photo mode plugin API 29's calls were made for - the world held still and stepped, the controller and the keyboard read as its own, the HUD left out of the picture, a look over the area's own and its settings as the game's own dialog at the bottom right. A `photo_mode` plugin in a plugins folder, not switched off (`photo_mode = false` under `[plugins]`), keeps bbhost from loading bbphoto beside it, so the two never both answer L3 and P. | | `debug_menu` | Restores the developers' debug menu (`` ` `` opens it), in English or the developers' Japanese, and makes the debug font it draws with from the public-domain X11 fonts k14 and 7x14, so nothing has to be downloaded. Cheating against other players with it gets an account banned; trying it out online with friends is fine. | The gameplay plugins - all five - announce themselves in the session's diff --git a/docs/rendering.md b/docs/rendering.md index a15c6641..56ecf2b0 100644 --- a/docs/rendering.md +++ b/docs/rendering.md @@ -440,11 +440,30 @@ path at all: - YEBIS, the post-processing library (bloom, glare, depth of field, tone mapping): every stage's resources and constants are built by bbhost. + Its depth of field blends each blurred level in by the circle of + confusion in pixels, which grows with the picture, against an offset that + does not. A blur drawn with several levels keeps its look by itself, as a + growing circle moves on to the next, larger level (the cutscenes, a + plugin's lens), but the areas' own faint far blur has one level, so it + faded out below 1080 lines and grew above them. On a side drawn with one + level the offset now scales with the picture's height over 1080, which + keeps the 1080-line look at every Resolution; with an upscaler the height + is the picture's, the one YEBIS works at. - Scaleform, the menu renderer: its draws are taken from its hardware abstraction layer. - Depth snapshots, the on-screen overlay and FSR 1 upscaling are bbhost's own. The depth snapshot's compute pass goes into the recorder's stream (`BBHOST_STREAM_DEPTH_COPY=0` records it in place, draining the recorder). + The scene's own depth copy is one: after the G-buffer the game copies its + depth into DepthRenderTarget (and its first G-buffer target, the normals, + into GBuffer0), which SSAO, the sun's screen-space shadows, motion blur's + and screen space reflections' smaller depths, the decals, the forward + passes and depth of field read. The world's view makes them with + CopyResource; the renderer's two other modes make them with three calls of + their own (`0x26a10c0`, `0x26a2829`, `0x26a283f`), which the built-in + Performance patch turned into NOPs until v0.2.35 - calls the world's view + never makes, so leaving them out changed nothing there; only a view drawn in + those modes read targets nothing had written that frame. ## Native or emulated @@ -870,6 +889,14 @@ pool's constant-buffer copies take the last 16 MiB of the command processor's ring, which keeps the rest while the pool runs, so on a card with a small window of video memory the CPU writes both stay in video memory (in host memory the GPU read them across the bus: +11% GPU time on an RTX 4070). +Their tables - the vertex and resource tables a draw's user data points at - +take the last 16 MiB of GX's tables ring in the same way, in 1 MiB segments a +pool thread owns while it places there, each taken again only once no commit +placed in it can still be spliced and the recordings its commits went into +have run; the command processor's part of that ring waits, at a lap, for the +recording that last placed in a segment to have run. (Until 2026-11-13 a pool +thread kept a chunk of the shared ring until it was full - across a rest at a +frame cap too - and could write over tables the ring had handed out since.) Unset, the switch follows the constant buffers' homes: segments where the homes bind by handle, off elsewhere (small video memory, an integrated GPU) with the reason in the log; the pool needs 8 hardware threads or more. @@ -973,7 +1000,19 @@ waiting 8-15%), where it used to work on for good, it tries a rest - the switch's 1.5 s, then 1-1.5 s counted - and keeps it where the cap holds the frame without it, else it works again and the next trial waits the cap's backoff), while the frame is the GPU's (busy 90% of two windows, until it is -under 80% over six), and wherever resting costs the frame nothing. That last is +under 80% over six), and wherever resting costs the frame nothing. With no cap +holding the frame, a rest the GPU began is judged by the frame when it ends: +resting 8% slower than the GPU-bound windows that began it, the pool's work was +what kept the frame the GPU's, and that is an experiment's clear answer - the +pool works, and no GPU-bound rest and no probe come for 40 s, then 160, then 240 +(a loading screen starts the place over; at a cap nothing changes). On the RTX +4070 below, uncapped, the Hunter's Dream ran 204-208 fps working with the GPU +91-95% busy and ~170 resting (the command processor the wall, the game held +back 70%), and Cainhurst's courtyard 166-170 and 106-113: the GPU's rest began +after two windows, ended after six and began again two later, ten times in +every 20 s, and the places ran 180-184 and 121-124 fps against 216 and 167 with +the pool never resting. A rest that runs as fast - an APU's frame, the GPU's +either way - is the GPU's as before. That last is measured at each place, both ways: 10 s after the pool began to work there, an experiment rests it for 5.5 s and lets it work for 5.5 s more, and compares the frame rate resting with the windows on either side of it; under 0.5% slower @@ -1242,7 +1281,11 @@ memory at its first use, unless that use is a copy-back over all of it. What reads a home without a handle - a dispatch, a copy, a device address - finds it by address; a CPU copy of its stale guest bytes is refused; a page-table walk that reads it gets it copied back to its memory first, and -it stays the home. A home ends with its buffer, and a buffer made past the +it stays the home. The command processor's index of the homes by address +changes in place, so the draw pool's threads read a copy published for them +instead - the homes touching each 4 KiB page as an immutable list swapped by +pointer, freed once no reader can hold it, a run of changes seen whole or not +at all - and change nothing. A home ends with its buffer, and a buffer made past the pool's budget (128 MiB, `BBHOST_GXVK_HOMES_BUDGET_MB`) takes today's path for its life. Off on an integrated GPU, and with small video memory under 5,000 MiB free at the start unless a budget is given (on a 4 GB card the pool's ~80 @@ -1273,5 +1316,8 @@ another thread before the capture read it. | `BBHOST_VK_VALIDATE=1` | runs with the Vulkan validation layer | | `BBHOST_VA_TRACE=1` | logs every guest-memory import made, put in place, retired and freed, every window whose page-table entries move, every device buffer made through `create_dev_buffer` with its owner and every staging or scratch chunk freed (`va:` lines, the wall clock in seconds and microseconds, to match `journalctl -k -o short-unix`); a device fault report then looks its addresses up in them. `=2` adds the driver's own binds and unbinds where it reports them (VK_EXT_device_address_binding_report) | | `BBHOST_GPU_PROFILE=1` | per-pass GPU timings | +| `BBHOST_GPU_CHECKPOINTS=amd` | the GPU's progress markers (VK_AMD_buffer_marker, which NVIDIA's drivers have too) everywhere, not only while a loading screen is up, as they are by default: two words before each draw and dispatch, and the front end's word before the ops between them where it stops or the pass changes - barriers, pass ends and begins - with every op noted. A lost device then names the draw or dispatch the GPU had started, the op its front end had reached, the ops between the two, and whether a barrier among them says the draw had finished (barriers hold the front end on NVIDIA's and AMD's GPUs; the specification does not promise it); a loss after a loading screen's markers ended says so, and that they were off there. The default's window opens at the first submission recorded once a loading screen is up and closes at the first one 200 ms after it has gone, and nothing of them is written or done in between - in the world they cost frames. `=0` keeps them off in loading screens too; `=after-loss` also marks everything for the three starts after a loss; `=amd-dry` and `=loading-dry` record them, everywhere or in loading screens, on a device without the extension (lavapipe) | +| `BBHOST_GPU_MARKER_OPS=all` | with the markers on, the front end's word before every op between draws: where the front end was held between two barriers shows too, at a cost on NVIDIA's GPUs, where a word between two copies holds them apart | +| `BBHOST_MARKER_TRACE=[:n]` | with the markers on, the ops noted after the first n (4) draws of the pipelines whose name starts with the prefix, and every 300 flips what a lost device would say from the words as they stand | | `BBHOST_UPSCALE_CHECK=4` + `tools/upscale_check.py` | the upscalers' reprojection check, with an upscaler on and `BBHOST_UPSCALE_JITTER=0`: in place of the upscaler's picture, green where the motion explains how the scene changed since the last frame, red where it does not, blue where a surface came from off the screen; every 30 frames the log has red's share of what changed, over the picture and in sixteen bands of its width, and the tool sums it over the windows where the picture moved | | `bbhost --stream-selftest[=N]` | checks the command stream headless against a CPU model, N rounds (16 by default), and exits with 0 when it matched; run it with `BBHOST_VK_VALIDATE=1` too | diff --git a/docs/running.md b/docs/running.md index 8ba4f5ef..856838a4 100644 --- a/docs/running.md +++ b/docs/running.md @@ -45,6 +45,8 @@ Started without a configuration, bbhost opens its setup window: pick the game folder and the eboot (both are checked as you go), choose the online server and account if you want to play online, and press Play. The window writes the per-user `bbhost.toml` and starts the game. `bbhost --setup` opens it again. +Over Play, on every page, **Discord** opens the community's Discord invite and +**Website** opens thehuntersdream.com, each in your browser. The game turns its shaders into HLSL and compiles them on your PC in the background, so you can play straight away; the first session uses the @@ -110,8 +112,15 @@ that cannot move it uses the old folder as it is. ## Saves Saves are in `/saves/SPRJ0005`, where `` defaults to -`%LOCALAPPDATA%\bbhost\data` or `~/.local/share/bbhost/data`. Each time the -game writes a save (at most every five minutes) a copy goes to +`%LOCALAPPDATA%\bbhost\data` or `~/.local/share/bbhost/data`. The game writes +a save into a copy beside it, `.SPRJ0005.stage`, and bbhost then moves the +copy's files into `SPRJ0005` one by one, under a list in `.SPRJ0005.commit` +(on Linux, where the file system can swap two folders in one step, it swaps +them instead). If bbhost ends in the middle, its next start finishes the save +or drops it, so `SPRJ0005` always holds a whole save, the new one or the one +before; leave the copy and the list alone. On Windows the `SPRJ0005` folder +itself never moves, so a File Explorer window open in it stays open. Each time +the game writes a save (at most every five minutes) a copy goes to `/save-backups/`, and the newest eight are kept. To restore one, quit and copy its files over `/saves/SPRJ0005`. @@ -251,9 +260,11 @@ without it: its title screen would otherwise be a flat green picture. **The graphics card stops responding.** When the GPU hangs and the system resets it, nothing can be drawn again in that session; bbhost stops the sound, -says so in a box and exits. The next three starts run with the GPU's progress -markers enabled, so the log of a second hang names the draw that hung - send -that log. Overlays that hook Vulkan are a common cause: OBS's game capture is +says so in a box and exits. Loading screens run with the GPU's progress +markers, so the log of a hang in one names the draw that hung and how far past +it the GPU had got - send that log. `set BBHOST_GPU_CHECKPOINTS=amd` in +run-bbhost.bat (`BBHOST_GPU_CHECKPOINTS=amd` before the command on Linux) +marks the whole game, at some cost to the frame rate. Overlays that hook Vulkan are a common cause: OBS's game capture is kept out automatically on AMD cards (`[video] obs_capture` changes that), and OBS's Window Capture records bbhost without any hook. @@ -731,7 +742,15 @@ GPU for minutes. Graphics > Upscaling (F10, the setup window's Graphics page, or System > PC Upscaling in the game) runs one of these in place of the game's own -anti-aliasing: +anti-aliasing. Whatever the choice, Off included, a Resolution below the +window's draws only the 3D at it: the game, its post effects, the HUD and the +menus stay at the window's size (with Off the game's own copy of the 3D into +its post chain stretches it up). With Off that costs some GPU time on a large +window - the post effects and the HUD are drawn at its size: about 6% uncapped +on a 2560x1600 laptop screen at a 1920x1080 Resolution. +`set BBHOST_RENDER_SCALE=0` in run-bbhost.bat (`BBHOST_RENDER_SCALE=0` before +the command on Linux) goes back to the way before v0.2.35: with Off, the whole +picture drawn at the Resolution and stretched to the window. | Choice | Where it runs | |---|---| diff --git a/examples/plugins/menu/menu.c b/examples/plugins/menu/menu.c new file mode 100644 index 00000000..d9c23bb1 --- /dev/null +++ b/examples/plugins/menu/menu.c @@ -0,0 +1,53 @@ +/* An in-game menu (plugin API 29): a counter with two buttons, in the game's + * own look. Its table names the menu, so the in-game plugin menu (F10) has an + * "Open Counter" button for it: the plugin has no input code at all. */ +#include "bbhost_plugin.h" + +#include +#include + +static const BbHostApi* api; +static int count; + +/* The page's rows, set at run time: they are not settings, so the host keeps + * them for the menu and never writes them to the config. */ +static void fill(void) { + char text[16]; + snprintf(text, sizeof(text), "%d", count); + const BbOption rows[] = { + {BB_OPT_INFO, "count", "Count", "How many times Add one was pressed.", text}, + {BB_OPT_ACTION, "add", "Add one", "Adds one to the count."}, + {BB_OPT_ACTION | BB_OPT_CONFIRM, "reset", "Reset the count", "The count goes back to 0."}, + }; + api->panel_rows("menu", "counter", rows, sizeof(rows) / sizeof(rows[0])); +} + +/* A run-time row's button comes back as "/". */ +static void on_action(const char* action, void* user) { + char text[16]; + (void)user; + if (strcmp(action, "counter/add") == 0) count += 1; + else if (strcmp(action, "counter/reset") == 0) count = 0; + else return; + if (strcmp(api->config("menu.loud"), "true") == 0) api->log("menu: %s, the count %d", action, count); + snprintf(text, sizeof(text), "%d", count); + api->panel_value("menu", "counter", "count", text); +} + +BB_PLUGIN_EXPORT const BbPluginInfo bb_plugin_info = { + BB_PLUGIN_API_VERSION, 0, "menu", "Menu example", "1.0.0", "bbhost", "An in-game menu in the game's look."}; + +/* A setting, kept in the config and shown with the plugin in the overlay; then + * the menu: one page, named Counter, its rows filled at run time. */ +BB_PLUGIN_EXPORT const BbOption bb_plugin_options[] = { + {BB_OPT_BOOL | BB_OPT_LIVE, "loud", "Log each press", 0, "false"}, + {BB_OPT_HEADING | BB_OPT_PANEL | BB_OPT_MENU, "counter", "Counter", "Press Add one, or Reset.", "Counter"}, + {0}}; + +BB_PLUGIN_EXPORT int bb_plugin_image(const BbHostApi* host) { + if (host->version < 29 || host->size < sizeof(BbHostApi)) return 1; /* panel_rows arrived in 29 */ + api = host; + api->on_action("menu", on_action, 0); + fill(); + return 0; +} diff --git a/include/bbhost_plugin.h b/include/bbhost_plugin.h index 745c57c2..090869a2 100644 --- a/include/bbhost_plugin.h +++ b/include/bbhost_plugin.h @@ -1,4 +1,4 @@ -/* bbhost plugin API, version 28. +/* bbhost plugin API, version 29. * * A plugin is a shared library (.so on Linux, .dll on Windows) in * /plugins or /plugins. The host loads every one at start and @@ -38,7 +38,7 @@ extern "C" { #endif -#define BB_PLUGIN_API_VERSION 28 +#define BB_PLUGIN_API_VERSION 29 #if defined(_WIN32) #define BB_PLUGIN_EXPORT __declspec(dllexport) @@ -155,6 +155,8 @@ typedef struct BbPluginInfo { #define BB_OPT_TEXT 5 #define BB_OPT_ACTION 6 /* a button (in game only) */ #define BB_OPT_HEADING 7 /* a section title: label (and help) only */ +#define BB_OPT_INFO 8 /* version 29: a label and a value the player cannot change (`def`, or what panel_value + sets) - on an in-game menu's page only; never in the config */ #define BB_OPT_LIVE 0x100u /* or-ed into type: takes effect at once in game (on_option); without it, at the next start */ #define BB_OPT_WHEN 0x200u /* version 21, or-ed into the type of any option but a @@ -163,11 +165,26 @@ typedef struct BbPluginInfo { plugin's option `key` holds that value (older hosts show it as always). On a HEADING it covers the rows under it, up to the next heading. */ +#define BB_OPT_PANEL 0x400u /* version 29, or-ed into a HEADING's type: it and the rows + under it, up to the next heading, are a page of the + plugin's panel (panel_show) - drawn over the game while + the plugin shows it - and not in the menus */ +#define BB_OPT_MENU 0x800u /* version 29, or-ed into a PANEL heading's type: its page starts an in-game menu named + by its `def` (its label when NULL) - the overlay's "Open " button for it. The + PANEL pages after it, up to the next MENU heading, are that menu's, in L1/R1 order. + A plugin with no MENU heading has one unnamed menu of all its pages (no button). */ +#define BB_OPT_SUBPAGE 0x1000u /* version 29, or-ed into a PANEL heading's type: its page is out of its menu's + L1/R1 order, opened from a row (BB_OPT_OPEN) or panel_open; Circle there goes back */ +#define BB_OPT_OPEN 0x2000u /* version 29, or-ed into an ACTION's type: pressing it opens the page named by its + `def` on top of the one shown (Circle there comes back) and calls on_action, which can + fill that page (panel_rows) */ +#define BB_OPT_CONFIRM 0x4000u /* version 29, or-ed into an ACTION's type: the host asks first, in the game's yes/no + dialog ("