44#define ACTIVE_LINES 192
45#define FRAME_LINES 262
49#define CMD_REGISTER 0x80
50#define CMD_VRAM_READ 0x00
51#define CMD_VRAM_WRITE 0x40
67#if PICO9918_SINGLE_INSTANCE
71 if (!tms9918)
return 1;
89 static const uint8_t glyph[8] = {0x3c, 0x42, 0x81, 0xa5, 0x81, 0x99, 0x42, 0x3c};
102 printf(
"read back 0x%02X 0x%02X (wrote 0x%02X 0x%02X)\n", first, second, glyph[0], glyph[1]);
106 unsigned lit = 0, acks = 0;
107 for (uint16_t y = 0; y < FRAME_LINES; ++y)
109 if (y < ACTIVE_LINES)
114 if ((line[x] & 0x0f) != 0x04) ++lit;
116 else if (y == ACTIVE_LINES)
126 printf(
"line %u: /INT, SR0 0x%02X, now %s\n", y, sr0,
131 printf(
"%u lit pixels, %u interrupt%s in one frame\n", lit, acks, acks == 1 ?
"" :
"s");
136 printf(
"masked in R1: /INT %s, SR0 still 0x%02X\n",
140#if !PICO9918_SINGLE_INSTANCE
uint8_t pico9918_peek_status(pico9918_t *tms9918)
read from the status register without resetting it
uint8_t pico9918_read_data(pico9918_t *tms9918)
read data (mode = 0) from the tms9918
void pico9918_destroy(pico9918_t *tms9918)
destroy a TMS9918
void pico9918_write_addr(pico9918_t *tms9918, uint8_t data)
write an address (mode = 1) to the tms9918
const uint8_t * pico9918_line_source(pico9918_t *tms9918)
where the scanline just generated actually is.
void pico9918_interrupt_set(pico9918_t *tms9918)
raise the INT status flag
uint32_t pico9918_line_bytes(pico9918_t *tms9918)
how many bytes of pixels[] this mode fills.
uint8_t pico9918_scan_line(pico9918_t *tms9918, uint16_t y)
generate a scanline
void pico9918_reset(pico9918_t *tms9918)
reset the new TMS9918
uint8_t pico9918_read_status(pico9918_t *tms9918)
read from the status register
bool pico9918_interrupt_status(pico9918_t *tms9918)
return true if both INT status and INT control set
void pico9918_write_data(pico9918_t *tms9918, uint8_t data)
write data (mode = 0) to the tms9918
pico9918-core - core interface
pico9918_t * pico9918_new(void)
create a new TMS9918
#define PICO9918_INST_ARG
declare the instance ahead of other parameters
#define PICO9918_INST_ONLY
pass the instance as the only argument
#define PICO9918_INST
pass the instance ahead of other arguments