2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-18 01:08:10 +02:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 22:43:11 -04:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Core
|
|
|
|
|
|
|
|
// The external interface to the emulator core. Plus some extras.
|
|
|
|
// This is another part of the emu that needs cleaning - Core.cpp really has
|
|
|
|
// too much random junk inside.
|
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-05-12 01:18:30 +00:00
|
|
|
#include <functional>
|
2008-12-08 04:46:09 +00:00
|
|
|
#include <string>
|
2014-02-19 13:09:14 -05:00
|
|
|
#include <vector>
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Common/CommonTypes.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
namespace Core
|
|
|
|
{
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2015-10-16 22:52:38 -04:00
|
|
|
// TODO: ugly, remove
|
|
|
|
extern bool g_aspect_wide;
|
|
|
|
|
2014-09-06 17:26:40 -04:00
|
|
|
extern bool g_want_determinism;
|
|
|
|
|
2015-12-16 00:10:47 +01:00
|
|
|
bool GetIsThrottlerTempDisabled();
|
|
|
|
void SetIsThrottlerTempDisabled(bool disable);
|
2013-03-18 20:41:45 -04:00
|
|
|
|
2011-01-31 01:28:32 +00:00
|
|
|
void Callback_VideoCopiedToXFB(bool video_update);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2011-03-15 23:09:12 +00:00
|
|
|
enum EState
|
|
|
|
{
|
2013-04-16 23:14:36 -04:00
|
|
|
CORE_UNINITIALIZED,
|
|
|
|
CORE_PAUSE,
|
|
|
|
CORE_RUN,
|
2011-03-15 23:09:12 +00:00
|
|
|
CORE_STOPPING
|
|
|
|
};
|
2009-01-18 01:45:53 +00:00
|
|
|
|
2011-03-15 23:09:12 +00:00
|
|
|
bool Init();
|
|
|
|
void Stop();
|
2015-06-06 14:52:09 +02:00
|
|
|
void Shutdown();
|
2010-06-06 03:52:11 +00:00
|
|
|
|
2015-06-06 01:41:26 -04:00
|
|
|
void DeclareAsCPUThread();
|
|
|
|
void UndeclareAsCPUThread();
|
|
|
|
|
2015-05-28 20:28:48 -04:00
|
|
|
std::string StopMessage(bool, const std::string&);
|
2010-07-16 14:14:57 +00:00
|
|
|
|
2011-03-15 23:09:12 +00:00
|
|
|
bool IsRunning();
|
2014-11-13 21:28:27 -05:00
|
|
|
bool IsRunningAndStarted(); // is running and the CPU loop has been entered
|
|
|
|
bool IsRunningInCurrentThread(); // this tells us whether we are running in the CPU thread.
|
|
|
|
bool IsCPUThread(); // this tells us whether we are the CPU thread.
|
2011-12-30 20:16:12 -08:00
|
|
|
bool IsGPUThread();
|
|
|
|
|
2016-05-12 09:17:17 +00:00
|
|
|
// [NOT THREADSAFE] For use by Host only
|
|
|
|
void SetState(EState state);
|
2011-03-15 23:09:12 +00:00
|
|
|
EState GetState();
|
2009-02-22 21:16:12 +00:00
|
|
|
|
2011-03-15 23:09:12 +00:00
|
|
|
void SaveScreenShot();
|
2015-07-09 07:24:30 -04:00
|
|
|
void SaveScreenShot(const std::string& name);
|
2011-03-15 23:09:12 +00:00
|
|
|
|
|
|
|
void Callback_WiimoteInterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
|
|
|
|
|
|
|
|
// This displays messages in a user-visible way.
|
2014-03-12 15:33:41 -04:00
|
|
|
void DisplayMessage(const std::string& message, int time_in_ms);
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2011-03-15 23:09:12 +00:00
|
|
|
std::string GetStateFileName();
|
2015-05-28 20:28:48 -04:00
|
|
|
void SetStateFileName(const std::string& val);
|
2013-04-16 23:14:36 -04:00
|
|
|
|
2011-03-15 23:09:12 +00:00
|
|
|
void SetBlockStart(u32 addr);
|
|
|
|
|
2015-06-06 01:20:51 -04:00
|
|
|
void FrameUpdateOnCPUThread();
|
|
|
|
|
2011-03-15 23:09:12 +00:00
|
|
|
bool ShouldSkipFrame(int skipped);
|
|
|
|
void VideoThrottle();
|
2011-12-14 04:03:05 -08:00
|
|
|
void RequestRefreshInfo();
|
2011-03-15 23:09:12 +00:00
|
|
|
|
2013-01-16 22:52:01 -05:00
|
|
|
void UpdateTitle();
|
|
|
|
|
2011-12-30 20:16:12 -08:00
|
|
|
// waits until all systems are paused and fully idle, and acquires a lock on that state.
|
|
|
|
// or, if doLock is false, releases a lock on that state and optionally unpauses.
|
|
|
|
// calls must be balanced (once with doLock true, then once with doLock false) but may be recursive.
|
|
|
|
// the return value of the first call should be passed in as the second argument of the second call.
|
2016-05-12 09:17:17 +00:00
|
|
|
// [NOT THREADSAFE] Host only
|
|
|
|
bool PauseAndLock(bool doLock, bool unpauseOnUnlock = true);
|
2011-12-30 20:16:12 -08:00
|
|
|
|
2014-06-20 02:43:57 +02:00
|
|
|
// for calling back into UI code without introducing a dependency on it in core
|
|
|
|
typedef void(*StoppedCallbackFunc)(void);
|
|
|
|
void SetOnStoppedCallback(StoppedCallbackFunc callback);
|
|
|
|
|
2016-05-12 09:17:17 +00:00
|
|
|
// Run on the Host thread when the factors change. [NOT THREADSAFE]
|
2014-09-06 17:26:40 -04:00
|
|
|
void UpdateWantDeterminism(bool initial = false);
|
|
|
|
|
2016-05-12 01:18:30 +00:00
|
|
|
// Queue an arbitrary function to asynchronously run once on the Host thread later.
|
|
|
|
// Threadsafe. Can be called by any thread, including the Host itself.
|
|
|
|
// Jobs will be executed in RELATIVE order. If you queue 2 jobs from the same thread
|
|
|
|
// then they will be executed in the order they were queued; however, there is no
|
|
|
|
// global order guarantee across threads - jobs from other threads may execute in
|
|
|
|
// between.
|
|
|
|
// NOTE: Make sure the jobs check the global state instead of assuming everything is
|
|
|
|
// still the same as when the job was queued.
|
|
|
|
// NOTE: Jobs that are not set to run during stop will be discarded instead.
|
|
|
|
void QueueHostJob(std::function<void()> job, bool run_during_stop = false);
|
|
|
|
|
|
|
|
// Should be called periodically by the Host to run pending jobs.
|
|
|
|
// WM_USER_JOB_DISPATCH will be sent when something is added to the queue.
|
|
|
|
void HostDispatchJobs();
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
} // namespace
|