atari 2600 cleanup

This commit is contained in:
adelikat 2017-05-05 13:49:36 -05:00
parent d467a1427d
commit 7b29970ef9
12 changed files with 841 additions and 768 deletions

View File

@ -291,7 +291,7 @@
<DependentUpon>Atari2600.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Atari\2600\Atari2600.IEmulator.cs">
<DependentUpon>Atari2600.cs</DependentUpon>
<DependentUpon>Atari2600.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Atari\2600\Atari2600.IInputPollable.cs">
<DependentUpon>Atari2600.cs</DependentUpon>
@ -347,9 +347,13 @@
<Compile Include="Consoles\Atari\2600\Tia\Tia.BallData.cs" />
<Compile Include="Consoles\Atari\2600\Tia\TIA.cs" />
<Compile Include="Consoles\Atari\2600\Tia\Tia.HMoveData.cs" />
<Compile Include="Consoles\Atari\2600\Tia\Tia.ISoundProvider.cs" />
<Compile Include="Consoles\Atari\2600\Tia\Tia.IVideoProvider.cs" />
<Compile Include="Consoles\Atari\2600\Tia\Tia.MissleData.cs" />
<Compile Include="Consoles\Atari\2600\Tia\Tia.Palette.cs" />
<Compile Include="Consoles\Atari\2600\Tia\Tia.PlayerData.cs" />
<Compile Include="Consoles\Atari\2600\Tia\Tia.PlayfieldData.cs" />
<Compile Include="Consoles\Atari\2600\Tia\Tia.SyncState.cs" />
<Compile Include="Consoles\Atari\7800\Atari7800.cs" />
<Compile Include="Consoles\Atari\7800\Atari7800.IDebuggable.cs">
<DependentUpon>Atari7800.cs</DependentUpon>

View File

@ -69,11 +69,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
if ((addr & 0x1080) == 0x0080)
{
_tia.bus_state = _m6532.ReadMemory(addr, false);
_tia.BusState = _m6532.ReadMemory(addr, false);
return _m6532.ReadMemory(addr, false);
}
_tia.bus_state = Rom[addr & 0x0FFF];
_tia.BusState = Rom[addr & 0x0FFF];
return Rom[addr & 0x0FFF];
}
@ -95,7 +95,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
internal void BaseWriteMemory(ushort addr, byte value)
{
_tia.bus_state = value;
_tia.BusState = value;
if (addr != _lastAddress)
{
DistinctAccessCount++;
@ -144,7 +144,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_mapper.Bit13 = addr.Bit(13);
var temp = _mapper.ReadMemory((ushort)(addr & 0x1FFF));
_tia.bus_state = temp;
_tia.BusState = temp;
MemoryCallbacks.CallReads(addr);
return temp;

View File

@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
if (rendersound == false)
{
_tia._audioClocks = 0; // we need this here since the async sound provider won't check in this case
_tia.AudioClocks = 0; // we need this here since the async sound provider won't check in this case
}
FinishFrameCond();

View File

@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
if (Settings == null || Settings.SECAMColors != o.SECAMColors)
{
_tia?.SetSECAM(o.SECAMColors);
_tia?.SetSecam(o.SECAMColors);
}
Settings = o;

View File

@ -7,9 +7,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
private readonly Atari2600 _core;
private byte DDRa = 0x00;
private byte DDRb = 0x00;
private byte outputA = 0x00;
private byte _ddRa = 0x00;
private byte _ddRb = 0x00;
private byte _outputA = 0x00;
public TimerData Timer;
@ -37,31 +37,29 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Read Output reg A
// Combine readings from player 1 and player 2
// actually depends on setting in SWCHCNTA (aka DDRa)
var temp = (byte)(_core.ReadControls1(peek) & 0xF0 | ((_core.ReadControls2(peek) >> 4) & 0x0F));
temp = (byte)(temp & ~DDRa);
temp = (byte)(temp + (outputA & DDRa));
temp = (byte)(temp & ~_ddRa);
temp = (byte)(temp + (_outputA & _ddRa));
return temp;
}
if (registerAddr == 0x01)
{
// Read DDRA
return DDRa;
return _ddRa;
}
if (registerAddr == 0x02)
{
// Read Output reg B
var temp = _core.ReadConsoleSwitches(peek);
temp = (byte)(temp & ~DDRb);
temp = (byte)(temp & ~_ddRb);
return temp;
}
if (registerAddr == 0x03) // Read DDRB
{
return DDRb;
return _ddRb;
}
if ((registerAddr & 0x5) == 0x4)
@ -157,12 +155,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
if (registerAddr == 0x00)
{
// Write Output reg A
outputA = value;
_outputA = value;
}
else if (registerAddr == 0x01)
{
// Write DDRA
DDRa = value;
_ddRa = value;
}
else if (registerAddr == 0x02)
{
@ -172,7 +170,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else if (registerAddr == 0x03)
{
// Write DDRB
DDRb = value;
_ddRb = value;
}
}
}
@ -181,9 +179,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public void SyncState(Serializer ser)
{
ser.BeginSection("M6532");
ser.Sync("ddra", ref DDRa);
ser.Sync("ddrb", ref DDRb);
ser.Sync("OutputA", ref outputA);
ser.Sync("ddra", ref _ddRa);
ser.Sync("ddrb", ref _ddRb);
ser.Sync("OutputA", ref _outputA);
Timer.SyncState(ser);
ser.EndSection();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,65 @@
using System;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
public partial class TIA : ISoundProvider
{
public bool CanProvideAsync => false;
public void SetSyncMode(SyncSoundMode mode)
{
if (mode != SyncSoundMode.Sync)
{
throw new InvalidOperationException("Only Sync mode is supported.");
}
}
public SyncSoundMode SyncMode => SyncSoundMode.Sync;
public void GetSamplesSync(out short[] samples, out int nsamp)
{
short[] ret = new short[_spf * 2];
GetSamples(ret);
samples = ret;
nsamp = _spf;
}
public void GetSamplesAsync(short[] samples)
{
throw new NotSupportedException("Async is not available");
}
public void DiscardSamples()
{
AudioClocks = 0;
}
private readonly int _spf;
// Exposing this as GetSamplesAsync would allow this to provide async sound
// However, it does nothing special for async sound so I don't see a point
private void GetSamples(short[] samples)
{
if (AudioClocks > 0)
{
var samples31Khz = new short[AudioClocks]; // mono
for (int i = 0; i < AudioClocks; i++)
{
samples31Khz[i] = LocalAudioCycles[i];
LocalAudioCycles[i] = 0;
}
// convert from 31khz to 44khz
for (var i = 0; i < samples.Length / 2; i++)
{
samples[i * 2] = samples31Khz[(int)(((double)samples31Khz.Length / (double)(samples.Length / 2)) * i)];
samples[(i * 2) + 1] = samples[i * 2];
}
}
AudioClocks = 0;
}
}
}

View File

@ -0,0 +1,51 @@
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
public partial class TIA : IVideoProvider
{
public int[] GetVideoBuffer()
{
return _frameBuffer;
}
public int VirtualWidth
{
get
{
if (_pal)
{
return 320;
}
return 275; // 275 comes from NTSC specs and the actual pixel clock of a 2600 TIA
}
}
public int VirtualHeight => BufferHeight;
public int BufferWidth => ScreenWidth;
public int BufferHeight
{
get
{
if (_pal)
{
return _core.Settings.PALBottomLine - _core.Settings.PALTopLine;
}
return _core.Settings.NTSCBottomLine - _core.Settings.NTSCTopLine;
}
}
public int VsyncNumerator => _vsyncNum;
public int VsyncDenominator => _vsyncDen;
public int BackgroundColor => _core.Settings.BackgroundColor.ToArgb();
private readonly int[] _frameBuffer = new int[ScreenWidth * MaxScreenHeight];
private int _vsyncNum, _vsyncDen;
}
}

View File

@ -15,29 +15,27 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public byte Collisions;
// Resp commands do not trigger start signals for main copies. We need to model this
private int Draw_To;
private byte ScanCnt;
private bool ScanCntInit;
private int Start_Signal;
private int Signal_Reached;
private int _drawTo;
private byte _scanCnt;
private bool _scanCntInit;
private int _startSignal;
private int _signalReached;
public bool Tick()
{
var result = false;
if (ScanCntInit == true)
if (_scanCntInit)
{
if (ScanCnt < (1 << Size) && Enabled && !ResetToPlayer)
if (_scanCnt < 1 << Size && Enabled && !ResetToPlayer)
{
result = true;
ScanCnt++;
_scanCnt++;
}
else
{
ScanCntInit = false;
_scanCntInit = false;
}
}
/*
@ -87,32 +85,32 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
}*/
if (Start_Signal == 160)
if (_startSignal == 160)
{
ScanCnt = 0;
Start_Signal++;
ScanCntInit = true;
_scanCnt = 0;
_startSignal++;
_scanCntInit = true;
}
if (Start_Signal == 16 && ((Number & 0x07) == 0x01 || ((Number & 0x07) == 0x03)))
if (_startSignal == 16 && ((Number & 0x07) == 0x01 || ((Number & 0x07) == 0x03)))
{
ScanCnt = 0;
Start_Signal++;
ScanCntInit = true;
_scanCnt = 0;
_startSignal++;
_scanCntInit = true;
}
if (Start_Signal == 32 && ((Number & 0x07) == 0x02 || ((Number & 0x07) == 0x03) || ((Number & 0x07) == 0x06)))
if (_startSignal == 32 && ((Number & 0x07) == 0x02 || ((Number & 0x07) == 0x03) || ((Number & 0x07) == 0x06)))
{
ScanCnt = 0;
Start_Signal++;
ScanCntInit = true;
_scanCnt = 0;
_startSignal++;
_scanCntInit = true;
}
if (Start_Signal == 64 && ((Number & 0x07) == 0x04 || ((Number & 0x07) == 0x06)))
if (_startSignal == 64 && ((Number & 0x07) == 0x04 || ((Number & 0x07) == 0x06)))
{
ScanCnt = 0;
Start_Signal++;
ScanCntInit = true;
_scanCnt = 0;
_startSignal++;
_scanCntInit = true;
}
// Increment the counter
@ -125,13 +123,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// drawing on a real TIA
if (HPosCnt == 156 || HPosCnt == 12 || HPosCnt == 28 || HPosCnt == 60)
{
Start_Signal = HPosCnt;
Signal_Reached = HPosCnt + 5;
_startSignal = HPosCnt;
_signalReached = HPosCnt + 5;
}
if (Start_Signal < Signal_Reached)
if (_startSignal < _signalReached)
{
Start_Signal++;
_startSignal++;
}
return result;
@ -147,11 +145,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.Sync("number", ref Number);
ser.Sync("HM", ref Hm);
ser.Sync("collisions", ref Collisions);
ser.Sync("start_signal", ref Start_Signal);
ser.Sync("signal_reached", ref Signal_Reached);
ser.Sync("draw_to", ref Draw_To);
ser.Sync("scanCnt", ref ScanCnt);
ser.Sync("scanCntInit", ref ScanCntInit);
ser.Sync("start_signal", ref _startSignal);
ser.Sync("signal_reached", ref _signalReached);
ser.Sync("draw_to", ref _drawTo);
ser.Sync("scanCnt", ref _scanCnt);
ser.Sync("scanCntInit", ref _scanCntInit);
ser.EndSection();
}
}

View File

@ -0,0 +1,207 @@
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
public partial class TIA
{
private static readonly int[] PALPalette =
{
0x000000, 0x000000, 0x2b2b2b, 0x2b2b2b,
0x525252, 0x525252, 0x767676, 0x767676,
0x979797, 0x979797, 0xb6b6b6, 0xb6b6b6,
0xd2d2d2, 0xd2d2d2, 0xececec, 0xececec,
0x000000, 0x000000, 0x2b2b2b, 0x2b2b2b,
0x525252, 0x525252, 0x767676, 0x767676,
0x979797, 0x979797, 0xb6b6b6, 0xb6b6b6,
0xd2d2d2, 0xd2d2d2, 0xececec, 0xececec,
0x805800, 0x000000, 0x96711a, 0x2b2b2b,
0xab8732, 0x525252, 0xbe9c48, 0x767676,
0xcfaf5c, 0x979797, 0xdfc06f, 0xb6b6b6,
0xeed180, 0xd2d2d2, 0xfce090, 0xececec,
0x445c00, 0x000000, 0x5e791a, 0x2b2b2b,
0x769332, 0x525252, 0x8cac48, 0x767676,
0xa0c25c, 0x979797, 0xb3d76f, 0xb6b6b6,
0xc4ea80, 0xd2d2d2, 0xd4fc90, 0xececec,
0x703400, 0x000000, 0x89511a, 0x2b2b2b,
0xa06b32, 0x525252, 0xb68448, 0x767676,
0xc99a5c, 0x979797, 0xdcaf6f, 0xb6b6b6,
0xecc280, 0xd2d2d2, 0xfcd490, 0xececec,
0x006414, 0x000000, 0x1a8035, 0x2b2b2b,
0x329852, 0x525252, 0x48b06e, 0x767676,
0x5cc587, 0x979797, 0x6fd99e, 0xb6b6b6,
0x80ebb4, 0xd2d2d2, 0x90fcc8, 0xececec,
0x700014, 0x000000, 0x891a35, 0x2b2b2b,
0xa03252, 0x525252, 0xb6486e, 0x767676,
0xc95c87, 0x979797, 0xdc6f9e, 0xb6b6b6,
0xec80b4, 0xd2d2d2, 0xfc90c8, 0xececec,
0x005c5c, 0x000000, 0x1a7676, 0x2b2b2b,
0x328e8e, 0x525252, 0x48a4a4, 0x767676,
0x5cb8b8, 0x979797, 0x6fcbcb, 0xb6b6b6,
0x80dcdc, 0xd2d2d2, 0x90ecec, 0xececec,
0x70005c, 0x000000, 0x841a74, 0x2b2b2b,
0x963289, 0x525252, 0xa8489e, 0x767676,
0xb75cb0, 0x979797, 0xc66fc1, 0xb6b6b6,
0xd380d1, 0xd2d2d2, 0xe090e0, 0xececec,
0x003c70, 0x000000, 0x195a89, 0x2b2b2b,
0x2f75a0, 0x525252, 0x448eb6, 0x767676,
0x57a5c9, 0x979797, 0x68badc, 0xb6b6b6,
0x79ceec, 0xd2d2d2, 0x88e0fc, 0xececec,
0x580070, 0x000000, 0x6e1a89, 0x2b2b2b,
0x8332a0, 0x525252, 0x9648b6, 0x767676,
0xa75cc9, 0x979797, 0xb76fdc, 0xb6b6b6,
0xc680ec, 0xd2d2d2, 0xd490fc, 0xececec,
0x002070, 0x000000, 0x193f89, 0x2b2b2b,
0x2f5aa0, 0x525252, 0x4474b6, 0x767676,
0x578bc9, 0x979797, 0x68a1dc, 0xb6b6b6,
0x79b5ec, 0xd2d2d2, 0x88c8fc, 0xececec,
0x340080, 0x000000, 0x4a1a96, 0x2b2b2b,
0x5f32ab, 0x525252, 0x7248be, 0x767676,
0x835ccf, 0x979797, 0x936fdf, 0xb6b6b6,
0xa280ee, 0xd2d2d2, 0xb090fc, 0xececec,
0x000088, 0x000000, 0x1a1a9d, 0x2b2b2b,
0x3232b0, 0x525252, 0x4848c2, 0x767676,
0x5c5cd2, 0x979797, 0x6f6fe1, 0xb6b6b6,
0x8080ef, 0xd2d2d2, 0x9090fc, 0xececec,
0x000000, 0x000000, 0x2b2b2b, 0x2b2b2b,
0x525252, 0x525252, 0x767676, 0x767676,
0x979797, 0x979797, 0xb6b6b6, 0xb6b6b6,
0xd2d2d2, 0xd2d2d2, 0xececec, 0xececec,
0x000000, 0x000000, 0x2b2b2b, 0x2b2b2b,
0x525252, 0x525252, 0x767676, 0x767676,
0x979797, 0x979797, 0xb6b6b6, 0xb6b6b6,
0xd2d2d2, 0xd2d2d2, 0xececec, 0xececec
};
private static readonly int[] NTSCPalette =
{
0x000000, 0, 0x4a4a4a, 0, 0x6f6f6f, 0, 0x8e8e8e, 0,
0xaaaaaa, 0, 0xc0c0c0, 0, 0xd6d6d6, 0, 0xececec, 0,
0x484800, 0, 0x69690f, 0, 0x86861d, 0, 0xa2a22a, 0,
0xbbbb35, 0, 0xd2d240, 0, 0xe8e84a, 0, 0xfcfc54, 0,
0x7c2c00, 0, 0x904811, 0, 0xa26221, 0, 0xb47a30, 0,
0xc3903d, 0, 0xd2a44a, 0, 0xdfb755, 0, 0xecc860, 0,
0x901c00, 0, 0xa33915, 0, 0xb55328, 0, 0xc66c3a, 0,
0xd5824a, 0, 0xe39759, 0, 0xf0aa67, 0, 0xfcbc74, 0,
0x940000, 0, 0xa71a1a, 0, 0xb83232, 0, 0xc84848, 0,
0xd65c5c, 0, 0xe46f6f, 0, 0xf08080, 0, 0xfc9090, 0,
0x840064, 0, 0x97197a, 0, 0xa8308f, 0, 0xb846a2, 0,
0xc659b3, 0, 0xd46cc3, 0, 0xe07cd2, 0, 0xec8ce0, 0,
0x500084, 0, 0x68199a, 0, 0x7d30ad, 0, 0x9246c0, 0,
0xa459d0, 0, 0xb56ce0, 0, 0xc57cee, 0, 0xd48cfc, 0,
0x140090, 0, 0x331aa3, 0, 0x4e32b5, 0, 0x6848c6, 0,
0x7f5cd5, 0, 0x956fe3, 0, 0xa980f0, 0, 0xbc90fc, 0,
0x000094, 0, 0x181aa7, 0, 0x2d32b8, 0, 0x4248c8, 0,
0x545cd6, 0, 0x656fe4, 0, 0x7580f0, 0, 0x8490fc, 0,
0x001c88, 0, 0x183b9d, 0, 0x2d57b0, 0, 0x4272c2, 0,
0x548ad2, 0, 0x65a0e1, 0, 0x75b5ef, 0, 0x84c8fc, 0,
0x003064, 0, 0x185080, 0, 0x2d6d98, 0, 0x4288b0, 0,
0x54a0c5, 0, 0x65b7d9, 0, 0x75cceb, 0, 0x84e0fc, 0,
0x004030, 0, 0x18624e, 0, 0x2d8169, 0, 0x429e82, 0,
0x54b899, 0, 0x65d1ae, 0, 0x75e7c2, 0, 0x84fcd4, 0,
0x004400, 0, 0x1a661a, 0, 0x328432, 0, 0x48a048, 0,
0x5cba5c, 0, 0x6fd26f, 0, 0x80e880, 0, 0x90fc90, 0,
0x143c00, 0, 0x355f18, 0, 0x527e2d, 0, 0x6e9c42, 0,
0x87b754, 0, 0x9ed065, 0, 0xb4e775, 0, 0xc8fc84, 0,
0x303800, 0, 0x505916, 0, 0x6d762b, 0, 0x88923e, 0,
0xa0ab4f, 0, 0xb7c25f, 0, 0xccd86e, 0, 0xe0ec7c, 0,
0x482c00, 0, 0x694d14, 0, 0x866a26, 0, 0xa28638, 0,
0xbb9f47, 0, 0xd2b656, 0, 0xe8cc63, 0, 0xfce070, 0
};
private static readonly int[] SecamPalette =
{
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x2121FF, 0x2121FF,
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff
};
}
}

View File

@ -21,8 +21,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public byte Collisions;
// Resp commands do not trigger start signals for main copies. We need to model this
private int Start_Signal;
private int Signal_Reached;
private int _startSignal;
private int _signalReached;
public bool Tick()
{
@ -63,7 +63,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
}
// Increment the Player Graphics Scan Counter
// This counter advances once per clock for single sized players,
@ -74,7 +73,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// The first tick for single sized players happens immediately.
// The first tick for double and quad sized players is delayed one clock cycle,
// and then happen every 2 or 4 clocks
if ((Nusiz & 0x07) == 0x05)
{
if ((HPosCnt + 3) % 2 == 0)
@ -114,10 +112,10 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// At counter position 0 we should initalize the scan counter.
// Note that for double and quad sized players that the scan counter is not started immediately.
if (Start_Signal == 160)
if (_startSignal == 160)
{
ScanCnt = 0;
Start_Signal++;
_startSignal++;
if ((Nusiz & 0x07) == 0x05)
{
ScanCntInit = true;
@ -132,22 +130,22 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
}
if (Start_Signal == 16 && ((Nusiz & 0x07) == 0x01 || ((Nusiz & 0x07) == 0x03)))
if (_startSignal == 16 && ((Nusiz & 0x07) == 0x01 || ((Nusiz & 0x07) == 0x03)))
{
ScanCnt = 0;
Start_Signal++;
_startSignal++;
}
if (Start_Signal == 32 && ((Nusiz & 0x07) == 0x02 || ((Nusiz & 0x07) == 0x03) || ((Nusiz & 0x07) == 0x06)))
if (_startSignal == 32 && ((Nusiz & 0x07) == 0x02 || ((Nusiz & 0x07) == 0x03) || ((Nusiz & 0x07) == 0x06)))
{
ScanCnt = 0;
Start_Signal++;
_startSignal++;
}
if (Start_Signal == 64 && ((Nusiz & 0x07) == 0x04 || ((Nusiz & 0x07) == 0x06)))
if (_startSignal == 64 && ((Nusiz & 0x07) == 0x04 || ((Nusiz & 0x07) == 0x06)))
{
ScanCnt = 0;
Start_Signal++;
_startSignal++;
}
// Increment the counter
@ -160,13 +158,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// drawing on a real TIA
if (HPosCnt == 156 || HPosCnt == 12 || HPosCnt == 28 || HPosCnt == 60)
{
Start_Signal = HPosCnt - 1;
Signal_Reached = HPosCnt + 5;
_startSignal = HPosCnt - 1;
_signalReached = HPosCnt + 5;
}
if (Start_Signal<Signal_Reached)
if (_startSignal < _signalReached)
{
Start_Signal++;
_startSignal++;
}
return result;
@ -186,8 +184,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.Sync("delay", ref Delay);
ser.Sync("nusiz", ref Nusiz);
ser.Sync("collisions", ref Collisions);
ser.Sync("start_signal", ref Start_Signal);
ser.Sync("signal_reached", ref Signal_Reached);
ser.Sync("start_signal", ref _startSignal);
ser.Sync("signal_reached", ref _signalReached);
}
}
}

View File

@ -0,0 +1,80 @@
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
public partial class TIA
{
public void SyncState(Serializer ser)
{
ser.BeginSection("TIA");
_ball.SyncState(ser);
_hmove.SyncState(ser);
ser.Sync("hsyncCnt", ref _hsyncCnt);
// add everything to the state
ser.Sync("Bus_State", ref BusState);
ser.Sync("PF0_up", ref _pf0Update);
ser.Sync("PF1_up", ref _pf1Update);
ser.Sync("PF2_up", ref _pf2Update);
ser.Sync("PF0_upper", ref _pf0Updater);
ser.Sync("PF1_upper", ref _pf1Updater);
ser.Sync("PF2_upper", ref _pf2Updater);
ser.Sync("PF0_delay", ref _pf0DelayClock);
ser.Sync("PF1_delay", ref _pf1DelayClock);
ser.Sync("PF2_delay", ref _pf2DelayClock);
ser.Sync("PF0_max", ref _pf0MaxDelay);
ser.Sync("PF1_max", ref _pf1MaxDelay);
ser.Sync("PF2_max", ref _pf2MaxDelay);
ser.Sync("Enam0_delay", ref _enam0Delay);
ser.Sync("Enam1_delay", ref _enam1Delay);
ser.Sync("Enab_delay", ref _enambDelay);
ser.Sync("Enam0_val", ref _enam0Val);
ser.Sync("Enam1_val", ref _enam1Val);
ser.Sync("Enab_val", ref _enambVal);
ser.Sync("P0_stuff", ref _p0Stuff);
ser.Sync("P1_stuff", ref _p1Stuff);
ser.Sync("M0_stuff", ref _m0Stuff);
ser.Sync("M1_stuf", ref _m1Stuff);
ser.Sync("b_stuff", ref _bStuff);
ser.Sync("hmp0_delay", ref _hmp0Delay);
ser.Sync("hmp0_val", ref _hmp0Val);
ser.Sync("hmp1_delay", ref _hmp1Delay);
ser.Sync("hmp1_val", ref _hmp1Val);
ser.Sync("PRG0_delay", ref _prg0Delay);
ser.Sync("PRG1_delay", ref _prg1Delay);
ser.Sync("PRG0_val", ref _prg0Val);
ser.Sync("PRG1_val", ref _prg1Val);
ser.Sync("Ticks", ref _doTicks);
ser.Sync("VBlankDelay", ref _vblankDelay);
ser.Sync("VBlankValue", ref _vblankValue);
// some of these things weren't in the state because they weren't needed if
// states were always taken at frame boundaries
ser.Sync("capChargeStart", ref _capChargeStart);
ser.Sync("capCharging", ref _capCharging);
ser.Sync("vblankEnabled", ref _vblankEnabled);
ser.Sync("vsyncEnabled", ref _vsyncEnabled);
ser.Sync("CurrentScanLine", ref _currentScanLine);
ser.Sync("scanlinebuffer", ref _scanlinebuffer, false);
ser.Sync("AudioClocks", ref AudioClocks);
ser.Sync("FrameStartCycles", ref _frameStartCycles);
ser.Sync("FrameEndCycles", ref _frameEndCycles);
ser.BeginSection("Player0");
_player0.SyncState(ser);
ser.EndSection();
ser.BeginSection("Player1");
_player1.SyncState(ser);
ser.EndSection();
_playField.SyncState(ser);
ser.EndSection();
}
}
}