From c972a741323664dee3f94cd0e282f9fb8198e618 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Mon, 31 Jul 2017 12:14:42 -0400 Subject: [PATCH] A7800Hawk: Filters and video provider -Moved IVideoProvider out of Maria to make eventual A2600 mode support a bit easier. -Add filter option so Tower Toppler looks correct, not implemeneted yet though --- .../Atari/A7800Hawk/A7800Hawk.IEmulator.cs | 45 ++++++++++++++++++- .../Atari/A7800Hawk/A7800Hawk.ISettable.cs | 15 ++++++- .../Consoles/Atari/A7800Hawk/A7800Hawk.cs | 20 +++++---- .../Consoles/Atari/A7800Hawk/Maria.cs | 27 ++--------- 4 files changed, 72 insertions(+), 35 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs index abe7641ba6..fc8eb4bc34 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs @@ -1,10 +1,11 @@ using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; using System; +using System.Collections.Generic; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { - public partial class A7800Hawk : IEmulator + public partial class A7800Hawk : IEmulator, IVideoProvider { public IEmulatorServiceProvider ServiceProvider { get; } @@ -304,5 +305,47 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk tia = null; m6532 = null; } + + + #region Video provider + + public int _frameHz = 60; + public int _screen_width = 320; + public int _screen_height = 263; + public int _vblanklines = 20; + + public int[] _vidbuffer; + + public int[] GetVideoBuffer() + { + if (_syncSettings.Filter != "None") + { + apply_filter(); + Console.WriteLine("works!"); + } + return _vidbuffer; + } + + public int VirtualWidth => 320; + public int VirtualHeight => _screen_height - _vblanklines; + public int BufferWidth => 320; + public int BufferHeight => _screen_height - _vblanklines; + public int BackgroundColor => unchecked((int)0xff000000); + public int VsyncNumerator => _frameHz; + public int VsyncDenominator => 1; + + public void apply_filter() + { + + } + + public static Dictionary ValidFilterTypes = new Dictionary + { + { "None", "None"}, + { "NTSC", "NTSC"}, + { "Pal", "Pal"} + }; + + #endregion } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISettable.cs index 7f646316af..06e2ae1273 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISettable.cs @@ -1,4 +1,6 @@ using System; +using System.ComponentModel; + using Newtonsoft.Json; using BizHawk.Common; @@ -32,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk } private A7800Settings _settings = new A7800Settings(); - private A7800SyncSettings _syncSettings = new A7800SyncSettings(); + public A7800SyncSettings _syncSettings = new A7800SyncSettings(); public class A7800Settings { @@ -46,6 +48,17 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { private string _port1 = A7800HawkControllerDeck.DefaultControllerName; private string _port2 = A7800HawkControllerDeck.DefaultControllerName; + private string _Filter = "None"; + + [JsonIgnore] + public string Filter + { + get { return _Filter; } + set + { + _Filter = value; + } + } [JsonIgnore] public string Port1 diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs index 296378a96a..62c478b1d0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs @@ -204,18 +204,18 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk // set up palette and frame rate if (_isPAL) { - maria._frameHz = 50; - maria._screen_width = 320; - maria._screen_height = 313; - maria._vblanklines = 20; + _frameHz = 50; + _screen_width = 320; + _screen_height = 313; + _vblanklines = 20; maria._palette = PALPalette; } else { - maria._frameHz = 60; - maria._screen_width = 320; - maria._screen_height = 263; - maria._vblanklines = 20; + _frameHz = 60; + _screen_width = 320; + _screen_height = 263; + _vblanklines = 20; maria._palette = NTSCPalette; } @@ -223,7 +223,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk m6532.Core = this; tia.Core = this; - ser.Register(maria); + ser.Register(this); ser.Register(tia); ServiceProvider = ser; @@ -253,6 +253,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk RAM = new byte[0x1000]; cpu_cycle = 0; + + _vidbuffer = new int[VirtualWidth * VirtualHeight]; } private void ExecFetch(ushort addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs index f36aa4fffd..ae907bde03 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs @@ -6,7 +6,7 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Emulates the Atari 7800 Maria graphics chip - public class Maria : IVideoProvider + public class Maria { public A7800Hawk Core { get; set; } @@ -32,28 +32,9 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk int GFX_index = 0; - public int _frameHz = 60; - public int _screen_width = 320; - public int _screen_height = 263; - public int _vblanklines = 20; - - public int[] _vidbuffer; public int[] _palette; public int[] scanline_buffer = new int[320]; - public int[] GetVideoBuffer() - { - return _vidbuffer; - } - - public int VirtualWidth => 320; - public int VirtualHeight => _screen_height - _vblanklines; - public int BufferWidth => 320; - public int BufferHeight => _screen_height - _vblanklines; - public int BackgroundColor => unchecked((int)0xff000000); - public int VsyncNumerator => _frameHz; - public int VsyncDenominator => 1; - // the Maria chip can directly access memory public Func ReadMemory; @@ -173,7 +154,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk // Now proceed with the remaining scanlines // the first one is a pre-render line, since we didn't actually put any data into the buffer yet - while (scanline < _screen_height) + while (scanline < Core._screen_height) { if (cycle == 28 && Core.Maria_regs[0x1C].Bit(6) && !Core.Maria_regs[0x1C].Bit(5)) { @@ -284,7 +265,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk } // send buffer to the video buffer - _vidbuffer[(scanline - 21) * 320 + pixel] = scanline_buffer[pixel]; + Core._vidbuffer[(scanline - 21) * 320 + pixel] = scanline_buffer[pixel]; // clear the line ram line_ram[local_GFX_index, pixel] = 0; @@ -660,8 +641,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public void Reset() { - _vidbuffer = new int[VirtualWidth * VirtualHeight]; - for (int i = 0; i < 128; i++) { GFX_Objects[i].obj = new byte[128];