mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-17 14:06:42 -04:00
767ba3bb14
* launch.json cwd * bodge to load gci for testing * stub card stat * gameplay bodges * viewport, ub fixes * add release with debug info cmake variant * be fixes, sound stub * viewport h * d_msg_flow BE * be fopAcM_createItemFromEnemyID * update launch configuration to use iso * more audio stubs * Attempt to set viewport and get messages for brightness check * skip opening scene again, fixed JMessage::TResourceContainer::TCResource::Do_destroy * add guards for viewport changes * moar endian swapping to get Link sitting in PROC_OPENING_SCENE and for dialogues * BE d_msg_class i_data * stub bgm start * fix div by 0 error (for now) * TEMP_BROKEN in d_menu_ring * REQUIRES_GX_LINES * properly stub renderingAmap::draw with REQUIRES_GX_LINES * better stubbing outside of stubs * fix event data getting swapped multiple times * evil draw vp fix * Stub log imgui This redirects all spammy logs to an imgui window that is cleared per frame. This fixes the serious performance dip of the logging, and makes the regular log readable. * Oops move those optimization changes I accidentally committed behind a flag DUSK_SELECTED_OPT * gx_line macro in map * fix audio stubbing * switch to CARD API aurora impl * remove kabufuda from link libs * refactor imgui stuff and add input viewer * merge stub log with refactor * accidentally committed a metaforce header shh * basic map loader * ImGuiConsole: Add missing <thread> include * you may now play as luigi (you may now load stages with bridges) * bloom fix * bloom leak fix * cloud shadow fix * add soft reset button to imgui menu * if it broke dont not fix it * i swear i committed this * BE swap indMtx in JPAResource::setPTev * wnark ct fix * frsqrte implementation from kinoko * Fix Clang compile error in JAISeq::prepare_getSeqData_ * Add endian conversions to dMsgFlow_c::getInitNodeIndex This fixes a freeze when Fado tries to stop you from leaving the starting area. * Add RAII GXTexObj wrapper; fix almost all leaks * Update aurora for indirect texturing * Update aurora for CARD fix * Fix Clang build * More d_msg_flow endian fixes Fixes softlock when trying to talk to Fado and possibly other NPCs. * no frame limiter * get pause menu working * proper frame limiting * particle pointer size fix * improve map loader a bit --------- Co-authored-by: Jasper St. Pierre <jstpierre@mecheye.net> Co-authored-by: TakaRikka <takarikka@outlook.com> Co-authored-by: CraftyBoss <talibabdulmaalik@gmail.com> Co-authored-by: Luke Street <luke@street.dev> Co-authored-by: Lurs <2795933+Lurs@users.noreply.github.com> Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com> Co-authored-by: tgsm <doodrabbit@hotmail.com> Co-authored-by: Max Roncace <me@caseif.net> Co-authored-by: Phillip Stephens <antidote.crk@gmail.com>
199 lines
5.7 KiB
C++
199 lines
5.7 KiB
C++
#ifndef JGADGET_BINARY_H
|
|
#define JGADGET_BINARY_H
|
|
|
|
#include "JSystem/JUtility/JUTAssert.h"
|
|
#include "JSystem/JGadget/search.h"
|
|
#include "dusk/endian.h"
|
|
|
|
namespace JGadget {
|
|
namespace binary {
|
|
|
|
struct TEBit {
|
|
u32 value;
|
|
};
|
|
|
|
const void* parseVariableUInt_16_32_following(const void* pu16, u32* pu32First, u32* pu32Second, TEBit* tebit);
|
|
|
|
inline bool isPower2(unsigned int arg0) {
|
|
return arg0 != 0 && (arg0 & arg0 - 1) == 0;
|
|
}
|
|
|
|
inline u32 align_roundUp(unsigned int arg0, unsigned int uAlign) {
|
|
JUT_ASSERT(98, isPower2(uAlign));
|
|
return (arg0 + uAlign - 1) & ~(uAlign - 1);
|
|
}
|
|
|
|
struct TParseData {
|
|
TParseData(const void* pContent) : raw(pContent) {}
|
|
|
|
const void* getRaw() const { return raw; }
|
|
void setRaw(const void* p) { raw = p; }
|
|
|
|
/* 0x0 */ const void* raw;
|
|
};
|
|
|
|
template <int S>
|
|
struct TParseData_aligned : public TParseData {
|
|
TParseData_aligned(const void* pContent) : TParseData(pContent) {}
|
|
void setRaw(const void* p) {
|
|
/* if ((u32)p % S != 0) {
|
|
JUTWarn w;
|
|
w << "misaligned : " << (u32)p;
|
|
} */
|
|
static_cast<TParseData*>(this)->setRaw(p);
|
|
}
|
|
};
|
|
|
|
// Base for header and/or block parsing
|
|
struct 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;
|
|
|
|
bool parse_next(const void** ppData_inout, u32 a2);
|
|
|
|
bool parse(const void* ppData_inout, u32 a2) {
|
|
return parse_next(&ppData_inout, a2);
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
struct TParseValue_raw_ {
|
|
typedef T ParseType;
|
|
static T parse(const void* data) {
|
|
T val = *(T*)data;
|
|
#ifdef TARGET_PC
|
|
if constexpr (sizeof(T) > 1) {
|
|
be_swap(val);
|
|
}
|
|
#endif
|
|
return val;
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
struct TParseValue_raw : public TParseValue_raw_<T> {
|
|
typedef TParseValue_raw_<T> InnerParseValueClass;
|
|
};
|
|
|
|
template <typename T>
|
|
struct TParseValue_endian_big_ : public TParseValue_raw_<T> {
|
|
static T parse(const void* data) { return TParseValue_raw_<T>::parse(data); }
|
|
};
|
|
|
|
template <class Parser>
|
|
struct TParseValue : public Parser {
|
|
static typename Parser::ParseType parse(const void* data) { return Parser::parse(data); }
|
|
|
|
static typename Parser::ParseType parse(const void* data, s32 advanceNum) {
|
|
return Parser::parse(advance(data, advanceNum));
|
|
}
|
|
|
|
static const void* advance(const void* data, s32 advanceNum) {
|
|
return (char*)data + (advanceNum * sizeof(typename Parser::ParseType));
|
|
}
|
|
};
|
|
|
|
template<class Parser, int size>
|
|
struct TValueIterator
|
|
: public JGadget::TIterator<
|
|
std::random_access_iterator_tag,
|
|
typename Parser::ParseType,
|
|
ptrdiff_t,
|
|
typename Parser::ParseType*,
|
|
typename Parser::ParseType&
|
|
>
|
|
{
|
|
typedef typename Parser::ParseType ValueType;
|
|
|
|
TValueIterator(const void* begin) {
|
|
mBegin = reinterpret_cast<const char*>(begin);
|
|
bool unused = false;
|
|
(void)&unused;
|
|
}
|
|
|
|
const void* get() const { return mBegin; }
|
|
|
|
typename Parser::ParseType operator*() const {
|
|
return TParseValue<typename Parser::InnerParseValueClass>::parse(get());
|
|
}
|
|
|
|
TValueIterator& operator++() {
|
|
mBegin += size;
|
|
return *this;
|
|
}
|
|
|
|
const TValueIterator operator++(int) {
|
|
TValueIterator old(*this);
|
|
++(*this);
|
|
return old;
|
|
}
|
|
|
|
TValueIterator& operator+=(s32 n) {
|
|
mBegin += size * n;
|
|
return *this;
|
|
}
|
|
|
|
TValueIterator& operator--() {
|
|
mBegin -= size;
|
|
return *this;
|
|
}
|
|
|
|
char const* mBegin;
|
|
};
|
|
|
|
template<typename T>
|
|
struct TValueIterator_raw : public TValueIterator<TParseValue_raw<T>, sizeof(T)> {
|
|
TValueIterator_raw(const void* begin) : TValueIterator<TParseValue_raw<T>, sizeof(T)>(begin) {}
|
|
|
|
friend bool operator==(TValueIterator<TParseValue_raw<T>, sizeof(T)> a, TValueIterator<TParseValue_raw<T>, sizeof(T)> b) {
|
|
return a.mBegin == b.mBegin;
|
|
}
|
|
|
|
friend bool operator!=(TValueIterator<TParseValue_raw<T>, sizeof(T)> a, TValueIterator<TParseValue_raw<T>, sizeof(T)> b) {
|
|
return !operator==(a, b);
|
|
}
|
|
|
|
friend TValueIterator<TParseValue_raw<T>, sizeof(T)> operator+(TValueIterator<TParseValue_raw<T>, sizeof(T)> a, s32 b) {
|
|
TValueIterator<TParseValue_raw<T>, sizeof(T)> it = a;
|
|
it += b;
|
|
return it;
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
struct TParseValue_misaligned_ : public TParseValue_raw_<T> {
|
|
typedef T ParseType;
|
|
static T parse(const void* data) { return TParseValue_raw_<T>::parse(data); }
|
|
};
|
|
|
|
template <typename T>
|
|
struct TParseValue_misaligned : public TParseValue_raw_<T> {
|
|
typedef TParseValue_misaligned_<T> InnerParseValueClass;
|
|
};
|
|
|
|
template<typename T>
|
|
struct TValueIterator_misaligned : public TValueIterator<TParseValue_misaligned<T>, sizeof(T)> {
|
|
TValueIterator_misaligned(const void* begin) : TValueIterator<TParseValue_misaligned<T>, sizeof(T)>(begin) {}
|
|
|
|
friend bool operator==(TValueIterator<TParseValue_misaligned<T>, sizeof(T)> a, TValueIterator<TParseValue_misaligned<T>, sizeof(T)> b) {
|
|
return a.mBegin == b.mBegin;
|
|
}
|
|
|
|
friend bool operator!=(TValueIterator<TParseValue_misaligned<T>, sizeof(T)> a, TValueIterator<TParseValue_misaligned<T>, sizeof(T)> b) {
|
|
return !operator==(a, b);
|
|
}
|
|
|
|
friend TValueIterator<TParseValue_misaligned<T>, sizeof(T)> operator+(TValueIterator<TParseValue_misaligned<T>, sizeof(T)> a, s32 b) {
|
|
TValueIterator<TParseValue_misaligned<T>, sizeof(T)> it(a);
|
|
it += b;
|
|
return it;
|
|
}
|
|
};
|
|
|
|
} // namespace binary
|
|
} // namespace JGadget
|
|
|
|
#endif /* JGADGET_BINARY_H */
|