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

pico9918-core - the library-paced GPU More...

#include "impl/pico9918_priv.h"
#include "gpu/gpu.h"
#include <stdio.h>
+ Include dependency graph for gpu_test.c:

Go to the source code of this file.

Macros

#define PROGRAM_AT   0x2000u
 
#define RESULT_AT   0x2100u
 
#define MARKER   0xbeefu
 
#define DMA_SRC   0x1000u
 
#define DMA_DST   0x1800u
 

Functions

static void fail (const char *what, unsigned wanted, unsigned got)
 
static void regWrite (uint8_t reg, uint8_t value)
 
static void unlock (void)
 
static void loadProgram (void)
 
static uint16_t result (void)
 
static void arm (void)
 
static void loadDmaProgram (void)
 
static void dma (uint32_t src, uint32_t dst, uint8_t width, uint8_t height, uint8_t stride, uint8_t params)
 
static void expect (const char *what, uint32_t at, uint8_t wanted)
 
int main (void)
 

Variables

static int failures
 

Detailed Description

pico9918-core - the library-paced GPU

Copyright (c) 2026 Troy Schrapel

This code is licensed under the MIT license

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

pico9918_gpu_set_clock's contract, which nothing else covers: a rate makes the library run an armed program from inside the arming write, and zero leaves the GPU to the host.

The first half is what software detecting an F18A depends on. The probe arms a tiny self-modifying program and reads its result back within a handful of host cycles, so a host servicing the GPU once a scanline sees the chip only when a scanline boundary happens to fall in between - a real flaky-detection bug in two emulators.

The last section is the DMA engine, which is here because a program triggering one is the only way to reach it: the ports it answers to are above the address space a host can write.

Definition in file gpu_test.c.

Macro Definition Documentation

◆ PROGRAM_AT

#define PROGRAM_AT   0x2000u

Definition at line 29 of file gpu_test.c.

◆ RESULT_AT

#define RESULT_AT   0x2100u

Definition at line 30 of file gpu_test.c.

◆ MARKER

#define MARKER   0xbeefu

Definition at line 31 of file gpu_test.c.

◆ DMA_SRC

#define DMA_SRC   0x1000u

Definition at line 101 of file gpu_test.c.

◆ DMA_DST

#define DMA_DST   0x1800u

Definition at line 102 of file gpu_test.c.

Function Documentation

◆ fail()

static void fail ( const char *  what,
unsigned  wanted,
unsigned  got 
)
static

Definition at line 35 of file gpu_test.c.

◆ regWrite()

static void regWrite ( uint8_t  reg,
uint8_t  value 
)
static

Definition at line 41 of file gpu_test.c.

◆ unlock()

static void unlock ( void  )
static

Definition at line 47 of file gpu_test.c.

◆ loadProgram()

static void loadProgram ( void  )
static

Definition at line 61 of file gpu_test.c.

◆ result()

static uint16_t result ( void  )
static

Definition at line 72 of file gpu_test.c.

◆ arm()

static void arm ( void  )
static

Definition at line 78 of file gpu_test.c.

◆ loadDmaProgram()

static void loadDmaProgram ( void  )
static

Definition at line 93 of file gpu_test.c.

◆ dma()

static void dma ( uint32_t  src,
uint32_t  dst,
uint8_t  width,
uint8_t  height,
uint8_t  stride,
uint8_t  params 
)
static

Definition at line 106 of file gpu_test.c.

◆ expect()

static void expect ( const char *  what,
uint32_t  at,
uint8_t  wanted 
)
static

Definition at line 128 of file gpu_test.c.

◆ main()

int main ( void  )

Definition at line 133 of file gpu_test.c.

Variable Documentation

◆ failures

int failures
static

Definition at line 33 of file gpu_test.c.