pico9918-core 1.3.0
TMS9918A / F18A video display processor emulation in C99
Loading...
Searching...
No Matches
pico9918_util.c
Go to the documentation of this file.
1/**
2 * \file
3 * \brief pico9918-core - utility / helper functions
4 *
5 * Copyright (c) 2022 Troy Schrapel
6 *
7 * This code is licensed under the MIT license
8 *
9 * https://github.com/visrealm/pico9918-core
10 */
11
12#include "pico9918_util.h"
13
14#ifndef WIN32
15#undef PICO9918_DLLEXPORT
16#define PICO9918_DLLEXPORT
17#endif
18
19#undef PICO9918_DLLEXPORT_CONST
20#define PICO9918_DLLEXPORT_CONST
21
22
23/** \brief the sprite Y value that terminates the sprite list */
24#define LAST_SPRITE_YPOS 0xD0
25
26/** \brief the sixteen TMS9918 colours, each packed as 0xrrggbbaa */
27PICO9918_DLLEXPORT_CONST uint32_t pico9918_palette[] = {
28 0x00000000, /* transparent */
29 0x000000ff, /* black */
30 0x21c942ff, /* medium green */
31 0x5edc78ff, /* light green */
32 0x5455edff, /* dark blue */
33 0x7d75fcff, /* light blue */
34 0xd3524dff, /* dark red */
35 0x43ebf6ff, /* cyan */
36 0xfd5554ff, /* medium red */
37 0xff7978ff, /* light red */
38 0xd3c153ff, /* dark yellow */
39 0xe5ce80ff, /* light yellow */
40 0x21b03cff, /* dark green */
41 0xc95bbaff, /* magenta */
42 0xccccccff, /* grey */
43 0xffffffff /* white */
44};
45
46/** \brief zero the 16KB of VRAM, then park all 32 sprites past the end of the list */
61
62/** \brief program Graphics I, the default table addresses and black on cyan, then clear VRAM */
78
79
80/** \brief as pico9918_initialise_gfx_i(), but for Graphics II and with the name table
81 * filled with a rising pattern index
82 */
void pico9918_write_data(pico9918_t *tms9918, uint8_t data)
write data (mode = 0) to the tms9918
Definition pico9918.c:395
#define TMS_R1_MODE_GRAPHICS_I
Graphics I - no bit of its own in R1.
Definition pico9918.h:303
#define TMS_R1_RAM_16K
register 1 bits: VRAM size, blanking, interrupt, mode and sprite size
Definition pico9918.h:297
#define PICO9918_INST_ONLY
pass the instance as the only argument
Definition pico9918.h:74
#define TMS_R0_MODE_GRAPHICS_I
register 0 bits: mode selection and the external VDP input.
Definition pico9918.h:286
#define TMS_R1_DISP_ACTIVE
render the active display
Definition pico9918.h:300
#define TMS_R0_MODE_GRAPHICS_II
Graphics II - the only mode R0 selects.
Definition pico9918.h:287
#define TMS_R0_EXT_VDP_DISABLE
ignore the external VDP input
Definition pico9918.h:292
#define PICO9918_INST_ONLY_ARG
declare the instance as the only parameter
Definition pico9918.h:72
#define TMS_R1_INT_ENABLE
assert /INT at end of frame
Definition pico9918.h:301
#define TMS_R1_MODE_GRAPHICS_II
Graphics II - selected in R0.
Definition pico9918.h:304
#define PICO9918_INST
pass the instance ahead of other arguments
Definition pico9918.h:73
#define PICO9918_DLLEXPORT
the linkage every public entry point carries - see LINKAGE MODES above
Definition pico9918.h:41
PICO9918_DLLEXPORT void pico9918_initialise_gfx_ii(pico9918_t *tms9918)
as pico9918_initialise_gfx_i(), but for Graphics II and with the name table filled with a rising patt...
PICO9918_DLLEXPORT_CONST uint32_t pico9918_palette[]
the sixteen TMS9918 colours, each packed as 0xrrggbbaa
static void clearTmsRam(pico9918_t *tms9918)
zero the 16KB of VRAM, then park all 32 sprites past the end of the list
#define LAST_SPRITE_YPOS
the sprite Y value that terminates the sprite list
PICO9918_DLLEXPORT void pico9918_initialise_gfx_i(pico9918_t *tms9918)
program Graphics I, the default table addresses and black on cyan, then clear VRAM
pico9918-core - utility / helper functions
#define TMS_DEFAULT_VRAM_PATT_ADDRESS
pattern table (R4)
#define TMS_DEFAULT_VRAM_COLOR_ADDRESS
colour table (R3)
static void pico9918_set_address_write(pico9918_t *tms9918, uint16_t addr)
point the VRAM address register at addr for writing, ie.
static void pico9918_set_fg_bg_color(pico9918_t *tms9918, pico9918_color_t fg, pico9918_color_t bg)
set register 7, the text-mode foreground colour and the backdrop
static void pico9918_set_color_table_addr(pico9918_t *tms9918, uint16_t addr)
set the colour table address, which register 3 holds in 64-byte units
static void pico9918_set_sprite_patt_table_addr(pico9918_t *tms9918, uint16_t addr)
set the sprite pattern table address, which register 6 holds in 2KB units
static void pico9918_set_name_table_addr(pico9918_t *tms9918, uint16_t addr)
set the name table address, which register 2 holds in 1KB units
static void pico9918_set_sprite_attr_table_addr(pico9918_t *tms9918, uint16_t addr)
set the sprite attribute table address, which register 5 holds in 128-byte units
#define TMS_DEFAULT_VRAM_SPRITE_PATT_ADDRESS
sprite pattern table (R6)
static void pico9918_write_byte_rpt(pico9918_t *tms9918, uint8_t byte, size_t rpt)
write byte to VRAM rpt times from the current address
static void pico9918_write_register_value(pico9918_t *tms9918, pico9918_register_t reg, uint8_t value)
write a VDP register as a host would, value byte first
#define TMS_DEFAULT_VRAM_NAME_ADDRESS
the VRAM table layout pico9918_initialise_gfx_i() and GfxII() program
#define TMS_DEFAULT_VRAM_SPRITE_ATTR_ADDRESS
sprite attribute table (R5)
static void pico9918_set_pattern_table_addr(pico9918_t *tms9918, uint16_t addr)
set the pattern table address, which register 4 holds in 2KB units