Revolution SDK work (#3091)

* Implement revolution/ax

Copied mostly unchanged from Petari

* Implement revolution/axfx

Copied mostly unchanged from Petari

* Implement revolution/arc

Copied mostly unchanged from Petari

* Implement revolution/mem

Copied mostly unchanged from Petari

* Implement revolution/tpl

Copied verbatim from Petari

* revolution/ipc matching (except small linking issue on ShieldD)

* revolution/pad/Pad matching

Largely copied from Petari with significant modifications

* Fix up ut_TextWriterBase symbols

* Fix homebuttonLib file names in Shield splits
This commit is contained in:
Max Roncace
2026-02-11 03:10:40 -05:00
committed by GitHub
parent b9de3375b4
commit 255705a4cd
40 changed files with 1976 additions and 393 deletions
+47 -49
View File
@@ -1,5 +1,5 @@
#ifndef _REVOLUTION_ARC_H_
#define _REVOLUTION_ARC_H_
#ifndef ARC_H
#define ARC_H
#include <revolution/types.h>
@@ -7,61 +7,59 @@
extern "C" {
#endif
#define ARC_ENTRY_NUM_INVALID (-1)
typedef struct {
unsigned int magic;
int fstStart;
int fstSize;
int fileStart;
int pad[4];
} ARCHeader;
typedef struct {
unsigned int magic;
int fstStart;
int fstSize;
int fileStart;
int pad[4];
} ARCHeader;
typedef struct {
void* archiveStartAddr; // 0x0
void* FSTStart; // 0x4
void* fileStart; // 0x8
u32 entryNum; // 0xC
char* FSTStringStart; // 0x10
u32 FSTLength; // 0x14
u32 currDir; // 0x18
} ARCHandle;
typedef struct {
void* archiveStartAddr; // 0x0
void* FSTStart; // 0x4
void* fileStart; // 0x8
u32 entryNum; // 0xC
char* FSTStringStart; // 0x10
u32 FSTLength; // 0x14
u32 currDir; // 0x18
} ARCHandle;
typedef struct {
ARCHandle* handle;
u32 startOffset;
u32 length;
} ARCFileInfo;
typedef struct {
ARCHandle* handle;
u32 startOffset;
u32 length;
} ARCFileInfo;
typedef struct {
ARCHandle* handle;
u32 entryNum;
u32 location;
u32 next;
} ARCDir;
typedef struct {
ARCHandle* handle;
u32 entryNum;
u32 location;
u32 next;
} ARCDir;
typedef struct {
ARCHandle* handle;
u32 entryNum;
BOOL isDir;
char* name;
} ARCDirEntry;
typedef struct {
ARCHandle* handle;
u32 entryNum;
BOOL isDir;
char* name;
} ARCDirEntry;
BOOL ARCInitHandle(void *, ARCHandle *);
BOOL ARCFastOpen(ARCHandle *, s32, ARCFileInfo *);
s32 ARCConvertPathToEntrynum(ARCHandle *, const char *);
void* ARCGetStartAddrInMem(ARCFileInfo *);
u32 ARCGetLength(ARCFileInfo *);
BOOL ARCClose(ARCFileInfo *);
BOOL ARCChangeDir(ARCHandle *, const char *);
BOOL ARCGetCurrentDir(ARCHandle *, char *, u32);
BOOL ARCInitHandle(void*, ARCHandle*);
BOOL ARCFastOpen(ARCHandle*, s32, ARCFileInfo*);
s32 ARCConvertPathToEntrynum(ARCHandle*, const char*);
void* ARCGetStartAddrInMem(ARCFileInfo*);
u32 ARCGetLength(ARCFileInfo*);
BOOL ARCClose(ARCFileInfo*);
BOOL ARCChangeDir(ARCHandle*, const char*);
BOOL ARCGetCurrentDir(ARCHandle*, char*, u32);
BOOL ARCOpenDir(ARCHandle*, const char*, ARCDir*);
BOOL ARCReadDir(ARCDir*, ARCDirEntry*);
BOOL ARCCloseDir(ARCDir*);
BOOL ARCOpenDir(ARCHandle *, const char *, ARCDir *);
BOOL ARCReadDir(ARCDir *, ARCDirEntry *);
BOOL ARCCloseDir(ARCDir *);
#ifdef __cplusplus
}
#endif
#endif // _REVOLUTION_ARC_H_
#endif // ARC_H
+10
View File
@@ -362,6 +362,16 @@ void AXSetVoiceLpf(AXVPB* p, AXPBLPF* lpf);
void AXSetVoiceLpfCoefs(AXVPB* p, u16 a0, u16 b0);
void AXGetLpfCoefs(u16 freq, u16* a0, u16* b0);
void AXGetAuxACallback(AXAuxCallback* cbOut, void** contextOut);
u16 AXGetAuxAReturnVolume(void);
u16 AXGetAuxBReturnVolume(void);
u16 AXGetAuxCReturnVolume(void);
void AXSetAuxAReturnVolume(u16 volume);
void AXSetAuxBReturnVolume(u16 volume);
void AXSetAuxCReturnVolume(u16 volume);
void AXSetMasterVolume(u16 volume);
u16 AXGetMasterVolume(void);
// DSPCode
extern u16 axDspSlaveLength;
extern u16 axDspSlave[AX_DSP_SLAVE_LENGTH];
+78 -183
View File
@@ -1,214 +1,109 @@
#ifndef _REVOLUTION_AXFX_H_
#define _REVOLUTION_AXFX_H_
#ifndef AXFX_H
#define AXFX_H
#include <revolution/types.h>
#include <revolution/ax.h>
#include <revolution.h>
#include <cstdio>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct AXFX_REVSTD_DELAYLINE {
/* 0x00 */ s32 inPoint;
/* 0x04 */ s32 outPoint;
/* 0x08 */ s32 length;
/* 0x0C */ f32* inputs;
/* 0x10 */ f32 lastOutput;
} AXFX_REVSTD_DELAYLINE;
typedef struct AXFX_BUS {
s32* left;
s32* right;
s32* surround;
typedef struct AXFX_REVSTD_WORK {
/* 0x000 */ AXFX_REVSTD_DELAYLINE AP[6];
/* 0x078 */ AXFX_REVSTD_DELAYLINE C[6];
/* 0x0F0 */ f32 allPassCoeff;
/* 0x0F4 */ f32 combCoef[6];
/* 0x10C */ f32 lpLastout[3];
/* 0x118 */ f32 level;
/* 0x11C */ f32 damping;
/* 0x120 */ s32 preDelayTime;
/* 0x124 */ f32* preDelayLine[3];
/* 0x130 */ f32* preDelayPtr[3];
} AXFX_REVSTD_WORK;
typedef struct AXFX_REVERBSTD {
/* 0x000 */ AXFX_REVSTD_WORK rv;
/* 0x13C */ u8 tempDisableFX;
/* 0x140 */ f32 coloration;
/* 0x144 */ f32 mix;
/* 0x148 */ f32 time;
/* 0x14C */ f32 damping;
/* 0x150 */ f32 preDelay;
} AXFX_REVERBSTD;
} AXFX_BUS;
typedef struct AXFX_BUFFERUPDATE {
/* 0x00 */ s32* left;
/* 0x04 */ s32* right;
/* 0x08 */ s32* surround;
s32* left;
s32* right;
s32* surround;
} AXFX_BUFFERUPDATE;
typedef struct AXFX_BUFFERUPDATE_DPL2 {
/* 0x00 */ s32* L;
/* 0x04 */ s32* R;
/* 0x08 */ s32* Ls;
/* 0x0C */ s32* Rs;
} AXFX_BUFFERUPDATE_DPL2;
typedef struct AXFX_REVERBHI_EXP {
f32* earlyLine[3]; // at 0x0
u32 earlyPos[3]; // at 0xC
u32 earlyLength; // at 0x18
u32 earlyMaxLength; // at 0x1C
f32 earlyCoef[3]; // at 0x20
// REVHI Structs
f32* preDelayLine[3]; // at 0x2C
u32 preDelayPos; // at 0x38
u32 preDelayLength; // at 0x3C
u32 preDelayMaxLength; // at 0x40
typedef struct AXFX_REVHI_DELAYLINE {
/* 0x00 */ s32 inPoint;
/* 0x04 */ s32 outPoint;
/* 0x08 */ s32 length;
/* 0x0C */ f32* inputs;
/* 0x10 */ f32 lastOutput;
} AXFX_REVHI_DELAYLINE;
f32* combLine[3][3]; // at 0x44
u32 combPos[3]; // at 0x68
u32 combLength[3]; // at 0x74
u32 combMaxLength[3]; // at 0x80
f32 combCoef[3]; // at 0x8C
typedef struct AXFX_REVHI_WORK {
/* 0x000 */ AXFX_REVHI_DELAYLINE AP[9];
/* 0x0B4 */ AXFX_REVHI_DELAYLINE C[9];
/* 0x168 */ f32 allPassCoeff;
/* 0x16C */ f32 combCoef[9];
/* 0x190 */ f32 lpLastout[3];
/* 0x19C */ f32 level;
/* 0x1A0 */ f32 damping;
/* 0x1A4 */ s32 preDelayTime;
/* 0x1A8 */ f32 crosstalk;
/* 0x1AC */ f32* preDelayLine[3];
/* 0x1B8 */ f32* preDelayPtr[3];
} AXFX_REVHI_WORK;
f32* allpassLine[3][2]; // at 0x98
u32 allpassPos[2]; // at 0xB0
u32 allpassLength[2]; // at 0xB8
u32 allpassMaxLength[2]; // at 0xC0
typedef struct AXFX_REVHI_WORK_DPL2 {
/* 0x000 */ AXFX_REVHI_DELAYLINE AP[12];
/* 0x0F0 */ AXFX_REVHI_DELAYLINE C[12];
/* 0x1E0 */ f32 allPassCoeff;
/* 0x1E4 */ f32 combCoef[12];
/* 0x214 */ f32 lpLastout[4];
/* 0x224 */ f32 level;
/* 0x228 */ f32 damping;
/* 0x22C */ s32 preDelayTime;
/* 0x230 */ f32 crosstalk;
/* 0x234 */ f32* preDelayLine[4];
/* 0x244 */ f32* preDelayPtr[4];
} AXFX_REVHI_WORK_DPL2;
f32* lastAllpassLine[3]; // at 0xC8
u32 lastAllpassPos[3]; // at 0xD4
u32 lastAllpassLength[3]; // at 0xE0
u32 lastAllpassMaxLength[3]; // at 0xEC
f32 allpassCoef; // at 0xF8
f32 lastLpfOut[3]; // at 0xFC
f32 lpfCoef; // at 0x108
u32 active; // at 0x10C
u32 earlyMode; // at 0x110
f32 preDelayTimeMax; // at 0x114
f32 preDelayTime; // at 0x118
u32 fusedMode; // at 0x11C
f32 fusedTime; // at 0x120
f32 coloration; // at 0x124
f32 damping; // at 0x128
f32 crosstalk; // at 0x12C
f32 earlyGain; // at 0x130
f32 fusedGain; // at 0x134
AXFX_BUS* busIn; // at 0x138
AXFX_BUS* busOut; // at 0x13C
f32 outGain; // at 0x140
f32 sendGain; // at 0x144
} AXFX_REVERBHI_EXP;
typedef struct AXFX_REVERBHI {
/* 0x000 */ AXFX_REVHI_WORK rv;
/* 0x1C4 */ u8 tempDisableFX;
/* 0x1C8 */ f32 coloration;
/* 0x1CC */ f32 mix;
/* 0x1D0 */ f32 time;
/* 0x1D4 */ f32 damping;
/* 0x1D8 */ f32 preDelay;
/* 0x1DC */ f32 crosstalk;
AXFX_REVERBHI_EXP exp; // at 0x0
f32 coloration; // at 0x148
f32 mix; // at 0x14C
f32 time; // at 0x150
f32 damping; // at 0x154
f32 preDelay; // at 0x158
f32 crosstalk; // at 0x15C
} AXFX_REVERBHI;
typedef struct AXFX_REVERBHI_DPL2 {
/* 0x000 */ AXFX_REVHI_WORK_DPL2 rv;
/* 0x254 */ u8 tempDisableFX;
/* 0x258 */ f32 coloration;
/* 0x25C */ f32 mix;
/* 0x260 */ f32 time;
/* 0x264 */ f32 damping;
/* 0x268 */ f32 preDelay;
} AXFX_REVERBHI_DPL2;
typedef void* (*AXFXAllocHook)(size_t size);
typedef void (*AXFXFreeHook)(void* block);
typedef struct AXFX_DELAY {
/* 0x00 */ u32 currentSize[3];
/* 0x0C */ u32 currentPos[3];
/* 0x18 */ u32 currentFeedback[3];
/* 0x24 */ u32 currentOutput[3];
/* 0x30 */ s32* left;
/* 0x34 */ s32* right;
/* 0x38 */ s32* sur;
/* 0x3C */ u32 delay[3];
/* 0x48 */ u32 feedback[3];
/* 0x54 */ u32 output[3];
} AXFX_DELAY;
extern AXFXAllocHook __AXFXAlloc;
extern AXFXFreeHook __AXFXFree;
typedef struct AXFX_CHORUS_SRCINFO {
/* 0x00 */ s32* dest;
/* 0x04 */ s32* smpBase;
/* 0x08 */ s32* old;
/* 0x0C */ u32 posLo;
/* 0x10 */ u32 posHi;
/* 0x14 */ u32 pitchLo;
/* 0x18 */ u32 pitchHi;
/* 0x1C */ u32 trigger;
/* 0x20 */ u32 target;
} AXFX_CHORUS_SRCINFO;
void AXFXSetHooks(AXFXAllocHook alloc, AXFXFreeHook free);
void AXFXGetHooks(AXFXAllocHook* alloc, AXFXFreeHook* free);
typedef struct AXFX_CHORUS_WORK {
/* 0x00 */ s32* lastLeft[3];
/* 0x0C */ s32* lastRight[3];
/* 0x18 */ s32* lastSur[3];
/* 0x24 */ u8 currentLast;
/* 0x28 */ s32 oldLeft[4];
/* 0x38 */ s32 oldRight[4];
/* 0x48 */ s32 oldSur[4];
/* 0x58 */ u32 currentPosLo;
/* 0x5C */ u32 currentPosHi;
/* 0x60 */ s32 pitchOffset;
/* 0x64 */ u32 pitchOffsetPeriodCount;
/* 0x68 */ u32 pitchOffsetPeriod;
/* 0x6C */ AXFX_CHORUS_SRCINFO src;
} AXFX_CHORUS_WORK;
BOOL AXFXReverbHiInit(AXFX_REVERBHI* fx);
BOOL AXFXReverbHiShutdown(AXFX_REVERBHI* fx);
void AXFXReverbHiCallback(void* update, void* fx);
typedef struct AXFX_CHORUS {
/* 0x00 */ AXFX_CHORUS_WORK work;
/* 0x90 */ u32 baseDelay;
/* 0x94 */ u32 variation;
/* 0x98 */ u32 period;
} AXFX_CHORUS;
BOOL AXFXReverbHiExpInit(AXFX_REVERBHI_EXP* fx);
void AXFXReverbHiExpShutdown(AXFX_REVERBHI_EXP* fx);
void AXFXReverbHiExpCallback(AXFX_BUFFERUPDATE* update, AXFX_REVERBHI_EXP* fx);
typedef void* (*AXFXAllocFunc)(u32);
typedef void (*AXFXFreeFunc)(void*);
// chorus
int AXFXChorusInit(AXFX_CHORUS* c);
int AXFXChorusShutdown(AXFX_CHORUS* c);
int AXFXChorusSettings(AXFX_CHORUS* c);
void AXFXChorusCallback(AXFX_BUFFERUPDATE* bufferUpdate, AXFX_CHORUS* chorus);
// delay
void AXFXDelayCallback(AXFX_BUFFERUPDATE* bufferUpdate, AXFX_DELAY* delay);
int AXFXDelaySettings(AXFX_DELAY* delay);
int AXFXDelayInit(AXFX_DELAY* delay);
int AXFXDelayShutdown(AXFX_DELAY* delay);
// reverb_hi
void DoCrossTalk(s32* l, s32* r, f32 cross, f32 invcross);
int AXFXReverbHiInit(AXFX_REVERBHI* rev);
int AXFXReverbHiShutdown(AXFX_REVERBHI* rev);
int AXFXReverbHiSettings(AXFX_REVERBHI* rev);
// reverb_hi_4ch
int AXFXReverbHiInitDpl2(AXFX_REVERBHI_DPL2* reverb);
int AXFXReverbHiShutdownDpl2(AXFX_REVERBHI_DPL2* reverb);
int AXFXReverbHiSettingsDpl2(AXFX_REVERBHI_DPL2* rev);
void AXFXReverbHiCallbackDpl2(AXFX_BUFFERUPDATE_DPL2* bufferUpdate, AXFX_REVERBHI_DPL2* reverb);
// reverb_std
int AXFXReverbStdInit(AXFX_REVERBSTD* rev);
int AXFXReverbStdShutdown(AXFX_REVERBSTD* rev);
int AXFXReverbStdSettings(AXFX_REVERBSTD* rev);
void AXFXReverbStdCallback(AXFX_BUFFERUPDATE* bufferUpdate, AXFX_REVERBSTD* reverb);
void AXFXReverbHiCallback(void *data, void *context);
void AXGetAuxACallback(AXAuxCallback* cbOut, void** contextOut);
void AXFXSetHooks(AXFXAllocFunc alloc, AXFXFreeFunc free);
void AXFXGetHooks(AXFXAllocFunc* allocOut, AXFXFreeFunc* freeOut);
void AXFXSetHooks(AXFXAllocHook alloc, AXFXFreeHook free);
void AXFXGetHooks(AXFXAllocHook* allocOut, AXFXFreeHook* freeOut);
BOOL AXFXReverbHiInit(AXFX_REVERBHI* reverbHi);
BOOL AXFXReverbHiShutdown(AXFX_REVERBHI* reverbHi);
u16 AXGetAuxAReturnVolume(void);
u16 AXGetAuxBReturnVolume(void);
u16 AXGetAuxCReturnVolume(void);
void AXSetAuxAReturnVolume(u16 volume);
void AXSetAuxBReturnVolume(u16 volume);
void AXSetAuxCReturnVolume(u16 volume);
void AXSetMasterVolume(u16 volume);
u16 AXGetMasterVolume(void);
#ifdef __cplusplus
}
#endif
#endif // _REVOLUTION_AXFX_H_
#endif // AXFX_H
+2
View File
@@ -10,7 +10,9 @@ extern "C" {
#endif
void IPCInit(void);
#if SDK_AUG2010
void IPCReInit(void);
#endif
u32 IPCReadReg(u32 regIdx);
void IPCWriteReg(u32 regIdx, u32 data);
void* IPCGetBufferHi(void);
+2
View File
@@ -12,7 +12,9 @@ extern "C" {
typedef IOSError (*IOSIpcCb)(IOSError, void*);
IOSError IPCCltInit(void);
#if SDK_AUG2010
IOSError IPCCltReInit(void);
#endif
IOSError IOS_OpenAsync(const char* pPath, u32 flags, IOSIpcCb cb, void* callback_arg);
IOSError IOS_Open(const char* path, u32 flags);
+26 -1
View File
@@ -9,7 +9,7 @@ extern "C" {
typedef struct MEMiExpHeapMBlockHead MEMiExpHeapMBlockHead;
struct MEMiExPheapMBlockHead {
struct MEMiExpHeapMBlockHead {
u16 signature;
union {
@@ -27,6 +27,31 @@ struct MEMiExPheapMBlockHead {
MEMiExpHeapMBlockHead* next;
};
typedef struct MEMiExpMBlockList MEMiExpMBlockList;
struct MEMiExpMBlockList {
MEMiExpHeapMBlockHead* head;
MEMiExpHeapMBlockHead* tail;
};
typedef struct MEMiExpHeapHead MEMiExpHeapHead;
struct MEMiExpHeapHead {
MEMiExpMBlockList mbFreeList;
MEMiExpMBlockList mbUsedList;
u16 groupID;
union {
u16 val;
struct {
u16 _reserved : 14;
u16 useMarginOfAlign : 1;
u16 allocMode : 1;
} fields;
} feature;
};
MEMHeapHandle MEMCreateExpHeapEx(void*, u32, u16);
void* MEMDestroyExpHeap(MEMHeapHandle);
void* MEMAllocFromExpHeapEx(MEMHeapHandle, u32, int);
+53
View File
@@ -7,6 +7,7 @@ extern "C" {
#include <revolution/mem/list.h>
#include <revolution/os.h>
#include <cstring>
typedef struct MEMiHeapHead MEMiHeapHead;
@@ -36,6 +37,58 @@ static inline UIntPtr GetUIntPtr(const void* ptr) {
return (UIntPtr)(ptr);
}
static inline u32 GetOffsetFromPtr(const void* start, const void* end) {
return GetUIntPtr(end) - GetUIntPtr(start);
}
static inline void* SubU32ToPtr(void* ptr, u32 val) {
return (void*)(GetUIntPtr(ptr) - val);
}
static inline void* AddU32ToPtr(void* ptr, u32 val) {
return (void*)(GetUIntPtr(ptr) + val);
}
static inline void SetOptForHeap(MEMiHeapHead* pHeapHd, u16 optFlag) {
pHeapHd->attribute.fields.optFlag = (u8)optFlag;
}
static inline u16 GetOptForHeap(const MEMiHeapHead* pHeapHd) {
return (u16)pHeapHd->attribute.fields.optFlag;
}
static inline void FillAllocMemory(MEMiHeapHead* pHeapHd, void* address, u32 size) {
if (GetOptForHeap(pHeapHd) & 1) {
(void)memset(address, 0, size);
}
}
static inline int ComparePtr(const void* a, const void* b) {
const u8* wa = (const u8*)a;
const u8* wb = (const u8*)b;
return wa - wb;
}
static inline void LockHeap(MEMiHeapHead* pHeapHd) {
if (GetOptForHeap(pHeapHd) & 4) {
OSLockMutex(&pHeapHd->mutex);
}
}
static inline void UnlockHeap(MEMiHeapHead* pHeapHd) {
if (GetOptForHeap(pHeapHd) & 4) {
OSUnlockMutex(&pHeapHd->mutex);
}
}
void MEMiInitHeapHead(MEMiHeapHead* pHeapHd, u32 signature, void* heapStart, void* heapEnd, u16 optFlag);
void MEMiFinalizeHeap(MEMiHeapHead* pHeapHd);
void MEMiDumpHeapHead(MEMiHeapHead* pHeapHd);
#ifdef __cplusplus
}
#endif
+2 -1
View File
@@ -21,9 +21,10 @@ typedef struct {
void MEMInitList(MEMList*, u16);
void MEMAppendListObject(MEMList*, void*);
void MEMRemoveListObject(MEMList*, void*);
void* MEMGetNextListObject(MEMList*, void*);
#define MEM_INIT_LIST(list, structName, linkName) MEMInitList(list, offsetof(structName, linkName))
#ifdef __cplusplus
}
#endif