mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-28 06:57:02 -04:00
Reorganize library code into libs/ (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}
* Update configure.py and project.py for new libs structure
* Refactor `#include <dolphin/x.h>` -> `<x.h>`
* Remove `__REVOLUTION_SDK__` forwards from dolphin
* Fix dolphin/ references in revolution
* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`
* Always build TRK against dolphin headers
* Resolve revolution SDK header resolution issues
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#ifndef JMESSAGE_H
|
||||
#define JMESSAGE_H
|
||||
|
||||
#ifdef __REVOLUTION_SDK__
|
||||
#include <revolution.h>
|
||||
#else
|
||||
#include <dolphin.h>
|
||||
#endif
|
||||
|
||||
// Struct definitions might be wrong
|
||||
typedef struct bmg_header_t {
|
||||
/* 0x00 */ char magic[8]; // "MESGbmg1"
|
||||
/* 0x08 */ u32 size; // total size of file not including FLW1/FLI1 sections
|
||||
/* 0x0C */ u32 n_sections; // number of sections
|
||||
/* 0x10 */ u8 encoding; // text encoding
|
||||
/* 0x11 */ u8 padding[0x20 - 0x11]; // padding
|
||||
} bmg_header_t;
|
||||
|
||||
typedef struct bmg_section_t {
|
||||
/* 0x0 */ u32 magic; // four character magic string
|
||||
/* 0x4 */ u32 size; // total size of the section
|
||||
} bmg_section_t;
|
||||
|
||||
typedef struct inf1_entry_t {
|
||||
/* 0x0 */ u32 string_offset; // offset into DAT1 section entries, pointing to where message text starts
|
||||
/* 0x4 */ // attributes // attribute data. size fills up the rest of defined INF1 "entry_size"
|
||||
} inf1_entry_t;
|
||||
|
||||
typedef struct inf1_section_t {
|
||||
/* 0x00 */ bmg_section_t header; // section header
|
||||
/* 0x08 */ u16 entry_num; // number of entries in this section
|
||||
/* 0x0A */ u16 entry_size; // size of an entry
|
||||
/* 0x0C */ u8 padding[4]; // padding
|
||||
} inf1_section_t;
|
||||
|
||||
typedef struct str1_entry_t {
|
||||
char str[0];
|
||||
} str1_entry_t;
|
||||
|
||||
typedef struct str1_section_t {
|
||||
/* 0x00 */ bmg_section_t header; // section header
|
||||
/* 0x08 */ str1_entry_t entries[0];
|
||||
} str1_section_t;
|
||||
|
||||
#endif /* JMESSAGE_H */
|
||||
@@ -0,0 +1,92 @@
|
||||
#ifndef JMESSAGE_CONTROL_H
|
||||
#define JMESSAGE_CONTROL_H
|
||||
|
||||
#include "JSystem/JMessage/processor.h"
|
||||
|
||||
namespace JMessage {
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct TControl {
|
||||
TControl();
|
||||
virtual ~TControl();
|
||||
|
||||
void reset();
|
||||
int update();
|
||||
void render();
|
||||
int setMessageCode(u16 u16GroupID, u16 u16Index);
|
||||
int setMessageID(u32 uMsgID, u32 param_1, bool* pbValid);
|
||||
bool setMessageCode_inSequence_(const TProcessor* pProcessor, u16 u16GroupID, u16 u16Index);
|
||||
|
||||
bool isReady_update_() const { return pMessageText_begin_ != 0 && pSequenceProcessor_ != NULL; }
|
||||
bool isReady_render_() const { return pMessageText_current_ != 0 && pRenderingProcessor_ != NULL; }
|
||||
|
||||
TProcessor* getProcessor() const {
|
||||
if (pSequenceProcessor_ != NULL) {
|
||||
return (TProcessor*)pSequenceProcessor_;
|
||||
} else {
|
||||
return (TProcessor*)pRenderingProcessor_;
|
||||
}
|
||||
}
|
||||
|
||||
int setMessageCode(u32 uCode) {
|
||||
return setMessageCode(uCode >> 16, uCode);
|
||||
}
|
||||
|
||||
int setMessageCode_inReset_(const TProcessor* pProcessor, u16 u16GroupID, u16 u16Index) {
|
||||
JUT_ASSERT(138, pEntry_==NULL);
|
||||
JUT_ASSERT(139, pszText_update_current_==NULL);
|
||||
JUT_ASSERT(140, oStack_renderingProcessor_.empty());
|
||||
|
||||
if (!setMessageCode_inSequence_(pProcessor, u16GroupID, u16Index)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isReady_update_()) {
|
||||
pSequenceProcessor_->setBegin_messageEntryText(pResourceCache_, pEntry_, pMessageText_begin_);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* getMessageText_begin() const { return pMessageText_begin_; }
|
||||
void* getMessageEntry() const { return pEntry_; }
|
||||
u32 getMessageCode() const { return (uMessageGroupID_ << 16) | uMessageID_; }
|
||||
void setSequenceProcessor(TSequenceProcessor* pProcessor) { pSequenceProcessor_ = pProcessor; }
|
||||
void setRenderingProcessor(TRenderingProcessor* pProcessor) { pRenderingProcessor_ = pProcessor; }
|
||||
|
||||
void resetResourceCache() {
|
||||
if (pSequenceProcessor_ != NULL) {
|
||||
pSequenceProcessor_->resetResourceCache();
|
||||
}
|
||||
|
||||
if (pRenderingProcessor_ != NULL) {
|
||||
pRenderingProcessor_->resetResourceCache();
|
||||
}
|
||||
|
||||
pResourceCache_ = NULL;
|
||||
}
|
||||
|
||||
void render_synchronize() {
|
||||
if (isReady_render_()) {
|
||||
pMessageText_current_ = pszText_update_current_;
|
||||
oStack_renderingProcessor_ = pRenderingProcessor_->oStack_;
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x04 */ TSequenceProcessor* pSequenceProcessor_;
|
||||
/* 0x08 */ TRenderingProcessor* pRenderingProcessor_;
|
||||
/* 0x0C */ u16 uMessageGroupID_;
|
||||
/* 0x0E */ u16 uMessageID_;
|
||||
/* 0x10 */ const TResource* pResourceCache_;
|
||||
/* 0x14 */ void* pEntry_;
|
||||
/* 0x18 */ const char* pMessageText_begin_;
|
||||
/* 0x1C */ const char* pszText_update_current_;
|
||||
/* 0x20 */ const char* pMessageText_current_;
|
||||
/* 0x24 */ TProcessor::TStack_ oStack_renderingProcessor_;
|
||||
};
|
||||
}; // namespace JMessage
|
||||
|
||||
#endif /* JMESSAGE_CONTROL_H */
|
||||
@@ -0,0 +1,102 @@
|
||||
#ifndef JMESSAGE_DATA_H
|
||||
#define JMESSAGE_DATA_H
|
||||
|
||||
#include "JSystem/JGadget/binary.h"
|
||||
|
||||
namespace JMessage {
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct data {
|
||||
// TParse_THeader handles parsing the BMG file header data
|
||||
struct TParse_THeader : public JGadget::binary::TParseData_aligned<4> {
|
||||
TParse_THeader(const void* pData) : TParseData_aligned(pData) {}
|
||||
|
||||
const void* getContent() const { return (char*)getRaw() + 0x20; }
|
||||
char* get() const { return (char*)getRaw(); }
|
||||
|
||||
u32* get_signature() const { return (u32*)(get() + 0x0); }
|
||||
u32 get_type() const { return *(u32*)(get() + 0x4); }
|
||||
u32 get_blockNumber() const { return *(u32*)(get() + 0xC); }
|
||||
u32 get_encoding() const { return *(u8*)(get() + 0x10); }
|
||||
};
|
||||
|
||||
// TParse_TBlock handles parsing the generic section header data
|
||||
struct TParse_TBlock : public JGadget::binary::TParseData_aligned<4> {
|
||||
TParse_TBlock(const void* pData) : TParseData_aligned(pData) {}
|
||||
|
||||
const char* get() const { return (char*)getRaw(); }
|
||||
u32 get_size() const { return *(u32*)(get() + 0x4); }
|
||||
const void* getNext() const { return (char*)getRaw() + get_size(); }
|
||||
u32 get_type() const { return *(u32*)(get() + 0x0); }
|
||||
};
|
||||
|
||||
// TParse_TBlock_info handles parsing INF1 section data
|
||||
struct TParse_TBlock_info : public TParse_TBlock {
|
||||
TParse_TBlock_info(const void* pData) : TParse_TBlock(pData) {}
|
||||
|
||||
char* get() const { return (char*)getRaw(); }
|
||||
|
||||
char* getContent() const { return (char*)getRaw() + 0x10; }
|
||||
|
||||
u32 get_messageEntrySize() const { return *(u16*)(get() + 0xA); }
|
||||
|
||||
u32 get_messageEntryNumber() const { return *(u16*)(get() + 0x8); }
|
||||
|
||||
u16 get_groupID() const { return *(u16*)(get() + 0xC); }
|
||||
};
|
||||
|
||||
// TParse_TBlock_messageID handles parsing MID1 section data
|
||||
struct TParse_TBlock_messageID : public TParse_TBlock {
|
||||
TParse_TBlock_messageID(const void* pData) : TParse_TBlock(pData) {}
|
||||
|
||||
char* get() const { return (char*)getRaw(); }
|
||||
u8 get_formSupplement() const { return *(u8*)(get() + 0xB); }
|
||||
int get_number() const { return *(u16*)(get() + 0x8); }
|
||||
u32* getContent() const { return (u32*)((u32)getRaw() + 0x10); }
|
||||
u32 get_form() const { return *(u8*)(get() + 0xA) & 0xF; }
|
||||
bool get_isOrdered() const { return *(u8*)(get() + 0xA) & 0xF0; }
|
||||
};
|
||||
|
||||
struct TParse_TBlock_color : public TParse_TBlock {
|
||||
TParse_TBlock_color(const void* pData) : TParse_TBlock(pData) {}
|
||||
};
|
||||
|
||||
// TParse_TBlock_messageText handles parsing DAT1 section data
|
||||
struct TParse_TBlock_messageText : public TParse_TBlock {
|
||||
TParse_TBlock_messageText(const void* pData) : TParse_TBlock(pData) {}
|
||||
|
||||
char* getContent() const { return (char*)getRaw() + 0x8; }
|
||||
};
|
||||
|
||||
// TParse_TBlock_stringAttribute handles parsing STR1 section data
|
||||
struct TParse_TBlock_stringAttribute : public TParse_TBlock {
|
||||
TParse_TBlock_stringAttribute(const void* pData) : TParse_TBlock(pData) {}
|
||||
|
||||
char* getContent() const { return (char*)getRaw() + 0x8; }
|
||||
};
|
||||
|
||||
static unsigned int getTagCode(u32 tag) { return tag & 0xFFFF; }
|
||||
static u8 getTagGroup(u32 tag) { return tag >> 0x10; }
|
||||
|
||||
static const u32 ga4cSignature;
|
||||
static const u32 ga4cSignature_color;
|
||||
|
||||
static const int gcTagBegin = '\x1A'; // All text Control Tags will begin with this character
|
||||
|
||||
enum {
|
||||
MESSAGEINDEX_USER_ENUM_MIN = 0x0000,
|
||||
MESSAGEINDEX_USER_ENUM_MAX = 0xFEFF,
|
||||
|
||||
MESSAGEINDEX_RESERVED_ENUM_MIN = 0xFF00,
|
||||
MESSAGEINDEX_RESERVED_ENUM_MAX = 0xFFFF,
|
||||
|
||||
MESSAGEGROUPID_USER_ENUM_MIN = 0x0000,
|
||||
MESSAGEGROUPID_USER_ENUM_MAX = 0xFFFF,
|
||||
};
|
||||
};
|
||||
}; // namespace JMessage
|
||||
|
||||
#endif /* JMESSAGE_DATA_H */
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef JMESSAGE_LOCALE_H
|
||||
#define JMESSAGE_LOCALE_H
|
||||
|
||||
#ifdef __REVOLUTION_SDK__
|
||||
#include <revolution.h>
|
||||
#else
|
||||
#include <dolphin.h>
|
||||
#endif
|
||||
|
||||
namespace JMessage {
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct locale {
|
||||
typedef int (*parseCharacter_function)(const char**);
|
||||
|
||||
static bool isLeadByte_ShiftJIS(int c) {
|
||||
return c >= 0x81 && (c <= 0x9F || (c >= 0xE0 && c <= 0xFC));
|
||||
}
|
||||
|
||||
static int parseCharacter_1Byte(const char** ppszText);
|
||||
static int parseCharacter_2Byte(const char** ppszText);
|
||||
static int parseCharacter_ShiftJIS(const char** ppszText);
|
||||
static int parseCharacter_UTF8(const char** ppszText);
|
||||
};
|
||||
}; // namespace JMessage
|
||||
|
||||
#endif /* JMESSAGE_LOCALE_H */
|
||||
@@ -0,0 +1,363 @@
|
||||
#ifndef JMESSAGE_PROCESSOR_H
|
||||
#define JMESSAGE_PROCESSOR_H
|
||||
|
||||
#include "JSystem/JMessage/resource.h"
|
||||
#include <algorithm>
|
||||
#include "global.h"
|
||||
|
||||
namespace JMessage {
|
||||
struct TResource;
|
||||
struct TResourceContainer;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct TReference {
|
||||
TReference() { pcResource_ = NULL; }
|
||||
|
||||
virtual ~TReference();
|
||||
virtual const char* do_word(u32) const;
|
||||
|
||||
int on_parseCharacter(const char** ppszText) const {
|
||||
JUT_ASSERT(97, pcResource_!=NULL);
|
||||
return pcResource_->parseCharacter(ppszText);
|
||||
}
|
||||
|
||||
const char* on_word(u32 param_0) const { return do_word(param_0); }
|
||||
|
||||
TResource* getResource_groupID(u16 u16GroupID) const {
|
||||
return pcResource_ == NULL ? NULL : pcResource_->getResource_groupID(u16GroupID);
|
||||
}
|
||||
|
||||
TResourceContainer* getResourceContainer() const { return pcResource_; }
|
||||
void setResourceContainer(TResourceContainer* container) { pcResource_ = container; }
|
||||
|
||||
/* 0x4 */ TResourceContainer* pcResource_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct TProcessor {
|
||||
TProcessor(const TReference* pReference)
|
||||
: pReference_(pReference),
|
||||
pResourceCache_(NULL),
|
||||
pszCurrent_(NULL)
|
||||
{
|
||||
JUT_ASSERT(584, pReference_!=NULL);
|
||||
}
|
||||
|
||||
typedef bool (*pfnProcess_func)(TProcessor*);
|
||||
|
||||
struct TStack_ {
|
||||
TStack_() { clear(); }
|
||||
|
||||
bool empty() const { return upsz_ == 0; }
|
||||
bool IsPushable() const { return size() < max_size(); }
|
||||
|
||||
void clear() { upsz_ = 0; }
|
||||
u32 max_size() const { return 4; }
|
||||
u32 size() const { return upsz_; }
|
||||
|
||||
const char* top() const {
|
||||
JUT_ASSERT(181, upsz_>0);
|
||||
return stack[upsz_ - 1];
|
||||
}
|
||||
|
||||
void push(const char* pszText) {
|
||||
JUT_ASSERT(186, IsPushable());
|
||||
stack[upsz_] = pszText;
|
||||
upsz_++;
|
||||
}
|
||||
|
||||
void pop() {
|
||||
JUT_ASSERT(192, upsz_>0);
|
||||
upsz_--;
|
||||
|
||||
#if PLATFORM_SHIELD
|
||||
stack[upsz_] = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
TStack_& operator=(const TStack_& other) {
|
||||
upsz_ = other.upsz_;
|
||||
char** start = (char**)other.stack;
|
||||
char** end = (char**)(other.stack + other.upsz_);
|
||||
std::copy(start, end, stack);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* 0x0 */ u32 upsz_; // stack size
|
||||
/* 0x4 */ const char* stack[4];
|
||||
}; // Size: 0x14
|
||||
|
||||
struct TProcess_ {
|
||||
TProcess_() { reset_normal(); }
|
||||
|
||||
void reset_normal() { pfnProcess_onCharacterEnd = process_onCharacterEnd_normal_; }
|
||||
void reset_select() { pfnProcess_onCharacterEnd = process_onCharacterEnd_select_; }
|
||||
|
||||
/* 0x0 */ pfnProcess_func pfnProcess_onCharacterEnd;
|
||||
struct rdata {
|
||||
/* 0x0 */ const char* (*pfn)(TProcessor*);
|
||||
/* 0x4 */ const char* pcBase;
|
||||
/* 0x8 */ const void* pOffset;
|
||||
/* 0xC */ u32 uRest;
|
||||
}
|
||||
/* 0x4 */ rData;
|
||||
}; // Size: 0x14
|
||||
|
||||
void reset();
|
||||
void stack_pushCurrent(char const* pszText);
|
||||
void stack_popCurrent();
|
||||
const TResource* getResource_groupID(u16 u16GroupID) const;
|
||||
u32 toMessageCode_messageID(u32 uMsgID, u32, bool* pbValid) const;
|
||||
void on_select_begin(char const* (*pfn)(JMessage::TProcessor*), void const* pOffset,
|
||||
char const* pcBase, u32 uNumber);
|
||||
void on_select_end();
|
||||
void on_select_separate();
|
||||
void on_tag_();
|
||||
bool process_character_();
|
||||
static bool process_onCharacterEnd_normal_(JMessage::TProcessor* pThis);
|
||||
static bool process_onCharacterEnd_select_(JMessage::TProcessor* pThis);
|
||||
static const char* process_onSelect_limited_(JMessage::TProcessor* pThis);
|
||||
static const char* process_onSelect_(JMessage::TProcessor* pThis);
|
||||
const char* on_message(u32 uCode) const { return getMessageText_messageCode(uCode); }
|
||||
const char* getMessageText_messageCode(u32 uCode) const {
|
||||
return getMessageText_messageCode(uCode >> 16, uCode & 0xFFFF);
|
||||
}
|
||||
|
||||
virtual ~TProcessor();
|
||||
virtual void do_reset();
|
||||
virtual void do_begin(void const* pEntry, char const* pszText);
|
||||
virtual void do_end();
|
||||
virtual void do_character(int iCharacter);
|
||||
virtual bool do_tag(u32 uTag, void const* pData, u32 uSize);
|
||||
virtual void do_select_begin(u32 uNumber);
|
||||
virtual void do_select_end();
|
||||
virtual void do_select_separate();
|
||||
virtual void do_resetStatus_(char const* pszText);
|
||||
virtual bool do_setBegin_isReady_() const;
|
||||
virtual void do_begin_(void const* pEntry, char const* pszText) = 0;
|
||||
virtual void do_end_() = 0;
|
||||
virtual void do_tag_(u32 uTag, void const* pData, u32 uSize) = 0;
|
||||
|
||||
void on_resetStatus_(const char* pszText) {
|
||||
pszCurrent_ = pszText;
|
||||
oStack_.clear();
|
||||
oProcess_.reset_normal();
|
||||
do_resetStatus_(pszText);
|
||||
}
|
||||
|
||||
void on_begin(const void* pEntry, const char* pszText) {
|
||||
do_begin_(pEntry, pszText);
|
||||
do_begin(pEntry, pszText);
|
||||
}
|
||||
|
||||
void on_end() {
|
||||
do_end_();
|
||||
do_end();
|
||||
}
|
||||
|
||||
void on_tag(u32 uTag, const void* pData, u32 uSize) {
|
||||
if (!do_tag(uTag, pData, uSize)) {
|
||||
do_tag_(uTag, pData, uSize);
|
||||
}
|
||||
}
|
||||
|
||||
const char* on_word(u32 param_0) const { return pReference_->on_word(param_0); }
|
||||
|
||||
int on_parseCharacter(const char** ppszText) const {
|
||||
return pReference_->on_parseCharacter(ppszText);
|
||||
}
|
||||
void on_character(int iCharacter) { do_character(iCharacter); }
|
||||
|
||||
const char* on_message_limited(u16 u16Index) const {
|
||||
JUT_ASSERT(482, pResourceCache_!=NULL);
|
||||
return pResourceCache_->getMessageText_messageIndex(u16Index);
|
||||
}
|
||||
|
||||
bool on_setBegin_isReady_() const { return do_setBegin_isReady_(); }
|
||||
|
||||
int setBegin_messageEntryText(const TResource* pResource, const void* pEntry, const char* pszText) {
|
||||
JUT_ASSERT(297, on_setBegin_isReady_());
|
||||
pResourceCache_ = pResource;
|
||||
on_resetStatus_(pszText);
|
||||
on_begin(pEntry, pszText);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int setBegin_messageEntryText(const TProcessor* pProcessor, const void* pEntry, const char* pszText) {
|
||||
JUT_ASSERT(306, pProcessor!=NULL);
|
||||
setBegin_messageEntryText(pProcessor->getResourceCache(), pEntry, pszText);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void* getMessageEntry_messageCode(u16 u16Code, u16 u16Index) const {
|
||||
const TResource* pResource = getResource_groupID(u16Code);
|
||||
|
||||
if (pResource == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pResource->getMessageEntry_messageIndex(u16Index);
|
||||
}
|
||||
|
||||
const char* getMessageText_messageCode(u16 u16Code, u16 u16Index) const {
|
||||
void* pEntry = getMessageEntry_messageCode(u16Code, u16Index);
|
||||
|
||||
if (pEntry == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pResourceCache_->getMessageText_messageEntry(pEntry);
|
||||
}
|
||||
|
||||
void stack_pushCurrent_(const char* pszText) {
|
||||
oStack_.push(getCurrent());
|
||||
pszCurrent_ = pszText;
|
||||
}
|
||||
|
||||
void stack_popCurrent_() {
|
||||
pszCurrent_ = oStack_.top();
|
||||
oStack_.pop();
|
||||
}
|
||||
|
||||
bool stack_isPushable() const { return oStack_.IsPushable(); }
|
||||
|
||||
const TResource* getResourceCache() const { return pResourceCache_; }
|
||||
const char* getCurrent() const { return pszCurrent_; }
|
||||
const TReference* getReference() const { return pReference_; }
|
||||
|
||||
const TResource* getResource_groupID_uncached(u16 u16GroupID) const {
|
||||
return pReference_->getResource_groupID(u16GroupID);
|
||||
}
|
||||
|
||||
bool isResourceCache_groupID(u16 u16GroupID) const {
|
||||
return pResourceCache_ != NULL && u16GroupID == pResourceCache_->getGroupID();
|
||||
}
|
||||
|
||||
TResourceContainer* getResourceContainer() const {
|
||||
return pReference_ == NULL ? NULL : pReference_->getResourceContainer();
|
||||
}
|
||||
|
||||
void setResourceCache(TResource* pResource) { pResourceCache_ = pResource; }
|
||||
void resetResourceCache() { setResourceCache(NULL); }
|
||||
|
||||
/* 0x04 */ const TReference* pReference_;
|
||||
/* 0x08 */ const mutable TResource* pResourceCache_;
|
||||
/* 0x0C */ const char* pszCurrent_;
|
||||
/* 0x10 */ TStack_ oStack_;
|
||||
/* 0x24 */ TProcess_ oProcess_;
|
||||
};
|
||||
|
||||
struct TControl;
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct TSequenceProcessor : public TProcessor {
|
||||
typedef const void* (*branchPfn)(const TSequenceProcessor*, u32);
|
||||
typedef const void* (*jumpPfn)(const TSequenceProcessor*);
|
||||
|
||||
struct TProcess_ {
|
||||
TProcess_() { reset(); }
|
||||
|
||||
void reset() {}
|
||||
|
||||
union processData {
|
||||
struct branchData {
|
||||
/* 0x0 */ branchPfn branchFn;
|
||||
/* 0x4 */ const void* pTarget;
|
||||
/* 0x8 */ u32 uTarget;
|
||||
} branch_process;
|
||||
struct jumpData {
|
||||
/* 0x0 */ jumpPfn jumpFn;
|
||||
/* 0x4 */ u32 u32Target;
|
||||
} jump_process;
|
||||
}
|
||||
/* 0x0 */ process;
|
||||
};
|
||||
|
||||
enum SeqStatus {
|
||||
STATUS_READY,
|
||||
STATUS_ONE,
|
||||
STATUS_NORMAL,
|
||||
STATUS_JUMP,
|
||||
STATUS_BRANCH,
|
||||
};
|
||||
|
||||
TSequenceProcessor(JMessage::TReference const* pReference, JMessage::TControl* pControl);
|
||||
const char* process(char const* pszText);
|
||||
bool on_isReady();
|
||||
void on_jump_register(jumpPfn pfn, u32 u32Target);
|
||||
bool on_jump_isReady();
|
||||
void on_jump(void const* pEntry, char const* pszText);
|
||||
void on_branch_register(branchPfn pfn, void const* pTarget, u32 uTarget);
|
||||
void on_branch_query(u32 uCode);
|
||||
u32 on_branch_queryResult();
|
||||
void on_branch(void const* pEntry, char const* pszText);
|
||||
static void process_setMessageIndex_reserved_(u16 u16Index);
|
||||
static void* process_setMessageCode_(TSequenceProcessor const* pProcessor, u16 u16GroupID, u16 u16Index);
|
||||
static const void* process_onJump_limited_(TSequenceProcessor const* pProcessor);
|
||||
static const void* process_onJump_(TSequenceProcessor const* pProcessor);
|
||||
static const void* process_onBranch_limited_(TSequenceProcessor const* pProcessor, u32 uTargetIndex);
|
||||
static const void* process_onBranch_(TSequenceProcessor const* pProcessor, u32 uTargetIndex);
|
||||
|
||||
virtual ~TSequenceProcessor();
|
||||
virtual void do_resetStatus_(char const* pszText);
|
||||
virtual bool do_setBegin_isReady_() const;
|
||||
virtual void do_begin_(void const* pEntry, char const* pszText);
|
||||
virtual void do_end_();
|
||||
virtual void do_tag_(u32 uTag, void const* pData, u32 uSize);
|
||||
virtual bool do_isReady();
|
||||
virtual bool do_jump_isReady();
|
||||
virtual void do_jump(void const* pEntry, char const* pszText);
|
||||
virtual void do_branch_query(u32 uCode);
|
||||
virtual s32 do_branch_queryResult();
|
||||
virtual void do_branch(void const* pEntry, char const* pszText);
|
||||
|
||||
TControl* getControl() const { return pControl_; }
|
||||
|
||||
static const void* process_setMessageIndex_(const TSequenceProcessor* pProcessor, u16 u16Index) {
|
||||
return process_setMessageCode_(pProcessor, pProcessor->getResourceCache()->getGroupID(),
|
||||
u16Index);
|
||||
}
|
||||
|
||||
static const void* process_setMessageCode_(const TSequenceProcessor* pProcessor, u32 uCode) {
|
||||
return process_setMessageCode_(pProcessor, uCode >> 16, uCode & 0xFFFF);
|
||||
}
|
||||
|
||||
/* 0x38 */ TControl* pControl_;
|
||||
/* 0x3C */ SeqStatus eStatus_;
|
||||
/* 0x40 */ TProcess_ oProcess2_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct TRenderingProcessor : public TProcessor {
|
||||
TRenderingProcessor(JMessage::TReference const* pReference);
|
||||
int process(char const* pszText);
|
||||
|
||||
virtual ~TRenderingProcessor();
|
||||
virtual void do_begin_(void const* pEntry, char const* pszText);
|
||||
virtual void do_end_();
|
||||
virtual void do_tag_(u32 uTag, void const* pData, u32 uSize);
|
||||
|
||||
bool process_messageEntryText(const TProcessor* pProcessor, void const* pEntry, const char* pszText) {
|
||||
if (!TProcessor::setBegin_messageEntryText(pProcessor, pEntry, pszText)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
process(NULL);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}; // namespace JMessage
|
||||
|
||||
#endif /* JMESSAGE_PROCESSOR_H */
|
||||
@@ -0,0 +1,171 @@
|
||||
#ifndef JMESSAGE_RESOURCE_H
|
||||
#define JMESSAGE_RESOURCE_H
|
||||
|
||||
#include "JSystem/JGadget/linklist.h"
|
||||
#include "JSystem/JMessage/data.h"
|
||||
#include "JSystem/JMessage/locale.h"
|
||||
|
||||
namespace JMessage {
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct TResource {
|
||||
TResource()
|
||||
: oParse_THeader_(NULL),
|
||||
oParse_TBlock_info_(NULL),
|
||||
pMessageText_(NULL),
|
||||
pStringAttribute_(NULL),
|
||||
oParse_TBlock_messageID_(NULL)
|
||||
{}
|
||||
|
||||
u16 toMessageIndex_messageID(u32 uMsgID, u32, bool* pbValid) const;
|
||||
|
||||
bool isContained_messageIndex(u16 uMessageIndex) const {
|
||||
return uMessageIndex < getMessageEntryNumber();
|
||||
}
|
||||
|
||||
u32 getMessageEntrySize() const { return oParse_TBlock_info_.get_messageEntrySize(); }
|
||||
u32 getMessageEntryNumber() const { return oParse_TBlock_info_.get_messageEntryNumber(); }
|
||||
|
||||
u16 getGroupID() const { return oParse_TBlock_info_.get_groupID(); }
|
||||
|
||||
void* getMessageEntry_messageIndex(u16 uMessageIndex) const {
|
||||
if (!isContained_messageIndex(uMessageIndex)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* pEntry = oParse_TBlock_info_.getContent() + (uMessageIndex * getMessageEntrySize());
|
||||
return pEntry;
|
||||
}
|
||||
|
||||
char* getMessageText_messageEntry(const void* pEntry) const {
|
||||
JUT_ASSERT(141, pEntry!=NULL);
|
||||
return pMessageText_ + *(int*)pEntry;
|
||||
}
|
||||
|
||||
const char* getMessageText_messageIndex(u16 uMessageIndex) const {
|
||||
void* pEntry = getMessageEntry_messageIndex(uMessageIndex);
|
||||
if (pEntry == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return getMessageText_messageEntry(pEntry);
|
||||
}
|
||||
|
||||
void setData_header(const void* pData) {
|
||||
oParse_THeader_.setRaw(pData);
|
||||
}
|
||||
|
||||
void setData_block_info(const void* pData) {
|
||||
oParse_TBlock_info_.setRaw(pData);
|
||||
|
||||
JGADGET_ASSERTWARN(75, oParse_TBlock_info_.get_groupID()<= data::MESSAGEGROUPID_USER_ENUM_MAX);
|
||||
|
||||
JGADGET_ASSERTWARN(77, oParse_TBlock_info_.get_messageEntryNumber()<= data::MESSAGEINDEX_USER_ENUM_MAX);
|
||||
}
|
||||
|
||||
void setData_block_messageText(const void* pData) {
|
||||
pMessageText_ = data::TParse_TBlock_messageText(pData).getContent();
|
||||
}
|
||||
|
||||
void setData_block_stringAttribute(const void* pData) {
|
||||
pStringAttribute_ = data::TParse_TBlock_stringAttribute(pData).getContent();
|
||||
}
|
||||
|
||||
void setData_block_messageID(const void* pData) {
|
||||
oParse_TBlock_messageID_.setRaw(pData);
|
||||
}
|
||||
|
||||
JGadget::TLinkListNode ocObject_;
|
||||
/* 0x08 */ data::TParse_THeader oParse_THeader_;
|
||||
/* 0x0C */ data::TParse_TBlock_info oParse_TBlock_info_;
|
||||
/* 0x10 */ char* pMessageText_;
|
||||
/* 0x14 */ char* pStringAttribute_;
|
||||
/* 0x18 */ data::TParse_TBlock_messageID oParse_TBlock_messageID_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct TResource_color {
|
||||
TResource_color()
|
||||
: oParse_THeader_(NULL),
|
||||
oParse_TBlock_color_(NULL)
|
||||
{}
|
||||
|
||||
void reset() {
|
||||
oParse_THeader_.setRaw(NULL);
|
||||
oParse_TBlock_color_.setRaw(NULL);
|
||||
}
|
||||
|
||||
/* 0x0 */ data::TParse_THeader oParse_THeader_;
|
||||
/* 0x4 */ data::TParse_TBlock_color oParse_TBlock_color_;
|
||||
}; // Size: 0x8
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct TResourceContainer {
|
||||
struct TCResource : public JGadget::TLinkList_factory<TResource, 0> {
|
||||
TCResource();
|
||||
TResource* Get_groupID(u16 u16GroupID);
|
||||
|
||||
virtual ~TCResource();
|
||||
virtual JMessage::TResource* Do_create();
|
||||
virtual void Do_destroy(JMessage::TResource* pResource);
|
||||
};
|
||||
|
||||
TResourceContainer();
|
||||
void setEncoding(u8 e);
|
||||
void setEncoding_(u8 e);
|
||||
|
||||
int parseCharacter(const char** ppszText) const {
|
||||
JUT_ASSERT(330, pfnParseCharacter_!=NULL);
|
||||
return pfnParseCharacter_(ppszText);
|
||||
}
|
||||
|
||||
TResource* getResource_groupID(u16 u16GroupID) { return resContainer_.Get_groupID(u16GroupID); }
|
||||
TResource* getResource_groupID(u16 u16GroupID) const { return getResource_groupID(u16GroupID); }
|
||||
|
||||
bool isEncodingSettable(u8 e) const { return encodingType_ == e || encodingType_ == 0; }
|
||||
const TCResource* getResourceContainer() const { return &resContainer_; }
|
||||
void destroyResource() {
|
||||
resContainer_.Clear_destroy();
|
||||
}
|
||||
void destroyResource_color() {
|
||||
resColor_.reset();
|
||||
}
|
||||
void destroyResource_all() {
|
||||
destroyResource();
|
||||
destroyResource_color();
|
||||
}
|
||||
|
||||
static JMessage::locale::parseCharacter_function sapfnParseCharacter_[5];
|
||||
|
||||
/* 0x00 */ u8 encodingType_;
|
||||
/* 0x04 */ JMessage::locale::parseCharacter_function pfnParseCharacter_;
|
||||
/* 0x08 */ TCResource resContainer_;
|
||||
/* 0x18 */ TResource_color resColor_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jmessage
|
||||
*
|
||||
*/
|
||||
struct TParse : public JGadget::binary::TParse_header_block {
|
||||
TParse(JMessage::TResourceContainer* pContainer);
|
||||
|
||||
virtual ~TParse();
|
||||
virtual bool parseHeader_next(const void** ppData_inout, u32* puBlock_out, u32);
|
||||
virtual bool parseBlock_next(const void** ppData_inout, u32* puData_out, u32);
|
||||
|
||||
/* 0x4 */ TResourceContainer* pContainer_;
|
||||
/* 0x8 */ TResource* pResource_;
|
||||
};
|
||||
}; // namespace JMessage
|
||||
|
||||
#endif /* JMESSAGE_RESOURCE_H */
|
||||
Reference in New Issue
Block a user