2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 * Code for localizable text
35 #define SHAREWARE_TEXTSIZE 14677
39 char *Text_string[N_TEXT_STRINGS];
46 // rotates a byte left one bit, preserving the bit falling off the right
48 encode_rotate_left(char *c)
60 #define BITMAP_TBL_XOR 0xD3
62 //decode an encoded line of text of bitmaps.tbl
63 void decode_text_line(char *p)
66 encode_rotate_left(p);
67 *p = *p ^ BITMAP_TBL_XOR;
68 encode_rotate_left(p);
72 // decode buffer of text, preserves newlines
73 void decode_text(char *buf, int len)
78 for (i = 0, ptr = buf; i < len; i++, ptr++)
82 encode_rotate_left(ptr);
83 *ptr = *ptr ^ BITMAP_TBL_XOR;
84 encode_rotate_left(ptr);
90 #if !defined(_MSC_VER) && !defined(macintosh)
93 //load all the text strings for Descent
98 int len,i, have_binary = 0;
100 char *filename="descent.tex";
102 if ((i=FindArg("-text"))!=0)
103 filename = Args[i+1];
105 if ((tfile = cfopen(filename,"rb")) == NULL) {
106 filename="descent.txb";
107 if ((ifile = cfopen(filename, "rb")) == NULL) {
108 Error("Cannot open file DESCENT.TEX or DESCENT.TXB");
113 len = cfilelength(ifile);
115 MALLOC(text,char,len);
119 cfread(text,1,len,ifile);
127 len = cfilelength(tfile);
129 MALLOC(text,char,len);
133 //fread(text,1,len,tfile);
144 for (i=0,tptr=text;i<N_TEXT_STRINGS;i++) {
147 Text_string[i] = tptr;
149 tptr = strchr(tptr,'\n');
153 if (i == 644) break; /* older datafiles */
155 Error("Not enough strings in text file - expecting %d, found %d\n", N_TEXT_STRINGS, i);
158 if ( tptr ) *tptr++ = 0;
161 decode_text_line(Text_string[i]);
163 //scan for special chars (like \n)
164 for (p=Text_string[i];(p=strchr(p,'\\'));) {
167 if (p[1] == 'n') newchar = '\n';
168 else if (p[1] == 't') newchar = '\t';
169 else if (p[1] == '\\') newchar = '\\';
171 Error("Unsupported key sequence <\\%c> on line %d of file <%s>",p[1],i+1,filename);
175 //shift rest of string to left
176 for (q = p+1; *q; q++) {
188 if (len == SHAREWARE_TEXTSIZE)
190 Text_string[173] = Text_string[172];
191 Text_string[172] = Text_string[171];
192 Text_string[171] = Text_string[170];
193 Text_string[170] = Text_string[169];
194 Text_string[169] = "Windows Joystick";
197 Text_string[644] = "Z1";
198 Text_string[645] = "UN";
199 Text_string[646] = "P1";
200 Text_string[647] = "R1";
201 Text_string[648] = "Y1";
204 //Assert(tptr==text+len || tptr==text+len-2);