mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-12 17:58:29 +12:00
Add all the files
This commit is contained in:
parent
e3db07a16a
commit
d60742f52b
1445 changed files with 430238 additions and 0 deletions
75
src/Cafe/HW/Espresso/PPCCallback.h
Normal file
75
src/Cafe/HW/Espresso/PPCCallback.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
#pragma once
|
||||
#include "PPCState.h"
|
||||
|
||||
struct PPCCoreCallbackData_t
|
||||
{
|
||||
sint32 gprCount = 0;
|
||||
sint32 floatCount = 0;
|
||||
};
|
||||
|
||||
// callback functions
|
||||
inline uint32 PPCCoreCallback(MPTR function, const PPCCoreCallbackData_t& data)
|
||||
{
|
||||
return PPCCore_executeCallbackInternal(function)->gpr[3];
|
||||
}
|
||||
|
||||
template <typename T, typename... TArgs>
|
||||
uint32 PPCCoreCallback(MPTR function, PPCCoreCallbackData_t& data, T currentArg, TArgs... args)
|
||||
{
|
||||
cemu_assert_debug(data.gprCount <= 8);
|
||||
cemu_assert_debug(data.floatCount <= 8);
|
||||
if constexpr (std::is_pointer_v<T>)
|
||||
{
|
||||
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = MEMPTR(currentArg).GetMPTR();
|
||||
data.gprCount++;
|
||||
}
|
||||
else if constexpr (std::is_base_of_v<MEMPTRBase, std::remove_reference_t<T>>)
|
||||
{
|
||||
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = currentArg.GetMPTR();
|
||||
data.gprCount++;
|
||||
}
|
||||
else if constexpr (std::is_reference_v<T>)
|
||||
{
|
||||
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = MEMPTR(¤tArg).GetMPTR();
|
||||
data.gprCount++;
|
||||
}
|
||||
else if constexpr(std::is_enum_v<T>)
|
||||
{
|
||||
using TEnum = typename std::underlying_type<T>::type;
|
||||
return PPCCoreCallback<TEnum>(function, data, (TEnum)currentArg, std::forward(args)...);
|
||||
}
|
||||
else if constexpr (std::is_floating_point_v<T>)
|
||||
{
|
||||
ppcInterpreterCurrentInstance->fpr[1 + data.floatCount].fpr = (double)currentArg;
|
||||
data.floatCount++;
|
||||
}
|
||||
else if constexpr (std::is_integral_v<T> && sizeof(T) == sizeof(uint64))
|
||||
{
|
||||
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = (uint32)(currentArg >> 32); // high
|
||||
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount + 1] = (uint32)currentArg; // low
|
||||
|
||||
data.gprCount += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = (uint32)currentArg;
|
||||
data.gprCount++;
|
||||
}
|
||||
|
||||
return PPCCoreCallback(function, data, args...);
|
||||
}
|
||||
|
||||
template <typename... TArgs>
|
||||
uint32 PPCCoreCallback(MPTR function, TArgs... args)
|
||||
{
|
||||
PPCCoreCallbackData_t data{};
|
||||
return PPCCoreCallback(function, data, std::forward<TArgs>(args)...);
|
||||
}
|
||||
|
||||
template <typename... TArgs>
|
||||
uint32 PPCCoreCallback(void* functionPtr, TArgs... args)
|
||||
{
|
||||
MEMPTR<void> _tmp{ functionPtr };
|
||||
PPCCoreCallbackData_t data{};
|
||||
return PPCCoreCallback(_tmp.GetMPTR(), data, std::forward<TArgs>(args)...);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue