Compile fixes for Android

This commit is contained in:
Connor McLaughlin 2019-11-28 01:55:33 +10:00
parent 457743e109
commit f11d357ab9
19 changed files with 187 additions and 107 deletions

View File

@ -29,7 +29,9 @@ endif()
# Required libraries.
find_package(SDL2 REQUIRED)
if(NOT ANDROID)
find_package(SDL2 REQUIRED)
endif()
# Set _DEBUG macro for Debug builds.
@ -72,7 +74,10 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-switch")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-class-memaccess -Wno-invalid-offsetof")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch")
if(NOT ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess -Wno-invalid-offsetof")
endif()
endif()
@ -91,7 +96,7 @@ elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86" OR ${CMAKE_SYSTEM_PROCESSOR} STR
set(CPU_ARCH "x86")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(CPU_ARCH "aarch64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7-a")
set(CPU_ARCH "arm")
else()
message(FATAL_ERROR "Unknown system processor: " ${CMAKE_SYSTEM_PROCESSOR})
@ -107,3 +112,7 @@ find_package(Threads REQUIRED)
enable_testing()
add_subdirectory(dep)
add_subdirectory(src)
if(ANDROID)
add_subdirectory(android/app/src/cpp)
endif()

View File

@ -1,16 +1,20 @@
add_subdirectory(glad)
add_subdirectory(imgui)
add_subdirectory(libcue)
add_subdirectory(nativefiledialog)
add_subdirectory(simpleini)
add_subdirectory(stb)
if(NOT ANDROID)
add_subdirectory(nativefiledialog)
endif()
###################### YBaseLib ############################
set(YBASELIB_SRC_BASE ${CMAKE_SOURCE_DIR}/dep/YBaseLib/Source)
set(YBASELIB_INCLUDES ${CMAKE_SOURCE_DIR}/dep/YBaseLib/Include)
set(YBASELIB_SRC_FILES
${YBASELIB_SRC_BASE}/YBaseLib/Android
${YBASELIB_SRC_BASE}/YBaseLib/Android/AndroidBarrier.cpp
${YBASELIB_SRC_BASE}/YBaseLib/Android/AndroidConditionVariable.cpp
${YBASELIB_SRC_BASE}/YBaseLib/Android/AndroidEvent.cpp
${YBASELIB_SRC_BASE}/YBaseLib/Android/AndroidFileSystem.cpp
@ -86,4 +90,8 @@ set(YBASELIB_SRC_FILES
add_library(YBaseLib STATIC ${YBASELIB_SRC_FILES})
target_include_directories(YBaseLib PRIVATE ${YBASELIB_INCLUDES} ${YBASELIB_SRC_BASE})
target_include_directories(YBaseLib PUBLIC ${YBASELIB_INCLUDES})
target_link_libraries(YBaseLib Threads::Threads)
target_link_libraries(YBaseLib PUBLIC Threads::Threads)
if(ANDROID)
target_link_libraries(YBaseLib PRIVATE log)
endif()

@ -1 +1 @@
Subproject commit 9c5869b61158382ac8d4254961f33b1e9a6d2091
Subproject commit 7004a8b562373915bb56ea73171c4f3b43fafdea

View File

@ -1,3 +1,6 @@
add_subdirectory(common)
add_subdirectory(core)
add_subdirectory(duckstation)
if(NOT ANDROID)
add_subdirectory(duckstation)
endif()

View File

@ -20,7 +20,7 @@ public:
HeapArray(const this_type& copy)
{
m_data = new T[size];
m_data = new T[SIZE];
std::copy(copy.cbegin(), copy.cend(), begin());
}

View File

@ -176,7 +176,7 @@ ALWAYS_INLINE constexpr bool ConvertToBool(TValue value)
// Unsafe integer to boolean
template<typename TValue>
ALWAYS_INLINE constexpr bool ConvertToBoolUnchecked(TValue value)
ALWAYS_INLINE bool ConvertToBoolUnchecked(TValue value)
{
// static_assert(sizeof(uint8) == sizeof(bool));
bool ret;

View File

@ -13,14 +13,6 @@ add_library(core
cpu_core.inl
cpu_disasm.cpp
cpu_disasm.h
cpu_recompiler_code_generator.cpp
cpu_recompiler_code_generator.h
cpu_recompiler_code_generator_generic.cpp
cpu_recompiler_register_cache.cpp
cpu_recompiler_register_cache.h
cpu_recompiler_thunks.cpp
cpu_recompiler_thunks.h
cpu_recompiler_types.h
cpu_types.cpp
cpu_types.h
digital_controller.cpp
@ -66,9 +58,21 @@ add_library(core
types.h
)
set(RECOMPILER_SRCS
cpu_recompiler_code_generator.cpp
cpu_recompiler_code_generator.h
cpu_recompiler_code_generator_generic.cpp
cpu_recompiler_register_cache.cpp
cpu_recompiler_register_cache.h
cpu_recompiler_thunks.cpp
cpu_recompiler_thunks.h
cpu_recompiler_types.h
)
target_include_directories(core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_link_libraries(core PRIVATE Threads::Threads YBaseLib common imgui glad simpleini stb)
target_link_libraries(core PUBLIC Threads::Threads YBaseLib common imgui)
target_link_libraries(core PRIVATE glad simpleini stb)
if(WIN32)
target_sources(core PRIVATE
@ -79,7 +83,10 @@ endif()
if(${CPU_ARCH} STREQUAL "x64")
target_include_directories(core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../dep/xbyak/xbyak")
target_sources(core PRIVATE cpu_recompiler_code_generator_x64.cpp)
target_compile_definitions(core PRIVATE "WITH_RECOMPILER=1")
target_sources(core PRIVATE ${RECOMPILER_SRCS}
cpu_recompiler_code_generator_x64.cpp
)
message("Building x64 recompiler")
else()
message("Not building recompiler")

View File

@ -1,6 +1,7 @@
#pragma once
#include "types.h"
#include <optional>
#include <string>
#include <string_view>
#include <vector>

View File

@ -5,6 +5,7 @@
#include "types.h"
#include <array>
#include <bitset>
#include <vector>
class StateWrapper;

View File

@ -260,7 +260,7 @@
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>ENABLE_VOODOO=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;_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\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -282,7 +282,7 @@
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>ENABLE_VOODOO=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;_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\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -304,7 +304,7 @@
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>ENABLE_VOODOO=1;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;_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\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -329,7 +329,7 @@
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>ENABLE_VOODOO=1;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;_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\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -355,7 +355,7 @@
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>ENABLE_VOODOO=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;_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\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>false</WholeProgramOptimization>
@ -378,7 +378,7 @@
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>ENABLE_VOODOO=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;_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\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>true</WholeProgramOptimization>
@ -402,7 +402,7 @@
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>ENABLE_VOODOO=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;_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\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>false</WholeProgramOptimization>
@ -425,7 +425,7 @@
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>ENABLE_VOODOO=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WITH_RECOMPILER=1;_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\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>true</WholeProgramOptimization>

View File

@ -2,11 +2,14 @@
#include "YBaseLib/Log.h"
#include "cpu_core.h"
#include "cpu_disasm.h"
#include "cpu_recompiler_code_generator.h"
#include "cpu_recompiler_thunks.h"
#include "system.h"
Log_SetChannel(CPU::CodeCache);
#ifdef WITH_RECOMPILER
#include "cpu_recompiler_code_generator.h"
#include "cpu_recompiler_thunks.h"
#endif
namespace CPU {
constexpr bool USE_BLOCK_LINKING = true;
@ -23,11 +26,15 @@ void CodeCache::Initialize(System* system, Core* core, Bus* bus, bool use_recomp
m_system = system;
m_core = core;
m_bus = bus;
m_use_recompiler = use_recompiler;
#ifdef WITH_RECOMPILER
m_use_recompiler = use_recompiler;
m_code_buffer = std::make_unique<JitCodeBuffer>(RECOMPILER_CODE_CACHE_SIZE, RECOMPILER_FAR_CODE_CACHE_SIZE);
m_asm_functions = std::make_unique<Recompiler::ASMFunctions>();
m_asm_functions->Generate(m_code_buffer.get());
#else
m_use_recompiler = false;
#endif
}
void CodeCache::Execute()
@ -120,11 +127,13 @@ void CodeCache::Execute()
void CodeCache::SetUseRecompiler(bool enable)
{
#ifdef WITH_RECOMPILER
if (m_use_recompiler == enable)
return;
m_use_recompiler = enable;
Flush();
#endif
}
void CodeCache::Flush()
@ -134,7 +143,9 @@ void CodeCache::Flush()
it.clear();
m_blocks.clear();
#ifdef WITH_RECOMPILER
m_code_buffer->Reset();
#endif
}
void CodeCache::LogCurrentState()
@ -297,6 +308,7 @@ bool CodeCache::CompileBlock(CodeBlock* block)
return false;
}
#ifdef WITH_RECOMPILER
if (m_use_recompiler)
{
// Ensure we're not going to run out of space while compiling this block.
@ -316,6 +328,7 @@ bool CodeCache::CompileBlock(CodeBlock* block)
return false;
}
}
#endif
return true;
}

View File

@ -18,6 +18,69 @@ namespace Recompiler {
class ASMFunctions;
}
union CodeBlockKey
{
u32 bits;
BitField<u32, bool, 0, 1> user_mode;
BitField<u32, u32, 2, 30> aligned_pc;
ALWAYS_INLINE u32 GetPC() const { return aligned_pc << 2; }
ALWAYS_INLINE void SetPC(u32 pc) { aligned_pc = pc >> 2; }
ALWAYS_INLINE CodeBlockKey& operator=(const CodeBlockKey& rhs)
{
bits = rhs.bits;
return *this;
}
ALWAYS_INLINE bool operator==(const CodeBlockKey& rhs) const { return bits == rhs.bits; }
ALWAYS_INLINE bool operator!=(const CodeBlockKey& rhs) const { return bits != rhs.bits; }
ALWAYS_INLINE bool operator<(const CodeBlockKey& rhs) const { return bits < rhs.bits; }
};
struct CodeBlockInstruction
{
Instruction instruction;
u32 pc;
bool is_branch_instruction : 1;
bool is_branch_delay_slot : 1;
bool is_load_instruction : 1;
bool is_store_instruction : 1;
bool is_load_delay_slot : 1;
bool is_last_instruction : 1;
bool has_load_delay : 1;
bool can_trap : 1;
};
struct CodeBlock
{
using HostCodePointer = void (*)(Core*);
CodeBlock(const CodeBlockKey key_) : key(key_) {}
CodeBlockKey key;
u32 host_code_size = 0;
HostCodePointer host_code = nullptr;
std::vector<CodeBlockInstruction> instructions;
std::vector<CodeBlock*> link_predecessors;
std::vector<CodeBlock*> link_successors;
bool invalidated = false;
const u32 GetPC() const { return key.GetPC(); }
const u32 GetSizeInBytes() const { return static_cast<u32>(instructions.size()) * sizeof(Instruction); }
const u32 GetStartPageIndex() const { return (key.GetPC() / CPU_CODE_CACHE_PAGE_SIZE); }
const u32 GetEndPageIndex() const { return ((key.GetPC() + GetSizeInBytes()) / CPU_CODE_CACHE_PAGE_SIZE); }
bool IsInRAM() const
{
// TODO: Constant
return key.GetPC() < 0x200000;
}
};
class CodeCache
{
public:
@ -69,8 +132,10 @@ private:
Core* m_core;
Bus* m_bus;
#ifdef WITH_RECOMPILER
std::unique_ptr<JitCodeBuffer> m_code_buffer;
std::unique_ptr<Recompiler::ASMFunctions> m_asm_functions;
#endif
BlockMap m_blocks;

View File

@ -5,6 +5,7 @@
#include "common/jit_code_buffer.h"
#include "cpu_code_cache.h"
#include "cpu_recompiler_register_cache.h"
#include "cpu_recompiler_thunks.h"
#include "cpu_recompiler_types.h"

View File

@ -46,6 +46,7 @@ enum class Condition : u8
};
#if defined(Y_CPU_X64)
using HostReg = Xbyak::Operand::Code;
using CodeEmitter = Xbyak::CodeGenerator;
enum : u32
@ -63,15 +64,22 @@ constexpr u32 MAX_FAR_HOST_BYTES_PER_INSTRUCTION = 128;
constexpr bool SHIFTS_ARE_IMPLICITLY_MASKED = true;
#else
using HostReg = void;
using CodeEmitter = void;
using HostReg = int;
class CodeEmitter
{
};
enum : u32
{
HostReg_Count = 0
HostReg_Count = 1
};
constexpr HostReg HostReg_Invalid = static_cast<HostReg>(HostReg_Count);
constexpr OperandSize HostPointerSize = OperandSize_64;
constexpr RegSize HostPointerSize = RegSize_64;
constexpr bool SHIFTS_ARE_IMPLICITLY_MASKED = false;
#endif
} // namespace Recompiler

View File

@ -380,67 +380,4 @@ struct Cop0Registers
} dcic;
};
union CodeBlockKey
{
u32 bits;
BitField<u32, bool, 0, 1> user_mode;
BitField<u32, u32, 2, 30> aligned_pc;
ALWAYS_INLINE u32 GetPC() const { return aligned_pc << 2; }
ALWAYS_INLINE void SetPC(u32 pc) { aligned_pc = pc >> 2; }
ALWAYS_INLINE CodeBlockKey& operator=(const CodeBlockKey& rhs)
{
bits = rhs.bits;
return *this;
}
ALWAYS_INLINE bool operator==(const CodeBlockKey& rhs) const { return bits == rhs.bits; }
ALWAYS_INLINE bool operator!=(const CodeBlockKey& rhs) const { return bits != rhs.bits; }
ALWAYS_INLINE bool operator<(const CodeBlockKey& rhs) const { return bits < rhs.bits; }
};
struct CodeBlockInstruction
{
Instruction instruction;
u32 pc;
bool is_branch_instruction : 1;
bool is_branch_delay_slot : 1;
bool is_load_instruction : 1;
bool is_store_instruction : 1;
bool is_load_delay_slot : 1;
bool is_last_instruction : 1;
bool has_load_delay : 1;
bool can_trap : 1;
};
struct CodeBlock
{
using HostCodePointer = void (*)(Core*);
CodeBlock(const CodeBlockKey key_) : key(key_) {}
CodeBlockKey key;
u32 host_code_size = 0;
HostCodePointer host_code = nullptr;
std::vector<CodeBlockInstruction> instructions;
std::vector<CodeBlock*> link_predecessors;
std::vector<CodeBlock*> link_successors;
bool invalidated = false;
const u32 GetPC() const { return key.GetPC(); }
const u32 GetSizeInBytes() const { return static_cast<u32>(instructions.size()) * sizeof(Instruction); }
const u32 GetStartPageIndex() const { return (key.GetPC() / CPU_CODE_CACHE_PAGE_SIZE); }
const u32 GetEndPageIndex() const { return ((key.GetPC() + GetSizeInBytes()) / CPU_CODE_CACHE_PAGE_SIZE); }
bool IsInRAM() const
{
// TODO: Constant
return key.GetPC() < 0x200000;
}
};
} // namespace CPU

View File

@ -2,6 +2,7 @@
#include "common/bitfield.h"
#include "types.h"
#include <array>
#include <vector>
class StateWrapper;

View File

@ -15,6 +15,33 @@ Log_SetChannel(HostInterface);
#include <time.h>
#endif
#ifdef ANDROID
#include <cstring>
static std::string GetRelativePath(const std::string& path, const char* new_filename)
{
const char* last = std::strrchr(path.c_str(), '/');
if (!last)
return new_filename;
std::string new_path(path.c_str(), last - path.c_str() + 1);
new_path += new_filename;
return new_path;
}
#else
#include <filesystem>
static std::string GetRelativePath(const std::string& path, const char* new_filename)
{
return std::filesystem::path(path).replace_filename(new_filename).string();
}
#endif
HostInterface::HostInterface()
{
m_settings.SetDefaults();
@ -83,8 +110,6 @@ std::optional<std::vector<u8>> HostInterface::GetBIOSImage(ConsoleRegion region)
} \
} while (0)
#define RELATIVE_PATH(filename) std::filesystem::path(m_settings.bios_path).replace_filename(filename).string()
// Try the configured image.
TRY_FILENAME(m_settings.bios_path);
@ -92,18 +117,18 @@ std::optional<std::vector<u8>> HostInterface::GetBIOSImage(ConsoleRegion region)
switch (region)
{
case ConsoleRegion::NTSC_J:
TRY_FILENAME(RELATIVE_PATH("scph1000.bin"));
TRY_FILENAME(RELATIVE_PATH("scph5500.bin"));
TRY_FILENAME(GetRelativePath(m_settings.bios_path, "scph1000.bin"));
TRY_FILENAME(GetRelativePath(m_settings.bios_path, "scph5500.bin"));
break;
case ConsoleRegion::NTSC_U:
TRY_FILENAME(RELATIVE_PATH("scph1001.bin"));
TRY_FILENAME(RELATIVE_PATH("scph5501.bin"));
TRY_FILENAME(GetRelativePath(m_settings.bios_path, "scph1001.bin"));
TRY_FILENAME(GetRelativePath(m_settings.bios_path, "scph5501.bin"));
break;
case ConsoleRegion::PAL:
TRY_FILENAME(RELATIVE_PATH("scph1002.bin"));
TRY_FILENAME(RELATIVE_PATH("scph5502.bin"));
TRY_FILENAME(GetRelativePath(m_settings.bios_path, "scph1002.bin"));
TRY_FILENAME(GetRelativePath(m_settings.bios_path, "scph5502.bin"));
break;
default:

View File

@ -1,6 +1,7 @@
#pragma once
#include "types.h"
#include <optional>
#include <string>
struct Settings
{

View File

@ -1054,7 +1054,7 @@ void SPU::DrawDebugStateWindow()
ImGui::SameLine(offsets[2]);
ImGui::TextColored(m_SPUCNT.external_audio_enable ? active_color : inactive_color, "External Audio");
ImGui::SameLine(offsets[3]);
ImGui::TextColored(m_SPUCNT.ram_transfer_mode != RAMTransferMode::Stopped ? active_color : inactive_color,
ImGui::TextColored(m_SPUCNT.ram_transfer_mode != RAMTransferMode::Stopped ? active_color : inactive_color, "%s",
transfer_modes[static_cast<u8>(m_SPUCNT.ram_transfer_mode.GetValue())]);
ImGui::Text("Status: ");
@ -1138,7 +1138,7 @@ void SPU::DrawDebugStateWindow()
ImGui::NextColumn();
ImGui::TextColored(color, "%08X", v.regs.adsr.bits);
ImGui::NextColumn();
ImGui::TextColored(color, adsr_phases[static_cast<u8>(v.adsr_phase)]);
ImGui::TextColored(color, "%s", adsr_phases[static_cast<u8>(v.adsr_phase)]);
ImGui::NextColumn();
ImGui::TextColored(color, "%d", ZeroExtend32(v.regs.adsr_volume));
ImGui::NextColumn();