Пример #1
0
        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();
        }
Пример #2
0
        public string[] LoadLevelList()
        {
            if (gameDataBinFolder == null || gameDataBinFolder.Trim().Equals(""))
            {
                return(null);
            }
            gameDataBinFolder += "/";
            if (!File.Exists(gameDataBinFolder + "data.bin"))
            {
                return(null);
            }
            if (!File.Exists(gameDataBinFolder + "fat.bin"))
            {
                return(null);
            }
            files_array[SMem.Data] = new ROMBIN("data.bin", gameDataBinFolder + "data.bin", SMem.Data);
            files_array[SMem.Fat]  = new ROMBIN("fat.bin", gameDataBinFolder + "fat.bin", SMem.Fat);

            // Load fat
            Reader reader     = files_array[SMem.Fat].reader;
            uint   num_tables = reader.ReadUInt32();

            if (fatTables == null)
            {
                fatTables = new FATTable[num_tables + 2];
            }
            for (uint i = 0; i < num_tables + 2; i++)
            {
                fatTables[i] = FATTable.Read(reader, Pointer.Current(reader), readEntries: i < 2);
            }
            string[] levels        = new string[num_tables];
            Pointer  off_levelList = GetStructPtr(FATEntry.Type.LevelList, (ushort)(0 | FATEntry.Flag.Fix), false);

            for (int i = 0; i < levels.Length; i++)
            {
                Pointer.DoAt(ref reader, off_levelList + 64 * i, () => {
                    reader.ReadUInt16();
                    levels[i] = reader.ReadNullDelimitedString();
                });
            }

            /*LevelList levelList = GetOrRead<LevelList>(reader, 0x8000, l => l.num_levels = (ushort)num_tables);
             * levels = levelList.levels.Select(l => l.name).ToArray();*/
            return(levels);
        }