public SadConsoleMain( SadConsoleConfig sadConsoleConfig, EmulatorScreenConfig emulatorScreenConfig, SadConsoleEmulatorLoop sadConsoleEmulatorLoop) { _sadConsoleConfig = sadConsoleConfig; _emulatorScreenConfig = emulatorScreenConfig; _sadConsoleEmulatorLoop = sadConsoleEmulatorLoop; }
public void Start() { _options.EmulatorConfig.Validate(); // Init CPU emulator var computer = SetupEmulator(_options.EmulatorConfig); // Create SadConsole renderer that reads screen data from emulator memory and displays it on a SadConsole screen/console var sadConsoleEmulatorRenderer = new SadConsoleEmulatorRenderer( GetSadConsoleScreen, computer.Mem, _options.EmulatorConfig.Memory.Screen); // Init emulator memory based on our configured memory layout sadConsoleEmulatorRenderer.InitEmulatorScreenMemory(); // Create SadConsole input handler that forwards pressed keys to the emulator via memory addresses var sadConsoleEmulatorInput = new SadConsoleEmulatorInput( computer.Mem, _options.EmulatorConfig.Memory.Input); // Create SadConsole executor that executes instructions in the emulator until a certain memory address has been flagged that emulator code is done for current frame var sadConsoleEmulatorExecutor = new SadConsoleEmulatorExecutor( computer, _options.EmulatorConfig.Memory.Screen, _options.EmulatorConfig.StopAtBRK); // Create the main game loop class that invokes emulator and render to host screen var sadConsoleEmulatorLoop = new SadConsoleEmulatorLoop( sadConsoleEmulatorRenderer, sadConsoleEmulatorInput, sadConsoleEmulatorExecutor, updateEmulatorEveryXFrame: _options.EmulatorConfig.RunEmulatorEveryFrame); // Create the main SadConsole class that is responsible for configuring and starting up SadConsole with our preferred configuration. SadConsoleMain = new SadConsoleMain( _options.SadConsoleConfig, _options.EmulatorConfig.Memory.Screen, sadConsoleEmulatorLoop); // Start SadConsole. Will exit from this method after SadConsole window is closed. SadConsoleMain.Run(); }