git: Line endings of README.txt
[projects/chimara/chimara.git] / interpreters / nitfol.patch
1 diff -P'aurx.*' nitfol-0.5/automap.c nitfol-chimara/automap.c
2 --- nitfol-0.5/automap.c        1999-10-20 02:09:46.000000000 +0200
3 +++ nitfol-chimara/automap.c    2009-09-10 21:39:06.000000000 +0200
4 @@ -1066,6 +1066,8 @@
5  
6  #else
7  
8 +char *roomsymbol = NULL;
9 +
10  BOOL automap_unexplore(void)
11  {
12    return FALSE;
13 diff -P'aurx.*' nitfol-0.5/automap.h nitfol-chimara/automap.h
14 --- nitfol-0.5/automap.h        1999-10-25 02:55:13.000000000 +0200
15 +++ nitfol-chimara/automap.h    2009-09-10 21:39:11.000000000 +0200
16 @@ -26,6 +26,7 @@
17  BOOL automap_unexplore (void);
18  
19  #else
20 +extern char * roomsymbol;
21  BOOL automap_unexplore (void);
22  
23  #endif
24 Only in nitfol-0.5: copying.c
25 Only in nitfol-0.5: dbg_help.h
26 Only in nitfol-0.5: dbg_help.texi
27 Only in nitfol-0.5: gi_blorb.h
28 Only in nitfol-0.5: glk.h
29 Only in nitfol-0.5: glkstart.h
30 Only in nitfol-0.5: inform.c
31 Only in nitfol-0.5: inform.hhh
32 diff -P'aurx.*' nitfol-0.5/inform.y nitfol-chimara/inform.y
33 --- nitfol-0.5/inform.y 1999-10-25 02:37:17.000000000 +0200
34 +++ nitfol-chimara/inform.y     2009-09-10 21:38:56.000000000 +0200
35 @@ -304,7 +304,7 @@
36  /* :: Show the current source language. */
37         | LANGUAGE              { infix_print_string("The current source language is \"inform\".\n"); }
38  /* :: Get information on the current source file. */
39 -       | INFOSOURCE            { infix_print_string("Current source file is "); infix_print_string(cur_file->filename); infix_print_string("\nContains "); infix_print_number(cur_file->num_lines); infix_print_string(" lines.\nSource language is inform.\n"); }
40 +       | INFOSOURCE            { infix_print_string("Current source file is "); infix_print_string(cur_file?cur_file->filename:"unknown"); infix_print_string("\nContains "); infix_print_number(cur_file?cur_file->num_lines:0); infix_print_string(" lines.\nSource language is inform.\n"); }
41  /* :: List source files. */
42         | INFOSOURCES           { infix_print_string("Source files for which symbols have been read in:\n\n"); infix_list_files(); infix_print_char('\n'); }
43  /* :: Show licensing information. */
44 @@ -346,9 +346,9 @@
45  */
46  ;
47  
48 -linespec: NUM                  { if($1.t == Z_ROUTINE) $$ = infix_get_routine_PC($1.v); else { infix_location l; infix_decode_fileloc(&l, cur_file->filename, $1.v); $$ = l.thisPC; } }
49 -       | '+' NUM               { infix_location l; infix_decode_fileloc(&l, cur_file->filename, cur_line + $2.v); $$ = l.thisPC; }
50 -       | '-' NUM               { infix_location l; infix_decode_fileloc(&l, cur_file->filename, cur_line - $2.v); $$ = l.thisPC; }
51 +linespec: NUM                  { if($1.t == Z_ROUTINE) $$ = infix_get_routine_PC($1.v); else { infix_location l; infix_decode_fileloc(&l, cur_file?cur_file->filename:"", $1.v); $$ = l.thisPC; } }
52 +       | '+' NUM               { infix_location l; infix_decode_fileloc(&l, cur_file?cur_file->filename:"", cur_line + $2.v); $$ = l.thisPC; }
53 +       | '-' NUM               { infix_location l; infix_decode_fileloc(&l, cur_file?cur_file->filename:"", cur_line - $2.v); $$ = l.thisPC; }
54         | DFILE ':' NUM         { if($3.t == Z_ROUTINE) $$ = UNPACKR($3.v); else { infix_location l; infix_decode_fileloc(&l, $1->filename, $3.v); $$ = l.thisPC; } }
55         | '*' NUM               { $$ = $2.v;                    }
56  ;
57 @@ -388,6 +388,7 @@
58  /* Expressions with conditions */
59  condexp:
60         exp CONDITION { cond_list newcond; newcond.val = $1.v; newcond.condfunc = $2.condfunc; newcond.opposite = $2.opposite; LEaddm(condlist, newcond, n_rmmalloc); } orlist { if($4) ignoreeffects--; $$.v = $4; $$.t = Z_BOOLEAN; LEremovem(condlist, n_rmfreeone); }
61 +;
62  
63  /* Expressions without commas */
64  exp:     NUM
65 diff -P'aurx.*' nitfol-0.5/init.c nitfol-chimara/init.c
66 --- nitfol-0.5/init.c   1999-10-24 17:38:06.000000000 +0200
67 +++ nitfol-chimara/init.c       2009-09-10 21:38:52.000000000 +0200
68 @@ -250,7 +250,10 @@
69    z_synonymtable  = MSBdecodeZ(header + HD_ABBREV);
70    
71    switch(zversion) {
72 -  case 1: case 2: case 3:
73 +  case 1: case 2:
74 +    game_size     = filesize;
75 +    break;
76 +  case 3:
77      game_size     = ((offset) MSBdecodeZ(header + HD_LENGTH)) * 2;
78      break;
79    case 4: case 5:
80 @@ -329,13 +332,15 @@
81      n_show_fatal(E_SYSTEM, "unexpected number of bytes read", bytes_read);
82  
83    z_checksum = 0;
84 -  for(i = 0x40; i < game_size; i++)
85 -    z_checksum += HIBYTE(i);
86 -  z_checksum = ARITHMASK(z_checksum);
87 -
88 -  if(z_checksum != LOWORD(HD_CHECKSUM)) {
89 -    n_show_error(E_CORRUPT, "Checksum does not match", z_checksum);
90 -    check_ascii_mode();
91 +  if (zversion >= 3) {
92 +    for(i = 0x40; i < game_size; i++)
93 +      z_checksum += HIBYTE(i);
94 +    z_checksum = ARITHMASK(z_checksum);
95 +
96 +    if(LOWORD(HD_CHECKSUM) != 0 && z_checksum != LOWORD(HD_CHECKSUM)) {
97 +      n_show_error(E_CORRUPT, "Checksum does not match", z_checksum);
98 +      check_ascii_mode();
99 +    }
100    }
101  
102  
103 diff -P'aurx.*' nitfol-0.5/io.c nitfol-chimara/io.c
104 --- nitfol-0.5/io.c     1999-10-22 04:53:34.000000000 +0200
105 +++ nitfol-chimara/io.c 2009-09-10 21:41:59.000000000 +0200
106 @@ -103,9 +103,9 @@
107                     stylehint_Proportional, 0);
108    glk_stylehint_set(wintype_TextBuffer, style_BlockQuote,
109                     stylehint_Justification, stylehint_just_Centered);
110 -#ifdef stylehint_Reverse
111 +#ifdef stylehint_ReverseColor
112    glk_stylehint_set(wintype_TextBuffer, style_BlockQuote,
113 -                   stylehint_Reverse, 1);
114 +                   stylehint_ReverseColor, 1);
115  #endif
116  
117    /* User1 will be used for bold italics */
118 @@ -410,7 +410,7 @@
119  
120    upper_win->win = glk_window_open(game_windows[0].win,
121                                     winmethod_Above | winmethod_Fixed,
122 -                                   upper_height,
123 +                                   1, /* XXX huh? upper_height, */
124                                     wintype_TextGrid, 1);
125  
126    if(upper_win->win == 0) {
127 diff -P'aurx.*' nitfol-0.5/main.c nitfol-chimara/main.c
128 --- nitfol-0.5/main.c   1999-10-18 01:14:39.000000000 +0200
129 +++ nitfol-chimara/main.c       2009-09-10 21:42:28.000000000 +0200
130 @@ -90,17 +90,33 @@
131    if(!current_zfile) {
132      winid_t tempwin;
133      tempwin = glk_window_open(0, 0, 100, wintype_TextBuffer, 0);
134 -    while(!current_zfile) {
135 -      strid_t z = n_file_prompt(fileusage_Data | fileusage_BinaryMode,
136 -                               filemode_Read);
137 -      if(!z) {
138 -       w_glk_put_string_stream(glk_window_get_stream(tempwin),
139 -                               "File not found.");
140 -       continue;
141 -      }
142 -      set_zfile(z);
143 -    }
144 -    glk_window_close(tempwin, NULL);
145 +       glk_set_window(tempwin);
146 +       glk_set_style(style_Preformatted);
147 +       glk_put_string(
148 +"Usage: nitfol [OPTIONS] gamefile\n"
149 +" -i, -ignore      Ignore Z-machine strictness errors\n"
150 +" -f, -fullname    For running under Emacs or DDD\n"
151 +" -x, -command     Read commands from this file\n"
152 +" -P, -pirate      Aye, matey\n"
153 +"     -spell       Perform spelling correction\n"
154 +"     -expand      Expand one letter abbreviations\n"
155 +" -s, -symbols     Specify symbol file for game\n"
156 +" -t, -tandy       Censors some Infocom games\n"
157 +" -T, -transcript  Write transcript to this file\n"
158 +" -d, -debug       Enter debugger immediatly\n"
159 +"     -prompt      Specify debugging prompt\n"
160 +"     -autoundo    Ensure '@save_undo' is called every turn\n"
161 +" -S, -stacklimit  Exit when the stack is this deep\n"
162 +" -a, -alias       Specify an alias\n"
163 +"     -ralias      Specify an recursive alias\n"
164 +"     -unalias     Remove an alias\n"
165 +" -r, -random      Set random seed\n"
166 +"     -mapsym      Specify mapping glyphs\n"
167 +"     -mapsize     Specify map size\n"
168 +"     -maploc      Specify map location\n"
169 +"     -terpnum     Specify interpreter number\n"
170 +"     -terpver     Specify interpreter version\n");
171 +    glk_exit();
172    }
173    z_init(current_zfile);
174    if(savefile) {
175 Only in nitfol-0.5: Make.dummy
176 Only in nitfol-0.5: Makefile
177 diff -P'aurx.*' nitfol-0.5/Makefile.am nitfol-chimara/Makefile.am
178 --- nitfol-0.5/Makefile.am      1970-01-01 01:00:00.000000000 +0100
179 +++ nitfol-chimara/Makefile.am  2009-09-10 00:04:11.000000000 +0200
180 @@ -0,0 +1,58 @@
181 +PLUGIN_LIBTOOL_FLAGS=-module -avoid-version -export-symbols-regex "^glk"
182 +
183 +GRAPHICS = no_graph.c no_graph.h
184 +# GRAPHICS = graphics.c graphics.h
185 +BLORB = blorb.c 
186 +# BLORB = no_blorb.c
187 +SOUND = no_snd.c no_snd.h
188 +# SOUND = sound.c sound.h
189 +
190 +dist_noinst_SCRIPTS = copying.awk opt2glkc.pl y2help.pl
191 +
192 +pkglib_LTLIBRARIES = nitfol.la
193 +nitfol_la_SOURCES = automap.c automap.h binary.h copying.h debug.c debug.h \
194 +       decode.c decode.h errmesg.c errmesg.h globals.c globals.h hash.c hash.h \
195 +       iff.c iff.h infix.c infix.h inform.y inform.h init.c init.h io.c \
196 +       linkevil.h main.c main.h nio.h nitfol.h no_blorb.h objects.c objects.h \
197 +       op_call.c op_call.h op_jmp.c op_jmp.h oplist.c oplist.h op_math.c \
198 +       op_math.h op_save.c op_save.h op_table.c op_table.h op_v6.c op_v6.h \
199 +       portfunc.c portfunc.h quetzal.c quetzal.h solve.c solve.h stack.c stack.h \
200 +       struct.c struct.h tokenise.c tokenise.h undo.c undo.h z_io.c z_io.h \
201 +       zscii.c zscii.h \
202 +       $(GRAPHICS) \
203 +       $(BLORB) \
204 +       $(SOUND)
205 +nodist_nitfol_la_SOURCES = copying.c dbg_help.h startunix.c
206 +nitfol_la_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/libchimara \
207 +       -DSMART_TOKENISER -DUSE_INLINE
208 +nitfol_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
209 +
210 +info_TEXINFOS = nitfol.texi
211 +nitfol_TEXINFOS = dbg_help.texi options.texi
212 +# man_MANS = nitfol.6
213 +
214 +BUILT_SOURCES = copying.c dbg_help.h startunix.c
215 +CLEANFILES = $(BUILT_SOURCES) dbg_help.texi nitfol.6 options.texi 
216 +
217 +dbg_help.h: inform.y y2help.pl
218 +       $(PERL) $(srcdir)/y2help.pl $(srcdir)/inform.y
219 +
220 +dbg_help.texi: inform.y y2help.pl
221 +       $(PERL) $(srcdir)/y2help.pl $(srcdir)/inform.y
222 +
223 +copying.c: COPYING copying.awk
224 +       $(AWK) --file $(srcdir)/copying.awk <$(srcdir)/COPYING >copying.c
225 +
226 +# nitfol.6: nitfol.opt opt2glkc.pl
227 +#      $(PERL) $(srcdir)/opt2glkc.pl -man $(srcdir)/nitfol.opt
228 +
229 +options.texi: nitfol.opt opt2glkc.pl
230 +       $(PERL) $(srcdir)/opt2glkc.pl -info $(srcdir)/nitfol.opt
231 +
232 +startunix.c: nitfol.opt opt2glkc.pl
233 +       $(PERL) $(srcdir)/opt2glkc.pl -unix $(srcdir)/nitfol.opt
234 +
235 +EXTRA_DIST = nitfol.opt crashme.inf test.inf 
236 +
237 +nitfoldocdir = $(datadir)/doc/$(PACKAGE)/nitfol
238 +dist_nitfoldoc_DATA = ChangeLog COPYING INSTALL README
239 Only in nitfol-0.5: nitfol
240 Only in nitfol-0.5: nitfol.6
241 diff -P'aurx.*' nitfol-0.5/nitfol.h nitfol-chimara/nitfol.h
242 --- nitfol-0.5/nitfol.h 1999-10-24 16:56:06.000000000 +0200
243 +++ nitfol-chimara/nitfol.h     2009-09-10 21:56:44.000000000 +0200
244 @@ -30,11 +30,12 @@
245  #define NITFOL_MINOR 5
246  
247  /* Change these next few typedefs depending on your compiler */
248 -typedef unsigned char zbyte;
249 +#include <stdint.h>
250 +typedef uint8_t zbyte;
251  
252  #ifdef FAST_SHORT
253 -typedef unsigned short zword;
254 -typedef unsigned long offset;
255 +typedef uint16_t zword;
256 +typedef uint32_t offset;
257  
258  #ifdef TWOS16SHORT
259  #define FAST_TWOS16SHORT
260 @@ -43,11 +44,11 @@
261  #else
262  
263  #ifdef FAST_SIGNED
264 -typedef int zword;
265 -typedef long offset;
266 +typedef int32_t zword;
267 +typedef int32_t offset;
268  #else
269 -typedef unsigned int  zword;  /* Needs to be >= real zword */
270 -typedef unsigned long offset;
271 +typedef uint32_t zword;  /* Needs to be >= real zword */
272 +typedef uint32_t offset;
273  #endif
274  
275  #endif
276 Only in nitfol-0.5: nitfol.html
277 Only in nitfol-0.5: nitfol.info
278 diff -P'aurx.*' nitfol-0.5/nitfol.opt nitfol-chimara/nitfol.opt
279 --- nitfol-0.5/nitfol.opt       1999-10-24 16:56:06.000000000 +0200
280 +++ nitfol-chimara/nitfol.opt   2009-09-10 21:56:44.000000000 +0200
281 @@ -3,7 +3,7 @@
282  # You can alter the 'default' part to change the game's default options.
283  
284  # Longest name         Long    short   description                             type    default code
285 - "Ignore errors"               ignore  i       "Ignore Z-machine strictness errors"    flag    1       { ignore_errors = flag; }
286 + "Ignore errors"               ignore  i       "Ignore Z-machine strictness errors"    flag    1       { ignore_errors = flag; }
287  Normally nitfol checks for illegal and undefined Z-machine behaviour and alerts the user.  If you're playing someone else's buggy game, this can be annoying and you should use this option.
288  
289  "Inferior debugger"    fullname f      "For running under Emacs or DDD"        flag    0       { fullname = flag; }
290 Only in nitfol-0.5: options.texi
291 Only in nitfol-0.5: rg_qsort.h
292 Only in nitfol-0.5: startdos.c
293 Only in nitfol-0.5: startmac.c
294 Only in nitfol-0.5: startunix.c
295 Only in nitfol-0.5: startwin.c
296 diff -P'aurx.*' nitfol-0.5/z_io.c nitfol-chimara/z_io.c
297 --- nitfol-0.5/z_io.c   1999-10-24 19:20:50.000000000 +0200
298 +++ nitfol-chimara/z_io.c       2009-04-05 19:17:51.000000000 +0200
299 @@ -900,13 +900,14 @@
300  
301    length = n_read(text + 1, maxlen, operand[1], 0,
302                   operand[2], operand[3], &term);
303 -  if(!read_abort)
304 +  if(!read_abort) {
305      LOBYTEwrite(text + 1 + length, 0);  /* zero terminator */
306  
307 -  if(allow_saveundo) {
308 -    if(!has_done_save_undo && auto_save_undo)
309 -      saveundo(FALSE);
310 -    has_done_save_undo = FALSE;
311 +    if(allow_saveundo) {
312 +      if(!has_done_save_undo && auto_save_undo)
313 +        saveundo(FALSE);
314 +      has_done_save_undo = FALSE;
315 +    }
316    }
317  }
318  
319 @@ -928,12 +929,12 @@
320    if(!read_abort) {
321      LOBYTEwrite(text + 1, length);
322      mop_store_result(term);
323 -  }
324 -
325 -  if(allow_saveundo) {
326 -    if(!has_done_save_undo && auto_save_undo)
327 -      saveundo(FALSE);
328 -    has_done_save_undo = FALSE;
329 +  
330 +    if(allow_saveundo) {
331 +      if(!has_done_save_undo && auto_save_undo)
332 +        saveundo(FALSE);
333 +      has_done_save_undo = FALSE;
334 +    }
335    }
336  }
337  
338 @@ -1094,5 +1095,38 @@
339  
340  void op_print_unicode(void)
341  {
342 -  output_char(operand[0]);
343 +  if(!allow_output)
344 +    return;
345 +  if(operand[0] >= 256 || (operand[0] > 127 && operand[0] < 160)) {
346 +    output_char('?');
347 +    return;
348 +  }
349 +  if(output_stream & STREAM3) {
350 +    if(operand[0] >= 160) {
351 +      const unsigned char default_unicode_zscii_translation[] = {
352 +        0x00, 0xde, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x00, 
353 +        0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, 
354 +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
355 +        0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0xdf, 
356 +        0xba, 0xaf, 0xc4, 0xd0, 0x9e, 0xca, 0xd4, 0xd6, 
357 +        0xbb, 0xb0, 0xc5, 0xa7, 0xbc, 0xb1, 0xc6, 0xa8, 
358 +        0xda, 0xd1, 0xbd, 0xb2, 0xc7, 0xd2, 0x9f, 0x00, 
359 +        0xcc, 0xbe, 0xb3, 0xc8, 0xa0, 0xb4, 0xd9, 0xa1, 
360 +        0xb5, 0xa9, 0xbf, 0xcd, 0x9b, 0xc9, 0xd3, 0xd5, 
361 +        0xb6, 0xaa, 0xc0, 0xa4, 0xb7, 0xab, 0xc1, 0xa5, 
362 +        0xd8, 0xce, 0xb8, 0xac, 0xc2, 0xcf, 0x9c, 0x00, 
363 +        0xcb, 0xb9, 0xad, 0xc3, 0x9d, 0xae, 0xd7, 0xa6
364 +      };
365 +      unsigned char c = default_unicode_zscii_translation[operand[0] - 160];
366 +      output_char(c == 0 ? '?' : c);
367 +    } else if(operand[0] == 10) {
368 +      output_char(13);
369 +    } else {
370 +      output_char(operand[0]);
371 +    }
372 +  } else {
373 +    if(output_stream & STREAM1) {
374 +      z_put_char(current_window, operand[0]);
375 +    }
376 +  }
377  }
378 diff -P'aurx.*' nitfol-0.5/zscii.c nitfol-chimara/zscii.c
379 --- nitfol-0.5/zscii.c  1999-10-18 01:14:45.000000000 +0200
380 +++ nitfol-chimara/zscii.c      2009-04-05 19:17:51.000000000 +0200
381 @@ -41,7 +41,7 @@
382  
383  
384  /* Returns character for given alphabet, letter pair */
385 -static char alphabetsoup(unsigned spoon, unsigned char letter)
386 +static unsigned char alphabetsoup(unsigned spoon, unsigned char letter)
387  {
388    const char *alphabet;
389