mirror of
https://github.com/livingcomputermuseum/Darkstar.git
synced 2026-01-12 00:42:59 +00:00
Some useful improvements/changes to Darkstar
new functionality - ethernet: new network device for direct connection to a Dodo NetHub (instead of going through a real network device) - configuration-dialog: extensions for selecting and configuring the NetHub connection - command-line: new optional parameter "-start" for starting the emulator when the UI is ready - configuration-file: added new parameters to match the items that can be specified through the UI, also to autostart the system new entries: NetHubHost, NetHubPort, AltBootMode, Start (see the sample config-file in star_os_5.0.zip for all options) changes/fixes: - development: use of SharpDevelop with .net 4.5 - ethernet: add 2 extra zero-words to prevent packets larger than 56 bytes from being ignored by the ethernet microcode - configuration-dialog: allow to specify 48 bit machine-ids (only 40 significant bits were accepted so far) - display: reversed the order of the pattern lines to match the background pattern in the main display area
This commit is contained in:
parent
5b292b02e8
commit
a109b60e94
@ -57,6 +57,9 @@ namespace D
|
||||
SlowPhosphor = true;
|
||||
HostPacketInterfaceName = String.Empty;
|
||||
|
||||
NetHubHost = "localhost";
|
||||
NetHubPort = 3333;
|
||||
|
||||
TODDateTime = new DateTime(1979, 12, 10);
|
||||
TODDate = new DateTime(1955, 11, 5);
|
||||
TODSetMode = TODPowerUpSetMode.HostTimeY2K;
|
||||
@ -138,6 +141,16 @@ namespace D
|
||||
/// </summary>
|
||||
public static string HostPacketInterfaceName;
|
||||
|
||||
/// <summary>
|
||||
/// The host name to connect to if the network interface is NetHub
|
||||
/// </summary>
|
||||
public static string NetHubHost;
|
||||
|
||||
/// <summary>
|
||||
/// The port to connect to if the network interface is NetHub
|
||||
/// </summary>
|
||||
public static ushort NetHubPort;
|
||||
|
||||
/// <summary>
|
||||
/// Whether any packet interfaces are available on the host
|
||||
/// </summary>
|
||||
@ -188,6 +201,16 @@ namespace D
|
||||
/// The types of logging to enable.
|
||||
/// </summary>
|
||||
public static LogType LogTypes;
|
||||
|
||||
/// <summary>
|
||||
/// The preferred Alt-Boot mode
|
||||
/// </summary>
|
||||
public static AltBootValues AltBootMode = AltBootValues.None;
|
||||
|
||||
/// <summary>
|
||||
/// Do start system when the UI is brought up?
|
||||
/// </summary>
|
||||
public static bool Start = false;
|
||||
|
||||
/// <summary>
|
||||
/// Reads the current configuration file from the appropriate place.
|
||||
@ -239,7 +262,9 @@ namespace D
|
||||
HardDriveImage = Properties.Settings.Default.HardDriveImage;
|
||||
FloppyDriveImage = Properties.Settings.Default.FloppyDriveImage;
|
||||
HostID = Properties.Settings.Default.HostAddress;
|
||||
HostPacketInterfaceName = Properties.Settings.Default.HostPacketInterfaceName;
|
||||
HostPacketInterfaceName = Properties.Settings.Default.HostPacketInterfaceName;
|
||||
NetHubHost = Properties.Settings.Default.NetHubHost;
|
||||
NetHubPort = Properties.Settings.Default.NetHubPort;
|
||||
ThrottleSpeed = Properties.Settings.Default.ThrottleSpeed;
|
||||
DisplayScale = Properties.Settings.Default.DisplayScale;
|
||||
FullScreenStretch = Properties.Settings.Default.FullScreenFilter;
|
||||
@ -255,7 +280,9 @@ namespace D
|
||||
Properties.Settings.Default.HardDriveImage = HardDriveImage;
|
||||
Properties.Settings.Default.FloppyDriveImage = FloppyDriveImage;
|
||||
Properties.Settings.Default.HostAddress = HostID;
|
||||
Properties.Settings.Default.HostPacketInterfaceName = HostPacketInterfaceName;
|
||||
Properties.Settings.Default.HostPacketInterfaceName = HostPacketInterfaceName;
|
||||
Properties.Settings.Default.NetHubHost = NetHubHost;
|
||||
Properties.Settings.Default.NetHubPort = NetHubPort;
|
||||
Properties.Settings.Default.ThrottleSpeed = ThrottleSpeed;
|
||||
Properties.Settings.Default.DisplayScale = DisplayScale;
|
||||
Properties.Settings.Default.FullScreenFilter = FullScreenStretch;
|
||||
@ -357,7 +384,7 @@ namespace D
|
||||
|
||||
case "UInt16":
|
||||
{
|
||||
UInt16 v = Convert.ToUInt16(value, 16);
|
||||
UInt16 v = Convert.ToUInt16(value, 10);
|
||||
field.SetValue(null, v);
|
||||
}
|
||||
break;
|
||||
@ -427,6 +454,12 @@ namespace D
|
||||
field.SetValue(null, sc);
|
||||
}
|
||||
break;
|
||||
|
||||
case "AltBootValues":
|
||||
{
|
||||
field.SetValue(null, Enum.Parse(typeof(AltBootValues), value, true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@ -8,9 +8,19 @@
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>D</RootNamespace>
|
||||
<AssemblyName>Darkstar</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<NoWin32Manifest>False</NoWin32Manifest>
|
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||
<NoStdLib>False</NoStdLib>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
|
||||
<DefineConstants>TRACE ORIGINAL_CODE</DefineConstants>
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<DelaySign>False</DelaySign>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@ -18,16 +28,14 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>PdbOnly</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
@ -37,26 +45,40 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Dandelion.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||
<BaseAddress>4194304</BaseAddress>
|
||||
<Prefer32Bit>True</Prefer32Bit>
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'x64' ">
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<StartAction>Project</StartAction>
|
||||
<StartArguments>-config xde_5.0.cfg</StartArguments>
|
||||
<StartWorkingDirectory>C:\_Hans\Darkstar_NewFeatures\D</StartWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PacketDotNet, Version=0.13.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Sharp_Pcap.4.2.0\lib\PacketDotNet.dll</HintPath>
|
||||
@ -122,6 +144,7 @@
|
||||
<Compile Include="Display\DisplayController.cs" />
|
||||
<Compile Include="Ethernet\HostEthernet.cs" />
|
||||
<Compile Include="Ethernet\IPacketInterface.cs" />
|
||||
<Compile Include="Ethernet\NethubInterface.cs" />
|
||||
<Compile Include="IOP\Beeper.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
BIN
D/Disks/star_os_5.0.zip
Normal file
BIN
D/Disks/star_os_5.0.zip
Normal file
Binary file not shown.
@ -171,7 +171,7 @@ namespace D.Display
|
||||
{
|
||||
// Normal line : 32 bits of border pattern, 1024 bits of display, 32 bits of border pattern
|
||||
// Border pattern: low byte on lines 4n, 4n+1; high byte on 4n+2, 4n+3.
|
||||
int patternByte = (effectiveScanline & 0x2) == 0 ? _displayBorder & 0xff : _displayBorder >> 8;
|
||||
int patternByte = (effectiveScanline & 0x2) == 2 ? _displayBorder & 0xff : _displayBorder >> 8;
|
||||
ushort patternWord = (ushort)(patternByte | (patternByte << 8));
|
||||
|
||||
_scanlineData[0] = patternWord;
|
||||
@ -213,7 +213,7 @@ namespace D.Display
|
||||
{
|
||||
// Just display the border pattern everywhere:
|
||||
// low byte on lines 4n, 4n+1; high byte on 4n+2, 4n+3.
|
||||
int patternByte = (effectiveScanline & 0x2) == 0 ? _displayBorder & 0xff : _displayBorder >> 8;
|
||||
int patternByte = (effectiveScanline & 0x2) == 2 ? _displayBorder & 0xff : _displayBorder >> 8;
|
||||
ushort patternWord = (ushort)(patternByte | (patternByte << 8));
|
||||
|
||||
for (int i = 0; i < _scanlineData.Length; i++)
|
||||
|
||||
@ -624,12 +624,14 @@ namespace D.Ethernet
|
||||
_readerLock.ExitWriteLock();
|
||||
|
||||
if (Log.Enabled) Log.Write(LogComponent.EthernetReceive, "Packet (length {0}) added to pending buffer.", data.Length);
|
||||
//(debug) Console.Write(" -- Packet (length {0}) added to pending buffer -- currently enqueued: {1}\n", data.Length, _pendingPackets.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Too many queued-up packets, drop this one.
|
||||
//
|
||||
//(debug) Console.WriteLine("Pending buffer full; dropping this packet.");
|
||||
if (Log.Enabled) Log.Write(LogComponent.EthernetReceive, "Pending buffer full; dropping this packet.");
|
||||
}
|
||||
_readerLock.ExitUpgradeableReadLock();
|
||||
@ -720,6 +722,12 @@ namespace D.Ethernet
|
||||
_inputPacket.Enqueue((ushort)(packetStream.ReadByte() << 8));
|
||||
}
|
||||
|
||||
// add 2 words to ensure that the ethernet task microcode does not ignore the packet
|
||||
// (the microcode seems to expect a 4 byte "frame check sequence" at the packet end)
|
||||
_inputPacket.Enqueue((ushort)0);
|
||||
_inputPacket.Enqueue((ushort)0);
|
||||
// end adding 2 words
|
||||
|
||||
_fifo.Clear();
|
||||
_fifoHead = 0;
|
||||
|
||||
@ -848,9 +856,12 @@ namespace D.Ethernet
|
||||
try
|
||||
{
|
||||
|
||||
if (Configuration.HostRawEthernetInterfacesAvailable &&
|
||||
!string.IsNullOrWhiteSpace(Configuration.HostPacketInterfaceName))
|
||||
{
|
||||
if (Configuration.HostPacketInterfaceName == NethubInterface.NETHUB_NAME) {
|
||||
_hostInterface = new NethubInterface();
|
||||
_hostInterface.RegisterReceiveCallback(OnHostPacketReceived);
|
||||
Console.WriteLine("** connected to nethub");
|
||||
} else if (Configuration.HostRawEthernetInterfacesAvailable &&
|
||||
!string.IsNullOrWhiteSpace(Configuration.HostPacketInterfaceName)) {
|
||||
_hostInterface = new HostEthernetEncapsulation(Configuration.HostPacketInterfaceName);
|
||||
_hostInterface.RegisterReceiveCallback(OnHostPacketReceived);
|
||||
}
|
||||
@ -859,6 +870,9 @@ namespace D.Ethernet
|
||||
{
|
||||
_hostInterface = null;
|
||||
Log.Write(LogComponent.HostEthernet, "Unable to configure network interface. Error {0}", e.Message);
|
||||
if (Configuration.HostPacketInterfaceName == NethubInterface.NETHUB_NAME) {
|
||||
Console.WriteLine("##\n## failed to connect to nethub: " + e.Message + "\n##");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
209
D/Ethernet/NethubInterface.cs
Normal file
209
D/Ethernet/NethubInterface.cs
Normal file
@ -0,0 +1,209 @@
|
||||
/*
|
||||
BSD 2-Clause License
|
||||
|
||||
Copyright Dr. Hans-Walter Latz 2020 and Living Computer Museum + Labs 2018
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
namespace D.Ethernet
|
||||
{
|
||||
/// <summary>
|
||||
/// Packet interface for accessing a Dodo NetHub as network device for Darkstar.
|
||||
/// </summary>
|
||||
public class NethubInterface : IPacketInterface
|
||||
{
|
||||
|
||||
// this is the name of the NetHub network-device in the configuration dialog resp. the configuration file
|
||||
public const string NETHUB_NAME = "[[ Dodo-Nethub ]]";
|
||||
|
||||
private TcpClient client = null;
|
||||
private NetworkStream stream = null;
|
||||
|
||||
private ulong localAddress;
|
||||
private ulong broadcastAddress;
|
||||
|
||||
private ReceivePacketDelegate receiver = null;
|
||||
private Thread receiverThread = null;
|
||||
|
||||
private Byte[] sendBuffer = new byte[1026]; // this assumes that there is only ONE processing thread (which is the case for DarkStar!)
|
||||
|
||||
public NethubInterface()
|
||||
{
|
||||
client = new TcpClient(Configuration.NetHubHost, Configuration.NetHubPort);
|
||||
stream = client.GetStream();
|
||||
|
||||
this.localAddress = Configuration.HostID;
|
||||
this.broadcastAddress = 0x0000FFFFFFFFFFFF;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a callback delegate to handle packets that are received.
|
||||
/// </summary>
|
||||
/// <param name="callback"></param>
|
||||
void IPacketInterface.RegisterReceiveCallback(ReceivePacketDelegate callback) {
|
||||
this.stopReceiverThread();
|
||||
this.receiver = callback;
|
||||
this.receiverThread = new Thread(this.PacketReceiver);
|
||||
this.receiverThread.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the specified word array over the device.
|
||||
/// </summary>
|
||||
/// <param name="packet"></param>
|
||||
void IPacketInterface.Send(ushort[] packet) {
|
||||
NetworkStream str = this.stream;
|
||||
if (str == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int byteLen = packet.Length * 2;
|
||||
//(debug) Console.Write("** sending packed, len = {0} bytes\n", byteLen);
|
||||
|
||||
// build the NetHub transmission packet
|
||||
int src = 0;
|
||||
int dst = 0;
|
||||
|
||||
// first word is the packet length (big-endian)
|
||||
sendBuffer[dst++] = (byte)((byteLen >> 8) & 0xFF);
|
||||
sendBuffer[dst++] = (byte)(byteLen & 0xFF);
|
||||
|
||||
// then of course the packet itself
|
||||
int limit = Math.Min( byteLen + 2 , sendBuffer.Length );
|
||||
while (dst < limit)
|
||||
{
|
||||
ushort w = packet[src++];
|
||||
sendBuffer[dst++] = (byte)((w >> 8) & 0xFF);
|
||||
sendBuffer[dst++] = (byte)(w & 0xFF);
|
||||
}
|
||||
|
||||
// transmit it
|
||||
try {
|
||||
str.Write(sendBuffer, 0, dst);
|
||||
str.Flush();
|
||||
} catch (Exception) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shuts down the encapsulation provider.
|
||||
/// </summary>
|
||||
void IPacketInterface.Shutdown() {
|
||||
//(debug) Console.WriteLine("** Stopping nethub interface...");
|
||||
if (this.stream != null) { this.stream.Close(); }
|
||||
if (this.client != null) { this.client.Close(); }
|
||||
this.stopReceiverThread();
|
||||
this.receiver = null;
|
||||
Console.WriteLine("** Nethub interface shut down");
|
||||
}
|
||||
|
||||
private void stopReceiverThread() {
|
||||
if (this.receiverThread != null) {
|
||||
this.receiverThread.Interrupt();
|
||||
this.receiverThread.Join();
|
||||
this.receiverThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void PacketReceiver() {
|
||||
Byte[] data = new Byte[1024];
|
||||
try {
|
||||
while(true) {
|
||||
NetworkStream str = this.stream;
|
||||
if (str == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// wait for next packet from the nethub
|
||||
int byteLen = this.getLenPrefix(str);
|
||||
|
||||
// read the packet content up to the buffer size
|
||||
int pos = 0;
|
||||
while(pos < byteLen && pos < data.Length) {
|
||||
data[pos++] = this.getByte(str);
|
||||
}
|
||||
|
||||
// swallow the exceeding bytes in the packet
|
||||
while(pos < byteLen) {
|
||||
pos++;
|
||||
this.getByte(str);
|
||||
}
|
||||
|
||||
// check if it is for us (to reduce traffic on this machine), also get sending machine for logging
|
||||
ulong dstAddress = readAddress(data, 0);
|
||||
ulong srcAddress = readAddress(data, 6);
|
||||
if (dstAddress == this.localAddress || dstAddress == this.broadcastAddress) {
|
||||
// pass it the the ethernet controller
|
||||
ReceivePacketDelegate rcvr = this.receiver;
|
||||
if (rcvr != null) {
|
||||
//(debug) Console.Write("** received packed from 0x{0:x12} , len = {1} bytes\n", srcAddress, byteLen);
|
||||
rcvr(new MemoryStream(data, 0, byteLen));
|
||||
}
|
||||
} else {
|
||||
//(debug) Console.Write("~~ skipped packet to 0x{0:x16} (not us) from 0x{1:x16} , len = {2} bytes\n", dstAddress, srcAddress, byteLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(ThreadInterruptedException)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
private int getLenPrefix(NetworkStream str) {
|
||||
Int32 b1 = this.getByte(str) & 0xFF;
|
||||
Int32 b2 = this.getByte(str) & 0xFF;
|
||||
return (b1 << 8) | b2;
|
||||
|
||||
}
|
||||
|
||||
private byte getByte(NetworkStream str) {
|
||||
int value = -1;
|
||||
try {
|
||||
value = str.ReadByte();
|
||||
} catch(Exception) {
|
||||
// ignored
|
||||
}
|
||||
if (value < 0) {
|
||||
throw new ThreadInterruptedException();
|
||||
}
|
||||
return (byte)value;
|
||||
}
|
||||
|
||||
private ulong readAddress(byte[] data, int at) {
|
||||
ulong addr = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
addr <<= 8;
|
||||
addr |= (ulong)(data[at++] & 0xFF);
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -44,6 +44,7 @@ namespace D
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
bool doStart = false;
|
||||
//
|
||||
// Check for command-line arguments.
|
||||
//
|
||||
@ -77,6 +78,10 @@ namespace D
|
||||
}
|
||||
break;
|
||||
|
||||
case "-start":
|
||||
doStart = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
PrintUsage();
|
||||
return;
|
||||
@ -89,6 +94,7 @@ namespace D
|
||||
// Cons up a system to run stuff on.
|
||||
DSystem system = new DSystem();
|
||||
system.Reset();
|
||||
Configuration.Start |= doStart;
|
||||
|
||||
//
|
||||
// Start the UI, this will not return from ShowDialog
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
/*
|
||||
using System;
|
||||
|
||||
/*
|
||||
BSD 2-Clause License
|
||||
|
||||
Copyright Vulcan Inc. 2017-2018 and Living Computer Museum + Labs 2018
|
||||
@ -24,33 +26,27 @@
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
using System.Reflection;
|
||||
*/using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Darkstar")]
|
||||
[assembly: AssemblyDescription("A Xerox Star/1108 Emulator")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Living Computers: Museum+Labs")]
|
||||
[assembly: AssemblyProduct("Darkstar")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017-2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: AssemblyTitle ("Darkstar")]
|
||||
[assembly: AssemblyDescription ("A Xerox Star/1108 Emulator")]
|
||||
[assembly: AssemblyConfiguration ("")]
|
||||
[assembly: AssemblyCompany ("Living Computers: Museum+Labs")]
|
||||
[assembly: AssemblyProduct ("Darkstar")]
|
||||
[assembly: AssemblyCopyright ("Copyright © 2017-2019")]
|
||||
[assembly: AssemblyTrademark ("")]
|
||||
[assembly: AssemblyCulture ("")]
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: ComVisible (false)]
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("0590465e-1d91-4591-946e-ee3f7d82834b")]
|
||||
|
||||
[assembly: Guid ("0590465e-1d91-4591-946e-ee3f7d82834b")]
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
@ -61,5 +57,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
[assembly: AssemblyVersion ("1.1.9.0")]
|
||||
[assembly: AssemblyFileVersion ("1.1.9.0")]
|
||||
|
||||
28
D/Properties/Settings.Designer.cs
generated
28
D/Properties/Settings.Designer.cs
generated
@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@ -12,7 +12,7 @@ namespace D.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@ -166,5 +166,29 @@ namespace D.Properties {
|
||||
this["FullScreenFilter"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("localhost")]
|
||||
public string NetHubHost {
|
||||
get {
|
||||
return ((string)(this["NetHubHost"]));
|
||||
}
|
||||
set {
|
||||
this["NetHubHost"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("3333")]
|
||||
public ushort NetHubPort {
|
||||
get {
|
||||
return ((ushort)(this["NetHubPort"]));
|
||||
}
|
||||
set {
|
||||
this["NetHubPort"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
83
D/UI/ConfigurationDialog.Designer.cs
generated
83
D/UI/ConfigurationDialog.Designer.cs
generated
@ -68,6 +68,7 @@ namespace D.UI
|
||||
this.EthernetInterfaceListBox = new System.Windows.Forms.ListBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.DisplayTab = new System.Windows.Forms.TabPage();
|
||||
this.FullScreenStretchCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.DisplayScaleComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.SlowPhosphorCheckBox = new System.Windows.Forms.CheckBox();
|
||||
@ -82,12 +83,16 @@ namespace D.UI
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.OKButton = new System.Windows.Forms.Button();
|
||||
this.Cancel_Button = new System.Windows.Forms.Button();
|
||||
this.FullScreenStretchCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.lblNetHubHost = new System.Windows.Forms.Label();
|
||||
this.txtNetHubHost = new System.Windows.Forms.TextBox();
|
||||
this.numNetHubPort = new System.Windows.Forms.NumericUpDown();
|
||||
this.lblNetHubPort = new System.Windows.Forms.Label();
|
||||
this.TabControl.SuspendLayout();
|
||||
this.SystemPage.SuspendLayout();
|
||||
this.EthernetTab.SuspendLayout();
|
||||
this.DisplayTab.SuspendLayout();
|
||||
this.TimeTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numNetHubPort)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// TabControl
|
||||
@ -171,6 +176,10 @@ namespace D.UI
|
||||
//
|
||||
// EthernetTab
|
||||
//
|
||||
this.EthernetTab.Controls.Add(this.lblNetHubPort);
|
||||
this.EthernetTab.Controls.Add(this.numNetHubPort);
|
||||
this.EthernetTab.Controls.Add(this.txtNetHubHost);
|
||||
this.EthernetTab.Controls.Add(this.lblNetHubHost);
|
||||
this.EthernetTab.Controls.Add(this.EthernetInterfaceListBox);
|
||||
this.EthernetTab.Controls.Add(this.label5);
|
||||
this.EthernetTab.Location = new System.Drawing.Point(4, 22);
|
||||
@ -186,8 +195,9 @@ namespace D.UI
|
||||
this.EthernetInterfaceListBox.FormattingEnabled = true;
|
||||
this.EthernetInterfaceListBox.Location = new System.Drawing.Point(10, 24);
|
||||
this.EthernetInterfaceListBox.Name = "EthernetInterfaceListBox";
|
||||
this.EthernetInterfaceListBox.Size = new System.Drawing.Size(332, 134);
|
||||
this.EthernetInterfaceListBox.Size = new System.Drawing.Size(332, 121);
|
||||
this.EthernetInterfaceListBox.TabIndex = 1;
|
||||
this.EthernetInterfaceListBox.SelectedValueChanged += new System.EventHandler(this.OnEthernetInterfaceChanged);
|
||||
//
|
||||
// label5
|
||||
//
|
||||
@ -212,6 +222,16 @@ namespace D.UI
|
||||
this.DisplayTab.Text = "Display";
|
||||
this.DisplayTab.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FullScreenStretchCheckBox
|
||||
//
|
||||
this.FullScreenStretchCheckBox.AutoSize = true;
|
||||
this.FullScreenStretchCheckBox.Location = new System.Drawing.Point(6, 55);
|
||||
this.FullScreenStretchCheckBox.Name = "FullScreenStretchCheckBox";
|
||||
this.FullScreenStretchCheckBox.Size = new System.Drawing.Size(186, 17);
|
||||
this.FullScreenStretchCheckBox.TabIndex = 3;
|
||||
this.FullScreenStretchCheckBox.Text = "Stretch screen in Fullscreen mode";
|
||||
this.FullScreenStretchCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// DisplayScaleComboBox
|
||||
//
|
||||
this.DisplayScaleComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
@ -367,15 +387,53 @@ namespace D.UI
|
||||
this.Cancel_Button.Text = "Cancel";
|
||||
this.Cancel_Button.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FullScreenFilterCheckBox
|
||||
// lblNetHubHost
|
||||
//
|
||||
this.FullScreenStretchCheckBox.AutoSize = true;
|
||||
this.FullScreenStretchCheckBox.Location = new System.Drawing.Point(6, 55);
|
||||
this.FullScreenStretchCheckBox.Name = "FullScreenFilterCheckBox";
|
||||
this.FullScreenStretchCheckBox.Size = new System.Drawing.Size(186, 17);
|
||||
this.FullScreenStretchCheckBox.TabIndex = 3;
|
||||
this.FullScreenStretchCheckBox.Text = "Stretch screen in Fullscreen mode";
|
||||
this.FullScreenStretchCheckBox.UseVisualStyleBackColor = true;
|
||||
this.lblNetHubHost.AutoSize = true;
|
||||
this.lblNetHubHost.Location = new System.Drawing.Point(10, 150);
|
||||
this.lblNetHubHost.Name = "lblNetHubHost";
|
||||
this.lblNetHubHost.Size = new System.Drawing.Size(72, 13);
|
||||
this.lblNetHubHost.TabIndex = 2;
|
||||
this.lblNetHubHost.Text = "NetHub Host:";
|
||||
//
|
||||
// txtNetHubHost
|
||||
//
|
||||
this.txtNetHubHost.Location = new System.Drawing.Point(81, 147);
|
||||
this.txtNetHubHost.Name = "txtNetHubHost";
|
||||
this.txtNetHubHost.Size = new System.Drawing.Size(166, 20);
|
||||
this.txtNetHubHost.TabIndex = 3;
|
||||
this.txtNetHubHost.Validating += new System.ComponentModel.CancelEventHandler(this.OnNetHubHostValidating);
|
||||
//
|
||||
// numNetHubPort
|
||||
//
|
||||
this.numNetHubPort.Location = new System.Drawing.Point(282, 146);
|
||||
this.numNetHubPort.Maximum = new decimal(new int[] {
|
||||
65535,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numNetHubPort.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numNetHubPort.Name = "numNetHubPort";
|
||||
this.numNetHubPort.Size = new System.Drawing.Size(60, 20);
|
||||
this.numNetHubPort.TabIndex = 4;
|
||||
this.numNetHubPort.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// lblNetHubPort
|
||||
//
|
||||
this.lblNetHubPort.AutoSize = true;
|
||||
this.lblNetHubPort.Location = new System.Drawing.Point(253, 149);
|
||||
this.lblNetHubPort.Name = "lblNetHubPort";
|
||||
this.lblNetHubPort.Size = new System.Drawing.Size(29, 13);
|
||||
this.lblNetHubPort.TabIndex = 5;
|
||||
this.lblNetHubPort.Text = "Port:";
|
||||
//
|
||||
// ConfigurationDialog
|
||||
//
|
||||
@ -404,6 +462,7 @@ namespace D.UI
|
||||
this.DisplayTab.PerformLayout();
|
||||
this.TimeTabPage.ResumeLayout(false);
|
||||
this.TimeTabPage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numNetHubPort)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -436,5 +495,9 @@ namespace D.UI
|
||||
private System.Windows.Forms.DateTimePicker TODDatePicker;
|
||||
private System.Windows.Forms.RadioButton SpecifiedDateRadioButton;
|
||||
private System.Windows.Forms.CheckBox FullScreenStretchCheckBox;
|
||||
private System.Windows.Forms.Label lblNetHubPort;
|
||||
private System.Windows.Forms.NumericUpDown numNetHubPort;
|
||||
private System.Windows.Forms.TextBox txtNetHubHost;
|
||||
private System.Windows.Forms.Label lblNetHubHost;
|
||||
}
|
||||
}
|
||||
@ -48,6 +48,8 @@ namespace D.UI
|
||||
public bool ThrottleSpeed;
|
||||
|
||||
public string HostPacketInterfaceName;
|
||||
public string NetHubHost;
|
||||
public ushort NetHubPort;
|
||||
|
||||
public bool SlowPhosphor;
|
||||
public uint DisplayScale;
|
||||
@ -123,13 +125,19 @@ namespace D.UI
|
||||
//
|
||||
// Populate the list with the interfaces available on the machine, if any.
|
||||
//
|
||||
EthernetInterfaceListBox.Enabled = Configuration.HostRawEthernetInterfacesAvailable;
|
||||
EthernetInterfaceListBox.Enabled = true; // Configuration.HostRawEthernetInterfacesAvailable;
|
||||
EthernetInterfaceListBox.Items.Clear();
|
||||
|
||||
|
||||
// Add the "Use no interface" option
|
||||
EthernetInterfaceListBox.Items.Add(
|
||||
new EthernetInterface("None", "No network adapter"));
|
||||
|
||||
// Add the "Use Nethub interface" option
|
||||
EthernetInterfaceListBox.Items.Add(
|
||||
new EthernetInterface(NethubInterface.NETHUB_NAME, "Network adapter to Dodo Nethub"));
|
||||
txtNetHubHost.Text = NetHubHost;
|
||||
numNetHubPort.Value = NetHubPort;
|
||||
|
||||
// Add all interfaces that PCAP knows about.
|
||||
|
||||
@ -199,7 +207,7 @@ namespace D.UI
|
||||
ulong newValue = Convert.ToUInt64(stripped, 16);
|
||||
|
||||
// Ensure the value is in range
|
||||
if ((newValue & 0xffff0000000000) != 0)
|
||||
if ((newValue & 0xffff000000000000) != 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("HostID");
|
||||
}
|
||||
@ -228,6 +236,8 @@ namespace D.UI
|
||||
FullScreenStretch = FullScreenStretchCheckBox.Checked;
|
||||
|
||||
HostPacketInterfaceName = ((EthernetInterface)EthernetInterfaceListBox.SelectedItem).Name;
|
||||
NetHubHost = txtNetHubHost.Text;
|
||||
NetHubPort = (ushort)numNetHubPort.Value;
|
||||
|
||||
if (CurrentTimeDateRadioButton.Checked)
|
||||
{
|
||||
@ -252,5 +262,22 @@ namespace D.UI
|
||||
TODSetMode = TODPowerUpSetMode.NoChange;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEthernetInterfaceChanged(object sender, EventArgs e)
|
||||
{
|
||||
EthernetInterface iface = (EthernetInterface)EthernetInterfaceListBox.SelectedItem;
|
||||
bool isNetHub = (iface.Name == NethubInterface.NETHUB_NAME);
|
||||
txtNetHubHost.Enabled = isNetHub;
|
||||
numNetHubPort.Enabled = isNetHub;
|
||||
}
|
||||
|
||||
private void OnNetHubHostValidating(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (String.IsNullOrEmpty(txtNetHubHost.Text))
|
||||
{
|
||||
MessageBox.Show("The NetHub host can not be empty");
|
||||
txtNetHubHost.Text = "localhost";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,6 +101,21 @@ namespace D.UI
|
||||
UpdateFloppyDriveLabel();
|
||||
UpdateMouseState();
|
||||
}
|
||||
|
||||
private bool firstShown = true;
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
if (firstShown) {
|
||||
firstShown = false;
|
||||
if (Configuration.Start && !_system.IsExecuting)
|
||||
{
|
||||
SystemExecutionContext context = new SystemExecutionContext(null, null, null, OnExecutionError);
|
||||
_system.StartExecution(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// UI Event handlers:
|
||||
@ -305,6 +320,8 @@ namespace D.UI
|
||||
configDialog.MemorySize = Configuration.MemorySize;
|
||||
configDialog.HostID = Configuration.HostID;
|
||||
configDialog.HostPacketInterfaceName = Configuration.HostPacketInterfaceName;
|
||||
configDialog.NetHubHost = Configuration.NetHubHost;
|
||||
configDialog.NetHubPort = Configuration.NetHubPort;
|
||||
configDialog.ThrottleSpeed = Configuration.ThrottleSpeed;
|
||||
configDialog.DisplayScale = Configuration.DisplayScale;
|
||||
configDialog.FullScreenStretch = Configuration.FullScreenStretch;
|
||||
@ -331,9 +348,13 @@ namespace D.UI
|
||||
((IOPMemoryBus)_system.IOP.Memory).UpdateHostIDProm();
|
||||
}
|
||||
|
||||
if (configDialog.HostPacketInterfaceName != Configuration.HostPacketInterfaceName)
|
||||
if (configDialog.HostPacketInterfaceName != Configuration.HostPacketInterfaceName
|
||||
|| configDialog.NetHubHost != Configuration.NetHubHost
|
||||
|| configDialog.NetHubPort != Configuration.NetHubPort)
|
||||
{
|
||||
Configuration.HostPacketInterfaceName = configDialog.HostPacketInterfaceName;
|
||||
Configuration.NetHubHost = configDialog.NetHubHost;
|
||||
Configuration.NetHubPort = configDialog.NetHubPort;
|
||||
_system.EthernetController.HostInterfaceChanged();
|
||||
}
|
||||
|
||||
@ -443,7 +464,7 @@ namespace D.UI
|
||||
|
||||
private void OnFrameTimerTick(object sender, EventArgs e)
|
||||
{
|
||||
FPSStatusLabel.Text = String.Format("{0} Fields/Sec ({1}%)",
|
||||
FPSStatusLabel.Text = String.Format("{0:d3} Fields/Sec ({1:d3}%)",
|
||||
_frameCount,
|
||||
(int)((_frameCount / 77.4) * 100.0));
|
||||
|
||||
@ -529,6 +550,7 @@ namespace D.UI
|
||||
|
||||
private void PopulateAltBoot()
|
||||
{
|
||||
_system.IOP.MiscIO.AltBoot = Configuration.AltBootMode;
|
||||
for (AltBootValues v = AltBootValues.None; v < AltBootValues.HeadCleaning; v++)
|
||||
{
|
||||
ToolStripMenuItem item = new ToolStripMenuItem(v.ToString());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user