misc code cleanups in Atari 2600

This commit is contained in:
adelikat 2017-04-24 10:09:17 -05:00
parent 3dd5478efd
commit 2964585401
26 changed files with 177 additions and 306 deletions

View File

@ -11,8 +11,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
"Atari2600Hawk",
"Micro500, adelikat, natt",
isPorted: false,
isReleased: true
)]
isReleased: true)]
[ServiceNotApplicable(typeof(ISaveRam), typeof(IDriveLight))]
public partial class Atari2600 : IEmulator, IStatable, IDebuggable, IInputPollable,
IRegionable, ICreateGameDBEntries, ISettable<Atari2600.A2600Settings, Atari2600.A2600SyncSettings>
@ -64,18 +63,15 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.Register<ISoundProvider>(_dcfilter);
}
public IEmulatorServiceProvider ServiceProvider { get; private set; }
public IEmulatorServiceProvider ServiceProvider { get; }
public DisplayType Region
{
get { return _pal ? DisplayType.PAL : Common.DisplayType.NTSC; }
}
public DisplayType Region => _pal ? DisplayType.PAL : DisplayType.NTSC;
public string SystemId => "A26";
public string BoardName => _mapper.GetType().Name;
public CoreComm CoreComm { get; private set; }
public CoreComm CoreComm { get; }
public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } }
@ -117,7 +113,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_islag = false;
}
public void Dispose() { }
public void Dispose()
{
}
private static bool DetectPal(GameInfo game, byte[] rom)
{

View File

@ -7,9 +7,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
private readonly Atari2600 _core;
public byte DDRa = 0x00;
public byte DDRb = 0x00;
public byte outputA = 0x00;
private byte DDRa = 0x00;
private byte DDRb = 0x00;
private byte outputA = 0x00;
public TimerData Timer;
@ -79,12 +79,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
return Timer.Value;
}
// TODO: fix this to match real behaviour
// This is an undocumented instruction whose behaviour is more dynamic then indicated here
if ((registerAddr & 0x5) == 0x5)
{
// Read interrupt flag
if (Timer.InterruptFlag) //Timer.InterruptEnabled && )
if (Timer.InterruptFlag) // Timer.InterruptEnabled && )
{
return 0xC0;
}
@ -118,7 +119,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Write to Timer/1
Timer.PrescalerShift = 0;
Timer.Value = value;
Timer.PrescalerCount = 0;// 1 << Timer.PrescalerShift;
Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift;
Timer.InterruptFlag = false;
}
else if (registerAddr == 0x05)
@ -126,7 +127,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Write to Timer/8
Timer.PrescalerShift = 3;
Timer.Value = value;
Timer.PrescalerCount = 0;// 1 << Timer.PrescalerShift;
Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift;
Timer.InterruptFlag = false;
}
else if (registerAddr == 0x06)
@ -134,7 +135,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Write to Timer/64
Timer.PrescalerShift = 6;
Timer.Value = value;
Timer.PrescalerCount = 0;// 1 << Timer.PrescalerShift;
Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift;
Timer.InterruptFlag = false;
}
else if (registerAddr == 0x07)
@ -142,7 +143,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Write to Timer/1024
Timer.PrescalerShift = 10;
Timer.Value = value;
Timer.PrescalerCount = 0;// 1 << Timer.PrescalerShift;
Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift;
Timer.InterruptFlag = false;
}
}
@ -224,7 +225,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.Sync("interruptEnabled", ref InterruptEnabled);
ser.Sync("interruptFlag", ref InterruptFlag);
}
}
}
}

View File

@ -6,15 +6,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
public Atari2600 Core { get; set; }
public virtual bool HasCartRam
{
get { return false; }
}
public virtual bool HasCartRam => false;
public virtual ByteBuffer CartRam
{
get { return new ByteBuffer(0); }
}
public virtual ByteBuffer CartRam => new ByteBuffer(0);
public virtual byte ReadMemory(ushort addr)
{
@ -36,13 +30,21 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
Core.BasePokeMemory(addr, value);
}
public virtual void SyncState(Serializer ser) { }
public virtual void SyncState(Serializer ser)
{
}
public virtual void Dispose() { }
public virtual void Dispose()
{
}
public virtual void ClockCpu() { }
public virtual void ClockCpu()
{
}
public virtual void HardReset() { }
public virtual void HardReset()
{
}
// THis is here purely for mapper 3E because it needs the 13th bit to determine bankswitching (but only receives the first 12 on read memory)
public bool Bit13 { get; set; }

View File

@ -1,5 +1,4 @@
using System.Linq;
using BizHawk.Common;
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{

View File

@ -1,5 +1,4 @@
using System.Linq;
using BizHawk.Common;
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{

View File

@ -1,5 +1,4 @@
using System.Linq;
using BizHawk.Common;
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{

View File

@ -27,15 +27,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private bool _hasRam;
private ByteBuffer _ram = new ByteBuffer(256 * 1024); // Up to 256k
public override bool HasCartRam
{
get { return true; }
}
public override bool HasCartRam => true;
public override ByteBuffer CartRam
{
get { return _ram; }
}
public override ByteBuffer CartRam => _ram;
public override void SyncState(Serializer ser)
{

View File

@ -56,7 +56,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private int _sliceLow;
private int _sliceMiddle;
private byte[] _romImage = null;
private byte[] _romImage;
private byte[] RomImage
{
get
@ -67,14 +67,14 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Supported file sizes are 32/64/128K, which are duplicated if necessary
_romImage = new byte[131072];
if(Core.Rom.Length < 65536)
if (Core.Rom.Length < 65536)
{
for (int i = 0; i < 4; i++)
{
Array.Copy(Core.Rom, 0, _romImage, 32768 * i, 32768);
}
}
else if(Core.Rom.Length < 131072)
else if (Core.Rom.Length < 131072)
{
for (int i = 0; i < 2; i++)
{
@ -87,15 +87,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
}
public override bool HasCartRam
{
get { return true; }
}
public override bool HasCartRam => true;
public override ByteBuffer CartRam
{
get { return _ram; }
}
public override ByteBuffer CartRam => _ram;
public override void Dispose()
{
@ -121,7 +115,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
base.SyncState(ser);
}
public override void HardReset()
{
_ram = new ByteBuffer(32768);
@ -169,18 +162,20 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else if (addr < 0x2000) // 256B region from 0x1f00 - 0x1fff
{
val = RomImage[(addr & 0xff) + (RomImage.Length - 256)];
if (((_lastData & 0xe0) == 0x60) && ((_lastAddress >= 0x1000) ||
(_lastAddress < 0x200)) && !peek)
if ((_lastData & 0xe0) == 0x60 && (_lastAddress >= 0x1000 ||
_lastAddress < 0x200) && !peek)
{
_sliceHigh = (_sliceHigh & 0xf0ff) | ((addr & 0x8) << 8) |
((addr & 0x70) << 4);
}
}
if (!peek)
{
_lastData = val;
_lastAddress = (ushort)(addr & 0x1fff);
}
return val;
}
@ -228,7 +223,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else if (addr < 0x2000 && !poke) // 256B region at 0x1f00 - 0x1fff
{
if (((_lastData & 0xe0) == 0x60) &&
((_lastAddress >= 0x1000) || (_lastAddress < 0x200)) && !poke)
(_lastAddress >= 0x1000 || (_lastAddress < 0x200)) && !poke)
{
_sliceHigh = (_sliceHigh & 0xf0ff) | ((addr & 0x8) << 8) |
((addr & 0x70) << 4);
@ -304,6 +299,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_sliceMiddle = _sliceMiddle ^ 0x1000;
}
}
// Zero-page hotspots for upper page
// 0xf4, 0xf6, 0xfc, 0xfe for ROM
// 0xf5, 0xf7, 0xfd, 0xff for RAM

View File

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using BizHawk.Common;
/**
This is the cartridge class for Arcadia (aka Starpath) Supercharger
@ -43,9 +41,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private ByteBuffer _superChargerImage = new ByteBuffer(8192);
private IntBuffer _imageOffsets = new IntBuffer(2);
private bool _writePending = false;
private int _distinctAccesses = 0;
private bool _writeEnabled = false;
private bool _writePending;
private int _distinctAccesses;
private bool _writeEnabled;
private byte _dataHoldRegister;
private byte _numberOfLoadImages;
private ByteBuffer _loadedImages;
@ -60,7 +58,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// TODO: clean this stuff up
/*****************************************/
int size = Core.Rom.Length;
_size = Core.Rom.Length < 8448 ? 8448 : Core.Rom.Length; //8448 or Rom size, whichever is bigger
_size = Core.Rom.Length < 8448 ? 8448 : Core.Rom.Length; // 8448 or Rom size, whichever is bigger
_numberOfLoadImages = (byte)(_size / 8448);
@ -75,9 +73,10 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
for (int i = size; i < _size; i++)
{
_loadedImages[i] = DefaultHeader[i];
_loadedImages[i] = _defaultHeader[i];
}
}
/*****************************************/
InitializeRom();
@ -86,7 +85,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
#region SuperCharger Data
private readonly byte[] DummyRomCode = {
private readonly byte[] _dummyRomCode =
{
0xa5, 0xfa, 0x85, 0x80, 0x4c, 0x18, 0xf8, 0xff,
0xff, 0xff, 0x78, 0xd8, 0xa0, 0x00, 0xa2, 0x00,
0x94, 0x00, 0xe8, 0xd0, 0xfb, 0x4c, 0x50, 0xf8,
@ -126,7 +126,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
0xfa, 0x00, 0xcd, 0xf8, 0xff, 0x4c
};
private readonly byte[] DefaultHeader = {
private readonly byte[] _defaultHeader =
{
0xac, 0xfa, 0x0f, 0x18, 0x62, 0x00, 0x24, 0x02,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
@ -163,15 +164,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
#endregion
public override bool HasCartRam
{
get { return true; }
}
public override bool HasCartRam => true;
public override ByteBuffer CartRam
{
get { return _superChargerImage; }
}
public override ByteBuffer CartRam => _superChargerImage;
public override void HardReset()
{
@ -235,18 +230,26 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private byte ReadMem(ushort addr, bool peek)
{
if (addr < 0x1000) { if (peek) { return base.PeekMemory(addr); } else { return base.ReadMemory(addr); } }
if (addr < 0x1000)
{
if (peek)
{
return base.PeekMemory(addr);
}
return base.ReadMemory(addr);
}
/*---------------------------*/
if (addr == 0x1850 && _imageOffsets[1] == (3 << 11))
if (addr == 0x1850 && _imageOffsets[1] == 3 << 11)
{
LoadIntoRam(Core.MemoryDomains["System Bus"].PeekByte(0x80)); // Get load that's being accessed (BIOS places load number at 0x80) // TODO: a better way to do this
return _superChargerImage[(addr & 0x7FF) + _imageOffsets[1]];
}
if (_writePending && // Cancel any pending write if more than 5 distinct accesses have occurred // TODO: Modify to handle when the distinct counter wraps around...
(Core.DistinctAccessCount > _distinctAccesses + 5))
if (_writePending // Cancel any pending write if more than 5 distinct accesses have occurred // TODO: Modify to handle when the distinct counter wraps around...
&& Core.DistinctAccessCount > _distinctAccesses + 5)
{
_writePending = false;
}
@ -263,10 +266,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
_writePending = false;
BankConfiguration(_dataHoldRegister);
}
else if (_writeEnabled && _writePending &&
Core.DistinctAccessCount == (_distinctAccesses + 5))
Core.DistinctAccessCount == _distinctAccesses + 5)
{
if ((addr & 0x800) == 0)
{
@ -315,6 +317,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_distinctAccesses = Core.DistinctAccessCount;
_writePending = true;
}
// Is the bank configuration hotspot being accessed?
else if (!poke && (addr & 0x1FFF) == 0x1FF8)
{
@ -362,10 +365,10 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// The scrom.asm code checks a value at offset 109 as follows:
// 0xFF -> do a complete jump over the SC BIOS progress bars code
// 0x00 -> show SC BIOS progress bars as normal
DummyRomCode[109] = (byte)(Core.SyncSettings.FastScBios ? 0xFF : 0x00);
_dummyRomCode[109] = (byte)(Core.SyncSettings.FastScBios ? 0xFF : 0x00);
// Stella does this, but randomness is bad for determinacy! Hopefully we don't really need it
//ourDummyROMCode[281] = mySystem->randGenerator().next();
// ourDummyROMCode[281] = mySystem->randGenerator().next();
// Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam
for (int i = 0; i < 2048; i++)
@ -374,9 +377,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
// Copy the "dummy" Supercharger BIOS code into the ROM area
for (int i = 0; i < DummyRomCode.Length; i++)
for (int i = 0; i < _dummyRomCode.Length; i++)
{
_superChargerImage[(3 << 11) + i] = DummyRomCode[i];
_superChargerImage[(3 << 11) + i] = _dummyRomCode[i];
}
// Finally set 6502 vectors to point to initial load code at 0xF80A of BIOS

View File

@ -1,6 +1,5 @@
using BizHawk.Common;
using BizHawk.Common.NumberExtensions;
using System;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
@ -182,10 +181,10 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private ByteBuffer _ram = new ByteBuffer(2048);
private int _bank4K = 3; // On Start up, controller port is all 1's, so start on the last bank, flags enabled
private bool _disableRam = true;
private bool _writeMode = false;
private int _column = 0;
public bool _func_key = false;
public bool _shift_key = false;
private bool _writeMode;
private int _column;
private bool _funcKey;
private bool _shiftKey;
public override void Dispose()
{
@ -200,74 +199,67 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_disableRam = true;
_writeMode = true;
_column = 0;
_func_key = false;
_shift_key = false;
_funcKey = false;
_shiftKey = false;
base.HardReset();
}
public override void SyncState(Serializer ser)
{
// TODO
ser.Sync("cartRam", ref _ram);
ser.Sync("bank4k", ref _bank4K);
ser.Sync("column", ref _column);
ser.Sync("disableRam", ref _disableRam);
ser.Sync("writeMode", ref _writeMode);
ser.Sync("FuncKey", ref _func_key);
ser.Sync("ShiftKey", ref _shift_key);
ser.Sync("FuncKey", ref _funcKey);
ser.Sync("ShiftKey", ref _shiftKey);
base.SyncState(ser);
}
private byte ReadMem(ushort addr, bool peek)
{
// A unique feature of the keyboard is that it changes the operation of inputs 0-3
// by holding them high in the no-button-pressed state.
// However exposing this behaviour to the rest of the system would be overly cunmbersome
// so instead we bypass these cases here
if ((addr & 0x000F) == 8 && (addr & 0x1080)==0 && addr<1000)
if ((addr & 0x000F) == 8 && (addr & 0x1080) == 0 && addr < 1000)
{
// if func key pressed
if (_func_key == true)
if (_funcKey)
{
return 0x80;
}
else
{
return 0;
}
return 0;
}
else if ((addr & 0x000F) == 9 && (addr & 0x1080) == 0 && addr < 1000)
if ((addr & 0x000F) == 9 && (addr & 0x1080) == 0 && addr < 1000)
{
return 0x80;
}
else if ((addr & 0x000F) == 0xA && (addr & 0x1080) == 0 && addr < 1000)
if ((addr & 0x000F) == 0xA && (addr & 0x1080) == 0 && addr < 1000)
{
return 0x80;
}
else if ((addr & 0x000F) == 0xB && (addr & 0x1080) == 0 && addr < 1000)
if ((addr & 0x000F) == 0xB && (addr & 0x1080) == 0 && addr < 1000)
{
// if shift key pressed
if (_shift_key == true)
if (_shiftKey)
{
return 0x80;
}
else
{
return 0;
}
return 0;
}
else if (addr < 0x1000)
if (addr < 0x1000)
{
return base.ReadMemory(addr);
}
// Lower 2K is always the first 2K of the ROM bank
// Upper 2K is also Rom if ram is enabled
@ -298,19 +290,17 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private void WriteMem(ushort addr, byte value, bool poke)
{
//Mimicking the 6532 logic for accesing port A, for testing
// Mimicking the 6532 logic for accesing port A, for testing
var isPortA = false;
if ((addr & 0x0200) == 0) // If the RS bit is not set, this is a ram write
{
}
else
{
// If bit 0x0010 is set, and bit 0x0004 is set, this is a timer write
if ((addr & 0x0014) == 0x0014)
{
}
// If bit 0x0004 is not set, bit 0x0010 is ignored and
@ -321,7 +311,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
if (registerAddr == 0x00)
{
if (addr != 640 && addr>=0x280) // register addresses are only above 0x280
if (addr != 640 && addr >= 0x280) // register addresses are only above 0x280
{
// Write Output reg A
isPortA = true;
@ -330,24 +320,23 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
}
if (addr == 0x280 && !poke) //Stella uses only 280
//if (isPortA && !poke)
if (addr == 0x280 && !poke) // Stella uses only 280
////if (isPortA && !poke)
{
var bit5 = value.Bit(5);
var bit4 = value.Bit(4);
//D5 RAM direction. (high = write, low = read)
//0 -> enable RAM writing (if D4 = 1)
//D4 = RAM enable: 1 = disable RAM, 0 = enable RAM
// D5 RAM direction. (high = write, low = read)
// 0 -> enable RAM writing (if D4 = 1)
// D4 = RAM enable: 1 = disable RAM, 0 = enable RAM
_disableRam = bit4;
//_writeMode = bit5 || bit4; // ?? Am I interpretting this correctly?
_writeMode = (value & 0x30) == 0x20;
_bank4K = value & 0x03;
//D6 = 1 -> increase key column (0 to 9)
//D5 = 1 -> reset key column to 0 (if D4 = 0)
// D6 = 1 -> increase key column (0 to 9)
// D5 = 1 -> reset key column to 0 (if D4 = 0)
if (bit5 && !bit4)
{
_column = 0;
@ -366,15 +355,16 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_ram[addr & 0x7FF] = value;
}
}
if (addr<0x1000) {
if (addr < 0x1000)
{
base.WriteMemory(addr, value);
}
}
public override void WriteMemory(ushort addr, byte value)
{
WriteMem(addr, value, false);
WriteMem(addr, value, false);
}
public override void PokeMemory(ushort addr, byte value)

View File

@ -15,20 +15,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
Example games:
Magicard
*/
internal class mCV: MapperBase
internal class mCV : MapperBase
{
private ByteBuffer _ram = new ByteBuffer(1024);
public override bool HasCartRam
{
get { return true; }
}
public override bool HasCartRam => true;
public override ByteBuffer CartRam
{
get { return _ram; }
}
public override ByteBuffer CartRam => _ram;
public override void SyncState(Serializer ser)
{
@ -44,8 +37,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public override void Dispose()
{
base.Dispose();
_ram.Dispose();
base.Dispose();
}
public override byte ReadMemory(ushort addr)

View File

@ -225,6 +225,10 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
*/
internal class mDPC : MapperBase
{
// Table for computing the input bit of the random number generator's
// shift register (it's the NOT of the EOR of four bits)
private readonly byte[] _randomInputBits = { 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1 };
private IntBuffer _counters = new IntBuffer(8);
private ByteBuffer _tops = new ByteBuffer(8);
private ByteBuffer _flags = new ByteBuffer(8);
@ -237,17 +241,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private float _fractionalClocks; // Fractional DPC music OSC clocks unused during the last update
private byte[] _dspData;
public byte[] DspData
{
get
{
return _dspData ?? (_dspData = Core.Rom.Skip(8192).Take(2048).ToArray());
}
}
// Table for computing the input bit of the random number generator's
// shift register (it's the NOT of the EOR of four bits)
private readonly byte[] _randomInputBits = { 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1 };
public byte[] DspData => _dspData ?? (_dspData = Core.Rom.Skip(8192).Take(2048).ToArray());
public override void Dispose()
{

View File

@ -29,13 +29,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private float _fractionalClocks; // Fractional DPC music OSC clocks unused during the last update
private byte[] _dspData;
public byte[] DspData
{
get
{
return _dspData ?? (_dspData = Core.Rom.Skip(8192).Take(2048).ToArray());
}
}
public byte[] DspData => _dspData ?? (_dspData = Core.Rom.Skip(8192).Take(2048).ToArray());
// Table for computing the input bit of the random number generator's
// shift register (it's the NOT of the EOR of four bits)

View File

@ -60,15 +60,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_ram.Dispose();
}
public override bool HasCartRam
{
get { return true; }
}
public override bool HasCartRam => true;
public override ByteBuffer CartRam
{
get { return _ram; }
}
public override ByteBuffer CartRam => _ram;
private byte ReadMem(ushort addr, bool peek)
{
@ -100,12 +94,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
if (addr < 0x1900) // Ram 1 Write port
{
return _ram[RamBank1Offset + (_rambank1Toggle * 0x100) + (addr & 0xFF)] = 0xFF; // Reading from the 256b write port @1800 riggers an unwanted write
}
if (addr < 0x1A00) // Ram 1 Read port
{
return _ram[(RamBank1Offset + _rambank1Toggle * 0x100) + (addr & 0xFF)];
return _ram[RamBank1Offset + (_rambank1Toggle * 0x100) + (addr & 0xFF)];
}
if (addr < 0x2000)

View File

@ -12,15 +12,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private int _bank4k;
private ByteBuffer _ram = new ByteBuffer(128);
public override bool HasCartRam
{
get { return true; }
}
public override bool HasCartRam => true;
public override ByteBuffer CartRam
{
get { return _ram; }
}
public override ByteBuffer CartRam => _ram;
public override void SyncState(Serializer ser)
{

View File

@ -11,15 +11,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private int _bank4k;
private ByteBuffer _ram = new ByteBuffer(128);
public override bool HasCartRam
{
get { return true; }
}
public override bool HasCartRam => true;
public override ByteBuffer CartRam
{
get { return _ram; }
}
public override ByteBuffer CartRam => _ram;
public override void SyncState(Serializer ser)
{
@ -58,7 +52,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_ram[(addr & 0x7F)] = 0xFF; // Reading from the write port triggers an unwanted write of open bus
return 0xFF; // 0xFF is used for deterministic emulation, in reality it would be a random value based on pins being high or low
}
else if (addr < 0x1100)
if (addr < 0x1100)
{
return _ram[(addr & 0x7F)];
}

View File

@ -11,15 +11,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private int _bank4k;
private ByteBuffer _ram = new ByteBuffer(128);
public override bool HasCartRam
{
get { return true; }
}
public override bool HasCartRam => true;
public override ByteBuffer CartRam
{
get { return _ram; }
}
public override ByteBuffer CartRam => _ram;
public override void SyncState(Serializer ser)
{

View File

@ -11,15 +11,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private int _bank_4K;
private ByteBuffer _ram = new ByteBuffer(128);
public override bool HasCartRam
{
get { return true; }
}
public override bool HasCartRam => true;
public override ByteBuffer CartRam
{
get { return _ram; }
}
public override ByteBuffer CartRam => _ram;
public override void HardReset()
{

View File

@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
internal class mF8_sega : MapperBase
{
private int _bank4K=1;
private int _bank4K = 1;
public override void SyncState(Serializer ser)
{

View File

@ -13,15 +13,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private int _bank4k;
private ByteBuffer _ram = new ByteBuffer(256);
public override bool HasCartRam
{
get { return true; }
}
public override bool HasCartRam => true;
public override ByteBuffer CartRam
{
get { return _ram; }
}
public override ByteBuffer CartRam => _ram;
public override void SyncState(Serializer ser)
{

View File

@ -1,6 +1,4 @@
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
/*
FE (Activision special)

View File

@ -9,10 +9,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
internal class mSB : MapperBase
{
private int _bank4K;
private int myStartBank
{
get { return (Core.Rom.Length >> 12) - 1; }
}
private int myStartBank => (Core.Rom.Length >> 12) - 1;
public override void SyncState(Serializer ser)
{
base.SyncState(ser);

View File

@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
#region palette
const int BackColor = unchecked((int)0xff000000);
private const int BackColor = unchecked((int)0xff000000);
static TIA()
{
@ -230,22 +230,15 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// in all cases, the TIA has 228 clocks per scanline
// the NTSC TIA has a clock rate of 3579575hz
// the PAL/SECAM TIA has a clock rate of 3546894hz
private bool _pal;
public int NominalNumScanlines
{
get
{
return _pal ? 312 : 262;
}
}
public int NominalNumScanlines => _pal ? 312 : 262;
public void GetFrameRate(out int num, out int den)
{
// TODO when sound timing is made exact:
// NTSC refclock is actually 315 / 88 mhz
//3546895
// 3546895
int clockrate = _pal ? 3546895 : 3579545;
int clocksperframe = 228 * NominalNumScanlines;
@ -347,20 +340,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_palette = _pal ? secam ? SECAMPalette : PALPalette : NTSCPalette;
}
public int CurrentScanLine
{
get { return _CurrentScanLine; }
}
public int CurrentScanLine => _CurrentScanLine;
public bool IsVBlank
{
get { return _vblankEnabled; }
}
public bool IsVBlank => _vblankEnabled;
public bool IsVSync
{
get { return _vsyncEnabled; }
}
public bool IsVSync => _vsyncEnabled;
/// <summary>
/// a count of lines emulated; incremented by the TIA but not used by it
@ -382,19 +366,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
return 320;
}
return 275; // 275 comes from NTSC specs and the actual pixel clock of a 2600 TIA
return 275; // 275 comes from NTSC specs and the actual pixel clock of a 2600 TIA
}
}
public int VirtualHeight
{
get { return BufferHeight; }
}
public int VirtualHeight => BufferHeight;
public int BufferWidth
{
get { return ScreenWidth; }
}
public int BufferWidth => ScreenWidth;
public int BufferHeight
{
@ -407,10 +385,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
}
public int BackgroundColor
{
get { return _core.Settings.BackgroundColor.ToArgb(); }
}
public int BackgroundColor => _core.Settings.BackgroundColor.ToArgb();
public int[] GetVideoBuffer()
{
@ -493,12 +468,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_vblankEnabled = (vblank_value & 0x02) != 0;
vblank_delay = 0;
}
}
//delay latch to new playfield register
// delay latch to new playfield register
if (pf0_updater == true)
{
pf0_delay_clock++;
@ -527,7 +499,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
}
//delay latch to missile enable
// delay latch to missile enable
if (enam0_delay > 0)
{
enam0_delay++;
@ -536,7 +508,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
enam0_delay = 0;
_player0.Missile.Enabled = enam0_val;
}
}
if (enam1_delay > 0)
@ -547,7 +518,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
enam1_delay = 0;
_player1.Missile.Enabled = enam1_val;
}
}
// delay latch to ball enable
@ -559,7 +529,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
enamb_delay = 0;
_ball.Enabled = enamb_val;
}
}
// delay latch to player graphics registers
@ -572,7 +541,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_player0.Grp = prg0_val;
_player1.Dgrp = _player1.Grp;
}
}
if (prg1_delay > 0)
@ -587,7 +555,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// TODO: Find a game that uses this functionality and test it
_ball.Denabled = _ball.Enabled;
}
}
// HMP write delay
@ -615,7 +582,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
if (_hsyncCnt <= 0)
{
_core.Cpu.RDY = true;
}
// Assume we're on the left side of the screen for now
@ -654,7 +620,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
collisions |= CXPF;
}
// ---- Player 0 ----
collisions |= _player0.Tick() ? CXP0 : (byte)0x00;
@ -749,9 +714,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
if (_playField.Priority && (collisions & CXPF) != 0 && _core.Settings.ShowPlayfield)
{
pixelColor = _palette[_playField.PfColor];
}
// Handle vblank
@ -799,18 +762,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
}
// Handle HMOVE
if (_hmove.HMoveEnabled)
{
if (_hmove.DecCntEnabled)
{
// Actually do stuff only evey 4 pulses
if (_hmove.HMoveCnt == 0)
{
@ -1032,7 +988,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
}
// do the audio sampling
if (_hsyncCnt == 36 || _hsyncCnt == 148)
{
@ -1195,9 +1150,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
mask = 0x7f;
}
//some bits of the databus will be undriven when a read call is made. Our goal here is to sort out what
// some bits of the databus will be undriven when a read call is made. Our goal here is to sort out what
// happens to the undriven pins. Most of the time, they will be in whatever state they were when previously
//assigned in some other bus access, so let's go with that.
// assigned in some other bus access, so let's go with that.
coll += (byte)(mask & bus_state);
if (!peek) bus_state = (int)coll;
@ -1626,15 +1581,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
throw new NotSupportedException("Async is not available");
}
public bool CanProvideAsync
{
get { return false; }
}
public bool CanProvideAsync => false;
public SyncSoundMode SyncMode
{
get { return SyncSoundMode.Sync; }
}
public SyncSoundMode SyncMode => SyncSoundMode.Sync;
public void SetSyncMode(SyncSoundMode mode)
{

View File

@ -15,32 +15,31 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public byte Collisions;
// Resp commands do not trigger start signals for main copies. We need to model this
public int Draw_To;
public byte ScanCnt;
public bool ScanCntInit;
public int Start_Signal;
public int Signal_Reached;
private int Draw_To;
private byte ScanCnt;
private bool ScanCntInit;
private int Start_Signal;
private int Signal_Reached;
public bool Tick()
{
var result = false;
if (ScanCntInit==true)
if (ScanCntInit == true)
{
if (ScanCnt < (1 << Size) && Enabled && !ResetToPlayer)
{
result = true;
ScanCnt++;
} else
}
else
{
ScanCntInit = false;
}
}
/*
// At hPosCnt == 0, start drawing the missile, if enabled
if (HPosCnt < (1 << Size))
@ -122,8 +121,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Counter loops at 160
HPosCnt %= 160;
//our goal here is to send a start signal 4 clocks before drawing begins. The properly emulates
//drawing on a real TIA
// our goal here is to send a start signal 4 clocks before drawing begins. The properly emulates
// drawing on a real TIA
if (HPosCnt == 156 || HPosCnt == 12 || HPosCnt == 28 || HPosCnt == 60)
{
Start_Signal = HPosCnt;

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
public int Start_Signal;
public int Signal_Reached;
private int Start_Signal;
private int Signal_Reached;
public bool Tick()
{
@ -114,7 +114,7 @@ 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 (Start_Signal == 160)
{
ScanCnt = 0;
Start_Signal++;
@ -156,11 +156,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Counter loops at 160
HPosCnt %= 160;
//our goal here is to send a start signal 4 clocks before drawing begins. This properly emulates
//drawing on a real TIA
if (HPosCnt==156 || HPosCnt==12 || HPosCnt==28 || HPosCnt==60)
// our goal here is to send a start signal 4 clocks before drawing begins. This properly emulates
// drawing on a real TIA
if (HPosCnt == 156 || HPosCnt == 12 || HPosCnt == 28 || HPosCnt == 60)
{
Start_Signal = HPosCnt-1;
Start_Signal = HPosCnt - 1;
Signal_Reached = HPosCnt + 5;
}
@ -168,6 +168,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
Start_Signal++;
}
return result;
}

View File

@ -47,5 +47,6 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SGX/@EntryIndexedValue">SGX</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SNES/@EntryIndexedValue">SNES</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TI/@EntryIndexedValue">TI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TIA/@EntryIndexedValue">TIA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=MethodPropertyEvent/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String></wpf:ResourceDictionary>