From a8a179cf67d8ea50160c7cb97208f5bf223f3037 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 29 Sep 2020 10:39:51 -0400 Subject: organize include/, split Gecko_ExceptionPPC.s --- asm/libstdc++/Gecko_ExceptionPPC.s | 35 ++++++++++++++++++++++++++++++ asm/libstdc++/__init_cpp_exceptions.s | 2 +- asm/text_5_2.s | 32 ---------------------------- include/GameSpy/darray.h | 40 +++++++++++++++++++++++++++++++++++ include/GameSpy/hashtable.h | 34 +++++++++++++++++++++++++++++ include/GameSpy/nonport.h | 16 ++++++++++++++ include/darray.h | 40 ----------------------------------- include/hashtable.h | 34 ----------------------------- include/libstdc++/qsort.h | 15 +++++++++++++ include/nonport.h | 16 -------------- include/qsort.h | 15 ------------- obj_files.mk | 1 + 12 files changed, 142 insertions(+), 138 deletions(-) create mode 100644 asm/libstdc++/Gecko_ExceptionPPC.s create mode 100644 include/GameSpy/darray.h create mode 100644 include/GameSpy/hashtable.h create mode 100644 include/GameSpy/nonport.h delete mode 100644 include/darray.h delete mode 100644 include/hashtable.h create mode 100644 include/libstdc++/qsort.h delete mode 100644 include/nonport.h delete mode 100644 include/qsort.h diff --git a/asm/libstdc++/Gecko_ExceptionPPC.s b/asm/libstdc++/Gecko_ExceptionPPC.s new file mode 100644 index 0000000..0291da9 --- /dev/null +++ b/asm/libstdc++/Gecko_ExceptionPPC.s @@ -0,0 +1,35 @@ +.include "macros.inc" + +.section .text, "ax" # 0x80006980 - 0x803E1E60 + +.global __register_fragment +__register_fragment: +/* 801C7830 001C3490 3C A0 80 49 */ lis r5, lbl_8048EAE0@ha +/* 801C7834 001C3494 38 A5 EA E0 */ addi r5, r5, lbl_8048EAE0@l +/* 801C7838 001C3498 80 05 00 08 */ lwz r0, 8(r5) +/* 801C783C 001C349C 2C 00 00 00 */ cmpwi r0, 0 +/* 801C7840 001C34A0 40 82 00 1C */ bne lbl_801C785C +/* 801C7844 001C34A4 90 65 00 00 */ stw r3, 0(r5) +/* 801C7848 001C34A8 38 00 00 01 */ li r0, 1 +/* 801C784C 001C34AC 38 60 00 00 */ li r3, 0 +/* 801C7850 001C34B0 90 85 00 04 */ stw r4, 4(r5) +/* 801C7854 001C34B4 90 05 00 08 */ stw r0, 8(r5) +/* 801C7858 001C34B8 4E 80 00 20 */ blr +lbl_801C785C: +/* 801C785C 001C34BC 38 60 FF FF */ li r3, -1 +/* 801C7860 001C34C0 4E 80 00 20 */ blr + +.global __unregister_fragment +__unregister_fragment: +/* 801C7864 001C34C4 2C 03 00 00 */ cmpwi r3, 0 +/* 801C7868 001C34C8 4D 80 00 20 */ bltlr +/* 801C786C 001C34CC 2C 03 00 01 */ cmpwi r3, 1 +/* 801C7870 001C34D0 4C 80 00 20 */ bgelr +/* 801C7874 001C34D4 1C 83 00 0C */ mulli r4, r3, 0xc +/* 801C7878 001C34D8 3C 60 80 49 */ lis r3, lbl_8048EAE0@ha +/* 801C787C 001C34DC 38 00 00 00 */ li r0, 0 +/* 801C7880 001C34E0 38 63 EA E0 */ addi r3, r3, lbl_8048EAE0@l +/* 801C7884 001C34E4 7C 03 21 6E */ stwux r0, r3, r4 +/* 801C7888 001C34E8 90 03 00 04 */ stw r0, 4(r3) +/* 801C788C 001C34EC 90 03 00 08 */ stw r0, 8(r3) +/* 801C7890 001C34F0 4E 80 00 20 */ blr diff --git a/asm/libstdc++/__init_cpp_exceptions.s b/asm/libstdc++/__init_cpp_exceptions.s index aa1fa2a..7e12b85 100644 --- a/asm/libstdc++/__init_cpp_exceptions.s +++ b/asm/libstdc++/__init_cpp_exceptions.s @@ -35,7 +35,7 @@ __fini_cpp_exceptions_tmp: #__fini_cpp_exceptions /* 801C7808 001C3468 80 6D 83 D8 */ lwz r3, lbl_8063D698-_SDA_BASE_(r13) /* 801C780C 001C346C 2C 03 FF FE */ cmpwi r3, -2 /* 801C7810 001C3470 41 82 00 10 */ beq lbl_801C7820 -/* 801C7814 001C3474 48 00 00 51 */ bl func_801C7864 +/* 801C7814 001C3474 48 00 00 51 */ bl __unregister_fragment /* 801C7818 001C3478 38 00 FF FE */ li r0, -2 /* 801C781C 001C347C 90 0D 83 D8 */ stw r0, lbl_8063D698-_SDA_BASE_(r13) lbl_801C7820: diff --git a/asm/text_5_2.s b/asm/text_5_2.s index 06e2e4e..67a841f 100644 --- a/asm/text_5_2.s +++ b/asm/text_5_2.s @@ -2,38 +2,6 @@ .section .text, "ax" # 0x80006980 - 0x803E1E60 -.global __register_fragment -__register_fragment: -/* 801C7830 001C3490 3C A0 80 49 */ lis r5, lbl_8048EAE0@ha -/* 801C7834 001C3494 38 A5 EA E0 */ addi r5, r5, lbl_8048EAE0@l -/* 801C7838 001C3498 80 05 00 08 */ lwz r0, 8(r5) -/* 801C783C 001C349C 2C 00 00 00 */ cmpwi r0, 0 -/* 801C7840 001C34A0 40 82 00 1C */ bne lbl_801C785C -/* 801C7844 001C34A4 90 65 00 00 */ stw r3, 0(r5) -/* 801C7848 001C34A8 38 00 00 01 */ li r0, 1 -/* 801C784C 001C34AC 38 60 00 00 */ li r3, 0 -/* 801C7850 001C34B0 90 85 00 04 */ stw r4, 4(r5) -/* 801C7854 001C34B4 90 05 00 08 */ stw r0, 8(r5) -/* 801C7858 001C34B8 4E 80 00 20 */ blr -lbl_801C785C: -/* 801C785C 001C34BC 38 60 FF FF */ li r3, -1 -/* 801C7860 001C34C0 4E 80 00 20 */ blr - -.global func_801C7864 -func_801C7864: -/* 801C7864 001C34C4 2C 03 00 00 */ cmpwi r3, 0 -/* 801C7868 001C34C8 4D 80 00 20 */ bltlr -/* 801C786C 001C34CC 2C 03 00 01 */ cmpwi r3, 1 -/* 801C7870 001C34D0 4C 80 00 20 */ bgelr -/* 801C7874 001C34D4 1C 83 00 0C */ mulli r4, r3, 0xc -/* 801C7878 001C34D8 3C 60 80 49 */ lis r3, lbl_8048EAE0@ha -/* 801C787C 001C34DC 38 00 00 00 */ li r0, 0 -/* 801C7880 001C34E0 38 63 EA E0 */ addi r3, r3, lbl_8048EAE0@l -/* 801C7884 001C34E4 7C 03 21 6E */ stwux r0, r3, r4 -/* 801C7888 001C34E8 90 03 00 04 */ stw r0, 4(r3) -/* 801C788C 001C34EC 90 03 00 08 */ stw r0, 8(r3) -/* 801C7890 001C34F0 4E 80 00 20 */ blr - .global func_801C7894 func_801C7894: /* 801C7894 001C34F4 94 21 FF E0 */ stwu r1, -0x20(r1) diff --git a/include/GameSpy/darray.h b/include/GameSpy/darray.h new file mode 100644 index 0000000..5c7c170 --- /dev/null +++ b/include/GameSpy/darray.h @@ -0,0 +1,40 @@ +#ifndef POKEREVO_DARRAY_H +#define POKEREVO_DARRAY_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef s32 (*CompareFunction)(const void *, const void *); +typedef BOOL (*MapFunction)(const void *, s32); +typedef void (*DtorFunction)(void *); + +typedef struct DArray { + s32 size; + s32 capacity; + u32 elemSz; + s32 growAmount; + DtorFunction elemDtor; + char *buf; +} DArray; + +DArray *ArrayNew(u32 elemSz, s32 initialCap, DtorFunction dtor); +void ArrayFree(DArray *d); +s32 ArrayLength(DArray *d); +void *ArrayNth(DArray *d, s32 n); +void ArrayAppend(DArray *d, void *elem); +void ArrayInsertSorted(DArray *d, void *elem, CompareFunction compar); +void ArrayRemoveAt(DArray *d, s32 n); +void ArrayDeleteAt(DArray *d, s32 n); +void ArrayReplaceAt(DArray *d, void *elem, s32 n); +void ArraySort(DArray *d, CompareFunction compar); +s32 ArraySearch(DArray *d, void *elem, CompareFunction cmp, s32 start, s32 doBinarySearch); +void ArrayMapBackwards(DArray *d, MapFunction map, s32 p3); +void *ArrayMapBackwards2(DArray *d, MapFunction map, s32 p3); +void ArrayClear(DArray *d); + +#ifdef __cplusplus +} +#endif + +#endif //POKEREVO_DARRAY_H diff --git a/include/GameSpy/hashtable.h b/include/GameSpy/hashtable.h new file mode 100644 index 0000000..784ab35 --- /dev/null +++ b/include/GameSpy/hashtable.h @@ -0,0 +1,34 @@ +#ifndef POKEREVO_HASHTABLE_H +#define POKEREVO_HASHTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "darray.h" + +typedef s32 (*HashFunction)(void *, s32); + +typedef struct HashTable { + DArray **chains; + s32 size; + DtorFunction dtor; + HashFunction hashFunc; + CompareFunction compar; +} HashTable; + +HashTable *TableNew(u32 p1, s32 p2, HashFunction hf, CompareFunction cmp, DtorFunction dtor); +HashTable *TableNew2(u32 p1, s32 size, s32 p3, HashFunction hf, CompareFunction cmp, DtorFunction dtor); +void TableFree(HashTable *table); +s32 TableCount(HashTable *table); +void TableEnter(HashTable *table, void *elem); +BOOL TableRemove(HashTable *table, void *elem); +void *TableLookup(HashTable *table, void *elem); +void TableMapSafe(HashTable *table, MapFunction p2, s32 p3); +void *TableMapSafe2(HashTable *table, MapFunction p2, s32 p3); + +#ifdef __cplusplus +} +#endif + +#endif //POKEREVO_HASHTABLE_H diff --git a/include/GameSpy/nonport.h b/include/GameSpy/nonport.h new file mode 100644 index 0000000..c1ed0e7 --- /dev/null +++ b/include/GameSpy/nonport.h @@ -0,0 +1,16 @@ +#ifndef POKEREVO_NONPORT_H +#define POKEREVO_NONPORT_H + +#ifdef __cplusplus +extern "C" { +#endif + +void *gsimalloc(u32 sz); +void *gsirealloc(void *ptr, u32 sz); +void gsifree(void *ptr); + +#ifdef __cplusplus +} +#endif + +#endif //POKEREVO_NONPORT_H diff --git a/include/darray.h b/include/darray.h deleted file mode 100644 index 5c7c170..0000000 --- a/include/darray.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef POKEREVO_DARRAY_H -#define POKEREVO_DARRAY_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef s32 (*CompareFunction)(const void *, const void *); -typedef BOOL (*MapFunction)(const void *, s32); -typedef void (*DtorFunction)(void *); - -typedef struct DArray { - s32 size; - s32 capacity; - u32 elemSz; - s32 growAmount; - DtorFunction elemDtor; - char *buf; -} DArray; - -DArray *ArrayNew(u32 elemSz, s32 initialCap, DtorFunction dtor); -void ArrayFree(DArray *d); -s32 ArrayLength(DArray *d); -void *ArrayNth(DArray *d, s32 n); -void ArrayAppend(DArray *d, void *elem); -void ArrayInsertSorted(DArray *d, void *elem, CompareFunction compar); -void ArrayRemoveAt(DArray *d, s32 n); -void ArrayDeleteAt(DArray *d, s32 n); -void ArrayReplaceAt(DArray *d, void *elem, s32 n); -void ArraySort(DArray *d, CompareFunction compar); -s32 ArraySearch(DArray *d, void *elem, CompareFunction cmp, s32 start, s32 doBinarySearch); -void ArrayMapBackwards(DArray *d, MapFunction map, s32 p3); -void *ArrayMapBackwards2(DArray *d, MapFunction map, s32 p3); -void ArrayClear(DArray *d); - -#ifdef __cplusplus -} -#endif - -#endif //POKEREVO_DARRAY_H diff --git a/include/hashtable.h b/include/hashtable.h deleted file mode 100644 index 784ab35..0000000 --- a/include/hashtable.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef POKEREVO_HASHTABLE_H -#define POKEREVO_HASHTABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "darray.h" - -typedef s32 (*HashFunction)(void *, s32); - -typedef struct HashTable { - DArray **chains; - s32 size; - DtorFunction dtor; - HashFunction hashFunc; - CompareFunction compar; -} HashTable; - -HashTable *TableNew(u32 p1, s32 p2, HashFunction hf, CompareFunction cmp, DtorFunction dtor); -HashTable *TableNew2(u32 p1, s32 size, s32 p3, HashFunction hf, CompareFunction cmp, DtorFunction dtor); -void TableFree(HashTable *table); -s32 TableCount(HashTable *table); -void TableEnter(HashTable *table, void *elem); -BOOL TableRemove(HashTable *table, void *elem); -void *TableLookup(HashTable *table, void *elem); -void TableMapSafe(HashTable *table, MapFunction p2, s32 p3); -void *TableMapSafe2(HashTable *table, MapFunction p2, s32 p3); - -#ifdef __cplusplus -} -#endif - -#endif //POKEREVO_HASHTABLE_H diff --git a/include/libstdc++/qsort.h b/include/libstdc++/qsort.h new file mode 100644 index 0000000..c13ae0e --- /dev/null +++ b/include/libstdc++/qsort.h @@ -0,0 +1,15 @@ +#ifndef POKEREVO_QSORT_H +#define POKEREVO_QSORT_H + +#ifdef __cplusplus +extern "C" { +#endif + +void qsort(void *base, u32 nmemb, u32 size, + s32 (*compar)(const void *, const void *)); + +#ifdef __cplusplus +} +#endif + +#endif //POKEREVO_QSORT_H diff --git a/include/nonport.h b/include/nonport.h deleted file mode 100644 index c1ed0e7..0000000 --- a/include/nonport.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef POKEREVO_NONPORT_H -#define POKEREVO_NONPORT_H - -#ifdef __cplusplus -extern "C" { -#endif - -void *gsimalloc(u32 sz); -void *gsirealloc(void *ptr, u32 sz); -void gsifree(void *ptr); - -#ifdef __cplusplus -} -#endif - -#endif //POKEREVO_NONPORT_H diff --git a/include/qsort.h b/include/qsort.h deleted file mode 100644 index c13ae0e..0000000 --- a/include/qsort.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef POKEREVO_QSORT_H -#define POKEREVO_QSORT_H - -#ifdef __cplusplus -extern "C" { -#endif - -void qsort(void *base, u32 nmemb, u32 size, - s32 (*compar)(const void *, const void *)); - -#ifdef __cplusplus -} -#endif - -#endif //POKEREVO_QSORT_H diff --git a/obj_files.mk b/obj_files.mk index 3f1b7f9..f4c8687 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -19,6 +19,7 @@ TEXT_O_FILES := \ $(BUILD_DIR)/src/libstdc++/ptmf.o \ $(BUILD_DIR)/asm/libstdc++/runtime.o \ $(BUILD_DIR)/asm/libstdc++/__init_cpp_exceptions.o \ + $(BUILD_DIR)/asm/libstdc++/Gecko_ExceptionPPC.o \ $(BUILD_DIR)/asm/text_5_2.o \ $(BUILD_DIR)/asm/text_6.o \ $(BUILD_DIR)/asm/MetroTRK/mem_TRK.o \ -- cgit v1.2.3