-
Notifications
You must be signed in to change notification settings - Fork 0
/
tms9918.h
64 lines (51 loc) · 1.53 KB
/
tms9918.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef _TMS9918_H
#define _TMS9918_H
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "z80.h"
#define TMS9918_VRAM_MAX 0x4000
typedef enum {
TMS9918_MODE_UNKNOWN,
TMS9918_MODE_GRAPHICS_I,
TMS9918_MODE_GRAPHICS_II,
TMS9918_MODE_MULTICOLOR,
TMS9918_MODE_TEXT,
} tms9918_mode_t;
typedef struct tms9918_s {
uint8_t vram[TMS9918_VRAM_MAX];
uint16_t vram_address;
uint8_t vram_read_ahead;
bool ctrl_latched;
uint8_t ctrl_latch;
bool interrupt_flag;
bool fifth_sprite_flag;
bool coincidence_flag;
uint8_t fifth_sprite_number;
bool mode_bit[3];
tms9918_mode_t mode;
bool blank;
bool interrupt_enable;
bool sprite_size;
bool sprite_mag;
uint16_t ntba; /* Name Table Base Address */
uint16_t ctba; /* Color Table Base Address */
uint16_t pgba; /* Pattern Generator Base Address */
uint16_t satba; /* Sprite Attribute Table Base Address */
uint16_t spgba; /* Sprite Pattern Generator Base Address */
uint8_t text_color_0;
uint8_t text_color_1;
uint16_t pixel_clock;
uint16_t scanline;
uint32_t frame_no;
bool frame_ready;
} tms9918_t;
void tms9918_init(tms9918_t *tms9918, z80_t *z80);
void tms9918_execute(tms9918_t *tms9918);
void tms9918_dump(FILE *fh, tms9918_t *tms9918);
void tms9918_dump_vram(FILE *fh, tms9918_t *tms9918,
uint16_t start, uint16_t end);
void tms9918_dump_patterns(FILE *fh, tms9918_t *tms9918, bool sprites);
void tms9918_dump_sprites(FILE *fh, tms9918_t *tms9918);
void tms9918_dump_name_table(FILE *fh, tms9918_t *tms9918);
#endif /* _TMS9918_H */