Skip to content

CommonTools: screen events, what the screen shows and since when - #534

Draft
dayfine wants to merge 5 commits into
plza/upstream/s1-05from
plza/upstream/s1-06
Draft

dayfine wants to merge 5 commits into
plza/upstream/s1-05from
plza/upstream/s1-06

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Depends on #533

Adds CommonTools/ScreenEvents: what the screen shows (a fade, a location banner, a dialogue box, a battle starting) as events every game shares, with their timed log and fade reading. Each game implements ScreenEventObserver with its own detectors (the first is PLZA's; Used by the PLZA program PR (batch 2)), and the judgements built on these events are the same for all of them. Tests: the ScreenEvents suite (synthetic frames), built and run by Fork Draft CI. Part of the re-split of #522/#524/#525 into reviewable steps; review fixes are new commits on the PR that owns each problem, merged up the chain.

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed SHA: c43d9e9

Verdict

NEEDS_REWORK

First-pass review (agent), own diff against plza/upstream/s1-05, at the infra bar (CommonTools). Code health job passes; CI at review time: build/no-tabs pass, Fork Draft CI ubuntu / build pending. Files are CRLF; the watcher uses the Mutex/LockGuard wrappers and atomics correctly for one inference thread plus readers. I checked fade_of_screen on an empty frame: image_stats gives NaN averages, so it reads NONE, not black - fine.

High

  1. Nothing implements ScreenEventObserver and nothing outside tests constructs a ScreenEventWatcher, here or anywhere up to the chain tip (944abe8; the only non-test mention is Pokemon_ScreenObservation.h, which bridges it). Infra with no implementer is the hardest kind to review: whether the eleven events, the observer's now parameter and the 256-change log are the right shape can only be judged against a real game's detectors. Name the PR that adds the first observer (PLZA?) in the description, or land this with it.

Medium

  1. Game vocabulary in a shared module (T9): ScreenEventTypes.h / ScreenFades.h are in CommonTools but speak Pokemon tile games and the Switch - WarpFade ("warp"), "a cave exit's white, with no battle after it", "a cave mouth's dim fade", "a dim cave floor (mean about 46 a channel)", LOCATION_BANNER ("an observer given an expected map reports only that map's"), SWITCH_HOME_MENU (a console concept in a console-agnostic folder). Either keep the generic part here (fade black/white, dialog/choice box, screen still) with neutral names (ScreenFade, "a screen-wide fade"), and move the rest to Pokemon/ or NintendoSwitch/, or say in the header why a closed, shared enum is the intended design (every new game's event means editing CommonTools).
  2. ScreenEvents reimplements std::bitset<SCREEN_EVENT_COUNT> (has, set(event, bool), merge, bits, from_bits), plus a hand-kept SCREEN_EVENT_COUNT = 11 with a static_assert. A thin wrapper over std::bitset (or at least set/reset instead of set(event, bool on), a bool parameter per TotW #94) would be less to review. If uint32_t is needed for the atomics, say so on the class.
  3. ScreenEvents.cpp defines the functions of four headers (ScreenEventTypes.h, ScreenFades.h, ScreenEventLog.h, ScreenEvents.h). For infra, one .cpp per header so each piece's dependencies are visible (the fade code pulls ImageStats/SolidColorTest into the log's translation unit).

Low

  1. ScreenEventWatcher::reset() clears m_seen, m_stopped_on and the log in three separate steps; a frame processed in between leaves them inconsistent. Fine if reset() is only called between actions - say so in its comment.
  2. ScreenEventObserver::observe(frame, now): the watcher always passes frame.timestamp as now, and the comment says "the caller's clock". If observers should always use the frame's time, drop the parameter; otherwise say when they differ.
  3. ScreenEventLog(size_t capacity = SCREEN_EVENT_LOG_CAPACITY) and the "a minute or more of a busy scene" estimate: fine, but record() documents "now must not go back in time" without checking it; one if (or a note that callers own it).
  4. ScreenEvents_Tests.cpp expect_equal is the same helper as Pokemon_TestExpect.h later in the chain (#537); one of them should go when the chain settles (CommonTools cannot include Pokemon, so the shared one belongs here or in Common/Cpp/TestRunners).

No brace-style, tabs, Qt, std::filesystem or raw-thread issues; SourceFiles.cmake lists every new file.

@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Review fixes, tip 4044e37b9 (merge only):

1: the description now names the first observer, PLZA's, in the PLZA program PR (batch 2).
Not changed: 2-8. The closed shared enum and the bitset question are design calls for the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant