mirror of
https://github.com/N64Recomp/N64ModernRuntime.git
synced 2025-10-30 08:02:29 +00:00
Finish wiring stuff up
This commit is contained in:
parent
ca53e8f85a
commit
35d6ec1752
2 changed files with 64 additions and 10 deletions
|
|
@ -6,8 +6,31 @@
|
|||
|
||||
template<int index, typename T>
|
||||
T _arg(uint8_t* rdram, recomp_context* ctx) {
|
||||
static_assert(index < 4, "Only args 0 through 3 supported");
|
||||
gpr raw_arg = (&ctx->r4)[index];
|
||||
static_assert(index >= 0, "");
|
||||
gpr raw_arg;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
raw_arg = ctx->r4;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
raw_arg = ctx->r5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
raw_arg = ctx->r6;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
raw_arg = ctx->r7;
|
||||
break;
|
||||
|
||||
default:
|
||||
raw_arg = MEM_W(4 * index, ctx->r29);
|
||||
break;
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
if constexpr (index < 2) {
|
||||
static_assert(index != 1, "Floats in arg 1 not supported");
|
||||
|
|
|
|||
|
|
@ -27,10 +27,9 @@ extern "C" void osPfsAllocateFile_recomp(uint8_t * rdram, recomp_context * ctx)
|
|||
u16 company_code = _arg<1, u16>(rdram, ctx);
|
||||
u32 game_code = _arg<2, u32>(rdram, ctx);
|
||||
PTR(u8) game_name = _arg<3, PTR(u8)>(rdram, ctx);
|
||||
// TODO
|
||||
PTR(u8) ext_name = 0; // _arg<4, PTR(u8)>(rdram, ctx);
|
||||
int file_size_in_bytes = 0; // _arg<5, int>(rdram, ctx);
|
||||
PTR(s32) file_no = 0; // _arg<6, s32>(rdram, ctx);
|
||||
PTR(u8) ext_name = _arg<4, PTR(u8)>(rdram, ctx);
|
||||
int file_size_in_bytes = _arg<5, int>(rdram, ctx);
|
||||
PTR(s32) file_no = _arg<6, PTR(s32)>(rdram, ctx);
|
||||
|
||||
s32 ret = osPfsAllocateFile(rdram, pfs, company_code, game_code, game_name, ext_name, file_size_in_bytes, file_no);
|
||||
|
||||
|
|
@ -38,19 +37,51 @@ extern "C" void osPfsAllocateFile_recomp(uint8_t * rdram, recomp_context * ctx)
|
|||
}
|
||||
|
||||
extern "C" void osPfsDeleteFile_recomp(uint8_t * rdram, recomp_context * ctx) {
|
||||
ctx->r2 = 1; // PFS_ERR_NOPACK
|
||||
PTR(OSPfs) pfs = _arg<0, PTR(OSPfs)>(rdram, ctx);
|
||||
u16 company_code = _arg<1, u16>(rdram, ctx);
|
||||
u32 game_code = _arg<2, u32>(rdram, ctx);
|
||||
PTR(u8) game_name = _arg<3, PTR(u8)>(rdram, ctx);
|
||||
PTR(u8) ext_name = _arg<4, PTR(u8)>(rdram, ctx);
|
||||
|
||||
s32 ret = osPfsDeleteFile(rdram, pfs, company_code, game_code, game_name, ext_name);
|
||||
|
||||
_return<s32>(ctx, ret);
|
||||
}
|
||||
|
||||
extern "C" void osPfsFileState_recomp(uint8_t * rdram, recomp_context * ctx) {
|
||||
ctx->r2 = 1; // PFS_ERR_NOPACK
|
||||
PTR(OSPfs) pfs = _arg<0, PTR(OSPfs)>(rdram, ctx);
|
||||
s32 file_no = _arg<1, s32>(rdram, ctx);
|
||||
PTR(OSPfsState) state = _arg<2, PTR(OSPfsState)>(rdram, ctx);
|
||||
|
||||
s32 ret = osPfsFileState(rdram, pfs, file_no, state);
|
||||
|
||||
_return<s32>(ctx, ret);
|
||||
}
|
||||
|
||||
extern "C" void osPfsFindFile_recomp(uint8_t * rdram, recomp_context * ctx) {
|
||||
ctx->r2 = 1; // PFS_ERR_NOPACK
|
||||
PTR(OSPfs) pfs = _arg<0, PTR(OSPfs)>(rdram, ctx);
|
||||
u16 company_code = _arg<1, u16>(rdram, ctx);
|
||||
u32 game_code = _arg<2, u32>(rdram, ctx);
|
||||
PTR(u8) game_name = _arg<3, PTR(u8)>(rdram, ctx);
|
||||
PTR(u8) ext_name = _arg<4, PTR(u8)>(rdram, ctx);
|
||||
PTR(s32) file_no = _arg<5, PTR(s32)>(rdram, ctx);
|
||||
|
||||
s32 ret = osPfsFindFile(rdram, pfs, company_code, game_code, game_name, ext_name, file_no);
|
||||
|
||||
_return<s32>(ctx, ret);
|
||||
}
|
||||
|
||||
extern "C" void osPfsReadWriteFile_recomp(uint8_t * rdram, recomp_context * ctx) {
|
||||
ctx->r2 = 1; // PFS_ERR_NOPACK
|
||||
PTR(OSPfs) pfs = _arg<0, PTR(OSPfs)>(rdram, ctx);
|
||||
s32 file_no = _arg<1, s32>(rdram, ctx);
|
||||
u8 flag = _arg<2, u8>(rdram, ctx);
|
||||
int offset = _arg<3, int>(rdram, ctx);
|
||||
int size_in_bytes = _arg<4, int>(rdram, ctx);
|
||||
PTR(u8) data_buffer = _arg<5, PTR(u8)>(rdram, ctx);
|
||||
|
||||
s32 ret = osPfsReadWriteFile(rdram, pfs, file_no, flag, offset, size_in_bytes, data_buffer);
|
||||
|
||||
_return<s32>(ctx, ret);
|
||||
}
|
||||
|
||||
extern "C" void osPfsChecker_recomp(uint8_t * rdram, recomp_context * ctx) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue