Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziemas committed May 2, 2024
1 parent b5b45b2 commit 78917bd
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
71 changes: 71 additions & 0 deletions game/overlord/jak3/pagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
11 changes: 9 additions & 2 deletions game/overlord/jak3/pagemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 78917bd

Please sign in to comment.