X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=src%2Ftables.c;h=4158253d8e5af79a89fc1bf38db8e6d8d301a627;hb=d11f2f726ed7feea617476d99cf7505ddd9a27ce;hp=103f6f91e432566d96b63bf53f085c805113c9e5;hpb=81ffe9a7de1db0b3a318a053b38882d1b7ab304c;p=inform.git diff --git a/src/tables.c b/src/tables.c index 103f6f9..4158253 100644 --- a/src/tables.c +++ b/src/tables.c @@ -3,9 +3,8 @@ /* end of dynamic memory, gluing together all the required */ /* tables. */ /* */ -/* Copyright (c) Graham Nelson 1993 - 2018 */ -/* */ -/* This file is part of Inform. */ +/* Part of Inform 6.35 */ +/* copyright (c) Graham Nelson 1993 - 2021 */ /* */ /* Inform is free software: you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ @@ -18,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with Inform. If not, see https://gnu.org/licenses/ */ +/* along with Inform. If not, see https://gnu.org/licenses/ * /* */ /* ------------------------------------------------------------------------- */ @@ -32,7 +31,7 @@ uchar *zmachine_paged_memory; /* Where we shall store the story file at the end of the compilation pass */ /* In Glulx, zmachine_paged_memory contains all of RAM -- i.e. all but - the header, the code, and the static strings. */ + the header, the code, the static arrays, and the static strings. */ /* ------------------------------------------------------------------------- */ /* Offsets of various areas in the Z-machine: these are set to nominal */ @@ -72,7 +71,8 @@ int32 code_offset, routine_flags_array_offset, global_names_offset, global_flags_array_offset, - array_flags_array_offset; + array_flags_array_offset, + static_arrays_offset; int32 arrays_offset, object_tree_offset, grammar_table_offset, @@ -191,6 +191,8 @@ static int32 rough_size_of_paged_memory_z(void) total += (subtract_pointers(dictionary_top, dictionary)) /* dictionary */ + ((module_switch)?30:0); /* module map */ + total += static_array_area_size; /* static arrays */ + total += scale_factor*0x100 /* maximum null bytes before code */ + 1000; /* fudge factor (in case the above is wrong) */ @@ -201,7 +203,7 @@ static int32 rough_size_of_paged_memory_g(void) { /* This function calculates a modest over-estimate of the amount of memory required to store the machine's paged memory area - (that is, everything up to the start of the code area). */ + (that is, everything past the start of RAM). */ int32 total; @@ -246,7 +248,8 @@ static void construct_storyfile_z(void) int32 globals_at=0, link_table_at=0, dictionary_at=0, actions_at=0, preactions_at=0, abbrevs_at=0, prop_defaults_at=0, object_tree_at=0, object_props_at=0, map_of_module=0, grammar_table_at=0, charset_at=0, headerext_at=0, - terminating_chars_at=0, unicode_at=0, id_names_length=0; + terminating_chars_at=0, unicode_at=0, id_names_length=0, + static_arrays_at=0; int skip_backpatching = FALSE; char *output_called = (module_switch)?"module":"story file"; @@ -292,13 +295,23 @@ static void construct_storyfile_z(void) p[0x42+i]=low_strings[i]; abbrevs_at = mark; - for (i=0; i<3*32; i++) /* Initially all 96 entries */ - { p[mark++]=0; p[mark++]=0x20; /* are set to " " */ + + if (MAX_ABBREVS + MAX_DYNAMIC_STRINGS != 96) + fatalerror("MAX_ABBREVS + MAX_DYNAMIC_STRINGS is not 96"); + + /* Initially all 96 entries are set to " ". (We store half of 0x40, + the address of the " " we wrote above.) */ + for (i=0; i<3*32; i++) + { p[mark++]=0; p[mark++]=0x20; } - for (i=0; i= 256, hence long constants) */ @@ -706,6 +725,7 @@ or less."); prop_values_offset = object_props_at; static_memory_offset = grammar_table_at; grammar_table_offset = grammar_table_at; + static_arrays_offset = static_arrays_at; if (extend_memory_map) { extend_offset=256; @@ -1142,6 +1162,11 @@ printf(" + - - - - - - - - - - + %05lx\n", (long int) map_of_module); printf(" | map of module addrs |\n"); } +if (static_array_area_size) +{ +printf(" +---------------------+ %05lx\n", (long int) static_arrays_at); +printf(" | static arrays |\n"); +} printf(" +=====================+ %05lx\n", (long int) Write_Code_At); printf("Above | Z-code |\n"); printf("readable+---------------------+ %05lx\n", @@ -1196,7 +1221,7 @@ static void construct_storyfile_g(void) int32 globals_at, dictionary_at, actions_at, preactions_at, abbrevs_at, prop_defaults_at, object_tree_at, object_props_at, grammar_table_at, charset_at, headerext_at, - unicode_at, arrays_at; + unicode_at, arrays_at, static_arrays_at; int32 threespaces, code_length; char *output_called = (module_switch)?"module":"story file"; @@ -1217,7 +1242,7 @@ static void construct_storyfile_g(void) "array name strings"); write_the_identifier_names(); - threespaces = compile_string(" ", FALSE, FALSE); + threespaces = compile_string(" ", STRCTX_GAME); compress_game_text(); @@ -1256,8 +1281,10 @@ static void construct_storyfile_g(void) Write_Strings_At = Write_Code_At + code_length; strings_length = compression_table_size + compression_string_size; + static_arrays_at = Write_Strings_At + strings_length; + /* Now figure out where RAM starts. */ - Write_RAM_At = Write_Strings_At + strings_length; + Write_RAM_At = static_arrays_at + static_array_area_size; /* The Write_RAM_At boundary must be a multiple of GPAGESIZE. */ while (Write_RAM_At % GPAGESIZE) Write_RAM_At++; @@ -1568,6 +1595,7 @@ table format requested (producing number 2 format instead)"); code_offset = Write_Code_At; strings_offset = Write_Strings_At; + static_arrays_offset = static_arrays_at; /* --------------------------- The Header ----------------------------- */ @@ -1739,9 +1767,10 @@ Out: %s %s %d.%c%c%c%c%c%c (%ld%sK long):\n", write_debug_section("string decoding table", Write_Strings_At); write_debug_section("strings area", Write_Strings_At + compression_table_size); - if (Write_Strings_At + strings_length < Write_RAM_At) + write_debug_section("static array space", static_arrays_at); + if (static_arrays_at + static_array_area_size < Write_RAM_At) { write_debug_section - ("zero padding", Write_Strings_At + strings_length); + ("zero padding", static_arrays_at + static_array_area_size); } if (globals_at) { compiler_error("Failed assumption that globals are at start of " @@ -1784,6 +1813,12 @@ printf(" | string decode table |\n"); printf(" + - - - - - - - - - - + %06lx\n", (long int) Write_Strings_At + compression_table_size); printf(" | strings |\n"); + if (static_array_area_size) + { +printf(" +---------------------+ %06lx\n", + (long int) (static_arrays_at)); +printf(" | static arrays |\n"); + } printf(" +=====================+ %06lx\n", (long int) (Write_RAM_At+globals_at)); printf("Dynamic | global variables |\n"); @@ -1911,6 +1946,7 @@ extern void init_tables_vars(void) identifier_names_offset=0x800; class_numbers_offset = 0x800; arrays_offset = 0x0800; /* only used in Glulx, but might as well set */ + static_arrays_offset = 0x0800; } else { code_offset = 0x12345; @@ -1924,6 +1960,7 @@ extern void init_tables_vars(void) individuals_offset=0x12345; identifier_names_offset=0x12345; class_numbers_offset = 0x12345; + static_arrays_offset = 0x12345; } }