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:
lepelog
2021-05-03 02:03:24 +02:00
committed by GitHub
parent 913bb08f51
commit 0b8db42226
360 changed files with 6646 additions and 12699 deletions
+68
View File
@@ -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 */
+24
View File
@@ -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 */
+33
View File
@@ -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 */
+46
View File
@@ -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 */
+67
View File
@@ -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 */
+63
View File
@@ -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 */
+213
View File
@@ -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
+29
View File
@@ -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 */
+22
View File
@@ -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 */
+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
+60
View File
@@ -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 */
+13
View File
@@ -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 */
+27
View File
@@ -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 */
+54
View File
@@ -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 */
+40
View File
@@ -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 */
+87
View File
@@ -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 */
+24
View File
@@ -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 */
+57
View File
@@ -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 */
+67
View File
@@ -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 */
+51
View File
@@ -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 */
+209
View File
@@ -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 */
+36
View File
@@ -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 */
+54
View File
@@ -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 */
+110
View File
@@ -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 */
View File
+15
View File
@@ -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 */
+16
View File
@@ -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 */
+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;
};
#endif
+251
View File
@@ -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
+10
View File
@@ -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 */
+61
View File
@@ -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 */
+42 -1
View File
@@ -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 */
+180
View File
@@ -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 */
+7
View File
@@ -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
+46
View File
@@ -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 */
+1
View File
@@ -2,6 +2,7 @@
#define C_LIB_H_
#include "SSystem/SComponent/c_xyz.h"
#include "dolphin/mtx/mtx.h"
#include "dolphin/types.h"
void cLib_memCpy(void* dst, const void* src, unsigned long size);
+1 -1
View File
@@ -2,8 +2,8 @@
#define C_M3D_G_LIN_H
#include "SSystem/SComponent/c_xyz.h"
#include "dolphin/mtx/vec.h"
#include "dolphin/types.h"
#include "mtx_vec.h"
// Line
class cM3dGLin {
+1 -1
View File
@@ -1,8 +1,8 @@
#ifndef C_XYZ_H
#define C_XYZ_H
#include "dolphin/mtx/vec.h"
#include "global.h"
#include "mtx_vec.h"
struct cXyz : Vec {
static const cXyz Zero;
+6
View File
@@ -3,4 +3,10 @@
#include "dolphin/types.h"
extern "C" {
u32 ARInit(u32*, u32);
u32 ARAlloc(u32);
u32 ARGetSize(void);
}
#endif /* AR_H */
+19
View File
@@ -3,4 +3,23 @@
#include "dolphin/types.h"
typedef void (*ARQCallback)(u32 request_address);
struct ARQRequest {
ARQRequest* next;
u32 owner;
u32 type;
u32 priority;
u32 source;
u32 destination;
u32 length;
ARQCallback callback;
};
extern "C" {
void ARQInit(void);
void ARQPostRequest(ARQRequest* task, u32 owner, u32 type, u32 priority, u32 source,
u32 destination, u32 length, ARQCallback callback);
}
#endif /* ARQ_H */
+85
View File
@@ -3,4 +3,89 @@
#include "dolphin/types.h"
extern "C" {
typedef enum DVDState {
DVD_STATE_END = 0x0,
DVD_STATE_BUSY = 0x1,
DVD_STATE_WAITING = 0x2,
DVD_STATE_COVER_CLOSED = 0x3,
DVD_STATE_NO_DISK = 0x4,
DVD_STATE_COVER_OPEN = 0x5,
DVD_STATE_WRONG_DISK = 0x6,
DVD_STATE_MOTOR_STOPPED = 0x7,
DVD_STATE_IGNORED = 0x8,
DVD_STATE_CANCELED = 0xa, // lmao they skipped 9
DVD_STATE_RETRY = 0xb,
DVD_STATE_FATAL_ERROR = -1,
} DVDState;
}
struct DVDDirectory {
u32 entry_number;
u32 location;
u32 next;
};
struct DVDDirectoryEntry {
u32 entry_number;
BOOL is_directory;
char* name;
};
struct DVDDiskID {
char game_name[4];
char company[2];
u8 disk_number;
u8 game_version;
u8 is_streaming;
u8 streaming_buffer_size;
u8 padding[22];
};
struct DVDFileInfo;
struct DVDCommandBlock;
typedef void (*DVDCBCallback)(s32 result, DVDCommandBlock* block);
typedef void (*DVDCallback)(s32 result, DVDFileInfo* info);
struct DVDCommandBlock {
DVDCommandBlock* next;
DVDCommandBlock* prev;
u32 command;
s32 state;
u32 offset;
u32 length;
void* buffer;
u32 current_transfer_size;
u32 transferred_size;
DVDDiskID* disk_id;
DVDCBCallback callback;
void* user_data;
};
struct DVDFileInfo {
DVDCommandBlock block;
u32 start_address;
u32 length;
DVDCallback callback;
};
extern "C" {
s32 DVDOpen(const char*, DVDFileInfo*);
s32 DVDClose(DVDFileInfo*);
void DVDReadPrio(DVDFileInfo*, void*, s32, s32, s32);
DVDDiskID* DVDGetCurrentDiskID(void);
s32 DVDFastOpen(long, DVDFileInfo*);
int DVDGetCommandBlockStatus(DVDCommandBlock*);
s32 DVDReadAsyncPrio(DVDFileInfo*, void*, long, long, DVDCallback, long);
s32 DVDConvertPathToEntrynum(const char*);
DVDState DVDGetDriveStatus(void);
s32 DVDCheckDisk(void);
BOOL DVDChangeDir(const char*);
BOOL DVDCloseDir(DVDDirectory*);
BOOL DVDOpenDir(const char*, DVDDirectory*);
BOOL DVDReadDir(DVDDirectory*, DVDDirectoryEntry*);
}
#endif /* DVD_H */
+168
View File
@@ -0,0 +1,168 @@
#ifndef GX_H_
#define GX_H_
#include "dolphin/gx/GXTexture.h"
#include "dolphin/types.h"
// TODO: maybe split?
typedef enum _GXCullMode {
GX_CULL_NONE = 0,
GX_CULL_FRONT = 1,
GX_CULL_BACK = 2,
GX_CULL_ALL = 3
} GXCullMode;
typedef enum _GXTexMapID {
GX_TEXMAP1 = 1,
GX_TEXMAP2 = 2,
GX_TEXMAP0 = 0,
GX_TEXMAP5 = 5,
GX_TEXMAP6 = 6,
GX_TEXMAP3 = 3,
GX_TEXMAP4 = 4,
GX_TEXMAP_NULL = 255,
GX_TEX_DISABLE = 256,
GX_TEXMAP7 = 7,
GX_MAX_TEXMAP = 8
} GXTexMapID;
struct GXRenderModeObj {
s32 vi_tv_mode;
u16 fb_width;
u16 efb_height;
u16 xfb_height;
u16 vi_x_origin;
u16 vi_y_origin;
u16 vi_width;
u16 vi_height;
s32 xfb_mode;
u8 field_rendering;
u8 antialiasing;
u8 sample_pattern[12][2];
u8 vfilter[7];
};
typedef enum GXTexFmt8 { /* 8-bit version of GXTexFmt for use in structures */
GX_CTF_A8 = 39,
GX_CTF_B8 = 42,
GX_CTF_G8 = 41,
GX_CTF_GB8 = 44,
GX_CTF_R4 = 32,
GX_CTF_R8 = 40,
GX_CTF_RA4 = 34,
GX_CTF_RA8 = 35,
GX_CTF_RG8 = 43,
GX_CTF_YUVA8 = 38,
GX_CTF_Z16L = 60,
GX_CTF_Z4 = 48,
GX_CTF_Z8L = 58,
GX_CTF_Z8M = 57,
GX_TF_CMPR = 14,
GX_TF_I4 = 0,
GX_TF_I8 = 1,
GX_TF_IA4 = 2,
GX_TF_IA8 = 3,
GX_TF_RGB565 = 4,
GX_TF_RGB5A3 = 5,
GX_TF_RGBA8 = 6,
GX_TF_Z16 = 19,
GX_TF_Z24X8 = 22,
GX_TF_Z8 = 17
} GXTexFmt8;
typedef enum GXTexWrapMode8 { /* Same as GXTexWrapMode, but as 1 byte for use inside structures */
GX_CLAMP = 0,
GX_MIRROR = 2,
GX_REPEAT = 1
} GXTexWrapMode8;
typedef enum GXTexFilter8 { /* Same as GXTexFilter, but as 1 byte for use within structures that
store the value as a byte */
GX_LINEAR = 1,
GX_LIN_MIP_LIN = 5,
GX_LIN_MIP_NEAR = 3,
GX_NEAR = 0,
GX_NEAR_MIP_LIN = 4,
GX_NEAR_MIP_NEAR = 2
} GXTexFilter8;
extern "C" {
f32 GXGetYScaleFactor(u16 efb_height, u16 xfb_height);
u16 GXGetNumXfbLines(u32 efb_height, f32 y_scale);
void GXBegin(u8, u8, u16);
void GXLoadTexObj(u32*, s32);
void GXInitTexObjLOD(f32, f32, f32, u32*, s32, s32, u32, u8, u32);
void GXInitTexObj(u32*, u32, u32, u32, u32, u32, u8);
void GXSetNumChans(u32);
void GXSetNumTevStages(u32);
void GXSetNumTexGens(u32);
void GXSetTevOrder(u32, u32, u32, u32);
void GXSetChanCtrl(u32, u32, u32, u32, u32, u32, s32);
void GXSetTevOp(s32, s32);
void GXSetTevColor(s32, _GXColor);
void GXSetTevColorIn(s32, u32, u32, u32, u32);
void GXSetTevAlphaIn(s32, u32, u32, u32, u32);
void GXSetTevColorOp(s32, u32, u32, u32, u32, u32);
void GXSetTevAlphaOp(s32, u32, u32, u32, u32, u32);
void GXSetBlendMode(u32, u32, u32, u32);
void GXSetVtxAttrFmt(u32, u32, u32, u32, u32);
void GXClearVtxDesc();
void GXSetVtxDesc(u32, u32);
typedef void (*GXDrawDoneCallback)(void);
void GXSetDrawDoneCallback(GXDrawDoneCallback);
void GXDrawDone(void);
void GXAbortFrame(void);
void GXFlush(void);
struct OSThread;
OSThread* GXSetCurrentGXThread(void);
OSThread* GXGetCurrentGXThread(void);
// Below needs proper symbols
void GXClearVtxDesc(void);
void GXCopyTex(void);
void GXGetProjectionv(void);
u32 GXGetTexBufferSize(u16 width, u16 height, u32 format, s32 is_mip_map, u8 max_lod);
void GXGetViewportv(void);
void GXInitLightColor(void);
void GXInitLightDir(void);
void GXInitLightDistAttn(void);
void GXInitLightPos(void);
void GXInitLightSpot(void);
void GXInvalidateTexAll(void);
void GXLoadLightObjImm(void);
void GXLoadPosMtxImm(void);
void GXLoadTexMtxImm(void);
void GXPixModeSync(void);
void GXProject(void);
void GXSetAlphaCompare(void);
void GXSetAlphaUpdate(void);
void GXSetChanMatColor(void);
void GXSetClipMode(void);
void GXSetCoPlanar(void);
void GXSetCopyFilter(void);
void GXSetCullMode(void);
void GXSetCurrentMtx(void);
void GXSetDither(void);
void GXSetFog(void);
void GXSetFogRangeAdj(void);
void GXSetNumIndStages(void);
void GXSetProjection(void);
void GXSetScissor(void);
void GXSetTevColorS10(void);
void GXSetTevKAlphaSel(void);
void GXSetTevSwapMode(void);
void GXSetTevSwapModeTable(void);
void GXSetTexCoordGen2(void);
void GXSetTexCopyDst(void);
void GXSetTexCopySrc(void);
void GXSetViewport(void);
void GXSetZCompLoc(void);
void GXSetZMode(void);
void GXSetZTexture(void);
};
#endif
+26
View File
@@ -1,6 +1,32 @@
#ifndef MTX_H
#define MTX_H
#include "dolphin/mtx/quat.h"
#include "dolphin/mtx/vec.h"
#include "dolphin/types.h"
typedef float Mtx[3][4];
extern "C" {
void PSMTXIdentity(Mtx matrix);
void PSMTXCopy(const Mtx src, Mtx dst);
void PSMTXConcat(const Mtx src_a, const Mtx src_b, Mtx dst);
u32 PSMTXInverse(const Mtx src, Mtx dst);
void PSMTXRotRad(Mtx matrix, u8 axis, float rad);
void PSMTXRotTrig(Mtx matrix, u8 axis, float sin, float cos);
double __PSMTXRotAxisRadInternal(double param_1, double param_2, int param_3, int param_4);
void PSMTXRotAxisRad(Mtx matrix, const Vec* axis, float rad);
void PSMTXTrans(Mtx matrix, float x_trans, float y_trans, float z_trans);
void PSMTXTransApply(const Mtx src, Mtx dst, float x, float y, float z);
void PSMTXScale(Mtx matrix, float x_scale, float y_scale, float z_scale);
void PSMTXScaleApply(const Mtx src, Mtx dst, float x_scale, float y_scale, float z_scale);
void PSMTXQuat(Mtx matrix, const Quaternion* quat);
void C_MTXLookAt(Mtx param_1, const Vec* param_2, const Vec* param_3, const Vec* param_4);
void C_MTXLightPerspective(Mtx matrix, float fov_y, float aspect, float scale_s, float scale_t,
float trans_s, float trans_t);
void C_MTXLightOrtho(Mtx matrix, float top, float bottom, float left, float right, float scale_s,
float scale_t, float trans_s, float trans_t);
}
#endif /* MTX_H */
+9
View File
@@ -3,4 +3,13 @@
#include "dolphin/types.h"
typedef float Mtx44[4][4];
extern "C" {
void C_MTXPerspective(Mtx44 matrix, float fov_y, float aspect, float near, float far);
void C_MTXOrtho(Mtx44 matrix, float top, float bottom, float left, float right, float near,
float far);
}
#endif /* MTX44_H */
+9
View File
@@ -1,6 +1,15 @@
#ifndef MTXVEC_H
#define MTXVEC_H
#include "dolphin/mtx/mtx.h"
#include "dolphin/mtx/vec.h"
#include "dolphin/types.h"
extern "C" {
void PSMTXMultVec(const Mtx matrix, const Vec* src, Vec* dst);
void PSMTXMultVecArray(const Mtx matrix, const Vec* src, Vec* dst, u32 count);
void PSMTXMultVecSR(const Mtx matrix, const Vec* src, Vec* dst);
void PSMTXMultVecArraySR(const Mtx matrix, const Vec* src, Vec* dst, u32 count);
}
#endif /* MTXVEC_H */
+11
View File
@@ -1,6 +1,17 @@
#ifndef QUAT_H
#define QUAT_H
#include "dolphin/mtx/vec.h"
#include "dolphin/types.h"
struct Quaternion {
float x, y, z, w;
};
extern "C" {
void PSQUATMultiply(const Quaternion* src_a, const Quaternion* src_b, Quaternion* dst);
void C_QUATRotAxisRad(Quaternion* quat, const Vec* axis, float rad);
void C_QUATSlerp(const Quaternion* p, const Quaternion* q, Quaternion* r, float t);
}
#endif /* QUAT_H */
+15
View File
@@ -13,4 +13,19 @@ struct Vec {
float getZDiff(const Vec* other) const { return z - other->z; }
};
extern "C" {
void PSVECAdd(const Vec* src_a, const Vec* src_b, Vec* dst);
void PSVECSubtract(const Vec* a, const Vec* b, Vec* dst);
void PSVECScale(const Vec* src, Vec* dst, float scale);
void PSVECNormalize(const Vec* src, Vec* dst);
float PSVECSquareMag(const Vec* vec);
float PSVECMag(const Vec* data);
float PSVECDotProduct(const Vec* a, const Vec* b);
void PSVECCrossProduct(const Vec* src_a, const Vec* src_b, Vec* dst);
void C_VECHalfAngle(const Vec* incident, const Vec* line_of_sight, Vec* out_half);
void C_VECReflect(const Vec* src, const Vec* surface_normal, Vec* dst);
float PSVECSquareDistance(const Vec* a, const Vec* b);
float PSVECDistance(const Vec* a, const Vec* b);
}
#endif /* VEC_H */
+297 -3
View File
@@ -1,6 +1,300 @@
#ifndef OS_H
#define OS_H
// at some point: we should split this up into various OS/... headers. but not
// yet, since barely any files include this atm.
#ifndef OS_H_
#define OS_H_
#include "dolphin/types.h"
#endif /* OS_H */
/* TODO: more structs, and get rid of the ones that are faked! */
#define OS_MESSAGE_NON_BLOCKING 0
#define OS_MESSAGE_BLOCKING 1
struct OSThread;
struct OSMutex {
u8 unk[24];
};
struct OSMutexLink {
struct OSMutex* prev;
struct OSMutex* next;
};
struct OSMutexQueue {
struct OSMutex* prev;
struct OSMutex* next;
};
struct OSContext {
u32 gpr[32];
u32 cr;
u32 lr;
u32 ctr;
u32 xer;
double fpr[32];
u32 padding_1;
u32 fpscr;
u32 srr0;
u32 srr1;
u16 mode;
u16 state;
u32 gqr[8];
u32 padding_2;
double ps[32];
};
typedef void (*OSSwitchThreadCallback)(OSThread* from, OSThread* to);
struct OSThreadLink {
struct OSThread* prev;
struct OSThread* next;
};
struct OSThreadQueue {
struct OSThread* head;
struct OSThread* tail;
};
struct OSCond {
struct OSThreadQueue queue;
};
typedef void* OSMessage;
struct OSMessageQueue {
struct OSThreadQueue sending_queue;
struct OSThreadQueue receiving_queue;
void** message_array;
s32 num_messages;
s32 first_index;
s32 num_used;
};
typedef u32 OSTick;
typedef s64 OSTime;
struct OSCalendarTime {
s32 seconds;
s32 minutes;
s32 hours;
s32 day_of_month;
s32 month;
s32 year;
s32 week_day;
s32 year_day;
s32 milliseconds;
s32 microseconds;
};
typedef s32 OSHeapHandle;
typedef enum OSSoundMode {
SOUND_MODE_MONO = 0,
SOUND_MODE_STEREO = 1,
} OSSoundMode;
typedef u16 OSThreadState;
#define OS_THREAD_STATE_UNINITIALIZED 0
#define OS_THREAD_STATE_READY 1
#define OS_THREAD_STATE_RUNNING 2
#define OS_THREAD_STATE_WAITING 4
#define OS_THREAD_STATE_DEAD 8
struct OSThread {
OSContext context;
OSThreadState state;
u16 attributes;
s32 suspend_count;
u32 effective_priority;
u32 base_priority;
void* exit_value;
OSThreadQueue* queue;
OSThreadLink link;
OSThreadQueue join_queue;
OSMutex* mutex;
OSMutexQueue owned_mutexes;
OSThreadLink active_threads_link;
u8* stack_base;
u8* stack_end;
u8* error_code;
void* data[2];
};
struct __va_list_struct {};
extern "C" {
s32 OSEnableScheduler(void);
s32 OSDisableScheduler(void);
s32 OSCheckActiveThreads(void);
OSThread* OSGetCurrentThread(void);
s32 OSSuspendThread(OSThread* thread);
s32 OSSetThreadPriority(OSThread* thread, u32 pri);
s32 OSGetThreadPriority(OSThread* thread);
s32 OSCreateThread(OSThread* thread, void* func, void* param, void* stack, u32 stackSize,
int param_6, int param_7);
void OSCancelThread(OSThread* thread);
void OSDetachThread(OSThread* thread);
s32 OSResumeThread(OSThread* thread);
void OSExitThread(void* exit_val);
bool OSIsThreadSuspended(OSThread* thread);
BOOL OSIsThreadTerminated(OSThread* thread);
OSSwitchThreadCallback OSSetSwitchThreadCallback(OSSwitchThreadCallback* callback);
void OSInitMessageQueue(OSMessageQueue* queue, OSMessage* messages, int message_count);
BOOL OSReceiveMessage(OSMessageQueue* queue, OSMessage* message, int flags);
BOOL OSSendMessage(OSMessageQueue* queue, OSMessage message, int flags);
BOOL OSJamMessage(OSMessageQueue* queue, OSMessage message, int flags);
s32 OSGetConsoleType(void);
u32 OSGetResetCode(void);
u32 OSGetSoundMode(void);
void OSSetSoundMode(OSSoundMode mode);
void OSAttention(const char* msg, ...);
void OSPanic(const char* file, s32 line, const char* fmt, ...);
void OSReport(const char* fmt, ...);
void OSReport_Error(const char* fmt, ...);
void OSReport_FatalError(const char* fmt, ...);
void OSReport_System(const char* fmt, ...);
void OSReport_Warning(const char* fmt, ...);
void OSReportDisable(void);
void OSReportEnable(void);
void OSReportForceEnableOff(void);
void OSReportForceEnableOn(void);
void OSVReport(const char* format, __va_list_struct* list);
void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime* out_time);
OSTime OSGetTime(void);
OSTick OSGetTick(void);
u32 OSGetArenaLo();
u32 OSGetArenaHi();
u32 OSInitAlloc(u32 low, u32 high, int param_3);
void OSSetArenaLo(u32 param_1);
void OSSetArenaHi(u32 param_1);
void* OSAllocFromArenaLo(u32 size, int alignment);
// void OSCancelAlarm(OSAlarm *alarm);
void OSInitMutex(OSMutex* mutex);
void OSLockMutex(OSMutex* mutex);
void OSTryLockMutex(OSMutex* mutex);
void OSUnlockMutex(OSMutex* mutex);
s32 OSDisableInterrupts();
s32 OSEnableInterrupts();
s32 OSRestoreInterrupts(s32 level);
void OSResetSystem(s32 param_1, u32 param_2, s32 param_3);
void OSSetSaveRegion(void* start, void* end);
void LCDisable(void);
void OSReportInit__Fv(void); // needed for inline asm
u8* OSGetStackPointer(void);
}; // extern "C"
void OSSwitchFiberEx(u32, u32, u32, u32, u32, u32);
void OSVAttention(const char* fmt, __va_list_struct* va_list);
void OSReportInit(void);
#include "dolphin/dvd/dvd.h"
struct GLOBAL_MEMORY {
DVDDiskID disk;
u32 nintendo_boot_code; /* Nintendo Standard Boot Code. */
u32 field_0x24; /* Version (set by apploader) */
u32 memory_size; /* Memory Size (Physical) 24MB */
u32 field_0x2c; /* Production Board Model */
u32 arena_low; /* Arena Low */
u32 arena_high; /* Arena High */
u32 field_0x38; /* Start of FST (varies in all games) */
u32 field_0x3c; /* Maximum FST Size (varies in all games) */
u8 padding_0x40[32];
u8 field_0x60[36]; /* Hook is PPC assembler used by Debugger. */
u8 padding_0x84[84];
OSContext* field_0xd8; /* Current OSContext instance. */
OSThread* field_0xdc; /* OSThread pointer, previously created thread. */
OSThread* field_0xe0; /* OSThread pointer, most recently created thread. */
OSThread* field_0xe4; /* Current thread pointer. */
u32 field_0xe8; /* Dev Debugger Monitor Address (If present) */
u32 field_0xec; /* Simulated Memory Size */
u32 field_0xf0; /* Pointer to data read from partition's bi2.bin, set by apploader */
u32 field_0xf4; /* Console Bus Speed */
u32 field_0xf8; /* Console CPU Speed */
u8 padding_0xfc[5892];
u8 field_0x1800[6144]; /* Unused Exception Vector */
u8 padding_0x3000[64];
u32 field_0x3040[34]; /* __OSInterrupt table. */
u32 field_0x30c8; /* Pointer to the first loaded REL file. */
u32 field_0x30cc; /* Pointer to the last loaded REL file. */
u32 field_0x30d0; /* Pointer to a REL module name table, or 0. */
u8 padding_0x30d8[4];
u64 field_0x30d8; /* System time */
u8 padding_0x30e0[4];
u32 field_0x30e4; /* __OSPADButton */
u8 padding_0x30ec[8];
u32 field_0x30f0; /* DOL Execute Parameters */
u8 padding_0x30f4[12];
u32 field_0x3100; /* Physical MEM1 size */
u32 field_0x3104; /* Simulated MEM1 size */
u8 padding_0x3108[8];
u32 field_0x3110; /* Heap pointer (end of usable memory by the game) */
u8 padding_0x3114[4];
u32 field_0x3118; /* Physical MEM2 size */
u32 field_0x311c; /* Simulated MEM2 size */
u8 padding_0x3120[16];
u32 field_0x3130; /* IOS Heap Range (start) */
u32 field_0x3134; /* IOS Heap Range (end) */
u32 field_0x3138; /* Hollywood Version */
u8 padding_0x313c[4];
u32 field_0x3140; /* IOS version */
u32 field_0x3144; /* IOS Build Date */
u8 padding_0x3148[16];
u32 field_0x3158; /* GDDR Vendor Code */
u32 field_0x315c; /* During the boot process, */
u32 field_0x3160; /* Init semaphore (1-2 main() waits for this to clear) */
u32 field_0x3164; /* GC (MIOS) mode flag? */
u8 padding_0x3168[24];
u32 field_0x3180; /* Game ID */
u8 field_0x3184; /* Application type. 0x80 for disc games, 0x81 for channels. */
u8 padding_0x3185;
u8 field_0x3186; /* Application type 2 */
u8 padding_0x3187;
u32 field_0x3188; /* Minimum IOS version */
u32 field_0x318c; /* Title Booted from NAND (Launch Code) */
u32 field_0x3190; /* Title Booted from NAND (Return Code) */
u32 field_0x3194; /* While reading a disc, the system menu reads the first partition table (0x20
bytes from 0x00040020) and stores a pointer to the data partition entry.
When launching the disc game, it copies the partition type to 0x3194. The
partition type for data partitions is 0, so typically this location always
has 0. */
u32 field_0x3198; /* While reading a disc, the system menu reads the first partition table (0x20
bytes from 0x00040020) and stores a pointer to the data partition entry.
When launching the disc game, it copies the partition offset to 0x3198. */
u32 field_0x319c; /* Set by the apploader to 0x80 for single-layer discs and 0x81 for dual-layer
discs (determined by whether 0x7ed40000 is the value at offset 0x30 in the
partition's bi2.bin; it seems that that value is 0 for single-layer discs).
Early titles' apploaders do not set it at all, leaving the value as 0. This
controls the /dev/di#0x8D_DVDLowUnencryptedRead out-of-bounds Error #001
read for titles that do make such a read: they try to read at 0x7ed40000
for dual-layer discs and 0x460a0000 for single-layer discs. */
u8 field_0x31a0[3424];
};
#define OS_ASSERT(...)
inline void* OSPhysicalToCached(u32 offset) {
OS_ASSERT(offset <= 0x1fffffff);
return (void*)(offset + 0x80000000);
}
#endif
+5
View File
@@ -3,4 +3,9 @@
#include "dolphin/types.h"
extern "C" {
void DCInvalidateRange(void*, u32);
void DCStoreRange(void*, u32);
}
#endif /* OSCACHE_H */
+37
View File
@@ -3,4 +3,41 @@
#include "dolphin/types.h"
typedef enum PADMask {
// PAD_CHAN3_BIT = (1 << 0),
// PAD_CHAN2_BIT = (1 << 1),
// PAD_CHAN1_BIT = (1 << 2),
// PAD_CHAN0_BIT = (1 << 3),
PAD_CHAN3_BIT = (1 << 28),
PAD_CHAN2_BIT = (1 << 29),
PAD_CHAN1_BIT = (1 << 30),
PAD_CHAN0_BIT = (1 << 31),
} PADMask;
typedef struct PADStatus {
u16 button;
s8 stick_x;
s8 stick_y;
s8 substick_x;
s8 substick_y;
u8 trigger_left;
u8 trigger_right;
u8 analog_a;
u8 analog_b;
s8 error;
} PADStatus;
extern "C" {
u32 PADInit(void);
void PADSetAnalogMode(u32 mode);
void PADSetSpec(int spec);
s32 PADReset(PADMask mask);
void PADClampCircle(PADStatus* status);
void PADClamp(PADStatus* status);
u32 PADRead(PADStatus* status);
void PADControlMotor(s32 channel, u32 command);
s32 PADRecalibrate(PADMask mask);
}
#endif /* PAD_H */
+4
View File
@@ -3,4 +3,8 @@
#include "dolphin/types.h"
typedef void (*VIRetraceCallback)(u32);
extern "C" void VIWaitForRetrace(void);
#endif /* VI_H */
-65
View File
@@ -1,65 +0,0 @@
#ifndef MTX_VEC_H_
#define MTX_VEC_H_
#include "dolphin/types.h"
struct Vec {
float x, y, z;
float GetX() const { return x; }
float GetY() const { return y; }
float GetZ() const { return z; }
float getXDiff(const Vec* other) const { return x - other->x; }
float getYDiff(const Vec* other) const { return y - other->y; }
float getZDiff(const Vec* other) const { return z - other->z; }
};
struct Quaternion {
float x, y, z, w;
};
typedef float Mtx[3][4];
extern "C" {
void PSMTXIdentity(Mtx matrix);
void PSMTXCopy(const Mtx src, Mtx dst);
void PSMTXConcat(const Mtx src_a, const Mtx src_b, Mtx dst);
u32 PSMTXInverse(const Mtx src, Mtx dst);
void PSMTXRotRad(Mtx matrix, u8 axis, float rad);
void PSMTXRotTrig(Mtx matrix, u8 axis, float sin, float cos);
double __PSMTXRotAxisRadInternal(double param_1, double param_2, int param_3, int param_4);
void PSMTXRotAxisRad(Mtx matrix, const Vec* axis, float rad);
void PSMTXTrans(Mtx matrix, float x_trans, float y_trans, float z_trans);
void PSMTXTransApply(const Mtx src, Mtx dst, float x, float y, float z);
void PSMTXScale(Mtx matrix, float x_scale, float y_scale, float z_scale);
void PSMTXScaleApply(const Mtx src, Mtx dst, float x_scale, float y_scale, float z_scale);
void PSMTXQuat(Mtx matrix, const Quaternion* quat);
void C_MTXLookAt(Mtx param_1, const Vec* param_2, const Vec* param_3, const Vec* param_4);
void C_MTXLightPerspective(Mtx matrix, float fov_y, float aspect, float scale_s, float scale_t,
float trans_s, float trans_t);
void C_MTXLightOrtho(Mtx matrix, float top, float bottom, float left, float right, float scale_s,
float scale_t, float trans_s, float trans_t);
void PSMTXMultVec(const Mtx matrix, const Vec* src, Vec* dst);
void PSMTXMultVecArray(const Mtx matrix, const Vec* src, Vec* dst, u32 count);
void PSMTXMultVecSR(const Mtx matrix, const Vec* src, Vec* dst);
void PSMTXMultVecArraySR(const Mtx matrix, const Vec* src, Vec* dst, u32 count);
void C_MTXPerspective(Mtx matrix, float fov_y, float aspect, float near, float far);
void C_MTXOrtho(Mtx matrix, float top, float bottom, float left, float right, float near,
float far);
void PSVECAdd(const Vec* src_a, const Vec* src_b, Vec* dst);
void PSVECSubtract(const Vec* a, const Vec* b, Vec* dst);
void PSVECScale(const Vec* src, Vec* dst, float scale);
void PSVECNormalize(const Vec* src, Vec* dst);
float PSVECSquareMag(const Vec* vec);
float PSVECMag(const Vec* data);
float PSVECDotProduct(const Vec* a, const Vec* b);
void PSVECCrossProduct(const Vec* src_a, const Vec* src_b, Vec* dst);
void C_VECHalfAngle(const Vec* incident, const Vec* line_of_sight, Vec* out_half);
void C_VECReflect(const Vec* src, const Vec* surface_normal, Vec* dst);
float PSVECSquareDistance(const Vec* a, const Vec* b);
float PSVECDistance(const Vec* a, const Vec* b);
void PSQUATMultiply(const Quaternion* src_a, const Quaternion* src_b, Quaternion* dst);
void C_QUATRotAxisRad(Quaternion* quat, const Vec* axis, float rad);
void C_QUATSlerp(const Quaternion* p, const Quaternion* q, Quaternion* r, float t);
}
#endif