From a54df87b02ca827564c6c3653276b7f5df5fa957 Mon Sep 17 00:00:00 2001 From: saxxonpike Date: Sat, 10 Nov 2012 05:57:46 +0000 Subject: [PATCH] commodore64: simplification and performance increase: VIC implements IVideoProvider, SID implements ISoundProvider --- BizHawk.Emulation/BizHawk.Emulation.csproj | 2 + .../Computers/Commodore64/C64.core.cs | 2 - .../Computers/Commodore64/C64.cs | 65 +------------------ .../Computers/Commodore64/Sid.cs | 2 +- .../Computers/Commodore64/SidSoundProvider.cs | 29 +++++++++ .../Computers/Commodore64/VicII.cs | 2 +- .../Commodore64/VicIIVideoProvider.cs | 35 ++++++++++ 7 files changed, 70 insertions(+), 67 deletions(-) create mode 100644 BizHawk.Emulation/Computers/Commodore64/SidSoundProvider.cs create mode 100644 BizHawk.Emulation/Computers/Commodore64/VicIIVideoProvider.cs diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 7b504ed1cd..dbe44868ec 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -90,7 +90,9 @@ + + diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.core.cs b/BizHawk.Emulation/Computers/Commodore64/C64.core.cs index ad80133123..cc384fa5c5 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.core.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.core.cs @@ -81,8 +81,6 @@ namespace BizHawk.Emulation.Computers.Commodore64 } break; } - - videoProvider = new MyVideoProvider(vic); } public byte PeekMemory(ushort addr) diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.cs b/BizHawk.Emulation/Computers/Commodore64/C64.cs index e162e81e50..22eff6e32a 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.cs @@ -37,8 +37,8 @@ namespace BizHawk.Emulation.Computers.Commodore64 public void ClearSaveRam() { } public bool SaveRamModified { get; set; } public void Dispose() { } - public IVideoProvider VideoProvider { get { return videoProvider; } } - public ISoundProvider SoundProvider { get { return soundProvider; } } + public IVideoProvider VideoProvider { get { return vic; } } + public ISoundProvider SoundProvider { get { return sid; } } public void ResetFrameCounter() { _frame = 0; @@ -73,23 +73,6 @@ namespace BizHawk.Emulation.Computers.Commodore64 } }; - class MySoundProvider : ISoundProvider - { - Atari7800 emu; - public MySoundProvider(Atari7800 emu) - { - this.emu = emu; - } - public int MaxVolume { get { return 0; } set { } } - public void DiscardSamples() - { - } - - public void GetSamples(short[] samples) - { - } - } - public void FrameAdvance(bool render, bool rendersound) { _frame++; @@ -125,50 +108,6 @@ namespace BizHawk.Emulation.Computers.Commodore64 { LagCount++; } - - videoProvider.FillFrameBuffer(); - } - - /*******************************/ - - private MySoundProvider soundProvider; - private MyVideoProvider videoProvider; - - class MyVideoProvider : IVideoProvider - { - public int top; - public int bottom; - public int left; - public int right; - - VicII vic; - public MyVideoProvider(VicII vic) - { - this.vic = vic; - - buffer = new int[vic.visibleWidth * vic.visibleHeight]; - top = 0; - bottom = vic.visibleHeight - 1; - left = 0; - right = vic.visibleWidth - 1; - } - - int[] buffer; - - public void FillFrameBuffer() - { - Array.Copy(vic.buffer, buffer, buffer.Length); - } - - public int[] GetVideoBuffer() - { - return buffer; - } - - public int VirtualWidth { get { return BufferWidth; } } - public int BufferWidth { get { return right - left + 1; } } - public int BufferHeight { get { return bottom - top + 1; } } - public int BackgroundColor { get { return 0; } } } private void SetupMemoryDomains() diff --git a/BizHawk.Emulation/Computers/Commodore64/Sid.cs b/BizHawk.Emulation/Computers/Commodore64/Sid.cs index 402838e524..0c12744a28 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Sid.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Sid.cs @@ -256,7 +256,7 @@ namespace BizHawk.Emulation.Computers.Commodore64 } - public class Sid + public partial class Sid : ISoundProvider { private int[] envRateIndex = { 9, 32, 63, 95, diff --git a/BizHawk.Emulation/Computers/Commodore64/SidSoundProvider.cs b/BizHawk.Emulation/Computers/Commodore64/SidSoundProvider.cs new file mode 100644 index 0000000000..621d675ff6 --- /dev/null +++ b/BizHawk.Emulation/Computers/Commodore64/SidSoundProvider.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Computers.Commodore64 +{ + public partial class Sid : ISoundProvider + { + public void GetSamples(short[] samples) + { + } + + public void DiscardSamples() + { + } + + public int MaxVolume + { + get + { + return 0; + } + set + { + } + } + } +} diff --git a/BizHawk.Emulation/Computers/Commodore64/VicII.cs b/BizHawk.Emulation/Computers/Commodore64/VicII.cs index ef141161fe..5245b149ba 100644 --- a/BizHawk.Emulation/Computers/Commodore64/VicII.cs +++ b/BizHawk.Emulation/Computers/Commodore64/VicII.cs @@ -451,7 +451,7 @@ namespace BizHawk.Emulation.Computers.Commodore64 DramRefresh } - public class VicII + public partial class VicII : IVideoProvider { // graphics buffer public int[] buffer; diff --git a/BizHawk.Emulation/Computers/Commodore64/VicIIVideoProvider.cs b/BizHawk.Emulation/Computers/Commodore64/VicIIVideoProvider.cs new file mode 100644 index 0000000000..bd721afa95 --- /dev/null +++ b/BizHawk.Emulation/Computers/Commodore64/VicIIVideoProvider.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Computers.Commodore64 +{ + public partial class VicII : IVideoProvider + { + public int[] GetVideoBuffer() + { + return buffer; + } + + public int VirtualWidth + { + get { return visibleWidth; } + } + + public int BufferWidth + { + get { return visibleWidth; } + } + + public int BufferHeight + { + get { return visibleHeight; } + } + + public int BackgroundColor + { + get { return Colors.ARGB(0, 0, 0); } + } + } +}