mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-08-09 02:15:52 -04:00
Add & Link JKernel (#142)
* match and link JKRAram.cpp * match and link JKRExpHeap * match and link JKRAramStream.cpp * match and link JKRFileLoader.cpp * match and link JKRFileFinder.cpp * JKernel Dump * match and link JKRAramArchive.cpp * match and link JKRDvdArchive.cpp * match and link JKRCompArchive.cpp * match but not link JKRDvdAramRipper * small refactors * match and link JKRThread.cpp * fix and link JKRDvdAramStream.cpp * Formatting fixes --------- Co-authored-by: SwareJonge <olaf23okken@gmail.com>
This commit is contained in:
@@ -5,9 +5,11 @@
|
||||
#include "dolphin/ar.h"
|
||||
#include "dolphin/os/OSMessage.h"
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
#include "JSystem/JKernel/JKREnum.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JKernel/JKRThread.h"
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
#include "JSystem/JSupport/JSUStream.h"
|
||||
|
||||
#define ARAM_GROUP_ID_ALL 0
|
||||
#define ARAM_GROUP_ID_DEFAULT 0xFF
|
||||
@@ -22,7 +24,9 @@ class JKRAramHeap;
|
||||
class JKRDecompCommand;
|
||||
class JKRAMCommand;
|
||||
|
||||
class JKRAramBlock {
|
||||
class JKRAramBlock
|
||||
{
|
||||
public:
|
||||
JKRAramBlock(u32 address, u32 size, u32 freeSize, u8 groupID, bool tempMemory);
|
||||
|
||||
virtual ~JKRAramBlock();
|
||||
@@ -46,33 +50,11 @@ class JKRAramBlock {
|
||||
friend class JKRAramHeap;
|
||||
};
|
||||
|
||||
class JKRAram : public JKRThread {
|
||||
class JKRAramHeap : public JKRDisposer
|
||||
{
|
||||
public:
|
||||
JKRAram(u32, u32, s32);
|
||||
|
||||
virtual ~JKRAram();
|
||||
virtual void* run();
|
||||
|
||||
static JKRAram* sAramObject;
|
||||
static const OSMessageQueue sMessageQueue;
|
||||
static JSUList<JKRAMCommand> sAramCommandList;
|
||||
static u32 sSZSBufferSize;
|
||||
static OSMessage sMessageBuffer[ARAM_MESGBUF_COUNT];
|
||||
|
||||
private:
|
||||
u32 mAudioMemoryPtr;
|
||||
u32 mAudioMemorySize;
|
||||
u32 mGraphMemoryPtr;
|
||||
u32 mGraphMemorySize;
|
||||
u32 mAramMemoryPtr;
|
||||
u32 mAramMemorySize;
|
||||
JKRAramHeap* mAramHeap;
|
||||
u32 mBlockLength;
|
||||
u8 _9C[4];
|
||||
};
|
||||
|
||||
class JKRAramHeap : public JKRDisposer {
|
||||
enum EAllocMode {
|
||||
enum EAllocMode
|
||||
{
|
||||
Head = 0,
|
||||
Tail = 1
|
||||
};
|
||||
@@ -108,7 +90,77 @@ class JKRAramHeap : public JKRDisposer {
|
||||
friend class JKRAramBlock;
|
||||
};
|
||||
|
||||
class JKRAMCommand : public ARQRequest {
|
||||
class JKRAram : public JKRThread
|
||||
{
|
||||
public:
|
||||
JKRAram(u32, u32, long);
|
||||
|
||||
virtual ~JKRAram(); // _08
|
||||
virtual void* run(); // _0C
|
||||
|
||||
static bool checkOkAddress(u8* addr, u32 size, JKRAramBlock* block, u32 param_4);
|
||||
static void changeGroupIdIfNeed(u8* data, int groupId);
|
||||
|
||||
static JKRAram* create(u32, u32, long, long, long);
|
||||
static JKRAramBlock* mainRamToAram(u8*, u32, u32, JKRExpandSwitch, u32, JKRHeap*, int);
|
||||
static JKRAramBlock* mainRamToAram(u8*, JKRAramBlock* block, u32, JKRExpandSwitch, u32, JKRHeap*, int);
|
||||
static u8* aramToMainRam(u32, u8*, u32, JKRExpandSwitch, u32, JKRHeap*, int, u32*);
|
||||
static u8* aramToMainRam(JKRAramBlock*, u8*, u32, u32, JKRExpandSwitch, u32, JKRHeap*, int, u32*);
|
||||
|
||||
void aramSync(JKRAMCommand*, int);
|
||||
|
||||
u32 getAudioMemory() const
|
||||
{
|
||||
return mAudioMemoryPtr;
|
||||
}
|
||||
|
||||
u32 getAudioMemSize() const
|
||||
{
|
||||
return mAudioMemorySize;
|
||||
}
|
||||
|
||||
static u32 getSZSBufferSize()
|
||||
{
|
||||
return sSZSBufferSize;
|
||||
}
|
||||
|
||||
static JKRAramHeap* getAramHeap()
|
||||
{
|
||||
return sAramObject->mAramHeap;
|
||||
}
|
||||
|
||||
static JKRAram* getManager()
|
||||
{
|
||||
return sAramObject;
|
||||
}
|
||||
|
||||
static u8 decideAramGroupId(int id)
|
||||
{
|
||||
if (id < 0)
|
||||
return getAramHeap()->getCurrentGroupID();
|
||||
else
|
||||
return id;
|
||||
}
|
||||
|
||||
static u32 sSZSBufferSize;
|
||||
|
||||
static JKRAram* sAramObject;
|
||||
static OSMessage sMessageBuffer[4];
|
||||
static OSMessageQueue sMessageQueue;
|
||||
static JSUList<JKRAMCommand> sAramCommandList;
|
||||
|
||||
u32 mAudioMemoryPtr; // _7C
|
||||
u32 mAudioMemorySize; // _80
|
||||
u32 mGraphMemoryPtr; // _84
|
||||
u32 mGraphMemorySize; // _88
|
||||
u32 mUserMemoryPtr; // _8C
|
||||
u32 mUserMemorySize; // _90
|
||||
JKRAramHeap* mAramHeap; // _94
|
||||
u32 mStackArray[3]; // _98
|
||||
};
|
||||
|
||||
class JKRAMCommand : public ARQRequest
|
||||
{
|
||||
public:
|
||||
typedef void (*AMCommandCallback)(u32);
|
||||
|
||||
@@ -134,9 +186,11 @@ public:
|
||||
void* _94;
|
||||
};
|
||||
|
||||
class JKRAramCommand {
|
||||
class JKRAramCommand
|
||||
{
|
||||
public:
|
||||
inline void setting(BOOL active, void* arg) {
|
||||
inline void setting(BOOL active, void* arg)
|
||||
{
|
||||
this->mActive = active;
|
||||
this->mArg = arg;
|
||||
}
|
||||
@@ -145,7 +199,8 @@ public:
|
||||
void* mArg;
|
||||
};
|
||||
|
||||
class JKRAramPiece {
|
||||
class JKRAramPiece
|
||||
{
|
||||
public:
|
||||
static JKRAMCommand* prepareCommand(int direction, u32 source, u32 destination, u32 length, JKRAramBlock* aramBlock, JKRAMCommand::AMCommandCallback callback);
|
||||
static void sendCommand(JKRAMCommand* cmd);
|
||||
@@ -163,12 +218,97 @@ private:
|
||||
static void unlock() { OSUnlockMutex(&mMutex); }
|
||||
};
|
||||
|
||||
inline bool JKRAramPcs(int direction, u32 source, u32 destination, u32 length, JKRAramBlock* block) {
|
||||
class JKRAramStreamCommand
|
||||
{
|
||||
public:
|
||||
enum ECommandType
|
||||
{
|
||||
ECT_UNK = 0,
|
||||
ECT_READ = 1,
|
||||
ECT_WRITE = 2,
|
||||
};
|
||||
|
||||
JKRAramStreamCommand();
|
||||
|
||||
ECommandType type; // _00
|
||||
u32 mAddress; // _04
|
||||
u32 mSize; // _08
|
||||
u32 _0C; // _0C
|
||||
JSUFileInputStream* mStream; // _10
|
||||
u32 mOffset; // _14
|
||||
u8* mTransferBuffer; // _18
|
||||
u32 mTransferBufferSize; // _1C
|
||||
JKRHeap* mHeap; // _20
|
||||
bool mAllocatedTransferBuffer; // _24
|
||||
u32 _28; // _28
|
||||
OSMessageQueue mMessageQueue; // _2C
|
||||
void* mMessage; // _4C
|
||||
u32 _50; // _50
|
||||
u32 _54; // _54
|
||||
};
|
||||
|
||||
class JKRAramStream : public JKRThread
|
||||
{
|
||||
public:
|
||||
JKRAramStream(long);
|
||||
|
||||
virtual ~JKRAramStream(); // _08
|
||||
virtual void* run(); // _0C
|
||||
|
||||
static JKRAramStream* create(s32);
|
||||
|
||||
static u32 readFromAram();
|
||||
static s32 writeToAram(JKRAramStreamCommand*);
|
||||
static JKRAramStreamCommand* write_StreamToAram_Async(JSUFileInputStream*, JKRAramBlock*, u32, u32);
|
||||
static JKRAramStreamCommand* write_StreamToAram_Async(JSUFileInputStream*, u32, u32, u32);
|
||||
static JKRAramStreamCommand* sync(JKRAramStreamCommand*, BOOL);
|
||||
static void setTransBuffer(u8*, u32, JKRHeap*);
|
||||
|
||||
static JKRAramStream* sAramStreamObject;
|
||||
static OSMessage sMessageBuffer[4];
|
||||
static OSMessageQueue sMessageQueue;
|
||||
|
||||
static u8* transBuffer;
|
||||
static JKRHeap* transHeap;
|
||||
static u32 transSize;
|
||||
|
||||
// _00 = VTBL
|
||||
// _00-_7C = JKRThread
|
||||
};
|
||||
|
||||
inline JKRAramBlock* JKRAllocFromAram(u32 size, JKRAramHeap::EAllocMode allocMode)
|
||||
{
|
||||
return JKRAram::getAramHeap()->alloc(size, allocMode);
|
||||
}
|
||||
|
||||
inline void JKRFreeToAram(JKRAramBlock* block)
|
||||
{
|
||||
JKRAram::getAramHeap()->free(block);
|
||||
}
|
||||
|
||||
inline u8* JKRAramToMainRam(u32 address, u8* buf, u32 bufSize, JKRExpandSwitch expandSwitch, u32 p5, JKRHeap* heap, int id, u32* pSize)
|
||||
{
|
||||
JKRAram::aramToMainRam(address, buf, bufSize, expandSwitch, p5, heap, id, pSize);
|
||||
}
|
||||
|
||||
inline JKRAramBlock* JKRMainRamToAram(u8* buf, u32 bufSize, u32 alignedSize, JKRExpandSwitch expandSwitch, u32 fileSize, JKRHeap* heap, int id, u32)
|
||||
{
|
||||
return JKRAram::mainRamToAram(buf, bufSize, alignedSize, expandSwitch, fileSize, heap, id);
|
||||
}
|
||||
|
||||
inline JKRAramStream* JKRCreateAramStreamManager(s32 priority)
|
||||
{
|
||||
return JKRAramStream::create(priority);
|
||||
}
|
||||
|
||||
inline bool JKRAramPcs(int direction, u32 source, u32 destination, u32 length, JKRAramBlock* block)
|
||||
{
|
||||
return JKRAramPiece::orderSync(direction, source, destination, length, block);
|
||||
}
|
||||
|
||||
inline void JKRAramPcs_SendCommand(JKRAMCommand* cmd) {
|
||||
inline void JKRAramPcs_SendCommand(JKRAMCommand* cmd)
|
||||
{
|
||||
JKRAramPiece::sendCommand(cmd);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,342 @@
|
||||
#ifndef JKRARCHIVE_H_
|
||||
#define JKRARCHIVE_H_
|
||||
|
||||
#include "JSystem/JKernel/JKRDvdFile.h"
|
||||
#include "JSystem/JKernel/JKRFileLoader.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "types.h"
|
||||
|
||||
// NOTE: Vtable offsets are off
|
||||
|
||||
#define JKRARCHIVE_ATTR_COMPRESSION 0x04
|
||||
#define JKRARCHIVE_ATTR_YAY0 0x80
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
class JKRArchive : public JKRFileLoader
|
||||
{
|
||||
public:
|
||||
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(const char** p1, char p2) { p1[0] = store(p1[0], p2); }
|
||||
|
||||
const char* getString() const { return mString; }
|
||||
u16 getHash() const { return mHash; }
|
||||
void store(const char*);
|
||||
const char* store(const char*, char);
|
||||
|
||||
// Unused/inlined:
|
||||
CArcName() {}
|
||||
CArcName(const char* data) { store(data); }
|
||||
|
||||
u16 mHash; // _00
|
||||
u16 _02; // _02
|
||||
char mString[256]; // _04
|
||||
u8 _104[4]; // _104, unknown, used to fix stack size
|
||||
};
|
||||
|
||||
struct SDIFileEntry
|
||||
{
|
||||
u16 getNameHash() const { return mHash; }
|
||||
u32 getNameOffset() const { return mFlag & 0xFFFFFF; }
|
||||
u32 getFlags() const { return mFlag >> 24; }
|
||||
u32 getAttr() const { return getFlags(); }
|
||||
u32 getSize() { return mSize; }
|
||||
u16 getFileID() const { return mFileID; }
|
||||
bool isDirectory() const { return (getFlags() & 0x02) != 0; }
|
||||
bool isCompressed() const { return (getFlags() & 0x04) != 0; }
|
||||
u8 getCompressFlag() const { return (getFlags() & 0x04); } // apparently both necessary?
|
||||
bool isYAZ0Compressed() const { return (getFlags() & 0x80) != 0; }
|
||||
|
||||
bool getFlag01() const { return (getFlags() & 0x01) != 0; }
|
||||
bool getFlag04() { return mFlag >> 0x18 & 0x04; }
|
||||
bool getFlag10() { return mFlag >> 0x18 & 0x10; }
|
||||
bool getFlag80() { return mFlag >> 0x18 & 0x80; }
|
||||
|
||||
u16 mFileID; // _00
|
||||
u16 mHash; // _02
|
||||
u32 mFlag; // _04
|
||||
u32 mDataOffset; // _08
|
||||
u32 mSize; // _0C
|
||||
void* mData; // _10
|
||||
};
|
||||
|
||||
struct SDirEntry
|
||||
{
|
||||
u8 mFlags; // _00
|
||||
u8 _01; // _01
|
||||
u16 mID; // _02
|
||||
char* mName; // _04
|
||||
};
|
||||
|
||||
struct SDIDirEntry
|
||||
{
|
||||
u32 mType; // _00
|
||||
u32 mOffset; // _04
|
||||
u16 _08; // _08
|
||||
u16 mNum; // _0A
|
||||
u32 mFirstIdx; // _0C
|
||||
};
|
||||
|
||||
// NB: Fabricated name
|
||||
struct SArcDataInfo
|
||||
{
|
||||
u32 num_nodes; // _00
|
||||
u32 node_offset; // _04
|
||||
u32 num_file_entries; // _08
|
||||
u32 file_entry_offset; // _0C
|
||||
u32 string_table_length; // _10
|
||||
u32 string_table_offset; // _14
|
||||
u16 nextFreeFileID; // _18
|
||||
bool isSyncIDs; // _1A
|
||||
u8 _1B[5]; // _1B, unknown
|
||||
};
|
||||
|
||||
// NB: Fabricated name - need to check size
|
||||
struct SArcHeader
|
||||
{
|
||||
u32 signature; // _00
|
||||
u32 file_length; // _04
|
||||
u32 header_length; // _08
|
||||
u32 file_data_offset; // _0C
|
||||
u32 file_data_length; // _10
|
||||
u32 _14; // _14
|
||||
u32 _18; // _18
|
||||
u32 _1C; // _1C
|
||||
};
|
||||
|
||||
JKRArchive(s32, EMountMode);
|
||||
|
||||
virtual ~JKRArchive(); // _08
|
||||
virtual bool becomeCurrent(const char*); // _10
|
||||
virtual void* getResource(const char* path); // _14
|
||||
virtual void* getResource(u32 type, const char* name); // _18
|
||||
virtual size_t readResource(void* resourceBuffer, u32 bufferSize, const char* path, JKRExpandSwitch expandSwitch); // _1C
|
||||
virtual size_t readResource(void* resourceBuffer, u32 bufferSize, u32 type, const char* name); // _20
|
||||
virtual void removeResourceAll(); // _24
|
||||
virtual bool removeResource(void*); // _28
|
||||
virtual bool detachResource(void*); // _2C
|
||||
virtual s32 getResSize(const void*) const; // _30
|
||||
virtual u32 countFile(const char*) const; // _34
|
||||
virtual JKRFileFinder* getFirstFile(const char*) const; // _38
|
||||
virtual void* fetchResource(SDIFileEntry* entry, u32* outSize) = 0; // _40
|
||||
virtual void* fetchResource(void* resourceBuffer, u32 bufferSize, SDIFileEntry* entry, u32* resSize, JKRExpandSwitch expandSwitch) = 0; // _44
|
||||
|
||||
SDIDirEntry* findDirectory(const char*, u32) const;
|
||||
SDIFileEntry* findFsResource(const char*, u32) const;
|
||||
SDIFileEntry* findIdResource(u16) const;
|
||||
SDIFileEntry* findIdxResource(u32) const;
|
||||
SDIFileEntry* findNameResource(const char*) const;
|
||||
SDIFileEntry* findPtrResource(const void*) const;
|
||||
SDIFileEntry* findTypeResource(u32, const char*) const;
|
||||
bool isSameName(CArcName&, u32, u16) const;
|
||||
|
||||
bool getDirEntry(SDirEntry*, u32) const;
|
||||
void* getIdxResource(u32 index);
|
||||
size_t readResource(void* resourceBuffer, u32 bufferSize, u16 id);
|
||||
|
||||
static JKRArchive* mount(char const*, EMountMode, JKRHeap*, EMountDirection);
|
||||
static JKRArchive* mount(void*, JKRHeap*, EMountDirection);
|
||||
static JKRArchive* mount(s32, EMountMode, JKRHeap*, EMountDirection);
|
||||
static void* getGlbResource(u32 type, const char* name, JKRArchive* archive);
|
||||
|
||||
// Unused/inlined:
|
||||
JKRArchive();
|
||||
JKRArchive(const char* p1, EMountMode mountMode);
|
||||
static JKRArchive* check_mount_already(s32);
|
||||
static JKRArchive* check_mount_already(s32, JKRHeap*);
|
||||
SDIDirEntry* findResType(u32) const;
|
||||
SDIFileEntry* findTypeResource(u32, u32) const;
|
||||
|
||||
static int convertAttrToCompressionType(int attr)
|
||||
{
|
||||
int compression;
|
||||
if (FLAG_ON(attr, JKRARCHIVE_ATTR_COMPRESSION))
|
||||
compression = JKRCOMPRESSION_NONE;
|
||||
else if (!FLAG_ON(attr, JKRARCHIVE_ATTR_YAY0))
|
||||
compression = JKRCOMPRESSION_YAZ0;
|
||||
else
|
||||
compression = JKRCOMPRESSION_YAY0;
|
||||
|
||||
return compression;
|
||||
}
|
||||
|
||||
u32 getMountMode() const { return mMountMode; }
|
||||
u32 countFile() const { return mArcInfoBlock->num_file_entries; }
|
||||
int countDirectory() const { return mArcInfoBlock->num_nodes; }
|
||||
static u32 getCurrentDirID() { return sCurrentDirID; }
|
||||
static void setCurrentDirID(u32 dirID) { sCurrentDirID = dirID; }
|
||||
|
||||
static u32 sCurrentDirID;
|
||||
|
||||
protected:
|
||||
// _00 = VTBL
|
||||
// _00-_38 = JKRFileLoader
|
||||
JKRHeap* mHeap; // _38
|
||||
u8 mMountMode; // _3C
|
||||
s32 mEntryNum; // _40
|
||||
SArcDataInfo* mArcInfoBlock; // _44
|
||||
SDIDirEntry* mDirectories; // _48
|
||||
SDIFileEntry* mFileEntries; // _4C
|
||||
const char* mStrTable; // _50
|
||||
int _54; // _54
|
||||
int mCompression; // _58
|
||||
EMountDirection mMountDirection; // _5C
|
||||
};
|
||||
|
||||
enum JKRMemBreakFlag
|
||||
{
|
||||
MBF_0 = 0,
|
||||
MBF_1 = 1
|
||||
};
|
||||
|
||||
class JKRAramArchive : public JKRArchive
|
||||
{
|
||||
public:
|
||||
JKRAramArchive();
|
||||
JKRAramArchive(s32, EMountDirection);
|
||||
|
||||
virtual ~JKRAramArchive(); // _08
|
||||
virtual void* fetchResource(SDIFileEntry*, u32*); // _40
|
||||
virtual void* fetchResource(void*, u32, SDIFileEntry*, u32*, JKRExpandSwitch expandSwitch); // _44
|
||||
|
||||
bool open(s32);
|
||||
u32 getAramAddress_Entry(SDIFileEntry* fileEntry);
|
||||
u32 getAramAddress(u32, const char* file);
|
||||
static u32 fetchResource_subroutine(u32, u32, u8*, u32, int);
|
||||
static u32 fetchResource_subroutine(u32, u32, JKRHeap*, int, u8**);
|
||||
|
||||
void fixedInit(s32 entryNum, EMountDirection direction);
|
||||
bool mountFixed(s32 entryNum, EMountDirection direction);
|
||||
bool mountFixed(const char* path, EMountDirection direction);
|
||||
void unmountFixed();
|
||||
|
||||
// _00 = VTBL
|
||||
// _00-_60 = JKRArchive
|
||||
JKRAramBlock* mBlock; // _60
|
||||
JKRFile* mDvdFile; // _64
|
||||
};
|
||||
|
||||
struct JKRCompArchive : public JKRArchive
|
||||
{
|
||||
JKRCompArchive(s32, EMountDirection);
|
||||
|
||||
virtual ~JKRCompArchive(); // _08
|
||||
virtual void removeResourceAll(); // _24
|
||||
virtual bool removeResource(void*); // _28
|
||||
virtual void* fetchResource(SDIFileEntry* entry, u32* outSize); // _40
|
||||
virtual void* fetchResource(void* resourceBuffer, u32 bufferSize, SDIFileEntry* entry, u32* resSize, JKRExpandSwitch expandSwitch); // _44
|
||||
|
||||
bool open(s32);
|
||||
|
||||
// Unused/inlined:
|
||||
void fixedInit(s32);
|
||||
void mountFixed(s32);
|
||||
void mountFixed(const char*);
|
||||
void unmountFixed();
|
||||
|
||||
// _00 = VTBL
|
||||
// _00-_5C = JKRArchive
|
||||
u32 _60; // _60
|
||||
JKRAramBlock* mAramPart; // _64
|
||||
u32 _68; // _68
|
||||
JKRFile* mDvdFile; // _6C
|
||||
u32 mSizeOfMemPart; // _70
|
||||
u32 mSizeOfAramPart; // _74
|
||||
u32 _78; // _78
|
||||
};
|
||||
|
||||
struct JKRDvdArchive : public JKRArchive
|
||||
{
|
||||
JKRDvdArchive();
|
||||
JKRDvdArchive(s32, JKRArchive::EMountDirection);
|
||||
|
||||
virtual ~JKRDvdArchive(); // _00
|
||||
virtual void* fetchResource(SDIFileEntry* entry, u32* outSize); // _38
|
||||
virtual void* fetchResource(void* resourceBuffer, u32 bufferSize, SDIFileEntry* entry, u32* resSize, JKRExpandSwitch expandSwitch); // _3C
|
||||
|
||||
bool open(s32);
|
||||
static u32 fetchResource_subroutine(s32, u32, u32, u8*, u32, int, int);
|
||||
static u32 fetchResource_subroutine(s32, u32, u32, JKRHeap*, int, int, u8**);
|
||||
|
||||
// Unused/inlined:
|
||||
unknown fixedInit(s32, EMountDirection);
|
||||
unknown mountFixed(s32, EMountDirection);
|
||||
unknown mountFixed(const char*, EMountDirection);
|
||||
unknown unmountFixed();
|
||||
|
||||
// _00 = VTBL
|
||||
// _00-_5C = JKRArchive
|
||||
int _60; // _60
|
||||
JKRFile* mDvdFile; // _64
|
||||
};
|
||||
|
||||
struct JKRMemArchive : public JKRArchive
|
||||
{
|
||||
JKRMemArchive(); // unused/inlined
|
||||
JKRMemArchive(s32, EMountDirection);
|
||||
JKRMemArchive(void*, u32, JKRMemBreakFlag);
|
||||
JKRMemArchive(const char*, EMountDirection); // unused/inlined
|
||||
|
||||
virtual ~JKRMemArchive(); // _08
|
||||
virtual void removeResourceAll(); // _24
|
||||
virtual bool removeResource(void*); // _28
|
||||
virtual void* fetchResource(SDIFileEntry* entry, u32* outSize); // _40
|
||||
virtual void* fetchResource(void* resourceBuffer, u32 bufferSize, SDIFileEntry* entry, u32* resSize, JKRExpandSwitch expandSwitch); // _44
|
||||
|
||||
bool open(s32, EMountDirection);
|
||||
bool open(void*, u32, JKRMemBreakFlag);
|
||||
static u32 fetchResource_subroutine(u8*, u32, u8*, u32, int);
|
||||
|
||||
// Unused/inlined:
|
||||
void fixedInit(s32);
|
||||
void mountFixed(s32, EMountDirection);
|
||||
void mountFixed(const char*, EMountDirection);
|
||||
void mountFixed(void*, JKRMemBreakFlag);
|
||||
void unmountFixed();
|
||||
void open(const char*, EMountDirection);
|
||||
|
||||
// _00 = VTBL
|
||||
// _00-_60 = JKRArchive
|
||||
SArcHeader* mArcHeader; // _60
|
||||
u8* mArchiveData; // _64
|
||||
bool mIsOpen; // _68
|
||||
};
|
||||
|
||||
inline int JKRConvertAttrToCompressionType(int attr)
|
||||
{
|
||||
return JKRArchive::convertAttrToCompressionType(attr);
|
||||
}
|
||||
|
||||
inline JKRArchive* JKRMountArchive(const char* path, JKRArchive::EMountMode mountMode, JKRHeap* heap, JKRArchive::EMountDirection mountDirection)
|
||||
{
|
||||
return JKRArchive::mount(path, mountMode, heap, mountDirection);
|
||||
}
|
||||
|
||||
inline JKRArchive* JKRMountArchive(void* inBuf, JKRHeap* heap, JKRArchive::EMountDirection mountDirection)
|
||||
{
|
||||
return JKRArchive::mount(inBuf, heap, mountDirection);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSMessage.h"
|
||||
#include "JSystem/JKernel/JKRDvdFile.h"
|
||||
#include "JSystem/JKernel/JKRThread.h"
|
||||
#include "JSystem/JKernel/JKRAram.h"
|
||||
|
||||
@@ -78,6 +79,14 @@ inline JKRDecomp* JKRCreateDecompManager(s32 priority) {
|
||||
return JKRDecomp::create(priority);
|
||||
}
|
||||
|
||||
inline int JKRCheckCompressed_noASR(u8* pBuf)
|
||||
{
|
||||
int compression = JKRDecomp::checkCompressed(pBuf);
|
||||
if (compression == JKRCOMPRESSION_ASR)
|
||||
compression = JKRCOMPRESSION_NONE;
|
||||
return compression;
|
||||
}
|
||||
|
||||
inline JKRDecomp::CompressionMode JKRCheckCompressed(u8* buf) {
|
||||
return JKRDecomp::checkCompressed(buf);
|
||||
}
|
||||
@@ -90,4 +99,8 @@ inline void JKRDecompress(u8* src, u8* dst, u32 srcLength, u32 skipCount) {
|
||||
JKRDecomp::orderSync(src, dst, srcLength, skipCount);
|
||||
}
|
||||
|
||||
int JKRDecompressFromDVD(JKRDvdFile* srcFile, void* buf, u32 size, u32 maxDest, u32 fileOffset, u32 srcOffset);
|
||||
int JKRDecompressFromDVDToAram(JKRDvdFile* srcFile, u32 address, u32 fileSize, u32 maxDest, u32 fileOffset, u32 srcOffset);
|
||||
int JKRDecompressFromAramToMainRam(u32 srcAddress, void* dst, u32 fileSize, u32 maxDest, u32 fileOffset);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
virtual ~JKRDisposer();
|
||||
|
||||
public:
|
||||
JKRHeap *mRootHeap; // _4
|
||||
JKRHeap* mRootHeap; // _4
|
||||
JSULink<JKRDisposer> mPointerLinks; // _8
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef JKRDVDARAMRIPPER_H
|
||||
#define JKRDVDARAMRIPPER_H
|
||||
|
||||
#include "JSystem/JKernel/JKRAram.h"
|
||||
#include "JSystem/JKernel/JKRDvdFile.h"
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
#include "types.h"
|
||||
|
||||
class JKRADCommand
|
||||
{
|
||||
public:
|
||||
typedef void (*LoadCallback)(u32);
|
||||
JKRADCommand();
|
||||
~JKRADCommand();
|
||||
|
||||
// Fields might need more swapping
|
||||
JSULink<JKRADCommand> mLink;
|
||||
JKRDvdFile* mDvdFile; // _28
|
||||
u32 _14; // _14
|
||||
u32 _18; // _18, probably size
|
||||
u32 _1C; // _1C
|
||||
JKRAramBlock* mBlock; // _20
|
||||
JKRExpandSwitch mExpandSwitch; // _24
|
||||
u8 _28[0x10]; // _28 - unknown/padding
|
||||
u32* _3C; // _3C
|
||||
s32 _40; // _40
|
||||
LoadCallback mCallBack; // _40
|
||||
u8 _44; // _44
|
||||
JKRAramStreamCommand* mStreamCommand; // _48
|
||||
};
|
||||
|
||||
class JKRDvdAramRipper
|
||||
{
|
||||
public:
|
||||
static JKRAramBlock* loadToAram(char const*, u32, JKRExpandSwitch, u32, u32);
|
||||
static JKRAramBlock* loadToAram(s32, u32, JKRExpandSwitch, u32, u32);
|
||||
static JKRAramBlock* loadToAram(JKRDvdFile*, u32, JKRExpandSwitch, u32, u32);
|
||||
static JKRADCommand* loadToAram_Async(JKRDvdFile*, u32, JKRExpandSwitch, JKRADCommand::LoadCallback, u32, u32);
|
||||
static JKRADCommand* callCommand_Async(JKRADCommand*);
|
||||
static bool syncAram(JKRADCommand*, int);
|
||||
|
||||
// unused/inlined:
|
||||
static JKRADCommand* loadToAram_Async(const char*, u32, JKRExpandSwitch, JKRADCommand::LoadCallback, u32, u32);
|
||||
static JKRADCommand* loadToAram_Async(s32, u32, JKRExpandSwitch, JKRADCommand::LoadCallback, u32, u32);
|
||||
static void syncAramAll(int);
|
||||
static void countLeftSync();
|
||||
static void afterAramAsync(JKRADCommand*);
|
||||
|
||||
static int getSZSBufferSize() { return sSZSBufferSize; }
|
||||
static bool isErrorRetry() { return errorRetry; }
|
||||
|
||||
static bool errorRetry;
|
||||
static int sSZSBufferSize;
|
||||
static JSUList<JKRADCommand> sDvdAramAsyncList;
|
||||
};
|
||||
|
||||
inline JKRAramBlock* JKRDvdToAram(s32 entrynum, u32 p2, JKRExpandSwitch expSwitch, u32 p4, u32 p5)
|
||||
{
|
||||
return JKRDvdAramRipper::loadToAram(entrynum, p2, expSwitch, p4, p5);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef JKRDVDFILE_H
|
||||
#define JKRDVDFILE_H
|
||||
|
||||
#include "JSystem/JKernel/JKRAram.h"
|
||||
#include "JSystem/JKernel/JKRFile.h"
|
||||
#include "JSystem/JSupport/JSUStream.h"
|
||||
|
||||
@@ -30,22 +31,22 @@ public:
|
||||
}
|
||||
|
||||
inline int readDataAsync(void* addr, s32 length, s32 offset) {
|
||||
OSLockMutex(&this->mMutex1);
|
||||
OSLockMutex(&this->mDvdMutex);
|
||||
s32 retAddr;
|
||||
|
||||
if (this->mThread2 != nullptr) {
|
||||
OSUnlockMutex(&this->mMutex1);
|
||||
if (this->mDvdThread != nullptr) {
|
||||
OSUnlockMutex(&this->mDvdMutex);
|
||||
retAddr = -1;
|
||||
}
|
||||
else {
|
||||
this->mThread2 = OSGetCurrentThread();
|
||||
this->mDvdThread = OSGetCurrentThread();
|
||||
retAddr = -1;
|
||||
if (DVDReadAsync(&this->mDvdFileInfo, addr, length, offset, JKRDvdFile::doneProcess)) {
|
||||
retAddr = this->sync();
|
||||
}
|
||||
|
||||
this->mThread2 = nullptr;
|
||||
OSUnlockMutex(&this->mMutex1);
|
||||
this->mDvdThread = nullptr;
|
||||
OSUnlockMutex(&this->mDvdMutex);
|
||||
}
|
||||
|
||||
return retAddr;
|
||||
@@ -60,20 +61,20 @@ public:
|
||||
|
||||
static JSUList<JKRDvdFile> sDvdList;
|
||||
|
||||
protected:
|
||||
OSMutex mMutex1;
|
||||
OSMutex mMutex2;
|
||||
public:
|
||||
OSMutex mDvdMutex;
|
||||
OSMutex mAramMutex;
|
||||
JKRAramBlock* mAramBlock;
|
||||
OSThread* mThread1;
|
||||
OSThread* mAramThread;
|
||||
JSUFileInputStream* mInputStream;
|
||||
u32 _58;
|
||||
JKRDvdFileInfo mDvdFileInfo;
|
||||
OSMessageQueue mMessageQueue1;
|
||||
OSMessage mMsg1;
|
||||
OSMessageQueue mMessageQueue2;
|
||||
OSMessage mMsg2;
|
||||
OSMessageQueue mAramMessageQueue;
|
||||
OSMessage mAramMessage;
|
||||
OSMessageQueue mDvdMessageQueue;
|
||||
OSMessage mDvdMessage;
|
||||
JSULink<JKRDvdFile> mLink;
|
||||
OSThread* mThread2;
|
||||
OSThread* mDvdThread;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,18 @@
|
||||
|
||||
#define SZP_BUFFERSIZE 1024
|
||||
#define REF_BUFFERSIZE 0x1120
|
||||
#define DMA_BUFFERSIZE 0x100
|
||||
|
||||
struct SZPHeader {
|
||||
u32 magic;
|
||||
u32 decompSize;
|
||||
};
|
||||
|
||||
struct SYaz0Header {
|
||||
u32 signature;
|
||||
u32 length;
|
||||
};
|
||||
|
||||
class JKRDMCommand {
|
||||
JKRDMCommand();
|
||||
~JKRDMCommand();
|
||||
@@ -37,6 +43,14 @@ public:
|
||||
static bool errorRetry;
|
||||
};
|
||||
|
||||
static int JKRDecompressFromDVD(JKRDvdFile* srcFile, void* buf, u32 size, u32 maxDest, u32 fileOffset, u32 srcOffset);
|
||||
inline void* JKRDvdToMainRam(long entryNum, u8* dst, JKRExpandSwitch expandSwitch, u32 fileSize, JKRHeap* heap, JKRDvdRipper::EAllocDirection allocDirection, u32 startOffset, int* pCompression)
|
||||
{
|
||||
return JKRDvdRipper::loadToMainRAM(entryNum, dst, expandSwitch, fileSize, heap, allocDirection, startOffset, pCompression);
|
||||
}
|
||||
|
||||
inline void* JKRDvdToMainRam(const char* path, u8* dst, JKRExpandSwitch expandSwitch, u32 fileSize, JKRHeap* heap, JKRDvdRipper::EAllocDirection allocDirection, u32 startOffset, int* pCompression)
|
||||
{
|
||||
return JKRDvdRipper::loadToMainRAM(path, dst, expandSwitch, fileSize, heap, allocDirection, startOffset, pCompression);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,10 +7,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum JKRExpandSwitch {
|
||||
EXPAND_SWITCH_DEFAULT, /* Do nothing? treated same as 2 */
|
||||
#define JKRCOMPRESSION_NONE 0
|
||||
#define JKRCOMPRESSION_YAY0 1
|
||||
#define JKRCOMPRESSION_YAZ0 2
|
||||
#define JKRCOMPRESSION_ASR 3
|
||||
|
||||
typedef enum JKRExpandSwitch
|
||||
{
|
||||
EXPAND_SWITCH_DEFAULT, /* Do nothing? treated same as 2 */
|
||||
EXPAND_SWITCH_DECOMPRESS, /* Check for compression and decompress */
|
||||
EXPAND_SWITCH_NONE /* Do nothing */
|
||||
EXPAND_SWITCH_NONE /* Do nothing */
|
||||
} JKRExpandSwitch;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
#ifndef JKREXPHEAP_H
|
||||
#define JKREXPHEAP_H
|
||||
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "types.h"
|
||||
|
||||
class JKRExpHeap : public JKRHeap
|
||||
{
|
||||
public:
|
||||
class CMemBlock
|
||||
{
|
||||
public:
|
||||
CMemBlock* allocBack(u32, u8, u8, u8, u8);
|
||||
CMemBlock* allocFore(u32, u8, u8, u8, u8);
|
||||
void* free(JKRExpHeap*);
|
||||
static CMemBlock* getHeapBlock(void*);
|
||||
void initiate(CMemBlock*, CMemBlock*, u32, u8, u8);
|
||||
|
||||
void newGroupId(u8 groupId) { mGroupID = groupId; }
|
||||
bool isValid() const { return mUsageHeader == 'HM'; }
|
||||
bool _isTempMemBlock() const { return (mFlags & 0x80) ? true : false; }
|
||||
int getAlignment() const { return mFlags & 0x7f; }
|
||||
void* getContent() const { return (void*)(this + 1); }
|
||||
CMemBlock* getPrevBlock() const { return mPrev; }
|
||||
CMemBlock* getNextBlock() const { return mNext; }
|
||||
u32 getSize() const { return mAllocatedSpace; }
|
||||
u8 getGroupId() const { return mGroupID; }
|
||||
static CMemBlock* getBlock(void* data) { return (CMemBlock*)((u32)data + -0x10); }
|
||||
|
||||
u16 mUsageHeader; // _00
|
||||
u8 mFlags; // _02, a|bbbbbbb = a=temp, b=aln
|
||||
u8 mGroupID; // _03
|
||||
int mAllocatedSpace; // _04
|
||||
CMemBlock* mPrev; // _08
|
||||
CMemBlock* mNext; // _0C
|
||||
};
|
||||
|
||||
JKRExpHeap(void*, u32, JKRHeap*, bool);
|
||||
|
||||
virtual ~JKRExpHeap(); // _08
|
||||
virtual void* do_alloc(u32, int); // _10
|
||||
virtual void do_free(void*); // _14
|
||||
virtual void do_freeTail(); // _18
|
||||
virtual void do_freeAll(); // _1C
|
||||
virtual s32 do_resize(void*, u32); // _20
|
||||
virtual s32 do_getSize(void*); // _24
|
||||
virtual s32 do_getFreeSize(); // _28
|
||||
virtual s32 do_getTotalFreeSize(); // _2C
|
||||
virtual bool check(); // _34
|
||||
virtual bool dump_sort(); // _38
|
||||
virtual bool dump(); // _3C
|
||||
virtual s32 do_changeGroupID(u8); // _40
|
||||
virtual void state_register(TState*, u32) const; // _48
|
||||
virtual bool state_compare(const TState&, const TState&) const; // _4C
|
||||
|
||||
virtual u8 do_getCurrentGroupId() { return mCurrentGroupID; } // _44 (weak)
|
||||
virtual u32 getHeapType() { return 'EXPH'; } // _30 (weak)
|
||||
|
||||
void* allocFromHead(u32, int);
|
||||
void* allocFromHead(u32);
|
||||
void* allocFromTail(u32, int);
|
||||
void* allocFromTail(u32);
|
||||
void appendUsedList(CMemBlock*);
|
||||
static JKRExpHeap* create(u32, JKRHeap*, bool);
|
||||
static JKRExpHeap* create(void*, u32, JKRHeap*, bool);
|
||||
static JKRExpHeap* createRoot(int, bool);
|
||||
int freeGroup(u8 groupID);
|
||||
void joinTwoBlocks(CMemBlock*);
|
||||
void recycleFreeBlock(CMemBlock*);
|
||||
void removeFreeBlock(CMemBlock*);
|
||||
void setFreeBlock(CMemBlock*, CMemBlock*, CMemBlock*);
|
||||
|
||||
// unused/inlined:
|
||||
void removeUsedBlock(CMemBlock*);
|
||||
bool isEmpty();
|
||||
s32 getUsedSize(u8 groupId) const;
|
||||
|
||||
CMemBlock* getHeadUsedList() const { return mHeadUsedList; }
|
||||
void setAllocationMode(EAllocMode mode) { mCurrentAllocMode = mode; }
|
||||
|
||||
static s32 getUsedSize_(JKRExpHeap* expHeap)
|
||||
{
|
||||
// s32 totalFreeSize = expHeap->getTotalFreeSize();
|
||||
return expHeap->mSize - expHeap->getTotalFreeSize();
|
||||
}
|
||||
static u32 getState_(TState* state) { return getState_buf_(state); } // might instead be a pointer to a next state?
|
||||
|
||||
private:
|
||||
// _00 = VTBL
|
||||
// _00-_6C = JKRHeap
|
||||
u8 mCurrentAllocMode; // _6C
|
||||
u8 mCurrentGroupID; // _6D
|
||||
u8 _6E; // _6E
|
||||
void* _70; // _70
|
||||
u32 _74; // _74
|
||||
CMemBlock* mHead; // _78, free list
|
||||
CMemBlock* mTail; // _7C, free list
|
||||
CMemBlock* mHeadUsedList; // _80
|
||||
CMemBlock* mTailUsedList; // _84
|
||||
};
|
||||
|
||||
inline JKRExpHeap* JKRCreateExpHeap(u32 size, JKRHeap* parent, bool errorFlag)
|
||||
{
|
||||
return JKRExpHeap::create(size, parent, errorFlag);
|
||||
}
|
||||
|
||||
#endif /* JKREXPHEAP_H */
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "dolphin/dvd.h"
|
||||
#include "dolphin/os.h"
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
#include "JSystem/JKernel/JKRAram.h"
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
#include "JSystem/JKernel/JKRMacro.h"
|
||||
|
||||
@@ -14,8 +13,8 @@ public:
|
||||
inline JKRFile()
|
||||
: JKRDisposer()
|
||||
, mFileOpen(false)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~JKRFile() { }
|
||||
virtual bool open(const char* path) = 0;
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef _JKRFILEFINDER_H
|
||||
#define _JKRFILEFINDER_H
|
||||
|
||||
#include <dolphin/dvd.h>
|
||||
#include <dolphin/os.h>
|
||||
#include "types.h"
|
||||
|
||||
class JKRArchive;
|
||||
|
||||
struct JKRFileFinderBase
|
||||
{
|
||||
char* mFileName; // _00
|
||||
int mFileIndex; // _04
|
||||
u16 mFileID; // _08
|
||||
u16 mFileTypeFlags; // _0A
|
||||
};
|
||||
|
||||
class JKRFileFinder
|
||||
{
|
||||
public:
|
||||
JKRFileFinder()
|
||||
: mIsAvailable(false), mIsFileOrDir(false)
|
||||
{
|
||||
}
|
||||
|
||||
JKRFileFinderBase mBase;
|
||||
|
||||
virtual ~JKRFileFinder() {} // _08 (weak)
|
||||
virtual bool findNextFile() = 0; // _0C
|
||||
|
||||
bool isAvailable() const
|
||||
{
|
||||
return mIsAvailable;
|
||||
}
|
||||
|
||||
// _00 = VTBL
|
||||
|
||||
bool mIsAvailable; // _10
|
||||
bool mIsFileOrDir; // _11
|
||||
};
|
||||
|
||||
class JKRArcFinder : public JKRFileFinder
|
||||
{
|
||||
public:
|
||||
JKRArcFinder(JKRArchive*, long, long);
|
||||
|
||||
virtual ~JKRArcFinder() {} // _08 (weak)
|
||||
virtual bool findNextFile(); // _0C
|
||||
|
||||
// _00 = VTBL
|
||||
// _00-_14 = JKRFileFinder
|
||||
JKRArchive* mArchive; // _14
|
||||
long mStartIndex; // _18
|
||||
long mEndIndex; // _1C
|
||||
long mNextIndex; // _20
|
||||
};
|
||||
|
||||
class JKRDvdFinder : public JKRFileFinder
|
||||
{
|
||||
public:
|
||||
JKRDvdFinder(const char*);
|
||||
|
||||
virtual ~JKRDvdFinder() // _08 (weak)
|
||||
{
|
||||
if (mIsDvdOpen)
|
||||
{
|
||||
DVDCloseDir(&mDir);
|
||||
}
|
||||
}
|
||||
virtual bool findNextFile(); // _0C
|
||||
|
||||
// _00 = VTBL
|
||||
// _00-_14 = JKRFileFinder
|
||||
DVDDir mDir; // _14
|
||||
bool mIsDvdOpen; // _20
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef JKRFILELOADER_H_
|
||||
#define JKRFILELOADER_H_
|
||||
|
||||
#include "JSystem/JKernel/JKREnum.h"
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
|
||||
class JKRFileFinder;
|
||||
class JKRFileLoader : public JKRDisposer
|
||||
{
|
||||
public:
|
||||
JKRFileLoader();
|
||||
|
||||
virtual ~JKRFileLoader(); // _08
|
||||
virtual void unmount(); // _0C
|
||||
virtual bool becomeCurrent(const char*) = 0; // _10
|
||||
virtual void* getResource(const char* path) = 0; // _14
|
||||
virtual void* getResource(u32 type, const char* name) = 0; // _18
|
||||
virtual size_t readResource(void* resourceBuffer, u32 bufferSize, const char* path, JKRExpandSwitch expandSwitch) = 0; // _1C
|
||||
virtual size_t readResource(void* resourceBuffer, u32 bufferSize, u32 type, const char* name) = 0; // _20
|
||||
virtual void removeResourceAll() = 0; // _24
|
||||
virtual bool removeResource(void*) = 0; // _28
|
||||
virtual bool detachResource(void*) = 0; // _2C
|
||||
virtual long getResSize(const void*) const = 0; // _30
|
||||
virtual u32 countFile(const char*) const = 0; // _34
|
||||
virtual JKRFileFinder* getFirstFile(const char*) const = 0; // _38
|
||||
|
||||
bool isMounted() const { return mIsMounted; }
|
||||
u32 getVolumeType() const { return mVolumeType; }
|
||||
|
||||
static void changeDirectory(const char* dir);
|
||||
|
||||
static void* getGlbResource(const char*);
|
||||
static void* getGlbResource(const char*, JKRFileLoader* fileLoader);
|
||||
static size_t readGlbResource(void* resourceBuffer, u32 bufferSize, const char* path, JKRExpandSwitch expandSwitch);
|
||||
|
||||
static bool removeResource(void* resourceBuffer, JKRFileLoader* fileLoader);
|
||||
static bool detachResource(void* resourceBuffer, JKRFileLoader* fileLoader);
|
||||
|
||||
static JKRFileLoader* findVolume(const char**);
|
||||
static JKRFileFinder* findFirstFile(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;
|
||||
|
||||
protected:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ // JKRDisposer
|
||||
JSULink<JKRFileLoader> mFileLoaderLink; // 0x18
|
||||
const char* mVolumeName; // 0x28
|
||||
u32 mVolumeType; // 0x2C
|
||||
bool mIsMounted; // 0x30
|
||||
u8 field_0x31[3]; // 0x31
|
||||
u32 mMountCount; // 0x34
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef void JKRHeapErrorHandler(void *, u32, int);
|
||||
typedef void JKRHeapErrorHandler(void*, u32, int);
|
||||
|
||||
class JKRHeap : public JKRDisposer
|
||||
{
|
||||
@@ -24,29 +24,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void *_00; // _00
|
||||
void* _00; // _00
|
||||
int _04; // _04
|
||||
};
|
||||
|
||||
struct TArgument
|
||||
{
|
||||
TArgument(const JKRHeap *heap, u32 p2, bool p3)
|
||||
TArgument(const JKRHeap* heap, u32 p2, bool p3)
|
||||
: mHeap((heap) ? heap : JKRHeap::sCurrentHeap), mId(p2), mIsCompareOnDestructed(p3)
|
||||
{
|
||||
}
|
||||
|
||||
const JKRHeap *mHeap; // _00
|
||||
const JKRHeap* mHeap; // _00
|
||||
u32 mId; // _04
|
||||
bool mIsCompareOnDestructed; // _08
|
||||
};
|
||||
|
||||
TState(const JKRHeap *heap, u32 id, bool isCompareOnDestructed)
|
||||
TState(const JKRHeap* heap, u32 id, bool isCompareOnDestructed)
|
||||
: mUsedSize(0), mCheckCode(0), mArgument(heap, id, isCompareOnDestructed)
|
||||
{
|
||||
mArgument.mHeap->state_register(this, mArgument.mId);
|
||||
}
|
||||
|
||||
TState(JKRHeap *heap)
|
||||
TState(JKRHeap* heap)
|
||||
: mUsedSize(0), mCheckCode(0), mArgument(heap, 0xFFFFFFFF, true)
|
||||
{
|
||||
}
|
||||
@@ -57,13 +57,13 @@ public:
|
||||
bool isCompareOnDestructed() const { return mArgument.mIsCompareOnDestructed; };
|
||||
u32 getUsedSize() const { return mUsedSize; }
|
||||
u32 getCheckCode() const { return mCheckCode; }
|
||||
const JKRHeap *getHeap() const { return mArgument.mHeap; }
|
||||
const JKRHeap* getHeap() const { return mArgument.mHeap; }
|
||||
u32 getId() const { return mArgument.mId; }
|
||||
|
||||
// unused/inlined:
|
||||
TState(const JKRHeap::TState::TArgument &arg, const JKRHeap::TState::TLocation &location);
|
||||
TState(const JKRHeap::TState &other, bool p2);
|
||||
TState(const JKRHeap::TState &other, const JKRHeap::TState::TLocation &location, bool p3);
|
||||
TState(const JKRHeap::TState::TArgument& arg, const JKRHeap::TState::TLocation& location);
|
||||
TState(const JKRHeap::TState& other, bool p2);
|
||||
TState(const JKRHeap::TState& other, const JKRHeap::TState::TLocation& location, bool p3);
|
||||
|
||||
static bool bVerbose_;
|
||||
|
||||
@@ -76,19 +76,19 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
JKRHeap(void *, u32, JKRHeap *, bool);
|
||||
JKRHeap(void*, u32, JKRHeap*, bool);
|
||||
|
||||
bool setErrorFlag(bool errorFlag);
|
||||
bool isSubHeap(JKRHeap *heap) const;
|
||||
bool isSubHeap(JKRHeap* heap) const;
|
||||
|
||||
virtual ~JKRHeap();
|
||||
virtual void callAllDisposer();
|
||||
virtual void *do_alloc(u32, int) = 0;
|
||||
virtual void do_free(void *) = 0;
|
||||
virtual void* do_alloc(u32, int) = 0;
|
||||
virtual void do_free(void*) = 0;
|
||||
virtual void do_freeAll() = 0;
|
||||
virtual void do_freeTail() = 0;
|
||||
virtual s32 do_resize(void *, u32) = 0;
|
||||
virtual s32 do_getSize(void *) = 0;
|
||||
virtual s32 do_resize(void*, u32) = 0;
|
||||
virtual s32 do_getSize(void*) = 0;
|
||||
virtual s32 do_getFreeSize() = 0;
|
||||
virtual s32 do_getTotalFreeSize() = 0;
|
||||
virtual u32 getHeapType() = 0;
|
||||
@@ -97,54 +97,54 @@ public:
|
||||
virtual bool dump() = 0;
|
||||
virtual s32 do_changeGroupID(u8 newGroupID) { return 0; }
|
||||
virtual u8 do_getCurrentGroupId() { return 0; }
|
||||
virtual void state_register(JKRHeap::TState *, u32) const;
|
||||
virtual bool state_compare(JKRHeap::TState const &, JKRHeap::TState const &) const;
|
||||
virtual void state_dump(JKRHeap::TState const &) const;
|
||||
virtual void state_register(JKRHeap::TState*, u32) const;
|
||||
virtual bool state_compare(JKRHeap::TState const&, JKRHeap::TState const&) const;
|
||||
virtual void state_dump(JKRHeap::TState const&) const;
|
||||
|
||||
JKRHeap *becomeSystemHeap();
|
||||
JKRHeap *becomeCurrentHeap();
|
||||
JKRHeap* becomeSystemHeap();
|
||||
JKRHeap* becomeCurrentHeap();
|
||||
void destroy();
|
||||
void *alloc(u32, int);
|
||||
void free(void *);
|
||||
void* alloc(u32, int);
|
||||
void free(void*);
|
||||
void freeAll();
|
||||
void freeTail();
|
||||
void fillFreeArea();
|
||||
void resize(void *, u32);
|
||||
static s32 getSize(void *, JKRHeap*);
|
||||
void resize(void*, u32);
|
||||
static s32 getSize(void*, JKRHeap*);
|
||||
|
||||
// ... more functions
|
||||
|
||||
s32 getSize(void *ptr);
|
||||
s32 getSize(void* ptr);
|
||||
s32 getFreeSize();
|
||||
void *getMaxFreeBlock();
|
||||
void* getMaxFreeBlock();
|
||||
s32 getTotalFreeSize();
|
||||
u8 getCurrentGroupId();
|
||||
s32 changeGroupID(u8 newGroupId);
|
||||
u32 getMaxAllocatableSize(int alignment);
|
||||
JKRHeap *find(void *) const; // 0x80084640
|
||||
JKRHeap *findAllHeap(void *) const; // 0x8008492c
|
||||
JKRHeap* find(void*) const; // 0x80084640
|
||||
JKRHeap* findAllHeap(void*) const; // 0x8008492c
|
||||
void dispose_subroutine(u32 begin, u32 end);
|
||||
bool dispose(void *, u32); // 0x80084b9c
|
||||
void dispose(void *, void *); // 0x80084c2c
|
||||
bool dispose(void*, u32); // 0x80084b9c
|
||||
void dispose(void*, void*); // 0x80084c2c
|
||||
void dispose(); // 0x80084cb8
|
||||
|
||||
void appendDisposer(JKRDisposer *disposer)
|
||||
void appendDisposer(JKRDisposer* disposer)
|
||||
{
|
||||
mDisposerList.append(&disposer->mPointerLinks);
|
||||
}
|
||||
|
||||
void removeDisposer(JKRDisposer *disposer)
|
||||
void removeDisposer(JKRDisposer* disposer)
|
||||
{
|
||||
mDisposerList.remove(&disposer->mPointerLinks);
|
||||
}
|
||||
|
||||
void setDebugFill(bool debugFill) { mDebugFill = debugFill; }
|
||||
bool getDebugFill() const { return mDebugFill; }
|
||||
void *getStartAddr() const { return (void *)mStart; }
|
||||
void *getEndAddr() const { return (void *)mEnd; }
|
||||
void* getStartAddr() const { return (void*)mStart; }
|
||||
void* getEndAddr() const { return (void*)mEnd; }
|
||||
u32 getHeapSize() const { return mSize; }
|
||||
bool getErrorFlag() const { return mErrorFlag; }
|
||||
void callErrorHandler(JKRHeap *heap, u32 size, int alignment)
|
||||
void callErrorHandler(JKRHeap* heap, u32 size, int alignment)
|
||||
{
|
||||
if (mErrorHandler)
|
||||
{
|
||||
@@ -152,34 +152,59 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// TState related
|
||||
static u32 getState_buf_(TState* state) { return state->mBuf; } // might instead be a pointer to a next state?
|
||||
static void setState_u32ID_(TState* state, u32 id)
|
||||
{
|
||||
state->mArgument.mId = id;
|
||||
}
|
||||
static void setState_uUsedSize_(TState* state, u32 usedSize)
|
||||
{
|
||||
state->mUsedSize = usedSize;
|
||||
}
|
||||
static void setState_u32CheckCode_(TState* state, u32 checkCode) { state->mCheckCode = checkCode; }
|
||||
|
||||
void lock() const { OSLockMutex(const_cast<OSMutex*>(&mMutex)); }
|
||||
void unlock() const { OSUnlockMutex(const_cast<OSMutex*>(&mMutex)); }
|
||||
|
||||
JKRHeap* getParent()
|
||||
{
|
||||
return mChildTree.getParent()->getObject();
|
||||
}
|
||||
|
||||
const JSUTree<JKRHeap>& getHeapTree()
|
||||
{
|
||||
return mChildTree;
|
||||
}
|
||||
|
||||
// Unused
|
||||
void checkMemoryFilled(u8 *, u32 size, u8);
|
||||
void checkMemoryFilled(u8*, u32 size, u8);
|
||||
|
||||
static void destroy(JKRHeap *heap); // fabricated
|
||||
static bool initArena(char **, u32 *, int);
|
||||
static void *alloc(u32, int, JKRHeap *);
|
||||
static void copyMemory(void *, void *, u32);
|
||||
static void free(void *, JKRHeap *);
|
||||
static void state_dumpDifference(const TState &, const TState &);
|
||||
static JKRHeap *findFromRoot(void *);
|
||||
static JKRHeapErrorHandler *setErrorHandler(JKRHeapErrorHandler *);
|
||||
static void destroy(JKRHeap* heap); // fabricated
|
||||
static bool initArena(char**, u32*, int);
|
||||
static void* alloc(u32, int, JKRHeap*);
|
||||
static void copyMemory(void*, void*, u32);
|
||||
static void free(void*, JKRHeap*);
|
||||
static void state_dumpDifference(const TState&, const TState&);
|
||||
static JKRHeap* findFromRoot(void*);
|
||||
static JKRHeapErrorHandler* setErrorHandler(JKRHeapErrorHandler*);
|
||||
|
||||
static void *getCodeStart()
|
||||
static void* getCodeStart()
|
||||
{
|
||||
return mCodeStart;
|
||||
}
|
||||
|
||||
static void *getCodeEnd()
|
||||
static void* getCodeEnd()
|
||||
{
|
||||
return mCodeEnd;
|
||||
}
|
||||
|
||||
static void *getUserRamStart()
|
||||
static void* getUserRamStart()
|
||||
{
|
||||
return mUserRamStart;
|
||||
}
|
||||
|
||||
static void *getUserRamEnd()
|
||||
static void* getUserRamEnd()
|
||||
{
|
||||
return mUserRamEnd;
|
||||
}
|
||||
@@ -189,42 +214,42 @@ public:
|
||||
return mMemorySize;
|
||||
}
|
||||
|
||||
static JKRHeap *getCurrentHeap()
|
||||
static JKRHeap* getCurrentHeap()
|
||||
{
|
||||
return sCurrentHeap;
|
||||
}
|
||||
|
||||
static JKRHeap *getRootHeap()
|
||||
static JKRHeap* getRootHeap()
|
||||
{
|
||||
return sRootHeap;
|
||||
}
|
||||
|
||||
static JKRHeap *getSystemHeap()
|
||||
static JKRHeap* getSystemHeap()
|
||||
{
|
||||
return sSystemHeap;
|
||||
}
|
||||
|
||||
static void *mCodeStart;
|
||||
static void *mCodeEnd;
|
||||
static void *mUserRamStart;
|
||||
static void *mUserRamEnd;
|
||||
static void* mCodeStart;
|
||||
static void* mCodeEnd;
|
||||
static void* mUserRamStart;
|
||||
static void* mUserRamEnd;
|
||||
static u32 mMemorySize;
|
||||
|
||||
static JKRHeap *sSystemHeap;
|
||||
static JKRHeap *sCurrentHeap;
|
||||
static JKRHeap *sRootHeap;
|
||||
static JKRHeap* sSystemHeap;
|
||||
static JKRHeap* sCurrentHeap;
|
||||
static JKRHeap* sRootHeap;
|
||||
|
||||
static bool sDefaultFillFlag;
|
||||
static bool sDefaultFillCheckFlag;
|
||||
|
||||
static JKRHeapErrorHandler *mErrorHandler;
|
||||
static JKRHeapErrorHandler* mErrorHandler;
|
||||
|
||||
protected:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ // JKRDisposer
|
||||
/* 0x18 */ OSMutex mMutex;
|
||||
/* 0x30 */ void *mStart;
|
||||
/* 0x34 */ void *mEnd;
|
||||
/* 0x30 */ void* mStart;
|
||||
/* 0x34 */ void* mEnd;
|
||||
/* 0x38 */ u32 mSize;
|
||||
/* 0x3C */ bool mDebugFill;
|
||||
/* 0x3D */ bool mCheckMemoryFilled;
|
||||
@@ -237,52 +262,58 @@ protected:
|
||||
/* 0x6A */ u8 padding_0x6a[2];
|
||||
};
|
||||
|
||||
inline JKRHeap *JKRGetCurrentHeap()
|
||||
inline JKRHeap* JKRGetCurrentHeap()
|
||||
{
|
||||
return JKRHeap::getCurrentHeap();
|
||||
}
|
||||
|
||||
inline JKRHeap *JKRGetSystemHeap()
|
||||
inline JKRHeap* JKRGetSystemHeap()
|
||||
{
|
||||
return JKRHeap::getSystemHeap();
|
||||
}
|
||||
|
||||
inline JKRHeap *JKRGetRootHeap()
|
||||
inline JKRHeap* JKRGetRootHeap()
|
||||
{
|
||||
return JKRHeap::getRootHeap();
|
||||
}
|
||||
|
||||
inline void *JKRAllocFromSysHeap(u32 size, int alignment)
|
||||
inline void* JKRAllocFromSysHeap(u32 size, int alignment)
|
||||
{
|
||||
return JKRHeap::getSystemHeap()->alloc(size, alignment);
|
||||
}
|
||||
|
||||
inline void *JKRAllocFromHeap(JKRHeap *heap, u32 size, int alignment)
|
||||
inline void* JKRAllocFromHeap(JKRHeap* heap, u32 size, int alignment)
|
||||
{
|
||||
return JKRHeap::alloc(size, alignment, heap);
|
||||
}
|
||||
|
||||
inline void JKRFree(void *pBuf)
|
||||
inline void JKRFree(void* pBuf)
|
||||
{
|
||||
JKRHeap::free(pBuf, nullptr);
|
||||
}
|
||||
|
||||
inline void JKRFreeToSysHeap(void *buf)
|
||||
inline void JKRFreeToHeap(JKRHeap* heap, void* ptr)
|
||||
{
|
||||
JKRHeap::free(ptr, heap);
|
||||
}
|
||||
|
||||
inline void JKRFreeToSysHeap(void* buf)
|
||||
{
|
||||
JKRHeap::getSystemHeap()->free(buf);
|
||||
}
|
||||
|
||||
void JKRDefaultMemoryErrorRoutine(void *, u32, int);
|
||||
void JKRDefaultMemoryErrorRoutine(void*, u32, int);
|
||||
|
||||
void *operator new(size_t);
|
||||
void *operator new(size_t, s32);
|
||||
void *operator new(size_t, JKRHeap *, int);
|
||||
void* operator new(size_t);
|
||||
void* operator new(size_t, s32);
|
||||
void* operator new(size_t, JKRHeap*, int);
|
||||
inline void* operator new(size_t, void* buf) { return buf; } // i believe this is actually part of MSL_C?
|
||||
|
||||
void *operator new[](size_t);
|
||||
void *operator new[](size_t, s32);
|
||||
void *operator new[](size_t, JKRHeap *, int);
|
||||
void* operator new[](size_t);
|
||||
void* operator new[](size_t, s32);
|
||||
void* operator new[](size_t, JKRHeap*, int);
|
||||
|
||||
void operator delete(void *);
|
||||
void operator delete[](void *);
|
||||
void operator delete(void*);
|
||||
void operator delete[](void*);
|
||||
|
||||
#endif // !JKRHEAP_H
|
||||
|
||||
@@ -6,16 +6,62 @@
|
||||
#include "dolphin/os/OSThread.h"
|
||||
#include "dolphin/os/OSTime.h"
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
#include "JSystem/JUtility/JUTConsole.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
|
||||
struct JKRThread;
|
||||
|
||||
struct JKRThreadName_
|
||||
{
|
||||
s32 id;
|
||||
char* name;
|
||||
};
|
||||
|
||||
typedef void (*JKRThreadSwitch_PreCallback)(OSThread* current, OSThread* next);
|
||||
typedef void (*JKRThreadSwitch_PostCallback)(OSThread* current, OSThread* next);
|
||||
|
||||
class JKRThreadSwitch
|
||||
{
|
||||
public:
|
||||
JKRThreadSwitch(JKRHeap*);
|
||||
virtual void draw(JKRThreadName_* param_1, JUTConsole* param_2);
|
||||
virtual void draw(JKRThreadName_* param_1);
|
||||
virtual ~JKRThreadSwitch();
|
||||
|
||||
static JKRThreadSwitch* createManager(JKRHeap* heap);
|
||||
|
||||
JKRThread* enter(JKRThread* param_1, int param_2);
|
||||
static void callback(OSThread* param_1, OSThread* param_2);
|
||||
|
||||
static u32 getTotalCount() { return sTotalCount; }
|
||||
|
||||
private:
|
||||
static JKRThreadSwitch* sManager;
|
||||
static u32 sTotalCount;
|
||||
static u64 sTotalStart;
|
||||
static JKRThreadSwitch_PreCallback mUserPreCallback;
|
||||
static JKRThreadSwitch_PostCallback mUserPostCallback;
|
||||
|
||||
private:
|
||||
JKRHeap* mHeap; // _04
|
||||
bool mSetNextHeap; // _08
|
||||
u8 _09[3]; // _09, padding?
|
||||
u32 _0C; // _0C
|
||||
u32 _10; // _10
|
||||
u8 _14[4]; // _14 - unknown/padding
|
||||
s64 _18; // _18
|
||||
JUTConsole* mConsole; // _20
|
||||
JKRThreadName_* mThreadName; // _24
|
||||
};
|
||||
|
||||
class JKRThread : public JKRDisposer {
|
||||
public:
|
||||
JKRThread(u32 stackSize, int msgCount, int threadPrio);
|
||||
JKRThread(OSThread* osThread, int msgCount);
|
||||
|
||||
virtual ~JKRThread();
|
||||
__declspec(weak) virtual void* run();
|
||||
virtual void* run() { return nullptr; }
|
||||
|
||||
static void* start(void* param);
|
||||
static JSUList<JKRThread>* getList() { return &JKRThread::sThreadList; }
|
||||
@@ -55,4 +101,78 @@ protected:
|
||||
u32 mStackSize;
|
||||
};
|
||||
|
||||
// Unused class, function definitions from Sunshine and MKDD
|
||||
class JKRTask : public JKRThread
|
||||
{
|
||||
typedef void (*RequestCallback)(void*);
|
||||
|
||||
/**
|
||||
* @fabricated
|
||||
* @size{0xC}
|
||||
*/
|
||||
struct Request
|
||||
{
|
||||
RequestCallback mCb;
|
||||
void* mArg;
|
||||
void* mMsg;
|
||||
};
|
||||
|
||||
JKRTask(); // unused/inlined
|
||||
|
||||
virtual ~JKRTask(); // _08
|
||||
virtual void* run(); // _0C
|
||||
|
||||
bool request(RequestCallback, void*, void*);
|
||||
|
||||
static JKRTask* create();
|
||||
|
||||
// unused/inlined:
|
||||
Request* searchBlank();
|
||||
void requestJam(RequestCallback, void*, void*);
|
||||
void cancelAll();
|
||||
void createTaskEndMessageQueue(int, JKRHeap*);
|
||||
void destroyTaskEndMessageQueue();
|
||||
void waitQueueMessageBlock(OSMessageQueue*, int*);
|
||||
void waitQueueMessage(OSMessageQueue*, int*);
|
||||
|
||||
OSMessage waitMessageBlock()
|
||||
{
|
||||
OSMessage msg;
|
||||
OSReceiveMessage(&mMesgQueue, &msg, OS_MESSAGE_BLOCK);
|
||||
return msg;
|
||||
}
|
||||
|
||||
void destroy();
|
||||
|
||||
// Unused
|
||||
static OSMessage* sEndMesgBuffer;
|
||||
static u32 sEndMesgBufSize;
|
||||
|
||||
// u32 _78; // _78
|
||||
//JSULink<JKRTask> mTaskLink; // _7C, this didn't exist yet
|
||||
Request* mRequest; // _8C - ptr to request array
|
||||
u32 mRequestCnt; // _90 - amount of requests
|
||||
OSMessageQueue* mTaskMsgQueue; // _94
|
||||
|
||||
static JSUList<JKRTask> sTaskList;
|
||||
static u8 sEndMesgQueue[32]; // Unused
|
||||
};
|
||||
|
||||
/** @unused */
|
||||
struct JKRIdleThread : public JKRThread
|
||||
{
|
||||
virtual ~JKRIdleThread() {}; // _08
|
||||
virtual void* run() // _0C
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
};
|
||||
virtual void destroy() {} // 0x10
|
||||
|
||||
static void create(JKRHeap*, int, u32);
|
||||
|
||||
static JKRIdleThread* sThread;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef JSYSTEM_JSUPPORT_H
|
||||
#define JSYSTEM_JSUPPORT_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
inline u8 JSULoByte(u16 in) { return in & 0xff; }
|
||||
inline u8 JSUHiByte(u16 in) { return in >> 8; }
|
||||
|
||||
#endif
|
||||
@@ -9,7 +9,6 @@ class JSUFileInputStream : public JSURandomInputStream {
|
||||
public:
|
||||
JSUFileInputStream(JKRFile* file);
|
||||
|
||||
virtual ~JSUFileInputStream() { }
|
||||
virtual int readData(void* buf, s32 len);
|
||||
virtual int getLength() const { return ((JKRFile*)this->mObject)->getFileSize(); }
|
||||
virtual int getPosition() const { return this->mPosition; }
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef _JSYSTEM_JUT_JUTCONSOLE_H
|
||||
#define _JSYSTEM_JUT_JUTCONSOLE_H
|
||||
|
||||
#include "va_args.h"
|
||||
|
||||
class JUTConsole; // TODO
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
void JUTConsole_print_f_va_(JUTConsole*, const char*, va_list);
|
||||
|
||||
JUTConsole* JUTGetReportConsole();
|
||||
void JUTSetReportConsole(JUTConsole*);
|
||||
JUTConsole* JUTGetWarningConsole();
|
||||
void JUTSetWarningConsole(JUTConsole*);
|
||||
void JUTReportConsole(const char*);
|
||||
void JUTReportConsole_f(const char*, ...);
|
||||
void JUTReportConsole_f_va(const char*, va_list);
|
||||
void JUTWarningConsole(const char*);
|
||||
void JUTWarningConsole_f(const char*, ...);
|
||||
void JUTWarningConsole_f_va(const char*, va_list);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef _CTYPE_H
|
||||
#define _CTYPE_H
|
||||
|
||||
#include "types.h"
|
||||
#include "MSL_C/locale.h"
|
||||
#include "MSL_C/ctype_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
__declspec(weak) int isalpha(int __c);
|
||||
__declspec(weak) int isdigit(int __c);
|
||||
__declspec(weak) int isspace(int __c);
|
||||
__declspec(weak) int isupper(int __c);
|
||||
__declspec(weak) int isxdigit(int __c);
|
||||
|
||||
__declspec(weak) int tolower(int __c);
|
||||
__declspec(weak) int toupper(int __c);
|
||||
|
||||
// added underscore to avoid naming conflicts
|
||||
inline int _isalpha(int c) { return (int)(__ctype_map[(u8)c] & __letter); }
|
||||
inline int _isdigit(int c) { return (int)(__ctype_map[(u8)c] & __digit); }
|
||||
inline int _isspace(int c) { return (int)(__ctype_map[(u8)c] & __whitespace); }
|
||||
inline int _isupper(int c) { return (int)(__ctype_map[(u8)c] & __upper_case); }
|
||||
inline int _isxdigit(int c) { return (int)(__ctype_map[(u8)c] & __hex_digit); }
|
||||
inline int _tolower(int c) { return (c == -1 ? -1 : (int)__lower_map[(u8)c]); }
|
||||
inline int _toupper(int c) { return (c == -1 ? -1 : (int)__upper_map[(u8)c]); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef _MSL_CTYPE_API_H
|
||||
#define _MSL_CTYPE_API_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
extern unsigned char __ctype_map[256];
|
||||
extern unsigned char __lower_map[256];
|
||||
extern unsigned char __upper_map[256];
|
||||
|
||||
#define __control_char 0x01
|
||||
#define __motion_char 0x02
|
||||
#define __space_char 0x04
|
||||
#define __punctuation 0x08
|
||||
#define __digit 0x10
|
||||
#define __hex_digit 0x20
|
||||
#define __lower_case 0x40
|
||||
#define __upper_case 0x80
|
||||
|
||||
#define __letter (__lower_case | __upper_case)
|
||||
#define __alphanumeric (__letter | __digit)
|
||||
#define __graphic (__alphanumeric | __punctuation)
|
||||
#define __printable (__graphic | __space_char)
|
||||
#define __whitespace (__motion_char | __space_char)
|
||||
#define __control (__motion_char | __control_char)
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,130 @@
|
||||
#ifndef _LOCALE_H
|
||||
#define _LOCALE_H
|
||||
|
||||
#include "types.h"
|
||||
//#include "stdlib.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef int (*__decode_mbyte)(wchar_t *, const char *, size_t);
|
||||
typedef int (*__encode_mbyte)(char *, wchar_t);
|
||||
|
||||
struct lconv
|
||||
{
|
||||
char *decimal_point;
|
||||
char *thousands_sep;
|
||||
char *grouping;
|
||||
char *mon_decimal_point;
|
||||
char *mon_thousands_sep;
|
||||
char *mon_grouping;
|
||||
char *positive_sign;
|
||||
char *negative_sign;
|
||||
char *currency_symbol;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char n_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
char *int_curr_symbol;
|
||||
char int_frac_digits;
|
||||
char int_p_cs_precedes;
|
||||
char int_n_cs_precedes;
|
||||
char int_p_sep_by_space;
|
||||
char int_n_sep_by_space;
|
||||
char int_p_sign_posn;
|
||||
char int_n_sign_posn;
|
||||
};
|
||||
|
||||
struct _loc_mon_cmpt
|
||||
{
|
||||
char CmptName[8];
|
||||
char *mon_decimal_point;
|
||||
char *mon_thousands_sep;
|
||||
char *mon_grouping;
|
||||
char *positive_sign;
|
||||
char *negative_sign;
|
||||
char *currency_symbol;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char n_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
char *int_curr_symbol;
|
||||
char int_frac_digits;
|
||||
char int_p_cs_precedes;
|
||||
char int_n_cs_precedes;
|
||||
char int_p_sep_by_space;
|
||||
char int_n_sep_by_space;
|
||||
char int_p_sign_posn;
|
||||
char int_n_sign_posn;
|
||||
};
|
||||
|
||||
struct _loc_num_cmpt
|
||||
{
|
||||
char CmptName[8];
|
||||
char *decimal_point;
|
||||
char *thousands_sep;
|
||||
char *grouping;
|
||||
};
|
||||
|
||||
struct _loc_time_cmpt
|
||||
{
|
||||
char CmptName[8];
|
||||
char *am_pm;
|
||||
char *DateTime_Format;
|
||||
char *Twelve_hr_format;
|
||||
char *Date_Format;
|
||||
char *Time_Format;
|
||||
char *Day_Names;
|
||||
char *MonthNames;
|
||||
char *TimeZone;
|
||||
};
|
||||
|
||||
struct _loc_coll_cmpt
|
||||
{
|
||||
char CmptName[8];
|
||||
int char_start_value;
|
||||
int char_coll_tab_size;
|
||||
short char_spec_accents;
|
||||
unsigned short *char_coll_table_ptr;
|
||||
unsigned short *wchar_coll_seq_ptr;
|
||||
};
|
||||
|
||||
struct _loc_ctype_cmpt
|
||||
{
|
||||
char CmptName[8];
|
||||
const unsigned short *ctype_map_ptr;
|
||||
const unsigned char *upper_map_ptr;
|
||||
const unsigned char *lower_map_ptr;
|
||||
const unsigned short *wctype_map_ptr;
|
||||
const wchar_t *wupper_map_ptr;
|
||||
const wchar_t *wlower_map_ptr;
|
||||
__decode_mbyte decode_mb;
|
||||
__encode_mbyte encode_wc;
|
||||
};
|
||||
|
||||
struct __locale
|
||||
{
|
||||
struct __locale *next_locale;
|
||||
char locale_name[48];
|
||||
struct _loc_coll_cmpt *coll_cmpt_ptr;
|
||||
struct _loc_ctype_cmpt *ctype_cmpt_ptr;
|
||||
struct _loc_mon_cmpt *mon_cmpt_ptr;
|
||||
struct _loc_num_cmpt *num_cmpt_ptr;
|
||||
struct _loc_time_cmpt *time_cmpt_ptr;
|
||||
};
|
||||
|
||||
extern struct __locale _current_locale;
|
||||
extern struct lconv __lconv;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -2,7 +2,7 @@
|
||||
#define RAND_H
|
||||
#include "types.h"
|
||||
|
||||
void srand (u32 seeed);
|
||||
void srand(u32 seed);
|
||||
int rand(void);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -48,6 +48,11 @@ typedef u32 unknown;
|
||||
|
||||
#define ALIGN_PREV(u, align) (u & (~(align-1)))
|
||||
#define ALIGN_NEXT(u, align) ((u + (align-1)) & (~(align-1)))
|
||||
#define IS_ALIGNED(X, N) (((X) & ((N)-1)) == 0)
|
||||
#define IS_NOT_ALIGNED(X, N) (((X) & ((N)-1)) != 0)
|
||||
|
||||
#define FLAG_ON(V, F) (((V) & (F)) == 0)
|
||||
#define FLAG_OFF(V, F) (((V) & (F)) != 0)
|
||||
|
||||
#ifndef ATTRIBUTE_ALIGN
|
||||
#if defined(__MWERKS__) || defined(__GNUC__)
|
||||
|
||||
Reference in New Issue
Block a user