|
pico9918-core 1.3.0
TMS9918A / F18A video display processor emulation in C99
|
pico9918-core - Diagnostics overlay More...
#include "diag.h"#include "overlay/bmp_font.h"#include "impl/pico9918_priv.h"#include "gpu/gpu.h"#include <stdbool.h>#include <string.h>
Include dependency graph for diag.c:Go to the source code of this file.
Data Structures | |
| struct | IntString |
Macros | |
| #define | DIAG_COLOR(pramOrder) ((PICO9918_PIXEL_T)(PICO9918_PIXEL_FROM_RGB12(pramOrder) & 0x0fff)) |
| #define | FONT_CHARS 96 |
| #define | FONT_FIRST 32 |
| #define | INK_WORDS (PICO9918_DIAG_CHAR_WIDTH / PICO9918_INK_PIXELS) |
| #define | INK_STRIDE (INK_WORDS <= 4 ? 4 : 8) |
Typedefs | |
| typedef void(* | DiagPtr) (uint16_t, PICO9918_PIXEL_T *) |
Functions | |
| static void | clear (IntString *number) |
| static void | flt2Str (float flt, int prec, IntString *out) |
| static void | uint2hexStr (uint32_t number, int width, IntString *out) |
| static void | glyphMaskInit (void) |
| void | pico9918_diag_init (void) |
| one-time initialisation of the panel value strings | |
| 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_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_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. | |
| PICO9918_INLINE int | renderRow (uint16_t row, const char *text, uint16_t x, PICO9918_PIXEL_T fg, PICO9918_PIXEL_T *pixels) |
| PICO9918_INLINE int | renderNum (uint16_t row, IntString *str, uint16_t x, PICO9918_PIXEL_T fg, PICO9918_PIXEL_T *pixels) |
| void | pico9918_diag_update_render_time (uint32_t renderTime, uint32_t frameTime) |
| accumulate one scanline's render and total time, in microseconds | |
| static int | backgroundPixels (int xPos, int count, PICO9918_PIXEL_T *pixels) |
| static void | renderLeft (const char *label, IntString *val, const char *units, uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagHwVer (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagFwVer (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagRenderTime (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagScanlineRenderTime (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagGpuTime (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagFPS (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagTemp (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagOutput (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagClock (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagNameTab (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagColorTab (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagPattTab (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagSprAttrTab (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagSprPattTab (uint16_t row, PICO9918_PIXEL_T *pixels) |
| static void | diagMode (uint16_t row, PICO9918_PIXEL_T *pixels) |
| void | pico9918_diag_config_updated (pico9918_t *tms9918) |
| rebuild the panel row table - call whenever the PICO9918_CONF_DIAG* bytes change | |
| static void | renderPalette (pico9918_t *tms9918, int y, uint32_t vVirtualPixels, PICO9918_PIXEL_T *pixels) |
| 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 | |
Variables | |
| IntString | frameTimeStr = {0} |
| IntString | renderTimePerScanlineStr = {0} |
| IntString | temperatureStr = {0} |
| IntString | gpuPctStr = {0} |
| IntString | clockMhzStr = {0} |
| IntString | modeStr = {0} |
| IntString | fpsStr = {0} |
| IntString | hwVerStr = {0} |
| IntString | fwVerStr = {0} |
| IntString | outputStr = {0} |
| static const char * | outputUnitsStr = "" |
| IntString | nameTabStr = {0} |
| IntString | colorTabStr = {0} |
| IntString | pattTabStr = {0} |
| IntString | sprAttTabStr = {0} |
| IntString | sprPattTabStr = {0} |
| uint32_t | accumulatedRenderTime = 0 |
| uint32_t | accumulatedFrameTime = 0 |
| uint32_t | accumulatedScanlines = 0 |
| uint32_t | lastUpdateTime = 0 |
| const PICO9918_PIXEL_T | labelColor = DIAG_COLOR(0xff07) |
| const PICO9918_PIXEL_T | valueColor = DIAG_COLOR(0xff0f) |
| const PICO9918_PIXEL_T | unitsColor = DIAG_COLOR(0x8808) |
| static float | precLookup [] = {1.0f, 10.0f, 100.0f, 1000.0f} |
| static PICO9918_INK_T | glyphMask [64][INK_STRIDE] |
| const char * | modeNames [] |
| static float | hostFrameRateHz = 0.0f |
| static const char | nibbleBinStr [16][8] |
| static const uint8_t | extReg [] |
| const uint32_t | leftXPos = 2 |
| static DiagPtr const | performanceDiags [] |
| static DiagPtr const | addressDiags [] |
| static DiagPtr | leftDiags [sizeof(performanceDiags)/sizeof(performanceDiags[0])+sizeof(addressDiags)/sizeof(addressDiags[0])+2] = {0} |
| static int | leftDiagRows = 0 |
pico9918-core - Diagnostics overlay
Copyright (c) 2024 Troy Schrapel
This code is licensed under the MIT license
https://github.com/visrealm/pico9918-core
Definition in file diag.c.
| #define DIAG_COLOR | ( | pramOrder | ) | ((PICO9918_PIXEL_T)(PICO9918_PIXEL_FROM_RGB12(pramOrder) & 0x0fff)) |
| #define INK_WORDS (PICO9918_DIAG_CHAR_WIDTH / PICO9918_INK_PIXELS) |
|
static |
|
static |
| void pico9918_diag_init | ( | void | ) |
| 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.
| 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.
| void pico9918_diag_set_temperature | ( | float | tempC | ) |
core temperature, degrees C
Definition at line 260 of file diag.c.
Referenced by pico9918_frame_end().
| void pico9918_diag_set_clock_hz | ( | float | clockHz | ) |
| 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().
| 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().
| 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_INLINE int renderRow | ( | uint16_t | row, |
| const char * | text, | ||
| uint16_t | x, | ||
| PICO9918_PIXEL_T | fg, | ||
| PICO9918_PIXEL_T * | pixels | ||
| ) |
| PICO9918_INLINE int renderNum | ( | uint16_t | row, |
| IntString * | str, | ||
| uint16_t | x, | ||
| PICO9918_PIXEL_T | fg, | ||
| PICO9918_PIXEL_T * | pixels | ||
| ) |
| 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().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| 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().
|
static |
| 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().
| const char* modeNames[] |
|
static |
|
static |
|
static |
|
static |
|
static |