mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-09-03 00:53:47 -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,132 @@
|
||||
#ifndef JHICOMM_H
|
||||
#define JHICOMM_H
|
||||
|
||||
#include "JSystem/JHostIO/JHICommonMem.h"
|
||||
|
||||
class JHICommBufHeader {
|
||||
public:
|
||||
void init();
|
||||
void init(JHICommonMem*, u32, u32, u32);
|
||||
int load();
|
||||
|
||||
u32 getMsgBufSize() { return m_msgBufSize; }
|
||||
|
||||
/* 0x00 */ JHICommonMem* mp_memBuffer;
|
||||
/* 0x04 */ u32 field_0x4;
|
||||
/* 0x08 */ u32 m_msgBufSize;
|
||||
/* 0x0C */ u32 field_0xc;
|
||||
/* 0x10 */ u32 field_0x10;
|
||||
/* 0x14 */ u32 field_0x14;
|
||||
/* 0x18 */ u32 field_0x18;
|
||||
/* 0x1C */ u32 field_0x1c;
|
||||
/* 0x20 */ u32 field_0x20;
|
||||
/* 0x24 */ u32 field_0x24;
|
||||
/* 0x28 */ u32 m_alignment;
|
||||
/* 0x2C */ u32 field_0x2c;
|
||||
};
|
||||
|
||||
class JHICommBufWriter {
|
||||
public:
|
||||
struct Header : public JHICommBufHeader {
|
||||
int load();
|
||||
int getRemSize();
|
||||
void updatePutAdrs();
|
||||
u32 getWritebleSize() const;
|
||||
void alignPutAdrs();
|
||||
void addPutAdrs(int);
|
||||
u32 getPutAdrs() const;
|
||||
|
||||
/* 0x30 */ u8 field_0x30;
|
||||
/* 0x31 */ u8 field_0x31;
|
||||
/* 0x32 */ u8 field_0x32;
|
||||
/* 0x33 */ u8 field_0x33;
|
||||
/* 0x34 */ u32 field_0x34;
|
||||
};
|
||||
|
||||
JHICommBufWriter(u32, u32, u32 alignment);
|
||||
int writeBegin();
|
||||
void writeEnd();
|
||||
int write(void*, int);
|
||||
|
||||
void init() { m_header.init(); }
|
||||
|
||||
/* 0x00 */ Header m_header;
|
||||
/* 0x38 */ JHIMemBuf* mp_memBuffer;
|
||||
};
|
||||
|
||||
class JHICommBufReader {
|
||||
public:
|
||||
struct Header : public JHICommBufHeader {
|
||||
void updateGetAdrs();
|
||||
u32 getReadableSize() const;
|
||||
void addGetAdrs(int);
|
||||
u32 getGetAdrs() const;
|
||||
void alignGetAdrs();
|
||||
int getContSize();
|
||||
|
||||
int load() {
|
||||
int result = JHICommBufHeader::load();
|
||||
if (!result) {
|
||||
field_0x30 = field_0xc;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* 0x30 */ u32 field_0x30;
|
||||
};
|
||||
|
||||
JHICommBufReader(u32, u32, u32 alignment);
|
||||
int readBegin();
|
||||
void readEnd();
|
||||
int read(void*, int);
|
||||
|
||||
u32 getMsgBufSize() { return m_header.getMsgBufSize(); }
|
||||
void init() { m_header.init(); }
|
||||
|
||||
u32 available() {
|
||||
if (m_header.load()) {
|
||||
return 0xFFFFFFFF;
|
||||
} else {
|
||||
return m_header.getReadableSize();
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x00 */ Header m_header;
|
||||
/* 0x34 */ JHIMemBuf* mp_memBuffer;
|
||||
};
|
||||
|
||||
struct JHICmnMem {
|
||||
u32 sendBegin() { return mp_writeBuf->writeBegin(); }
|
||||
int sendCont(const void* param_0, int param_1) { return mp_writeBuf->write((void*)param_0, param_1); }
|
||||
void sendEnd() { mp_writeBuf->writeEnd(); }
|
||||
u32 available() { return mp_readBuf->available(); }
|
||||
u32 getMaxReaderableSize() { return mp_readBuf->getMsgBufSize(); }
|
||||
|
||||
void setBuf(JHICommBufReader* pReader, JHICommBufWriter* pWriter) {
|
||||
mp_readBuf = pReader;
|
||||
mp_writeBuf = pWriter;
|
||||
}
|
||||
|
||||
void initBuffers() {
|
||||
mp_readBuf->init();
|
||||
mp_writeBuf->init();
|
||||
}
|
||||
|
||||
int receive(void* param_1, int param_2) {
|
||||
int result = 0;
|
||||
result = mp_readBuf->read(param_1, param_2);
|
||||
mp_readBuf->readEnd();
|
||||
return result;
|
||||
}
|
||||
|
||||
/* 0x0 */ JHICommBufReader* mp_readBuf;
|
||||
/* 0x4 */ JHICommBufWriter* mp_writeBuf;
|
||||
/* 0x8 */ u8 field_0x8;
|
||||
};
|
||||
|
||||
struct JHIContext {
|
||||
JHICommBufReader* mp_reader;
|
||||
JHICommBufWriter* mp_writer;
|
||||
};
|
||||
|
||||
#endif /* JHICOMM_H */
|
||||
@@ -0,0 +1,83 @@
|
||||
#ifndef JHICOMMONMEM_H
|
||||
#define JHICOMMONMEM_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
inline u32 JHIhtonl(u32 v) {
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
return v;
|
||||
#else
|
||||
// todo
|
||||
#endif
|
||||
}
|
||||
|
||||
inline u32 JHIntohl(u32 v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T> class JHIComPortManager;
|
||||
|
||||
template <typename T>
|
||||
struct JHITag {
|
||||
JHITag(u32 tag) {
|
||||
m_tag = tag;
|
||||
mp_data = NULL;
|
||||
}
|
||||
|
||||
s32 send(const void* param_0, s32 param_1) {
|
||||
u32 sp10[2];
|
||||
sp10[0] = JHIhtonl(m_tag);
|
||||
sp10[1] = JHIhtonl(param_1);
|
||||
|
||||
if (mp_data->port.sendBegin() >= param_1 + 8) {
|
||||
mp_data->port.sendCont(sp10, 8);
|
||||
mp_data->port.sendCont(param_0, param_1);
|
||||
mp_data->port.sendEnd();
|
||||
}
|
||||
|
||||
return param_1;
|
||||
}
|
||||
|
||||
virtual ~JHITag() {}
|
||||
virtual void receive(const char*, s32) {}
|
||||
|
||||
/* 0x4 */ u32 m_tag;
|
||||
/* 0x8 */ JHIComPortManager<T>* mp_data;
|
||||
};
|
||||
|
||||
class JHIMemBuf;
|
||||
|
||||
class JHICommonMem {
|
||||
public:
|
||||
virtual ~JHICommonMem() {}
|
||||
virtual int create() = 0;
|
||||
virtual int open() = 0;
|
||||
virtual void close() = 0;
|
||||
virtual u8* getPointer() const = 0;
|
||||
virtual void readIO(u32 position, u32* out_data) const = 0;
|
||||
virtual u32 readIO(u32 position) const = 0;
|
||||
virtual void writeIO(u32 position, u32 data) const = 0;
|
||||
virtual void writeIO(u32 position, u8* src_data, u32 length) const = 0;
|
||||
|
||||
static JHIMemBuf* Instance();
|
||||
static JHIMemBuf* instance;
|
||||
};
|
||||
|
||||
class JHIMemBuf : public JHICommonMem {
|
||||
public:
|
||||
JHIMemBuf();
|
||||
|
||||
virtual ~JHIMemBuf();
|
||||
virtual int create();
|
||||
virtual int open();
|
||||
virtual void close();
|
||||
virtual u8* getPointer() const;
|
||||
virtual void readIO(u32 position, u32* out_data) const;
|
||||
virtual u32 readIO(u32 position) const;
|
||||
virtual void writeIO(u32 position, u32 data) const;
|
||||
virtual void writeIO(u32 position, u8* src_data, u32 length) const;
|
||||
|
||||
/* 0x4 */ u8* mp_buffer;
|
||||
};
|
||||
|
||||
#endif /* JHICOMMONMEM_H */
|
||||
@@ -0,0 +1,77 @@
|
||||
#ifndef JORMCCBUF_H_H
|
||||
#define JORMCCBUF_H_H
|
||||
|
||||
#include "JSystem/JHostIO/JHIComm.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
|
||||
class JHIMccBuf {
|
||||
public:
|
||||
JHIMccBuf(u16 channel, u16, u32);
|
||||
|
||||
void setHeaderToBuf(u32 data, u32 position, u16 size);
|
||||
u32 setDataToBuf(void* pData, u16 size);
|
||||
int readData(u32 position, u32* pOutData);
|
||||
int readDataFromBuf(void* pBuf, u32 size);
|
||||
|
||||
int JHIRead(u32 channel, u32 offset, void* buffer, u32 size);
|
||||
int JHIWrite(u32 channel, u32 offset, void* buffer, u32 size);
|
||||
|
||||
int JHIMCCWrite(u32 channel, u32 offset, void* buffer, u32 size);
|
||||
int JHIMCCRead(u32 channel, u32 offset, void* buffer, u32 size);
|
||||
|
||||
virtual ~JHIMccBuf();
|
||||
virtual void initInstance(u16 channel, u16, u32);
|
||||
virtual void init();
|
||||
virtual void initBuf();
|
||||
virtual void enablePort() { mPortEnabled = true; }
|
||||
virtual void disablePort() { mPortEnabled = false; }
|
||||
virtual bool isPort() { return mPortEnabled; }
|
||||
|
||||
static u8* mTempBuf;
|
||||
static u16 mRefCount;
|
||||
|
||||
/* 0x04 */ u32 mTag;
|
||||
/* 0x08 */ u16 field_0x8;
|
||||
/* 0x0A */ u16 field_0xa;
|
||||
/* 0x0C */ u16 field_0xc;
|
||||
/* 0x0E */ u16 mChannel;
|
||||
/* 0x10 */ u16 field_0x10;
|
||||
/* 0x14 */ int mReadOffset;
|
||||
/* 0x18 */ int mWriteOffset;
|
||||
/* 0x1C */ int field_0x1c;
|
||||
/* 0x20 */ u32 field_0x20;
|
||||
/* 0x24 */ u32 mBeginPos;
|
||||
/* 0x28 */ u32 mEndPos;
|
||||
/* 0x2C */ bool mPortEnabled;
|
||||
};
|
||||
|
||||
class JHIMccBufReader : public JHIMccBuf {
|
||||
public:
|
||||
JHIMccBufReader(u16 channel, u16, u32);
|
||||
virtual ~JHIMccBufReader();
|
||||
|
||||
u32 available();
|
||||
int readBegin();
|
||||
int read(void* pBuf);
|
||||
void readEnd();
|
||||
};
|
||||
|
||||
class JHIMccBufWriter : public JHIMccBuf {
|
||||
public:
|
||||
JHIMccBufWriter(u16 channel, u16, u32);
|
||||
virtual ~JHIMccBufWriter();
|
||||
|
||||
int writeBegin();
|
||||
int write(void* pBuf, u32 size);
|
||||
void writeEnd();
|
||||
};
|
||||
|
||||
struct JHIMccContext {
|
||||
JHIMccBufReader* mp_reader;
|
||||
JHIMccBufWriter* mp_writer;
|
||||
};
|
||||
|
||||
void JHIReport(const char* fmt, ...);
|
||||
void JHIHalt(const char* fmt, ...);
|
||||
|
||||
#endif /* JORMCCBUF_H_H */
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef JHIRMCC_H
|
||||
#define JHIRMCC_H
|
||||
|
||||
#ifdef __REVOLUTION_SDK__
|
||||
#include <revolution.h>
|
||||
#else
|
||||
#include <dolphin.h>
|
||||
#endif
|
||||
|
||||
struct JHIMccContext;
|
||||
|
||||
u32 JHIInitInterface();
|
||||
bool JHINegotiateInterface(u32);
|
||||
JHIMccContext JHIGetHiSpeedContext();
|
||||
JHIMccContext JHIGetLowSpeedContext();
|
||||
BOOL JHIInitMCC(JHIMccContext* pCtx, bool* param_1);
|
||||
s32 JHIGetHIO2Handle();
|
||||
|
||||
#endif /* JHIRMCC_H */
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef JHIHIOASYNC_H
|
||||
#define JHIHIOASYNC_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
struct JHIContext;
|
||||
|
||||
BOOL JHIInit(u32 enabled);
|
||||
u32 JHIEventLoop();
|
||||
BOOL JOR_CHECKINTERFACE();
|
||||
void JHISetBuffer(JHIContext* pCtx);
|
||||
|
||||
#endif /* JHIHIOASYNC_H */
|
||||
@@ -0,0 +1,113 @@
|
||||
#ifndef JORENTRY_H
|
||||
#define JORENTRY_H
|
||||
|
||||
#include "JSystem/JHostIO/JHIComm.h"
|
||||
#include <os.h>
|
||||
|
||||
template<typename T, int I>
|
||||
class JHIpvector {
|
||||
public:
|
||||
JHIpvector() { m_size = 0; }
|
||||
|
||||
s32 size() const { return m_size; }
|
||||
T get(u32 i) const { return m_vector[i]; }
|
||||
|
||||
s32 push_back(T p) {
|
||||
if (m_size >= I) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_vector[m_size++] = p;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 0x00 */ T m_vector[I];
|
||||
/* 0x28 */ s32 m_size;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class JHIComPortManager {
|
||||
public:
|
||||
JHIComPortManager() {
|
||||
field_0x10040 = 0;
|
||||
field_0x10041 = 0;
|
||||
}
|
||||
|
||||
T& getRefPort() { return port; }
|
||||
|
||||
void addTag(JHITag<T>* pTag) {
|
||||
pTag->mp_data = this;
|
||||
field_0xc.push_back(pTag);
|
||||
}
|
||||
|
||||
JHITag<T>* find(u32 param_1) {
|
||||
for (u32 i = 0; i < field_0xc.size(); i++) {
|
||||
JHITag<T>* tag = field_0xc.get(i);
|
||||
if (tag->m_tag == param_1) {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void dispatchMessage() {
|
||||
u32 r29 = port.available();
|
||||
while (true) {
|
||||
if (!field_0x10040) {
|
||||
if (r29 < 8) {
|
||||
return;
|
||||
}
|
||||
port.receive(&field_0x10038, 8);
|
||||
r29 -= 8;
|
||||
field_0x10038 = JHIntohl(field_0x10038);
|
||||
field_0x1003c = JHIntohl(field_0x1003c);
|
||||
field_0x10040 = 1;
|
||||
JHITag<T>* r27 = find(field_0x10038);
|
||||
if (field_0x1003c > port.getMaxReaderableSize()) {
|
||||
port.initBuffers();
|
||||
OSReport("JHostIO::ERROR: JHIComportManager: invalid datasize ( port.initialized )\n");
|
||||
} else if (!r27) {
|
||||
OSReport("JHostIO::ERROR: JHIComportManager: invalid tag message\n");
|
||||
}
|
||||
}
|
||||
if (!field_0x10040) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r29 < field_0x1003c) {
|
||||
return;
|
||||
}
|
||||
u32 r26 = port.receive(field_0x38, field_0x1003c);
|
||||
r29 -= r26;
|
||||
JHITag<T>* r28 = find(field_0x10038);
|
||||
field_0x10040 = 0;
|
||||
if (r28) {
|
||||
r28->receive(field_0x38, field_0x1003c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static JHIComPortManager<T>* create() {
|
||||
if (instance == NULL) {
|
||||
instance = new JHIComPortManager<T>();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
static JHIComPortManager<T>* getInstance() { return instance; }
|
||||
|
||||
static JHIComPortManager<T>* instance;
|
||||
|
||||
/* 0x00000 */ T port;
|
||||
/* 0x0000C */ JHIpvector<JHITag<T>*, 10> field_0xc;
|
||||
/* 0x00038 */ char field_0x38[0x10000];
|
||||
/* 0x10038 */ u32 field_0x10038;
|
||||
/* 0x1003C */ u32 field_0x1003c;
|
||||
/* 0x10040 */ u8 field_0x10040;
|
||||
/* 0x10041 */ u8 field_0x10041;
|
||||
};
|
||||
|
||||
void JORInit();
|
||||
|
||||
#endif /* JORENTRY_H */
|
||||
@@ -0,0 +1,99 @@
|
||||
#ifndef JORFILE_H
|
||||
#define JORFILE_H
|
||||
|
||||
#include "JSystem/JSupport/JSUMemoryStream.h"
|
||||
|
||||
class JORDir {
|
||||
public:
|
||||
void setStatus(u32 status) { m_status = status; }
|
||||
void setFindHandle(u32 handle) { m_findHandle = handle; }
|
||||
void setFileAttribute(u32 attribute) { m_fileAttribute = attribute; }
|
||||
void setLowDateTime(u32 time) { m_lowDateTime = time; }
|
||||
void setHighDateTime(u32 time) { m_highDateTime = time; }
|
||||
|
||||
char* getFilename() { return m_filename; }
|
||||
|
||||
/* 0x00 */ u32 m_status;
|
||||
/* 0x04 */ u32 m_findHandle;
|
||||
/* 0x08 */ u32 m_fileAttribute;
|
||||
/* 0x0C */ u32 m_lowDateTime;
|
||||
/* 0x10 */ u32 m_highDateTime;
|
||||
/* 0x14 */ char* m_filename;
|
||||
};
|
||||
|
||||
class JORFile {
|
||||
public:
|
||||
enum ECommand {
|
||||
ECommand_OPEN,
|
||||
ECommand_CLOSE,
|
||||
ECommand_READ,
|
||||
ECommand_WRITE,
|
||||
};
|
||||
|
||||
enum EStatus {
|
||||
EStatus_WAIT,
|
||||
EStatus_READ_BEGIN,
|
||||
EStatus_READ_DATA,
|
||||
EStatus_READ_END,
|
||||
EStatus_WRITE_BEGIN,
|
||||
EStatus_WRITE_DATA,
|
||||
EStatus_WRITE_END,
|
||||
};
|
||||
|
||||
enum EFlags {
|
||||
EFlags_READ = (1 << 0),
|
||||
EFlags_WRITE = (1 << 1),
|
||||
EFlags_UNK_0x4 = (1 << 2),
|
||||
EFlags_DEFAULT_EXT = (1 << 4),
|
||||
EFlags_UNK_0x20 = (1 << 5),
|
||||
EFlags_HAS_SUFFIX = (1 << 6),
|
||||
};
|
||||
|
||||
JORFile();
|
||||
|
||||
int countMaskSize(const char* mask);
|
||||
void setBuffer(void* buffer, s32 length);
|
||||
|
||||
char* getFilename() { return mFilename; }
|
||||
u32 getHandle() const { return mHandle; }
|
||||
|
||||
JSUMemoryOutputStream& getDataStream() { return mDataStream; }
|
||||
|
||||
void setHandle(u32 handle) { mHandle = handle; }
|
||||
void setFileLength(s32 length) { mFileLength = length; }
|
||||
void setNFileName(u16 length) { mNFileName = length; }
|
||||
void setNBaseName(u16 length) { mNBaseName = length; }
|
||||
void setNExtensionName(u16 length) { mNExtensionName = length; }
|
||||
void setStatus(s32 status) { mStatus = status; }
|
||||
|
||||
virtual ~JORFile() {
|
||||
close();
|
||||
}
|
||||
virtual int open(const char* path, u32 flags, const char* extMask, const char* defaultExt, const char* param_4, const char* fileSuffix);
|
||||
virtual int open(u32 flags, const char* extMask, const char* defaultExt, const char* param_4, const char* fileSuffix) {
|
||||
return open(NULL, flags, extMask, defaultExt, param_4, fileSuffix);
|
||||
}
|
||||
virtual void close();
|
||||
virtual s32 readData(void* buffer, s32 length);
|
||||
virtual s32 writeData(const void* buffer, s32 length);
|
||||
virtual void readBegin_(s32 len);
|
||||
virtual void readLoop_();
|
||||
virtual void writeBegin_(s32 len);
|
||||
virtual void writeLoop_(const void* pBuffer, s32 size, u32 pos);
|
||||
virtual void writeDone_(s32 len);
|
||||
virtual void waitMessage_();
|
||||
virtual s32 getFileSize() const { return mFileLength; }
|
||||
|
||||
/* 0x04 */ u32 mHandle;
|
||||
/* 0x08 */ s32 mFileLength;
|
||||
/* 0x0C */ s32 mStatus;
|
||||
/* 0x10 */ u16 mNFileName;
|
||||
/* 0x12 */ u16 mNBaseName;
|
||||
/* 0x14 */ u16 mNExtensionName;
|
||||
/* 0x16 */ u16 mFlags;
|
||||
/* 0x18 */ int field_0x18;
|
||||
/* 0x1C */ JSUMemoryOutputStream mDataStream;
|
||||
/* 0x30 */ char mFilename[256];
|
||||
};
|
||||
|
||||
#endif /* JORFILE_H */
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef JORHOSTINFO_H
|
||||
#define JORHOSTINFO_H
|
||||
|
||||
#ifdef __REVOLUTION_SDK__
|
||||
#include <revolution.h>
|
||||
#else
|
||||
#include <dolphin.h>
|
||||
#endif
|
||||
|
||||
#define HOSTINFO_REQ_COMPUTER_NAME 0
|
||||
#define HOSTINFO_REQ_USERNAME 1
|
||||
#define HOSTINFO_REQ_LOCAL_TIME 2
|
||||
|
||||
class JORHostInfo {
|
||||
public:
|
||||
/* 0x0 */ s32 m_result;
|
||||
|
||||
void setResult(s32 result) { m_result = result; }
|
||||
s32 getResult() { return m_result; }
|
||||
|
||||
JORHostInfo() { m_result = 0; }
|
||||
virtual ~JORHostInfo() {}
|
||||
};
|
||||
|
||||
class JORHostInfo_String : public JORHostInfo {
|
||||
public:
|
||||
virtual ~JORHostInfo_String() {}
|
||||
|
||||
JORHostInfo_String() {
|
||||
m_stringBuffer = NULL;
|
||||
m_bufferSize = 0;
|
||||
}
|
||||
|
||||
void setStringBuffer(char* buffer) { m_stringBuffer = buffer; }
|
||||
void setBufferSize(u32 size) { m_bufferSize = size; }
|
||||
char* getString() { return m_stringBuffer; }
|
||||
u32 getBufferSize() { return m_bufferSize; }
|
||||
|
||||
/* 0x8 */ char* m_stringBuffer;
|
||||
/* 0xC */ u32 m_bufferSize;
|
||||
};
|
||||
|
||||
class JORHostInfo_CalendarTime : public JORHostInfo {
|
||||
public:
|
||||
JORHostInfo_CalendarTime() { m_calendarTimeBuffer = NULL; }
|
||||
virtual ~JORHostInfo_CalendarTime() {}
|
||||
|
||||
void setCalendarTimeBuffer(OSCalendarTime* pCalendarTime) { m_calendarTimeBuffer = pCalendarTime; }
|
||||
OSCalendarTime* getCalendarTime() { return m_calendarTimeBuffer; }
|
||||
|
||||
/* 0x8 */ OSCalendarTime* m_calendarTimeBuffer;
|
||||
};
|
||||
|
||||
BOOL JORGetYearDays(int year, int mon);
|
||||
|
||||
#endif /* JORHOSTINFO_H */
|
||||
@@ -0,0 +1,324 @@
|
||||
#ifndef JORMCONTEXT_H
|
||||
#define JORMCONTEXT_H
|
||||
|
||||
#ifdef __REVOLUTION_SDK__
|
||||
#include <revolution.h>
|
||||
#else
|
||||
#include <dolphin.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include "JSystem/JHostIO/JORReflexible.h"
|
||||
#include "JSystem/JSupport/JSUMemoryStream.h"
|
||||
|
||||
#define MCTX_MSG_RESET 0
|
||||
#define MCTX_MSG_GET_ROOT_OBJ 2
|
||||
#define MCTX_MSG_GEN_OBJ_INFO 4
|
||||
#define MCTX_MSG_INVALID_NODE 5
|
||||
#define MCTX_MSG_UPDATE_NODE 8
|
||||
#define MCTX_MSG_FIO 9
|
||||
#define MCTX_MSG_OPEN_MESSAGE_BOX 10
|
||||
#define MCTX_MSG_START_NODE 12
|
||||
#define MCTX_MSG_GET_HOST_INFO 14
|
||||
#define MCTX_MSG_SHELL_EXEC 15
|
||||
|
||||
#define MCTX_COMMAND_START_NODE (u32)0
|
||||
#define MCTX_COMMAND_END_NODE (u32)1
|
||||
#define MCTX_COMMAND_GEN_CONTROL (u32)2
|
||||
#define MCTX_COMMAND_GEN_NODE (u32)3
|
||||
#define MCTX_COMMAND_START_SELECTOR (u32)4
|
||||
#define MCTX_COMMAND_END_SELECTOR (u32)5
|
||||
#define MCTX_COMMAND_SELECTOR_ITEM (u32)6
|
||||
#define MCTX_COMMAND_INVALID_NODE (u32)7
|
||||
#define MCTX_COMMAND_UPDATE_CONTROL (u32)8
|
||||
|
||||
#define JORM_DEFAULT_WIDTH 0x200
|
||||
#define JORM_DEFAULT_HEIGHT 0x18
|
||||
#define JORM_DEFAULT_COMBOBOX_WIDTH 0x100
|
||||
#define JORM_DEFAULT_COMBOBOX_HEIGHT 0x1a
|
||||
|
||||
#define DEFINE_GEN_CHECKBOX(T, kind) \
|
||||
void genCheckBox(const char* label, T* pSrc, T mask, u32 style = 0, \
|
||||
JOREventListener* pListener = NULL, u16 posX = -1, u16 posY = -1, \
|
||||
u16 width = JORM_DEFAULT_WIDTH, u16 height = JORM_DEFAULT_HEIGHT) { \
|
||||
genCheckBoxSub(kind, label, (uintptr_t)pSrc, style, *pSrc, mask, pListener, posX, posY, \
|
||||
width, height); \
|
||||
}
|
||||
|
||||
#define DEFINE_GEN_CHECKBOX_ID(T, kind) \
|
||||
void genCheckBoxID(const char* label, u32 id, T mask, T initValue, u32 style = 0, \
|
||||
JOREventListener* pListener = NULL, u16 posX = -1, u16 posY = -1, \
|
||||
u16 width = JORM_DEFAULT_WIDTH, u16 height = JORM_DEFAULT_HEIGHT) { \
|
||||
genCheckBoxSub(kind, label, id, style, initValue, mask, pListener, posX, posY, width, \
|
||||
height); \
|
||||
}
|
||||
|
||||
#define DEFINE_GEN_SLIDER(T, kind) \
|
||||
void genSlider(const char* label, T* pSrc, T rangeMin, T rangeMax, u32 style = 0, \
|
||||
JOREventListener* pListener = NULL, u16 posX = -1, u16 posY = -1, \
|
||||
u16 width = JORM_DEFAULT_WIDTH, u16 height = JORM_DEFAULT_HEIGHT) { \
|
||||
genSliderSub(kind, label, (uintptr_t)pSrc, style, *pSrc, rangeMin, rangeMax, pListener, \
|
||||
posX, posY, width, height); \
|
||||
}
|
||||
|
||||
#define DEFINE_GEN_SLIDER_ID(T, kind) \
|
||||
void genSliderID(const char* label, u32 id, T data, T rangeMin, T rangeMax, u32 style = 0, \
|
||||
JOREventListener* pListener = NULL, u16 posX = -1, u16 posY = -1, \
|
||||
u16 width = JORM_DEFAULT_WIDTH, u16 height = JORM_DEFAULT_HEIGHT) { \
|
||||
genSliderSub(kind, label, id, style, data, rangeMin, rangeMax, pListener, posX, posY, \
|
||||
width, height); \
|
||||
}
|
||||
|
||||
#define DEFINE_START_COMBO_BOX(T, kind) \
|
||||
void startComboBox(const char* label, T* pSrc, u32 style = 0, \
|
||||
JOREventListener* pListener = NULL, u16 posX = -1, u16 posY = -1, \
|
||||
u16 width = JORM_DEFAULT_COMBOBOX_WIDTH, \
|
||||
u16 height = JORM_DEFAULT_COMBOBOX_HEIGHT) { \
|
||||
startSelectorSub('CMBX', kind, label, (uintptr_t)pSrc, style, *pSrc, pListener, posX, \
|
||||
posY, width, height); \
|
||||
}
|
||||
|
||||
#define DEFINE_START_COMBO_BOX_ID(T, kind) \
|
||||
void startComboBoxID(const char* label, u32 id, T data, u32 style = 0, \
|
||||
JOREventListener* pListener = NULL, u16 posX = -1, u16 posY = -1, \
|
||||
u16 width = JORM_DEFAULT_WIDTH, u16 height = JORM_DEFAULT_HEIGHT) { \
|
||||
startSelectorSub('CMBX', kind, label, id, style, data, pListener, posX, posY, width, \
|
||||
height); \
|
||||
}
|
||||
|
||||
#define DEFINE_UPDATE_COMBO_BOX(T) \
|
||||
void updateComboBox(u32 mode, T* pSrc, u32 param_2) { \
|
||||
updateSelectorSub(mode, (uintptr_t)pSrc, *pSrc, param_2); \
|
||||
}
|
||||
|
||||
#define DEFINE_UPDATE_COMBO_BOX_ID(T) \
|
||||
void updateComboBoxID(u32 mode, u32 id, T value, u32 param_4) { \
|
||||
updateSelectorSub(mode, id, value, param_4); \
|
||||
}
|
||||
|
||||
#define DEFINE_UPDATE_SLIDER(T) \
|
||||
void updateSlider(u32 mode, T* pSrc, T rangeMin, T rangeMax, u32 param_5) { \
|
||||
updateSliderSub(mode, (uintptr_t)pSrc, *pSrc, rangeMin, rangeMax, param_5); \
|
||||
}
|
||||
|
||||
#define DEFINE_UPDATE_SLIDER_ID(T) \
|
||||
void updateSliderID(u32 mode, u32 id, T value, T rangeMin, T rangeMax, u32 param_5) { \
|
||||
updateSliderSub(mode, id, value, rangeMin, rangeMax, param_5); \
|
||||
}
|
||||
|
||||
#define DEFINE_START_RADIO_BUTTON(T, kind) \
|
||||
void startRadioButton(const char* label, T* pSrc, u32 style, JOREventListener* pListener, \
|
||||
u16 posX, u16 posY, u16 width, u16 height) { \
|
||||
startSelectorSub('RBTN', kind, label, (uintptr_t)pSrc, style, *pSrc, pListener, posX, \
|
||||
posY, width, height); \
|
||||
}
|
||||
|
||||
namespace jhostio {
|
||||
enum EKind {
|
||||
EKind_8B = 0x08,
|
||||
EKind_16B = 0x10,
|
||||
EKind_32B = 0x20,
|
||||
};
|
||||
|
||||
inline u32 GetEKindSize(u32 param_0) {
|
||||
return param_0 & 0xFF;
|
||||
}
|
||||
} // namespace jhostio
|
||||
|
||||
class JORReflexible;
|
||||
class JORFile;
|
||||
class JOREventListener;
|
||||
class JORHostInfo;
|
||||
|
||||
class JORMContext {
|
||||
public:
|
||||
JORMContext() : mOutputStream(this, 0x10000) {}
|
||||
|
||||
void bufInit() { mOutputStream.seek(0, JSUStreamSeekFrom_SET); }
|
||||
void putMsgID(u32 msgID) { mOutputStream << msgID; }
|
||||
s32 msgSize() { return mOutputStream.getPosition(); }
|
||||
u8* msgPtr() { return mBuffer; }
|
||||
|
||||
void openFile(JORFile* pFile, u32 flags, const char* path, const char* extMask, u32 maskSize,
|
||||
const char* defaultExt, const char* param_6, const char* fileSuffix);
|
||||
void closeFile(JORFile* pFile);
|
||||
void readBegin(JORFile* pFile, s32 size);
|
||||
void readData(JORFile* pFile);
|
||||
void writeBegin(JORFile* pFile, u16 flags, u32 size);
|
||||
void writeData(JORFile* pFile, const void* pBuffer, s32 size, u32 position);
|
||||
void writeDone(JORFile* pFile, u32 size);
|
||||
void sendShellExecuteRequest(void*, const char*, const char*, const char*, const char*, int);
|
||||
void sendHostInfoRequest(u32 requestType, JORHostInfo* pHostInfo);
|
||||
void endNode();
|
||||
|
||||
void genRootNode(const char* label, JORReflexible* obj, u32 param_2, u32 param_3) {
|
||||
genNodeSub(label, obj, param_2, param_3);
|
||||
}
|
||||
|
||||
void genNode(const char* label, JORReflexible* obj, u32 param_2, u32 param_3) {
|
||||
mOutputStream << MCTX_COMMAND_GEN_NODE;
|
||||
genNodeSub(label, obj, param_2, param_3);
|
||||
}
|
||||
|
||||
void genNode(JORReflexible* parentObj, u32 param_1, const char* label, JORReflexible* obj,
|
||||
u32 param_4, u32 param_5) {
|
||||
ASSERTMSGLINE(97, parentObj != NULL,
|
||||
"JORMContext: genNode must specify strict( not null node ) parent object\n");
|
||||
|
||||
mOutputStream << MCTX_COMMAND_GEN_NODE;
|
||||
mOutputStream << param_1;
|
||||
putNode(parentObj);
|
||||
genNodeSub(label, obj, param_4, param_5);
|
||||
}
|
||||
|
||||
void startNode(JORReflexible* parentObj, u32 param_1, const char* label, JORReflexible* obj,
|
||||
u32 param_4, u32 param_5) {
|
||||
ASSERTMSGLINE(
|
||||
113, parentObj != NULL,
|
||||
"JORMContext: startNode must specify strict( not null node ) parent object\n");
|
||||
|
||||
mOutputStream << MCTX_COMMAND_START_NODE;
|
||||
mOutputStream << param_1;
|
||||
putNode(parentObj);
|
||||
genNodeSub(label, obj, param_4, param_5);
|
||||
}
|
||||
|
||||
void startNode(const char* label, JORReflexible* obj, u32 param_2, u32 param_3) {
|
||||
mOutputStream << MCTX_COMMAND_START_NODE;
|
||||
genNodeSub(label, obj, param_2, param_3);
|
||||
}
|
||||
|
||||
void endUpdateNode() {
|
||||
// empty function
|
||||
}
|
||||
|
||||
void startUpdateNode(JORReflexible* obj) { putNode(obj); }
|
||||
|
||||
void genNodeSub(const char* label, JORReflexible* i_node, u32, u32);
|
||||
void putNode(JORReflexible* obj) {
|
||||
mOutputStream << (uintptr_t)obj;
|
||||
}
|
||||
void invalidNode(JORReflexible* i_node, u32);
|
||||
|
||||
void genControl(u32 type, u32 kind, const char* label, u32 style, u32 id,
|
||||
JOREventListener* pListener, u32 initValue);
|
||||
|
||||
void genSliderSub(u32 kind, const char* label, u32 id, u32 style, s32 initValue, s32 rangeMin,
|
||||
s32 rangeMax, JOREventListener* pListener, u16 posX, u16 posY, u16 width,
|
||||
u16 height);
|
||||
|
||||
void genCheckBoxSub(u32 kind, const char* label, u32 id, u32 style, u16 initValue, u16 mask,
|
||||
JOREventListener* pListener, u16 posX, u16 posY, u16 width, u16 height);
|
||||
|
||||
void startSelectorSub(u32 type, u32 kind, const char* label, u32 id, u32 style, s32 initValue,
|
||||
JOREventListener* pListener, u16 posX, u16 posY, u16 width, u16 height);
|
||||
|
||||
void endSelectorSub();
|
||||
|
||||
void genSelectorItemSub(const char* label, s32 itemNo, u32 param_2, u16 posX, u16 posY,
|
||||
u16 width, u16 height);
|
||||
|
||||
void genButton(const char* label, u32 id, u32 style = 0, JOREventListener* pListener = NULL,
|
||||
u16 posX = -1, u16 posY = -1, u16 width = JORM_DEFAULT_WIDTH,
|
||||
u16 height = JORM_DEFAULT_HEIGHT);
|
||||
|
||||
void genLabel(const char* label, u32 id, u32 style = 0, JOREventListener* pListener = NULL,
|
||||
u16 posX = -1, u16 posY = -1, u16 width = JORM_DEFAULT_WIDTH,
|
||||
u16 height = JORM_DEFAULT_HEIGHT);
|
||||
|
||||
void genGroupBox(const char* label, u32 id, u32 style = 0, JOREventListener* pListener = NULL,
|
||||
u16 posX = -1, u16 posY = -1, u16 width = JORM_DEFAULT_WIDTH,
|
||||
u16 height = JORM_DEFAULT_HEIGHT);
|
||||
|
||||
void genEditBoxID(const char* label, u32 id, const char* string, u16 length, u32 style = 0,
|
||||
JOREventListener* pListener = NULL, u16 posX = -1, u16 posY = -1,
|
||||
u16 width = JORM_DEFAULT_WIDTH, u16 height = JORM_DEFAULT_HEIGHT);
|
||||
|
||||
/**
|
||||
* === CHECKBOX ===
|
||||
*/
|
||||
DEFINE_GEN_CHECKBOX(u8, 0x100 | jhostio::EKind_8B)
|
||||
DEFINE_GEN_CHECKBOX(u16, 0x100 | jhostio::EKind_16B)
|
||||
|
||||
DEFINE_GEN_CHECKBOX_ID(u16, JORPropertyEvent::EKind_ValueID | 0x100)
|
||||
|
||||
/**
|
||||
* === SLIDER ===
|
||||
*/
|
||||
DEFINE_GEN_SLIDER(u8, 0x100 | jhostio::EKind_8B)
|
||||
DEFINE_GEN_SLIDER(s16, jhostio::EKind_16B)
|
||||
DEFINE_GEN_SLIDER(f32, JORPropertyEvent::EKind_FloatValue | jhostio::EKind_32B)
|
||||
DEFINE_GEN_SLIDER(s32, jhostio::EKind_32B)
|
||||
|
||||
DEFINE_GEN_SLIDER_ID(f64, JORPropertyEvent::EKind_ValueID | JORPropertyEvent::EKind_FloatValue)
|
||||
DEFINE_GEN_SLIDER_ID(int, JORPropertyEvent::EKind_ValueID)
|
||||
|
||||
DEFINE_UPDATE_SLIDER(u8)
|
||||
DEFINE_UPDATE_SLIDER(s16)
|
||||
DEFINE_UPDATE_SLIDER(f32)
|
||||
DEFINE_UPDATE_SLIDER(s32)
|
||||
|
||||
DEFINE_UPDATE_SLIDER_ID(f64)
|
||||
DEFINE_UPDATE_SLIDER_ID(int)
|
||||
|
||||
/**
|
||||
* === COMBO BOX ===
|
||||
*/
|
||||
DEFINE_START_COMBO_BOX(u8, 0x100 | jhostio::EKind_8B)
|
||||
DEFINE_START_COMBO_BOX(s16, jhostio::EKind_16B)
|
||||
DEFINE_START_COMBO_BOX(s32, jhostio::EKind_32B)
|
||||
|
||||
DEFINE_START_COMBO_BOX_ID(s32, JORPropertyEvent::EKind_ValueID)
|
||||
|
||||
DEFINE_UPDATE_COMBO_BOX(u8)
|
||||
|
||||
DEFINE_UPDATE_COMBO_BOX_ID(s32)
|
||||
|
||||
void endComboBox() { endSelectorSub(); }
|
||||
|
||||
void genComboBoxItem(const char* label, s32 itemNo) {
|
||||
genSelectorItemSub(label, itemNo, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* === RADIO BUTTON ===
|
||||
*/
|
||||
DEFINE_START_RADIO_BUTTON(u8, 0x100 | jhostio::EKind_8B)
|
||||
DEFINE_START_RADIO_BUTTON(s16, jhostio::EKind_16B)
|
||||
DEFINE_START_RADIO_BUTTON(s32, jhostio::EKind_32B)
|
||||
|
||||
void endRadioButton() { endSelectorSub(); }
|
||||
|
||||
void genRadioButtonItem(const char* label, s32 itemNo, u32 param_2, u16 posX, u16 posY,
|
||||
u16 width, u16 height) {
|
||||
genSelectorItemSub(label, itemNo, param_2, posX, posY, width, height);
|
||||
}
|
||||
|
||||
void updateControl(u32 mode, u32 id, u32 param_2);
|
||||
void updateControl(u32 mode, u32 id, const char* param_2);
|
||||
void updateLabel(u32 mode, u32 id, const char* param_2) { updateControl(mode, id, param_2); }
|
||||
void updateSliderSub(u32 mode, u32 id, s32 value, s32 rangeMin, s32 rangeMax, u32 param_5);
|
||||
void updateCheckBoxSub(u32 mode, u32 id, u16 value, u16 mask, u32 param_4);
|
||||
void updateSelectorSub(u32 mode, u32 id, s32 value, u32 param_3);
|
||||
void updateEditBoxID(u32 mode, u32 id, const char* string, u32 param_3, u16 length);
|
||||
|
||||
void updateCheckBox(u32 mode, u8* pSrc, u8 mask, u32 param_4) {
|
||||
updateCheckBoxSub(mode, (uintptr_t)pSrc, *pSrc, mask, param_4);
|
||||
}
|
||||
|
||||
void updateCheckBoxID(u32 mode, u32 id, u8 value, u8 mask, u32 param_4) {
|
||||
updateCheckBoxSub(mode, id, value, mask, param_4);
|
||||
}
|
||||
|
||||
void updateRadioButton(u32 mode, s16* pSrc, u32 param_3) {
|
||||
updateSelectorSub(mode, (uintptr_t)pSrc, *pSrc, param_3);
|
||||
}
|
||||
|
||||
void editComboBoxItem(u32 param_0, u32 param_1, const char* param_2, s32 param_3, u32 param_4);
|
||||
|
||||
void openMessageBox(void* param_0, u32 style, const char* message, const char* title);
|
||||
|
||||
/* 0x00000 */ u8 mBuffer[0x10000];
|
||||
/* 0x10000 */ JSUMemoryOutputStream mOutputStream;
|
||||
};
|
||||
|
||||
#endif /* JORMCONTEXT_H */
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef JORREFLEXIBLE_H
|
||||
#define JORREFLEXIBLE_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
class JORReflexible;
|
||||
|
||||
struct JOREvent {};
|
||||
|
||||
struct JORPropertyEvent : JOREvent {
|
||||
enum EKind {
|
||||
EKind_HasListener = (1 << 30),
|
||||
EKind_ValueID = (1 << 29),
|
||||
EKind_FloatValue = (1 << 9),
|
||||
};
|
||||
|
||||
/* 0x00 */ u8 field_0x0[0x4 - 0x0];
|
||||
/* 0x04 */ u32 type;
|
||||
/* 0x08 */ u32 kind;
|
||||
/* 0x0C */ char* id; // id?
|
||||
/* 0x10 */ JORReflexible* field_0x10; // ?
|
||||
/* 0x14 */ u32 field_0x14;
|
||||
union {
|
||||
u32 U32;
|
||||
u16 U16[2];
|
||||
}
|
||||
/* 0x18 */ field_0x18;
|
||||
};
|
||||
|
||||
struct JORGenEvent : JOREvent {};
|
||||
|
||||
struct JORNodeEvent : JOREvent {
|
||||
/* 0x00 */ u32 field_0x0;
|
||||
};
|
||||
|
||||
class JORMContext;
|
||||
class JORServer;
|
||||
|
||||
class JOREventListener {
|
||||
public:
|
||||
#if DEBUG
|
||||
JOREventListener() {}
|
||||
virtual void listenPropertyEvent(const JORPropertyEvent*) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
class JORReflexible : public JOREventListener {
|
||||
public:
|
||||
#if DEBUG
|
||||
JORReflexible() {}
|
||||
static JORServer* getJORServer();
|
||||
|
||||
virtual void listenPropertyEvent(const JORPropertyEvent*);
|
||||
virtual void listen(u32, const JOREvent*);
|
||||
virtual void genObjectInfo(const JORGenEvent*);
|
||||
virtual void genMessage(JORMContext*) = 0;
|
||||
virtual void listenNodeEvent(const JORNodeEvent*);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* JORREFLEXIBLE_H */
|
||||
@@ -0,0 +1,195 @@
|
||||
#ifndef JORSERVER_H
|
||||
#define JORSERVER_H
|
||||
|
||||
#include "JSystem/JHostIO/JOREntry.h"
|
||||
#include "JSystem/JHostIO/JORMContext.h"
|
||||
#include "JSystem/JHostIO/JHIComm.h"
|
||||
#include "JSystem/JHostIO/JHIhioASync.h"
|
||||
#include "JSystem/JGadget/linklist.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
|
||||
u32 JORMessageBox(const char* message, const char* title, u32 style);
|
||||
int JORShellExecute(const char* param_0, const char* param_1, const char* param_2, const char* param_3, int param_4);
|
||||
|
||||
struct JOREventCallbackListNode {
|
||||
JOREventCallbackListNode(u32, u32, bool);
|
||||
void JORAppend();
|
||||
void JORRemove();
|
||||
|
||||
virtual int JORAct(u32, const char*);
|
||||
virtual ~JOREventCallbackListNode();
|
||||
|
||||
bool JORIsAcceptableID(u32 eventID) const {
|
||||
bool result = false;
|
||||
if (field_0xc <= eventID && eventID <= field_0x10) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* 0x04 */ JGadget::TLinkListNode m_node;
|
||||
/* 0x0C */ u32 field_0xc;
|
||||
/* 0x10 */ u32 field_0x10;
|
||||
};
|
||||
|
||||
class JORFile;
|
||||
class JORDir;
|
||||
class JORHostInfo_String;
|
||||
class JORHostInfo_CalendarTime;
|
||||
|
||||
class JORServer : public JHITag<JHICmnMem> {
|
||||
public:
|
||||
typedef void (*EventFunc)(u32,char *);
|
||||
typedef JGadget::TLinkList<JOREventCallbackListNode, -4> CallbackLinkList;
|
||||
|
||||
enum ECommand {
|
||||
ECommand_GetRootObj = 1,
|
||||
ECommand_GenObjInfo = 3,
|
||||
ECommand_NodeEvent = 6,
|
||||
ECommand_PropertyEvent = 7,
|
||||
ECommand_FIO = 9,
|
||||
ECommand_ReadResultS32 = 10,
|
||||
ECommand_ReadOrEvent = 11,
|
||||
ECommand_DIR = 13,
|
||||
ECommand_HostInfo = 14,
|
||||
ECommand_ReadResultU32 = 15,
|
||||
};
|
||||
|
||||
JORServer() : JHITag<JHICmnMem>('ORef'),
|
||||
m_event(false),
|
||||
m_eventDone(true),
|
||||
m_eventFunc(NULL),
|
||||
m_isEventCallbackListEnabled(false)
|
||||
{}
|
||||
|
||||
static JORServer* create();
|
||||
void receive(const char*, s32);
|
||||
|
||||
JORMContext* attachMCTX(u32);
|
||||
void releaseMCTX(JORMContext*);
|
||||
|
||||
void appendEventCallbackListNode(JOREventCallbackListNode* p) {
|
||||
JUT_ASSERT(256, p!=NULL);
|
||||
m_eventCallbackList.Push_front(p);
|
||||
}
|
||||
|
||||
void removeEventCallbackListNode(JOREventCallbackListNode* p) {
|
||||
JUT_ASSERT(257, p!=NULL);
|
||||
m_eventCallbackList.Remove(p);
|
||||
}
|
||||
|
||||
static void defSetVal(void*, u32, s32);
|
||||
static void defSetBitVal(void*, u32, u16, u16);
|
||||
|
||||
void fio_openFile_(JSUMemoryInputStream&);
|
||||
void fio_closeFile_(JSUMemoryInputStream&);
|
||||
void fio_readData_(JSUMemoryInputStream&);
|
||||
void fio_writeData_(JSUMemoryInputStream&);
|
||||
void fio_dispatchMessage_(JSUMemoryInputStream&);
|
||||
|
||||
void dir_findFirstFile_(JSUMemoryInputStream&, JORDir*);
|
||||
void dir_findNextFile_(JSUMemoryInputStream&, JORDir*);
|
||||
void dir_browseForFolder_(JSUMemoryInputStream&, JORDir*);
|
||||
|
||||
void readResultS32_(JSUMemoryInputStream&);
|
||||
void readOrEvent_(JSUMemoryInputStream&);
|
||||
void dir_dispatchMessage_(JSUMemoryInputStream&);
|
||||
void hostinfo_dispatchMessage_(JSUMemoryInputStream&);
|
||||
void hostinfo_recvString_(JSUMemoryInputStream&, JORHostInfo_String*);
|
||||
void hostinfo_localTime_(JSUMemoryInputStream&, JORHostInfo_CalendarTime*);
|
||||
void readResultU32_(JSUMemoryInputStream&);
|
||||
|
||||
void sendReset();
|
||||
|
||||
void setRootNode(const char*, JORReflexible*, u32, u32);
|
||||
void doneEvent();
|
||||
|
||||
bool getEvent() { return m_event; }
|
||||
void setEvent(bool event) { m_event = event; }
|
||||
void setEventDone(bool eventDone) { m_eventDone = eventDone; }
|
||||
u32 getEventNum() { return m_eventNum; }
|
||||
char* getEventName() { return m_eventName; }
|
||||
EventFunc getEventFunc() { return m_eventFunc; }
|
||||
void setEventFunc(EventFunc func) { m_eventFunc = func; }
|
||||
bool isEventCallbackListEnabled() const { return m_isEventCallbackListEnabled; }
|
||||
void enableEventCallbackList(bool enable) { m_isEventCallbackListEnabled = enable; }
|
||||
CallbackLinkList* referEventCallbackList() { return &m_eventCallbackList; }
|
||||
|
||||
static JORServer* getInstance() { return instance; }
|
||||
static JORServer* instance;
|
||||
|
||||
/* 0x0000C */ JORMContext m_context;
|
||||
/* 0x10020 */ JORReflexible* mp_rootObj;
|
||||
/* 0x10024 */ char m_rootName[64];
|
||||
/* 0x10064 */ u32 field_0x10064;
|
||||
/* 0x10068 */ u32 field_0x10068;
|
||||
/* 0x1006C */ bool m_event;
|
||||
/* 0x1006D */ bool m_eventDone;
|
||||
/* 0x10070 */ u32 m_eventNum;
|
||||
/* 0x10074 */ char m_eventName[0x1000];
|
||||
/* 0x11074 */ EventFunc m_eventFunc;
|
||||
/* 0x11078 */ bool m_isEventCallbackListEnabled;
|
||||
/* 0x1107C */ CallbackLinkList m_eventCallbackList;
|
||||
};
|
||||
|
||||
inline u32 JOR_MESSAGELOOP() {
|
||||
JORServer* server = JORServer::getInstance();
|
||||
JHIComPortManager<JHICmnMem>::getInstance()->dispatchMessage();
|
||||
if (server->getEvent()) {
|
||||
server->setEvent(false);
|
||||
server->setEventDone(false);
|
||||
u32 eventNum = server->getEventNum();
|
||||
char* eventName = server->getEventName();
|
||||
if (server->isEventCallbackListEnabled() && eventNum >= 0x80000000) {
|
||||
JORServer::CallbackLinkList* list = server->referEventCallbackList();
|
||||
JORServer::CallbackLinkList::iterator end = list->end();
|
||||
for (JORServer::CallbackLinkList::iterator it = list->begin(); it != end;) {
|
||||
JOREventCallbackListNode& callback = *it;
|
||||
++it;
|
||||
if (!callback.JORIsAcceptableID(eventNum)) {
|
||||
continue;
|
||||
}
|
||||
if (callback.JORAct(eventNum, eventName)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
JORServer::EventFunc func = server->getEventFunc();
|
||||
if (func) {
|
||||
func(eventNum, eventName);
|
||||
}
|
||||
}
|
||||
server->doneEvent();
|
||||
}
|
||||
return JHIEventLoop();
|
||||
}
|
||||
|
||||
inline void JOR_INIT() {
|
||||
JORInit();
|
||||
JORServer::getInstance()->setEventFunc(NULL);
|
||||
}
|
||||
inline void JOR_SETROOTNODE(const char* name, JORReflexible* node, u32 param_3, u32 param_4) {
|
||||
JORServer::getInstance()->setRootNode(name, node, param_3, param_4);
|
||||
}
|
||||
|
||||
inline JORMContext* attachJORMContext(u32 msgID) {
|
||||
return JORServer::getInstance()->attachMCTX(msgID);
|
||||
}
|
||||
|
||||
inline JORMContext* JORAttachMContext(u32 msgID) {
|
||||
return JORServer::getInstance()->attachMCTX(msgID);
|
||||
}
|
||||
|
||||
inline void releaseJORMContext(JORMContext* mctx) {
|
||||
JORServer::getInstance()->releaseMCTX(mctx);
|
||||
}
|
||||
|
||||
inline void JORReleaseMContext(JORMContext* mctx) {
|
||||
JORServer::getInstance()->releaseMCTX(mctx);
|
||||
}
|
||||
|
||||
inline void JOR_ENABLEEVENTCALLBACKLIST(bool enable) {
|
||||
JORServer::getInstance()->enableEventCallbackList(enable);
|
||||
}
|
||||
|
||||
#endif /* JORSERVER_H */
|
||||
Reference in New Issue
Block a user