Sync some SDK stuff to Wii Sports

This commit is contained in:
Amber Brault 2024-09-21 01:29:34 -04:00
parent e8262d9123
commit 23c37a9a75
52 changed files with 2501 additions and 1170 deletions

View File

@ -11,6 +11,7 @@ extern "C" {
#include <revolution/nwc24/NWC24Schedule.h>
#include <revolution/nwc24/NWC24System.h>
#include <revolution/nwc24/NWC24Time.h>
#include <revolution/nwc24/NWC24Types.h>
#ifdef __cplusplus
}

View File

@ -4,7 +4,6 @@
extern "C" {
#endif
#include <revolution/wpad/debug_msg.h>
#include <revolution/wpad/WPAD.h>
#ifdef __cplusplus

View File

@ -4,7 +4,6 @@
extern "C" {
#endif
#include <revolution/wud/debug_msg.h>
#ifdef __cplusplus
}

View File

@ -1,6 +1,6 @@
#ifndef RVL_SDK_DVD_FS_H
#define RVL_SDK_DVD_FS_H
#include <revolution/DVD/dvd.h>
#include <revolution/dvd/dvd.h>
#include <revolution/OS.h>
#include <types.h>
#ifdef __cplusplus

View File

@ -1,6 +1,6 @@
#ifndef RVL_SDK_DVD_ID_UTILS_H
#define RVL_SDK_DVD_ID_UTILS_H
#include <revolution/DVD/dvd.h>
#include <revolution/dvd/dvd.h>
#include <types.h>
#ifdef __cplusplus
extern "C" {

View File

@ -1,6 +1,6 @@
#ifndef RVL_SDK_DVD_QUEUE_H
#define RVL_SDK_DVD_QUEUE_H
#include <revolution/DVD/dvd.h>
#include <revolution/dvd/dvd.h>
#include <types.h>
#ifdef __cplusplus
extern "C" {

View File

@ -5,7 +5,6 @@
extern "C" {
#endif
// Forward declarations
typedef struct OSContext;
@ -57,7 +56,7 @@ static u32 __EXISwap32(u32 val) {
val << 8 & 0x00FF0000 | val << 24 & 0xFF000000;
}
BOOL EXIWriteReg(EXIChannel chan, u32 dev, u32 r5, const void* buf, s32 len);
BOOL EXIWriteReg(EXIChannel chan, u32 dev, u32 cmd, const void* buf, s32 len);
#ifdef __cplusplus
}

View File

@ -1,12 +1,12 @@
#ifndef RVL_SDK_EXI_UART_H
#define RVL_SDK_EXI_UART_H
#include <revolution/exi/EXIBios.h>
#include <revolution/exi/EXICommon.h>
#include <types.h>
#ifdef __cplusplus
extern "C" {
#endif
void __OSEnableBarnacle(EXIChannel, u32);
void __OSEnableBarnacle(EXIChannel chan, u32 dev);
#ifdef __cplusplus
}

View File

@ -8,7 +8,7 @@ extern "C" {
#define FS_MAX_PATH 64
typedef void (*FSAsyncCallback)(s32, void*);
typedef void (*FSAsyncCallback)(s32 result, void* arg);
typedef struct FSStats {
char UNK_0x0[0x1C];
@ -20,13 +20,6 @@ typedef struct FSFileStats {
u32 position; // at 0x4
} FSFileStats ALIGN(32);
typedef struct FSFileAttr {
u32 ownerId; // at 0x0
u16 groupId; // at 0x4
u8 attr; // at 0x6
u8 perm; // at 0x7
} FSFileAttr;
s32 ISFS_OpenLib(void);
s32 ISFS_CreateDir(const char* path, u32 attr, u32 ownerPerm, u32 groupPerm,
u32 otherPerm);
@ -74,8 +67,6 @@ s32 ISFS_Close(s32 fd);
s32 ISFS_CloseAsync(s32 fd, FSAsyncCallback callback, void* callbackArg);
s32 ISFS_ShutdownAsync(FSAsyncCallback callback, void* callbackArg);
#ifdef __cplusplus
}
#endif

View File

@ -15,7 +15,7 @@
#define RVL_SDK_GX_HARDWARE_H
#include <types.h>
#include <revolution/GX/GXTypes.h>
#include <revolution/gx/GXTypes.h>
#ifdef __cplusplus
extern "C" {
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,10 @@
#ifndef RVL_SDK_GX_PIXEL_H
#define RVL_SDK_GX_PIXEL_H
#include <revolution/gx/GXTypes.h>
#include <revolution/MTX.h>
#include <types.h>
#include <revolution/gx/GXTypes.h>
#include <revolution/MTX.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -11,6 +13,8 @@ typedef struct _GXFogAdjTable {
u16 r[10]; // at 0x0
} GXFogAdjTable;
#define GX_FOG_ADJ_TABLE_SZ 10
void GXSetFog(GXFogType type, GXColor color, f32 start, f32 end, f32 near,
f32 far);
void GXInitFogAdjTable(GXFogAdjTable* table, u16 width, const Mtx44 proj);

View File

@ -1,8 +1,10 @@
#ifndef RVL_SDK_GX_TRANSFORM_H
#define RVL_SDK_GX_TRANSFORM_H
#include <revolution/gx/GXTypes.h>
#include <revolution/MTX.h>
#include <types.h>
#include <revolution/gx/GXTypes.h>
#include <revolution/MTX.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -25,9 +25,9 @@ void PSMTXConcatArray(const Mtx, const Mtx, Mtx, u32);
void PSMTXTranspose(const Mtx, Mtx);
void PSMTXInverse(const Mtx, Mtx);
void PSMTXInvXpose(const Mtx, Mtx);
void PSMTXRotRad(Mtx, char, f32);
void PSMTXRotTrig(Mtx, char, f32, f32);
void PSMTXRotAxisRad(Mtx, const struct Vec*, f32);
void PSMTXRotRad(Mtx, f32, char);
void PSMTXRotTrig(Mtx, f32, f32, char);
void PSMTXRotAxisRad(Mtx, const Vec*, f32);
void PSMTXTrans(Mtx, f32, f32, f32);
void PSMTXTransApply(const Mtx, Mtx, f32, f32, f32);
void PSMTXScale(Mtx, f32, f32, f32);

View File

@ -21,5 +21,4 @@ void C_QUATSlerp(const Quaternion*, const Quaternion*, Quaternion*, f32);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -4,7 +4,7 @@
#include <types.h>
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
#endif
void PSVECAdd(const Vec* a, const Vec* b, Vec* sum);
void PSVECScale(const Vec* in, Vec* out, f32 scale);

View File

@ -1,11 +1,16 @@
#ifndef RVL_SDK_NWC24_SCHEDULE_H
#define RVL_SDK_NWC24_SCHEDULE_H
#include <revolution/nwc24/NWC24Types.h>
#include <types.h>
#ifdef __cplusplus
extern "C" {
#endif
s32 NWC24SuspendScheduler(void);
s32 NWC24ResumeScheduler(void);
NWC24Err NWC24iRequestGenerateUserId(u64* idOut, u32* arg1);
NWC24Err NWC24iTrySuspendForOpenLib(void);
NWC24Err NWC24iResumeForCloseLib(void);
#ifdef __cplusplus
}

View File

@ -1,11 +1,15 @@
#ifndef RVL_SDK_NWC24_SYSTEM_H
#define RVL_SDK_NWC24_SYSTEM_H
#include <revolution/nwc24/NWC24Types.h>
#include <types.h>
#ifdef __cplusplus
extern "C" {
#endif
s32 NWC24iPrepareShutdown(void);
NWC24Err NWC24EnableLedNotification(BOOL enable);
NWC24Err NWC24iPrepareShutdown(void);
NWC24Err NWC24iRequestShutdown(u32 event, NWC24Err* resultOut);
BOOL NWC24Shutdown(BOOL final, u32 event);
#ifdef __cplusplus
}

View File

@ -1,11 +1,15 @@
#ifndef RVL_SDK_NWC24_TIME_H
#define RVL_SDK_NWC24_TIME_H
#include <revolution/nwc24/NWC24Types.h>
#include <types.h>
#ifdef __cplusplus
extern "C" {
#endif
s32 NWC24iSynchronizeRtcCounter(BOOL val);
NWC24Err NWC24iGetUniversalTime(s64* timeOut);
NWC24Err NWC24iGetTimeDifference(s64* diffOut);
NWC24Err NWC24iSetRtcCounter(u32 rtc, u32 flags);
NWC24Err NWC24iSynchronizeRtcCounter(BOOL forceSave);
#ifdef __cplusplus
}

View File

@ -0,0 +1,108 @@
#ifndef RVL_SDK_NWC24_TYPES_H
#define RVL_SDK_NWC24_TYPES_H
#include <types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
NWC24_ERR_OTHER_REGION = -52,
NWC24_ERR_GIVE_UP,
NWC24_ERR_SCRIPT_VERSION,
NWC24_ERR_OLD_SYSTEM,
NWC24_ERR_CANCELLED,
NWC24_ERR_INVALID_CHAR,
NWC24_ERR_FILE_BROKEN,
NWC24_ERR_VERIFY_SIGNATURE,
NWC24_ERR_ID_NOT_REGISTERED,
NWC24_ERR_INTERNAL_VF,
NWC24_ERR_INTERNAL_IPC,
NWC24_ERR_FILE_EXISTS,
NWC24_ERR_INVALID_OPERATION,
NWC24_ERR_DISABLED,
NWC24_ERR_NAND_CORRUPT,
NWC24_ERR_ID_CRC,
NWC24_ERR_ID_REGISTERED,
NWC24_ERR_ID_GENERATED,
NWC24_ERR_ID_NOEXISTS,
NWC24_ERR_CONFIG_NETWORK,
NWC24_ERR_SERVER,
NWC24_ERR_NETWORK,
NWC24_ERR_NOT_READY,
NWC24_ERR_INPROGRESS,
NWC24_ERR_HIDDEN,
NWC24_ERR_VER_MISMATCH,
NWC24_ERR_BUSY,
NWC24_ERR_STRING_END,
NWC24_ERR_FORMAT,
NWC24_ERR_ALIGNMENT,
NWC24_ERR_MUTEX,
NWC24_ERR_FILE_OTHER,
NWC24_ERR_FILE_NOEXISTS,
NWC24_ERR_FILE_WRITE,
NWC24_ERR_FILE_READ,
NWC24_ERR_FILE_CLOSE,
NWC24_ERR_FILE_OPEN,
NWC24_ERR_DONE,
NWC24_ERR_BROKEN,
NWC24_ERR_NOT_FOUND,
NWC24_ERR_CONFIG,
NWC24_ERR_NOMEM,
NWC24_ERR_LIB_OPENED,
NWC24_ERR_LIB_NOT_OPENED,
NWC24_ERR_OVERFLOW,
NWC24_ERR_PROTECTED,
NWC24_ERR_FULL,
NWC24_ERR_NULL,
NWC24_ERR_NOT_SUPPORTED,
NWC24_ERR_INVALID_VALUE,
NWC24_ERR_FAILED,
NWC24_ERR_FATAL,
NWC24_OK
} NWC24Err;
typedef enum {
NWC24_APPLICATION_OCTET_STREAM = 0x00030000,
NWC24_X_WII_MINIDATA = 0x00030002,
NWC24_X_WII_MSGBOARD = 0x00030001,
NWC24_IMAGE_JPEG = 0x00020000,
NWC24_X_WII_PICTURE = 0x00020001,
NWC24_MULTIPART_ALTERNATIVE = 0x000F0001,
NWC24_MULTIPART_MIXED = 0x000F0000,
NWC24_MULTIPART_RELATED = 0x000F0002,
NWC24_TEXT_HTML = 0x00010001,
NWC24_TEXT_PLAIN = 0x00010000
} NWC24MIMEType;
typedef enum {
NWC24_EUC_JP = 0x00020002,
NWC24_ISO_2022_JP = 0x00020000,
NWC24_ISO_8859_1 = 0x00080001,
NWC24_ISO_8859_10 = 0x0008000A,
NWC24_ISO_8859_15 = 0x0008000F,
NWC24_ISO_8859_2 = 0x00080002,
NWC24_ISO_8859_3 = 0x00080003,
NWC24_ISO_8859_5 = 0x00080005,
NWC24_ISO_8859_7 = 0x00080007,
NWC24_ISO_8859_9 = 0x00080009,
NWC24_SHIFT_JIS = 0x00020001,
NWC24_US_ASCII = 0x00000000,
NWC24_UTF_16BE = 0x00010010,
NWC24_UTF_32BE = 0x00010020,
NWC24_UTF_8 = 0x00010008,
NWC24_WINDOWS_1252 = 0x000F1252,
NWC24_CHARSET_UNKNOWN = 0xFFFFFFFF
} NWC24Charset;
typedef enum {
NWC24_ENC_7BIT,
NWC24_ENC_8BIT,
NWC24_ENC_BASE64,
NWC24_ENC_QUOTED_PRINTABLE,
NWC24_MAX_ENCODINGS
} NWC24Encoding;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -24,8 +24,8 @@ void ICEnable(void);
void LCEnable(void);
void LCDisable(void);
void LCLoadBlocks(void* dst, const void* src, u32 len);
void LCStoreBlocks(void* dst, const void* src, u32 len);
void LCLoadBlocks(void* dst, const void* src, u32 blocks);
void LCStoreBlocks(void* dst, const void* src, u32 blocks);
u32 LCStoreData(void* dst, const void* src, u32 len);
u32 LCQueueLength(void);
void LCQueueWait(u32 n);

View File

@ -9,7 +9,8 @@ extern "C" {
typedef struct OSContext;
#define OSError(...) OSPanic(__FILE__, __LINE__, __VA_ARGS__)
#define OSAssert(exp, ...) \
#define OS_ASSERT(exp, ...) \
if (!(exp)) \
OSPanic(__FILE__, __LINE__, __VA_ARGS__)

View File

@ -10,8 +10,9 @@ extern "C" {
// GQR3: unsigned 16 bit
// GQR4: signed 8 bit
// GQR5: signed 16 bit
static inline void OSInitFastCast(){
asm{
static inline void OSInitFastCast(void) {
// clang-format off
asm {
li r3, 4
oris r3, r3, 4
mtgqr2 r3
@ -28,77 +29,98 @@ static inline void OSInitFastCast(){
oris r3, r3, 7
mtgqr5 r3
}
// clang-format on
}
static inline void OSSetGQR6(register u32 type, register u32 scale) {
register u32 val = ((scale << 8 | type) << 16) | ((scale << 8) | type);
// clang-format off
asm {
mtspr 0x396, val
}
// clang-format on
}
static inline void OSSetGQR7(register u32 type, register u32 scale) {
register u32 val = ((scale << 8 | type) << 16) | ((scale << 8) | type);
// clang-format off
asm {
mtspr 0x397, val
}
// clang-format on
}
static inline f32 __OSu16tof32(register const u16* arg) {
register f32 ret;
// clang-format off
asm {
psq_l ret, 0(arg), 1, 3
}
// clang-format on
return ret;
}
static inline void OSu16tof32(const u16* in, f32* out) { *out = __OSu16tof32(in); }
static inline void OSu16tof32(const u16* in, f32* out) {
*out = __OSu16tof32(in);
}
static inline u16 __OSf32tou16(register f32 arg) {
f32 a;
register f32* ptr = &a;
u16 r;
asm {
// clang-format off
asm {
psq_st arg, 0(ptr), 1, 3
}
// clang-format on
r = *(u16*)ptr;
return r;
}
static inline void OSf32tou16(const f32* in, u16* out) { *out = __OSf32tou16(*in); }
static inline void OSf32tou16(const f32* in, u16* out) {
*out = __OSf32tou16(*in);
}
static inline f32 __OSs16tof32(register const s16* arg) {
register f32 ret;
asm {
// clang-format off
asm {
psq_l ret, 0(arg), 1, 5
}
// clang-format on
return ret;
}
static inline void OSs16tof32(const s16* in, f32* out) { *out = __OSs16tof32(in); }
static inline void OSs16tof32(const s16* in, f32* out) {
*out = __OSs16tof32(in);
}
static inline s16 __OSf32tos16(register f32 arg) {
f32 a;
register f32* ptr = &a;
s16 r;
asm {
// clang-format off
asm {
psq_st arg, 0(ptr), 1, 5
}
// clang-format on
r = *(s16*)ptr;
return r;
}
static inline void OSf32tos16(const f32* in, s16* out) { *out = __OSf32tos16(*in); }
static inline void OSf32tos16(const f32* in, s16* out) {
*out = __OSf32tos16(*in);
}
#ifdef __cplusplus
}

View File

@ -86,6 +86,7 @@ typedef struct OSBI2 {
/**
* 0x80000000 - 0x80000100
*/
// clang-format off
OS_DEF_GLOBAL_VAR(OSBootInfo, BOOT_INFO, 0x80000000);
OS_DEF_GLOBAL_VAR(OSDebugInterface, DEBUG_INTERFACE, 0x80000040);
OS_DEF_GLOBAL_ARR(u8, DB_INTEGRATOR_HOOK, [0x24], 0x80000060);
@ -104,10 +105,12 @@ OS_DEF_GLOBAL_VAR(u32, SIMULATED_MEM_SIZE, 0x800000F0);
OS_DEF_GLOBAL_VAR(OSBI2*, DVD_BI2, 0x800000F4);
OS_DEF_GLOBAL_VAR(u32, BUS_CLOCK_SPEED, 0x800000F8);
OS_DEF_GLOBAL_VAR(u32, CPU_CLOCK_SPEED, 0x800000FC);
// clang-format on
/**
* 0x80003000 - 0x80003F00
*/
// clang-format off
OS_DEF_GLOBAL_ARR(void*, EXCEPTION_TABLE, [15], 0x80003000);
OS_DEF_GLOBAL_VAR(void*, INTR_HANDLER_TABLE, 0x80003040);
OS_DEF_GLOBAL_ARR(volatile s32, EXI_LAST_INSERT, [], 0x800030C0);
@ -154,6 +157,7 @@ OS_DEF_GLOBAL_VAR(u8, BOOT_PARTITION_319C, 0x8000319C);
OS_DEF_GLOBAL_ARR(u8, NWC24_USER_ID_BUFFER, [32], 0x800031C0);
OS_DEF_GLOBAL_VAR(u64, NWC24_USER_ID, 0x800031C0);
OS_DEF_GLOBAL_ARR(u8, SC_PRDINFO, [0x100], 0x80003800);
// clang-format on
/**
* PI hardware globals
@ -254,16 +258,20 @@ typedef enum {
/**
* DI hardware globals
*/
// clang-format off
OS_DEF_HW_REG(volatile u32, DI_DMA_ADDR, 0xCD006014);
OS_DEF_HW_REG(volatile u32, DI_CONFIG, 0xCD006024);
// clang-format on
/**
* Misc/unknown globals
*/
// clang-format off
OS_DEF_HW_REG(volatile u32, UNK_CD000034, 0xCD000034);
OS_DEF_HW_REG(volatile u32, UNK_CD800180, 0xCD800180);
OS_DEF_HW_REG(volatile u32, UNK_CD8001CC, 0xCD8001CC);
OS_DEF_HW_REG(volatile u32, UNK_CD8001D0, 0xCD8001D0);
// clang-format on
#ifdef __cplusplus
}

View File

@ -9,7 +9,7 @@ extern "C" {
// General-purpose typedef
typedef void* OSMessage;
typedef enum { OS_MSG_PERSISTENT = (1 << 0) } OSMessageFlags;
typedef enum { OS_MSG_BLOCKING = (1 << 0) } OSMessageFlags;
typedef struct OSMessageQueue {
OSThreadQueue sendQueue; // at 0x0

View File

@ -7,8 +7,6 @@ extern "C" {
typedef BOOL (*OSShutdownFunction)(BOOL final, u32 event);
typedef enum { OS_SD_PASS_FIRST, OS_SD_PASS_SECOND } OSShutdownPass;
typedef enum {
OS_SD_EVENT_SHUTDOWN = 2,
OS_SD_EVENT_RESTART = 4,

View File

@ -9,7 +9,7 @@ extern "C" {
#endif
typedef enum {
SC_STATUS_READY,
SC_STATUS_OK,
SC_STATUS_BUSY,
SC_STATUS_FATAL,
SC_STATUS_PARSE

View File

@ -5,7 +5,6 @@
extern "C" {
#endif
/**
* VI hardware registers
*/

View File

@ -16,16 +16,27 @@ typedef enum {
} WPADChan;
typedef enum {
WPAD_RESULT_ERR_3 = -3,
WPAD_RESULT_ERR_2,
WPAD_RESULT_ERR_1,
WPAD_ERR_CORRUPTED = -7,
WPAD_ERR_6,
WPAD_ERR_5,
WPAD_ERR_INVALID,
WPAD_ERR_TRANSFER,
WPAD_ERR_BUSY,
WPAD_ERR_NO_CONTROLLER,
WPAD_RESULT_SUCCESS = 0,
WPAD_ERR_OK = 0,
} WPADResult;
UNKTYPE WPADControlSpeaker(s32, UNKWORD, WPADCallback);
typedef enum {
WPAD_SPEAKER_OFF,
WPAD_SPEAKER_ON,
WPAD_SPEAKER_PLAY = 4,
} WPADSpeakerCommand;
s32 WPADControlSpeaker(s32, UNKWORD, WPADCallback);
BOOL WPADCanSendStreamData(s32);
UNKWORD WPADSendStreamData(s32, UNKTYPE*, UNKWORD);
s32 WPADSendStreamData(s32, UNKTYPE*, UNKWORD);
s32 WPADProbe(s32 chan, u32* type);
s32 WPADReadFaceData(s32 chan, void* dst, u32 size, u32 src, WPADCallback cb);

View File

@ -165,7 +165,8 @@ void __AIDHandler(s32 intr, OSContext* ctx) {
}
static asm void __AICallbackStackSwitch(register AIDMACallback callback) {
// clang-format off
mr r31, callback
lis r5, __OldStack@ha
@ -187,7 +188,8 @@ static asm void __AICallbackStackSwitch(register AIDMACallback callback) {
frfree
blr
}
// clang-format on
}
static void __AI_SRC_INIT(void) {
s64 start = 0;

View File

@ -15,10 +15,11 @@ BOOL ARCInitHandle(void* bin, ARCHandle* handle) {
ARCNode* nodes;
ARCHeader* header = (ARCHeader*)bin;
if (header->magic != ARC_FILE_MAGIC) {
// clang-format off
#line 74
OSError("ARCInitHandle: bad archive format");
}
OS_ASSERT(header->magic == ARC_FILE_MAGIC, "ARCInitHandle: bad archive format");
// clang-format on
handle->header = header;
nodes = (ARCNode*)((u8*)header + header->nodes.offset);

View File

@ -2,15 +2,19 @@
#include <revolution/OS.h>
asm u32 PPCMfmsr(void) {
// clang-format off
nofralloc
mfmsr r3
blr
// clang-format on
}
asm void PPCMtmsr(register u32 val) {
// clang-format off
nofralloc
mtmsr val
blr
// clang-format on
}
@ -27,15 +31,19 @@ asm void PPCAndCMsr(){
}
asm u32 PPCMfhid0(void) {
// clang-format off
nofralloc
mfhid0 r3
blr
// clang-format on
}
asm void PPCMthid0(register u32 val) {
// clang-format off
nofralloc
mthid0 val
blr
// clang-format on
}
//unused
@ -43,21 +51,27 @@ asm void PPCMfhid1(){
}
asm u32 PPCMfl2cr(void) {
// clang-format off
nofralloc
mfl2cr r3
blr
// clang-format on
}
asm void PPCMtl2cr(register u32 val) {
// clang-format off
nofralloc
mtl2cr val
blr
// clang-format on
}
asm void PPCMtdec(register u32 val) {
// clang-format off
nofralloc
mtdec val
blr
// clang-format on
}
//unused
@ -65,9 +79,11 @@ asm void PPCMfdec(){
}
asm void PPCSync(void) {
// clang-format off
nofralloc
sc
blr
// clang-format on
}
//unused
@ -75,6 +91,7 @@ asm void PPCEieio(){
}
asm void PPCHalt(void) {
// clang-format off
nofralloc
sync
@ -83,6 +100,7 @@ loop:
li r3, 0
nop
b loop
// clang-format on
}
//unused
@ -90,9 +108,11 @@ asm void PPCMfmmcr0(){
}
asm void PPCMtmmcr0(register u32 val) {
// clang-format off
nofralloc
mtmmcr0 val
blr
// clang-format on
}
//unused
@ -100,9 +120,11 @@ asm void PPCMfmmcr1(){
}
asm void PPCMtmmcr1(register u32 val) {
// clang-format off
nofralloc
mtmmcr1 val
blr
// clang-format on
}
//unused
@ -110,9 +132,11 @@ asm void PPCMfpmc1(){
}
asm void PPCMtpmc1(register u32 val) {
// clang-format off
nofralloc
mtpmc1 val
blr
// clang-format on
}
//unused
@ -120,9 +144,11 @@ asm void PPCMfpmc2(){
}
asm void PPCMtpmc2(register u32 val) {
// clang-format off
nofralloc
mtpmc2 val
blr
// clang-format on
}
//unused
@ -130,9 +156,11 @@ asm void PPCMfpmc3(){
}
asm void PPCMtpmc3(register u32 val) {
// clang-format off
nofralloc
mtpmc3 val
blr
// clang-format on
}
//unused
@ -140,9 +168,11 @@ asm void PPCMfpmc4(){
}
asm void PPCMtpmc4(register u32 val){
// clang-format off
nofralloc
mtpmc4 val
blr
// clang-format on
}
//unused
@ -154,17 +184,19 @@ asm void PPCMtsia(){
}
u32 PPCMffpscr(void) {
// clang-format off
register u64 fpscr;
asm {
mffs f31
stfd f31, fpscr
}
return fpscr;
// clang-format on
}
void PPCMtfpscr(register u32 val) {
// clang-format off
register struct {
f32 tmp;
f32 data;
@ -177,31 +209,40 @@ void PPCMtfpscr(register u32 val) {
lfd f31, fpscr.tmp
mtfs f31
}
// clang-format on
}
asm u32 PPCMfhid2(void) {
// clang-format off
nofralloc
mfspr r3, 0x398 //HID2
blr
// clang-format on
}
asm void PPCMthid2(register u32 val) {
// clang-format off
nofralloc
mtspr 0x398, val //HID2
blr
// clang-format on
}
asm u32 PPCMfwpar(void) {
// clang-format off
nofralloc
sync
mfwpar r3
blr
// clang-format on
}
asm void PPCMtwpar(register u32 val) {
// clang-format off
nofralloc
mtwpar r3
blr
// clang-format on
}
//unused
@ -235,9 +276,11 @@ asm void PPCSetFpIEEEMode(){
}
asm void PPCSetFpNonIEEEMode(void) {
// clang-format off
nofralloc
mtfsb1 29
blr
// clang-format on
}
//unused
@ -246,14 +289,18 @@ void PPCMfhid4(){
void PPCMthid4(register u32 val) {
if (val & HID4_H4A) {
// clang-format off
asm {
mtspr 0x3F3, val //HID4
}
// clang-format on
} else {
OSReport("H4A should not be cleared because of Broadway errata.\n");
val |= HID4_H4A;
// clang-format off
asm {
mtspr 0x3F3, val //HID4
}
// clang-format on
}
}

View File

@ -25,7 +25,8 @@ void __DBExceptionDestinationAux(void) {
}
asm void __DBExceptionDestination(void){
nofralloc
// clang-format off
nofralloc
// Set up MMU
mfmsr r3
@ -33,6 +34,7 @@ asm void __DBExceptionDestination(void){
mtmsr r3
b __DBExceptionDestinationAux
// clang-format on
}
BOOL __DBIsExceptionMarked(u8 exc) {
@ -47,4 +49,6 @@ void __DBMarkException(){
void __DBSetPresent(){
}
void DBPrintf(const char* msg, ...) {}
void DBPrintf(const char* msg, ...) {
#pragma unused(msg)
}

View File

@ -367,7 +367,7 @@ static void stateReadingFST(void) {
// clang-format off
#line 1090
OSAssert(bootInfo->fstSize >= BB2.fstSize, "DVDChangeDisk(): FST in the new disc is too big. ");
OS_ASSERT(bootInfo->fstSize >= BB2.fstSize, "DVDChangeDisk(): FST in the new disc is too big. ");
// clang-format on
DVDLowClearCoverInterrupt(NULL);

View File

@ -5,6 +5,7 @@ inline void LoadProjPS(register f32* dst) {
register f32 ps_0, ps_1, ps_2;
register GXData* src;
// clang-format off
asm volatile {
lwz src, __GXData
psq_l ps_0, 0 + GXData.proj(src), 0, 0
@ -14,11 +15,13 @@ inline void LoadProjPS(register f32* dst) {
psq_st ps_1, 8(dst), 0, 0
psq_st ps_2, 16(dst), 0, 0
}
// clang-format on
}
inline void WriteProjPS(register volatile void* dst, register const f32* src) {
register f32 ps_0, ps_1, ps_2;
// clang-format off
asm volatile {
psq_l ps_0, 0(src), 0, 0
psq_l ps_1, 8(src), 0, 0
@ -27,11 +30,13 @@ inline void WriteProjPS(register volatile void* dst, register const f32* src) {
psq_st ps_1, 0(dst), 0, 0
psq_st ps_2, 0(dst), 0, 0
}
// clang-format on
}
inline void Copy6Floats(register f32* dst, register const f32* src) {
register f32 ps_0, ps_1, ps_2;
// clang-format off
asm volatile {
psq_l ps_0, 0(src), 0, 0
psq_l ps_1, 8(src), 0, 0
@ -40,6 +45,7 @@ inline void Copy6Floats(register f32* dst, register const f32* src) {
psq_st ps_1, 8(dst), 0, 0
psq_st ps_2, 16(dst), 0, 0
}
// clang-format on
}
//unused
@ -89,6 +95,7 @@ void GXGetProjectionv(f32 proj[7]) {
inline void WriteMTXPS4x3(register volatile void* dst, register const Mtx src) {
register f32 ps_0, ps_1, ps_2, ps_3, ps_4, ps_5;
// clang-format off
asm volatile {
psq_l ps_0, 0(src), 0, 0
psq_l ps_1, 8(src), 0, 0
@ -104,11 +111,13 @@ inline void WriteMTXPS4x3(register volatile void* dst, register const Mtx src) {
psq_st ps_4, 0(dst), 0, 0
psq_st ps_5, 0(dst), 0, 0
}
// clang-format on
}
inline void WriteMTXPS3x3(register volatile void* dst, register const Mtx src) {
register f32 ps_0, ps_1, ps_2, ps_3, ps_4, ps_5;
// clang-format off
asm volatile {
psq_l ps_0, 0(src), 0, 0
lfs ps_1, 8(src)
@ -124,11 +133,13 @@ inline void WriteMTXPS3x3(register volatile void* dst, register const Mtx src) {
psq_st ps_4, 0(dst), 0, 0
stfs ps_5, 0(dst)
}
// clang-format on
}
inline void WriteMTXPS4x2(register volatile void* dst, register const Mtx src) {
register f32 ps_0, ps_1, ps_2, ps_3;
// clang-format off
asm volatile {
psq_l ps_0, 0(src), 0, 0
psq_l ps_1, 8(src), 0, 0
@ -140,6 +151,7 @@ inline void WriteMTXPS4x2(register volatile void* dst, register const Mtx src) {
psq_st ps_2, 0(dst), 0, 0
psq_st ps_3, 0(dst), 0, 0
}
// clang-format on
}
void GXLoadPosMtxImm(const Mtx mtx, u32 id) {
@ -224,10 +236,7 @@ void __GXSetViewport(void) {
void GXSetViewportJitter(f32 ox, f32 oy, f32 sx, f32 sy, f32 near, f32 far,
u32 nextField) {
// "Field" as in VI field
// TODO: Is this an enum? I don't know anything about the return value other
// than that it is a u32 (NW4R signature)
if (nextField == 0) {
if (nextField == GX_FIELD_EVEN) {
oy -= 0.5f;
}

View File

@ -310,19 +310,19 @@ loc0:
void C_MTXRotRad(){
}
void PSMTXRotRad(Mtx m, char axis, f32 rad) {
void PSMTXRotRad(Mtx m, f32 rad, char axis) {
f32 sinA, cosA;
sinA = sinf(rad);
cosA = cosf(rad);
PSMTXRotTrig(m, axis, sinA, cosA);
PSMTXRotTrig(m, sinA, cosA, axis);
}
//unused
void C_MTXRotTrig(){
}
void PSMTXRotTrig(register Mtx m, register char arg2, register f32 arg3,
register f32 arg4) {
void PSMTXRotTrig(register Mtx m, register f32 arg3,
register f32 arg4, register char arg2) {
register f32 vv1, vv2, vv3;
register f32 vv4, vv5, vv6, vv7;

View File

@ -28,14 +28,13 @@ void C_MTXFrustum(Mtx44 mtx, f32 t, f32 b, f32 l, f32 r, f32 n, f32 f) {
mtx[3][3] = 0.0f;
}
DECOMP_FORCELITERAL(mtx44_c, 0.5f);
void C_MTXPerspective(Mtx44 mtx, f32 fovy, f32 aspect, f32 n, f32 f) {
f32 rad, cot;
f32 invrange;
f32 fov;
fov = 0.5f * fovy;
rad = M_PI / 180.0f * fov;
rad = M_PI / 180.0f * (0.5f * fovy);
cot = 1.0f / tanf(rad);
mtx[0][0] = cot / aspect;

View File

@ -226,9 +226,12 @@ static asm void DecrementerExceptionHandler(register u8 type,
stwu r1, -8(r1)
b DecrementerExceptionCallback
}
// clang-format on
}
void OSSetAlarmTag(OSAlarm* alarm, u32 tag) { alarm->tag = tag; }
void OSSetAlarmTag(OSAlarm* alarm, u32 tag) {
alarm->tag = tag;
}
//unused
void OSCancelAlarms(){
@ -238,7 +241,7 @@ static BOOL OnReset(BOOL final, u32 event) {
OSAlarm* iter;
OSAlarm* next;
if (final != OS_SD_PASS_FIRST) {
if (final) {
iter = AlarmQueue.head;
next = (iter != NULL) ? iter->next : NULL;
@ -259,7 +262,9 @@ void OSSetAlarmUserData(OSAlarm* alarm, void* userData) {
alarm->userData = userData;
}
void* OSGetAlarmUserData(const OSAlarm* alarm) { return alarm->userData; }
void* OSGetAlarmUserData(const OSAlarm* alarm) {
return alarm->userData;
}
//unused
void __OSSetInternalAlarmUserData(OSAlarm* alarm, void* userData){

View File

@ -5,36 +5,60 @@ static void* s_mem2ArenaLo = (void*)-1;
static void* __OSArenaHi = NULL;
static void* s_mem2ArenaHi = NULL;
void* OSGetMEM1ArenaHi(void) { return __OSArenaHi; }
void* OSGetMEM1ArenaHi(void) {
return __OSArenaHi;
}
void* OSGetMEM2ArenaHi(void) { return s_mem2ArenaHi; }
void* OSGetMEM2ArenaHi(void) {
return s_mem2ArenaHi;
}
void* OSGetArenaHi(void) { return OSGetMEM1ArenaHi(); }
void* OSGetArenaHi(void) {
return OSGetMEM1ArenaHi();
}
void* OSGetMEM1ArenaLo(void) { return __OSArenaLo; }
void* OSGetMEM1ArenaLo(void) {
return __OSArenaLo;
}
void* OSGetMEM2ArenaLo(void) { return s_mem2ArenaLo; }
void* OSGetMEM2ArenaLo(void) {
return s_mem2ArenaLo;
}
void* OSGetArenaLo(void) { return OSGetMEM1ArenaLo(); }
void* OSGetArenaLo(void) {
return OSGetMEM1ArenaLo();
}
void OSSetMEM1ArenaHi(void* hi) { __OSArenaHi = hi; }
void OSSetMEM1ArenaHi(void* hi) {
__OSArenaHi = hi;
}
void OSSetMEM2ArenaHi(void* hi) { s_mem2ArenaHi = hi; }
void OSSetMEM2ArenaHi(void* hi) {
s_mem2ArenaHi = hi;
}
void OSSetArenaHi(void* hi) { OSSetMEM1ArenaHi(hi); }
void OSSetArenaHi(void* hi) {
OSSetMEM1ArenaHi(hi);
}
void OSSetMEM1ArenaLo(void* lo) { __OSArenaLo = lo; }
void OSSetMEM1ArenaLo(void* lo) {
__OSArenaLo = lo;
}
void OSSetMEM2ArenaLo(void* lo) { s_mem2ArenaLo = lo; }
void OSSetMEM2ArenaLo(void* lo) {
s_mem2ArenaLo = lo;
}
void OSSetArenaLo(void* lo) { OSSetMEM1ArenaLo(lo); }
void OSSetArenaLo(void* lo) {
OSSetMEM1ArenaLo(lo);
}
void* OSAllocFromMEM1ArenaLo(size_t size, u32 align) {
u8* blk_start = ROUND_UP_PTR(OSGetMEM1ArenaLo(), align);
u8* blk_end = blk_start + size;
blk_end = ROUND_UP_PTR(blk_end, align);
OSSetMEM1ArenaLo(blk_end);
return blk_start;
u8* begin = ROUND_UP_PTR(OSGetMEM1ArenaLo(), align);
u8* end = begin + size;
end = ROUND_UP_PTR(end, align);
OSSetMEM1ArenaLo(end);
return begin;
}
//unused

View File

@ -16,7 +16,8 @@ asm void DCEnable(void) {
mthid0 r3
blr
}
// clang-format on
}
//unused
asm void DCDisable(){
@ -181,7 +182,8 @@ do_zero:
bdnz do_zero
blr
}
// clang-format on
}
//unused
asm void DCTouchRange(){
@ -234,7 +236,8 @@ asm void ICEnable(void) {
mthid0 r3
blr
}
// clang-format on
}
//unused
asm void ICDisable(){
@ -346,7 +349,8 @@ do_invalidate:
mtspr 0x398, r4
blr
}
// clang-format on
}
//unused
asm void LCIsEnable(){
@ -361,15 +365,15 @@ asm void LCAllocTags(){
}
asm void LCLoadBlocks(register void* dst, register const void* src,
register u32 len) {
register u32 blocks) {
// clang-format off
nofralloc
rlwinm r6, len, 30, 27, 31
rlwinm r6, blocks, 30, 27, 31
clrlwi src, src, 3
or r6, r6, src
mtspr DMA_U, r6
rlwinm r6, len, 2, 28, 29
rlwinm r6, blocks, 2, 28, 29
or r6, r6, dst
ori r6, r6, 0x12
mtspr DMA_L, r6
@ -379,21 +383,22 @@ asm void LCLoadBlocks(register void* dst, register const void* src,
}
asm void LCStoreBlocks(register void* dst, register const void* src,
register u32 len){
register u32 blocks){
// clang-format off
nofralloc
rlwinm r6, len, 30, 27, 31
rlwinm r6, blocks, 30, 27, 31
clrlwi dst, dst, 3
or r6, r6, dst
mtspr DMA_U, r6
rlwinm r6, len, 2, 28, 29
rlwinm r6, blocks, 2, 28, 29
or r6, r6, src
ori r6, r6, 0x2
mtspr DMA_L, r6
blr
}
// clang-format on
}
//unused
asm void LCAlloc(){
@ -448,7 +453,8 @@ asm void LCQueueWait(register u32 n) {
bgt LCQueueWait
blr
}
// clang-format on
}
//unused
asm void LCFlushQueue(){

View File

@ -172,6 +172,7 @@ static asm void __OSSaveFPUContext(UNKWORD unused, UNKWORD unused1,
_exit:
blr
// clang-format on
}
//unused
@ -357,7 +358,8 @@ asm void* OSGetStackPointer(void) {
mr r3, r1
blr
}
// clang-format on
}
//unused
asm void OSSwitchStack(){

View File

@ -152,9 +152,8 @@ u16 OSGetFontEncode(void) {
switch (*(u32*)OSPhysicalToCached(OS_PHYS_TV_FORMAT)) {
case VI_NTSC:
FontEncode = ((VI_HW_REGS[VI_VISEL] & 2) != 0)
? OS_FONT_ENCODE_SJIS
: OS_FONT_ENCODE_ANSI;
FontEncode = ((VI_HW_REGS[VI_VISEL] & 2) != 0) ? OS_FONT_ENCODE_SJIS
: OS_FONT_ENCODE_ANSI;
break;
case VI_PAL:
case VI_MPAL:
@ -170,7 +169,6 @@ u16 OSGetFontEncode(void) {
return FontEncode;
}
u16 OSSetFontEncode(u16 encode) {
u16 old = OSGetFontEncode();

View File

@ -5,7 +5,9 @@ static OSShutdownFunctionInfo ShutdownFunctionInfo = {OnShutdown, 127, NULL,
NULL};
//unused
u32 OSGetPhysicalMem1Size(void) { return OS_PHYSICAL_MEM1_SIZE; }
u32 OSGetPhysicalMem1Size(void) {
return OS_PHYSICAL_MEM1_SIZE;
}
u32 OSGetPhysicalMem2Size(void) {
return OS_PHYSICAL_MEM2_SIZE;
@ -22,7 +24,7 @@ u32 OSGetConsoleSimulatedMem2Size(void) {
static BOOL OnShutdown(BOOL final, u32 event) {
#pragma unused(event)
if (final != OS_SD_PASS_FIRST) {
if (final) {
MI_HW_REGS[MI_PROT_MEM0] = 0xFF;
__OSMaskInterrupts(
OS_INTR_MASK(OS_INTR_MEM_0) | OS_INTR_MASK(OS_INTR_MEM_1) |
@ -32,7 +34,7 @@ static BOOL OnShutdown(BOOL final, u32 event) {
return TRUE;
}
// Typo
// TYPO
static void MEMIntrruptHandler(s32 intr, OSContext* ctx) {
#pragma unused(intr)
@ -87,7 +89,8 @@ static asm void ConfigMEM1_24MB(void) {
mflr r3
mtsrr0 r3
rfi
}
// clang-format on
}
static asm void ConfigMEM2_52MB(void) {
// clang-format off

View File

@ -15,7 +15,7 @@ BOOL OSSendMessage(OSMessageQueue* queue, OSMessage mesg, u32 flags) {
BOOL enabled = OSDisableInterrupts();
while (queue->capacity <= queue->size) {
if (!(flags & OS_MSG_PERSISTENT)) {
if (!(flags & OS_MSG_BLOCKING)) {
OSRestoreInterrupts(enabled);
return FALSE;
}
@ -36,7 +36,7 @@ BOOL OSReceiveMessage(OSMessageQueue* queue, OSMessage* mesg, u32 flags) {
BOOL enabled = OSDisableInterrupts();
while (queue->size == 0) {
if (!(flags & OS_MSG_PERSISTENT)) {
if (!(flags & OS_MSG_BLOCKING)) {
OSRestoreInterrupts(enabled);
return FALSE;
}
@ -61,7 +61,7 @@ BOOL OSJamMessage(OSMessageQueue* queue, OSMessage mesg, u32 flags) {
BOOL enabled = OSDisableInterrupts();
while (queue->capacity <= queue->size) {
if (!(flags & OS_MSG_PERSISTENT)) {
if (!(flags & OS_MSG_BLOCKING)) {
OSRestoreInterrupts(enabled);
return FALSE;
}

View File

@ -141,9 +141,10 @@ void __OSShutdownToSBY(void) {
VI_HW_REGS[VI_DCR] = 0;
// clang-format off
#line 347
OSAssert(StmReady,
"Error: The firmware doesn't support shutdown feature.\n");
OS_ASSERT(StmReady, "Error: The firmware doesn't support shutdown feature.\n");
// clang-format on
in_args[0] = 0;
IOS_Ioctl(StmImDesc, STM_IOCTL_SHUTDOWN_TO_SBY, StmImInBuf,
@ -160,8 +161,10 @@ void __OSShutdownToIDL(){
void __OSHotReset(void) {
VI_HW_REGS[VI_DCR] = 0;
// clang-format off
#line 412
OSAssert(StmReady, "Error: The firmware doesn't support reboot feature.\n");
OS_ASSERT(StmReady, "Error: The firmware doesn't support reboot feature.\n");
// clang-format on
IOS_Ioctl(StmImDesc, STM_IOCTL_HOT_RESET, StmImInBuf, sizeof(StmImInBuf),
StmImOutBuf, sizeof(StmImOutBuf));
@ -307,8 +310,10 @@ static s32 __OSStateEventHandler(s32 result, void* arg) {
BOOL enabled;
OSStateCallback callback;
// clang-format off
#line 820
OSAssert(result == IPC_RESULT_OK, "Error on STM state event handler\n");
OS_ASSERT(result == IPC_RESULT_OK, "Error on STM state event handler\n");
// clang-format on
StmEhRegistered = FALSE;

View File

@ -297,7 +297,9 @@ u8 SCGetWpadSpeakerVolume(void) {
return item;
}
void SCSetWpadSpeakerVolume(u8 vol) { SCReplaceU8Item(vol, SC_ITEM_BT_SPKV); }
void SCSetWpadSpeakerVolume(u8 vol) {
SCReplaceU8Item(vol, SC_ITEM_BT_SPKV);
}
//unused
void SCGetOwnerNickName(){

View File

@ -59,19 +59,19 @@ void SISetSamplingRate(u32 msec) {
SamplingRate = msec;
switch ((u32)VIGetTvFormat()) {
case VI_NTSC:
case VI_MPAL:
case VI_EURGB60:
xy = &XYNTSC;
break;
case VI_PAL:
xy = &XYPAL;
break;
default:
OSReport("SISetSamplingRate: unknown TV format. Use default.");
msec = 0;
xy = &XYNTSC;
break;
case VI_NTSC:
case VI_MPAL:
case VI_EURGB60:
xy = &XYNTSC;
break;
case VI_PAL:
xy = &XYPAL;
break;
default:
OSReport("SISetSamplingRate: unknown TV format. Use default.");
msec = 0;
xy = &XYNTSC;
break;
}
m = (VI_HW_REGS[VI_VICLK] & VI_VICLK_SPEED) != VI_VICLK_27MHZ ? 2 : 1;

View File

@ -7,7 +7,7 @@ void TPLBind(TPLPalette* pal) {
u16 i;
#line 24
OSAssert(pal->version == TPL_VERSION,
OS_ASSERT(pal->version == TPL_VERSION,
"invalid version number for texture palette");
pal->descriptors = (TPLDescriptor*)((char*)pal->descriptors + (u32)pal);

View File

@ -3,11 +3,6 @@
#include <revolution/USB.h>
#include <stdio.h>
/**
* Documentation from WiiBrew:
* https://wiibrew.org/wiki//dev/usb/oh0
*/
#define USB_HEAP_SIZE 0x4000
typedef enum {
@ -146,7 +141,9 @@ end:
return result;
}
IPCResult IUSB_CloseLib(void) { return IPC_RESULT_OK; }
IPCResult IUSB_CloseLib(void) {
return IPC_RESULT_OK;
}
static s32 _intrBlkCtrlIsoCb(s32 result, void* arg) {
int i;

View File

@ -41,7 +41,7 @@ bool CDeviceSC::func_80447C60(){
}
bool CDeviceSC::wkStartup(){
if(SCCheckStatus() == SC_STATUS_READY){
if(SCCheckStatus() == SC_STATUS_OK){
u32 r3 = CDeviceClock::func_8044DEE0();
if(r3 != 0){
//Update SC values

View File

@ -19,8 +19,8 @@ struct BinaryFileHeader {
u16 dataBlocks; // at 0xE
};
bool IsValidBinaryFile(const BinaryFileHeader* header, u32 magic, u16 version,
u16 numBlocks);
bool IsValidBinaryFile(const BinaryFileHeader* header, u32 signature,
u16 version, u16 minBlocks);
bool IsReverseEndianBinaryFile(const BinaryFileHeader* fileHeader);
BinaryBlockHeader* GetNextBinaryBlockHeader(BinaryFileHeader* fileHeader, BinaryBlockHeader* blockHeader);