diff --git a/src/apps/Highbyte.DotNet6502.App.SadConsole/SadConsoleHostApp.cs b/src/apps/Highbyte.DotNet6502.App.SadConsole/SadConsoleHostApp.cs index 6be4d7a7c..15afbdd2a 100644 --- a/src/apps/Highbyte.DotNet6502.App.SadConsole/SadConsoleHostApp.cs +++ b/src/apps/Highbyte.DotNet6502.App.SadConsole/SadConsoleHostApp.cs @@ -3,7 +3,7 @@ using Highbyte.DotNet6502.Impl.NAudio; using Highbyte.DotNet6502.Impl.NAudio.NAudioOpenALProvider; using Highbyte.DotNet6502.Impl.SadConsole; -using Highbyte.DotNet6502.Impl.SadConsole.Commodore64.Video; +using Highbyte.DotNet6502.Impl.SadConsole.Commodore64.Render; using Highbyte.DotNet6502.Systems; using Highbyte.DotNet6502.Systems.Commodore64; using Highbyte.DotNet6502.Systems.Logging.InMem; @@ -128,7 +128,6 @@ public void Run() .SetStartingScreen(CreateMainSadConsoleScreen) .IsStartingScreenFocused(false) // Let the object focused in the create method remain. .AddFrameUpdateEvent(UpdateSadConsole); - //.AddFrameRenderEvent(RenderSadConsole); // Old rendering pipeline Settings.WindowTitle = "Highbyte.DotNet6502 emulator + SadConsole (with NAudio)"; Settings.ResizeMode = Settings.WindowResizeOptions.None; diff --git a/src/apps/Highbyte.DotNet6502.App.SilkNetNative/SilkNetHostApp.cs b/src/apps/Highbyte.DotNet6502.App.SilkNetNative/SilkNetHostApp.cs index 75c01b059..089692a2f 100644 --- a/src/apps/Highbyte.DotNet6502.App.SilkNetNative/SilkNetHostApp.cs +++ b/src/apps/Highbyte.DotNet6502.App.SilkNetNative/SilkNetHostApp.cs @@ -128,7 +128,6 @@ public void Run() _window.Load += OnLoad; _window.Closing += OnClosing; _window.Update += OnUpdate; - //_window.Render += OnRender; // old rendering pipeline _window.Resize += OnResize; _window.Run(); diff --git a/src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Video/C64SadConsoleRenderTargetCustomization.cs b/src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Render/C64SadConsoleRenderTargetCustomization.cs similarity index 98% rename from src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Video/C64SadConsoleRenderTargetCustomization.cs rename to src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Render/C64SadConsoleRenderTargetCustomization.cs index 38274950c..180dd794e 100644 --- a/src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Video/C64SadConsoleRenderTargetCustomization.cs +++ b/src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Render/C64SadConsoleRenderTargetCustomization.cs @@ -1,6 +1,6 @@ using Highbyte.DotNet6502.Systems.Commodore64; -namespace Highbyte.DotNet6502.Impl.SadConsole.Commodore64.Video; +namespace Highbyte.DotNet6502.Impl.SadConsole.Commodore64.Render; public class C64SadConsoleRenderTargetCustomization { private readonly C64 _c64; diff --git a/src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Video/C64SadConsoleColors.cs b/src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Video/C64SadConsoleColors.cs deleted file mode 100644 index 3883f834e..000000000 --- a/src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Video/C64SadConsoleColors.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Highbyte.DotNet6502.Systems.Commodore64.Video; - -namespace Highbyte.DotNet6502.Impl.SadConsole.Commodore64.Video; - -public class C64SadConsoleColors -{ - private readonly Dictionary _systemToSadConsoleColorMap = new(); - - public C64SadConsoleColors(string colorMapName) - { - foreach (var systemColor in ColorMaps.GetAllSystemColors(colorMapName)) - { - _systemToSadConsoleColorMap.Add(systemColor, ToSadConsoleColor(systemColor)); - } - } - - public Color GetSadConsoleColor(System.Drawing.Color systemColorValue) - { - Color color; - if (!_systemToSadConsoleColorMap.ContainsKey(systemColorValue)) - color = _systemToSadConsoleColorMap.Values.First(); - else - color = _systemToSadConsoleColorMap[systemColorValue]; - return color; - } - - private Color ToSadConsoleColor(System.Drawing.Color color) - { - return new Color(color.R, color.G, color.B, color.A); - } -} diff --git a/src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Video/C64SadConsoleRenderer.cs b/src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Video/C64SadConsoleRenderer.cs deleted file mode 100644 index 272112899..000000000 --- a/src/libraries/Highbyte.DotNet6502.Impl.SadConsole/Commodore64/Video/C64SadConsoleRenderer.cs +++ /dev/null @@ -1,240 +0,0 @@ -//using Highbyte.DotNet6502.Systems; -//using Highbyte.DotNet6502.Systems.Commodore64; -//using Highbyte.DotNet6502.Systems.Commodore64.Video; -//using Highbyte.DotNet6502.Systems.Instrumentation; - -//namespace Highbyte.DotNet6502.Impl.SadConsole.Commodore64.Video; - -//// TODO: Is this completely replace in new render pipeline with a VideoCommand render target + custom adjustment? -//public class C64SadConsoleRenderer_LEGACY -//{ -// private readonly C64 _c64; -// public ISystem System => _c64; -// private readonly SadConsoleRenderContext _sadConsoleRenderContext = default!; -// private C64SadConsoleColors _c64SadConsoleColors = default!; - -// // Instrumentations -// public Instrumentations Instrumentations { get; } = new(); - - -// public C64SadConsoleRenderer_LEGACY(C64 c64, SadConsoleRenderContext sadConsoleRenderContext) -// { -// _c64 = c64; -// _sadConsoleRenderContext = sadConsoleRenderContext; -// } - -// public void Init() -// { -// _c64SadConsoleColors = new C64SadConsoleColors(_c64.ColorMapName); -// } - -// public void Cleanup() -// { -// } - -// public void GenerateFrame() -// { -// // All drawing is done in DrawFrame with commands against SadConsole screen, so nothing to do here. -// } - -// public void DrawFrame() -// { -// RenderMainScreen(_c64); -// RenderBorder(_c64); -// } - -// private void RenderMainScreen(C64 c64) -// { -// var vic2 = c64.Vic2; -// var vic2Mem = vic2.Vic2Mem; -// var vic2Screen = vic2.Vic2Screen; - -// // // Top Left -// // DrawEmulatorCharacterOnScreen(0, 0, 65, 0x01, 0x05); -// // // Bottom Right -// // DrawEmulatorCharacterOnScreen(_emulatorMemoryConfig.Cols-1, _emulatorMemoryConfig.Rows-1 , 66, 0x01, 0x05); -// // return; - -// var bgColor = c64.ReadIOStorage(Vic2Addr.BACKGROUND_COLOR_0); - -// // Build screen data characters based on emulator memory contents (byte) -// var currentScreenAddress = vic2.VideoMatrixBaseAddress; -// var currentColorAddress = Vic2Addr.COLOR_RAM_START; -// for (var row = 0; row < vic2Screen.TextRows; row++) -// { -// for (var col = 0; col < vic2Screen.TextCols; col++) -// { -// var charByte = vic2Mem[currentScreenAddress++]; -// var colorByte = c64.ReadIOStorage(currentColorAddress++); -// DrawEmulatorCharacterOnScreen( -// col, -// row, -// charByte, -// colorByte, -// bgColor, -// c64, -// adjustForBorder: true -// ); -// } -// } -// } - -// private void RenderBorder(C64 c64) -// { -// var emulatorMem = c64.Mem; -// var vic2Screen = c64.Vic2.Vic2Screen; - -// byte borderCharacter = 0; // 0 = no character -// var borderBgColor = c64.ReadIOStorage(Vic2Addr.BORDER_COLOR); -// var borderFgColor = borderBgColor; - -// var border_cols = GetBorderCols(c64); -// var border_rows = GetBorderRows(c64); - -// for (var row = 0; row < vic2Screen.TextRows + border_rows * 2; row++) -// { -// for (var col = 0; col < vic2Screen.TextCols + border_cols * 2; col++) -// { -// if (row < border_rows || row >= vic2Screen.TextRows + border_rows -// || col < border_cols || col >= vic2Screen.TextCols + border_cols) -// { -// DrawEmulatorCharacterOnScreen( -// col, -// row, -// borderCharacter, -// borderFgColor, -// borderBgColor, -// c64, -// adjustForBorder: false -// ); -// } -// } -// } -// } - -// /// -// /// Draw character to screen, with adjusted position for border. -// /// Colors are translated from emulator to SadConsole. -// /// -// /// -// /// -// /// -// /// -// /// -// public void DrawEmulatorCharacterOnScreen(int x, int y, byte emulatorCharacter, byte emulatorFgColor, byte emulatorBgColor, C64 c64, bool adjustForBorder) -// { -// if (adjustForBorder) -// { -// x += GetBorderCols(c64); -// y += GetBorderRows(c64); -// } - -// byte sadConsoleCharacter; -// sadConsoleCharacter = TranslateC64ScreenCodeToSadConsoleC64ROMFontIndex(emulatorCharacter, out bool inverted); - -// Color fgColorTemp = _c64SadConsoleColors.GetSadConsoleColor(ColorMaps.GetSystemColor(emulatorFgColor, c64.ColorMapName)); -// Color bgColorTemp = _c64SadConsoleColors.GetSadConsoleColor(ColorMaps.GetSystemColor(emulatorBgColor, c64.ColorMapName)); - -// Color fgColor; -// Color bgColor; -// if (inverted) -// { -// fgColor = bgColorTemp; -// bgColor = fgColorTemp; -// } -// else -// { -// fgColor = fgColorTemp; -// bgColor = bgColorTemp; -// } -// ; - -// DrawCharacter( -// x, -// y, -// sadConsoleCharacter, -// fgColor, -// bgColor); -// } - -// private byte TranslateC64ScreenCodeToSadConsoleC64ROMFontIndex(byte sourceByte, out bool inverted) -// { -// // The custom SadConsole font C64_ROM.font: -// // - is a combination of the two built-in C64 ROM fonts, the non-inverted parts of "shifted" and "unshifted" ROM fonts. -// // - the first 128 characters from the shifted font (non-inverted) are index 0-127. -// // - the first 128 characters from the unshufter font (non-inverted) are index 1-255. -// // - Other changes: -// // - A sad console font must have index 0 as empty (only transparent background). As the C64 font has a @ sign in this position, it has been removed. -// // - A sad console font must have one index as a solid block (only forground). As the C64 non-inverted parts of the C64 ROM fons does not contain a solid block, a duplicate of an empty block (160) has been changed to contain a solid block, one of the duplicate empty characters has been replace with a solid block. -// // - These differences, as well as detecting inverted characters (and swapping foreground/background color when drawing) are mapped via code. - - -// // ---------- -// // Mapping general C64 font -> SadConsole C64_ROM.font font translation -// // ---------- -// byte sadConsoleGlyphIndex; -// bool isUnshiftedC64CharRom = _c64.Vic2.CharsetManager.CharacterSetAddressInVIC2BankIsChargenROMUnshifted; -// if (isUnshiftedC64CharRom) -// { -// if (sourceByte < 128) -// sadConsoleGlyphIndex = (byte)(sourceByte + 128); -// else -// sadConsoleGlyphIndex = sourceByte; -// } -// else -// { -// if (sourceByte >= 128) -// sadConsoleGlyphIndex = (byte)(sourceByte - 128); -// else -// sadConsoleGlyphIndex = sourceByte; -// } - -// // ---------- -// // Mapping exceptions between C64 font -> SadConsole C64_ROM.font font -// // ---------- -// // The first glyph in a SadConsole font must be empty (where the C64 ROM font has a @ sign). -// // The @ sign has been removed from the C64 ROM font. The @ sign has a duplicate in position 128. -// if (sourceByte == 0) -// { -// sadConsoleGlyphIndex = 128; -// inverted = false; -// } -// // One glyph in SadConsole font must contain a solid block. As the combined font from C64 shifted and unshifted (with both inverted removed), -// // a duplicate of an empty block (160) has been changed to contain a solid block. -// // To avoid Space (32) when using an unshifted C64 Char ROM (that would add 128 to the index of the combined SadConsole font) to -// // be the solid block (see below), always use Space (32). -// else if (sourceByte == 32) -// { -// sadConsoleGlyphIndex = 32; -// inverted = false; -// } -// // One glyph in SadConsole font must contain a solid block. As the combined font from C64 shifted and unshifted (with both inverted removed), -// // a duplicate of an empty block (160) has been changed to contain a solid block. -// // In the original C64 font (both shifted and unshifted) this position was a solid block. So use it, and tell not to invert it. -// else if (sourceByte == 160) -// { -// sadConsoleGlyphIndex = 160; -// inverted = false; -// } -// else -// { -// inverted = sourceByte >= 128; -// } - -// return sadConsoleGlyphIndex; -// } - -// private int GetBorderCols(C64 c64) -// { -// return c64.Vic2.Vic2Screen.VisibleLeftRightBorderWidth / c64.Vic2.Vic2Screen.CharacterWidth; -// } -// private int GetBorderRows(C64 c64) -// { -// return c64.Vic2.Vic2Screen.VisibleTopBottomBorderHeight / c64.Vic2.Vic2Screen.CharacterHeight; -// } - -// private void DrawCharacter(int x, int y, int sadConsoleCharCode, Color fgColor, Color bgColor) -// { -// _sadConsoleRenderContext.Console.SetGlyph(x, y, sadConsoleCharCode, fgColor, bgColor); -// } -//} diff --git a/src/libraries/Highbyte.DotNet6502.Impl.Skia/Commodore64/Render/Legacy/v2/C64LegacyRenderTarget2.cs b/src/libraries/Highbyte.DotNet6502.Impl.Skia/Commodore64/Render/Legacy/v2/C64LegacyRenderTarget2.cs index 903b5c41c..e63ca0b6f 100644 --- a/src/libraries/Highbyte.DotNet6502.Impl.Skia/Commodore64/Render/Legacy/v2/C64LegacyRenderTarget2.cs +++ b/src/libraries/Highbyte.DotNet6502.Impl.Skia/Commodore64/Render/Legacy/v2/C64LegacyRenderTarget2.cs @@ -28,7 +28,7 @@ namespace Highbyte.DotNet6502.Impl.Skia.Commodore64.Render.Legacy.v2; /// - Fine scroll per frame. /// - Sprites (Standard, MultiColor) /// -/// Compared to C64SkiaRenderer: +/// Compared to C64LegacyRenderTarget: /// - A bit slower, but supports Bitmap graphics and still able to run in a browser with Blazor WebAssembly. /// [DisplayName("Skia legacy v2")] diff --git a/src/libraries/Highbyte.DotNet6502.Systems/HostApp.cs b/src/libraries/Highbyte.DotNet6502.Systems/HostApp.cs index 3d8821c5e..777fd7427 100644 --- a/src/libraries/Highbyte.DotNet6502.Systems/HostApp.cs +++ b/src/libraries/Highbyte.DotNet6502.Systems/HostApp.cs @@ -182,7 +182,6 @@ public List GetAvailableSystemRenderProviderTypes() return available; } - public async Task SelectSystem(string systemName) { if (EmulatorState != EmulatorState.Uninitialized) @@ -387,7 +386,6 @@ public void RunEmulatorOneFrame() public virtual void OnAfterRunEmulatorOneFrame(ExecEvaluatorTriggerResult execEvaluatorTriggerResult) { } - // New rendering pipeline private void InitRendererForSystem() { // Skip rendering initialization if no render config has been provided (e.g., in unit tests) diff --git a/src/libraries/Highbyte.DotNet6502.Systems/SystemRunner.cs b/src/libraries/Highbyte.DotNet6502.Systems/SystemRunner.cs index 2f4b546c0..43258af66 100644 --- a/src/libraries/Highbyte.DotNet6502.Systems/SystemRunner.cs +++ b/src/libraries/Highbyte.DotNet6502.Systems/SystemRunner.cs @@ -28,16 +28,12 @@ public class SystemRunner public SystemRunner(ISystem system, IInputHandler inputHandler, IAudioHandler audioHandler) { - // if (system != renderer.System) - // throw new DotNet6502Exception("Renderer must be for the same system as the SystemRunner."); if (system != inputHandler.System) throw new DotNet6502Exception("InputHandler must be for the same system as the SystemRunner."); if (system != audioHandler.System) throw new DotNet6502Exception("AudioHandler must be for the same system as the SystemRunner."); _system = system; - //_renderer = renderer; // Old renderer pipeline - //_renderer = renderer ?? new NullRenderer(system); _inputHandler = inputHandler; _audioHandler = audioHandler; } @@ -84,17 +80,8 @@ public ExecEvaluatorTriggerResult RunEmulatorOneFrame() return execEvaluatorTriggerResult; } - /// - /// Called by host app that runs the emulator, once per frame tied to the host app rendering frequency. - /// - public void Draw() - { - //_renderer.DrawFrame(); - } - public void Cleanup() { - //_renderer?.Cleanup(); // Old renderer pipeline _audioHandler.Cleanup(); _inputHandler.Cleanup(); }