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 static char rcsid[] = "$Id: text.c,v 1.2 2001-01-24 04:42:21 bradleyb Exp $";
37 char *Text_string[N_TEXT_STRINGS];
44 // rotates a byte left one bit, preserving the bit falling off the right
46 encode_rotate_left(char *c)
58 //decode and encoded line of text
59 void decode_text_line(char *p)
62 encode_rotate_left(p);
63 *p = *p ^ BITMAP_TBL_XOR;
64 encode_rotate_left(p);
68 //load all the text strings for Descent
73 int len,i, have_binary = 0;
75 char *filename="descent.tex";
77 if ((i=FindArg("-text"))!=0)
80 if ((tfile = cfopen(filename,"rb")) == NULL) {
81 filename="descent.txb";
82 if ((ifile = cfopen(filename, "rb")) == NULL)
83 Error("Cannot open file DESCENT.TEX or DESCENT.TXB\nIs descent2.hog in your current directory?");
86 len = cfilelength(ifile);
88 MALLOC(text,char,len);
92 cfread(text,1,len,ifile);
100 len = cfilelength(tfile);
102 MALLOC(text,char,len);
106 //fread(text,1,len,tfile);
117 for (i=0,tptr=text;i<N_TEXT_STRINGS;i++) {
120 Text_string[i] = tptr;
122 tptr = strchr(tptr,'\n');
124 #ifdef MACINTOSH // total hack for mac patch since they don't want to patch data.
125 if (!tptr && (i == 644) )
130 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);
135 if ( tptr ) *tptr++ = 0;
138 decode_text_line(Text_string[i]);
140 //scan for special chars (like \n)
141 for (p=Text_string[i];(p=strchr(p,'\\'));) {
144 if (p[1] == 'n') newchar = '\n';
145 else if (p[1] == 't') newchar = '\t';
146 else if (p[1] == '\\') newchar = '\\';
148 Error("Unsupported key sequence <\\%c> on line %d of file <%s>",p[1],i+1,filename);
157 // Assert(tptr==text+len || tptr==text+len-2);