mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-26 02:54:17 +01:00
nn_save: Refactor and modernize code
This commit is contained in:
parent
1ee9d5c78c
commit
da8fd5b7c7
@ -90,7 +90,7 @@ uint8* PPCInterpreterGetStackPointer()
|
|||||||
return memory_getPointerFromVirtualOffset(PPCInterpreter_getCurrentInstance()->gpr[1]);
|
return memory_getPointerFromVirtualOffset(PPCInterpreter_getCurrentInstance()->gpr[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8* PPCInterpreterGetAndModifyStackPointer(sint32 offset)
|
uint8* PPCInterpreter_PushAndReturnStackPointer(sint32 offset)
|
||||||
{
|
{
|
||||||
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
|
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
|
||||||
uint8* result = memory_getPointerFromVirtualOffset(hCPU->gpr[1] - offset);
|
uint8* result = memory_getPointerFromVirtualOffset(hCPU->gpr[1] - offset);
|
||||||
|
@ -213,7 +213,7 @@ void PPCTimer_start();
|
|||||||
// core info and control
|
// core info and control
|
||||||
extern uint32 ppcThreadQuantum;
|
extern uint32 ppcThreadQuantum;
|
||||||
|
|
||||||
uint8* PPCInterpreterGetAndModifyStackPointer(sint32 offset);
|
uint8* PPCInterpreter_PushAndReturnStackPointer(sint32 offset);
|
||||||
uint8* PPCInterpreterGetStackPointer();
|
uint8* PPCInterpreterGetStackPointer();
|
||||||
void PPCInterpreterModifyStackPointer(sint32 offset);
|
void PPCInterpreterModifyStackPointer(sint32 offset);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@ using PAddr = uint32; // physical address
|
|||||||
|
|
||||||
extern uint8* memory_base;
|
extern uint8* memory_base;
|
||||||
extern uint8* PPCInterpreterGetStackPointer();
|
extern uint8* PPCInterpreterGetStackPointer();
|
||||||
extern uint8* PPCInterpreterGetAndModifyStackPointer(sint32 offset);
|
extern uint8* PPCInterpreter_PushAndReturnStackPointer(sint32 offset);
|
||||||
extern void PPCInterpreterModifyStackPointer(sint32 offset);
|
extern void PPCInterpreterModifyStackPointer(sint32 offset);
|
||||||
|
|
||||||
class MEMPTRBase {};
|
class MEMPTRBase {};
|
||||||
|
@ -10,14 +10,16 @@ public:
|
|||||||
|
|
||||||
explicit StackAllocator(const uint32 items)
|
explicit StackAllocator(const uint32 items)
|
||||||
{
|
{
|
||||||
|
m_items = items;
|
||||||
m_modified_size = count * sizeof(T) * items + kStaticMemOffset * 2;
|
m_modified_size = count * sizeof(T) * items + kStaticMemOffset * 2;
|
||||||
|
m_modified_size = (m_modified_size/8+7) * 8; // pad to 8 bytes
|
||||||
auto tmp = PPCInterpreterGetStackPointer();
|
m_ptr = new(PPCInterpreter_PushAndReturnStackPointer(m_modified_size) + kStaticMemOffset) T[count * items]();
|
||||||
m_ptr = (T*)(PPCInterpreterGetAndModifyStackPointer(m_modified_size) + kStaticMemOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~StackAllocator()
|
~StackAllocator()
|
||||||
{
|
{
|
||||||
|
for (size_t i = 0; i < count * m_items; ++i)
|
||||||
|
m_ptr[i].~T();
|
||||||
PPCInterpreterModifyStackPointer(-m_modified_size);
|
PPCInterpreterModifyStackPointer(-m_modified_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,4 +66,5 @@ private:
|
|||||||
|
|
||||||
T* m_ptr;
|
T* m_ptr;
|
||||||
sint32 m_modified_size;
|
sint32 m_modified_size;
|
||||||
|
uint32 m_items;
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user