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

pico9918-core - Platform Abstraction (portable C) More...

#include <stdint.h>
#include <string.h>
#include <time.h>
+ Include dependency graph for platform_std.h:

Go to the source code of this file.

Data Structures

struct  pico9918_fill32_t
 
struct  pico9918_copy32_t
 

Macros

#define PICO9918_SECTION_SCRATCH_X(name)
 
#define PICO9918_SECTION_SCRATCH_Y(name)
 
#define PICO9918_UNINITIALIZED(decl)   decl
 
#define PICO9918_IN_FLASH_FUNC(fn)   fn
 
#define PICO9918_HOST_SET_INT(active)   ((void)(active))
 
#define PICO9918_FILL_BORDER   pico9918_fill_border
 
#define PICO9918_FILL32_INIT(inst, srcPtr)
 
#define PICO9918_FILL32_SET_COUNT(inst, n)
 
#define PICO9918_FILL32_TRIGGER(inst, dstPtr)
 
#define PICO9918_FILL32_WAIT(inst)   ((void)0) /* TRIGGER is synchronous */
 
#define PICO9918_DMA_CLAIM()   ((void)0)
 
#define PICO9918_FILL_MASKS   pico9918_fill_masks
 
#define PICO9918_FILL_LINE   pico9918_fill_line
 
#define PICO9918_COPY   pico9918_copy
 
#define PICO9918_COPY_STATE()
 
#define PICO9918_COPY_INIT(inst)
 
#define PICO9918_COPY_SET_WIDTH(inst, wordAligned)
 
#define PICO9918_COPY_SET_SRC(inst, srcPtr)
 
#define PICO9918_COPY_SET_DST(inst, dstPtr)
 
#define PICO9918_COPY_TRIGGER(inst, n)   memcpy((inst).dst, (inst).src, (size_t)(n) << (inst).shift)
 
#define PICO9918_COPY_WAIT(inst)   ((void)0) /* TRIGGER is synchronous */
 
#define PICO9918_DIVMOD_U32(n, d, q, r)
 
#define PICO9918_PIXEL_T   PICO9918_PIXEL_T
 
#define PICO9918_PIXEL_FROM_RGB12(rgb)    ((PICO9918_PIXEL_T)(((rgb) & 0xFF0F) | ((((rgb) & 0xFF0F) >> 12) << 4)))
 
#define PICO9918_PIXEL_FROM_RGB12_PAIR(packed)
 
#define PICO9918_PIXEL_PAIR(p)   ((uint32_t)(p) * 0x10001u)
 
#define PICO9918_LOW16(x)   ((uint32_t)(uint16_t)(x))
 
#define PICO9918_PIXEL_DARKEN(p)   ((PICO9918_PIXEL_T)(((p) >> 2) & 0x333))
 
#define PICO9918_PIXEL_PAIR_DIM(w)   (((w) >> 1) & 0x07770777u)
 
#define PICO9918_INK_T   PICO9918_INK_T
 
#define PICO9918_INK_PIXELS   2
 
#define PICO9918_INK_FILL(fg)   PICO9918_PIXEL_PAIR(fg)
 
#define PICO9918_INK_DARKEN(w)   (((w) >> 2) & 0x03330333u)
 
#define PICO9918_INK_ONE(k)   (0xffffu << ((k) * 16))
 
#define PICO9918_PALETTE_LUT_T   PICO9918_PALETTE_LUT_T
 
#define PICO9918_EXPAND_INIT(lut)   ((void)0)
 
#define PICO9918_EXPAND_INDEXED(dst, src, n, lut)
 
#define PICO9918_EXPAND_INDEXED_WIDE(dst, src, n, lut)
 
#define __force_inline   inline
 

Typedefs

typedef uint16_t PICO9918_PIXEL_T
 
typedef uint32_t PICO9918_INK_T
 
typedef uint32_t PICO9918_PALETTE_LUT_T
 

Functions

static uint32_t time_us_32 (void)
 

Variables

pico9918_fill32_t pico9918_fill_border
 
pico9918_fill32_t pico9918_fill_masks
 
pico9918_fill32_t pico9918_fill_line
 
pico9918_copy32_t pico9918_copy
 

Detailed Description

pico9918-core - Platform Abstraction (portable C)

Copyright (c) 2021 Troy Schrapel

This code is licensed under the MIT license

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

Included by impl/platform.h when PICO_BUILD is not defined. Do not include directly.

Every macro here is overridable: a host may #define any PICO9918_* symbol before including pico9918.h to substitute its own (a real lock, a BGRA pixel type, a different fill). Defaults are guarded accordingly.

Definition in file platform_std.h.

Macro Definition Documentation

◆ PICO9918_SECTION_SCRATCH_X

#define PICO9918_SECTION_SCRATCH_X (   name)

Definition at line 25 of file platform_std.h.

◆ PICO9918_SECTION_SCRATCH_Y

#define PICO9918_SECTION_SCRATCH_Y (   name)

Definition at line 26 of file platform_std.h.

◆ PICO9918_UNINITIALIZED

#define PICO9918_UNINITIALIZED (   decl)    decl

Definition at line 29 of file platform_std.h.

◆ PICO9918_IN_FLASH_FUNC

#define PICO9918_IN_FLASH_FUNC (   fn)    fn

Definition at line 32 of file platform_std.h.

◆ PICO9918_HOST_SET_INT

#define PICO9918_HOST_SET_INT (   active)    ((void)(active))

Definition at line 47 of file platform_std.h.

◆ PICO9918_FILL_BORDER

#define PICO9918_FILL_BORDER   pico9918_fill_border

Definition at line 68 of file platform_std.h.

◆ PICO9918_FILL32_INIT

#define PICO9918_FILL32_INIT (   inst,
  srcPtr 
)
Value:
do \
{ \
(inst).src = (srcPtr); \
(inst).count = 0; \
} while (0)

Definition at line 70 of file platform_std.h.

◆ PICO9918_FILL32_SET_COUNT

#define PICO9918_FILL32_SET_COUNT (   inst,
 
)
Value:
do \
{ \
(inst).count = (unsigned)(n); \
} while (0)

Definition at line 76 of file platform_std.h.

◆ PICO9918_FILL32_TRIGGER

#define PICO9918_FILL32_TRIGGER (   inst,
  dstPtr 
)
Value:
do \
{ \
uint32_t _v = *(const uint32_t*)(inst).src; \
uint32_t* _d = (uint32_t*)(dstPtr); \
for (unsigned _i = 0; _i < (inst).count; ++_i) _d[_i] = _v; \
} while (0)

Definition at line 82 of file platform_std.h.

◆ PICO9918_FILL32_WAIT

#define PICO9918_FILL32_WAIT (   inst)    ((void)0) /* TRIGGER is synchronous */

Definition at line 90 of file platform_std.h.

◆ PICO9918_DMA_CLAIM

#define PICO9918_DMA_CLAIM ( )    ((void)0)

Definition at line 93 of file platform_std.h.

◆ PICO9918_FILL_MASKS

#define PICO9918_FILL_MASKS   pico9918_fill_masks

Definition at line 103 of file platform_std.h.

◆ PICO9918_FILL_LINE

#define PICO9918_FILL_LINE   pico9918_fill_line

Definition at line 104 of file platform_std.h.

◆ PICO9918_COPY

#define PICO9918_COPY   pico9918_copy

Definition at line 117 of file platform_std.h.

◆ PICO9918_COPY_STATE

#define PICO9918_COPY_STATE ( )

Definition at line 120 of file platform_std.h.

◆ PICO9918_COPY_INIT

#define PICO9918_COPY_INIT (   inst)
Value:
do \
{ \
(inst).shift = 0u; \
} while (0)

Definition at line 121 of file platform_std.h.

◆ PICO9918_COPY_SET_WIDTH

#define PICO9918_COPY_SET_WIDTH (   inst,
  wordAligned 
)
Value:
do \
{ \
(inst).shift = (wordAligned) ? 2u : 0u; \
} while (0)

Definition at line 126 of file platform_std.h.

◆ PICO9918_COPY_SET_SRC

#define PICO9918_COPY_SET_SRC (   inst,
  srcPtr 
)
Value:
do \
{ \
(inst).src = (srcPtr); \
} while (0)

Definition at line 131 of file platform_std.h.

◆ PICO9918_COPY_SET_DST

#define PICO9918_COPY_SET_DST (   inst,
  dstPtr 
)
Value:
do \
{ \
(inst).dst = (dstPtr); \
} while (0)

Definition at line 136 of file platform_std.h.

◆ PICO9918_COPY_TRIGGER

#define PICO9918_COPY_TRIGGER (   inst,
 
)    memcpy((inst).dst, (inst).src, (size_t)(n) << (inst).shift)

Definition at line 141 of file platform_std.h.

◆ PICO9918_COPY_WAIT

#define PICO9918_COPY_WAIT (   inst)    ((void)0) /* TRIGGER is synchronous */

Definition at line 142 of file platform_std.h.

◆ PICO9918_DIVMOD_U32

#define PICO9918_DIVMOD_U32 (   n,
  d,
  q,
 
)
Value:
do \
{ \
uint32_t _n = (uint32_t)(n), _d = (uint32_t)(d); \
(q) = _n / _d; \
(r) = _n % _d; \
} while (0)

Definition at line 145 of file platform_std.h.

◆ PICO9918_PIXEL_T

#define PICO9918_PIXEL_T   PICO9918_PIXEL_T

Definition at line 168 of file platform_std.h.

◆ PICO9918_PIXEL_FROM_RGB12

#define PICO9918_PIXEL_FROM_RGB12 (   rgb)     ((PICO9918_PIXEL_T)(((rgb) & 0xFF0F) | ((((rgb) & 0xFF0F) >> 12) << 4)))

Definition at line 178 of file platform_std.h.

◆ PICO9918_PIXEL_FROM_RGB12_PAIR

#define PICO9918_PIXEL_FROM_RGB12_PAIR (   packed)
Value:
((((uint32_t)PICO9918_PIXEL_FROM_RGB12((packed) >> 16)) << 16) | \
(uint16_t)PICO9918_PIXEL_FROM_RGB12((uint16_t)(packed)))

Definition at line 185 of file platform_std.h.

◆ PICO9918_PIXEL_PAIR

#define PICO9918_PIXEL_PAIR (   p)    ((uint32_t)(p) * 0x10001u)

Definition at line 191 of file platform_std.h.

◆ PICO9918_LOW16

#define PICO9918_LOW16 (   x)    ((uint32_t)(uint16_t)(x))

Definition at line 195 of file platform_std.h.

◆ PICO9918_PIXEL_DARKEN

#define PICO9918_PIXEL_DARKEN (   p)    ((PICO9918_PIXEL_T)(((p) >> 2) & 0x333))

Definition at line 200 of file platform_std.h.

◆ PICO9918_PIXEL_PAIR_DIM

#define PICO9918_PIXEL_PAIR_DIM (   w)    (((w) >> 1) & 0x07770777u)

Definition at line 208 of file platform_std.h.

◆ PICO9918_INK_T

#define PICO9918_INK_T   PICO9918_INK_T

Definition at line 216 of file platform_std.h.

◆ PICO9918_INK_PIXELS

#define PICO9918_INK_PIXELS   2

Definition at line 217 of file platform_std.h.

◆ PICO9918_INK_FILL

#define PICO9918_INK_FILL (   fg)    PICO9918_PIXEL_PAIR(fg)

Definition at line 218 of file platform_std.h.

◆ PICO9918_INK_DARKEN

#define PICO9918_INK_DARKEN (   w)    (((w) >> 2) & 0x03330333u)

Definition at line 219 of file platform_std.h.

◆ PICO9918_INK_ONE

#define PICO9918_INK_ONE (   k)    (0xffffu << ((k) * 16))

Definition at line 220 of file platform_std.h.

◆ PICO9918_PALETTE_LUT_T

#define PICO9918_PALETTE_LUT_T   PICO9918_PALETTE_LUT_T

Definition at line 229 of file platform_std.h.

◆ PICO9918_EXPAND_INIT

#define PICO9918_EXPAND_INIT (   lut)    ((void)0)

Definition at line 234 of file platform_std.h.

◆ PICO9918_EXPAND_INDEXED

#define PICO9918_EXPAND_INDEXED (   dst,
  src,
  n,
  lut 
)
Value:
do \
{ \
const uint8_t* _s = (const uint8_t*)(src); \
const uint8_t* _e = _s + (n); \
uint32_t* _d = (uint32_t*)(dst); \
const PICO9918_PALETTE_LUT_T* _l = (lut); \
while (_s < _e) \
{ \
_d[0] = _l[_s[0]]; \
_d[1] = _l[_s[1]]; \
_d[2] = _l[_s[2]]; \
_d[3] = _l[_s[3]]; \
_d[4] = _l[_s[4]]; \
_d[5] = _l[_s[5]]; \
_d[6] = _l[_s[6]]; \
_d[7] = _l[_s[7]]; \
_d += 8; \
_s += 8; \
} \
} while (0)

Definition at line 242 of file platform_std.h.

◆ PICO9918_EXPAND_INDEXED_WIDE

#define PICO9918_EXPAND_INDEXED_WIDE (   dst,
  src,
  n,
  lut 
)
Value:
do \
{ \
const uint8_t* _s = (const uint8_t*)(src); \
uint32_t* _d = (uint32_t*)(dst); \
const PICO9918_PALETTE_LUT_T* _l = (lut); \
for (unsigned _i = 0; _i < (unsigned)(n); _i += 2) \
_d[_i / 2] = (_l[_s[_i]] & 0xffff) | (_l[_s[_i + 1]] << 16); \
} while (0)

Definition at line 271 of file platform_std.h.

◆ __force_inline

#define __force_inline   inline

Definition at line 318 of file platform_std.h.

Typedef Documentation

◆ PICO9918_PIXEL_T

typedef uint16_t PICO9918_PIXEL_T

Definition at line 167 of file platform_std.h.

◆ PICO9918_INK_T

typedef uint32_t PICO9918_INK_T

Definition at line 215 of file platform_std.h.

◆ PICO9918_PALETTE_LUT_T

typedef uint32_t PICO9918_PALETTE_LUT_T

Definition at line 228 of file platform_std.h.

Function Documentation

◆ time_us_32()

static uint32_t time_us_32 ( void  )
inlinestatic

Definition at line 298 of file platform_std.h.