Atari: Changed the core to make the TIA the video and sound provider.
This commit is contained in:
parent
2b9483f68f
commit
3591f7ca47
|
@ -4,16 +4,15 @@ using System.IO;
|
||||||
|
|
||||||
namespace BizHawk
|
namespace BizHawk
|
||||||
{
|
{
|
||||||
public partial class Atari2600 : IEmulator, IVideoProvider, ISoundProvider
|
public partial class Atari2600 : IEmulator
|
||||||
{
|
{
|
||||||
public string SystemId { get { return "A26"; } }
|
public string SystemId { get { return "A26"; } }
|
||||||
public GameInfo game;
|
public GameInfo game;
|
||||||
|
|
||||||
public int[] frameBuffer = new int[320 * 262];
|
|
||||||
public CoreInputComm CoreInputComm { get; set; }
|
public CoreInputComm CoreInputComm { get; set; }
|
||||||
public CoreOutputComm CoreOutputComm { get; private set; }
|
public CoreOutputComm CoreOutputComm { get; private set; }
|
||||||
public IVideoProvider VideoProvider { get { return this; } }
|
public IVideoProvider VideoProvider { get { return tia; } }
|
||||||
public ISoundProvider SoundProvider { get { return this; } }
|
public ISoundProvider SoundProvider { get { return tia; } }
|
||||||
|
|
||||||
public Atari2600(GameInfo game, byte[] rom)
|
public Atari2600(GameInfo game, byte[] rom)
|
||||||
{
|
{
|
||||||
|
@ -80,48 +79,7 @@ namespace BizHawk
|
||||||
bw.Flush();
|
bw.Flush();
|
||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
}
|
}
|
||||||
public int[] GetVideoBuffer() { return frameBuffer; }
|
|
||||||
public int BufferWidth { get { return 320; } }
|
|
||||||
public int BufferHeight { get { return 262; } }
|
|
||||||
public int BackgroundColor { get { return 0; } }
|
|
||||||
public void GetSamples(short[] samples)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
int freqDiv = 0;
|
|
||||||
byte myP4 = 0x00;
|
|
||||||
|
|
||||||
short[] moreSamples = new short[1000];
|
|
||||||
for (int i = 0; i < 1000; i++)
|
|
||||||
{
|
|
||||||
if (++freqDiv == (tia.audioFreqDiv * 2))
|
|
||||||
{
|
|
||||||
freqDiv = 0;
|
|
||||||
myP4 = (byte)(((myP4 & 0x0f) != 0) ? ((myP4 << 1) | ((((myP4 & 0x08) != 0) ? 1 : 0) ^ (((myP4 & 0x04) != 0) ? 1 : 0))) : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
moreSamples[i] = (short)(((myP4 & 0x08) != 0) ? 32767 : 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < samples.Length/2; i++)
|
|
||||||
{
|
|
||||||
//samples[i] = 0;
|
|
||||||
if (tia.audioEnabled)
|
|
||||||
{
|
|
||||||
samples[i*2] = moreSamples[(int)(((double)moreSamples.Length / (double)(samples.Length/2)) * i)];
|
|
||||||
//samples[i * 2 + 1] = moreSamples[(int)((moreSamples.Length / (samples.Length / 2)) * i)];
|
|
||||||
//samples[i] = (short)(Math.Sin(((((32000.0 / (tia.audioFreqDiv+1)) / 60.0) * Math.PI) / samples.Length) * i) * MaxVolume + MaxVolume);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
samples[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//samples = tia.samples;
|
|
||||||
* */
|
|
||||||
}
|
|
||||||
public void DiscardSamples() { }
|
|
||||||
public int MaxVolume { get; set; }
|
|
||||||
private IList<MemoryDomain> memoryDomains;
|
private IList<MemoryDomain> memoryDomains;
|
||||||
public IList<MemoryDomain> MemoryDomains { get { return memoryDomains; } }
|
public IList<MemoryDomain> MemoryDomains { get { return memoryDomains; } }
|
||||||
public MemoryDomain MainMemory { get { return memoryDomains[0]; } }
|
public MemoryDomain MainMemory { get { return memoryDomains[0]; } }
|
||||||
|
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||||
namespace BizHawk.Emulation.Consoles.Atari
|
namespace BizHawk.Emulation.Consoles.Atari
|
||||||
{
|
{
|
||||||
// Emulates the TIA
|
// Emulates the TIA
|
||||||
public partial class TIA
|
public partial class TIA : IVideoProvider, ISoundProvider
|
||||||
{
|
{
|
||||||
Atari2600 core;
|
Atari2600 core;
|
||||||
|
|
||||||
|
@ -418,6 +418,52 @@ namespace BizHawk.Emulation.Consoles.Atari
|
||||||
player1.scanCnt = 8;
|
player1.scanCnt = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int[] frameBuffer = new int[320 * 262];
|
||||||
|
public int[] GetVideoBuffer() { return frameBuffer; }
|
||||||
|
public int BufferWidth { get { return 320; } }
|
||||||
|
public int BufferHeight { get { return 262; } }
|
||||||
|
public int BackgroundColor { get { return 0; } }
|
||||||
|
|
||||||
|
public void GetSamples(short[] samples)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
int freqDiv = 0;
|
||||||
|
byte myP4 = 0x00;
|
||||||
|
|
||||||
|
short[] moreSamples = new short[1000];
|
||||||
|
for (int i = 0; i < 1000; i++)
|
||||||
|
{
|
||||||
|
if (++freqDiv == (tia.audioFreqDiv * 2))
|
||||||
|
{
|
||||||
|
freqDiv = 0;
|
||||||
|
myP4 = (byte)(((myP4 & 0x0f) != 0) ? ((myP4 << 1) | ((((myP4 & 0x08) != 0) ? 1 : 0) ^ (((myP4 & 0x04) != 0) ? 1 : 0))) : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
moreSamples[i] = (short)(((myP4 & 0x08) != 0) ? 32767 : 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < samples.Length/2; i++)
|
||||||
|
{
|
||||||
|
//samples[i] = 0;
|
||||||
|
if (tia.audioEnabled)
|
||||||
|
{
|
||||||
|
samples[i*2] = moreSamples[(int)(((double)moreSamples.Length / (double)(samples.Length/2)) * i)];
|
||||||
|
//samples[i * 2 + 1] = moreSamples[(int)((moreSamples.Length / (samples.Length / 2)) * i)];
|
||||||
|
//samples[i] = (short)(Math.Sin(((((32000.0 / (tia.audioFreqDiv+1)) / 60.0) * Math.PI) / samples.Length) * i) * MaxVolume + MaxVolume);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
samples[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//samples = tia.samples;
|
||||||
|
* */
|
||||||
|
}
|
||||||
|
public void DiscardSamples() { }
|
||||||
|
public int MaxVolume { get; set; }
|
||||||
|
|
||||||
|
|
||||||
// Execute TIA cycles
|
// Execute TIA cycles
|
||||||
public void execute(int cycles)
|
public void execute(int cycles)
|
||||||
{
|
{
|
||||||
|
@ -737,11 +783,11 @@ namespace BizHawk.Emulation.Consoles.Atari
|
||||||
{
|
{
|
||||||
if (scanlinesBuffer.Count > row)
|
if (scanlinesBuffer.Count > row)
|
||||||
{
|
{
|
||||||
core.frameBuffer[row * 320 + col] = (int)(scanlinesBuffer[row][col / 2]);
|
frameBuffer[row * 320 + col] = (int)(scanlinesBuffer[row][col / 2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
core.frameBuffer[row * 320 + col] = 0x000000;
|
frameBuffer[row * 320 + col] = 0x000000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue