summaryrefslogtreecommitdiff
path: root/lib/libgfxd/priv.h
blob: 34d96f675c476c578afd8d7a0f4d7f3a6ba42715 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef GFXD_PRIV_H
#define GFXD_PRIV_H
#include "gfxd.h"

#define CONFIG_MT

#ifdef CONFIG_MT
# ifdef _MSC_VER
#  define TLOCAL __declspec(thread)
# else
#  define TLOCAL _Thread_local
# endif
#else
#define TLOCAL
#endif

#define UCFUNC static inline

#define config gfxd_config__

typedef int gfxd_argfn_t(const gfxd_value_t *v);

typedef struct
{
	int		fmt;
	gfxd_argfn_t *	fn;
} gfxd_arg_type_t;

typedef struct
{
	int		type;
	const char *	name;
	gfxd_value_t	value;
	int		bad;
} gfxd_arg_t;

typedef struct
{
	int		id;
	gfxd_arg_t	arg[18];
} gfxd_macro_t;

typedef int gfxd_disas_fn_t(gfxd_macro_t *macro, uint32_t hi, uint32_t lo);
typedef int gfxd_combine_fn_t(gfxd_macro_t *macro, int n_macro);

typedef struct
{
	const char *		prefix;
	const char *		suffix;
	int			opcode;
	int			n_arg;
	int			n_gfx;
	gfxd_disas_fn_t *	disas_fn;
	gfxd_combine_fn_t *	combine_fn;
	int			alias;
	int			ext;
} gfxd_macro_type_t;

struct gfxd_ucode
{
	gfxd_disas_fn_t *		disas_fn;
	gfxd_combine_fn_t *		combine_fn;
	const gfxd_arg_type_t *		arg_tbl;
	const gfxd_macro_type_t *	macro_tbl;
};

struct gfxd_state
{
	int			macro_offset;

	Gfx			gfx[9];
	int			n_byte;
	int			n_gfx;
	gfxd_macro_t		macro[9];

	int			end_input;
	int			ret;
};

struct gfxd_config
{
	gfxd_ucode_t		ucode;
	int			endian;
	int			wordsize;
	const char *		arg;
	void *			udata;

	int			stop_on_invalid;
	int			stop_on_end;
	int			emit_dec_color;
	int			emit_q_macro;
	int			emit_ext_macro;

	const char *		input_buf;
	int			input_buf_size;
	int			input_fd;
	gfxd_input_fn_t *	input_fn;

	char *			output_buf;
	int			output_buf_size;
	int			output_fd;
	gfxd_output_fn_t *	output_fn;

	gfxd_macro_fn_t *	macro_fn;
	gfxd_arg_fn_t *		arg_fn;

	gfxd_tlut_fn_t *	tlut_fn;
	gfxd_timg_fn_t *	timg_fn;
	gfxd_cimg_fn_t *	cimg_fn;
	gfxd_zimg_fn_t *	zimg_fn;
	gfxd_dl_fn_t *		dl_fn;
	gfxd_mtx_fn_t *		mtx_fn;
	gfxd_lookat_fn_t *	lookat_fn;
	gfxd_light_fn_t *	light_fn;
	gfxd_seg_fn_t *		seg_fn;
	gfxd_vtx_fn_t *		vtx_fn;
	gfxd_vp_fn_t *		vp_fn;
	gfxd_uctext_fn_t *	uctext_fn;
	gfxd_ucdata_fn_t *	ucdata_fn;
	gfxd_dram_fn_t *	dram_fn;
};

extern TLOCAL struct gfxd_config gfxd_config__;

#endif