X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=src%2Ffiles.c;h=68d1c5581a8130a7009848b7e3d9c3f7b383b4b1;hb=56a5292888e1d46fe3033cd1d5c636051692453f;hp=06e85d07031e821b8abc1de0ec7a8c94bae3ab0e;hpb=8e63120c630c94c598d4e2d6ba823dac59bce8fa;p=inform.git diff --git a/src/files.c b/src/files.c index 06e85d0..68d1c55 100644 --- a/src/files.c +++ b/src/files.c @@ -7,8 +7,8 @@ /* routines in "inform.c", since they are tied up with ICL */ /* settings and are very host OS-dependent. */ /* */ -/* Part of Inform 6.40 */ -/* copyright (c) Graham Nelson 1993 - 2022 */ +/* Part of Inform 6.42 */ +/* copyright (c) Graham Nelson 1993 - 2024 */ /* */ /* Inform is free software: you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ @@ -40,7 +40,7 @@ int32 total_chars_read; /* Characters read in (from all static int checksum_low_byte, /* For calculating the Z-machine's */ checksum_high_byte; /* "verify" checksum */ -static int32 checksum_long; /* For the Glulx checksum, */ +static uint32 checksum_long; /* For the Glulx checksum, */ static int checksum_count; /* similarly */ /* ------------------------------------------------------------------------- */ @@ -115,7 +115,7 @@ extern void load_sourcefile(char *filename_given, int same_directory_flag) do { x = translate_in_filename(x, name, filename_given, same_directory_flag, (total_files==0)?1:0); - handle = fopen(name,"r"); + handle = fopen(name,"rb"); } while ((handle == NULL) && (x != 0)); InputFiles[total_files].filename = my_malloc(strlen(name)+1, "filename storage"); @@ -273,7 +273,7 @@ extern int file_load_chars(int file_number, char *buffer, int length) } /* ------------------------------------------------------------------------- */ -/* Final assembly and output of the story file/module. */ +/* Final assembly and output of the story file. */ /* ------------------------------------------------------------------------- */ FILE *sf_handle; @@ -283,9 +283,7 @@ static void sf_put(int c) if (!glulx_mode) { /* The checksum is the unsigned sum mod 65536 of the bytes in the - story file from 0x0040 (first byte after header) to the end. - - The link data does not contribute to the checksum of a module. */ + story file from 0x0040 (first byte after header) to the end. */ checksum_low_byte += c; if (checksum_low_byte>=256) @@ -302,16 +300,16 @@ static void sf_put(int c) switch (checksum_count) { case 0: - checksum_long += (((int32)(c & 0xFF)) << 24); + checksum_long += (((uint32)(c & 0xFF)) << 24); break; case 1: - checksum_long += (((int32)(c & 0xFF)) << 16); + checksum_long += (((uint32)(c & 0xFF)) << 16); break; case 2: - checksum_long += (((int32)(c & 0xFF)) << 8); + checksum_long += (((uint32)(c & 0xFF)) << 8); break; case 3: - checksum_long += ((int32)(c & 0xFF)); + checksum_long += ((uint32)(c & 0xFF)); break; } @@ -359,7 +357,7 @@ static void output_compression(int entnum, int32 *size, int *count) (*size) += 1; break; case 3: - cx = (char *)abbreviations_at + ent->u.val*MAX_ABBREV_LENGTH; + cx = abbreviation_text(ent->u.val); while (*cx) { sf_put(*cx); cx++; @@ -400,9 +398,6 @@ static void output_file_z(void) /* Enter the length information into the header. */ length=((int32) Write_Strings_At) + static_strings_extent; - if (module_switch) length += link_data_size + - zcode_backpatch_size + - zmachine_backpatch_size; while ((length%length_scale_factor)!=0) { length++; blanks++; } length=length/length_scale_factor; @@ -425,7 +420,7 @@ static void output_file_z(void) /* Set the type and creator to Andrew Plotkin's MaxZip, a popular Z-code interpreter on the Macintosh */ - if (!module_switch) fsetfileinfo(new_name, 'mxZR', 'ZCOD'); + fsetfileinfo(new_name, 'mxZR', 'ZCOD'); #endif /* (1) Output the paged memory. */ @@ -468,7 +463,6 @@ static void output_file_z(void) size_before_code = size; j=0; - if (!module_switch) for (i=0; i> 24)); - sf_put((VersionNum >> 16)); - sf_put((VersionNum >> 8)); - sf_put((VersionNum)); + sf_put((final_glulx_version >> 24)); + sf_put((final_glulx_version >> 16)); + sf_put((final_glulx_version >> 8)); + sf_put((final_glulx_version)); /* RAMSTART */ sf_put((Write_RAM_At >> 24)); sf_put((Write_RAM_At >> 16)); @@ -808,7 +785,6 @@ game features require version 0x%08lx", (long)requested_glulx_version, (long)Ver size_before_code = size; j=0; - if (!module_switch) for (i=0; i> 16) & 0xFFFF; + int32 minor = (final_glulx_version >> 8) & 0xFF; + int32 patch = final_glulx_version & 0xFF; + snprintf(botline_buffer, 256, "[Compiled Glulx version %d.%d.%d]", major, minor, patch); + } + write_to_transcript_file(botline_buffer, STRCTX_INFO); + write_serial_number(sn_buffer); - sprintf(botline_buffer, "[End of transcript: release %d, serial %s]", + snprintf(botline_buffer, 256, "[End of transcript: release %d, serial %s]", release_number, sn_buffer); - write_to_transcript_file("", STRCTX_INFO); write_to_transcript_file(botline_buffer, STRCTX_INFO); write_to_transcript_file("", STRCTX_INFO);