Exemple #1
0
        private void InitMedia(byte[] rom)
        {
            switch (C64FormatFinder.GetFormat(rom))
            {
            case C64Format.D64:
                var d64 = D64.Read(rom);
                if (d64 != null)
                {
                    _board.DiskDrive.InsertMedia(d64);
                }
                break;

            case C64Format.G64:
                var g64 = G64.Read(rom);
                if (g64 != null)
                {
                    _board.DiskDrive.InsertMedia(g64);
                }
                break;

            case C64Format.CRT:
                var cart = CartridgeDevice.Load(rom);
                if (cart != null)
                {
                    _board.CartPort.Connect(cart);
                }
                break;

            case C64Format.TAP:
                var tape = Tape.Load(rom);
                if (tape != null)
                {
                    _board.TapeDrive.Insert(tape);
                }
                break;

            case C64Format.Unknown:
                var prgDisk = new DiskBuilder
                {
                    Entries = new List <DiskBuilder.Entry>
                    {
                        new DiskBuilder.Entry
                        {
                            Closed       = true,
                            Data         = rom,
                            Locked       = false,
                            Name         = "PRG",
                            RecordLength = 0,
                            Type         = DiskBuilder.FileType.Program
                        }
                    }
                }.Build();
                if (prgDisk != null)
                {
                    _board.DiskDrive.InsertMedia(prgDisk);
                }
                break;
            }
        }
Exemple #2
0
        private void Init(VicType initRegion, BorderType borderType, SidType sidType, TapeDriveType tapeDriveType, DiskDriveType diskDriveType)
        {
            // Force certain drive types to be available depending on ROM type
            foreach (var rom in Roms)
            {
                switch (C64FormatFinder.GetFormat(rom))
                {
                case C64Format.D64:
                case C64Format.G64:
                case C64Format.X64:
                    if (diskDriveType == DiskDriveType.None)
                    {
                        diskDriveType = DiskDriveType.Commodore1541;
                    }
                    break;

                case C64Format.T64:
                case C64Format.TAP:
                    if (tapeDriveType == TapeDriveType.None)
                    {
                        tapeDriveType = TapeDriveType.Commodore1530;
                    }
                    break;

                case C64Format.CRT:
                    // Nothing required.
                    break;

                case C64Format.Unknown:
                    if (rom.Length >= 0xFE00)
                    {
                        throw new Exception("The image format is not known, and too large to be used as a PRG.");
                    }
                    if (diskDriveType == DiskDriveType.None)
                    {
                        diskDriveType = DiskDriveType.Commodore1541;
                    }
                    break;

                default:
                    throw new Exception("The image format is not yet supported by the Commodore 64 core.");
                }
            }

            _board = new Motherboard(this, initRegion, borderType, sidType, tapeDriveType, diskDriveType);
            InitRoms(diskDriveType);
            _board.Init();

            // configure video
            CoreComm.VsyncDen = _board.Vic.CyclesPerFrame;
            CoreComm.VsyncNum = _board.Vic.CyclesPerSecond;
        }
Exemple #3
0
        // Currently we will require at least one rom.  If multiple they MUST be all the same media type in the same format
        // Given a good enough use case we could in theory expand those requirements, but for now we need a sanity check
        private void RomSanityCheck()
        {
            if (Roms.Count == 0)
            {
                throw new NotSupportedException("Currently, a Rom is required to run this core.");
            }

            var formats = Roms.Select(rom => C64FormatFinder.GetFormat(rom));

            HashSet <C64Format> uniqueFormats = new HashSet <C64Format>();

            foreach (var format in formats)
            {
                uniqueFormats.Add(format);
            }

            if (uniqueFormats.Count > 1)
            {
                throw new NotSupportedException("Currently Roms must all be of the same type.");
            }
        }