1188
|
1 /*
|
|
2 * viewgif.h -- common header fodder for viewgif
|
|
3 */
|
|
4
|
|
5 #include <stdio.h>
|
|
6
|
|
7 #ifdef OSK
|
|
8 /* the OS-9/68000 C compiler knows about void now! */
|
|
9 #define DIRECT
|
|
10 typedef unsigned char BYTE;
|
|
11 #define arith(byte) (byte)
|
|
12 #else
|
|
13 typedef int void;
|
|
14 #define DIRECT direct
|
|
15 typedef char BYTE;
|
|
16 #define arith(byte) ((byte) & 0xff)
|
|
17 #endif
|
|
18
|
|
19 /* the canonical dodge for being sure of exactly one defining declaration */
|
|
20
|
|
21 #ifndef EXTERN
|
|
22 #define EXTERN extern
|
|
23 #endif
|
|
24
|
|
25 typedef char bool; /* make up for a C deficiency */
|
|
26
|
|
27 #define FALSE (1 == 0)
|
|
28 #define TRUE (!FALSE)
|
|
29
|
|
30 #define elements(array) (sizeof(array) / sizeof(array[0]))
|
|
31 #define maxnum(bits) ((1 << (bits)) - 1)
|
|
32
|
|
33 /*
|
|
34 * typedef to let us look at RGB colors two ways--one, as an array of
|
|
35 * components; two, as a structure with nameable components.
|
|
36 */
|
|
37
|
|
38 typedef union {
|
|
39 BYTE rgbarr[3];
|
|
40 struct {
|
|
41 BYTE rval, gval, bval;
|
|
42 } rgbstr;
|
|
43 } rgbcolor;
|
|
44
|
|
45 #define red rgbstr.rval
|
|
46 #define green rgbstr.gval
|
|
47 #define blue rgbstr.bval
|
|
48
|
|
49 /* Values and variables related to the GIF spec */
|
|
50
|
|
51 #define MGCLUT 256 /* maximum number of colors in a GIF picture */
|
|
52 #define GBITS 8 /* # of bits in each component of a GIF color */
|
|
53 #define MCODE 4096 /* number of 12-bit LZ codes */
|
|
54
|
|
55 typedef struct cstruct {
|
|
56 struct cstruct *prefix;
|
|
57 char first, suffix;
|
|
58 } codetype;
|
|
59
|
|
60 EXTERN bool coloruse[MGCLUT]; /* flags colors in use */
|
|
61 EXTERN bool globuse[MGCLUT]; /* global usage flag */
|
|
62 EXTERN rgbcolor globclut[MGCLUT]; /* RGB colors in image */
|
|
63 EXTERN DIRECT int globbits; /* # bits for global color map */
|
|
64 EXTERN DIRECT int globcolors; /* # possible colors */
|
|
65 EXTERN DIRECT unsigned imagwid, imaghigh; /* image width/height in pixels */
|
|
66
|
|
67 EXTERN codetype codetab[MCODE]; /* LZ code table */
|
|
68 EXTERN BYTE codestk[MCODE]; /* buffer for decoded bytes */
|
|
69 EXTERN DIRECT int codesize; /* LZ code size in bits */
|
|
70 EXTERN DIRECT int codemask; /* LZ code mask */
|
|
71 EXTERN DIRECT int clear; /* code for code table clear */
|
|
72 EXTERN DIRECT int eoi; /* code for end of image */
|
|
73 EXTERN DIRECT int datasize; /* ??? */
|
|
74
|
|
75 /* Now for CoCo-related stuff... */
|
|
76
|
|
77 #define MCCLUT 16 /* max size of Color Look-Up Table on CoCo 3 */
|
|
78 #define CBITS 2 /* # of bits in each component of a CoCo 3 color */
|
|
79 #define MROWS 192 /* max number of rows we can display */
|
|
80 #define MCOLS 640 /* max number of cols we can display */
|
|
81
|
|
82 #define MSCREENS 2 /* number of screens we may cycle among */
|
|
83
|
|
84 /* type to hold the CoCo encoding of a color */
|
|
85
|
|
86 typedef BYTE colorcode;
|
|
87
|
|
88 /*
|
|
89 * type to represent the screens that will collectively contain the
|
|
90 * GIF image for display--we add one to the sizes of the arrays for
|
|
91 * palettes to try to speed up the search for color mappings (see
|
|
92 * setmap.c functions)
|
|
93 */
|
|
94
|
|
95 typedef struct {
|
|
96 int winpath; /* path # for window to display on */
|
|
97 int clutsize; /* colors actually used */
|
|
98 rgbcolor clut[MCCLUT]; /* their RGB values */
|
|
99 colorcode pal[MCCLUT]; /* their CoCo encodings */
|
|
100 } cocoscreen;
|
|
101
|
|
102 typedef struct {
|
|
103 char addval;
|
|
104 char clutval[MSCREENS];
|
|
105 } xlate;
|
|
106
|
|
107 EXTERN cocoscreen screen[MSCREENS]; /* screens to be cycled among */
|
|
108 EXTERN int ilevtab[MROWS + 1]; /* interleave table */
|
|
109 EXTERN int xtab[MCOLS]; /* ??? */
|
|
110 EXTERN int linestor[MCOLS]; /* ??? */
|
|
111 EXTERN xlate transtab[MGCLUT][5]; /* translations of GIF colors */
|
|
112 EXTERN char randtab[16][16]; /* pseudo-random table */
|
|
113
|
|
114 /* non-scan line values for ilevtab[] */
|
|
115 #define ILEVMISS (-1) /* marks scan lines missed */
|
|
116 /* in readimag() scaling loops */
|
|
117 #define ILEVEND (-20) /* end marker guaranteed not */
|
|
118 /* to match a valid scan line */
|
|
119 /* or ILEVMISS! */
|
|
120
|
|
121 /* conversion between GIF's RGB space and the CoCo's RGB space */
|
|
122 #define SCALE1 (maxnum(GBITS) / maxnum(CBITS))
|
|
123 #define SCALE2 (SCALE1 / 2)
|
|
124
|
|
125 /* limits */
|
|
126
|
|
127 /* dithering factor */
|
|
128 #define MAXDITH1 (SCALE1 / 2)
|
|
129 #define MAXDITH2 (SCALE2 / 2)
|
|
130 #define BOGUSDITH 127 /* end marker for addval */
|
|
131 /* color tolerance (represented by negative "dithering factor") */
|
|
132 #define MAXTOL1 SCALE1
|
|
133 #define MAXTOL2 SCALE2
|
|
134 /* magnification factor */
|
|
135 #define MINMAG 1
|
|
136 #define MAXMAG 64
|
|
137 /* brightness */
|
|
138 #define MINBRITE 1
|
|
139 #define MAXBRITE 16
|
|
140 /* starting coordinates (units: 64ths of the image size along the axis) */
|
|
141 #define MINCOORD 1
|
|
142 #define MAXCOORD 64
|
|
143
|
|
144 /* some symbolic names for the values of some twistable knobs */
|
|
145
|
|
146 #define NO_INFO 0
|
|
147 #define SOME_INFO 1
|
|
148 #define MUCH_INFO 2
|
|
149
|
|
150 #define NO_GRAY 0
|
|
151 #define AVG_GRAY 1
|
|
152 #define MAX_GRAY 2
|
|
153 #define NTSC_GRAY 3
|
|
154
|
|
155 /* default values */
|
|
156
|
|
157 #define D_INFO SOME_INFO
|
|
158 #define D_GRAY NO_GRAY
|
|
159 #define D_BRITE MAXBRITE
|
|
160 #define D_DITHER MAXDITH1
|
|
161 #define D_MAG MINMAG
|
|
162 #define D_HEIGHT MROWS
|
|
163
|
|
164 EXTERN DIRECT FILE *infile; /* file containing GIF image */
|
|
165 EXTERN DIRECT long clutpos; /* position of global CLUT in file */
|
|
166 EXTERN DIRECT int infomode; /* control amount of commentary */
|
|
167 EXTERN DIRECT int graytype; /* what kind of gray scale, if any */
|
|
168 EXTERN DIRECT int dfactor; /* dithering factor */
|
|
169 EXTERN DIRECT int maxdith; /* upper bound on random dither */
|
|
170 EXTERN DIRECT int magfact; /* magnification factor */
|
|
171 EXTERN DIRECT int britefac; /* brightness factor */
|
|
172 EXTERN DIRECT int startx, starty; /* coord to map to top left corner */
|
|
173 EXTERN DIRECT bool realrand; /* use random #s instead of table */
|
|
174 EXTERN DIRECT bool flicker; /* cycle among screens */
|
|
175 EXTERN DIRECT bool dispon; /* display the image */
|
|
176 EXTERN DIRECT bool zapmap; /* overwrite unused map colors */
|
|
177 EXTERN DIRECT bool vefon; /* save the image in VEF fmt */
|
|
178 EXTERN DIRECT bool aligned; /* align to pixels */
|
|
179 EXTERN DIRECT bool newscrn; /* switch to new window for display */
|
|
180 EXTERN DIRECT char *usefname; /* to name of color usage file */
|
|
181 EXTERN DIRECT char *vefname; /* to name of VEF output file */
|
|
182 EXTERN DIRECT int mywidth, myheight; /* width, height we will display */
|
|
183 EXTERN DIRECT int actwin; /* path for buffered gfx data */
|
|
184 EXTERN DIRECT int groupnum, bufnum; /* get/put buffer information */
|
|
185 EXTERN DIRECT int framenum; /* frame number--whatever that is */
|
|
186 EXTERN DIRECT char *gpbufptr; /* pointer to get/put buffer */
|
|
187 EXTERN DIRECT int gmode; /* graphics mode we're using */
|
|
188 EXTERN DIRECT int newuse; /* ??? */
|
|
189 EXTERN DIRECT bool (*approx)(); /* to color approximation function */
|
|
190 EXTERN DIRECT int minmod; /* modulus for minadd() */
|
|
191 EXTERN DIRECT int low0, up0; /* default upper/lower limits for */
|
|
192 /* approximation searches */
|
|
193 extern bool approx1(); /* one-screen approximation */
|
|
194 extern bool approx2(); /* two-screen approximation */
|
|
195
|
|
196 /* miscellanea for support routines */
|
|
197 #define fatal(s) error((s), 1) /* fatal error (no natural errno) */
|