/* This file is part of ContrAlto. ContrAlto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ContrAlto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with ContrAlto. If not, see . */ using Contralto.Logging; using System; using System.IO; namespace Contralto { /// /// The configuration of the Alto to emulate /// public enum SystemType { /// /// Alto I System with 1K ROM, 1K RAM /// AltoI, /// /// Alto II XM System with the standard 1K ROM, 1K RAM /// OneKRom, /// /// Alto II XM System with 2K ROM, 1K RAM /// TwoKRom, /// /// Alto II XM System with 3K RAM /// ThreeKRam, } public enum PacketInterfaceType { /// /// Encapsulate frames inside raw ethernet frames on the host interface. /// Requires PCAP. /// EthernetEncapsulation, /// /// Encapsulate frames inside UDP datagrams on the host interface. /// UDPEncapsulation, /// /// No encapsulation; sent packets are dropped on the floor and no packets are received. /// None, } public enum AlternateBootType { None, Disk, Ethernet, } public enum PlatformType { Windows, Unix } /// /// Encapsulates user-configurable settings. To be enhanced. /// public class Configuration { static Configuration() { // Initialize things to defaults. HostAddress = 0x22; AlternateBootType = AlternateBootType.Disk; BootAddress = 0; BootFile = 0; SystemType = SystemType.TwoKRom; InterlaceDisplay = false; ThrottleSpeed = true; switch(Environment.OSVersion.Platform) { case PlatformID.MacOSX: case PlatformID.Unix: Platform = PlatformType.Unix; break; default: Platform = PlatformType.Windows; break; } ReadConfiguration(); } /// /// What kind of system we're running on. (Not technically configurable.) /// public static PlatformType Platform; /// /// The type of Alto II to emulate /// public static SystemType SystemType; /// /// The currently loaded image for Drive 0 /// public static string Drive0Image; /// /// The currently loaded image for Drive 1 /// public static string Drive1Image; /// /// The Ethernet host address for this Alto /// public static byte HostAddress; /// /// The name of the Ethernet adaptor on the emulator host to use for Ethernet emulation /// public static string HostPacketInterfaceName; /// /// Whether any packet interfaces are available on the host /// public static bool HostRawEthernetInterfacesAvailable; /// /// The type of interface to use to host networking. /// public static PacketInterfaceType HostPacketInterfaceType; /// /// The type of Alternate Boot to apply /// public static AlternateBootType AlternateBootType; /// /// The address to boot at reset for a disk alternate boot /// public static ushort BootAddress; /// /// The file to boot at reset for an ethernet alternate boot /// public static ushort BootFile; /// /// Whether to render the display "interlaced" or not. /// public static bool InterlaceDisplay; /// /// Whether to cap execution speed at native execution speed or not. /// public static bool ThrottleSpeed; public static string GetAltoIRomPath(string romFileName) { return Path.Combine("ROM", "AltoI", romFileName); } public static string GetAltoIIRomPath(string romFileName) { return Path.Combine("ROM", "AltoII", romFileName); } public static string GetRomPath(string romFileName) { return Path.Combine("ROM", romFileName); } /// /// Reads the current configuration file from the app's configuration. /// /// TODO: use reflection to do this. /// public static void ReadConfiguration() { Drive0Image = (string)Properties.Settings.Default["Drive0Image"]; Drive1Image = (string)Properties.Settings.Default["Drive1Image"]; SystemType = (SystemType)Properties.Settings.Default["SystemType"]; HostAddress = (byte)Properties.Settings.Default["HostAddress"]; HostPacketInterfaceName = (string)Properties.Settings.Default["HostPacketInterfaceName"]; HostPacketInterfaceType = (PacketInterfaceType)Properties.Settings.Default["HostPacketInterfaceType"]; AlternateBootType = (AlternateBootType)Properties.Settings.Default["AlternateBootType"]; BootAddress = (ushort)Properties.Settings.Default["BootAddress"]; BootFile = (ushort)Properties.Settings.Default["BootFile"]; InterlaceDisplay = (bool)Properties.Settings.Default["InterlaceDisplay"]; ThrottleSpeed = (bool)Properties.Settings.Default["ThrottleSpeed"]; } /// /// Commits the current configuration to the app's settings. /// public static void WriteConfiguration() { Properties.Settings.Default["Drive0Image"] = Drive0Image; Properties.Settings.Default["Drive1Image"] = Drive1Image; Properties.Settings.Default["SystemType"] = (int)SystemType; Properties.Settings.Default["HostAddress"] = HostAddress; Properties.Settings.Default["HostPacketInterfaceName"] = HostPacketInterfaceName; Properties.Settings.Default["HostPacketInterfaceType"] = (int)HostPacketInterfaceType; Properties.Settings.Default["AlternateBootType"] = (int)AlternateBootType; Properties.Settings.Default["BootAddress"] = BootAddress; Properties.Settings.Default["BootFile"] = BootFile; Properties.Settings.Default["InterlaceDisplay"] = InterlaceDisplay; Properties.Settings.Default["ThrottleSpeed"] = ThrottleSpeed; Properties.Settings.Default.Save(); } } }