mirror of
https://github.com/zeldaret/ss
synced 2026-06-19 07:37:01 -04:00
ut_list
This commit is contained in:
@@ -153,6 +153,9 @@ m/m_mtx.cpp:
|
||||
rvl/CX/cx.c:
|
||||
.text start:0x803CEE90 end:0x803D0B20
|
||||
|
||||
nw4r/ut/ut_list.cpp:
|
||||
.text start:0x8042A530 end:0x8042A850
|
||||
|
||||
nw4r/db/db_directPrint.cpp:
|
||||
.text start:0x804342A0 end:0x80434EA0
|
||||
.rodata start:0x804F5D28 end:0x804F5FE0
|
||||
|
||||
@@ -23926,14 +23926,14 @@ fn_8042A148 = .text:0x8042A148; // type:function size:0x124
|
||||
fn_8042A26C = .text:0x8042A26C; // type:function size:0x104
|
||||
fn_8042A370 = .text:0x8042A370; // type:function size:0xE0
|
||||
fn_8042A450 = .text:0x8042A450; // type:function size:0xE0
|
||||
fn_8042A530 = .text:0x8042A530; // type:function size:0x18
|
||||
fn_8042A550 = .text:0x8042A550; // type:function size:0x70
|
||||
fn_8042A5C0 = .text:0x8042A5C0; // type:function size:0x6C
|
||||
fn_8042A630 = .text:0x8042A630; // type:function size:0x120
|
||||
fn_8042A750 = .text:0x8042A750; // type:function size:0x6C
|
||||
fn_8042A7C0 = .text:0x8042A7C0; // type:function size:0x20
|
||||
fn_8042A7E0 = .text:0x8042A7E0; // type:function size:0x1C
|
||||
fn_8042A800 = .text:0x8042A800; // type:function size:0x50
|
||||
List_Init__Q24nw4r2utFPQ34nw4r2ut4ListUs = .text:0x8042A530; // type:function size:0x18
|
||||
List_Append__Q24nw4r2utFPQ34nw4r2ut4ListPv = .text:0x8042A550; // type:function size:0x70
|
||||
List_Prepend__Q24nw4r2utFPQ34nw4r2ut4ListPv = .text:0x8042A5C0; // type:function size:0x6C
|
||||
List_Insert__Q24nw4r2utFPQ34nw4r2ut4ListPvPv = .text:0x8042A630; // type:function size:0x120
|
||||
List_Remove__Q24nw4r2utFPQ34nw4r2ut4ListPv = .text:0x8042A750; // type:function size:0x6C
|
||||
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
|
||||
|
||||
@@ -310,6 +310,12 @@ config.libs = [
|
||||
Object(NonMatching, "nw4r/db/db_directPrint.cpp"),
|
||||
],
|
||||
),
|
||||
nw4rLib(
|
||||
"ut",
|
||||
[
|
||||
Object(Matching, "nw4r/ut/ut_list.cpp"),
|
||||
],
|
||||
),
|
||||
# EGG
|
||||
EGGLib(
|
||||
"core",
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
#include <nw4r/ut/ut_list.h>
|
||||
|
||||
namespace nw4r {
|
||||
namespace ut {
|
||||
|
||||
#define NODE_PTR(list, object) ((Node*)(((char*)object) + list->offset))
|
||||
|
||||
void* List_GetNth(const List* list, u16 n) {
|
||||
void *object;
|
||||
int c;
|
||||
|
||||
for (c = 0, object = nullptr; object = List_GetNext(list, object); c++) {
|
||||
if (n == c) {
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* List_GetPrev(const List* list, const void* object) {
|
||||
if (object == nullptr) {
|
||||
return list->last;
|
||||
} else {
|
||||
return NODE_PTR(list, object)->prev;
|
||||
}
|
||||
}
|
||||
|
||||
void* List_GetNext(const List* list, const void* object) {
|
||||
if (object == nullptr) {
|
||||
return list->first;
|
||||
} else {
|
||||
return NODE_PTR(list, object)->next;
|
||||
}
|
||||
}
|
||||
|
||||
void List_Remove(List* list, void* object) {
|
||||
Node *node = NODE_PTR(list, object);
|
||||
if (node->prev == nullptr) {
|
||||
list->first = node->next;
|
||||
} else {
|
||||
NODE_PTR(list, node->prev)->next = node->next;
|
||||
}
|
||||
|
||||
if (node->next == nullptr) {
|
||||
list->last = node->prev;
|
||||
} else {
|
||||
NODE_PTR(list, node->next)->prev = node->prev;
|
||||
}
|
||||
|
||||
node->prev = nullptr;
|
||||
node->next = nullptr;
|
||||
list->size--;
|
||||
}
|
||||
|
||||
void List_Insert(List* list, void* next, void* object) {
|
||||
if (next == nullptr) {
|
||||
List_Append(list, object);
|
||||
} else if (next == list->first) {
|
||||
List_Prepend(list, object);
|
||||
} else {
|
||||
Node *newNode = NODE_PTR(list, object);
|
||||
void *prevObj = NODE_PTR(list, next)->prev;
|
||||
Node *prevNode = NODE_PTR(list, prevObj);
|
||||
newNode->prev = prevObj;
|
||||
newNode->next = next;
|
||||
prevNode->next = object;
|
||||
NODE_PTR(list, next)->prev = object;
|
||||
list->size++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void List_Prepend(List* list, void* object) {
|
||||
if (list->first == nullptr) {
|
||||
Node *node = NODE_PTR(list, object);
|
||||
node->next = nullptr;
|
||||
node->prev = nullptr;
|
||||
list->first = object;
|
||||
list->last = object;
|
||||
list->size++;
|
||||
} else {
|
||||
Node *node = NODE_PTR(list, object);
|
||||
node->prev = nullptr;
|
||||
node->next = list->first;
|
||||
NODE_PTR(list, list->first)->prev = object;
|
||||
list->first = object;
|
||||
list->size++;
|
||||
}
|
||||
}
|
||||
|
||||
void List_Append(List* list, void* object) {
|
||||
if (list->first == nullptr) {
|
||||
Node *node = NODE_PTR(list, object);
|
||||
node->next = nullptr;
|
||||
node->prev = nullptr;
|
||||
list->first = object;
|
||||
list->last = object;
|
||||
list->size++;
|
||||
} else {
|
||||
Node *node = NODE_PTR(list, object);
|
||||
node->prev = list->last;
|
||||
node->next = nullptr;
|
||||
NODE_PTR(list, list->last)->next = object;
|
||||
list->last = object;
|
||||
list->size++;
|
||||
}
|
||||
}
|
||||
|
||||
void List_Init(List* list, u16 offset) {
|
||||
list->first = nullptr;
|
||||
list->last = nullptr;
|
||||
list->size = 0;
|
||||
list->offset = offset;
|
||||
}
|
||||
|
||||
} // namespace ut
|
||||
} // namespace nw4r
|
||||
Reference in New Issue
Block a user