support args >= 4 via the stack in _arg template (#138)
Some checks failed
validate / ubuntu (arm64, Debug) (push) Has been cancelled
validate / ubuntu (arm64, Release) (push) Has been cancelled
validate / ubuntu (x64, Debug) (push) Has been cancelled
validate / ubuntu (x64, Release) (push) Has been cancelled
validate / windows (x64, Debug) (push) Has been cancelled
validate / windows (x64, Release) (push) Has been cancelled
validate / macos (arm64, Debug) (push) Has been cancelled
validate / macos (arm64, Release) (push) Has been cancelled
validate / macos (x64, Debug) (push) Has been cancelled
validate / macos (x64, Release) (push) Has been cancelled

* support args >= 4 via the stack

* fix offset
This commit is contained in:
Garrett Smith 2026-05-26 21:53:50 -07:00 committed by GitHub
parent 8cd9d14817
commit ae1ffbb909
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,8 +7,7 @@
#include <ultramodern/ultra64.h>
template<int index, typename T>
T _arg(uint8_t* rdram, recomp_context* ctx) {
static_assert(index < 4, "Only args 0 through 3 supported");
T _arg(uint8_t* rdram, recomp_context* ctx) requires(index < 4) {
gpr raw_arg = (&ctx->r4)[index];
if constexpr (std::is_same_v<T, float>) {
if constexpr (index < 2) {
@ -38,6 +37,25 @@ T _arg(uint8_t* rdram, recomp_context* ctx) {
}
}
template<int index, typename T>
T _arg(uint8_t* rdram, recomp_context* ctx) requires(index >= 4) {
const auto raw_arg = MEM_W(index * 4, ctx->r29);
if constexpr (std::is_pointer_v<T>) {
static_assert (!std::is_pointer_v<std::remove_pointer_t<T>>, "Double pointers not supported");
return TO_PTR(std::remove_pointer_t<T>, raw_arg);
}
else if constexpr (std::is_integral_v<T>) {
static_assert(sizeof(T) <= 4, "64-bit args not supported");
return static_cast<T>(raw_arg);
}
else {
// static_assert in else workaround
[] <bool flag = false>() {
static_assert(flag, "Unsupported type");
}();
}
}
inline float _arg_float_a1(uint8_t* rdram, recomp_context* ctx) {
(void)rdram;
union {