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