1 /* $Id: text.c,v 1.15 2004-10-23 17:42:13 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.15 2004-10-23 17:42:13 schaffner Exp $";
41 #define SHAREWARE_TEXTSIZE 14677
45 char *Text_string[N_TEXT_STRINGS];
52 // rotates a byte left one bit, preserving the bit falling off the right
54 encode_rotate_left(char *c)
66 #define BITMAP_TBL_XOR 0xD3
68 //decode an encoded line of text of bitmaps.tbl
69 void decode_text_line(char *p)
72 encode_rotate_left(p);
73 *p = *p ^ BITMAP_TBL_XOR;
74 encode_rotate_left(p);
78 #if !defined(_MSC_VER) && !defined(macintosh)
81 //load all the text strings for Descent
86 int len,i, have_binary = 0;
88 char *filename="descent.tex";
90 if ((i=FindArg("-text"))!=0)
93 if ((tfile = cfopen(filename,"rb")) == NULL) {
94 filename="descent.txb";
95 if ((ifile = cfopen(filename, "rb")) == NULL) {
96 Warning("Cannot open file DESCENT.TEX or DESCENT.TXB");
101 len = cfilelength(ifile);
103 MALLOC(text,char,len);
107 cfread(text,1,len,ifile);
115 len = cfilelength(tfile);
117 MALLOC(text,char,len);
121 //fread(text,1,len,tfile);
132 for (i=0,tptr=text;i<N_TEXT_STRINGS;i++) {
135 Text_string[i] = tptr;
137 tptr = strchr(tptr,'\n');
141 if (i == 644) break; /* older datafiles */
143 Error("Not enough strings in text file - expecting %d, found %d\n", N_TEXT_STRINGS, i);
146 if ( tptr ) *tptr++ = 0;
149 decode_text_line(Text_string[i]);
151 //scan for special chars (like \n)
152 for (p=Text_string[i];(p=strchr(p,'\\'));) {
155 if (p[1] == 'n') newchar = '\n';
156 else if (p[1] == 't') newchar = '\t';
157 else if (p[1] == '\\') newchar = '\\';
159 Error("Unsupported key sequence <\\%c> on line %d of file <%s>",p[1],i+1,filename);
171 if (len == SHAREWARE_TEXTSIZE)
173 Text_string[173] = Text_string[172];
174 Text_string[172] = Text_string[171];
175 Text_string[171] = Text_string[170];
176 Text_string[170] = Text_string[169];
177 Text_string[169] = "Windows Joystick";
180 Text_string[644] = "Z1";
181 Text_string[645] = "UN";
182 Text_string[646] = "P1";
183 Text_string[647] = "R1";
184 Text_string[648] = "Y1";
187 //Assert(tptr==text+len || tptr==text+len-2);