internal static void configure(int min_version, int max_version) { // buffer = new zbyte_t[tx_h.PAGE_SIZE]; int i; buffer = new zbyte_t[gfp.Length]; gfp.Read(buffer, 0, buffer.Length); //#if !defined(lint) // assert (sizeof (zheader_t) == 64); // assert (sizeof (zheader_t) <= PAGE_SIZE); //#endif /* !defined(lint) */ // read_page(0, buffer); tx_h.datap = buffer; header = new tx_h.zheader_t(); header.version = tx_h.get_byte(tx_h.H_VERSION); header.config = tx_h.get_byte(tx_h.H_CONFIG); header.release = tx_h.get_word(tx_h.H_RELEASE); header.resident_size = tx_h.get_word(tx_h.H_RESIDENT_SIZE); header.start_pc = tx_h.get_word(tx_h.H_START_PC); header.dictionary = tx_h.get_word(tx_h.H_DICTIONARY); header.objects = tx_h.get_word(tx_h.H_OBJECTS); header.globals = tx_h.get_word(tx_h.H_GLOBALS); header.dynamic_size = tx_h.get_word(tx_h.H_DYNAMIC_SIZE); header.flags = tx_h.get_word(tx_h.H_FLAGS); for (i = 0; i < header.serial.Length; i++) header.serial[i] = tx_h.get_byte(tx_h.H_SERIAL + i); header.abbreviations = tx_h.get_word(tx_h.H_ABBREVIATIONS); header.file_size = tx_h.get_word(tx_h.H_FILE_SIZE); header.checksum = tx_h.get_word(tx_h.H_CHECKSUM); header.interpreter_number = tx_h.get_byte(tx_h.H_INTERPRETER_NUMBER); header.interpreter_version = tx_h.get_byte(tx_h.H_INTERPRETER_VERSION); header.screen_rows = tx_h.get_byte(tx_h.H_SCREEN_ROWS); header.screen_columns = tx_h.get_byte(tx_h.H_SCREEN_COLUMNS); header.screen_width = tx_h.get_word(tx_h.H_SCREEN_WIDTH); header.screen_height = tx_h.get_word(tx_h.H_SCREEN_HEIGHT); if (header.version != tx_h.V6) { header.font_width = (byte)tx_h.get_word(tx_h.H_FONT_WIDTH); header.font_height = tx_h.get_byte(tx_h.H_FONT_HEIGHT); } else { header.font_width = (byte)tx_h.get_word(tx_h.H_FONT_HEIGHT); header.font_height = tx_h.get_byte(tx_h.H_FONT_WIDTH); } header.routines_offset = tx_h.get_word(tx_h.H_ROUTINES_OFFSET); header.strings_offset = tx_h.get_word(tx_h.H_STRINGS_OFFSET); header.default_background = tx_h.get_byte(tx_h.H_DEFAULT_BACKGROUND); header.default_foreground = tx_h.get_byte(tx_h.H_DEFAULT_FOREGROUND); header.terminating_keys = tx_h.get_word(tx_h.H_TERMINATING_KEYS); header.line_width = tx_h.get_word(tx_h.H_LINE_WIDTH); header.specification_hi = tx_h.get_byte(tx_h.H_SPECIFICATION_HI); header.specification_lo = tx_h.get_byte(tx_h.H_SPECIFICATION_LO); header.alphabet = tx_h.get_word(tx_h.H_ALPHABET); header.mouse_table = tx_h.get_word(tx_h.H_MOUSE_TABLE); for (i = 0; i < header.name.Length; i++) header.name[i] = tx_h.get_byte(tx_h.H_NAME + i); if ((uint)header.version < (uint)min_version || (uint)header.version > (uint)max_version || ((uint)header.config & tx_h.CONFIG_BYTE_SWAPPED) != 0) { throw new ArgumentException("\nFatal: wrong game or version\n"); } if ((uint)header.version < tx_h.V4) { story_scaler = 2; story_shift = 1; code_scaler = 2; code_shift = 1; property_mask = tx_h.P3_MAX_PROPERTIES - 1; property_size_mask = 0xe0; } else if ((uint)header.version < tx_h.V6) { story_scaler = 4; story_shift = 2; code_scaler = 4; code_shift = 2; property_mask = tx_h.P4_MAX_PROPERTIES - 1; property_size_mask = 0x3f; } else if ((uint)header.version < tx_h.V8) { story_scaler = 8; story_shift = 3; code_scaler = 4; code_shift = 2; property_mask = tx_h.P4_MAX_PROPERTIES - 1; property_size_mask = 0x3f; } else { story_scaler = 8; story_shift = 3; code_scaler = 8; code_shift = 3; property_mask = tx_h.P4_MAX_PROPERTIES - 1; property_size_mask = 0x3f; } /* Calculate the file size */ if ((uint)header.file_size == 0) { throw new ArgumentException("Can't handle files with no length. Giving up!"); // file_size = get_story_size(); } else if ((uint)header.version <= tx_h.V3) file_size = header.file_size * 2; else if ((uint)header.version <= tx_h.V5) file_size = header.file_size * 4; else file_size = header.file_size * 8; }/* configure */
internal static void configure(int min_version, int max_version) { // buffer = new zbyte_t[tx_h.PAGE_SIZE]; int i; buffer = new zbyte_t[gfp.Length]; gfp.Read(buffer, 0, buffer.Length); //#if !defined(lint) // assert (sizeof (zheader_t) == 64); // assert (sizeof (zheader_t) <= PAGE_SIZE); //#endif /* !defined(lint) */ // read_page(0, buffer); tx_h.datap = buffer; header = new tx_h.zheader_t(); header.version = tx_h.get_byte(tx_h.H_VERSION); header.config = tx_h.get_byte(tx_h.H_CONFIG); header.release = tx_h.get_word(tx_h.H_RELEASE); header.resident_size = tx_h.get_word(tx_h.H_RESIDENT_SIZE); header.start_pc = tx_h.get_word(tx_h.H_START_PC); header.dictionary = tx_h.get_word(tx_h.H_DICTIONARY); header.objects = tx_h.get_word(tx_h.H_OBJECTS); header.globals = tx_h.get_word(tx_h.H_GLOBALS); header.dynamic_size = tx_h.get_word(tx_h.H_DYNAMIC_SIZE); header.flags = tx_h.get_word(tx_h.H_FLAGS); for (i = 0; i < header.serial.Length; i++) { header.serial[i] = tx_h.get_byte(tx_h.H_SERIAL + i); } header.abbreviations = tx_h.get_word(tx_h.H_ABBREVIATIONS); header.file_size = tx_h.get_word(tx_h.H_FILE_SIZE); header.checksum = tx_h.get_word(tx_h.H_CHECKSUM); header.interpreter_number = tx_h.get_byte(tx_h.H_INTERPRETER_NUMBER); header.interpreter_version = tx_h.get_byte(tx_h.H_INTERPRETER_VERSION); header.screen_rows = tx_h.get_byte(tx_h.H_SCREEN_ROWS); header.screen_columns = tx_h.get_byte(tx_h.H_SCREEN_COLUMNS); header.screen_width = tx_h.get_word(tx_h.H_SCREEN_WIDTH); header.screen_height = tx_h.get_word(tx_h.H_SCREEN_HEIGHT); if (header.version != tx_h.V6) { header.font_width = (byte)tx_h.get_word(tx_h.H_FONT_WIDTH); header.font_height = tx_h.get_byte(tx_h.H_FONT_HEIGHT); } else { header.font_width = (byte)tx_h.get_word(tx_h.H_FONT_HEIGHT); header.font_height = tx_h.get_byte(tx_h.H_FONT_WIDTH); } header.routines_offset = tx_h.get_word(tx_h.H_ROUTINES_OFFSET); header.strings_offset = tx_h.get_word(tx_h.H_STRINGS_OFFSET); header.default_background = tx_h.get_byte(tx_h.H_DEFAULT_BACKGROUND); header.default_foreground = tx_h.get_byte(tx_h.H_DEFAULT_FOREGROUND); header.terminating_keys = tx_h.get_word(tx_h.H_TERMINATING_KEYS); header.line_width = tx_h.get_word(tx_h.H_LINE_WIDTH); header.specification_hi = tx_h.get_byte(tx_h.H_SPECIFICATION_HI); header.specification_lo = tx_h.get_byte(tx_h.H_SPECIFICATION_LO); header.alphabet = tx_h.get_word(tx_h.H_ALPHABET); header.mouse_table = tx_h.get_word(tx_h.H_MOUSE_TABLE); for (i = 0; i < header.name.Length; i++) { header.name[i] = tx_h.get_byte(tx_h.H_NAME + i); } if ((uint)header.version < (uint)min_version || (uint)header.version > (uint)max_version || ((uint)header.config & tx_h.CONFIG_BYTE_SWAPPED) != 0) { throw new ArgumentException("\nFatal: wrong game or version\n"); } if ((uint)header.version < tx_h.V4) { story_scaler = 2; story_shift = 1; code_scaler = 2; code_shift = 1; property_mask = tx_h.P3_MAX_PROPERTIES - 1; property_size_mask = 0xe0; } else if ((uint)header.version < tx_h.V6) { story_scaler = 4; story_shift = 2; code_scaler = 4; code_shift = 2; property_mask = tx_h.P4_MAX_PROPERTIES - 1; property_size_mask = 0x3f; } else if ((uint)header.version < tx_h.V8) { story_scaler = 8; story_shift = 3; code_scaler = 4; code_shift = 2; property_mask = tx_h.P4_MAX_PROPERTIES - 1; property_size_mask = 0x3f; } else { story_scaler = 8; story_shift = 3; code_scaler = 8; code_shift = 3; property_mask = tx_h.P4_MAX_PROPERTIES - 1; property_size_mask = 0x3f; } /* Calculate the file size */ if ((uint)header.file_size == 0) { throw new ArgumentException("Can't handle files with no length. Giving up!"); // file_size = get_story_size(); } else if ((uint)header.version <= tx_h.V3) { file_size = header.file_size * 2; } else if ((uint)header.version <= tx_h.V5) { file_size = header.file_size * 4; } else { file_size = header.file_size * 8; } }/* configure */