mirror of
https://github.com/zeldaret/tp
synced 2026-07-09 06:53:23 -04:00
Copy JKernel (#126)
* start JSystem * JKRAram and JUTGamePad * started heap and thread * more JKernel * mostly finished JKernel * delete unused asm * JKRFileFinder * delete unused asm and match findNextFile * format * fix mtx_vec
This commit is contained in:
@@ -3,4 +3,72 @@
|
||||
|
||||
#include "dolphin/types.h"
|
||||
|
||||
#include "JSystem/JKernel/JKRAramHeap.h"
|
||||
#include "JSystem/JKernel/JKRDvdRipper.h"
|
||||
#include "JSystem/JKernel/JKRThread.h"
|
||||
|
||||
class JKRHeap;
|
||||
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 void mainRamToAram(u8*, u32, u32, JKRExpandSwitch, u32, JKRHeap*, int, u32*);
|
||||
static void 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;
|
||||
};
|
||||
|
||||
// void JKRDecompressFromAramToMainRam(u32, void*, u32, u32, u32, u32*);
|
||||
|
||||
#endif /* JKRARAM_H */
|
||||
|
||||
@@ -1,6 +1,30 @@
|
||||
#ifndef JKRARAMARCHIVE_H
|
||||
#define JKRARAMARCHIVE_H
|
||||
|
||||
#include "JSystem/JKernel/JKRArchive.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
class JKRAramArchive : public JKRArchive {
|
||||
public:
|
||||
JKRAramArchive(long, JKRArchive::EMountDirection);
|
||||
virtual ~JKRAramArchive();
|
||||
|
||||
void open(long);
|
||||
void getAramAddress_Entry(SDIFileEntry*);
|
||||
void getAramAddress(char const*);
|
||||
|
||||
/* vt[15] */ u32 getExpandedResSize(const void*); /* override */
|
||||
/* vt[16] */ void* fetchResource(SDIFileEntry*, u32*); /* override */
|
||||
/* vt[17] */ void* fetchResource(void*, u32, SDIFileEntry*, u32*); /* override */
|
||||
|
||||
public:
|
||||
static void fetchResource_subroutine(u32, u32, u8*, u32, int);
|
||||
static void fetchResource_subroutine(u32, u32, JKRHeap*, int, u8**);
|
||||
|
||||
private:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ // JKRArchive
|
||||
u8 unk[16];
|
||||
};
|
||||
|
||||
#endif /* JKRARAMARCHIVE_H */
|
||||
|
||||
@@ -3,4 +3,37 @@
|
||||
|
||||
#include "dolphin/types.h"
|
||||
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
class JKRAramHeap;
|
||||
class JKRAramBlock {
|
||||
public:
|
||||
JKRAramBlock(u32, u32, u32, u8, bool);
|
||||
virtual ~JKRAramBlock();
|
||||
|
||||
JKRAramBlock* allocHead(u32, u8, JKRAramHeap*);
|
||||
JKRAramBlock* allocTail(u32, u8, JKRAramHeap*);
|
||||
|
||||
void* getAddress() const { return (void*)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 */
|
||||
|
||||
@@ -1,6 +1,52 @@
|
||||
#ifndef JKRARAMHEAP_H
|
||||
#define JKRARAMHEAP_H
|
||||
|
||||
#include "JSystem/JKernel/JKRAramBlock.h"
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
#include "dolphin/os/OS.h"
|
||||
#include "dolphin/types.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);
|
||||
|
||||
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 */
|
||||
|
||||
@@ -1,6 +1,73 @@
|
||||
#ifndef JKRARAMPIECE_H
|
||||
#define JKRARAMPIECE_H
|
||||
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
#include "dolphin/ar/arq.h"
|
||||
#include "dolphin/os/OS.h"
|
||||
#include "dolphin/types.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 */
|
||||
|
||||
@@ -1,6 +1,69 @@
|
||||
#ifndef JKRARAMSTREAM_H
|
||||
#define JKRARAMSTREAM_H
|
||||
|
||||
#include "JSystem/JKernel/JKRThread.h"
|
||||
#include "JSystem/JSupport/JSUFileStream.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
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 */
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
#ifndef JKRARCHIVE_H
|
||||
#define JKRARCHIVE_H
|
||||
|
||||
#include "JSystem/JKernel/JKRCompression.h"
|
||||
#include "JSystem/JKernel/JKRDecomp.h"
|
||||
#include "JSystem/JKernel/JKRFileLoader.h"
|
||||
#include "global.h"
|
||||
|
||||
struct SArcHeader {
|
||||
u32 signature;
|
||||
u32 file_length;
|
||||
u32 header_length;
|
||||
u32 file_data_offset;
|
||||
u32 file_data_length;
|
||||
u32 field_0x14;
|
||||
u32 field_0x18;
|
||||
u32 field_0x1c;
|
||||
};
|
||||
|
||||
struct SArcDataInfo {
|
||||
u32 num_nodes;
|
||||
u32 node_offset;
|
||||
u32 num_file_entries;
|
||||
u32 file_entry_offset;
|
||||
u32 string_table_length;
|
||||
u32 string_table_offset;
|
||||
u16 next_free_file_id;
|
||||
bool sync_file_ids_and_indices;
|
||||
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(SArcHeader* header) {
|
||||
u8* fileLength = (u8*)&header->file_length;
|
||||
return read_big_endian_u32(fileLength);
|
||||
}
|
||||
|
||||
extern u32 sCurrentDirID__10JKRArchive; // JKRArchive::sCurrentDirID
|
||||
|
||||
class JKRHeap;
|
||||
class JKRDvdFile;
|
||||
class JKRArchive : public JKRFileLoader {
|
||||
public:
|
||||
struct SDirEntry {
|
||||
union {
|
||||
u32 type;
|
||||
struct {
|
||||
u8 flags;
|
||||
u8 padding;
|
||||
u16 id;
|
||||
} other;
|
||||
};
|
||||
|
||||
const char* name;
|
||||
u16 field_0x8;
|
||||
u16 num_entries;
|
||||
s32 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; }
|
||||
bool isYAZ0Compressed() const { return (getFlags() & 0x80) != 0; }
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
u32 getMountMode() const { return mMountMode; }
|
||||
|
||||
protected:
|
||||
bool isSameName(CArcName&, u32, u16) const;
|
||||
SDirEntry* findResType(u32) const;
|
||||
SDirEntry* findDirectory(const char*, u32) const;
|
||||
SDIFileEntry* findTypeResource(u32, const char*) const;
|
||||
SDIFileEntry* findFsResource(const char*, u32) const;
|
||||
SDIFileEntry* findIdxResource(u32) const;
|
||||
SDIFileEntry* findNameResource(const char*) 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;
|
||||
|
||||
protected:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ // JKRFileLoader
|
||||
/* 0x38 */ JKRHeap* mHeap;
|
||||
/* 0x3C */ u8 mMountMode;
|
||||
/* 0x3D */ u8 field_0x3d[3];
|
||||
/* 0x40 */ s32 mEntryNum;
|
||||
/* 0x44 */ SArcDataInfo* mArcInfoBlock;
|
||||
/* 0x48 */ SDirEntry* mNodes;
|
||||
/* 0x4C */ SDIFileEntry* mFiles;
|
||||
/* 0x50 */ s32* mExpandedSize;
|
||||
/* 0x54 */ char* mStringTable;
|
||||
/* 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);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,35 @@
|
||||
#ifndef JKRASSERTHEAP_H
|
||||
#define JKRASSERTHEAP_H
|
||||
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "dolphin/types.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 u8 do_changeGroupID(u8 param_1); /* override */
|
||||
/* vt[20] */ virtual u8 do_getCurrentGroupId(void); /* override */
|
||||
|
||||
public:
|
||||
static JKRAssertHeap* create(JKRHeap*);
|
||||
};
|
||||
|
||||
#endif /* JKRASSERTHEAP_H */
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
#ifndef JKRCOMPARCHIVE_H
|
||||
#define JKRCOMPARCHIVE_H
|
||||
|
||||
#include "JSystem/JKernel/JKRArchive.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
class JKRCompArchive : public JKRArchive {
|
||||
public:
|
||||
JKRCompArchive(long, JKRArchive::EMountDirection);
|
||||
virtual ~JKRCompArchive();
|
||||
|
||||
void open(long);
|
||||
|
||||
/* vt[09] */ void removeResourceAll(void); /* override */
|
||||
/* vt[10] */ bool removeResource(void*); /* override */
|
||||
|
||||
/* vt[15] */ u32 getExpandedResSize(const void*); /* override */
|
||||
/* vt[16] */ void* fetchResource(SDIFileEntry*, u32*); /* override */
|
||||
/* vt[17] */ void* fetchResource(void*, u32, SDIFileEntry*, u32*); /* override */
|
||||
|
||||
public:
|
||||
private:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ // JKRArchive
|
||||
u8 unk[36];
|
||||
};
|
||||
|
||||
#endif /* JKRCOMPARCHIVE_H */
|
||||
|
||||
@@ -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
|
||||
@@ -1,6 +1,66 @@
|
||||
#ifndef JKRDECOMP_H
|
||||
#define JKRDECOMP_H
|
||||
|
||||
#include "JSystem/JKernel/JKRCompression.h"
|
||||
#include "JSystem/JKernel/JKRThread.h"
|
||||
#include "dolphin/types.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);
|
||||
}
|
||||
|
||||
#endif /* JKRDECOMP_H */
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
#ifndef JKRDISPOSER_H
|
||||
#define JKRDISPOSER_H
|
||||
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
class JKRHeap;
|
||||
class JKRDisposer {
|
||||
public:
|
||||
JKRDisposer();
|
||||
virtual ~JKRDisposer();
|
||||
|
||||
public:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ JKRHeap* mHeap;
|
||||
/* 0x08 */ JSULink<JKRDisposer> mLink;
|
||||
};
|
||||
|
||||
#endif /* JKRDISPOSER_H */
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
#ifndef JKRDVDARAMRIPPER_H
|
||||
#define JKRDVDARAMRIPPER_H
|
||||
|
||||
#include "JSystem/JKernel/JKRDvdRipper.h"
|
||||
#include "JSystem/JSupport/JSUFileStream.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
class JKRADCommand {
|
||||
public:
|
||||
JKRADCommand();
|
||||
~JKRADCommand();
|
||||
};
|
||||
|
||||
class JKRDvdFile;
|
||||
class JKRDvdAramRipper {
|
||||
public:
|
||||
static void loadToAram(long, u32, JKRExpandSwitch, u32, u32, u32*);
|
||||
static void loadToAram(JKRDvdFile*, u32, JKRExpandSwitch, u32, u32, u32*);
|
||||
static void loadToAram_Async(JKRDvdFile*, u32, JKRExpandSwitch, void (*)(u32), u32, u32, u32*);
|
||||
static void callCommand_Async(JKRADCommand*);
|
||||
static void syncAram(JKRADCommand*, int);
|
||||
|
||||
// TODO: fix type
|
||||
static u8 sDvdAramAsyncList[12];
|
||||
static u32 sSZSBufferSize;
|
||||
};
|
||||
|
||||
#endif /* JKRDVDARAMRIPPER_H */
|
||||
|
||||
@@ -1,6 +1,33 @@
|
||||
#ifndef JKRDVDARCHIVE_H
|
||||
#define JKRDVDARCHIVE_H
|
||||
|
||||
#include "JSystem/JKernel/JKRArchive.h"
|
||||
#include "dolphin/types.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 */
|
||||
|
||||
@@ -1,6 +1,60 @@
|
||||
#ifndef JKRDVDFILE_H
|
||||
#define JKRDVDFILE_H
|
||||
|
||||
#include "JSystem/JKernel/JKRFile.h"
|
||||
#include "dolphin/dvd/dvd.h"
|
||||
#include "dolphin/os/OS.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
class JKRADCommand;
|
||||
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; }
|
||||
const DVDFileInfo& getFileInfo() const { 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 */ u32 field_0x4c;
|
||||
/* 0x50 */ u32 field_0x50;
|
||||
/* 0x54 */ u32 field_0x54;
|
||||
/* 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 */
|
||||
|
||||
@@ -1,6 +1,46 @@
|
||||
#ifndef JKRDVDRIPPER_H
|
||||
#define JKRDVDRIPPER_H
|
||||
|
||||
#include "JSystem/JKernel/JKRDecomp.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
enum JKRExpandSwitch {
|
||||
EXPAND_SWITCH_UNKNOWN0 = 0,
|
||||
EXPAND_SWITCH_UNKNOWN1 = 1,
|
||||
EXPAND_SWITCH_UNKNOWN2 = 2,
|
||||
};
|
||||
|
||||
class JKRHeap;
|
||||
class JKRDvdFile;
|
||||
class JKRDvdRipper {
|
||||
public:
|
||||
// TODO: fix type
|
||||
static u8 sDvdAsyncList[12];
|
||||
static u32 sSZSBufferSize;
|
||||
|
||||
enum EAllocDirection {
|
||||
UNKNOWN_EALLOC_DIRECTION = 0,
|
||||
ALLOC_DIRECTION_FORWARD = 1,
|
||||
ALLOC_DIRECTION_BACKWARD = 2,
|
||||
};
|
||||
|
||||
static void* loadToMainRAM(char const*, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection,
|
||||
u32, JKRCompression*, u32*);
|
||||
static void* loadToMainRAM(long, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection, u32,
|
||||
JKRCompression*, u32*);
|
||||
static void* loadToMainRAM(JKRDvdFile*, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection,
|
||||
u32, JKRCompression*, u32*);
|
||||
|
||||
u8 isErrorRetry(void);
|
||||
};
|
||||
|
||||
// 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, JKRCompression* compression, u32* returnSize) {
|
||||
return JKRDvdRipper::loadToMainRAM(entryNum, dst, expandSwitch, dstLength, heap, allocDirection,
|
||||
offset, compression, returnSize);
|
||||
}
|
||||
|
||||
#endif /* JKRDVDRIPPER_H */
|
||||
|
||||
@@ -1,6 +1,93 @@
|
||||
#ifndef JKREXPHEAP_H
|
||||
#define JKREXPHEAP_H
|
||||
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
class JKRExpHeap : public JKRHeap {
|
||||
public:
|
||||
class CMemBlock {
|
||||
public:
|
||||
void initiate(CMemBlock*, CMemBlock*, u32, u8, u8);
|
||||
void allocFore(u32, u8, u8, u8, u8);
|
||||
void allocBack(u32, u8, u8, u8, u8);
|
||||
void free(JKRExpHeap*);
|
||||
void getHeapBlock(void*);
|
||||
|
||||
void newGroupId(u8 groupId) { this->mGroupId = groupId; }
|
||||
bool isValid() const { return this->mMagic == 0x484d; }
|
||||
bool _isTempMemBlock() const { return (this->mFlags & 0x80) ? true : false; }
|
||||
int getAlignment() const { return this->mFlags & 0x7f; }
|
||||
void* getContent() const { return (void*)(this + 1); }
|
||||
CMemBlock* getPrevBlock() const { return this->mPrev; }
|
||||
CMemBlock* getNextBlock() const { return this->mNext; }
|
||||
u32 getSize() const { return this->size; }
|
||||
static CMemBlock* getBlock(void* data) { return (CMemBlock*)((u32)data + -0x10); }
|
||||
|
||||
private:
|
||||
u16 mMagic;
|
||||
u8 mFlags; // a|bbbbbbb a=temporary b=alignment
|
||||
u8 mGroupId;
|
||||
u32 size;
|
||||
CMemBlock* mPrev;
|
||||
CMemBlock* mNext;
|
||||
};
|
||||
|
||||
protected:
|
||||
JKRExpHeap(void*, u32, JKRHeap*, bool);
|
||||
virtual ~JKRExpHeap();
|
||||
|
||||
void allocFromHead(u32, int);
|
||||
void allocFromHead(u32);
|
||||
void allocFromTail(u32, int);
|
||||
void allocFromTail(u32);
|
||||
void appendUsedList(CMemBlock*);
|
||||
void setFreeBlock(CMemBlock*, CMemBlock*, CMemBlock*);
|
||||
void removeFreeBlock(CMemBlock*);
|
||||
void removeUsedBlock(CMemBlock*);
|
||||
void recycleFreeBlock(CMemBlock*);
|
||||
void joinTwoBlocks(CMemBlock*);
|
||||
|
||||
public:
|
||||
s32 getUsedSize(u8) const;
|
||||
s32 getTotalUsedSize(void) const;
|
||||
CMemBlock* getHeadUsedList() const { return mHeadUsedList; }
|
||||
|
||||
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 u8 do_changeGroupID(u8 newGroupID); /* override */
|
||||
/* vt[20] */ virtual u8 do_getCurrentGroupId(); /* override */
|
||||
/* vt[21] */ virtual void state_register(JKRHeap::TState*, u32) const; /* override */
|
||||
/* vt[22] */ virtual bool state_compare(JKRHeap::TState const&,
|
||||
JKRHeap::TState const&) const; /* override */
|
||||
|
||||
private:
|
||||
u32 field_0x6c;
|
||||
u32 field_0x70;
|
||||
u32 field_0x74;
|
||||
CMemBlock* mHeadFreeList;
|
||||
CMemBlock* mTailFreeList;
|
||||
CMemBlock* mHeadUsedList;
|
||||
CMemBlock* mTailUsedList;
|
||||
|
||||
public:
|
||||
static void createRoot(int, bool);
|
||||
static void create(u32, JKRHeap*, bool);
|
||||
static void create(void*, u32, JKRHeap*, bool);
|
||||
};
|
||||
|
||||
#endif /* JKREXPHEAP_H */
|
||||
|
||||
@@ -1,6 +1,30 @@
|
||||
#ifndef JKRFILE_H
|
||||
#define JKRFILE_H
|
||||
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
#include "dolphin/types.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 */
|
||||
|
||||
@@ -1,6 +1,63 @@
|
||||
#ifndef JKRFILECACHE_H
|
||||
#define JKRFILECACHE_H
|
||||
|
||||
#include "JSystem/JKernel/JKRFileLoader.h"
|
||||
#include "dolphin/types.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*);
|
||||
};
|
||||
|
||||
#endif /* JKRFILECACHE_H */
|
||||
|
||||
@@ -1,6 +1,73 @@
|
||||
#ifndef JKRFILEFINDER_H
|
||||
#define JKRFILEFINDER_H
|
||||
|
||||
#include "dolphin/dvd/dvd.h"
|
||||
#include "dolphin/types.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 */
|
||||
|
||||
@@ -1,6 +1,57 @@
|
||||
#ifndef JKRFILELOADER_H
|
||||
#define JKRFILELOADER_H
|
||||
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
#include "JSystem/JSupport/JSUList.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;
|
||||
};
|
||||
|
||||
#endif /* JKRFILELOADER_H */
|
||||
|
||||
@@ -1,6 +1,215 @@
|
||||
#ifndef JKRHEAP_H
|
||||
#define JKRHEAP_H
|
||||
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
#include "dolphin/os/OS.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
class JKRHeap;
|
||||
typedef void (*JKRErrorHandler)(void*, u32, int);
|
||||
|
||||
class JKRHeap : public JKRDisposer {
|
||||
public:
|
||||
class TState {
|
||||
public:
|
||||
u32 mUsedSize;
|
||||
u32 mCheckCode;
|
||||
u32 mBuf;
|
||||
u32 field_0xc;
|
||||
JKRHeap* mHeap;
|
||||
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*, u32, JKRHeap*, bool);
|
||||
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();
|
||||
u8 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 u8 do_changeGroupID(u8 newGroupID);
|
||||
/* vt[20] */ virtual u8 do_getCurrentGroupId();
|
||||
/* vt[21] */ virtual void state_register(JKRHeap::TState*, unsigned long) const;
|
||||
/* vt[22] */ virtual bool state_compare(JKRHeap::TState const&, JKRHeap::TState const&) const;
|
||||
/* vt[23] */ virtual void state_dump(JKRHeap::TState const&) 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); }
|
||||
|
||||
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**, u32*, int);
|
||||
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* 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; }
|
||||
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;
|
||||
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 JKRFree(void* ptr) {
|
||||
JKRHeap::free(ptr, NULL);
|
||||
}
|
||||
|
||||
inline JKRHeap* JKRGetSystemHeap() {
|
||||
return JKRHeap::getSystemHeap();
|
||||
}
|
||||
|
||||
inline JKRHeap* JKRGetCurrentHeap() {
|
||||
return JKRHeap::getCurrentHeap();
|
||||
}
|
||||
|
||||
#endif /* JKRHEAP_H */
|
||||
|
||||
@@ -1,6 +1,42 @@
|
||||
#ifndef JKRMEMARCHIVE_H
|
||||
#define JKRMEMARCHIVE_H
|
||||
|
||||
#include "JSystem/JKernel/JKRArchive.h"
|
||||
#include "dolphin/types.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);
|
||||
|
||||
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 */
|
||||
|
||||
@@ -1,6 +1,60 @@
|
||||
#ifndef JKRSOLIDHEAP_H
|
||||
#define JKRSOLIDHEAP_H
|
||||
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "dolphin/types.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();
|
||||
|
||||
s32 adjustSize(void);
|
||||
void* allocFromHead(u32, int);
|
||||
void* allocFromTail(u32, int);
|
||||
|
||||
s32 getUsedSize() { return mSize - 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 void 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:
|
||||
static JKRSolidHeap* create(u32, JKRHeap*, bool);
|
||||
};
|
||||
|
||||
#endif /* JKRSOLIDHEAP_H */
|
||||
|
||||
@@ -1,6 +1,116 @@
|
||||
#ifndef JKRTHREAD_H
|
||||
#define JKRTHREAD_H
|
||||
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
#include "dolphin/os/OS.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
class JKRThreadName_;
|
||||
class JUTConsole;
|
||||
class JKRHeap;
|
||||
class JKRThread : JKRDisposer {
|
||||
public:
|
||||
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; }
|
||||
u8 getLoadInfo() const { return field_0x60; }
|
||||
JKRHeap* getCurrentHeap() const { return mCurrentHeap; }
|
||||
JKRHeap* getCurrentHeapError() const { return mCurrentHeapError; }
|
||||
|
||||
protected:
|
||||
void resume() { OSResumeThread(mThreadRecord); }
|
||||
void sendMessage(OSMessage message) {
|
||||
OSSendMessage(&mMessageQueue, message, OS_MESSAGE_NON_BLOCKING);
|
||||
}
|
||||
void sendMessageBlock(OSMessage message) {
|
||||
OSSendMessage(&mMessageQueue, message, OS_MESSAGE_BLOCKING);
|
||||
}
|
||||
OSMessage waitMessage() {
|
||||
OSMessage message;
|
||||
OSReceiveMessage(&mMessageQueue, &message, OS_MESSAGE_NON_BLOCKING);
|
||||
return message;
|
||||
}
|
||||
OSMessage waitMessageBlock() {
|
||||
OSMessage message;
|
||||
OSReceiveMessage(&mMessageQueue, &message, OS_MESSAGE_BLOCKING);
|
||||
return message;
|
||||
}
|
||||
void jamMessageBlock(OSMessage message) {
|
||||
OSJamMessage(&mMessageQueue, message, OS_MESSAGE_BLOCKING);
|
||||
}
|
||||
|
||||
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 */ u8 field_0x60;
|
||||
/* 0x61 */ u8 padding_0x61[3];
|
||||
/* 0x64 */ u32 mCost;
|
||||
/* 0x68 */ u32 mSwitchCount;
|
||||
/* 0x6C */ u32 field_0x6c;
|
||||
/* 0x70 */ u32 field_0x70;
|
||||
/* 0x74 */ JKRHeap* mCurrentHeap;
|
||||
/* 0x78 */ JKRHeap* 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];
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
// TODO: fix types
|
||||
static u8 sManager[4];
|
||||
static u8 sTotalCount[4];
|
||||
static u8 sTotalStart[4];
|
||||
static u8 mUserPreCallback[4];
|
||||
static u8 mUserPostCallback[4];
|
||||
|
||||
public:
|
||||
JKRHeap* heap;
|
||||
u8 field_0x8[4];
|
||||
u32 field_0xC[2];
|
||||
u8 field_0x14[4];
|
||||
u32 field_0x18;
|
||||
u32 field_0x1C;
|
||||
u32 field_0x20;
|
||||
u32 field_0x24;
|
||||
};
|
||||
|
||||
struct JKRTask {
|
||||
static JSUList<JKRTask> sTaskList;
|
||||
static u8 sEndMesgQueue[32];
|
||||
};
|
||||
|
||||
#endif /* JKRTHREAD_H */
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
#ifndef JSUFILESTREAM_H
|
||||
#define JSUFILESTREAM_H
|
||||
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
struct JKRFile;
|
||||
|
||||
class JSUFileInputStream : public JSURandomInputStream {
|
||||
public:
|
||||
virtual ~JSUFileInputStream();
|
||||
|
||||
// TODO: fix return values
|
||||
/* 802DC638 */ JSUFileInputStream(JKRFile*);
|
||||
/* 802DC67C */ s32 readData(void*, s32);
|
||||
/* 802DC74C */ void seekPos(s32, JSUStreamSeekFrom);
|
||||
/* 802DC82C */ s32 getLength() const;
|
||||
/* 802DC85C */ s32 getPosition() const;
|
||||
};
|
||||
|
||||
#endif /* JSUFILESTREAM_H */
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
#ifndef JSUINPUTSTREAM_H
|
||||
#define JSUINPUTSTREAM_H
|
||||
|
||||
#include "JSystem/JSupport/JSUIosBase.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
struct JSUStreamSeekFrom {};
|
||||
|
||||
class JSUInputStream : public JSUIosBase {
|
||||
public:
|
||||
JSUInputStream();
|
||||
virtual ~JSUInputStream();
|
||||
|
||||
/* vt[3] */ virtual s32 getAvailable() const = 0;
|
||||
/* vt[4] */ virtual s32 skip(s32);
|
||||
/* vt[5] */ virtual s32 readData(void*, s32) = 0;
|
||||
|
||||
// TODO: return value probably wrong
|
||||
/* 802DC298 */ void read(void*, s32);
|
||||
};
|
||||
|
||||
#endif /* JSUINPUTSTREAM_H */
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,4 +3,255 @@
|
||||
|
||||
#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) {}
|
||||
|
||||
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.other; }
|
||||
|
||||
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
|
||||
//
|
||||
|
||||
#define JSU_TREE_FROM_LINK(T, LINK) (JSUTree<T>*)(((u8*)(LINK)) - 12)
|
||||
#define JSU_TREE_LINK_IF_NOT_NULL(TREE) \
|
||||
if (TREE) { \
|
||||
TREE = (JSUTree<T>*)(&(TREE)->mLink); \
|
||||
}
|
||||
|
||||
#define _JSU_TREE_AS_LINK(TREE) ((JSULink<T>*)(TREE))
|
||||
|
||||
template <typename T>
|
||||
class JSUTree {
|
||||
public:
|
||||
JSUTree(T* owner) : mList(), mLink(owner) {}
|
||||
~JSUTree() {}
|
||||
|
||||
bool appendChild(JSUTree<T>* child) {
|
||||
JSU_TREE_LINK_IF_NOT_NULL(child);
|
||||
return this->mList.append(_JSU_TREE_AS_LINK(child));
|
||||
}
|
||||
|
||||
bool removeChild(JSUTree<T>* child) {
|
||||
JSU_TREE_LINK_IF_NOT_NULL(child);
|
||||
return this->mList.remove(_JSU_TREE_AS_LINK(child));
|
||||
}
|
||||
|
||||
bool insertChild(JSUTree<T>* before, JSUTree<T>* child) {
|
||||
JSU_TREE_LINK_IF_NOT_NULL(before);
|
||||
JSU_TREE_LINK_IF_NOT_NULL(child);
|
||||
return this->mList.insert(_JSU_TREE_AS_LINK(before), _JSU_TREE_AS_LINK(child));
|
||||
}
|
||||
|
||||
JSUTree<T>* getEndChild() const { return NULL; }
|
||||
|
||||
JSUTree<T>* getFirstChild() const {
|
||||
JSULink<T>* link = this->mList.getFirst();
|
||||
return link ? JSU_TREE_FROM_LINK(T, link) : (JSUTree<T>*)link;
|
||||
}
|
||||
|
||||
JSUTree<T>* getLastChild() const {
|
||||
JSULink<T>* link = this->mList.getLast();
|
||||
return link ? JSU_TREE_FROM_LINK(T, link) : (JSUTree<T>*)link;
|
||||
}
|
||||
|
||||
JSUTree<T>* getNextChild() const {
|
||||
JSULink<T>* link = this->mLink.getNext();
|
||||
return link ? JSU_TREE_FROM_LINK(T, link) : (JSUTree<T>*)link;
|
||||
}
|
||||
|
||||
JSUTree<T>* getPrevChild() const {
|
||||
JSULink<T>* link = this->mLink.getPrev();
|
||||
return link ? JSU_TREE_FROM_LINK(T, link) : (JSUTree<T>*)link;
|
||||
}
|
||||
|
||||
u32 getNumChildren() const { return this->mList.getNumLinks(); }
|
||||
|
||||
T* getObject() const { return this->mLink.getObject(); }
|
||||
|
||||
JSUTree<T>* getParent() const { return (JSUTree<T>*)this->mLink.getList(); }
|
||||
|
||||
private:
|
||||
JSUList<T> mList;
|
||||
JSULink<T> mLink;
|
||||
};
|
||||
|
||||
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,25 @@
|
||||
#ifndef JSURANDOMINPUTSTREAM_H_
|
||||
#define JSURANDOMINPUTSTREAM_H_
|
||||
|
||||
#include "JSystem/JSupport/JSUInputStream.h"
|
||||
#include "dolphin/types.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 s32 readData(void*, s32) = 0;
|
||||
/* vt[6] */ virtual s32 getLength() const = 0;
|
||||
/* vt[7] */ virtual s32 getPosition() const = 0;
|
||||
/* vt[7] */ virtual s32 seekPos() = 0;
|
||||
|
||||
// TODO: fix return types
|
||||
/* 802DC370 */ void align(s32);
|
||||
/* 802DC458 */ void peek(void*, s32);
|
||||
/* 802DC4DC */ void seek(s32, JSUStreamSeekFrom);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,4 +3,14 @@
|
||||
|
||||
#include "dolphin/types.h"
|
||||
|
||||
// TODO: make it a namespace
|
||||
struct JUTAssertion {
|
||||
/* 802E495C */ static void create();
|
||||
/* 802E4960 */ static void flush_subroutine();
|
||||
/* 802E499C */ static void flushMessage();
|
||||
/* 802E4A54 */ static void flushMessage_dbPrint();
|
||||
/* 802E4C34 */ static void setVisible(bool);
|
||||
/* 802E4C3C */ static void setMessageCount(int);
|
||||
};
|
||||
|
||||
#endif /* JUTASSERT_H */
|
||||
|
||||
@@ -1,6 +1,67 @@
|
||||
#ifndef JUTEXCEPTION_H
|
||||
#define JUTEXCEPTION_H
|
||||
|
||||
#include "dolphin/gx/GX.h"
|
||||
#include "dolphin/os/OS.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
struct _GXRenderModeObj;
|
||||
struct _GXGamma {};
|
||||
|
||||
struct JUTExternalFB {
|
||||
/* 802E40CC */ JUTExternalFB(_GXRenderModeObj*, _GXGamma, void*, u32);
|
||||
};
|
||||
|
||||
struct JUTDirectPrint {
|
||||
/* 802E456C */ void changeFrameBuffer(void*, u16, u16);
|
||||
};
|
||||
|
||||
struct JUTException {
|
||||
struct EInfoPage {};
|
||||
|
||||
// TODO: return types are probably wrong
|
||||
/* 802E1D5C */ JUTException(JUTDirectPrint*);
|
||||
/* 802E1E40 */ void create(JUTDirectPrint*);
|
||||
/* 802E1EA8 */ void run();
|
||||
/* 802E1FCC */ void errorHandler(u16, OSContext*, u32, u32);
|
||||
/* 802E20C0 */ void panic_f_va(char const*, int, char const*, __va_list_struct*);
|
||||
/* 802E21FC */ static void panic_f(char const*, int, char const*, ...);
|
||||
/* 802E227C */ void setFPException(u32);
|
||||
/* 802E22C4 */ void showFloatSub(int, f32);
|
||||
/* 802E2454 */ void showFloat(OSContext*);
|
||||
/* 802E2578 */ void searchPartialModule(u32, u32*, u32*, u32*, u32*);
|
||||
/* 802E26B0 */ void showStack(OSContext*);
|
||||
/* 802E27B0 */ void showMainInfo(u16, OSContext*, u32, u32);
|
||||
/* 802E2A84 */ void showGPR(OSContext*);
|
||||
/* 802E2B44 */ void showMapInfo_subroutine(u32, bool);
|
||||
/* 802E2CA0 */ void showGPRMap(OSContext*);
|
||||
/* 802E2DAC */ void showSRR0Map(OSContext*);
|
||||
/* 802E2E70 */ void printDebugInfo(JUTException::EInfoPage, u16, OSContext*, u32, u32);
|
||||
/* 802E2F18 */ void isEnablePad() const;
|
||||
/* 802E2F54 */ void readPad(u32*, u32*);
|
||||
/* 802E34C0 */ void printContext(u16, OSContext*, u32, u32);
|
||||
/* 802E3980 */ void waitTime(s32);
|
||||
/* 802E3A08 */ void createFB();
|
||||
/* 802E3AEC */ void setPreUserCallback(void (*)(u16, OSContext*, u32, u32));
|
||||
/* 802E3AFC */ void setPostUserCallback(void (*)(u16, OSContext*, u32, u32));
|
||||
/* 802E3B0C */ void appendMapFile(char const*);
|
||||
/* 802E3BA0 */ void queryMapAddress(char*, u32, s32, u32*, u32*, char*, u32, bool, bool);
|
||||
/* 802E3C90 */ void queryMapAddress_single(char*, u32, s32, u32*, u32*, char*, u32, bool, bool);
|
||||
/* 802E3FEC */ void createConsole(void*, u32);
|
||||
/* 802E40EC */ ~JUTException();
|
||||
|
||||
static u8 sMessageQueue[32];
|
||||
static void* sCpuExpName[17];
|
||||
static u8 sMapFileList[12 + 4 /* padding */];
|
||||
static u8 sMessageBuffer[4 + 4 /* padding */];
|
||||
static u8 sErrorManager[4];
|
||||
static u8 sPreUserCallback[4];
|
||||
static u8 sPostUserCallback[4];
|
||||
static u8 sConsoleBuffer[4];
|
||||
static u8 sConsoleBufferSize[4];
|
||||
static u8 sConsole[4];
|
||||
static u8 msr[4];
|
||||
static u8 fpscr[4];
|
||||
};
|
||||
|
||||
#endif /* JUTEXCEPTION_H */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef JUTFONT_H
|
||||
#define JUTFONT_H
|
||||
|
||||
#include "dolphin/gx/GXTexture.h"
|
||||
#include "dolphin/gx/GX.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
namespace JUtility {
|
||||
@@ -21,4 +21,45 @@ struct TColor : _GXColor {
|
||||
|
||||
} // namespace JUtility
|
||||
|
||||
class JUTFont {
|
||||
public:
|
||||
JUTFont();
|
||||
virtual ~JUTFont() {}
|
||||
|
||||
struct TWidth {};
|
||||
|
||||
/* 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 u16 getLeading() const = 0;
|
||||
/* 0x1c */ virtual u16 getAscent() const = 0;
|
||||
/* 0x20 */ virtual u16 getDescent() const = 0;
|
||||
/* 0x24 */ virtual u32 getHeight() const = 0;
|
||||
/* 0x28 */ virtual u32 getWidth() const = 0;
|
||||
/* 0x2c */ virtual void getWidthEntry(int i_no, TWidth* width) const;
|
||||
/* 0x30 */ virtual u32 getCellWidth() const;
|
||||
/* 0x34 */ virtual u32 getCellHeight() const;
|
||||
/* 0x38 */ virtual u32 getFontType() const = 0;
|
||||
/* 0x3c */ virtual void 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 a1, f32 a2, f32 a3, f32 a4, const char* a5, u32 usz, bool a7);
|
||||
|
||||
u8 unk4;
|
||||
bool unk5;
|
||||
int unk8;
|
||||
JUtility::TColor mColor1;
|
||||
JUtility::TColor mColor2;
|
||||
JUtility::TColor mColor3;
|
||||
JUtility::TColor mColor4;
|
||||
int unk1C;
|
||||
};
|
||||
|
||||
#endif /* JUTFONT_H */
|
||||
|
||||
@@ -1,6 +1,186 @@
|
||||
#ifndef JUTGAMEPAD_H
|
||||
#define JUTGAMEPAD_H
|
||||
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
#include "dolphin/os/OS.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,
|
||||
};
|
||||
}
|
||||
|
||||
struct JUTGamePad : public JKRDisposer {
|
||||
public:
|
||||
// TODO: fix types
|
||||
// static JSUList<JUTGamePad> mPadList;
|
||||
static u8 mPadList[12];
|
||||
static PADStatus mPadStatus[4];
|
||||
static u8 mPadButton[192];
|
||||
static u8 mPadMStick[64];
|
||||
static u8 mPadSStick[64];
|
||||
static u32 sStickMode;
|
||||
static u32 sClampMode;
|
||||
static u8 mPadAssign[4];
|
||||
static u8 sSuppressPadReset[4];
|
||||
static s32 sAnalogMode;
|
||||
static u8 sRumbleSupported[4];
|
||||
|
||||
enum EStickMode {};
|
||||
enum EWhichStick {};
|
||||
// typedef u32 EPadPort;
|
||||
enum EPadPort { Port_1 = 0, Port_2 = 0, Port_3 = 0, Port_4 = 0 };
|
||||
JUTGamePad(JUTGamePad::EPadPort port);
|
||||
virtual ~JUTGamePad();
|
||||
|
||||
void initList();
|
||||
static s32 init();
|
||||
void clear();
|
||||
void read();
|
||||
void assign();
|
||||
void checkResetCallback(OSTime unk); // todo: weird arg
|
||||
void update();
|
||||
void stopPatternedRumble() { this->rumble.stopPatternedRumble(this->pad_port); }
|
||||
static void checkResetSwitch();
|
||||
static void clearForReset();
|
||||
static JUTGamePad* getGamePad(int pad_index);
|
||||
static bool recalibrate(/*PADMask*/ u32 pad_mask);
|
||||
|
||||
struct CButton {
|
||||
CButton();
|
||||
void clear();
|
||||
u32 update(PADStatus const*, u32 unk);
|
||||
void setRepeat(u32 unk0, u32 unk1, u32 unk2);
|
||||
|
||||
u32 mButtonFlags;
|
||||
|
||||
u32 mPressedButtonFlags;
|
||||
u32 mReleasedButtonFlags;
|
||||
|
||||
u8 mAnalogARaw;
|
||||
u8 mAnalogBRaw;
|
||||
u8 mTriggerLeftRaw;
|
||||
u8 mTriggerRightRaw;
|
||||
f32 mTriggerLeft;
|
||||
f32 mTriggerRight;
|
||||
|
||||
u32 field_0x18; // padding?
|
||||
u32 field_0x1c;
|
||||
u32 field_0x20;
|
||||
u32 field_0x24;
|
||||
u32 field_0x28;
|
||||
u32 field_0x2c;
|
||||
};
|
||||
|
||||
struct C3ButtonReset {
|
||||
// TODO: fix types
|
||||
static u32 sResetPattern;
|
||||
static u32 sResetMaskPattern;
|
||||
static callbackFn sCallback;
|
||||
static void* sCallbackArg;
|
||||
static OSTime sThreshold;
|
||||
static s32 sResetOccurredPort;
|
||||
};
|
||||
|
||||
struct CStick {
|
||||
static f32 sPressPoint;
|
||||
static f32 sReleasePoint;
|
||||
|
||||
CStick();
|
||||
void clear();
|
||||
void clear(JUTGamePad* pad);
|
||||
u32 update(s8 unk0, s8 unk1, JUTGamePad::EStickMode mode, JUTGamePad::EWhichStick stick,
|
||||
u32 unk2);
|
||||
u32 getButton(u32 unk);
|
||||
|
||||
float mPosX;
|
||||
float mPosY;
|
||||
float mValue;
|
||||
s16 mAngle;
|
||||
s8 field_0xe;
|
||||
s8 field_0xf;
|
||||
};
|
||||
|
||||
struct CRumble {
|
||||
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(/*PADMask*/ u32 pad_mask);
|
||||
|
||||
u32 field_0x0;
|
||||
u32 field_0x4;
|
||||
u8* field_0x8;
|
||||
u32 field_0xc;
|
||||
u8* field_0x10;
|
||||
};
|
||||
|
||||
CButton buttons;
|
||||
CStick control_stick;
|
||||
CStick c_stick;
|
||||
CRumble rumble;
|
||||
s16 pad_port;
|
||||
s8 error_value;
|
||||
u8 pad0;
|
||||
JSUPtrLink ptr_link;
|
||||
u8 unk0[8];
|
||||
u8 field_0x98;
|
||||
u8 unk1[3];
|
||||
u8 reset_flag;
|
||||
u8 pad1[3];
|
||||
OSTime reset_time;
|
||||
u8 field_0xa8;
|
||||
|
||||
friend class CRumble;
|
||||
};
|
||||
|
||||
struct JUTGamePadLongPress {
|
||||
// TODO: fix type
|
||||
// static JSUList<JUTGamePadLongPress> sPatternList;
|
||||
static u8 sPatternList[12];
|
||||
void checkCallback(int unk0, u32 unk2);
|
||||
|
||||
u8 unk0[17];
|
||||
bool field_0x11; // bool?
|
||||
u8 unk1[10];
|
||||
u32 field_0x1c;
|
||||
u8 unk2[28];
|
||||
u8 field_0x3c;
|
||||
u8 unk3[11];
|
||||
bool field_0x48[4]; // bool[4]?
|
||||
void (*callback)(s32, JUTGamePadLongPress*, s32);
|
||||
s32 field_0x50;
|
||||
};
|
||||
|
||||
#endif /* JUTGAMEPAD_H */
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef JSYSTEM_JUTILITY_JUTREPORT_H
|
||||
#define JSYSTEM_JUTILITY_JUTREPORT_H
|
||||
|
||||
void JUTReport(int, int, const char*, ...);
|
||||
void JUTReport(int, int, int, const char*, ...);
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,52 @@
|
||||
#ifndef JUTVIDEO_H
|
||||
#define JUTVIDEO_H
|
||||
|
||||
#include "dolphin/gx/GX.h"
|
||||
#include "dolphin/os/OS.h"
|
||||
#include "dolphin/types.h"
|
||||
#include "dolphin/vi/vi.h"
|
||||
|
||||
// TODO: placeholder
|
||||
struct _GXRenderModeObj {};
|
||||
|
||||
struct JUTVideo {
|
||||
static JUTVideo* sManager;
|
||||
// TODO: figure out type
|
||||
static u8 sVideoLastTick[4];
|
||||
static u8 sVideoInterval[4];
|
||||
|
||||
JUTVideo(_GXRenderModeObj const*);
|
||||
virtual ~JUTVideo();
|
||||
|
||||
typedef void (*CallbackFn)(void);
|
||||
|
||||
// struct JUTVideo_vtable * vtable;
|
||||
GXRenderModeObj* render_object;
|
||||
u32 field_0x8;
|
||||
u32 retrace_count;
|
||||
u32 field_0x10;
|
||||
u32 field_0x14;
|
||||
u32 field_0x18;
|
||||
VIRetraceCallback pre_retrace_callback;
|
||||
VIRetraceCallback post_retrace_callback;
|
||||
CallbackFn unknown_callback_1;
|
||||
CallbackFn unknown_callback_2;
|
||||
bool set_black;
|
||||
u8 padding[3];
|
||||
s32 set_black_frame_counter;
|
||||
OSMessage message;
|
||||
OSMessageQueue message_queue;
|
||||
|
||||
// TODO: return types not confirmed
|
||||
/* 802E4C54 */ void createManager(_GXRenderModeObj const*);
|
||||
/* 802E4CAC */ void destroyManager();
|
||||
/* 802E4E50 */ void preRetraceProc(u32);
|
||||
/* 802E5088 */ void drawDoneStart();
|
||||
/* 802E50B0 */ void dummyNoDrawWait();
|
||||
/* 802E50BC */ void drawDoneCallback();
|
||||
/* 802E5144 */ void postRetraceProc(u32);
|
||||
/* 802E5198 */ void setRenderMode(_GXRenderModeObj const*);
|
||||
/* 802E5210 */ void waitRetraceIfNeed();
|
||||
};
|
||||
|
||||
#endif /* JUTVIDEO_H */
|
||||
|
||||
Reference in New Issue
Block a user