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.
19 static char rcsid[] = "$Id: text.c,v 1.5 2002-07-16 20:47:27 bradleyb Exp $";
38 char *Text_string[N_TEXT_STRINGS];
45 // rotates a byte left one bit, preserving the bit falling off the right
47 encode_rotate_left(char *c)
59 //decode and encoded line of text
60 void decode_text_line(char *p)
63 encode_rotate_left(p);
64 *p = *p ^ BITMAP_TBL_XOR;
65 encode_rotate_left(p);
70 //load all the text strings for Descent
75 int len,i, have_binary = 0;
77 char *filename="descent.tex";
79 if ((i=FindArg("-text"))!=0)
82 if ((tfile = cfopen(filename,"rb")) == NULL) {
83 filename="descent.txb";
84 if ((ifile = cfopen(filename, "rb")) == NULL) {
85 Error("Cannot open file DESCENT.TEX or DESCENT.TXB\nIs descent2.hog in %s?", AltHogdir_initialized?AltHogDir:"current directory");
89 len = cfilelength(ifile);
91 MALLOC(text,char,len);
95 cfread(text,1,len,ifile);
103 len = cfilelength(tfile);
105 MALLOC(text,char,len);
109 //fread(text,1,len,tfile);
120 for (i=0,tptr=text;i<N_TEXT_STRINGS;i++) {
123 Text_string[i] = tptr;
125 tptr = strchr(tptr,'\n');
127 #ifdef MACINTOSH // total hack for mac patch since they don't want to patch data.
128 if (!tptr && (i == 644) )
133 Warning("Not enough strings in text file - expecting %d, found %d\nThis probably means you have the wrong version of the descent 2 datafiles. You need version 1.2\n",N_TEXT_STRINGS,i);
138 if ( tptr ) *tptr++ = 0;
141 decode_text_line(Text_string[i]);
143 //scan for special chars (like \n)
144 for (p=Text_string[i];(p=strchr(p,'\\'));) {
147 if (p[1] == 'n') newchar = '\n';
148 else if (p[1] == 't') newchar = '\t';
149 else if (p[1] == '\\') newchar = '\\';
151 Error("Unsupported key sequence <\\%c> on line %d of file <%s>",p[1],i+1,filename);
160 // Assert(tptr==text+len || tptr==text+len-2);