2015-07-01 23:17:14 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2015-07-05 19:05:33 -04:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.IO.Compression;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2016-01-16 19:33:10 -05:00
|
|
|
|
using System.Windows.Forms;
|
2016-08-28 18:58:22 -04:00
|
|
|
|
using Mesen.GUI.Config;
|
2016-02-19 13:05:04 -05:00
|
|
|
|
using Mesen.GUI.Forms;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI
|
|
|
|
|
{
|
|
|
|
|
public class InteropEmu
|
|
|
|
|
{
|
2016-12-11 17:41:17 -05:00
|
|
|
|
private const string DLLPath = "MesenCore.dll";
|
2016-01-16 19:33:10 -05:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool TestDll();
|
|
|
|
|
|
2016-02-08 23:23:31 -05:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "GetMesenVersion")] private static extern UInt32 GetMesenVersionWrapper();
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void InitializeEmu([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string homeFolder, IntPtr windowHandle, IntPtr dxViewerHandle, [MarshalAs(UnmanagedType.I1)]bool noAudio, [MarshalAs(UnmanagedType.I1)]bool noVideo, [MarshalAs(UnmanagedType.I1)]bool noInput);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void Release();
|
2015-07-05 22:23:44 -04:00
|
|
|
|
|
2016-02-19 13:05:04 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetDisplayLanguage(Language lang);
|
|
|
|
|
|
2017-11-29 23:24:26 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetFullscreenMode([MarshalAs(UnmanagedType.I1)]bool fullscreen, IntPtr windowHandle, UInt32 monitorWidth, UInt32 monitorHeight);
|
|
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsRunning();
|
|
|
|
|
|
2017-07-30 09:03:54 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void LoadROM([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string patchFile);
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void AddKnownGameFolder([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string folder);
|
2017-08-11 22:20:07 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetFolderOverrides([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string saveDataFolder, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string saveStateFolder, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string screenshotFolder);
|
2017-07-25 22:43:39 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void LoadRecentGame([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filepath, [MarshalAs(UnmanagedType.I1)]bool resetGame);
|
2015-07-05 22:23:44 -04:00
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "GetArchiveRomList")] private static extern IntPtr GetArchiveRomListWrapper([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename);
|
2016-06-17 20:53:05 -04:00
|
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetMousePosition(double x, double y);
|
2017-11-19 23:08:23 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetMouseMovement(Int16 x, Int16 y);
|
2016-02-05 23:14:27 -05:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool HasZapper();
|
2016-02-14 12:58:35 -05:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool HasArkanoidPaddle();
|
2016-07-09 15:58:49 -04:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool HasFourScore();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
|
|
|
|
[DllImport(DLLPath)] public static extern void SetControllerType(int port, ControllerType type);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void SetControllerKeys(int port, KeyMappingSet mapping);
|
2017-07-30 19:22:01 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetZapperDetectionRadius(UInt32 detectionRadius);
|
2016-02-05 23:14:27 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetExpansionDevice(ExpansionPortDevice device);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void SetConsoleType(ConsoleType type);
|
2017-12-21 21:31:42 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetMouseSensitivity(MouseDevice device, double sensitivity);
|
2017-09-08 10:38:41 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void ClearShortcutKeys();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void SetShortcutKey(EmulatorShortcut shortcut, KeyCombination keyCombination, int keySetIndex);
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
2016-07-09 15:58:49 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern ControllerType GetControllerType(int port);
|
|
|
|
|
[DllImport(DLLPath)] public static extern ExpansionPortDevice GetExpansionDevice();
|
|
|
|
|
[DllImport(DLLPath)] public static extern ConsoleType GetConsoleType();
|
2017-03-16 21:34:28 -04:00
|
|
|
|
|
2016-07-16 16:25:57 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void UpdateInputDevices();
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern ConsoleFeatures GetAvailableFeatures();
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "GetPressedKeys")] private static extern void GetPressedKeysWrapper(IntPtr keyBuffer);
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern UInt32 GetKeyCode([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string keyName);
|
|
|
|
|
[DllImport(DLLPath, EntryPoint = "GetKeyName")] private static extern IntPtr GetKeyNameWrapper(UInt32 key);
|
2016-07-28 17:45:18 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetKeyState(Int32 scanCode, [MarshalAs(UnmanagedType.I1)]bool pressed);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void ResetKeyState();
|
2017-09-08 10:38:41 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DisableAllKeys([MarshalAs(UnmanagedType.I1)]bool disabled);
|
2017-03-16 21:34:28 -04:00
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void Run();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void Pause();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void Resume();
|
2016-01-16 19:33:10 -05:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsPaused();
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void Stop();
|
2016-06-17 20:53:05 -04:00
|
|
|
|
|
2017-08-03 21:30:44 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "GetRomInfo")] private static extern UInt32 GetRomInfoWrapper(ref InteropRomInfo romInfo, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename = "");
|
2016-06-17 20:53:05 -04:00
|
|
|
|
|
2017-05-02 23:31:06 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void PowerCycle();
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void Reset();
|
2016-07-10 18:22:37 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void ResetLagCounter();
|
|
|
|
|
|
2016-02-06 15:33:45 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void StartServer(UInt16 port, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string hostPlayerName);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void StopServer();
|
2016-01-16 19:33:10 -05:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsServerRunning();
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void Connect([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string host, UInt16 port, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string playerName, [MarshalAs(UnmanagedType.I1)]bool spectator);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void Disconnect();
|
2016-01-16 19:33:10 -05:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsConnected();
|
2016-02-06 15:33:45 -05:00
|
|
|
|
|
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 NetPlayGetAvailableControllers();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void NetPlaySelectController(Int32 controllerPort);
|
|
|
|
|
[DllImport(DLLPath)] public static extern ControllerType NetPlayGetControllerType(Int32 controllerPort);
|
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 NetPlayGetControllerPort();
|
|
|
|
|
|
2015-07-05 19:05:33 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void TakeScreenshot();
|
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern IntPtr RegisterNotificationCallback(NotificationListener.NotificationCallback callback);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void UnregisterNotificationCallback(IntPtr notificationListener);
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DisplayMessage([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string title, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string message, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string param1 = null);
|
|
|
|
|
[DllImport(DLLPath, EntryPoint = "GetLog")] private static extern IntPtr GetLogWrapper();
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void MoviePlay([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename);
|
2017-12-28 13:15:01 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void MovieRecord(ref RecordMovieOptions options);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void MovieStop();
|
2016-01-16 19:33:10 -05:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool MoviePlaying();
|
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool MovieRecording();
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void AviRecord([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename, VideoCodec codec, UInt32 compressionLevel);
|
2016-12-29 21:19:13 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void AviStop();
|
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool AviIsRecording();
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void WaveRecord([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename);
|
2016-06-05 14:36:20 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void WaveStop();
|
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool WaveIsRecording();
|
|
|
|
|
|
2017-04-23 18:47:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 RunRecordedTest([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename);
|
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 RunAutomaticTest([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename);
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void RomTestRecord([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename, [MarshalAs(UnmanagedType.I1)]bool reset);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void RomTestRecordFromMovie([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string testFilename, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string movieFilename);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void RomTestRecordFromTest([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string newTestFilename, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string existingTestFilename);
|
2015-12-26 17:11:00 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void RomTestStop();
|
2016-01-16 19:33:10 -05:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool RomTestRecording();
|
2015-12-26 17:11:00 -05:00
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SaveState(UInt32 stateIndex);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void LoadState(UInt32 stateIndex);
|
2017-09-01 18:45:53 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SaveStateFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filepath);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void LoadStateFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filepath);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern Int64 GetStateInfo(UInt32 stateIndex);
|
|
|
|
|
|
2016-06-25 20:46:54 -04:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsNsf();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void NsfSelectTrack(Byte trackNumber);
|
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 NsfGetCurrentTrack();
|
|
|
|
|
[DllImport(DLLPath, EntryPoint = "NsfGetHeader")] private static extern void NsfGetHeaderWrapper(out NsfHeader header);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void NsfSetNsfConfig(Int32 autoDetectSilenceDelay, Int32 moveToNextTrackTime, [MarshalAs(UnmanagedType.I1)]bool disableApuIrqs);
|
|
|
|
|
|
2016-01-28 20:47:16 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern UInt32 FdsGetSideCount();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void FdsEjectDisk();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void FdsInsertDisk(UInt32 diskNumber);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void FdsSwitchDiskSide();
|
2017-05-19 20:28:00 -04:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool FdsIsAutoInsertDiskEnabled();
|
2016-01-28 20:47:16 -05:00
|
|
|
|
|
2016-04-30 20:08:53 -04:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsVsSystem();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void VsInsertCoin(UInt32 port);
|
2016-07-10 09:05:41 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void VsSetGameConfig(PpuModel model, VsInputType inputType, byte dipSwitches);
|
2016-04-30 20:08:53 -04:00
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void InputBarcode(UInt64 barcode, Int32 digitCount);
|
|
|
|
|
|
2017-11-24 21:38:12 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void LoadTapeFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filepath);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void StartRecordingTapeFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filepath);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void StopRecordingTapeFile();
|
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsRecordingTapeFile();
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetCheats([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]InteropCheatInfo[] cheats, UInt32 length);
|
2015-07-05 19:05:33 -04:00
|
|
|
|
|
2017-08-08 23:58:45 -04:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool CheckFlag(EmulationFlags flag);
|
2016-01-06 23:10:29 -05:00
|
|
|
|
[DllImport(DLLPath)] private static extern void SetFlags(EmulationFlags flags);
|
|
|
|
|
[DllImport(DLLPath)] private static extern void ClearFlags(EmulationFlags flags);
|
2016-08-24 17:32:22 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetRamPowerOnState(RamPowerOnState state);
|
2016-01-14 01:21:09 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetMasterVolume(double volume);
|
2016-01-30 14:57:50 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetChannelVolume(AudioChannel channel, double volume);
|
2016-12-09 21:23:20 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetChannelPanning(AudioChannel channel, double panning);
|
2017-04-15 13:54:47 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetEqualizerFilterType(EqualizerFilterType filter);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void SetEqualizerBands([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]double[] bands, UInt32 length);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void SetBandGain(int band, double gain);
|
2016-01-14 19:33:16 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetSampleRate(UInt32 sampleRate);
|
2015-07-17 20:58:57 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetAudioLatency(UInt32 msLatency);
|
2016-02-21 15:31:39 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetStereoFilter(StereoFilter stereoFilter);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void SetStereoDelay(Int32 delay);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void SetStereoPanningAngle(double angle);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void SetReverbParameters(double strength, double delay);
|
2016-12-09 14:47:34 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetCrossFeedRatio(UInt32 ratio);
|
|
|
|
|
|
2015-07-21 23:05:27 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetNesModel(NesModel model);
|
2015-08-24 20:27:07 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetEmulationSpeed(UInt32 emulationSpeed);
|
2016-09-11 08:29:34 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void IncreaseEmulationSpeed();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void DecreaseEmulationSpeed();
|
|
|
|
|
[DllImport(DLLPath)] public static extern UInt32 GetEmulationSpeed();
|
2017-04-28 19:54:58 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetTurboRewindSpeed(UInt32 turboSpeed, UInt32 rewindSpeed);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void SetRewindBufferSize(UInt32 seconds);
|
2016-06-12 18:11:31 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetOverclockRate(UInt32 overclockRate, [MarshalAs(UnmanagedType.I1)]bool adjustApu);
|
2016-06-21 18:58:22 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetPpuNmiConfig(UInt32 extraScanlinesBeforeNmi, UInt32 extraScanlineAfterNmi);
|
2015-07-23 23:16:31 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetOverscanDimensions(UInt32 left, UInt32 right, UInt32 top, UInt32 bottom);
|
2016-02-07 13:05:32 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetVideoScale(double scale);
|
2017-11-11 20:55:33 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetScreenRotation(UInt32 angle);
|
2017-12-28 10:59:27 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetExclusiveRefreshRate(UInt32 refreshRate);
|
2017-02-18 13:41:16 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetVideoAspectRatio(VideoAspectRatio aspectRatio, double customRatio);
|
2016-01-05 21:28:38 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetVideoFilter(VideoFilterType filter);
|
2016-05-24 19:45:58 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetVideoResizeFilter(VideoResizeFilter filter);
|
2016-05-27 17:19:23 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetRgbPalette(byte[] palette);
|
2016-05-26 22:32:20 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetPictureSettings(double brightness, double contrast, double saturation, double hue, double scanlineIntensity);
|
2018-01-07 15:52:05 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetNtscFilterSettings(double artifacts, double bleed, double fringing, double gamma, double resolution, double sharpness, [MarshalAs(UnmanagedType.I1)]bool mergeFields, double yFilterLength, double iFilterLength, double qFilterLength, [MarshalAs(UnmanagedType.I1)]bool verticalBlend);
|
2016-07-19 16:30:18 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetInputDisplaySettings(byte visiblePorts, InputDisplayPosition displayPosition, [MarshalAs(UnmanagedType.I1)]bool displayHorizontally);
|
2016-08-31 20:54:38 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetAutoSaveOptions(UInt32 delayInMinutes, [MarshalAs(UnmanagedType.I1)]bool showMessage);
|
2016-05-26 22:32:20 -04:00
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "GetRgbPalette")] private static extern void GetRgbPaletteWrapper(IntPtr paletteBuffer);
|
|
|
|
|
|
|
|
|
|
[DllImport(DLLPath, EntryPoint = "GetScreenSize")] private static extern void GetScreenSizeWrapper(out ScreenSize size, [MarshalAs(UnmanagedType.I1)]bool ignoreScale);
|
2015-07-17 20:58:57 -04:00
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "GetAudioDevices")] private static extern IntPtr GetAudioDevicesWrapper();
|
2016-01-17 22:16:20 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void SetAudioDevice(string audioDevice);
|
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugInitialize();
|
2016-08-25 19:02:33 -04:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool DebugIsDebuggerRunning();
|
2015-08-02 19:27:02 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugRelease();
|
2016-06-05 10:26:05 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugSetFlags(DebuggerFlags flags);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugGetState(ref DebugState state);
|
2018-01-01 23:23:18 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugGetApuState(ref ApuState state);
|
2016-11-26 17:48:11 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugSetState(DebugState state);
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugSetBreakpoints([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]InteropBreakpoint[] breakpoints, UInt32 length);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugSetLabel(UInt32 address, AddressType addressType, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string label, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string comment);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugStep(UInt32 count);
|
2016-06-04 15:38:48 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugPpuStep(UInt32 count);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugStepCycles(UInt32 count);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugStepOut();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugStepOver();
|
2017-08-01 22:49:50 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugStepBack();
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugRun();
|
2016-11-26 17:48:11 -05:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool DebugIsExecutionStopped();
|
2016-11-22 22:38:14 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 DebugGetRelativeAddress(UInt32 absoluteAddr, AddressType type);
|
2017-03-09 20:42:53 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 DebugFindSubEntryPoint(UInt16 relativeAddr);
|
2016-11-21 22:34:47 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 DebugGetAbsoluteAddress(UInt32 relativeAddr);
|
2017-08-13 20:45:36 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 DebugGetAbsoluteChrAddress(UInt32 relativeAddr);
|
2017-12-31 17:22:54 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 DebugGetRelativeChrAddress(UInt32 absoluteAddr);
|
2016-12-01 19:38:48 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 DebugGetMemorySize(DebugMemoryType type);
|
2017-03-04 21:50:19 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern Byte DebugGetMemoryValue(DebugMemoryType type, UInt32 address);
|
2017-02-26 20:47:39 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugSetMemoryValue(DebugMemoryType type, UInt32 address, byte value);
|
2017-08-05 23:26:21 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugSetInputOverride(Int32 port, Int32 state);
|
2017-03-11 15:01:33 -05:00
|
|
|
|
|
2017-10-07 15:16:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 DebugLoadScript([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string name, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string content, Int32 scriptId = -1);
|
2017-08-30 18:31:27 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugRemoveScript(Int32 scriptId);
|
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetScriptLog")] private static extern IntPtr DebugGetScriptLogWrapper(Int32 scriptId);
|
|
|
|
|
public static string DebugGetScriptLog(Int32 scriptId) { return PtrToStringUtf8(InteropEmu.DebugGetScriptLogWrapper(scriptId)).Replace("\n", Environment.NewLine); }
|
|
|
|
|
|
2017-03-11 21:03:45 -05:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugStartCodeRunner")] private static extern void DebugStartCodeRunnerWrapper(IntPtr byteCode, Int32 codeLength);
|
|
|
|
|
public static void DebugStartCodeRunner(byte[] data)
|
|
|
|
|
{
|
|
|
|
|
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugStartCodeRunnerWrapper(handle.AddrOfPinnedObject(), data.Length);
|
|
|
|
|
} finally {
|
|
|
|
|
handle.Free();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-11 15:01:33 -05:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugSetMemoryValues")] private static extern void DebugSetMemoryValuesWrapper(DebugMemoryType type, UInt32 address, IntPtr data, Int32 length);
|
|
|
|
|
public static void DebugSetMemoryValues(DebugMemoryType type, UInt32 address, byte[] data)
|
|
|
|
|
{
|
|
|
|
|
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugSetMemoryValuesWrapper(type, address, handle.AddrOfPinnedObject(), data.Length);
|
|
|
|
|
} finally {
|
|
|
|
|
handle.Free();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 22:38:14 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugGetAbsoluteAddressAndType(UInt32 relativeAddr, ref AddressTypeInfo addressTypeInfo);
|
2016-11-26 20:44:23 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugSetPpuViewerScanlineCycle(Int32 scanline, Int32 cycle);
|
2016-11-22 22:38:14 -05:00
|
|
|
|
|
2017-03-02 20:33:25 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugSetFreezeState(UInt16 address, [MarshalAs(UnmanagedType.I1)]bool frozen);
|
|
|
|
|
|
2015-08-17 21:59:22 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugSetNextStatement(UInt16 addr);
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern Int32 DebugEvaluateExpression([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string expression, out EvalResultType resultType);
|
2016-12-01 19:38:48 -05:00
|
|
|
|
|
2017-03-04 15:18:00 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugStartTraceLogger([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugStopTraceLogger();
|
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugSetTraceOptions(TraceLoggerOptions options);
|
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetExecutionTrace")] private static extern IntPtr DebugGetExecutionTraceWrapper(UInt32 lineCount);
|
|
|
|
|
public static string DebugGetExecutionTrace(UInt32 lineCount) { return PtrToStringUtf8(InteropEmu.DebugGetExecutionTraceWrapper(lineCount)); }
|
2017-03-16 21:34:28 -04:00
|
|
|
|
|
2018-01-03 18:48:16 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugMarkPrgBytesAs(UInt32 start, UInt32 end, CdlPrgFlags type);
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool DebugLoadCdlFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string cdlFilepath);
|
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool DebugSaveCdlFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string cdlFilepath);
|
2015-08-17 19:32:10 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugGetCdlRatios(ref CdlRatios ratios);
|
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugResetCdlLog();
|
2016-12-01 19:38:48 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugResetMemoryAccessCounts();
|
2016-12-08 19:30:41 -05:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugResetProfiler();
|
|
|
|
|
|
2017-08-21 23:11:14 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void DebugRevertPrgChrChanges();
|
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool DebugHasPrgChrChanges();
|
|
|
|
|
|
2017-08-12 16:52:45 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetNesHeader")] public static extern void DebugGetNesHeaderWrapper(IntPtr headerBuffer);
|
|
|
|
|
public static byte[] DebugGetNesHeader()
|
|
|
|
|
{
|
|
|
|
|
byte[] header = new byte[16];
|
|
|
|
|
GCHandle handle = GCHandle.Alloc(header, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetNesHeaderWrapper(handle.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
handle.Free();
|
|
|
|
|
}
|
|
|
|
|
return header;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-01 12:09:33 -05:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugSaveRomToDisk")] public static extern void DebugSaveRomToDiskWrapper([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename, [MarshalAs(UnmanagedType.I1)]bool saveAsIps, IntPtr headerBuffer, CdlStripFlag cdlStripFlag);
|
|
|
|
|
public static void DebugSaveRomToDisk(string filename, bool saveAsIps = false, byte[] header = null, CdlStripFlag cdlStripFlag = CdlStripFlag.StripNone)
|
2017-08-12 16:52:45 -04:00
|
|
|
|
{
|
|
|
|
|
if(header != null) {
|
|
|
|
|
GCHandle handle = GCHandle.Alloc(header, GCHandleType.Pinned);
|
|
|
|
|
try {
|
2018-01-01 12:09:33 -05:00
|
|
|
|
InteropEmu.DebugSaveRomToDiskWrapper(filename, saveAsIps, handle.AddrOfPinnedObject(), cdlStripFlag);
|
2017-08-12 16:52:45 -04:00
|
|
|
|
} finally {
|
|
|
|
|
handle.Free();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2018-01-01 12:09:33 -05:00
|
|
|
|
InteropEmu.DebugSaveRomToDiskWrapper(filename, saveAsIps, IntPtr.Zero, cdlStripFlag);
|
2017-08-12 16:52:45 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-26 17:33:46 -05:00
|
|
|
|
|
2017-12-26 16:11:28 -05:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetCode")] private static extern IntPtr DebugGetCodeWrapper(ref UInt32 length);
|
|
|
|
|
public static string DebugGetCode(bool forceRefresh)
|
2017-03-09 23:50:20 -05:00
|
|
|
|
{
|
2017-12-26 16:11:28 -05:00
|
|
|
|
UInt32 length = forceRefresh ? UInt32.MaxValue : 0;
|
|
|
|
|
IntPtr ptrCodeString = InteropEmu.DebugGetCodeWrapper(ref length);
|
2017-03-10 18:35:01 -05:00
|
|
|
|
if(ptrCodeString == IntPtr.Zero) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
return PtrToStringUtf8(ptrCodeString, length);
|
|
|
|
|
}
|
2017-03-09 23:50:20 -05:00
|
|
|
|
}
|
2016-11-21 22:34:47 -05:00
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugAssembleCode")] private static extern UInt32 DebugAssembleCodeWrapper([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string code, UInt16 startAddress, IntPtr assembledCodeBuffer);
|
2017-03-07 17:51:14 -05:00
|
|
|
|
public static Int16[] DebugAssembleCode(string code, UInt16 startAddress)
|
|
|
|
|
{
|
|
|
|
|
code = code.Replace(Environment.NewLine, "\n");
|
|
|
|
|
int lineCount = code.Count(c => c == '\n');
|
|
|
|
|
|
|
|
|
|
Int16[] assembledCode = new Int16[(lineCount + 1) * 4];
|
|
|
|
|
UInt32 size = 0;
|
|
|
|
|
|
|
|
|
|
GCHandle hAssembledCode = GCHandle.Alloc(assembledCode, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
size = InteropEmu.DebugAssembleCodeWrapper(code, startAddress, hAssembledCode.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hAssembledCode.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Array.Resize(ref assembledCode, (int)size);
|
|
|
|
|
return assembledCode;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetMemoryState")] private static extern UInt32 DebugGetMemoryStateWrapper(DebugMemoryType type, IntPtr buffer);
|
2015-08-05 20:40:10 -04:00
|
|
|
|
public static byte[] DebugGetMemoryState(DebugMemoryType type)
|
|
|
|
|
{
|
2017-05-02 21:23:28 -04:00
|
|
|
|
byte[] buffer = new byte[InteropEmu.DebugGetMemorySize(type)];
|
2015-08-05 20:40:10 -04:00
|
|
|
|
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
UInt32 memorySize = InteropEmu.DebugGetMemoryStateWrapper(type, handle.AddrOfPinnedObject());
|
|
|
|
|
Array.Resize(ref buffer, (int)memorySize);
|
|
|
|
|
} finally {
|
|
|
|
|
handle.Free();
|
|
|
|
|
}
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
2015-07-05 19:05:33 -04:00
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugSetMemoryState")] private static extern void DebugSetMemoryStateWrapper(DebugMemoryType type, IntPtr buffer);
|
2016-09-05 09:05:34 -04:00
|
|
|
|
public static void DebugSetMemoryState(DebugMemoryType type, byte[] data)
|
|
|
|
|
{
|
|
|
|
|
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugSetMemoryStateWrapper(type, handle.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
handle.Free();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-25 19:02:33 -04:00
|
|
|
|
public static byte[] DebugGetInternalRam()
|
|
|
|
|
{
|
|
|
|
|
byte[] buffer = new byte[0x800];
|
|
|
|
|
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
UInt32 memorySize = InteropEmu.DebugGetMemoryStateWrapper(DebugMemoryType.InternalRam, handle.AddrOfPinnedObject());
|
|
|
|
|
Array.Resize(ref buffer, (int)memorySize);
|
|
|
|
|
} finally {
|
|
|
|
|
handle.Free();
|
|
|
|
|
}
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetNametable")] private static extern void DebugGetNametableWrapper(UInt32 nametableIndex, IntPtr frameBuffer, IntPtr tileData, IntPtr attributeData);
|
2015-08-08 22:36:39 -04:00
|
|
|
|
public static void DebugGetNametable(int nametableIndex, out byte[] frameData, out byte[] tileData, out byte[] attributeData)
|
|
|
|
|
{
|
|
|
|
|
frameData = new byte[256*240*4];
|
|
|
|
|
tileData = new byte[32*30];
|
|
|
|
|
attributeData = new byte[32*30];
|
|
|
|
|
|
|
|
|
|
GCHandle hFrameData = GCHandle.Alloc(frameData, GCHandleType.Pinned);
|
|
|
|
|
GCHandle hTileData = GCHandle.Alloc(tileData, GCHandleType.Pinned);
|
|
|
|
|
GCHandle hAttributeData = GCHandle.Alloc(attributeData, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetNametableWrapper((UInt32)nametableIndex, hFrameData.AddrOfPinnedObject(), hTileData.AddrOfPinnedObject(), hAttributeData.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hFrameData.Free();
|
|
|
|
|
hTileData.Free();
|
|
|
|
|
hAttributeData.Free();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-01 00:31:16 -05:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetChrBank")] private static extern void DebugGetChrBankWrapper(UInt32 bankIndex, IntPtr frameBuffer, Byte palette, [MarshalAs(UnmanagedType.I1)]bool largeSprites, CdlHighlightType highlightType, IntPtr paletteBuffer);
|
|
|
|
|
public static byte[] DebugGetChrBank(int bankIndex, int palette, bool largeSprites, CdlHighlightType highlightType, out UInt32[] paletteData)
|
2015-08-08 22:36:39 -04:00
|
|
|
|
{
|
|
|
|
|
byte[] frameData = new byte[128*128*4];
|
2018-01-01 00:31:16 -05:00
|
|
|
|
paletteData = new UInt32[16*16];
|
2015-08-08 22:36:39 -04:00
|
|
|
|
|
|
|
|
|
GCHandle hFrameData = GCHandle.Alloc(frameData, GCHandleType.Pinned);
|
2018-01-01 00:31:16 -05:00
|
|
|
|
GCHandle hPaletteData = GCHandle.Alloc(paletteData, GCHandleType.Pinned);
|
2015-08-08 22:36:39 -04:00
|
|
|
|
try {
|
2018-01-01 00:31:16 -05:00
|
|
|
|
InteropEmu.DebugGetChrBankWrapper((UInt32)bankIndex, hFrameData.AddrOfPinnedObject(), (Byte)palette, largeSprites, highlightType, hPaletteData.AddrOfPinnedObject());
|
2015-08-08 22:36:39 -04:00
|
|
|
|
} finally {
|
|
|
|
|
hFrameData.Free();
|
2018-01-01 00:31:16 -05:00
|
|
|
|
hPaletteData.Free();
|
2015-08-08 22:36:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return frameData;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetSprites")] private static extern void DebugGetSpritesWrapper(IntPtr frameBuffer);
|
2015-08-08 22:36:39 -04:00
|
|
|
|
public static byte[] DebugGetSprites()
|
|
|
|
|
{
|
|
|
|
|
byte[] frameData = new byte[64*128*4];
|
|
|
|
|
|
|
|
|
|
GCHandle hFrameData = GCHandle.Alloc(frameData, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetSpritesWrapper(hFrameData.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hFrameData.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return frameData;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetPalette")] private static extern void DebugGetPaletteWrapper(IntPtr frameBuffer);
|
2017-08-15 22:01:54 -04:00
|
|
|
|
public static int[] DebugGetPalette()
|
2015-08-08 22:36:39 -04:00
|
|
|
|
{
|
2017-08-15 22:01:54 -04:00
|
|
|
|
int[] frameData = new int[4*8];
|
2015-08-08 22:36:39 -04:00
|
|
|
|
|
|
|
|
|
GCHandle hFrameData = GCHandle.Alloc(frameData, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetPaletteWrapper(hFrameData.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hFrameData.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return frameData;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-16 17:36:37 -05:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetPpuRegisterWriteData")] private static extern void DebugGetPpuRegisterWriteDataWrapper(IntPtr frameBuffer, IntPtr infoArray);
|
|
|
|
|
public static void DebugGetPpuRegisterWriteData(out byte[] pictureData, out PpuRegisterWriteInfo[] ppuWrites)
|
|
|
|
|
{
|
|
|
|
|
pictureData = new byte[256 * 240 * 4];
|
|
|
|
|
ppuWrites = new PpuRegisterWriteInfo[1000];
|
|
|
|
|
|
|
|
|
|
GCHandle hPictureData = GCHandle.Alloc(pictureData, GCHandleType.Pinned);
|
|
|
|
|
GCHandle hPpuWrites = GCHandle.Alloc(ppuWrites, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetPpuRegisterWriteDataWrapper(hPictureData.AddrOfPinnedObject(), hPpuWrites.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hPictureData.Free();
|
|
|
|
|
hPpuWrites.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < 1000; i++) {
|
|
|
|
|
if(ppuWrites[i].Cycle == 0xFFFF) {
|
|
|
|
|
Array.Resize(ref ppuWrites, i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetProfilerData")] private static extern void DebugGetProfilerDataWrapper(IntPtr profilerData, ProfilerDataType dataType);
|
2016-12-08 19:30:41 -05:00
|
|
|
|
public static Int64[] DebugGetProfilerData(ProfilerDataType dataType)
|
|
|
|
|
{
|
|
|
|
|
Int64[] profileData = new Int64[InteropEmu.DebugGetMemorySize(DebugMemoryType.PrgRom) + 2];
|
|
|
|
|
|
|
|
|
|
GCHandle hProfilerData = GCHandle.Alloc(profileData, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetProfilerDataWrapper(hProfilerData.AddrOfPinnedObject(), dataType);
|
|
|
|
|
} finally {
|
|
|
|
|
hProfilerData.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return profileData;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetMemoryAccessCounts")] private static extern void DebugGetMemoryAccessCountsWrapper(AddressType type, MemoryOperationType operationType, IntPtr counts, [MarshalAs(UnmanagedType.I1)]bool forUninitReads);
|
2016-12-01 19:38:48 -05:00
|
|
|
|
public static Int32[] DebugGetMemoryAccessCounts(AddressType type, MemoryOperationType operationType, bool forUninitReads)
|
|
|
|
|
{
|
|
|
|
|
int size = 0;
|
|
|
|
|
switch(type) {
|
|
|
|
|
case AddressType.InternalRam: size = 0x2000; break;
|
|
|
|
|
case AddressType.PrgRom: size = InteropEmu.DebugGetMemorySize(DebugMemoryType.PrgRom); break;
|
|
|
|
|
case AddressType.WorkRam: size = InteropEmu.DebugGetMemorySize(DebugMemoryType.WorkRam); break;
|
|
|
|
|
case AddressType.SaveRam: size = InteropEmu.DebugGetMemorySize(DebugMemoryType.SaveRam); break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Int32[] counts = new Int32[size];
|
|
|
|
|
|
|
|
|
|
if(size > 0) {
|
|
|
|
|
GCHandle hCounts = GCHandle.Alloc(counts, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetMemoryAccessCountsWrapper(type, operationType, hCounts.AddrOfPinnedObject(), forUninitReads);
|
|
|
|
|
} finally {
|
|
|
|
|
hCounts.Free();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return counts;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetMemoryAccessStamps")] private static extern void DebugGetMemoryAccessStampsWrapper(UInt32 offset, UInt32 length, DebugMemoryType type, MemoryOperationType operationType, IntPtr stamps);
|
2017-03-01 20:52:15 -05:00
|
|
|
|
public static Int32[] DebugGetMemoryAccessStamps(UInt32 offset, UInt32 length, DebugMemoryType type, MemoryOperationType operationType)
|
|
|
|
|
{
|
|
|
|
|
Int32[] stamps = new Int32[length];
|
|
|
|
|
|
|
|
|
|
GCHandle hStamps = GCHandle.Alloc(stamps, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetMemoryAccessStampsWrapper(offset, length, type, operationType, hStamps.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hStamps.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return stamps;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetMemoryAccessCountsEx")] private static extern void DebugGetMemoryAccessCountsExWrapper(UInt32 offset, UInt32 length, DebugMemoryType type, MemoryOperationType operationType, IntPtr counts);
|
2017-03-04 23:15:50 -05:00
|
|
|
|
public static Int32[] DebugGetMemoryAccessCountsEx(UInt32 offset, UInt32 length, DebugMemoryType type, MemoryOperationType operationType)
|
|
|
|
|
{
|
|
|
|
|
Int32[] counts = new Int32[length];
|
|
|
|
|
|
|
|
|
|
GCHandle hResult = GCHandle.Alloc(counts, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetMemoryAccessCountsExWrapper(offset, length, type, operationType, hResult.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hResult.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return counts;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetFreezeState")] private static extern void DebugGetFreezeStateWrapper(UInt16 startAddress, UInt16 length, IntPtr freezeState);
|
2017-03-02 20:33:25 -05:00
|
|
|
|
public static bool[] DebugGetFreezeState(UInt16 startAddress, UInt16 length)
|
|
|
|
|
{
|
|
|
|
|
bool[] freezeState = new bool[length];
|
|
|
|
|
|
|
|
|
|
GCHandle hFreezeState = GCHandle.Alloc(freezeState, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetFreezeStateWrapper(startAddress, length, hFreezeState.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hFreezeState.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return freezeState;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 17:33:46 -05:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetCdlData")] private static extern void DebugGetCdlDataWrapper(UInt32 offset, UInt32 length, DebugMemoryType type, IntPtr counts);
|
|
|
|
|
public static byte[] DebugGetCdlData(UInt32 offset, UInt32 length, DebugMemoryType type)
|
|
|
|
|
{
|
|
|
|
|
byte[] cdlData = new byte[length];
|
|
|
|
|
|
|
|
|
|
GCHandle hResult = GCHandle.Alloc(cdlData, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetCdlDataWrapper(offset, length, type, hResult.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hResult.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cdlData;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetCallstack")] private static extern void DebugGetCallstackWrapper(IntPtr callstackAbsolute, IntPtr callstackRelative);
|
2015-08-09 14:47:27 -04:00
|
|
|
|
public static void DebugGetCallstack(out Int32[] callstackAbsolute, out Int32[] callstackRelative)
|
|
|
|
|
{
|
|
|
|
|
callstackAbsolute = new Int32[1024];
|
|
|
|
|
callstackRelative = new Int32[1024];
|
|
|
|
|
|
|
|
|
|
GCHandle hAbsolute = GCHandle.Alloc(callstackAbsolute, GCHandleType.Pinned);
|
|
|
|
|
GCHandle hRelative = GCHandle.Alloc(callstackRelative, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.DebugGetCallstackWrapper(hAbsolute.AddrOfPinnedObject(), hRelative.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hAbsolute.Free();
|
|
|
|
|
hRelative.Free();
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-09 23:50:20 -05:00
|
|
|
|
[DllImport(DLLPath)] private static extern Int32 DebugGetFunctionEntryPointCount();
|
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetFunctionEntryPoints")] private static extern void DebugGetFunctionEntryPointsWrapper(IntPtr callstackAbsolute, Int32 maxCount);
|
2016-11-20 13:15:37 -05:00
|
|
|
|
public static Int32[] DebugGetFunctionEntryPoints()
|
|
|
|
|
{
|
2017-03-09 23:50:20 -05:00
|
|
|
|
int maxCount = DebugGetFunctionEntryPointCount();
|
|
|
|
|
Int32[] entryPoints = new Int32[maxCount+1];
|
2016-11-20 13:15:37 -05:00
|
|
|
|
|
|
|
|
|
GCHandle hEntryPoints = GCHandle.Alloc(entryPoints, GCHandleType.Pinned);
|
|
|
|
|
try {
|
2017-03-09 23:50:20 -05:00
|
|
|
|
InteropEmu.DebugGetFunctionEntryPointsWrapper(hEntryPoints.AddrOfPinnedObject(), maxCount+1);
|
2016-11-20 13:15:37 -05:00
|
|
|
|
} finally {
|
|
|
|
|
hEntryPoints.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return entryPoints;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 18:10:37 -05:00
|
|
|
|
[DllImport(DLLPath, EntryPoint = "DebugGetPpuScroll")] private static extern UInt32 DebugGetPpuScrollWrapper();
|
|
|
|
|
public static void DebugGetPpuScroll(out int xScroll, out int yScroll)
|
|
|
|
|
{
|
|
|
|
|
UInt32 ppuScroll = InteropEmu.DebugGetPpuScrollWrapper();
|
|
|
|
|
xScroll = (int)ppuScroll & 0xFFFF;
|
|
|
|
|
yScroll = (int)(ppuScroll >> 16) & 0xFFFF;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-19 17:51:36 -04:00
|
|
|
|
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsHdPpu();
|
2017-08-15 23:59:55 -04:00
|
|
|
|
|
2017-06-28 19:00:08 -04:00
|
|
|
|
[DllImport(DLLPath)] public static extern void HdBuilderStartRecording(
|
|
|
|
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string saveFolder,
|
|
|
|
|
ScaleFilterType filterType,
|
|
|
|
|
UInt32 scale,
|
|
|
|
|
HdPackRecordFlags flags,
|
|
|
|
|
UInt32 chrRamBankSize);
|
|
|
|
|
|
|
|
|
|
[DllImport(DLLPath)] public static extern void HdBuilderStopRecording();
|
|
|
|
|
|
|
|
|
|
[DllImport(DLLPath, EntryPoint = "HdBuilderGetBankPreview")] private static extern void HdBuilderGetBankPreviewWrapper(UInt32 bankNumber, UInt32 pageNumber, IntPtr rgbBuffer);
|
|
|
|
|
public static byte[] HdBuilderGetBankPreview(UInt32 bankNumber, int scale, UInt32 pageNumber)
|
|
|
|
|
{
|
|
|
|
|
byte[] frameData = new byte[128*128*4*scale*scale];
|
|
|
|
|
|
|
|
|
|
GCHandle hFrameData = GCHandle.Alloc(frameData, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.HdBuilderGetBankPreviewWrapper(bankNumber, pageNumber, hFrameData.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hFrameData.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return frameData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DllImport(DLLPath, EntryPoint = "HdBuilderGetChrBankList")] private static extern void HdBuilderGetChrBankListWrapper(IntPtr bankList);
|
|
|
|
|
public static UInt32[] HdBuilderGetChrBankList()
|
|
|
|
|
{
|
|
|
|
|
UInt32[] bankList = new UInt32[1024];
|
|
|
|
|
GCHandle hBankList = GCHandle.Alloc(bankList, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.HdBuilderGetChrBankListWrapper(hBankList.AddrOfPinnedObject());
|
|
|
|
|
for(int i = 0; i < bankList.Length; i++) {
|
|
|
|
|
if(bankList[i] == UInt32.MaxValue) {
|
|
|
|
|
Array.Resize(ref bankList, i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
hBankList.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bankList;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
public static List<UInt32> GetPressedKeys()
|
|
|
|
|
{
|
|
|
|
|
UInt32[] keyBuffer = new UInt32[3];
|
|
|
|
|
GCHandle handle = GCHandle.Alloc(keyBuffer, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.GetPressedKeysWrapper(handle.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
handle.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<UInt32> keys = new List<UInt32>();
|
|
|
|
|
for(int i = 0; i < 3; i++) {
|
|
|
|
|
if(keyBuffer[i] != 0) {
|
|
|
|
|
keys.Add(keyBuffer[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return keys;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-25 20:46:54 -04:00
|
|
|
|
public static NsfHeader NsfGetHeader()
|
|
|
|
|
{
|
|
|
|
|
NsfHeader header = new NsfHeader();
|
|
|
|
|
NsfGetHeaderWrapper(out header);
|
|
|
|
|
return header;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 09:03:54 -04:00
|
|
|
|
public static RomInfo GetRomInfo(string filename = "")
|
2016-06-17 20:53:05 -04:00
|
|
|
|
{
|
|
|
|
|
InteropRomInfo romInfo = new InteropRomInfo();
|
2017-07-30 09:03:54 -04:00
|
|
|
|
InteropEmu.GetRomInfoWrapper(ref romInfo, filename);
|
2016-06-17 20:53:05 -04:00
|
|
|
|
return new RomInfo(romInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-07 13:05:32 -05:00
|
|
|
|
public static ScreenSize GetScreenSize(bool ignoreScale)
|
2016-01-05 21:28:38 -05:00
|
|
|
|
{
|
|
|
|
|
ScreenSize size;
|
2016-02-07 13:05:32 -05:00
|
|
|
|
GetScreenSizeWrapper(out size, ignoreScale);
|
2016-01-05 21:28:38 -05:00
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-06 23:10:29 -05:00
|
|
|
|
public static void SetFlag(EmulationFlags flag, bool value)
|
|
|
|
|
{
|
|
|
|
|
if(value) {
|
|
|
|
|
InteropEmu.SetFlags(flag);
|
|
|
|
|
} else {
|
|
|
|
|
InteropEmu.ClearFlags(flag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-08 23:23:31 -05:00
|
|
|
|
public static string GetMesenVersion()
|
|
|
|
|
{
|
|
|
|
|
UInt32 version = GetMesenVersionWrapper();
|
|
|
|
|
UInt32 revision = version & 0xFF;
|
|
|
|
|
UInt32 minor = (version >> 8) & 0xFF;
|
|
|
|
|
UInt32 major = (version >> 16) & 0xFFFF;
|
|
|
|
|
return string.Format("{0}.{1}.{2}", major.ToString(), minor.ToString(), revision.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-17 14:21:31 -05:00
|
|
|
|
public static Int32[] GetRgbPalette()
|
|
|
|
|
{
|
|
|
|
|
Int32[] paleteData = new Int32[64];
|
|
|
|
|
|
|
|
|
|
GCHandle hPaletteData = GCHandle.Alloc(paleteData, GCHandleType.Pinned);
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.GetRgbPaletteWrapper(hPaletteData.AddrOfPinnedObject());
|
|
|
|
|
} finally {
|
|
|
|
|
hPaletteData.Free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return paleteData;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-19 16:54:34 -04:00
|
|
|
|
public static string GetLog() { return PtrToStringUtf8(InteropEmu.GetLogWrapper()).Replace("\n", Environment.NewLine); }
|
2015-07-11 08:27:22 -04:00
|
|
|
|
public static string GetKeyName(UInt32 key) { return PtrToStringUtf8(InteropEmu.GetKeyNameWrapper(key)); }
|
2016-01-17 22:16:20 -05:00
|
|
|
|
public static List<string> GetAudioDevices()
|
|
|
|
|
{
|
2017-03-16 21:34:28 -04:00
|
|
|
|
return new List<string>(PtrToStringUtf8(InteropEmu.GetAudioDevicesWrapper()).Split(new string[1] { "||" }, StringSplitOptions.RemoveEmptyEntries));
|
2016-01-17 22:16:20 -05:00
|
|
|
|
}
|
2015-07-11 08:27:22 -04:00
|
|
|
|
|
2017-09-30 14:07:07 -04:00
|
|
|
|
public class ArchiveRomEntry
|
|
|
|
|
{
|
|
|
|
|
public string Filename;
|
|
|
|
|
public bool IsUtf8;
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Filename;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<ArchiveRomEntry> GetArchiveRomList(string filename)
|
|
|
|
|
{
|
|
|
|
|
//Split the array on the [!|!] delimiter
|
|
|
|
|
byte[] buffer = PtrToByteArray(InteropEmu.GetArchiveRomListWrapper(filename));
|
|
|
|
|
List<List<byte>> filenames = new List<List<byte>>();
|
|
|
|
|
List<byte> filenameBytes = new List<byte>();
|
|
|
|
|
for(int i = 0; i < buffer.Length - 5; i++) {
|
|
|
|
|
if(buffer[i] == '[' && buffer[i+1] == '!' && buffer[i+2] == '|' && buffer[i+3] == '!' && buffer[i+4] == ']') {
|
|
|
|
|
filenames.Add(filenameBytes);
|
|
|
|
|
filenameBytes = new List<byte>();
|
|
|
|
|
i+=4;
|
|
|
|
|
} else {
|
|
|
|
|
filenameBytes.Add(buffer[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
filenames.Add(filenameBytes);
|
|
|
|
|
|
|
|
|
|
List<ArchiveRomEntry> entries = new List<ArchiveRomEntry>();
|
|
|
|
|
|
|
|
|
|
//Check whether or not each string is a valid utf8 filename, if not decode it using the system's default encoding.
|
|
|
|
|
//This is necessary because zip files do not have any rules when it comes to encoding filenames
|
|
|
|
|
for(int i = 0; i < filenames.Count; i++) {
|
|
|
|
|
byte[] originalBytes = filenames[i].ToArray();
|
|
|
|
|
string utf8Filename = Encoding.UTF8.GetString(originalBytes);
|
|
|
|
|
byte[] convertedBytes = Encoding.UTF8.GetBytes(utf8Filename);
|
|
|
|
|
bool equal = true;
|
|
|
|
|
if(originalBytes.Length == convertedBytes.Length) {
|
|
|
|
|
for(int j = 0; j < convertedBytes.Length; j++) {
|
|
|
|
|
if(convertedBytes[j] != originalBytes[j]) {
|
|
|
|
|
equal = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
equal = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!equal) {
|
|
|
|
|
//String doesn't appear to be an utf8 string, use the system's default encoding
|
|
|
|
|
entries.Add(new ArchiveRomEntry() { Filename = Encoding.Default.GetString(originalBytes), IsUtf8 = false });
|
|
|
|
|
} else {
|
|
|
|
|
entries.Add(new ArchiveRomEntry() { Filename = utf8Filename, IsUtf8 = true });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return entries;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-09 23:50:20 -05:00
|
|
|
|
private static byte[] _codeByteArray = new byte[0];
|
|
|
|
|
private static string PtrToStringUtf8(IntPtr ptr, UInt32 length = 0)
|
2015-07-11 08:27:22 -04:00
|
|
|
|
{
|
|
|
|
|
if(ptr == IntPtr.Zero) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2017-03-09 23:50:20 -05:00
|
|
|
|
|
2015-07-11 08:27:22 -04:00
|
|
|
|
int len = 0;
|
2017-03-09 23:50:20 -05:00
|
|
|
|
if(length == 0) {
|
|
|
|
|
while(System.Runtime.InteropServices.Marshal.ReadByte(ptr, len) != 0) {
|
|
|
|
|
len++;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
len = (int)length;
|
2015-07-11 08:27:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(len == 0) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-09 23:50:20 -05:00
|
|
|
|
if(length == 0) {
|
|
|
|
|
byte[] array = new byte[len];
|
|
|
|
|
System.Runtime.InteropServices.Marshal.Copy(ptr, array, 0, len);
|
|
|
|
|
return System.Text.Encoding.UTF8.GetString(array);
|
|
|
|
|
} else {
|
|
|
|
|
//For the code window, reuse the same buffer to reduce allocations
|
|
|
|
|
if(_codeByteArray.Length < len) {
|
|
|
|
|
Array.Resize(ref _codeByteArray, len);
|
|
|
|
|
}
|
|
|
|
|
System.Runtime.InteropServices.Marshal.Copy(ptr, _codeByteArray, 0, len);
|
|
|
|
|
return System.Text.Encoding.UTF8.GetString(_codeByteArray, 0, len);
|
|
|
|
|
}
|
2015-07-11 08:27:22 -04:00
|
|
|
|
}
|
2015-07-05 19:05:33 -04:00
|
|
|
|
|
2017-09-30 14:07:07 -04:00
|
|
|
|
private static byte[] PtrToByteArray(IntPtr ptr)
|
|
|
|
|
{
|
|
|
|
|
if(ptr == IntPtr.Zero) {
|
|
|
|
|
return new byte[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int len = 0;
|
|
|
|
|
while(System.Runtime.InteropServices.Marshal.ReadByte(ptr, len) != 0) {
|
|
|
|
|
len++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
byte[] array = new byte[len];
|
|
|
|
|
System.Runtime.InteropServices.Marshal.Copy(ptr, array, 0, len);
|
|
|
|
|
|
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
public enum ConsoleNotificationType
|
|
|
|
|
{
|
|
|
|
|
GameLoaded = 0,
|
|
|
|
|
StateLoaded = 1,
|
|
|
|
|
GameReset = 2,
|
|
|
|
|
GamePaused = 3,
|
|
|
|
|
GameResumed = 4,
|
|
|
|
|
GameStopped = 5,
|
|
|
|
|
CodeBreak = 6,
|
2015-08-08 22:36:39 -04:00
|
|
|
|
CheatAdded = 7,
|
|
|
|
|
CheatRemoved = 8,
|
|
|
|
|
PpuFrameDone = 9,
|
2016-01-05 21:28:38 -05:00
|
|
|
|
MovieEnded = 10,
|
|
|
|
|
ResolutionChanged = 11,
|
2017-11-19 23:08:23 -05:00
|
|
|
|
FdsBiosNotFound = 12,
|
|
|
|
|
ConfigChanged = 13,
|
|
|
|
|
DisconnectedFromServer = 14,
|
|
|
|
|
PpuViewerDisplayFrame = 15,
|
|
|
|
|
ExecuteShortcut = 16,
|
|
|
|
|
EmulationStopped = 17,
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum ControllerType
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
StandardController = 1,
|
|
|
|
|
Zapper = 2,
|
2016-02-14 12:58:35 -05:00
|
|
|
|
ArkanoidController = 3,
|
2017-11-19 23:08:23 -05:00
|
|
|
|
SnesController = 4,
|
|
|
|
|
PowerPad = 5,
|
|
|
|
|
SnesMouse = 6,
|
|
|
|
|
SuborMouse = 7,
|
2016-02-14 12:58:35 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum ExpansionPortDevice
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
Zapper = 1,
|
|
|
|
|
FourPlayerAdapter = 2,
|
|
|
|
|
ArkanoidController = 3,
|
2016-07-30 17:27:14 -04:00
|
|
|
|
OekaKidsTablet = 4,
|
2017-11-19 23:08:23 -05:00
|
|
|
|
FamilyTrainerMat = 5,
|
|
|
|
|
KonamiHyperShot = 6,
|
|
|
|
|
FamilyBasicKeyboard = 7,
|
|
|
|
|
PartyTap = 8,
|
|
|
|
|
Pachinko = 9,
|
|
|
|
|
ExcitingBoxing = 10,
|
|
|
|
|
JissenMahjong = 11,
|
|
|
|
|
SuborKeyboard = 12,
|
|
|
|
|
BarcodeBattler = 13,
|
|
|
|
|
HoriTrack = 14,
|
|
|
|
|
BandaiHyperShot = 15,
|
|
|
|
|
AsciiTurboFile = 16,
|
|
|
|
|
BattleBox = 17,
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-21 21:31:42 -05:00
|
|
|
|
public enum MouseDevice
|
|
|
|
|
{
|
|
|
|
|
Unknown = 0,
|
|
|
|
|
SnesMouse,
|
|
|
|
|
SuborMouse,
|
|
|
|
|
ArkanoidController,
|
|
|
|
|
HoriTrack
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 09:05:41 -04:00
|
|
|
|
public enum VsInputType
|
|
|
|
|
{
|
|
|
|
|
Default = 0,
|
|
|
|
|
TypeA = 1,
|
|
|
|
|
TypeB = 2,
|
|
|
|
|
TypeC = 3,
|
|
|
|
|
TypeD = 4,
|
|
|
|
|
TypeE = 5
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-30 20:08:53 -04:00
|
|
|
|
public enum PpuModel
|
|
|
|
|
{
|
|
|
|
|
Ppu2C02 = 0,
|
|
|
|
|
Ppu2C03 = 1,
|
|
|
|
|
Ppu2C04A = 2,
|
|
|
|
|
Ppu2C04B = 3,
|
|
|
|
|
Ppu2C04C = 4,
|
|
|
|
|
Ppu2C04D = 5,
|
|
|
|
|
Ppu2C05A = 6,
|
|
|
|
|
Ppu2C05B = 7,
|
|
|
|
|
Ppu2C05C = 8,
|
|
|
|
|
Ppu2C05D = 9,
|
|
|
|
|
Ppu2C05E = 10,
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
|
public struct KeyMappingSet
|
|
|
|
|
{
|
|
|
|
|
public KeyMapping Mapping1;
|
|
|
|
|
public KeyMapping Mapping2;
|
|
|
|
|
public KeyMapping Mapping3;
|
|
|
|
|
public KeyMapping Mapping4;
|
|
|
|
|
public UInt32 TurboSpeed;
|
2017-12-22 21:57:25 -05:00
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool PowerpadUseSideA;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-10 21:07:24 -04:00
|
|
|
|
public struct KeyMapping
|
|
|
|
|
{
|
|
|
|
|
public UInt32 A;
|
|
|
|
|
public UInt32 B;
|
|
|
|
|
public UInt32 Up;
|
|
|
|
|
public UInt32 Down;
|
|
|
|
|
public UInt32 Left;
|
|
|
|
|
public UInt32 Right;
|
|
|
|
|
public UInt32 Start;
|
|
|
|
|
public UInt32 Select;
|
|
|
|
|
public UInt32 TurboA;
|
|
|
|
|
public UInt32 TurboB;
|
|
|
|
|
public UInt32 TurboStart;
|
|
|
|
|
public UInt32 TurboSelect;
|
2017-08-12 11:54:05 -04:00
|
|
|
|
public UInt32 Microphone;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
public UInt32 LButton;
|
|
|
|
|
public UInt32 RButton;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
|
|
|
|
public UInt32[] PowerPadButtons;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 72)]
|
|
|
|
|
public UInt32[] FamilyBasicKeyboardButtons;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
|
|
|
|
public UInt32[] PartyTapButtons;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
|
|
|
|
public UInt32[] PachinkoButtons;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
|
|
|
|
public UInt32[] ExcitingBoxingButtons;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 21)]
|
|
|
|
|
public UInt32[] JissenMahjongButtons;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 99)]
|
|
|
|
|
public UInt32[] SuborKeyboardButtons;
|
2017-12-25 23:26:35 -05:00
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
|
|
|
|
public UInt32[] BandaiMicrophoneButtons;
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-21 15:31:39 -05:00
|
|
|
|
public enum StereoFilter
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
Delay = 1,
|
|
|
|
|
Panning = 2,
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-05 21:28:38 -05:00
|
|
|
|
public struct ScreenSize
|
|
|
|
|
{
|
|
|
|
|
public Int32 Width;
|
|
|
|
|
public Int32 Height;
|
2016-12-22 23:08:34 -05:00
|
|
|
|
public double Scale;
|
2016-01-05 21:28:38 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-19 16:30:18 -04:00
|
|
|
|
public enum InputDisplayPosition
|
|
|
|
|
{
|
|
|
|
|
TopLeft = 0,
|
|
|
|
|
TopRight = 1,
|
|
|
|
|
BottomLeft = 2,
|
|
|
|
|
BottomRight = 3
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
public class NotificationEventArgs
|
|
|
|
|
{
|
|
|
|
|
public ConsoleNotificationType NotificationType;
|
2017-09-08 10:38:41 -04:00
|
|
|
|
public IntPtr Parameter;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class NotificationListener : IDisposable
|
|
|
|
|
{
|
2017-09-08 10:38:41 -04:00
|
|
|
|
public delegate void NotificationCallback(int type, IntPtr parameter);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
public delegate void NotificationEventHandler(NotificationEventArgs e);
|
|
|
|
|
public event NotificationEventHandler OnNotification;
|
|
|
|
|
|
|
|
|
|
//Need to keep a reference to this callback, or it will get garbage collected (since the only reference to it is on the native side)
|
|
|
|
|
NotificationCallback _callback;
|
|
|
|
|
IntPtr _notificationListener;
|
|
|
|
|
|
|
|
|
|
public NotificationListener()
|
|
|
|
|
{
|
2017-09-08 10:38:41 -04:00
|
|
|
|
_callback = (int type, IntPtr parameter) => {
|
|
|
|
|
this.ProcessNotification(type, parameter);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
};
|
|
|
|
|
_notificationListener = InteropEmu.RegisterNotificationCallback(_callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
InteropEmu.UnregisterNotificationCallback(_notificationListener);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
public void ProcessNotification(int type, IntPtr parameter)
|
2015-07-01 23:17:14 -04:00
|
|
|
|
{
|
|
|
|
|
if(this.OnNotification != null) {
|
2017-09-08 10:38:41 -04:00
|
|
|
|
this.OnNotification(new NotificationEventArgs() {
|
|
|
|
|
NotificationType = (ConsoleNotificationType)type,
|
|
|
|
|
Parameter = parameter
|
|
|
|
|
});
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-17 19:32:10 -04:00
|
|
|
|
public struct CdlRatios
|
|
|
|
|
{
|
|
|
|
|
public float CodeRatio;
|
|
|
|
|
public float DataRatio;
|
|
|
|
|
public float PrgRatio;
|
2017-03-16 21:34:28 -04:00
|
|
|
|
|
2015-08-17 19:32:10 -04:00
|
|
|
|
public float ChrRatio;
|
|
|
|
|
public float ChrReadRatio;
|
|
|
|
|
public float ChrDrawnRatio;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-05 12:09:14 -04:00
|
|
|
|
public enum CdlHighlightType
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
HighlightUsed = 1,
|
|
|
|
|
HighlightUnused = 2
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-01 12:09:33 -05:00
|
|
|
|
public enum CdlStripFlag
|
|
|
|
|
{
|
|
|
|
|
StripNone = 0,
|
|
|
|
|
StripUnused = 1,
|
|
|
|
|
StripUsed = 2
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-03 18:48:16 -05:00
|
|
|
|
public enum CdlPrgFlags
|
|
|
|
|
{
|
|
|
|
|
None = 0x00,
|
|
|
|
|
Code = 0x01,
|
|
|
|
|
Data = 0x02,
|
|
|
|
|
IndirectCode = 0x10,
|
|
|
|
|
IndirectData = 0x20,
|
|
|
|
|
PcmData = 0x40,
|
|
|
|
|
SubEntryPoint = 0x80
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-16 17:36:37 -05:00
|
|
|
|
public struct PpuRegisterWriteInfo
|
|
|
|
|
{
|
|
|
|
|
public byte Address;
|
|
|
|
|
public byte Value;
|
|
|
|
|
public UInt16 Cycle;
|
|
|
|
|
public Int16 Scanline;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
public struct DebugState
|
|
|
|
|
{
|
|
|
|
|
public CPUState CPU;
|
|
|
|
|
public PPUDebugState PPU;
|
2016-09-04 18:08:16 -04:00
|
|
|
|
public CartridgeState Cartridge;
|
2017-08-30 19:36:20 -04:00
|
|
|
|
public ApuState APU;
|
|
|
|
|
public NesModel Model;
|
2016-09-04 18:08:16 -04:00
|
|
|
|
}
|
2017-03-16 21:34:28 -04:00
|
|
|
|
|
2016-09-04 18:08:16 -04:00
|
|
|
|
public struct CartridgeState
|
|
|
|
|
{
|
2016-09-05 12:09:14 -04:00
|
|
|
|
public UInt32 PrgRomSize;
|
|
|
|
|
public UInt32 ChrRomSize;
|
|
|
|
|
public UInt32 ChrRamSize;
|
|
|
|
|
|
2016-09-04 18:08:16 -04:00
|
|
|
|
public UInt32 PrgPageCount;
|
|
|
|
|
public UInt32 PrgPageSize;
|
2016-09-08 18:11:50 -04:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
2016-09-04 18:08:16 -04:00
|
|
|
|
public UInt32[] PrgSelectedPages;
|
|
|
|
|
|
|
|
|
|
public UInt32 ChrPageCount;
|
|
|
|
|
public UInt32 ChrPageSize;
|
2016-09-08 18:11:50 -04:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
2016-09-04 18:08:16 -04:00
|
|
|
|
public UInt32[] ChrSelectedPages;
|
|
|
|
|
|
2017-08-30 19:36:20 -04:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
2016-09-04 18:08:16 -04:00
|
|
|
|
public UInt32[] Nametables;
|
2018-01-02 12:06:20 -05:00
|
|
|
|
|
|
|
|
|
public Int32 WorkRamStart;
|
|
|
|
|
public Int32 WorkRamEnd;
|
|
|
|
|
public Int32 SaveRamStart;
|
|
|
|
|
public Int32 SaveRamEnd;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct PPUDebugState
|
|
|
|
|
{
|
|
|
|
|
public PPUControlFlags ControlFlags;
|
|
|
|
|
public PPUStatusFlags StatusFlags;
|
|
|
|
|
public PPUState State;
|
|
|
|
|
public Int32 Scanline;
|
|
|
|
|
public UInt32 Cycle;
|
2016-09-03 21:52:59 -04:00
|
|
|
|
public UInt32 FrameCount;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct PPUState
|
|
|
|
|
{
|
|
|
|
|
public Byte Control;
|
|
|
|
|
public Byte Mask;
|
|
|
|
|
public Byte Status;
|
|
|
|
|
public UInt32 SpriteRamAddr;
|
|
|
|
|
public UInt16 VideoRamAddr;
|
|
|
|
|
public Byte XScroll;
|
|
|
|
|
public UInt16 TmpVideoRamAddr;
|
2017-08-30 22:08:12 -04:00
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool WriteToggle;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
|
|
|
|
public UInt16 HighBitShift;
|
|
|
|
|
public UInt16 LowBitShift;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct PPUControlFlags
|
|
|
|
|
{
|
|
|
|
|
public Byte VerticalWrite;
|
|
|
|
|
public UInt16 SpritePatternAddr;
|
|
|
|
|
public UInt16 BackgroundPatternAddr;
|
|
|
|
|
public Byte LargeSprites;
|
|
|
|
|
public Byte VBlank;
|
|
|
|
|
|
|
|
|
|
public Byte Grayscale;
|
|
|
|
|
public Byte BackgroundMask;
|
|
|
|
|
public Byte SpriteMask;
|
|
|
|
|
public Byte BackgroundEnabled;
|
|
|
|
|
public Byte SpritesEnabled;
|
|
|
|
|
public Byte IntensifyRed;
|
|
|
|
|
public Byte IntensifyGreen;
|
|
|
|
|
public Byte IntensifyBlue;
|
2016-11-26 17:48:11 -05:00
|
|
|
|
|
|
|
|
|
public Byte GetMask()
|
|
|
|
|
{
|
|
|
|
|
byte mask = 0;
|
|
|
|
|
if(Grayscale != 0) mask |= 0x01;
|
|
|
|
|
if(BackgroundMask != 0) mask |= 0x02;
|
|
|
|
|
if(SpriteMask != 0) mask |= 0x04;
|
|
|
|
|
if(BackgroundEnabled != 0) mask |= 0x08;
|
|
|
|
|
if(SpritesEnabled != 0) mask |= 0x10;
|
|
|
|
|
if(IntensifyBlue != 0) mask |= 0x80;
|
|
|
|
|
if(IntensifyRed != 0) mask |= 0x20;
|
|
|
|
|
if(IntensifyGreen != 0) mask |= 0x40;
|
|
|
|
|
return mask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Byte GetControl()
|
|
|
|
|
{
|
|
|
|
|
byte control = 0;
|
|
|
|
|
if(VerticalWrite != 0) control |= 0x04;
|
|
|
|
|
if(SpritePatternAddr == 0x1000) control |= 0x08;
|
|
|
|
|
if(BackgroundPatternAddr != 0x1000) control |= 0x10;
|
|
|
|
|
if(LargeSprites != 0) control |= 0x20;
|
|
|
|
|
if(VBlank != 0) control |= 0x80;
|
|
|
|
|
return control;
|
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct PPUStatusFlags
|
|
|
|
|
{
|
|
|
|
|
public Byte SpriteOverflow;
|
|
|
|
|
public Byte Sprite0Hit;
|
|
|
|
|
public Byte VerticalBlank;
|
2016-11-26 17:48:11 -05:00
|
|
|
|
|
|
|
|
|
public Byte GetStatus()
|
|
|
|
|
{
|
|
|
|
|
byte status = 0;
|
|
|
|
|
if(SpriteOverflow != 0) status |= 0x20;
|
|
|
|
|
if(Sprite0Hit != 0) status |= 0x40;
|
|
|
|
|
if(VerticalBlank != 0) status |= 0x80;
|
|
|
|
|
return status;
|
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct CPUState
|
|
|
|
|
{
|
|
|
|
|
public UInt16 PC;
|
|
|
|
|
public Byte SP;
|
|
|
|
|
public Byte A;
|
|
|
|
|
public Byte X;
|
|
|
|
|
public Byte Y;
|
|
|
|
|
public Byte PS;
|
|
|
|
|
public IRQSource IRQFlag;
|
2016-01-02 13:52:55 -05:00
|
|
|
|
public Int32 CycleCount;
|
2017-03-16 21:34:28 -04:00
|
|
|
|
|
2015-08-02 19:27:02 -04:00
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
2015-07-01 23:17:14 -04:00
|
|
|
|
public bool NMIFlag;
|
2015-08-02 19:27:02 -04:00
|
|
|
|
|
|
|
|
|
public UInt16 DebugPC;
|
2016-01-10 19:56:40 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-30 19:36:20 -04:00
|
|
|
|
public struct ApuLengthCounterState
|
|
|
|
|
{
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool Halt;
|
|
|
|
|
public Byte Counter;
|
|
|
|
|
public Byte ReloadValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ApuEnvelopeState
|
|
|
|
|
{
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool StartFlag;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool Loop;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool ConstantVolume;
|
|
|
|
|
public Byte Divider;
|
|
|
|
|
public Byte Counter;
|
|
|
|
|
public Byte Volume;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ApuSquareState
|
|
|
|
|
{
|
|
|
|
|
public Byte Duty;
|
|
|
|
|
public Byte DutyPosition;
|
|
|
|
|
public UInt16 Period;
|
2018-01-01 23:23:18 -05:00
|
|
|
|
public UInt16 Timer;
|
2017-08-30 19:36:20 -04:00
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool SweepEnabled;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool SweepNegate;
|
|
|
|
|
public Byte SweepPeriod;
|
|
|
|
|
public Byte SweepShift;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool Enabled;
|
|
|
|
|
public Byte OutputVolume;
|
2017-12-28 12:47:26 -05:00
|
|
|
|
public double Frequency;
|
2017-08-30 19:36:20 -04:00
|
|
|
|
|
|
|
|
|
public ApuLengthCounterState LengthCounter;
|
|
|
|
|
public ApuEnvelopeState Envelope;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ApuTriangleState
|
|
|
|
|
{
|
|
|
|
|
public UInt16 Period;
|
2018-01-01 23:23:18 -05:00
|
|
|
|
public UInt16 Timer;
|
2017-08-30 19:36:20 -04:00
|
|
|
|
public Byte SequencePosition;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool Enabled;
|
2017-12-28 12:47:26 -05:00
|
|
|
|
public double Frequency;
|
2017-08-30 19:36:20 -04:00
|
|
|
|
public Byte OutputVolume;
|
|
|
|
|
|
|
|
|
|
public ApuLengthCounterState LengthCounter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ApuNoiseState
|
|
|
|
|
{
|
|
|
|
|
public UInt16 Period;
|
2018-01-01 23:23:18 -05:00
|
|
|
|
public UInt16 Timer;
|
2017-08-30 19:36:20 -04:00
|
|
|
|
public UInt16 ShiftRegister;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool ModeFlag;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool Enabled;
|
2017-12-28 12:47:26 -05:00
|
|
|
|
public double Frequency;
|
2017-08-30 19:36:20 -04:00
|
|
|
|
public Byte OutputVolume;
|
|
|
|
|
|
|
|
|
|
public ApuLengthCounterState LengthCounter;
|
|
|
|
|
public ApuEnvelopeState Envelope;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ApuDmcState
|
|
|
|
|
{
|
2018-01-01 23:23:18 -05:00
|
|
|
|
public double SampleRate;
|
2017-08-30 19:36:20 -04:00
|
|
|
|
public UInt16 SampleAddr;
|
|
|
|
|
public UInt16 SampleLength;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool Loop;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool IrqEnabled;
|
|
|
|
|
public UInt16 Period;
|
2018-01-01 23:23:18 -05:00
|
|
|
|
public UInt16 Timer;
|
2017-08-30 19:36:20 -04:00
|
|
|
|
public UInt16 BytesRemaining;
|
|
|
|
|
|
|
|
|
|
public Byte OutputVolume;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ApuFrameCounterState
|
|
|
|
|
{
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool FiveStepMode;
|
|
|
|
|
public Byte SequencePosition;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool IrqEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ApuState
|
|
|
|
|
{
|
|
|
|
|
public ApuSquareState Square1;
|
|
|
|
|
public ApuSquareState Square2;
|
|
|
|
|
public ApuTriangleState Triangle;
|
|
|
|
|
public ApuNoiseState Noise;
|
|
|
|
|
public ApuDmcState Dmc;
|
|
|
|
|
public ApuFrameCounterState FrameCounter;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
public enum StatusFlagFormat
|
|
|
|
|
{
|
|
|
|
|
Hexadecimal = 0,
|
|
|
|
|
Text = 1,
|
|
|
|
|
CompactText = 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
2016-09-03 21:52:59 -04:00
|
|
|
|
public struct TraceLoggerOptions
|
2016-01-10 19:56:40 -05:00
|
|
|
|
{
|
2016-09-03 21:52:59 -04:00
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool ShowByteCode;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool ShowRegisters;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool ShowCpuCycles;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool ShowPpuCycles;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool ShowPpuScanline;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool ShowPpuFrames;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool ShowExtraInfo;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool IndentCode;
|
2016-11-19 19:21:28 -05:00
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool ShowEffectiveAddresses;
|
2018-02-14 21:46:24 -05:00
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool ShowMemoryValues;
|
2017-03-04 15:18:00 -05:00
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool UseLabels;
|
2017-03-16 21:34:28 -04:00
|
|
|
|
public StatusFlagFormat StatusFormat;
|
2017-08-05 12:13:53 -04:00
|
|
|
|
|
|
|
|
|
[NonSerialized]
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1000)]
|
|
|
|
|
public byte[] Condition;
|
2016-01-10 19:56:40 -05:00
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
2016-12-08 19:30:41 -05:00
|
|
|
|
public enum ProfilerDataType
|
|
|
|
|
{
|
|
|
|
|
FunctionExclusive = 0,
|
|
|
|
|
FunctionInclusive = 1,
|
|
|
|
|
Instructions = 2,
|
|
|
|
|
FunctionCallCount = 3,
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
[Flags]
|
|
|
|
|
public enum IRQSource : uint
|
|
|
|
|
{
|
|
|
|
|
External = 1,
|
|
|
|
|
FrameCounter = 2,
|
|
|
|
|
DMC = 4,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Flags]
|
|
|
|
|
public enum PSFlags
|
|
|
|
|
{
|
|
|
|
|
Carry = 0x01,
|
|
|
|
|
Zero = 0x02,
|
|
|
|
|
Interrupt = 0x04,
|
|
|
|
|
Decimal = 0x08,
|
|
|
|
|
Break = 0x10,
|
|
|
|
|
Reserved = 0x20,
|
|
|
|
|
Overflow = 0x40,
|
|
|
|
|
Negative = 0x80
|
|
|
|
|
}
|
2015-07-05 19:05:33 -04:00
|
|
|
|
|
2015-07-17 21:18:57 -04:00
|
|
|
|
[Flags]
|
2017-02-24 21:43:42 -05:00
|
|
|
|
public enum EmulationFlags : UInt64
|
2015-07-17 21:18:57 -04:00
|
|
|
|
{
|
|
|
|
|
Paused = 0x01,
|
2015-08-23 20:24:24 -04:00
|
|
|
|
ShowFPS = 0x02,
|
2016-01-06 20:34:45 -05:00
|
|
|
|
VerticalSync = 0x04,
|
2016-01-14 19:52:28 -05:00
|
|
|
|
AllowInvalidInput = 0x08,
|
2016-01-14 22:20:50 -05:00
|
|
|
|
RemoveSpriteLimit = 0x10,
|
2016-01-16 09:50:33 -05:00
|
|
|
|
UseHdPacks = 0x20,
|
2016-02-05 23:14:27 -05:00
|
|
|
|
HasFourScore = 0x40,
|
2016-01-28 20:47:16 -05:00
|
|
|
|
|
2016-01-31 14:28:31 -05:00
|
|
|
|
PauseOnMovieEnd = 0x0100,
|
2016-01-31 13:53:17 -05:00
|
|
|
|
PauseWhenInBackground = 0x0200,
|
|
|
|
|
AllowBackgroundInput = 0x0400,
|
2016-01-31 11:58:41 -05:00
|
|
|
|
ReduceSoundInBackground = 0x0800,
|
|
|
|
|
MuteSoundInBackground = 0x1000,
|
2016-01-31 13:53:17 -05:00
|
|
|
|
|
2016-01-28 20:47:16 -05:00
|
|
|
|
FdsFastForwardOnLoad = 0x2000,
|
|
|
|
|
FdsAutoLoadDisk = 0x4000,
|
2016-01-06 23:10:29 -05:00
|
|
|
|
Mmc3IrqAltBehavior = 0x8000,
|
2016-01-31 13:53:17 -05:00
|
|
|
|
|
2016-02-19 19:25:28 -05:00
|
|
|
|
SwapDutyCycles = 0x10000,
|
|
|
|
|
|
2016-06-15 21:59:34 -04:00
|
|
|
|
DisableGameDatabase = 0x20000,
|
2016-07-09 15:58:49 -04:00
|
|
|
|
AutoConfigureInput = 0x40000,
|
2016-06-15 21:59:34 -04:00
|
|
|
|
|
2016-07-10 18:22:37 -04:00
|
|
|
|
ShowLagCounter = 0x80000,
|
|
|
|
|
|
2016-07-19 17:36:37 -04:00
|
|
|
|
SilenceTriangleHighFreq = 0x100000,
|
2016-12-04 23:31:52 -05:00
|
|
|
|
ReduceDmcPopping = 0x200000,
|
2016-07-19 17:36:37 -04:00
|
|
|
|
|
2016-12-04 23:31:52 -05:00
|
|
|
|
DisableBackground = 0x400000,
|
|
|
|
|
DisableSprites = 0x800000,
|
|
|
|
|
ForceBackgroundFirstColumn = 0x1000000,
|
|
|
|
|
ForceSpritesFirstColumn = 0x2000000,
|
2017-02-22 20:41:58 -05:00
|
|
|
|
DisablePpu2004Reads = 0x4000000,
|
|
|
|
|
DisableNoiseModeFlag = 0x8000000,
|
2017-02-24 21:43:42 -05:00
|
|
|
|
DisablePaletteRead = 0x10000000,
|
|
|
|
|
DisableOamAddrBug = 0x20000000,
|
2017-02-24 23:06:13 -05:00
|
|
|
|
DisablePpuReset = 0x40000000,
|
2017-04-08 14:13:10 -04:00
|
|
|
|
EnableOamDecay = 0x80000000,
|
2016-09-11 11:03:26 -04:00
|
|
|
|
|
2017-04-08 14:13:10 -04:00
|
|
|
|
UseNes101Hvc101Behavior = 0x100000000,
|
2017-04-30 19:28:35 -04:00
|
|
|
|
ShowFrameCounter = 0x200000000,
|
2017-05-13 15:43:02 -04:00
|
|
|
|
ShowGameTimer = 0x400000000,
|
2017-02-25 10:56:38 -05:00
|
|
|
|
|
2017-05-13 15:43:02 -04:00
|
|
|
|
FdsAutoInsertDisk = 0x800000000,
|
2017-05-04 22:55:46 -04:00
|
|
|
|
|
2017-04-30 01:16:33 -04:00
|
|
|
|
Turbo = 0x2000000000,
|
2017-02-24 21:43:42 -05:00
|
|
|
|
InBackground = 0x4000000000,
|
2017-04-30 01:16:33 -04:00
|
|
|
|
NsfPlayerEnabled = 0x8000000000,
|
2017-04-15 15:47:50 -04:00
|
|
|
|
|
|
|
|
|
DisplayMovieIcons = 0x10000000000,
|
|
|
|
|
HidePauseOverlay = 0x20000000000,
|
2017-05-06 15:27:48 -04:00
|
|
|
|
|
2017-05-22 18:22:26 -04:00
|
|
|
|
UseCustomVsPalette = 0x40000000000,
|
|
|
|
|
|
2017-06-08 20:00:51 -04:00
|
|
|
|
AdaptiveSpriteLimit = 0x80000000000,
|
|
|
|
|
|
2017-07-23 14:11:59 -04:00
|
|
|
|
DisableOsd = 0x100000000000,
|
2017-07-25 22:43:39 -04:00
|
|
|
|
DisableGameSelectionScreen = 0x200000000000,
|
2017-07-23 14:11:59 -04:00
|
|
|
|
|
2017-08-12 18:58:38 -04:00
|
|
|
|
ConfirmExitResetPower = 0x400000000000,
|
|
|
|
|
|
2017-08-13 10:51:13 -04:00
|
|
|
|
NsfRepeat = 0x800000000000,
|
|
|
|
|
NsfShuffle = 0x1000000000000,
|
|
|
|
|
|
2017-09-29 22:09:00 -04:00
|
|
|
|
IntegerFpsMode = 0x2000000000000,
|
|
|
|
|
|
2017-10-07 21:00:02 -04:00
|
|
|
|
DebuggerWindowEnabled = 0x4000000000000,
|
|
|
|
|
|
2017-05-22 18:22:26 -04:00
|
|
|
|
ForceMaxSpeed = 0x4000000000000000,
|
2017-05-06 15:27:48 -04:00
|
|
|
|
ConsoleMode = 0x8000000000000000,
|
2015-07-17 21:18:57 -04:00
|
|
|
|
}
|
2016-06-05 10:26:05 -04:00
|
|
|
|
|
|
|
|
|
[Flags]
|
|
|
|
|
public enum DebuggerFlags
|
|
|
|
|
{
|
2017-03-04 16:18:28 -05:00
|
|
|
|
None = 0x00,
|
|
|
|
|
PpuPartialDraw = 0x01,
|
|
|
|
|
ShowEffectiveAddresses = 0x02,
|
2018-01-03 18:48:16 -05:00
|
|
|
|
DisplayOpCodesInLowerCase = 0x04,
|
|
|
|
|
BreakOnBrk = 0x08,
|
|
|
|
|
BreakOnUnofficialOpCode = 0x10,
|
|
|
|
|
|
|
|
|
|
DisassembleVerifiedData = 0x20,
|
|
|
|
|
DisassembleUnidentifiedData = 0x40,
|
|
|
|
|
ShowVerifiedData = 0x80,
|
|
|
|
|
ShowUnidentifiedData = 0x100,
|
2018-01-15 22:20:51 -05:00
|
|
|
|
|
|
|
|
|
IgnoreRedundantWrites= 0x200,
|
2016-06-05 10:26:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-17 20:53:05 -04:00
|
|
|
|
public struct InteropRomInfo
|
|
|
|
|
{
|
|
|
|
|
public IntPtr RomNamePointer;
|
|
|
|
|
public UInt32 Crc32;
|
2016-07-10 09:05:41 -04:00
|
|
|
|
public UInt32 PrgCrc32;
|
2017-03-04 22:24:41 -05:00
|
|
|
|
public RomFormat Format;
|
2017-06-28 19:00:08 -04:00
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool IsChrRam;
|
2017-03-04 22:24:41 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum RomFormat
|
|
|
|
|
{
|
|
|
|
|
Unknown = 0,
|
|
|
|
|
iNes = 1,
|
|
|
|
|
Unif = 2,
|
|
|
|
|
Fds = 3,
|
2017-07-28 20:58:55 -04:00
|
|
|
|
Nsf = 4,
|
2016-06-17 20:53:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class RomInfo
|
|
|
|
|
{
|
2017-08-19 21:09:44 -04:00
|
|
|
|
public ResourcePath RomFile;
|
2016-06-17 20:53:05 -04:00
|
|
|
|
public UInt32 Crc32;
|
2016-07-10 09:05:41 -04:00
|
|
|
|
public UInt32 PrgCrc32;
|
2017-03-04 22:24:41 -05:00
|
|
|
|
public RomFormat Format;
|
2017-06-28 19:00:08 -04:00
|
|
|
|
public bool IsChrRam;
|
2016-06-17 20:53:05 -04:00
|
|
|
|
|
|
|
|
|
public RomInfo(InteropRomInfo romInfo)
|
|
|
|
|
{
|
2017-08-19 21:09:44 -04:00
|
|
|
|
this.RomFile = (ResourcePath)UTF8Marshaler.GetStringFromIntPtr(romInfo.RomNamePointer);
|
2016-06-17 20:53:05 -04:00
|
|
|
|
this.Crc32 = romInfo.Crc32;
|
2016-07-10 09:05:41 -04:00
|
|
|
|
this.PrgCrc32 = romInfo.PrgCrc32;
|
2017-03-04 22:24:41 -05:00
|
|
|
|
this.Format = romInfo.Format;
|
2017-06-28 19:00:08 -04:00
|
|
|
|
this.IsChrRam = romInfo.IsChrRam;
|
2016-06-17 20:53:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetRomName()
|
|
|
|
|
{
|
2017-08-19 21:09:44 -04:00
|
|
|
|
return Path.GetFileNameWithoutExtension(this.RomFile.FileName);
|
2016-06-17 20:53:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetCrcString()
|
|
|
|
|
{
|
|
|
|
|
return this.Crc32.ToString("X8");
|
|
|
|
|
}
|
2016-08-18 22:33:36 -04:00
|
|
|
|
|
|
|
|
|
public string GetPrgCrcString()
|
|
|
|
|
{
|
|
|
|
|
return this.PrgCrc32.ToString("X8");
|
|
|
|
|
}
|
2016-06-17 20:53:05 -04:00
|
|
|
|
};
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
public struct KeyCombination
|
2016-09-02 19:36:37 -04:00
|
|
|
|
{
|
2017-09-08 10:38:41 -04:00
|
|
|
|
public UInt32 Key1;
|
|
|
|
|
public UInt32 Key2;
|
|
|
|
|
public UInt32 Key3;
|
2016-09-02 19:36:37 -04:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
public bool IsEmpty { get { return Key1 == 0 && Key2 == 0 && Key3 == 0; } }
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
2017-11-19 23:08:23 -05:00
|
|
|
|
if(IsEmpty) {
|
|
|
|
|
return "";
|
|
|
|
|
} else {
|
|
|
|
|
return GetKeyNames();
|
|
|
|
|
}
|
2017-09-08 10:38:41 -04:00
|
|
|
|
}
|
2017-04-28 19:54:58 -04:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
public KeyCombination(List<UInt32> scanCodes = null)
|
|
|
|
|
{
|
|
|
|
|
if(scanCodes != null) {
|
|
|
|
|
Key1 = scanCodes.Count > 0 ? scanCodes[0] : 0;
|
|
|
|
|
Key2 = scanCodes.Count > 1 ? scanCodes[1] : 0;
|
|
|
|
|
Key3 = scanCodes.Count > 2 ? scanCodes[2] : 0;
|
|
|
|
|
} else {
|
|
|
|
|
Key1 = 0;
|
|
|
|
|
Key2 = 0;
|
|
|
|
|
Key3 = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-28 19:54:58 -04:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
private string GetKeyNames()
|
|
|
|
|
{
|
|
|
|
|
List<UInt32> scanCodes = new List<uint>() { Key1, Key2, Key3 };
|
|
|
|
|
List<string> keyNames = scanCodes.Select((UInt32 scanCode) => InteropEmu.GetKeyName(scanCode)).Where((keyName) => !string.IsNullOrWhiteSpace(keyName)).ToList();
|
|
|
|
|
keyNames.Sort((string a, string b) => {
|
|
|
|
|
if(a == b) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2016-09-02 19:36:37 -04:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
if(a == "Ctrl") {
|
|
|
|
|
return -1;
|
|
|
|
|
} else if(b == "Ctrl") {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2016-09-02 19:36:37 -04:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
if(a == "Alt") {
|
|
|
|
|
return -1;
|
|
|
|
|
} else if(b == "Alt") {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2016-09-02 19:36:37 -04:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
if(a == "Shift") {
|
|
|
|
|
return -1;
|
|
|
|
|
} else if(b == "Shift") {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2016-09-02 19:36:37 -04:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
return a.CompareTo(b);
|
|
|
|
|
});
|
2017-03-19 14:21:53 -04:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
return string.Join("+", keyNames);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-22 18:08:38 -04:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
public enum EmulatorShortcut
|
|
|
|
|
{
|
|
|
|
|
FastForward,
|
|
|
|
|
Rewind,
|
|
|
|
|
RewindTenSecs,
|
|
|
|
|
RewindOneMin,
|
|
|
|
|
|
|
|
|
|
MoveToNextStateSlot,
|
|
|
|
|
MoveToPreviousStateSlot,
|
|
|
|
|
SaveState,
|
|
|
|
|
LoadState,
|
|
|
|
|
|
|
|
|
|
InsertNextDisk,
|
|
|
|
|
VsServiceButton,
|
|
|
|
|
|
|
|
|
|
ToggleCheats,
|
|
|
|
|
ToggleAudio,
|
2017-09-08 13:40:16 -04:00
|
|
|
|
ToggleFastForward,
|
|
|
|
|
ToggleRewind,
|
2017-12-17 21:11:54 -05:00
|
|
|
|
ToggleKeyboardMode,
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
|
|
|
|
RunSingleFrame,
|
|
|
|
|
|
|
|
|
|
// Everything below this is handled UI-side
|
|
|
|
|
SwitchDiskSide,
|
|
|
|
|
EjectDisk,
|
|
|
|
|
|
|
|
|
|
InsertCoin1,
|
|
|
|
|
InsertCoin2,
|
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
|
InputBarcode,
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
TakeScreenshot,
|
|
|
|
|
|
|
|
|
|
IncreaseSpeed,
|
|
|
|
|
DecreaseSpeed,
|
|
|
|
|
MaxSpeed,
|
|
|
|
|
|
|
|
|
|
Pause,
|
|
|
|
|
Reset,
|
|
|
|
|
PowerCycle,
|
|
|
|
|
PowerOff,
|
|
|
|
|
Exit,
|
|
|
|
|
|
|
|
|
|
SetScale1x,
|
|
|
|
|
SetScale2x,
|
|
|
|
|
SetScale3x,
|
|
|
|
|
SetScale4x,
|
|
|
|
|
SetScale5x,
|
|
|
|
|
SetScale6x,
|
|
|
|
|
ToggleFullscreen,
|
|
|
|
|
ToggleFps,
|
2017-10-02 18:44:36 -04:00
|
|
|
|
ToggleGameTimer,
|
|
|
|
|
ToggleFrameCounter,
|
|
|
|
|
ToggleLagCounter,
|
|
|
|
|
ToggleOsd,
|
2017-12-26 12:38:30 -05:00
|
|
|
|
ToggleAlwaysOnTop,
|
2017-10-02 18:44:36 -04:00
|
|
|
|
ToggleSprites,
|
|
|
|
|
ToggleBackground,
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
|
|
|
|
LoadRandomGame,
|
|
|
|
|
SaveStateSlot1,
|
|
|
|
|
SaveStateSlot2,
|
|
|
|
|
SaveStateSlot3,
|
|
|
|
|
SaveStateSlot4,
|
|
|
|
|
SaveStateSlot5,
|
|
|
|
|
SaveStateSlot6,
|
|
|
|
|
SaveStateSlot7,
|
|
|
|
|
SaveStateToFile,
|
|
|
|
|
|
|
|
|
|
LoadStateSlot1,
|
|
|
|
|
LoadStateSlot2,
|
|
|
|
|
LoadStateSlot3,
|
|
|
|
|
LoadStateSlot4,
|
|
|
|
|
LoadStateSlot5,
|
|
|
|
|
LoadStateSlot6,
|
|
|
|
|
LoadStateSlot7,
|
|
|
|
|
LoadStateSlot8,
|
|
|
|
|
LoadStateFromFile,
|
|
|
|
|
|
|
|
|
|
OpenFile,
|
|
|
|
|
OpenDebugger,
|
|
|
|
|
OpenAssembler,
|
|
|
|
|
OpenPpuViewer,
|
|
|
|
|
OpenMemoryTools,
|
|
|
|
|
OpenScriptWindow,
|
2017-09-08 13:28:46 -04:00
|
|
|
|
OpenTraceLogger,
|
2018-01-01 23:23:18 -05:00
|
|
|
|
OpenApuViewer,
|
2016-09-02 19:36:37 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-28 18:58:22 -04:00
|
|
|
|
public struct InteropCheatInfo
|
|
|
|
|
{
|
|
|
|
|
public CheatType CheatType;
|
|
|
|
|
public UInt32 ProActionRockyCode;
|
|
|
|
|
public UInt32 Address;
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
|
|
|
|
|
public byte[] GameGenieCode;
|
|
|
|
|
public byte Value;
|
|
|
|
|
public byte CompareValue;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool UseCompareValue;
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool IsRelativeAddress;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-09 13:15:43 -05:00
|
|
|
|
public struct InteropBreakpoint
|
|
|
|
|
{
|
2018-02-10 21:23:22 -05:00
|
|
|
|
public DebugMemoryType MemoryType;
|
2016-01-09 13:15:43 -05:00
|
|
|
|
public BreakpointType Type;
|
2016-12-04 12:21:20 -05:00
|
|
|
|
public Int32 StartAddress;
|
|
|
|
|
public Int32 EndAddress;
|
|
|
|
|
|
2016-01-09 13:15:43 -05:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1000)]
|
|
|
|
|
public byte[] Condition;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-25 20:46:54 -04:00
|
|
|
|
public struct NsfHeader
|
|
|
|
|
{
|
|
|
|
|
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 5)]
|
|
|
|
|
public Byte[] Header;
|
|
|
|
|
|
|
|
|
|
public Byte Version;
|
|
|
|
|
public Byte TotalSongs;
|
|
|
|
|
public Byte StartingSong;
|
|
|
|
|
public UInt16 LoadAddress;
|
|
|
|
|
public UInt16 InitAddress;
|
|
|
|
|
public UInt16 PlayAddress;
|
|
|
|
|
|
|
|
|
|
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 256)]
|
|
|
|
|
public Byte[] SongName;
|
|
|
|
|
|
|
|
|
|
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 256)]
|
|
|
|
|
public Byte[] ArtistName;
|
|
|
|
|
|
|
|
|
|
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 256)]
|
|
|
|
|
public Byte[] CopyrightHolder;
|
|
|
|
|
|
|
|
|
|
public UInt16 PlaySpeedNtsc;
|
|
|
|
|
|
|
|
|
|
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 8)]
|
|
|
|
|
public Byte[] BankSetup;
|
|
|
|
|
|
|
|
|
|
public UInt16 PlaySpeedPal;
|
|
|
|
|
public Byte Flags;
|
|
|
|
|
public Byte SoundChips;
|
|
|
|
|
|
|
|
|
|
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4)]
|
|
|
|
|
public Byte[] Padding;
|
|
|
|
|
|
|
|
|
|
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 256)]
|
|
|
|
|
public Byte[] RipperName;
|
|
|
|
|
|
|
|
|
|
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 20000)]
|
|
|
|
|
public Byte[] TrackName;
|
|
|
|
|
|
|
|
|
|
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 256)]
|
|
|
|
|
public Int32[] TrackLength;
|
|
|
|
|
|
|
|
|
|
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 256)]
|
|
|
|
|
public Int32[] TrackFade;
|
|
|
|
|
|
|
|
|
|
private string ConvertString(Byte[] input)
|
|
|
|
|
{
|
|
|
|
|
string output = Encoding.UTF8.GetString(input, 0, Array.IndexOf(input, (Byte)0));
|
2016-06-26 15:08:46 -04:00
|
|
|
|
if(output.Length == 0 || output == "<?>") {
|
|
|
|
|
return ResourceHelper.GetMessage("NsfUnknownField");
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-25 20:46:54 -04:00
|
|
|
|
if(output[0] == 0xFFFD) {
|
|
|
|
|
//Patch to convert an invalid character at index 0 to a copyright sign
|
|
|
|
|
//This is usually the case for NSFe files (not sure what the encoding for NSF/NSFe is meant to be. Is it properly defined?)
|
|
|
|
|
return "©" + output.Substring(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-13 11:00:43 -04:00
|
|
|
|
public bool HasSongName { get { return this.GetSongName() != ResourceHelper.GetMessage("NsfUnknownField"); } }
|
|
|
|
|
|
2016-06-25 20:46:54 -04:00
|
|
|
|
public string GetSongName()
|
|
|
|
|
{
|
|
|
|
|
return ConvertString(this.SongName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetArtistName()
|
|
|
|
|
{
|
|
|
|
|
return ConvertString(this.ArtistName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetCopyrightHolder()
|
|
|
|
|
{
|
|
|
|
|
return ConvertString(this.CopyrightHolder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetRipperName()
|
|
|
|
|
{
|
|
|
|
|
return ConvertString(this.RipperName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string[] GetTrackNames()
|
|
|
|
|
{
|
|
|
|
|
return Encoding.UTF8.GetString(this.TrackName, 0, Array.IndexOf(this.TrackName, (Byte)0)).Split(new string[] { "[!|!]" }, StringSplitOptions.None);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-22 15:08:58 -05:00
|
|
|
|
public enum RecordMovieFrom
|
|
|
|
|
{
|
|
|
|
|
StartWithoutSaveData,
|
|
|
|
|
StartWithSaveData,
|
|
|
|
|
CurrentState
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct RecordMovieOptions
|
|
|
|
|
{
|
|
|
|
|
private const int AuthorMaxSize = 250;
|
|
|
|
|
private const int DescriptionMaxSize = 10000;
|
|
|
|
|
private const int FilenameMaxSize = 2000;
|
|
|
|
|
|
|
|
|
|
public RecordMovieOptions(string filename, string author, string description, RecordMovieFrom recordFrom)
|
|
|
|
|
{
|
|
|
|
|
Author = Encoding.UTF8.GetBytes(author);
|
|
|
|
|
Array.Resize(ref Author, AuthorMaxSize);
|
|
|
|
|
Author[AuthorMaxSize-1] = 0;
|
|
|
|
|
|
|
|
|
|
Description = Encoding.UTF8.GetBytes(description.Replace("\r", ""));
|
|
|
|
|
Array.Resize(ref Description, DescriptionMaxSize);
|
|
|
|
|
Description[DescriptionMaxSize-1] = 0;
|
|
|
|
|
|
|
|
|
|
Filename = Encoding.UTF8.GetBytes(filename);
|
|
|
|
|
Array.Resize(ref Filename, FilenameMaxSize);
|
|
|
|
|
Filename[FilenameMaxSize-1] = 0;
|
|
|
|
|
|
|
|
|
|
RecordFrom = recordFrom;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = FilenameMaxSize)]
|
|
|
|
|
public byte[] Filename;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = AuthorMaxSize)]
|
|
|
|
|
public byte[] Author;
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DescriptionMaxSize)]
|
|
|
|
|
public byte[] Description;
|
|
|
|
|
|
|
|
|
|
public RecordMovieFrom RecordFrom;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-09 13:15:43 -05:00
|
|
|
|
[Flags]
|
2015-07-19 11:55:53 -04:00
|
|
|
|
public enum BreakpointType
|
|
|
|
|
{
|
2016-01-09 13:15:43 -05:00
|
|
|
|
Global = 0,
|
|
|
|
|
Execute = 1,
|
|
|
|
|
Read = 2,
|
|
|
|
|
Write = 4,
|
|
|
|
|
ReadVram = 8,
|
|
|
|
|
WriteVram = 16
|
2016-01-10 13:23:19 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum EvalResultType
|
|
|
|
|
{
|
|
|
|
|
Numeric = 0,
|
|
|
|
|
Boolean = 1,
|
2017-12-29 22:08:50 -05:00
|
|
|
|
Invalid = 2,
|
|
|
|
|
DivideBy0 = 3
|
2016-01-10 13:23:19 -05:00
|
|
|
|
}
|
2015-07-19 11:55:53 -04:00
|
|
|
|
|
2015-07-21 23:05:27 -04:00
|
|
|
|
public enum NesModel
|
|
|
|
|
{
|
|
|
|
|
Auto = 0,
|
|
|
|
|
NTSC = 1,
|
2016-01-30 19:33:32 -05:00
|
|
|
|
PAL = 2,
|
|
|
|
|
Dendy = 3,
|
2015-07-21 23:05:27 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
|
public enum ConsoleType
|
|
|
|
|
{
|
|
|
|
|
Nes = 0,
|
2016-07-10 09:05:41 -04:00
|
|
|
|
Famicom = 1
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-24 17:32:22 -04:00
|
|
|
|
public enum RamPowerOnState
|
|
|
|
|
{
|
|
|
|
|
AllZeros = 0,
|
|
|
|
|
AllOnes = 1,
|
|
|
|
|
Random = 2
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:57:50 -05:00
|
|
|
|
public enum AudioChannel
|
|
|
|
|
{
|
|
|
|
|
Square1 = 0,
|
|
|
|
|
Square2 = 1,
|
|
|
|
|
Triangle = 2,
|
|
|
|
|
Noise = 3,
|
|
|
|
|
DMC = 4,
|
|
|
|
|
FDS = 5,
|
|
|
|
|
MMC5 = 6,
|
|
|
|
|
VRC6 = 7,
|
|
|
|
|
VRC7 = 8,
|
|
|
|
|
Namco163 = 9,
|
|
|
|
|
Sunsoft5B = 10
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-15 13:54:47 -04:00
|
|
|
|
public enum EqualizerFilterType
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
Butterworth = 1,
|
|
|
|
|
Chebyshev1 = 2,
|
|
|
|
|
Chebyshev2 = 3
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-29 21:19:13 -05:00
|
|
|
|
public enum VideoCodec
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
ZMBV = 1,
|
2017-01-01 10:15:42 -05:00
|
|
|
|
CSCD = 2,
|
2016-12-29 21:19:13 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-28 19:00:08 -04:00
|
|
|
|
public enum ScaleFilterType
|
|
|
|
|
{
|
|
|
|
|
xBRZ = 0,
|
|
|
|
|
HQX = 1,
|
|
|
|
|
Scale2x = 2,
|
|
|
|
|
_2xSai = 3,
|
|
|
|
|
Super2xSai = 4,
|
|
|
|
|
SuperEagle = 5,
|
|
|
|
|
Prescale = 6,
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-05 21:28:38 -05:00
|
|
|
|
public enum VideoFilterType
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
NTSC = 1,
|
2016-12-27 15:04:20 -05:00
|
|
|
|
BisqwitNtscQuarterRes = 2,
|
|
|
|
|
BisqwitNtscHalfRes = 3,
|
|
|
|
|
BisqwitNtsc = 4,
|
|
|
|
|
xBRZ2x = 5,
|
|
|
|
|
xBRZ3x = 6,
|
|
|
|
|
xBRZ4x = 7,
|
|
|
|
|
xBRZ5x = 8,
|
|
|
|
|
xBRZ6x = 9,
|
|
|
|
|
HQ2x = 10,
|
|
|
|
|
HQ3x = 11,
|
|
|
|
|
HQ4x = 12,
|
|
|
|
|
Scale2x = 13,
|
|
|
|
|
Scale3x = 14,
|
|
|
|
|
Scale4x = 15,
|
|
|
|
|
_2xSai = 16,
|
|
|
|
|
Super2xSai = 17,
|
|
|
|
|
SuperEagle = 18,
|
|
|
|
|
Prescale2x = 19,
|
|
|
|
|
Prescale3x = 20,
|
|
|
|
|
Prescale4x = 21,
|
2017-03-19 13:26:05 -04:00
|
|
|
|
Prescale6x = 22,
|
|
|
|
|
Prescale8x = 23,
|
|
|
|
|
Prescale10x = 24,
|
2016-01-05 21:28:38 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-24 19:45:58 -04:00
|
|
|
|
public enum VideoResizeFilter
|
|
|
|
|
{
|
|
|
|
|
NearestNeighbor = 0,
|
|
|
|
|
Bilinear = 1
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-06 20:34:45 -05:00
|
|
|
|
public enum VideoAspectRatio
|
|
|
|
|
{
|
2017-06-08 21:23:51 -04:00
|
|
|
|
NoStretching = 0,
|
|
|
|
|
Auto = 1,
|
|
|
|
|
NTSC = 2,
|
|
|
|
|
PAL = 3,
|
|
|
|
|
Standard = 4,
|
|
|
|
|
Widescreen = 5,
|
|
|
|
|
Custom = 6
|
2016-01-06 20:34:45 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-28 10:59:27 -05:00
|
|
|
|
public enum VideoRefreshRates
|
|
|
|
|
{
|
|
|
|
|
_50 = 50,
|
|
|
|
|
_60 = 60,
|
|
|
|
|
_100 = 100,
|
|
|
|
|
_120 = 120,
|
|
|
|
|
_200 = 200,
|
|
|
|
|
_240 = 240
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
|
[Flags]
|
|
|
|
|
public enum ConsoleFeatures
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
Fds = 1,
|
|
|
|
|
Nsf = 2,
|
|
|
|
|
VsSystem = 4,
|
|
|
|
|
BarcodeReader = 8,
|
2017-11-24 21:38:12 -05:00
|
|
|
|
TapeRecorder = 16,
|
2017-12-25 23:26:35 -05:00
|
|
|
|
BandaiMicrophone = 32,
|
|
|
|
|
DatachBarcodeReader = 64,
|
2017-11-19 23:08:23 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-11 20:55:33 -05:00
|
|
|
|
public enum ScreenRotation
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
_90Degrees = 90,
|
|
|
|
|
_180Degrees = 180,
|
|
|
|
|
_270Degrees = 270
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-05 20:40:10 -04:00
|
|
|
|
public enum DebugMemoryType
|
|
|
|
|
{
|
|
|
|
|
CpuMemory = 0,
|
|
|
|
|
PpuMemory = 1,
|
2015-08-05 21:43:53 -04:00
|
|
|
|
PaletteMemory = 2,
|
|
|
|
|
SpriteMemory = 3,
|
|
|
|
|
SecondarySpriteMemory = 4,
|
|
|
|
|
PrgRom = 5,
|
|
|
|
|
ChrRom = 6,
|
2016-01-19 20:16:00 -05:00
|
|
|
|
ChrRam = 7,
|
2016-09-05 09:05:34 -04:00
|
|
|
|
WorkRam = 8,
|
|
|
|
|
SaveRam = 9,
|
|
|
|
|
InternalRam = 10
|
2015-08-05 20:40:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 22:38:14 -05:00
|
|
|
|
public enum AddressType
|
|
|
|
|
{
|
|
|
|
|
InternalRam = 0,
|
|
|
|
|
PrgRom = 1,
|
|
|
|
|
WorkRam = 2,
|
|
|
|
|
SaveRam = 3,
|
2016-11-23 18:48:29 -05:00
|
|
|
|
Register = 4
|
2016-11-22 22:38:14 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-10 21:23:22 -05:00
|
|
|
|
public static class AddressTypeExtensions
|
|
|
|
|
{
|
|
|
|
|
public static DebugMemoryType ToMemoryType(this AddressType type)
|
|
|
|
|
{
|
|
|
|
|
switch(type) {
|
|
|
|
|
case AddressType.InternalRam: return DebugMemoryType.InternalRam;
|
|
|
|
|
case AddressType.Register: return DebugMemoryType.CpuMemory;
|
|
|
|
|
case AddressType.PrgRom: return DebugMemoryType.PrgRom;
|
|
|
|
|
case AddressType.WorkRam: return DebugMemoryType.WorkRam;
|
|
|
|
|
case AddressType.SaveRam: return DebugMemoryType.SaveRam;
|
|
|
|
|
}
|
|
|
|
|
return DebugMemoryType.CpuMemory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static AddressType ToAddressType(this DebugMemoryType type)
|
|
|
|
|
{
|
|
|
|
|
switch(type) {
|
|
|
|
|
case DebugMemoryType.InternalRam: return AddressType.InternalRam;
|
|
|
|
|
case DebugMemoryType.CpuMemory: return AddressType.Register;
|
|
|
|
|
case DebugMemoryType.PrgRom: return AddressType.PrgRom;
|
|
|
|
|
case DebugMemoryType.WorkRam: return AddressType.WorkRam;
|
|
|
|
|
case DebugMemoryType.SaveRam: return AddressType.SaveRam;
|
|
|
|
|
}
|
|
|
|
|
return AddressType.Register;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-01 19:38:48 -05:00
|
|
|
|
public enum MemoryOperationType
|
|
|
|
|
{
|
|
|
|
|
//Note: Not identical to the C++ enum
|
|
|
|
|
Read = 0,
|
|
|
|
|
Write = 1,
|
|
|
|
|
Exec = 2,
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-28 19:00:08 -04:00
|
|
|
|
[Flags]
|
|
|
|
|
public enum HdPackRecordFlags
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
UseLargeSprites = 1,
|
|
|
|
|
SortByUsageFrequency = 2,
|
|
|
|
|
GroupBlankTiles = 4,
|
2017-08-12 21:21:55 -04:00
|
|
|
|
IgnoreOverscan = 8,
|
2017-06-28 19:00:08 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 22:38:14 -05:00
|
|
|
|
public struct AddressTypeInfo
|
|
|
|
|
{
|
|
|
|
|
public Int32 Address;
|
|
|
|
|
public AddressType Type;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-05 19:05:33 -04:00
|
|
|
|
public class MD5Helper
|
|
|
|
|
{
|
|
|
|
|
public static string GetMD5Hash(string filename)
|
|
|
|
|
{
|
2016-01-28 22:36:27 -05:00
|
|
|
|
if(File.Exists(filename)) {
|
|
|
|
|
var md5 = System.Security.Cryptography.MD5.Create();
|
2016-06-17 20:53:05 -04:00
|
|
|
|
return BitConverter.ToString(md5.ComputeHash(File.ReadAllBytes(filename))).Replace("-", "");
|
2015-07-05 19:05:33 -04:00
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-11 08:27:22 -04:00
|
|
|
|
|
|
|
|
|
public class UTF8Marshaler : ICustomMarshaler
|
|
|
|
|
{
|
|
|
|
|
static UTF8Marshaler _instance;
|
|
|
|
|
|
|
|
|
|
public IntPtr MarshalManagedToNative(object managedObj)
|
|
|
|
|
{
|
|
|
|
|
if(managedObj == null) {
|
|
|
|
|
return IntPtr.Zero;
|
|
|
|
|
}
|
|
|
|
|
if(!(managedObj is string)) {
|
|
|
|
|
throw new MarshalDirectiveException("UTF8Marshaler must be used on a string.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// not null terminated
|
|
|
|
|
byte[] strbuf = Encoding.UTF8.GetBytes((string)managedObj);
|
|
|
|
|
IntPtr buffer = Marshal.AllocHGlobal(strbuf.Length + 1);
|
|
|
|
|
Marshal.Copy(strbuf, 0, buffer, strbuf.Length);
|
|
|
|
|
|
|
|
|
|
// write the terminating null
|
|
|
|
|
Marshal.WriteByte(buffer + strbuf.Length, 0);
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-16 22:41:21 -05:00
|
|
|
|
public object MarshalNativeToManaged(IntPtr pNativeData)
|
2015-07-11 08:27:22 -04:00
|
|
|
|
{
|
2016-06-17 20:53:05 -04:00
|
|
|
|
return GetStringFromIntPtr(pNativeData);
|
2015-07-11 08:27:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CleanUpNativeData(IntPtr pNativeData)
|
|
|
|
|
{
|
|
|
|
|
Marshal.FreeHGlobal(pNativeData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CleanUpManagedData(object managedObj)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetNativeDataSize()
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ICustomMarshaler GetInstance(string cookie)
|
|
|
|
|
{
|
|
|
|
|
if(_instance == null) {
|
|
|
|
|
return _instance = new UTF8Marshaler();
|
|
|
|
|
}
|
|
|
|
|
return _instance;
|
|
|
|
|
}
|
2016-06-17 20:53:05 -04:00
|
|
|
|
|
|
|
|
|
public static string GetStringFromIntPtr(IntPtr pNativeData)
|
|
|
|
|
{
|
|
|
|
|
int offset = 0;
|
|
|
|
|
byte b = 0;
|
|
|
|
|
do {
|
|
|
|
|
b = Marshal.ReadByte(pNativeData, offset);
|
|
|
|
|
offset++;
|
|
|
|
|
} while(b != 0);
|
|
|
|
|
|
|
|
|
|
int length = offset - 1;
|
|
|
|
|
|
|
|
|
|
// should not be null terminated
|
|
|
|
|
byte[] strbuf = new byte[length];
|
|
|
|
|
// skip the trailing null
|
|
|
|
|
Marshal.Copy((IntPtr)pNativeData, strbuf, 0, length);
|
|
|
|
|
string data = Encoding.UTF8.GetString(strbuf);
|
|
|
|
|
return data;
|
|
|
|
|
}
|
2015-07-11 08:27:22 -04:00
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|