From c2e54ec0b39f322aaf0987b93fdb23a6e09de75b Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Sun, 13 Apr 2025 05:30:06 -0300 Subject: [PATCH 01/13] restore console --- src/port/Engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index de023957..a64c6c3f 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -73,7 +73,7 @@ GameEngine::GameEngine() { const std::string assets_path = Ship::Context::GetPathRelativeToAppDirectory("starship.o2r"); #ifdef _WIN32 - // AllocConsole(); + AllocConsole(); #endif if (!fs::exists("mods")) { From a4a465151ae6eb5a3ce92c821bc00bea105ab8b1 Mon Sep 17 00:00:00 2001 From: shep7955 <86570596+shep7955@users.noreply.github.com> Date: Mon, 14 Apr 2025 18:30:57 -0600 Subject: [PATCH 02/13] Quick typo fix for building instructions (#192) --- docs/BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/BUILDING.md b/docs/BUILDING.md index e6922301..6d4e1267 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -86,7 +86,7 @@ C:\Program Files\CMake\bin\cmake.exe --build build-cmake --target clean #### Debian/Ubuntu ```sh # using gcc -apt-get install gcc g++ git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libboost-dev libopengl-dev libogg-dev ibvorbis-dev +apt-get install gcc g++ git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libboost-dev libopengl-dev libogg-dev libvorbis-dev # or using clang apt-get install clang git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libboost-dev libopengl-dev libogg-dev libvorbis-dev From 54a4d76b6ffd6b276a951224b62881fa6c4ff9a9 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo Nitti <96613413+sonicdcer@users.noreply.github.com> Date: Fri, 18 Apr 2025 03:22:13 -0400 Subject: [PATCH 03/13] Bump LUS (#191) * Bump LUS (#190) * Bump LUS * Disabled shader-based linear conversion on metal * Fixed missing mInterpolationIndex * Bump LUS --------- Co-authored-by: KiritoDv * restore console * bump LUS * Reverted linear conversion on shader --------- Co-authored-by: KiritoDv --- libultraship | 2 +- src/engine/fox_bg.c | 2 +- src/port/Engine.cpp | 56 +++++++++++++++++++------------- src/port/Engine.h | 16 +++++---- src/port/GBIMiddleware.cpp | 2 -- src/port/Game.cpp | 2 +- src/port/Variables.cpp | 6 ---- src/port/ui/ImguiUI.cpp | 2 +- src/port/ui/ResolutionEditor.cpp | 20 +++++++----- 9 files changed, 59 insertions(+), 49 deletions(-) delete mode 100644 src/port/Variables.cpp diff --git a/libultraship b/libultraship index ec63c739..dda07c8a 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit ec63c7390050c452b34c3f78be7499f88fae2636 +Subproject commit dda07c8ac6033ff98d37a05bc28406440c7769e4 diff --git a/src/engine/fox_bg.c b/src/engine/fox_bg.c index 862851bc..65831bc4 100644 --- a/src/engine/fox_bg.c +++ b/src/engine/fox_bg.c @@ -258,7 +258,7 @@ void Background_DrawStarfield(void) { float originalWidth = currentScreenWidth / 3; float originalAspect = originalWidth / (currentScreenHeight / 3); - float renderMaskWidth = originalWidth * (OTRGetAspectRatio() / originalAspect); + float renderMaskWidth = originalWidth * (GameEngine_GetAspectRatio() / originalAspect); float marginX = (currentScreenWidth - renderMaskWidth) / 2; float renderMaskHeight = currentScreenHeight / 3; diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index a64c6c3f..d8d34711 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -41,7 +41,7 @@ #include "port/patches/DisplayListPatch.h" #include "port/mods/PortEnhancements.h" -#include +#include #include #ifdef __SWITCH__ @@ -453,14 +453,16 @@ void GameEngine::RunCommands(Gfx* Commands, const std::vectorGetInterpreterWeak().lock().get(); + // Process window events for resize, mouse, keyboard events wnd->HandleEvents(); - gInterpolationIndex = 0; + interpreter->mInterpolationIndex = 0; for (const auto& m : mtx_replacements) { wnd->DrawAndRunGraphicsCommands(Commands, m); - gInterpolationIndex++; + interpreter->mInterpolationIndex++; } bool curAltAssets = CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0); @@ -616,8 +618,16 @@ extern "C" uint32_t GameEngine_GetSamplesPerFrame() { // End +Fast::Interpreter* GameEngine_GetInterpreter() { + return static_pointer_cast(Ship::Context::GetInstance()->GetWindow()) + ->GetInterpreterWeak() + .lock() + .get(); +} + extern "C" float GameEngine_GetAspectRatio() { - return gfx_current_dimensions.aspect_ratio; + auto interpreter = GameEngine_GetInterpreter(); + return interpreter->mCurDimensions.aspect_ratio; } extern "C" uint32_t GameEngine_GetGameVersion() { @@ -730,34 +740,33 @@ extern "C" uint32_t OTRGetCurrentHeight() { return GameEngine::Instance->context->GetWindow()->GetHeight(); } -extern "C" float OTRGetAspectRatio() { - return gfx_current_dimensions.aspect_ratio; -} - extern "C" float OTRGetHUDAspectRatio() { - if (CVarGetInteger("gHUDAspectRatio.Enabled", 0) == 0 || CVarGetInteger("gHUDAspectRatio.X", 0) == 0 || CVarGetInteger("gHUDAspectRatio.Y", 0) == 0) - { - return OTRGetAspectRatio(); + if (CVarGetInteger("gHUDAspectRatio.Enabled", 0) == 0 || CVarGetInteger("gHUDAspectRatio.X", 0) == 0 || CVarGetInteger("gHUDAspectRatio.Y", 0) == 0) { + return GameEngine_GetAspectRatio(); } return ((float)CVarGetInteger("gHUDAspectRatio.X", 1) / (float)CVarGetInteger("gHUDAspectRatio.Y", 1)); } extern "C" float OTRGetDimensionFromLeftEdge(float v) { - return (gfx_native_dimensions.width / 2 - gfx_native_dimensions.height / 2 * OTRGetAspectRatio() + (v)); + auto interpreter = GameEngine_GetInterpreter(); + return (interpreter->mNativeDimensions.width / 2 - interpreter->mNativeDimensions.height / 2 * interpreter->mCurDimensions.aspect_ratio + (v)); } extern "C" float OTRGetDimensionFromRightEdge(float v) { - return (gfx_native_dimensions.width / 2 + gfx_native_dimensions.height / 2 * OTRGetAspectRatio() - - (gfx_native_dimensions.width - v)); + auto interpreter = GameEngine_GetInterpreter(); + return (interpreter->mNativeDimensions.width / 2 + interpreter->mNativeDimensions.height / 2 * interpreter->mCurDimensions.aspect_ratio - + (interpreter->mNativeDimensions.width - v)); } extern "C" float OTRGetDimensionFromLeftEdgeForcedAspect(float v, float aspectRatio) { - return (gfx_native_dimensions.width / 2 - gfx_native_dimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : OTRGetAspectRatio()) + (v)); + auto interpreter = GameEngine_GetInterpreter(); + return (interpreter->mNativeDimensions.width / 2 - interpreter->mNativeDimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : interpreter->mCurDimensions.aspect_ratio) + (v)); } extern "C" float OTRGetDimensionFromRightEdgeForcedAspect(float v, float aspectRatio) { - return (gfx_native_dimensions.width / 2 + gfx_native_dimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : OTRGetAspectRatio()) - - (gfx_native_dimensions.width - v)); + auto interpreter = GameEngine_GetInterpreter(); + return (interpreter->mNativeDimensions.width / 2 + interpreter->mNativeDimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : interpreter->mCurDimensions.aspect_ratio) - + (interpreter->mNativeDimensions.width - v)); } extern "C" float OTRGetDimensionFromLeftEdgeOverride(float v) { @@ -770,12 +779,14 @@ extern "C" float OTRGetDimensionFromRightEdgeOverride(float v) { // Gets the width of the current render target area extern "C" uint32_t OTRGetGameRenderWidth() { - return gfx_current_dimensions.width; + auto interpreter = GameEngine_GetInterpreter(); + return interpreter->mCurDimensions.width; } // Gets the height of the current render target area extern "C" uint32_t OTRGetGameRenderHeight() { - return gfx_current_dimensions.height; + auto interpreter = GameEngine_GetInterpreter(); + return interpreter->mCurDimensions.height; } extern "C" int16_t OTRGetRectDimensionFromLeftEdge(float v) { @@ -803,9 +814,10 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdgeOverride(float v) { } extern "C" int32_t OTRConvertHUDXToScreenX(int32_t v) { - float gameAspectRatio = gfx_current_dimensions.aspect_ratio; - int32_t gameHeight = gfx_current_dimensions.height; - int32_t gameWidth = gfx_current_dimensions.width; + auto interpreter = GameEngine_GetInterpreter(); + float gameAspectRatio = interpreter->mCurDimensions.aspect_ratio; + int32_t gameHeight = interpreter->mCurDimensions.height; + int32_t gameWidth = interpreter->mCurDimensions.width; float hudAspectRatio = 4.0f / 3.0f; int32_t hudHeight = gameHeight; int32_t hudWidth = hudHeight * hudAspectRatio; diff --git a/src/port/Engine.h b/src/port/Engine.h index 43dbf066..bbb50c60 100644 --- a/src/port/Engine.h +++ b/src/port/Engine.h @@ -12,7 +12,7 @@ typedef enum { #ifdef __cplusplus #include #include -#include +#include #include "libultraship/src/Context.h" #ifndef IDYES @@ -48,21 +48,23 @@ class GameEngine { static bool HasVersion(SF64Version ver); }; -extern "C" void* GameEngine_Malloc(size_t size); - +Fast::Interpreter* GameEngine_GetInterpreter(); #define memallocn(type, n) (type*) GameEngine_Malloc(sizeof(type) * n) #define memalloc(type) memallocn(type, 1) +extern "C" { #else #include +#define memalloc(size) GameEngine_Malloc(size) +#endif +void* GameEngine_Malloc(size_t size); bool GameEngine_HasVersion(SF64Version ver); void GameEngine_ProcessGfxCommands(Gfx* commands); float GameEngine_GetAspectRatio(); -uint8_t GameEngine_OTRSigCheck(char* imgData); +uint8_t GameEngine_OTRSigCheck(const char* imgData); uint32_t OTRGetCurrentWidth(void); uint32_t OTRGetCurrentHeight(void); -float OTRGetAspectRatio(void); float OTRGetHUDAspectRatio(); int32_t OTRConvertHUDXToScreenX(int32_t v); float OTRGetDimensionFromLeftEdge(float v); @@ -83,5 +85,7 @@ void* GameEngine_Malloc(size_t size); void GameEngine_GetTextureInfo(const char* path, int32_t* width, int32_t* height, float* scale, bool* custom); void gDPSetTileSizeInterp(Gfx* pkt, int t, float uls, float ult, float lrs, float lrt); uint32_t GameEngine_GetInterpolationFrameCount(); -#define memalloc(size) GameEngine_Malloc(size) + +#ifdef __cplusplus +} #endif \ No newline at end of file diff --git a/src/port/GBIMiddleware.cpp b/src/port/GBIMiddleware.cpp index e0355a6d..152d0203 100644 --- a/src/port/GBIMiddleware.cpp +++ b/src/port/GBIMiddleware.cpp @@ -3,8 +3,6 @@ #include "Engine.h" #include "DisplayList.h" -extern "C" uint8_t GameEngine_OTRSigCheck(const char* data); - extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) { char* imgData = (char*)dl; diff --git a/src/port/Game.cpp b/src/port/Game.cpp index 18a4c312..ef7894be 100644 --- a/src/port/Game.cpp +++ b/src/port/Game.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include "Engine.h" extern "C" { diff --git a/src/port/Variables.cpp b/src/port/Variables.cpp deleted file mode 100644 index f7ccf0eb..00000000 --- a/src/port/Variables.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -extern "C" { - -} \ No newline at end of file diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index 1748523a..615a07d0 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "port/Engine.h" #include "port/notification/notification.h" #include "utils/StringHelper.h" diff --git a/src/port/ui/ResolutionEditor.cpp b/src/port/ui/ResolutionEditor.cpp index cac3b8be..cc78edaf 100644 --- a/src/port/ui/ResolutionEditor.cpp +++ b/src/port/ui/ResolutionEditor.cpp @@ -1,10 +1,11 @@ #include "ResolutionEditor.h" #include "UIWidgets.h" #include "libultraship/src/Context.h" +#include "port/Engine.h" #include #include -#include +#include /* Console Variables are grouped under gAdvancedResolution. (e.g. "gAdvancedResolution.Enabled") @@ -59,6 +60,7 @@ namespace AdvancedResolutionSettings { for (unsigned short i = 0; i < sizeof(setting); i++) update[i] = false; static short updateCountdown = 0; + auto interpreter = GameEngine_GetInterpreter(); short countdownStartingValue = CVarGetInteger("gInterpolationFPS", 60) / 2; // half of a second, in frames. // Initialise integer scale bounds. @@ -67,13 +69,13 @@ namespace AdvancedResolutionSettings { short integerScale_maximumBounds = 1; // can change when window is resized // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. - if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) > - ((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) { + if (((float)interpreter->mGameWindowViewport.width / interpreter->mGameWindowViewport.height) > + ((float)interpreter->mCurDimensions.width / interpreter->mCurDimensions.height)) { // Scale to window height - integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_dimensions.height; + integerScale_maximumBounds = interpreter->mGameWindowViewport.height / interpreter->mCurDimensions.height; } else { // Scale to window width - integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_dimensions.width; + integerScale_maximumBounds = interpreter->mGameWindowViewport.width / interpreter->mCurDimensions.width; } // Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS. // Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded. @@ -136,9 +138,9 @@ namespace AdvancedResolutionSettings { } } // Resolution visualiser - ImGui::Text("Viewport dimensions: %d x %d", gfx_current_game_window_viewport.width, - gfx_current_game_window_viewport.height); - ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height); + ImGui::Text("Viewport dimensions: %d x %d", interpreter->mGameWindowViewport.width, + interpreter->mGameWindowViewport.height); + ImGui::Text("Internal resolution: %d x %d", interpreter->mCurDimensions.width, interpreter->mCurDimensions.height); UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); @@ -171,7 +173,7 @@ namespace AdvancedResolutionSettings { } else if (showHorizontalResField) { // Show calculated aspect ratio if (item_aspectRatio) { UIWidgets::Spacer(2); - float resolvedAspectRatio = (float)gfx_current_dimensions.height / gfx_current_dimensions.width; + float resolvedAspectRatio = (float)interpreter->mCurDimensions.height / interpreter->mCurDimensions.width; ImGui::Text("Aspect ratio: %.4f", resolvedAspectRatio); } else { UIWidgets::Spacer(enhancementSpacerHeight); From 4311aeda88f5aa79c47fcaf3a707723985e90675 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Wed, 23 Apr 2025 13:26:30 -0600 Subject: [PATCH 04/13] Removed mods folder on gitignore and bump torch --- .gitignore | 3 ++- tools/Torch | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a516fcfe..0ef6aa29 100644 --- a/.gitignore +++ b/.gitignore @@ -57,4 +57,5 @@ src/jp/ src/eu/ src/cn/ -properties.h \ No newline at end of file +properties.h +mods*/ \ No newline at end of file diff --git a/tools/Torch b/tools/Torch index 580350a2..770387ae 160000 --- a/tools/Torch +++ b/tools/Torch @@ -1 +1 @@ -Subproject commit 580350a2c2a0987811b31e562133106c4979bf05 +Subproject commit 770387ae325139069475fb0384d501b3669132c5 From 5391a5efe3e2b014e85e00a091e0502ed4c68863 Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Tue, 29 Apr 2025 18:55:54 -0300 Subject: [PATCH 05/13] comment out audio prints for now --- src/audio/audio_load.c | 4 ++-- src/audio/audio_playback.c | 2 +- src/port/resource/loaders/AudioLoader.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/audio/audio_load.c b/src/audio/audio_load.c index 361f303a..4f9a3e8a 100644 --- a/src/audio/audio_load.c +++ b/src/audio/audio_load.c @@ -419,8 +419,8 @@ void AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { void* AudioLoad_SyncLoadSeq(s32 seqId) { AudioTable* table = AudioLoad_GetLoadTable(SEQUENCE_TABLE); char* seqPath = ResourceGetNameByCrc((uint64_t) table->entries[seqId].romAddr); - printf("seqId: %d\n", seqId); - printf("seqPath: %s\n", seqPath); + // printf("seqId: %d\n", seqId); + // printf("seqPath: %s\n", seqPath); return ResourceGetDataByCrc((uint64_t) table->entries[seqId].romAddr); } diff --git a/src/audio/audio_playback.c b/src/audio/audio_playback.c index 03d4b639..be9dfbcd 100644 --- a/src/audio/audio_playback.c +++ b/src/audio/audio_playback.c @@ -243,7 +243,7 @@ Instrument* Audio_GetInstrument(s32 fontId, s32 instId) { D_80155D88 = (fontId << 8) + instId + 0x01000000; return instrument; } - printf("InstId: %d\n", instId); + // printf("InstId: %d\n", instId); return instrument; } diff --git a/src/port/resource/loaders/AudioLoader.cpp b/src/port/resource/loaders/AudioLoader.cpp index 8965af9f..6db4a312 100644 --- a/src/port/resource/loaders/AudioLoader.cpp +++ b/src/port/resource/loaders/AudioLoader.cpp @@ -11,7 +11,7 @@ extern "C" SoundFont* Audio_LoadFont(AudioTableEntry entry, uint32_t fontId) { auto crc = (uint64_t) gSoundFontTable->entries[fontId].romAddr; auto path = ResourceGetNameByCrc(crc); - printf("Font: %s\n", path); + // printf("Font: %s\n", path); return (SoundFont*) ResourceGetDataByCrc(crc); } From 3a21c8c5d6c0d564a417130c07dfef620c0de4bf Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Tue, 29 Apr 2025 20:49:58 -0300 Subject: [PATCH 06/13] update Torch --- tools/Torch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Torch b/tools/Torch index 770387ae..9c460ea5 160000 --- a/tools/Torch +++ b/tools/Torch @@ -1 +1 @@ -Subproject commit 770387ae325139069475fb0384d501b3669132c5 +Subproject commit 9c460ea54312e9cefabf155e3b83021c01862843 From d02bae05950bedbb973cd35cfdc27636dbee9e74 Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Tue, 6 May 2025 10:31:07 -0300 Subject: [PATCH 07/13] N64 Recorded Cutscene Timings for Corneria, Meteo, Macbeth and Sector Y Bosses --- include/fox_record.h | 22 +++++++++++++++++ src/engine/fox_demo.c | 24 ++++++++++++++++++ src/engine/fox_display.c | 15 +++++++++-- src/overlays/ovl_i1/fox_co.c | 48 +++++++++++++++++++++++++++++------- src/overlays/ovl_i2/fox_me.c | 22 +++++++++++++++++ src/overlays/ovl_i5/fox_ma.c | 32 ++++++++++++++++++++++++ src/overlays/ovl_i6/fox_sy.c | 17 +++++++++++++ src/port/Engine.cpp | 2 +- 8 files changed, 170 insertions(+), 12 deletions(-) create mode 100644 include/fox_record.h diff --git a/include/fox_record.h b/include/fox_record.h new file mode 100644 index 00000000..1fbfd3ff --- /dev/null +++ b/include/fox_record.h @@ -0,0 +1,22 @@ +/** + * Used to reproduce recordings made from real N64 hardware + * to accurately reproduce Cutscenes at the correct speed. + * These recordings adjust gVisPerFrame during runtime to produce + * the same behaviour as the original game. + */ +#ifndef N64_RECORD_H +#define N64_RECORD_H + +#include "global.h" + +typedef struct Record { + u8 vis; + u16 frame; +} Record; + +extern u8 gCarrierCutsceneRecord[200]; + +void UpdateVisPerFrameFromRecording(u8* record, s32 maxFrames); +void UpdateVisPerFrameFromRecording2(Record* record, s32 maxFrames); + +#endif diff --git a/src/engine/fox_demo.c b/src/engine/fox_demo.c index 40506dbb..c3315a63 100644 --- a/src/engine/fox_demo.c +++ b/src/engine/fox_demo.c @@ -19,6 +19,28 @@ #include "assets/ast_katina.h" #include "assets/ast_allies.h" #include "port/hooks/Events.h" +#include "fox_co.h" +#include "fox_record.h" + +void UpdateVisPerFrameFromRecording(u8* record, s32 maxFrames) { + if (gCsFrameCount < maxFrames) { + gVIsPerFrame = record[gCsFrameCount]; + } +} + +void UpdateVisPerFrameFromRecording2(Record* record, s32 maxFrames) { + int i; + + if (gCsFrameCount > record[maxFrames - 1].frame) { + return; + } + + for (i = 0; i < maxFrames; i++) { + if (gCsFrameCount == record[i].frame) { + gVIsPerFrame = record[i].vis; + } + } +} void func_demo_80048AC0(TeamId teamId) { s32 teamShield; @@ -925,6 +947,8 @@ void Cutscene_CoComplete2(Player* player) { Math_SmoothStepToF(&player->camRoll, 0.0f, 0.1f, 5.0f, 0.01f); + UpdateVisPerFrameFromRecording(gCarrierCutsceneRecord, ARRAY_COUNT(gCarrierCutsceneRecord)); + switch (player->csState) { case 10: D_ctx_80177A48[2] = 0.0f; diff --git a/src/engine/fox_display.c b/src/engine/fox_display.c index d636ad62..0d6e2bad 100644 --- a/src/engine/fox_display.c +++ b/src/engine/fox_display.c @@ -148,7 +148,8 @@ void Display_DrawHelpAlert(void) { RCP_SetupDL(&gMasterDisp, SETUPDL_76_OPTIONAL); gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 0, 255); if (sp78 < 0.0f) { - Graphics_DisplaySmallText(OTRGetRectDimensionFromLeftEdgeOverride(38.0f), 106, 1.0f, 1.0f, "HELP!!"); + Graphics_DisplaySmallText(OTRGetRectDimensionFromLeftEdgeOverride(38.0f), 106, 1.0f, 1.0f, + "HELP!!"); } else { Graphics_DisplaySmallText(OTRGetRectDimensionFromRightEdgeOverride(248), 106, 1.0f, 1.0f, "HELP!!"); } @@ -1138,7 +1139,7 @@ void Display_ArwingLaserCharge(Player* player) { // @port: Tag the transform. FrameInterpolation_RecordOpenChild("ArwingMuzzleFlash", 0); - + Matrix_Translate(gGfxMatrix, sp94.x, sp94.y, sp94.z, MTXF_NEW); Matrix_Scale(gGfxMatrix, gMuzzleFlashScale[player->num], gMuzzleFlashScale[player->num], 1.0f, MTXF_APPLY); @@ -2049,6 +2050,16 @@ void Display_Update(void) { if (gInputPress->stick_y < 0) Graphics_DisplaySmallText(110, 220, 1.0f, 1.0f, "NEG:"); #endif +// For debugging cutscene timings +#if 0 + RCP_SetupDL(&gMasterDisp, SETUPDL_83); + gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 0, 255); + Graphics_DisplaySmallText(10 + 210, 190, 1.0f, 1.0f, "CSFMS:"); + Graphics_DisplaySmallNumber(60 + 210, 190, (int) gCsFrameCount); + Graphics_DisplaySmallText(10 + 210, 200, 1.0f, 1.0f, "PLTIM:"); + Graphics_DisplaySmallNumber(60 + 210, 200, (int) gPlayer->csTimer); +#endif + // @port: @event: Call DisplayPostUpdateEvent CALL_EVENT(DisplayPostUpdateEvent); } diff --git a/src/overlays/ovl_i1/fox_co.c b/src/overlays/ovl_i1/fox_co.c index 0e225f4e..456889c8 100644 --- a/src/overlays/ovl_i1/fox_co.c +++ b/src/overlays/ovl_i1/fox_co.c @@ -10,6 +10,34 @@ #include "fox_co.h" #include "port/hooks/Events.h" +// Carrier destroy cutscene timings recorded from a real N64 +u8 gCarrierCutsceneRecord[200] = { + 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x04, 0x04, 0x04, 0x05, 0x05, 0x04, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 +}; + +// Granga destroy cutscene timings recorded from a real N64 +u8 gGrangaCutsceneRecord[161] = { + 0x02, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02 +}; + u8 sFightCarrier; f32 sCoGrangaWork[68]; @@ -182,9 +210,9 @@ void Corneria_CoGranga_HandleDamage(CoGranga* this) { this->state = GRANGA_EXPLODE; + this->timer_050 = 100; // original value // @port: Adjust timing to compensate the lack of lag. - // this->timer_050 = 100; - this->timer_050 = 138; + // this->timer_050 = 138; // @port SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM, 80); SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 80); @@ -2236,19 +2264,19 @@ void Corneria_CoCarrier_Update(CoCarrier* this) { Math_SmoothStepToF(&this->vel.y, 0.0f, 0.1f, 2.0f, 0.00001f); Math_SmoothStepToF(&this->vel.z, 0.0f, 0.1f, 2.0f, 0.00001f); + this->obj.rot.z -= 2.0f; // original value + this->gravity = 1.0f; // original value // @port: Adjust gravity and rot to compensate the lack of lag. - // this->obj.rot.z -= 2.0f - // this->gravity = 1.0f; - this->obj.rot.z -= 2.0f - 0.86f; - this->gravity = 1.0f - 0.43f; + // this->obj.rot.z -= 2.0f - 0.86f; + // this->gravity = 1.0f - 0.43f; if (this->obj.pos.y < (gGroundHeight + 150.0f)) { gCameraShake = 100; func_effect_80081A8C(this->obj.pos.x, this->obj.pos.y, this->obj.pos.z, 40.0f, 12); - + + this->timer_050 = 20; // original value // @port: Adjust timings to compensate the lack of lag. - // this->timer_050 = 20; - this->timer_050 = 40; + // this->timer_050 = 40; this->vel.y = -10.0f; this->gravity = 0.0f; this->fwork[17] = 20.0f; @@ -3456,6 +3484,8 @@ void Corneria_LevelComplete1(Player* player) { f32 temp_fa1; f32 temp_deg; + UpdateVisPerFrameFromRecording(gGrangaCutsceneRecord, ARRAY_COUNT(gGrangaCutsceneRecord)); + player->arwing.upperRightFlapYrot = player->arwing.upperLeftFlapYrot = player->arwing.bottomRightFlapYrot = player->arwing.bottomLeftFlapYrot = 0.0f; diff --git a/src/overlays/ovl_i2/fox_me.c b/src/overlays/ovl_i2/fox_me.c index 678dbfe0..4655908d 100644 --- a/src/overlays/ovl_i2/fox_me.c +++ b/src/overlays/ovl_i2/fox_me.c @@ -6,6 +6,26 @@ #include "global.h" #include "assets/ast_meteo.h" +#include "fox_record.h" + +// MeCrusher destroy cutscene timings recorded from a real N64 +u8 gMeCrusherCutsceneRecord[] = { + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x02 +}; Vec3f D_i2_80195430[] = { { 122.0, -5.0, -1200.0 }, { 122.0, -103.0, -727.0 }, { 142.0, -323.0, -848.0 }, { 362.0, -59.0, -435.0 }, @@ -2426,6 +2446,8 @@ void Meteo_LevelComplete(Player* player) { Math_SmoothStepToAngle(&player->aerobaticPitch, 0.0f, 0.1f, 20.0f, 0.0f); Math_SmoothStepToF(&player->boostSpeed, 0.0f, 0.1f, 3.0f, 0.0f); + UpdateVisPerFrameFromRecording(gMeCrusherCutsceneRecord, ARRAY_COUNT(gMeCrusherCutsceneRecord)); + switch (player->csState) { case 0: Audio_StopSfxByBankAndSource(1, player->sfxSource); diff --git a/src/overlays/ovl_i5/fox_ma.c b/src/overlays/ovl_i5/fox_ma.c index 414d0090..6825f828 100644 --- a/src/overlays/ovl_i5/fox_ma.c +++ b/src/overlays/ovl_i5/fox_ma.c @@ -10,6 +10,7 @@ #include "assets/ast_landmaster.h" #include "assets/ast_enmy_planet.h" // #include "prevent_bss_reordering2.h" +#include "fox_record.h" typedef struct { /* 0x00 */ f32 unk_00; @@ -59,6 +60,29 @@ Vec3f D_i5_801BE688[2]; Vec3f D_i5_801BE6A0[12]; s32 D_i5_801BE734[4]; +// Train cutscene timings recorded from a real N64 +Record sf64_virecord_macbeth_records[] = { + // Train breaking barriers + { 0x02, 0x000000 }, + { 0x03, 0x000002 }, + { 0x02, 0x00001F }, + { 0x03, 0x000190 }, + { 0x02, 0x0001A2 }, + { 0x03, 0x0001B1 }, + { 0x04, 0x0001B3 }, + { 0x03, 0x0001BC }, + { 0x02, 0x0001FD }, + // { 0x03, 0x00022F }, + // { 0x02, 0x000245 }, + // { 0x03, 0x00024B }, + // Explosions + { 0x02, 0x00024D }, + { 0x03, 0x0002CA }, + { 0x04, 0x000335 }, + { 0x05, 0x000351 }, + { 0x02, 0x0003AE }, +}; + UnkStruct_D_i5_801B8E50 D_i5_801B8E50[156] = { { 5174.4f, -2141.0f, 0.0f, 350.0f, OBJ_SCENERY_MA_TRAIN_TRACK_3 }, { 3401.4f, -1828.0f, 0.0f, 350.0f, OBJ_SCENERY_MA_TRAIN_TRACK_3 }, @@ -6472,6 +6496,12 @@ f32 D_i5_801BA854[8] = { 1.5f, -1.0f, 0.7f, 0.0f, 0.9f, 0.7f, -1.0f, 1.5f }; f32 D_i5_801BA874[8] = { 200.0f, 300.0f, 400.0f, 0.0f, 500.0f, 100.0f, 120.0f, 100.0f }; f32 D_i5_801BA894[8] = { 200.0f, 250.0f, 220.0f, 0.0f, 200.0f, 230.0f, 220.0f, 350.0f }; + + + + + + void Macbeth_LevelComplete2(Player* player) { s32 i; s32 j; @@ -6479,6 +6509,8 @@ void Macbeth_LevelComplete2(Player* player) { Vec3f spD8; f32 zeroVar = 0.0f; + UpdateVisPerFrameFromRecording2(sf64_virecord_macbeth_records, ARRAY_COUNT(sf64_virecord_macbeth_records)); + switch (player->csState) { case 0: gCsFrameCount = 0; diff --git a/src/overlays/ovl_i6/fox_sy.c b/src/overlays/ovl_i6/fox_sy.c index dd7b13fa..7eb32b89 100644 --- a/src/overlays/ovl_i6/fox_sy.c +++ b/src/overlays/ovl_i6/fox_sy.c @@ -6,6 +6,7 @@ #include "global.h" #include "assets/ast_sector_y.h" +#include "fox_record.h" #define SHOGUN_SHIP (0) @@ -29,6 +30,19 @@ void SectorY_801A0510(ActorCutscene*, s32); void SectorY_ActorDebris_Setup(Actor*, f32, f32, f32, f32, f32, f32, s32); void SectorY_ActorDebris_Spawn(f32, f32, f32, f32, f32, f32, s32); +// SyRobot destroy cutscene timings recorded from a real N64 +u8 gSyRobotCutsceneRecord[158] = { + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02 +}; + f32 D_i6_801A8440[3]; void SectorY_80197B30(ActorCutscene* this, s32 timer) { @@ -475,6 +489,7 @@ void SectorY_80198F5C(SyShogun* this) { this->vel.y = 0.0f; this->vel.x = 0.0f; + // first and second robot explode if ((gPlayer[0].state == PLAYERSTATE_ACTIVE) || (gPlayer[0].state == PLAYERSTATE_U_TURN)) { this->timer_058 = 100; gPlayer[0].state = PLAYERSTATE_STANDBY; @@ -2090,6 +2105,8 @@ void SectorY_LevelComplete(Player* player) { SyShogun* boss = &gBosses[0]; f32 temp_ft1; + UpdateVisPerFrameFromRecording(gSyRobotCutsceneRecord, ARRAY_COUNT(gSyRobotCutsceneRecord)); + switch (player->csState) { case 0: gCsFrameCount = 0; diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index d8d34711..519a00d0 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -376,7 +376,7 @@ void GameEngine::HandleAudioThread() { // gVIsPerFrame = 2; #define AUDIO_FRAMES_PER_UPDATE (gVIsPerFrame > 0 ? gVIsPerFrame : 1) -#define MAX_AUDIO_FRAMES_PER_UPDATE 3 // Compile-time constant with max value of gVIsPerFrame +#define MAX_AUDIO_FRAMES_PER_UPDATE 5 // Compile-time constant with max value of gVIsPerFrame std::unique_lock Lock(audio.mutex); int samples_left = AudioPlayerBuffered(); From 6353f248bccc60de93bcb4edb788aae97798abac Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Tue, 6 May 2025 16:03:51 -0300 Subject: [PATCH 08/13] fix compilation error --- src/overlays/ovl_i1/fox_co.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/overlays/ovl_i1/fox_co.c b/src/overlays/ovl_i1/fox_co.c index 456889c8..a3cd7257 100644 --- a/src/overlays/ovl_i1/fox_co.c +++ b/src/overlays/ovl_i1/fox_co.c @@ -9,6 +9,7 @@ #include "assets/ast_corneria.h" #include "fox_co.h" #include "port/hooks/Events.h" +#include "fox_record.h" // Carrier destroy cutscene timings recorded from a real N64 u8 gCarrierCutsceneRecord[200] = { From fe69a3ff835748bb9bf977db3a15d166ff61f968 Mon Sep 17 00:00:00 2001 From: sitton76 <58642183+sitton76@users.noreply.github.com> Date: Tue, 6 May 2025 16:18:19 -0500 Subject: [PATCH 09/13] Attempted appimage load fix (#195) --- src/port/Engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 519a00d0..3ebf88f3 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -70,7 +70,7 @@ GameEngine::GameEngine() { std::vector archiveFiles; const std::string main_path = Ship::Context::GetPathRelativeToAppDirectory("sf64.o2r"); - const std::string assets_path = Ship::Context::GetPathRelativeToAppDirectory("starship.o2r"); + const std::string assets_path = Ship::Context::GetPathRelativeToAppBundle("starship.o2r"); #ifdef _WIN32 AllocConsole(); From 2c9bc2738dfd03eaf81e0c9339107f63062f5d99 Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Tue, 13 May 2025 21:59:01 -0300 Subject: [PATCH 10/13] update LUS --- libultraship | 2 +- port/shaders/directx/default.shader.hlsl | 6 +++--- src/port/Engine.cpp | 5 +++++ src/port/resource/importers/ResourceUtil.h | 1 + src/port/resource/importers/audio/SampleFactory.cpp | 2 +- src/port/resource/importers/audio/SoundFontFactory.cpp | 1 + 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libultraship b/libultraship index dda07c8a..a8cddd2f 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit dda07c8ac6033ff98d37a05bc28406440c7769e4 +Subproject commit a8cddd2f8991c9d50783db4de855c98a392f4ac9 diff --git a/port/shaders/directx/default.shader.hlsl b/port/shaders/directx/default.shader.hlsl index f36c2dae..980becb8 100644 --- a/port/shaders/directx/default.shader.hlsl +++ b/port/shaders/directx/default.shader.hlsl @@ -186,7 +186,7 @@ float4 PSMain(PSInput input, float4 screenSpace : SV_Position) : SV_TARGET { float2 tc@{i} = input.uv@{i}; @{s = o_clamp[i][0]} @{t = o_clamp[i][1]} - @if(s && t) + @if(s || t) int2 texSize@{i}; g_texture@{i}.GetDimensions(texSize@{i}.x, texSize@{i}.y); @if(s && t) @@ -224,7 +224,7 @@ float4 PSMain(PSInput input, float4 screenSpace : SV_Position) : SV_TARGET { @else float4 blendVal@{i} = float4(0, 0, 0, 0); @end - texval@{i} = lerp(texVal@{i}, blendVal@{i}, g_textureMask@{i}.Sample(g_sampler@{i}, tc@{i}).a); + texVal@{i} = lerp(texVal@{i}, blendVal@{i}, g_textureMask@{i}.Sample(g_sampler@{i}, tc@{i}).a); @end } @else @@ -329,4 +329,4 @@ float4 PSMain(PSInput input, float4 screenSpace : SV_Position) : SV_TARGET { return float4(texel, 1.0); @end @end -} \ No newline at end of file +} diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 3ebf88f3..a2c16ca8 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -70,7 +70,12 @@ GameEngine::GameEngine() { std::vector archiveFiles; const std::string main_path = Ship::Context::GetPathRelativeToAppDirectory("sf64.o2r"); +#ifdef __linux__ const std::string assets_path = Ship::Context::GetPathRelativeToAppBundle("starship.o2r"); +#else + const std::string assets_path = Ship::Context::GetPathRelativeToAppDirectory("starship.o2r"); +#endif + #ifdef _WIN32 AllocConsole(); diff --git a/src/port/resource/importers/ResourceUtil.h b/src/port/resource/importers/ResourceUtil.h index 32a6fd4c..67ed936a 100644 --- a/src/port/resource/importers/ResourceUtil.h +++ b/src/port/resource/importers/ResourceUtil.h @@ -1,6 +1,7 @@ #pragma once #include "resourcebridge.h" +#include "ResourceManager.h" #include "Context.h" namespace SF64 { diff --git a/src/port/resource/importers/audio/SampleFactory.cpp b/src/port/resource/importers/audio/SampleFactory.cpp index 87f6ec14..d4115cb9 100644 --- a/src/port/resource/importers/audio/SampleFactory.cpp +++ b/src/port/resource/importers/audio/SampleFactory.cpp @@ -4,7 +4,7 @@ #include "sf64audio_provisional.h" #define DR_WAV_IMPLEMENTATION #include - +#include #define DR_MP3_IMPLEMENTATION #include diff --git a/src/port/resource/importers/audio/SoundFontFactory.cpp b/src/port/resource/importers/audio/SoundFontFactory.cpp index 126b43fe..c3d16d0f 100644 --- a/src/port/resource/importers/audio/SoundFontFactory.cpp +++ b/src/port/resource/importers/audio/SoundFontFactory.cpp @@ -3,6 +3,7 @@ #include "utils/StringHelper.h" #include #include "port/resource/type/audio/SoundFont.h" +#include namespace SF64 { std::shared_ptr ResourceFactoryBinarySoundFontV0::ReadResource(std::shared_ptr file, From 79f939a818c14c362d81e79cc8913784a8b9d4f3 Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Tue, 13 May 2025 23:45:53 -0300 Subject: [PATCH 11/13] fix OpenGL --- port/shaders/opengl/default.shader.fs | 31 ++++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/port/shaders/opengl/default.shader.fs b/port/shaders/opengl/default.shader.fs index b15e1598..404caae6 100644 --- a/port/shaders/opengl/default.shader.fs +++ b/port/shaders/opengl/default.shader.fs @@ -44,6 +44,10 @@ out vec4 vOutColor; uniform int frame_count; uniform float noise_scale; +uniform int texture_width[2]; +uniform int texture_height[2]; +uniform int texture_filtering[2]; + #define TEX_OFFSET(off) @{texture}(tex, texCoord - off / texSize) #define WRAP(x, low, high) mod((x)-(low), (high)-(low)) + (low) @@ -59,7 +63,6 @@ vec4 fromLinear(vec4 linearRGB){ return vec4(mix(higher, lower, cutoff), linearRGB.a); } -@if(o_current_filter == FILTER_THREE_POINT) vec4 filter3point(in sampler2D tex, in vec2 texCoord, in vec2 texSize) { vec2 offset = fract(texCoord*texSize - vec2(0.5)); offset -= step(1.0, offset.x + offset.y); @@ -69,14 +72,16 @@ vec4 filter3point(in sampler2D tex, in vec2 texCoord, in vec2 texSize) { return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0); } -vec4 hookTexture2D(in sampler2D tex, in vec2 uv, in vec2 texSize) { - return filter3point(tex, uv, texSize); -} -@else -vec4 hookTexture2D(in sampler2D tex, in vec2 uv, in vec2 texSize) { +vec4 hookTexture2D(in int id, sampler2D tex, in vec2 uv, in vec2 texSize) { +@if(o_three_point_filtering) + if(texture_filtering[id] == @{FILTER_THREE_POINT}) { + return filter3point(tex, uv, texSize); + } +@end return @{texture}(tex, uv); } -@end + +#define TEX_SIZE(tex) vec2(texture_width[tex], texture_height[tex]) void main() { @for(i in 0..2) @@ -84,11 +89,7 @@ void main() { @{s = o_clamp[i][0]} @{t = o_clamp[i][1]} - @if(opengles) - vec2 texSize@{i} = vec2(textureSize(uTex@{i}, 0)); - @else - vec2 texSize@{i} = textureSize(uTex@{i}, 0); - @end + vec2 texSize@{i} = TEX_SIZE(@{i}); @if(!s && !t) vec2 vTexCoordAdj@{i} = vTexCoord@{i}; @@ -102,7 +103,7 @@ void main() { @end @end - vec4 texVal@{i} = hookTexture2D(uTex@{i}, vTexCoordAdj@{i}, texSize@{i}); + vec4 texVal@{i} = hookTexture2D(@{i}, uTex@{i}, vTexCoordAdj@{i}, texSize@{i}); @if(o_masks[i]) @if(opengles) @@ -111,10 +112,10 @@ void main() { vec2 maskSize@{i} = textureSize(uTexMask@{i}, 0); @end - vec4 maskVal@{i} = hookTexture2D(uTexMask@{i}, vTexCoordAdj@{i}, maskSize@{i}); + vec4 maskVal@{i} = hookTexture2D(@{i}, uTexMask@{i}, vTexCoordAdj@{i}, maskSize@{i}); @if(o_blend[i]) - vec4 blendVal@{i} = hookTexture2D(uTexBlend@{i}, vTexCoordAdj@{i}, texSize@{i}); + vec4 blendVal@{i} = hookTexture2D(@{i}, uTexBlend@{i}, vTexCoordAdj@{i}, texSize@{i}); @else vec4 blendVal@{i} = vec4(0, 0, 0, 0); @end From 93ce49e48e513ef008965e202b0dc172b5962f4f Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Wed, 14 May 2025 00:47:09 -0300 Subject: [PATCH 12/13] CODEC_S16 fix from 2ship --- src/audio/audio_synthesis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/audio_synthesis.c b/src/audio/audio_synthesis.c index 1558adfc..84d894c5 100644 --- a/src/audio/audio_synthesis.c +++ b/src/audio/audio_synthesis.c @@ -1070,7 +1070,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisSta dmemUncompressedAddrOffset1 = numSamplesToLoadAdj; if (((synthState->samplePosInt * 2) + (numSamplesToLoadAdj)*SAMPLE_SIZE) < bookSample->size) { - bytesToRead = (numSamplesToLoadAdj)*SAMPLE_SIZE; + bytesToRead = (numSamplesToLoadAdj + 16)*SAMPLE_SIZE; } else { bytesToRead = bookSample->size - (synthState->samplePosInt * 2); } From d35f0ee2644fd958c4544dc9d6ee74bef3b6d94e Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Fri, 16 May 2025 01:40:54 -0300 Subject: [PATCH 13/13] Fix planet texture scroll cache --- src/overlays/ovl_menu/fox_map.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/overlays/ovl_menu/fox_map.c b/src/overlays/ovl_menu/fox_map.c index 2708defe..c02cbd83 100644 --- a/src/overlays/ovl_menu/fox_map.c +++ b/src/overlays/ovl_menu/fox_map.c @@ -2075,6 +2075,7 @@ void Map_Texture_Sphere(u8* textureDest, u8* textureSrc, f32* offset) { if (*offset > 95.0f) { *offset = 0.0f; } + gSPInvalidateTexCache(gMasterDisp++, NULL); } void Map_Prologue_Update(void) {