summaryrefslogtreecommitdiff
path: root/Emulator
diff options
context:
space:
mode:
Diffstat (limited to 'Emulator')
-rw-r--r--Emulator/Chip/Q1Cpu.cs8
-rw-r--r--Emulator/Program.cs16
2 files changed, 11 insertions, 13 deletions
diff --git a/Emulator/Chip/Q1Cpu.cs b/Emulator/Chip/Q1Cpu.cs
index 16e1e14..d1fcf7a 100644
--- a/Emulator/Chip/Q1Cpu.cs
+++ b/Emulator/Chip/Q1Cpu.cs
@@ -5,8 +5,9 @@ using Assembler;
public partial class Q1Cpu
{
- public const u16 StackStart = 0x2FFF;
- public const u16 StackLength = 16 * 2; // 16 16-bit values
+ public const u16 StackStart = 0x2FFF;
+ public const u16 StackLength = 16 * 2; // 16 16-bit values
+ public const u16 ProgramStart = 0x1FFF;
public Random Random;
@@ -18,7 +19,6 @@ public partial class Q1Cpu
public u16 PC { get; set; } // Program counter
public u16[] V { get; set; } // Variable registers (64 total)
- public u16 I { get; set; } // Index register
public u16 Cycles { get; set; } // Number of cycles
public Bus Bus { get; set; }
@@ -38,7 +38,7 @@ public partial class Q1Cpu
this.SP = Q1Cpu.StackStart;
this.PushStack(0xFFFF);
- this.I = 0;
+ this.PC = Q1Cpu.ProgramStart;
}
public void Clock()
diff --git a/Emulator/Program.cs b/Emulator/Program.cs
index cd6a8c0..3104fa9 100644
--- a/Emulator/Program.cs
+++ b/Emulator/Program.cs
@@ -20,9 +20,7 @@ internal class Program
Bus bus = new(u16.MinValue, u16.MaxValue);
RamDevice ram = new(0x1FFF, 1024 * 8);
File.ReadAllBytes(options.InputFile).CopyTo(ram.Memory, 0);
-
- cpu.PC = ram.AddressableStart;
-
+
DisplayDevice display = new(16, 64, 32, 0x3FFF);
display.SetPalette([
Color.Red,
@@ -55,13 +53,13 @@ internal class Program
cpu.Reset();
while (!cpu.AbortRequested)
{
- for (int i = 0; i < 64; i++)
- cpu.Clock();
-
- Thread.Sleep(1);
+ // for (int i = 0; i < 64; i++)
+ // cpu.Clock();
+ //
+ // Thread.Sleep(1);
//
- // cpu.Clock();
- // Thread.Sleep(1000);
+ cpu.Clock();
+ Thread.Sleep(1000);
}
Console.WriteLine($"Exit code: 0x{cpu.V[0]:X4}");
});