1 /* $Id: text.c,v 1.14 2004-10-14 16:43:23 schaffner 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
26 static char rcsid[] = "$Id: text.c,v 1.14 2004-10-14 16:43:23 schaffner Exp $";
42 #define SHAREWARE_TEXTSIZE 14677
46 char *Text_string[N_TEXT_STRINGS];
53 // rotates a byte left one bit, preserving the bit falling off the right
55 encode_rotate_left(char *c)
67 //decode and encoded line of text
68 void decode_text_line(char *p)
71 encode_rotate_left(p);
72 *p = *p ^ BITMAP_TBL_XOR;
73 encode_rotate_left(p);
77 #if !defined(_MSC_VER) && !defined(macintosh)
80 //load all the text strings for Descent
85 int len,i, have_binary = 0;
87 char *filename="descent.tex";
89 if ((i=FindArg("-text"))!=0)
92 if ((tfile = cfopen(filename,"rb")) == NULL) {
93 filename="descent.txb";
94 if ((ifile = cfopen(filename, "rb")) == NULL) {
95 Warning("Cannot open file DESCENT.TEX or DESCENT.TXB");
100 len = cfilelength(ifile);
102 MALLOC(text,char,len);
106 cfread(text,1,len,ifile);
114 len = cfilelength(tfile);
116 MALLOC(text,char,len);
120 //fread(text,1,len,tfile);
131 for (i=0,tptr=text;i<N_TEXT_STRINGS;i++) {
134 Text_string[i] = tptr;
136 tptr = strchr(tptr,'\n');
140 if (i == 644) break; /* older datafiles */
142 Error("Not enough strings in text file - expecting %d, found %d\n", N_TEXT_STRINGS, i);
145 if ( tptr ) *tptr++ = 0;
148 decode_text_line(Text_string[i]);
150 //scan for special chars (like \n)
151 for (p=Text_string[i];(p=strchr(p,'\\'));) {
154 if (p[1] == 'n') newchar = '\n';
155 else if (p[1] == 't') newchar = '\t';
156 else if (p[1] == '\\') newchar = '\\';
158 Error("Unsupported key sequence <\\%c> on line %d of file <%s>",p[1],i+1,filename);
170 if (len == SHAREWARE_TEXTSIZE)
172 Text_string[173] = Text_string[172];
173 Text_string[172] = Text_string[171];
174 Text_string[171] = Text_string[170];
175 Text_string[170] = Text_string[169];
176 Text_string[169] = "Windows Joystick";
179 Text_string[644] = "Z1";
180 Text_string[645] = "UN";
181 Text_string[646] = "P1";
182 Text_string[647] = "R1";
183 Text_string[648] = "Y1";
186 //Assert(tptr==text+len || tptr==text+len-2);