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
+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);