private static void ExecuteCommandFunction(string obj) { bool runCommand = true; // If we are in source code mode, we need to check if we need a new recompile if (srcFrameView.Visible) { string src = srcLinesView.SourceCode; // if the src code in the source view is different, then recompile if (src.Length > 0) { var hashCode = src.GetHashCode(); if ((hashCode != s8parser.SourceFileHash) | (obj == "RUN!")) { // Source code in editor different from stored version. Compile!! try { s8parser.SetSourceCode(src); var result = s8parser.s8a.AssembleSourceCode(src); if (result is not null) { s8parser.s8d.InitFromMemory(result); } ; } catch (S8AssemblerException s8ex) { runCommand = false; string error = s8ex.Message + "\r\nLine: " + s8ex.SourceCodeLine.ToString(); MessageBox.ErrorQuery(50, 7, "Compile Error", error, "Cancel"); srcLinesView.SetLineFocus(s8ex.SourceCodeLine); } catch (Exception ex) { runCommand = false; MessageBox.ErrorQuery(50, 7, "Compile Error", ex.ToString(), "Cancel"); } } } } if (runCommand) { s8parser.ParseCommand(obj); } }
static void Main(string[] args) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Green; string defaultS8File = @"s8.s8"; parser = new S8CommandParser(); parser.MessageHandler += Parser_Message; parser.s8d.Init(defaultS8File); parser.s8d.cpu.HWDisplay.OnVSync += HWDisplay_OnVSync; Console.WriteLine("Velkommen til Slede8 debugger"); Console.WriteLine("H => HELP"); Console.WriteLine(""); Console.WriteLine("Enter command 'GUI' to enter GUI mode"); Console.WriteLine(""); bool debugging = true; while (debugging) { if (parser.showAddress) { Console.Write("S8#["); } else { Console.Write("s8 ["); } Console.Write(parser.currentAddress.ToString("X3") + "] "); string input = Console.ReadLine(); switch (input.ToUpper()) { case "Q": case "QUIT": case "DIE": debugging = false; break; case "CLS": Console.Clear(); break; case "G": case "GUI": var s8gui = new S8Gui(parser); disableConsoleLogging = true; s8gui.RunGui(null); disableConsoleLogging = false; Console.Clear(); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Green; break; case "W": case "WIN": case "WINRUN": if (vgaView is null) { initVga(); } if (vgaView is not null) { vgaView.RunUI(); vgaView.CleanupSDL(); vgaView = null; } else { Console.WriteLine("Failed to initialize SDL2/WIN"); } break; default: parser.ParseCommand(input); break; } } if (vgaView is not null) { vgaView.CleanupSDL(); vgaView = null; } }