Various JSystem work (#2383)

* JKernel and JStudio cleanup

* JMessage cleanup

* JAudio cleanup

* JASBNKParser work

* functionvalue work

* fvb work

* J2D and J3D cleanup

* steal from tww

* J2DPictureEx mostly done

* fix build
This commit is contained in:
Caroline Madsen
2025-04-09 13:45:30 -07:00
committed by GitHub
parent 6672817e41
commit c6f76e7240
78 changed files with 1793 additions and 2710 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ struct TParseData_aligned : public TParseData {
// Base for header and/or block parsing
struct TParse_header_block {
virtual ~TParse_header_block();
virtual ~TParse_header_block() = 0;
virtual bool parseHeader_next(const void** ppData_inout, u32* puBlock_out, u32 arg2) = 0;
virtual bool parseBlock_next(const void** ppData_inout, u32* puData_out, u32 arg2) = 0;
+11 -1
View File
@@ -2,6 +2,7 @@
#define LINKLIST_H
#include "JSystem/JUtility/JUTAssert.h"
#include <iterator.h>
namespace JGadget {
struct TLinkListNode {
@@ -146,6 +147,12 @@ struct TLinkList : public TNodeLinkList {
T* operator->() const { return Element_toValue(base.operator->()); }
T& operator*() const { return *operator->(); }
typedef s32 difference_type;
typedef T value_type;
typedef T* pointer;
typedef T& reference;
typedef std::bidirectional_iterator_tag iterator_category;
public:
/* 0x00 */ TNodeLinkList::iterator base;
};
@@ -221,7 +228,7 @@ struct TLinkList : public TNodeLinkList {
template <typename T, int I>
struct TLinkList_factory : public TLinkList<T, I> {
virtual ~TLinkList_factory() {}
inline virtual ~TLinkList_factory() = 0;
virtual T* Do_create() = 0;
virtual void Do_destroy(T*) = 0;
void Clear_destroy() {
@@ -233,6 +240,9 @@ struct TLinkList_factory : public TLinkList<T, I> {
}
};
template <typename T, int I>
TLinkList_factory<T, I>::~TLinkList_factory() {}
template <typename T>
struct TEnumerator {
inline TEnumerator(T _current, T _end)
+101
View File
@@ -2,9 +2,24 @@
#define SEARCH_H
#include "dolphin/os.h"
#include <iterator.h>
#include <functional.h>
#include <algorithm.h>
namespace JGadget {
namespace search {
template <typename T>
struct TExpandStride_ {};
template <>
struct TExpandStride_<s32> {
static s32 get(s32 n) { return n << 3; }
};
} // namespace search
//! @todo: mangled name isn't correct, fix this
//! Current: toValueFromIndex<PFdd_d>__7JGadgetFiPCPFdd_dUlRCPFdd_d
//! Target: toValueFromIndex<PFdd_d>__7JGadgetFiPCPFdd_dUlRCPFdd_d_RCPFdd_d
@@ -14,6 +29,92 @@ inline const T& toValueFromIndex(int idx, const T* pValue, u32 count, const T& f
return (idx >= count) ? fallback : pValue[idx];
}
template <typename Iterator, typename T, typename Predicate>
inline Iterator findUpperBound_binary_all(Iterator first, Iterator last, const T& val, Predicate p) {
return upper_bound(first, last, val, p);
}
template <typename Iterator, typename T, typename Predicate>
inline Iterator findUpperBound_binary_begin(Iterator first, Iterator last, const T& val, Predicate p) {
if (first == last) {
return last;
}
typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
difference_type dist = std::distance(first, last);
difference_type stride = 1;
search::TExpandStride_<difference_type> expand;
Iterator i = first;
while (true) {
if (p(val, *i)) {
if (stride == 1) {
return i;
} else {
break;
}
}
first = i;
dist -= stride;
if (dist <= 0) {
i = last;
break;
}
i += stride;
stride = expand.get(stride);
}
return findUpperBound_binary_all(first, i, val, p);
}
template <typename Iterator, typename T, typename Predicate>
inline Iterator findUpperBound_binary_end(Iterator first, Iterator last, const T& val, Predicate p) {
if (first == last) {
return last;
}
typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
--last;
difference_type dist = std::distance(first, last);
difference_type stride = 1;
search::TExpandStride_<difference_type> expand;
Iterator i = last;
while (true) {
if (!p(val, *i)) {
if (stride == 1) {
return ++i;
} else {
break;
}
}
last = i;
dist -= stride;
if (dist <= 0) {
i = first;
break;
}
i -= stride;
stride = expand.get(stride);
}
return findUpperBound_binary_all(i, ++last, val, p);
}
template <typename Iterator, typename T, typename Predicate>
Iterator findUpperBound_binary_current(Iterator first, Iterator last, Iterator current, const T& val, Predicate p) {
return current == last || p(val, *current) ?
findUpperBound_binary_end(first, current, val, p)
: findUpperBound_binary_begin(current, last, val, p);
}
// NONMATCHING stack alloc
template <typename Iterator, typename T>
Iterator findUpperBound_binary_current(Iterator first, Iterator last, Iterator current, const T& val) {
std::less<T> less;
return findUpperBound_binary_current(first, last, current, val, less);
}
} // namespace JGadget
#endif /* SEARCH_H */
+28 -11
View File
@@ -2,8 +2,8 @@
#define STD_VECTOR_H
#include "JSystem/JGadget/std-memory.h"
#include "algorithm.h"
#include "msl_memory.h"
#include <algorithm.h>
#include <msl_memory.h>
namespace JGadget {
namespace vector {
@@ -41,12 +41,6 @@ struct TVector {
mAllocator.deallocate(pBegin_, 0);
}
T* insert(T* pos, const T& val) {
u32 diff = (int)((u32)pos - (u32)begin()) / 4;
insert(pos, 1, val);
return pBegin_ + diff;
}
void insert(T* pos, u32 count, const T& val) {
if (count != 0) {
T* ptr = Insert_raw(pos, count);
@@ -110,11 +104,17 @@ struct TVector {
return endOfCopy;
}
T* begin() { return pBegin_; }
T* insert(T* pos, const T& val) {
u32 diff = (int)((u32)pos - (u32)begin()) / 4;
insert(pos, 1, val);
return pBegin_ + diff;
}
T* end() { return pEnd_; }
T* begin() const { return pBegin_; }
u32 size() {
T* end() const { return pEnd_; }
u32 size() const {
if (pBegin_ == 0) {
return 0;
}
@@ -171,6 +171,23 @@ struct TVector_pointer_void : public TVector<void*, TAllocator<void*> > {
void clear() { erase(begin(), end()); }
void push_back(const void*& value) { insert(end(), (void* const&)value); }
};
template <typename T>
struct TVector_pointer : TVector_pointer_void {
TVector_pointer(const TAllocator<void*>& allocator) : TVector_pointer_void(allocator) {}
~TVector_pointer() {}
const T* begin() const { return (const T*)TVector_pointer_void::begin(); }
T* begin() { return (T*)TVector_pointer_void::begin(); }
const T* end() const { return (const T*)TVector_pointer_void::end(); }
T* end() { return (T*)TVector_pointer_void::end(); }
void push_back(const T& ref) {
static_cast<TVector_pointer_void*>(this)->push_back((const void*&)ref);
}
};
} // namespace JGadget
#endif /* STD_VECTOR_H */
+3 -3
View File
@@ -1,9 +1,9 @@
#ifndef VECTOR_H
#define VECTOR_H
#include <dolphin/types.h>
extern u8 data_804511E0;
extern u8 lit_569[];
namespace JGadget {
@@ -18,7 +18,7 @@ typedef u32 (*ExtendFunc)(u32, u32, u32);
template <typename T>
struct TAllocator {
static TAllocator get() {}
inline TAllocator() { _0 = lit_569[0]; }
inline TAllocator(u8 param_0) { _0 = param_0; }
/* 0x0 */ u8 _0;
/* 0x4 */ u32 _4;
/* 0x8 */ u32 _8;
@@ -83,4 +83,4 @@ struct TVector_pointer : TVector_pointer_void {
} // namespace JGadget
#endif /* VECTOR_H */
#endif /* VECTOR_H */