Example #1
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = new PETSCII();
            byte[] sector;

            StringBuilder sbInformation = new StringBuilder();

            sbInformation.AppendLine("Commodore file system");

            XmlFsType = new FileSystemType
            {
                Type = "Commodore file system", Clusters = imagePlugin.Info.Sectors, ClusterSize = 256
            };

            if (imagePlugin.Info.Sectors == 3200)
            {
                sector = imagePlugin.ReadSector(1560);
                CommodoreHeader cbmHdr = Marshal.ByteArrayToStructureLittleEndian <CommodoreHeader>(sector);

                sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmHdr.directoryTrack,
                                           cbmHdr.directorySector).AppendLine();
                sbInformation
                .AppendFormat("Disk DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.diskDosVersion }))
                .AppendLine();
                sbInformation.AppendFormat("DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.dosVersion }))
                .AppendLine();
                sbInformation.AppendFormat("Disk Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.diskVersion }))
                .AppendLine();
                sbInformation.AppendFormat("Disk ID: {0}", cbmHdr.diskId).AppendLine();
                sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmHdr.name, Encoding))
                .AppendLine();

                XmlFsType.VolumeName   = StringHandlers.CToString(cbmHdr.name, Encoding);
                XmlFsType.VolumeSerial = $"{cbmHdr.diskId}";
            }
            else
            {
                sector = imagePlugin.ReadSector(357);
                CommodoreBam cbmBam = Marshal.ByteArrayToStructureLittleEndian <CommodoreBam>(sector);

                sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmBam.directoryTrack,
                                           cbmBam.directorySector).AppendLine();
                sbInformation.AppendFormat("Disk DOS type: {0}",
                                           Encoding.ASCII.GetString(BitConverter.GetBytes(cbmBam.dosType)))
                .AppendLine();
                sbInformation.AppendFormat("DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmBam.dosVersion }))
                .AppendLine();
                sbInformation.AppendFormat("Disk ID: {0}", cbmBam.diskId).AppendLine();
                sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmBam.name, Encoding))
                .AppendLine();

                XmlFsType.VolumeName   = StringHandlers.CToString(cbmBam.name, Encoding);
                XmlFsType.VolumeSerial = $"{cbmBam.diskId}";
            }

            information = sbInformation.ToString();
        }
Example #2
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (partition.Start > 0)
            {
                return(false);
            }

            if (imagePlugin.Info.SectorSize != 256)
            {
                return(false);
            }

            if (imagePlugin.Info.Sectors != 683 && imagePlugin.Info.Sectors != 768 && imagePlugin.Info.Sectors != 1366 &&
                imagePlugin.Info.Sectors != 3200)
            {
                return(false);
            }

            byte[] sector;

            if (imagePlugin.Info.Sectors == 3200)
            {
                sector = imagePlugin.ReadSector(1560);
                CommodoreHeader cbmHdr    = new CommodoreHeader();
                IntPtr          cbmHdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cbmHdr));
                Marshal.Copy(sector, 0, cbmHdrPtr, Marshal.SizeOf(cbmHdr));
                cbmHdr = (CommodoreHeader)Marshal.PtrToStructure(cbmHdrPtr, typeof(CommodoreHeader));
                Marshal.FreeHGlobal(cbmHdrPtr);

                if (cbmHdr.diskDosVersion == 0x44 && cbmHdr.dosVersion == 0x33 && cbmHdr.diskVersion == 0x44)
                {
                    return(true);
                }
            }
            else
            {
                sector = imagePlugin.ReadSector(357);
                CommodoreBAM cbmBam    = new CommodoreBAM();
                IntPtr       cbmBamPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cbmBam));
                Marshal.Copy(sector, 0, cbmBamPtr, Marshal.SizeOf(cbmBam));
                cbmBam = (CommodoreBAM)Marshal.PtrToStructure(cbmBamPtr, typeof(CommodoreBAM));
                Marshal.FreeHGlobal(cbmBamPtr);

                if (cbmBam.dosVersion == 0x41 && (cbmBam.doubleSided == 0x00 || cbmBam.doubleSided == 0x80) &&
                    cbmBam.unused1 == 0x00 && cbmBam.directoryTrack == 0x12)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (partition.Start > 0)
            {
                return(false);
            }

            if (imagePlugin.Info.SectorSize != 256)
            {
                return(false);
            }

            if (imagePlugin.Info.Sectors != 683 &&
                imagePlugin.Info.Sectors != 768 &&
                imagePlugin.Info.Sectors != 1366 &&
                imagePlugin.Info.Sectors != 3200)
            {
                return(false);
            }

            byte[] sector;

            if (imagePlugin.Info.Sectors == 3200)
            {
                sector = imagePlugin.ReadSector(1560);
                CommodoreHeader cbmHdr = Marshal.ByteArrayToStructureLittleEndian <CommodoreHeader>(sector);

                if (cbmHdr.diskDosVersion == 0x44 &&
                    cbmHdr.dosVersion == 0x33 &&
                    cbmHdr.diskVersion == 0x44)
                {
                    return(true);
                }
            }
            else
            {
                sector = imagePlugin.ReadSector(357);
                CommodoreBam cbmBam = Marshal.ByteArrayToStructureLittleEndian <CommodoreBam>(sector);

                if (cbmBam.dosVersion == 0x41 &&
                    (cbmBam.doubleSided == 0x00 || cbmBam.doubleSided == 0x80) &&
                    cbmBam.unused1 == 0x00 &&
                    cbmBam.directoryTrack == 0x12)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #4
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = new PETSCII();
            byte[] sector;

            StringBuilder sbInformation = new StringBuilder();

            sbInformation.AppendLine("Commodore file system");

            XmlFsType = new FileSystemType
            {
                Type        = "Commodore file system",
                Clusters    = (long)imagePlugin.Info.Sectors,
                ClusterSize = 256
            };

            if (imagePlugin.Info.Sectors == 3200)
            {
                sector = imagePlugin.ReadSector(1560);
                CommodoreHeader cbmHdr    = new CommodoreHeader();
                IntPtr          cbmHdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cbmHdr));
                Marshal.Copy(sector, 0, cbmHdrPtr, Marshal.SizeOf(cbmHdr));
                cbmHdr = (CommodoreHeader)Marshal.PtrToStructure(cbmHdrPtr, typeof(CommodoreHeader));
                Marshal.FreeHGlobal(cbmHdrPtr);

                sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmHdr.directoryTrack,
                                           cbmHdr.directorySector).AppendLine();
                sbInformation
                .AppendFormat("Disk DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.diskDosVersion }))
                .AppendLine();
                sbInformation.AppendFormat("DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.dosVersion }))
                .AppendLine();
                sbInformation.AppendFormat("Disk Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.diskVersion }))
                .AppendLine();
                sbInformation.AppendFormat("Disk ID: {0}", cbmHdr.diskId).AppendLine();
                sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmHdr.name, Encoding))
                .AppendLine();

                XmlFsType.VolumeName   = StringHandlers.CToString(cbmHdr.name, Encoding);
                XmlFsType.VolumeSerial = $"{cbmHdr.diskId}";
            }
            else
            {
                sector = imagePlugin.ReadSector(357);
                CommodoreBAM cbmBam    = new CommodoreBAM();
                IntPtr       cbmBamPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cbmBam));
                Marshal.Copy(sector, 0, cbmBamPtr, Marshal.SizeOf(cbmBam));
                cbmBam = (CommodoreBAM)Marshal.PtrToStructure(cbmBamPtr, typeof(CommodoreBAM));
                Marshal.FreeHGlobal(cbmBamPtr);

                sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmBam.directoryTrack,
                                           cbmBam.directorySector).AppendLine();
                sbInformation.AppendFormat("Disk DOS type: {0}",
                                           Encoding.ASCII.GetString(BitConverter.GetBytes(cbmBam.dosType)))
                .AppendLine();
                sbInformation.AppendFormat("DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmBam.dosVersion }))
                .AppendLine();
                sbInformation.AppendFormat("Disk ID: {0}", cbmBam.diskId).AppendLine();
                sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmBam.name, Encoding))
                .AppendLine();

                XmlFsType.VolumeName   = StringHandlers.CToString(cbmBam.name, Encoding);
                XmlFsType.VolumeSerial = $"{cbmBam.diskId}";
            }

            information = sbInformation.ToString();
        }