1 /* $Id: text.c,v 1.11 2003-11-26 12:26:33 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Code for localizable text
20 * Revision 1.1 1995/05/16 15:31:44 allender
23 * Revision 2.0 1995/02/27 11:33:09 john
24 * New version 2.0, which has no anonymous unions, builds with
25 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
27 * Revision 1.11 1994/12/14 12:53:23 matt
28 * Improved error handling
30 * Revision 1.10 1994/12/09 18:36:44 john
31 * Added code to make text read from hogfile.
33 * Revision 1.9 1994/12/08 20:56:34 john
36 * Revision 1.8 1994/12/08 17:20:06 yuan
39 * Revision 1.7 1994/12/05 15:10:36 allender
40 * support encoded descent.tex file (descent.txb)
42 * Revision 1.6 1994/12/01 14:18:34 matt
43 * Now support backslash chars in descent.tex file
45 * Revision 1.5 1994/10/27 00:13:10 john
48 * Revision 1.4 1994/07/11 15:33:49 matt
49 * Put in command-line switch to load different text files
51 * Revision 1.3 1994/07/10 09:56:25 yuan
52 * #include <stdio.h> added for FILE type.
54 * Revision 1.2 1994/07/09 22:48:14 matt
55 * Added localizable text
57 * Revision 1.1 1994/07/09 21:30:46 matt
68 static char rcsid[] = "$Id: text.c,v 1.11 2003-11-26 12:26:33 btb Exp $";
84 #define SHAREWARE_TEXTSIZE 14677
88 char *Text_string[N_TEXT_STRINGS];
95 // rotates a byte left one bit, preserving the bit falling off the right
97 encode_rotate_left(char *c)
109 //decode and encoded line of text
110 void decode_text_line(char *p)
113 encode_rotate_left(p);
114 *p = *p ^ BITMAP_TBL_XOR;
115 encode_rotate_left(p);
122 //load all the text strings for Descent
127 int len,i, have_binary = 0;
129 char *filename="descent.tex";
131 if ((i=FindArg("-text"))!=0)
132 filename = Args[i+1];
134 if ((tfile = cfopen(filename,"rb")) == NULL) {
135 filename="descent.txb";
136 if ((ifile = cfopen(filename, "rb")) == NULL) {
137 Warning("Cannot open file DESCENT.TEX or DESCENT.TXB");
142 len = cfilelength(ifile);
144 MALLOC(text,char,len);
148 cfread(text,1,len,ifile);
156 len = cfilelength(tfile);
158 MALLOC(text,char,len);
162 //fread(text,1,len,tfile);
173 for (i=0,tptr=text;i<N_TEXT_STRINGS;i++) {
176 Text_string[i] = tptr;
178 tptr = strchr(tptr,'\n');
182 if (i == 644) break; /* older datafiles */
184 Error("Not enough strings in text file - expecting %d, found %d\n", N_TEXT_STRINGS, i);
187 if ( tptr ) *tptr++ = 0;
190 decode_text_line(Text_string[i]);
192 //scan for special chars (like \n)
193 for (p=Text_string[i];(p=strchr(p,'\\'));) {
196 if (p[1] == 'n') newchar = '\n';
197 else if (p[1] == 't') newchar = '\t';
198 else if (p[1] == '\\') newchar = '\\';
200 Error("Unsupported key sequence <\\%c> on line %d of file <%s>",p[1],i+1,filename);
212 if (len == SHAREWARE_TEXTSIZE)
214 Text_string[173] = Text_string[172];
215 Text_string[172] = Text_string[171];
216 Text_string[171] = Text_string[170];
217 Text_string[170] = Text_string[169];
218 Text_string[169] = "Windows Joystick";
221 Text_string[644] = "Z1";
222 Text_string[645] = "UN";
223 Text_string[647] = "P1";
224 Text_string[648] = "R1";
225 Text_string[649] = "Y1";
228 //Assert(tptr==text+len || tptr==text+len-2);