mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-08-16 20:27:38 -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
|
||||
@@ -0,0 +1,73 @@
|
||||
#ifndef _DOLPHIN_PPCARCH_H
|
||||
#define _DOLPHIN_PPCARCH_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define HID0 0x3f0
|
||||
#define HID0_ICE 0x8000
|
||||
#define HID0_ICFI 0x800
|
||||
#define HID0_DCE 0x4000
|
||||
#define HID2 0x398
|
||||
#define HID2_LCE_BIT 3
|
||||
#define MSR_ME 0x1000
|
||||
#define LC_BASE_PREFIX 0xE000
|
||||
#define DBAT3L 3
|
||||
#define DBAT3U 3
|
||||
#define DMA_U 0x39a
|
||||
#define DMA_L 0x39b
|
||||
#define DMA_L_STORE 0
|
||||
#define DMA_L_TRIGGER 2
|
||||
#define LC_MAX_DMA_BLOCKS 128
|
||||
#define LC_MAX_DMA_BYTES 0x1000
|
||||
|
||||
#define MSR_IR 0x00000020 // instruction relocate
|
||||
#define MSR_DR 0x00000010 // data relocate
|
||||
|
||||
#define HID2_DCHERR 0x00800000 // ERROR: dcbz_l cache hit
|
||||
#define HID2_DNCERR 0x00400000 // ERROR: DMA access to normal cache
|
||||
#define HID2_DCMERR 0x00200000 // ERROR: DMA cache miss error
|
||||
#define HID2_DQOERR 0x00100000 // ERROR: DMA queue overflow
|
||||
#define HID2_DCHEE 0x00080000 // dcbz_l cache hit error enable
|
||||
#define HID2_DNCEE 0x00040000 // DMA access to normal cache error enable
|
||||
#define HID2_DCMEE 0x00020000 // DMA cache miss error error enable
|
||||
#define HID2_DQOEE 0x00010000 // DMA queue overflow error enable
|
||||
|
||||
#define L2CR_L2E 0x80000000 // L2 Enable
|
||||
#define L2CR_L2I 0x00200000 // Global invalidate
|
||||
#define L2CR_L2IP 0x00000001 // L2 global invalidate in progress
|
||||
|
||||
#define SRR1_DMA_BIT 0x00200000
|
||||
#define SRR1_L2DP_BIT 0x00100000
|
||||
|
||||
u32 PPCMfmsr();
|
||||
void PPCMtmsr(u32 newMSR);
|
||||
// u32 PPCOrMsr(u32 value);
|
||||
void PPCOrMsr();
|
||||
u32 PPCMfhid0();
|
||||
void PPCMthid0(u32 newHID0);
|
||||
u32 PPCMfl2cr();
|
||||
void PPCMtl2cr(u32 newL2cr);
|
||||
void PPCMtdec(u32 newDec);
|
||||
void PPCSync();
|
||||
void PPCHalt();
|
||||
u32 PPCMffpscr();
|
||||
void PPCMtfpscr(u32 newFPSCR);
|
||||
u32 PPCMfhid2();
|
||||
void PPCMthid2(u32 newhid2);
|
||||
u32 PPCMfwpar();
|
||||
void PPCMtwpar(u32 newwpar);
|
||||
void PPCEnableSpeculation();
|
||||
void PPCDisableSpeculation();
|
||||
void PPCSetFpIEEEMode();
|
||||
void PPCSetFpNonIEEEMode();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,90 @@
|
||||
#ifndef _DOLPHIN_AR_H
|
||||
#define _DOLPHIN_AR_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
///////////////// AR TYPES /////////////////
|
||||
typedef struct ARQRequest ARQRequest;
|
||||
|
||||
// AR callback function type.
|
||||
typedef void (*ARCallback)(void);
|
||||
|
||||
// ARQ callback function type.
|
||||
typedef void (*ARQCallback)(u32 ptrToRequest);
|
||||
|
||||
struct ARQRequest {
|
||||
ARQRequest* next; // _00
|
||||
u32 owner; // _04
|
||||
u32 type; // _08
|
||||
u32 priority; // _0C
|
||||
u32 source; // _10
|
||||
u32 dest; // _14
|
||||
u32 length; // _18
|
||||
ARQCallback callback; // _1C
|
||||
};
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
/////////////// AR FUNCTIONS ///////////////
|
||||
// ARQ functions.
|
||||
void ARQInit();
|
||||
void ARQPostRequest(ARQRequest* task, u32 owner, u32 type, u32 priority, u32 source, u32 dest, u32 length, ARQCallback callback);
|
||||
|
||||
// AR functions.
|
||||
ARCallback ARRegisterDMACallback(ARCallback callback);
|
||||
u32 ARGetDMAStatus();
|
||||
void ARStartDMA(u32 type, u32 mainmem_addr, u32 aram_addr, u32 length);
|
||||
u32 ARAlloc(u32 length);
|
||||
u32 ARInit(u32* stack_index_addr, u32 num_entries);
|
||||
u32 ARGetBaseAddress();
|
||||
u32 ARGetSize();
|
||||
|
||||
// Unused/inlined in P2.
|
||||
u32 ARFree(u32* length);
|
||||
BOOL ARCheckInit();
|
||||
void ARReset();
|
||||
void ARSetSize();
|
||||
u32 ARGetInternalSize();
|
||||
void ARClear(u32 flag);
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
//////////////// AR DEFINES ////////////////
|
||||
// AR defines.
|
||||
#define AR_STACK_INDEX_ENTRY_SIZE sizeof(u32)
|
||||
|
||||
#define ARAM_DIR_MRAM_TO_ARAM 0x00
|
||||
#define ARAM_DIR_ARAM_TO_MRAM 0x01
|
||||
|
||||
#define AR_CLEAR_INTERNAL_ALL 0x00
|
||||
#define AR_CLEAR_INTERNAL_USER 0x01
|
||||
#define AR_CLEAR_EXPANSION 0x02
|
||||
|
||||
#define __AR_ARAM_OS_BASE_ADDR 0x0000 // OS area at bottom of ARAM
|
||||
#define __AR_ARAM_USR_BASE_ADDR 0x4000 // USR area at 16KB (0x4000)
|
||||
|
||||
// AR macros.
|
||||
#define ARStartDMARead(mmem, aram, len) ARStartDMA(ARAM_DIR_ARAM_TO_MRAM, mmem, aram, len)
|
||||
#define ARStartDMAWrite(mmem, aram, len) ARStartDMA(ARAM_DIR_MRAM_TO_ARAM, mmem, aram, len)
|
||||
|
||||
// ARQ defines.
|
||||
#define ARQ_DMA_ALIGNMENT 32
|
||||
#define ARQ_CHUNK_SIZE_DEFAULT 4096
|
||||
|
||||
#define ARQ_TYPE_MRAM_TO_ARAM ARAM_DIR_MRAM_TO_ARAM
|
||||
#define ARQ_TYPE_ARAM_TO_MRAM ARAM_DIR_ARAM_TO_MRAM
|
||||
|
||||
#define ARQ_PRIORITY_LOW 0
|
||||
#define ARQ_PRIORITY_HIGH 1
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,202 @@
|
||||
#ifndef _DOLPHIN_DVD_H
|
||||
#define _DOLPHIN_DVD_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
/////////// DVD TYPES ///////////
|
||||
typedef struct DVDCommandBlock DVDCommandBlock;
|
||||
typedef struct DVDFileInfo DVDFileInfo;
|
||||
|
||||
// Callback function types.
|
||||
typedef void (*DVDCallback)(s32 result, DVDFileInfo* fileInfo);
|
||||
typedef void (*DVDCBCallback)(s32 result, DVDCommandBlock* block);
|
||||
typedef void (*DVDLowCallback)(u32 intType);
|
||||
typedef void (*DVDDoneReadCallback)(s32, DVDFileInfo*);
|
||||
typedef void (*DVDOptionalCommandChecker)(DVDCommandBlock* block, DVDLowCallback callback);
|
||||
|
||||
typedef struct DVDDriveInfo {
|
||||
u16 revisionLevel; // _00
|
||||
u16 deviceCode; // _02
|
||||
u32 releaseDate; // _04
|
||||
u8 padding[24]; // _08
|
||||
} DVDDriveInfo;
|
||||
|
||||
// Struct for DVD information (size 0x20)
|
||||
typedef struct DVDDiskID {
|
||||
char gameName[4]; // _00
|
||||
char company[2]; // _04
|
||||
u8 diskNumber; // _06
|
||||
u8 gameVersion; // _07
|
||||
u8 streaming; // _08
|
||||
u8 streamBufSize; // _09, default = 0
|
||||
u8 padding[22]; // _0A, all 0s
|
||||
} DVDDiskID;
|
||||
|
||||
// Struct for command information (size 0x30).
|
||||
struct DVDCommandBlock {
|
||||
DVDCommandBlock* next; // _00
|
||||
DVDCommandBlock* prev; // _04
|
||||
u32 command; // _08
|
||||
s32 state; // _0C
|
||||
u32 offset; // _10
|
||||
u32 length; // _14
|
||||
void* addr; // _18
|
||||
u32 currTransferSize; // _1C
|
||||
u32 transferredSize; // _20
|
||||
DVDDiskID* id; // _24
|
||||
DVDCBCallback callback; // _28
|
||||
void* userData; // _2C
|
||||
};
|
||||
|
||||
// Struct for file information (size 0x3C).
|
||||
// NB: we had this as DVDPlayer previously.
|
||||
struct DVDFileInfo {
|
||||
DVDCommandBlock cBlock; // _00
|
||||
u32 startAddr; // _30
|
||||
u32 length; // _34
|
||||
DVDCallback callback; // _38
|
||||
};
|
||||
|
||||
// Struct for directory information (size 0xC).
|
||||
typedef struct DVDDir {
|
||||
u32 entryNum; // _00
|
||||
u32 location; // _04
|
||||
u32 next; // _08
|
||||
} DVDDir;
|
||||
|
||||
// Struct for directory entries (size 0xC).
|
||||
typedef struct DVDDirEntry {
|
||||
u32 entryNum; // _00
|
||||
BOOL isDir; // _04
|
||||
char* name; // _08
|
||||
} DVDDirEntry;
|
||||
|
||||
// Struct for handing queues.
|
||||
typedef struct DVDQueue DVDQueue;
|
||||
|
||||
struct DVDQueue {
|
||||
DVDQueue* mHead; // _00
|
||||
DVDQueue* mTail; // _04
|
||||
};
|
||||
|
||||
// DVD Boot information instructions.
|
||||
// Struct 1.
|
||||
typedef struct DVDBB1 {
|
||||
u32 appLoaderLength; // _00
|
||||
void* appLoaderFunc1; // _04
|
||||
void* appLoaderFunc2; // _08
|
||||
void* appLoaderFunc3; // _0C
|
||||
} DVDBB1;
|
||||
|
||||
// Struct 2.
|
||||
typedef struct DVDBB2 {
|
||||
u32 bootFilePosition; // _00
|
||||
u32 FSTPosition; // _04
|
||||
u32 FSTLength; // _08
|
||||
u32 FSTMaxLength; // _0C
|
||||
void* FSTAddress; // _10
|
||||
u32 userPosition; // _14
|
||||
u32 userLength; // _18
|
||||
u32 reserved_1C; // _1C
|
||||
} DVDBB2;
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
///////// DVD FUNCTIONS //////////
|
||||
// Basic DVD functions.
|
||||
void DVDInit();
|
||||
BOOL DVDOpen(char* filename, DVDFileInfo* fileInfo);
|
||||
BOOL DVDFastOpen(s32 entryNum, DVDFileInfo* fileInfo);
|
||||
s32 DVDReadPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, s32 prio);
|
||||
BOOL DVDReadAsyncPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, DVDCallback callback, s32 prio);
|
||||
BOOL DVDClose(DVDFileInfo* fileInfo);
|
||||
|
||||
void DVDResume();
|
||||
void DVDReset();
|
||||
|
||||
BOOL DVDCancelAsync(DVDCommandBlock* block, DVDCBCallback callback);
|
||||
s32 DVDCancel(DVDCommandBlock* block);
|
||||
|
||||
s32 DVDChangeDisk(DVDCommandBlock* block, DVDDiskID* id);
|
||||
BOOL DVDChangeDiskAsync(DVDCommandBlock* block, DVDDiskID* id, DVDCBCallback callback);
|
||||
|
||||
// Status functions.
|
||||
s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block);
|
||||
s32 DVDGetDriveStatus();
|
||||
BOOL DVDSetAutoInvalidation(BOOL doAutoInval);
|
||||
void* DVDGetFSTLocation();
|
||||
|
||||
// DVD Dir functions.
|
||||
BOOL DVDOpenDir(char* dirName, DVDDir* dir);
|
||||
BOOL DVDReadDir(DVDDir* dir, DVDDirEntry* dirEntry);
|
||||
BOOL DVDCloseDir(DVDDir* dir);
|
||||
BOOL DVDGetCurrentDir(char* path, u32 maxLength);
|
||||
BOOL DVDChangeDir(char* dirName);
|
||||
s32 DVDConvertPathToEntrynum(char* path);
|
||||
|
||||
// Other disk functions.
|
||||
s32 DVDGetTransferredSize(DVDFileInfo* fileInfo);
|
||||
DVDDiskID* DVDGetCurrentDiskID();
|
||||
BOOL DVDCompareDiskID(DVDDiskID* id1, DVDDiskID* id2);
|
||||
DVDLowCallback DVDLowClearCallback();
|
||||
|
||||
BOOL DVDCheckDisk();
|
||||
|
||||
// Unused/inlined in P2.
|
||||
void DVDPause();
|
||||
s32 DVDSeekPrio(DVDFileInfo* fileInfo, s32 offset, s32 prio);
|
||||
BOOL DVDSeekAsyncPrio(DVDFileInfo* fileInfo, s32 offset, DVDCallback callback, s32 prio);
|
||||
s32 DVDGetFileInfoStatus(DVDFileInfo* fileInfo);
|
||||
BOOL DVDFastOpenDir(s32 entryNum, DVDDir* dir);
|
||||
BOOL DVDCancelAllAsync(DVDCBCallback callback);
|
||||
s32 DVDCancelAll();
|
||||
void DVDDumpWaitingQueue();
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
////// USEFUL DVD DEFINES ////////
|
||||
// Macro for reading.
|
||||
#define DVDReadAsync(fileInfo, addr, length, offset, callback) DVDReadAsyncPrio((fileInfo), (addr), (length), (offset), (callback), 2)
|
||||
#define DVDGetFileInfoStatus(fileInfo) DVDGetCommandBlockStatus(&(fileInfo)->cBlock)
|
||||
|
||||
// Minimum transfer size.
|
||||
#define DVD_MIN_TRANSFER_SIZE 32
|
||||
|
||||
// DVD states.
|
||||
#define DVD_STATE_FATAL_ERROR -1
|
||||
#define DVD_STATE_END 0
|
||||
#define DVD_STATE_BUSY 1
|
||||
#define DVD_STATE_WAITING 2
|
||||
#define DVD_STATE_COVER_CLOSED 3
|
||||
#define DVD_STATE_NO_DISK 4
|
||||
#define DVD_STATE_COVER_OPEN 5
|
||||
#define DVD_STATE_WRONG_DISK 6
|
||||
#define DVD_STATE_MOTOR_STOPPED 7
|
||||
#define DVD_STATE_PAUSING 8
|
||||
#define DVD_STATE_IGNORED 9
|
||||
#define DVD_STATE_CANCELED 10
|
||||
#define DVD_STATE_RETRY 11
|
||||
|
||||
// File info states.
|
||||
#define DVD_FILEINFO_READY 0
|
||||
#define DVD_FILEINFO_BUSY 1
|
||||
|
||||
// DVD results.
|
||||
#define DVD_RESULT_GOOD 0
|
||||
#define DVD_RESULT_FATAL_ERROR -1
|
||||
#define DVD_RESULT_IGNORED -2
|
||||
#define DVD_RESULT_CANCELED -3
|
||||
|
||||
#define DVD_AIS_SUCCESS 0
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -3,11 +3,17 @@
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSContext.h"
|
||||
#include "dolphin/os/OSMessage.h"
|
||||
#include "va_args.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// __ppc_eabi_init
|
||||
extern void __OSPSInit();
|
||||
extern void __OSFPRInit();
|
||||
extern void __OSCacheInit();
|
||||
|
||||
void OSPanic(const char *file, int line, const char *message, ...);
|
||||
void OSReport(const char*, ...);
|
||||
void OSVReport(const char* format, va_list list);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef _DOLPHIN_OS_OSMESSAGE_H
|
||||
#define _DOLPHIN_OS_OSMESSAGE_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSUtil.h"
|
||||
#include "dolphin/os/OSThread.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
///////// MESSAGE TYPES //////////
|
||||
typedef struct OSMessageQueue OSMessageQueue;
|
||||
|
||||
// Useful typedef for messages.
|
||||
typedef void* OSMessage;
|
||||
|
||||
// Struct for managing the message queue.
|
||||
struct OSMessageQueue {
|
||||
OSThreadQueue queueSend; // _00
|
||||
OSThreadQueue queueReceive; // _08
|
||||
OSMessage* msgArray; // _10, array of messages.
|
||||
int msgCount; // _14, array limit size.
|
||||
int firstIndex; // _18, first message index in array.
|
||||
int usedCount; // _1C, actual number of used messages.
|
||||
};
|
||||
|
||||
// Defines for message flags for sending/receiving.
|
||||
#define OS_MESSAGE_NOBLOCK (0)
|
||||
#define OS_MESSAGE_BLOCK (1)
|
||||
|
||||
typedef enum {
|
||||
OS_MSG_PERSISTENT = (1 << 0),
|
||||
} OSMessageFlags;
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
/////// MESSAGE FUNCTIONS ////////
|
||||
// Functions for handling messages.
|
||||
void OSInitMessageQueue(OSMessageQueue* queue, OSMessage* msgArray, int msgCount);
|
||||
BOOL OSSendMessage(OSMessageQueue* queue, OSMessage msg, int flags);
|
||||
BOOL OSJamMessage(OSMessageQueue* queue, OSMessage msg, int flags);
|
||||
BOOL OSReceiveMessage(OSMessageQueue* queue, OSMessage* msgPtr, int flags);
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -8,26 +8,26 @@ extern "C"
|
||||
|
||||
#include "dolphin/os/OSThread.h"
|
||||
|
||||
struct OSMutex
|
||||
{
|
||||
OSThreadQueue queue;
|
||||
OSThread *thread; // the current owner
|
||||
s32 count; // lock count
|
||||
OSMutexLink link; // for OSThread.queueMutex
|
||||
};
|
||||
struct OSMutex
|
||||
{
|
||||
OSThreadQueue queue;
|
||||
OSThread *thread; // the current owner
|
||||
s32 count; // lock count
|
||||
OSMutexLink link; // for OSThread.queueMutex
|
||||
};
|
||||
|
||||
struct OSCond
|
||||
{
|
||||
OSThreadQueue queue;
|
||||
};
|
||||
struct OSCond
|
||||
{
|
||||
OSThreadQueue queue;
|
||||
};
|
||||
|
||||
void OSInitMutex(OSMutex *mutex);
|
||||
void OSLockMutex(OSMutex *mutex);
|
||||
void OSUnlockMutex(OSMutex *mutex);
|
||||
BOOL OSTryLockMutex(OSMutex *mutex);
|
||||
void OSInitCond(OSCond *cond);
|
||||
void OSWaitCond(OSCond *cond, OSMutex *mutex);
|
||||
void OSSignalCond(OSCond *cond);
|
||||
void OSInitMutex(OSMutex *mutex);
|
||||
void OSLockMutex(OSMutex *mutex);
|
||||
void OSUnlockMutex(OSMutex *mutex);
|
||||
BOOL OSTryLockMutex(OSMutex *mutex);
|
||||
void OSInitCond(OSCond *cond);
|
||||
void OSWaitCond(OSCond *cond, OSMutex *mutex);
|
||||
void OSSignalCond(OSCond *cond);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -8,75 +8,75 @@ extern "C"
|
||||
|
||||
#include "dolphin/os/OSContext.h"
|
||||
|
||||
typedef struct OSThread OSThread;
|
||||
typedef struct OSThreadQueue OSThreadQueue;
|
||||
typedef struct OSThreadLink OSThreadLink;
|
||||
typedef s32 OSPriority; // 0 highest, 31 lowest
|
||||
typedef struct OSThread OSThread;
|
||||
typedef struct OSThreadQueue OSThreadQueue;
|
||||
typedef struct OSThreadLink OSThreadLink;
|
||||
typedef s32 OSPriority; // 0 highest, 31 lowest
|
||||
|
||||
typedef struct OSMutex OSMutex;
|
||||
typedef struct OSMutexQueue OSMutexQueue;
|
||||
typedef struct OSMutexLink OSMutexLink;
|
||||
typedef struct OSCond OSCond;
|
||||
typedef struct OSMutex OSMutex;
|
||||
typedef struct OSMutexQueue OSMutexQueue;
|
||||
typedef struct OSMutexLink OSMutexLink;
|
||||
typedef struct OSCond OSCond;
|
||||
|
||||
typedef void (*OSIdleFunction)(void *param);
|
||||
typedef void (*OSIdleFunction)(void *param);
|
||||
|
||||
struct OSThreadQueue
|
||||
{
|
||||
OSThread *head;
|
||||
OSThread *tail;
|
||||
};
|
||||
struct OSThreadQueue
|
||||
{
|
||||
OSThread *head;
|
||||
OSThread *tail;
|
||||
};
|
||||
|
||||
struct OSThreadLink
|
||||
{
|
||||
OSThread *next;
|
||||
OSThread *prev;
|
||||
};
|
||||
struct OSThreadLink
|
||||
{
|
||||
OSThread *next;
|
||||
OSThread *prev;
|
||||
};
|
||||
|
||||
struct OSMutexQueue
|
||||
{
|
||||
OSMutex *head;
|
||||
OSMutex *tail;
|
||||
};
|
||||
struct OSMutexQueue
|
||||
{
|
||||
OSMutex *head;
|
||||
OSMutex *tail;
|
||||
};
|
||||
|
||||
struct OSMutexLink
|
||||
{
|
||||
OSMutex *next;
|
||||
OSMutex *prev;
|
||||
};
|
||||
struct OSMutexLink
|
||||
{
|
||||
OSMutex *next;
|
||||
OSMutex *prev;
|
||||
};
|
||||
|
||||
struct OSThread
|
||||
{
|
||||
OSContext context; // register context
|
||||
struct OSThread
|
||||
{
|
||||
OSContext context; // register context
|
||||
|
||||
u16 state; // OS_THREAD_STATE_*
|
||||
u16 attr; // OS_THREAD_ATTR_*
|
||||
s32 suspend; // suspended if the count is greater than zero
|
||||
OSPriority priority; // effective scheduling priority
|
||||
OSPriority base; // base scheduling priority
|
||||
void *val; // exit value
|
||||
u16 state; // OS_THREAD_STATE_*
|
||||
u16 attr; // OS_THREAD_ATTR_*
|
||||
s32 suspend; // suspended if the count is greater than zero
|
||||
OSPriority priority; // effective scheduling priority
|
||||
OSPriority base; // base scheduling priority
|
||||
void *val; // exit value
|
||||
|
||||
OSThreadQueue *queue; // queue thread is on
|
||||
OSThreadLink link; // queue link
|
||||
OSThreadQueue *queue; // queue thread is on
|
||||
OSThreadLink link; // queue link
|
||||
|
||||
OSThreadQueue queueJoin; // list of threads waiting for termination (join)
|
||||
OSThreadQueue queueJoin; // list of threads waiting for termination (join)
|
||||
|
||||
OSMutex *mutex; // mutex trying to lock
|
||||
OSMutexQueue queueMutex; // list of mutexes owned
|
||||
OSMutex *mutex; // mutex trying to lock
|
||||
OSMutexQueue queueMutex; // list of mutexes owned
|
||||
|
||||
OSThreadLink linkActive; // link of all threads for debugging
|
||||
OSThreadLink linkActive; // link of all threads for debugging
|
||||
|
||||
u8 *stackBase; // the thread's designated stack (high address)
|
||||
u32 *stackEnd; // last word of stack (low address)
|
||||
};
|
||||
u8 *stackBase; // the thread's designated stack (high address)
|
||||
u32 *stackEnd; // last word of stack (low address)
|
||||
};
|
||||
|
||||
// Thread states
|
||||
enum OS_THREAD_STATE
|
||||
{
|
||||
OS_THREAD_STATE_READY = 1,
|
||||
OS_THREAD_STATE_RUNNING = 2,
|
||||
OS_THREAD_STATE_WAITING = 4,
|
||||
OS_THREAD_STATE_MORIBUND = 8
|
||||
};
|
||||
// Thread states
|
||||
enum OS_THREAD_STATE
|
||||
{
|
||||
OS_THREAD_STATE_READY = 1,
|
||||
OS_THREAD_STATE_RUNNING = 2,
|
||||
OS_THREAD_STATE_WAITING = 4,
|
||||
OS_THREAD_STATE_MORIBUND = 8
|
||||
};
|
||||
|
||||
// Thread priorities
|
||||
#define OS_PRIORITY_MIN 0 // highest
|
||||
|
||||
@@ -5,8 +5,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OSDiffTick(tick1, tick0) ((s32)(tick1) - (s32)(tick0))
|
||||
|
||||
typedef s64 OSTime;
|
||||
typedef u32 OSTick;
|
||||
|
||||
OSTime OSGetTime(void);
|
||||
OSTick OSGetTick(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+11
-2
@@ -3,6 +3,15 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void VISetBlack(BOOL);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#endif
|
||||
void VISetBlack(BOOL);
|
||||
extern void VIWaitForRetrace();
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,4 +37,8 @@ typedef u32 unknown;
|
||||
#define FALSE 0
|
||||
#define NULL ((void*)0)
|
||||
#define nullptr 0
|
||||
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user