Esempio n. 1
0
        public byte[] SaveToArray()
        {
            byte[] temp = new byte[Leo.LBAToByte(DiskType, Leo.RamStartLBA[DiskType], 3)];

            Util.WriteStringN(MFS.RAM_ID, temp, 0, MFS.RAM_ID.Length);
            temp[0x0E] = (byte)(0 | (Attributes.isVolumeWriteProtected ? 0x20 : 0) | (Attributes.isVolumeReadProtected ? 0x40 : 0) | (Attributes.isWriteProtected ? 0x80 : 0));
            temp[0x0F] = (byte)DiskType;

            Util.WriteStringN(Name, temp, 0x10, 0x14);
            Util.WriteBEU32(Date.Save(), temp, 0x24);
            Util.WriteBEU16(Renewal, temp, 0x28);
            temp[0x2A] = Country;

            //Save FAT Entries
            for (int i = 0; i < FAT.Length; i++)
            {
                Util.WriteBEU16(FAT[i], temp, 0x3C + (i * 2));
            }

            //Save File Entries 0x16B0
            for (int i = 0; i < Entries.Count; i++)
            {
                byte[] tempentry;
                if (Entries[i].GetType() == typeof(MFSDirectory))
                {
                    tempentry = ((MFSDirectory)Entries[i]).Save();
                }
                else
                {
                    tempentry = ((MFSFile)Entries[i]).Save();
                }
                Array.Copy(tempentry, 0, temp, 0x16B0 + (0x30 * i), 0x30);
            }

            //Checksum
            uint crc = 0;

            for (int i = 0; i < (temp.Length / 4); i++)
            {
                crc ^= Util.ReadBEU32(temp, i * 4);
            }
            Util.WriteBEU32(crc, temp, 0x2C);

            return(temp);
        }
Esempio n. 2
0
        public byte[] SaveEntry()
        {
            byte[] temp = new byte[0x30];

            //Attributes
            temp[0] = (byte)(0 | (Attributes.CopyLimit ? 0x02 : 0) | (Attributes.Encode ? 0x04 : 0) | (Attributes.Hidden ? 0x08 : 0)
                             | (Attributes.DisableRead ? 0x10 : 0) | (Attributes.DisableWrite ? 0x20 : 0));

            Util.WriteBEU16(ParentDirectory, temp, 2);
            Util.WriteStringN(CompanyCode, temp, 4, 2);
            Util.WriteStringN(GameCode, temp, 6, 4);
            Util.WriteStringN(Name, temp, 0x10, 0x14);

            temp[0x2A] = Renewal;
            Util.WriteBEU32(Date.Save(), temp, 0x2C);

            return(temp);
        }