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[] CloneSaveRam();
///
/// 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. this probably shouldn't be used; instantiate a new core to clear persistent things.
///
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; }
}
public interface IDebuggable : IEmulator
{
///
/// Returns a list of Cpu registers and their current state
///
///
Dictionary GetCpuFlagsAndRegisters();
///
/// Sets a given Cpu register to the given value
///
///
///
void SetCpuRegister(string register, int value);
}
public interface ISettable : IEmulator
{
object GetSettings();
object GetSyncSettings();
bool PutSettings(object o);
bool PutSyncSettings(object o);
}
public interface ISettable : ISettable
{
// 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.
/// VERY IMPORTANT: changes to the object returned by this function SHOULD NOT have any effect on emulation
/// (unless the object is later passed to PutSettings)
///
/// a json-serializable object
new TSettings 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.
/// VERY IMPORTANT: changes to the object returned by this function MUST NOT have any effect on emulation
/// (unless the object is later passed to PutSyncSettings)
///
/// a json-serializable object
new TSync 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 make the changes effective
new bool PutSettings(TSettings o);
///
/// changes the movie-sync relevant settings. THIS SHOULD NEVER BE CALLED WHILE RECORDING
/// if it is called while recording, the core need not guarantee continued determinism
///
/// an object of the same type as the return for GetSyncSettings
/// true if a core reboot will be required to make the changes effective
new bool PutSyncSettings(TSync o);
}
public enum DisplayType { NTSC, PAL, DENDY }
}