1
2#include <stdio.h>
3#include <stdlib.h>
4
5const char *opcodes[] = {
6	"line_open",		/* 0000 */
7	"autoline_open",	/* 0001 */
8	"line_close",		/* 0010 */
9	"autoline_close",	/* 0011 */
10
11	"trapezoid",		/* 0100 */
12	"trapezoid texture map", /* 0101 */
13	"reserved trap",	/* 0110 */
14	"reserved trap",	/* 0111 */
15
16	"bitblt",		/* 1000 */
17	"iload",		/* 1001 */
18	"reserved",		/* 1010 */
19	"reserved",		/* 1011 */
20
21	"fbitblt",		/* 1100 */
22	"iload scale",		/* 1101 */
23	"reserved",		/* 1110 */
24	"iload filter"		/* 1111 */
25};
26
27const char *atype[] = {
28	"rpl - Write (Replace)",		/* 000 */
29	"rstr - read-modify-write (raster)",	/* 001 */
30	"reserved",	/* 010 */
31	"z1 - depth mode with gouraud",	/* 011 */
32	"blk - block write mode",	/* 100 */
33	"reserved",	/* 101 */
34	"reserved",	/* 110 */
35	"I - Gouraud (with depth compare)"	/* 111 */
36};
37
38const char *zmode[] = {
39	"NOZCMP - always",		/* 000 */
40	"reserved",	/* 001 */
41	"ZE - depth =",	/* 010 */
42	"zne - depth !=",	/* 011 */
43	"zlt",	/* 100 */
44	"zlte",	/* 101 */
45	"zgt",	/* 110 */
46	"zgte"	/* 111 */
47};
48
49const char *bop[] = {
50	"0",		/* 0000 */
51	"~(D|S)",	/* 0001 */
52	"D & ~S",	/* 0010 */
53	"~S",		/* 0011 */
54
55	"(~D) & S",	/* 0100 */
56	"~D",		/* 0101 */
57	"D ^ S",	/* 0110 */
58	"~ (D & S)",	/* 0111 */
59
60	"D & S",	/* 1000 */
61	"~(D^S)",	/* 1001 */
62	"D",		/* 1010 */
63	"D | ~S",	/* 1011 */
64
65	"S",		/* 1100 */
66	"(~D) | S",	/* 1101 */
67	"D | S",	/* 1110 */
68	"1"		/* 1111 */
69};
70
71const char *bitmod[] = {
72	"BMONOLEF - Source is mono, or if iload, source is little endian",	/* 0000 */
73	"BPLAN - source is mono from one plane",				/* 0001 */
74	"BFCOL - source is colour, and is formatted from host",			/* 0010 */
75	"BU32BGR - source is colour. For ILOAD, it's in 32bpp, BGR format",	/* 0011 */
76
77	"BMONOWEF - source is mono, or if iload, source is windows format",	/* 0100 */
78	"error! no such mode",	/* 0101 */
79	"error! no such mode",	/* 0110 */
80	"BU32RGB - source is colour, or if iload, source is 32 bpp RGB",	/* 0111 */
81
82	"error! no such mode",	/* 1000 */
83	"error! no such mode",	/* 1001 */
84	"error! no such mode",	/* 1010 */
85	"BU24BGR - source is colour, of if iload, source is 24 bpp BGR",	/* 1011 */
86
87	"error! no such mode",	/* 1100 */
88	"error! no such mode",	/* 1101 */
89	"BUYUV - source is color, or for ILOAD, it's in 4:2:2 YUV format",	/* 1110 */
90	"BU24RGB - source is color, or for ILOAD, it's in 24 bpp RGB"		/* 1111 */
91};
92
93int main(int argc, char **argv)
94{
95	unsigned long val, tmp;
96
97	if ( argc != 2 )
98	{
99		fprintf(stderr, "usage: %s hexval\n", argv[0]);
100		return 1;
101	}
102
103	val = strtoul(argv[1], NULL, 16);
104
105	printf("the val is : %lu\n", val);
106
107	/* opcode */
108
109	tmp = val & 0x0f;
110
111	printf("opcode: %s\n", opcodes[tmp]);
112
113	tmp = ( val >> 4 ) & 0x7;
114
115	printf("atype: %s\n", atype[tmp]);
116
117
118	if ( val & 128 )
119		printf("xy bitblt\n");
120	else
121		printf("linear bitblt\n");
122
123	tmp = ( val >> 8 ) & 7;
124
125	printf("zmode: %s\n", zmode[tmp]);
126
127
128	if ( val & ( 1 << 11 ) )
129		printf("solid line or constant trapezoid\n");
130	else
131		printf("src0 - 3 may need to be loaded");
132
133	if ( val & ( 1 << 12 ))
134		printf("ar0-ar6 = 0\n");
135	else
136		printf("you may need to set ar0-6.\n");
137
138
139	if ( val & ( 1 << 13 ))
140		printf("sgn = 0\n");
141	else
142		printf("sgn is not affected\n");
143
144
145	if ( val & ( 1 << 14 ))
146		printf("shift = 0\n");
147	else
148		printf("shift is not affected\n");
149
150
151	tmp = (val>>16) & 0x0f;
152
153	if ( ((val >> 4) & 7) == 4 && tmp != 0x0c )
154		printf("Error! Block (BLK) atype and non-source binary op chosen. Replace (S) bop will be used.\n");
155
156	printf("bop = %s, where ~ = bitwise complement, ^ = xor\n", bop[tmp]);
157
158	if ( ((val >> 20) & 0x0f) == 0 )
159		printf("opaque object\n");
160	else
161		printf("partially opaque object\n");
162
163	tmp = (val >> 25) & 0x0f;
164	printf("bitmod: %s\n", bitmod[tmp]);
165
166	if ((val >> 29) & 0x01)
167		printf("patterning enabled\n");
168	else
169		printf("patterning disabled\n");
170
171	if ((val >> 30) & 0x01)
172		printf("background colour is transparent\n");
173	else
174		printf("background colour is opaque\n");
175
176	return 0;
177}
178