pico9918-core 1.3.0
TMS9918A / F18A video display processor emulation in C99
Loading...
Searching...
No Matches
diag.h File Reference

pico9918-core - Diagnostics overlay More...

#include "impl/platform.h"
#include "pico9918.h"
#include "pico9918_build_config.h"
#include <stdint.h>
+ Include dependency graph for diag.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PICO9918_DIAG_GPU_FRAME_COUNTER   0
 set to 1 to build the GPU-frames row and its setter
 
#define PICO9918_DIAG_CHAR_WIDTH   6
 glyph cell width, pixels
 
#define PICO9918_DIAG_CHAR_HEIGHT   6
 glyph cell height, pixels
 

Functions

 PICO9918_STATIC_ASSERT (sizeof(PICO9918_PIXEL_T)==PICO9918_BUILD_PIXEL_SIZE, "PICO9918_PIXEL_T does not match the width this library was built " "with (see pico9918_build_config.h). Select the same pixel " "policy the library used - one ships, and it is the default in " "platform/ on both platforms.")
 
void pico9918_diag_init (void)
 one-time initialisation of the panel value strings
 
void pico9918_diag_config_updated (pico9918_t *tms9918)
 rebuild the panel row table - call whenever the PICO9918_CONF_DIAG* bytes change
 
void pico9918_diag_set_temperature (float tempC)
 core temperature, degrees C
 
void pico9918_diag_set_clock_hz (float clockHz)
 system clock, Hz
 
void pico9918_diag_set_frame_rate (float frameRateHz)
 Host display timing, Hz.
 
void pico9918_diag_set_version_info (const char *hwVersion, const char *fwVersion)
 Version identity for the HWVER / FWVER rows.
 
void pico9918_diag_set_output_name (const char *name, const char *units)
 Display-mode label for the OUTPUT row, e.g.
 
void pico9918_diag_update_render_time (uint32_t renderTime, uint32_t frameTime)
 accumulate one scanline's render and total time, in microseconds
 
void pico9918_diag_update (pico9918_t *tms9918, uint32_t frameCount)
 recompute the panel values - call once per frame
 
int pico9918_diag_render_text (uint16_t scanline, const char *text, uint16_t x, uint16_t y, PICO9918_PIXEL_T fg, PICO9918_PIXEL_T *pixels)
 render text into the scanline buffer, if row scanline falls in the glyph band starting at y.
 
void pico9918_diag_render (pico9918_t *tms9918, uint16_t y, uint32_t vVirtualPixels, PICO9918_PIXEL_T *pixels)
 render the diagnostics panels for border row y
 

Detailed Description

pico9918-core - Diagnostics overlay

Copyright (c) 2024 Troy Schrapel

This code is licensed under the MIT license

https://github.com/visrealm/pico9918-core

The diagnostics panels the device draws over the borders when the PICO9918_CONF_DIAG* config bytes are set: render timings, frame rate, GPU load, temperature, the register dump, the table addresses and the palette strip. Device behaviour, not decoration - the panels are driven entirely by library-owned config bytes rendering library-owned state.

Geometry arrives per call, like the splash overlay. Everything the library cannot know - the host's frame rate, its dropped-frame accounting, its board revision strings and its display-mode labels - arrives through push setters, called per frame or rarer. The library never reaches back into the host.

pico9918_diag_render_text is public because the host also draws its own text over the border (the pending-display banner); the font and the glyph blitter live here, so there is one text path rather than two.

Definition in file diag.h.

Macro Definition Documentation

◆ PICO9918_DIAG_GPU_FRAME_COUNTER

#define PICO9918_DIAG_GPU_FRAME_COUNTER   0

set to 1 to build the GPU-frames row and its setter

Definition at line 42 of file diag.h.

◆ PICO9918_DIAG_CHAR_WIDTH

#define PICO9918_DIAG_CHAR_WIDTH   6

glyph cell width, pixels

Definition at line 46 of file diag.h.

◆ PICO9918_DIAG_CHAR_HEIGHT

#define PICO9918_DIAG_CHAR_HEIGHT   6

glyph cell height, pixels

Definition at line 47 of file diag.h.

Function Documentation

◆ pico9918_diag_init()

void pico9918_diag_init ( void  )

one-time initialisation of the panel value strings

Definition at line 200 of file diag.c.

◆ pico9918_diag_config_updated()

void pico9918_diag_config_updated ( pico9918_t *  tms9918)

rebuild the panel row table - call whenever the PICO9918_CONF_DIAG* bytes change

Definition at line 541 of file diag.c.

Referenced by pico9918_frame_raise_end_of_frame_int().

◆ pico9918_diag_set_temperature()

void pico9918_diag_set_temperature ( float  tempC)

core temperature, degrees C

Definition at line 260 of file diag.c.

Referenced by pico9918_frame_end().

◆ pico9918_diag_set_clock_hz()

void pico9918_diag_set_clock_hz ( float  clockHz)

system clock, Hz

Definition at line 265 of file diag.c.

◆ pico9918_diag_set_frame_rate()

void pico9918_diag_set_frame_rate ( float  frameRateHz)

Host display timing, Hz.

The library has no clock of its own, so the FPS row is (16 - droppedFrames) * (frameRate / 16); only this term is pushed. The dropped frames come from the frame module, which owns that accounting and is read directly.

Definition at line 274 of file diag.c.

Referenced by pico9918_frame_end().

◆ pico9918_diag_set_version_info()

void pico9918_diag_set_version_info ( const char *  hwVersion,
const char *  fwVersion 
)

Version identity for the HWVER / FWVER rows.

The strings are host policy: only the host knows its board revisions and its own firmware version, and the library must not carry PICO9918 revision knowledge. Both are copied into the panel buffers, so the caller keeps no lifetime obligation. Either may be NULL to leave that row's current text alone.

Definition at line 226 of file diag.c.

◆ pico9918_diag_set_output_name()

void pico9918_diag_set_output_name ( const char *  name,
const char *  units 
)

Display-mode label for the OUTPUT row, e.g.

"480P " + "@60". The encoding of PICO9918_CONF_DISP_DRIVER is host policy (which timings a board supports), so the host supplies the label rather than the library carrying board-specific strings. name is copied; units is retained by pointer, so it must have static storage duration. Either may be NULL to leave that part alone.

Definition at line 243 of file diag.c.

◆ pico9918_diag_update_render_time()

void pico9918_diag_update_render_time ( uint32_t  renderTime,
uint32_t  frameTime 
)

accumulate one scanline's render and total time, in microseconds

Definition at line 393 of file diag.c.

Referenced by pico9918_frame_scanline().

◆ pico9918_diag_update()

void pico9918_diag_update ( pico9918_t *  tms9918,
uint32_t  frameCount 
)

recompute the panel values - call once per frame

Definition at line 280 of file diag.c.

References pico9918_display_mode(), pico9918_gpu_reset_time(), pico9918_gpu_time(), and PICO9918_INST_ONLY.

Referenced by pico9918_frame_end().

◆ pico9918_diag_render_text()

int pico9918_diag_render_text ( uint16_t  scanline,
const char *  text,
uint16_t  x,
uint16_t  y,
PICO9918_PIXEL_T  fg,
PICO9918_PIXEL_T *  pixels 
)

render text into the scanline buffer, if row scanline falls in the glyph band starting at y.

Returns the x position just past the last pixel written, so calls chain. A cell's unlit pixels are darkened, not left untouched. x must be a whole number of ink words - cells are written a word at a time.

Definition at line 348 of file diag.c.

References PICO9918_DIAG_CHAR_HEIGHT.

◆ pico9918_diag_render()

void pico9918_diag_render ( pico9918_t *  tms9918,
uint16_t  y,
uint32_t  vVirtualPixels,
PICO9918_PIXEL_T *  pixels 
)

render the diagnostics panels for border row y

Definition at line 596 of file diag.c.

References PICO9918_DIAG_CHAR_WIDTH, and PICO9918_INST.

Referenced by pico9918_frame_output_line(), and pico9918_frame_scanline().