public async Task LoadFat() { data = files_array[SMem.Data] as ROMBIN; fat = files_array[SMem.Fat] as ROMBIN; Reader reader = files_array[SMem.Fat].reader; loadingState = "Loading struct tables"; await WaitIfNecessary(); uint num_tables = reader.ReadUInt32(); if (fatTables == null) { fatTables = new FATTable[num_tables + 2]; } for (uint i = 0; i < num_tables + 2; i++) { if (i < 2) { loadingState = "Loading struct table " + (i + 1) + "/" + (num_tables + 2); await WaitIfNecessary(); } fatTables[i] = FATTable.Read(reader, Pointer.Current(reader), readEntries: i < 2); } await WaitIfNecessary(); }
public async Task LoadFix() { data = files_array[SMem.Data] as ROMBIN; Reader reader = files_array[SMem.Data].reader; reader.ReadUInt16(); reader.ReadUInt16(); ushort num_textureTables = reader.ReadUInt16(); // for texture data. not referenced in fat.bin ushort flags = reader.ReadUInt16(); ushort num_levels = reader.ReadUInt16(); reader.ReadUInt16(); if (Settings.s.platform == Settings.Platform.DS || Settings.s.platform == Settings.Platform.N64) { loadingState = "Loading texture tables"; await WaitIfNecessary(); for (int i = 0; i < 18; i++) { Pointer off_list = Pointer.Read(reader); uint num_list = reader.ReadUInt32(); } Pointer off_table_i4 = Pointer.Read(reader); uint sz_table_i4 = reader.ReadUInt32() >> 2; Pointer off_table_i8 = Pointer.Read(reader); uint sz_table_i8 = reader.ReadUInt32() >> 2; Pointer off_table_rgba = Pointer.Read(reader); uint sz_table_rgba = reader.ReadUInt32() >> 2; ind_textureTable_i4 = 0; ind_textureTable_i8 = ind_textureTable_i4 + (sz_table_i4); ind_textureTable_rgba = ind_textureTable_i8 + (sz_table_i8); uint totalSz = ind_textureTable_rgba + (sz_table_rgba); texturesTable = new Pointer[totalSz]; Pointer.DoAt(ref reader, off_table_i4, () => { for (int i = 0; i < sz_table_i4; i++) { texturesTable[ind_textureTable_i4 + i] = Pointer.Read(reader); } }); Pointer.DoAt(ref reader, off_table_i8, () => { for (int i = 0; i < sz_table_i8; i++) { texturesTable[ind_textureTable_i8 + i] = Pointer.Read(reader); } }); Pointer.DoAt(ref reader, off_table_rgba, () => { for (int i = 0; i < sz_table_rgba; i++) { texturesTable[ind_textureTable_rgba + i] = Pointer.Read(reader); } }); Pointer off_palettesTable = Pointer.Read(reader); if (Settings.s.platform == Settings.Platform.DS) { uint sz_palettesTable = reader.ReadUInt32() >> 2; palettesTable = new Pointer[sz_palettesTable]; print(texturesTable.Length + " - " + palettesTable.Length); Pointer.DoAt(ref reader, off_palettesTable, () => { for (int i = 0; i < sz_palettesTable; i++) { palettesTable[i] = Pointer.Read(reader); } }); } else { palettesTable = new Pointer[0]; } } // Read fix texture list loadingState = "Loading engine structure"; await WaitIfNecessary(); EngineStruct engineStruct = GetOrRead <EngineStruct>(reader, (ushort)(0 | FATEntry.Flag.Fix)); // Read languages table loadingState = "Loading language tables"; await WaitIfNecessary(); NumLanguages numLanguages = GetOrRead <NumLanguages>(reader, 0); print("Number of languages: " + numLanguages.num_languages); localizationROM = new LanguageTable[numLanguages.num_languages]; for (ushort i = 0; i < numLanguages.num_languages; i++) { loadingState = "Loading language table " + (i + 1) + "/" + numLanguages.num_languages; await WaitIfNecessary(); localizationROM[i] = GetOrRead <LanguageTable>(reader, i); if (localizationROM[i] != null) { print(localizationROM[i].name); } } // Load level list loadingState = "Loading level list"; await WaitIfNecessary(); LevelList levelList = GetOrRead <LevelList>(reader, (ushort)(0 | FATEntry.Flag.Fix), l => l.num_levels = num_levels); for (int i = 0; i < num_levels; i++) { if (levelList.levels[i].name.ToLower() == lvlName.ToLower()) { CurrentLevel = i; break; } } }