BizHawk/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs

91 lines
3.0 KiB
C#
Raw Normal View History

2012-03-07 00:40:20 +00:00
using System;
using System.Collections.Generic;
using System.IO;
namespace BizHawk
{
public partial class Atari2600 : IEmulator
2012-03-07 00:40:20 +00:00
{
public string SystemId { get { return "A26"; } }
2012-03-30 00:35:15 +00:00
public GameInfo game;
2012-03-07 00:40:20 +00:00
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public IVideoProvider VideoProvider { get { return tia; } }
public ISoundProvider SoundProvider { get { return tia; } }
2012-03-30 00:35:15 +00:00
2012-03-07 00:40:20 +00:00
public Atari2600(GameInfo game, byte[] rom)
{
var domains = new List<MemoryDomain>(1);
2012-03-21 02:57:26 +00:00
domains.Add(new MemoryDomain("Main RAM", 128, Endian.Little, addr => ram[addr & 127], (addr, value) => ram[addr & 127] = value));
2012-03-07 00:40:20 +00:00
memoryDomains = domains.AsReadOnly();
CoreOutputComm = new CoreOutputComm();
CoreInputComm = new CoreInputComm();
this.rom = rom;
2012-03-30 00:35:15 +00:00
this.game = game;
Console.WriteLine("Game uses mapper " + game.GetOptionsDict()["m"]);
2012-03-07 00:40:20 +00:00
HardReset();
}
public void ResetFrameCounter()
{
_frame = 0;
2012-03-07 00:40:20 +00:00
}
public static readonly ControllerDefinition Atari2600ControllerDefinition = new ControllerDefinition
{
Name = "Atari 2600 Basic Controller",
BoolButtons =
{
2012-03-22 06:33:28 +00:00
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Button",
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Button",
"Reset", "Select"
2012-03-07 00:40:20 +00:00
}
};
void SyncState(Serializer ser)
{
cpu.SyncState(ser);
ser.Sync("ram", ref ram, false);
ser.Sync("Lag", ref _lagcount);
ser.Sync("Frame", ref _frame);
ser.Sync("IsLag", ref _islag);
tia.SyncState(ser);
m6532.SyncState(ser);
2012-03-30 00:35:15 +00:00
mapper.SyncState(ser);
2012-03-07 00:40:20 +00:00
}
public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } }
public IController Controller { get; set; }
public int Frame { get { return _frame; } set { _frame = value; } }
public int LagCount { get { return _lagcount; } set { _lagcount = value; } }
public bool IsLagFrame { get { return _islag; } }
private bool _islag = true;
private int _lagcount = 0;
private int _frame = 0;
2012-03-07 00:40:20 +00:00
2012-09-04 07:09:00 +00:00
public byte[] ReadSaveRam { get { return new byte[0]; } }
2012-03-07 00:40:20 +00:00
public bool DeterministicEmulation { get; set; }
public bool SaveRamModified { get; set; }
public void SaveStateText(TextWriter writer) { SyncState(Serializer.CreateTextWriter(writer)); }
public void LoadStateText(TextReader reader) { SyncState(Serializer.CreateTextReader(reader)); }
public void SaveStateBinary(BinaryWriter bw) { SyncState(Serializer.CreateBinaryWriter(bw)); }
public void LoadStateBinary(BinaryReader br) { SyncState(Serializer.CreateBinaryReader(br)); }
public byte[] SaveStateBinary()
{
MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);
SaveStateBinary(bw);
bw.Flush();
return ms.ToArray();
}
2012-03-07 00:40:20 +00:00
private IList<MemoryDomain> memoryDomains;
public IList<MemoryDomain> MemoryDomains { get { return memoryDomains; } }
public MemoryDomain MainMemory { get { return memoryDomains[0]; } }
public void Dispose() { }
}
}