Import project

Original repository: https://github.com/encounter/ww
This commit is contained in:
Luke Street
2023-09-10 00:42:26 -04:00
parent 81ac53f131
commit adb95b135c
3731 changed files with 481532 additions and 0 deletions
+76
View File
@@ -0,0 +1,76 @@
#ifndef DYNAMICLINK_H
#define DYNAMICLINK_H
#include "dolphin/types.h"
typedef struct OSModuleInfo OSModuleInfo;
class JKRArchive;
class JKRFileCache;
class mDoDvdThd_callback_c;
struct DynamicModuleControlBase {
/* 0x00 */ u16 mLinkCount;
/* 0x02 */ u16 mDoLinkCount;
/* 0x04 */ DynamicModuleControlBase* mPrev;
/* 0x08 */ DynamicModuleControlBase* mNext;
/* 0x0C */ /*vtable*/
virtual ~DynamicModuleControlBase();
virtual const char* getModuleName() const { return NULL; }
virtual int getModuleSize() const { return 0; }
virtual const char* getModuleTypeString() const { return "Base"; }
virtual void dump();
static void dump();
virtual void dump2() { /* empty function */
}
virtual bool do_load() { return true; }
virtual BOOL do_load_async() { return true; }
virtual bool do_unload() { return true; }
virtual BOOL do_link() { return TRUE; }
virtual bool do_unlink() { return true; }
DynamicModuleControlBase();
BOOL link();
BOOL unlink();
BOOL load_async();
bool force_unlink();
static inline DynamicModuleControlBase* getFirstClass() { return mFirst; }
inline DynamicModuleControlBase* getNextClass() { return mNext; }
bool isLinked() const { return mLinkCount != 0; }
static DynamicModuleControlBase* mFirst;
static DynamicModuleControlBase* mLast;
};
struct DynamicModuleControl : DynamicModuleControlBase {
virtual ~DynamicModuleControl() {}
virtual const char* getModuleName() const { return mName; }
virtual int getModuleSize() const;
virtual const char* getModuleTypeString() const;
virtual void dump2();
virtual bool do_load();
virtual BOOL do_load_async();
virtual bool do_unload();
virtual BOOL do_link();
virtual bool do_unlink();
DynamicModuleControl(char const*);
static JKRArchive* mountCallback(void*);
static bool initialize();
static bool callback(void*);
/* 0x10 */ OSModuleInfo* mModule;
/* 0x14 */ void* mBss;
/* 0x18 */ u32 unk_24;
/* 0x1c */ const char* mName;
/* 0x20 */ u8 mResourceType;
/* 0x21 */ u8 unk_33;
/* 0x22 */ u16 mChecksum;
/* 0x24 */ s32 mSize;
/* 0x28 */ mDoDvdThd_callback_c* mAsyncLoadCallback;
static u32 sAllocBytes;
static JKRArchive* sArchive;
static JKRFileCache* sFileCache;
};
#endif /* DYNAMICLINK_H */
+125
View File
@@ -0,0 +1,125 @@
#ifndef LINKLIST_H
#define LINKLIST_H
#include "dolphin/types.h"
namespace JGadget {
struct TLinkListNode {
TLinkListNode() {
mNext = NULL;
mPrev = NULL;
}
TLinkListNode* getNext() { return mNext; }
/* 0x0 */ TLinkListNode* mNext;
/* 0x4 */ TLinkListNode* mPrev;
}; // Size: 0x8
struct TNodeLinkList {
struct iterator {
iterator(TLinkListNode* pNode) { node = pNode; }
iterator(const iterator& iter) { *this = iter; }
iterator& operator++() {
node = node->getNext();
return *this;
}
TLinkListNode* node;
};
struct const_iterator {
const_iterator(TLinkListNode* pNode) { node = pNode; }
const_iterator(const const_iterator& iter) { *this = iter; }
TLinkListNode* node;
};
TNodeLinkList() : ocObject_() { Initialize_(); }
void Initialize_() {
count = 0;
ocObject_.mNext = &ocObject_;
ocObject_.mPrev = &ocObject_;
}
iterator end() {
iterator iter(&ocObject_);
return iter;
}
iterator begin() {
iterator iter(ocObject_.mNext);
return iter;
}
~TNodeLinkList();
iterator erase(JGadget::TNodeLinkList::iterator, JGadget::TNodeLinkList::iterator);
iterator erase(JGadget::TNodeLinkList::iterator);
void splice(JGadget::TNodeLinkList::iterator, JGadget::TNodeLinkList&,
JGadget::TNodeLinkList::iterator);
iterator Insert(JGadget::TNodeLinkList::iterator, JGadget::TLinkListNode*);
iterator Erase(JGadget::TLinkListNode*);
void Remove(JGadget::TLinkListNode*);
/* 0x00 */ int count;
/* 0x04 */ TLinkListNode ocObject_;
}; // Size: 0xC
template <typename T, int I>
struct TLinkList : public TNodeLinkList {
TLinkList() : TNodeLinkList() {}
struct iterator : TNodeLinkList::iterator {
iterator(TNodeLinkList::iterator iter) : TNodeLinkList::iterator(iter) {}
};
TLinkListNode* Element_toNode(T* element) const { return &element->ocObject_; }
void Insert(TLinkList::iterator iter, T* element) {
TLinkListNode* node = Element_toNode(element);
TNodeLinkList::Insert(iter, node);
}
iterator Erase(T* element) {
TLinkListNode* node = Element_toNode(element);
return ((TNodeLinkList*)this)->Erase(node);
}
TLinkList::iterator end() {
TNodeLinkList::iterator node_iter = TNodeLinkList::end();
TLinkList::iterator iter(node_iter);
return iter;
}
TLinkList::iterator begin() {
TNodeLinkList::iterator node_iter = TNodeLinkList::begin();
TLinkList::iterator iter(node_iter);
return iter;
}
void Push_back(T* element) {
TLinkList::iterator iter(TLinkList::end());
this->Insert(iter, element);
}
};
template <typename T, int I>
struct TLinkList_factory : public TLinkList<T, I> {
virtual ~TLinkList_factory() {}
virtual T* Do_create() = 0;
virtual void Do_destroy(T*) = 0;
};
template <typename T, int I>
struct TEnumerator {
TLinkList<T, I> field_0x0;
TLinkList<T, I> field_0x4;
};
template <typename T, int I>
struct TContainerEnumerator_const : public TEnumerator<T, I> {};
}; // namespace JGadget
#endif /* LINKLIST_H */
+89
View File
@@ -0,0 +1,89 @@
#ifndef JKRARAM_H
#define JKRARAM_H
#include "JSystem/JKernel/JKRAramHeap.h"
#include "JSystem/JKernel/JKRDvdRipper.h"
#include "JSystem/JKernel/JKRThread.h"
class JKRHeap;
class JKRAMCommand;
class JKRAramBlock;
class JKRAram : public JKRThread {
private:
JKRAram(u32, u32, long);
virtual ~JKRAram();
/* vt[03] */ void* run(void); /* override */
public:
u32 getAudioMemory() const { return mAudioMemoryPtr; }
u32 getAudioMemSize() const { return mAudioMemorySize; }
u32 getGraphMemory() const { return mGraphMemoryPtr; }
u32 getGraphMemSize() const { return mGraphMemorySize; }
//private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRThread
/* 0x7C */ u32 mAudioMemoryPtr;
/* 0x80 */ u32 mAudioMemorySize;
/* 0x84 */ u32 mGraphMemoryPtr;
/* 0x88 */ u32 mGraphMemorySize;
/* 0x8C */ u32 mAramMemoryPtr;
/* 0x90 */ u32 mAramMemorySize;
/* 0x94 */ JKRAramHeap* mAramHeap;
/* 0x98 */ u32 mStackArray[3];
public:
static JKRAram* create(u32, u32, long, long, long);
static void checkOkAddress(u8*, u32, JKRAramBlock*, u32);
static void changeGroupIdIfNeed(u8*, int);
static JKRAramBlock* mainRamToAram(u8*, u32, u32, JKRExpandSwitch, u32, JKRHeap*, int, u32*);
static u8* aramToMainRam(u32, u8*, u32, JKRExpandSwitch, u32, JKRHeap*, int, u32*);
static void dump(void);
static JKRAram* getManager() { return sAramObject; }
static JKRAramHeap* getAramHeap() { return getManager()->mAramHeap; }
static JSUList<JKRAMCommand>& getCommandList() { return sAramCommandList; }
static u8 decideAramGroupId(int groupId) {
JKRAramHeap* heap;
u8 finalGroupId;
if (groupId < 0) {
return getAramHeap()->getCurrentGroupID();
}
return (u8)groupId;
}
static u32 getSZSBufferSize() { return sSZSBufferSize; }
static void setSZSBufferSize(u32 size) { sSZSBufferSize = size; }
static OSMessageQueue sMessageQueue;
private:
static JKRAram* sAramObject;
static u32 sSZSBufferSize;
static OSMessage sMessageBuffer[4];
static JSUList<JKRAMCommand> sAramCommandList;
};
inline void* JKRAllocFromAram(u32 size, JKRAramHeap::EAllocMode allocMode) {
return JKRAram::getAramHeap()->alloc(size, allocMode);
}
inline void JKRFreeToAram(JKRAramBlock* block) {
JKRAram::getAramHeap()->free(block);
}
inline void JKRAramToMainRam(u32 p1, u8* p2, u32 p3, JKRExpandSwitch p4, u32 p5, JKRHeap* p6,
int p7, u32* p8) {
JKRAram::aramToMainRam(p1, p2, p3, p4, p5, p6, p7, p8);
}
inline JKRAramBlock *JKRMainRamToAram(u8 *buf, u32 bufSize, u32 alignedSize, JKRExpandSwitch expandSwitch, u32 fileSize, JKRHeap *heap, int id, u32 *pSize) {
return JKRAram::mainRamToAram(buf, bufSize, alignedSize, expandSwitch, fileSize, heap, id, pSize);
}
// void JKRDecompressFromAramToMainRam(u32, void*, u32, u32, u32, u32*);
#endif /* JKRARAM_H */
+36
View File
@@ -0,0 +1,36 @@
#ifndef JKRARAMARCHIVE_H
#define JKRARAMARCHIVE_H
#include "JSystem/JKernel/JKRArchive.h"
#include "dolphin/types.h"
class JKRAramBlock;
class JKRDvdFile;
class JKRAramArchive : public JKRArchive {
public:
JKRAramArchive(long, JKRArchive::EMountDirection);
virtual ~JKRAramArchive();
bool open(long);
u32 getAramAddress_Entry(SDIFileEntry*);
u32 getAramAddress(char const*);
/* vt[15] */ u32 getExpandedResSize(const void*) const; /* override */
/* vt[16] */ void* fetchResource(SDIFileEntry*, u32*); /* override */
/* vt[17] */ void* fetchResource(void*, u32, SDIFileEntry*, u32*); /* override */
public:
static u32 fetchResource_subroutine(u32, u32, u8*, u32, int);
static u32 fetchResource_subroutine(u32, u32, JKRHeap*, int, u8**);
private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRArchive
/* 0x5C */ JKRCompression mCompression;
/* 0x60 */ EMountDirection mMountDirection;
/* 0x64 */ JKRAramBlock* mBlock;
/* 0x68 */ JKRDvdFile* mDvdFile;
}; // Size = 0x6C
#endif /* JKRARAMARCHIVE_H */
+36
View File
@@ -0,0 +1,36 @@
#ifndef JKRARAMBLOCK_H
#define JKRARAMBLOCK_H
#include "JSystem/JSupport/JSUList.h"
class JKRAramHeap;
class JKRAramBlock {
public:
JKRAramBlock(u32, u32, u32, u8, bool);
virtual ~JKRAramBlock();
JKRAramBlock* allocHead(u32, u8, JKRAramHeap*);
JKRAramBlock* allocTail(u32, u8, JKRAramHeap*);
u32 getAddress() const { return mAddress; }
u32 getSize() const { return mSize; }
u32 getFreeSize() const { return mFreeSize; }
bool isTempMemory() const { return mIsTempMemory; }
void newGroupID(u8 groupId) { mGroupId = groupId; }
public:
/* 0x00 */ // vtable
/* 0x04 */ JSULink<JKRAramBlock> mBlockLink;
/* 0x14 */ u32 mAddress;
/* 0x18 */ u32 mSize;
/* 0x1C */ u32 mFreeSize;
/* 0x20 */ u8 mGroupId;
/* 0x21 */ u8 mIsTempMemory;
/* 0x22 */ u8 padding[2];
};
#endif /* JKRARAMBLOCK_H */
+54
View File
@@ -0,0 +1,54 @@
#ifndef JKRARAMHEAP_H
#define JKRARAMHEAP_H
#include "JSystem/JKernel/JKRAramBlock.h"
#include "JSystem/JKernel/JKRDisposer.h"
#include "dolphin/os/OSMutex.h"
class JKRAramHeap : public JKRDisposer {
public:
enum EAllocMode {
HEAD = 0,
TAIL = 1,
};
public:
// TODO: fix type
static JSUList<JKRAramBlock> sAramList;
JKRAramHeap(u32, u32);
virtual ~JKRAramHeap();
JKRAramBlock* alloc(u32, EAllocMode);
JKRAramBlock* allocFromHead(u32);
JKRAramBlock* allocFromTail(u32);
u32 getFreeSize(void);
u32 getTotalFreeSize(void);
// u32 getUsedSize(void);
void dump(void);
void free(JKRAramBlock *block) {
delete block;
}
u8 getCurrentGroupID() const { return mGroupId; }
JKRHeap* getMgrHeap() const { return mHeap; }
private:
void lock() { OSLockMutex(&mMutex); }
void unlock() { OSUnlockMutex(&mMutex); }
public:
/* 0x00 */ // vtable
/* 0x04 */ // JKRDisposer
/* 0x18 */ OSMutex mMutex;
/* 0x30 */ JKRHeap* mHeap;
/* 0x34 */ u32 mHeadAddress;
/* 0x38 */ u32 mTailAddress;
/* 0x3C */ u32 mSize;
/* 0x40 */ u8 mGroupId;
/* 0x41 */ u8 padding_0x41[3];
};
#endif /* JKRARAMHEAP_H */
+73
View File
@@ -0,0 +1,73 @@
#ifndef JKRARAMPIECE_H
#define JKRARAMPIECE_H
#include "JSystem/JSupport/JSUList.h"
#include "dolphin/ar/arq.h"
#include "dolphin/os/OSMessage.h"
#include "dolphin/os/OSMutex.h"
class JKRAramBlock;
class JKRDecompCommand;
class JKRAMCommand {
public:
typedef void (*AsyncCallback)(u32);
JKRAMCommand();
~JKRAMCommand();
public:
/* 0x00 */ ARQRequest mRequest;
/* 0x20 */ JSULink<JKRAMCommand> mPieceLink;
/* 0x30 */ JSULink<JKRAMCommand> field_0x30;
/* 0x40 */ s32 mTransferDirection;
/* 0x44 */ u32 mDataLength;
/* 0x48 */ u32 mSrc;
/* 0x4C */ u32 mDst;
/* 0x50 */ JKRAramBlock* mAramBlock;
/* 0x54 */ u32 field_0x54;
/* 0x58 */ AsyncCallback mCallback;
/* 0x5C */ OSMessageQueue* field_0x5C;
/* 0x60 */ s32 field_0x60;
/* 0x64 */ JKRDecompCommand* mDecompCommand;
/* 0x68 */ OSMessageQueue mMessageQueue;
/* 0x88 */ OSMessage mMessage;
/* 0x8C */ void* field_0x8C;
/* 0x90 */ void* field_0x90;
/* 0x94 */ void* field_0x94;
};
class JKRAramPiece {
public:
static OSMutex mMutex;
// TODO: fix type
static JSUList<JKRAMCommand> sAramPieceCommandList;
public:
struct Message {
s32 field_0x00;
JKRAMCommand* command;
};
public:
static JKRAMCommand* prepareCommand(int, u32, u32, u32, JKRAramBlock*,
JKRAMCommand::AsyncCallback);
static void sendCommand(JKRAMCommand*);
static JKRAMCommand* orderAsync(int, u32, u32, u32, JKRAramBlock*, JKRAMCommand::AsyncCallback);
static BOOL sync(JKRAMCommand*, int);
static BOOL orderSync(int, u32, u32, u32, JKRAramBlock*);
static void startDMA(JKRAMCommand*);
static void doneDMA(u32);
private:
static void lock() { OSLockMutex(&mMutex); }
static void unlock() { OSUnlockMutex(&mMutex); }
};
inline BOOL JKRAramPcs(int direction, u32 source, u32 destination, u32 length,
JKRAramBlock* block) {
return JKRAramPiece::orderSync(direction, source, destination, length, block);
}
#endif /* JKRARAMPIECE_H */
+68
View File
@@ -0,0 +1,68 @@
#ifndef JKRARAMSTREAM_H
#define JKRARAMSTREAM_H
#include "JSystem/JKernel/JKRThread.h"
class JSUFileInputStream;
class JKRAramStreamCommand {
public:
enum Type {
UNKNOWN = 0,
READ = 1,
WRITE = 2,
};
JKRAramStreamCommand();
public:
/* 0x00 */ Type mType;
/* 0x04 */ u32 mAddress;
/* 0x08 */ u32 mSize;
/* 0x0C */ u32 field_0x0c;
/* 0x10 */ JSUFileInputStream* mStream;
/* 0x14 */ u32 mOffset;
/* 0x18 */ u32* mReturnSize;
/* 0x1C */ u8* mTransferBuffer;
/* 0x20 */ u32 mTransferBufferSize;
/* 0x24 */ JKRHeap* mHeap;
/* 0x28 */ bool mAllocatedTransferBuffer;
/* 0x29 */ u8 padding_0x29[3];
/* 0x2C */ u32 field_0x2c;
/* 0x30 */ OSMessageQueue mMessageQueue;
/* 0x50 */ OSMessage mMessage;
/* 0x54 */ u32 field_0x54;
/* 0x58 */ u32 field_0x58;
};
class JKRAramStream : public JKRThread {
private:
JKRAramStream(long);
virtual ~JKRAramStream();
/* vt[03] */ void* run(void); /* override */
public:
static JKRAramStream* create(long);
static s32 readFromAram(void);
static s32 writeToAram(JKRAramStreamCommand*);
static JKRAramStreamCommand* write_StreamToAram_Async(JSUFileInputStream*, u32, u32, u32, u32*);
static JKRAramStreamCommand* sync(JKRAramStreamCommand*, BOOL);
static void setTransBuffer(u8*, u32, JKRHeap*);
private:
static JKRAramStream* sAramStreamObject;
static OSMessage sMessageBuffer[4];
static OSMessageQueue sMessageQueue;
static u8* transBuffer;
static u32 transSize;
static JKRHeap* transHeap;
};
inline JKRAramStream* JKRCreateAramStreamManager(long priority) {
return JKRAramStream::create(priority);
}
#endif /* JKRARAMSTREAM_H */
+227
View File
@@ -0,0 +1,227 @@
#ifndef JKRARCHIVE_H
#define JKRARCHIVE_H
#include "JSystem/JKernel/JKRCompression.h"
#include "JSystem/JKernel/JKRFileLoader.h"
#include "global.h"
class JKRHeap;
struct SArcHeader {
/* 0x00 */ u32 signature;
/* 0x04 */ u32 file_length;
/* 0x08 */ u32 header_length;
/* 0x0C */ u32 file_data_offset;
/* 0x10 */ u32 file_data_length;
/* 0x14 */ u32 field_0x14;
/* 0x18 */ u32 field_0x18;
/* 0x1C */ u32 field_0x1c;
};
struct SArcDataInfo {
/* 0x00 */ u32 num_nodes;
/* 0x04 */ u32 node_offset;
/* 0x08 */ u32 num_file_entries;
/* 0x0C */ u32 file_entry_offset;
/* 0x10 */ u32 string_table_length;
/* 0x14 */ u32 string_table_offset;
/* 0x18 */ u16 next_free_file_id;
/* 0x1A */ bool sync_file_ids_and_indices;
/* 0x1B */ u8 field_1b[5];
};
inline u32 read_big_endian_u32(void* ptr) {
u8* uptr = (u8*)ptr;
return ((u32)uptr[0] << 0x18) | ((u32)uptr[1] << 0x10) | ((u32)uptr[2] << 8) | (u32)uptr[3];
}
inline u16 read_big_endian_u16(void* ptr) {
u8* uptr = (u8*)ptr;
return ((u16)uptr[0] << 8) | ((u16)uptr[1]);
}
inline u32 JKRDecompExpandSize(u8 * pBuf) {
return (pBuf[4] << 0x18) | (pBuf[5] << 0x10) | (pBuf[6] << 8) | pBuf[7];
}
extern u32 sCurrentDirID__10JKRArchive; // JKRArchive::sCurrentDirID
class JKRArchive : public JKRFileLoader {
public:
struct SDirEntry {
u8 flags;
u8 padding;
u16 id;
const char* name;
};
struct SDIDirEntry {
u32 type;
u32 name_offset;
u16 field_0x8;
u16 num_entries;
u32 first_file_index;
};
struct SDIFileEntry {
u16 file_id;
u16 name_hash;
u32 type_flags_and_name_offset;
u32 data_offset;
u32 data_size;
void* data;
u32 getNameOffset() const { return type_flags_and_name_offset & 0xFFFFFF; }
u16 getNameHash() const { return name_hash; }
u32 getFlags() const { return type_flags_and_name_offset >> 24; }
u32 getAttr() const { return getFlags(); }
u16 getFileID() const { return file_id; }
bool isDirectory() const { return (getFlags() & 0x02) != 0; }
bool isUnknownFlag1() const { return (getFlags() & 0x01) != 0; }
bool isCompressed() const { return (getFlags() & 0x04) != 0; }
// was needed for open__14JKRAramArchiveFl
u8 getCompressFlag() const { return (getFlags() & 0x04); }
bool isYAZ0Compressed() const { return (getFlags() & 0x80) != 0; }
u32 getSize() const { return data_size; }
};
enum EMountMode {
UNKNOWN_MOUNT_MODE = 0,
MOUNT_MEM = 1,
MOUNT_ARAM = 2,
MOUNT_DVD = 3,
MOUNT_COMP = 4,
};
enum EMountDirection {
UNKNOWN_MOUNT_DIRECTION = 0,
MOUNT_DIRECTION_HEAD = 1,
MOUNT_DIRECTION_TAIL = 2,
};
class CArcName {
public:
CArcName() {}
CArcName(char const* data) { this->store(data); }
CArcName(char const** data, char endChar) { *data = this->store(*data, endChar); }
void store(char const* data);
const char* store(char const* data, char endChar);
u16 getHash() const { return mHash; }
const char* getString() const { return mData; }
private:
u16 mHash;
u16 mLength;
char mData[256];
};
protected:
JKRArchive();
JKRArchive(long, EMountMode);
virtual ~JKRArchive();
public:
bool getDirEntry(SDirEntry*, u32) const;
void* getIdxResource(u32);
void* getResource(u16);
u32 readIdxResource(void*, u32, u32);
u32 readResource(void*, u32, u16);
u32 countResource(void) const;
u32 getFileAttribute(u32) const;
SDIFileEntry* findNameResource(const char*) const;
bool isSameName(CArcName&, u32, u16) const;
SDIDirEntry* findResType(u32) const;
SDIDirEntry* findDirectory(const char*, u32) const;
SDIFileEntry* findTypeResource(u32, const char*) const;
SDIFileEntry* findFsResource(const char*, u32) const;
SDIFileEntry* findIdxResource(u32) const;
SDIFileEntry* findPtrResource(const void*) const;
SDIFileEntry* findIdResource(u16) const;
public:
/* vt[04] */ virtual bool becomeCurrent(const char*); /* override */
/* vt[05] */ virtual void* getResource(const char*); /* override */
/* vt[06] */ virtual void* getResource(u32, const char*); /* override */
/* vt[07] */ virtual u32 readResource(void*, u32, const char*); /* override */
/* vt[08] */ virtual u32 readResource(void*, u32, u32, const char*); /* override */
/* vt[09] */ virtual void removeResourceAll(void); /* override */
/* vt[10] */ virtual bool removeResource(void*); /* override */
/* vt[11] */ virtual bool detachResource(void*); /* override */
/* vt[12] */ virtual u32 getResSize(const void*) const; /* override */
/* vt[13] */ virtual u32 countFile(const char*) const; /* override */
/* vt[14] */ virtual JKRFileFinder* getFirstFile(const char*) const; /* override */
/* vt[15] */ virtual u32 getExpandedResSize(const void*) const;
/* vt[16] */ virtual void* fetchResource(SDIFileEntry*, u32*) = 0;
/* vt[17] */ virtual void* fetchResource(void*, u32, SDIFileEntry*, u32*) = 0;
/* vt[18] */ virtual void setExpandSize(SDIFileEntry*, u32);
/* vt[19] */ virtual u32 getExpandSize(SDIFileEntry*) const;
u32 countFile() const { return mArcInfoBlock->num_file_entries; }
s32 countDirectory() const { return mArcInfoBlock->num_nodes; }
u8 getMountMode() const { return mMountMode; }
bool isFileEntry(u32 param_0) {
return getFileAttribute(param_0) & 1;
}
public:
/* 0x00 */ // vtable
/* 0x04 */ // JKRFileLoader
/* 0x38 */ JKRHeap* mHeap;
/* 0x3C */ u8 mMountMode;
/* 0x3D */ u8 field_0x3d[3];
/* 0x40 */ s32 mEntryNum;
/* 0x44 */ SArcDataInfo* mArcInfoBlock;
/* 0x48 */ SDIDirEntry* mNodes;
/* 0x4C */ SDIFileEntry* mFiles;
/* 0x50 */ s32* mExpandedSize;
/* 0x54 */ char* mStringTable;
protected:
/* 0x58 */ u32 field_0x58;
public:
static JKRArchive* check_mount_already(s32, JKRHeap*);
static JKRArchive* mount(const char*, EMountMode, JKRHeap*, EMountDirection);
static JKRArchive* mount(void*, JKRHeap*, EMountDirection);
static JKRArchive* mount(s32, EMountMode, JKRHeap*, EMountDirection);
static void* getGlbResource(u32, const char*, JKRArchive*);
static JKRCompression convertAttrToCompressionType(u32 attr) {
#define JKRARCHIVE_ATTR_COMPRESSION 0x04
#define JKRARCHIVE_ATTR_YAY0 0x80
JKRCompression compression;
if (FLAG_ON(attr, JKRARCHIVE_ATTR_COMPRESSION)) {
compression = COMPRESSION_NONE;
} else if (!FLAG_ON(attr, JKRARCHIVE_ATTR_YAY0)) {
compression = COMPRESSION_YAZ0;
} else {
compression = COMPRESSION_YAY0;
}
return compression;
}
static u32 getCurrentDirID() { return sCurrentDirID; }
static void setCurrentDirID(u32 dirID) { sCurrentDirID = dirID; }
private:
static u32 sCurrentDirID;
};
inline JKRCompression JKRConvertAttrToCompressionType(u32 attr) {
return JKRArchive::convertAttrToCompressionType(attr);
}
inline void* JKRGetResource(u32 node, const char* path, JKRArchive* archive) {
return JKRArchive::getGlbResource(node, path, archive);
}
inline void* JKRGetTypeResource(u32 tag, const char* name, JKRArchive* arc) {
return JKRArchive::getGlbResource(tag, name, arc);
}
#endif
+5
View File
@@ -0,0 +1,5 @@
#ifndef JKRARCHIVEPRI_H
#define JKRARCHIVEPRI_H
#endif /* JKRARCHIVEPRI_H */
+5
View File
@@ -0,0 +1,5 @@
#ifndef JKRARCHIVEPUB_H
#define JKRARCHIVEPUB_H
#endif /* JKRARCHIVEPUB_H */
+34
View File
@@ -0,0 +1,34 @@
#ifndef JKRASSERTHEAP_H
#define JKRASSERTHEAP_H
#include "JSystem/JKernel/JKRHeap.h"
class JKRAssertHeap : public JKRHeap {
protected:
JKRAssertHeap(void*, unsigned long, JKRHeap*, bool);
virtual ~JKRAssertHeap();
public:
/* vt[04] */ virtual u32 getHeapType(void); /* override */
/* vt[05] */ virtual bool check(void); /* override */
/* vt[06] */ virtual bool dump_sort(void); /* override */
/* vt[07] */ virtual bool dump(void); /* override */
/* vt[08] */ virtual void do_destroy(void); /* override */
/* vt[09] */ virtual void* do_alloc(u32, int); /* override */
/* vt[10] */ virtual void do_free(void*); /* override */
/* vt[11] */ virtual void do_freeAll(void); /* override */
/* vt[12] */ virtual void do_freeTail(void); /* override */
/* vt[13] */ virtual void do_fillFreeArea(void); /* override */
/* vt[14] */ virtual s32 do_resize(void*, u32); /* override */
/* vt[15] */ virtual s32 do_getSize(void*); /* override */
/* vt[16] */ virtual s32 do_getFreeSize(void); /* override */
/* vt[17] */ virtual void* do_getMaxFreeBlock(void); /* override */
/* vt[18] */ virtual s32 do_getTotalFreeSize(void); /* override */
/* vt[19] */ virtual s32 do_changeGroupID(u8 param_1); /* override */
/* vt[20] */ virtual u8 do_getCurrentGroupId(void); /* override */
public:
static JKRAssertHeap* create(JKRHeap*);
};
#endif /* JKRASSERTHEAP_H */
+38
View File
@@ -0,0 +1,38 @@
#ifndef JKRCOMPARCHIVE_H
#define JKRCOMPARCHIVE_H
#include "JSystem/JKernel/JKRArchive.h"
class JKRAramBlock;
class JKRDvdFile;
class JKRCompArchive : public JKRArchive {
public:
JKRCompArchive(long, JKRArchive::EMountDirection);
virtual ~JKRCompArchive();
bool open(long);
/* vt[09] */ void removeResourceAll(void); /* override */
/* vt[10] */ bool removeResource(void*); /* override */
/* vt[15] */ u32 getExpandedResSize(const void*) const; /* override */
/* vt[16] */ void* fetchResource(SDIFileEntry*, u32*); /* override */
/* vt[17] */ void* fetchResource(void*, u32, SDIFileEntry*, u32*); /* override */
public:
private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRArchive
/* 0x5C */ int mCompression;
/* 0x60 */ EMountDirection mMountDirection;
/* 0x64 */ int field_0x64;
/* 0x68 */ JKRAramBlock* mAramPart;
/* 0x6C */ int field_0x6c;
/* 0x70 */ JKRDvdFile* mDvdFile;
/* 0x74 */ u32 mSizeOfMemPart;
/* 0x78 */ u32 mSizeOfAramPart;
/* 0x7C */ int field_0x7c;
};
#endif /* JKRCOMPARCHIVE_H */
+10
View File
@@ -0,0 +1,10 @@
#ifndef JKRCOMPREESION_H_
#define JKRCOMPREESION_H_
typedef int JKRCompression;
const JKRCompression COMPRESSION_NONE = 0;
const JKRCompression COMPRESSION_YAY0 = 1;
const JKRCompression COMPRESSION_YAZ0 = 2;
const JKRCompression COMPRESSION_ASR = 3;
#endif
+72
View File
@@ -0,0 +1,72 @@
#ifndef JKRDECOMP_H
#define JKRDECOMP_H
#include "JSystem/JKernel/JKRCompression.h"
#include "JSystem/JKernel/JKRThread.h"
class JKRAMCommand;
class JKRDecompCommand {
public:
typedef void (*AsyncCallback)(u32);
JKRDecompCommand();
~JKRDecompCommand();
public:
/* 0x00 */ u32 field_0x0;
/* 0x04 */ u8* mSrcBuffer;
/* 0x08 */ u8* mDstBuffer;
/* 0x0C */ u32 mSrcLength;
/* 0x10 */ u32 mDstLength;
/* 0x14 */ AsyncCallback mCallback;
/* 0x18 */ JKRDecompCommand* mThis;
/* 0x1C */ OSMessageQueue* field_0x1c;
/* 0x20 */ s32 field_0x20;
/* 0x24 */ JKRAMCommand* mAMCommand;
/* 0x28 */ OSMessageQueue mMessageQueue;
/* 0x48 */ OSMessage mMessage;
};
#define JKRDECOMP_SYNC_BLOCKING 0
#define JKRDECOMP_SYNC_NON_BLOCKING 1
class JKRDecomp : public JKRThread {
private:
JKRDecomp(long);
virtual ~JKRDecomp();
/* vt[03] */ virtual void* run(); /* override */
public:
static JKRDecomp* create(long);
static JKRDecompCommand* prepareCommand(u8*, u8*, u32, u32, JKRDecompCommand::AsyncCallback);
static void sendCommand(JKRDecompCommand*);
static bool sync(JKRDecompCommand*, int);
static JKRDecompCommand* orderAsync(u8*, u8*, u32, u32, JKRDecompCommand::AsyncCallback);
static bool orderSync(u8*, u8*, u32, u32);
static void decode(u8*, u8*, u32, u32);
static void decodeSZP(u8*, u8*, u32, u32);
static void decodeSZS(u8*, u8*, u32, u32);
static JKRCompression checkCompressed(u8*);
static JKRDecomp* sDecompObject;
static OSMessage sMessageBuffer[8];
static OSMessageQueue sMessageQueue;
};
inline void JKRDecompress(u8* srcBuffer, u8* dstBuffer, u32 srcLength, u32 dstLength) {
JKRDecomp::orderSync(srcBuffer, dstBuffer, srcLength, dstLength);
}
inline JKRDecomp* JKRCreateDecompManager(long priority) {
return JKRDecomp::create(priority);
}
inline JKRCompression JKRCheckCompressed_noASR(u8 *pBuf) {
JKRCompression compression = JKRDecomp::checkCompressed(pBuf);
if (compression == COMPRESSION_ASR) // ternary i had before was either incorrect, or was not a ternary at all
compression = COMPRESSION_NONE;
return compression;
}
#endif /* JKRDECOMP_H */
+19
View File
@@ -0,0 +1,19 @@
#ifndef JKRDISPOSER_H
#define JKRDISPOSER_H
#include "JSystem/JSupport/JSUList.h"
class JKRHeap;
class JKRDisposer {
public:
JKRDisposer();
virtual ~JKRDisposer();
public:
/* 0x00 */ // vtable
/* 0x04 */ JKRHeap* mHeap;
/* 0x08 */ JSULink<JKRDisposer> mLink;
/* 0x18 */
};
#endif /* JKRDISPOSER_H */
@@ -0,0 +1,56 @@
#ifndef JKRDVDARAMRIPPER_H
#define JKRDVDARAMRIPPER_H
#include "JSystem/JKernel/JKRDvdRipper.h"
#include "dolphin/types.h"
class JKRAramBlock;
class JKRAramStreamCommand;
class JKRADCommand {
public:
JKRADCommand();
~JKRADCommand();
/* 0x00 */ JSULink<JKRADCommand> mLink;
/* 0x10 */ int field_0x10;
/* 0x14 */ int field_0x14;
/* 0x18 */ int field_0x18;
/* 0x1C */ int field_0x1c;
/* 0x20 */ int field_0x20;
/* 0x24 */ int field_0x24;
/* 0x28 */ JKRDvdFile* mDvdFile;
/* 0x2C */ u32 field_0x2c;
/* 0x30 */ JKRAramBlock* mBlock;
/* 0x34 */ int field_0x34;
/* 0x38 */ void (*field_0x38)(u32);
/* 0x3C */ u32 field_0x3c;
/* 0x40 */ u32 field_0x40;
/* 0x44 */ u32* field_0x44;
/* 0x48 */ int field_0x48;
/* 0x4C */ u8 field_0x4c;
/* 0x50 */ JKRAramStreamCommand* mStreamCommand;
};
class JKRDvdFile;
class JKRDvdAramRipper {
public:
static JKRAramBlock* loadToAram(long, u32, JKRExpandSwitch, u32, u32, u32*);
static JKRAramBlock* loadToAram(JKRDvdFile*, u32, JKRExpandSwitch, u32, u32, u32*);
static JKRADCommand* loadToAram_Async(JKRDvdFile*, u32, JKRExpandSwitch, void (*)(u32), u32,
u32, u32*);
static JKRADCommand* callCommand_Async(JKRADCommand*);
static bool syncAram(JKRADCommand*, int);
static void setSZSBufferSize(u32 size) { sSZSBufferSize = size; }
// TODO: fix type
static u8 sDvdAramAsyncList[12];
static u32 sSZSBufferSize;
};
inline JKRAramBlock *JKRDvdToAram(s32 entrynum, u32 p2, JKRExpandSwitch expSwitch, u32 p4, u32 p5, u32 *p6) {
return JKRDvdAramRipper::loadToAram(entrynum, p2, expSwitch, p4, p5, p6);
}
#endif /* JKRDVDARAMRIPPER_H */
+32
View File
@@ -0,0 +1,32 @@
#ifndef JKRDVDARCHIVE_H
#define JKRDVDARCHIVE_H
#include "JSystem/JKernel/JKRArchive.h"
class JKRDvdFile;
class JKRDvdArchive : public JKRArchive {
public:
JKRDvdArchive(s32, JKRArchive::EMountDirection);
virtual ~JKRDvdArchive();
bool open(s32);
/* vt[15] */ virtual u32 getExpandedResSize(const void*) const; /* override */
/* vt[16] */ virtual void* fetchResource(SDIFileEntry*, u32*); /* override */
/* vt[17] */ virtual void* fetchResource(void*, u32, SDIFileEntry*, u32*); /* override */
public:
static u32 fetchResource_subroutine(s32, u32, u32, u8*, u32, JKRCompression, JKRCompression);
static u32 fetchResource_subroutine(s32, u32, u32, JKRHeap*, JKRCompression, JKRCompression,
u8**);
private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRArchive
/* 0x5C */ JKRCompression mCompression;
/* 0x60 */ EMountDirection mMountDirection;
/* 0x64 */ s32 field_0x64;
/* 0x68 */ JKRDvdFile* mDvdFile;
};
#endif /* JKRDVDARCHIVE_H */
+63
View File
@@ -0,0 +1,63 @@
#ifndef JKRDVDFILE_H
#define JKRDVDFILE_H
#include "JSystem/JKernel/JKRFile.h"
#include "dolphin/dvd/dvd.h"
#include "dolphin/os/OSMessage.h"
#include "dolphin/os/OSMutex.h"
struct OSThread;
class JKRADCommand;
class JKRAramBlock;
class JSUFileInputStream;
class JKRDvdFile : public JKRFile {
public:
JKRDvdFile();
JKRDvdFile(const char*);
JKRDvdFile(long);
virtual ~JKRDvdFile();
void initiate(void);
s32 sync(void);
u32 getFileID() const { return mFileInfo.start_address; }
DVDFileInfo* getFileInfo() { return &mFileInfo; }
int getStatus() { return DVDGetCommandBlockStatus(&mFileInfo.block); }
public:
/* vt[03] */ virtual bool open(const char*); /* override */
/* vt[04] */ virtual void close(void); /* override */
/* vt[05] */ virtual s32 readData(void*, s32, s32); /* override */
/* vt[06] */ virtual s32 writeData(const void*, s32, s32); /* override */
/* vt[07] */ virtual s32 getFileSize(void) const; /* override */
/* vt[08] */ virtual bool open(s32);
// private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRFile
/* 0x1C */ OSMutex mMutex1;
/* 0x34 */ OSMutex mMutex2;
/* 0x4C */ JKRAramBlock* mBlock;
/* 0x50 */ OSThread* field_0x50;
/* 0x54 */ JSUFileInputStream* mFileStream;
/* 0x58 */ u32 field_0x58;
/* 0x5C */ DVDFileInfo mFileInfo;
/* 0x98 */ JKRDvdFile* mDvdFile;
/* 0x9C */ OSMessageQueue mMessageQueue1;
/* 0xBC */ OSMessage mMessage1;
/* 0xC0 */ OSMessageQueue mMessageQueue2;
/* 0xE0 */ OSMessage mMessage2;
/* 0xE4 */ JSULink<JKRDvdFile> mDvdLink;
/* 0xF4 */ OSThread* mOSThread;
public:
static void doneProcess(long, DVDFileInfo*);
static JSUList<JKRDvdFile>& getDvdList() { return sDvdList; }
private:
static JSUList<JKRDvdFile> sDvdList;
};
#endif /* JKRDVDFILE_H */
+65
View File
@@ -0,0 +1,65 @@
#ifndef JKRDVDRIPPER_H
#define JKRDVDRIPPER_H
#include "JSystem/JKernel/JKRCompression.h"
#include "JSystem/JSupport/JSUList.h"
enum JKRExpandSwitch {
EXPAND_SWITCH_UNKNOWN0 = 0,
EXPAND_SWITCH_UNKNOWN1 = 1,
EXPAND_SWITCH_UNKNOWN2 = 2,
};
struct SYaz0Header {
u32 signature;
u32 length;
};
class JKRDMCommand {
JKRDMCommand();
~JKRDMCommand();
};
class JKRHeap;
class JKRDvdFile;
class JKRDvdRipper {
public:
static JSUList<JKRDMCommand> sDvdAsyncList;
static u32 sSZSBufferSize;
enum EAllocDirection {
UNKNOWN_EALLOC_DIRECTION = 0,
ALLOC_DIRECTION_FORWARD = 1,
ALLOC_DIRECTION_BACKWARD = 2,
};
static void setSZSBufferSize(u32 size) { sSZSBufferSize = size; }
static void* loadToMainRAM(char const*, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection,
u32, int*);
static void* loadToMainRAM(long, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection, u32,
int*);
static void* loadToMainRAM(JKRDvdFile*, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection,
u32, int*);
static u8 isErrorRetry(void);
inline static u32 getSZSBufferSize() { return sSZSBufferSize; }
};
// void JKRDecompressFromDVD(JKRDvdFile*, void*, u32, u32, u32, u32, u32*);
inline void* JKRDvdToMainRam(s32 entryNum, u8* dst, JKRExpandSwitch expandSwitch, u32 dstLength,
JKRHeap* heap, JKRDvdRipper::EAllocDirection allocDirection,
u32 offset, int* returnSize) {
return JKRDvdRipper::loadToMainRAM(entryNum, dst, expandSwitch, dstLength, heap, allocDirection,
offset, returnSize);
}
inline void* JKRDvdToMainRam(const char* name, u8* dst, JKRExpandSwitch expandSwitch, u32 dstLength,
JKRHeap* heap, JKRDvdRipper::EAllocDirection allocDirection,
u32 offset, int* returnSize) {
return JKRDvdRipper::loadToMainRAM(name, dst, expandSwitch, dstLength, heap, allocDirection,
offset, returnSize);
}
#endif /* JKRDVDRIPPER_H */
+113
View File
@@ -0,0 +1,113 @@
#ifndef JKREXPHEAP_H
#define JKREXPHEAP_H
#include "JSystem/JKernel/JKRHeap.h"
class JKRExpHeap : public JKRHeap {
public:
enum EAllocMode {
ALLOC_MODE_1 = 1,
};
class CMemBlock {
friend class JKRExpHeap;
public:
void initiate(CMemBlock* prev, CMemBlock* next, u32 size, u8 groupId, u8 alignment);
JKRExpHeap::CMemBlock* allocFore(u32 size, u8 groupId1, u8 alignment1, u8 groupId2,
u8 alignment2);
JKRExpHeap::CMemBlock* allocBack(u32 size, u8 groupId1, u8 alignment1, u8 groupId2,
u8 alignment2);
int free(JKRExpHeap* heap);
static CMemBlock* getHeapBlock(void* ptr);
void newGroupId(u8 groupId) { mGroupId = groupId; }
bool isValid() const { return mMagic == 'HM'; }
bool _isTempMemBlock() const { return (mFlags & 0x80) ? true : false; }
int getAlignment() const { return mFlags & 0x7f; }
void* getContent() const { return (void*)(this + 1); }
CMemBlock* getPrevBlock() const { return mPrev; }
CMemBlock* getNextBlock() const { return mNext; }
u32 getSize() const { return size; }
u8 getGroupId() const { return mGroupId; }
static CMemBlock* getBlock(void* data) { return (CMemBlock*)((u32)data + -0x10); }
private:
/* 0x0 */ u16 mMagic;
/* 0x2 */ u8 mFlags; // a|bbbbbbb a=temporary b=alignment
/* 0x3 */ u8 mGroupId;
/* 0x4 */ u32 size;
/* 0x8 */ CMemBlock* mPrev;
/* 0xC */ CMemBlock* mNext;
}; // Size: 0x10
friend class CMemBlock;
protected:
JKRExpHeap(void* data, u32 size, JKRHeap* parent, bool errorFlag);
virtual ~JKRExpHeap();
void* allocFromHead(u32 size, int align);
void* allocFromHead(u32 size);
void* allocFromTail(u32 size, int align);
void* allocFromTail(u32 size);
void appendUsedList(CMemBlock* newblock);
void setFreeBlock(CMemBlock* block, CMemBlock* prev, CMemBlock* next);
void removeFreeBlock(CMemBlock* block);
void removeUsedBlock(CMemBlock* block);
void recycleFreeBlock(CMemBlock* block);
void joinTwoBlocks(CMemBlock* block);
public:
s32 getUsedSize(u8 groupId) const;
s32 getTotalUsedSize(void) const;
CMemBlock* getHeadUsedList() const { return mHeadUsedList; }
void setAllocationMode(EAllocMode mode) {
mAllocMode = mode;
}
public:
/* vt[04] */ virtual u32 getHeapType(); /* override */
/* vt[05] */ virtual bool check(); /* override */
/* vt[06] */ virtual bool dump_sort(); /* override */
/* vt[07] */ virtual bool dump(); /* override */
/* vt[08] */ virtual void do_destroy(); /* override */
/* vt[09] */ virtual void* do_alloc(u32 size, int alignment); /* override */
/* vt[10] */ virtual void do_free(void* ptr); /* override */
/* vt[11] */ virtual void do_freeAll(); /* override */
/* vt[12] */ virtual void do_freeTail(); /* override */
/* vt[13] */ virtual void do_fillFreeArea(); /* override */
/* vt[14] */ virtual s32 do_resize(void* ptr, u32 size); /* override */
/* vt[15] */ virtual s32 do_getSize(void* ptr); /* override */
/* vt[16] */ virtual s32 do_getFreeSize(); /* override */
/* vt[17] */ virtual void* do_getMaxFreeBlock(); /* override */
/* vt[18] */ virtual s32 do_getTotalFreeSize(); /* override */
/* vt[19] */ virtual s32 do_changeGroupID(u8 newGroupID); /* override */
/* vt[20] */ virtual u8 do_getCurrentGroupId(); /* override */
/* vt[21] */ virtual u32 state_register(JKRHeap::TState* p, u32 id) const; /* override */
/* vt[22] */ virtual bool state_compare(JKRHeap::TState const& r1,
JKRHeap::TState const& r2) const; /* override */
/* 0x6C */ u8 mAllocMode;
/* 0x6D */ u8 mCurrentGroupId;
/* 0x6E */ bool field_0x6e;
private:
/* 0x70 */ void* field_0x70;
/* 0x74 */ u32 field_0x74;
/* 0x78 */ CMemBlock* mHeadFreeList;
/* 0x7C */ CMemBlock* mTailFreeList;
/* 0x80 */ CMemBlock* mHeadUsedList;
/* 0x84 */ CMemBlock* mTailUsedList;
public:
static JKRExpHeap* createRoot(int maxHeaps, bool errorFlag);
static JKRExpHeap* create(u32 size, JKRHeap* parent, bool errorFlag);
static JKRExpHeap* create(void* ptr, u32 size, JKRHeap* parent, bool errorFlag);
};
inline JKRExpHeap* JKRCreateExpHeap(u32 size, JKRHeap* parent, bool errorFlag) {
return JKRExpHeap::create(size, parent, errorFlag);
}
#endif /* JKREXPHEAP_H */
+29
View File
@@ -0,0 +1,29 @@
#ifndef JKRFILE_H
#define JKRFILE_H
#include "JSystem/JKernel/JKRDisposer.h"
class JKRFile : public JKRDisposer {
public:
JKRFile() : mIsAvailable(false) {}
virtual ~JKRFile() {}
s32 read(void*, long, long);
bool isAvailable() const { return mIsAvailable; }
public:
/* vt[03] */ virtual bool open(const char*) = 0;
/* vt[04] */ virtual void close() = 0;
/* vt[05] */ virtual s32 readData(void*, s32, s32) = 0;
/* vt[06] */ virtual s32 writeData(const void*, s32, s32) = 0;
/* vt[07] */ virtual s32 getFileSize() const = 0;
protected:
/* 0x00 */ // vtable
/* 0x04 */ // JKRDisposer
/* 0x18 */ bool mIsAvailable;
/* 0x19 */ u8 field_0x19[3];
};
#endif /* JKRFILE_H */
+66
View File
@@ -0,0 +1,66 @@
#ifndef JKRFILECACHE_H
#define JKRFILECACHE_H
#include "JSystem/JKernel/JKRFileLoader.h"
class JKRHeap;
class JKRFileCache : public JKRFileLoader {
public:
class CCacheBlock {
public:
CCacheBlock(u32, u32, const void*);
~CCacheBlock() {}
public:
/* 0x00 */ JSULink<CCacheBlock> mCacheBlockLink;
/* 0x10 */ u32 mReferenceCount;
/* 0x14 */ u32 mFileId;
/* 0x18 */ u32 mFileSize;
/* 0x1C */ void* mMemoryPtr;
};
protected:
JKRFileCache(const char*, const char*);
virtual ~JKRFileCache();
CCacheBlock* findCacheBlock(const void*) const;
CCacheBlock* findCacheBlock(u32) const;
bool findFile(char*, const char*) const;
char* getDvdPathName(const char*) const;
void convStrLower(char*) const;
public:
/* vt[04] */ virtual bool becomeCurrent(const char*); /* override */
/* vt[05] */ virtual void* getResource(const char*); /* override */
/* vt[06] */ virtual void* getResource(u32, const char*); /* override */
/* vt[07] */ virtual u32 readResource(void*, u32, const char*); /* override */
/* vt[08] */ virtual u32 readResource(void*, u32, u32, const char*); /* override */
/* vt[09] */ virtual void removeResourceAll(void); /* override */
/* vt[10] */ virtual bool removeResource(void*); /* override */
/* vt[11] */ virtual bool detachResource(void*); /* override */
/* vt[12] */ virtual u32 getResSize(const void*) const; /* override */
/* vt[13] */ virtual u32 countFile(const char*) const; /* override */
/* vt[14] */ virtual JKRFileFinder* getFirstFile(const char*) const; /* override */
/* vt[15] */ virtual void* getFsResource(const char*);
/* vt[16] */ virtual void* getNameResource(u32, const char*);
/* vt[17] */ virtual u32 readFsResource(void*, u32, const char*);
/* vt[18] */ virtual u32 readNameResource(void*, u32, u32, const char*);
private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRFileLoader
/* 0x38 */ JKRHeap* mParentHeap;
/* 0x3C */ JSUList<CCacheBlock> mCacheBlockList;
/* 0x48 */ char* mRootPath;
/* 0x4C */ char* mCurrentPath;
/* 0x50 */ char* mVolumePath;
public:
static JKRFileCache* mount(const char*, JKRHeap*, const char*);
};
inline JKRFileCache* JKRMountDvdDrive(const char* path, JKRHeap* heap, const char* param_2) {
return JKRFileCache::mount(path, heap, param_2);
}
#endif /* JKRFILECACHE_H */
+72
View File
@@ -0,0 +1,72 @@
#ifndef JKRFILEFINDER_H
#define JKRFILEFINDER_H
#include "dolphin/dvd/dvd.h"
struct JKRFileFinder_UnknownBase {
const char* mEntryName;
s32 mEntryFileIndex;
u16 mEntryId;
u16 mEntryTypeFlags;
};
class JKRFileFinder : public JKRFileFinder_UnknownBase {
public:
JKRFileFinder() {
mIsAvailable = false;
mIsFileOrDirectory = false;
}
inline virtual ~JKRFileFinder();
bool isAvailable() const { return mIsAvailable; }
bool isFile() const { return mIsFileOrDirectory; }
bool isDirectory() const { return mIsFileOrDirectory; }
public:
/* vt[3] */ virtual bool findNextFile(void) = 0;
protected:
/* 0x00 */ // JKRFileFinder_UnknownBase
/* 0x0C */ // vtable
/* 0x10 */ bool mIsAvailable;
/* 0x11 */ bool mIsFileOrDirectory;
/* 0x12 */ u8 field_0x12[2];
};
class JKRArchive;
class JKRArcFinder : public JKRFileFinder {
public:
JKRArcFinder(JKRArchive*, s32, s32);
inline virtual ~JKRArcFinder();
public:
/* vt[3] */ virtual bool findNextFile(void); /* override */
private:
/* 0x00 */ // JKRFileFinder_UnknownBase
/* 0x0C */ // vtable
/* 0x10 */ // JKRFileFinder
/* 0x14 */ JKRArchive* mArchive;
/* 0x18 */ s32 mStartIndex;
/* 0x1C */ s32 mEndIndex;
/* 0x20 */ s32 mNextIndex;
};
class JKRDvdFinder : public JKRFileFinder {
public:
JKRDvdFinder(const char*);
virtual ~JKRDvdFinder();
public:
/* vt[3] */ virtual bool findNextFile(void); /* override */
private:
/* 0x00 */ // JKRFileFinder_UnknownBase
/* 0x0C */ // vtable
/* 0x10 */ // JKRFileFinder
/* 0x14 */ DVDDirectory mDvdDirectory;
/* 0x20 */ bool mDvdIsOpen;
/* 0x21 */ u8 field_0x21[3];
};
#endif /* JKRFILEFINDER_H */
+68
View File
@@ -0,0 +1,68 @@
#ifndef JKRFILELOADER_H
#define JKRFILELOADER_H
#include "JSystem/JKernel/JKRDisposer.h"
#include "dolphin/types.h"
class JKRFileFinder;
class JKRFileLoader : public JKRDisposer {
public:
JKRFileLoader(void);
virtual ~JKRFileLoader();
bool isMounted() const { return this->mIsMounted; }
u32 getVolumeType() const { return this->mVolumeType; }
public:
/* vt[03] */ virtual void unmount(void);
/* vt[04] */ virtual bool becomeCurrent(const char*) = 0;
/* vt[05] */ virtual void* getResource(const char*) = 0;
/* vt[06] */ virtual void* getResource(u32, const char*) = 0;
/* vt[07] */ virtual u32 readResource(void*, u32, const char*) = 0;
/* vt[08] */ virtual u32 readResource(void*, u32, u32, const char*) = 0;
/* vt[09] */ virtual void removeResourceAll(void) = 0;
/* vt[10] */ virtual bool removeResource(void*) = 0;
/* vt[11] */ virtual bool detachResource(void*) = 0;
/* vt[12] */ virtual u32 getResSize(const void*) const = 0;
/* vt[13] */ virtual u32 countFile(const char*) const = 0;
/* vt[14] */ virtual JKRFileFinder* getFirstFile(const char*) const = 0;
protected:
/* 0x00 */ // vtable
/* 0x04 */ // JKRDisposer
/* 0x18 */ JSULink<JKRFileLoader> mFileLoaderLink;
/* 0x28 */ const char* mVolumeName;
/* 0x2C */ u32 mVolumeType;
/* 0x30 */ bool mIsMounted;
/* 0x31 */ u8 field_0x31[3];
/* 0x34 */ u32 mMountCount;
public:
static void* getGlbResource(const char*);
static void* getGlbResource(const char*, JKRFileLoader*);
static bool removeResource(void*, JKRFileLoader*);
static bool detachResource(void*, JKRFileLoader*);
static JKRFileLoader* findVolume(const char**);
static const char* fetchVolumeName(char*, long, const char*);
static JKRFileLoader* getCurrentVolume() { return sCurrentVolume; }
static void setCurrentVolume(JKRFileLoader* fileLoader) { sCurrentVolume = fileLoader; }
static JSUList<JKRFileLoader>& getVolumeList() { return sVolumeList; }
static JKRFileLoader* sCurrentVolume;
static JSUList<JKRFileLoader> sVolumeList;
};
inline bool JKRDetachResource(void* resource, JKRFileLoader* fileLoader) {
return JKRFileLoader::detachResource(resource, fileLoader);
}
inline void* JKRGetNameResource(const char* name, JKRFileLoader* loader) {
return JKRFileLoader::getGlbResource(name, loader);
}
inline void* JKRGetResource(const char* name) {
return JKRFileLoader::getGlbResource(name);
}
#endif /* JKRFILELOADER_H */
+242
View File
@@ -0,0 +1,242 @@
#ifndef JKRHEAP_H
#define JKRHEAP_H
#include "JSystem/JKernel/JKRDisposer.h"
#include "dolphin/os/OSMutex.h"
class JKRHeap;
typedef void (*JKRErrorHandler)(void*, u32, int);
extern bool data_804508B0;
class JKRHeap : public JKRDisposer {
public:
class TState {
public:
/* 0x00 */ u32 mUsedSize;
/* 0x04 */ u32 mCheckCode;
/* 0x08 */ u32 mBuf;
/* 0x0C */ u32 field_0xc;
/* 0x10 */ JKRHeap* mHeap;
/* 0x14 */ u32 mId;
public:
u32 getUsedSize() const { return mUsedSize; }
u32 getCheckCode() const { return mCheckCode; }
JKRHeap* getHeap() const { return mHeap; }
u32 getId() const { return mId; }
};
public:
JKRHeap(void* data, u32 size, JKRHeap* parent, bool errorFlag);
virtual ~JKRHeap();
JKRHeap* becomeSystemHeap();
JKRHeap* becomeCurrentHeap();
void destroy();
void* alloc(u32 size, int alignment);
void free(void* ptr);
void freeAll();
void freeTail();
s32 resize(void* ptr, u32 size);
s32 getSize(void* ptr);
s32 getFreeSize();
void* getMaxFreeBlock();
s32 getTotalFreeSize();
s32 changeGroupID(u8 newGroupId);
u32 getMaxAllocatableSize(int alignment);
JKRHeap* find(void* ptr) const;
JKRHeap* findAllHeap(void* ptr) const;
void dispose_subroutine(u32 start, u32 end);
bool dispose(void* ptr, u32 size);
void dispose(void* begin, void* end);
void dispose();
bool setErrorFlag(bool errorFlag);
bool isSubHeap(JKRHeap* heap) const;
/* vt[03] */ virtual void callAllDisposer();
/* vt[04] */ virtual u32 getHeapType() = 0;
/* vt[05] */ virtual bool check() = 0;
/* vt[06] */ virtual bool dump_sort();
/* vt[07] */ virtual bool dump() = 0;
/* vt[08] */ virtual void do_destroy() = 0;
/* vt[09] */ virtual void* do_alloc(u32 size, int alignment) = 0;
/* vt[10] */ virtual void do_free(void* ptr) = 0;
/* vt[11] */ virtual void do_freeAll() = 0;
/* vt[12] */ virtual void do_freeTail() = 0;
/* vt[13] */ virtual void do_fillFreeArea() = 0;
/* vt[14] */ virtual s32 do_resize(void* ptr, u32 size) = 0;
/* vt[15] */ virtual s32 do_getSize(void* ptr) = 0;
/* vt[16] */ virtual s32 do_getFreeSize() = 0;
/* vt[17] */ virtual void* do_getMaxFreeBlock() = 0;
/* vt[18] */ virtual s32 do_getTotalFreeSize() = 0;
/* vt[19] */ virtual s32 do_changeGroupID(u8 newGroupID);
/* vt[20] */ virtual u8 do_getCurrentGroupId();
/* vt[21] */ virtual u32 state_register(JKRHeap::TState* p, u32 id) const;
/* vt[22] */ virtual bool state_compare(JKRHeap::TState const& r1, JKRHeap::TState const& r2) const;
/* vt[23] */ virtual void state_dump(JKRHeap::TState const& p) const;
void setDebugFill(bool debugFill) { mDebugFill = debugFill; }
bool getDebugFill() const { return mDebugFill; }
void* getStartAddr() const { return (void*)mStart; }
void* getEndAddr() const { return (void*)mEnd; }
u32 getSize() const { return mSize; }
bool getErrorFlag() const { return mErrorFlag; }
void callErrorHandler(JKRHeap* heap, u32 size, int alignment) {
if (mErrorHandler) {
(*mErrorHandler)(heap, size, alignment);
}
}
JKRHeap* getParent() const {
JSUTree<JKRHeap>* parent = mChildTree.getParent();
return parent->getObject();
}
JSUTree<JKRHeap>& getHeapTree() { return mChildTree; }
void appendDisposer(JKRDisposer* disposer) { mDisposerList.append(&disposer->mLink); }
void removeDisposer(JKRDisposer* disposer) { mDisposerList.remove(&disposer->mLink); }
void lock() { OSLockMutex(&mMutex); }
void unlock() { OSUnlockMutex(&mMutex); }
u32 getHeapSize() { return mSize; }
protected:
/* 0x00 */ // vtable
/* 0x04 */ // JKRDisposer
/* 0x18 */ OSMutex mMutex;
/* 0x30 */ u8* mStart;
/* 0x34 */ u8* mEnd;
/* 0x38 */ u32 mSize;
/* 0x3C */ bool mDebugFill;
/* 0x3D */ bool mCheckMemoryFilled;
/* 0x3E */ u8 mAllocationMode; // EAllocMode?
/* 0x3F */ u8 mGroupId;
/* 0x40 */ JSUTree<JKRHeap> mChildTree;
/* 0x5C */ JSUList<JKRDisposer> mDisposerList;
/* 0x68 */ bool mErrorFlag;
/* 0x69 */ bool mInitFlag;
/* 0x6A */ u8 padding_0x6a[2];
public:
static bool initArena(char** memory, u32* size, int maxHeaps);
static void* alloc(u32 size, int alignment, JKRHeap* heap);
static void free(void* ptr, JKRHeap* heap);
static s32 resize(void* ptr, u32 size, JKRHeap* heap);
static s32 getSize(void* ptr, JKRHeap* heap);
static JKRHeap* findFromRoot(void* ptr);
static void copyMemory(void* dst, void* src, u32 size);
static void fillMemory(void* dst, u32 size, u8 value); // NOTE: never used
static bool checkMemoryFilled(void* src, u32 size, u8 value);
static JKRErrorHandler setErrorHandler(JKRErrorHandler errorHandler);
static void setDefaultDebugFill(bool status) { data_804508B0 = status; }
static void* getCodeStart(void) { return mCodeStart; }
static void* getCodeEnd(void) { return mCodeEnd; }
static void* getUserRamStart(void) { return mUserRamStart; }
static void* getUserRamEnd(void) { return mUserRamEnd; }
static u32 getMemorySize(void) { return mMemorySize; }
static JKRHeap* getRootHeap() { return sRootHeap; }
#if DEBUG
static JKRHeap* getRootHeap2() { return sRootHeap2; }
#endif
static JKRHeap* getSystemHeap() { return sSystemHeap; }
static JKRHeap* getCurrentHeap() { return sCurrentHeap; }
static void setSystemHeap(JKRHeap* heap) { sSystemHeap = heap; }
static void setCurrentHeap(JKRHeap* heap) { sCurrentHeap = heap; }
static void setState_u32ID_(TState* state, u32 id) { state->mId = id; }
static void setState_uUsedSize_(TState* state, u32 usedSize) { state->mUsedSize = usedSize; }
static void setState_u32CheckCode_(TState* state, u32 checkCode) {
state->mCheckCode = checkCode;
}
static void* getState_buf_(TState* state) { return &state->mBuf; }
static void* getState_(TState* state) { return getState_buf_(state); }
static void* mCodeStart;
static void* mCodeEnd;
static void* mUserRamStart;
static void* mUserRamEnd;
static u32 mMemorySize;
static JKRHeap* sRootHeap;
#if DEBUG
static JKRHeap* sRootHeap2;
#endif
static JKRHeap* sSystemHeap;
static JKRHeap* sCurrentHeap;
static JKRErrorHandler mErrorHandler;
};
void* operator new(u32 size);
void* operator new(u32 size, int alignment);
void* operator new(u32 size, JKRHeap* heap, int alignment);
void* operator new[](u32 size);
void* operator new[](u32 size, int alignment);
void* operator new[](u32 size, JKRHeap* heap, int alignment);
void operator delete(void* ptr);
void operator delete[](void* ptr);
inline void* operator new(u32 size, void* ptr) {
return ptr;
}
void JKRDefaultMemoryErrorRoutine(void* heap, u32 size, int alignment);
inline void* JKRAllocFromHeap(JKRHeap* heap, u32 size, int alignment) {
return JKRHeap::alloc(size, alignment, heap);
}
inline void* JKRAllocFromSysHeap(u32 size, int alignment) {
JKRHeap* systemHeap = JKRHeap::getSystemHeap();
return systemHeap->alloc(size, alignment);
}
inline void JKRFreeToHeap(JKRHeap* heap, void* ptr) {
JKRHeap::free(ptr, heap);
}
inline void JKRFreeToSysHeap(void* ptr) {
JKRHeap* systemHeap = JKRHeap::getSystemHeap();
systemHeap->free(ptr);
}
inline void i_JKRFree(void* ptr) {
JKRHeap::free(ptr, NULL);
}
inline JKRHeap* JKRGetSystemHeap() {
return JKRHeap::getSystemHeap();
}
inline JKRHeap* JKRGetCurrentHeap() {
return JKRHeap::getCurrentHeap();
}
inline u32 JKRGetMemBlockSize(JKRHeap* heap, void* block) {
return JKRHeap::getSize(block, heap);
}
inline void* JKRAlloc(u32 size, int alignment) {
return JKRHeap::alloc(size, alignment, NULL);
}
inline s32 JKRResizeMemBlock(JKRHeap* heap, void* ptr, u32 size) {
return JKRHeap::resize(ptr, size, heap);
}
inline JKRHeap* JKRGetRootHeap() {
return JKRHeap::getRootHeap();
}
#endif /* JKRHEAP_H */
+42
View File
@@ -0,0 +1,42 @@
#ifndef JKRMEMARCHIVE_H
#define JKRMEMARCHIVE_H
#include "JSystem/JKernel/JKRArchive.h"
enum JKRMemBreakFlag {
JKRMEMBREAK_FLAG_UNKNOWN0 = 0,
JKRMEMBREAK_FLAG_UNKNOWN1 = 1,
};
class JKRMemArchive : public JKRArchive {
public:
JKRMemArchive(long, JKRArchive::EMountDirection);
JKRMemArchive(void*, u32, JKRMemBreakFlag);
virtual ~JKRMemArchive();
bool open(long, JKRArchive::EMountDirection);
bool open(void*, u32, JKRMemBreakFlag);
/* vt[09] */ void removeResourceAll(void); /* override */
/* vt[10] */ bool removeResource(void*); /* override */
/* vt[15] */ u32 getExpandedResSize(const void*) const; /* override */
/* vt[16] */ void* fetchResource(SDIFileEntry*, u32*); /* override */
/* vt[17] */ void* fetchResource(void*, u32, SDIFileEntry*, u32*); /* override */
public:
static u32 fetchResource_subroutine(u8*, u32, u8*, u32, JKRCompression);
SArcHeader* getArcHeader() { return mArcHeader; }
private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRArchive
/* 0x5C */ JKRCompression mCompression;
/* 0x60 */ EMountDirection mMountDirection;
/* 0x64 */ SArcHeader* mArcHeader;
/* 0x68 */ u8* mArchiveData;
/* 0x6C */ bool mIsOpen;
/* 0x6D */ u8 field_0x6d[3];
};
#endif /* JKRMEMARCHIVE_H */
+60
View File
@@ -0,0 +1,60 @@
#ifndef JKRSOLIDHEAP_H
#define JKRSOLIDHEAP_H
#include "JSystem/JKernel/JKRHeap.h"
class JKRSolidHeap : public JKRHeap {
public:
struct Unknown {
u32 field_0x0;
u32 field_0x4;
u32 field_0x8;
void* field_0xc;
Unknown* mNext;
};
protected:
JKRSolidHeap(void*, u32, JKRHeap*, bool);
virtual ~JKRSolidHeap();
void* allocFromHead(u32, int);
void* allocFromTail(u32, int);
static s32 getUsedSize(JKRSolidHeap* heap) { return heap->mSize - heap->getTotalFreeSize(); }
public:
/* vt[04] */ virtual u32 getHeapType(void); /* override */
/* vt[05] */ virtual bool check(void); /* override */
/* vt[07] */ virtual bool dump(void); /* override */
/* vt[08] */ virtual void do_destroy(void); /* override */
/* vt[09] */ virtual void* do_alloc(u32, int); /* override */
/* vt[10] */ virtual void do_free(void*); /* override */
/* vt[11] */ virtual void do_freeAll(void); /* override */
/* vt[12] */ virtual void do_freeTail(void); /* override */
/* vt[13] */ virtual void do_fillFreeArea(void); /* override */
/* vt[14] */ virtual s32 do_resize(void*, u32); /* override */
/* vt[15] */ virtual s32 do_getSize(void*); /* override */
/* vt[16] */ virtual s32 do_getFreeSize(void); /* override */
/* vt[17] */ virtual void* do_getMaxFreeBlock(void); /* override */
/* vt[18] */ virtual s32 do_getTotalFreeSize(void); /* override */
/* vt[21] */ virtual u32 state_register(JKRHeap::TState*, u32) const; /* override */
/* vt[22] */ virtual bool state_compare(JKRHeap::TState const&,
JKRHeap::TState const&) const; /* override */
private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRHeap
/* 0x6C */ u32 mFreeSize;
/* 0x70 */ u8* mSolidHead;
/* 0x74 */ u8* mSolidTail;
/* 0x78 */ Unknown* field_0x78;
public:
s32 adjustSize(void);
static JKRSolidHeap* create(u32, JKRHeap*, bool);
};
#endif /* JKRSOLIDHEAP_H */
+164
View File
@@ -0,0 +1,164 @@
#ifndef JKRTHREAD_H
#define JKRTHREAD_H
#include "JSystem/JKernel/JKRHeap.h"
#include "dolphin/os/OSMessage.h"
#include "dolphin/os/OSTime.h"
#include "dolphin/types.h"
struct JKRThreadName_ {
s32 id;
char* name;
};
class JUTConsole;
class JKRThread : JKRDisposer {
public:
class TLoad {
public:
TLoad() {
clear();
mValid = false;
mThreadId = 0;
}
bool isValid() const { return mValid; }
u32 getCost() const { return mCost; }
u32 getCount() const { return mSwitchCount; }
s32 getId() const { return mThreadId; }
void setValid(bool valid) { mValid = valid; }
void setId(s32 id) { mThreadId = id; }
void setCurrentTime() { mLastTick = OSGetTick(); }
void resetCost() { mCost = 0; }
void resetCount() { mSwitchCount = 0; }
void incCount() { mSwitchCount++; }
void addCurrentCost() { mCost = mCost + (OSGetTick() - mLastTick); }
void clear() {
resetCount();
resetCost();
mLastTick = 0;
}
private:
/* 0x00 */ bool mValid;
/* 0x01 */ u8 padding_0x61[3];
/* 0x04 */ u32 mCost;
/* 0x08 */ u32 mSwitchCount;
/* 0x0C */ OSTick mLastTick;
/* 0x10 */ s32 mThreadId;
};
JKRThread(u32 stack_size, int message_count, int param_3);
JKRThread(JKRHeap* heap, u32 stack_size, int message_count, int param_4);
JKRThread(OSThread* thread, int message_count);
virtual ~JKRThread();
/* vt[03] */ virtual void* run();
void setCommon_mesgQueue(JKRHeap* heap, int message_count);
void setCommon_heapSpecified(JKRHeap* heap, u32 stack_size, int param_3);
OSThread* getThreadRecord() const { return mThreadRecord; }
void* getStack() const { return mStackMemory; }
TLoad* getLoadInfo() { return &mLoadInfo; }
JKRHeap* getCurrentHeap() const { return mCurrentHeap; }
s32 getCurrentHeapError() const { return mCurrentHeapError; }
void setCurrentHeap(JKRHeap* heap) {
mCurrentHeap = heap ? heap : JKRHeap::getCurrentHeap();
}
protected:
void resume() { OSResumeThread(mThreadRecord); }
void sendMessage(OSMessage message) {
OSSendMessage(&mMessageQueue, message, OS_MESSAGE_NOBLOCK);
}
void sendMessageBlock(OSMessage message) {
OSSendMessage(&mMessageQueue, message, OS_MESSAGE_BLOCK);
}
OSMessage waitMessage() {
OSMessage message;
OSReceiveMessage(&mMessageQueue, &message, OS_MESSAGE_NOBLOCK);
return message;
}
OSMessage waitMessageBlock() {
OSMessage message;
OSReceiveMessage(&mMessageQueue, &message, OS_MESSAGE_BLOCK);
return message;
}
void jamMessageBlock(OSMessage message) {
OSJamMessage(&mMessageQueue, message, OS_MESSAGE_BLOCK);
}
private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRDisposer
/* 0x18 */ JSULink<JKRThread> mThreadListLink;
/* 0x28 */ JKRHeap* mHeap;
/* 0x2C */ OSThread* mThreadRecord;
/* 0x30 */ OSMessageQueue mMessageQueue;
/* 0x50 */ OSMessage* mMessages;
/* 0x54 */ s32 mMessageCount;
/* 0x58 */ void* mStackMemory;
/* 0x5C */ u32 mStackSize;
/* 0x60 */ TLoad mLoadInfo;
/* 0x74 */ JKRHeap* mCurrentHeap;
/* 0x78 */ s32 mCurrentHeapError;
public:
static void* start(void* param_1);
static JKRThread* searchThread(OSThread* thread);
static JSUList<JKRThread>& getList() { return (JSUList<JKRThread>&)sThreadList; }
static JSUList<JKRThread> sThreadList;
// static u8 sThreadList[12];
};
typedef void (*JKRThreadSwitch_PreCallback)(OSThread* current, OSThread* next);
typedef void (*JKRThreadSwitch_PostCallback)(OSThread* current, OSThread* next);
class JKRThreadSwitch {
public:
JKRThreadSwitch(JKRHeap*);
virtual void draw(JKRThreadName_* param_1, JUTConsole* param_2);
virtual void draw(JKRThreadName_* param_1);
virtual ~JKRThreadSwitch();
static JKRThreadSwitch* createManager(JKRHeap* heap);
JKRThread* enter(JKRThread* param_1, int param_2);
static void callback(OSThread* param_1, OSThread* param_2);
static JKRThreadSwitch* getManager() { return sManager; }
static u32 getTotalCount() { return sTotalCount; }
private:
static JKRThreadSwitch* sManager;
static u32 sTotalCount;
static u32 sTotalStart;
static JKRThreadSwitch_PreCallback mUserPreCallback;
static JKRThreadSwitch_PostCallback mUserPostCallback;
private:
/* 0x00 */ // vtable
/* 0x04 */ JKRHeap* mHeap;
/* 0x08 */ bool mSetNextHeap;
/* 0x09 */ u8 field_0x9[3];
/* 0x0C */ u32 field_0xC;
/* 0x10 */ u32 field_0x10;
/* 0x14 */ u8 field_0x14[4];
/* 0x18 */ s64 field_0x18;
/* 0x20 */ u32 field_0x20;
/* 0x24 */ u32 field_0x24;
};
struct JKRTask {
static JSUList<JKRTask> sTaskList;
static u8 sEndMesgQueue[32];
};
#endif /* JKRTHREAD_H */
View File
+46
View File
@@ -0,0 +1,46 @@
#ifndef JPATEXTURE_H
#define JPATEXTURE_H
#include "JSystem/JUtility/JUTTexture.h"
#include "dolphin/gx/GX.h"
#include "dolphin/types.h"
class JKRHeap;
struct JPATextureData {
// Probably magic / size / flags up top here, but they're unused.
/* 0x00 */ char field_0x00[0x0C];
/* 0x0C */ char mName[0x14];
/* 0x20 */ ResTIMG mResTIMG;
};
class JPATexture {
public:
virtual ~JPATexture();
virtual const char* getName() const;
virtual void load(GXTexMapID);
virtual JUTTexture* getJUTTexture();
JUTTexture mTexture;
};
class JPATextureArc : public JPATexture {
public:
JPATextureArc(u8 const*);
virtual ~JPATextureArc();
const char* getName() const { return mpData->mName; }
void load(GXTexMapID texMapID) { mTexture.load(texMapID); }
JUTTexture* getJUTTexture() { return &mTexture; }
public:
const JPATextureData* mpData;
};
struct JPADefaultTexture {
void initialize(JKRHeap *);
u8 * imgBuf;
GXTexObj mTexObj;
};
#endif /* JPATEXTURE_H */
+24
View File
@@ -0,0 +1,24 @@
#ifndef JSUFILESTREAM_H
#define JSUFILESTREAM_H
#include "JSystem/JSupport/JSURandomInputStream.h"
class JKRFile;
class JSUFileInputStream : public JSURandomInputStream {
public:
virtual ~JSUFileInputStream() {}
// TODO: fix return values
/* 802DC638 */ JSUFileInputStream(JKRFile*);
/* 802DC67C */ u32 readData(void*, s32);
/* 802DC74C */ s32 seekPos(s32, JSUStreamSeekFrom);
/* 802DC82C */ s32 getLength() const;
/* 802DC85C */ s32 getPosition() const;
private:
/* 0x08 */ JKRFile* mFile;
/* 0x0C */ s32 mPosition;
}; // Size = 0x10
#endif /* JSUFILESTREAM_H */
+77
View File
@@ -0,0 +1,77 @@
#ifndef JSUINPUTSTREAM_H
#define JSUINPUTSTREAM_H
#include "JSystem/JSupport/JSUIosBase.h"
enum JSUStreamSeekFrom {
JSUStreamSeekFrom_SET = 0, // absolute
JSUStreamSeekFrom_CUR = 1, // relative
JSUStreamSeekFrom_END = 2, // relative to end
};
class JSUInputStream : public JSUIosBase {
public:
JSUInputStream() {}
virtual ~JSUInputStream();
/* vt[3] */ virtual s32 getAvailable() const = 0;
/* vt[4] */ virtual s32 skip(s32);
/* vt[5] */ virtual u32 readData(void*, s32) = 0;
u32 readU32() {
u32 val;
this->read(&val, sizeof(val));
return val;
}
u32 read32b() {
u32 val;
this->read(&val, sizeof(val));
return val;
}
s32 readS32() {
s32 val;
this->read(&val, sizeof(val));
return val;
}
s16 readS16() {
s16 val;
this->read(&val, sizeof(val));
return val;
}
u16 readU16() {
u16 val;
this->read(&val, sizeof(val));
return val;
}
u8 readU8() {
u8 val;
this->read(&val, sizeof(val));
return val;
}
u8 read8b() {
u8 val;
this->read(&val, sizeof(val));
return val;
}
u16 read16b() {
u16 val;
this->read(&val, sizeof(val));
return val;
}
// TODO: return value probably wrong
/* 802DC298 */ s32 read(void*, s32);
}; // Size = 0x8
// move?
template <typename T>
T* JSUConvertOffsetToPtr(const void*, const void*);
#endif /* JSUINPUTSTREAM_H */
+24
View File
@@ -0,0 +1,24 @@
#ifndef JSUIOSBASE_H_
#define JSUIOSBASE_H_
#include "dolphin/types.h"
enum EIoState {
IOS_STATE_1 = 1,
};
class JSUIosBase {
public:
JSUIosBase() { mState = false; }
virtual ~JSUIosBase() {}
bool isGood() const { return mState == 0; }
void clrState(EIoState state) { mState &= ~state; }
void setState(EIoState state) { mState |= state; }
private:
u8 mState;
}; // Size = 0x8
#endif
+223
View File
@@ -0,0 +1,223 @@
#ifndef JSULIST_H
#define JSULIST_H
#include "dolphin/types.h"
template <typename T>
class JSUList;
//
// Link
//
class JSUPtrList;
class JSUPtrLink {
public:
JSUPtrLink(void* object);
~JSUPtrLink();
void* getObjectPtr() const { return mObject; }
JSUPtrList* getList() const { return mList; }
JSUPtrLink* getNext() const { return mNext; }
JSUPtrLink* getPrev() const { return mPrev; }
public:
void* mObject;
JSUPtrList* mList;
JSUPtrLink* mPrev;
JSUPtrLink* mNext;
};
template <typename T>
class JSULink : public JSUPtrLink {
public:
JSULink(T* object) : JSUPtrLink((void*)object) {}
T* getObject() const { return (T*)getObjectPtr(); }
JSUList<T>* getSupervisor() const { return (JSUList<T>*)this->getList(); }
JSULink<T>* getNext() const { return (JSULink<T>*)this->JSUPtrLink::getNext(); }
JSULink<T>* getPrev() const { return (JSULink<T>*)this->JSUPtrLink::getPrev(); }
};
//
// List
//
class JSUPtrList {
public:
JSUPtrList() { this->initiate(); }
JSUPtrList(bool init);
~JSUPtrList();
void initiate();
void setFirst(JSUPtrLink* first);
bool append(JSUPtrLink* ptr);
bool prepend(JSUPtrLink* ptr);
bool insert(JSUPtrLink* before, JSUPtrLink* ptr);
bool remove(JSUPtrLink* ptr);
JSUPtrLink* getNthLink(u32 i) const;
JSUPtrLink* getFirstLink() const { return mHead; }
JSUPtrLink* getLastLink() const { return mTail; }
u32 getNumLinks() const { return mLength; }
private:
JSUPtrLink* mHead;
JSUPtrLink* mTail;
u32 mLength;
};
template <typename T>
class JSUList : public JSUPtrList {
public:
JSUList() : JSUPtrList() {}
JSUList(bool init) : JSUPtrList(init) {}
~JSUList() {}
bool append(JSULink<T>* link) { return this->JSUPtrList::append((JSUPtrLink*)link); }
bool prepend(JSULink<T>* link) { return this->JSUPtrList::prepend((JSUPtrLink*)link); }
bool insert(JSULink<T>* before, JSULink<T>* link) {
return this->JSUPtrList::insert((JSUPtrLink*)before, (JSUPtrLink*)link);
}
bool remove(JSULink<T>* link) { return this->JSUPtrList::remove((JSUPtrLink*)link); }
JSULink<T>* getFirst() const { return (JSULink<T>*)getFirstLink(); }
JSULink<T>* getLast() const { return (JSULink<T>*)getLastLink(); }
JSULink<T>* getEnd() const { return NULL; }
u32 getNumLinks() const { return this->JSUPtrList::getNumLinks(); }
};
template <typename T>
class JSUListIterator {
public:
JSUListIterator() : mLink(NULL) {}
JSUListIterator(JSULink<T>* link) : mLink(link) {}
JSUListIterator(JSUList<T>* list) : mLink(list->getFirst()) {}
JSUListIterator<T>& operator=(JSULink<T>* link) {
this->mLink = link;
return *this;
}
T* getObject() { return this->mLink->getObject(); }
bool operator==(JSULink<T> const* other) const { return this->mLink == other; }
bool operator!=(JSULink<T> const* other) const { return this->mLink != other; }
bool operator==(JSUListIterator<T> const& other) const { return this->mLink == other.mLink; }
bool operator!=(JSUListIterator<T> const& other) const { return this->mLink != other.mLink; }
JSUListIterator<T> operator++(int) {
JSUListIterator<T> prev = *this;
this->mLink = this->mLink->getNext();
return prev;
}
JSUListIterator<T>& operator++() {
this->mLink = this->mLink->getNext();
return *this;
}
JSUListIterator<T> operator--(int) {
JSUListIterator<T> prev = *this;
this->mLink = this->mLink->getPrev();
return prev;
}
JSUListIterator<T>& operator--() {
this->mLink = this->mLink->getPrev();
return *this;
}
T& operator*() { return *this->getObject(); }
T* operator->() { return this->getObject(); }
// private:
JSULink<T>* mLink;
};
//
// Tree
//
template <typename T>
class JSUTree : public JSUList<T>, public JSULink<T> {
public:
JSUTree(T* owner) : JSUList<T>(), JSULink<T>(owner) {}
~JSUTree() {}
bool appendChild(JSUTree<T>* child) { return this->append(child); }
bool removeChild(JSUTree<T>* child) { return this->remove(child); }
bool insertChild(JSUTree<T>* before, JSUTree<T>* child) { return this->insert(before, child); }
JSUTree<T>* getEndChild() const { return NULL; }
JSUTree<T>* getFirstChild() const { return (JSUTree<T>*)this->getFirst(); }
JSUTree<T>* getLastChild() const { return (JSUTree<T>*)this->getLast(); }
JSUTree<T>* getNextChild() const { return (JSUTree<T>*)this->getNext(); }
JSUTree<T>* getPrevChild() const { return (JSUTree<T>*)this->getPrev(); }
u32 getNumChildren() const { return this->getNumLinks(); }
T* getObject() const { return (T*)this->getObjectPtr(); }
JSUTree<T>* getParent() const { return (JSUTree<T>*)this->getList(); }
};
template <typename T>
class JSUTreeIterator {
public:
JSUTreeIterator() : mTree(NULL) {}
JSUTreeIterator(JSUTree<T>* tree) : mTree(tree) {}
JSUTreeIterator<T>& operator=(JSUTree<T>* tree) {
this->mTree = tree;
return *this;
}
T* getObject() { return this->mTree->getObject(); }
bool operator==(JSUTree<T>* other) { return this->mTree == other; }
bool operator!=(JSUTree<T>* other) { return this->mTree != other; }
JSUTreeIterator<T> operator++(int) {
JSUTreeIterator<T> prev = *this;
this->mTree = this->mTree->getNextChild();
return prev;
}
JSUTreeIterator<T>& operator++() {
this->mTree = this->mTree->getNextChild();
return *this;
}
T& operator*() { return *this->getObject(); }
T* operator->() { return this->getObject(); }
private:
JSUTree<T>* mTree;
};
#endif /* JSULIST_H */
@@ -0,0 +1,23 @@
#ifndef JSUMEMORYSTREAM_H
#define JSUMEMORYSTREAM_H
#include "JSystem/JSupport/JSURandomInputStream.h"
class JSUMemoryInputStream : public JSURandomInputStream {
public:
JSUMemoryInputStream(const void* res, u32 size) { setBuffer(res, size); }
/* 802552B8 */ virtual ~JSUMemoryInputStream() {}
/* 802DC520 */ void setBuffer(void const*, s32);
/* 802DC534 */ u32 readData(void*, s32);
/* 802DC5AC */ s32 seekPos(s32, JSUStreamSeekFrom);
/* 802DC628 */ s32 getLength() const;
/* 802DC630 */ s32 getPosition() const;
private:
/* 0x08 */ const void* mBuffer;
/* 0x0C */ s32 mLength;
/* 0x10 */ s32 mPosition;
}; // Size = 0x14
#endif /* JSUMEMORYSTREAM_H */
@@ -0,0 +1,24 @@
#ifndef JSURANDOMINPUTSTREAM_H_
#define JSURANDOMINPUTSTREAM_H_
#include "JSystem/JSupport/JSUInputStream.h"
class JSURandomInputStream : public JSUInputStream {
public:
JSURandomInputStream() {}
virtual ~JSURandomInputStream() {}
/* vt[3] */ virtual s32 getAvailable() const; /* override */
/* vt[4] */ virtual s32 skip(s32); /* override */
/* vt[5] */ virtual u32 readData(void*, s32) = 0;
/* vt[6] */ virtual s32 getLength() const = 0;
/* vt[7] */ virtual s32 getPosition() const = 0;
/* vt[8] */ virtual s32 seekPos(s32, JSUStreamSeekFrom) = 0;
// TODO: fix return types
/* 802DC370 */ s32 align(s32);
/* 802DC458 */ s32 peek(void*, s32);
/* 802DC4DC */ s32 seek(s32, JSUStreamSeekFrom);
}; // Size = 0x8
#endif
+27
View File
@@ -0,0 +1,27 @@
#ifndef JSUPPORT_H
#define JSUPPORT_H
template <typename T>
T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) {
if (offset == NULL) {
return NULL;
} else {
return (T*)((s32)ptr + (s32)offset);
}
}
inline u8 JSULoNibble(u8 param_0) { return param_0 & 0x0f; }
inline u8 JSUHiNibble(u8 param_0) {return param_0 >> 4; }
inline u8 JSULoByte(u16 in) {
return in & 0xff;
}
inline u8 JSUHiByte(u16 in) {
return in >> 8;
}
inline u16 JSULoHalf(u32 param_0) {return param_0; }
#endif
+30
View File
@@ -0,0 +1,30 @@
#ifndef JUTASSERT_H
#define JUTASSERT_H
#include "dolphin/types.h"
#include "dolphin/os/OS.h"
#define JUT_ASSERT(FILE, LINE, COND) \
if (!(COND)) { \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), FILE, LINE, #COND); \
OSPanic(FILE, LINE, "Halt"); \
}
#define JUT_PANIC(FILE, LINE, TEXT) \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), FILE, LINE, TEXT); \
OSPanic(FILE, LINE, "Halt");
namespace JUTAssertion {
u32 getSDevice();
void showAssert(u32 device, const char * file, int line, const char * assertion);
void create();
u32 flush_subroutine();
void flushMessage();
void flushMessage_dbPrint();
void setVisible(bool);
void setMessageCount(int);
};
extern bool sAssertVisible;
#endif /* JUTASSERT_H */
+80
View File
@@ -0,0 +1,80 @@
#ifndef JUTCACHEFONT_H
#define JUTCACHEFONT_H
#include "JSystem/JUtility/JUTResFont.h"
#include "global.h"
class JKRAramBlock;
class JUTCacheFont : public JUTResFont {
public:
struct TGlyphCacheInfo {
/* 0x0 */ TGlyphCacheInfo* mPrev;
/* 0x4 */ TGlyphCacheInfo* mNext;
};
struct TCachePage {
/* 0x00 */ u8 field_0x0[8];
/* 0x08 */ s16 field_0x8;
/* 0x0A */ u16 field_0xa;
/* 0x0C */ u8 field_0xc[4];
/* 0x10 */ u8* field_0x10;
/* 0x14 */ u16 field_0x14;
/* 0x16 */ u16 field_0x16;
/* 0x18 */ u16 field_0x18;
/* 0x1A */ u16 field_0x1a;
/* 0x1C */ u16 field_0x1c;
/* 0x1E */ u16 field_0x1e;
}; // Size: 0x20
enum EPagingType {
PAGE_TYPE_0,
PAGE_TYPE_1,
};
/* 802DD188 */ JUTCacheFont(ResFONT const*, u32, JKRHeap*);
/* 802DD29C */ void deleteMemBlocks_CacheFont();
/* 802DD320 */ void initialize_state();
/* 802DD35C */ int getMemorySize(ResFONT const*, u16*, u32*, u16*, u32*, u16*, u32*, u32*);
/* 802DD4EC */ int initiate(ResFONT const*, void*, u32, JKRHeap*);
/* 802DD54C */ bool internal_initiate(ResFONT const*, void*, u32, JKRHeap*);
/* 802DD650 */ bool allocArea(void*, u32, JKRHeap*);
/* 802DD804 */ bool allocArray(JKRHeap*);
/* 802DDB0C */ void determineBlankPage();
/* 802DDBBC */ void getGlyphFromAram(JUTCacheFont::TGlyphCacheInfo*, JUTCacheFont::TCachePage*,
int*, int*);
/* 802DDD98 */ void loadCache_char_subroutine(int*, bool);
/* 802DDEE0 */ void invalidiateAllCache();
/* 802DDF68 */ void unlink(JUTCacheFont::TGlyphCacheInfo*);
/* 802DDFAC */ void prepend(JUTCacheFont::TGlyphCacheInfo*);
/* 802DD208 */ virtual ~JUTCacheFont();
/* 802DDCE4 */ virtual void loadImage(int, _GXTexMapID);
/* 802DD8EC */ virtual void setBlock();
void setPagingType(EPagingType type) { mPagingType = type; }
static u32 calcCacheSize(u32 param_0, int param_1) { return (ALIGN_NEXT(param_0, 0x20) + 0x40) * param_1; }
private:
/* 0x70 */ u32 mTotalWidSize;
/* 0x74 */ u32 mTotalGlySize;
/* 0x78 */ u32 mTotalMapSize;
/* 0x7C */ void* field_0x7c;
/* 0x80 */ void* field_0x80;
/* 0x84 */ void* field_0x84;
/* 0x88 */ u32 mMaxSheetSize;
/* 0x8C */ EPagingType mPagingType;
/* 0x90 */ void* mCacheBuffer;
/* 0x94 */ int field_0x94;
/* 0x98 */ u32 mCachePage;
/* 0x9C */ TGlyphCacheInfo* field_0x9c;
/* 0xA0 */ TGlyphCacheInfo* field_0xa0;
/* 0xA4 */ void* field_0xa4;
/* 0xA8 */ u32 field_0xa8;
/* 0xAC */ JKRAramBlock* field_0xac;
/* 0xB0 */ u8 field_0xb0;
/* 0xB4 */ int field_0xb4;
}; // Size: 0xB8
#endif /* JUTCACHEFONT_H */
+153
View File
@@ -0,0 +1,153 @@
#ifndef JUTCONSOLE_H
#define JUTCONSOLE_H
#include "JSystem/JGadget/linklist.h"
#include "JSystem/JKernel/JKRDisposer.h"
#include "JSystem/JUtility/JUTFont.h"
#include "Runtime.PPCEABI.H/__va_arg.h"
#include "dolphin/types.h"
class JUTConsole : public JKRDisposer {
public:
enum EConsoleType {
CONSOLE_TYPE_0 = 0,
CONSOLE_TYPE_1 = 1,
CONSOLE_TYPE_2 = 2,
};
enum OutputFlag {
/* 0x0 */ OUTPUT_NONE,
/* 0x1 */ OUTPUT_OSREPORT,
/* 0x2 */ OUTPUT_CONSOLE,
/* 0x3 */ OUTPUT_OSR_AND_CONSOLE,
};
/* 802E73E4 */ static JUTConsole* create(unsigned int, void*, u32);
/* 802E7354 */ static JUTConsole* create(unsigned int, unsigned int, JKRHeap*);
/* 802E746C */ JUTConsole(unsigned int, unsigned int, bool);
/* 802E75CC */ static size_t getObjectSizeFromBufferSize(unsigned int, unsigned int);
/* 802E75DC */ static size_t getLineFromObjectSize(u32, unsigned int);
/* 802E75EC */ void clear();
/* 802E7648 */ void doDraw(JUTConsole::EConsoleType) const;
/* 802E7BB8 */ void print_f(char const*, ...);
/* 802E7C38 */ void print(char const*);
/* 802E7F7C */ void dumpToTerminal(unsigned int);
/* 802E80A8 */ void scroll(int);
/* 802E8184 */ int getUsedLine() const;
/* 802E81A8 */ int getLineOffset() const;
/* 802E755C */ virtual ~JUTConsole();
void setOutput(unsigned int output) { mOutput = output; }
void setPosition(int x, int y) {
mPositionX = x;
mPositionY = y;
}
void setFontSize(f32 x, f32 y) {
mFontSizeX = x;
mFontSizeY = y;
}
void setHeight(u32 height) {
mHeight = height;
if (mHeight > mMaxLines) {
mHeight = mMaxLines;
}
}
void setFont(JUTFont* p_font) {
mFont = p_font;
setFontSize(p_font->getWidth(), p_font->getHeight());
}
u32 getOutput() const { return mOutput; }
int getPositionY() const { return mPositionY; }
int getPositionX() const { return mPositionX; }
u32 getHeight() const { return mHeight; }
bool isVisible() const { return mVisible; }
void setVisible(bool visible) { mVisible = visible; }
void setLineAttr(int param_0, u8 param_1) { mBuf[(field_0x20 + 2) * param_0] = param_1; }
u8* getLinePtr(int param_0) const { return &mBuf[(field_0x20 + 2) * param_0] + 1; }
int diffIndex(int param_0, int param_1) const {
int diff = param_1 - param_0;
if (diff >= 0) {
return diff;
}
return diff += mMaxLines;
}
int nextIndex(int param_0) const {
int index = param_0 + 1;
if (mMaxLines <= index) {
index = 0;
}
return index;
}
void scrollToLastLine() { scroll(mMaxLines); }
void scrollToFirstLine() { scroll(-mMaxLines); }
private:
/* 0x18 */ JGadget::TLinkListNode mListNode;
private:
/* 0x20 */ u32 field_0x20;
/* 0x24 */ u32 mMaxLines;
/* 0x28 */ u8* mBuf;
/* 0x2C */ bool field_0x2c;
/* 0x30 */ int field_0x30;
/* 0x34 */ int field_0x34;
/* 0x38 */ int field_0x38;
/* 0x3C */ int field_0x3c;
/* 0x40 */ int mPositionX;
/* 0x44 */ int mPositionY;
/* 0x48 */ u32 mHeight;
/* 0x4C */ JUTFont* mFont;
/* 0x50 */ f32 mFontSizeX;
/* 0x54 */ f32 mFontSizeY;
/* 0x58 */ int mOutput;
/* 0x5C */ JUtility::TColor field_0x5c;
/* 0x60 */ JUtility::TColor field_0x60;
/* 0x64 */ int field_0x64;
/* 0x68 */ bool mVisible;
/* 0x69 */ bool field_0x69;
/* 0x6A */ bool field_0x6a;
/* 0x6B */ bool field_0x6b;
}; // Size: 0x6C
class JUTConsoleManager {
public:
/* 802E81CC */ JUTConsoleManager();
/* 802E81F4 */ static JUTConsoleManager* createManager(JKRHeap*);
/* 802E8240 */ void appendConsole(JUTConsole*);
/* 802E82B0 */ void removeConsole(JUTConsole*);
/* 802E8384 */ void draw() const;
/* 802E8450 */ void drawDirect(bool) const;
/* 802E84C4 */ void setDirectConsole(JUTConsole*);
JUTConsole* getDirectConsole() const { return mDirectConsole; }
static JUTConsoleManager* getManager() { return sManager; }
static JUTConsoleManager* sManager;
private:
/* 0x00 */ JGadget::TLinkList<JUTConsole, 4> mLinkList;
/* 0x0C */ JUTConsole* mActiveConsole;
/* 0x10 */ JUTConsole* mDirectConsole;
}; // Size: 0x14
extern "C" void JUTConsole_print_f_va_(JUTConsole*, const char*, va_list);
extern "C" void JUTSetReportConsole(JUTConsole*);
extern "C" JUTConsole* JUTGetReportConsole();
extern "C" void JUTSetWarningConsole(JUTConsole*);
extern "C" JUTConsole* JUTGetWarningConsole();
extern "C" void JUTReportConsole_f_va(const char*, va_list);
extern "C" void JUTReportConsole_f(const char*, ...);
extern "C" void JUTWarningConsole(const char* message);
extern "C" void JUTWarningConsole_f(const char* message, ...);
extern "C" void JUTReportConsole(const char* message);
#endif /* JUTCONSOLE_H */
+43
View File
@@ -0,0 +1,43 @@
#ifndef JUTDBPRINT_H
#define JUTDBPRINT_H
#include "JSystem/JUtility/JUTFont.h"
class JKRHeap;
// TODO: fix struct
struct unk_print {
/* 0x00 */ unk_print* mNext;
/* 0x04 */ s16 unk_0x04;
/* 0x06 */ s16 unk_0x06;
/* 0x08 */ s16 unk_0x08;
/* 0x0A */ s16 unk_0x0A;
/* 0x0C */ char unk_0x0C[0];
};
class JUTDbPrint {
public:
/* 802E0148 */ JUTDbPrint(JUTFont*, JKRHeap*);
/* 802E0190 */ static JUTDbPrint* start(JUTFont*, JKRHeap*);
/* 802E0204 */ JUTFont* changeFont(JUTFont*);
/* 802E021C */ void enter(int, int, int, char const*, int);
/* 802E02DC */ void flush(int, int, int, int);
/* 802E02A4 */ void flush();
/* 802E0440 */ void drawString(int, int, int, u8 const*);
static JUTDbPrint* getManager() { return sDebugPrint; }
void setVisible(bool visible) { mVisible = visible; }
JUTFont* getFont() const { return mFont; }
static JUTDbPrint* sDebugPrint;
private:
/* 0x00 */ unk_print* mFirst;
/* 0x04 */ JUTFont* mFont;
/* 0x08 */ JUtility::TColor mColor;
/* 0x0C */ bool mVisible;
/* 0x10 */ JKRHeap* mHeap;
};
#endif /* JUTDBPRINT_H */
+25
View File
@@ -0,0 +1,25 @@
#ifndef JUTDIRECTFILE_H
#define JUTDIRECTFILE_H
#include "dolphin/dvd/dvd.h"
#define JUTDF_BUFSIZE (0x800)
struct JUTDirectFile {
/* 802E8730 */ int fetch32byte();
/* 802E87F8 */ JUTDirectFile();
/* 802E881C */ ~JUTDirectFile();
/* 802E8860 */ bool fopen(char const*);
/* 802E88FC */ void fclose();
/* 802E8958 */ int fgets(void*, int);
/* 0x000 */ u8 mBuffer[0x820];
/* 0x820 */ u8* mSectorStart;
/* 0x824 */ u32 mToRead;
/* 0x828 */ u32 mLength;
/* 0x82C */ u32 mPos;
/* 0x830 */ bool mIsOpen;
/* 0x834 */ DVDFileInfo mFileInfo;
};
#endif /* JUTDIRECTFILE_H */
+57
View File
@@ -0,0 +1,57 @@
#ifndef JUTDIRECTPRINT_H
#define JUTDIRECTPRINT_H
#include "JSystem/JUtility/TColor.h"
#include "Runtime.PPCEABI.H/__va_arg.h"
class JUTDirectPrint {
private:
/* 802E41E8 */ JUTDirectPrint();
public:
/* 802E4288 */ void erase(int, int, int, int);
/* 802E431C */ void drawChar(int, int, int);
/* 802E456C */ void changeFrameBuffer(void*, u16, u16);
/* -------- */ void print(u16, u16, char const*, ...);
/* 802E45A4 */ void printSub(u16, u16, char const*, va_list, bool);
/* 802E46D8 */ void drawString(u16, u16, char*);
/* 802E4708 */ void drawString_f(u16, u16, char const*, ...);
/* 802E47C8 */ void setCharColor(u8, u8, u8);
/* 802E4798 */ void setCharColor(JUtility::TColor);
/* 802E4240 */ static JUTDirectPrint* start();
bool isActive() const { return field_0x00 != 0; }
JUtility::TColor getCharColor() const { return mCharColor; }
static JUTDirectPrint* getManager() { return sDirectPrint; }
private:
static u8 sAsciiTable[128];
static u32 sFontData[64];
static u32 sFontData2[77];
static JUTDirectPrint* sDirectPrint;
static u8 sDirectPrint_padding[4 /* padding */];
private:
/* 0x00 */ void* field_0x00;
/* 0x04 */ u16 mFrameBufferWidth;
/* 0x06 */ u16 mFrameBufferHeight;
/* 0x08 */ u16 mStride;
/* 0x0A */ u16 field_0x0A;
/* 0x0C */ size_t mFrameBufferSize;
/* 0x10 */ u8 field_0x10[4];
/* 0x14 */ u16* mFrameBuffer;
/* 0x18 */ JUtility::TColor mCharColor;
/* 0x1C */ u16 mCharColor_Y;
/* 0x1E */ u16 mCharColor_Cb;
/* 0x20 */ u16 mCharColor_Cb2;
/* 0x22 */ u16 mCharColor_Cb4;
/* 0x24 */ u16 mCharColor_Cr;
/* 0x26 */ u16 mCharColor_Cr2;
/* 0x28 */ u16 mCharColor_Cr4;
/* 0x2A */ u16 field_0x2A;
/* 0x2C */
};
#endif /* JUTDIRECTPRINT_H */
+141
View File
@@ -0,0 +1,141 @@
#ifndef JUTEXCEPTION_H
#define JUTEXCEPTION_H
#include "JSystem/JKernel/JKRThread.h"
#include "JSystem/JUtility/JUTGamePad.h"
#include "Runtime.PPCEABI.H/__va_arg.h"
#include "dolphin/gx/GXEnum.h"
#include "dolphin/os/OSError.h"
#include "dolphin/types.h"
#include "global.h"
typedef struct _GXRenderModeObj GXRenderModeObj;
typedef struct OSContext OSContext;
class JUTDirectPrint;
class JUTExternalFB {
public:
/* 802E40CC */ JUTExternalFB(_GXRenderModeObj*, GXGamma, void*, u32);
private:
/* 0x00 */ _GXRenderModeObj* mRenderMode;
/* 0x04 */ u32 mSize;
/* 0x08 */ u32 field_0x08;
/* 0x0C */ u16 field_0x0C;
/* 0x0E */ u16 mGamma;
/* 0x10 */ bool field_0x10;
/* 0x11 */ u8 field_[3];
};
STATIC_ASSERT(sizeof(JUTExternalFB) == 0x14);
#define JUT_PRINT_GPR 1
#define JUT_PRINT_GPR_MAP 2
#define JUT_PRINT_SRR0_MAP 4
#define JUT_PRINT_FLOAT 8
#define JUT_PRINT_STACK 16
class JUTException : public JKRThread {
public:
enum EInfoPage {
EINFO_PAGE_GPR = 1,
EINFO_PAGE_FLOAT = 2,
EINFO_PAGE_STACK = 3,
EINFO_PAGE_GPR_MAP = 4,
EINFO_PAGE_SSR0_MAP = 5,
};
class JUTExMapFile {
public:
JUTExMapFile(char* path) : mLink(this) { mPath = path; }
public:
/* 0x00 */ char* mPath;
/* 0x04 */ JSULink<JUTExMapFile> mLink;
/* 0x14 */
};
/* 802E1D5C */ JUTException(JUTDirectPrint*);
/* 802E40EC */ virtual ~JUTException();
/* 802E22C4 */ void showFloatSub(int, f32);
/* 802E2454 */ void showFloat(OSContext*);
/* 802E26B0 */ void showStack(OSContext*);
/* 802E27B0 */ void showMainInfo(u16, OSContext*, u32, u32);
/* 802E2A84 */ void showGPR(OSContext*);
/* 802E2B44 */ bool showMapInfo_subroutine(u32, bool);
/* 802E2CA0 */ void showGPRMap(OSContext*);
/* 802E2DAC */ void showSRR0Map(OSContext*);
/* 802E2E70 */ void printDebugInfo(JUTException::EInfoPage, OSError, OSContext*, u32, u32);
/* 802E2F18 */ bool isEnablePad() const;
/* 802E2F54 */ bool readPad(u32*, u32*);
/* 802E34C0 */ void printContext(u16, OSContext*, u32, u32);
/* 802E3A08 */ void createFB();
/* 802E1EA8 */ /* vt[03] */ virtual void* run();
/* 802E1E40 */ static JUTException* create(JUTDirectPrint*);
/* 802E1FCC */ static void errorHandler(OSError, OSContext*, u32, u32);
/* 802E20C0 */ static void panic_f_va(char const*, int, char const*, va_list);
/* 802E21FC */ static void panic_f(char const*, int, char const*, ...);
/* 802E227C */ static void setFPException(u32);
/* 802E2578 */ static bool searchPartialModule(u32, u32*, u32*, u32*, u32*);
/* 802E3AEC */ static OSErrorHandler setPreUserCallback(OSErrorHandler);
/* 802E3AFC */ static OSErrorHandler setPostUserCallback(OSErrorHandler);
/* 802E3B0C */ static void appendMapFile(char const*);
/* 802E3BA0 */ static bool queryMapAddress(char*, u32, s32, u32*, u32*, char*, u32, bool, bool);
/* 802E3C90 */ static bool queryMapAddress_single(char*, u32, s32, u32*, u32*, char*, u32, bool,
bool);
/* 802E3FEC */ static void createConsole(void*, u32);
/* 802E3980 */ static void waitTime(s32);
static JUTException* getManager() { return sErrorManager; }
static JUTConsole* getConsole() { return sConsole; }
JUTExternalFB* getFrameMemory() const { return mFrameMemory; }
void setTraceSuppress(u32 param_0) { mTraceSuppress = param_0; }
void setGamePad(JUTGamePad* gamePad) {
mGamePad = gamePad;
mGamePadPort = JUTGamePad::Port_Unknown;
}
static void setMapFile(const char* map) {
appendMapFile(map);
}
private:
static OSMessageQueue sMessageQueue;
static const char* sCpuExpName[17];
static JSUList<JUTException::JUTExMapFile> sMapFileList;
static u8 sMessageBuffer[4 + 4 /* padding */];
static JUTException* sErrorManager;
static OSErrorHandler sPreUserCallback;
static OSErrorHandler sPostUserCallback;
static void* sConsoleBuffer;
static u32 sConsoleBufferSize;
static JUTConsole* sConsole;
static u32 msr;
static u32 fpscr;
private:
/* 0x7C */ JUTExternalFB* mFrameMemory;
/* 0x80 */ JUTDirectPrint* mDirectPrint;
/* 0x84 */ JUTGamePad* mGamePad;
/* 0x88 */ JUTGamePad::EPadPort mGamePadPort;
/* 0x8C */ s32 mPrintWaitTime0;
/* 0x90 */ s32 mPrintWaitTime1;
/* 0x94 */ u32 mTraceSuppress;
/* 0x98 */ u32 field_0x98;
/* 0x9C */ u32 mPrintFlags;
/* 0xA0 */ u32 mStackPointer;
};
STATIC_ASSERT(sizeof(JUTException) == 0xA4);
struct JUTWarn {
JUTWarn& operator<<(const char*) { return *this; }
JUTWarn& operator<<(long) { return *this; }
};
#endif /* JUTEXCEPTION_H */
+35
View File
@@ -0,0 +1,35 @@
#ifndef JUTFADER_H
#define JUTFADER_H
#include "JSystem/JGeometry.h"
#include "JSystem/JUtility/TColor.h"
class JUTFader {
public:
enum EStatus {
UNKSTATUS_M1 = -1,
UNKSTATUS_0 = 0,
};
/* 802E5530 */ JUTFader(int, int, int, int, JUtility::TColor);
/* 802E55DC */ void control();
/* 802E57D0 */ void setStatus(JUTFader::EStatus, int);
/* 802E5840 */ virtual ~JUTFader();
/* 802E576C */ virtual bool startFadeIn(int);
/* 802E579C */ virtual bool startFadeOut(int);
/* 802E56DC */ virtual void draw();
s32 getStatus() const { return mStatus; }
void setColor(JUtility::TColor& color) { mColor.set(color); }
/* 0x04 */ s32 mStatus;
/* 0x08 */ u16 field_0x8;
/* 0x0A */ u16 field_0xa;
/* 0x0C */ JUtility::TColor mColor;
/* 0x10 */ JGeometry::TBox2<f32> mBox;
/* 0x20 */ int mEStatus;
/* 0x24 */ u32 field_0x24;
};
#endif /* JUTFADER_H */
+128
View File
@@ -0,0 +1,128 @@
#ifndef JUTFONT_H
#define JUTFONT_H
#include "JSystem/JUtility/TColor.h"
#include "MSL_C/string.h"
struct ResFONT {
struct INF1 {
/* 0x00 */ u32 magic;
/* 0x04 */ u32 size;
/* 0x08 */ u16 fontType;
/* 0x0A */ u16 ascent;
/* 0x0C */ u16 descent;
/* 0x0E */ u16 width;
/* 0x10 */ u16 leading;
/* 0x12 */ u16 defaultCode;
};
struct WID1 {
/* 0x00 */ u32 magic;
/* 0x04 */ u32 size;
/* 0x08 */ u16 startCode;
/* 0x0A */ u16 endCode;
/* 0x0C */ u8 mChunkNum[4];
};
struct MAP1 {
/* 0x00 */ u32 magic;
/* 0x04 */ u32 size;
/* 0x08 */ u16 mappingMethod;
/* 0x0A */ u16 startCode;
/* 0x0C */ u16 endCode;
/* 0x0E */ u16 numEntries;
/* 0x10 */ u16 mLeading;
};
struct GLY1 {
/* 0x00 */ u32 magic;
/* 0x04 */ u32 size;
/* 0x08 */ u16 startCode;
/* 0x0A */ u16 endCode;
/* 0x0C */ u16 cellWidth;
/* 0x0E */ u16 cellHeight;
/* 0x10 */ u32 textureSize;
/* 0x14 */ u16 textureFormat;
/* 0x16 */ u16 numRows;
/* 0x18 */ u16 numColumns;
/* 0x1A */ u16 textureWidth;
/* 0x1C */ u16 textureHeight;
/* 0x1E */ u16 padding;
/* 0x20 */ u8 data[];
};
/* 0x00 */ u64 magic;
/* 0x08 */ u32 filesize;
/* 0x0C */ u32 numBlocks;
/* 0x10 */ u8 padding[0x10];
/* 0x20 */ u8 data[];
};
class JUTFont {
public:
JUTFont();
virtual ~JUTFont() {}
struct TWidth {
u8 field_0x0;
u8 field_0x1;
};
/* 0x0C */ virtual void setGX() = 0;
/* 0x10 */ virtual void setGX(JUtility::TColor col1, JUtility::TColor col2);
/* 0x14 */ virtual f32 drawChar_scale(f32 a1, f32 a2, f32 a3, f32 a4, int a5, bool a6) = 0;
/* 0x18 */ virtual int getLeading() const = 0;
/* 0x1C */ virtual s32 getAscent() const = 0;
/* 0x20 */ virtual s32 getDescent() const = 0;
/* 0x24 */ virtual s32 getHeight() const = 0;
/* 0x28 */ virtual s32 getWidth() const = 0;
/* 0x2C */ virtual void getWidthEntry(int i_no, TWidth* width) const = 0;
/* 0x30 */ virtual int getCellWidth() const;
/* 0x34 */ virtual s32 getCellHeight() const;
/* 0x38 */ virtual int getFontType() const = 0;
/* 0x3C */ virtual ResFONT* getResFont() const = 0;
/* 0x40 */ virtual bool isLeadByte(int a1) const = 0;
static bool isLeadByte_1Byte(int b);
static bool isLeadByte_2Byte(int b);
static bool isLeadByte_ShiftJIS(int b);
void initialize_state();
void setCharColor(JUtility::TColor col1);
void setGradColor(JUtility::TColor col1, JUtility::TColor col2);
f32 drawString_size_scale(f32 posX, f32 posY, f32 width, f32 height, const char* str, u32 usz,
bool visible);
void drawString(int posX, int posY, const char* str, bool visible) {
drawString_size(posX, posY, str, strlen(str), visible);
}
void drawString_size(int posX, int posY, const char* str, u32 len, bool visible) {
drawString_size_scale(posX, posY, getWidth(), getHeight(), str, len, visible);
}
void drawString_scale(f32 posX, f32 posY, f32 width, f32 height, const char* str,
bool visible) {
drawString_size_scale(posX, posY, width, height, str, strlen(str), visible);
}
int getWidth(int i_no) const {
TWidth width;
getWidthEntry(i_no, &width);
return width.field_0x1;
}
bool isValid() const { return mValid; }
bool isFixed() const { return mFixed; }
int getFixedWidth() const { return mFixedWidth; }
/* 0x04 */ bool mValid;
/* 0x05 */ bool mFixed;
/* 0x08 */ int mFixedWidth;
/* 0x0C */ JUtility::TColor mColor1;
/* 0x10 */ JUtility::TColor mColor2;
/* 0x14 */ JUtility::TColor mColor3;
/* 0x18 */ JUtility::TColor mColor4;
};
#endif /* JUTFONT_H */
@@ -0,0 +1,6 @@
#ifndef JUTFONTDATA_ASCFONT_FIX12_H
#define JUTFONTDATA_ASCFONT_FIX12_H
#include "dolphin/types.h"
#endif /* JUTFONTDATA_ASCFONT_FIX12_H */
+283
View File
@@ -0,0 +1,283 @@
#ifndef JUTGAMEPAD_H
#define JUTGAMEPAD_H
#include "JSystem/JKernel/JKRDisposer.h"
#include "dolphin/os/OSTime.h"
#include "dolphin/pad/Pad.h"
#include "dolphin/types.h"
typedef void (*callbackFn)(int, void*);
namespace CButton {
enum {
DPAD_LEFT = 0x0001,
DPAD_RIGHT = 0x0002,
DPAD_DOWN = 0x0004,
DPAD_UP = 0x0008,
Z = 0x0010,
R = 0x0020,
L = 0x0040,
A = 0x0100,
B = 0x0200,
X = 0x0400,
Y = 0x0800,
START = 0x1000,
};
}
extern bool sResetSwitchPushing__Q210JUTGamePad13C3ButtonReset;
struct JUTGamePadRecordBase {
virtual void unk0() {}
virtual void unk1(PADStatus* pad) {}
virtual void unk2() {}
/* 0x4 */ bool mActive;
};
struct JUTGamePad : public JKRDisposer {
public:
enum EStickMode {
STICK_MODE_1 = 1,
};
enum EWhichStick {
WS_MAIN_STICK,
WS_SUB_STICK,
};
enum EPadPort {
Port_Unknown = -1,
Port_1,
Port_2,
Port_3,
Port_4,
};
JUTGamePad(JUTGamePad::EPadPort port);
virtual ~JUTGamePad();
void initList();
static s32 init();
void clear();
static u32 read();
void assign();
void checkResetCallback(OSTime unk);
void update();
void stopPatternedRumble() { mRumble.stopPatternedRumble(mPortNum); }
static void checkResetSwitch();
static void clearForReset();
static JUTGamePad* getGamePad(int pad_index);
static bool recalibrate(u32 pad_mask);
static void setAnalogMode(u32 mode) {
sAnalogMode = mode;
PADSetAnalogMode(mode);
}
static void clearResetOccurred() { C3ButtonReset::sResetOccurred = false; }
static void setResetCallback(callbackFn callback, void* param_0) {
C3ButtonReset::sCallback = callback;
C3ButtonReset::sCallbackArg = param_0;
}
u32 getButton() const { return mButton.mButton; }
u32 getTrigger() const { return mButton.mTrigger; }
f32 getMainStickX() const { return mMainStick.mPosX; }
f32 getMainStickY() const { return mMainStick.mPosY; }
f32 getMainStickValue() const { return mMainStick.mValue; }
s16 getMainStickAngle() const { return mMainStick.mAngle; }
f32 getSubStickX() const { return mSubStick.mPosX; }
f32 getSubStickY() const { return mSubStick.mPosY; }
f32 getSubStickValue() const { return mSubStick.mValue; }
s16 getSubStickAngle() const { return mSubStick.mAngle; }
u8 getAnalogA() const { return mButton.mAnalogA; }
u8 getAnalogB() const { return mButton.mAnalogB; }
u8 getAnalogL() const { return mButton.mAnalogL; }
u8 getAnalogR() const { return mButton.mAnalogR; }
s8 getErrorStatus() const { return mErrorStatus; }
s16 getPortNum() const { return mPortNum; }
JUTGamePadRecordBase* getPadReplay() const { return mPadReplay; }
JUTGamePadRecordBase* getPadRecord() const { return mPadRecord; }
u32 testTrigger(u32 button) const { return mButton.mTrigger & button; }
bool isPushing3ButtonReset() const {
bool isPushingReset = false;
if (mPortNum != -1 && mButtonReset.mReset != false) {
isPushingReset = true;
}
return isPushingReset;
}
inline void stopMotorWave() { mRumble.stopPatternedRumbleAtThePeriod(); }
void stopMotor() { mRumble.stopMotor(mPortNum, false); }
void stopMotorHard() { mRumble.stopMotorHard(mPortNum); }
static s8 getPortStatus(u32 port) { return mPadStatus[port].error; }
struct CButton {
CButton() { clear(); }
void clear();
void update(PADStatus const*, u32 unk);
void setRepeat(u32 unk0, u32 unk1, u32 unk2);
/* 0x00 */ u32 mButton;
/* 0x04 */ u32 mTrigger; // Pressed Buttons
/* 0x08 */ u32 mRelease; // Released Buttons
/* 0x0C */ u8 mAnalogA;
/* 0x0D */ u8 mAnalogB;
/* 0x0E */ u8 mAnalogL;
/* 0x0F */ u8 mAnalogR;
/* 0x10 */ f32 mAnalogLf;
/* 0x14 */ f32 mAnalogRf;
/* 0x18 */ u32 mRepeat;
/* 0x1C */ u32 field_0x1c;
/* 0x20 */ u32 field_0x20;
/* 0x24 */ u32 field_0x24;
/* 0x28 */ u32 field_0x28;
/* 0x2C */ u32 field_0x2c;
}; // Size: 0x30
struct C3ButtonReset {
C3ButtonReset() { mReset = false; }
static u32 sResetPattern;
static u32 sResetMaskPattern;
static callbackFn sCallback;
static void* sCallbackArg;
static OSTime sThreshold;
static s32 sResetOccurredPort;
static bool sResetOccurred;
static bool sResetSwitchPushing;
/* 0x0 */ bool mReset;
}; // Size: 0x4
struct CStick {
static f32 sPressPoint;
static f32 sReleasePoint;
CStick() { clear(); }
void clear();
void clear(JUTGamePad* pad);
u32 update(s8 unk0, s8 unk1, JUTGamePad::EStickMode mode, JUTGamePad::EWhichStick stick,
u32 unk2);
u32 getButton(u32 unk);
/* 0x0 */ f32 mPosX;
/* 0x4 */ f32 mPosY;
/* 0x8 */ f32 mValue;
/* 0xC */ s16 mAngle;
/* 0xE */ s8 field_0xe;
/* 0xF */ s8 field_0xf;
}; // Size: 0x10
void stopMotorWaveHard() { mRumble.stopPatternedRumble(mPortNum); }
struct CRumble {
CRumble(JUTGamePad* pad) { clear(pad); }
static PADMask sChannelMask[4];
static bool mStatus[4];
static PADMask mEnabled;
enum ERumble {
VAL_0 = 0,
VAL_1 = 1,
VAL_2 = 2,
};
void clear();
void clear(JUTGamePad* pad);
static void startMotor(int channel);
static void stopMotor(int channel, bool stop);
void update(s16 unk0);
void triggerPatternedRumble(u32 unk0);
void startPatternedRumble(void* unk0, ERumble rumble, u32 unk1);
void stopPatternedRumble(s16 pad_port);
void stopPatternedRumbleAtThePeriod();
static void setEnabled(u32 pad_mask);
void stopMotorHard(int portNo) { stopMotor(portNo, true); }
static bool isEnabled(u32 mask) { return mEnabled & mask; }
static bool isEnabledPort(int port) { return isEnabled(sChannelMask[port]); }
/* 0x00 */ u32 field_0x0;
/* 0x04 */ u32 field_0x4;
/* 0x08 */ u8* field_0x8;
/* 0x0C */ u32 field_0xc;
/* 0x10 */ u8* field_0x10;
}; // Size: 0x14
void startMotorWave(void* param_2, CRumble::ERumble rumble, u32 param_4) {
mRumble.startPatternedRumble(param_2, rumble, param_4);
}
/* 0x18 */ CButton mButton;
/* 0x48 */ CStick mMainStick;
/* 0x58 */ CStick mSubStick;
/* 0x68 */ CRumble mRumble;
/* 0x7C */ s16 mPortNum;
/* 0x7E */ s8 mErrorStatus;
/* 0x80 */ JSULink<JUTGamePad> mLink;
/* 0x90 */ JUTGamePadRecordBase* mPadRecord;
/* 0x94 */ JUTGamePadRecordBase* mPadReplay;
/* 0x98 */ C3ButtonReset mButtonReset;
/* 0x9C */ u8 field_0x9c[4];
/* 0xA0 */ OSTime mResetTime;
/* 0xA8 */ u8 field_0xa8;
static JSUList<JUTGamePad> mPadList;
static bool mListInitialized;
static PADStatus mPadStatus[4];
static CButton mPadButton[4];
static CStick mPadMStick[4];
static CStick mPadSStick[4];
static EStickMode sStickMode;
static u32 sClampMode;
static u8 mPadAssign[4];
static u32 sSuppressPadReset;
static s32 sAnalogMode;
static u32 sRumbleSupported;
};
struct JUTGamePadLongPress {
static JSUList<JUTGamePadLongPress> sPatternList;
void checkCallback(int port, u32 timer);
u32 getMaskPattern() const { return mMaskPattern; }
u32 getPattern() const { return mPattern; }
/* 0x00 */ u8 field_0x0[0x10];
/* 0x10 */ bool mValid;
/* 0x11 */ bool field_0x11;
/* 0x14 */ u32 mPattern;
/* 0x18 */ u32 mMaskPattern;
/* 0x1C */ u32 field_0x1c;
/* 0x20 */ bool field_0x20[4];
/* 0x28 */ OSTime mTimer[4];
/* 0x48 */ bool field_0x48[4];
/* 0x4C */ void (*mCallback)(s32, JUTGamePadLongPress*, s32);
/* 0x50 */ s32 field_0x50;
};
#endif /* JUTGAMEPAD_H */
+36
View File
@@ -0,0 +1,36 @@
#ifndef JUTGRAPHFIFO_H
#define JUTGRAPHFIFO_H
#include "dolphin/gx/GX.h"
class JUTGraphFifo {
public:
/* 802DEB58 */ JUTGraphFifo(u32);
/* 802DEC34 */ virtual ~JUTGraphFifo();
void getGpStatus() {
GXGetGPStatus((GXBool*)&mGpStatus[0], (GXBool*)&mGpStatus[1], (GXBool*)&mGpStatus[2],
(GXBool*)&mGpStatus[3], (GXBool*)&mGpStatus[4]);
}
bool isGPActive() {
getGpStatus();
return mGpStatus[2] == false;
}
void save() { GXSaveCPUFifo(this->mFifo); }
static JUTGraphFifo* sCurrentFifo;
static bool mGpStatus[5];
private:
/* 0x04 */ GXFifoObj* mFifo;
/* 0x08 */ void* mBase;
/* 0x0C */ u32 mSize;
/* 0x10 */ u8 field_0x10[0xC];
};
inline void JUTCreateFifo(u32 bufSize) { new JUTGraphFifo(bufSize); }
#endif /* JUTGRAPHFIFO_H */
+37
View File
@@ -0,0 +1,37 @@
#ifndef JUTNAMETAB_H
#define JUTNAMETAB_H
#include "dolphin/types.h"
struct ResNTAB {
u16 mEntryNum;
u16 mPad0;
struct Entry {
u16 mKeyCode;
u16 mOffs;
} mEntries[1];
inline const char* getName(u32 index) const {
return ((const char*)mEntries) + mEntries[index].mOffs - 4;
}
};
class JUTNameTab {
public:
JUTNameTab();
JUTNameTab(const ResNTAB* pNameTable);
virtual ~JUTNameTab() {};
void setResource(const ResNTAB* pNameTable);
s32 getIndex(char const*) const;
const char* getName(u16 index) const;
u16 calcKeyCode(char const* pName) const;
const ResNTAB* getResNameTable() const { return mNameTable; }
private:
/* 0x4 */ const ResNTAB* mNameTable;
/* 0x8 */ const char* mpStrData;
/* 0xC */ u16 mNameNum;
};
#endif /* JUTNAMETAB_H */
+44
View File
@@ -0,0 +1,44 @@
#ifndef JUTPALETTE_H
#define JUTPALETTE_H
#include "dolphin/gx/GXEnum.h"
#include "dolphin/gx/GXStruct.h"
enum JUTTransparency { UNK0, UNK1 };
struct ResTLUT {
u8 format;
u8 transparency;
u16 numColors;
};
class JUTPalette {
public:
JUTPalette(_GXTlut p1, _GXTlutFmt p2, JUTTransparency p3, u16 p4, void* p5) {
this->storeTLUT(p1, p2, p3, p4, p5);
}
JUTPalette(GXTlut tlutNo, ResTLUT* p_tlutRes) {
storeTLUT(tlutNo, p_tlutRes);
}
/* 802DE890 */ void storeTLUT(_GXTlut, ResTLUT*);
/* 802DE91C */ void storeTLUT(_GXTlut, _GXTlutFmt, JUTTransparency, u16, void*);
/* 802DE95C */ bool load();
u8 getTlutName() const { return mTlutName; }
u8 getFormat() const { return mFormat; }
u8 getTransparency() const { return mTransparency; }
u16 getNumColors() const { return mNumColors; }
ResTLUT* getColorTable() const { return mColorTable; }
private:
/* 0x00 */ _GXTlutObj mTlutObj;
/* 0x0C */ u8 mTlutName;
/* 0x0D */ u8 mFormat;
/* 0x10 */ ResTLUT* mColorTable;
/* 0x14 */ u16 mNumColors;
/* 0x16 */ u8 mTransparency;
};
#endif /* JUTPALETTE_H */
+103
View File
@@ -0,0 +1,103 @@
#ifndef JUTPROCBAR_H
#define JUTPROCBAR_H
#include "JSystem/JUtility/TColor.h"
#include "dolphin/os/OSTime.h"
class JKRHeap;
class JUTProcBar {
public:
class CTime {
public:
/* 802E7340 */ CTime();
void start(u8 param_0, u8 param_1, u8 param_2) {
mR = param_0;
mG = param_1;
mB = param_2;
mTick = OSGetTick();
}
void end() {
mCost = ((OSGetTick() - mTick) * 8) / ((*(u32*)0x800000F8 / 4) / 125000);
if (mCost == 0) {
mCost = 1;
}
}
void accumePeek() {
if (++field_0xc >= 0x10 || mCost >= field_0x8) {
field_0x8 = mCost;
field_0xc = 0;
}
}
int calcBarSize(int p1, int p2) { return mCost * p1 / p2; }
/* 0x00 */ u32 mTick;
/* 0x04 */ u32 mCost;
/* 0x08 */ u32 field_0x8;
/* 0x0C */ u32 field_0xc;
/* 0x10 */ u8 mR;
/* 0x11 */ u8 mG;
/* 0x12 */ u8 mB;
};
class CParamSet {
public:
/* 0x00 */ int mBarWidth;
/* 0x04 */ int mPosX;
/* 0x08 */ int mPosY;
/* 0x0C */ int mWidth;
/* 0x10 */ int mUserPosition;
};
/* 802E5888 */ JUTProcBar();
/* 802E599C */ ~JUTProcBar();
/* 802E59E0 */ static JUTProcBar* create();
/* 802E5A28 */ static void destroy();
/* 802E5A60 */ static void clear();
/* 802E5B30 */ void bar_subroutine(int, int, int, int, int, int, int, JUtility::TColor,
JUtility::TColor);
/* 802E5CC4 */ void adjustMeterLength(u32, f32*, f32, f32, int*);
/* 802E5E08 */ void draw();
/* 802E5E3C */ void drawProcessBar();
/* 802E6FA0 */ void drawHeapBar();
void cpuStart() { mCpu.start(255, 129, 30); }
void cpuEnd() { mCpu.end(); }
void gpWaitStart() { mGpWait.start(255, 129, 30); }
void gpWaitEnd() { mGpWait.end(); }
void gpStart() { mGp.start(255, 129, 30); }
void gpEnd() { mGp.end(); }
void wholeLoopStart() { mWholeLoop.start(255, 129, 30); }
void wholeLoopEnd() { mWholeLoop.end(); }
void idleStart() { mIdle.start(255, 129, 30); }
void idleEnd() { mIdle.end(); }
void setCostFrame(int frame) { mCostFrame = frame; }
void setVisible(bool visible) { mVisible = visible; }
void setVisibleHeapBar(bool visible) { mHeapBarVisible = visible; }
static JUTProcBar* getManager() { return sManager; }
static JUTProcBar* sManager;
private:
/* 0x000 */ CTime mIdle;
/* 0x014 */ CTime mGp;
/* 0x028 */ CTime mCpu;
/* 0x03C */ CTime mGpWait;
/* 0x050 */ CTime mWholeLoop;
/* 0x064 */ CTime mUsers[8];
/* 0x104 */ int mCostFrame;
/* 0x108 */ int field_0x108;
/* 0x10C */ bool mVisible;
/* 0x110 */ int field_0x110;
/* 0x114 */ CParamSet mParams;
/* 0x128 */ int field_0x128;
/* 0x12C */ JKRHeap* mWatchHeap;
/* 0x130 */ bool mHeapBarVisible;
};
#endif /* JUTPROCBAR_H */
+7
View File
@@ -0,0 +1,7 @@
#ifndef JSYSTEM_JUTILITY_JUTREPORT_H
#define JSYSTEM_JUTILITY_JUTREPORT_H
void JUTReport(int x_pos, int y_pos, const char* str, ...);
void JUTReport(int x_pos, int y_pos, int, const char* str, ...);
#endif
+74
View File
@@ -0,0 +1,74 @@
#ifndef JUTRESFONT_H
#define JUTRESFONT_H
#include "JSystem/JUtility/JUTFont.h"
#include "dolphin/gx/GXEnum.h"
class JKRHeap;
typedef bool (*IsLeadByte_func)(int);
struct BlockHeader {
const BlockHeader* getNext() const { return reinterpret_cast<const BlockHeader*>(reinterpret_cast<const u8*>(this) + size); }
u32 magic;
u32 size;
};
class JUTResFont : public JUTFont {
public:
/* 802DF000 */ virtual ~JUTResFont();
/* 802DF48C */ virtual void setGX();
/* 802DF584 */ virtual void setGX(JUtility::TColor, JUtility::TColor);
/* 802DF7C4 */ virtual f32 drawChar_scale(f32, f32, f32, f32, int, bool);
/* 802DDFEC */ virtual int getLeading() const;
/* 802DE004 */ virtual s32 getAscent() const;
/* 802DE010 */ virtual s32 getDescent() const;
/* 802DE01C */ virtual s32 getHeight() const;
/* 802DDFF8 */ virtual s32 getWidth() const;
/* 802DFC64 */ virtual void getWidthEntry(int, JUTFont::TWidth*) const;
/* 802DFD0C */ virtual int getCellWidth() const;
/* 802DFD58 */ virtual s32 getCellHeight() const;
/* 802DDFE0 */ virtual int getFontType() const;
/* 802DDFD8 */ virtual ResFONT* getResFont() const;
/* 802DFDA4 */ virtual bool isLeadByte(int) const;
/* 802DFF60 */ virtual void loadImage(int, _GXTexMapID);
/* 802DF344 */ virtual void setBlock();
/* 802DEF94 */ JUTResFont(ResFONT const*, JKRHeap*);
/* 802DEF48 */ JUTResFont();
/* 802DF08C */ void deleteMemBlocks_ResFont();
/* 802DF0B0 */ void initialize_state();
/* 802DF0DC */ bool initiate(ResFONT const*, JKRHeap*);
/* 802DF13C */ bool protected_initiate(ResFONT const*, JKRHeap*);
/* 802DF248 */ void countBlock();
/* 802DFBE8 */ void loadFont(int, _GXTexMapID, JUTFont::TWidth*);
/* 802DFDD8 */ int getFontCode(int) const;
/* 802E00C4 */ int convertSjis(int, u16*) const;
inline void delete_and_initialize() {
deleteMemBlocks_ResFont();
initialize_state();
}
static IsLeadByte_func const saoAboutEncoding_[3];
// some types uncertain, may need to be fixed
/* 0x1C */ int mWidth;
/* 0x20 */ int mHeight;
/* 0x24 */ _GXTexObj field_0x24;
/* 0x44 */ int field_0x44;
/* 0x48 */ const ResFONT* mResFont;
/* 0x4C */ ResFONT::INF1* mInf1Ptr;
/* 0x50 */ void** mMemBlocks;
/* 0x54 */ ResFONT::WID1** mpWidthBlocks;
/* 0x58 */ ResFONT::GLY1** mpGlyphBlocks;
/* 0x5C */ ResFONT::MAP1** mpMapBlocks;
/* 0x60 */ u16 mWid1BlockNum;
/* 0x62 */ u16 mGly1BlockNum;
/* 0x64 */ u16 mMap1BlockNum;
/* 0x66 */ u16 field_0x66;
/* 0x68 */ u16 mMaxCode;
/* 0x6C */ IsLeadByte_func* mIsLeadByte;
};
#endif /* JUTRESFONT_H */
+30
View File
@@ -0,0 +1,30 @@
#ifndef JUTRESOURCE_H
#define JUTRESOURCE_H
#include "dolphin/types.h"
class JKRArchive;
class JSUInputStream;
class JUTResReference {
private:
/* 0x001 */ u8 mType;
/* 0x002 */ u8 mNameLength;
/* 0x003 */ char mName[0x100];
public:
enum ResType {
RESTYPE_Null = 0,
RESTYPE_Unk1 = 1,
RESTYPE_Unk2 = 2,
RESTYPE_Unk3 = 3,
RESTYPE_Unk4 = 4,
};
JUTResReference() { mType = 0; }
/* 802DE078 */ void* getResource(JSUInputStream*, u32, JKRArchive*);
/* 802DE120 */ void* getResource(void const*, u32, JKRArchive*);
/* 802DE1BC */ void* getResource(u32, JKRArchive*);
};
// only rough size known due to getPointer__7J2DPaneFP20JSURandomInputStreamUlP10JKRArchive
#endif /* JUTRESOURCE_H */
+106
View File
@@ -0,0 +1,106 @@
#ifndef JUTTEXTURE_H
#define JUTTEXTURE_H
#include "dolphin/gx/GXEnum.h"
#include "dolphin/gx/GXStruct.h"
class JUTPalette;
/*
* Acts as the header to image data. Usually texture data immediately follows it,
* so any pointer arithmetic to go past the end of this structure is so that a
* variable sized allocated buffer can be accessed.
*/
struct ResTIMG {
/* 0x00 */ u8 format;
/* 0x01 */ u8 alphaEnabled;
/* 0x02 */ u16 width;
/* 0x04 */ u16 height;
/* 0x06 */ u8 wrapS;
/* 0x07 */ u8 wrapT;
/* 0x08 */ u8 indexTexture;
/* 0x09 */ u8 colorFormat;
/* 0x0A */ u16 numColors;
/* 0x0C */ u32 paletteOffset;
/* 0x10 */ u8 mipmapEnabled;
/* 0x11 */ u8 doEdgeLOD;
/* 0x12 */ u8 biasClamp;
/* 0x13 */ u8 maxAnisotropy;
/* 0x14 */ u8 minFilter;
/* 0x15 */ u8 magFilter;
/* 0x16 */ s8 minLOD;
/* 0x17 */ s8 maxLOD;
/* 0x18 */ u8 mipmapCount;
/* 0x19 */ u8 unknown;
/* 0x1A */ s16 LODBias;
/* 0x1C */ u32 imageOffset;
}; // Size: 0x20
class JUTTexture {
public:
JUTTexture() {
setCaptureFlag(false);
mEmbPalette = NULL;
mTexInfo = NULL;
}
JUTTexture(const ResTIMG* p_timg, u8 param_1) {
mEmbPalette = NULL;
storeTIMG(p_timg, param_1);
setCaptureFlag(false);
}
~JUTTexture();
void storeTIMG(ResTIMG const*, JUTPalette*, _GXTlut);
void storeTIMG(ResTIMG const*, u8);
void storeTIMG(ResTIMG const*, JUTPalette*);
void attachPalette(JUTPalette*);
void init();
void initTexObj(_GXTlut);
void initTexObj();
void load(_GXTexMapID);
const ResTIMG* getTexInfo() const { return mTexInfo; }
u8 getFormat() const { return mTexInfo->format; }
s32 getTransparency() { return mTexInfo->alphaEnabled; }
s32 getWidth() const { return mTexInfo->width; }
s32 getHeight() const { return mTexInfo->height; }
void setCaptureFlag(bool flag) { mFlags &= 2 | flag; }
u8 getCaptureFlag() const { return mFlags & 1; }
u8 getEmbPaletteDelFlag() const { return mFlags & 2; }
void setEmbPaletteDelFlag(bool flag) { mFlags = (mFlags & 1) | (flag << 1);}
u8 getTlutName() const { return mTlutName; }
bool operator==(const JUTTexture& other) {
return mTexInfo == other.mTexInfo
&& field_0x2c == other.field_0x2c
&& mWrapS == other.mWrapS
&& mWrapT == other.mWrapT
&& mMinFilter == other.mMinFilter
&& mMagFilter == other.mMagFilter
&& mMinLOD == other.mMinLOD
&& mMinLOD == other.mMinLOD
&& mLODBias == other.mLODBias;
}
bool operator!=(const JUTTexture& other) {
return !operator==(other);
}
private:
/* 0x00 */ GXTexObj mTexObj;
/* 0x20 */ const ResTIMG* mTexInfo;
/* 0x24 */ void* mTexData;
/* 0x28 */ JUTPalette* mEmbPalette;
/* 0x2C */ JUTPalette* field_0x2c;
/* 0x30 */ u8 mWrapS;
/* 0x31 */ u8 mWrapT;
/* 0x32 */ u8 mMinFilter;
/* 0x33 */ u8 mMagFilter;
/* 0x34 */ u16 mMinLOD;
/* 0x36 */ u16 mMaxLOD;
/* 0x38 */ s16 mLODBias;
/* 0x3A */ u8 mTlutName;
/* 0x3B */ u8 mFlags;
/* 0x3C */ void* field_0x3c;
};
#endif /* JUTTEXTURE_H */
+74
View File
@@ -0,0 +1,74 @@
#ifndef JUTVIDEO_H
#define JUTVIDEO_H
#include "dolphin/gx/GXStruct.h"
#include "dolphin/os/OSMessage.h"
#include "dolphin/os/OSTime.h"
#include "dolphin/vi/vi.h"
typedef u8 (*Pattern)[2];
class JUTVideo {
public:
typedef void (*Callback)(u32);
JUTVideo(GXRenderModeObj const*);
virtual ~JUTVideo();
// TODO: return types not confirmed
/* 802E4C54 */ static JUTVideo* createManager(GXRenderModeObj const*);
/* 802E4CAC */ static void destroyManager();
/* 802E5088 */ static void drawDoneStart();
/* 802E50B0 */ static void dummyNoDrawWait();
/* 802E5198 */ void setRenderMode(GXRenderModeObj const*);
/* 802E5210 */ void waitRetraceIfNeed();
/* 802E4E50 */ static void preRetraceProc(u32);
/* 802E5144 */ static void postRetraceProc(u32);
/* 802E50BC */ static void drawDoneCallback();
u16 getFbWidth() const { return mRenderObj->fb_width; }
u16 getEfbHeight() const { return mRenderObj->efb_height; }
void getBounds(u16& width, u16& height) const {
width = (u16)getFbWidth();
height = (u16)getEfbHeight();
}
u16 getXfbHeight() const { return mRenderObj->xfb_height; }
u32 isAntiAliasing() const { return mRenderObj->antialiasing; }
Pattern getSamplePattern() const { return mRenderObj->sample_pattern; }
u8* getVFilter() const { return mRenderObj->vfilter; }
OSMessageQueue* getMessageQueue() { return &mMessageQueue; }
static JUTVideo* getManager() { return sManager; }
static OSTick getVideoInterval() { return sVideoInterval; }
static OSTick getVideoLastTick() { return sVideoLastTick; }
GXRenderModeObj* getRenderMode() const { return mRenderObj; }
private:
static JUTVideo* sManager;
static OSTick sVideoLastTick;
static OSTick sVideoInterval;
private:
/* 0x04 */ _GXRenderModeObj* mRenderObj;
/* 0x08 */ u32 field_0x8;
/* 0x0C */ u32 mRetraceCount;
/* 0x10 */ u32 field_0x10;
/* 0x14 */ u32 field_0x14;
/* 0x18 */ u32 field_0x18;
/* 0x1C */ VIRetraceCallback mPreRetraceCallback;
/* 0x20 */ VIRetraceCallback mPostRetraceCallback;
/* 0x24 */ Callback mPreCallback;
/* 0x28 */ Callback mPostCallback;
/* 0x2C */ bool mSetBlack;
/* 0x30 */ s32 mSetBlackFrameCount;
/* 0x34 */ OSMessage mMessage;
/* 0x38 */ OSMessageQueue mMessageQueue;
};
inline JUTVideo* JUTGetVideoManager() {
return JUTVideo::getManager();
}
#endif /* JUTVIDEO_H */
+71
View File
@@ -0,0 +1,71 @@
#ifndef JUTXFB_H
#define JUTXFB_H
#include "JSystem/JUtility/JUTVideo.h"
typedef struct _GXRenderModeObj GXRenderModeObj;
class JKRHeap;
class JUTXfb {
public:
enum EXfbNumber { // TODO: placeholder
UNK_0 = 0,
UNK_1 = 1,
UNK_2 = 2,
UNK_3 = 3,
};
/* 802E5214 */ void clearIndex();
/* 802E5228 */ void common_init(int);
/* 802E5260 */ JUTXfb(_GXRenderModeObj const*, JKRHeap*, JUTXfb::EXfbNumber);
/* 802E5308 */ ~JUTXfb();
/* 802E5378 */ void delXfb(int);
/* 802E53B8 */ static JUTXfb* createManager(JKRHeap*, JUTXfb::EXfbNumber);
/* 802E5424 */ static void destroyManager();
/* 802E5454 */ void initiate(u16, u16, JKRHeap*, JUTXfb::EXfbNumber);
s32 getBufferNum() const { return mBufferNum; }
s16 getDrawnXfbIndex() const { return mDrawnXfbIndex; }
s16 getDrawingXfbIndex() const { return mDrawingXfbIndex; }
s16 getDisplayingXfbIndex() const { return mDisplayingXfbIndex; }
s32 getSDrawingFlag() const { return mSDrawingFlag; }
void* getDrawnXfb() const {
if (mDrawnXfbIndex >= 0)
return mBuffer[mDrawnXfbIndex];
return NULL;
}
void* getDrawingXfb() const {
if (mDrawingXfbIndex >= 0)
return mBuffer[mDrawingXfbIndex];
return NULL;
}
void* getDisplayingXfb() const {
if (mDisplayingXfbIndex >= 0)
return mBuffer[mDisplayingXfbIndex];
return NULL;
}
void setDisplayingXfbIndex(s16 index) { mDisplayingXfbIndex = index; }
void setSDrawingFlag(s32 flag) { mSDrawingFlag = flag; }
void setDrawnXfbIndex(s16 index) { mDrawnXfbIndex = index; }
void setDrawingXfbIndex(s16 index) { mDrawingXfbIndex = index; }
static JUTXfb* getManager() { return sManager; }
private:
static JUTXfb* sManager;
private:
/* 0x00 */ void* mBuffer[3];
/* 0x0C */ bool mXfbAllocated[3];
/* 0x10 */ s32 mBufferNum;
/* 0x14 */ s16 mDrawingXfbIndex;
/* 0x16 */ s16 mDrawnXfbIndex;
/* 0x18 */ s16 mDisplayingXfbIndex;
/* 0x1C */ s32 mSDrawingFlag;
};
#endif /* JUTXFB_H */
+34
View File
@@ -0,0 +1,34 @@
#ifndef TCOLOR_H
#define TCOLOR_H
#include "dolphin/gx/GXStruct.h"
namespace JUtility {
struct TColor : public GXColor {
TColor(u8 r, u8 g, u8 b, u8 a) { set(r, g, b, a); }
TColor() { set(0xffffffff); }
TColor(u32 u32Color) { set(u32Color); }
TColor(GXColor color) { set(color); }
// TColor(const TColor& other) { set(other.toUInt32()); }
TColor& operator=(const TColor& other) {
((GXColor*)this)->operator=(other);
return *this;
}
operator u32() const { return toUInt32(); }
u32 toUInt32() const { return *(u32*)&r; }
void set(u8 cR, u8 cG, u8 cB, u8 cA) {
r = cR;
g = cG;
b = cB;
a = cA;
}
void set(u32 u32Color) { *(u32*)&r = u32Color; }
void set(GXColor gxColor) { *(GXColor*)&r = gxColor; }
};
} // namespace JUtility
#endif
+18
View File
@@ -0,0 +1,18 @@
#ifndef MSL_COMMON_SRC_FILE_POS_H
#define MSL_COMMON_SRC_FILE_POS_H
#include "MSL_C/MSL_Common/Src/ansi_files.h"
#ifdef __cplusplus
extern "C" {
#endif
int fseek(FILE* file, long offset, int mode);
int _fseek(FILE* file, fpos_t offset, int mode);
long ftell(FILE* file);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_FILE_POS_H */
+17
View File
@@ -0,0 +1,17 @@
#ifndef MSL_COMMON_SRC_ABORT_EXIT_H
#define MSL_COMMON_SRC_ABORT_EXIT_H
#ifdef __cplusplus
extern "C" {
#endif
void exit(int status);
void abort(void);
extern void (*__stdio_exit)(void);
#ifdef __cplusplus
};
#endif
#endif /* MSL_COMMON_SRC_ABORT_EXIT_H */
+17
View File
@@ -0,0 +1,17 @@
#ifndef MSL_COMMON_SRC_ALLOC_H
#define MSL_COMMON_SRC_ALLOC_H
#include "MSL_C/MSL_Common/Src/ansi_files.h"
#ifdef __cplusplus
extern "C" {
#endif
void free(FILE* file);
void __pool_free(int** param_1, unsigned int** param_2);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_ALLOC_H */
+131
View File
@@ -0,0 +1,131 @@
#ifndef MSL_COMMON_SRC_ANSI_FILES_H
#define MSL_COMMON_SRC_ANSI_FILES_H
#include "MSL_C/MSL_Common/Src/stddef.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
typedef unsigned long __file_handle;
typedef unsigned long fpos_t;
#ifndef __cplusplus
typedef unsigned short wchar_t;
#endif
#define set_error(file) \
do { \
(file)->file_state.error = 1; \
(file)->buffer_length = 0; \
} while (0)
enum __file_kinds {
__closed_file,
__disk_file,
__console_file,
__unavailable_file,
};
enum __file_orientation {
/* 0x0 */ UNORIENTED,
/* 0x1 */ CHAR_ORIENTED,
/* 0x2 */ WIDE_ORIENTED,
};
typedef struct _file_modes {
unsigned int open_mode : 2;
unsigned int io_mode : 3;
unsigned int buffer_mode : 2;
unsigned int file_kind : 3;
unsigned int file_orientation : 2;
unsigned int binary_io : 1;
} file_modes;
enum __io_modes {
__read = 1,
__write = 2,
__read_write = 3,
__append = 4,
};
enum __io_states {
__neutral,
__writing,
__reading,
__rereading,
};
enum __io_results {
__no_io_error,
__io_error,
__io_EOF,
};
typedef struct _file_states {
unsigned int io_state : 3;
unsigned int free_buffer : 1;
unsigned char eof;
unsigned char error;
} file_states;
typedef void (*__idle_proc)(void);
typedef int (*__pos_proc)(__file_handle file, fpos_t* position, int mode, __idle_proc idle_proc);
typedef int (*__io_proc)(__file_handle file, unsigned char* buff, size_t* count,
__idle_proc idle_proc);
typedef int (*__close_proc)(__file_handle file);
typedef struct _FILE {
/* 0x00 */ __file_handle handle;
/* 0x04 */ file_modes file_mode;
/* 0x08 */ file_states file_state;
/* 0x0C */ unsigned char is_dynamically_allocated;
/* 0x0D */ char char_buffer;
/* 0x0E */ char char_buffer_overflow;
/* 0x0F */ char ungetc_buffer[2];
/* 0x12 */ wchar_t ungetc_wide_buffer[2];
/* 0x18 */ unsigned long position;
/* 0x1C */ unsigned char* buffer;
/* 0x20 */ unsigned long buffer_size;
/* 0x24 */ unsigned char* buffer_ptr;
/* 0x28 */ unsigned long buffer_length;
/* 0x2C */ unsigned long buffer_alignment;
/* 0x30 */ unsigned long save_buffer_length;
/* 0x34 */ unsigned long buffer_position;
/* 0x38 */ __pos_proc position_fn;
/* 0x3C */ __io_proc read_fn;
/* 0x40 */ __io_proc write_fn;
/* 0x44 */ __close_proc close_fn;
/* 0x48 */ __idle_proc idle_fn;
/* 0x4C */ struct _FILE* next_file;
} FILE;
typedef struct _files {
FILE _stdin;
FILE _stdout;
FILE _stderr;
FILE empty;
} files;
#define _IONBF 0
#define _IOLBF 1
#define _IOFBF 2
extern files __files;
extern int __close_console(__file_handle file);
extern int __write_console(__file_handle file, unsigned char* buf, size_t* count,
__idle_proc idle_fn);
extern int __read_console(__file_handle file, unsigned char* buf, size_t* count,
__idle_proc idle_fn);
unsigned int __flush_all(void);
void __close_all(void);
#ifdef __cplusplus
};
#endif
#endif /* MSL_COMMON_SRC_ANSI_FILES_H */
+19
View File
@@ -0,0 +1,19 @@
#ifndef MSL_COMMON_SRC_ARITH_H
#define MSL_COMMON_SRC_ARITH_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
int quot; /* quotient */
int rem; /* remainder */
} div_t;
div_t div(int numerator, int denominator);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_ARITH_H */
+11
View File
@@ -0,0 +1,11 @@
#ifndef MSL_COMMON_SRC_BUFFER_IO_H
#define MSL_COMMON_SRC_BUFFER_IO_H
#include "MSL_C/MSL_Common/Src/ansi_files.h"
enum { __align_buffer, __dont_align_buffer };
void __prep_buffer(FILE* file);
int __flush_buffer(FILE* file, size_t* bytes_flushed);
#endif /* MSL_COMMON_SRC_BUFFER_IO_H */
+17
View File
@@ -0,0 +1,17 @@
#ifndef MSL_COMMON_SRC_CHAR_IO_H
#define MSL_COMMON_SRC_CHAR_IO_H
#include "MSL_C/MSL_Common/Src/ansi_files.h"
#ifdef __cplusplus
extern "C" {
#endif
int fputs(const char* str, FILE* stream);
int __put_char(int c, FILE* stream);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_CHAR_IO_H */
+37
View File
@@ -0,0 +1,37 @@
#ifndef MSL_COMMON_SRC_CTYPE_H
#define MSL_COMMON_SRC_CTYPE_H
#ifdef __cplusplus
extern "C" {
#endif
#define EOF -1L
extern unsigned char __ctype_map[];
extern unsigned char __lower_map[];
extern unsigned char __upper_map[];
#define __control_char 0x01
#define __motion_char 0x02
#define __space_char 0x04
#define __punctuation 0x08
#define __digit 0x10
#define __hex_digit 0x20
#define __lower_case 0x40
#define __upper_case 0x80
#define __letter (__lower_case | __upper_case)
#define __alphanumeric (__letter | __digit)
#define __graphic (__alphanumeric | __punctuation)
#define __printable (__graphic | __space_char)
#define __whitespace (__motion_char | __space_char)
#define __control (__motion_char | __control_char)
#define __zero_fill(c) ((int)(unsigned char)(c))
int tolower(int);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_CTYPE_H */
+17
View File
@@ -0,0 +1,17 @@
#ifndef MSL_COMMON_SRC_DIRECT_IO_H
#define MSL_COMMON_SRC_DIRECT_IO_H
#include "MSL_C/MSL_Common/Src/ansi_files.h"
#ifdef __cplusplus
extern "C" {
#endif
size_t __fwrite(const void* buffer, size_t size, size_t count, FILE* stream);
size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_DIRECT_IO_H */
+15
View File
@@ -0,0 +1,15 @@
#ifndef MSL_COMMON_SRC_EXTRAS_H
#define MSL_COMMON_SRC_EXTRAS_H
#ifdef __cplusplus
extern "C" {
#endif
int strnicmp(const char* str1, const char* str2, int n);
int stricmp(const char* str1, const char* str2);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_EXTRAS_H */
+18
View File
@@ -0,0 +1,18 @@
#ifndef MSL_COMMON_SRC_FILE_IO_H
#define MSL_COMMON_SRC_FILE_IO_H
#include "MSL_C/MSL_Common/Src/ansi_files.h"
#ifdef __cplusplus
extern "C" {
#endif
int __msl_strnicmp(const char* str1, const char* str2, size_t n);
int fflush(FILE* file);
int fclose(FILE* file);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_FILE_IO_H */
+69
View File
@@ -0,0 +1,69 @@
#ifndef MSL_COMMON_SRC_FLOAT_H
#define MSL_COMMON_SRC_FLOAT_H
#include "fdlibm.h"
#define FP_SNAN 0
#define FP_QNAN 1
#define FP_INFINITE 2
#define FP_ZERO 3
#define FP_NORMAL 4
#define FP_SUBNORMAL 5
#define FP_NAN FP_QNAN
#define fpclassify(x) ((sizeof(x) == sizeof(float)) ? __fpclassifyf(x) : __fpclassifyd(x))
#define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf(x) : __signbitd(x))
#define isfinite(x) ((fpclassify(x) > 2))
#define __signbitf(x) ((*(unsigned char*)&(x)) & 0x80)
// TODO: OK?
#define __signbitd(x) ((*(unsigned char*)&(x)) & 0x80)
extern unsigned long __float_nan[];
extern unsigned long __float_huge[];
extern unsigned long __float_max[];
extern unsigned long __float_epsilon[];
inline int __fpclassifyf(float __value) {
unsigned long integer = *(unsigned long*)&__value;
switch (integer & 0x7f800000) {
case 0x7f800000:
if ((integer & 0x7fffff) != 0) {
return FP_QNAN;
}
return FP_INFINITE;
case 0:
if ((integer & 0x7fffff) != 0) {
return FP_SUBNORMAL;
}
return FP_ZERO;
}
return FP_NORMAL;
}
inline int __fpclassifyd(double __value) {
switch (__HI(__value) & 0x7ff00000) {
case 0x7ff00000: {
if ((__HI(__value) & 0x000fffff) || (__LO(__value) & 0xffffffff))
return FP_QNAN;
else
return FP_INFINITE;
break;
}
case 0: {
if ((__HI(__value) & 0x000fffff) || (__LO(__value) & 0xffffffff))
return FP_SUBNORMAL;
else
return FP_ZERO;
break;
}
}
return FP_NORMAL;
}
#endif /* MSL_COMMON_SRC_FLOAT_H */
+70
View File
@@ -0,0 +1,70 @@
#ifndef _STD_LIMITS_H
#define _STD_LIMITS_H
namespace std {
template <typename T>
class numeric_limits {
public:
inline static T min();
inline static T max();
};
template <>
class numeric_limits<char> {
public:
inline static char min() { return -0x80; }
inline static char max() { return 0x7F; }
};
template <>
class numeric_limits<short> {
public:
inline static short min() { return -0x8000; }
inline static short max() { return 0x7FFF; }
};
template <>
class numeric_limits<int> {
public:
inline static int min() { return -0x80000000; }
inline static int max() { return 0x7FFFFFFF; }
};
template <>
class numeric_limits<long> {
public:
inline static long min() { return -0x80000000; }
inline static long max() { return 0x7FFFFFFF; }
};
template <>
class numeric_limits<unsigned char> {
public:
inline static unsigned char min() { return 0x0; }
inline static unsigned char max() { return 0xFF; }
};
template <>
class numeric_limits<unsigned short> {
public:
inline static unsigned short min() { return 0x0; }
inline static unsigned short max() { return 0xFFFF; }
};
template <>
class numeric_limits<unsigned int> {
public:
inline static unsigned int min() { return 0x0; }
inline static unsigned int max() { return 0xFFFFFFFF; }
};
template <>
class numeric_limits<unsigned long> {
public:
inline static unsigned long min() { return 0x0; }
inline static unsigned long max() { return 0xFFFFFFFF; }
};
} // namespace std
#endif
+16
View File
@@ -0,0 +1,16 @@
#ifndef MSL_COMMON_SRC_MBSTRING_H
#define MSL_COMMON_SRC_MBSTRING_H
#include "MSL_C/MSL_Common/Src/wchar_io.h"
#ifdef __cplusplus
extern "C" {
#endif
size_t wcstombs(char* dst, const wchar_t* src, size_t n);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_MBSTRING_H */
+19
View File
@@ -0,0 +1,19 @@
#ifndef MSL_COMMON_SRC_MEM_H
#define MSL_COMMON_SRC_MEM_H
#include "MSL_C/MSL_Common/Src/stddef.h"
#ifdef __cplusplus
extern "C" {
#endif
int memcmp(const void* lhs, const void* rhs, size_t count);
void* __memrchr(const void* ptr, int ch, size_t count);
void* memchr(const void* ptr, int ch, size_t count);
void* memmove(void* dst, const void* src, size_t n);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_MEM_H */
+19
View File
@@ -0,0 +1,19 @@
#ifndef MSL_COMMON_SRC_MEM_FUNCS_H
#define MSL_COMMON_SRC_MEM_FUNCS_H
#include "MSL_C/MSL_Common/Src/stddef.h"
#ifdef __cplusplus
extern "C" {
#endif
void __copy_longs_rev_unaligned(void* dst, const void* src, size_t n);
void __copy_longs_unaligned(void* dst, const void* src, size_t n);
void __copy_longs_rev_aligned(void* dst, const void* src, size_t n);
void __copy_longs_aligned(void* dst, const void* src, size_t n);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_MEM_FUNCS_H */
+14
View File
@@ -0,0 +1,14 @@
#ifndef MSL_COMMON_SRC_MISC_IO_H
#define MSL_COMMON_SRC_MISC_IO_H
#ifdef __cplusplus
extern "C" {
#endif
void __stdio_atexit(void);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_MISC_IO_H */
+22
View File
@@ -0,0 +1,22 @@
#ifndef MSL_COMMON_SRC_PRINTF_H
#define MSL_COMMON_SRC_PRINTF_H
#include "MSL_C/MSL_Common/Src/ansi_files.h"
#include "Runtime.PPCEABI.H/__va_arg.h"
#ifdef __cplusplus
extern "C" {
#endif
int fprintf(FILE* stream, const char* format, ...);
int printf(const char* format, ...);
int sprintf(const char* str, const char* format, ...);
int snprintf(const char* str, size_t n, const char* format, ...);
int vsnprintf(char* str, size_t n, const char* format, va_list arg);
int vprintf(const char* format, va_list arg);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_PRINTF_H */
+14
View File
@@ -0,0 +1,14 @@
#ifndef MSL_COMMON_SRC_SCANF_H
#define MSL_COMMON_SRC_SCANF_H
#ifdef __cplusplus
extern "C" {
#endif
int __StringRead(char* str, int ch, int behavior);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_SCANF_H */
+14
View File
@@ -0,0 +1,14 @@
#ifndef MSL_COMMON_SRC_SIGNAL_H
#define MSL_COMMON_SRC_SIGNAL_H
#ifdef __cplusplus
extern "C" {
#endif
int raise(int sig);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_SIGNAL_H */
+19
View File
@@ -0,0 +1,19 @@
#ifndef _STDDEF_H_
#define _STDDEF_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned long size_t;
typedef long ptrdiff_t;
#ifndef NULL
#define NULL (0)
#endif
#ifdef __cplusplus
}
#endif
#endif
+26
View File
@@ -0,0 +1,26 @@
#ifndef MSL_COMMON_SRC_STRING_H
#define MSL_COMMON_SRC_STRING_H
#include "MSL_C/MSL_Common/Src/stddef.h"
#ifdef __cplusplus
extern "C" {
#endif
void* memcpy(void* dst, const void* src, size_t n);
void* memset(void* dst, int val, size_t n);
char* strrchr(const char* str, int c);
char* strchr(const char* str, int c);
int strncmp(const char* str1, const char* str2, size_t n);
int strcmp(const char* str1, const char* str2);
char* strcat(char* dst, const char* src);
char* strncpy(char* dst, const char* src, size_t n);
char* strcpy(char* dst, const char* src);
size_t strlen(const char* str);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_STRING_H */
+16
View File
@@ -0,0 +1,16 @@
#ifndef MSL_COMMON_SRC_STRTOUL_H
#define MSL_COMMON_SRC_STRTOUL_H
#ifdef __cplusplus
extern "C" {
#endif
long strtol(const char* str, char** endptr, int base);
unsigned long strtoul(const char* str, char** endptr, int base);
unsigned long __strtoul(const char* str, char** endptr, int base);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_STRTOUL_H */
+12
View File
@@ -0,0 +1,12 @@
#ifndef MSL_COMMON_SRC_WCHAR_IO_H
#define MSL_COMMON_SRC_WCHAR_IO_H
#include "MSL_C/MSL_Common/Src/ansi_files.h"
#ifndef __cplusplus
typedef unsigned short wchar_t;
#endif
int fwide(FILE* file, int mode);
#endif /* MSL_COMMON_SRC_WCHAR_IO_H */
@@ -0,0 +1,4 @@
#ifndef MSL_COMMON_EMBEDDED_SRC_ANSI_FP_H
#define MSL_COMMON_EMBEDDED_SRC_ANSI_FP_H
#endif /* MSL_COMMON_EMBEDDED_SRC_ANSI_FP_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_E_ACOS_H
#define MATH_DOUBLE_PRECISION_E_ACOS_H
#endif /* MATH_DOUBLE_PRECISION_E_ACOS_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_E_ASIN_H
#define MATH_DOUBLE_PRECISION_E_ASIN_H
#endif /* MATH_DOUBLE_PRECISION_E_ASIN_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_E_ATAN2_H
#define MATH_DOUBLE_PRECISION_E_ATAN2_H
#endif /* MATH_DOUBLE_PRECISION_E_ATAN2_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_E_EXP_H
#define MATH_DOUBLE_PRECISION_E_EXP_H
#endif /* MATH_DOUBLE_PRECISION_E_EXP_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_E_FMOD_H
#define MATH_DOUBLE_PRECISION_E_FMOD_H
#endif /* MATH_DOUBLE_PRECISION_E_FMOD_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_E_POW_H
#define MATH_DOUBLE_PRECISION_E_POW_H
#endif /* MATH_DOUBLE_PRECISION_E_POW_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_E_REM_PIO2_H
#define MATH_DOUBLE_PRECISION_E_REM_PIO2_H
#endif /* MATH_DOUBLE_PRECISION_E_REM_PIO2_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_E_SQRT_H
#define MATH_DOUBLE_PRECISION_E_SQRT_H
#endif /* MATH_DOUBLE_PRECISION_E_SQRT_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_K_COS_H
#define MATH_DOUBLE_PRECISION_K_COS_H
#endif /* MATH_DOUBLE_PRECISION_K_COS_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_K_REM_PIO2_H
#define MATH_DOUBLE_PRECISION_K_REM_PIO2_H
#endif /* MATH_DOUBLE_PRECISION_K_REM_PIO2_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_K_SIN_H
#define MATH_DOUBLE_PRECISION_K_SIN_H
#endif /* MATH_DOUBLE_PRECISION_K_SIN_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_K_TAN_H
#define MATH_DOUBLE_PRECISION_K_TAN_H
#endif /* MATH_DOUBLE_PRECISION_K_TAN_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_S_ATAN_H
#define MATH_DOUBLE_PRECISION_S_ATAN_H
#endif /* MATH_DOUBLE_PRECISION_S_ATAN_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_S_CEIL_H
#define MATH_DOUBLE_PRECISION_S_CEIL_H
#endif /* MATH_DOUBLE_PRECISION_S_CEIL_H */
@@ -0,0 +1,4 @@
#ifndef MATH_DOUBLE_PRECISION_S_COPYSIGN_H
#define MATH_DOUBLE_PRECISION_S_COPYSIGN_H
#endif /* MATH_DOUBLE_PRECISION_S_COPYSIGN_H */

Some files were not shown because too many files have changed in this diff Show More