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 "pico9918_debug.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 NEW_WP   0x2800u
 
#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 loadWorkspaceProgram (void)
 
static void loadEchoProgram (void)
 
static void loadStatusProgram (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)
 
static bool stepWatch (pico9918_t *vdp, uint16_t pc, void *userdata)
 
int main (void)
 

Variables

static int failures
 
static uint16_t stepPc [8]
 
static unsigned stepCalls
 
static uint16_t stepStopAt
 
static unsigned stepWrongArgs
 

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 30 of file gpu_test.c.

◆ RESULT_AT

#define RESULT_AT   0x2100u

Definition at line 31 of file gpu_test.c.

◆ MARKER

#define MARKER   0xbeefu

Definition at line 32 of file gpu_test.c.

◆ NEW_WP

#define NEW_WP   0x2800u

Definition at line 102 of file gpu_test.c.

◆ DMA_SRC

#define DMA_SRC   0x1000u

Definition at line 148 of file gpu_test.c.

◆ DMA_DST

#define DMA_DST   0x1800u

Definition at line 149 of file gpu_test.c.

Function Documentation

◆ fail()

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

Definition at line 36 of file gpu_test.c.

◆ regWrite()

static void regWrite ( uint8_t  reg,
uint8_t  value 
)
static

Definition at line 42 of file gpu_test.c.

◆ unlock()

static void unlock ( void  )
static

Definition at line 48 of file gpu_test.c.

◆ loadProgram()

static void loadProgram ( void  )
static

Definition at line 62 of file gpu_test.c.

◆ result()

static uint16_t result ( void  )
static

Definition at line 73 of file gpu_test.c.

◆ arm()

static void arm ( void  )
static

Definition at line 79 of file gpu_test.c.

◆ loadDmaProgram()

static void loadDmaProgram ( void  )
static

Definition at line 94 of file gpu_test.c.

◆ loadWorkspaceProgram()

static void loadWorkspaceProgram ( void  )
static

Definition at line 109 of file gpu_test.c.

◆ loadEchoProgram()

static void loadEchoProgram ( void  )
static

Definition at line 125 of file gpu_test.c.

◆ loadStatusProgram()

static void loadStatusProgram ( void  )
static

Definition at line 141 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 153 of file gpu_test.c.

◆ expect()

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

Definition at line 175 of file gpu_test.c.

◆ stepWatch()

static bool stepWatch ( pico9918_t *  vdp,
uint16_t  pc,
void *  userdata 
)
static

Definition at line 185 of file gpu_test.c.

◆ main()

int main ( void  )

Definition at line 210 of file gpu_test.c.

Variable Documentation

◆ failures

int failures
static

Definition at line 34 of file gpu_test.c.

◆ stepPc

uint16_t stepPc[8]
static

Definition at line 180 of file gpu_test.c.

◆ stepCalls

unsigned stepCalls
static

Definition at line 181 of file gpu_test.c.

◆ stepStopAt

uint16_t stepStopAt
static

Definition at line 182 of file gpu_test.c.

◆ stepWrongArgs

unsigned stepWrongArgs
static

Definition at line 183 of file gpu_test.c.