Only in nitfol-carbon/nitfol-0.5 Carbon src/: BasicApp.rsrc Only in nitfol-0.5: nitfol Only in nitfol-carbon/nitfol-0.5 Carbon src/: nitfol.π Only in nitfol-carbon/nitfol-0.5 Carbon src/: nitfolmacros.h diff -r -c nitfol-0.5/opt2glkc.pl nitfol-carbon/nitfol-0.5 Carbon src/opt2glkc.pl *** nitfol-0.5/opt2glkc.pl Sat Oct 23 09:15:15 1999 --- nitfol-carbon/nitfol-0.5 Carbon src/opt2glkc.pl Sun Aug 22 13:59:56 2004 *************** *** 40,45 **** --- 40,49 ---- # # The author can be reached at nitfol@my-deja.com + # + # Added parentheses and type-casting to gamehandle -- Matthew T. Russotto 27/Oct/2000 + # + my @LoL; my $argtype; my $systemtype; *************** *** 575,580 **** --- 579,585 ---- print "#line " . (__LINE__+1) . ' "' . __FILE__ . '"' . " #include \"$header\" #include \"macglk_startup.h\" + #include /*Added by MTR 28 October 2000 */ static strid_t mac_gamefile; *************** *** 582,587 **** --- 587,598 ---- static AliasHandle gamehandle; "; make_generic_findfile(); + make_generic_startup_open(); #/* Added by MTR 28 Oct 2000 */ + make_generic_startup_wopen(); #/* Added by MTR 28 Oct 2000 */ + make_functions(); #/* Added by MTR 28 Oct 2000 */ + make_useful_command_structure(); #/* Added by MTR 28 Oct 2000 */ + make_default_setter(); #/* Added by MTR 28 Oct 2000 */ + make_textpref_reader(); #/* Added by MTR 28 Oct 2000 */ print "#line " . (__LINE__+1) . ' "' . __FILE__ . '"' . " strid_t intd_filehandle_open(strid_t savefile, glui32 operating_id, glui32 contents_id, glui32 interp_id, *************** *** 596,603 **** if(interp_id != ", string_to_iff(" "), ") return 0; ! gamehandle = NewHandle(length); ! glk_get_buffer_stream(savefile, *gamehandle, length); hashandle = TRUE; ResolveAlias(NULL, gamehandle, &file, &wasChanged); return macglk_stream_open_fsspec(&file, 0, 0); --- 607,614 ---- if(interp_id != ", string_to_iff(" "), ") return 0; ! gamehandle = (AliasHandle)NewHandle(length); ! glk_get_buffer_stream(savefile, (char *)*gamehandle, length); hashandle = TRUE; ResolveAlias(NULL, gamehandle, &file, &wasChanged); return macglk_stream_open_fsspec(&file, 0, 0); *************** *** 613,626 **** glk_put_char_stream(savefile, 0); /* Reserved */ glk_put_char_stream(savefile, 0); /* Reserved */ glk_put_string_stream(savefile, \" \");/* Interpreter ID */ ! glk_put_buffer_stream(savefile, *gamehandle, *gamehandle->aliasSize); } glui32 intd_get_size(void) { if(!hashandle) return 0; ! return *gamehandle->aliasSize + 12; } static Boolean mac_whenselected(FSSpec *file, OSType filetype) --- 624,637 ---- glk_put_char_stream(savefile, 0); /* Reserved */ glk_put_char_stream(savefile, 0); /* Reserved */ glk_put_string_stream(savefile, \" \");/* Interpreter ID */ ! glk_put_buffer_stream(savefile, (char *)*gamehandle, (*gamehandle)->aliasSize); } glui32 intd_get_size(void) { if(!hashandle) return 0; ! return (*gamehandle)->aliasSize + 12; } static Boolean mac_whenselected(FSSpec *file, OSType filetype) *************** *** 635,640 **** --- 646,669 ---- return game_use_file(mac_gamefile); } + /* Function added by MTR 28 Oct 2000 */ + static void macglk_setprefs() + { + OSErr err; + short foundRefNum; + long foundDirId; + short file; + FSSpec prefs_spec; + strid_t pref; + + set_defaults(); + err = FindFolder(kOnSystemDisk, 'pref', kDontCreateFolder, &foundRefNum, &foundDirId); + if (err != noErr) return; + err = FSMakeFSSpec(foundRefNum, foundDirId, \"\\pNitfol Prefs\", &prefs_spec); + pref = macglk_stream_open_fsspec(&prefs_spec, TRUE, 0); + read_textpref(pref, \"Nitfol\" /* No way of setting this right now */); + } + Boolean macglk_startup_code(macglk_startup_t *data) { OSType mac_gamefile_types[] = { "; *************** *** 659,664 **** --- 688,694 ---- data->gamefile = &mac_gamefile; data->when_selected = mac_whenselected; data->when_builtin = mac_whenbuiltin; + macglk_setprefs(); /* Added by MTR 28 Oct 2000 */ return TRUE; } diff -r -c nitfol-0.5/startmac.c nitfol-carbon/nitfol-0.5 Carbon src/startmac.c *** nitfol-0.5/startmac.c Sun Oct 24 20:55:37 1999 --- nitfol-carbon/nitfol-0.5 Carbon src/startmac.c Sun Aug 22 13:59:56 2004 *************** *** 1,17 **** ! #line 576 "opt2glkc.pl" #include "nitfol.h" #include "macglk_startup.h" static strid_t mac_gamefile; static BOOL hashandle = FALSE; static AliasHandle gamehandle; ! #line 694 "opt2glkc.pl" strid_t startup_findfile(void) { ; } ! #line 586 "opt2glkc.pl" strid_t intd_filehandle_open(strid_t savefile, glui32 operating_id, glui32 contents_id, glui32 interp_id, glui32 length) --- 1,247 ---- ! #line 580 "opt2glkc.pl" #include "nitfol.h" #include "macglk_startup.h" + #include /*Added by MTR 28 October 2000 */ static strid_t mac_gamefile; static BOOL hashandle = FALSE; static AliasHandle gamehandle; ! #line 724 "opt2glkc.pl" strid_t startup_findfile(void) { ; } ! #line 735 "opt2glkc.pl" ! strid_t startup_open(const char *name) ! { ! return n_file_name(fileusage_Data | fileusage_BinaryMode, ! filemode_Read, name); ! } ! #line 747 "opt2glkc.pl" ! static strid_t startup_wopen(const char *name) ! { ! return n_file_name(fileusage_Data | fileusage_BinaryMode, ! filemode_Write, name); ! } ! static void code_ignore(int flag) ! #line 6 "nitfol.opt" ! { ignore_errors = flag; } ! ! static void code_fullname(int flag) ! #line 9 "nitfol.opt" ! { fullname = flag; } ! ! static void code_command(strid_t stream) ! #line 12 "nitfol.opt" ! { if(stream) input_stream1 = stream; } ! ! static void code_pirate(int flag) ! #line 15 "nitfol.opt" ! { aye_matey = flag; } ! ! static void code_quiet(int flag) ! #line 18 "nitfol.opt" ! { quiet = flag; } ! ! static void code_spell(int flag) ! #line 21 "nitfol.opt" ! { do_spell_correct = flag; } ! ! static void code_expand(int flag) ! #line 24 "nitfol.opt" ! { do_expand = flag; } ! ! static void code_symbols(strid_t stream) ! #line 27 "nitfol.opt" ! { if(stream) init_infix(stream); } ! ! static void code_tandy(int flag) ! #line 30 "nitfol.opt" ! { do_tandy = flag; } ! ! static void code_transcript(strid_t stream) ! #line 33 "nitfol.opt" ! { if(stream) set_transcript(stream); } ! ! static void code_debug(int flag) ! #line 36 "nitfol.opt" ! { enter_debugger = flag; do_check_watches = flag; } ! ! static void code_prompt(const char *string) ! #line 39 "nitfol.opt" ! { n_free(db_prompt); db_prompt = n_strdup(string); } ! ! static void code_path(const char *string) ! #line 42 "nitfol.opt" ! { n_free(search_path); search_path = n_strdup(string); } ! ! static void code_autoundo(int flag) ! #line 45 "nitfol.opt" ! { auto_save_undo = flag; } ! ! static void code_stacklimit(int number) ! #line 52 "nitfol.opt" ! { stacklimit = number; } ! ! static void code_alias(const char *string) ! #line 55 "nitfol.opt" ! { if(string) parse_new_alias(string, FALSE); } ! ! static void code_ralias(const char *string) ! #line 58 "nitfol.opt" ! { if(string) parse_new_alias(string, TRUE); } ! ! static void code_unalias(const char *string) ! #line 61 "nitfol.opt" ! { if(string) remove_alias(string); } ! ! static void code_random(int number) ! #line 64 "nitfol.opt" ! { faked_random_seed = number; } ! ! static void code_mapsym(const char *string) ! #line 67 "nitfol.opt" ! { n_free(roomsymbol); roomsymbol = n_strdup(string); } ! ! static void code_mapsize(int number) ! #line 70 "nitfol.opt" ! { automap_size = number; } ! ! static void code_maploc(const char *string) ! #line 73 "nitfol.opt" ! { switch(glk_char_to_lower(*string)) { case 'a': case 't': case 'u': automap_split = winmethod_Above; break; case 'b': case 'd': automap_split = winmethod_Below; break; case 'l': automap_split = winmethod_Left; break; case 'r': automap_split = winmethod_Right; } } ! ! static void code_terpnum(int number) ! #line 76 "nitfol.opt" ! { interp_num = number; } ! ! static void code_terpver(const char *string) ! #line 79 "nitfol.opt" ! { if(string) { if(n_strlen(string) == 1) interp_ver = *string; else interp_ver = n_strtol(string, NULL, 10); } } ! ! #line 790 "opt2glkc.pl" ! typedef enum { option_flag, option_file, option_wfile, option_number, option_string } option_type; ! typedef struct { const char *longname; char shortname; const char *description; option_type type; void (*int_func)(int); int defint; void (*str_func)(strid_t); strid_t defstream; void (*string_func)(const char *); const char *defstring; } option_option; ! ! static option_option options[] = { ! { "ignore", 'i', "Ignore Z-machine strictness errors", option_flag, code_ignore, 0, NULL, NULL, NULL, NULL }, ! { "fullname", 'f', "For running under Emacs or DDD", option_flag, code_fullname, 0, NULL, NULL, NULL, NULL }, ! { "command", 'x', "Read commands from this file", option_file, NULL, 0, code_command, NULL, NULL, NULL }, ! { "pirate", 'P', "Aye, matey", option_flag, code_pirate, 0, NULL, NULL, NULL, NULL }, ! { "quiet", 'q', "Do not print introductory messages", option_flag, code_quiet, 1, NULL, NULL, NULL, NULL }, ! { "spell", '-', "Perform spelling correction", option_flag, code_spell, 1, NULL, NULL, NULL, NULL }, ! { "expand", '-', "Expand one letter abbreviations", option_flag, code_expand, 1, NULL, NULL, NULL, NULL }, ! { "symbols", 's', "Specify symbol file for game", option_file, NULL, 0, code_symbols, NULL, NULL, NULL }, ! { "tandy", 't', "Censors some Infocom games", option_flag, code_tandy, 0, NULL, NULL, NULL, NULL }, ! { "transcript", 'T', "Write transcript to this file", option_wfile, NULL, 0, code_transcript, NULL, NULL, NULL }, ! { "debug", 'd', "Enter debugger immediatly", option_flag, code_debug, 0, NULL, NULL, NULL, NULL }, ! { "prompt", '-', "Specify debugging prompt", option_string, NULL, 0, NULL, NULL, code_prompt, "(nitfol) " }, ! { "path", '-', "Look for games in this directory", option_string, NULL, 0, NULL, NULL, code_path, NULL }, ! { "autoundo", '-', "Ensure '@save_undo' is called every turn", option_flag, code_autoundo, 1, NULL, NULL, NULL, NULL }, ! { "stacklimit", 'S', "Exit when the stack is this deep", option_number, code_stacklimit, 0, NULL, NULL, NULL, NULL }, ! { "alias", 'a', "Specify an alias", option_string, NULL, 0, NULL, NULL, code_alias, NULL }, ! { "ralias", '-', "Specify an recursive alias", option_string, NULL, 0, NULL, NULL, code_ralias, NULL }, ! { "unalias", '-', "Remove an alias", option_string, NULL, 0, NULL, NULL, code_unalias, NULL }, ! { "random", 'r', "Set random seed", option_number, code_random, 0, NULL, NULL, NULL, NULL }, ! { "mapsym", '-', "Specify mapping glyphs", option_string, NULL, 0, NULL, NULL, code_mapsym, "*udb@UDB+" }, ! { "mapsize", '-', "Specify map size", option_number, code_mapsize, 12, NULL, NULL, NULL, NULL }, ! { "maploc", '-', "Specify map location", option_string, NULL, 0, NULL, NULL, code_maploc, "above" }, ! { "terpnum", '-', "Specify interpreter number", option_number, code_terpnum, 2, NULL, NULL, NULL, NULL }, ! { "terpver", '-', "Specify interpreter version", option_string, NULL, 0, NULL, NULL, code_terpver, "N" } ! }; ! ! #line 841 "opt2glkc.pl" ! static void set_defaults(void) ! { ! unsigned n; ! for(n = 0; n < sizeof(options) / sizeof(*options); n++) { ! if(options[n].int_func) ! options[n].int_func(options[n].defint); ! if(options[n].str_func) ! options[n].str_func(options[n].defstream); ! if(options[n].string_func) ! options[n].string_func(options[n].defstring); ! } ! } ! ! #line 859 "opt2glkc.pl" ! static void read_textpref(strid_t pref, const char *progname) ! { ! unsigned n; ! char buffer[1024]; ! int prognamelen = n_strlen(progname); ! if(!pref) ! return; ! while(glk_get_line_stream(pref, buffer, sizeof(buffer))) { ! char *optname; ! char *optval; ! long int optnum; ! ! if(buffer[0] == '#') ! continue; ! while(buffer[0] == '[') { ! if(n_strncasecmp(buffer+1, progname, prognamelen) != 0 ! || buffer[1+prognamelen] != ']') { ! while(glk_get_line_stream(pref, buffer, sizeof(buffer))) ! if(buffer[0] == '[') ! break; ! } else { ! glk_get_line_stream(pref, buffer, sizeof(buffer)); ! } ! } ! ! optname = buffer; ! while(isspace(*optname)) ! optname++; ! if((optval = n_strchr(optname, '=')) != NULL) { ! char *p; ! *optval = 0; ! optval++; ! ! if((p = n_strchr(optname, ' ')) != NULL) ! *p = 0; ! ! while(isspace(*optval)) ! optval++; ! ! while(isspace(optval[strlen(optval)-1])) ! optval[strlen(optval)-1] = 0; ! ! optnum = n_strtol(optval, NULL, 0); ! if(n_strcasecmp(optval, "false") == 0 ! || n_strcasecmp(optval, "f") == 0) ! optnum = FALSE; ! if(n_strcasecmp(optval, "true") == 0 ! || n_strcasecmp(optval, "t") == 0) ! optnum = TRUE; ! ! for(n = 0; n < sizeof(options) / sizeof(*options); n++) { ! if(n_strcmp(options[n].longname, optname) == 0) { ! switch(options[n].type) { ! case option_flag: ! case option_number: ! options[n].int_func(optnum); ! break; ! case option_file: ! options[n].str_func(startup_open(optval)); ! break; ! case option_wfile: ! options[n].str_func(startup_wopen(optval)); ! break; ! case option_string: ! options[n].string_func(optval); ! break; ! } ! break; ! } ! } ! } ! } ! glk_stream_close(pref, NULL); ! } ! ! #line 597 "opt2glkc.pl" strid_t intd_filehandle_open(strid_t savefile, glui32 operating_id, glui32 contents_id, glui32 interp_id, glui32 length) *************** *** 25,32 **** if(interp_id != 0x20202020 /* ' ' */) return 0; ! gamehandle = NewHandle(length); ! glk_get_buffer_stream(savefile, *gamehandle, length); hashandle = TRUE; ResolveAlias(NULL, gamehandle, &file, &wasChanged); return macglk_stream_open_fsspec(&file, 0, 0); --- 255,262 ---- if(interp_id != 0x20202020 /* ' ' */) return 0; ! gamehandle = (AliasHandle)NewHandle(length); ! glk_get_buffer_stream(savefile, (char *)*gamehandle, length); hashandle = TRUE; ResolveAlias(NULL, gamehandle, &file, &wasChanged); return macglk_stream_open_fsspec(&file, 0, 0); *************** *** 42,55 **** glk_put_char_stream(savefile, 0); /* Reserved */ glk_put_char_stream(savefile, 0); /* Reserved */ glk_put_string_stream(savefile, " ");/* Interpreter ID */ ! glk_put_buffer_stream(savefile, *gamehandle, *gamehandle->aliasSize); } glui32 intd_get_size(void) { if(!hashandle) return 0; ! return *gamehandle->aliasSize + 12; } static Boolean mac_whenselected(FSSpec *file, OSType filetype) --- 272,285 ---- glk_put_char_stream(savefile, 0); /* Reserved */ glk_put_char_stream(savefile, 0); /* Reserved */ glk_put_string_stream(savefile, " ");/* Interpreter ID */ ! glk_put_buffer_stream(savefile, (char *)*gamehandle, (*gamehandle)->aliasSize); } glui32 intd_get_size(void) { if(!hashandle) return 0; ! return (*gamehandle)->aliasSize + 12; } static Boolean mac_whenselected(FSSpec *file, OSType filetype) *************** *** 64,69 **** --- 294,317 ---- return game_use_file(mac_gamefile); } + /* Function added by MTR 28 Oct 2000 */ + static void macglk_setprefs() + { + OSErr err; + short foundRefNum; + long foundDirId; + short file; + FSSpec prefs_spec; + strid_t pref; + + set_defaults(); + err = FindFolder(kOnSystemDisk, 'pref', kDontCreateFolder, &foundRefNum, &foundDirId); + if (err != noErr) return; + err = FSMakeFSSpec(foundRefNum, foundDirId, "\pNitfol Prefs", &prefs_spec); + pref = macglk_stream_open_fsspec(&prefs_spec, TRUE, 0); + read_textpref(pref, "Nitfol" /* No way of setting this right now */); + } + Boolean macglk_startup_code(macglk_startup_t *data) { OSType mac_gamefile_types[] = { 0x5a434f44 /* 'ZCOD' */, 0x49465253 /* 'IFRS' */, 0x49465a53 /* 'IFZS' */ }; *************** *** 77,82 **** --- 325,331 ---- data->gamefile = &mac_gamefile; data->when_selected = mac_whenselected; data->when_builtin = mac_whenbuiltin; + macglk_setprefs(); /* Added by MTR 28 Oct 2000 */ return TRUE; }