nw4r ut almost matching

This commit is contained in:
elijah-thomas774
2024-05-05 22:27:50 -04:00
parent 126c5db943
commit 344348bc05
39 changed files with 2477 additions and 346 deletions
+11 -14
View File
@@ -17,10 +17,10 @@ typedef unsigned long fpos_t;
typedef unsigned short wchar_t;
#endif
#define set_error(file) \
do { \
(file)->file_state.error = 1; \
(file)->buffer_length = 0; \
#define set_error(file) \
do { \
(file)->file_state.error = 1; \
(file)->buffer_length = 0; \
} while (0)
enum __file_kinds {
@@ -73,9 +73,8 @@ typedef struct _file_states {
} file_states;
typedef void (*__idle_proc)(void);
typedef int (*__pos_proc)(__file_handle file, fpos_t* position, int mode, __idle_proc idle_proc);
typedef int (*__io_proc)(__file_handle file, unsigned char* buff, size_t* count,
__idle_proc idle_proc);
typedef int (*__pos_proc)(__file_handle file, fpos_t *position, int mode, __idle_proc idle_proc);
typedef int (*__io_proc)(__file_handle file, unsigned char *buff, size_t *count, __idle_proc idle_proc);
typedef int (*__close_proc)(__file_handle file);
typedef struct _FILE {
@@ -88,9 +87,9 @@ typedef struct _FILE {
/* 0x0F */ char ungetc_buffer[2];
/* 0x12 */ wchar_t ungetc_wide_buffer[2];
/* 0x18 */ unsigned long position;
/* 0x1C */ unsigned char* buffer;
/* 0x1C */ unsigned char *buffer;
/* 0x20 */ unsigned long buffer_size;
/* 0x24 */ unsigned char* buffer_ptr;
/* 0x24 */ unsigned char *buffer_ptr;
/* 0x28 */ unsigned long buffer_length;
/* 0x2C */ unsigned long buffer_alignment;
/* 0x30 */ unsigned long save_buffer_length;
@@ -100,7 +99,7 @@ typedef struct _FILE {
/* 0x40 */ __io_proc write_fn;
/* 0x44 */ __close_proc close_fn;
/* 0x48 */ __idle_proc idle_fn;
/* 0x4C */ struct _FILE* next_file;
/* 0x4C */ struct _FILE *next_file;
} FILE;
typedef struct _files {
@@ -116,10 +115,8 @@ typedef struct _files {
extern files __files;
extern int __close_console(__file_handle file);
extern int __write_console(__file_handle file, unsigned char* buf, size_t* count,
__idle_proc idle_fn);
extern int __read_console(__file_handle file, unsigned char* buf, size_t* count,
__idle_proc idle_fn);
extern int __write_console(__file_handle file, unsigned char *buf, size_t *count, __idle_proc idle_fn);
extern int __read_console(__file_handle file, unsigned char *buf, size_t *count, __idle_proc idle_fn);
unsigned int __flush_all(void);
void __close_all(void);
+1
View File
@@ -159,6 +159,7 @@ public:
void SetupGX();
void SetFontSize(f32 width, f32 height);
void SetFontSize(f32 height);
f32 GetFontWidth() const;
f32 GetFontHeight() const;
f32 GetFontAscent() const;
+9 -9
View File
@@ -24,7 +24,7 @@ public:
};
public:
DvdFileStream(s32 entrynum);
DvdFileStream(long entrynum);
DvdFileStream(const DVDFileInfo *info, bool close);
virtual ~DvdFileStream(); // at 0xC
@@ -67,15 +67,15 @@ public:
virtual void Close(); // at 0x10
virtual s32 Read(void *dst, u32 size); // at 0x14
virtual bool ReadAsync(void *dst, u32 size, AsyncCallback callback,
virtual long Read(void *dst, unsigned long size); // at 0x14
virtual bool ReadAsync(void *dst, unsigned long size, AsyncCallback callback,
void *arg); // at 0x18
virtual s32 Peek(void *dst, u32 size); // at 0x5C
virtual bool PeekAsync(void *dst, u32 size, AsyncCallback callback,
virtual long Peek(void *dst, unsigned long size); // at 0x5C
virtual bool PeekAsync(void *dst, unsigned long size, AsyncCallback callback,
void *arg); // at 0x60
virtual void Seek(s32 offset, u32 origin); // at 0x44
virtual void Seek(long offset, unsigned long origin); // at 0x44
virtual void Cancel(); // at 0x48
virtual bool CancelAsync(AsyncCallback callback, void *arg); // at 0x4C
@@ -88,11 +88,11 @@ public:
bool Open(const DVDFileInfo *info, bool close);
private:
static void DvdAsyncCallback_(s32 result, DVDFileInfo *info);
static void DvdCBAsyncCallback_(s32 result, DVDCommandBlock *block);
static void DvdAsyncCallback_(long result, DVDFileInfo *info);
static void DvdCBAsyncCallback_(long result, DVDCommandBlock *block);
void Initialize_();
u32 AdjustReadLength_(u32 len);
unsigned long AdjustReadLength_(unsigned long len);
private:
FilePosition mFilePosition; // at 0x14
+16 -7
View File
@@ -11,17 +11,19 @@ class DvdLockedFileStream : public DvdFileStream {
public:
NW4R_UT_RTTI_DECL(DvdLockedFileStream);
DvdLockedFileStream(s32 entrynum);
DvdLockedFileStream(long entrynum);
DvdLockedFileStream(const DVDFileInfo *info, bool close);
virtual ~DvdLockedFileStream(); // at 0xC
virtual s32 Read(void *dst, u32 size); // at 0x14
virtual bool ReadAsync(void *dst, u32 size, AsyncCallback callback, void *arg) {
virtual void Close(); // at 0x10
virtual long Read(void *dst, unsigned long size); // at 0x14
virtual bool ReadAsync(void *dst, unsigned long size, AsyncCallback callback, void *arg) {
return false;
} // at 0x18
virtual s32 Peek(void *dst, u32 size); // at 0x5C
virtual bool PeekAsync(void *dst, u32 size, AsyncCallback callback, void *arg) {
virtual long Peek(void *dst, unsigned long size); // at 0x5C
virtual bool PeekAsync(void *dst, unsigned long size, AsyncCallback callback, void *arg) {
return false;
} // at 0x60
@@ -29,11 +31,18 @@ public:
return false;
} // at 0x28
private:
static void InitMutex_();
void Cancel();
private:
static void InitMutex_();
bool LockMutex();
static void UnlockMutex();
void CancelMutex();
private:
volatile bool mCancelFlag; // 0x6f
static bool sInitialized;
static OSThreadQueue sThreadQueue;
static OSMutex sMutex;
};
+2 -3
View File
@@ -52,13 +52,12 @@ public:
virtual int GetCharWidth(u16 c) const = 0; // at 0x48
virtual CharWidths GetCharWidths(u16 c) const = 0; // at 0x4C
virtual void GetGlyph(Glyph *out, u16 c) const = 0; // at 0x50
virtual bool HasGlyph(u16 c) const = 0; // at 0x50
virtual FontEncoding GetEncoding() const = 0; // at 0x54
void InitReaderFunc(FontEncoding encode);
CharStrmReader GetCharStrmReader() const {
return CharStrmReader(mReadFunc);
}
CharStrmReader GetCharStrmReader() const;
private:
CharStrmReader::ReadFunc mReadFunc; // at 0x4
+3 -3
View File
@@ -15,11 +15,11 @@ public:
IOStream() : mIsOpen(false), mCallback(NULL), mCallbackArg(NULL) {}
virtual ~IOStream() {} // at 0xC
virtual void Close() = 0; // at 0x10
virtual s32 Read(void *dst, u32 size) = 0; // at 0x14
virtual void Close() = 0; // at 0x10
virtual long Read(void *dst, unsigned long size) = 0; // at 0x14
virtual bool ReadAsync(void *dst, unsigned long size, AsyncCallback callback,
void *arg); // at 0x18
virtual bool Write(const void *src, unsigned long size); // at 0x1C
virtual long Write(const void *src, unsigned long size); // at 0x1C
virtual bool WriteAsync(const void *src, unsigned long size, AsyncCallback callback,
void *arg); // at 0x20
virtual bool IsBusy() const; // at 0x24
+15 -15
View File
@@ -25,8 +25,8 @@ public:
};
public:
NandFileStream(const char *path, u32 access);
NandFileStream(const NANDFileInfo *info, u32 access, bool close);
NandFileStream(const char *path, unsigned long access);
NandFileStream(const NANDFileInfo *info, unsigned long access, bool close);
virtual ~NandFileStream(); // at 0xC
virtual bool IsBusy() const {
@@ -68,32 +68,32 @@ public:
virtual void Close(); // at 0x10
virtual s32 Read(void *dst, u32 size); // at 0x14
virtual bool ReadAsync(void *dst, u32 size, AsyncCallback callback,
virtual long Read(void *dst, unsigned long size); // at 0x14
virtual bool ReadAsync(void *dst, unsigned long size, AsyncCallback callback,
void *arg); // at 0x18
virtual void Write(const void *src, u32 size); // at 0x1C
virtual bool WriteAsync(const void *src, u32 size, AsyncCallback callback,
virtual long Write(const void *src, unsigned long size); // at 0x1C
virtual bool WriteAsync(const void *src, unsigned long size, AsyncCallback callback,
void *arg); // at 0x20
virtual void Seek(s32 offset, u32 origin); // at 0x44
virtual void Seek(long offset, unsigned long origin); // at 0x44
bool Open(const char *path, u32 access);
bool Open(const NANDFileInfo *info, u32 access, bool close) DECOMP_DONT_INLINE;
bool Open(const char *path, unsigned long access);
bool Open(const NANDFileInfo *info, unsigned long access, bool close) DECOMP_DONT_INLINE;
private:
static void NandAsyncCallback_(s32 result, NANDCommandBlock *block);
static void NandAsyncCallback_(long result, NANDCommandBlock *block);
void Initialize_();
private:
FilePosition mFilePosition; // at 0x14
AsyncContext mAsyncContext; // at 0x1C
bool mCanRead; // at 0x164
bool mCanWrite; // at 0x165
volatile bool mIsBusy; // at 0x166
bool mCloseOnDestroy; // at 0x167
bool mAllowClose; // at 0x168
bool mCanRead; // at 0x168
bool mCanWrite; // at 0x169
volatile bool mIsBusy; // at 0x16A
bool mCloseOnDestroy; // at 0x16B
bool mAllowClose; // at 0x16C
};
} // namespace ut
+3 -2
View File
@@ -8,12 +8,13 @@ namespace ut {
class ResFont : public detail::ResFontBase {
public:
static FontInformation* Rebuild(BinaryFileHeader* header);
static FontInformation *Rebuild(BinaryFileHeader *header);
ResFont();
~ResFont();
bool SetResource(void* buffer);
bool SetResource(void *buffer);
void *RemoveResource();
};
} // namespace ut
+24 -25
View File
@@ -6,11 +6,7 @@
namespace nw4r {
namespace ut {
enum FontMapMethod {
FONT_MAPMETHOD_LINEAR,
FONT_MAPMETHOD_ARRAY,
FONT_MAPMETHOD_SCAN
};
enum FontMapMethod { FONT_MAPMETHOD_LINEAR, FONT_MAPMETHOD_ARRAY, FONT_MAPMETHOD_SCAN };
struct FontTextureGlyph {
u8 cellWidth; // at 0x0
@@ -24,13 +20,13 @@ struct FontTextureGlyph {
u16 sheetLine; // at 0xE
u16 sheetWidth; // at 0x10
u16 sheetHeight; // at 0x12
u8* sheetImage; // at 0x14
u8 *sheetImage; // at 0x14
};
struct FontWidth {
u16 firstChar; // at 0x0
u16 lastChar; // at 0x2
FontWidth* next; // at 0x4
FontWidth *next; // at 0x4
CharWidths widthTable[]; // at 0x8
};
@@ -39,7 +35,7 @@ struct FontCodeMap {
u16 lastChar; // at 0x2
u16 mappingMethod; // at 0x4
u16 reserved; // at 0x6
FontCodeMap* next; // at 0x8
FontCodeMap *next; // at 0x8
u16 mapInfo[]; // at 0xc
};
@@ -49,9 +45,9 @@ struct FontInformation {
u16 alterCharIndex; // at 0x2
CharWidths defaultWidth; // at 0x4
u8 encoding; // at 0x7
FontTextureGlyph* fontGlyph; // at 0x8
FontWidth* fontWidth; // at 0xC
FontCodeMap* fontMap; // at 0x10
FontTextureGlyph *fontGlyph; // at 0x8
FontWidth *fontWidth; // at 0xC
FontCodeMap *fontMap; // at 0x10
u8 height; // at 0x14
u8 width; // at 0x15
u8 ascent; // at 0x16
@@ -76,34 +72,37 @@ public:
virtual GXTexFmt GetTextureFormat() const; // at 0x30
virtual int GetLineFeed() const; // at 0x34
virtual CharWidths GetDefaultCharWidths() const; // at 0x38
virtual void SetDefaultCharWidths(const CharWidths& widths); // at 0x3C
virtual void SetDefaultCharWidths(const CharWidths &widths); // at 0x3C
virtual bool SetAlternateChar(u16 c); // at 0x40
virtual void SetLineFeed(int lf); // at 0x44
virtual int GetCharWidth(u16 c) const; // at 0x48
virtual CharWidths GetCharWidths(u16 c) const; // at 0x4C
virtual void GetGlyph(Glyph* out, u16 c) const; // at 0x50
virtual FontEncoding GetEncoding() const; // at 0x54
virtual void GetGlyph(Glyph *out, u16 c) const; // at 0x50
virtual bool HasGlyph(u16 c) const; // at 0x54
virtual FontEncoding GetEncoding() const; // at 0x58
bool IsManaging(const void* buffer) const { return mResource == buffer; }
bool IsManaging(const void *buffer) const {
return mResource == buffer;
}
void SetResourceBuffer(void* buffer, FontInformation* info);
void SetResourceBuffer(void *buffer, FontInformation *info);
void *RemoveResourceBuffer();
u16 GetGlyphIndex(u16 c) const;
u16 FindGlyphIndex(u16 c) const;
u16 FindGlyphIndex(const FontCodeMap* map, u16 c) const;
u16 FindGlyphIndex(const FontCodeMap *map, u16 c) const;
const CharWidths& GetCharWidthsFromIndex(u16 index) const;
const CharWidths& GetCharWidthsFromIndex(const FontWidth* width,
u16 index) const;
const CharWidths &GetCharWidthsFromIndex(u16 index) const;
const CharWidths &GetCharWidthsFromIndex(const FontWidth *width, u16 index) const;
void GetGlyphFromIndex(Glyph* out, u16 index) const;
void GetGlyphFromIndex(Glyph *out, u16 index) const;
private:
void* mResource; // at 0x10
FontInformation* mFontInfo; // at 0x14
u16 mLastCharCode; // at 0x18
u16 mLastGlyphIndex; // at 0x18
void *mResource; // at 0x10
FontInformation *mFontInfo; // at 0x14
mutable u16 mLastCharCode; // at 0x18
mutable u16 mLastGlyphIndex; // at 0x1A
};
} // namespace detail
+2 -1
View File
@@ -30,7 +30,8 @@ public:
virtual int GetCharWidth(u16 c) const; // at 0x48
virtual CharWidths GetCharWidths(u16 c) const; // at 0x4C
virtual void GetGlyph(Glyph *out, u16 c) const; // at 0x50
virtual FontEncoding GetEncoding() const; // at 0x54
virtual bool HasGlyph(u16 c) const; // at 0x54
virtual FontEncoding GetEncoding() const; // at 0x58
bool Load(void *buffer);
u32 GetRequireBufferSize();
+35 -16
View File
@@ -64,7 +64,7 @@ public:
void SetDrawFlag(u32 flag) {
mDrawFlag = flag;
}
bool IsDrawFlagSet(u32 mask, u32 flag) const {
bool IsDrawFlagSet(unsigned long mask, u32 flag) const {
return (mDrawFlag & mask) == flag;
}
@@ -78,20 +78,39 @@ public:
mTagProcessor = &mDefaultTagProcessor;
}
void SetLineHeight(f32 height);
f32 GetLineHeight() const;
f32 CalcLineWidth(const T *str, int len);
f32 CalcStringWidth(const T *str, int len) const;
void CalcStringRect(Rect *rect, const T *str, int len) const;
f32 CalcFormatStringWidth(const T *str, ...) const;
f32 CalcFormatStringHeight(const T *str, ...) const;
void CalcFormatStringRect(Rect *rect, const T *str, ...) const;
void CalcVStringRect(Rect *rect, const T *str, va_list args) const;
int VSNPrintf(T *buffer, u32 count, const T *fmt, va_list args);
f32 CalcStringWidth(const T *format, int len) const;
f32 CalcStringHeight(const T *format, int len) const;
void CalcStringRect(Rect *rect, const T *format, int len) const;
f32 Printf(const T *format, ...);
f32 VPrintf(const T *str, va_list args);
f32 Print(const T *str, int len);
f32 PrintfMutable(const T *format, ...);
f32 VPrintfMutable(const T *format, va_list args);
f32 PrintMutable(const T *str, int n);
// static int VSNPrintf(T *buffer, unsigned long count, const T *fmt, va_list args);
static int VSNPrintf(char *buffer, unsigned long count, const char *fmt, va_list args) {
return vsnprintf(buffer, count, fmt, args);
}
static int VSNPrintf(wchar_t *buffer, unsigned long count, const wchar_t *fmt, va_list args) {
return vswprintf(buffer, count, fmt, args);
}
f32 CalcLineWidth(const T *format, int len);
bool CalcLineRectImpl(Rect *rect, const T **str, int len);
void CalcStringRectImpl(Rect *rect, const T *str, int len);
f32 PrintImpl(const T *str, int len);
f32 PrintImpl(const T *str, int len, bool m);
f32 AdjustCursor(f32 *x1, f32 *y1, const T *str, int len);
private:
@@ -103,19 +122,19 @@ private:
TagProcessorBase<T> *mTagProcessor; // at 0x60
static T *mFormatBuffer;
static u32 mFormatBufferSize;
static int mFormatBufferSize;
static TagProcessorBase<T> mDefaultTagProcessor;
};
template <>
inline int TextWriterBase<char>::VSNPrintf(char *buffer, u32 count, const char *fmt, va_list args) {
return vsnprintf(buffer, count, fmt, args);
}
// template <>
// int TextWriterBase<char>::VSNPrintf(char *buffer, unsigned long count, const char *fmt, va_list args) {
// return vsnprintf(buffer, count, fmt, args);
// }
template <>
inline int TextWriterBase<wchar_t>::VSNPrintf(wchar_t *buffer, u32 count, const wchar_t *fmt, va_list args) {
return vswprintf(buffer, count, fmt, args);
}
// template <>
// int TextWriterBase<wchar_t>::VSNPrintf(wchar_t *buffer, unsigned long count, const wchar_t *fmt, va_list args) {
// return vswprintf(buffer, count, fmt, args);
// }
} // namespace ut
} // namespace nw4r
+3
View File
@@ -6,9 +6,12 @@ extern "C" {
#include "rvl/DVD/dvd.h"
#include "rvl/DVD/dvd_broadway.h"
#include "rvl/DVD/dvderror.h"
#include "rvl/DVD/dvdfatal.h"
#include "rvl/DVD/dvdfs.h"
#include "rvl/DVD/dvdidutils.h"
#include "rvl/DVD/dvdqueue.h"
#ifdef __cplusplus
}
+90 -11
View File
@@ -5,14 +5,75 @@
extern "C" {
#endif
// OS sets MSB to signal that the device code was successfully read
#define DVD_DEVICE_CODE_READ (1 << 15)
#define MAKE_DVD_DEVICE_CODE(x) (DVD_DEVICE_CODE_READ | (x))
// Forward declarations
typedef struct DVDCommandBlock;
typedef struct DVDFileInfo;
typedef struct OSAlarm;
typedef struct DVDDriveBlock {
char UNK_0x0[0xC];
UNKWORD WORD_0xC;
char UNK_0x10[0x30 - 0x10];
} DVDDriveBlock;
typedef enum {
DVD_RESULT_COVER_CLOSED = -4,
DVD_RESULT_CANCELED,
DVD_RESULT_M2,
DVD_RESULT_FATAL,
DVD_RESULT_OK,
} DVDResult;
typedef enum {
DVD_STATE_FATAL = -1,
DVD_STATE_IDLE,
DVD_STATE_BUSY,
DVD_STATE_WAITING,
DVD_STATE_COVER_CLOSED,
DVD_STATE_NO_DISK,
DVD_STATE_COVER_OPENED,
DVD_STATE_WRONG_DISK_ID,
DVD_STATE_7,
DVD_STATE_PAUSED,
DVD_STATE_9,
DVD_STATE_CANCELED,
DVD_STATE_DISK_ERROR,
DVD_STATE_MOTOR_STOPPED,
} DVDAsyncState;
typedef enum {
DVD_COVER_BUSY,
DVD_COVER_OPENED,
DVD_COVER_CLOSED,
} DVDCoverState;
typedef void (*DVDAsyncCallback)(long result, struct DVDFileInfo *info);
typedef void (*DVDCommandCallback)(long result, struct DVDCommandBlock *block);
typedef struct DVDDiskID {
char game[4]; // at 0x0
char company[2]; // at 0x4
u8 disk; // at 0x6
u8 version; // at 0x7
u8 strmEnable; // at 0x8
u8 strmBufSize; // at 0x9
u8 padding[14]; // at 0xA
u32 rvlMagic; // at 0x18
u32 gcMagic; // at 0x1C
} DVDDiskID;
typedef struct DVDCommandBlock {
struct DVDCommandBlock *next; // at 0x0
struct DVDCommandBlock *prev; // at 0x4
u32 command; // at 0x8
volatile s32 state; // at 0xC
u32 offset; // at 0x10
u32 length; // at 0x14
void *addr; // at 0x18
u32 transferSize; // at 0x1C
u32 transferTotal; // at 0x20
DVDDiskID *id; // at 0x24
DVDCommandCallback callback; // at 0x28
void *userData; // at 0x2C
} DVDCommandBlock;
typedef struct DVDDriveInfo {
u16 revision; // at 0x0
@@ -21,16 +82,34 @@ typedef struct DVDDriveInfo {
char padding[32 - 0x8];
} DVDDriveInfo;
typedef void (*DVDInquiryCallback)(s32, DVDDriveBlock *);
typedef struct DVDFileInfo {
DVDCommandBlock block; // at 0x0
u32 offset; // at 0x30
u32 size; // at 0x34
DVDAsyncCallback callback; // at 0x38
} DVDFileInfo;
extern volatile u32 __DVDLayoutFormat;
void DVDInit(void);
BOOL DVDInquiryAsync(DVDDriveBlock *, DVDDriveInfo *, DVDInquiryCallback);
BOOL DVDReadAbsAsyncPrio(DVDCommandBlock *block, void *dst, u32 size, u32 offset, DVDCommandCallback callback,
s32 prio);
BOOL DVDInquiryAsync(DVDCommandBlock *block, DVDDriveInfo *info, DVDCommandCallback callback);
s32 DVDGetCommandBlockStatus(const DVDCommandBlock *block);
s32 DVDGetDriveStatus(void);
void DVDPause(void);
void DVDResume(void);
BOOL DVDCancelAsync(DVDCommandBlock *block, DVDCommandCallback callback);
s32 DVDCancel(DVDCommandBlock *block);
BOOL DVDCancelAllAsync(DVDCommandCallback callback);
const DVDDiskID *DVDGetCurrentDiskID(void);
u32 __DVDGetCoverStatus(void);
void __DVDPrepareResetAsync(DVDCommandCallback callback);
void __DVDPrepareReset(void);
BOOL __DVDTestAlarm(struct OSAlarm *);
BOOL __DVDTestAlarm(const struct OSAlarm *alarm);
BOOL __DVDLowBreak(void);
BOOL __DVDStopMotorAsync(DVDCommandBlock *block, DVDCommandCallback callback);
void __DVDRestartMotor(void);
#ifdef __cplusplus
}
+16 -12
View File
@@ -5,6 +5,9 @@
extern "C" {
#endif
#define DVD_LOW_OFFSET(x) ((x) >> 2)
#define DVD_LOW_SPEED(x) (((x) & 3) << 16)
// Forward declarations
typedef struct DVDDiskID;
typedef struct DVDDriveInfo;
@@ -12,21 +15,22 @@ typedef struct ESPTicket;
typedef struct ESPTmd;
typedef struct OSAlarm;
/**
* https://wiibrew.org/wiki//dev/di
* Names adjusted to be closer to those seen in assertions
*/
typedef enum {
DVD_INTTYPE_TC = (1 << 0), //!< Transaction callback?
DVD_INTTYPE_DE = (1 << 1), //!< Drive error
DVD_INTTYPE_CVR = (1 << 2), //!< Something with DVD cover
DVD_INTTYPE_BR = (1 << 3), //!< Break requested
DVD_INTTYPE_TIME = (1 << 4), //!< Time out
DVD_INTTYPE_SERR = (1 << 5), //!< Security error
DVD_INTTYPE_VERR = (1 << 6), //!< Verify error
DVD_INTTYPE_ARGS = (1 << 7), //!< Bad arguments
DVD_INTTYPE_TC = (1 << 0), // Transaction callback?
DVD_INTTYPE_DE = (1 << 1), // Drive error
DVD_INTTYPE_CVR = (1 << 2), // Something with DVD cover
DVD_INTTYPE_BR = (1 << 3), // Break requested
DVD_INTTYPE_TIME = (1 << 4), // Time out
DVD_INTTYPE_SERR = (1 << 5), // Security error
DVD_INTTYPE_VERR = (1 << 6), // Verify error
DVD_INTTYPE_ARGS = (1 << 7), // Bad arguments
} DVDLowIntType;
// DICVR - DI Cover Register (via DVDLowGetCoverRegister)
#define DVD_DICVR_CVR (1 << 0)
#define DVD_DICVR_CVRINTMASK (1 << 1)
#define DVD_DICVR_CVRINT (1 << 2)
typedef void (*DVDLowCallback)(u32 intType);
BOOL DVDLowInit(void);
+38
View File
@@ -0,0 +1,38 @@
#ifndef RVL_SDK_DVD_ERROR_H
#define RVL_SDK_DVD_ERROR_H
#include <common.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*DVDErrorCallback)(s32 result, s32 arg1);
#define DVD_ERROR_CMD_MAX 5
typedef struct DVDErrorInfo {
char game[4]; // at 0x0
u8 disk; // at 0x4
u8 version; // at 0x5
u32 error; // at 0x8
s32 sec; // at 0xC
u32 disr; // at 0x10
u32 dicr; // at 0x14
u32 next; // at 0x18
struct {
u32 command; // at 0x1C
u32 param1; // at 0x20
u32 param2; // at 0x24
u32 intType; // at 0x28
u32 tick; // at 0x2C
} info[DVD_ERROR_CMD_MAX];
} DVDErrorInfo;
extern DVDErrorInfo __ErrorInfo;
void __DVDStoreErrorCode(u32 error, DVDErrorCallback callback);
#ifdef __cplusplus
}
#endif
#endif
+12 -24
View File
@@ -1,36 +1,24 @@
#ifndef RVL_SDK_DVD_FS_H
#define RVL_SDK_DVD_FS_H
#include <RVL/DVD/dvd.h>
#include <RVL/OS.h>
#include <common.h>
#ifdef __cplusplus
extern "C" {
#endif
extern OSThreadQueue __DVDThreadQueue;
extern BOOL __DVDLongFileNameFlag;
typedef void (*DVDCommandCallback)(s32, struct DVDCommandBlock *);
typedef void (*DVDFileCallback)(s32, struct DVDFileInfo *);
typedef struct DVDCommandBlock {
/* 0x00 */ struct DVDCommandBlock *next;
/* 0x04 */ struct DVDCommandBlock *prev;
/* 0x08 */ u32 command;
/* 0x0c */ s32 state;
/* 0x10 */ u32 offset;
/* 0x14 */ u32 length;
/* 0x18 */ void *addr;
/* 0x1c */ u32 currTransferSize;
/* 0x20 */ u32 transferredSize;
/* 0x24 */ DVDDiskID *id;
/* 0x28 */ DVDCommandCallback callback;
/* 0x2c */ void *userData;
} DVDCommandBlock;
typedef struct DVDFileInfo {
/* 0x00 */ DVDCommandBlock cb;
/* 0x30 */ u32 startAddr;
/* 0x34 */ u32 length;
/* 0x38 */ DVDFileCallback *callback;
} DVDFileInfo;
void __DVDFSInit(void);
s32 DVDConvertPathToEntrynum(const char *path);
BOOL DVDFastOpen(s32 entrynum, DVDFileInfo *info);
BOOL DVDOpen(const char *path, DVDFileInfo *info);
BOOL DVDClose(DVDFileInfo *info);
BOOL DVDGetCurrentDir(char *buffer, u32 maxlen);
BOOL DVDReadAsyncPrio(DVDFileInfo *info, void *dst, s32 size, s32 offset, DVDAsyncCallback callback, s32 prio);
s32 DVDReadPrio(DVDFileInfo *info, void *dst, s32 size, s32 offset, s32 prio);
#ifdef __cplusplus
}
+2 -12
View File
@@ -1,22 +1,12 @@
#ifndef RVL_SDK_DVD_ID_UTILS_H
#define RVL_SDK_DVD_ID_UTILS_H
#include <RVL/DVD/dvd.h>
#include <common.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct DVDDiskID {
char game[4]; // at 0x0
char company[2]; // at 0x4
u8 disk; // at 0x6
u8 version; // at 0x7
u8 strmEnable; // at 0x8
u8 strmBufSize; // at 0x9
u8 padding[14]; // at 0xA
u32 rvlMagic; // at 0x18
u32 gcMagic; // at 0x1C
} DVDDiskID;
BOOL DVDCompareDiskID(const DVDDiskID *id1, const DVDDiskID *id2);
#ifdef __cplusplus
+28
View File
@@ -0,0 +1,28 @@
#ifndef RVL_SDK_DVD_QUEUE_H
#define RVL_SDK_DVD_QUEUE_H
#include <RVL/DVD/dvd.h>
#include <common.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
DVD_PRIO_HIGHEST,
DVD_PRIO_HIGH,
DVD_PRIO_MEDIUM,
DVD_PRIO_LOW,
DVD_PRIO_MAX,
} DVDQueuePriority;
void __DVDClearWaitingQueue(void);
BOOL __DVDPushWaitingQueue(s32 prio, DVDCommandBlock *block);
DVDCommandBlock *__DVDPopWaitingQueue(void);
BOOL __DVDCheckWaitingQueue(void);
DVDCommandBlock *__DVDGetNextWaitingQueue(void);
BOOL __DVDDequeueWaitingQueue(const DVDCommandBlock *block);
#ifdef __cplusplus
}
#endif
#endif
+8 -5
View File
@@ -1,5 +1,6 @@
#ifndef RVL_SDK_GX_INIT_H
#define RVL_SDK_GX_INIT_H
#include <RVL/GX/GXFifo.h>
#include <common.h>
#ifdef __cplusplus
extern "C" {
@@ -49,11 +50,11 @@ typedef struct _GXData {
char UNK_0x230[0x254 - 0x230];
u32 genMode; // at 0x254
char UNK_0x258[0x520 - 0x258];
GXAttrType normalType; // at 0x520
GXBool normal; // at 0x524
GXBool binormal; // at 0x525
GXProjMtxType projType; // at 0x528
f32 proj[6]; // at 0x52C
GXAttrType normalType; // at 0x520
GXBool normal; // at 0x524
GXBool binormal; // at 0x525
GXProjectionType projType; // at 0x528
f32 proj[6]; // at 0x52C
union {
struct {
f32 vpOx; // at 0x544
@@ -80,6 +81,8 @@ extern GXData *const __GXData;
// I hate typing this name out
#define gxdt __GXData
GXFifoObj *GXInit(void *, u32);
#ifdef __cplusplus
}
#endif
+1 -1
View File
@@ -19,7 +19,7 @@ void GXSetColorUpdate(GXBool enable);
void GXSetAlphaUpdate(GXBool enable);
void GXSetZMode(GXBool enableTest, GXCompare func, GXBool enableUpdate);
void GXSetZCompLoc(GXBool beforeTex);
void GXSetPixelFmt(GXPixelFmt pixelFmt, GXZFmt zFmt);
void GXSetPixelFmt(GXPixelFmt pixelFmt, GXZFmt16 zFmt);
void GXSetDither(GXBool enable);
void GXSetDstAlpha(GXBool enable, u8 alpha);
void GXSetFieldMask(GXBool enableEven, GXBool enableOdd);
+1 -1
View File
@@ -7,7 +7,7 @@
extern "C" {
#endif
void GXSetProjection(const Mtx44 proj, GXProjMtxType type);
void GXSetProjection(const Mtx44 proj, GXProjectionType type);
void GXSetProjectionv(const f32 proj[7]);
void GXGetProjectionv(f32 proj[7]);
void GXLoadPosMtxImm(const Mtx mtx, u32 id);
+77 -36
View File
@@ -158,7 +158,17 @@ typedef enum _GXChannelID {
GX_COLOR_NULL = 255
} GXChannelID;
// TODO: Fabricated names from patent
typedef enum _GXCITexFmt {
GX_TF_C4 = 8,
GX_TF_C8,
GX_TF_C14X2,
} GXCITexFmt;
typedef enum _GXClearZ {
GX_CLEAR_Z_MIN = 0,
GX_CLEAR_Z_MAX = (1 << 24) - 1,
} GXClearZ;
typedef enum _GXClipMode {
// "ClipDisable" in XF mem, so 0 = enable
GX_CLIP_ENABLE,
@@ -208,6 +218,13 @@ typedef enum _GXCompType {
GX_RGBA8
} GXCompType;
typedef enum _GXCopyClamp {
GX_CLAMP_NONE,
GX_CLAMP_TOP,
GX_CLAMP_BOTTOM,
GX_CLAMP_ALL,
} GXCopyClamp;
typedef enum _GXCullMode { GX_CULL_NONE, GX_CULL_FRONT, GX_CULL_BACK, GX_CULL_ALL } GXCullMode;
typedef enum _GXDiffuseFn { GX_DF_NONE, GX_DF_SIGN, GX_DF_CLAMP } GXDiffuseFn;
@@ -354,16 +371,16 @@ typedef enum _GXIndTexWrap {
} GXIndTexWrap;
typedef enum _GXLightID {
GX_LIGHT0 = 1,
GX_LIGHT1 = 2,
GX_LIGHT2 = 4,
GX_LIGHT3 = 8,
GX_LIGHT4 = 16,
GX_LIGHT5 = 32,
GX_LIGHT6 = 64,
GX_LIGHT7 = 128,
GX_LIGHT0 = (1 << 0),
GX_LIGHT1 = (1 << 1),
GX_LIGHT2 = (1 << 2),
GX_LIGHT3 = (1 << 3),
GX_LIGHT4 = (1 << 4),
GX_LIGHT5 = (1 << 5),
GX_LIGHT6 = (1 << 6),
GX_LIGHT7 = (1 << 7),
GX_MAX_LIGHT = 256,
GX_MAX_LIGHT = (1 << 8),
GX_LIGHT_NULL = 0
} GXLightID;
@@ -386,7 +403,6 @@ typedef enum _GXLogicOp {
GX_LO_SET
} GXLogicOp;
// TODO: Fabricated name
typedef enum _GXMtxType {
GX_MTX_3x4,
GX_MTX_2x4,
@@ -432,7 +448,7 @@ typedef enum _GXPrimitive {
GX_QUADS = 0x80,
} GXPrimitive;
typedef enum _GXProjMtxType { GX_PERSPECTIVE, GX_ORTHOGRAPHIC } GXProjMtxType;
typedef enum _GXProjectionType { GX_PERSPECTIVE, GX_ORTHOGRAPHIC } GXProjectionType;
typedef enum _GXSpotFn { GX_SP_OFF, GX_SP_FLAT, GX_SP_COS, GX_SP_COS2, GX_SP_SHARP, GX_SP_RING1, GX_SP_RING2 } GXSpotFn;
@@ -509,10 +525,12 @@ typedef enum _GXTevRegID {
} GXTevRegID;
typedef enum _GXTevScale {
GX_TEV_SCALE_0,
GX_TEV_SCALE_1,
GX_TEV_SCALE_2,
GX_TEV_SCALE_3,
GX_CS_SCALE_1,
GX_CS_SCALE_2,
GX_CS_SCALE_4,
GX_CS_DIVIDE_2,
GX_MAX_TEVSCALE
} GXTevScale;
typedef enum _GXTevStageID {
@@ -624,6 +642,8 @@ typedef enum _GXTevKColorSel {
GX_TEV_KCSEL_K3_A
} GXTevKColorSel;
typedef enum _GXTevMode { GX_MODULATE, GX_DECAL, GX_REPLACE, GX_PASSCLR, GX_BLEND } GXTevMode;
typedef enum _GXTexCoordID {
GX_TEXCOORD0,
GX_TEXCOORD1,
@@ -733,9 +753,9 @@ typedef enum _GXTexMapID {
GX_TEX_DISABLE
} GXTexMapID;
// TODO: Fabricated names
typedef enum _GXTexMtx {
// Any dimension (in standard XF matrix memory)
// Enum represents base row of matrix
GX_TEXMTX0 = 30,
GX_TEXMTX1 = 33,
GX_TEXMTX2 = 36,
@@ -746,18 +766,31 @@ typedef enum _GXTexMtx {
GX_TEXMTX7 = 51,
GX_TEXMTX8 = 54,
GX_TEXMTX9 = 57,
GX_TEXMTX_IDENT = 60,
// 3x4 matrices (in dual-tex XF matrix memory)
GX_DTEXMTX0 = 64,
GX_DTEXMTX1 = 67,
GX_DTEXMTX2 = 70,
GX_DTEXMTX3 = 73,
GX_DTEXMTX4 = 76,
GX_DTEXMTX5 = 79,
GX_DTEXMTX6 = 82,
GX_DTEXMTX7 = 85,
GX_DTEXMTX8 = 88,
GX_DTEXMTX9 = 91,
// Enum represents base row of matrix
GX_DUALMTX0 = 64,
GX_DUALMTX1 = 67,
GX_DUALMTX2 = 70,
GX_DUALMTX3 = 73,
GX_DUALMTX4 = 76,
GX_DUALMTX5 = 79,
GX_DUALMTX6 = 82,
GX_DUALMTX7 = 85,
GX_DUALMTX8 = 88,
GX_DUALMTX9 = 91,
GX_DUALMTX10 = 94,
GX_DUALMTX11 = 97,
GX_DUALMTX12 = 100,
GX_DUALMTX13 = 103,
GX_DUALMTX14 = 106,
GX_DUALMTX15 = 109,
GX_DUALMTX16 = 112,
GX_DUALMTX17 = 115,
GX_DUALMTX18 = 118,
GX_DUALMTX19 = 121,
GX_DUALMTX_IDENT = 125,
} GXTexMtx;
typedef enum _GXTexWrapMode {
@@ -776,9 +809,8 @@ typedef enum _GXTlutFmt {
GX_MAX_TLUTFMT
} GXTlutFmt;
// TODO: Fabricated name
typedef enum _GXVtxFmt {
GX_VTXFMT0, // from patent
GX_VTXFMT0,
GX_VTXFMT1,
GX_VTXFMT2,
GX_VTXFMT3,
@@ -787,15 +819,24 @@ typedef enum _GXVtxFmt {
GX_VTXFMT6,
GX_VTXFMT7,
GX_MAX_VTXFMT,
GX_MAX_VTXFMT
} GXVtxFmt;
typedef enum _GXZFmt {
GX_ZC_LINEAR, // from patent
GX_ZC_NEAR, // from Dolphin
GX_ZC_MID, // from Dolphin
GX_ZC_FAR, // from Dolphin
} GXZFmt;
typedef enum _GXZFmt16 {
GX_ZC_LINEAR,
GX_ZC_NEAR,
GX_ZC_MID,
GX_ZC_FAR,
} GXZFmt16;
// From patent
typedef enum _GXZTexOp {
GX_ZT_DISABLE,
GX_ZT_ADD,
GZ_ZT_REPLACE,
GX_MAX_ZTEXOP
} GXZTexOp;
#ifdef __cplusplus
}
+5 -4
View File
@@ -66,7 +66,7 @@ typedef enum {
NAND_PERM_RWALL = NAND_PERM_RALL | NAND_PERM_WALL
} NANDPermission;
typedef void (*NANDAsyncCallback)(s32 result, struct NANDCommandBlock *block);
typedef void (*NANDAsyncCallback)(long result, struct NANDCommandBlock *block);
typedef struct NANDStatus {
u32 ownerId; // at 0x0
@@ -76,8 +76,8 @@ typedef struct NANDStatus {
} NANDStatus;
typedef struct NANDFileInfo {
s32 fd; // at 0x0
s32 tempFd; // at 0x4
long fd; // at 0x0
long tempFd; // at 0x4
char openPath[FS_MAX_PATH]; // at 0x8
char tempPath[FS_MAX_PATH]; // at 0x48
u8 access; // at 0x88
@@ -118,6 +118,7 @@ typedef struct NANDCommandBlock {
u32 workBlocks; // at 0xAC
u32 workInodes; // at 0xB0
const char **dir; // at 0xB4
int simpleFlag; //
} NANDCommandBlock;
typedef struct NANDBanner {
@@ -157,7 +158,7 @@ NANDResult NANDPrivateCreateDirAsync(const char *path, u8 perm, u8 attr, NANDAsy
NANDResult NANDMove(const char *from, const char *to);
NANDResult NANDGetLength(NANDFileInfo *info, u32 *length);
NANDResult NANDGetLength(NANDFileInfo *info, unsigned long *length);
NANDResult NANDGetLengthAsync(NANDFileInfo *info, u32 *lengthOut, NANDAsyncCallback callback, NANDCommandBlock *block);
NANDResult NANDGetStatus(const char *path, NANDStatus *status);