示例#1
0
        /// <summary>
        /// Read the file system of the ROM and create the folder tree.
        /// </summary>
        /// <param name="str">Stream to read the file system.</param>
        public override void Read(DataStream str)
        {
            // Read File Allocation Table
            // I'm creating a new DataStream variable because Fat class needs to know its length.
            DataStream fatStr = new DataStream(str, this.header.FatOffset, this.header.FatSize);
            Fat        fat    = new Fat();

            fat.Read(fatStr);
            fatStr.Dispose();

            // Read File Name Table
            str.Seek(header.FntOffset, SeekMode.Origin);
            Fnt fnt = new Fnt();

            fnt.Read(str);

            // Get root folder
            this.root = fnt.CreateTree(fat.GetFiles());

            // Get ARM and Overlay files
            this.sysFolder = new GameFolder("System");

            this.sysFolder.AddFile(ArmFile.FromStream(str, this.header, true));
            this.sysFolder.AddFolder(OverlayFolder.FromTable(str, this.header, true, fat.GetFiles()));

            this.sysFolder.AddFile(ArmFile.FromStream(str, this.header, false));
            this.sysFolder.AddFolder(OverlayFolder.FromTable(str, this.header, false, fat.GetFiles()));
        }
示例#2
0
        /// <summary>
        /// Writes every ROM file (except System files) into the Stream.
        /// </summary>
        /// <param name="strOut">Output stream.</param>
        public void WriteFiles(DataStream strOut)
        {
            // Uses the Fat class because there it's donde the implementation
            // to sorted them
            Fat fat = new Fat();

            fat.Initialize(null, this.root);
            fat.WriteFiles(strOut);
        }
示例#3
0
        /// <summary>
        /// Write the file system to the stream.
        /// </summary>
        /// <param name="str">Stream to write to.</param>
        public override void Write(DataStream str)
        {
            // The order is: ARM9 - Overlays9 - ARM7 - Overlays7 - FNT - FAT
            this.WriteArm(str, true);                   // Write ARM9
            this.WriteArm(str, false);                  // Write ARM7

            // To get the first ROM file ID
            int numOverlays = this.CountOverlays(false) + this.CountOverlays(true);

            // Create a new File Name Table...
            Fnt fnt = new Fnt();

            fnt.Initialize(null, this.root, numOverlays);

            // ... and writes it
            this.header.FntOffset = (uint)(this.header.HeaderSize + str.Position);
            long fntStartOffset = str.Position;

            fnt.Write(str);
            this.header.FntSize = (uint)(str.Position - fntStartOffset);
            str.WritePadding(FileSystem.PaddingByte, FileSystem.PaddingAddress);

            // Create a temp dir with every file to be register in the FAT (Game + System)
            GameFolder tmpFolder = new GameFolder(string.Empty);

            tmpFolder.AddFolders(this.sysFolder.Folders);               // Overlay folders
            tmpFolder.AddFolder(this.root);                             // Game files

            // Write File Allocation Table
            Fat fat = new Fat();

            fat.Initialize(null, tmpFolder, Banner.Size + this.header.HeaderSize);              // First file offset after banner
            this.header.FatOffset = (uint)(this.header.HeaderSize + str.Position);
            fat.Write(str);
            str.WritePadding(FileSystem.PaddingByte, FileSystem.PaddingAddress);
            this.header.FatSize = fat.Size;
        }
示例#4
0
 /// <summary>
 /// Writes every ROM file (except System files) into the Stream.
 /// </summary>
 /// <param name="strOut">Output stream.</param>
 public void WriteFiles(DataStream strOut)
 {
     // Uses the Fat class because there it's donde the implementation
     // to sorted them
     Fat fat = new Fat();
     fat.Initialize(null, this.root);
     fat.WriteFiles(strOut);
 }
示例#5
0
        /// <summary>
        /// Write the file system to the stream.
        /// </summary>
        /// <param name="str">Stream to write to.</param>
        public override void Write(DataStream str)
        {
            // The order is: ARM9 - Overlays9 - ARM7 - Overlays7 - FNT - FAT
            this.WriteArm(str, true);	// Write ARM9
            this.WriteArm(str, false);	// Write ARM7

            // To get the first ROM file ID
            int numOverlays = this.CountOverlays(false) + this.CountOverlays(true);

            // Create a new File Name Table...
            Fnt fnt = new Fnt();
            fnt.Initialize(null, this.root, numOverlays);

            // ... and writes it
            this.header.FntOffset = (uint)(this.header.HeaderSize + str.Position);
            long fntStartOffset = str.Position;
            fnt.Write(str);
            this.header.FntSize = (uint)(str.Position - fntStartOffset);
            str.WritePadding(FileSystem.PaddingByte, FileSystem.PaddingAddress);

            // Create a temp dir with every file to be register in the FAT (Game + System)
            GameFolder tmpFolder = new GameFolder(string.Empty);
            tmpFolder.AddFolders(this.sysFolder.Folders);	// Overlay folders
            tmpFolder.AddFolder(this.root);					// Game files

            // Write File Allocation Table
            Fat fat = new Fat();
            fat.Initialize(null, tmpFolder, Banner.Size + this.header.HeaderSize);	// First file offset after banner
            this.header.FatOffset = (uint)(this.header.HeaderSize + str.Position);
            fat.Write(str);
            str.WritePadding(FileSystem.PaddingByte, FileSystem.PaddingAddress);
            this.header.FatSize = fat.Size;
        }
示例#6
0
        /// <summary>
        /// Read the file system of the ROM and create the folder tree.
        /// </summary>
        /// <param name="str">Stream to read the file system.</param>
        public override void Read(DataStream str)
        {
            // Read File Allocation Table
            // I'm creating a new DataStream variable because Fat class needs to know its length.
            DataStream fatStr = new DataStream(str, this.header.FatOffset, this.header.FatSize);
            Fat fat = new Fat();
            fat.Read(fatStr);
            fatStr.Dispose();

            // Read File Name Table
            str.Seek(header.FntOffset, SeekMode.Origin);
            Fnt fnt = new Fnt();
            fnt.Read(str);

            // Get root folder
            this.root = fnt.CreateTree(fat.GetFiles());

            // Get ARM and Overlay files
            this.sysFolder = new GameFolder("System");

            this.sysFolder.AddFile(ArmFile.FromStream(str, this.header, true));
            this.sysFolder.AddFolder(OverlayFolder.FromTable(str, this.header, true, fat.GetFiles()));

            this.sysFolder.AddFile(ArmFile.FromStream(str, this.header, false));
            this.sysFolder.AddFolder(OverlayFolder.FromTable(str, this.header, false, fat.GetFiles()));
        }