Large diffs are not rendered by default.

@@ -53,7 +53,8 @@ void cInterfaceEGL::DetectMode()
EGLint num_configs;
bool supportsGL = false, supportsGLES2 = false, supportsGLES3 = false;
std::array<int, 3> renderable_types{{
EGL_OPENGL_BIT, (1 << 6), /* EGL_OPENGL_ES3_BIT_KHR */
EGL_OPENGL_BIT,
(1 << 6), /* EGL_OPENGL_ES3_BIT_KHR */
EGL_OPENGL_ES2_BIT,
}};

@@ -237,7 +238,13 @@ bool cInterfaceEGL::Create(void* window_handle, bool stereo, bool core)
if (supports_core_profile && core && s_opengl_mode == GLInterfaceMode::MODE_OPENGL)
{
std::array<std::pair<int, int>, 7> versions_to_try = {{
{4, 5}, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {4, 0}, {3, 3},
{4, 5},
{4, 4},
{4, 3},
{4, 2},
{4, 1},
{4, 0},
{3, 3},
}};

for (const auto& version : versions_to_try)
@@ -35,6 +35,7 @@ class cInterfaceEGL : public cInterfaceBase
return (EGLNativeWindowType)EGL_DEFAULT_DISPLAY;
}
virtual void ShutdownPlatform() {}

public:
void Swap() override;
void SwapInterval(int interval) override;
@@ -230,17 +230,26 @@ bool cInterfaceWGL::Create(void* window_handle, bool stereo, bool core)
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0,
0, 0, 0, 0, 0, // Color Bits Ignored
0, // 8bit Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
0,
0,
0,
0,
0, // Color Bits Ignored
0, // 8bit Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0,
0,
0,
0, // Accumulation Bits Ignored
0, // 0Bit Z-Buffer (Depth Buffer)
0, // 0bit Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
0,
0,
0 // Layer Masks Ignored
};

m_dc = GetDC(m_window_handle);
@@ -358,22 +367,22 @@ HGLRC cInterfaceWGL::CreateCoreContext(HDC dc, HGLRC share_context)
for (const auto& version : try_versions)
{
// Construct list of attributes. Prefer a forward-compatible, core context.
std::array<int, 5 * 2> attribs = {
WGL_CONTEXT_PROFILE_MASK_ARB,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
std::array<int, 5 * 2> attribs = {WGL_CONTEXT_PROFILE_MASK_ARB,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
#ifdef _DEBUG
WGL_CONTEXT_FLAGS_ARB,
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB | WGL_CONTEXT_DEBUG_BIT_ARB,
WGL_CONTEXT_FLAGS_ARB,
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB |
WGL_CONTEXT_DEBUG_BIT_ARB,
#else
WGL_CONTEXT_FLAGS_ARB,
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
WGL_CONTEXT_FLAGS_ARB,
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
#endif
WGL_CONTEXT_MAJOR_VERSION_ARB,
version.first,
WGL_CONTEXT_MINOR_VERSION_ARB,
version.second,
0,
0};
WGL_CONTEXT_MAJOR_VERSION_ARB,
version.first,
WGL_CONTEXT_MINOR_VERSION_ARB,
version.second,
0,
0};

// Attempt creating this context.
HGLRC core_context = wglCreateContextAttribsARB(dc, nullptr, attribs.data());
@@ -967,7 +967,7 @@ void GekkoDisassembler::mtfsb(u32 in, int n)
}
}

// Paired instructions
// Paired instructions

#define RA ((inst >> 16) & 0x1f)
#define RB ((inst >> 11) & 0x1f)
@@ -76,6 +76,7 @@ class IniFile
const std::string& GetName() const { return name; }
const SectionMap& GetValues() const { return values; }
bool HasLines() const { return !m_lines.empty(); }

protected:
std::string name;

@@ -142,6 +143,7 @@ class IniFile
static void ParseLine(const std::string& line, std::string* keyOut, std::string* valueOut);

const std::list<Section>& GetSections() const { return sections; }

private:
std::list<Section> sections;

@@ -25,7 +25,7 @@
* When building with -march=native, or enabling the instruction sets in the compile flags, permit
* usage of the instrinsics without any function attributes. If the command-line architecture does
* not support this instruction set, enable it via function targeting.
*/
*/

#include <x86intrin.h>
#ifndef __SSE4_2__
@@ -35,6 +35,7 @@ class Lazy
const T* operator->() const { return ComputeValue(); }
T& operator*() { return *ComputeValue(); }
T* operator->() { return ComputeValue(); }

private:
T* ComputeValue() const
{
@@ -48,6 +48,7 @@ class FileLogListener : public LogListener
bool IsValid() const { return m_logfile.good(); }
bool IsEnabled() const { return m_enable; }
void SetEnable(bool enable) { m_enable = enable; }

private:
std::mutex m_log_lock;
std::ofstream m_logfile;
@@ -51,6 +51,7 @@ class ProfilerExecuter
public:
ProfilerExecuter(Profiler* _p) : m_p(_p) { m_p->Start(); }
~ProfilerExecuter() { m_p->Stop(); }

private:
Profiler* m_p;
};
@@ -27,6 +27,7 @@ class QoSSession
QoSSession& operator=(QoSSession&& session);
QoSSession(QoSSession&& session) { *this = std::move(session); }
bool Successful() const { return m_success; }

private:
#if defined(_WIN32)
void* m_qos_handle = nullptr;
@@ -24,6 +24,7 @@ class Result final
const T* operator->() const { return &std::get<T>(m_variant); }
T& operator*() { return std::get<T>(m_variant); }
T* operator->() { return &std::get<T>(m_variant); }

private:
std::variant<ResultCode, T> m_variant;
};
@@ -233,17 +233,17 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename)
}

/* Here's the layout:
*
* boot_sector
* fsinfo_sector
* empty
* backup boot sector
* backup fsinfo sector
* RESERVED_SECTORS - 4 empty sectors (if backup sectors), or RESERVED_SECTORS - 2 (if no backup)
* first fat
* second fat
* zero sectors
*/
*
* boot_sector
* fsinfo_sector
* empty
* backup boot sector
* backup fsinfo sector
* RESERVED_SECTORS - 4 empty sectors (if backup sectors), or RESERVED_SECTORS - 2 (if no backup)
* first fat
* second fat
* zero sectors
*/

if (write_sector(f, s_boot_sector))
goto FailWrite;
@@ -24,6 +24,7 @@ class Semaphore
~Semaphore() { CloseHandle(m_handle); }
void Wait() { WaitForSingleObject(m_handle, INFINITE); }
void Post() { ReleaseSemaphore(m_handle, 1, nullptr); }

private:
HANDLE m_handle;
};
@@ -42,6 +43,7 @@ class Semaphore
~Semaphore() { sem_destroy(&m_handle); }
void Wait() { sem_wait(&m_handle); }
void Post() { sem_post(&m_handle); }

private:
sem_t m_handle;
};
@@ -307,7 +307,7 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _
#ifdef _WIN32
":"
#endif
);
);
if (std::string::npos == dir_end)
dir_end = 0;
else
@@ -248,7 +248,7 @@ void OpArg::WriteRest(XEmitter* emit, int extraBytes, X64Reg _operandReg,
bool warn_64bit_offset) const
{
if (_operandReg == INVALID_REG)
_operandReg = (X64Reg) this->operandReg;
_operandReg = (X64Reg)this->operandReg;
int mod = 0;
int ireg = indexReg;
bool SIB = false;
@@ -28,6 +28,7 @@ class DolReader final : public BootExecutableReader
u32 GetEntryPoint() const override { return m_dolheader.entryPoint; }
bool LoadIntoMemory(bool only_in_mem1 = false) const override;
bool LoadSymbols() const override { return false; }

private:
enum
{
@@ -63,6 +63,7 @@ class ElfReader final : public BootExecutableReader
SectionID GetSectionByName(const char* name, int firstSection = 0) const; //-1 for not found

bool DidRelocate() const { return bRelocate; }

private:
void Initialize(u8* bytes);

@@ -23,57 +23,89 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
const static std::vector<Config::ConfigLocation> s_setting_saveable{
// Graphics.Hardware

Config::GFX_VSYNC.location, Config::GFX_ADAPTER.location,
Config::GFX_VSYNC.location,
Config::GFX_ADAPTER.location,

// Graphics.Settings

Config::GFX_WIDESCREEN_HACK.location, Config::GFX_ASPECT_RATIO.location,
Config::GFX_CROP.location, Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location,
Config::GFX_SHOW_FPS.location, Config::GFX_SHOW_NETPLAY_PING.location,
Config::GFX_SHOW_NETPLAY_MESSAGES.location, Config::GFX_LOG_RENDER_TIME_TO_FILE.location,
Config::GFX_OVERLAY_STATS.location, Config::GFX_OVERLAY_PROJ_STATS.location,
Config::GFX_DUMP_TEXTURES.location, Config::GFX_HIRES_TEXTURES.location,
Config::GFX_CACHE_HIRES_TEXTURES.location, Config::GFX_DUMP_EFB_TARGET.location,
Config::GFX_DUMP_FRAMES_AS_IMAGES.location, Config::GFX_FREE_LOOK.location,
Config::GFX_USE_FFV1.location, Config::GFX_DUMP_FORMAT.location,
Config::GFX_DUMP_CODEC.location, Config::GFX_DUMP_ENCODER.location,
Config::GFX_DUMP_PATH.location, Config::GFX_BITRATE_KBPS.location,
Config::GFX_WIDESCREEN_HACK.location,
Config::GFX_ASPECT_RATIO.location,
Config::GFX_CROP.location,
Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location,
Config::GFX_SHOW_FPS.location,
Config::GFX_SHOW_NETPLAY_PING.location,
Config::GFX_SHOW_NETPLAY_MESSAGES.location,
Config::GFX_LOG_RENDER_TIME_TO_FILE.location,
Config::GFX_OVERLAY_STATS.location,
Config::GFX_OVERLAY_PROJ_STATS.location,
Config::GFX_DUMP_TEXTURES.location,
Config::GFX_HIRES_TEXTURES.location,
Config::GFX_CACHE_HIRES_TEXTURES.location,
Config::GFX_DUMP_EFB_TARGET.location,
Config::GFX_DUMP_FRAMES_AS_IMAGES.location,
Config::GFX_FREE_LOOK.location,
Config::GFX_USE_FFV1.location,
Config::GFX_DUMP_FORMAT.location,
Config::GFX_DUMP_CODEC.location,
Config::GFX_DUMP_ENCODER.location,
Config::GFX_DUMP_PATH.location,
Config::GFX_BITRATE_KBPS.location,
Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS.location,
Config::GFX_ENABLE_GPU_TEXTURE_DECODING.location, Config::GFX_ENABLE_PIXEL_LIGHTING.location,
Config::GFX_FAST_DEPTH_CALC.location, Config::GFX_MSAA.location, Config::GFX_SSAA.location,
Config::GFX_EFB_SCALE.location, Config::GFX_TEXFMT_OVERLAY_ENABLE.location,
Config::GFX_TEXFMT_OVERLAY_CENTER.location, Config::GFX_ENABLE_WIREFRAME.location,
Config::GFX_DISABLE_FOG.location, Config::GFX_BORDERLESS_FULLSCREEN.location,
Config::GFX_ENABLE_VALIDATION_LAYER.location, Config::GFX_BACKEND_MULTITHREADING.location,
Config::GFX_COMMAND_BUFFER_EXECUTE_INTERVAL.location, Config::GFX_SHADER_CACHE.location,
Config::GFX_ENABLE_GPU_TEXTURE_DECODING.location,
Config::GFX_ENABLE_PIXEL_LIGHTING.location,
Config::GFX_FAST_DEPTH_CALC.location,
Config::GFX_MSAA.location,
Config::GFX_SSAA.location,
Config::GFX_EFB_SCALE.location,
Config::GFX_TEXFMT_OVERLAY_ENABLE.location,
Config::GFX_TEXFMT_OVERLAY_CENTER.location,
Config::GFX_ENABLE_WIREFRAME.location,
Config::GFX_DISABLE_FOG.location,
Config::GFX_BORDERLESS_FULLSCREEN.location,
Config::GFX_ENABLE_VALIDATION_LAYER.location,
Config::GFX_BACKEND_MULTITHREADING.location,
Config::GFX_COMMAND_BUFFER_EXECUTE_INTERVAL.location,
Config::GFX_SHADER_CACHE.location,
Config::GFX_WAIT_FOR_SHADERS_BEFORE_STARTING.location,
Config::GFX_SHADER_COMPILATION_MODE.location, Config::GFX_SHADER_COMPILER_THREADS.location,
Config::GFX_SHADER_COMPILATION_MODE.location,
Config::GFX_SHADER_COMPILER_THREADS.location,
Config::GFX_SHADER_PRECOMPILER_THREADS.location,

Config::GFX_SW_ZCOMPLOC.location, Config::GFX_SW_ZFREEZE.location,
Config::GFX_SW_DUMP_OBJECTS.location, Config::GFX_SW_DUMP_TEV_STAGES.location,
Config::GFX_SW_DUMP_TEV_TEX_FETCHES.location, Config::GFX_SW_DRAW_START.location,
Config::GFX_SW_ZCOMPLOC.location,
Config::GFX_SW_ZFREEZE.location,
Config::GFX_SW_DUMP_OBJECTS.location,
Config::GFX_SW_DUMP_TEV_STAGES.location,
Config::GFX_SW_DUMP_TEV_TEX_FETCHES.location,
Config::GFX_SW_DRAW_START.location,
Config::GFX_SW_DRAW_END.location,

// Graphics.Enhancements

Config::GFX_ENHANCE_FORCE_FILTERING.location, Config::GFX_ENHANCE_MAX_ANISOTROPY.location,
Config::GFX_ENHANCE_POST_SHADER.location, Config::GFX_ENHANCE_FORCE_TRUE_COLOR.location,
Config::GFX_ENHANCE_FORCE_FILTERING.location,
Config::GFX_ENHANCE_MAX_ANISOTROPY.location,
Config::GFX_ENHANCE_POST_SHADER.location,
Config::GFX_ENHANCE_FORCE_TRUE_COLOR.location,

// Graphics.Stereoscopy

Config::GFX_STEREO_MODE.location, Config::GFX_STEREO_DEPTH.location,
Config::GFX_STEREO_CONVERGENCE_PERCENTAGE.location, Config::GFX_STEREO_SWAP_EYES.location,
Config::GFX_STEREO_CONVERGENCE.location, Config::GFX_STEREO_EFB_MONO_DEPTH.location,
Config::GFX_STEREO_MODE.location,
Config::GFX_STEREO_DEPTH.location,
Config::GFX_STEREO_CONVERGENCE_PERCENTAGE.location,
Config::GFX_STEREO_SWAP_EYES.location,
Config::GFX_STEREO_CONVERGENCE.location,
Config::GFX_STEREO_EFB_MONO_DEPTH.location,
Config::GFX_STEREO_DEPTH_PERCENTAGE.location,

// Graphics.Hacks

Config::GFX_HACK_EFB_ACCESS_ENABLE.location, Config::GFX_HACK_BBOX_ENABLE.location,
Config::GFX_HACK_EFB_ACCESS_ENABLE.location,
Config::GFX_HACK_BBOX_ENABLE.location,
Config::GFX_HACK_BBOX_PREFER_STENCIL_IMPLEMENTATION.location,
Config::GFX_HACK_FORCE_PROGRESSIVE.location, Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM.location,
Config::GFX_HACK_FORCE_PROGRESSIVE.location,
Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM.location,
Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM.location,
Config::GFX_HACK_DISABLE_COPY_TO_VRAM.location, Config::GFX_HACK_IMMEDIATE_XFB.location,
Config::GFX_HACK_DISABLE_COPY_TO_VRAM.location,
Config::GFX_HACK_IMMEDIATE_XFB.location,
Config::GFX_HACK_COPY_EFB_SCALED.location,
Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES.location,
Config::GFX_HACK_VERTEX_ROUDING.location,
@@ -260,8 +260,9 @@ void ScheduleEvent(s64 cycles_into_future, EventType* event_type, u64 userdata,
{
if (Core::WantsDeterminism())
{
ERROR_LOG(POWERPC, "Someone scheduled an off-thread \"%s\" event while netplay or "
"movie play/record was active. This is likely to cause a desync.",
ERROR_LOG(POWERPC,
"Someone scheduled an off-thread \"%s\" event while netplay or "
"movie play/record was active. This is likely to cause a desync.",
event_type->name->c_str());
}

@@ -524,8 +524,9 @@ bool DSPAssembler::VerifyParams(const DSPOPCTemplate* opc, param_t* par, size_t
if (par[i].val >= 0x1e && par[i].val <= 0x1f)
{
fprintf(stderr, "%i : %s ", code_line, cur_line.c_str());
fprintf(stderr, "WARNING: $ACM%d register used instead of $ACC%d register Line: %d "
"Param: %zu Ext: %d\n",
fprintf(stderr,
"WARNING: $ACM%d register used instead of $ACC%d register Line: %d "
"Param: %zu Ext: %d\n",
(par[i].val & 1), (par[i].val & 1), code_line, current_param,
static_cast<int>(type));
}
@@ -63,6 +63,7 @@ class DSPAssembler

std::string GetErrorString() const { return last_error_str; }
AssemblerError GetError() const { return last_error; }

private:
struct param_t
{
@@ -43,6 +43,7 @@ class DSPBreakpoints

void Clear() { memset(b, 0, sizeof(b)); }
void DeleteByAddress(u32 addr) { b[addr] = 0; }

private:
u8 b[65536];
};
@@ -139,8 +139,9 @@ static Installation InstallCodeHandlerLocked()
// If the code is not going to fit in the space we have left then we have to skip it
if (next_address + active_code.codes.size() * CODE_SIZE > end_address)
{
NOTICE_LOG(ACTIONREPLAY, "Too many GeckoCodes! Ran out of storage space in Game RAM. Could "
"not write: \"%s\". Need %zu bytes, only %u remain.",
NOTICE_LOG(ACTIONREPLAY,
"Too many GeckoCodes! Ran out of storage space in Game RAM. Could "
"not write: \"%s\". Need %zu bytes, only %u remain.",
active_code.name.c_str(), active_code.codes.size() * CODE_SIZE,
end_address - next_address);
continue;
@@ -238,8 +239,9 @@ void RunCodeHandler()
PowerPC::HostWrite_U64(riPS0(i), SP + 24 + 2 * i * sizeof(u64));
PowerPC::HostWrite_U64(riPS1(i), SP + 24 + (2 * i + 1) * sizeof(u64));
}
DEBUG_LOG(ACTIONREPLAY, "GeckoCodes: Initiating phantom branch-and-link. "
"PC = 0x%08X, SP = 0x%08X, SFP = 0x%08X",
DEBUG_LOG(ACTIONREPLAY,
"GeckoCodes: Initiating phantom branch-and-link. "
"PC = 0x%08X, SP = 0x%08X, SFP = 0x%08X",
PC, SP, SFP);
LR = HLE_TRAMPOLINE_ADDRESS;
PC = NPC = ENTRY_POINT;
@@ -117,8 +117,8 @@ void AXUCode::HandleCommandList()

switch (cmd)
{
// Some of these commands are unknown, or unused in this AX HLE.
// We still need to skip their arguments using "curr_idx += N".
// Some of these commands are unknown, or unused in this AX HLE.
// We still need to skip their arguments using "curr_idx += N".

case CMD_SETUP:
addr_hi = m_cmdlist[curr_idx++];
@@ -460,8 +460,8 @@ void ProcessVoice(PB_TYPE& pb, const AXBuffers& buffers, u16 count, AXMixControl
pb.lpf.yn1 = LowPassFilter(samples, count, pb.lpf.yn1, pb.lpf.a0, pb.lpf.b0);
}

// Mix LRS, AUXA and AUXB depending on mixer_control
// TODO: Handle DPL2 on AUXB.
// Mix LRS, AUXA and AUXB depending on mixer_control
// TODO: Handle DPL2 on AUXB.

#define MIX_ON(C) (0 != (mctrl & MIX_##C))
#define RAMP_ON(C) (0 != (mctrl & MIX_##C##_RAMP))
@@ -59,8 +59,8 @@ void AXWiiUCode::HandleCommandList()
{
switch (cmd)
{
// Some of these commands are unknown, or unused in this AX HLE.
// We still need to skip their arguments using "curr_idx += N".
// Some of these commands are unknown, or unused in this AX HLE.
// We still need to skip their arguments using "curr_idx += N".

case CMD_SETUP_OLD:
addr_hi = m_cmdlist[curr_idx++];
@@ -156,8 +156,8 @@ void AXWiiUCode::HandleCommandList()
{
switch (cmd)
{
// Some of these commands are unknown, or unused in this AX HLE.
// We still need to skip their arguments using "curr_idx += N".
// Some of these commands are unknown, or unused in this AX HLE.
// We still need to skip their arguments using "curr_idx += N".

case CMD_SETUP:
addr_hi = m_cmdlist[curr_idx++];
@@ -66,8 +66,9 @@ void ProcessGBACrypto(u32 address)
HLEMemory_Write_U32(dest_addr + 4, t3);

// Done!
DEBUG_LOG(DSPHLE, "\n%08x -> challenge: %08x, len: %08x, dest_addr: %08x, "
"palette: %08x, speed: %08x key: %08x, auth_code: %08x",
DEBUG_LOG(DSPHLE,
"\n%08x -> challenge: %08x, len: %08x, dest_addr: %08x, "
"palette: %08x, speed: %08x key: %08x, auth_code: %08x",
address, challenge, length, dest_addr, logo_palette, logo_speed_32, key, t3);
}

@@ -51,6 +51,7 @@ class UCodeInterface

virtual void DoState(PointerWrap& p) { DoStateShared(p); }
static u32 GetCRC(UCodeInterface* ucode) { return ucode ? ucode->m_crc : UCODE_NULL; }

protected:
void PrepareBootUCode(u32 mail);

@@ -1035,10 +1035,15 @@ void ZeldaAudioRenderer::ApplyReverb(bool post_rendering)

// Each of the 4 RPBs maps to one of these buffers.
MixingBuffer* reverb_buffers[4] = {
&m_buf_unk0_reverb, &m_buf_unk1_reverb, &m_buf_front_left_reverb, &m_buf_front_right_reverb,
&m_buf_unk0_reverb,
&m_buf_unk1_reverb,
&m_buf_front_left_reverb,
&m_buf_front_right_reverb,
};
std::array<s16, 8>* last8_samples_buffers[4] = {
&m_buf_unk0_reverb_last8, &m_buf_unk1_reverb_last8, &m_buf_front_left_reverb_last8,
&m_buf_unk0_reverb_last8,
&m_buf_unk1_reverb_last8,
&m_buf_front_left_reverb_last8,
&m_buf_front_right_reverb_last8,
};

@@ -318,8 +318,9 @@ static u32 AdvanceDTK(u32 maximum_samples, u32* samples_to_process)
{
if (s_audio_position >= s_current_start + s_current_length)
{
DEBUG_LOG(DVDINTERFACE, "AdvanceDTK: NextStart=%08" PRIx64 ", NextLength=%08x, "
"CurrentStart=%08" PRIx64 ", CurrentLength=%08x, AudioPos=%08" PRIx64,
DEBUG_LOG(DVDINTERFACE,
"AdvanceDTK: NextStart=%08" PRIx64 ", NextLength=%08x, "
"CurrentStart=%08" PRIx64 ", CurrentLength=%08x, AudioPos=%08" PRIx64,
s_next_start, s_next_length, s_current_start, s_current_length, s_audio_position);

s_audio_position = s_next_start;
@@ -825,8 +826,9 @@ void ExecuteCommand(u32 command_0, u32 command_1, u32 command_2, u32 output_addr
{
u64 iDVDOffset = (u64)command_1 << 2;

INFO_LOG(DVDINTERFACE, "Read: DVDOffset=%08" PRIx64
", DMABuffer = %08x, SrcLength = %08x, DMALength = %08x",
INFO_LOG(DVDINTERFACE,
"Read: DVDOffset=%08" PRIx64
", DMABuffer = %08x, SrcLength = %08x, DMALength = %08x",
iDVDOffset, output_address, command_2, output_length);

command_handled_by_thread =
@@ -948,9 +950,10 @@ void ExecuteCommand(u32 command_0, u32 command_1, u32 command_2, u32 output_addr
switch (command_0 >> 16 & 0xFF)
{
case 0x00: // Returns streaming status
INFO_LOG(DVDINTERFACE, "(Audio): Stream Status: Request Audio status "
"AudioPos:%08" PRIx64 "/%08" PRIx64 " "
"CurrentStart:%08" PRIx64 " CurrentLength:%08x",
INFO_LOG(DVDINTERFACE,
"(Audio): Stream Status: Request Audio status "
"AudioPos:%08" PRIx64 "/%08" PRIx64 " "
"CurrentStart:%08" PRIx64 " CurrentLength:%08x",
s_audio_position, s_current_start + s_current_length, s_current_start,
s_current_length);
WriteImmediate(s_stream ? 1 : 0, output_address, reply_to_ios);
@@ -1295,8 +1298,9 @@ void ScheduleReads(u64 offset, u32 length, const DiscIO::Partition& partition, u
s_read_buffer_end_offset - s_read_buffer_start_offset, wii_disc));
}

DEBUG_LOG(DVDINTERFACE, "Schedule reads: ECC blocks unbuffered=%d, buffered=%d, "
"ticks=%" PRId64 ", time=%" PRId64 " us",
DEBUG_LOG(DVDINTERFACE,
"Schedule reads: ECC blocks unbuffered=%d, buffered=%d, "
"ticks=%" PRId64 ", time=%" PRId64 " us",
unbuffered_blocks, buffered_blocks, ticks_until_completion,
ticks_until_completion * 1000000 / SystemTimers::GetTicksPerSecond());
}
@@ -311,9 +311,10 @@ static void FinishRead(u64 id, s64 cycles_late)
const ReadRequest& request = result.first;
const std::vector<u8>& buffer = result.second;

DEBUG_LOG(DVDINTERFACE, "Disc has been read. Real time: %" PRIu64 " us. "
"Real time including delay: %" PRIu64 " us. "
"Emulated time including delay: %" PRIu64 " us.",
DEBUG_LOG(DVDINTERFACE,
"Disc has been read. Real time: %" PRIu64 " us. "
"Real time including delay: %" PRIu64 " us. "
"Emulated time including delay: %" PRIu64 " us.",
request.realtime_done_us - request.realtime_started_us,
Common::Timer::GetTimeUs() - request.realtime_started_us,
(CoreTiming::GetTicks() - request.time_started_ticks) /
@@ -81,6 +81,7 @@ class MemoryCardBase
virtual void DoState(PointerWrap& p) = 0;
u32 GetCardId() const { return m_nintendo_card_id; }
bool IsAddressInBounds(u32 address) const { return address <= (m_memory_card_size - 1); }

protected:
int m_card_index;
u16 m_nintendo_card_id;
@@ -27,7 +27,8 @@ static const u16 button_bitmasks[] = {
};

static const u16 trigger_bitmasks[] = {
PAD_TRIGGER_L, PAD_TRIGGER_R,
PAD_TRIGGER_L,
PAD_TRIGGER_R,
};

static const u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT,
@@ -148,17 +148,19 @@ class ComplexHandlingMethod : public ReadHandlingMethod<T>, public WriteHandling
std::function<T(u32)> InvalidReadLambda() const
{
return [](u32) {
DEBUG_ASSERT_MSG(MEMMAP, 0, "Called the read lambda on a write "
"complex handler.");
DEBUG_ASSERT_MSG(MEMMAP, 0,
"Called the read lambda on a write "
"complex handler.");
return 0;
};
}

std::function<void(u32, T)> InvalidWriteLambda() const
{
return [](u32, T) {
DEBUG_ASSERT_MSG(MEMMAP, 0, "Called the write lambda on a read "
"complex handler.");
DEBUG_ASSERT_MSG(MEMMAP, 0,
"Called the write lambda on a read "
"complex handler.");
};
}

@@ -62,9 +62,10 @@ inline bool IsMMIOAddress(u32 address)
// The block ID can easily be computed by simply checking bit 24 (CC vs. CD).
inline u32 UniqueID(u32 address)
{
DEBUG_ASSERT_MSG(MEMMAP, ((address & 0xFFFF0000) == 0x0C000000) ||
((address & 0xFFFF0000) == 0x0D000000) ||
((address & 0xFFFF0000) == 0x0D800000),
DEBUG_ASSERT_MSG(MEMMAP,
((address & 0xFFFF0000) == 0x0C000000) ||
((address & 0xFFFF0000) == 0x0D000000) ||
((address & 0xFFFF0000) == 0x0D800000),
"Trying to get the ID of a non-existing MMIO address.");

return (((address >> 24) & 1) << 16) | (address & 0xFFFF);
@@ -61,7 +61,8 @@ static UVIBorderBlankRegister m_BorderHBlank;
static u32 s_target_refresh_rate = 0;

static constexpr std::array<u32, 2> s_clock_freqs{{
27000000, 54000000,
27000000,
54000000,
}};

static u64 s_ticks_last_line_start; // number of ticks when the current full scanline started
@@ -323,10 +324,9 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
}));
mmio->Register(
base | VI_HORIZONTAL_BEAM_POSITION, MMIO::ComplexRead<u16>([](u32) {
u16 value =
static_cast<u16>(1 +
m_HTiming0.HLW * (CoreTiming::GetTicks() - s_ticks_last_line_start) /
(GetTicksPerHalfLine()));
u16 value = static_cast<u16>(1 + m_HTiming0.HLW *
(CoreTiming::GetTicks() - s_ticks_last_line_start) /
(GetTicksPerHalfLine()));
return MathUtil::Clamp(value, static_cast<u16>(1), static_cast<u16>(m_HTiming0.HLW * 2));
}),
MMIO::ComplexWrite<u16>([](u32, u16 val) {
@@ -644,13 +644,15 @@ static void LogField(FieldType field, u32 xfb_address)
static constexpr std::array<const char*, 2> field_type_names{{"Odd", "Even"}};

static const std::array<const UVIVBlankTimingRegister*, 2> vert_timing{{
&m_VBlankTimingOdd, &m_VBlankTimingEven,
&m_VBlankTimingOdd,
&m_VBlankTimingEven,
}};

const auto field_index = static_cast<size_t>(field);

DEBUG_LOG(VIDEOINTERFACE, "(VI->BeginField): Address: %.08X | WPL %u | STD %u | EQ %u | PRB %u | "
"ACV %u | PSB %u | Field %s",
DEBUG_LOG(VIDEOINTERFACE,
"(VI->BeginField): Address: %.08X | WPL %u | STD %u | EQ %u | PRB %u | "
"ACV %u | PSB %u | Field %s",
xfb_address, m_PictureConfiguration.WPL, m_PictureConfiguration.STD,
m_VerticalTimingRegister.EQU, vert_timing[field_index]->PRB,
m_VerticalTimingRegister.ACV, vert_timing[field_index]->PSB,
@@ -23,25 +23,54 @@ constexpr std::array<u8, 6> classic_id{{0x00, 0x00, 0xa4, 0x20, 0x01, 0x01}};

// Classic Controller calibration
constexpr std::array<u8, 0x10> classic_calibration{{
0xff, 0x00, 0x80, 0xff, 0x00, 0x80, 0xff, 0x00, 0x80, 0xff, 0x00, 0x80, 0x00, 0x00, 0x51, 0xa6,
0xff,
0x00,
0x80,
0xff,
0x00,
0x80,
0xff,
0x00,
0x80,
0xff,
0x00,
0x80,
0x00,
0x00,
0x51,
0xa6,
}};

constexpr std::array<u16, 9> classic_button_bitmasks{{
Classic::BUTTON_A, Classic::BUTTON_B, Classic::BUTTON_X, Classic::BUTTON_Y,
Classic::BUTTON_A,
Classic::BUTTON_B,
Classic::BUTTON_X,
Classic::BUTTON_Y,

Classic::BUTTON_ZL, Classic::BUTTON_ZR,
Classic::BUTTON_ZL,
Classic::BUTTON_ZR,

Classic::BUTTON_MINUS, Classic::BUTTON_PLUS,
Classic::BUTTON_MINUS,
Classic::BUTTON_PLUS,

Classic::BUTTON_HOME,
}};

constexpr std::array<const char*, 9> classic_button_names{{
"A", "B", "X", "Y", "ZL", "ZR", "-", "+", "Home",
"A",
"B",
"X",
"Y",
"ZL",
"ZR",
"-",
"+",
"Home",
}};

constexpr std::array<u16, 2> classic_trigger_bitmasks{{
Classic::TRIGGER_L, Classic::TRIGGER_R,
Classic::TRIGGER_L,
Classic::TRIGGER_R,
}};

constexpr std::array<const char*, 4> classic_trigger_names{{
@@ -56,7 +85,10 @@ constexpr std::array<const char*, 4> classic_trigger_names{{
}};

constexpr std::array<u16, 4> classic_dpad_bitmasks{{
Classic::PAD_UP, Classic::PAD_DOWN, Classic::PAD_LEFT, Classic::PAD_RIGHT,
Classic::PAD_UP,
Classic::PAD_DOWN,
Classic::PAD_LEFT,
Classic::PAD_RIGHT,
}};

Classic::Classic(ExtensionReg& reg) : Attachment(_trans("Classic"), reg)
@@ -20,17 +20,26 @@ namespace WiimoteEmu
constexpr std::array<u8, 6> drums_id{{0x01, 0x00, 0xa4, 0x20, 0x01, 0x03}};

constexpr std::array<u16, 6> drum_pad_bitmasks{{
Drums::PAD_RED, Drums::PAD_YELLOW, Drums::PAD_BLUE, Drums::PAD_GREEN, Drums::PAD_ORANGE,
Drums::PAD_RED,
Drums::PAD_YELLOW,
Drums::PAD_BLUE,
Drums::PAD_GREEN,
Drums::PAD_ORANGE,
Drums::PAD_BASS,
}};

constexpr std::array<const char*, 6> drum_pad_names{{
_trans("Red"), _trans("Yellow"), _trans("Blue"), _trans("Green"), _trans("Orange"),
_trans("Red"),
_trans("Yellow"),
_trans("Blue"),
_trans("Green"),
_trans("Orange"),
_trans("Bass"),
}};

constexpr std::array<u16, 2> drum_button_bitmasks{{
Drums::BUTTON_MINUS, Drums::BUTTON_PLUS,
Drums::BUTTON_MINUS,
Drums::BUTTON_PLUS,
}};

Drums::Drums(ExtensionReg& reg) : Attachment(_trans("Drums"), reg)
@@ -36,20 +36,29 @@ static const std::map<const ControlState, const u8> s_slider_bar_control_codes{
constexpr std::array<u8, 6> guitar_id{{0x00, 0x00, 0xa4, 0x20, 0x01, 0x03}};

constexpr std::array<u16, 5> guitar_fret_bitmasks{{
Guitar::FRET_GREEN, Guitar::FRET_RED, Guitar::FRET_YELLOW, Guitar::FRET_BLUE,
Guitar::FRET_GREEN,
Guitar::FRET_RED,
Guitar::FRET_YELLOW,
Guitar::FRET_BLUE,
Guitar::FRET_ORANGE,
}};

constexpr std::array<const char*, 5> guitar_fret_names{{
_trans("Green"), _trans("Red"), _trans("Yellow"), _trans("Blue"), _trans("Orange"),
_trans("Green"),
_trans("Red"),
_trans("Yellow"),
_trans("Blue"),
_trans("Orange"),
}};

constexpr std::array<u16, 2> guitar_button_bitmasks{{
Guitar::BUTTON_MINUS, Guitar::BUTTON_PLUS,
Guitar::BUTTON_MINUS,
Guitar::BUTTON_PLUS,
}};

constexpr std::array<u16, 2> guitar_strum_bitmasks{{
Guitar::BAR_UP, Guitar::BAR_DOWN,
Guitar::BAR_UP,
Guitar::BAR_DOWN,
}};

Guitar::Guitar(ExtensionReg& reg) : Attachment(_trans("Guitar"), reg)
@@ -24,7 +24,8 @@ namespace WiimoteEmu
constexpr std::array<u8, 6> nunchuk_id{{0x00, 0x00, 0xa4, 0x20, 0x00, 0x00}};

constexpr std::array<u8, 2> nunchuk_button_bitmasks{{
Nunchuk::BUTTON_C, Nunchuk::BUTTON_Z,
Nunchuk::BUTTON_C,
Nunchuk::BUTTON_Z,
}};

Nunchuk::Nunchuk(ExtensionReg& reg) : Attachment(_trans("Nunchuk"), reg)
@@ -23,14 +23,26 @@ namespace WiimoteEmu
constexpr std::array<u8, 6> turntable_id{{0x03, 0x00, 0xa4, 0x20, 0x01, 0x03}};

constexpr std::array<u16, 9> turntable_button_bitmasks{{
Turntable::BUTTON_L_GREEN, Turntable::BUTTON_L_RED, Turntable::BUTTON_L_BLUE,
Turntable::BUTTON_R_GREEN, Turntable::BUTTON_R_RED, Turntable::BUTTON_R_BLUE,
Turntable::BUTTON_MINUS, Turntable::BUTTON_PLUS, Turntable::BUTTON_EUPHORIA,
Turntable::BUTTON_L_GREEN,
Turntable::BUTTON_L_RED,
Turntable::BUTTON_L_BLUE,
Turntable::BUTTON_R_GREEN,
Turntable::BUTTON_R_RED,
Turntable::BUTTON_R_BLUE,
Turntable::BUTTON_MINUS,
Turntable::BUTTON_PLUS,
Turntable::BUTTON_EUPHORIA,
}};

constexpr std::array<const char*, 9> turntable_button_names{{
_trans("Green Left"), _trans("Red Left"), _trans("Blue Left"), _trans("Green Right"),
_trans("Red Right"), _trans("Blue Right"), "-", "+",
_trans("Green Left"),
_trans("Red Left"),
_trans("Blue Left"),
_trans("Green Right"),
_trans("Red Right"),
_trans("Blue Right"),
"-",
"+",
// i18n: This button name refers to a gameplay element in DJ Hero
_trans("Euphoria"),
}};
@@ -53,6 +53,7 @@ auto const PI = TAU / 2.0;

namespace WiimoteEmu
{
// clang-format off
static const u8 eeprom_data_0[] = {
// IR, maybe more
// assuming last 2 bytes are checksum
@@ -64,6 +65,7 @@ static const u8 eeprom_data_0[] = {
ACCEL_ZERO_G, ACCEL_ZERO_G, ACCEL_ZERO_G, 0, ACCEL_ONE_G, ACCEL_ONE_G, ACCEL_ONE_G, 0, 0, 0xA3,
ACCEL_ZERO_G, ACCEL_ZERO_G, ACCEL_ZERO_G, 0, ACCEL_ONE_G, ACCEL_ONE_G, ACCEL_ONE_G, 0, 0, 0xA3,
};
// clang-format on

static const u8 motion_plus_id[] = {0x00, 0x00, 0xA6, 0x20, 0x00, 0x05};

@@ -19,6 +19,7 @@ class WiimoteAndroid final : public Wiimote
WiimoteAndroid(int index);
~WiimoteAndroid() override;
std::string GetId() const override { return "Android " + std::to_string(m_mayflash_index); }

protected:
bool ConnectInternal() override;
void DisconnectInternal() override;
@@ -258,8 +258,9 @@ int WiimoteLinux::IORead(u8* buf)
if (errno == ENOTCONN)
{
// This can happen if the Bluetooth dongle is disconnected
ERROR_LOG(WIIMOTE, "Bluetooth appears to be disconnected. "
"Wiimote %i will be disconnected.",
ERROR_LOG(WIIMOTE,
"Bluetooth appears to be disconnected. "
"Wiimote %i will be disconnected.",
m_index + 1);
}

@@ -27,6 +27,7 @@ class WiimoteWindows final : public Wiimote
WiimoteWindows(const std::basic_string<TCHAR>& path, WinWriteMethod initial_write_method);
~WiimoteWindows() override;
std::string GetId() const override { return UTF16ToUTF8(m_devicepath); }

protected:
bool ConnectInternal() override;
void DisconnectInternal() override;
@@ -15,8 +15,9 @@ static bool IsDeviceUsable(const std::string& device_path)
hid_device* handle = hid_open_path(device_path.c_str());
if (handle == nullptr)
{
ERROR_LOG(WIIMOTE, "Could not connect to Wii Remote at \"%s\". "
"Do you have permission to access the device?",
ERROR_LOG(WIIMOTE,
"Could not connect to Wii Remote at \"%s\". "
"Do you have permission to access the device?",
device_path.c_str());
return false;
}
@@ -96,8 +97,9 @@ bool WiimoteHidapi::ConnectInternal()
m_handle = hid_open_path(m_device_path.c_str());
if (m_handle == nullptr)
{
ERROR_LOG(WIIMOTE, "Could not connect to Wii Remote at \"%s\". "
"Do you have permission to access the device?",
ERROR_LOG(WIIMOTE,
"Could not connect to Wii Remote at \"%s\". "
"Do you have permission to access the device?",
m_device_path.c_str());
}
return m_handle != nullptr;
@@ -17,6 +17,7 @@ class WiimoteHidapi final : public Wiimote
explicit WiimoteHidapi(const std::string& device_path);
~WiimoteHidapi() override;
std::string GetId() const override { return m_device_path; }

protected:
bool ConnectInternal() override;
void DisconnectInternal() override;
@@ -278,8 +278,9 @@ ReturnCode ES::ImportContentBegin(Context& context, u64 title_id, u32 content_id

if (title_id != context.title_import_export.tmd.GetTitleId())
{
ERROR_LOG(IOS_ES, "ImportContentBegin: title id %016" PRIx64 " != "
"TMD title id %016" PRIx64 ", ignoring",
ERROR_LOG(IOS_ES,
"ImportContentBegin: title id %016" PRIx64 " != "
"TMD title id %016" PRIx64 ", ignoring",
title_id, context.title_import_export.tmd.GetTitleId());
return ES_EINVAL;
}
@@ -318,6 +318,7 @@ struct ARMBinary final
u32 GetHeaderSize() const { return Common::swap32(m_bytes.data()); }
u32 GetElfOffset() const { return Common::swap32(m_bytes.data() + 0x4); }
u32 GetElfSize() const { return Common::swap32(m_bytes.data() + 0x8); }

private:
std::vector<u8> m_bytes;
};
@@ -100,10 +100,13 @@ namespace HLE
{
constexpr u32 DEFAULT_DEVICE_ID = 0x0403AC68;
constexpr u32 DEFAULT_KEY_ID = 0x6AAB8C59;

constexpr std::array<u8, 30> DEFAULT_PRIVATE_KEY = {{
0x00, 0xAB, 0xEE, 0xC1, 0xDD, 0xB4, 0xA6, 0x16, 0x6B, 0x70, 0xFD, 0x7E, 0x56, 0x67, 0x70,
0x57, 0x55, 0x27, 0x38, 0xA3, 0x26, 0xC5, 0x46, 0x16, 0xF7, 0x62, 0xC9, 0xED, 0x73, 0xF2,
}};

// clang-format off
constexpr ECCSignature DEFAULT_SIGNATURE = {{
// R
0x00, 0xD8, 0x81, 0x63, 0xB2, 0x00, 0x6B, 0x0B, 0x54, 0x82, 0x88, 0x63, 0x81, 0x1C, 0x00, 0x71,
@@ -112,6 +115,7 @@ constexpr ECCSignature DEFAULT_SIGNATURE = {{
0x00, 0x71, 0x8D, 0x82, 0x41, 0xEE, 0x45, 0x11, 0xC7, 0x3B, 0xAC, 0x08, 0xB6, 0x83, 0xDC, 0x05,
0xB8, 0xA8, 0x90, 0x1F, 0xA8, 0x2A, 0x0E, 0x4E, 0x76, 0xEF, 0x44, 0x72, 0x99, 0xF8,
}};
// clang-format on

const std::map<std::pair<IOSC::ObjectType, IOSC::ObjectSubType>, size_t> s_type_to_size_map = {{
{{IOSC::TYPE_SECRET_KEY, IOSC::SUBTYPE_AES128}, 16},
@@ -31,13 +31,13 @@ struct icmp_hdr
static u8 workspace[56];

/*
* Description:
* Calculate Internet checksum for data buffer and length (one's
* complement sum of 16-bit words). Used in IP, ICMP, UDP, IGMP.
*
* NOTE: to handle odd number of bytes, last (even) byte in
* buffer have a value of 0 (we assume that it does)
*/
* Description:
* Calculate Internet checksum for data buffer and length (one's
* complement sum of 16-bit words). Used in IP, ICMP, UDP, IGMP.
*
* NOTE: to handle odd number of bytes, last (even) byte in
* buffer have a value of 0 (we assume that it does)
*/
u16 cksum(const u16* buffer, int length)
{
u32 sum = 0;
@@ -251,8 +251,9 @@ IPCCommandResult NetIPTop::HandleSocketRequest(const IOCtlRequest& request)

WiiSockMan& sm = WiiSockMan::GetInstance();
const s32 return_value = sm.NewSocket(af, type, prot);
INFO_LOG(IOS_NET, "IOCTL_SO_SOCKET "
"Socket: %08x (%d,%d,%d), BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
INFO_LOG(IOS_NET,
"IOCTL_SO_SOCKET "
"Socket: %08x (%d,%d,%d), BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
return_value, af, type, prot, request.buffer_in, request.buffer_in_size,
request.buffer_out, request.buffer_out_size);

@@ -353,10 +354,11 @@ IPCCommandResult NetIPTop::HandleSetSockOptRequest(const IOCtlRequest& request)
optlen = std::min(optlen, (u32)sizeof(optval));
Memory::CopyFromEmu(optval, request.buffer_in + 0x10, optlen);

INFO_LOG(IOS_NET, "IOCTL_SO_SETSOCKOPT(%08x, %08x, %08x, %08x) "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)"
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx "
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx",
INFO_LOG(IOS_NET,
"IOCTL_SO_SETSOCKOPT(%08x, %08x, %08x, %08x) "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)"
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx "
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx",
fd, level, optname, optlen, request.buffer_in, request.buffer_in_size,
request.buffer_out, request.buffer_out_size, optval[0], optval[1], optval[2], optval[3],
optval[4], optval[5], optval[6], optval[7], optval[8], optval[9], optval[10], optval[11],
@@ -502,16 +504,18 @@ IPCCommandResult NetIPTop::HandleInetAToNRequest(const IOCtlRequest& request)
if (remoteHost == nullptr || remoteHost->h_addr_list == nullptr ||
remoteHost->h_addr_list[0] == nullptr)
{
INFO_LOG(IOS_NET, "IOCTL_SO_INETATON = -1 "
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: None",
INFO_LOG(IOS_NET,
"IOCTL_SO_INETATON = -1 "
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: None",
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
request.buffer_out_size);
return GetDefaultReply(0);
}

Memory::Write_U32(Common::swap32(*(u32*)remoteHost->h_addr_list[0]), request.buffer_out);
INFO_LOG(IOS_NET, "IOCTL_SO_INETATON = 0 "
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: %08X",
INFO_LOG(IOS_NET,
"IOCTL_SO_INETATON = 0 "
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: %08X",
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
request.buffer_out_size, Common::swap32(*(u32*)remoteHost->h_addr_list[0]));
return GetDefaultReply(1);
@@ -577,9 +581,10 @@ IPCCommandResult NetIPTop::HandlePollRequest(const IOCtlRequest& request)
ufds[i].events |= map.native;
unhandled_events &= ~map.wii;
}
DEBUG_LOG(IOS_NET, "IOCTL_SO_POLL(%d) "
"Sock: %08x, Unknown: %08x, Events: %08x, "
"NativeEvents: %08x",
DEBUG_LOG(IOS_NET,
"IOCTL_SO_POLL(%d) "
"Sock: %08x, Unknown: %08x, Events: %08x, "
"NativeEvents: %08x",
i, wii_fd, unknown, events, ufds[i].events);

// Do not pass return-only events to the native poll
@@ -625,8 +630,9 @@ IPCCommandResult NetIPTop::HandleGetHostByNameRequest(const IOCtlRequest& reques
std::string hostname = Memory::GetString(request.buffer_in);
hostent* remoteHost = gethostbyname(hostname.c_str());

INFO_LOG(IOS_NET, "IOCTL_SO_GETHOSTBYNAME "
"Address: %s, BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
INFO_LOG(IOS_NET,
"IOCTL_SO_GETHOSTBYNAME "
"Address: %s, BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
request.buffer_out_size);

@@ -718,8 +724,9 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
param5 = Memory::Read_U32(request.io_vectors[0].address + 4);
}

INFO_LOG(IOS_NET, "IOCTLV_SO_GETINTERFACEOPT(%08X, %08X, %X, %X, %X) "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i) ",
INFO_LOG(IOS_NET,
"IOCTLV_SO_GETINTERFACEOPT(%08X, %08X, %X, %X, %X) "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i) ",
param, param2, param3, param4, param5, request.in_vectors[0].address,
request.in_vectors[0].size,
request.in_vectors.size() > 1 ? request.in_vectors[1].address : 0,
@@ -989,8 +996,9 @@ IPCCommandResult NetIPTop::HandleICMPPingRequest(const IOCtlVRequest& request)

if (ip_info.length != 8 || ip_info.addr_family != AF_INET)
{
INFO_LOG(IOS_NET, "IOCTLV_SO_ICMPPING strange IPInfo:\n"
"length %x addr_family %x",
INFO_LOG(IOS_NET,
"IOCTLV_SO_ICMPPING strange IPInfo:\n"
"length %x addr_family %x",
ip_info.length, ip_info.addr_family);
}

@@ -165,7 +165,10 @@ u8 NetKDRequest::GetAreaCode(const std::string& area) const
u8 NetKDRequest::GetHardwareModel(const std::string& model) const
{
static const std::map<std::string, u8> models = {
{"RVL", MODEL_RVL}, {"RVT", MODEL_RVT}, {"RVV", MODEL_RVV}, {"RVD", MODEL_RVD},
{"RVL", MODEL_RVL},
{"RVT", MODEL_RVT},
{"RVV", MODEL_RVV},
{"RVD", MODEL_RVD},
};

auto entryPos = models.find(model);
@@ -38,8 +38,9 @@ void GetMACAddress(u8* mac)
SaveMACAddress(mac);
if (!wireless_mac.empty())
{
ERROR_LOG(IOS_NET, "The MAC provided (%s) is invalid. We have "
"generated another one for you.",
ERROR_LOG(IOS_NET,
"The MAC provided (%s) is invalid. We have "
"generated another one for you.",
Common::MacAddressToString(mac).c_str());
}
}
@@ -238,10 +238,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
WriteReturnValue(SSL_ERR_FAILED, BufferIn);
}

INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_NEW (%d, %s) "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_NEW (%d, %s) "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
verifyOption, hostname.c_str(), BufferIn, BufferInSize, BufferIn2, BufferInSize2,
BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2,
BufferOut3, BufferOutSize3);
@@ -275,20 +276,22 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
{
WriteReturnValue(SSL_ERR_ID, BufferIn);
}
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SHUTDOWN "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_SHUTDOWN "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
break;
}
case IOCTLV_NET_SSL_SETROOTCA:
{
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCA "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_SETROOTCA "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);

@@ -325,10 +328,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
}
case IOCTLV_NET_SSL_SETBUILTINCLIENTCERT:
{
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);

@@ -371,10 +375,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
}
case IOCTLV_NET_SSL_REMOVECLIENTCERT:
{
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_REMOVECLIENTCERT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_REMOVECLIENTCERT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);

@@ -424,10 +429,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
{
WriteReturnValue(SSL_ERR_ID, BufferIn);
}
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_SETBUILTINROOTCA "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
break;
@@ -450,10 +456,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
{
WriteReturnValue(SSL_ERR_ID, BufferIn);
}
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_CONNECT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_CONNECT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
break;
@@ -486,10 +493,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
{
WriteReturnValue(SSL_ERR_ID, BufferIn);
}
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_WRITE "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_WRITE "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
INFO_LOG(IOS_SSL, "%s", Memory::GetString(BufferOut2).c_str());
@@ -510,10 +518,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
WriteReturnValue(SSL_ERR_ID, BufferIn);
}

INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_READ(%d)"
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_READ(%d)"
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
break;
@@ -529,20 +538,22 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
{
WriteReturnValue(SSL_ERR_ID, BufferIn);
}
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCADEFAULT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_SETROOTCADEFAULT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
break;
}
case IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT:
{
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);

@@ -393,9 +393,10 @@ void WiiSocket::Update(bool read, bool write, bool except)
}
}

INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE = (%d) "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
INFO_LOG(IOS_SSL,
"IOCTLV_NET_SSL_DOHANDSHAKE = (%d) "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2);
break;
@@ -560,9 +561,10 @@ void WiiSocket::Update(bool read, bool write, bool except)
ReturnValue =
WiiSockMan::GetNetErrorCode(ret, BufferOutSize2 ? "SO_RECVFROM" : "SO_RECV", true);

INFO_LOG(IOS_NET, "%s(%d, %p) Socket: %08X, Flags: %08X, "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
INFO_LOG(IOS_NET,
"%s(%d, %p) Socket: %08X, Flags: %08X, "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
BufferOutSize2 ? "IOCTLV_SO_RECVFROM " : "IOCTLV_SO_RECV ", ReturnValue, data,
wii_fd, flags, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
BufferOutSize, BufferOut2, BufferOutSize2);
@@ -561,7 +561,9 @@ std::array<u32, 4> SDIOSlot0::GetCSDv1() const

// Form the csd using the description above
return {{
0x007f003, 0x5b5f8000 | (c_size >> 2), 0x3ffc7f80 | (c_size << 30) | (c_size_mult << 15),
0x007f003,
0x5b5f8000 | (c_size >> 2),
0x3ffc7f80 | (c_size << 30) | (c_size_mult << 15),
0x07c04001 | (crc << 1),
}};
}
@@ -616,7 +618,10 @@ std::array<u32, 4> SDIOSlot0::GetCSDv2() const

// Form the csd using the description above
return {{
0x400e005a, 0x5f590000 | (c_size >> 16), 0x00007f80 | (c_size << 16), 0x0a400001 | (crc << 1),
0x400e005a,
0x5f590000 | (c_size >> 16),
0x00007f80 | (c_size << 16),
0x0a400001 | (crc << 1),
}};
}

@@ -30,6 +30,7 @@ class BluetoothBase : public Device
virtual void UpdateSyncButtonState(bool is_held) {}
virtual void TriggerSyncButtonPressedEvent() {}
virtual void TriggerSyncButtonHeldEvent() {}

protected:
static constexpr int ACL_PKT_SIZE = 339;
static constexpr int ACL_PKT_NUM = 10;
@@ -288,8 +288,9 @@ void BluetoothEmu::AddEventToQueue(const SQueuedEvent& _event)
m_EventQueue.size());
m_EventQueue.push_back(_event);
const SQueuedEvent& event = m_EventQueue.front();
DEBUG_LOG(IOS_WIIMOTE, "HCI event %x "
"being written from queue (%zu) to %08x...",
DEBUG_LOG(IOS_WIIMOTE,
"HCI event %x "
"being written from queue (%zu) to %08x...",
((hci_event_hdr_t*)event.m_buffer)->event, m_EventQueue.size() - 1,
m_HCIEndpoint->ios_request.address);
m_HCIEndpoint->FillBuffer(event.m_buffer, event.m_size);
@@ -400,8 +401,9 @@ void BluetoothEmu::ACLPool::WriteToEndpoint(USB::V0BulkMessage& endpoint)
const u16 size = packet.size;
const u16 conn_handle = packet.conn_handle;

DEBUG_LOG(IOS_WIIMOTE, "ACL packet being written from "
"queue to %08x",
DEBUG_LOG(IOS_WIIMOTE,
"ACL packet being written from "
"queue to %08x",
endpoint.ios_request.address);

hci_acldata_hdr_t* pHeader = (hci_acldata_hdr_t*)Memory::GetPointer(endpoint.data_address);
@@ -1204,7 +1206,8 @@ void BluetoothEmu::CommandAcceptCon(const u8* input)
const hci_accept_con_cp* accept_connection = reinterpret_cast<const hci_accept_con_cp*>(input);

static char roles[][128] = {
{"Master (0x00)"}, {"Slave (0x01)"},
{"Master (0x00)"},
{"Slave (0x01)"},
};

INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_ACCEPT_CON");
@@ -87,6 +87,7 @@ class BluetoothEmu final : public BluetoothBase
bool IsEmpty() const { return m_queue.empty(); }
// For SaveStates
void DoState(PointerWrap& p) { p.Do(m_queue); }

private:
struct Packet
{
@@ -621,16 +621,16 @@ void WiimoteDevice::SendConfigurationRequest(u16 scid, u16 MTU, u16 FlushTimeOut
SendCommandToACL(L2CAP_CONFIG_REQ, L2CAP_CONFIG_REQ, Offset, Buffer);
}

//
//
//
//
// --- SDP
//
//
//
//
//
//
//
//
//
// --- SDP
//
//
//
//
//

#define SDP_UINT8 0x08
#define SDP_UINT16 0x09
@@ -34,6 +34,7 @@ class CBigEndianBuffer
void Write16(u32 offset, u16 data) { *(u16*)&m_pBuffer[offset] = Common::swap16(data); }
void Write32(u32 offset, u32 data) { *(u32*)&m_pBuffer[offset] = Common::swap32(data); }
u8* GetPointer(u32 offset) { return &m_pBuffer[offset]; }

private:
u8* m_pBuffer;
};
@@ -69,6 +70,7 @@ class WiimoteDevice
u16 GetLMPSubVersion() const { return lmp_subversion; }
u16 GetManufactorID() const { return 0x000F; } // Broadcom Corporation
const u8* GetLinkKey() const { return m_LinkKey; }

private:
enum ConnectionState
{
@@ -2530,11 +2530,11 @@ static __inline int hci_filter_test(uint8_t bit, const struct hci_filter* filter
return (filter->mask[off] & (1 << ((bit - 1) & 0x1f)));
}

/*
* HCI socket ioctl's
*
* Apart from GBTINFOA, these are all indexed on the unit name
*/
/*
* HCI socket ioctl's
*
* Apart from GBTINFOA, these are all indexed on the unit name
*/

#define SIOCGBTINFO _IOWR('b', 5, struct btreq) /* get unit info */
#define SIOCGBTINFOA _IOWR('b', 6, struct btreq) /* get info by address */
@@ -5,70 +5,70 @@
/* $NetBSD: l2cap.h,v 1.9 2009/09/13 18:45:11 pooka Exp $ */

/*-
* Copyright (c) 2005 Iain Hibbert.
* Copyright (c) 2006 Itronix Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of Itronix Inc. may not be used to endorse
* or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
* Copyright (c) 2005 Iain Hibbert.
* Copyright (c) 2006 Itronix Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of Itronix Inc. may not be used to endorse
* or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*-
* Copyright (c) Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: l2cap.h,v 1.9 2009/09/13 18:45:11 pooka Exp $
* $FreeBSD: src/sys/netgraph/bluetooth/include/l2cap.h,v 1.4 2005/08/31 18:13:23 emax Exp $
*/
* Copyright (c) Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: l2cap.h,v 1.9 2009/09/13 18:45:11 pooka Exp $
* $FreeBSD: src/sys/netgraph/bluetooth/include/l2cap.h,v 1.4 2005/08/31 18:13:23 emax Exp $
*/

/*
* This file contains everything that application needs to know about
* Link Layer Control and Adaptation Protocol (L2CAP). All information
* was obtained from Bluetooth Specification Books (v1.1 and up)
*
* This file can be included by both kernel and userland applications.
*/
* This file contains everything that application needs to know about
* Link Layer Control and Adaptation Protocol (L2CAP). All information
* was obtained from Bluetooth Specification Books (v1.1 and up)
*
* This file can be included by both kernel and userland applications.
*/

#pragma once

@@ -81,10 +81,10 @@
**************************************************************************/

/*
* Channel IDs are assigned per machine. So the total number of channels that
* a machine can have open at the same time is 0xffff - 0x0040 = 0xffbf (65471).
* This number does not depend on number of HCI connections.
*/
* Channel IDs are assigned per machine. So the total number of channels that
* a machine can have open at the same time is 0xffff - 0x0040 = 0xffbf (65471).
* This number does not depend on number of HCI connections.
*/

#define L2CAP_NULL_CID 0x0000 /* DO NOT USE THIS CID */
#define L2CAP_SIGNAL_CID 0x0001 /* signaling channel ID */
@@ -338,9 +338,9 @@ typedef struct
uint16_t type; /* requested information type */
uint16_t result; /* 0x00 - success */
/* uint8_t info[] -- info data (depends on type)
*
* L2CAP_CONNLESS_MTU - 2 bytes connectionless MTU
*/
*
* L2CAP_CONNLESS_MTU - 2 bytes connectionless MTU
*/
} l2cap_info_rsp_cp;

typedef union
@@ -36,6 +36,7 @@ class LibusbConfigDescriptor final
~LibusbConfigDescriptor();
libusb_config_descriptor* Get() const { return m_descriptor; }
bool IsValid() const { return m_descriptor != nullptr; }

private:
libusb_config_descriptor* m_descriptor = nullptr;
};
@@ -178,7 +178,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)

case IOCTL_WFSI_PREPARE_PROFILE:
m_base_extract_path = StringFromFormat("/vol/%s/tmp/", m_device_name.c_str());
// Fall through intended.
// Fall through intended.

case IOCTL_WFSI_PREPARE_CONTENT:
{
@@ -27,7 +27,9 @@
namespace PatchEngine
{
const char* PatchTypeStrings[] = {
"byte", "word", "dword",
"byte",
"word",
"dword",
};

static std::vector<Patch> onFrame;
@@ -93,6 +93,7 @@ class MemChecks

void Clear() { m_mem_checks.clear(); }
bool HasAny() const { return !m_mem_checks.empty(); }

private:
TMemChecks m_mem_checks;
};
@@ -31,6 +31,7 @@ class CachedInterpreter : public JitBase
JitBaseBlockCache* GetBlockCache() override { return &m_block_cache; }
const char* GetName() const override { return "Cached Interpreter"; }
const CommonAsmRoutinesBase* GetAsmRoutines() override { return nullptr; }

private:
struct Instruction;

@@ -10,7 +10,6 @@
#include <unistd.h>
#ifdef _WIN32
#include <iphlpapi.h>
#include <iphlpapi.h>
#include <ws2tcpip.h>
#else
#include <netinet/in.h>
@@ -92,8 +92,9 @@ static void Trace(UGeckoInstruction& inst)
}

std::string ppc_inst = GekkoDisassembler::Disassemble(inst.hex, PC);
DEBUG_LOG(POWERPC, "INTER PC: %08x SRR0: %08x SRR1: %08x CRval: %016lx FPSCR: %08x MSR: %08x LR: "
"%08x %s %08x %s",
DEBUG_LOG(POWERPC,
"INTER PC: %08x SRR0: %08x SRR1: %08x CRval: %016lx FPSCR: %08x MSR: %08x LR: "
"%08x %s %08x %s",
PC, SRR0, SRR1, (unsigned long)PowerPC::ppcState.cr_val[0], PowerPC::ppcState.fpscr,
PowerPC::ppcState.msr, PowerPC::ppcState.spr[8], regs.c_str(), inst.hex,
ppc_inst.c_str());
@@ -2,12 +2,12 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "Core/PowerPC/Interpreter/Interpreter.h"
#include "Common/Assert.h"
#include "Common/CommonTypes.h"
#include "Core/ConfigManager.h"
#include "Core/CoreTiming.h"
#include "Core/HLE/HLE.h"
#include "Core/PowerPC/Interpreter/Interpreter.h"
#include "Core/PowerPC/PowerPC.h"

void Interpreter::bx(UGeckoInstruction inst)
@@ -2,8 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "Core/PowerPC/Jit64/Jit.h"
#include "Core/PowerPC/Gekko.h"
#include "Core/PowerPC/Jit64/Jit.h"

static Jit64::Instruction dynaOpTable[64];
static Jit64::Instruction dynaOpTable4[1024];
@@ -2,12 +2,12 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "Core/PowerPC/Jit64/Jit.h"
#include "Common/Assert.h"
#include "Common/CommonTypes.h"
#include "Common/x64Emitter.h"
#include "Core/CoreTiming.h"
#include "Core/PowerPC/Gekko.h"
#include "Core/PowerPC/Jit64/Jit.h"
#include "Core/PowerPC/Jit64/JitRegCache.h"
#include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h"
#include "Core/PowerPC/PPCAnalyst.h"
@@ -2,10 +2,10 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "Core/PowerPC/Jit64/Jit.h"
#include "Common/BitSet.h"
#include "Common/CommonTypes.h"
#include "Common/x64Emitter.h"
#include "Core/PowerPC/Jit64/Jit.h"
#include "Core/PowerPC/Jit64/JitRegCache.h"
#include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h"

@@ -2,11 +2,11 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "Core/PowerPC/Jit64/Jit.h"
#include "Common/CPUDetect.h"
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"
#include "Common/x64Emitter.h"
#include "Core/PowerPC/Jit64/Jit.h"
#include "Core/PowerPC/Jit64/JitRegCache.h"

using namespace Gen;
@@ -2,13 +2,13 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "Core/PowerPC/Jit64/Jit.h"
#include "Common/BitSet.h"
#include "Common/CPUDetect.h"
#include "Common/CommonTypes.h"
#include "Common/x64Emitter.h"
#include "Core/CoreTiming.h"
#include "Core/HW/ProcessorInterface.h"
#include "Core/PowerPC/Jit64/Jit.h"
#include "Core/PowerPC/Jit64/JitRegCache.h"
#include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h"
#include "Core/PowerPC/PowerPC.h"
@@ -1059,8 +1059,9 @@ void EmuCodeBlock::SetFPRF(Gen::X64Reg xmm)
FixupBranch zeroExponent = J_CC(CC_Z);

// Nice normalized number: sign ? PPC_FPCLASS_NN : PPC_FPCLASS_PN;
LEA(32, RSCRATCH, MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_NN - MathUtil::PPC_FPCLASS_PN,
MathUtil::PPC_FPCLASS_PN));
LEA(32, RSCRATCH,
MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_NN - MathUtil::PPC_FPCLASS_PN,
MathUtil::PPC_FPCLASS_PN));
continue1 = J();

SetJumpTarget(maxExponent);
@@ -1073,17 +1074,19 @@ void EmuCodeBlock::SetFPRF(Gen::X64Reg xmm)

// Max exponent + no mantissa: sign ? PPC_FPCLASS_NINF : PPC_FPCLASS_PINF;
SetJumpTarget(notNAN);
LEA(32, RSCRATCH, MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_NINF - MathUtil::PPC_FPCLASS_PINF,
MathUtil::PPC_FPCLASS_PINF));
LEA(32, RSCRATCH,
MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_NINF - MathUtil::PPC_FPCLASS_PINF,
MathUtil::PPC_FPCLASS_PINF));
continue3 = J();

SetJumpTarget(zeroExponent);
PTEST(xmm, R(xmm));
FixupBranch zero = J_CC(CC_Z);

// No exponent + mantissa: sign ? PPC_FPCLASS_ND : PPC_FPCLASS_PD;
LEA(32, RSCRATCH, MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_ND - MathUtil::PPC_FPCLASS_PD,
MathUtil::PPC_FPCLASS_PD));
LEA(32, RSCRATCH,
MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_ND - MathUtil::PPC_FPCLASS_PD,
MathUtil::PPC_FPCLASS_PD));
continue4 = J();

// Zero: sign ? PPC_FPCLASS_NZ : PPC_FPCLASS_PZ;
@@ -1103,8 +1106,9 @@ void EmuCodeBlock::SetFPRF(Gen::X64Reg xmm)
FixupBranch infinity = J_CC(CC_E);
MOVQ_xmm(R(RSCRATCH), xmm);
SHR(64, R(RSCRATCH), Imm8(63));
LEA(32, RSCRATCH, MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_NN - MathUtil::PPC_FPCLASS_PN,
MathUtil::PPC_FPCLASS_PN));
LEA(32, RSCRATCH,
MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_NN - MathUtil::PPC_FPCLASS_PN,
MathUtil::PPC_FPCLASS_PN));
continue1 = J();
SetJumpTarget(nan);
MOVQ_xmm(R(RSCRATCH), xmm);
@@ -1114,15 +1118,17 @@ void EmuCodeBlock::SetFPRF(Gen::X64Reg xmm)
SetJumpTarget(infinity);
MOVQ_xmm(R(RSCRATCH), xmm);
SHR(64, R(RSCRATCH), Imm8(63));
LEA(32, RSCRATCH, MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_NINF - MathUtil::PPC_FPCLASS_PINF,
MathUtil::PPC_FPCLASS_PINF));
LEA(32, RSCRATCH,
MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_NINF - MathUtil::PPC_FPCLASS_PINF,
MathUtil::PPC_FPCLASS_PINF));
continue3 = J();
SetJumpTarget(zeroExponent);
TEST(64, R(RSCRATCH), R(RSCRATCH));
FixupBranch zero = J_CC(CC_Z);
SHR(64, R(RSCRATCH), Imm8(63));
LEA(32, RSCRATCH, MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_ND - MathUtil::PPC_FPCLASS_PD,
MathUtil::PPC_FPCLASS_PD));
LEA(32, RSCRATCH,
MScaled(RSCRATCH, MathUtil::PPC_FPCLASS_ND - MathUtil::PPC_FPCLASS_PD,
MathUtil::PPC_FPCLASS_PD));
continue4 = J();
SetJumpTarget(zero);
SHR(64, R(RSCRATCH), Imm8(63));
@@ -108,7 +108,17 @@ void Arm64GPRCache::Start(PPCAnalyst::BlockRegStats& stats)
bool Arm64GPRCache::IsCalleeSaved(ARM64Reg reg)
{
static constexpr std::array<ARM64Reg, 11> callee_regs{{
X28, X27, X26, X25, X24, X23, X22, X21, X20, X19, INVALID_REG,
X28,
X27,
X26,
X25,
X24,
X23,
X22,
X21,
X20,
X19,
INVALID_REG,
}};

return std::find(callee_regs.begin(), callee_regs.end(), EncodeRegTo64(reg)) != callee_regs.end();
@@ -317,10 +327,37 @@ void Arm64GPRCache::GetAllocationOrder()
// Callee saved registers first in hopes that we will keep everything stored there first
static constexpr std::array<ARM64Reg, 29> allocation_order{{
// Callee saved
W27, W26, W25, W24, W23, W22, W21, W20, W19,
W27,
W26,
W25,
W24,
W23,
W22,
W21,
W20,
W19,

// Caller saved
W18, W17, W16, W15, W14, W13, W12, W11, W10, W9, W8, W7, W6, W5, W4, W3, W2, W1, W0, W30,
W18,
W17,
W16,
W15,
W14,
W13,
W12,
W11,
W10,
W9,
W8,
W7,
W6,
W5,
W4,
W3,
W2,
W1,
W0,
W30,
}};

for (ARM64Reg reg : allocation_order)
@@ -545,11 +582,40 @@ void Arm64FPRCache::GetAllocationOrder()
{
static constexpr std::array<ARM64Reg, 32> allocation_order{{
// Callee saved
Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15,
Q8,
Q9,
Q10,
Q11,
Q12,
Q13,
Q14,
Q15,

// Caller saved
Q16, Q17, Q18, Q19, Q20, Q21, Q22, Q23, Q24, Q25, Q26, Q27, Q28, Q29, Q30, Q31, Q7, Q6, Q5,
Q4, Q3, Q2, Q1, Q0,
Q16,
Q17,
Q18,
Q19,
Q20,
Q21,
Q22,
Q23,
Q24,
Q25,
Q26,
Q27,
Q28,
Q29,
Q30,
Q31,
Q7,
Q6,
Q5,
Q4,
Q3,
Q2,
Q1,
Q0,
}};

for (ARM64Reg reg : allocation_order)
@@ -574,7 +640,15 @@ void Arm64FPRCache::FlushByHost(ARM64Reg host_reg)
bool Arm64FPRCache::IsCalleeSaved(ARM64Reg reg)
{
static constexpr std::array<ARM64Reg, 9> callee_regs{{
Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15, INVALID_REG,
Q8,
Q9,
Q10,
Q11,
Q12,
Q13,
Q14,
Q15,
INVALID_REG,
}};

return std::find(callee_regs.begin(), callee_regs.end(), reg) != callee_regs.end();
@@ -85,6 +85,7 @@ class OpArg
void IncrementLastUsed() { ++m_last_used; }
void SetDirty(bool dirty) { m_dirty = dirty; }
bool IsDirty() const { return m_dirty; }

private:
// For REG_REG
RegType m_type; // store type
@@ -108,6 +109,7 @@ class HostReg
void Unlock() { m_locked = false; }
Arm64Gen::ARM64Reg GetReg() const { return m_reg; }
bool operator==(const Arm64Gen::ARM64Reg& reg) { return reg == m_reg; }

private:
Arm64Gen::ARM64Reg m_reg;
bool m_locked;
@@ -231,6 +233,7 @@ class Arm64GPRCache : public Arm64RegCache

void StoreRegisters(BitSet32 regs) { FlushRegisters(regs, false); }
void StoreCRRegisters(BitSet32 regs) { FlushCRRegisters(regs, false); }

protected:
// Get the order of the host registers
void GetAllocationOrder() override;
@@ -284,6 +287,7 @@ class Arm64FPRCache : public Arm64RegCache
void FixSinglePrecision(size_t preg);

void StoreRegisters(BitSet32 regs) { FlushRegisters(regs, false); }

protected:
// Get the order of the host registers
void GetAllocationOrder() override;
@@ -2,14 +2,14 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "Core/PowerPC/JitArm64/Jit.h"
#include "Common/Arm64Emitter.h"
#include "Common/CommonTypes.h"
#include "Common/JitRegister.h"
#include "Common/MathUtil.h"
#include "Core/CoreTiming.h"
#include "Core/HW/CPU.h"
#include "Core/HW/Memmap.h"
#include "Core/PowerPC/JitArm64/Jit.h"
#include "Core/PowerPC/JitCommon/JitAsmCommon.h"
#include "Core/PowerPC/JitCommon/JitCache.h"
#include "Core/PowerPC/PowerPC.h"
@@ -824,35 +824,35 @@ TranslateResult JitCache_TranslateAddress(u32 address)
return TranslateResult{true, from_bat, tlb_addr.address};
}

// *********************************************************************************
// Warning: Test Area
//
// This code is for TESTING and it works in interpreter mode ONLY. Some games (like
// COD iirc) work thanks to this basic TLB emulation.
// It is just a small hack and we have never spend enough time to finalize it.
// Cheers PearPC!
//
// *********************************************************************************

/*
* PearPC
* ppc_mmu.cc
*
* Copyright (C) 2003, 2004 Sebastian Biallas (sb@biallas.net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// *********************************************************************************
// Warning: Test Area
//
// This code is for TESTING and it works in interpreter mode ONLY. Some games (like
// COD iirc) work thanks to this basic TLB emulation.
// It is just a small hack and we have never spend enough time to finalize it.
// Cheers PearPC!
//
// *********************************************************************************

/*
* PearPC
* ppc_mmu.cc
*
* Copyright (C) 2003, 2004 Sebastian Biallas (sb@biallas.net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#define PPC_EXC_DSISR_PAGE (1 << 30)
#define PPC_EXC_DSISR_PROT (1 << 27)
@@ -433,8 +433,9 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db)
else
unniceSize /= numUnNice;

INFO_LOG(SYMBOLS, "Functions analyzed. %i leafs, %i nice, %i unnice."
"%i timer, %i rfi. %i are branchless leafs.",
INFO_LOG(SYMBOLS,
"Functions analyzed. %i leafs, %i nice, %i unnice."
"%i timer, %i rfi. %i are branchless leafs.",
numLeafs, numNice, numUnNice, numTimer, numRFI, numStraightLeaf);
INFO_LOG(SYMBOLS, "Average size: %i (leaf), %i (nice), %i(unnice)", leafSize, niceSize,
unniceSize);
@@ -798,8 +799,9 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, u32
// bcx with conditional branch
conditional_continue = true;
}
else if (inst.OPCD == 19 && inst.SUBOP10 == 16 && ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0 ||
(inst.BO & BO_DONT_CHECK_CONDITION) == 0))
else if (inst.OPCD == 19 && inst.SUBOP10 == 16 &&
((inst.BO & BO_DONT_DECREMENT_FLAG) == 0 ||
(inst.BO & BO_DONT_CHECK_CONDITION) == 0))
{
// bclrx with conditional branch
conditional_continue = true;
@@ -34,10 +34,22 @@ size_t m_numInstructions;
namespace PowerPC
{
const std::array<u64, 16> m_crTable = {{
PPCCRToInternal(0x0), PPCCRToInternal(0x1), PPCCRToInternal(0x2), PPCCRToInternal(0x3),
PPCCRToInternal(0x4), PPCCRToInternal(0x5), PPCCRToInternal(0x6), PPCCRToInternal(0x7),
PPCCRToInternal(0x8), PPCCRToInternal(0x9), PPCCRToInternal(0xA), PPCCRToInternal(0xB),
PPCCRToInternal(0xC), PPCCRToInternal(0xD), PPCCRToInternal(0xE), PPCCRToInternal(0xF),
PPCCRToInternal(0x0),
PPCCRToInternal(0x1),
PPCCRToInternal(0x2),
PPCCRToInternal(0x3),
PPCCRToInternal(0x4),
PPCCRToInternal(0x5),
PPCCRToInternal(0x6),
PPCCRToInternal(0x7),
PPCCRToInternal(0x8),
PPCCRToInternal(0x9),
PPCCRToInternal(0xA),
PPCCRToInternal(0xB),
PPCCRToInternal(0xC),
PPCCRToInternal(0xD),
PPCCRToInternal(0xE),
PPCCRToInternal(0xF),
}};
} // namespace PowerPC

@@ -184,7 +184,8 @@ static void InitializeCPUCore(int cpu_core)
const std::vector<CPUCore>& AvailableCPUCores()
{
static const std::vector<CPUCore> cpu_cores = {
CORE_INTERPRETER, CORE_CACHEDINTERPRETER,
CORE_INTERPRETER,
CORE_CACHEDINTERPRETER,
#ifdef _M_X86_64
CORE_JIT64,
#elif defined(_M_ARM_64)
@@ -575,8 +575,8 @@ class DiscSystemUpdater final : public SystemUpdater
{
public:
DiscSystemUpdater(UpdateCallback update_callback, const std::string& image_path)
: m_update_callback{std::move(update_callback)},
m_volume{DiscIO::CreateVolumeFromFilename(image_path)}
: m_update_callback{std::move(update_callback)}, m_volume{DiscIO::CreateVolumeFromFilename(
image_path)}
{
}
UpdateResult DoDiscUpdate();
@@ -731,12 +731,13 @@ void DirectoryBlobPartition::WriteDirectory(const File::FSTEntry& parent_entry,
std::vector<File::FSTEntry> sorted_entries = parent_entry.children;

// Sort for determinism
std::sort(sorted_entries.begin(), sorted_entries.end(), [](const File::FSTEntry& one,
const File::FSTEntry& two) {
const std::string one_upper = ASCIIToUppercase(one.virtualName);
const std::string two_upper = ASCIIToUppercase(two.virtualName);
return one_upper == two_upper ? one.virtualName < two.virtualName : one_upper < two_upper;
});
std::sort(sorted_entries.begin(), sorted_entries.end(),
[](const File::FSTEntry& one, const File::FSTEntry& two) {
const std::string one_upper = ASCIIToUppercase(one.virtualName);
const std::string two_upper = ASCIIToUppercase(two.virtualName);
return one_upper == two_upper ? one.virtualName < two.virtualName :
one_upper < two_upper;
});

for (const File::FSTEntry& entry : sorted_entries)
{
@@ -52,6 +52,7 @@ class DiscContent
bool operator>(const DiscContent& other) const { return other < *this; }
bool operator<=(const DiscContent& other) const { return !(*this < other); }
bool operator>=(const DiscContent& other) const { return !(*this > other); }

private:
u64 m_offset;
u64 m_size = 0;
@@ -94,6 +95,7 @@ class DirectoryBlobPartition
const std::string& GetRootDirectory() const { return m_root_directory; }
const std::vector<u8>& GetHeader() const { return m_disc_header; }
const DiscContentContainer& GetContents() const { return m_contents; }

private:
void SetDiscHeaderAndDiscType(std::optional<bool> is_wii);
void SetBI2();
@@ -50,8 +50,9 @@ u64 ReadFile(const Volume& volume, const Partition& partition, const FileInfo* f

const u64 read_length = std::min(max_buffer_size, file_info->GetSize() - offset_in_file);

DEBUG_LOG(DISCIO, "Reading %" PRIx64 " bytes at %" PRIx64 " from file %s. Offset: %" PRIx64
" Size: %" PRIx32,
DEBUG_LOG(DISCIO,
"Reading %" PRIx64 " bytes at %" PRIx64 " from file %s. Offset: %" PRIx64
" Size: %" PRIx32,
read_length, offset_in_file, file_info->GetPath().c_str(), file_info->GetOffset(),
file_info->GetSize());

@@ -26,6 +26,7 @@ class DriveReader : public SectorReader
BlobType GetBlobType() const override { return BlobType::DRIVE; }
u64 GetDataSize() const override { return m_size; }
u64 GetRawSize() const override { return m_size; }

private:
DriveReader(const std::string& drive);
bool GetBlock(u64 block_num, u8* out_ptr) override;
@@ -65,6 +65,7 @@ class FileInfo
// pointers, but will not invalidate copies of the iterator or file info object.
const FileInfo& operator*() const { return *m_file_info.get(); }
const FileInfo* operator->() const { return m_file_info.get(); }

private:
std::unique_ptr<FileInfo> m_file_info;
};
@@ -67,6 +67,7 @@ class VolumeWii : public Volume

protected:
u32 GetOffsetShift() const override { return 2; }

private:
struct PartitionDetails
{
@@ -109,7 +109,9 @@ void GeneralWidget::CreateWidgets()
auto* shader_compilation_layout = new QGridLayout();

const std::array<const char*, 4> modes = {{
"Synchronous", "Synchronous (Ubershaders)", "Asynchronous (Ubershaders)",
"Synchronous",
"Synchronous (Ubershaders)",
"Asynchronous (Ubershaders)",
"Asynchronous (Skip Drawing)",
}};
for (size_t i = 0; i < modes.size(); i++)
@@ -198,7 +198,8 @@ void IOWindow::OnDetectButtonPressed()
releaseMouse();
releaseKeyboard();
removeEventFilter(BlockUserInputFilter::Instance());
}).detach();
})
.detach();
}

void IOWindow::OnRangeChanged(int value)
@@ -155,9 +155,10 @@ void BreakpointWidget::Update()

if (mbp.is_ranged)
{
m_table->setItem(i, 3, create_item(QStringLiteral("%1 - %2")
.arg(mbp.start_address, 8, 16, QLatin1Char('0'))
.arg(mbp.end_address, 8, 16, QLatin1Char('0'))));
m_table->setItem(i, 3,
create_item(QStringLiteral("%1 - %2")
.arg(mbp.start_address, 8, 16, QLatin1Char('0'))
.arg(mbp.end_address, 8, 16, QLatin1Char('0'))));
}
else
{
@@ -98,13 +98,14 @@ void RegisterColumn::Update()
switch (m_display)
{
case RegisterDisplay::Hex:
text = QStringLiteral("%1").arg(
m_value, (m_type == RegisterType::ibat || m_type == RegisterType::dbat ||
m_type == RegisterType::fpr || m_type == RegisterType::tb ?
sizeof(u64) :
sizeof(u32)) *
2,
16, QLatin1Char('0'));
text = QStringLiteral("%1").arg(m_value,
(m_type == RegisterType::ibat || m_type == RegisterType::dbat ||
m_type == RegisterType::fpr ||
m_type == RegisterType::tb ?
sizeof(u64) :
sizeof(u32)) *
2,
16, QLatin1Char('0'));
break;
case RegisterDisplay::SInt32:
text = QString::number(static_cast<qint32>(m_value));
@@ -247,11 +247,11 @@ void GCMemcardManager::SetSlotFile(int slot, QString path)

void GCMemcardManager::SetSlotFileInteractive(int slot)
{
QString path =
QFileDialog::getOpenFileName(this, slot == 0 ? tr("Set memory card file for Slot A") :
tr("Set memory card file for Slot B"),
QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)),
tr("GameCube Memory Cards (*.raw *.gcp)"));
QString path = QFileDialog::getOpenFileName(
this,
slot == 0 ? tr("Set memory card file for Slot A") : tr("Set memory card file for Slot B"),
QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)),
tr("GameCube Memory Cards (*.raw *.gcp)"));
if (!path.isEmpty())
m_slot_file_edit[slot]->setText(path);
}
@@ -291,8 +291,9 @@ void GameList::CompressISO()
}

QString dst_path = QFileDialog::getSaveFileName(
this, compressed ? tr("Select where you want to save the decompressed image") :
tr("Select where you want to save the compressed image"),
this,
compressed ? tr("Select where you want to save the decompressed image") :
tr("Select where you want to save the compressed image"),
QFileInfo(QString::fromStdString(GetSelectedGame()->GetFilePath()))
.dir()
.absoluteFilePath(QString::fromStdString(file->GetGameID()))
@@ -180,9 +180,10 @@ void GameCubePane::OnConfigPressed(int slot)

if (!mc.IsValid())
{
QMessageBox::critical(this, tr("Error"), tr("Cannot use that file as a memory card.\n%1\n"
"is not a valid GameCube memory card file")
.arg(filename));
QMessageBox::critical(this, tr("Error"),
tr("Cannot use that file as a memory card.\n%1\n"
"is not a valid GameCube memory card file")
.arg(filename));

return;
}
@@ -19,6 +19,7 @@ class ARCodeAddEdit final : public wxDialog
long style = wxDEFAULT_DIALOG_STYLE);

const ActionReplay::ARCode& GetCode() const { return m_code; }

private:
void CreateGUI();
void SaveCheatData(wxCommandEvent& event);
@@ -30,6 +30,7 @@ class CodeConfigPanel : public wxPanel
void LoadCodes(const IniFile& globalIni, const IniFile& localIni, const std::string& gameid = "",
bool checkRunning = false);
const std::vector<GeckoCode>& GetCodes() const { return m_gcodes; }

protected:
void UpdateInfoBox(wxCommandEvent&);
void ToggleCode(wxCommandEvent& evt);
@@ -46,15 +46,16 @@ void AdvancedConfigPane::InitializeGUI()
m_custom_rtc_time_picker = new wxTimePickerCtrl(this, wxID_ANY);

wxStaticText* const clock_override_description =
new wxStaticText(this, wxID_ANY, _("Adjusts the emulated CPU's clock rate.\n\n"
"Higher values may make variable-framerate games run "
"at a higher framerate, at the expense of performance. "
"Lower values may activate a game's internal "
"frameskip, potentially improving performance.\n\n"
"WARNING: Changing this from the default (100%) "
"can and will break games and cause glitches. "
"Do so at your own risk. Please do not report "
"bugs that occur with a non-default clock."));
new wxStaticText(this, wxID_ANY,
_("Adjusts the emulated CPU's clock rate.\n\n"
"Higher values may make variable-framerate games run "
"at a higher framerate, at the expense of performance. "
"Lower values may activate a game's internal "
"frameskip, potentially improving performance.\n\n"
"WARNING: Changing this from the default (100%) "
"can and will break games and cause glitches. "
"Do so at your own risk. Please do not report "
"bugs that occur with a non-default clock."));

wxStaticText* const custom_rtc_description = new wxStaticText(
this, wxID_ANY,
@@ -82,7 +82,8 @@ void GameCubeConfigPane::InitializeGUI()
// Device settings
// EXI Devices
wxStaticText* GCEXIDeviceText[3] = {
new wxStaticText(this, wxID_ANY, _("Slot A")), new wxStaticText(this, wxID_ANY, _("Slot B")),
new wxStaticText(this, wxID_ANY, _("Slot A")),
new wxStaticText(this, wxID_ANY, _("Slot B")),
new wxStaticText(this, wxID_ANY, "SP1"),
};

@@ -354,9 +354,9 @@ wxSizer* ControllerConfigDiag::CreateEmulatedBTConfigSizer()
wxDLG_UNIT(this, wxSize(60, -1)));
m_refresh_wm_button->Bind(wxEVT_BUTTON, &ControllerConfigDiag::OnWiimoteRefreshButton, this);

m_unsupported_bt_text =
new wxStaticText(this, wxID_ANY, _("A supported Bluetooth device could not be found,\n"
"so you must connect Wii Remotes manually."));
m_unsupported_bt_text = new wxStaticText(this, wxID_ANY,
_("A supported Bluetooth device could not be found,\n"
"so you must connect Wii Remotes manually."));
m_unsupported_bt_text->Show(!WiimoteReal::g_wiimote_scanner.IsReady());

// Balance Board
@@ -481,8 +481,9 @@ void ControllerConfigDiag::OnGameCubeConfigButton(wxCommandEvent& event)
else if (device_type == SerialInterface::SIDEVICE_WIIU_ADAPTER)
{
GCAdapterConfigDiag config_diag(
this, wxString::Format(_("Wii U GameCube Controller Adapter Configuration Port %i"),
port_num + 1),
this,
wxString::Format(_("Wii U GameCube Controller Adapter Configuration Port %i"),
port_num + 1),
port_num);
config_diag.ShowModal();
}
@@ -38,6 +38,7 @@ class CCodeView : public wxControl
}

void SetPlain() { m_plain = true; }

private:
void OnPaint(wxPaintEvent& event);
void OnScrollWheel(wxMouseEvent& event);
@@ -319,19 +319,19 @@ wxString CRegTable::GetValue(int row, int col)
PowerPC::ppcState.spr[SPR_DBAT0L + row * 2]);

if (row < 8)
return wxString::Format("%016llx", (u64)PowerPC::ppcState.spr[SPR_IBAT0U + (row - 4) * 2]
<< 32 |
PowerPC::ppcState.spr[SPR_IBAT0L + (row - 4) * 2]);
return wxString::Format("%016llx",
(u64)PowerPC::ppcState.spr[SPR_IBAT0U + (row - 4) * 2] << 32 |
PowerPC::ppcState.spr[SPR_IBAT0L + (row - 4) * 2]);

if (row < 12)
return wxString::Format("%016llx", (u64)PowerPC::ppcState.spr[SPR_DBAT4U + (row - 12) * 2]
<< 32 |
PowerPC::ppcState.spr[SPR_DBAT4L + (row - 12) * 2]);
return wxString::Format("%016llx",
(u64)PowerPC::ppcState.spr[SPR_DBAT4U + (row - 12) * 2] << 32 |
PowerPC::ppcState.spr[SPR_DBAT4L + (row - 12) * 2]);

if (row < 16)
return wxString::Format("%016llx", (u64)PowerPC::ppcState.spr[SPR_IBAT4U + (row - 16) * 2]
<< 32 |
PowerPC::ppcState.spr[SPR_IBAT4L + (row - 16) * 2]);
return wxString::Format("%016llx",
(u64)PowerPC::ppcState.spr[SPR_IBAT4U + (row - 16) * 2] << 32 |
PowerPC::ppcState.spr[SPR_IBAT4L + (row - 16) * 2]);

if (row == 16)
return wxString::Format("%016" PRIx64, static_cast<u64>(PowerPC::ppcState.spr[SPR_TU])