2015-07-01 23:17:14 -04:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
#include "../Core/MessageManager.h"
|
2018-07-02 14:49:19 -04:00
|
|
|
#include "../Core/NotificationManager.h"
|
2015-07-01 23:17:14 -04:00
|
|
|
#include "../Core/Console.h"
|
|
|
|
#include "../Core/GameServer.h"
|
|
|
|
#include "../Core/GameClient.h"
|
|
|
|
#include "../Core/ClientConnectionData.h"
|
|
|
|
#include "../Core/SaveStateManager.h"
|
2015-07-05 19:05:33 -04:00
|
|
|
#include "../Core/CheatManager.h"
|
2015-07-17 20:58:57 -04:00
|
|
|
#include "../Core/EmulationSettings.h"
|
2015-07-23 23:16:31 -04:00
|
|
|
#include "../Core/VideoDecoder.h"
|
2017-04-28 19:54:58 -04:00
|
|
|
#include "../Core/VideoRenderer.h"
|
2017-04-23 18:47:28 -04:00
|
|
|
#include "../Core/AutomaticRomTest.h"
|
|
|
|
#include "../Core/RecordedRomTest.h"
|
2016-01-28 20:47:16 -05:00
|
|
|
#include "../Core/FDS.h"
|
2016-04-30 20:08:53 -04:00
|
|
|
#include "../Core/VsControlManager.h"
|
2016-06-05 14:36:20 -04:00
|
|
|
#include "../Core/SoundMixer.h"
|
2016-06-17 20:53:05 -04:00
|
|
|
#include "../Core/RomLoader.h"
|
2016-06-25 20:46:54 -04:00
|
|
|
#include "../Core/NsfMapper.h"
|
2016-12-11 10:56:23 -05:00
|
|
|
#include "../Core/IRenderingDevice.h"
|
|
|
|
#include "../Core/IAudioDevice.h"
|
2017-04-18 22:39:45 -04:00
|
|
|
#include "../Core/MovieManager.h"
|
2017-09-30 14:07:07 -04:00
|
|
|
#include "../Core/VirtualFile.h"
|
2017-06-28 19:00:08 -04:00
|
|
|
#include "../Core/HdPackBuilder.h"
|
2016-12-29 21:19:13 -05:00
|
|
|
#include "../Utilities/AviWriter.h"
|
2017-09-08 10:38:41 -04:00
|
|
|
#include "../Core/ShortcutKeyHandler.h"
|
2017-11-19 23:08:23 -05:00
|
|
|
#include "../Core/SystemActionManager.h"
|
|
|
|
#include "../Core/FdsSystemActionManager.h"
|
|
|
|
#include "../Core/VsSystemActionManager.h"
|
|
|
|
#include "../Core/KeyManager.h"
|
2018-06-29 00:06:12 -04:00
|
|
|
#include "../Utilities/SimpleLock.h"
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2018-01-05 15:03:33 -05:00
|
|
|
#ifdef _WIN32
|
2016-12-11 10:56:23 -05:00
|
|
|
#include "../Windows/Renderer.h"
|
|
|
|
#include "../Windows/SoundManager.h"
|
|
|
|
#include "../Windows/WindowsKeyManager.h"
|
|
|
|
#else
|
2016-12-11 16:39:11 -05:00
|
|
|
#include "../Linux/SdlRenderer.h"
|
|
|
|
#include "../Linux/SdlSoundManager.h"
|
|
|
|
#include "../Linux/LinuxKeyManager.h"
|
2016-12-11 10:56:23 -05:00
|
|
|
#endif
|
|
|
|
|
2018-07-02 21:32:59 -04:00
|
|
|
unique_ptr<IRenderingDevice> _renderer;
|
|
|
|
unique_ptr<IAudioDevice> _soundManager;
|
|
|
|
unique_ptr<IKeyManager> _keyManager;
|
2017-09-08 10:38:41 -04:00
|
|
|
unique_ptr<ShortcutKeyHandler> _shortcutKeyHandler;
|
|
|
|
|
2018-07-02 21:32:59 -04:00
|
|
|
unique_ptr<IRenderingDevice> _dualRenderer;
|
|
|
|
unique_ptr<IAudioDevice> _dualSoundManager;
|
|
|
|
|
2018-06-09 15:42:27 -04:00
|
|
|
void* _windowHandle = nullptr;
|
2016-12-11 10:56:23 -05:00
|
|
|
void* _viewerHandle = nullptr;
|
2015-12-26 17:11:00 -05:00
|
|
|
string _returnString;
|
2016-06-19 16:54:34 -04:00
|
|
|
string _logString;
|
2018-07-01 15:21:05 -04:00
|
|
|
shared_ptr<Console> _console;
|
2018-06-29 00:06:12 -04:00
|
|
|
shared_ptr<RecordedRomTest> _recordedRomTest;
|
|
|
|
SimpleLock _externalNotificationListenerLock;
|
|
|
|
vector<shared_ptr<INotificationListener>> _externalNotificationListeners;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
typedef void (__stdcall *NotificationListenerCallback)(int, void*);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2018-07-06 00:10:10 -04:00
|
|
|
shared_ptr<Console> GetConsoleById(int32_t consoleId)
|
|
|
|
{
|
|
|
|
shared_ptr<Console> console;
|
|
|
|
if(consoleId == 1) {
|
|
|
|
//Get the VS Dualsystem's 2nd CPU, only if it's available (and requested)
|
|
|
|
console = _console->GetDualConsole();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!console) {
|
|
|
|
//Otherwise return the main CPU
|
|
|
|
console = _console;
|
|
|
|
}
|
|
|
|
return console;
|
|
|
|
}
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
namespace InteropEmu {
|
|
|
|
class InteropNotificationListener : public INotificationListener
|
|
|
|
{
|
|
|
|
NotificationListenerCallback _callback;
|
|
|
|
public:
|
|
|
|
InteropNotificationListener(NotificationListenerCallback callback)
|
|
|
|
{
|
|
|
|
_callback = callback;
|
|
|
|
}
|
2018-07-02 19:01:10 -04:00
|
|
|
|
|
|
|
virtual ~InteropNotificationListener()
|
|
|
|
{
|
|
|
|
}
|
2018-06-29 00:06:12 -04:00
|
|
|
|
2015-12-26 17:11:00 -05:00
|
|
|
void ProcessNotification(ConsoleNotificationType type, void* parameter)
|
2015-07-01 23:17:14 -04:00
|
|
|
{
|
2017-09-08 10:38:41 -04:00
|
|
|
_callback((int)type, parameter);
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-17 20:53:05 -04:00
|
|
|
struct RomInfo
|
|
|
|
{
|
|
|
|
const char* RomName;
|
|
|
|
uint32_t Crc32;
|
2016-07-10 09:05:41 -04:00
|
|
|
uint32_t PrgCrc32;
|
2017-03-04 22:24:41 -05:00
|
|
|
RomFormat Format;
|
2017-06-28 19:00:08 -04:00
|
|
|
bool IsChrRam;
|
2018-03-03 15:40:11 -05:00
|
|
|
uint16_t MapperId;
|
2018-06-19 23:51:15 -04:00
|
|
|
char Sha1[40];
|
2016-06-17 20:53:05 -04:00
|
|
|
};
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
extern "C" {
|
2016-01-16 19:33:10 -05:00
|
|
|
DllExport bool __stdcall TestDll()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-08 23:23:31 -05:00
|
|
|
DllExport uint32_t __stdcall GetMesenVersion() { return EmulationSettings::GetMesenVersion(); }
|
|
|
|
|
2016-12-11 10:56:23 -05:00
|
|
|
DllExport void __stdcall InitializeEmu(const char* homeFolder, void *windowHandle, void *viewerHandle, bool noAudio, bool noVideo, bool noInput)
|
2015-07-01 23:17:14 -04:00
|
|
|
{
|
2015-07-05 19:21:49 -04:00
|
|
|
FolderUtilities::SetHomeFolder(homeFolder);
|
2018-07-01 15:21:05 -04:00
|
|
|
_console.reset(new Console());
|
|
|
|
_console->Init();
|
|
|
|
_shortcutKeyHandler.reset(new ShortcutKeyHandler(_console));
|
2015-07-05 19:21:49 -04:00
|
|
|
|
2016-12-11 10:56:23 -05:00
|
|
|
if(windowHandle != nullptr && viewerHandle != nullptr) {
|
2015-08-23 11:45:13 -04:00
|
|
|
_windowHandle = windowHandle;
|
2016-12-11 10:56:23 -05:00
|
|
|
_viewerHandle = viewerHandle;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2016-07-23 15:28:52 -04:00
|
|
|
if(!noVideo) {
|
2016-12-11 10:56:23 -05:00
|
|
|
#ifdef _WIN32
|
2018-07-02 21:32:59 -04:00
|
|
|
_renderer.reset(new Renderer(_console, (HWND)_viewerHandle));
|
2016-12-11 10:56:23 -05:00
|
|
|
#else
|
2018-07-02 21:32:59 -04:00
|
|
|
_renderer.reset(new SdlRenderer(_console, _viewerHandle));
|
2016-12-11 10:56:23 -05:00
|
|
|
#endif
|
2016-07-23 15:28:52 -04:00
|
|
|
}
|
2015-07-10 21:07:24 -04:00
|
|
|
|
2016-07-23 15:28:52 -04:00
|
|
|
if(!noAudio) {
|
2016-12-11 10:56:23 -05:00
|
|
|
#ifdef _WIN32
|
2018-07-02 21:32:59 -04:00
|
|
|
_soundManager.reset(new SoundManager(_console, (HWND)_windowHandle));
|
2016-12-11 10:56:23 -05:00
|
|
|
#else
|
2018-07-02 21:32:59 -04:00
|
|
|
_soundManager.reset(new SdlSoundManager(_console));
|
2016-12-11 10:56:23 -05:00
|
|
|
#endif
|
2016-07-23 15:28:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!noInput) {
|
2016-12-11 10:56:23 -05:00
|
|
|
#ifdef _WIN32
|
2018-07-02 21:32:59 -04:00
|
|
|
_keyManager.reset(new WindowsKeyManager(_console, (HWND)_windowHandle));
|
2016-12-11 10:56:23 -05:00
|
|
|
#else
|
2018-07-02 21:32:59 -04:00
|
|
|
_keyManager.reset(new LinuxKeyManager(_console));
|
2016-12-11 10:56:23 -05:00
|
|
|
#endif
|
|
|
|
|
2018-07-02 21:32:59 -04:00
|
|
|
KeyManager::RegisterKeyManager(_keyManager.get());
|
2016-07-23 15:28:52 -04:00
|
|
|
}
|
2015-07-10 21:07:24 -04:00
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
2018-07-02 21:32:59 -04:00
|
|
|
|
|
|
|
DllExport void __stdcall InitializeDualSystem(void *windowHandle, void *viewerHandle)
|
|
|
|
{
|
|
|
|
shared_ptr<Console> slaveConsole = _console->GetDualConsole();
|
|
|
|
if(slaveConsole){
|
|
|
|
_console->Pause();
|
|
|
|
#ifdef _WIN32
|
|
|
|
_dualRenderer.reset(new Renderer(slaveConsole, (HWND)viewerHandle));
|
|
|
|
_dualSoundManager.reset(new SoundManager(slaveConsole, (HWND)windowHandle));
|
|
|
|
#else
|
|
|
|
_dualRenderer.reset(new SdlRenderer(slaveConsole, viewerHandle));
|
|
|
|
_dualSoundManager.reset(new SdlSoundManager(slaveConsole));
|
|
|
|
#endif
|
|
|
|
_console->Resume();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall ReleaseDualSystemAudioVideo()
|
|
|
|
{
|
|
|
|
_console->Pause();
|
|
|
|
_dualRenderer.reset();
|
|
|
|
_dualSoundManager.reset();
|
|
|
|
_console->Resume();
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2017-11-29 23:24:26 -05:00
|
|
|
DllExport void __stdcall SetFullscreenMode(bool fullscreen, void *windowHandle, uint32_t monitorWidth, uint32_t monitorHeight)
|
|
|
|
{
|
|
|
|
if(_renderer) {
|
|
|
|
_renderer->SetFullscreenMode(fullscreen, windowHandle, monitorWidth, monitorHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport bool __stdcall IsRunning() { return _console->IsRunning(); }
|
|
|
|
DllExport int32_t __stdcall GetStopCode() { return _console->GetStopCode(); }
|
2016-02-14 12:58:35 -05:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall LoadROM(char* filename, char* patchFile) { _console->Initialize(filename, patchFile); }
|
2016-12-09 12:49:17 -05:00
|
|
|
DllExport void __stdcall AddKnownGameFolder(char* folder) { FolderUtilities::AddKnownGameFolder(folder); }
|
2017-08-11 22:20:07 -04:00
|
|
|
DllExport void __stdcall SetFolderOverrides(char* saveFolder, char* saveStateFolder, char* screenshotFolder) { FolderUtilities::SetFolderOverrides(saveFolder, saveStateFolder, screenshotFolder); }
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall LoadRecentGame(char* filepath, bool resetGame) { _console->GetSaveStateManager()->LoadRecentGame(filepath, resetGame); }
|
2015-07-05 22:23:44 -04:00
|
|
|
|
2016-06-17 20:53:05 -04:00
|
|
|
DllExport const char* __stdcall GetArchiveRomList(char* filename) {
|
|
|
|
std::ostringstream out;
|
2017-07-30 09:03:54 -04:00
|
|
|
shared_ptr<ArchiveReader> reader = ArchiveReader::GetReader(filename);
|
|
|
|
if(reader) {
|
2017-09-30 14:07:07 -04:00
|
|
|
for(string romName : reader->GetFileList(VirtualFile::RomExtensions)) {
|
2017-07-30 09:03:54 -04:00
|
|
|
out << romName << "[!|!]";
|
|
|
|
}
|
2016-06-17 20:53:05 -04:00
|
|
|
}
|
|
|
|
_returnString = out.str();
|
|
|
|
return _returnString.c_str();
|
|
|
|
}
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
DllExport void __stdcall SetControllerType(uint32_t port, ControllerType type) { EmulationSettings::SetControllerType(port, type); }
|
|
|
|
DllExport void __stdcall SetControllerKeys(uint32_t port, KeyMappingSet mappings) { EmulationSettings::SetControllerKeys(port, mappings); }
|
2017-07-30 19:22:01 -04:00
|
|
|
DllExport void __stdcall SetZapperDetectionRadius(uint32_t detectionRadius) { EmulationSettings::SetZapperDetectionRadius(detectionRadius); }
|
2016-02-05 23:14:27 -05:00
|
|
|
DllExport void __stdcall SetExpansionDevice(ExpansionPortDevice device) { EmulationSettings::SetExpansionDevice(device); }
|
|
|
|
DllExport void __stdcall SetConsoleType(ConsoleType type) { EmulationSettings::SetConsoleType(type); }
|
2017-12-21 21:31:42 -05:00
|
|
|
DllExport void __stdcall SetMouseSensitivity(MouseDevice device, double sensitivity) { EmulationSettings::SetMouseSensitivity(device, sensitivity); }
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
|
|
DllExport void __stdcall ClearShortcutKeys() { EmulationSettings::ClearShortcutKeys(); }
|
|
|
|
DllExport void __stdcall SetShortcutKey(EmulatorShortcut shortcut, KeyCombination keyCombination, int keySetIndex) { EmulationSettings::SetShortcutKey(shortcut, keyCombination, keySetIndex); }
|
2016-07-09 15:58:49 -04:00
|
|
|
|
|
|
|
DllExport ControllerType __stdcall GetControllerType(uint32_t port) { return EmulationSettings::GetControllerType(port); }
|
|
|
|
DllExport ExpansionPortDevice GetExpansionDevice() { return EmulationSettings::GetExpansionDevice(); }
|
|
|
|
DllExport ConsoleType __stdcall GetConsoleType() { return EmulationSettings::GetConsoleType(); }
|
2016-02-05 23:14:27 -05:00
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
DllExport bool __stdcall HasZapper() { return EmulationSettings::HasZapper(); }
|
2016-07-09 15:58:49 -04:00
|
|
|
DllExport bool __stdcall HasFourScore() { return EmulationSettings::CheckFlag(EmulationFlags::HasFourScore); }
|
2016-02-14 12:58:35 -05:00
|
|
|
DllExport bool __stdcall HasArkanoidPaddle() { return EmulationSettings::HasArkanoidPaddle(); }
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
DllExport void __stdcall SetMousePosition(double x, double y) { KeyManager::SetMousePosition(x, y); }
|
|
|
|
DllExport void __stdcall SetMouseMovement(int16_t x, int16_t y) { KeyManager::SetMouseMovement(x, y); }
|
2015-07-10 21:07:24 -04:00
|
|
|
|
2016-07-23 15:28:52 -04:00
|
|
|
DllExport void __stdcall UpdateInputDevices() { if(_keyManager) { _keyManager->UpdateDevices(); } }
|
2017-09-08 10:38:41 -04:00
|
|
|
DllExport void __stdcall GetPressedKeys(uint32_t *keyBuffer) {
|
2017-11-19 23:08:23 -05:00
|
|
|
vector<uint32_t> pressedKeys = KeyManager::GetPressedKeys();
|
2017-09-08 22:17:23 -04:00
|
|
|
for(size_t i = 0; i < pressedKeys.size() && i < 3; i++) {
|
2017-09-08 10:38:41 -04:00
|
|
|
keyBuffer[i] = pressedKeys[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DllExport void __stdcall DisableAllKeys(bool disabled) {
|
|
|
|
if(_keyManager) {
|
|
|
|
_keyManager->SetDisabled(disabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DllExport void __stdcall SetKeyState(int32_t scanCode, bool state) {
|
|
|
|
if(_keyManager) {
|
|
|
|
_keyManager->SetKeyState(scanCode, state);
|
|
|
|
_shortcutKeyHandler->ProcessKeys();
|
|
|
|
}
|
|
|
|
}
|
2016-07-28 17:45:18 -04:00
|
|
|
DllExport void __stdcall ResetKeyState() { if(_keyManager) { _keyManager->ResetKeyState(); } }
|
2015-07-11 08:27:22 -04:00
|
|
|
DllExport const char* __stdcall GetKeyName(uint32_t keyCode)
|
|
|
|
{
|
2017-11-19 23:08:23 -05:00
|
|
|
_returnString = KeyManager::GetKeyName(keyCode);
|
2015-07-11 08:27:22 -04:00
|
|
|
return _returnString.c_str();
|
|
|
|
}
|
2016-02-05 23:14:27 -05:00
|
|
|
DllExport uint32_t __stdcall GetKeyCode(char* keyName) {
|
|
|
|
if(keyName) {
|
2017-11-19 23:08:23 -05:00
|
|
|
return KeyManager::GetKeyCode(keyName);
|
2016-02-05 23:14:27 -05:00
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2015-07-10 21:07:24 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
DllExport void __stdcall Run()
|
|
|
|
{
|
2018-07-01 15:21:05 -04:00
|
|
|
if(_console) {
|
|
|
|
_console->Run();
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-17 20:58:57 -04:00
|
|
|
DllExport void __stdcall Resume() { EmulationSettings::ClearFlags(EmulationFlags::Paused); }
|
2016-01-16 19:33:10 -05:00
|
|
|
DllExport bool __stdcall IsPaused() { return EmulationSettings::CheckFlag(EmulationFlags::Paused); }
|
2015-07-01 23:17:14 -04:00
|
|
|
DllExport void __stdcall Stop()
|
|
|
|
{
|
2018-07-01 15:21:05 -04:00
|
|
|
if(_console) {
|
2017-07-30 09:03:54 -04:00
|
|
|
GameServer::StopServer();
|
|
|
|
GameClient::Disconnect();
|
2018-07-01 15:21:05 -04:00
|
|
|
_console->Stop();
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
|
|
|
}
|
2016-06-17 20:53:05 -04:00
|
|
|
|
2018-06-25 16:21:15 -04:00
|
|
|
DllExport void __stdcall GetRomInfo(RomInfo &romInfo, char* filename)
|
2015-07-05 19:05:33 -04:00
|
|
|
{
|
2016-06-17 20:53:05 -04:00
|
|
|
string romPath = filename;
|
|
|
|
if(romPath.empty()) {
|
2018-07-01 15:21:05 -04:00
|
|
|
_returnString = _console->GetRomPath();
|
2016-06-17 20:53:05 -04:00
|
|
|
romInfo.RomName = _returnString.c_str();
|
2018-07-01 15:21:05 -04:00
|
|
|
MapperInfo mapperInfo = _console->GetMapperInfo();
|
2018-03-20 22:05:38 -04:00
|
|
|
romInfo.Crc32 = mapperInfo.Hash.Crc32Hash;
|
|
|
|
romInfo.PrgCrc32 = mapperInfo.Hash.PrgCrc32Hash;
|
2018-03-24 10:21:11 -04:00
|
|
|
romInfo.Format = mapperInfo.Format;
|
2018-03-20 22:05:38 -04:00
|
|
|
romInfo.IsChrRam = mapperInfo.UsesChrRam;
|
|
|
|
romInfo.MapperId = mapperInfo.MapperId;
|
2018-06-19 23:51:15 -04:00
|
|
|
if(mapperInfo.Hash.Sha1Hash.size() == 40) {
|
|
|
|
memcpy(romInfo.Sha1, mapperInfo.Hash.Sha1Hash.c_str(), 40);
|
|
|
|
}
|
2016-06-17 20:53:05 -04:00
|
|
|
} else {
|
2018-02-25 11:27:32 -05:00
|
|
|
RomLoader romLoader(true);
|
2017-07-30 09:03:54 -04:00
|
|
|
if(romLoader.LoadFile(romPath)) {
|
2016-06-17 20:53:05 -04:00
|
|
|
RomData romData = romLoader.GetRomData();
|
|
|
|
|
2017-08-19 21:09:44 -04:00
|
|
|
_returnString = romPath;
|
2016-06-17 20:53:05 -04:00
|
|
|
romInfo.RomName = _returnString.c_str();
|
|
|
|
romInfo.Crc32 = romData.Crc32;
|
2016-07-10 09:05:41 -04:00
|
|
|
romInfo.PrgCrc32 = romData.PrgCrc32;
|
2017-03-04 22:24:41 -05:00
|
|
|
romInfo.Format = RomFormat::Unknown;
|
2017-06-28 19:00:08 -04:00
|
|
|
romInfo.IsChrRam = romData.ChrRom.size() == 0;
|
2018-03-03 15:40:11 -05:00
|
|
|
romInfo.MapperId = 0;
|
2018-06-19 23:51:15 -04:00
|
|
|
if(romData.Sha1.size() == 40) {
|
|
|
|
memcpy(romInfo.Sha1, romData.Sha1.c_str(), 40);
|
|
|
|
}
|
2016-06-26 10:43:52 -04:00
|
|
|
} else {
|
|
|
|
_returnString = "";
|
|
|
|
romInfo.RomName = _returnString.c_str();
|
|
|
|
romInfo.Crc32 = 0;
|
2016-07-10 09:05:41 -04:00
|
|
|
romInfo.PrgCrc32 = 0;
|
2017-03-04 22:24:41 -05:00
|
|
|
romInfo.Format = RomFormat::Unknown;
|
2017-06-28 19:00:08 -04:00
|
|
|
romInfo.IsChrRam = false;
|
2018-03-03 15:40:11 -05:00
|
|
|
romInfo.MapperId = 0;
|
2016-06-17 20:53:05 -04:00
|
|
|
}
|
|
|
|
}
|
2015-07-05 19:05:33 -04:00
|
|
|
}
|
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall Reset() { _console->Reset(true); }
|
|
|
|
DllExport void __stdcall PowerCycle() { _console->Reset(false); }
|
|
|
|
DllExport void __stdcall ResetLagCounter() { _console->ResetLagCounter(); }
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall StartServer(uint16_t port, char* password, char* hostPlayerName) { GameServer::StartServer(_console, port, password, hostPlayerName); }
|
2015-07-01 23:17:14 -04:00
|
|
|
DllExport void __stdcall StopServer() { GameServer::StopServer(); }
|
2016-01-16 19:33:10 -05:00
|
|
|
DllExport bool __stdcall IsServerRunning() { return GameServer::Started(); }
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2018-06-16 14:02:12 -04:00
|
|
|
DllExport void __stdcall Connect(char* host, uint16_t port, char* password, char* playerName, bool spectator)
|
2015-07-01 23:17:14 -04:00
|
|
|
{
|
2018-06-16 14:02:12 -04:00
|
|
|
ClientConnectionData connectionData(host, port, password, playerName, spectator);
|
2018-07-01 15:21:05 -04:00
|
|
|
GameClient::Connect(_console, connectionData);
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall Disconnect() { GameClient::Disconnect(); }
|
2016-01-16 19:33:10 -05:00
|
|
|
DllExport bool __stdcall IsConnected() { return GameClient::Connected(); }
|
2016-02-06 15:33:45 -05:00
|
|
|
DllExport ControllerType __stdcall NetPlayGetControllerType(int32_t port) { return EmulationSettings::GetControllerType(port); }
|
|
|
|
|
|
|
|
DllExport int32_t __stdcall NetPlayGetAvailableControllers()
|
|
|
|
{
|
|
|
|
if(GameServer::Started()) {
|
|
|
|
return GameServer::GetAvailableControllers();
|
|
|
|
} else {
|
|
|
|
return GameClient::GetAvailableControllers();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall NetPlaySelectController(int32_t port)
|
|
|
|
{
|
|
|
|
if(GameServer::Started()) {
|
|
|
|
return GameServer::SetHostControllerPort(port);
|
|
|
|
} else {
|
|
|
|
return GameClient::SelectController(port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DllExport int32_t __stdcall NetPlayGetControllerPort()
|
|
|
|
{
|
|
|
|
if(GameServer::Started()) {
|
|
|
|
return GameServer::GetHostControllerPort();
|
|
|
|
} else {
|
|
|
|
return GameClient::GetControllerPort();
|
|
|
|
}
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
|
|
DllExport void __stdcall Pause()
|
|
|
|
{
|
|
|
|
if(!IsConnected()) {
|
2015-07-17 20:58:57 -04:00
|
|
|
EmulationSettings::SetFlags(EmulationFlags::Paused);
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall Release()
|
|
|
|
{
|
2018-07-02 21:32:59 -04:00
|
|
|
ReleaseDualSystemAudioVideo();
|
2017-09-08 10:38:41 -04:00
|
|
|
_shortcutKeyHandler.reset();
|
2018-01-03 01:14:46 -05:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
GameServer::StopServer();
|
|
|
|
GameClient::Disconnect();
|
2018-07-01 15:21:05 -04:00
|
|
|
|
|
|
|
_console->Stop();
|
|
|
|
|
2018-07-02 21:32:59 -04:00
|
|
|
_renderer.reset();
|
|
|
|
_soundManager.reset();
|
|
|
|
_keyManager.reset();
|
2018-07-01 15:21:05 -04:00
|
|
|
|
|
|
|
_console->Release(true);
|
|
|
|
_console.reset();
|
|
|
|
|
|
|
|
MessageManager::RegisterMessageManager(nullptr);
|
|
|
|
|
2018-06-09 15:42:27 -04:00
|
|
|
_shortcutKeyHandler.reset();
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall TakeScreenshot() { _console->GetVideoDecoder()->TakeScreenshot(); }
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2018-07-06 00:10:10 -04:00
|
|
|
DllExport INotificationListener* __stdcall RegisterNotificationCallback(int32_t consoleId, NotificationListenerCallback callback)
|
2015-07-01 23:17:14 -04:00
|
|
|
{
|
2018-06-29 00:06:12 -04:00
|
|
|
auto lock = _externalNotificationListenerLock.AcquireSafe();
|
|
|
|
auto listener = shared_ptr<INotificationListener>(new InteropNotificationListener(callback));
|
|
|
|
_externalNotificationListeners.push_back(listener);
|
2018-07-06 00:10:10 -04:00
|
|
|
GetConsoleById(consoleId)->GetNotificationManager()->RegisterNotificationListener(listener);
|
2018-06-29 00:06:12 -04:00
|
|
|
return listener.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall UnregisterNotificationCallback(INotificationListener *listener)
|
|
|
|
{
|
|
|
|
auto lock = _externalNotificationListenerLock.AcquireSafe();
|
|
|
|
_externalNotificationListeners.erase(
|
|
|
|
std::remove_if(
|
|
|
|
_externalNotificationListeners.begin(),
|
|
|
|
_externalNotificationListeners.end(),
|
|
|
|
[=](shared_ptr<INotificationListener> ptr) { return ptr.get() == listener; }
|
|
|
|
),
|
|
|
|
_externalNotificationListeners.end()
|
|
|
|
);
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
|
|
|
|
2016-02-19 13:05:04 -05:00
|
|
|
DllExport void __stdcall DisplayMessage(char* title, char* message, char* param1) { MessageManager::DisplayMessage(title, message, param1 ? param1 : ""); }
|
2016-06-19 16:54:34 -04:00
|
|
|
DllExport const char* __stdcall GetLog()
|
|
|
|
{
|
|
|
|
_logString = MessageManager::GetLog();
|
|
|
|
return _logString.c_str();
|
|
|
|
}
|
2015-07-05 19:05:33 -04:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall SaveState(uint32_t stateIndex) { _console->GetSaveStateManager()->SaveState(stateIndex); }
|
|
|
|
DllExport void __stdcall LoadState(uint32_t stateIndex) { _console->GetSaveStateManager()->LoadState(stateIndex); }
|
|
|
|
DllExport void __stdcall SaveStateFile(char* filepath) { _console->GetSaveStateManager()->SaveState(filepath); }
|
|
|
|
DllExport void __stdcall LoadStateFile(char* filepath) { _console->GetSaveStateManager()->LoadState(filepath); }
|
|
|
|
DllExport int64_t __stdcall GetStateInfo(uint32_t stateIndex) { return _console->GetSaveStateManager()->GetStateInfo(stateIndex); }
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall MoviePlay(char* filename) { MovieManager::Play(string(filename), _console); }
|
2017-12-28 13:15:01 -05:00
|
|
|
|
|
|
|
DllExport void __stdcall MovieRecord(RecordMovieOptions *options)
|
|
|
|
{
|
|
|
|
RecordMovieOptions opt = *options;
|
2018-07-01 15:21:05 -04:00
|
|
|
MovieManager::Record(opt, _console);
|
2017-12-28 13:15:01 -05:00
|
|
|
}
|
|
|
|
|
2017-04-18 22:39:45 -04:00
|
|
|
DllExport void __stdcall MovieStop() { MovieManager::Stop(); }
|
|
|
|
DllExport bool __stdcall MoviePlaying() { return MovieManager::Playing(); }
|
|
|
|
DllExport bool __stdcall MovieRecording() { return MovieManager::Recording(); }
|
2015-07-05 19:05:33 -04:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall AviRecord(char* filename, VideoCodec codec, uint32_t compressionLevel) { _console->GetVideoRenderer()->StartRecording(filename, codec, compressionLevel); }
|
|
|
|
DllExport void __stdcall AviStop() { _console->GetVideoRenderer()->StopRecording(); }
|
|
|
|
DllExport bool __stdcall AviIsRecording() { return _console->GetVideoRenderer()->IsRecording(); }
|
2016-12-29 21:19:13 -05:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall WaveRecord(char* filename) { _console->GetSoundMixer()->StartRecording(filename); }
|
|
|
|
DllExport void __stdcall WaveStop() { _console->GetSoundMixer()->StopRecording(); }
|
|
|
|
DllExport bool __stdcall WaveIsRecording() { return _console->GetSoundMixer()->IsRecording(); }
|
2016-06-05 14:36:20 -04:00
|
|
|
|
2017-04-23 18:47:28 -04:00
|
|
|
DllExport int32_t __stdcall RunRecordedTest(char* filename)
|
2015-12-26 17:11:00 -05:00
|
|
|
{
|
2018-07-01 15:21:05 -04:00
|
|
|
_recordedRomTest.reset(new RecordedRomTest(_console));
|
2018-07-02 14:49:19 -04:00
|
|
|
_console->GetNotificationManager()->RegisterNotificationListener(_recordedRomTest);
|
2018-07-01 15:21:05 -04:00
|
|
|
return _recordedRomTest->Run(filename);
|
2017-04-23 18:47:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
DllExport int32_t __stdcall RunAutomaticTest(char* filename)
|
|
|
|
{
|
2018-06-29 00:06:12 -04:00
|
|
|
shared_ptr<AutomaticRomTest> romTest(new AutomaticRomTest());
|
|
|
|
return romTest->Run(filename);
|
2015-12-26 17:11:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall RomTestRecord(char* filename, bool reset)
|
|
|
|
{
|
2018-07-01 15:21:05 -04:00
|
|
|
_recordedRomTest.reset(new RecordedRomTest(_console));
|
2018-07-02 14:49:19 -04:00
|
|
|
_console->GetNotificationManager()->RegisterNotificationListener(_recordedRomTest);
|
2017-04-23 18:47:28 -04:00
|
|
|
_recordedRomTest->Record(filename, reset);
|
2015-12-26 17:11:00 -05:00
|
|
|
}
|
|
|
|
|
2015-12-27 09:13:52 -05:00
|
|
|
DllExport void __stdcall RomTestRecordFromMovie(char* testFilename, char* movieFilename)
|
|
|
|
{
|
2018-07-01 15:21:05 -04:00
|
|
|
_recordedRomTest.reset(new RecordedRomTest(_console));
|
2018-07-02 14:49:19 -04:00
|
|
|
_console->GetNotificationManager()->RegisterNotificationListener(_recordedRomTest);
|
2017-11-19 23:08:23 -05:00
|
|
|
_recordedRomTest->RecordFromMovie(testFilename, string(movieFilename));
|
2015-12-27 09:13:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall RomTestRecordFromTest(char* newTestFilename, char* existingTestFilename)
|
|
|
|
{
|
2018-07-01 15:21:05 -04:00
|
|
|
_recordedRomTest.reset(new RecordedRomTest(_console));
|
2018-07-02 14:49:19 -04:00
|
|
|
_console->GetNotificationManager()->RegisterNotificationListener(_recordedRomTest);
|
2017-04-23 18:47:28 -04:00
|
|
|
_recordedRomTest->RecordFromTest(newTestFilename, existingTestFilename);
|
2015-12-27 09:13:52 -05:00
|
|
|
}
|
|
|
|
|
2015-12-26 17:11:00 -05:00
|
|
|
DllExport void __stdcall RomTestStop()
|
|
|
|
{
|
2017-04-23 18:47:28 -04:00
|
|
|
if(_recordedRomTest) {
|
|
|
|
_recordedRomTest->Stop();
|
2018-06-29 00:06:12 -04:00
|
|
|
_recordedRomTest.reset();
|
2015-12-26 17:11:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-23 18:47:28 -04:00
|
|
|
DllExport bool __stdcall RomTestRecording() { return _recordedRomTest != nullptr; }
|
2015-12-26 17:11:00 -05:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall SetCheats(CheatInfo cheats[], uint32_t length) { _console->GetCheatManager()->SetCheats(cheats, length); }
|
2015-07-17 20:58:57 -04:00
|
|
|
|
2017-04-30 01:16:33 -04:00
|
|
|
DllExport bool __stdcall CheckFlag(EmulationFlags flags) { return EmulationSettings::CheckFlag(flags); }
|
2016-01-06 20:34:45 -05:00
|
|
|
DllExport void __stdcall SetFlags(EmulationFlags flags) { EmulationSettings::SetFlags(flags); }
|
|
|
|
DllExport void __stdcall ClearFlags(EmulationFlags flags) { EmulationSettings::ClearFlags(flags); }
|
2016-08-24 17:32:22 -04:00
|
|
|
DllExport void __stdcall SetRamPowerOnState(RamPowerOnState state) { EmulationSettings::SetRamPowerOnState(state); }
|
2016-02-19 13:05:04 -05:00
|
|
|
DllExport void __stdcall SetDisplayLanguage(Language lang) { EmulationSettings::SetDisplayLanguage(lang); }
|
2015-07-17 20:58:57 -04:00
|
|
|
DllExport void __stdcall SetChannelVolume(uint32_t channel, double volume) { EmulationSettings::SetChannelVolume((AudioChannel)channel, volume); }
|
2016-12-09 21:23:20 -05:00
|
|
|
DllExport void __stdcall SetChannelPanning(uint32_t channel, double panning) { EmulationSettings::SetChannelPanning((AudioChannel)channel, panning); }
|
2017-04-15 13:54:47 -04:00
|
|
|
DllExport void __stdcall SetEqualizerFilterType(EqualizerFilterType filter) { EmulationSettings::SetEqualizerFilterType(filter); }
|
|
|
|
DllExport void __stdcall SetBandGain(uint32_t band, double gain) { EmulationSettings::SetBandGain(band, gain); }
|
|
|
|
DllExport void __stdcall SetEqualizerBands(double *bands, uint32_t bandCount) { EmulationSettings::SetEqualizerBands(bands, bandCount); }
|
2018-06-27 19:45:22 -04:00
|
|
|
DllExport void __stdcall SetMasterVolume(double volume, double volumeReduction) { EmulationSettings::SetMasterVolume(volume, volumeReduction); }
|
2016-01-14 19:33:16 -05:00
|
|
|
DllExport void __stdcall SetSampleRate(uint32_t sampleRate) { EmulationSettings::SetSampleRate(sampleRate); }
|
2015-07-17 20:58:57 -04:00
|
|
|
DllExport void __stdcall SetAudioLatency(uint32_t msLatency) { EmulationSettings::SetAudioLatency(msLatency); }
|
2016-02-21 15:31:39 -05:00
|
|
|
DllExport void __stdcall SetStereoFilter(StereoFilter stereoFilter) { EmulationSettings::SetStereoFilter(stereoFilter); }
|
|
|
|
DllExport void __stdcall SetStereoDelay(int32_t delay) { EmulationSettings::SetStereoDelay(delay); }
|
|
|
|
DllExport void __stdcall SetStereoPanningAngle(double angle) { EmulationSettings::SetStereoPanningAngle(angle); }
|
|
|
|
DllExport void __stdcall SetReverbParameters(double strength, double delay) { EmulationSettings::SetReverbParameters(strength, delay); }
|
2016-12-09 14:47:34 -05:00
|
|
|
DllExport void __stdcall SetCrossFeedRatio(uint32_t ratio) { EmulationSettings::SetCrossFeedRatio(ratio); }
|
2016-02-21 15:31:39 -05:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport NesModel __stdcall GetNesModel() { return _console->GetModel(); }
|
2015-07-21 23:05:27 -04:00
|
|
|
DllExport void __stdcall SetNesModel(uint32_t model) { EmulationSettings::SetNesModel((NesModel)model); }
|
2015-07-23 23:16:31 -04:00
|
|
|
DllExport void __stdcall SetOverscanDimensions(uint32_t left, uint32_t right, uint32_t top, uint32_t bottom) { EmulationSettings::SetOverscanDimensions(left, right, top, bottom); }
|
2016-09-11 08:29:34 -04:00
|
|
|
DllExport void __stdcall SetEmulationSpeed(uint32_t emulationSpeed) { EmulationSettings::SetEmulationSpeed(emulationSpeed, true); }
|
|
|
|
DllExport void __stdcall IncreaseEmulationSpeed() { EmulationSettings::IncreaseEmulationSpeed(); }
|
|
|
|
DllExport void __stdcall DecreaseEmulationSpeed() { EmulationSettings::DecreaseEmulationSpeed(); }
|
|
|
|
DllExport uint32_t __stdcall GetEmulationSpeed() { return EmulationSettings::GetEmulationSpeed(true); }
|
2017-04-28 19:54:58 -04:00
|
|
|
DllExport void __stdcall SetTurboRewindSpeed(uint32_t turboSpeed, uint32_t rewindSpeed) { EmulationSettings::SetTurboRewindSpeed(turboSpeed, rewindSpeed); }
|
|
|
|
DllExport void __stdcall SetRewindBufferSize(uint32_t seconds) { EmulationSettings::SetRewindBufferSize(seconds); }
|
2016-06-12 18:11:31 -04:00
|
|
|
DllExport void __stdcall SetOverclockRate(uint32_t overclockRate, bool adjustApu) { EmulationSettings::SetOverclockRate(overclockRate, adjustApu); }
|
2016-06-21 18:58:22 -04:00
|
|
|
DllExport void __stdcall SetPpuNmiConfig(uint32_t extraScanlinesBeforeNmi, uint32_t extraScanlinesAfterNmi) { EmulationSettings::SetPpuNmiConfig(extraScanlinesBeforeNmi, extraScanlinesAfterNmi); }
|
2016-02-07 13:05:32 -05:00
|
|
|
DllExport void __stdcall SetVideoScale(double scale) { EmulationSettings::SetVideoScale(scale); }
|
2017-11-11 20:55:33 -05:00
|
|
|
DllExport void __stdcall SetScreenRotation(uint32_t angle) { EmulationSettings::SetScreenRotation(angle); }
|
2017-12-28 10:59:27 -05:00
|
|
|
DllExport void __stdcall SetExclusiveRefreshRate(uint32_t angle) { EmulationSettings::SetExclusiveRefreshRate(angle); }
|
2017-02-18 13:41:16 -05:00
|
|
|
DllExport void __stdcall SetVideoAspectRatio(VideoAspectRatio aspectRatio, double customRatio) { EmulationSettings::SetVideoAspectRatio(aspectRatio, customRatio); }
|
2016-01-05 21:28:38 -05:00
|
|
|
DllExport void __stdcall SetVideoFilter(VideoFilterType filter) { EmulationSettings::SetVideoFilterType(filter); }
|
2016-05-24 19:45:58 -04:00
|
|
|
DllExport void __stdcall SetVideoResizeFilter(VideoResizeFilter filter) { EmulationSettings::SetVideoResizeFilter(filter); }
|
2016-01-17 14:21:31 -05:00
|
|
|
DllExport void __stdcall GetRgbPalette(uint32_t *paletteBuffer) { EmulationSettings::GetRgbPalette(paletteBuffer); }
|
|
|
|
DllExport void __stdcall SetRgbPalette(uint32_t *paletteBuffer) { EmulationSettings::SetRgbPalette(paletteBuffer); }
|
2016-05-26 22:32:20 -04:00
|
|
|
DllExport void __stdcall SetPictureSettings(double brightness, double contrast, double saturation, double hue, double scanlineIntensity) { EmulationSettings::SetPictureSettings(brightness, contrast, saturation, hue, scanlineIntensity); }
|
2018-01-11 22:31:07 -05:00
|
|
|
DllExport void __stdcall SetNtscFilterSettings(double artifacts, double bleed, double fringing, double gamma, double resolution, double sharpness, bool mergeFields, double yFilterLength, double iFilterLength, double qFilterLength, bool verticalBlend) { EmulationSettings::SetNtscFilterSettings(artifacts, bleed, fringing, gamma, resolution, sharpness, mergeFields, yFilterLength, iFilterLength, qFilterLength, verticalBlend, false); }
|
2018-06-03 14:35:54 -04:00
|
|
|
DllExport void __stdcall SetPauseScreenMessage(char* message) { EmulationSettings::SetPauseScreenMessage(message); }
|
2015-07-17 20:58:57 -04:00
|
|
|
|
2016-07-19 16:30:18 -04:00
|
|
|
DllExport void __stdcall SetInputDisplaySettings(uint8_t visiblePorts, InputDisplayPosition displayPosition, bool displayHorizontally) { EmulationSettings::SetInputDisplaySettings(visiblePorts, displayPosition, displayHorizontally); }
|
2016-08-31 20:54:38 -04:00
|
|
|
DllExport void __stdcall SetAutoSaveOptions(uint32_t delayInMinutes, bool showMessage) { EmulationSettings::SetAutoSaveOptions(delayInMinutes, showMessage); }
|
2016-07-19 16:30:18 -04:00
|
|
|
|
2016-01-17 22:16:20 -05:00
|
|
|
DllExport const char* __stdcall GetAudioDevices()
|
|
|
|
{
|
2016-07-23 15:28:52 -04:00
|
|
|
_returnString = _soundManager ? _soundManager->GetAvailableDevices() : "";
|
2016-01-17 22:16:20 -05:00
|
|
|
return _returnString.c_str();
|
|
|
|
}
|
|
|
|
|
2016-07-23 15:28:52 -04:00
|
|
|
DllExport void __stdcall SetAudioDevice(char* audioDevice) { if(_soundManager) { _soundManager->SetAudioDevice(audioDevice); } }
|
2016-01-17 22:16:20 -05:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall GetScreenSize(ScreenSize &size, bool ignoreScale) { _console->GetVideoDecoder()->GetScreenSize(size, ignoreScale); }
|
2017-11-19 23:08:23 -05:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall InputBarcode(uint64_t barCode, int32_t digitCount) { _console->InputBarcode(barCode, digitCount); }
|
2017-11-19 23:08:23 -05:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall LoadTapeFile(char *filepath) { _console->LoadTapeFile(filepath); }
|
|
|
|
DllExport void __stdcall StartRecordingTapeFile(char *filepath) { _console->StartRecordingTapeFile(filepath); }
|
|
|
|
DllExport void __stdcall StopRecordingTapeFile() { _console->StopRecordingTapeFile(); }
|
|
|
|
DllExport bool __stdcall IsRecordingTapeFile() { return _console->IsRecordingTapeFile(); }
|
2017-11-24 21:38:12 -05:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport ConsoleFeatures __stdcall GetAvailableFeatures() { return _console->GetAvailableFeatures(); }
|
2017-11-19 23:08:23 -05:00
|
|
|
|
2016-06-25 20:46:54 -04:00
|
|
|
//NSF functions
|
|
|
|
DllExport bool __stdcall IsNsf() { return NsfMapper::GetInstance() != nullptr; }
|
2017-11-19 23:08:23 -05:00
|
|
|
DllExport void __stdcall NsfSelectTrack(uint8_t trackNumber) {
|
2016-06-25 20:46:54 -04:00
|
|
|
if(NsfMapper::GetInstance()) {
|
|
|
|
NsfMapper::GetInstance()->SelectTrack(trackNumber);
|
|
|
|
}
|
|
|
|
}
|
2016-06-26 16:31:29 -04:00
|
|
|
DllExport int32_t __stdcall NsfGetCurrentTrack() {
|
2016-06-25 20:46:54 -04:00
|
|
|
if(NsfMapper::GetInstance()) {
|
|
|
|
return NsfMapper::GetInstance()->GetCurrentTrack();
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
DllExport void __stdcall NsfGetHeader(NsfHeader* header) {
|
|
|
|
if(NsfMapper::GetInstance()) {
|
|
|
|
*header = NsfMapper::GetInstance()->GetNsfHeader();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DllExport void __stdcall NsfSetNsfConfig(int32_t autoDetectSilenceDelay, int32_t moveToNextTrackTime, bool disableApuIrqs) {
|
|
|
|
EmulationSettings::SetNsfConfig(autoDetectSilenceDelay, moveToNextTrackTime, disableApuIrqs);
|
|
|
|
}
|
|
|
|
|
2016-01-28 20:47:16 -05:00
|
|
|
//FDS functions
|
2017-11-19 23:08:23 -05:00
|
|
|
DllExport uint32_t __stdcall FdsGetSideCount() {
|
2018-07-01 15:21:05 -04:00
|
|
|
shared_ptr<FdsSystemActionManager> sam = _console->GetSystemActionManager<FdsSystemActionManager>();
|
2017-11-19 23:08:23 -05:00
|
|
|
return sam ? sam->GetSideCount() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall FdsEjectDisk() {
|
2018-07-01 15:21:05 -04:00
|
|
|
shared_ptr<FdsSystemActionManager> sam = _console->GetSystemActionManager<FdsSystemActionManager>();
|
2017-11-19 23:08:23 -05:00
|
|
|
if(sam) {
|
|
|
|
sam->EjectDisk();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall FdsInsertDisk(uint32_t diskNumber) {
|
2018-07-01 15:21:05 -04:00
|
|
|
shared_ptr<FdsSystemActionManager> sam = _console->GetSystemActionManager<FdsSystemActionManager>();
|
2017-11-19 23:08:23 -05:00
|
|
|
if(sam) {
|
|
|
|
sam->InsertDisk(diskNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall FdsSwitchDiskSide() {
|
2018-07-01 15:21:05 -04:00
|
|
|
shared_ptr<FdsSystemActionManager> sam = _console->GetSystemActionManager<FdsSystemActionManager>();
|
2017-11-19 23:08:23 -05:00
|
|
|
if(sam) {
|
|
|
|
sam->SwitchDiskSide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DllExport bool __stdcall FdsIsAutoInsertDiskEnabled() {
|
2018-07-01 15:21:05 -04:00
|
|
|
shared_ptr<FdsSystemActionManager> sam = _console->GetSystemActionManager<FdsSystemActionManager>();
|
2017-11-19 23:08:23 -05:00
|
|
|
return sam ? sam->IsAutoInsertDiskEnabled() : false;
|
|
|
|
}
|
2016-04-30 20:08:53 -04:00
|
|
|
|
|
|
|
//VS System functions
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport bool __stdcall IsVsSystem() {
|
|
|
|
return dynamic_cast<VsControlManager*>(_console->GetControlManager()) != nullptr;
|
|
|
|
}
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
DllExport void __stdcall VsInsertCoin(uint32_t port) {
|
2018-07-01 15:21:05 -04:00
|
|
|
shared_ptr<VsSystemActionManager> sam = _console->GetSystemActionManager<VsSystemActionManager>();
|
2017-11-19 23:08:23 -05:00
|
|
|
if(sam) {
|
|
|
|
sam->InsertCoin(port);
|
2016-04-30 20:08:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-10 09:05:41 -04:00
|
|
|
DllExport void __stdcall VsSetGameConfig(PpuModel model, VsInputType inputType, uint8_t dipSwitches)
|
2016-04-30 20:08:53 -04:00
|
|
|
{
|
2018-07-01 15:21:05 -04:00
|
|
|
if(dynamic_cast<VsControlManager*>(_console->GetControlManager())) {
|
2016-04-30 20:08:53 -04:00
|
|
|
EmulationSettings::SetPpuModel(model);
|
2017-11-19 23:08:23 -05:00
|
|
|
EmulationSettings::SetDipSwitches(dipSwitches);
|
2018-01-04 19:03:47 -05:00
|
|
|
EmulationSettings::SetVsInputType(inputType);
|
2016-04-30 20:08:53 -04:00
|
|
|
}
|
|
|
|
}
|
2017-06-28 19:00:08 -04:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport bool __stdcall IsHdPpu() { return _console->IsHdPpu(); }
|
2017-08-15 23:59:55 -04:00
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
DllExport void __stdcall HdBuilderStartRecording(char* saveFolder, ScaleFilterType filterType, uint32_t scale, uint32_t flags, uint32_t chrRamBankSize) { _console->StartRecordingHdPack(saveFolder, filterType, scale, flags, chrRamBankSize); }
|
|
|
|
DllExport void __stdcall HdBuilderStopRecording() { _console->StopRecordingHdPack(); }
|
2017-06-28 19:00:08 -04:00
|
|
|
|
|
|
|
DllExport void __stdcall HdBuilderGetChrBankList(uint32_t* bankBuffer) { HdPackBuilder::GetChrBankList(bankBuffer); }
|
2018-06-19 20:43:16 -04:00
|
|
|
DllExport void __stdcall HdBuilderGetBankPreview(uint32_t bankNumber, uint32_t pageNumber, uint32_t *rgbBuffer) { HdPackBuilder::GetBankPreview(bankNumber, pageNumber, rgbBuffer); }
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
|
|
|
}
|