예제 #1
0
            /// <summary>
            /// Parses a new disk image and loads it into this floppy drive
            /// </summary>
            /// <param name="tapeData"></param>
            public void FDD_LoadDisk(byte[] diskData)
            {
                // try dsk first
                FloppyDisk fdd   = null;
                bool       found = false;

                foreach (DiskType type in Enum.GetValues(typeof(DiskType)))
                {
                    switch (type)
                    {
                    case DiskType.CPCExtended:
                        fdd   = new CPCExtendedFloppyDisk();
                        found = fdd.ParseDisk(diskData);
                        break;

                    case DiskType.CPC:
                        fdd   = new CPCFloppyDisk();
                        found = fdd.ParseDisk(diskData);
                        break;
                    }

                    if (found)
                    {
                        Disk = fdd;
                        break;
                    }
                }

                if (!found)
                {
                    throw new Exception(this.GetType().ToString() +
                                        "\n\nDisk image file could not be parsed. Potentially an unknown format.");
                }
            }
예제 #2
0
        /// <summary>
        /// Attempts to load all media into the relevant structures
        /// </summary>
        protected void LoadAllMedia()
        {
            tapeImages = new List <byte[]>();
            diskImages = new List <byte[]>();

            int cnt = 0;

            foreach (var m in mediaImages)
            {
                switch (IdentifyMedia(m))
                {
                case SpectrumMediaType.Tape:
                    tapeImages.Add(m);
                    Spectrum._tapeInfo.Add(Spectrum._gameInfo[cnt]);
                    break;

                case SpectrumMediaType.Disk:
                    diskImages.Add(m);
                    Spectrum._diskInfo.Add(Spectrum._gameInfo[cnt]);
                    break;

                case SpectrumMediaType.DiskDoubleSided:
                    // this is a bit tricky. we will attempt to parse the double sided disk image byte array,
                    // then output two separate image byte arrays
                    List <byte[]> working = new List <byte[]>();
                    foreach (DiskType type in Enum.GetValues(typeof(DiskType)))
                    {
                        bool found = false;

                        switch (type)
                        {
                        case DiskType.CPCExtended:
                            found = CPCExtendedFloppyDisk.SplitDoubleSided(m, working);
                            break;

                        case DiskType.CPC:
                            found = CPCFloppyDisk.SplitDoubleSided(m, working);
                            break;

                        case DiskType.UDI:
                            found = UDI1_0FloppyDisk.SplitDoubleSided(m, working);
                            break;
                        }

                        if (found)
                        {
                            // add side 1
                            diskImages.Add(working[0]);
                            // add side 2
                            diskImages.Add(working[1]);

                            Common.GameInfo one = new Common.GameInfo();
                            Common.GameInfo two = new Common.GameInfo();
                            var             gi  = Spectrum._gameInfo[cnt];
                            for (int i = 0; i < 2; i++)
                            {
                                Common.GameInfo work = new Common.GameInfo();
                                if (i == 0)
                                {
                                    work = one;
                                }
                                else if (i == 1)
                                {
                                    work = two;
                                }

                                work.FirmwareHash  = gi.FirmwareHash;
                                work.Hash          = gi.Hash;
                                work.Name          = gi.Name + " (Parsed Side " + (i + 1) + ")";
                                work.Region        = gi.Region;
                                work.NotInDatabase = gi.NotInDatabase;
                                work.Status        = gi.Status;
                                work.System        = gi.System;

                                Spectrum._diskInfo.Add(work);
                            }
                        }
                        else
                        {
                        }
                    }
                    break;
                }

                cnt++;
            }

            if (tapeImages.Count > 0)
            {
                LoadTapeMedia();
            }

            if (diskImages.Count > 0)
            {
                LoadDiskMedia();
            }
        }