pico9918-core 1.3.0
TMS9918A / F18A video display processor emulation in C99
Loading...
Searching...
No Matches
goldenHostOps.h
Go to the documentation of this file.
1/**
2 * \file
3 * \brief pico9918-core - the golden harness's view of the status publish
4 *
5 * Copyright (c) 2026 Troy Schrapel
6 *
7 * This code is licensed under the MIT license
8 *
9 * https://github.com/visrealm/pico9918-core
10 *
11 * Force-included (-include) into every TU of the golden build - the library AND
12 * the harness - the same way goldenClock.h is, and for the same reason: the op
13 * being overridden expands inside the library's own TUs, so a harness-only define
14 * would change nothing.
15 *
16 * WHY THIS EXISTS
17 *
18 * PICO9918_HOST_STATUS_VISIBLE() defaults to a no-op, so on desktop nothing can
19 * see whether a newly latched status was ever handed to the host. That is the one
20 * consequence of pico9918_frame_update_interrupts the frame group could not digest,
21 * and it is exactly the consequence a publish the frame path decides to SKIP would
22 * break. Recording the op closes that hole.
23 *
24 * WHAT IS RECORDED, AND WHAT IS DELIBERATELY NOT
25 *
26 * Only the SR0 value visible at the moment of the publish. The word the PICO9918
27 * firmware actually pushes carries a pin-direction byte, a read-ahead byte and a
28 * status-register select as well, but those are HOST policy - the library's own
29 * meaning for this op is "the newly latched status is now readable" - so digesting
30 * them here would pin firmware decisions in a library test.
31 *
32 * The call COUNT is recorded but must never be digested, for the reason
33 * goldenClock.h gives about its own step: a golden that pins how many times the
34 * library published bakes in the current call pattern and fails the moment someone
35 * legitimately changes it. The contract is that the host's view is never STALE, not
36 * that it is refreshed a particular number of times - so what a row digests is
37 * goldenPublishedStatus against the merged SR0 it expects.
38 *
39 * goldenPublishReset() states the precondition a row starts from: on the device a
40 * latched status has always been published by whoever latched it, so a row that
41 * installs SR0 directly has to say the host was told, or every row would read as a
42 * stale publish before the function under test has even run.
43 */
44
45#pragma once
46
47#include <stdint.h>
48
49extern uint8_t goldenPublishedStatus;
50extern uint32_t goldenPublishCount;
51
52static inline void goldenNotePublish(uint8_t status)
53{
54 goldenPublishedStatus = status;
55 ++goldenPublishCount;
56}
57
58static inline void goldenPublishReset(uint8_t status)
59{
60 goldenPublishedStatus = status;
61 goldenPublishCount = 0;
62}
63
64#define PICO9918_HOST_STATUS_VISIBLE() goldenNotePublish(TMS_STATUS(tms9918, 0))