Files
psxrecomp/runtime/tests/test_ws_local_view_margin.c
Shokunin 33b842e97f netplay: per-player own-view mods, widescreen only inside the local view
A [[plugin]] may declare netplay = "local_view": it only changes what one
player sees. A netplay session now keeps the player's own features whose every
contribution is such a plugin (no writes, overlays or derived discs) instead of
clearing them, without saving state.toml. They activate as usual, but their
hooks run only inside psx_mod_render_local_view (psx_mod_local_view_scope) and
their vblank/savestate callbacks not at all. With such a plan the widescreen
cull margin is the stock 0 in the shared game and this peer's own margin only
inside the sandboxed own-view draw; squash is not used. The canonical frame,
snapshots and digests stay identical on every peer whatever each player chose,
so nothing is negotiated, and each keeps their own aspect.

Tests: netplay_view_mods_test (flag, plan filter, parked hooks, no vblank,
state.toml untouched), ws_local_view_margin_test (margin scope), render-pass
sandbox asserts the scope around a local view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 14:17:26 -07:00

39 lines
1.3 KiB
C

#ifdef NDEBUG
#undef NDEBUG
#endif
/* Netplay own-view widescreen: with gpu_ws_set_local_view_only(1) the cull
* margin the guest sees is the stock 0 everywhere except inside a sandboxed
* local-view render (gpu_ws_set_local_view_scope), where it is the margin the
* configured native-wide aspect implies. Off (the default) changes nothing. */
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "../src/gpu.c"
#include "gpu_exec_stubs.inc"
int main(void) {
ws_mode = 2;
ws_cfg_num = 16; ws_cfg_den = 9;
hres1 = 1; hres2 = 0; video_mode = 0; /* 320 wide */
h_display_x1 = 0x260; h_display_x2 = 0xC60;
v_display_y1 = 0x10; v_display_y2 = 0x100;
const int wide = psx_ws_x_margin();
assert(wide > 0);
assert(!gpu_ws_local_view_only());
gpu_ws_set_local_view_only(1);
assert(psx_ws_x_margin() == 0); /* shared simulation: stock */
assert(psx_ws_player_x_bound(160) == 160);
gpu_ws_set_local_view_scope(1);
assert(psx_ws_x_margin() == wide); /* own view: this peer's */
gpu_ws_set_local_view_scope(0);
assert(psx_ws_x_margin() == 0);
gpu_ws_set_local_view_only(0);
assert(psx_ws_x_margin() == wide); /* offline: unchanged */
puts("ws_local_view_margin_test: ok");
return 0;
}