distribution/packages/emulators/libretro/duckstation-lr/patches/001-fix-gcc12-compile.patch
2023-10-24 13:59:09 +00:00

56 lines
2.2 KiB
Diff

# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2022-present - The JELOS Project (https://github.com/JustEnoughLinuxOS)
diff --git a/src/core/cpu_core.h b/src/core/cpu_core.h
index c9199153..5d82b5c0 100644
--- a/src/core/cpu_core.h
+++ b/src/core/cpu_core.h
@@ -84,6 +84,8 @@ struct State
std::array<u8, DCACHE_SIZE> dcache = {};
std::array<u32, ICACHE_LINES> icache_tags = {};
std::array<u8, ICACHE_SIZE> icache_data = {};
+
+ static constexpr u32 GTERegisterOffset(u32 index) { return offsetof(State, gte_regs.r32) + (sizeof(u32) * index); }
};
extern State g_state;
diff --git a/src/core/cpu_recompiler_code_generator.cpp b/src/core/cpu_recompiler_code_generator.cpp
index 68492b03..e550844e 100644
--- a/src/core/cpu_recompiler_code_generator.cpp
+++ b/src/core/cpu_recompiler_code_generator.cpp
@@ -2377,7 +2377,7 @@ Value CodeGenerator::DoGTERegisterRead(u32 index)
default:
{
- EmitLoadCPUStructField(value.host_reg, RegSize_32, offsetof(State, gte_regs.r32[index]));
+ EmitLoadCPUStructField(value.host_reg, RegSize_32, State::GTERegisterOffset(index));
}
break;
}
@@ -2406,7 +2406,7 @@ void CodeGenerator::DoGTERegisterWrite(u32 index, const Value& value)
{
// sign-extend z component of vector registers
Value temp = ConvertValueSize(value.ViewAsSize(RegSize_16), RegSize_32, true);
- EmitStoreCPUStructField(offsetof(State, gte_regs.r32[index]), temp);
+ EmitStoreCPUStructField(State::GTERegisterOffset(index), temp);
return;
}
break;
@@ -2419,7 +2419,7 @@ void CodeGenerator::DoGTERegisterWrite(u32 index, const Value& value)
{
// zero-extend unsigned values
Value temp = ConvertValueSize(value.ViewAsSize(RegSize_16), RegSize_32, false);
- EmitStoreCPUStructField(offsetof(State, gte_regs.r32[index]), temp);
+ EmitStoreCPUStructField(State::GTERegisterOffset(index), temp);
return;
}
break;
@@ -2461,7 +2461,7 @@ void CodeGenerator::DoGTERegisterWrite(u32 index, const Value& value)
default:
{
// written as-is, 2x16 or 1x32 bits
- EmitStoreCPUStructField(offsetof(State, gte_regs.r32[index]), value);
+ EmitStoreCPUStructField(State::GTERegisterOffset(index), value);
return;
}
}