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