diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index f84fec00..8b4cd82f 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -170,6 +170,9 @@ rvl/CX/cx.c: nw4r/ut/ut_list.cpp: .text start:0x8042A530 end:0x8042A850 +nw4r/ut/ut_LinkList.cpp: + .text start:0x8042A850 end:0x8042A9E0 + nw4r/db/db_directPrint.cpp: .text start:0x804342A0 end:0x80434E9C .rodata start:0x804F5D28 end:0x804F5FDC diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 195dcdc3..39171bc6 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -23934,11 +23934,11 @@ List_Remove__Q24nw4r2utFPQ34nw4r2ut4ListPv = .text:0x8042A750; // type:function List_GetNext__Q24nw4r2utFPCQ34nw4r2ut4ListPCv = .text:0x8042A7C0; // type:function size:0x20 List_GetPrev__Q24nw4r2utFPCQ34nw4r2ut4ListPCv = .text:0x8042A7E0; // type:function size:0x1C List_GetNth__Q24nw4r2utFPCQ34nw4r2ut4ListUs = .text:0x8042A800; // type:function size:0x50 -fn_8042A850 = .text:0x8042A850; // type:function size:0x84 -fn_8042A8E0 = .text:0x8042A8E0; // type:function size:0x48 -fn_8042A930 = .text:0x8042A930; // type:function size:0x44 -fn_8042A980 = .text:0x8042A980; // type:function size:0x2C -fn_8042A9B0 = .text:0x8042A9B0; // type:function size:0x30 +__dt__Q44nw4r2ut6detail12LinkListImplFv = .text:0x8042A850; // type:function size:0x84 +Erase__Q44nw4r2ut6detail12LinkListImplFQ54nw4r2ut6detail12LinkListImpl8Iterator = .text:0x8042A8E0; // type:function size:0x48 +Clear__Q44nw4r2ut6detail12LinkListImplFv = .text:0x8042A930; // type:function size:0x44 +Insert__Q44nw4r2ut6detail12LinkListImplFQ54nw4r2ut6detail12LinkListImpl8IteratorPQ34nw4r2ut12LinkListNode = .text:0x8042A980; // type:function size:0x2C +Erase__Q44nw4r2ut6detail12LinkListImplFPQ34nw4r2ut12LinkListNode = .text:0x8042A9B0; // type:function size:0x30 fn_8042A9E0 = .text:0x8042A9E0; // type:function size:0x74 fn_8042AA60 = .text:0x8042AA60; // type:function size:0x78 fn_8042AAE0 = .text:0x8042AAE0; // type:function size:0x1C diff --git a/configure.py b/configure.py index c3cea48b..075220c3 100644 --- a/configure.py +++ b/configure.py @@ -318,6 +318,7 @@ config.libs = [ "ut", [ Object(Matching, "nw4r/ut/ut_list.cpp"), + Object(Matching, "nw4r/ut/ut_LinkList.cpp"), ], ), # EGG diff --git a/src/nw4r/ut/ut_LinkList.cpp b/src/nw4r/ut/ut_LinkList.cpp new file mode 100644 index 00000000..5b0d8ee1 --- /dev/null +++ b/src/nw4r/ut/ut_LinkList.cpp @@ -0,0 +1,76 @@ +#include + +namespace nw4r { +namespace ut { +namespace detail { + +/* 8042a850 */ +LinkListImpl::~LinkListImpl() { + Clear(); +} + +/* 8042a8e0 */ +LinkListImpl::Iterator LinkListImpl::Erase(LinkListImpl::Iterator it) { + Iterator copy(it); + return Erase(it, ++copy); +} + +/* 8042a930 */ +void LinkListImpl::Clear() { + Erase(GetBeginIter(), GetEndIter()); +} + +/* 8042a980 */ +LinkListImpl::Iterator LinkListImpl::Insert(Iterator it, LinkListNode *p) { + LinkListNode *next = it.mNode; + LinkListNode *prev = next->mPrev; + + // prev <- p -> next + p->mNext = next; + p->mPrev = prev; + // prev <-> p <-> next + next->mPrev = p; + prev->mNext = p; + + mSize++; + + return Iterator(p); +} + +/* 8042a9b0 */ +LinkListImpl::Iterator LinkListImpl::Erase(LinkListNode *p) { + LinkListNode *next = p->mNext; + LinkListNode *prev = p->mPrev; + + // Remove connections to node + next->mPrev = prev; + prev->mNext = next; + + mSize--; + + // Isolate node + p->mNext = NULL; + p->mPrev = NULL; + + return Iterator(next); +} + +/* Not in SS */ +LinkListImpl::Iterator LinkListImpl::Erase(Iterator begin, Iterator end) { + LinkListNode *pCur = begin.mNode; + LinkListNode *pEnd = end.mNode; + + while (pCur != pEnd) { + // Preserve next node before erasing pointers + LinkListNode *pNext = pCur->mNext; + // Erase current node + Erase(pCur); + pCur = pNext; + } + + return Iterator(pEnd); +} + +} // namespace detail +} // namespace ut +} // namespace nw4r