mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-09-03 00:53:47 -04:00
Merge branch 'main' of https://github.com/zeldaret/tp
This commit is contained in:
@@ -50,11 +50,18 @@ struct JASGenericMemPool {
|
||||
void* alloc(u32);
|
||||
void free(void*, u32);
|
||||
|
||||
u32 getFreeMemCount() const {
|
||||
return freeMemCount;
|
||||
}
|
||||
|
||||
u32 getTotalMemCount() const {
|
||||
return totalMemCount;
|
||||
}
|
||||
|
||||
/* 0x00 */ void* field_0x0;
|
||||
/* 0x04 */ u32 freeMemCount;
|
||||
/* 0x08 */ u32 totalMemCount;
|
||||
/* 0x0C */ u32 usedMemCount;
|
||||
|
||||
};
|
||||
|
||||
namespace JASThreadingModel {
|
||||
@@ -87,6 +94,13 @@ namespace JASThreadingModel {
|
||||
A0* mMutex;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename A0>
|
||||
struct SingleThreaded {
|
||||
struct Lock {
|
||||
Lock(const A0& param_0) {}
|
||||
};
|
||||
};
|
||||
}; // namespace JASThreadingModel
|
||||
|
||||
/**
|
||||
@@ -96,17 +110,32 @@ namespace JASThreadingModel {
|
||||
template <typename T>
|
||||
class JASMemPool : public JASGenericMemPool {
|
||||
public:
|
||||
void newMemPool(int param_0) { JASGenericMemPool::newMemPool(sizeof(T), param_0); }
|
||||
void newMemPool(int param_0) {
|
||||
typename JASThreadingModel::SingleThreaded<JASMemPool<T> >::Lock lock(*this);
|
||||
JASGenericMemPool::newMemPool(sizeof(T), param_0);
|
||||
}
|
||||
|
||||
void* alloc(u32 n) {
|
||||
JUT_ASSERT(182, n == sizeof(T));
|
||||
typename JASThreadingModel::SingleThreaded<JASMemPool<T> >::Lock lock(*this);
|
||||
return JASGenericMemPool::alloc(n);
|
||||
}
|
||||
|
||||
void free(void* ptr, u32 n) {
|
||||
JUT_ASSERT(187, n == sizeof(T));
|
||||
typename JASThreadingModel::SingleThreaded<JASMemPool<T> >::Lock lock(*this);
|
||||
JASGenericMemPool::free(ptr, n);
|
||||
}
|
||||
|
||||
u32 getFreeMemCount() const {
|
||||
typename JASThreadingModel::SingleThreaded<JASMemPool<T> >::Lock lock(*this);
|
||||
return JASGenericMemPool::getFreeMemCount();
|
||||
}
|
||||
|
||||
u32 getTotalMemCount() const {
|
||||
typename JASThreadingModel::SingleThreaded<JASMemPool<T> >::Lock lock(*this);
|
||||
return JASGenericMemPool::getTotalMemCount();
|
||||
}
|
||||
};
|
||||
|
||||
namespace JASKernel { JKRHeap* getSystemHeap(); };
|
||||
@@ -255,25 +284,35 @@ template <typename T>
|
||||
class JASPoolAllocObject {
|
||||
public:
|
||||
static void* operator new(size_t n) {
|
||||
JASMemPool<T>* memPool = getMemPool_();
|
||||
return memPool->alloc(sizeof(T));
|
||||
JASMemPool<T>& memPool_ = getMemPool_();
|
||||
return memPool_.alloc(n);
|
||||
}
|
||||
static void* operator new(size_t n, void* ptr) {
|
||||
return ptr;
|
||||
}
|
||||
static void operator delete(void* ptr, size_t n) {
|
||||
JASMemPool<T>* memPool_ = getMemPool_();
|
||||
memPool_->free(ptr, sizeof(T));
|
||||
JASMemPool<T>& memPool_ = getMemPool_();
|
||||
memPool_.free(ptr, n);
|
||||
}
|
||||
static void newMemPool(int param_0) {
|
||||
JASMemPool<T>* memPool_ = getMemPool_();
|
||||
memPool_->newMemPool(param_0);
|
||||
JASMemPool<T>& memPool_ = getMemPool_();
|
||||
memPool_.newMemPool(param_0);
|
||||
}
|
||||
static u32 getFreeMemCount() {
|
||||
JASMemPool<T>& memPool_ = getMemPool_();
|
||||
return memPool_.getFreeMemCount();
|
||||
}
|
||||
static u32 getTotalMemCount() {
|
||||
JASMemPool<T>& memPool_ = getMemPool_();
|
||||
return memPool_.getTotalMemCount();
|
||||
}
|
||||
|
||||
private:
|
||||
static JASMemPool<T>* getMemPool_() {
|
||||
// Fakematch? Is memPool_ both an in-function static and an out-of-function static?
|
||||
static JASMemPool<T> memPool_;
|
||||
static JASMemPool<T>& getMemPool_() {
|
||||
static JASMemPool<T> memPool_;
|
||||
return &memPool_;
|
||||
return memPool_;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -308,25 +347,28 @@ template <typename T>
|
||||
class JASPoolAllocObject_MultiThreaded {
|
||||
public:
|
||||
static void* operator new(size_t n) {
|
||||
JASMemPool_MultiThreaded<T>* memPool_ = getMemPool();
|
||||
return memPool_->alloc(sizeof(T));
|
||||
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
|
||||
return memPool_.alloc(sizeof(T));
|
||||
}
|
||||
static void* operator new(size_t n, void* ptr) {
|
||||
return ptr;
|
||||
}
|
||||
static void operator delete(void* ptr, size_t n) {
|
||||
JASMemPool_MultiThreaded<T>* memPool_ = getMemPool();
|
||||
memPool_->free(ptr, sizeof(T));
|
||||
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
|
||||
memPool_.free(ptr, sizeof(T));
|
||||
}
|
||||
|
||||
static void newMemPool(int n) {
|
||||
getMemPool()->newMemPool(n);
|
||||
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
|
||||
memPool_.newMemPool(n);
|
||||
}
|
||||
|
||||
private:
|
||||
static JASMemPool_MultiThreaded<T>* getMemPool() {
|
||||
// Fakematch? Is memPool_ both an in-function static and an out-of-function static?
|
||||
static JASMemPool_MultiThreaded<T> memPool_;
|
||||
static JASMemPool_MultiThreaded<T>& getMemPool() {
|
||||
static JASMemPool_MultiThreaded<T> memPool_;
|
||||
return &memPool_;
|
||||
return memPool_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -37,11 +37,23 @@ public:
|
||||
u8* getCur() { return field_0x04; }
|
||||
u32 readByte() { return *field_0x04++; }
|
||||
u32 read16() {
|
||||
#ifdef __MWERKS__
|
||||
return *((u16*)field_0x04)++;
|
||||
#else
|
||||
u16* value = (u16*)field_0x04;
|
||||
field_0x04 += 2;
|
||||
return *value;
|
||||
#endif
|
||||
}
|
||||
u32 read24() {
|
||||
field_0x04--;
|
||||
#ifdef __MWERKS__
|
||||
return (*((u32*)field_0x04)++) & 0x00ffffff;
|
||||
#else
|
||||
u32* value = (u32*)field_0x04;
|
||||
field_0x04 += 4;
|
||||
return (*value) & 0x00ffffff;
|
||||
#endif
|
||||
}
|
||||
u16 getLoopCount() const {
|
||||
if (field_0x08 == 0) {
|
||||
|
||||
@@ -15,10 +15,17 @@ public:
|
||||
template<class T>
|
||||
class TPointer_delete : public TPointer<T> {
|
||||
public:
|
||||
#ifdef __MWERKS__
|
||||
TPointer_delete(T* ptr) : TPointer(ptr) {}
|
||||
~TPointer_delete() {
|
||||
delete mPtr;
|
||||
}
|
||||
#else
|
||||
TPointer_delete(T* ptr) : TPointer<T>(ptr) {}
|
||||
~TPointer_delete() {
|
||||
delete this->mPtr;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef JHIRMCC_H
|
||||
#define JHIRMCC_H
|
||||
|
||||
#include <dolphin.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
struct JHIMccContext;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef JORHOSTINFO_H
|
||||
#define JORHOSTINFO_H
|
||||
|
||||
#include <dolphin.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
#define HOSTINFO_REQ_COMPUTER_NAME 0
|
||||
#define HOSTINFO_REQ_USERNAME 1
|
||||
|
||||
@@ -31,28 +31,28 @@ struct TSinCosTable {
|
||||
T sinShort(s16 v) const { return table[(u16)v >> (16U - N)].first; }
|
||||
T cosShort(s16 v) const { return table[(u16)v >> (16U - N)].second; }
|
||||
|
||||
inline T sinLap(T v) {
|
||||
inline T sinLap(T v) const {
|
||||
if (v < (T)0.0) {
|
||||
return -table[(u16)(-(T)(1 << N) * v) & ((1 << N) - 1)].first;
|
||||
}
|
||||
return table[(u16)((T)(1 << N) * v) & ((1 << N) - 1)].first;
|
||||
}
|
||||
|
||||
inline T sinDegree(T degree) {
|
||||
inline T sinDegree(T degree) const {
|
||||
if (degree < (T)0.0) {
|
||||
return -table[(u16)(-((T)(1 << N) / (T)360.0) * degree) & ((1 << N) - 1)].first;
|
||||
}
|
||||
return table[(u16)(((T)(1 << N) / (T)360.0) * degree) & ((1 << N) - 1)].first;
|
||||
}
|
||||
|
||||
inline T cosDegree(T degree) {
|
||||
inline T cosDegree(T degree) const {
|
||||
if (degree < (T)0.0) {
|
||||
degree = -degree;
|
||||
}
|
||||
return table[(u16)(((T)(1 << N) / (T)360.0) * degree) & ((1 << N) - 1)].second;
|
||||
}
|
||||
|
||||
inline T sinRadian(T radian) {
|
||||
inline T sinRadian(T radian) const {
|
||||
if (radian < (T)0.0) {
|
||||
return -table[(u16)(-(T)(1 << N) / TAngleConstant_<T>::RADIAN_DEG360() * radian) & ((1 << N) - 1)].first;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
TRandom_(u32 value) : RandomT(value) {}
|
||||
|
||||
u8 get_uint8(u8 param_0) {
|
||||
return get_ufloat_1() * param_0;
|
||||
return this->get_ufloat_1() * param_0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef JMESSAGE_H
|
||||
#define JMESSAGE_H
|
||||
|
||||
#include <dolphin.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
// Struct definitions might be wrong
|
||||
typedef struct bmg_header_t {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef JMESSAGE_LOCALE_H
|
||||
#define JMESSAGE_LOCALE_H
|
||||
|
||||
#include <dolphin.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
namespace JMessage {
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
return ret;
|
||||
}
|
||||
const void* getContent() const {
|
||||
return (const void*)((int)getBlockEnd_() + align_roundUp(get_IDSize(), 4));
|
||||
return (const void*)((intptr_t)getBlockEnd_() + align_roundUp(get_IDSize(), 4));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef JSUPPORT_H
|
||||
#define JSUPPORT_H
|
||||
|
||||
#include <dolphin.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user