2011-01-21 03:59:50 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2011-01-11 02:55:51 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk
|
|
|
|
|
{
|
2011-07-30 20:49:36 +00:00
|
|
|
|
public interface IEmulator : IDisposable
|
|
|
|
|
{
|
|
|
|
|
IVideoProvider VideoProvider { get; }
|
|
|
|
|
ISoundProvider SoundProvider { get; }
|
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
|
|
|
|
ISyncSoundProvider SyncSoundProvider { get; }
|
|
|
|
|
/// <summary></summary>
|
|
|
|
|
/// <returns>false if core doesn't support async sound</returns>
|
|
|
|
|
bool StartAsyncSound();
|
|
|
|
|
void EndAsyncSound();
|
2011-07-30 20:49:36 +00:00
|
|
|
|
|
|
|
|
|
ControllerDefinition ControllerDefinition { get; }
|
|
|
|
|
IController Controller { get; set; }
|
|
|
|
|
|
2012-09-20 19:52:47 +00:00
|
|
|
|
// note that most cores expect you to call SoundProvider.GetSamples() after each FrameAdvance()
|
|
|
|
|
// please do this, even when rendersound = false
|
2012-09-20 20:00:14 +00:00
|
|
|
|
void FrameAdvance(bool render, bool rendersound = true);
|
2011-07-30 20:49:36 +00:00
|
|
|
|
|
|
|
|
|
int Frame { get; }
|
|
|
|
|
int LagCount { get; set; }
|
|
|
|
|
bool IsLagFrame { get; }
|
|
|
|
|
string SystemId { get; }
|
2012-10-03 15:31:04 +00:00
|
|
|
|
/// <summary>if you want to set this, look in the emulator's constructor or Load() method</summary>
|
|
|
|
|
bool DeterministicEmulation { get; }
|
2011-07-30 20:49:36 +00:00
|
|
|
|
|
2012-09-04 07:09:00 +00:00
|
|
|
|
/// <summary>
|
2012-09-14 22:28:38 +00:00
|
|
|
|
/// return a copy of the saveram. editing it won't do you any good unless you later call StoreSaveRam()
|
2012-09-04 07:09:00 +00:00
|
|
|
|
/// </summary>
|
2012-09-14 22:28:38 +00:00
|
|
|
|
byte[] ReadSaveRam();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// store new saveram to the emu core. the data should be the same size as the return from ReadSaveRam()
|
|
|
|
|
/// </summary>
|
|
|
|
|
void StoreSaveRam(byte[] data);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// reset saveram to a standard initial state
|
|
|
|
|
/// </summary>
|
|
|
|
|
void ClearSaveRam();
|
|
|
|
|
|
|
|
|
|
|
2011-07-30 20:49:36 +00:00
|
|
|
|
bool SaveRamModified { get; set; }
|
|
|
|
|
|
|
|
|
|
void ResetFrameCounter();
|
|
|
|
|
void SaveStateText(TextWriter writer);
|
|
|
|
|
void LoadStateText(TextReader reader);
|
|
|
|
|
void SaveStateBinary(BinaryWriter writer);
|
|
|
|
|
void LoadStateBinary(BinaryReader reader);
|
|
|
|
|
byte[] SaveStateBinary();
|
2011-01-21 03:59:50 +00:00
|
|
|
|
|
2011-08-04 03:20:54 +00:00
|
|
|
|
// Arbitrary extensible core comm mechanism
|
2011-06-11 22:15:08 +00:00
|
|
|
|
CoreInputComm CoreInputComm { get; set; }
|
|
|
|
|
CoreOutputComm CoreOutputComm { get; }
|
2011-02-21 09:48:53 +00:00
|
|
|
|
|
2011-07-30 20:49:36 +00:00
|
|
|
|
// ----- Client Debugging API stuff -----
|
|
|
|
|
IList<MemoryDomain> MemoryDomains { get; }
|
2012-09-11 17:37:17 +00:00
|
|
|
|
// this MUST BE the same as MemoryDomains[0], else DRAGONS
|
2011-07-30 20:49:36 +00:00
|
|
|
|
MemoryDomain MainMemory { get; }
|
|
|
|
|
}
|
2011-01-21 03:59:50 +00:00
|
|
|
|
|
2011-07-30 20:49:36 +00:00
|
|
|
|
public class MemoryDomain
|
|
|
|
|
{
|
|
|
|
|
public readonly string Name;
|
|
|
|
|
public readonly int Size;
|
|
|
|
|
public readonly Endian Endian;
|
2011-01-21 03:59:50 +00:00
|
|
|
|
|
2011-07-30 20:49:36 +00:00
|
|
|
|
public readonly Func<int, byte> PeekByte;
|
|
|
|
|
public readonly Action<int, byte> PokeByte;
|
2011-08-03 02:13:42 +00:00
|
|
|
|
|
2011-07-30 20:49:36 +00:00
|
|
|
|
public MemoryDomain(string name, int size, Endian endian, Func<int, byte> peekByte, Action<int, byte> pokeByte)
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
Size = size;
|
|
|
|
|
Endian = endian;
|
|
|
|
|
PeekByte = peekByte;
|
|
|
|
|
PokeByte = pokeByte;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-04 00:20:36 +00:00
|
|
|
|
public MemoryDomain()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-30 20:49:36 +00:00
|
|
|
|
public MemoryDomain(MemoryDomain domain)
|
|
|
|
|
{
|
|
|
|
|
Name = domain.Name;
|
|
|
|
|
Size = domain.Size;
|
|
|
|
|
Endian = domain.Endian;
|
|
|
|
|
PeekByte = domain.PeekByte;
|
|
|
|
|
PokeByte = domain.PokeByte;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum Endian { Big, Little, Unknown }
|
|
|
|
|
|
|
|
|
|
public enum DisplayType { NTSC, PAL }
|
2011-01-11 02:55:51 +00:00
|
|
|
|
}
|