From 93fab7ecc4e305f4e512025505a3d4e91a4933ea Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Tue, 18 Jun 2024 13:07:08 -0400 Subject: [PATCH] Provide missing pfs stub functions (#50) * `osPiRawStartDma_recomp` and `osEPiRawStartDma` * `osPfsNumFiles` and `osPfsRepairId` * whoops, wrong name * Fix missing new line on message box * Use actual pointers in osPfsNumFiles_recomp --- librecomp/src/pak.cpp | 20 +++++++++++++++++-- librecomp/src/pi.cpp | 32 +++++++++++++++++++++++++++++- ultramodern/src/error_handling.cpp | 2 +- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/librecomp/src/pak.cpp b/librecomp/src/pak.cpp index 92e0f10..0be1513 100644 --- a/librecomp/src/pak.cpp +++ b/librecomp/src/pak.cpp @@ -1,6 +1,8 @@ +#include "ultramodern/ultra64.h" +#include "ultramodern/ultramodern.hpp" + #include "recomp.h" -#include -#include +#include "helpers.hpp" extern "C" void osPfsInitPak_recomp(uint8_t * rdram, recomp_context* ctx) { ctx->r2 = 1; // PFS_ERR_NOPACK @@ -33,3 +35,17 @@ extern "C" void osPfsReadWriteFile_recomp(uint8_t * rdram, recomp_context * ctx) extern "C" void osPfsChecker_recomp(uint8_t * rdram, recomp_context * ctx) { ctx->r2 = 1; // PFS_ERR_NOPACK } + +extern "C" void osPfsNumFiles_recomp(uint8_t * rdram, recomp_context * ctx) { + s32* max_files = _arg<1, s32*>(rdram, ctx); + s32* files_used = _arg<2, s32*>(rdram, ctx); + + *max_files = 0; + *files_used = 0; + + _return(ctx, 1); // PFS_ERR_NOPACK +} + +extern "C" void osPfsRepairId_recomp(uint8_t * rdram, recomp_context * ctx) { + _return(ctx, 1); // PFS_ERR_NOPACK +} diff --git a/librecomp/src/pi.cpp b/librecomp/src/pi.cpp index cb48cb8..6819e44 100644 --- a/librecomp/src/pi.cpp +++ b/librecomp/src/pi.cpp @@ -300,5 +300,35 @@ extern "C" void osPiGetStatus_recomp(RDRAM_ARG recomp_context * ctx) { } extern "C" void osPiRawStartDma_recomp(RDRAM_ARG recomp_context * ctx) { - ctx->r2 = 0; + ultramodern::error_handling::message_box( + "Stub `osPiRawStartDma_recomp` function called!\n" + "Most games do not call this function directly, which means the libultra function\n" + "that uses this function was not properly named.\n" + "\n" + "If you triggered this message, please make sure you have properly identified\n" + "every libultra function on your recompiled game. If you are sure every libultra\n" + "function has been identified and you still get this problem then open an issue on\n" + "the N64ModernRuntime Github repository mentioning the game you are trying to\n" + "recompile and steps to reproduce the issue.\n" + "\n" + "The application will close now, bye and good luck!" + ); + ULTRAMODERN_QUICK_EXIT(); +} + +extern "C" void osEPiRawStartDma_recomp(RDRAM_ARG recomp_context * ctx) { + ultramodern::error_handling::message_box( + "Stub `osEPiRawStartDma_recomp` function called!\n" + "Most games do not call this function directly, which means the libultra function\n" + "that uses this function was not properly named.\n" + "\n" + "If you triggered this message, please make sure you have properly identified\n" + "every libultra function on your recompiled game. If you are sure every libultra\n" + "function has been identified and you still get this problem then open an issue on\n" + "the N64ModernRuntime Github repository mentioning the game you are trying to\n" + "recompile and steps to reproduce the issue.\n" + "\n" + "The application will close now, bye and good luck!" + ); + ULTRAMODERN_QUICK_EXIT(); } diff --git a/ultramodern/src/error_handling.cpp b/ultramodern/src/error_handling.cpp index 9be5acd..8ca779e 100644 --- a/ultramodern/src/error_handling.cpp +++ b/ultramodern/src/error_handling.cpp @@ -19,7 +19,7 @@ void ultramodern::error_handling::message_box(const char* msg) { } void ultramodern::error_handling::quick_exit(const char* filename, int line, const char *func, int exit_status) { - fprintf(stderr, "Exiting with exit status '%i'. Function %s, at file %s:%i, ", exit_status, func, filename, line); + fprintf(stderr, "Exiting with exit status '%i'. Function %s, at file %s:%i\n", exit_status, func, filename, line); #ifdef __APPLE__ std::_Exit(exit_status);