Remove YBaseLib dependency

This commit is contained in:
Connor McLaughlin
2020-01-10 13:31:12 +10:00
parent 1c2c4c8489
commit 71c1e243fe
112 changed files with 6888 additions and 522 deletions

View File

@ -79,7 +79,7 @@ set(RECOMPILER_SRCS
target_include_directories(core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_link_libraries(core PUBLIC Threads::Threads YBaseLib common imgui tinyxml2)
target_link_libraries(core PUBLIC Threads::Threads common imgui tinyxml2)
target_link_libraries(core PRIVATE glad stb)
if(WIN32)

View File

@ -1,5 +1,5 @@
#include "analog_controller.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "common/state_wrapper.h"
Log_SetChannel(AnalogController);
@ -133,7 +133,7 @@ void AnalogController::SetMotorState(u8 motor, u8 value)
bool AnalogController::Transfer(const u8 data_in, u8* data_out)
{
bool ack;
#ifdef Y_BUILD_CONFIG_DEBUG
#ifdef _DEBUG
u8 old_state = static_cast<u8>(m_state);
#endif

View File

@ -1,6 +1,7 @@
#include "bios.h"
#include "YBaseLib/Log.h"
#include "YBaseLib/MD5Digest.h"
#include "common/log.h"
#include "common/assert.h"
#include "common/md5_digest.h"
#include "cpu_disasm.h"
#include <cerrno>
Log_SetChannel(BIOS);

View File

@ -1,9 +1,8 @@
#include "bus.h"
#include "YBaseLib/ByteStream.h"
#include "YBaseLib/Log.h"
#include "YBaseLib/MD5Digest.h"
#include "YBaseLib/String.h"
#include "cdrom.h"
#include "common/align.h"
#include "common/assert.h"
#include "common/log.h"
#include "common/state_wrapper.h"
#include "cpu_code_cache.h"
#include "cpu_core.h"
@ -344,19 +343,19 @@ void Bus::DoWriteEXP2(MemoryAccessSize size, u32 offset, u32 value)
if (value == '\n')
{
if (!m_tty_line_buffer.IsEmpty())
if (!m_tty_line_buffer.empty())
{
Log_InfoPrintf("TTY: %s", m_tty_line_buffer.GetCharArray());
Log_InfoPrintf("TTY: %s", m_tty_line_buffer.c_str());
#ifdef _DEBUG
if (CPU::LOG_EXECUTION)
CPU::WriteToExecutionLog("TTY: %s\n", m_tty_line_buffer.GetCharArray());
CPU::WriteToExecutionLog("TTY: %s\n", m_tty_line_buffer.c_str());
#endif
}
m_tty_line_buffer.Clear();
m_tty_line_buffer.clear();
}
else
{
m_tty_line_buffer.AppendCharacter(Truncate8(value));
m_tty_line_buffer += static_cast<char>(Truncate8(value));
}
return;

View File

@ -1,10 +1,9 @@
#pragma once
#include "YBaseLib/String.h"
#include "common/bitfield.h"
#include "types.h"
#include <array>
#include <bitset>
#include <string>
#include <vector>
class StateWrapper;
@ -270,7 +269,7 @@ private:
MEMCTRL m_MEMCTRL = {};
u32 m_ram_size_reg = 0;
String m_tty_line_buffer;
std::string m_tty_line_buffer;
};
#include "bus.inl"

View File

@ -1,5 +1,5 @@
#include "cdrom.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "common/cd_image.h"
#include "common/state_wrapper.h"
#include "dma.h"
@ -1421,7 +1421,7 @@ static void ResampleXAADPCM(const s16* samples_in, u32 num_samples_in, SPU* spu,
if constexpr (!STEREO)
{
UNREFERENCED_PARAMETER(right);
UNREFERENCED_VARIABLE(right);
}
for (u32 sample_dup = 0; sample_dup < (SAMPLE_RATE ? 2 : 1); sample_dup++)

View File

@ -129,9 +129,6 @@
<ProjectReference Include="..\..\dep\tinyxml2\tinyxml2.vcxproj">
<Project>{933118a9-68c5-47b4-b151-b03c93961623}</Project>
</ProjectReference>
<ProjectReference Include="..\..\dep\YBaseLib\Source\YBaseLib.vcxproj">
<Project>{b56ce698-7300-4fa5-9609-942f1d05c5a2}</Project>
</ProjectReference>
<ProjectReference Include="..\common\common.vcxproj">
<Project>{ee054e08-3799-4a59-a422-18259c105ffd}</Project>
</ProjectReference>
@ -284,7 +281,7 @@
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<LanguageStandard>stdcpp17</LanguageStandard>
@ -306,7 +303,7 @@
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<LanguageStandard>stdcpp17</LanguageStandard>
@ -328,7 +325,7 @@
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
@ -353,7 +350,7 @@
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
@ -377,7 +374,7 @@
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>false</WholeProgramOptimization>
<LanguageStandard>stdcpp17</LanguageStandard>
@ -400,7 +397,7 @@
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>true</WholeProgramOptimization>
<LanguageStandard>stdcpp17</LanguageStandard>
@ -424,7 +421,7 @@
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>false</WholeProgramOptimization>
<LanguageStandard>stdcpp17</LanguageStandard>
@ -447,7 +444,7 @@
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>true</WholeProgramOptimization>
<LanguageStandard>stdcpp17</LanguageStandard>

View File

@ -1,5 +1,5 @@
#include "cpu_code_cache.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "cpu_core.h"
#include "cpu_disasm.h"
#include "system.h"

View File

@ -1,6 +1,7 @@
#include "cpu_core.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "common/state_wrapper.h"
#include "common/align.h"
#include "cpu_disasm.h"
#include <cstdio>
Log_SetChannel(CPU::Core);

View File

@ -1,5 +1,5 @@
#pragma once
#include "YBaseLib/Assert.h"
#include "common/align.h"
#include "bus.h"
#include "cpu_core.h"

View File

@ -1,5 +1,5 @@
#pragma once
#include "YBaseLib/String.h"
#include "common/string.h"
#include "cpu_types.h"
namespace CPU {

View File

@ -1,5 +1,5 @@
#include "cpu_recompiler_code_generator.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "cpu_core.h"
#include "cpu_disasm.h"
Log_SetChannel(CPU::Recompiler);
@ -12,7 +12,7 @@ namespace CPU::Recompiler {
u32 CodeGenerator::CalculateRegisterOffset(Reg reg)
{
return uint32(offsetof(Core, m_regs.r[0]) + (static_cast<u32>(reg) * sizeof(u32)));
return u32(offsetof(Core, m_regs.r[0]) + (static_cast<u32>(reg) * sizeof(u32)));
}
bool CodeGenerator::CompileBlock(const CodeBlock* block, CodeBlock::HostCodePointer* out_host_code,
@ -837,7 +837,7 @@ void CodeGenerator::BlockPrologue()
void CodeGenerator::BlockEpilogue()
{
#if defined(_DEBUG) && defined(Y_CPU_X64)
#if defined(_DEBUG) && defined(CPU_X64)
m_emit->nop();
#endif
@ -851,7 +851,7 @@ void CodeGenerator::BlockEpilogue()
void CodeGenerator::InstructionPrologue(const CodeBlockInstruction& cbi, TickCount cycles,
bool force_sync /* = false */)
{
#if defined(_DEBUG) && defined(Y_CPU_X64)
#if defined(_DEBUG) && defined(CPU_X64)
m_emit->nop();
#endif

View File

@ -11,17 +11,6 @@
#include "cpu_recompiler_types.h"
#include "cpu_types.h"
// ABI selection
#if defined(Y_CPU_X64)
#if defined(Y_PLATFORM_WINDOWS)
#define ABI_WIN64 1
#elif defined(Y_PLATFORM_LINUX) || defined(Y_PLATFORM_OSX) || defined(Y_PLATFORM_ANDROID)
#define ABI_SYSV 1
#else
#error Unknown ABI.
#endif
#endif
namespace CPU::Recompiler {
class CodeGenerator

View File

@ -1,4 +1,4 @@
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "cpu_recompiler_code_generator.h"
#include "cpu_recompiler_thunks.h"
#include "cpu_core.h"

View File

@ -1,5 +1,5 @@
#include "cpu_recompiler_register_cache.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "cpu_recompiler_code_generator.h"
#include <cinttypes>
Log_SetChannel(CPU::Recompiler);

View File

@ -1,5 +1,5 @@
#pragma once
#include "YBaseLib/Assert.h"
#include "common/assert.h"
#include "cpu_recompiler_types.h"
#include "cpu_types.h"

View File

@ -1,12 +1,22 @@
#pragma once
#include "common/cpu_detect.h"
#include "cpu_types.h"
#if defined(Y_CPU_X64)
#if defined(CPU_X64)
// We need to include windows.h before xbyak does..
#ifdef WIN32
#include "common/windows_headers.h"
#endif
#define XBYAK_NO_OP_NAMES 1
#include "xbyak.h"
#elif defined(Y_CPU_AARCH64)
#elif defined(CPU_AARCH64)
#include <vixl/aarch64/constants-aarch64.h>
#include <vixl/aarch64/macro-assembler-aarch64.h>
#endif
namespace CPU {
@ -48,7 +58,7 @@ enum class Condition : u8
Zero
};
#if defined(Y_CPU_X64)
#if defined(CPU_X64)
using HostReg = Xbyak::Operand::Code;
using CodeEmitter = Xbyak::CodeGenerator;
@ -67,14 +77,23 @@ constexpr u32 MAX_FAR_HOST_BYTES_PER_INSTRUCTION = 128;
// Are shifts implicitly masked to 0..31?
constexpr bool SHIFTS_ARE_IMPLICITLY_MASKED = true;
#elif defined(Y_CPU_AARCH64)
// ABI selection
#if defined(WIN32)
#define ABI_WIN64 1
#elif defined(__linux__) || defined(__ANDROID__)
#define ABI_SYSV 1
#else
#error Unknown ABI.
#endif
#elif defined(CPU_AARCH64)
using HostReg = unsigned;
using CodeEmitter = vixl::aarch64::MacroAssembler;
using LabelType = vixl::aarch64::Label;
enum : u32
{
HostReg_Count = vixl::aarch64::kNumberOfRegisters
HostReg_Count = vixl::aarch64::kNumberOfRegisters
};
constexpr HostReg HostReg_Invalid = static_cast<HostReg>(HostReg_Count);
constexpr RegSize HostPointerSize = RegSize_64;

View File

@ -1,5 +1,5 @@
#include "cpu_types.h"
#include "YBaseLib/Assert.h"
#include "common/assert.h"
#include <array>
namespace CPU {

View File

@ -1,5 +1,5 @@
#include "digital_controller.h"
#include "YBaseLib/Assert.h"
#include "common/assert.h"
DigitalController::DigitalController() = default;

View File

@ -1,5 +1,5 @@
#include "dma.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "bus.h"
#include "cdrom.h"
#include "common/state_wrapper.h"

View File

@ -1,13 +1,12 @@
#include "game_list.h"
#include "YBaseLib/AutoReleasePtr.h"
#include "YBaseLib/BinaryReader.h"
#include "YBaseLib/BinaryWriter.h"
#include "YBaseLib/ByteStream.h"
#include "YBaseLib/FileSystem.h"
#include "YBaseLib/Log.h"
#include "bios.h"
#include "common/assert.h"
#include "common/byte_stream.h"
#include "common/cd_image.h"
#include "common/file_system.h"
#include "common/iso_reader.h"
#include "common/log.h"
#include "common/string_util.h"
#include "settings.h"
#include <algorithm>
#include <array>
@ -17,12 +16,6 @@
#include <utility>
Log_SetChannel(GameList);
#ifdef _MSC_VER
#define CASE_COMPARE _stricmp
#else
#define CASE_COMPARE strcasecmp
#endif
GameList::GameList() = default;
GameList::~GameList() = default;
@ -91,7 +84,7 @@ std::string GameList::GetGameCodeForImage(CDImage* cdi)
// Find the BOOT line
auto iter = std::find_if(lines.begin(), lines.end(),
[](const auto& it) { return CASE_COMPARE(it.first.c_str(), "boot") == 0; });
[](const auto& it) { return StringUtil::Strcasecmp(it.first.c_str(), "boot") == 0; });
if (iter == lines.end())
return {};
@ -203,7 +196,8 @@ std::optional<ConsoleRegion> GameList::GetRegionForPath(const char* image_path)
bool GameList::IsExeFileName(const char* path)
{
const char* extension = std::strrchr(path, '.');
return (extension && (CASE_COMPARE(extension, ".exe") == 0 || CASE_COMPARE(extension, ".psexe") == 0));
return (extension &&
(StringUtil::Strcasecmp(extension, ".exe") == 0 || StringUtil::Strcasecmp(extension, ".psexe") == 0));
}
static std::string_view GetFileNameFromPath(const char* path)
@ -340,45 +334,93 @@ void GameList::LoadCache()
if (m_cache_filename.empty())
return;
ByteStream* stream = FileSystem::OpenFile(m_cache_filename.c_str(), BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_STREAMED);
std::unique_ptr<ByteStream> stream =
FileSystem::OpenFile(m_cache_filename.c_str(), BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_STREAMED);
if (!stream)
return;
if (!LoadEntriesFromCache(stream))
if (!LoadEntriesFromCache(stream.get()))
{
Log_WarningPrintf("Deleting corrupted cache file '%s'", m_cache_filename.c_str());
stream->Release();
stream.reset();
m_cache_map.clear();
DeleteCacheFile();
return;
}
}
stream->Release();
static bool ReadString(ByteStream* stream, std::string* dest)
{
u32 size;
if (!stream->Read2(&size, sizeof(size)))
return false;
dest->resize(size);
if (!stream->Read2(dest->data(), size))
return false;
return true;
}
static bool ReadU8(ByteStream* stream, u8* dest)
{
return stream->Read2(dest, sizeof(u8));
}
static bool ReadU32(ByteStream* stream, u32* dest)
{
return stream->Read2(dest, sizeof(u32));
}
static bool ReadU64(ByteStream* stream, u64* dest)
{
return stream->Read2(dest, sizeof(u64));
}
static bool WriteString(ByteStream* stream, const std::string& str)
{
const u32 size = static_cast<u32>(str.size());
return (stream->Write2(&size, sizeof(size)) && (size == 0 || stream->Write2(str.data(), size)));
}
static bool WriteU8(ByteStream* stream, u8 dest)
{
return stream->Write2(&dest, sizeof(u8));
}
static bool WriteU32(ByteStream* stream, u32 dest)
{
return stream->Write2(&dest, sizeof(u32));
}
static bool WriteU64(ByteStream* stream, u64 dest)
{
return stream->Write2(&dest, sizeof(u64));
}
bool GameList::LoadEntriesFromCache(ByteStream* stream)
{
BinaryReader reader(stream);
if (reader.ReadUInt32() != GAME_LIST_CACHE_SIGNATURE || reader.ReadUInt32() != GAME_LIST_CACHE_VERSION)
u32 file_signature, file_version;
if (!ReadU32(stream, &file_signature) || !ReadU32(stream, &file_version) ||
file_signature != GAME_LIST_CACHE_SIGNATURE || file_version != GAME_LIST_CACHE_VERSION)
{
Log_WarningPrintf("Game list cache is corrupted");
return false;
}
String path;
TinyString code;
SmallString title;
u64 total_size;
u64 last_modified_time;
u8 region;
u8 type;
while (stream->GetPosition() != stream->GetSize())
{
if (!reader.SafeReadSizePrefixedString(&path) || !reader.SafeReadSizePrefixedString(&code) ||
!reader.SafeReadSizePrefixedString(&title) || !reader.SafeReadUInt64(&total_size) ||
!reader.SafeReadUInt64(&last_modified_time) || !reader.SafeReadUInt8(&region) ||
region >= static_cast<u8>(ConsoleRegion::Count) || !reader.SafeReadUInt8(&type) ||
std::string path;
std::string code;
std::string title;
u64 total_size;
u64 last_modified_time;
u8 region;
u8 type;
if (!ReadString(stream, &path) || !ReadString(stream, &code) || !ReadString(stream, &title) ||
!ReadU64(stream, &total_size) || !ReadU64(stream, &last_modified_time) || !ReadU8(stream, &region) ||
region >= static_cast<u8>(ConsoleRegion::Count) || !ReadU8(stream, &type) ||
type > static_cast<u8>(EntryType::PSExe))
{
Log_WarningPrintf("Game list cache entry is corrupted");
@ -386,9 +428,9 @@ bool GameList::LoadEntriesFromCache(ByteStream* stream)
}
GameListEntry ge;
ge.path = path;
ge.code = code;
ge.title = title;
ge.path = std::move(path);
ge.code = std::move(code);
ge.title = std::move(title);
ge.total_size = total_size;
ge.last_modified_time = last_modified_time;
ge.region = static_cast<ConsoleRegion>(region);
@ -419,12 +461,11 @@ bool GameList::OpenCacheForWriting()
if (m_cache_write_stream->GetPosition() == 0)
{
// new cache file, write header
BinaryWriter writer(m_cache_write_stream);
if (!writer.SafeWriteUInt32(GAME_LIST_CACHE_SIGNATURE) || !writer.SafeWriteUInt32(GAME_LIST_CACHE_VERSION))
if (!WriteU32(m_cache_write_stream.get(), GAME_LIST_CACHE_SIGNATURE) ||
!WriteU32(m_cache_write_stream.get(), GAME_LIST_CACHE_VERSION))
{
Log_ErrorPrintf("Failed to write game list cache header");
m_cache_write_stream->Release();
m_cache_write_stream = nullptr;
m_cache_write_stream.reset();
FileSystem::DeleteFile(m_cache_filename.c_str());
return false;
}
@ -435,14 +476,13 @@ bool GameList::OpenCacheForWriting()
bool GameList::WriteEntryToCache(const GameListEntry* entry, ByteStream* stream)
{
BinaryWriter writer(stream);
bool result = writer.SafeWriteSizePrefixedString(entry->path.c_str());
result &= writer.SafeWriteSizePrefixedString(entry->code.c_str());
result &= writer.SafeWriteSizePrefixedString(entry->title.c_str());
result &= writer.SafeWriteUInt64(entry->total_size);
result &= writer.SafeWriteUInt64(entry->last_modified_time);
result &= writer.SafeWriteUInt8(static_cast<u8>(entry->region));
result &= writer.SafeWriteUInt8(static_cast<u8>(entry->type));
bool result = WriteString(stream, entry->path);
result &= WriteString(stream, entry->code);
result &= WriteString(stream, entry->title);
result &= WriteU64(stream, entry->total_size);
result &= WriteU64(stream, entry->last_modified_time);
result &= WriteU8(stream, static_cast<u8>(entry->region));
result &= WriteU8(stream, static_cast<u8>(entry->type));
return result;
}
@ -452,8 +492,7 @@ void GameList::CloseCacheFileStream()
return;
m_cache_write_stream->Commit();
m_cache_write_stream->Release();
m_cache_write_stream = nullptr;
m_cache_write_stream.reset();
}
void GameList::DeleteCacheFile()
@ -479,14 +518,14 @@ void GameList::ScanDirectory(const char* path, bool recursive)
for (const FILESYSTEM_FIND_DATA& ffd : files)
{
// if this is a .bin, check if we have a .cue. if there is one, skip it
const char* extension = std::strrchr(ffd.FileName, '.');
if (extension && CASE_COMPARE(extension, ".bin") == 0)
const char* extension = std::strrchr(ffd.FileName.c_str(), '.');
if (extension && StringUtil::Strcasecmp(extension, ".bin") == 0)
{
#if 0
std::string temp(ffd.FileName, extension - ffd.FileName);
temp += ".cue";
if (std::any_of(files.begin(), files.end(),
[&temp](const FILESYSTEM_FIND_DATA& it) { return CASE_COMPARE(it.FileName, temp.c_str()) == 0; }))
[&temp](const FILESYSTEM_FIND_DATA& it) { return StringUtil::Strcasecmp(it.FileName, temp.c_str()) == 0; }))
{
Log_DebugPrintf("Skipping due to '%s' existing", temp.c_str());
continue;
@ -512,7 +551,7 @@ void GameList::ScanDirectory(const char* path, bool recursive)
{
if (m_cache_write_stream || OpenCacheForWriting())
{
if (!WriteEntryToCache(&entry, m_cache_write_stream))
if (!WriteEntryToCache(&entry, m_cache_write_stream.get()))
Log_WarningPrintf("Failed to write entry '%s' to cache", entry.path.c_str());
}
}
@ -554,10 +593,10 @@ public:
bool VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* firstAttribute) override
{
// recurse into gamelist
if (CASE_COMPARE(element.Name(), "datafile") == 0)
if (StringUtil::Strcasecmp(element.Name(), "datafile") == 0)
return true;
if (CASE_COMPARE(element.Name(), "game") != 0)
if (StringUtil::Strcasecmp(element.Name(), "game") != 0)
return false;
const char* name = element.Attribute("name");

View File

@ -1,5 +1,6 @@
#pragma once
#include "types.h"
#include <memory>
#include <optional>
#include <string>
#include <string_view>
@ -48,6 +49,9 @@ public:
static const char* EntryTypeToString(EntryType type);
/// Returns true if the filename is a PlayStation executable we can inject.
static bool IsExeFileName(const char* path);
static std::string GetGameCodeForImage(CDImage* cdi);
static std::string GetGameCodeForPath(const char* image_path);
static std::optional<ConsoleRegion> GetRegionForCode(std::string_view code);
@ -76,7 +80,6 @@ private:
bool recursive;
};
static bool IsExeFileName(const char* path);
static bool GetExeListEntry(const char* path, GameListEntry* entry);
bool GetGameListEntry(const std::string& path, GameListEntry* entry);
@ -96,7 +99,7 @@ private:
DatabaseMap m_database;
EntryList m_entries;
CacheMap m_cache_map;
ByteStream* m_cache_write_stream = nullptr;
std::unique_ptr<ByteStream> m_cache_write_stream;
std::vector<DirectoryEntry> m_search_directories;
std::string m_cache_filename;

View File

@ -1,5 +1,5 @@
#include "gpu.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "common/heap_array.h"
#include "common/state_wrapper.h"
#include "dma.h"

View File

@ -3,6 +3,7 @@
#include "common/rectangle.h"
#include "timers.h"
#include "types.h"
#include <algorithm>
#include <array>
#include <deque>
#include <memory>

View File

@ -1,5 +1,6 @@
#include "YBaseLib/Log.h"
#include "YBaseLib/String.h"
#include "common/assert.h"
#include "common/log.h"
#include "common/string_util.h"
#include "gpu.h"
#include "interrupt_controller.h"
#include "system.h"
@ -356,8 +357,8 @@ bool GPU::HandleCopyRectangleCPUToVRAMCommand(const u32*& command_ptr, u32 comma
if (m_system->GetSettings().debugging.dump_cpu_to_vram_copies)
{
DumpVRAMToFile(SmallString::FromFormat("cpu_to_vram_copy_%u.png", s_cpu_to_vram_dump_id++), copy_width, copy_height,
sizeof(u16) * copy_width, &command_ptr[3], true);
DumpVRAMToFile(StringUtil::StdStringFromFormat("cpu_to_vram_copy_%u.png", s_cpu_to_vram_dump_id++).c_str(),
copy_width, copy_height, sizeof(u16) * copy_width, &command_ptr[3], true);
}
FlushRender();
@ -390,8 +391,8 @@ bool GPU::HandleCopyRectangleVRAMToCPUCommand(const u32*& command_ptr, u32 comma
if (m_system->GetSettings().debugging.dump_vram_to_cpu_copies)
{
DumpVRAMToFile(SmallString::FromFormat("vram_to_cpu_copy_%u.png", s_vram_to_cpu_dump_id++), m_vram_transfer.width,
m_vram_transfer.height, sizeof(u16) * VRAM_WIDTH,
DumpVRAMToFile(StringUtil::StdStringFromFormat("vram_to_cpu_copy_%u.png", s_vram_to_cpu_dump_id++).c_str(),
m_vram_transfer.width, m_vram_transfer.height, sizeof(u16) * VRAM_WIDTH,
&m_vram_ptr[m_vram_transfer.y * VRAM_WIDTH + m_vram_transfer.x], true);
}

View File

@ -1,6 +1,6 @@
#include "gpu_hw.h"
#include "YBaseLib/Assert.h"
#include "YBaseLib/Log.h"
#include "common/assert.h"
#include "common/log.h"
#include "common/state_wrapper.h"
#include "settings.h"
#include "system.h"

View File

@ -1,7 +1,6 @@
#include "gpu_hw_d3d11.h"
#include "YBaseLib/Assert.h"
#include "YBaseLib/Log.h"
#include "YBaseLib/String.h"
#include "common/assert.h"
#include "common/log.h"
#include "common/d3d11/shader_compiler.h"
#include "gpu_hw_shadergen.h"
#include "host_display.h"

View File

@ -1,7 +1,6 @@
#include "gpu_hw_opengl.h"
#include "YBaseLib/Assert.h"
#include "YBaseLib/Log.h"
#include "YBaseLib/String.h"
#include "common/assert.h"
#include "common/log.h"
#include "gpu_hw_shadergen.h"
#include "host_display.h"
#include "system.h"

View File

@ -1,7 +1,6 @@
#include "gpu_hw_opengl_es.h"
#include "YBaseLib/Assert.h"
#include "YBaseLib/Log.h"
#include "YBaseLib/String.h"
#include "common/assert.h"
#include "common/log.h"
#include "gpu_hw_shadergen.h"
#include "host_display.h"
#include "system.h"

View File

@ -1,6 +1,6 @@
#include "gpu_hw_shadergen.h"
#include "YBaseLib/Assert.h"
#include "YBaseLib/Log.h"
#include "common/assert.h"
#include "common/log.h"
#include <cstdio>
#include <glad.h>
Log_SetChannel(GPU_HW_ShaderGen);

View File

@ -1,5 +1,5 @@
#include "gpu_sw.h"
#include "YBaseLib/Assert.h"
#include "common/assert.h"
#include "host_display.h"
#include "system.h"
#include <algorithm>
@ -593,7 +593,7 @@ void GPU_SW::ShadePixel(u32 x, u32 y, u8 color_r, u8 color_g, u8 color_b, u8 tex
}
else
{
UNREFERENCED_PARAMETER(transparent);
UNREFERENCED_VARIABLE(transparent);
}
const u16 mask_and = m_GPUSTAT.GetMaskAND();

View File

@ -1,10 +1,12 @@
#include "host_interface.h"
#include "YBaseLib/ByteStream.h"
#include "YBaseLib/Log.h"
#include "YBaseLib/Timer.h"
#include "bios.h"
#include "cdrom.h"
#include "common/audio_stream.h"
#include "common/byte_stream.h"
#include "common/file_system.h"
#include "common/log.h"
#include "common/string_util.h"
#include "common/timer.h"
#include "dma.h"
#include "gpu.h"
#include "host_display.h"
@ -18,7 +20,7 @@
Log_SetChannel(HostInterface);
#ifdef _WIN32
#include "YBaseLib/Windows/WindowsHeaders.h"
#include "common/windows_headers.h"
#else
#include <time.h>
#endif
@ -50,7 +52,7 @@ static std::string GetRelativePath(const std::string& path, const char* new_file
HostInterface::HostInterface()
{
m_settings.SetDefaults();
m_last_throttle_time = Y_TimerGetValue();
m_last_throttle_time = Common::Timer::GetValue();
}
HostInterface::~HostInterface() = default;
@ -104,6 +106,26 @@ void HostInterface::ReportMessage(const char* message)
Log_InfoPrintf(message);
}
void HostInterface::ReportFormattedError(const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
std::string message = StringUtil::StdStringFromFormatV(format, ap);
va_end(ap);
ReportError(message.c_str());
}
void HostInterface::ReportFormattedMessage(const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
std::string message = StringUtil::StdStringFromFormatV(format, ap);
va_end(ap);
ReportMessage(message.c_str());
}
void HostInterface::DrawFPSWindow()
{
const bool show_fps = true;
@ -183,6 +205,21 @@ void HostInterface::AddOSDMessage(const char* message, float duration /*= 2.0f*/
m_osd_messages.push_back(std::move(msg));
}
void HostInterface::AddFormattedOSDMessage(float duration, const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
std::string message = StringUtil::StdStringFromFormatV(format, ap);
va_end(ap);
OSDMessage msg;
msg.text = std::move(message);
msg.duration = duration;
std::unique_lock<std::mutex> lock(m_osd_messages_lock);
m_osd_messages.push_back(std::move(msg));
}
void HostInterface::DrawOSDMessages()
{
constexpr ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs |
@ -213,7 +250,10 @@ void HostInterface::DrawOSDMessages()
ImGui::SetNextWindowSize(ImVec2(0.0f, 0.0f));
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, opacity);
if (ImGui::Begin(SmallString::FromFormat("osd_%u", index++), nullptr, window_flags))
char buf[64];
std::snprintf(buf, sizeof(buf), "osd_%u", index++);
if (ImGui::Begin(buf, nullptr, window_flags))
{
ImGui::TextUnformatted(msg.text.c_str());
position_y += ImGui::GetWindowSize().y + (4.0f * scale);
@ -339,47 +379,42 @@ void HostInterface::Throttle()
bool HostInterface::LoadState(const char* filename)
{
ByteStream* stream;
if (!ByteStream_OpenFileStream(filename, BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_STREAMED, &stream))
std::unique_ptr<ByteStream> stream = FileSystem::OpenFile(filename, BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_STREAMED);
if (!stream)
return false;
AddOSDMessage(SmallString::FromFormat("Loading state from %s...", filename));
AddFormattedOSDMessage(2.0f, "Loading state from %s...", filename);
const bool result = m_system->LoadState(stream);
const bool result = m_system->LoadState(stream.get());
if (!result)
{
ReportError(SmallString::FromFormat("Loading state from %s failed. Resetting.", filename));
ReportFormattedError("Loading state from %s failed. Resetting.", filename);
m_system->Reset();
}
stream->Release();
return result;
}
bool HostInterface::SaveState(const char* filename)
{
ByteStream* stream;
if (!ByteStream_OpenFileStream(filename,
BYTESTREAM_OPEN_CREATE | BYTESTREAM_OPEN_WRITE | BYTESTREAM_OPEN_TRUNCATE |
BYTESTREAM_OPEN_ATOMIC_UPDATE | BYTESTREAM_OPEN_STREAMED,
&stream))
{
std::unique_ptr<ByteStream> stream =
FileSystem::OpenFile(filename, BYTESTREAM_OPEN_CREATE | BYTESTREAM_OPEN_WRITE | BYTESTREAM_OPEN_TRUNCATE |
BYTESTREAM_OPEN_ATOMIC_UPDATE | BYTESTREAM_OPEN_STREAMED);
if (!stream)
return false;
}
const bool result = m_system->SaveState(stream);
const bool result = m_system->SaveState(stream.get());
if (!result)
{
ReportError(SmallString::FromFormat("Saving state to %s failed.", filename));
ReportFormattedError("Saving state to %s failed.", filename);
stream->Discard();
}
else
{
AddOSDMessage(SmallString::FromFormat("State saved to %s.", filename));
ReportFormattedError("State saved to %s.", filename);
stream->Commit();
}
stream->Release();
return result;
}

View File

@ -1,5 +1,5 @@
#pragma once
#include "YBaseLib/Timer.h"
#include "common/timer.h"
#include "settings.h"
#include "types.h"
#include <chrono>
@ -41,8 +41,12 @@ public:
virtual void ReportError(const char* message);
virtual void ReportMessage(const char* message);
void ReportFormattedError(const char* format, ...);
void ReportFormattedMessage(const char* format, ...);
/// Adds OSD messages, duration is in seconds.
void AddOSDMessage(const char* message, float duration = 2.0f);
void AddFormattedOSDMessage(float duration, const char* format, ...);
/// Loads the BIOS image for the specified region.
virtual std::optional<std::vector<u8>> GetBIOSImage(ConsoleRegion region);
@ -64,7 +68,7 @@ protected:
struct OSDMessage
{
std::string text;
Timer time;
Common::Timer time;
float duration;
};
@ -88,8 +92,8 @@ protected:
u64 m_last_throttle_time = 0;
s64 m_throttle_period = INT64_C(1000000000) / 60;
Timer m_throttle_timer;
Timer m_speed_lost_time_timestamp;
Common::Timer m_throttle_timer;
Common::Timer m_speed_lost_time_timestamp;
float m_vps = 0.0f;
float m_fps = 0.0f;
@ -97,7 +101,7 @@ protected:
u32 m_last_frame_number = 0;
u32 m_last_internal_frame_number = 0;
u32 m_last_global_tick_counter = 0;
Timer m_fps_timer;
Common::Timer m_fps_timer;
std::deque<OSDMessage> m_osd_messages;
std::mutex m_osd_messages_lock;

View File

@ -1,5 +1,5 @@
#include "interrupt_controller.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "common/state_wrapper.h"
#include "cpu_core.h"
Log_SetChannel(InterruptController);

View File

@ -1,5 +1,5 @@
#include "mdec.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "common/state_wrapper.h"
#include "dma.h"
#include "interrupt_controller.h"

View File

@ -1,8 +1,7 @@
#include "memory_card.h"
#include "YBaseLib/AutoReleasePtr.h"
#include "YBaseLib/ByteStream.h"
#include "YBaseLib/FileSystem.h"
#include "YBaseLib/Log.h"
#include "common/byte_stream.h"
#include "common/file_system.h"
#include "common/log.h"
#include "common/state_wrapper.h"
#include "host_interface.h"
#include "system.h"
@ -328,7 +327,7 @@ u8* MemoryCard::GetSectorPtr(u32 sector)
bool MemoryCard::LoadFromFile()
{
AutoReleasePtr<ByteStream> stream =
std::unique_ptr<ByteStream> stream =
FileSystem::OpenFile(m_filename.c_str(), BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_STREAMED);
if (!stream)
return false;
@ -348,7 +347,7 @@ bool MemoryCard::SaveToFile()
if (m_filename.empty())
return false;
AutoReleasePtr<ByteStream> stream =
std::unique_ptr<ByteStream> stream =
FileSystem::OpenFile(m_filename.c_str(), BYTESTREAM_OPEN_CREATE | BYTESTREAM_OPEN_TRUNCATE | BYTESTREAM_OPEN_WRITE |
BYTESTREAM_OPEN_ATOMIC_UPDATE | BYTESTREAM_OPEN_STREAMED);
if (!stream)

View File

@ -1,5 +1,5 @@
#include "pad.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "common/state_wrapper.h"
#include "controller.h"
#include "host_interface.h"
@ -42,9 +42,9 @@ bool Pad::DoState(StateWrapper& sw)
if (controller_type != state_controller_type)
{
m_system->GetHostInterface()->AddOSDMessage(SmallString::FromFormat(
"Save state contains controller type %s in port %u, but %s is used. Switching.",
Settings::GetControllerTypeName(state_controller_type), i, Settings::GetControllerTypeName(controller_type)));
m_system->GetHostInterface()->AddFormattedOSDMessage(
2.0f, "Save state contains controller type %s in port %u, but %s is used. Switching.",
Settings::GetControllerTypeName(state_controller_type), i, Settings::GetControllerTypeName(controller_type));
m_controllers[i].reset();
if (state_controller_type != ControllerType::None)
@ -62,20 +62,14 @@ bool Pad::DoState(StateWrapper& sw)
if (card_present && !m_memory_cards[i])
{
const TinyString message = TinyString::FromFormat(
"Memory card %c present in save state but not in system. Creating temporary card.", 'A' + i);
m_system->GetHostInterface()->AddOSDMessage(message);
Log_WarningPrint(message);
m_system->GetHostInterface()->AddFormattedOSDMessage(
2.0f, "Memory card %c present in save state but not in system. Creating temporary card.", 'A' + i);
m_memory_cards[i] = MemoryCard::Create(m_system);
}
else if (!card_present && m_memory_cards[i])
{
const TinyString message =
TinyString::FromFormat("Memory card %u present system but not save state. Removing card.", 'A' + i);
m_system->GetHostInterface()->AddOSDMessage(message);
Log_WarningPrint(message);
m_system->GetHostInterface()->AddFormattedOSDMessage(
2.0f, "Memory card %u present system but not save state. Removing card.", 'A' + i);
m_memory_cards[i].reset();
}

View File

@ -1,10 +1,6 @@
#include "settings.h"
#include "common/string_util.h"
#include <array>
#include <string.h>
#ifdef _MSC_VER
#define strcasecmp stricmp
#endif
Settings::Settings() = default;
@ -132,7 +128,7 @@ std::optional<ConsoleRegion> Settings::ParseConsoleRegionName(const char* str)
int index = 0;
for (const char* name : s_console_region_names)
{
if (strcasecmp(name, str) == 0)
if (StringUtil::Strcasecmp(name, str) == 0)
return static_cast<ConsoleRegion>(index);
index++;
@ -160,7 +156,7 @@ std::optional<CPUExecutionMode> Settings::ParseCPUExecutionMode(const char* str)
u8 index = 0;
for (const char* name : s_cpu_execution_mode_names)
{
if (strcasecmp(name, str) == 0)
if (StringUtil::Strcasecmp(name, str) == 0)
return static_cast<CPUExecutionMode>(index);
index++;
@ -195,7 +191,7 @@ std::optional<GPURenderer> Settings::ParseRendererName(const char* str)
int index = 0;
for (const char* name : s_gpu_renderer_names)
{
if (strcasecmp(name, str) == 0)
if (StringUtil::Strcasecmp(name, str) == 0)
return static_cast<GPURenderer>(index);
index++;
@ -222,7 +218,7 @@ std::optional<AudioBackend> Settings::ParseAudioBackend(const char* str)
int index = 0;
for (const char* name : s_audio_backend_names)
{
if (strcasecmp(name, str) == 0)
if (StringUtil::Strcasecmp(name, str) == 0)
return static_cast<AudioBackend>(index);
index++;
@ -250,7 +246,7 @@ std::optional<ControllerType> Settings::ParseControllerTypeName(const char* str)
int index = 0;
for (const char* name : s_controller_type_names)
{
if (strcasecmp(name, str) == 0)
if (StringUtil::Strcasecmp(name, str) == 0)
return static_cast<ControllerType>(index);
index++;

View File

@ -1,5 +1,5 @@
#include "sio.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "common/state_wrapper.h"
#include "host_interface.h"
#include "interrupt_controller.h"

View File

@ -1,5 +1,5 @@
#include "spu.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "common/audio_stream.h"
#include "common/state_wrapper.h"
#include "dma.h"

View File

@ -1,9 +1,8 @@
#include "system.h"
#include "YBaseLib/AutoReleasePtr.h"
#include "YBaseLib/Log.h"
#include "bios.h"
#include "bus.h"
#include "cdrom.h"
#include "common/log.h"
#include "common/state_wrapper.h"
#include "controller.h"
#include "cpu_code_cache.h"
@ -43,12 +42,6 @@ System::System(HostInterface* host_interface) : m_host_interface(host_interface)
System::~System() = default;
bool System::IsPSExe(const char* filename)
{
const StaticString filename_str(filename);
return filename_str.EndsWith(".psexe", false) || filename_str.EndsWith(".exe", false);
}
std::unique_ptr<System> System::Create(HostInterface* host_interface)
{
std::unique_ptr<System> system(new System(host_interface));
@ -61,8 +54,8 @@ std::unique_ptr<System> System::Create(HostInterface* host_interface)
bool System::RecreateGPU()
{
// save current state
AutoReleasePtr<ByteStream> state_stream = ByteStream_CreateGrowableMemoryStream();
StateWrapper sw(state_stream, StateWrapper::Mode::Write);
std::unique_ptr<ByteStream> state_stream = ByteStream_CreateGrowableMemoryStream();
StateWrapper sw(state_stream.get(), StateWrapper::Mode::Write);
const bool state_valid = m_gpu->DoState(sw);
if (!state_valid)
Log_ErrorPrintf("Failed to save old GPU state when switching renderers");
@ -92,7 +85,7 @@ bool System::Boot(const char* filename)
bool exe_boot = false;
if (filename)
{
exe_boot = IsPSExe(filename);
exe_boot = GameList::IsExeFileName(filename);
if (exe_boot)
{
if (m_region == ConsoleRegion::Auto)
@ -107,7 +100,7 @@ bool System::Boot(const char* filename)
media = CDImage::Open(filename);
if (!media)
{
m_host_interface->ReportError(SmallString::FromFormat("Failed to load CD image '%s'", filename));
m_host_interface->ReportFormattedError("Failed to load CD image '%s'", filename);
return false;
}
@ -139,8 +132,7 @@ bool System::Boot(const char* filename)
std::optional<BIOS::Image> bios_image = m_host_interface->GetBIOSImage(m_region);
if (!bios_image)
{
m_host_interface->ReportError(
TinyString::FromFormat("Failed to load %s BIOS", Settings::GetConsoleRegionName(m_region)));
m_host_interface->ReportFormattedError("Failed to load %s BIOS", Settings::GetConsoleRegionName(m_region));
return false;
}
@ -158,7 +150,7 @@ bool System::Boot(const char* filename)
// Load EXE late after BIOS.
if (exe_boot && !LoadEXE(filename, *bios_image))
{
m_host_interface->ReportError(SmallString::FromFormat("Failed to load EXE file '%s'", filename));
m_host_interface->ReportFormattedError("Failed to load EXE file '%s'", filename);
return false;
}
@ -457,11 +449,13 @@ Controller* System::GetController(u32 slot) const
void System::UpdateControllers()
{
const Settings& settings = m_host_interface->GetSettings();
for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++) {
for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++)
{
m_pad->SetController(i, nullptr);
const ControllerType type = settings.controller_types[i];
if (type != ControllerType::None) {
if (type != ControllerType::None)
{
std::unique_ptr<Controller> controller = Controller::Create(type);
if (controller)
m_pad->SetController(i, std::move(controller));

View File

@ -30,9 +30,6 @@ class System
public:
~System();
/// Returns true if the filename is a PlayStation executable we can inject.
static bool IsPSExe(const char* filename);
/// Creates a new System.
static std::unique_ptr<System> Create(HostInterface* host_interface);

View File

@ -1,5 +1,5 @@
#include "timers.h"
#include "YBaseLib/Log.h"
#include "common/log.h"
#include "common/state_wrapper.h"
#include "interrupt_controller.h"
#include "system.h"