Skip to content

Commit

Permalink
target: net8.0
Browse files Browse the repository at this point in the history
* target: net8.0
* updated nuget packages
* changed instruction counter to ulong so it can run for > 50k years
* updated README.md
* README cleanup
  • Loading branch information
sictransit authored Oct 1, 2024
1 parent ce11af7 commit 640cc4b
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 45 deletions.
6 changes: 3 additions & 3 deletions Core/CPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CPU : ICPU
private const int MEMORY_MANAGEMENT_MASK = 0b_111_111_000_000;
private const int INTERRUPT_MASK = 0b_000_111_111_000;

private readonly List<Breakpoint> breakpoints = new();
private readonly List<Breakpoint> breakpoints = [];

private readonly RK8EInstructions rk8eInstructions;
private readonly RX8EInstructions rx8eInstructions;
Expand Down Expand Up @@ -53,7 +53,7 @@ public class CPU : ICPU

private volatile bool running;

private int[] loopCap = new int[2];
private readonly int[] loopCap = new int[2];

public CPU()
{
Expand Down Expand Up @@ -94,7 +94,7 @@ public CPU()

public IInstruction Instruction { get; private set; }

public int InstructionCounter { get; private set; }
public ulong InstructionCounter { get; private set; }

public void Attach(IRK8E peripheral)
{
Expand Down
6 changes: 3 additions & 3 deletions Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ApplicationIcon />
<StartupObject />
<RootNamespace>Core8.Core</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Emulator/Emulator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Core8</RootNamespace>
<Copyright>Mikael Fredriksson &lt;micke@sictransit.net&gt;</Copyright>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions Emulator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ private static void Advent()

pdp.Continue(false);

List<(Func<IPrinterPunch, bool>, byte[])> steps = new()
{
List<(Func<IPrinterPunch, bool>, byte[])> steps =
[
(tty=>tty.Printout.Contains('.'), Encoding.ASCII.GetBytes("R FRTS\r")),
(tty=>tty.Printout.Contains('*'), Encoding.ASCII.GetBytes("ADVENT\r")),
(tty=>tty.Printout.Count(c=> c == '*') == 2, new byte[]{0x1b}),
};
(tty=>tty.Printout.Count(c=> c == '*') == 2, [0x1b]),
];

while (pdp.Running)
{
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Extensions.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Core8.Extensions</RootNamespace>
</PropertyGroup>

Expand Down
7 changes: 2 additions & 5 deletions Model/Breakpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

namespace Core8.Model
{
//disable once hit
//break now, or on x instructions
//chain
public class Breakpoint
{
private readonly Func<ICPU, bool> predicate;

private int delayedInstructionCounter = int.MinValue;
private ulong delayedInstructionCounter;

public Breakpoint(int octalAddress) : this(cpu => cpu.Registry.PC.Content == octalAddress.ToDecimal())
{
Expand All @@ -36,7 +33,7 @@ public Breakpoint(Func<ICPU, bool> predicate)

public Breakpoint Parent { get; set; }

public int Delay { get; set; }
public ulong Delay { get; set; }

public bool Check(ICPU cpu)
{
Expand Down
2 changes: 1 addition & 1 deletion Model/Interfaces/ICPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface ICPU

void SetBreakpoint(Breakpoint breakpoint);

int InstructionCounter { get; }
ulong InstructionCounter { get; }

void Attach(IRK8E peripheral);

Expand Down
4 changes: 2 additions & 2 deletions Model/Model.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Core8.Model</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog" Version="4.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,61 @@

This is my first attempt to write an emulator. Ever! It is work-in-progress and might even be finished eventually.

The emulator is stable enough to boot OS/8 and run [TINT8](https://github.com/PontusPih/TINT8), the PDP-8 version of a popular tile-matching puzzle video game. You can even play ADVENT (Colossal Cave) on it.
The emulator is stable enough to boot OS/8 and run [TINT8](https://github.com/PontusPih/TINT8), the PDP-8 version of a popular tile-matching puzzle video game. You can even play [ADVENT (Colossal Cave)](https://en.wikipedia.org/wiki/Colossal_Cave_Adventure) on it.

Have fun!

## Build

To build the Emulator:

PS c:\...\core8> dotnet build --configuration Release

This will build the Emulator in Release mode as well as the Terminal Server. Those are separate projects in the solution. The Terminal Server is a simple console application that listens on port 23 for incoming connections and should be started before the Emulator.

## Test

There are extensive tests for the emulator as described in the MAINDEC section below. To run them from the command line, use the following command:

PS c:\...\core8> dotnet test --configuration Release

## Run

Please note that the Emulator is a console application. It can do many things, but it does not have a GUI. Options are described below. Most users will probably hook up [Putty](https://www.putty.org/) to the terminal server.

Why not play a game of ADVENT?

### Launch the Terminal Server

PS c:\...\core8\TerminalServer\bin\Release\net8.0> .\TerminalServer.exe
[20:57:23 INF] Server starting ...

The Terminal Server is now running and waiting for connections.

### Connect using Putty

PS c:\bin\putty)> .\putty.exe -telnet -raw localhost 23
WELCOME TO THE PDP-8 TERMINAL SERVER

The Terminal Server shows something similar to this:

[21:01:15 INF] Connected: 127.0.0.1:61365

### Launch the Emulator

PS c:\...\core8\Emulator\bin\Release\net8.0\> .\Emulator.exe --advent

The Emulator will boot OS/8 and start ADVENT. You should see this is Putty:

.R FRTS
*ADVENT
*$
Welcome to Adventure!! Would you like instructions?

>

Type `Y` and hit `Enter` to get instructions. Have fun!

# Test-driven development - MAINDEC

The following MAINDEC diagnostics have been tested and run successfully.
Expand Down Expand Up @@ -48,7 +99,9 @@ In fact that's how I implemented the emulator. Run the tests, fix the code, ...
--dumpmemory (Default: false) dump memory

--os8 (Default: false) boot OS/8


--kermit (Default: false) boot Kermit utility disk

--advent (Default: false) run ADVENT

--debug (Default: false) debug mode
Expand Down
6 changes: 3 additions & 3 deletions RK8E/RK8E.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Core8.Peripherals.RK8E</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog" Version="4.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions RX8E/RX8E.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Core8.Peripherals.RX8E</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog" Version="4.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Teletype/Teletype.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Core8.Peripherals.Teletype</RootNamespace>
<AssemblyName>Teletype</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NetMQ" Version="4.0.1.13" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog" Version="4.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions TerminalServer/TerminalServer.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Core8.Peripherals</RootNamespace>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NetCoreServer" Version="6.7.0" />
<PackageReference Include="NetCoreServer" Version="8.0.7" />
<PackageReference Include="NetMQ" Version="4.0.1.13" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
</ItemGroup>

</Project>
16 changes: 8 additions & 8 deletions Tests/Core8Tests/Core8Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>

<RootNamespace>Core8.Tests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Utilities/Utilities.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Core8.Utilities</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog" Version="4.0.2" />
</ItemGroup>

</Project>

0 comments on commit 640cc4b

Please sign in to comment.