From 7a8d2bcd75d88a5429937bf551878c55e1dcf0fd Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Wed, 6 Aug 2025 22:36:34 +1000 Subject: moved everything to seperate projects, and started compiler work + push and pop instructions added --- Program.cs | 106 ------------------------------------------------------------- 1 file changed, 106 deletions(-) delete mode 100644 Program.cs (limited to 'Program.cs') diff --git a/Program.cs b/Program.cs deleted file mode 100644 index 016e557..0000000 --- a/Program.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.IO; -using System.Runtime.CompilerServices; -using System.Threading; -using Microsoft.Xna.Framework; -using Q1Emu.Chip; -using Q1Emu; -using Q1Emu.Assembler; - -internal class Program -{ - public static void Main(string[] args) - { - if (args.Length > 0) - { - string filePath = args[0]; - - Environment.CurrentDirectory = Path.GetDirectoryName(filePath) ?? Environment.CurrentDirectory; - filePath = Path.GetFileName(filePath); - - if (filePath.EndsWith(".q1")) - { - Run(filePath); - } - else - { - Program.AssembleAndRun(filePath); - } - } - else - { - Console.WriteLine("Usage: Q1Emu "); - Console.WriteLine("Example: Q1Emu game.q1"); - Console.WriteLine("Example: Q1Emu game.asm"); - } - } - private static void AssembleAndRun(string filePath) - { - StringReader reader = new(File.ReadAllText(filePath)); - BinaryWriter writer = new(File.Create(Path.ChangeExtension(filePath, ".q1"))); - - Assembler assembler = new(reader, writer); - assembler.Assemble(); - writer.Close(); - Console.WriteLine($"Assembled {filePath} to {Path.ChangeExtension(filePath, ".q1")}"); - Run(Path.ChangeExtension(filePath, ".q1")); - } - private static void Run(string filePath) - { - Q1Cpu cpu = new(); - Bus bus = new(u16.MinValue, u16.MaxValue); - RamDevice ram = new(0x1FFF, 1024 * 8); - File.ReadAllBytes(filePath).CopyTo(ram.Memory, 0); - - cpu.PC = ram.AddressableStart; - - DisplayDevice display = new(16, 64, 32, 0x3FFF); - display.SetPalette([ - Color.Red, - Color.Green, - Color.Blue, - Color.Yellow, - Color.Cyan, - Color.Magenta, - Color.White, - Color.Black, - Color.Gray, - Color.Orange, - Color.Purple, - Color.Brown, - Color.LightGray, - Color.DarkGray, - Color.LightBlue, - Color.LightGreen - ]); - - cpu.Bus = bus; - ram.AttachToBus(bus); - display.AttachToBus(bus); - - Thread t = new(() => - { - while (true) - { - for (int i = 0; i < 64; i++) - { - cpu.Clock(); - } - Thread.Sleep(1); - // - // cpu.Clock(); - // Thread.Sleep(1000); - } - }); - t.IsBackground = true; - t.Start(); - - using DisplayEngine game = new(64, 32, 10, - tex => - { - display.OutputTexture = tex; - Console.WriteLine("Display texture initialized."); - }, () => display.Clock()); - game.Run(); - } -} \ No newline at end of file -- cgit v1.3.1