Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop-satoko' into merge-satoko
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez committed Jan 1, 2025
2 parents 9c98f1f + a72c098 commit 2c79f92
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 22 deletions.
14 changes: 7 additions & 7 deletions mm/2s2h/BenPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,15 +1639,15 @@ extern "C" void OTRControllerCallback(uint8_t rumble) {
static std::shared_ptr<BenInputEditorWindow> controllerConfigWindow = nullptr;
if (controllerConfigWindow == nullptr) {
controllerConfigWindow = std::dynamic_pointer_cast<BenInputEditorWindow>(
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Input Editor"));
// TODO: Add SoH Controller Config window rumble testing to upstream LUS config window
// note: the current implementation may not be desired in LUS, as "true" rumble support
// using osMotor calls is planned: https://github.com/Kenix3/libultraship/issues/9
//
// } else if (controllerConfigWindow->TestingRumble()) {
// return;
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("2S2H Input Editor"));
// note: the current implementation may not be desired in LUS, as "true" rumble support
// using osMotor calls is planned: https://github.com/Kenix3/libultraship/issues/9
}
if (controllerConfigWindow->TestingRumble()) {
return;
}

// TODO: other ports?
if (rumble) {
Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StartRumble();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ void FrameInterpolation_StartRecord(void) {
current_recording = {};
current_path.clear();
current_path.push_back(&current_recording.root_path);
has_inv_actor_mtx = false;
interpolate_wider_angles = false;
ignore_inv_actor_mtx = false;

if (!camera_interpolation) {
// default to interpolating
camera_interpolation = true;
Expand Down Expand Up @@ -523,12 +527,16 @@ int FrameInterpolation_GetCameraEpoch(void) {
// Marks the current record path and its children to not apply the matrix result
// against the recorded actor inverted matrix
void FrameInterpolation_IgnoreActorMtx() {
if (!is_recording)
return;
ignore_inv_actor_mtx = true;
ignore_inv_actor_mtx_path_index = current_path.size();
}

// Allows interpolating from angle changes that are up to 123º for the next SetTranslateRotateYXZ
void FrameInterpolation_InterpolateWiderAngles() {
if (!is_recording)
return;
interpolate_wider_angles = true;
}

Expand Down
10 changes: 10 additions & 0 deletions mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern "C" {
#include "objects/object_fz/object_fz.h"
#include "objects/object_ik/object_ik.h"
#include "overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.h"
#include "overlays/ovl_fbdemo_wipe1/ovl_fbdemo_wipe1.h"
#include "overlays/ovl_Obj_Jgame_Light/ovl_Obj_Jgame_Light.h"

void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
Expand Down Expand Up @@ -312,11 +313,20 @@ void GfxPatcher_ApplyGeometryIssuePatches() {
PatchClockTownBuildingGeometry();
}

void GfxPatcher_ApplyTransitionWipePatch() {
// Removing G_ZBUFFER as gsDPSetPrimDepth is unimplemented in LUS.
// This should have the same effect of using a depth test value of 0, and allows it to render over everything.
// LUSTODO: Remove patch once gsDPSetPrimDepth is implemented properly.
ResourceMgr_PatchGfxByName(sTransWipe1DL, "zbufferRemoval", 4, gsSPSetGeometryMode(G_SHADE | G_SHADING_SMOOTH));
}

// Applies required patches for authentic bugs to allow the game to play and render properly
void GfxPatcher_ApplyNecessaryAuthenticPatches() {
PatchMiniGameCrossAndCircleSymbols();

GfxPatcher_ApplyOverflowTexturePatches();

GfxPatcher_ApplyGeometryIssuePatches();

GfxPatcher_ApplyTransitionWipePatch();
}
71 changes: 71 additions & 0 deletions mm/2s2h/Enhancements/Graphics/BowReticle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include "libultraship/libultraship.h"
#include "2s2h/GameInteractor/GameInteractor.h"
#include "2s2h/Enhancements/FrameInterpolation/FrameInterpolation.h"

extern "C" {
#include "functions.h"
#include "variables.h"
#include "objects/gameplay_keep/gameplay_keep.h"
}

void DrawBowReticle(PlayState* play, Player* player, f32 bowDistance) {
static Vec3f D_801C094C = { -500.0f, -100.0f, 0.0f };
CollisionPoly* poly;
s32 bgId;
Vec3f posA;
Vec3f posB;
Vec3f pos;
Vec3f projectedPos;
f32 projectedW;
f32 scale;

D_801C094C.z = 0.0f;
Matrix_MultVec3f(&D_801C094C, &posA);
D_801C094C.z = bowDistance;
Matrix_MultVec3f(&D_801C094C, &posB);

// If the line test doesn't hit a valid polygon, use the "farthest" point as the reticle position.
// This ensures that the reticle is always visible even when looking at the sky
if (!BgCheck_ProjectileLineTest(&play->colCtx, &posA, &posB, &pos, &poly, true, true, true, true, &bgId)) {
pos = posB;
}

OPEN_DISPS(play->state.gfxCtx);

OVERLAY_DISP = Gfx_SetupDL(OVERLAY_DISP, SETUPDL_7);

SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &projectedPos, &projectedW);

scale = (projectedW < 500.0f) ? 0.075f : (projectedW / 500.0f) * 0.075f;

Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW);
Matrix_Scale(scale, scale, scale, MTXMODE_APPLY);

gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);

gSPSegment(OVERLAY_DISP++, 0x06, (uintptr_t)play->objectCtx.slots[player->actor.objectSlot].segment);
gSPDisplayList(OVERLAY_DISP++, (Gfx*)gHookshotReticleDL);

CLOSE_DISPS(play->state.gfxCtx);
}

void RegisterBowReticle() {
GameInteractor::Instance->RegisterGameHookForID<GameInteractor::OnPlayerPostLimbDraw>(
PLAYER_LIMB_RIGHT_HAND, [](Player* player, s32 limbIndex) {
if (player->actor.scale.y >= 0.0f &&
((player->heldItemAction == PLAYER_IA_BOW_FIRE) || (player->heldItemAction == PLAYER_IA_BOW_ICE) ||
(player->heldItemAction == PLAYER_IA_BOW_LIGHT) || (player->heldItemAction == PLAYER_IA_BOW)) &&
CVarGetInteger("gEnhancements.Graphics.BowReticle", 0)) {

if (func_800B7128(player) != 0) {
// Rotation from link's right hand that aligns with arrow projection
Matrix_RotateZYX(0, -0x3B33, -0x4423, MTXMODE_APPLY);
Matrix_Translate(575.0f, 345.0f, 0.0f, MTXMODE_APPLY);

// 341000 as a value is selected roughly as a ratio of the hookshot value to maximum hookshot
// distance from player, multiplied by maximum arrow distance from player -- (77600 / 770) * 3385
DrawBowReticle(gPlayState, player, 341000.0f);
}
}
});
}
15 changes: 0 additions & 15 deletions mm/src/code/z_player_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3681,21 +3681,6 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G
Player_DrawHookshotReticle(play, player, 77600.0f);
}
}
} else if (CVarGetInteger("gEnhancements.Graphics.BowReticle", 0) &&
((player->heldItemAction == PLAYER_IA_BOW_FIRE) ||
(player->heldItemAction == PLAYER_IA_BOW_ICE) ||
(player->heldItemAction == PLAYER_IA_BOW_LIGHT) || (player->heldItemAction == PLAYER_IA_BOW))) {
if (heldActor != NULL) {
MtxF sp44;

Matrix_RotateZYX(0, -15216, -17496, MTXMODE_APPLY);
Matrix_Get(&sp44);

if (func_800B7128(player) != 0) {
Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY);
Player_DrawHookshotReticle(play, player, 776000.0f);
}
}
} else if (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) {
if (player->meleeWeaponAnimation == PLAYER_MWA_GORON_PUNCH_RIGHT) {
func_80126B8C(play, player);
Expand Down
6 changes: 6 additions & 0 deletions mm/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
void EnSob1_Init(Actor* thisx, PlayState* play);
void EnSob1_Destroy(Actor* thisx, PlayState* play);
void EnSob1_Update(Actor* thisx, PlayState* play);
void EnSob1_Reset(void);

void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, PlayState* play);
void EnSob1_GoronShopkeeper_Draw(Actor* thisx, PlayState* play);
Expand Down Expand Up @@ -75,6 +76,7 @@ ActorInit En_Sob1_InitVars = {
/**/ EnSob1_Destroy,
/**/ EnSob1_Update,
/**/ NULL,
/**/ EnSob1_Reset,
};

static s16 sObjectIds[][3] = {
Expand Down Expand Up @@ -1751,3 +1753,7 @@ void EnSob1_BombShopkeeper_Draw(Actor* thisx, PlayState* play) {

CLOSE_DISPS(play->state.gfxCtx);
}

void EnSob1_Reset(void) {
sShops[BOMB_SHOP][0].shopItemId = SI_BOMB_BAG_20_2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "z_obj_takaraya_wall.h"
#include "objects/object_takaraya_objects/object_takaraya_objects.h"

#include "2s2h/Enhancements/FrameInterpolation/FrameInterpolation.h"

#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20)

#define THIS ((ObjTakarayaWall*)thisx)
Expand Down Expand Up @@ -468,6 +470,7 @@ void ObjTakarayaWall_Draw(Actor* thisx, PlayState* play) {
for (i = 0; i < TAKARAYA_WALL_ROWS; i++) {
for (j = 0; j < TAKARAYA_WALL_COLUMNS; j++) {
if (sTakarayaWallHeights[i][j] > 0.0f) {
FrameInterpolation_RecordOpenChild(this, i * TAKARAYA_WALL_COLUMNS + j);
mtx->xw = (i * 120) - 1620;
mtx->yw = sTakarayaWallHeights[i][j] + (this->actor.world.pos.y - 120.0f);
mtx->zw = (j * 120) + 60;
Expand All @@ -494,6 +497,8 @@ void ObjTakarayaWall_Draw(Actor* thisx, PlayState* play) {
Audio_PlaySfx_AtPos(&sTakarayaWallAudioPositions[i][j], NA_SE_EV_ROCK_CUBE_FALL - SFX_FLAG);
}
}

FrameInterpolation_RecordCloseChild();
}
}
}
Expand Down

0 comments on commit 2c79f92

Please sign in to comment.