mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-18 19:37:00 +00:00
Add all the files
This commit is contained in:
parent
e3db07a16a
commit
d60742f52b
1445 changed files with 430238 additions and 0 deletions
41
src/Common/StackAllocator.h
Normal file
41
src/Common/StackAllocator.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#pragma once
|
||||
|
||||
template<typename T, int count = 1>
|
||||
class StackAllocator
|
||||
{
|
||||
public:
|
||||
StackAllocator()
|
||||
: StackAllocator(1)
|
||||
{}
|
||||
|
||||
explicit StackAllocator(const uint32 items)
|
||||
{
|
||||
m_modified_size = count * sizeof(T) * items + kStaticMemOffset * 2;
|
||||
|
||||
auto tmp = PPCInterpreterGetStackPointer();
|
||||
m_ptr = (T*)(PPCInterpreterGetAndModifyStackPointer(m_modified_size) + kStaticMemOffset);
|
||||
}
|
||||
|
||||
~StackAllocator()
|
||||
{
|
||||
PPCInterpreterModifyStackPointer(-m_modified_size);
|
||||
}
|
||||
|
||||
T* operator->() const
|
||||
{
|
||||
return GetPointer();
|
||||
}
|
||||
|
||||
T* GetPointer() const { return m_ptr; }
|
||||
uint32 GetMPTR() const { return MEMPTR<T>(m_ptr).GetMPTR(); }
|
||||
uint32 GetMPTRBE() const { return MEMPTR<T>(m_ptr).GetMPTRBE(); }
|
||||
|
||||
operator T*() const { return GetPointer(); }
|
||||
explicit operator uint32() const { return GetMPTR(); }
|
||||
|
||||
private:
|
||||
static const uint32 kStaticMemOffset = 64;
|
||||
|
||||
T* m_ptr;
|
||||
sint32 m_modified_size;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue