Files
dusklight/include/JSystem/JAudio2/JASGadget.h
T
Luke Street 1eb018ea26 Fix compilation errors after decomp/main merge
- Fix <string> -> <cstring> across all source files (upstream fix)
- Add <cstring> to JASGadget.h, <cstdarg> to JUTDbPrint.cpp
- Fix <string> -> <cstring> in JUTFont.h, d_save.h, f_ap_game.h
- Fix std::isnan usage in c_cc_d.cpp
- Fix cCcD_Src types: s32 -> u32 for bitmask fields (upstream fix)
- Fix AT_TYPE_WOLF_ATTACK/AT_TYPE_UNK unsigned literals (upstream fix)
- Remove (s32) casts on hex literals in collision data (upstream fix)
- Fix 0xFFFFFFFF literal in d_a_obj_wood_statue.cpp (upstream fix)
- Add braces to case 0 in d_a_e_gb.cpp to fix jump-over-init
- Fix Z2AudioCS.h include path (Z2AudioLib -> Z2AudioCS)
- Forward-declare Z2AudioCS in stubs.cpp to avoid revolution conflicts
- Guard JASGlobalInstance specializations with __MWERKS__ in m_Do_main
- Remove duplicate inline functions from d_com_inf_game.h
- Mark dummy() functions as static (upstream fix)
- Add JAUSectionHeap.h include to m_Do_main.cpp
2026-02-28 14:29:46 -07:00

96 lines
1.7 KiB
C++

#ifndef JASGADGET_H
#define JASGADGET_H
#include "JSystem/JUtility/JUTAssert.h"
#include <cstring>
#include <string>
#ifdef __MWERKS__
#define JAS_GLOBAL_INSTANCE_INIT
#else
#define JAS_GLOBAL_INSTANCE_INIT {}
#endif
/**
* @ingroup jsystem-jaudio
*
*/
template<class T>
class JASGlobalInstance {
public:
JASGlobalInstance(T* inst) {
sInstance = inst;
}
JASGlobalInstance(bool setInstance) {
if (setInstance) {
JUT_ASSERT(186, sInstance == NULL);
sInstance = (T*)this;
}
}
~JASGlobalInstance() {
if (sInstance == (T*)this) {
sInstance = NULL;
}
}
static T* getInstance() { return sInstance; }
static T* sInstance;
};
#ifndef __MWERKS__
template<class T>
T* JASGlobalInstance<T>::sInstance;
#endif
/**
* @ingroup jsystem-jaudio
*
*/
template<class T>
class JASPtrTable {
public:
JASPtrTable(T** param_0, u32 size) {
mTable = param_0;
mSize = size;
memset(mTable, 0, size * 4);
}
T* get(u32 index) {
if (index >= mSize) {
return NULL;
}
return mTable[index];
}
T* get(u32 index) const {
if (index >= mSize) {
return NULL;
}
return mTable[index];
}
void set(u32 index, T* value) {
JUT_ASSERT(229, index < mSize);
mTable[index] = value;
}
private:
/* 0x00 */ T** mTable;
/* 0x04 */ u32 mSize;
};
/**
* @ingroup jsystem-jaudio
*
*/
template<class T, size_t N>
class JASPtrArray : public JASPtrTable<T> {
public:
JASPtrArray() : JASPtrTable<T>(mArray, N) {}
private:
/* 0x08 */ T* mArray[N];
};
#endif /* JASGADGET_H */