using System;
using System.Collections.Generic;
using System.IO;
namespace BizHawk.Emulation.Common
{
public interface IEmulator : IDisposable
{
///
/// Video provider to the client
///
IVideoProvider VideoProvider { get; }
///
/// Sound provider for async operation. this is optional, and is only required after StartAsyncSound() is called and returns true
///
ISoundProvider SoundProvider { get; }
///
/// sound provider for sync operation. this is manditory
///
ISyncSoundProvider SyncSoundProvider { get; }
/// start async operation. (on construct, sync operation is assumed).
/// false if core doesn't support async sound; SyncSoundProvider will continue to be used in that case
bool StartAsyncSound();
///
/// end async operation, returning to sync operation. after this, all sound requests will go to the SyncSoundProvider
///
void EndAsyncSound();
///
/// Defines all the possible inputs and types that the core can receive
///
ControllerDefinition ControllerDefinition { get; }
IController Controller { get; set; }
///
// note that (some?) cores expect you to call SoundProvider.GetSamples() after each FrameAdvance()
// please do this, even when rendersound = false
///
///
void FrameAdvance(bool render, bool rendersound = true);
///
/// The frame count
///
int Frame { get; }
///
/// The lag count.
///
int LagCount { get; set; }
///
/// 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.
///
bool IsLagFrame { get; }
///
/// The unique Id of the given core, for instance "NES"
///
string SystemId { get; }
///
/// 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
///
bool DeterministicEmulation { get; }
///
/// identifying information about a "mapper" or similar capability. null if no such useful distinction can be drawn
///
string BoardName { get; }
///
/// return a copy of the saveram. editing it won't do you any good unless you later call StoreSaveRam()
///
byte[] ReadSaveRam();
///
/// store new saveram to the emu core. the data should be the same size as the return from ReadSaveRam()
///
void StoreSaveRam(byte[] data);
///
/// reset saveram to a standard initial state
///
void ClearSaveRam();
///
/// Whether or not Save ram has been modified since the last save
///
bool SaveRamModified { get; set; }
///
/// Resets the Frame and Lag counters, and any other similar counters a core might implement
///
void ResetCounters();
///
/// Savestate handling methods
///
///
void SaveStateText(TextWriter writer);
void LoadStateText(TextReader reader);
void SaveStateBinary(BinaryWriter writer);
void LoadStateBinary(BinaryReader reader);
///
/// save state binary to a byte buffer
///
/// you may NOT modify this. if you call SaveStateBinary() again with the same core, the old data MAY be overwritten.
byte[] SaveStateBinary();
///
/// true if the core would rather give a binary savestate than a text one. both must function regardless
///
bool BinarySaveStatesPreferred { get; }
///
/// the corecomm module in use by this core.
///
CoreComm CoreComm { get; }
///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; }
//Debugging
///
/// Returns a list of Cpu registers and their current state
///
///
List> GetCpuFlagsAndRegisters();
// ====settings interface====
// in addition to these methods, it's expected that the constructor or Load() method
// will take a Settings and SyncSettings object to set the initial state of the core
// (if those are null, default settings are to be used)
///
/// 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)
///
/// a json-serializable object
object GetSettings();
///
/// 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)
///
/// a json-serializable object
object GetSyncSettings();
///
/// change the core settings, excepting movie settings
///
/// an object of the same type as the return for GetSettings
/// true if a core reboot will be required to implement these
bool PutSettings(object o);
///
/// changes the movie-sync relevant settings. THIS SHOULD NEVER BE CALLED WHILE RECORDING
///
/// an object of the same type as the return for GetSyncSettings
/// true if a core reboot will be required to implement these
bool PutSyncSettings(object o);
}
public enum DisplayType { NTSC, PAL, DENDY }
}