Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Surface Material #1447

Merged
merged 11 commits into from
Nov 26, 2022
Merged

Document Surface Material #1447

merged 11 commits into from
Nov 26, 2022

Conversation

engineer124
Copy link
Contributor

This came up from a conversation in MM but this looks to document the values stored in surfaceTypes[poly->type].data[1] & 0xF which I'm currently calling "MATERIAL", and the values of the sfxOffset based on sequence 0 using the audio extraction PR:
#1236, which I'm calling "SFX_OFFSET"

entry player_child_step_dirt
entry player_child_step_sand
entry player_child_step_stone
entry player_child_step_jabu
entry player_child_step_water
entry player_child_step_water_deep
entry player_child_step_tall_grass
entry player_child_step_lava
entry player_child_step_grass
entry player_child_step_carpet
entry player_child_step_wood
entry player_child_step_bridge
entry player_step_vines
entry player_step_iron_boots
entry player_step_unused
entry player_child_step_ice

These two sets of values (material/sfxOffset) mostly line up, but there are some values that do not.

Comment on lines 1747 to 1751
actor->sfx = 3;
} else if (arg1 < 100) {
actor->sfx = NA_SE_PL_WALK_CONCRETE - SFX_FLAG;
actor->sfx = 2;
} else {
actor->sfx = NA_SE_PL_WALK_SAND - SFX_FLAG;
actor->sfx = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on this change? This doesn't play a sfx?

Copy link
Contributor Author

@engineer124 engineer124 Nov 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is confusing to explain, but these values are actually timer states that get fed as seq ioData into seq ioPort, that then triggers seq 0 to change the tempo of the ticking timer. This is all programmed internally in seq 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see (more or less)
Could you put a comment until this is documented, maybe something like With ACTOR_FLAG_28 the sfx value is not a sfx id, see func_80030ED8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even more specifically, they're indices to this table here, which then applies a delay to when the next "tick" is in the timer
https://github.com/MNGoldenEagle/oot/blob/fb5bcb9e5e9bfa5e9735c9a3015aa32d896a1767/assets/sequences/sfxbanks/env.seq.inc#L740-L744
Except the indices are offset by 1 (actor->sfx = 1; // index 0) so that it passes the actor->sfx != 0 check needed to play the sfx. Then the (s8)(actor->sfx - 1) gets the true index

Yeah, I can add a temporary comment. I'll also be tackling this function in the near future as well

func_80078914(&this->actor.projectedPos, NA_SE_VO_SK_CRASH);
} else if (Animation_OnFrame(skelAnime, 26.0f)) {
func_80078914(&this->actor.projectedPos, NA_SE_PL_BOUND_GRASS);
func_80078914(&this->actor.projectedPos, NA_SE_PL_BOUND + SURFACE_SFX_OFFSET_GRASS);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this kind of change necessary? Why not just have NA_SE_PL_BOUND_GRASS ? (idk)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this one is debatable and I'm still on the fence for it, but I feel it's good to always treat these player sfx id's as base + materialOffset + ageOffset because that's how it's designed. A huge number of sfxId's are all labelled DUMMY_ in the player bank because while they're all valid sfx, their mainly accessed through their base and offset. Just look at the player sfxId's at 0x80 - 0x8F, 0x90 - 0x9F, 0xA0 - 0xAF. But maybe long term when we properly name all sfxId's, we will be giving them all names based on combinations of base + material offset + age offset

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key thing that bothers me is as you said

these player sfx id's

so I understand it in the context of player, but this is just an actor randomly using a player sfx for its own purpose, it doesn't care all that much about the layout of the player bank?
(I'm on the fence too)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this specific actor is even weirder because it does use SurfaceType_GetSfxOffset so it's a poor example
The point stands for others though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. These "player sfxIds" are called "player" because the og name for this was "Player Bank". However, as you mentioned, some actors use these for themselves (non-player actors), like walking most commonly, but other sfx as well

Copy link
Contributor Author

@engineer124 engineer124 Nov 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actor specifically (Sheik) uses a hardcoded sfxId/material/offset because it's cutscene based, so it's all predetermined where she'll be walking (is my interpretation)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actor uses of this kind of concept are

Fishing in Fishing_UpdateLure (who would have guessed):
func_80078914(&D_80B7AF94, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_SAND);

Ganon in BossGanon_HitByLightBall:
Audio_PlayActorSfx2(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_TALL_GRASS);

Nabooru in EnNb_PlayLookRightSFX and EnNb_PlayLookLeftSFX
func_80078914(&this->actor.projectedPos, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_STONE);

Ruto (child) in undocumented territory:
func_80078914(&this->actor.projectedPos, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_JABU);

Sheik in EnXc_SetThrownAroundSFX
func_80078914(&this->actor.projectedPos, NA_SE_PL_BOUND + SURFACE_SFX_OFFSET_GRASS);
func_80078914(&this->actor.projectedPos, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_GRASS);

Saria in undocumented territory:
Audio_PlaySfxGeneral(NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_DIRT, ...)

Talon in EnTa_RunWithAccelerationAndSfx
Audio_PlayActorSfx2(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_DIRT);

Adult Zelda (Cutscenes) in undocumented territory:
Audio_PlayActorSfx2(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_DIRT);

@@ -3170,8 +3170,7 @@ void Message_Update(PlayState* play) {
R_TEXTBOX_TEXHEIGHT = 512;
} else {
Message_GrowTextbox(msgCtx);
// TODO: this may be NA_SE_PL_WALK_GROUND - SFX_FLAG, or not, investigate sfxId=0
Audio_PlaySfxIfNotInCutscene(0);
Audio_PlaySfxIfNotInCutscene(NA_SE_NONE);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this was (un)intended?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a textbox growing sound effect in beta (can hear it in some spaceworld era vids)

They likely just put a raw 0 in there to "comment it out" without removing the whole call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to say, I think Fig hypothesized that these were likely actual sounds in earlier releases (sw97) and that the sounds were too obnoxious or not right, so they put a NONE here to silence this sfx (maybe there was a debug conditional)? But I kinda lean into that kind of concept, so I suspect this was intentional and they were messing around with different sfx at this spot, but the final decision was to not include one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lmao. Beat me to the punch

include/sfx.h Outdated Show resolved Hide resolved
Copy link
Contributor

@hensldm hensldm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Do not really have any opinion on using the sfx directly for some actors, instead of adding the surface offset.

src/code/z_actor.c Outdated Show resolved Hide resolved
@fig02 fig02 merged commit c7a61aa into zeldaret:master Nov 26, 2022
@engineer124 engineer124 deleted the material branch November 26, 2022 23:11
Comment on lines +3044 to +3052
NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_DIRT,
NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_DIRT,
NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_DIRT,
NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_SAND,
NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_STONE,
NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_JABU,
NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_WATER_SHALLOW,
NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_WATER_DEEP,
NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_TALL_GRASS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you intend to delete the other constants, I don't think it's necessary to split sound effects in cases where they are intended to be called directly.

@@ -1751,7 +1751,7 @@ void func_808327F8(Player* this, f32 arg1) {
s32 sfxId;

if (this->currentBoots == PLAYER_BOOTS_IRON) {
sfxId = NA_SE_PL_WALK_HEAVYBOOTS;
sfxId = NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_IRON_BOOTS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sfxId = NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_IRON_BOOTS;
sfxId = NA_SE_PL_WALK_HEAVYBOOTS;

Same point here; NA_SE_PL_WALK_HEAVYBOOTS already expresses NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_IRON_BOOTS

@@ -1763,7 +1763,7 @@ void func_80832854(Player* this) {
s32 sfxId;

if (this->currentBoots == PLAYER_BOOTS_IRON) {
sfxId = NA_SE_PL_JUMP_HEAVYBOOTS;
sfxId = NA_SE_PL_JUMP + SURFACE_SFX_OFFSET_IRON_BOOTS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sfxId = NA_SE_PL_JUMP + SURFACE_SFX_OFFSET_IRON_BOOTS;
sfxId = NA_SE_PL_JUMP_HEAVYBOOTS;

@@ -1775,7 +1775,7 @@ void func_808328A0(Player* this) {
s32 sfxId;

if (this->currentBoots == PLAYER_BOOTS_IRON) {
sfxId = NA_SE_PL_LAND_HEAVYBOOTS;
sfxId = NA_SE_PL_LAND + SURFACE_SFX_OFFSET_IRON_BOOTS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sfxId = NA_SE_PL_LAND + SURFACE_SFX_OFFSET_IRON_BOOTS;
sfxId = NA_SE_PL_LAND_HEAVYBOOTS;

u32 SurfaceType_GetSfxType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u16 SurfaceType_GetSfxId(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u32 SurfaceType_GetMaterial(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u16 SurfaceType_GetSfxOffset(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
u16 SurfaceType_GetSfxOffset(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u16 SurfaceType_GetSfxMaterial(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);

It's a personal preference, but I think the name should retain the fact that it selects a material

louist103 pushed a commit to louist103/oot that referenced this pull request Jan 3, 2023
* material

* cleanup

* iron boots

* climb

* more docs

* rename

* small fix

* comments

* adjust bug comment

* simplify comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants