Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

203 lines
6.3 KiB
C
Raw Normal View History

// Copyright 2008 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <array>
#include <cstring>
#include <optional>
#include <string>
#include <string_view>
#include "Common/CommonTypes.h"
Boot: Clean up the boot code * Move out boot parameters to a separate struct, which is not part of SConfig/ConfigManager because there is no reason for it to be there. * Move out file name parsing and constructing the appropriate params from paths to a separate function that does that, and only that. * For every different boot type we support, add a proper struct with only the required parameters, with descriptive names and use std::variant to only store what we need. * Clean up the bHLE_BS2 stuff which made no sense sometimes. Now instead of using bHLE_BS2 for two different things, both for storing the user config setting and as a runtime boot parameter, we simply replace the Disc boot params with BootParameters::IPL. * Const correctness so it's clear what can or cannot update the config. * Drop unused parameters and unneeded checks. * Make a few checks a lot more concise. (Looking at you, extension checks for disc images.) * Remove a mildly terrible workaround where we needed to pass an empty string in order to boot the GC IPL without any game inserted. (Not required anymore thanks to std::variant and std::optional.) The motivation for this are multiple: cleaning up and being able to add support for booting an installed NAND title. Without this change, it'd be pretty much impossible to implement that. Also, using std::visit with std::variant makes the compiler do additional type checks: now we're guaranteed that the boot code will handle all boot types and no invalid boot type will be possible.
2017-05-27 15:43:40 +02:00
struct BootParameters;
struct GCPadStatus;
class PointerWrap;
2011-12-15 09:22:16 -08:00
2022-01-11 11:17:47 -08:00
namespace ExpansionInterface
{
enum class Slot : int;
}
2019-01-05 07:09:11 -06:00
namespace WiimoteCommon
{
class DataReportBuilder;
}
namespace WiimoteEmu
{
class EncryptionKey;
}
// Per-(video )Movie actions
namespace Movie
{
// Enumerations and structs
2021-07-04 13:38:30 +02:00
enum class ControllerType
{
None = 0,
GC,
GBA,
};
using ControllerTypeArray = std::array<ControllerType, 4>;
using WiimoteEnabledArray = std::array<bool, 4>;
// GameCube Controller State
#pragma pack(push, 1)
struct ControllerState
{
bool Start : 1, A : 1, B : 1, X : 1, Y : 1, Z : 1; // Binary buttons, 6 bits
bool DPadUp : 1, DPadDown : 1, // Binary D-Pad buttons, 4 bits
2014-09-08 20:15:47 -04:00
DPadLeft : 1, DPadRight : 1;
2017-02-09 15:03:43 -08:00
bool L : 1, R : 1; // Binary triggers, 2 bits
bool disc : 1; // Checks for disc being changed
bool reset : 1; // Console reset button
bool is_connected : 1; // Should controller be treated as connected
bool get_origin : 1; // Special bit to indicate analog origin reset
u8 TriggerL, TriggerR; // Triggers, 16 bits
u8 AnalogStickX, AnalogStickY; // Main Stick, 16 bits
u8 CStickX, CStickY; // Sub-Stick, 16 bits
};
static_assert(sizeof(ControllerState) == 8, "ControllerState should be 8 bytes");
#pragma pack(pop)
// When making changes to the DTM format, keep in mind that there are programs other
// than Dolphin that parse DTM files. The format is expected to be relatively stable.
#pragma pack(push, 1)
struct DTMHeader
{
std::string_view GetGameID() const
{
return {gameID.data(), strnlen(gameID.data(), gameID.size())};
}
std::array<u8, 4> filetype; // Unique Identifier (always "DTM"0x1A)
std::array<char, 6> gameID; // The Game ID
bool bWii; // Wii game
u8 controllers; // Controllers plugged in (from least to most significant,
// the bits are GC controllers 1-4 and Wiimotes 1-4)
bool
bFromSaveState; // false indicates that the recording started from bootup, true for savestate
u64 frameCount; // Number of frames in the recording
u64 inputCount; // Number of input frames in recording
u64 lagCount; // Number of lag frames in the recording
2011-12-26 05:09:30 -06:00
u64 uniqueID; // (not implemented) A Unique ID comprised of: md5(time + Game ID)
u32 numRerecords; // Number of rerecords/'cuts' of this TAS
std::array<char, 32> author; // Author's name (encoded in UTF-8)
std::array<char, 16> videoBackend; // UTF-8 representation of the video backend
std::array<char, 16> audioEmulator; // UTF-8 representation of the audio emulator
std::array<u8, 16> md5; // MD5 of game iso
2011-12-26 05:09:30 -06:00
u64 recordingStartTime; // seconds since 1970 that recording started (used for RTC)
bool bSaveConfig; // Loads the settings below on startup if true
bool bSkipIdle;
bool bDualCore;
bool bProgressive;
bool bDSPHLE;
bool bFastDiscSpeed;
2017-05-19 16:57:31 +02:00
u8 CPUCore; // Uses the values of PowerPC::CPUCore
bool bEFBAccessEnable;
bool bEFBCopyEnable;
bool bSkipEFBCopyToRam;
bool bEFBCopyCacheEnable;
bool bEFBEmulateFormatChanges;
bool bImmediateXFB;
bool bSkipXFBCopyToRam;
u8 memcards; // Memcards inserted (from least to most significant, the bits are slot A and B)
bool bClearSave; // Create a new memory card when playing back a movie if true
u8 bongos; // Bongos plugged in (from least to most significant, the bits are ports 1-4)
2013-06-20 06:08:17 -04:00
bool bSyncGPU;
bool bNetPlay;
bool bPAL60;
u8 language;
u8 reserved3;
bool bFollowBranch;
NetPlay/Jit64: Avoid using software FMA When I added the software FMA path in 2c38d64 and made us use it when determinism is enabled, I was assuming that either the performance impact of software FMA wouldn't be too large or CPUs that were too old to have FMA instructions were too slow to run Dolphin well anyway. This was wrong. To give an example, the netplay performance went from 60 FPS to 30 FPS in one case. This change makes netplay clients negotiate whether FMA should be used. If all clients use an x64 CPU that supports FMA, or AArch64, then FMA is enabled, and otherwise FMA is disabled. In other words, we sacrifice accuracy if needed to avoid massive slowdown, but not otherwise. When not using netplay, whether to enable FMA is simply based on whether the host CPU supports it. The only remaining case where the software FMA path gets used under normal circumstances is when an input recording is created on a CPU with FMA support and then played back on a CPU without. This is not an especially common scenario (though it can happen), and TASers are generally less picky about performance and more picky about accuracy than other users anyway. With this change, FMA desyncs are avoided between AArch64 and modern x64 CPUs (unlike before 2c38d64), but we do get FMA desyncs between AArch64 and old x64 CPUs (like before 2c38d64). This desync can be avoided by adding a non-FMA path to JitArm64 as an option, which I will wait with for another pull request so that we can get the performance regression fixed as quickly as possible. https://bugs.dolphin-emu.org/issues/12542
2021-06-09 20:16:41 +02:00
bool bUseFMA;
2021-07-04 13:38:30 +02:00
u8 GBAControllers; // GBA Controllers plugged in (the bits are ports 1-4)
std::array<u8, 7> reserved; // Padding for any new config options
std::array<char, 40> discChange; // Name of iso file to switch to, for two disc games.
std::array<u8, 20> revision; // Git hash
2014-09-08 20:15:47 -04:00
u32 DSPiromHash;
u32 DSPcoefHash;
u64 tickCount; // Number of ticks in the recording
std::array<u8, 11> reserved2; // Make heading 256 bytes, just because we can
};
2012-10-20 19:54:38 -04:00
static_assert(sizeof(DTMHeader) == 256, "DTMHeader should be 256 bytes");
#pragma pack(pop)
void FrameUpdate();
void InputUpdate();
Boot: Clean up the boot code * Move out boot parameters to a separate struct, which is not part of SConfig/ConfigManager because there is no reason for it to be there. * Move out file name parsing and constructing the appropriate params from paths to a separate function that does that, and only that. * For every different boot type we support, add a proper struct with only the required parameters, with descriptive names and use std::variant to only store what we need. * Clean up the bHLE_BS2 stuff which made no sense sometimes. Now instead of using bHLE_BS2 for two different things, both for storing the user config setting and as a runtime boot parameter, we simply replace the Disc boot params with BootParameters::IPL. * Const correctness so it's clear what can or cannot update the config. * Drop unused parameters and unneeded checks. * Make a few checks a lot more concise. (Looking at you, extension checks for disc images.) * Remove a mildly terrible workaround where we needed to pass an empty string in order to boot the GC IPL without any game inserted. (Not required anymore thanks to std::variant and std::optional.) The motivation for this are multiple: cleaning up and being able to add support for booting an installed NAND title. Without this change, it'd be pretty much impossible to implement that. Also, using std::visit with std::variant makes the compiler do additional type checks: now we're guaranteed that the boot code will handle all boot types and no invalid boot type will be possible.
2017-05-27 15:43:40 +02:00
void Init(const BootParameters& boot);
void SetPolledDevice();
bool IsRecordingInput();
bool IsRecordingInputFromSaveState();
bool IsJustStartingRecordingInputFromSaveState();
2012-10-18 04:03:12 -04:00
bool IsJustStartingPlayingInputFromSaveState();
bool IsPlayingInput();
bool IsMovieActive();
bool IsReadOnly();
u64 GetRecordingStartTime();
2016-08-04 12:54:45 -04:00
u64 GetCurrentFrame();
u64 GetTotalFrames();
u64 GetCurrentInputCount();
u64 GetTotalInputCount();
u64 GetCurrentLagCount();
u64 GetTotalLagCount();
void SetClearSave(bool enabled);
void SignalDiscChange(const std::string& new_path);
2016-08-04 12:54:45 -04:00
void SetReset(bool reset);
bool IsConfigSaved();
bool IsStartingFromClearSave();
2022-01-11 11:17:47 -08:00
bool IsUsingMemcard(ExpansionInterface::Slot slot);
void SetGraphicsConfig();
bool IsNetPlayRecording();
bool IsUsingPad(int controller);
bool IsUsingWiimote(int wiimote);
2012-12-18 23:19:15 -05:00
bool IsUsingBongo(int controller);
2021-07-04 13:38:30 +02:00
bool IsUsingGBA(int controller);
2019-01-26 10:29:06 -06:00
void ChangePads();
void ChangeWiiPads(bool instantly = false);
void SetReadOnly(bool bEnabled);
2021-07-04 13:38:30 +02:00
bool BeginRecordingInput(const ControllerTypeArray& controllers,
const WiimoteEnabledArray& wiimotes);
void RecordInput(const GCPadStatus* PadStatus, int controllerID);
void RecordWiimote(int wiimote, const u8* data, u8 size);
bool PlayInput(const std::string& movie_path, std::optional<std::string>* savestate_path);
void LoadInput(const std::string& movie_path);
void ReadHeader();
void PlayController(GCPadStatus* PadStatus, int controllerID);
bool PlayWiimote(int wiimote, WiimoteCommon::DataReportBuilder& rpt, int ext,
const WiimoteEmu::EncryptionKey& key);
void EndPlayInput(bool cont);
void SaveRecording(const std::string& filename);
2011-12-28 02:33:41 -06:00
void DoState(PointerWrap& p);
void Shutdown();
void CheckPadStatus(const GCPadStatus* PadStatus, int controllerID);
void CheckWiimoteStatus(int wiimote, const WiimoteCommon::DataReportBuilder& rpt, int ext,
const WiimoteEmu::EncryptionKey& key);
std::string GetInputDisplay();
2016-07-19 20:23:25 -04:00
std::string GetRTCDisplay();
std::string GetRerecords();
} // namespace Movie