diff --git a/game/overlord/jak3/pagemanager.cpp b/game/overlord/jak3/pagemanager.cpp index dc310dfc3cb..866bb34931d 100644 --- a/game/overlord/jak3/pagemanager.cpp +++ b/game/overlord/jak3/pagemanager.cpp @@ -36,6 +36,77 @@ CPageManager::CPage::CPage(u8* start, u8* end, int page_id) { m_nUnk2 = 0; } +int CPageManager::CPage::AddRef() { + int state, ret = -1; + + CpuSuspendIntr(&state); + + if (m_nAllocState == 1 && m_pPageList != nullptr) { + m_pPageList->m_nRefCount++; + m_nRefCount++; + ret = m_nRefCount; + } + + CpuResumeIntr(state); + + return ret; +} + +int CPageManager::CPage::ReleaseRef() { + int state, ret = -1; + + CpuSuspendIntr(&state); + + if (m_nAllocState == 1 && m_pPageList != nullptr) { + m_pPageList->m_nRefCount--; + m_nRefCount--; + ret = m_nRefCount; + } + + CpuResumeIntr(state); + + return ret; +} + +int CPageManager::CPage::AddDmaRef() { + int state, ret = -1; + + CpuSuspendIntr(&state); + + if (m_nAllocState == 1 && m_pPageList != nullptr) { + m_pPageList->m_nDmaRefCount++; + m_nDmaRefCount++; + ret = m_nDmaRefCount; + } + + CpuResumeIntr(state); + + return ret; +} + +int CPageManager::CPage::ReleaseDmaRef() { + int state, ret = -1; + + CpuSuspendIntr(&state); + + if (m_nAllocState == 1 && m_pPageList != nullptr) { + m_pPageList->m_nDmaRefCount--; + m_nDmaRefCount--; + ret = m_nDmaRefCount; + } + + CpuResumeIntr(state); + + return ret; +} + +void CPageManager::CPage::FromPagesCopy(u8* pInPageData, u8* pDest, int nNumBytes) { + if (nNumBytes <= 0) { + return; + } + +} + void CPageManager::Initialize() { m_Cache.Initialize(); } diff --git a/game/overlord/jak3/pagemanager.h b/game/overlord/jak3/pagemanager.h index df49b57b04b..757bb01be18 100644 --- a/game/overlord/jak3/pagemanager.h +++ b/game/overlord/jak3/pagemanager.h @@ -24,18 +24,25 @@ class CPageManager { CPageList* m_pPageList; u8* m_pData; u8* m_pEnd; // maybe - u32 m_nRefCount; - u32 m_nDmaRefCount; + int m_nRefCount; + int m_nDmaRefCount; int m_nPageID; int m_nAllocState; int m_nUnk2; }; class CPageList { + friend class CPage; + + public: int AddActivePages(int); int CancelActivePages(); CPage* StepActivePage(); void GarbageCollect(); + + private: + int m_nRefCount; + int m_nDmaRefCount; }; void Initialize();