Esempio n. 1
0
        private void ApplyConfiguration(AeonConfiguration config)
        {
            this.emulatorDisplay.ResetEmulator(config.PhysicalMemorySize ?? 16);

            var globalConfig = GlobalConfiguration.Load();

            foreach (var(letter, info) in config.Drives)
            {
                var driveLetter = ParseDriveLetter(letter);

                var vmDrive = this.emulatorDisplay.EmulatorHost.VirtualMachine.FileSystem.Drives[driveLetter];
                vmDrive.DriveType   = info.Type;
                vmDrive.VolumeLabel = info.Label;
                if (info.FreeSpace != null)
                {
                    vmDrive.FreeSpace = info.FreeSpace.GetValueOrDefault();
                }

                if (config.Archive == null)
                {
                    if (!string.IsNullOrEmpty(info.HostPath))
                    {
                        vmDrive.Mapping = info.ReadOnly ? new MappedFolder(info.HostPath) : new WritableMappedFolder(info.HostPath);
                    }
                    else if (!string.IsNullOrEmpty(info.ImagePath))
                    {
                        vmDrive.Mapping = new ISOImage(info.ImagePath);
                    }
                    else
                    {
                        throw new FormatException();
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(info.ImagePath))
                    {
                        if (info.ReadOnly)
                        {
                            vmDrive.Mapping = new MappedArchive(driveLetter, config.Archive);
                        }
                        else
                        {
                            var rootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Aeon Emulator", "Files", config.Id, letter.ToUpperInvariant());
                            vmDrive.Mapping = new DifferencingFolder(driveLetter, config.Archive, rootPath);
                        }
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }

                vmDrive.HasCommandInterpreter = vmDrive.DriveType == DriveType.Fixed;
            }

            this.emulatorDisplay.EmulatorHost.VirtualMachine.FileSystem.WorkingDirectory = new VirtualPath(config.StartupPath);

            var vm = this.emulatorDisplay.EmulatorHost.VirtualMachine;

            vm.RegisterVirtualDevice(new Sound.PCSpeaker.InternalSpeaker());
            vm.RegisterVirtualDevice(new Sound.Blaster.SoundBlaster(vm));
            vm.RegisterVirtualDevice(new Sound.FM.FmSoundCard());
            vm.RegisterVirtualDevice(new Sound.GeneralMidi(globalConfig.Mt32Enabled ? globalConfig.Mt32RomsPath : null));

            emulatorDisplay.EmulationSpeed = config.EmulationSpeed ?? 20_000_000;
            emulatorDisplay.MouseInputMode = config.IsMouseAbsolute ? Presentation.MouseInputMode.Absolute : Presentation.MouseInputMode.Relative;
            toolBar.Visibility             = config.HideUserInterface ? Visibility.Collapsed : Visibility.Visible;
            mainMenu.Visibility            = config.HideUserInterface ? Visibility.Collapsed : Visibility.Visible;
            if (!string.IsNullOrEmpty(config.Title))
            {
                this.Title = config.Title;
            }
Esempio n. 2
0
        public static int Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: aeonpack <AeonConfig> <PackageName>");
                return(1);
            }

            var archiveBuilder = new ArchiveBuilder();

            var config = AeonConfiguration.Load(args[0]);

            archiveBuilder.AddFile(GetArchiveConfigStream(config), "Archive.AeonConfig");

            int isoIndex = 1;

            foreach (var drive in config.Drives)
            {
                var driveConfig = drive.Value;
                if (!string.IsNullOrEmpty(driveConfig.HostPath))
                {
                    int hostPathLength = driveConfig.HostPath.Length;
                    if (!driveConfig.HostPath.EndsWith('\\') && !driveConfig.HostPath.EndsWith('/'))
                    {
                        hostPathLength++;
                    }

                    var drivePrefix = drive.Key.ToUpperInvariant() + ":\\";

                    foreach (var sourceFileName in Directory.EnumerateFiles(driveConfig.HostPath, "*", SearchOption.AllDirectories))
                    {
                        var destPath = getArchivePath(sourceFileName);
                        if (destPath != null)
                        {
                            Console.WriteLine($"Adding {sourceFileName} => {destPath}...");
                            archiveBuilder.AddFile(sourceFileName, destPath);
                        }
                    }

                    string getArchivePath(string srcPath)
                    {
                        var relativePath = srcPath.Substring(hostPathLength).Trim('\\', '/');
                        var pathParts    = relativePath.Split(Path.DirectorySeparatorChar);

                        if (!pathParts.All(Valid83PathRegex.IsMatch))
                        {
                            return(null);
                        }

                        return(drivePrefix + relativePath.ToUpperInvariant());
                    }
                }
                else if (!string.IsNullOrWhiteSpace(drive.Value.ImagePath))
                {
                    archiveBuilder.AddFile(drive.Value.ImagePath, $"Image{isoIndex}.iso");
                    isoIndex++;
                }
                else
                {
                    throw new InvalidDataException();
                }
            }

            Console.WriteLine($"Writing {args[1]}...");
            using var outputStream = File.Create(args[1]);
            Console.CursorVisible  = false;
            archiveBuilder.Write(outputStream, new BuilderProgress(archiveBuilder.DataCount));
            Console.CursorVisible = true;

            return(0);
        }