mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-13 02:08:31 +12:00
Code clean up + replace some wstring instances with utf8 (#640)
This commit is contained in:
parent
ca79a6aa0d
commit
f3ff919be2
41 changed files with 163 additions and 641 deletions
|
@ -559,19 +559,19 @@ LatteCMDPtr LatteCP_itLoadReg(LatteCMDPtr cmd, uint32 nWords, uint32 regBase)
|
|||
MPTR physAddressRegArea = LatteReadCMD();
|
||||
uint32 waitForIdle = LatteReadCMD();
|
||||
uint32 loadEntries = (nWords - 2) / 2;
|
||||
uint32 regIndex = 0;
|
||||
uint32 regShadowMemAddr = physAddressRegArea;
|
||||
for (uint32 i = 0; i < loadEntries; i++)
|
||||
{
|
||||
uint32 regOffset = LatteReadCMD();
|
||||
uint32 regCount = LatteReadCMD();
|
||||
cemu_assert_debug(regCount != 0);
|
||||
uint32 regAddr = regBase + regOffset;
|
||||
for (uint32 f = 0; f < regCount; f++)
|
||||
{
|
||||
uint32 regAddr = regBase + regOffset + f;
|
||||
uint32 regShadowMemAddr = physAddressRegArea + regIndex * 4;
|
||||
LatteGPUState.contextRegisterShadowAddr[regAddr] = regShadowMemAddr;
|
||||
LatteGPUState.contextRegister[regAddr] = memory_readU32Direct(regShadowMemAddr);
|
||||
regIndex++;
|
||||
LatteGPUState.contextRegister[regAddr] = memory_read<uint32>(regShadowMemAddr);
|
||||
regAddr++;
|
||||
regShadowMemAddr += 4;
|
||||
}
|
||||
}
|
||||
return cmd;
|
||||
|
@ -716,7 +716,7 @@ LatteCMDPtr LatteCP_itHLESampleTimer(LatteCMDPtr cmd, uint32 nWords)
|
|||
{
|
||||
cemu_assert_debug(nWords == 1);
|
||||
MPTR timerMPTR = (MPTR)LatteReadCMD();
|
||||
memory_writeU64Slow(timerMPTR, coreinit::coreinit_getTimerTick());
|
||||
memory_writeU64(timerMPTR, coreinit::coreinit_getTimerTick());
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ void LatteShaderCache_load()
|
|||
if(!fc_shaderCacheGeneric)
|
||||
{
|
||||
// no shader cache available yet
|
||||
forceLog_printfW(L"Unable to open or create shader cache file \"%s\"", pathGeneric.c_str());
|
||||
cemuLog_log(LogType::Force, "Unable to open or create shader cache file \"{}\"", _pathToUtf8(pathGeneric));
|
||||
LatteShaderCache_finish();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -695,7 +695,7 @@ void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, sint32 texture
|
|||
if (textureLoader.dump)
|
||||
{
|
||||
wchar_t path[1024];
|
||||
swprintf(path, 1024, L"dump\\textures\\%08x_fmt%04x_slice%d_mip%02d_%dx%d_tm%02d.tga", physImagePtr, (uint32)tex->format, sliceIndex, mipIndex, tex->width, tex->height, tileMode);
|
||||
swprintf(path, 1024, L"dump/textures/%08x_fmt%04x_slice%d_mip%02d_%dx%d_tm%02d.tga", physImagePtr, (uint32)tex->format, sliceIndex, mipIndex, tex->width, tex->height, tileMode);
|
||||
tga_write_rgba(path, textureLoader.width, textureLoader.height, textureLoader.dumpRGBA);
|
||||
free(textureLoader.dumpRGBA);
|
||||
}
|
||||
|
|
|
@ -293,11 +293,6 @@ uint8* memory_getPointerFromVirtualOffsetAllowNull(uint32 virtualOffset)
|
|||
return memory_getPointerFromVirtualOffset(virtualOffset);
|
||||
}
|
||||
|
||||
void memory_writeU32Direct(uint32 address, uint32 v)
|
||||
{
|
||||
*(uint32*)(memory_getPointerFromVirtualOffset(address)) = CPU_swapEndianU32(v);
|
||||
}
|
||||
|
||||
// write access
|
||||
void memory_writeDouble(uint32 address, double vf)
|
||||
{
|
||||
|
@ -320,12 +315,6 @@ void memory_writeU32(uint32 address, uint32 v)
|
|||
*(uint32*)(memory_getPointerFromVirtualOffset(address)) = CPU_swapEndianU32(v);
|
||||
}
|
||||
|
||||
void memory_writeU64Slow(uint32 address, uint64 v)
|
||||
{
|
||||
memory_writeU32(address+0, (v>>32)&0xFFFFFFFF);
|
||||
memory_writeU32(address+4, (v)&0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void memory_writeU64(uint32 address, uint64 v)
|
||||
{
|
||||
*(uint64*)(memory_getPointerFromVirtualOffset(address)) = CPU_swapEndianU64(v);
|
||||
|
@ -372,12 +361,6 @@ uint32 memory_readU32(uint32 address)
|
|||
return CPU_swapEndianU32(v);
|
||||
}
|
||||
|
||||
uint32 memory_readU32Direct(uint32 address)
|
||||
{
|
||||
uint32 v = *(uint32*)(memory_getPointerFromVirtualOffset(address));
|
||||
return CPU_swapEndianU32(v);
|
||||
}
|
||||
|
||||
uint16 memory_readU16(uint32 address)
|
||||
{
|
||||
uint16 v = *(uint16*)(memory_getPointerFromVirtualOffset(address));
|
||||
|
|
|
@ -15,7 +15,7 @@ uint8* memory_getPointerFromPhysicalOffset(uint32 physicalOffset);
|
|||
uint32 memory_virtualToPhysical(uint32 virtualOffset);
|
||||
uint32 memory_physicalToVirtual(uint32 physicalOffset);
|
||||
|
||||
extern uint8* memory_base; // points to 0x00000000
|
||||
extern uint8* memory_base; // points to base of PowerPC address space
|
||||
|
||||
enum class MMU_MEM_AREA_ID
|
||||
{
|
||||
|
@ -171,33 +171,26 @@ bool memory_isAddressRangeAccessible(MPTR virtualAddress, uint32 size);
|
|||
#define MEMORY_SHAREDDATA_AREA_ADDR (0xF8000000)
|
||||
#define MEMORY_SHAREDDATA_AREA_SIZE (0x02000000) // 32MB
|
||||
|
||||
static uint16 CPU_swapEndianU16(uint16 v)
|
||||
{
|
||||
return (v>>8)|(v<<8);
|
||||
}
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
#define CPU_swapEndianU64(_v) _byteswap_uint64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) _byteswap_ulong((uint32)(_v))
|
||||
#define CPU_swapEndianU16(_v) _byteswap_ushort((uint16)(_v))
|
||||
#elif BOOST_OS_LINUX
|
||||
#define CPU_swapEndianU64(_v) bswap_64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) bswap_32((uint32)(_v))
|
||||
#define CPU_swapEndianU16(_v) bswap_16((uint16)(_v))
|
||||
#elif BOOST_OS_MACOS
|
||||
#define CPU_swapEndianU64(_v) OSSwapInt64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) OSSwapInt32((uint32)(_v))
|
||||
#define CPU_swapEndianU16(_v) OSSwapInt16((uint16)(_v))
|
||||
#endif
|
||||
|
||||
// direct memory access (no hardware interface access)
|
||||
void memory_writeU32Direct(uint32 address, uint32 v);
|
||||
uint32 memory_readU32Direct(uint32 address);
|
||||
|
||||
// memory access (includes hardware interface, slower)
|
||||
// C-style memory access, deprecated. Use memory_read<> and memory_write<> templates instead
|
||||
void memory_writeDouble(uint32 address, double vf);
|
||||
void memory_writeFloat(uint32 address, float vf);
|
||||
void memory_writeU32(uint32 address, uint32 v);
|
||||
void memory_writeU16(uint32 address, uint16 v);
|
||||
void memory_writeU8(uint32 address, uint8 v);
|
||||
void memory_writeU64Slow(uint32 address, uint64 v);
|
||||
void memory_writeU64(uint32 address, uint64 v);
|
||||
|
||||
double memory_readDouble(uint32 address);
|
||||
|
@ -210,43 +203,24 @@ uint8 memory_readU8(uint32 address);
|
|||
void memory_createDump();
|
||||
|
||||
template<size_t count>
|
||||
void memory_readBytes(uint32 address, std::array<uint8, count>& buffer)
|
||||
void memory_readBytes(VAddr address, std::array<uint8, count>& buffer)
|
||||
{
|
||||
memcpy(buffer.data(), memory_getPointerFromVirtualOffset(address), count);
|
||||
}
|
||||
|
||||
template <typename T> T memory_read(uint32 address)
|
||||
template <typename T> inline T memory_read(VAddr address)
|
||||
{
|
||||
if constexpr(std::is_floating_point<T>::value)
|
||||
{
|
||||
if constexpr(sizeof(T) == sizeof(float))
|
||||
return memory_readFloat(address);
|
||||
else
|
||||
return memory_readDouble(address);
|
||||
}
|
||||
else if(std::is_integral<T>::value)
|
||||
{
|
||||
if constexpr (sizeof(T) == sizeof(uint8))
|
||||
return (T)memory_readU8(address);
|
||||
else if constexpr (sizeof(T) == sizeof(uint16))
|
||||
return (T)memory_readU16(address);
|
||||
else if constexpr (sizeof(T) == sizeof(uint32))
|
||||
return (T)memory_readU32(address);
|
||||
else if constexpr (sizeof(T) == sizeof(uint64))
|
||||
return (T)memory_readU64(address);
|
||||
}
|
||||
return *(betype<T>*)(memory_base + address);
|
||||
}
|
||||
|
||||
debugBreakpoint();
|
||||
return {};
|
||||
template <typename T> inline void memory_write(VAddr address, T value)
|
||||
{
|
||||
*(betype<T>*)(memory_base + address) = value;
|
||||
}
|
||||
|
||||
// LLE implementation
|
||||
void memory_initPhysicalLayout();
|
||||
|
||||
// updated code
|
||||
using EAddr = uint32; // effective address
|
||||
using PAddr = uint32; // physical address
|
||||
|
||||
namespace MMU
|
||||
{
|
||||
using MMIOFuncWrite32 = void (*)(PAddr addr, uint32 value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue