32#define MAP_AT(FIELD) ((uint32_t)offsetof(pico9918_mem_map_t, FIELD))
34#define DEBUG_RW (PICO9918_DEBUG_READABLE | PICO9918_DEBUG_WRITABLE)
43 {MAP_AT(pram), DEBUG_RW},
46 {MAP_AT(status), DEBUG_RW},
48 {(uint32_t)
sizeof(((pico9918_t*)0)->vram), DEBUG_RW},
53uint32_t pico9918_debug_region(uint32_t addr, uint32_t* end)
55 for (
unsigned i = 0; i <
sizeof(debugMap) /
sizeof(debugMap[0]); ++i)
57 if (addr < debugMap[i].end)
59 if (end) *end = debugMap[i].end;
60 return debugMap[i].flags;
75 if (!out || len == 0 || addr >= size)
return 0;
77 size_t count = size - addr;
78 if (count > len) count = len;
80 const uint8_t*
const from = (
const uint8_t*)&tms9918->vram + addr;
81 for (
size_t i = 0; i < count; ++i) out[i] = from[i];
98 const uint32_t flags = pico9918_debug_region(addr, &end);
102 size_t run = (size_t)(end - addr);
103 if (run > len - done) run = len - done;
105 uint8_t*
const to = (uint8_t*)&tms9918->vram + addr;
106 for (
size_t i = 0; i < run; ++i) to[i] = in[done + i];
112 addr += (uint32_t)run;
122 if (reg >= TMS_REGISTERS)
return 0;
124 return TMS_REGISTER(tms9918, reg);
131 if (reg >= TMS_REGISTERS)
return false;
133 TMS_REGISTER(tms9918, reg) = value;
135 tms9918->palDirty = 1;
148 return __builtin_bswap16(tms9918->vram.map.pram[index]);
162 return tms9918->restart != 0;
169 tms9918->gpuAddress = pc & 0xFFFE;
uint32_t pico9918_gpu_mem_size(void)
see the header.
#define PICO9918_INST_ARG
declare the instance ahead of other parameters
#define PICO9918_INST_ONLY
pass the instance as the only argument
#define PICO9918_R47_INDEX
first palette index to write
#define PICO9918_INST_ONLY_ARG
declare the instance as the only parameter
#define PICO9918_INST
pass the instance ahead of other arguments
#define PICO9918_DLLEXPORT
the linkage every public entry point carries - see LINKAGE MODES above
pico9918-core - debugger access
#define PICO9918_DEBUG_STATUS
the status file, which the library owns
#define PICO9918_DEBUG_WRITABLE
pico9918_debug_write stores here
#define PICO9918_DEBUG_REGISTERS
the register file - use pico9918_debug_reg_write
#define PICO9918_DEBUG_READABLE
pico9918_debug_read returns real bytes here
#define PICO9918_DEBUG_PALETTE
PRAM - a write here republishes the palette.
pico9918-core - the private instance layout
PICO9918_INLINE_HOT uint32_t pico9918_cpu_vram_addr_impl(pico9918_t *tms9918, uint32_t addr)
where a CPU-side VRAM access lands
PICO9918_INLINE void pico9918_write_reconcile_int_impl(pico9918_t *tms9918)
bring /INT into agreement after a write that can change the predicate.
void pico9918_debug_sync_mode_impl(pico9918_t *tms9918)
see impl/pico9918_priv.h.