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
|
|
|
|
|
2013-11-04 01:39:19 +00:00
|
|
|
|
namespace BizHawk.Emulation.Common
|
2011-01-11 02:55:51 +00:00
|
|
|
|
{
|
2011-07-30 20:49:36 +00:00
|
|
|
|
public interface IEmulator : IDisposable
|
|
|
|
|
{
|
2013-11-06 02:15:29 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Video provider to the client
|
|
|
|
|
/// </summary>
|
2011-07-30 20:49:36 +00:00
|
|
|
|
IVideoProvider VideoProvider { get; }
|
2013-11-06 02:15:29 +00:00
|
|
|
|
|
2012-10-11 01:14:14 +00:00
|
|
|
|
/// <summary>
|
2013-11-06 02:15:29 +00:00
|
|
|
|
/// Sound provider for async operation. this is optional, and is only required after StartAsyncSound() is called and returns true
|
2012-10-11 01:14:14 +00:00
|
|
|
|
/// </summary>
|
2011-07-30 20:49:36 +00:00
|
|
|
|
ISoundProvider SoundProvider { get; }
|
2013-11-06 02:15:29 +00:00
|
|
|
|
|
2012-10-11 01:14:14 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// sound provider for sync operation. this is manditory
|
|
|
|
|
/// </summary>
|
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; }
|
2013-11-06 02:15:29 +00:00
|
|
|
|
|
2012-10-11 01:14:14 +00:00
|
|
|
|
/// <summary>start async operation. (on construct, sync operation is assumed).</summary>
|
|
|
|
|
/// <returns>false if core doesn't support async sound; SyncSoundProvider will continue to be used in that case</returns>
|
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
|
|
|
|
bool StartAsyncSound();
|
2012-10-11 01:14:14 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// end async operation, returning to sync operation. after this, all sound requests will go to the SyncSoundProvider
|
|
|
|
|
/// </summary>
|
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
|
|
|
|
void EndAsyncSound();
|
2011-07-30 20:49:36 +00:00
|
|
|
|
|
2013-11-06 02:15:29 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Defines all the possible inputs and types that the core can receive
|
|
|
|
|
/// </summary>
|
2011-07-30 20:49:36 +00:00
|
|
|
|
ControllerDefinition ControllerDefinition { get; }
|
|
|
|
|
IController Controller { get; set; }
|
|
|
|
|
|
2013-11-06 02:15:29 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
// note that (some?) cores expect you to call SoundProvider.GetSamples() after each FrameAdvance()
|
2012-09-20 19:52:47 +00:00
|
|
|
|
// please do this, even when rendersound = false
|
2013-11-06 02:15:29 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// </summary>
|
2012-09-20 20:00:14 +00:00
|
|
|
|
void FrameAdvance(bool render, bool rendersound = true);
|
2011-07-30 20:49:36 +00:00
|
|
|
|
|
2013-11-06 02:15:29 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The frame count
|
|
|
|
|
/// </summary>
|
2011-07-30 20:49:36 +00:00
|
|
|
|
int Frame { get; }
|
2013-11-06 02:15:29 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The lag count.
|
|
|
|
|
/// </summary>
|
2011-07-30 20:49:36 +00:00
|
|
|
|
int LagCount { get; set; }
|
2013-11-06 02:15:29 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// If the current frame is a lag frame.
|
|
|
|
|
/// All cores should define it the same, a lag frame is a frame in which input was not polled.
|
|
|
|
|
/// </summary>
|
2011-07-30 20:49:36 +00:00
|
|
|
|
bool IsLagFrame { get; }
|
2013-11-06 02:15:29 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The unique Id of the given core, for instance "NES"
|
|
|
|
|
/// </summary>
|
2011-07-30 20:49:36 +00:00
|
|
|
|
string SystemId { get; }
|
2013-11-06 02:15:29 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This flag is a contract with the client.
|
|
|
|
|
/// If true, the core agrees to behave in a completely deterministic manner,
|
|
|
|
|
/// Features like movie recording depend on this.
|
|
|
|
|
/// It is the client's responsibility to manage this flag.
|
|
|
|
|
/// If a core wants to implement non-deterministic features (like speed hacks, frame-skipping), it must be done only when this flag is false
|
|
|
|
|
/// if you want to set this, look in the emulator's constructor or Load() method
|
|
|
|
|
/// </summary>
|
2012-10-03 15:31:04 +00:00
|
|
|
|
bool DeterministicEmulation { get; }
|
2011-07-30 20:49:36 +00:00
|
|
|
|
|
2013-08-24 16:54:22 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// identifying information about a "mapper" or similar capability. null if no such useful distinction can be drawn
|
|
|
|
|
/// </summary>
|
|
|
|
|
string BoardName { get; }
|
|
|
|
|
|
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();
|
|
|
|
|
|
2013-11-06 02:15:29 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether or not Save ram has been modified since the last save
|
|
|
|
|
/// </summary>
|
2011-07-30 20:49:36 +00:00
|
|
|
|
bool SaveRamModified { get; set; }
|
|
|
|
|
|
2013-11-06 02:15:29 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resets the Frame and Lag counters, and any other similar counters a core might implement
|
|
|
|
|
/// </summary>
|
2013-11-03 16:29:51 +00:00
|
|
|
|
void ResetCounters();
|
2013-11-06 02:15:29 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Savestate handling methods
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="writer"></param>
|
2011-07-30 20:49:36 +00:00
|
|
|
|
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
|
|
|
|
|
2013-05-06 20:51:28 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// true if the core would rather give a binary savestate than a text one. both must function regardless
|
|
|
|
|
/// </summary>
|
|
|
|
|
bool BinarySaveStatesPreferred { get; }
|
|
|
|
|
|
2012-12-10 00:43:43 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// the corecomm module in use by this core.
|
|
|
|
|
/// </summary>
|
|
|
|
|
CoreComm CoreComm { get; }
|
2011-02-21 09:48:53 +00:00
|
|
|
|
|
2013-11-06 02:15:29 +00:00
|
|
|
|
///The list of all avaialble memory domains
|
|
|
|
|
/// A memory domain is a byte array that respresents a distinct part of the emulated system.
|
|
|
|
|
/// By convention the Main Memory is the 1st domain in the list
|
|
|
|
|
// All cores sould implement a System Bus domain that represents the standard "Open bus" range for that system,
|
|
|
|
|
/// and a Main Memory which is typically the WRAM space (for instance, on NES - 0000-07FF),
|
|
|
|
|
/// Other chips, and ram spaces can be added as well.
|
|
|
|
|
/// Subdomains of another domain are also welcome.
|
|
|
|
|
/// The MainMemory identifier will be 0 if not set
|
|
|
|
|
MemoryDomainList MemoryDomains { get; }
|
2013-11-11 03:20:33 +00:00
|
|
|
|
|
|
|
|
|
//Debugging
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns a list of Cpu registers and their current state
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters();
|
2013-12-22 00:44:39 +00:00
|
|
|
|
|
|
|
|
|
// ====settings interface====
|
|
|
|
|
|
|
|
|
|
// in addition to these methods, it's expected that the constructor or Load() method
|
|
|
|
|
// will take a SyncSettings object to set the initial state of the core (and possibly a settings object?)
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-12-23 16:58:20 +00:00
|
|
|
|
/// get the current core settings, excepting movie settings. should be a clone of the active in-core object, and changes to the return
|
|
|
|
|
/// should not affect emulation (unless the object is later passed to PutSettings)
|
2013-12-22 00:44:39 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>a json-serializable object</returns>
|
|
|
|
|
object GetSettings();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-12-23 16:58:20 +00:00
|
|
|
|
/// get the current core settings that affect movie sync. these go in movie 2.0 files, so don't make the JSON too extravagant, please
|
|
|
|
|
/// should be a clone of the active in-core object, and changes to the return
|
|
|
|
|
/// should not affect emulation (unless the object is later passed to PutSyncSettings)
|
2013-12-22 00:44:39 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>a json-serializable object</returns>
|
|
|
|
|
object GetSyncSettings();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// change the core settings, excepting movie settings
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="o">an object of the same type as the return for GetSettings</param>
|
|
|
|
|
/// <returns>true if a core reboot will be required to implement these</returns>
|
|
|
|
|
bool PutSettings(object o);
|
|
|
|
|
|
2013-12-23 02:51:41 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// changes the movie-sync relevant settings. THIS SHOULD NEVER BE CALLED WHILE RECORDING
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="o">an object of the same type as the return for GetSyncSettings</param>
|
|
|
|
|
/// <returns>true if a core reboot will be required to implement these</returns>
|
|
|
|
|
bool PutSyncSettings(object o);
|
2011-07-30 20:49:36 +00:00
|
|
|
|
}
|
2011-01-21 03:59:50 +00:00
|
|
|
|
|
2013-03-25 01:59:34 +00:00
|
|
|
|
public enum DisplayType { NTSC, PAL, DENDY }
|
2011-01-11 02:55:51 +00:00
|
|
|
|
}
|