private static void RecordExpectedOutcome() { TestCase selected = PromptForTestCase(); if (selected != null) { try { using (Stream zcode = selected.GetZCode()) { RecordingIO io = new RecordingIO(selected.InputFile); ZMachine zm = new ZMachine(zcode, io); zm.PredictableRandom = true; zm.WritingCommandsToFile = true; string output = RunAndCollectOutput(zm, io); File.WriteAllText(selected.OutputFile, output); } } finally { selected.CleanUp(); } } }
protected override void Run() { //Console.WriteLine("Specify game path:"); //string fileName = string.Empty; try { //fileName = Console.ReadLine(); //if (fileName == "ls") //{ // foreach (var dir in Directory.GetFiles("0:\\")) // { // Console.WriteLine($"0:\\{dir}"); // } //} //else //{ var machine = new ZMachine(GameData); machine.Run(); //} } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { ZMachine zMachine = new ZMachine(new ConsoleIO()); FileStream fs = File.OpenRead(@"zork1.dat"); zMachine.LoadFile(fs); zMachine.Run(); }
public static void Initialize(ZMachine aMachine) { _machine = aMachine; DictionaryWordSize = aMachine.Story.Header.Version >= FileVersion.V4 ? 9 : 6; LoadAlphabets(); LoadExtraChars(); LoadTerminatingChars(); LoadWordSeparators(); }
static void Main(string[] args) { byte[] data; using (var reader = new FileStream("..\\..\\..\\..\\ZKernel\\ZORK1.DAT", FileMode.Open)) { data = new byte[reader.Length]; reader.Read(data, 0, data.Length); reader.Close(); reader.Dispose(); } var machine = new ZMachine(data); machine.Run(); Console.ReadKey(); }
private static bool?RunOneTest(TestCase test) { if (!File.Exists(test.InputFile) || !File.Exists(test.OutputFile)) { Console.WriteLine("skipping (expected outcome not recorded)."); return(null); } else { try { using (Stream zcode = test.GetZCode()) { ReplayIO io = new ReplayIO(test.InputFile); ZMachine zm = new ZMachine(zcode, io); zm.PredictableRandom = true; zm.ReadingCommandsFromFile = true; string output = RunAndCollectOutput(zm, io); string expectedOutput = File.ReadAllText(test.OutputFile); if (OutputDiffers(expectedOutput, output)) { Console.WriteLine("failed!"); File.WriteAllText(test.FailureFile, output); return(false); } else { Console.WriteLine("passed."); return(true); } } } finally { test.CleanUp(); } } }
private static string RunAndCollectOutput(ZMachine zm, TestCaseIO io) { string output = null; try { zm.PredictableRandom = true; zm.Run(); output = io.CollectOutput(); } catch (Exception ex) { if (output == null) { output = io.CollectOutput(); } output += "\n\n*** Exception ***\n" + ex.ToString(); } return(output); }
public Window(ZMachine.VM.Formatter formatter) { this.formatter = formatter; formatter.Window = this; }