mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-07-07 12:03:27 -04:00
merge cuyler's PR
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
#ifndef JKRARAM_H
|
||||
#define JKRARAM_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/ar.h"
|
||||
#include "dolphin/os/OSMessage.h"
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JKernel/JKRThread.h"
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
|
||||
#define ALIGN_PREV(u, align) (u & (~(align-1)))
|
||||
#define ALIGN_NEXT(u, align) ((u + (align-1)) & (~(align-1)))
|
||||
|
||||
#define ARAM_GROUP_ID_ALL 0
|
||||
#define ARAM_GROUP_ID_DEFAULT 0xFF
|
||||
|
||||
#define ARAM_MESGBUF_COUNT 4
|
||||
|
||||
#define ARAMPIECE_DONE_CALLBACK 0
|
||||
#define ARAMPIECE_DONE_NONE 1
|
||||
#define ARAMPIECE_DONE_DECOMPRESS 2
|
||||
|
||||
class JKRAramHeap;
|
||||
class JKRDecompCommand;
|
||||
class JKRAMCommand;
|
||||
|
||||
class JKRAramBlock {
|
||||
JKRAramBlock(u32 address, u32 size, u32 freeSize, u8 groupID, bool tempMemory);
|
||||
|
||||
virtual ~JKRAramBlock();
|
||||
|
||||
JKRAramBlock* allocHead(u32 size, u8 groupID, JKRAramHeap* heap);
|
||||
JKRAramBlock* allocTail(u32 size, u8 groupID, JKRAramHeap* heap);
|
||||
|
||||
u32 getAddress() const { return this->mAddress; }
|
||||
u32 getSize() const { return this->mSize; }
|
||||
u32 getFreeSize() const { return this->mFreeSize; }
|
||||
bool isTempMemory() const { return this->mIsTempMemory; }
|
||||
void newGroupID(u8 groupID) { this->mGroupID = groupID; }
|
||||
|
||||
JSULink<JKRAramBlock> mLink;
|
||||
u32 mAddress;
|
||||
u32 mSize;
|
||||
u32 mFreeSize;
|
||||
u8 mGroupID;
|
||||
bool mIsTempMemory;
|
||||
|
||||
friend class JKRAramHeap;
|
||||
};
|
||||
|
||||
class JKRAram : public JKRThread {
|
||||
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 {
|
||||
Head = 0,
|
||||
Tail = 1
|
||||
};
|
||||
|
||||
JKRAramHeap(u32 baseAddress, u32 size);
|
||||
|
||||
virtual ~JKRAramHeap();
|
||||
|
||||
JKRAramBlock* alloc(u32 size, EAllocMode mode);
|
||||
void free(JKRAramBlock* block);
|
||||
JKRAramBlock* allocFromHead(u32 size);
|
||||
JKRAramBlock* allocFromTail(u32 size);
|
||||
u32 getFreeSize();
|
||||
u32 getTotalFreeSize();
|
||||
u32 getUsedSize(u8 groupID);
|
||||
void dump();
|
||||
|
||||
u8 getCurrentGroupID() const { return this->mGroupID; }
|
||||
JKRHeap* getMgrHeap() const { return this->mHeap; }
|
||||
|
||||
void lock() { OSLockMutex(&this->mMutex); }
|
||||
void unlock() { OSUnlockMutex(&this->mMutex); }
|
||||
|
||||
static JSUList<JKRAramBlock> sAramList;
|
||||
|
||||
OSMutex mMutex;
|
||||
JKRHeap* mHeap;
|
||||
u32 mHeadAddress;
|
||||
u32 mTailAddress;
|
||||
u32 mSize;
|
||||
u8 mGroupID;
|
||||
|
||||
friend class JKRAramBlock;
|
||||
};
|
||||
|
||||
class JKRAMCommand : public ARQRequest {
|
||||
public:
|
||||
typedef void (*AMCommandCallback)(u32);
|
||||
|
||||
JKRAMCommand();
|
||||
~JKRAMCommand();
|
||||
|
||||
JSULink<JKRAMCommand> mAramPieceCommandLink;
|
||||
JSULink<JKRAMCommand> mLink30;
|
||||
s32 mDirection;
|
||||
u32 mLength;
|
||||
u32 mSource;
|
||||
u32 mDestination;
|
||||
JKRAramBlock* mAramBlock;
|
||||
u8 _54[4];
|
||||
AMCommandCallback mCallback;
|
||||
OSMessageQueue* mCompletedMesgQueue;
|
||||
s32 mCallbackType;
|
||||
JKRDecompCommand* mDecompCommand;
|
||||
OSMessageQueue mMesgQueue;
|
||||
OSMessage mMesgBuffer[1];
|
||||
void* _8C;
|
||||
void* _90;
|
||||
void* _94;
|
||||
};
|
||||
|
||||
class JKRAramCommand {
|
||||
public:
|
||||
inline void setting(BOOL active, void* arg) {
|
||||
this->mActive = active;
|
||||
this->mArg = arg;
|
||||
}
|
||||
|
||||
BOOL mActive;
|
||||
void* mArg;
|
||||
};
|
||||
|
||||
class JKRAramPiece {
|
||||
public:
|
||||
static JKRAMCommand* prepareCommand(int direction, u32 source, u32 destination, u32 length, JKRAramBlock* aramBlock, JKRAMCommand::AMCommandCallback callback);
|
||||
static void sendCommand(JKRAMCommand* cmd);
|
||||
static JKRAMCommand* orderAsync(int direction, u32 source, u32 destination, u32 length, JKRAramBlock* aramBlock, JKRAMCommand::AMCommandCallback callback);
|
||||
static bool sync(JKRAMCommand* cmd, BOOL noBlock);
|
||||
static bool orderSync(int direction, u32 source, u32 destination, u32 length, JKRAramBlock* aramBlock);
|
||||
static void startDMA(JKRAMCommand* cmd);
|
||||
static void doneDMA(u32 arg);
|
||||
|
||||
static OSMutex mMutex;
|
||||
static JSUList<JKRAMCommand> sAramPieceCommandList;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
inline void JKRAramPcs_SendCommand(JKRAMCommand* cmd) {
|
||||
JKRAramPiece::sendCommand(cmd);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
#ifndef JKRDECOMP_H
|
||||
#define JKRDECOMP_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSMessage.h"
|
||||
#include "JSystem/JKernel/JKRThread.h"
|
||||
#include "JSystem/JKernel/JKRAram.h"
|
||||
|
||||
#define JKRDECOMP_MSG_BUF_COUNT 4
|
||||
#define JKRDECOMP_STACK_SIZE 0x4000
|
||||
#define JKRDECOMP_THREAD_MSG_BUF_COUNT 16
|
||||
|
||||
#define JKRDECOMP_READU32BE(ptr, offset) (((u32)ptr[offset] << 24) | ((u32)ptr[offset + 1] << 16) | ((u32)ptr[offset + 2] << 8) | (u32)ptr[offset + 3])
|
||||
|
||||
#define SZ_MIN_BACKSIZE 3
|
||||
#define SZ_DEFAULT_BACKSIZE 15 + SZ_MIN_BACKSIZE
|
||||
|
||||
#define SZP_GETBACKOFS(buf) (((*((u8*)buf) & 0xF) << 8) | (*(((u8*)buf)+1)))
|
||||
#define SZP_GETCOUNT(buf) (*((u16*)buf) >> 12)
|
||||
|
||||
typedef void DecompCallback(u32);
|
||||
|
||||
class JKRDecompCommand {
|
||||
public:
|
||||
enum TransferType {
|
||||
MRAM = 0,
|
||||
ARAM = 1
|
||||
};
|
||||
|
||||
JKRDecompCommand();
|
||||
~JKRDecompCommand();
|
||||
|
||||
u8 _00[4];
|
||||
u8* mSrcBuffer;
|
||||
u8* mDstBuffer;
|
||||
u32 mSrcLength;
|
||||
u32 mSkipCount;
|
||||
DecompCallback* mCallback;
|
||||
JKRDecompCommand* mCmd;
|
||||
OSMessageQueue* pMesgQueue1C;
|
||||
TransferType transferType;
|
||||
JKRAMCommand* mAMCommand;
|
||||
OSMessageQueue mMesgQueue;
|
||||
OSMessage mMesgBuffer[1];
|
||||
};
|
||||
|
||||
class JKRDecomp : public JKRThread {
|
||||
public:
|
||||
enum CompressionMode {
|
||||
NONE = 0,
|
||||
SZP = 1,
|
||||
SZS = 2
|
||||
};
|
||||
|
||||
JKRDecomp(s32 decompPriority);
|
||||
|
||||
virtual ~JKRDecomp();
|
||||
|
||||
virtual void* run();
|
||||
|
||||
static JKRDecompCommand* prepareCommand(u8* srcBuffer, u8* dstBuffer, u32 srcLength, u32 skipCount, DecompCallback* callback);
|
||||
static CompressionMode checkCompressed(u8* buf);
|
||||
static JKRDecomp* create(s32 decompPriority);
|
||||
static void decode(u8* srcBuffer, u8* dstBuffer, u32 srcLength, u32 skipCount);
|
||||
static void decodeSZP(u8* srcBuffer, u8* dstBuffer, u32 srcLength, u32 skipCount);
|
||||
static void decodeSZS(u8* srcBuffer, u8* dstBuffer, u32 srcLength, u32 skipCount);
|
||||
static bool orderSync(u8* srcBuffer, u8* dstBuffer, u32 srcLength, u32 skipCount);
|
||||
static JKRDecompCommand* orderAsync(u8* srcBuffer, u8* dstBuffer, u32 srcLength, u32 skipCount, DecompCallback* callback);
|
||||
static bool sync(JKRDecompCommand* cmd, BOOL noBlock);
|
||||
static BOOL sendCommand(JKRDecompCommand* cmd);
|
||||
|
||||
static OSMessageQueue sMessageQueue;
|
||||
static OSMessage sMessageBuffer[JKRDECOMP_MSG_BUF_COUNT];
|
||||
static JKRDecomp* sDecompObject;
|
||||
};
|
||||
|
||||
inline JKRDecomp* JKRCreateDecompManager(s32 priority) {
|
||||
return JKRDecomp::create(priority);
|
||||
}
|
||||
|
||||
inline JKRDecomp::CompressionMode JKRCheckCompressed(u8* buf) {
|
||||
return JKRDecomp::checkCompressed(buf);
|
||||
}
|
||||
|
||||
inline u32 JKRDecompExpandSize(u8* buf) {
|
||||
return (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];
|
||||
}
|
||||
|
||||
inline void JKRDecompress(u8* src, u8* dst, u32 srcLength, u32 skipCount) {
|
||||
JKRDecomp::orderSync(src, dst, srcLength, skipCount);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
#ifndef JKRDVDFILE_H
|
||||
#define JKRDVDFILE_H
|
||||
|
||||
#include "JSystem/JKernel/JKRFile.h"
|
||||
#include "JSystem/JSupport/JSUStream.h"
|
||||
|
||||
class JKRDvdFile;
|
||||
|
||||
struct JKRDvdFileInfo : public DVDFileInfo {
|
||||
JKRDvdFile* mFile;
|
||||
};
|
||||
|
||||
class JKRDvdFile : public JKRFile {
|
||||
public:
|
||||
JKRDvdFile();
|
||||
JKRDvdFile(const char* filename);
|
||||
JKRDvdFile(s32 entrynum);
|
||||
|
||||
virtual ~JKRDvdFile();
|
||||
|
||||
virtual bool open(const char* filename);
|
||||
virtual bool close();
|
||||
virtual int readData(void* data, s32 length, s32 ofs);
|
||||
virtual int writeData(const void* data, s32 length, s32 ofs);
|
||||
virtual u32 getFileSize() const { return this->mDvdFileInfo.length; }
|
||||
virtual bool open(s32 entrynum);
|
||||
|
||||
inline DVDFileInfo* getFileInfo() {
|
||||
return &this->mDvdFileInfo;
|
||||
}
|
||||
|
||||
inline int readDataAsync(void* addr, s32 length, s32 offset) {
|
||||
OSLockMutex(&this->mMutex1);
|
||||
s32 retAddr;
|
||||
|
||||
if (this->mThread2 != nullptr) {
|
||||
OSUnlockMutex(&this->mMutex1);
|
||||
retAddr = -1;
|
||||
}
|
||||
else {
|
||||
this->mThread2 = OSGetCurrentThread();
|
||||
retAddr = -1;
|
||||
if (DVDReadAsync(&this->mDvdFileInfo, addr, length, offset, JKRDvdFile::doneProcess)) {
|
||||
retAddr = this->sync();
|
||||
}
|
||||
|
||||
this->mThread2 = nullptr;
|
||||
OSUnlockMutex(&this->mMutex1);
|
||||
}
|
||||
|
||||
return retAddr;
|
||||
}
|
||||
|
||||
inline int writeDataAsync(const void* data, s32 length, s32 offset) { return -1; }
|
||||
|
||||
void initiate();
|
||||
s32 sync();
|
||||
|
||||
static void doneProcess(s32 result, DVDFileInfo* info);
|
||||
|
||||
static JSUList<JKRDvdFile> sDvdList;
|
||||
|
||||
protected:
|
||||
OSMutex mMutex1;
|
||||
OSMutex mMutex2;
|
||||
JKRAramBlock* mAramBlock;
|
||||
OSThread* mThread1;
|
||||
JSUFileInputStream* mInputStream;
|
||||
u32 _58;
|
||||
JKRDvdFileInfo mDvdFileInfo;
|
||||
OSMessageQueue mMessageQueue1;
|
||||
OSMessage mMsg1;
|
||||
OSMessageQueue mMessageQueue2;
|
||||
OSMessage mMsg2;
|
||||
JSULink<JKRDvdFile> mLink;
|
||||
OSThread* mThread2;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef JKRDVDRIPPER_H
|
||||
#define JKRDVDRIPPER_H
|
||||
|
||||
#include "types.h"
|
||||
#include "JSystem/JKernel/JKRDvdFile.h"
|
||||
|
||||
#define SZP_BUFFERSIZE 1024
|
||||
#define REF_BUFFERSIZE 0x1120
|
||||
|
||||
enum JKRExpandSwitch {
|
||||
EXPAND_SWITCH_DEFAULT, /* Do nothing? treated same as 2 */
|
||||
EXPAND_SWITCH_DECOMPRESS, /* Check for compression and decompress */
|
||||
EXPAND_SWITCH_NONE /* Do nothing */
|
||||
};
|
||||
|
||||
struct SZPHeader {
|
||||
u32 magic;
|
||||
u32 decompSize;
|
||||
};
|
||||
|
||||
class JKRDMCommand {
|
||||
JKRDMCommand();
|
||||
~JKRDMCommand();
|
||||
};
|
||||
|
||||
class JKRDvdRipper {
|
||||
public:
|
||||
enum EAllocDirection {
|
||||
ALLOC_DIR_DEFAULT = 0,
|
||||
ALLOC_DIR_TOP = 1,
|
||||
ALLOC_DIR_BOTTOM = 2
|
||||
};
|
||||
|
||||
static void* loadToMainRAM(const char* file, u8* buf, JKRExpandSwitch expandSwitch, u32 maxDest, JKRHeap* heap, EAllocDirection allocDir, u32 offset, int* compressMode);
|
||||
static void* loadToMainRAM(s32 entrynum, u8* buf, JKRExpandSwitch expandSwitch, u32 maxDest, JKRHeap* heap, EAllocDirection allocDir, u32 offset, int* compressMode);
|
||||
static void* loadToMainRAM(JKRDvdFile* file, u8* buf, JKRExpandSwitch expandSwitch, u32 maxDest, JKRHeap* heap, EAllocDirection allocDir, u32 offset, int* compressMode);
|
||||
|
||||
static inline bool isErrorRetry() { return JKRDvdRipper::errorRetry; }
|
||||
|
||||
static JSUList<JKRDMCommand> sDvdAsyncList;
|
||||
|
||||
static bool errorRetry;
|
||||
};
|
||||
|
||||
static int JKRDecompressFromDVD(JKRDvdFile* srcFile, void* buf, u32 size, u32 maxDest, u32 fileOffset, u32 srcOffset);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef JKRFILE_H
|
||||
#define JKRFILE_H
|
||||
|
||||
#include "types.h"
|
||||
#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"
|
||||
|
||||
class JKRFile : public JKRDisposer {
|
||||
public:
|
||||
inline JKRFile()
|
||||
: JKRDisposer()
|
||||
, mFileOpen(false)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~JKRFile() { }
|
||||
virtual bool open(const char* path) = 0;
|
||||
virtual bool close() = 0;
|
||||
virtual int readData(void* data, s32 length, s32 ofs) = 0;
|
||||
virtual int writeData(const void* data, s32 length, s32 ofs) = 0;
|
||||
virtual u32 getFileSize() const = 0;
|
||||
|
||||
void read(void* data, s32 length, s32 ofs);
|
||||
bool isAvailable() { return this->mFileOpen; }
|
||||
|
||||
protected:
|
||||
bool mFileOpen;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef JKRMARCO_H
|
||||
#define JKRMACRO_H
|
||||
|
||||
#define JKR_ISALIGNED(addr, alignment) ((((u32)addr) & (((u32)alignment)-1)) == 0)
|
||||
#define JKR_ISALIGNED32(addr) (JKR_ISALIGNED(addr, 32))
|
||||
|
||||
#define JKR_ISNOTALIGNED(addr, alignment) ((((u32)addr) & (((u32)alignment)-1)) != 0)
|
||||
#define JKR_ISNOTALIGNED32(addr) (JKR_ISNOTALIGNED(addr, 32))
|
||||
|
||||
#define JKR_ALIGN(addr, alignment) (((u32)addr) & (~(((u32)alignment)-1)))
|
||||
#define JKR_ALIGN32(addr) (JKR_ALIGN(addr, 32))
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef JKRTHREAD_H
|
||||
#define JKRTHREAD_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSMessage.h"
|
||||
#include "dolphin/os/OSThread.h"
|
||||
#include "dolphin/os/OSTime.h"
|
||||
#include "JSystem/JSupport/JSUList.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JKernel/JKRDisposer.h"
|
||||
|
||||
class JKRThread : public JKRDisposer {
|
||||
public:
|
||||
JKRThread(u32 stackSize, int msgCount, int threadPrio);
|
||||
JKRThread(OSThread* osThread, int msgCount);
|
||||
|
||||
virtual ~JKRThread();
|
||||
__declspec(weak) virtual void* run();
|
||||
|
||||
static void* start(void* param);
|
||||
static JSUList<JKRThread>* getList() { return &JKRThread::sThreadList; }
|
||||
|
||||
OSThread* getThreadRecord() const { return this->mThreadRecord; }
|
||||
void* getStack() const { return this->mStackMemory; }
|
||||
|
||||
void resume() { OSResumeThread(this->mThreadRecord); }
|
||||
void jamMessageBlock(OSMessage msg) { OSJamMessage(&this->mMesgQueue, msg, OS_MESSAGE_BLOCK); }
|
||||
void sendMessage(OSMessage msg) { OSSendMessage(&this->mMesgQueue, msg, OS_MESSAGE_NOBLOCK); }
|
||||
|
||||
OSMessage waitMessage(int* received) {
|
||||
OSMessage mesg;
|
||||
BOOL retrieved = OSReceiveMessage(&this->mMesgQueue, &mesg, OS_MESSAGE_NOBLOCK);
|
||||
if (received != nullptr) {
|
||||
*received = retrieved;
|
||||
}
|
||||
return mesg;
|
||||
}
|
||||
|
||||
OSMessage waitMeessageBlock() {
|
||||
OSMessage mesg;
|
||||
OSReceiveMessage(&this->mMesgQueue, &mesg, OS_MESSAGE_BLOCK);
|
||||
return mesg;
|
||||
}
|
||||
|
||||
static JSUList<JKRThread> sThreadList;
|
||||
|
||||
protected:
|
||||
JSULink<JKRThread> mLink;
|
||||
JKRHeap* mHeap;
|
||||
OSThread* mThreadRecord;
|
||||
OSMessageQueue mMesgQueue;
|
||||
OSMessage* mMesgBuffer;
|
||||
int mMesgCount;
|
||||
void* mStackMemory;
|
||||
u32 mStackSize;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef JSUFILEINPUTSTREAM_H
|
||||
#define JSUFILEINPUTSTREAM_H
|
||||
|
||||
#include "types.h"
|
||||
#include "JSystem/JKernel/JKRFile.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
|
||||
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; }
|
||||
virtual int seekPos(s32 offset, JSUStreamSeekFrom from);
|
||||
|
||||
/* These two functions are shown in the symbol map, but are unused. */
|
||||
// bool open(const char* path);
|
||||
// bool close();
|
||||
|
||||
protected:
|
||||
const void* mObject;
|
||||
s32 mPosition;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,110 @@
|
||||
#ifndef JSUINPUTSTREAM_H
|
||||
#define JSUINPUTSTREAM_H
|
||||
|
||||
#include "types.h"
|
||||
#include "JSystem/JSupport/JSUIosBase.h"
|
||||
|
||||
class JSUInputStream : public JSUIosBase {
|
||||
public:
|
||||
virtual ~JSUInputStream();
|
||||
virtual int getAvailable() const = 0;
|
||||
virtual int skip(s32 amount);
|
||||
virtual int readData(void* buf, s32 size) = 0;
|
||||
|
||||
int read(void* buf, s32 size);
|
||||
char* read(char* buf);
|
||||
char* readString();
|
||||
char* readString(char* buf, u16 len);
|
||||
|
||||
int read(s8& p) { return this->read(&p, sizeof(s8)); } /* @fabricated */
|
||||
int read(u8& p) { return this->read(&p, sizeof(u8)); }
|
||||
int read(bool& p) { return this->read(&p, sizeof(bool)); }
|
||||
int read(s16& p) { return this->read(&p, sizeof(s16)); } /* @fabricated */
|
||||
int read(u16& p) { return this->read(&p, sizeof(u16)); } /* @fabricated */
|
||||
int read(s32& p) { return this->read(&p, sizeof(s32)); } /* @fabricated */
|
||||
int read(u32& p) { return this->read(&p, sizeof(u32)); }
|
||||
int read(s64& p) { return this->read(&p, sizeof(s64)); } /* @fabricated */
|
||||
int read(u64& p) { return this->read(&p, sizeof(u64)); } /* @fabricated */
|
||||
|
||||
u8 read8b() {
|
||||
u8 b;
|
||||
this->read(&b, sizeof(u8));
|
||||
return b;
|
||||
}
|
||||
|
||||
u16 read16b() {
|
||||
u16 s;
|
||||
this->read(&s, sizeof(u16));
|
||||
return s;
|
||||
}
|
||||
|
||||
u32 read32b() {
|
||||
u32 i;
|
||||
this->read(&i, sizeof(u32));
|
||||
return i;
|
||||
}
|
||||
|
||||
/* @fabricated */
|
||||
s8 readS8() {
|
||||
s8 b;
|
||||
this->read(&b, sizeof(s8));
|
||||
return b;
|
||||
}
|
||||
|
||||
u8 readU8() {
|
||||
u8 b;
|
||||
this->read(&b, sizeof(u8));
|
||||
return b;
|
||||
}
|
||||
|
||||
s16 readS16() {
|
||||
s16 s;
|
||||
this->read(&s, sizeof(s16));
|
||||
return s;
|
||||
}
|
||||
|
||||
u16 readU16() {
|
||||
u16 s;
|
||||
this->read(&s, sizeof(u16));
|
||||
return s;
|
||||
}
|
||||
|
||||
s32 readS32() {
|
||||
s32 i;
|
||||
this->read(&i, sizeof(s32));
|
||||
return i;
|
||||
}
|
||||
|
||||
u32 readU32() {
|
||||
u32 i;
|
||||
this->read(&i, sizeof(u32));
|
||||
return i;
|
||||
}
|
||||
|
||||
JSUInputStream& operator>>(s8& p) {
|
||||
this->read(&p, sizeof(s8));
|
||||
return *this;
|
||||
}
|
||||
|
||||
JSUInputStream& operator>>(u8& p) {
|
||||
this->read(&p, sizeof(u8));
|
||||
return *this;
|
||||
}
|
||||
|
||||
JSUInputStream& operator>>(s16& p) {
|
||||
this->read(&p, sizeof(s16));
|
||||
return *this;
|
||||
}
|
||||
|
||||
JSUInputStream& operator>>(u16& p) {
|
||||
this->read(&p, sizeof(u16));
|
||||
return *this;
|
||||
}
|
||||
|
||||
JSUInputStream& operator>>(u32& p) {
|
||||
this->read(&p, sizeof(u32));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef JSUIOSBASE_H
|
||||
#define JSUIOSBASE_H
|
||||
|
||||
#include "types.h"
|
||||
#include "JSystem/JSupport/JSUStreamEnum.h"
|
||||
|
||||
class JSUIosBase {
|
||||
public:
|
||||
inline JSUIosBase() : mState(GOOD) { }
|
||||
|
||||
virtual ~JSUIosBase() { }
|
||||
|
||||
bool isGood() { return !this->mState; }
|
||||
void clrState(EIoState ioState) { this->mState &= ~ioState; }
|
||||
void setState(EIoState ioState) { this->mState |= ioState; }
|
||||
|
||||
u8 mState;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef JSURANDOMINPUTSTREAM_H
|
||||
#define JSURANDOMINPUTSTREAM_H
|
||||
|
||||
#include "types.h"
|
||||
#include "JSystem/JKernel/JKRFile.h"
|
||||
#include "JSystem/JSupport/JSUInputStream.h"
|
||||
|
||||
class JSURandomInputStream : public JSUInputStream {
|
||||
public:
|
||||
virtual ~JSURandomInputStream() { }
|
||||
|
||||
virtual int getAvailable() const { return this->getLength() - this->getPosition(); }
|
||||
virtual int skip(s32 amount);
|
||||
virtual int readData(void* buf, s32 count) = 0;
|
||||
virtual int getLength() const = 0;
|
||||
virtual int getPosition() const = 0;
|
||||
virtual int seekPos(s32 offset, JSUStreamSeekFrom from) = 0;
|
||||
|
||||
int align(s32 alignment);
|
||||
int peek(void* buf, s32 len);
|
||||
int seek(s32 offset, JSUStreamSeekFrom from);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef JSUSTREAM_H
|
||||
#define JSUSTREAM_H
|
||||
|
||||
#include "JSystem/JSupport/JSUStreamEnum.h"
|
||||
#include "JSystem/JSupport/JSUIosBase.h"
|
||||
#include "JSystem/JSupport/JSUInputStream.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
#include "JSystem/JSupport/JSUFileInputStream.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef JSUSTREAMENUM_H
|
||||
#define JSUSTREAMENUM_H
|
||||
|
||||
enum JSUStreamSeekFrom {
|
||||
SEEK_SET = 0,
|
||||
SEEK_CUR = 1,
|
||||
SEEK_END = 2
|
||||
};
|
||||
|
||||
enum EIoState {
|
||||
GOOD = 0,
|
||||
EOF = 1
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef JSYSTEM_H
|
||||
#define JSYSTEM_H
|
||||
|
||||
#include "dolphin/os.h"
|
||||
#include "JSystem/JKernel/JKRAram.h"
|
||||
//#include "JSystem/JUtility/JUTException.h"
|
||||
|
||||
#define JLOG(msg) (OSReport(msg))
|
||||
#define JLOGF(msg, ...) (OSReport(msg, __VA_ARGS__))
|
||||
|
||||
/* Macros which will remove debug OSReport calls when not compiled for debug */
|
||||
#ifdef JSYSTEM_DEBUG
|
||||
#define JREPORT(msg) OSReport(msg)
|
||||
#define JREPORTF(msg, ...) OSReport(msg, __VA_ARGS__)
|
||||
#else
|
||||
#define JREPORT(msg)
|
||||
#define JREPORTF(msg, ...)
|
||||
#endif
|
||||
|
||||
#ifdef JSYSTEM_DEBUG
|
||||
#define JPANICLINE(line) ()
|
||||
#define JPANIC(line, msg) () /* TODO: JUTException */
|
||||
#define JPANICF(line, msg, ...) () /* TODO: JUTException */
|
||||
#else
|
||||
#define JPANICLINE(line) (OSErrorLine(line, "Abort."))
|
||||
#define JPANIC(line, msg) (OSErrorLine(line, msg))
|
||||
#define JPANICF(line, msg, ...) (OSErrorLine(line, msg, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,29 +1,29 @@
|
||||
#ifndef _JSYSTEM_JUT_JUTASSERTION_H
|
||||
#define _JSYSTEM_JUT_JUTASSERTION_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void JC_JUTAssertion_changeDevice(u32);
|
||||
|
||||
#define JUT_PANIC(...)
|
||||
#define JUT_PANIC_F(...)
|
||||
#define JUT_CONFIRM_MESSAGE(...)
|
||||
#define JUT_WARNING(...)
|
||||
#define JUT_WARNING_F(...)
|
||||
#define JUT_ASSERT(...)
|
||||
#define JUT_ASSERT_F(...)
|
||||
#define JUT_ASSERT_MSG(...)
|
||||
#define JUT_MINMAX_ASSERT(...)
|
||||
#define JUT_MAX_ASSERT(...)
|
||||
#define JUT_LOG_F(...)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifndef _JSYSTEM_JUT_JUTASSERTION_H
|
||||
#define _JSYSTEM_JUT_JUTASSERTION_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void JC_JUTAssertion_changeDevice(u32);
|
||||
|
||||
#define JUT_PANIC(...)
|
||||
#define JUT_PANIC_F(...)
|
||||
#define JUT_CONFIRM_MESSAGE(...)
|
||||
#define JUT_WARNING(...)
|
||||
#define JUT_WARNING_F(...)
|
||||
#define JUT_ASSERT(...)
|
||||
#define JUT_ASSERT_F(...)
|
||||
#define JUT_ASSERT_MSG(...)
|
||||
#define JUT_MINMAX_ASSERT(...)
|
||||
#define JUT_MAX_ASSERT(...)
|
||||
#define JUT_LOG_F(...)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef _JSYSTEM_JUT_JUTDBPRINT_H
|
||||
#define _JSYSTEM_JUT_JUTDBPRINT_H
|
||||
|
||||
void* JC_JUTDbPrint_getManager(void);
|
||||
void JC_JUTDbPrint_setVisible(void*, int); // I know these are C++ but these were used to match a c function so I'll fix these when I need them or fix zurumode update.
|
||||
|
||||
|
||||
|
||||
#ifndef _JSYSTEM_JUT_JUTDBPRINT_H
|
||||
#define _JSYSTEM_JUT_JUTDBPRINT_H
|
||||
|
||||
void* JC_JUTDbPrint_getManager(void);
|
||||
void JC_JUTDbPrint_setVisible(void*, int); // I know these are C++ but these were used to match a c function so I'll fix these when I need them or fix zurumode update.
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user