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.3 2001-01-31 15:17:59 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);
69 //load all the text strings for Descent
74 int len,i, have_binary = 0;
76 char *filename="descent.tex";
78 if ((i=FindArg("-text"))!=0)
81 if ((tfile = cfopen(filename,"rb")) == NULL) {
82 filename="descent.txb";
83 if ((ifile = cfopen(filename, "rb")) == NULL)
84 Error("Cannot open file DESCENT.TEX or DESCENT.TXB\nIs descent2.hog in your current directory?");
87 len = cfilelength(ifile);
89 MALLOC(text,char,len);
93 cfread(text,1,len,ifile);
101 len = cfilelength(tfile);
103 MALLOC(text,char,len);
107 //fread(text,1,len,tfile);
118 for (i=0,tptr=text;i<N_TEXT_STRINGS;i++) {
121 Text_string[i] = tptr;
123 tptr = strchr(tptr,'\n');
125 #ifdef MACINTOSH // total hack for mac patch since they don't want to patch data.
126 if (!tptr && (i == 644) )
131 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);
136 if ( tptr ) *tptr++ = 0;
139 decode_text_line(Text_string[i]);
141 //scan for special chars (like \n)
142 for (p=Text_string[i];(p=strchr(p,'\\'));) {
145 if (p[1] == 'n') newchar = '\n';
146 else if (p[1] == 't') newchar = '\t';
147 else if (p[1] == '\\') newchar = '\\';
149 Error("Unsupported key sequence <\\%c> on line %d of file <%s>",p[1],i+1,filename);
158 // Assert(tptr==text+len || tptr==text+len-2);