mirror of
https://github.com/zeldaret/st
synced 2026-10-07 13:25:33 -04:00
6d7abbdfec
* UnkStruct_027e09b4_017 (part 1?) OK * code_020c0b24_017 68% * rename file * AdventureModeManager_15C_20_00_017 96% * AdventureModeManager_15C_017 OK * match remaining .init, .ctor and .bss * fix build issues on other versions * UnkStruct_027e0cec_017 OK * UnkStruct_027e0cf8_017 OK * UnkStruct_ov024_020d86a0_017 OK * UnkStruct_027e09c0_017 OK * UnkStruct_027e0cec_18_017 OK * fix other versions build * code_020c201c_017 OK * SaveManager_017 OK * remove extern "C"s * port progression to the other versions * ninja format * fix regressions
106 lines
3.0 KiB
C++
106 lines
3.0 KiB
C++
#ifndef TYPES_H
|
|
#define TYPES_H
|
|
|
|
#include <nitro/types.h>
|
|
|
|
typedef s8 unk8;
|
|
typedef s16 unk16;
|
|
typedef s32 unk32;
|
|
|
|
#define CEIL_DIV(a, b) (((a) + (b) - 1) / (b))
|
|
|
|
#ifdef __cplusplus
|
|
#define DECL_PTMF(name, ...) \
|
|
template <typename T, typename R = void> struct name { \
|
|
typedef R (T::*PTMFCallback)(__VA_ARGS__); \
|
|
\
|
|
PTMFCallback callback; \
|
|
};
|
|
|
|
#define DECL_PTMF_RET(name, ret, ...) \
|
|
template <typename T, typename R = ret> struct name { \
|
|
typedef R (T::*PTMFCallback)(__VA_ARGS__); \
|
|
\
|
|
PTMFCallback callback; \
|
|
};
|
|
|
|
#define CALL_PTMF(type, data, ...) \
|
|
{ \
|
|
type &ptr = (data); \
|
|
(this->*ptr.callback)(__VA_ARGS__); \
|
|
}
|
|
|
|
#define CALL_PTMF_RET(type, data, ...) \
|
|
type &ptr = (data); \
|
|
ptmfResult = (this->*ptr.callback)(__VA_ARGS__);
|
|
|
|
#define STATIC_CALL_PTMF(type, data, thisx, ...) \
|
|
{ \
|
|
type &ptr = (data); \
|
|
((thisx)->*ptr.callback)(__VA_ARGS__); \
|
|
}
|
|
|
|
#define STATIC_PTMFCALLBACK(type, data, thisx, ...) \
|
|
{ \
|
|
type::PTMFCallback &ptr = (data); \
|
|
((thisx)->*ptr)(__VA_ARGS__); \
|
|
}
|
|
|
|
DECL_PTMF(PTMF);
|
|
DECL_PTMF_RET(PTMFBool, bool);
|
|
typedef void (*UnkCallback)(u16 param1);
|
|
|
|
template <typename T> class Instance {
|
|
public:
|
|
Instance(); //! TODO: should this be inlined?
|
|
~Instance(); //! TODO: should this be inlined?
|
|
};
|
|
|
|
template <typename T> class AutoInstance : public Instance<T> {
|
|
public:
|
|
AutoInstance() {}
|
|
~AutoInstance() {}
|
|
};
|
|
|
|
#define DECL_INSTANCE_CTOR(type, gpInstance) \
|
|
template <typename T> Instance<T>::Instance() { \
|
|
gpInstance = (type *) this; \
|
|
} \
|
|
template class Instance<type>;
|
|
|
|
#define DECL_INSTANCE_DTOR(type, gpInstance) \
|
|
template <> Instance<type>::~Instance() { \
|
|
gpInstance = NULL; \
|
|
}
|
|
|
|
#define DECL_INSTANCE(type, gpInstance) \
|
|
DECL_INSTANCE_CTOR(type, gpInstance) \
|
|
DECL_INSTANCE_DTOR(type, gpInstance)
|
|
|
|
template <typename T> struct StaticInstance {
|
|
static T sInstance;
|
|
};
|
|
|
|
#define DECL_STATIC_INSTANCE(T) T StaticInstance<T>::sInstance
|
|
|
|
#endif
|
|
|
|
//! TODO: move elsewhere
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct SPAHeader {
|
|
/* 00 */ u32 magic; // always 'SPA '
|
|
/* 04 */ unk32 mUnk_04;
|
|
/* 08 */ u16 mUnk_08;
|
|
/* 0A */ char pad[0x18 - 0x0A];
|
|
/* 18 */ unk32 mUnk_18;
|
|
} SPAHeader;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|