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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ s32 SurfaceType_CheckWallFlag2(CollisionContext* colCtx, CollisionPoly* poly, s3
u32 SurfaceType_GetFloorProperty(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u32 SurfaceType_IsSoft(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u32 SurfaceType_IsHorseBlocked(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
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

u32 SurfaceType_GetFloorEffect(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u32 SurfaceType_GetLightSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
Expand Down
1 change: 1 addition & 0 deletions include/sfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef struct {
#define DEFINE_SFX(enum, _1, _2, _3, _4) enum,

typedef enum {
NA_SE_NONE, // Requesting a sfx with this id will play no sound
NA_SE_PL_BASE = 0x7FF,
#include "tables/sfx/playerbank_table.h"
NA_SE_IT_BASE = 0x17FF,
Expand Down
51 changes: 35 additions & 16 deletions include/z64bgcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,41 @@ typedef enum {
} FloorProperty;

typedef enum {
/* 0 */ SURFACE_SFX_TYPE_0,
/* 1 */ SURFACE_SFX_TYPE_1,
/* 2 */ SURFACE_SFX_TYPE_2,
/* 3 */ SURFACE_SFX_TYPE_3,
/* 4 */ SURFACE_SFX_TYPE_4,
/* 5 */ SURFACE_SFX_TYPE_5,
/* 6 */ SURFACE_SFX_TYPE_6,
/* 7 */ SURFACE_SFX_TYPE_7,
/* 8 */ SURFACE_SFX_TYPE_8,
/* 9 */ SURFACE_SFX_TYPE_9,
/* 10 */ SURFACE_SFX_TYPE_10,
/* 11 */ SURFACE_SFX_TYPE_11,
/* 12 */ SURFACE_SFX_TYPE_12,
/* 13 */ SURFACE_SFX_TYPE_13,
/* 14 */ SURFACE_SFX_TYPE_MAX
} SurfaceSfxType;
/* 0 */ SURFACE_SFX_OFFSET_DIRT,
/* 1 */ SURFACE_SFX_OFFSET_SAND,
/* 2 */ SURFACE_SFX_OFFSET_STONE,
/* 3 */ SURFACE_SFX_OFFSET_JABU,
/* 4 */ SURFACE_SFX_OFFSET_WATER_SHALLOW,
/* 5 */ SURFACE_SFX_OFFSET_WATER_DEEP,
/* 6 */ SURFACE_SFX_OFFSET_TALL_GRASS,
/* 7 */ SURFACE_SFX_OFFSET_LAVA, // MAGMA?
/* 8 */ SURFACE_SFX_OFFSET_GRASS,
/* 9 */ SURFACE_SFX_OFFSET_CARPET,
/* 10 */ SURFACE_SFX_OFFSET_WOOD,
/* 11 */ SURFACE_SFX_OFFSET_BRIDGE, // WOOD_PLANK?
/* 12 */ SURFACE_SFX_OFFSET_VINE,
/* 13 */ SURFACE_SFX_OFFSET_IRON_BOOTS,
/* 14 */ SURFACE_SFX_OFFSET_UNUSED,
/* 15 */ SURFACE_SFX_OFFSET_ICE
} SurfaceSfxOffset;

typedef enum {
/* 0 */ SURFACE_MATERIAL_DIRT,
/* 1 */ SURFACE_MATERIAL_SAND,
/* 2 */ SURFACE_MATERIAL_STONE,
/* 3 */ SURFACE_MATERIAL_JABU,
/* 4 */ SURFACE_MATERIAL_WATER_SHALLOW,
/* 5 */ SURFACE_MATERIAL_WATER_DEEP,
/* 6 */ SURFACE_MATERIAL_TALL_GRASS,
/* 7 */ SURFACE_MATERIAL_LAVA, // MAGMA?
/* 8 */ SURFACE_MATERIAL_GRASS,
/* 9 */ SURFACE_MATERIAL_BRIDGE, // WOOD_PLANK?
/* 10 */ SURFACE_MATERIAL_WOOD,
/* 11 */ SURFACE_MATERIAL_DIRT_SOFT,
/* 12 */ SURFACE_MATERIAL_ICE,
/* 13 */ SURFACE_MATERIAL_CARPET,
/* 14 */ SURFACE_MATERIAL_MAX
} SurfaceMaterial;

typedef enum {
/* 0 */ FLOOR_EFFECT_0,
Expand Down
4 changes: 2 additions & 2 deletions include/z64player.h
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ typedef struct Player {
/* 0x0898 */ s16 unk_898;
/* 0x089A */ s16 unk_89A;
/* 0x089C */ s16 unk_89C;
/* 0x089E */ u16 unk_89E;
/* 0x089E */ u16 floorSfxOffset;
/* 0x08A0 */ u8 unk_8A0;
/* 0x08A1 */ u8 unk_8A1;
/* 0x08A2 */ s16 unk_8A2;
Expand All @@ -643,7 +643,7 @@ typedef struct Player {
/* 0x0A7B */ u8 unk_A7B;
/* 0x0A7C */ f32 unk_A7C;
/* 0x0A80 */ s16 unk_A80;
/* 0x0A82 */ u16 unk_A82;
/* 0x0A82 */ u16 prevFloorSfxOffset;
/* 0x0A84 */ s16 unk_A84;
/* 0x0A86 */ s8 unk_A86;
/* 0x0A87 */ u8 unk_A87;
Expand Down
25 changes: 14 additions & 11 deletions src/code/z_actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1701,20 +1701,20 @@ void Audio_PlayActorSfx2(Actor* actor, u16 sfxId) {
}

void func_8002F850(PlayState* play, Actor* actor) {
s32 sfxId;
s32 surfaceSfxOffset;

if (actor->bgCheckFlags & BGCHECKFLAG_WATER) {
if (actor->yDistToWater < 20.0f) {
sfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG;
surfaceSfxOffset = SURFACE_SFX_OFFSET_WATER_SHALLOW;
} else {
sfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG;
surfaceSfxOffset = SURFACE_SFX_OFFSET_WATER_DEEP;
}
} else {
sfxId = SurfaceType_GetSfxId(&play->colCtx, actor->floorPoly, actor->floorBgId);
surfaceSfxOffset = SurfaceType_GetSfxOffset(&play->colCtx, actor->floorPoly, actor->floorBgId);
}

func_80078914(&actor->projectedPos, NA_SE_EV_BOMB_BOUND);
func_80078914(&actor->projectedPos, sfxId + SFX_FLAG);
func_80078914(&actor->projectedPos, NA_SE_PL_WALK_GROUND + surfaceSfxOffset);
}

void func_8002F8F0(Actor* actor, u16 sfxId) {
Expand All @@ -1740,15 +1740,18 @@ void func_8002F974(Actor* actor, u16 sfxId) {
actor->sfx = sfxId;
}

void func_8002F994(Actor* actor, s32 arg1) {
void func_8002F994(Actor* actor, s32 timer) {
actor->flags |= ACTOR_FLAG_28;
actor->flags &= ~(ACTOR_FLAG_19 | ACTOR_FLAG_20 | ACTOR_FLAG_21);
if (arg1 < 40) {
actor->sfx = NA_SE_PL_WALK_DIRT - SFX_FLAG;
} else if (arg1 < 100) {
actor->sfx = NA_SE_PL_WALK_CONCRETE - SFX_FLAG;

// The sfx field is not used for an actual sound effect here.
// Instead, it controls the tick speed of the timer sound effect.
if (timer < 40) {
actor->sfx = 3;
} else if (timer < 100) {
actor->sfx = 2;
} else {
actor->sfx = NA_SE_PL_WALK_SAND - SFX_FLAG;
actor->sfx = 1;
}
}

Expand Down
42 changes: 21 additions & 21 deletions src/code/z_bgcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ s32 D_80119D90[WALL_TYPE_MAX] = {
WALL_FLAG_6, // WALL_TYPE_7
};

u16 D_80119E10[SURFACE_SFX_TYPE_MAX] = {
NA_SE_PL_WALK_GROUND - SFX_FLAG, // SURFACE_SFX_TYPE_0
NA_SE_PL_WALK_SAND - SFX_FLAG, // SURFACE_SFX_TYPE_1
NA_SE_PL_WALK_CONCRETE - SFX_FLAG, // SURFACE_SFX_TYPE_2
NA_SE_PL_WALK_DIRT - SFX_FLAG, // SURFACE_SFX_TYPE_3
NA_SE_PL_WALK_WATER0 - SFX_FLAG, // SURFACE_SFX_TYPE_4
NA_SE_PL_WALK_WATER1 - SFX_FLAG, // SURFACE_SFX_TYPE_5
NA_SE_PL_WALK_WATER2 - SFX_FLAG, // SURFACE_SFX_TYPE_6
NA_SE_PL_WALK_MAGMA - SFX_FLAG, // SURFACE_SFX_TYPE_7
NA_SE_PL_WALK_GRASS - SFX_FLAG, // SURFACE_SFX_TYPE_8
NA_SE_PL_WALK_GLASS - SFX_FLAG, // SURFACE_SFX_TYPE_9
NA_SE_PL_WALK_LADDER - SFX_FLAG, // SURFACE_SFX_TYPE_10
NA_SE_PL_WALK_GROUND - SFX_FLAG, // SURFACE_SFX_TYPE_11
NA_SE_PL_WALK_ICE - SFX_FLAG, // SURFACE_SFX_TYPE_12
NA_SE_PL_WALK_IRON - SFX_FLAG, // SURFACE_SFX_TYPE_13
u16 sSurfaceMaterialToSfxOffset[SURFACE_MATERIAL_MAX] = {
SURFACE_SFX_OFFSET_DIRT, // SURFACE_MATERIAL_DIRT
SURFACE_SFX_OFFSET_SAND, // SURFACE_MATERIAL_SAND
SURFACE_SFX_OFFSET_STONE, // SURFACE_MATERIAL_STONE
SURFACE_SFX_OFFSET_JABU, // SURFACE_MATERIAL_JABU
SURFACE_SFX_OFFSET_WATER_SHALLOW, // SURFACE_MATERIAL_WATER_SHALLOW
SURFACE_SFX_OFFSET_WATER_DEEP, // SURFACE_MATERIAL_WATER_DEEP
SURFACE_SFX_OFFSET_TALL_GRASS, // SURFACE_MATERIAL_TALL_GRASS
SURFACE_SFX_OFFSET_LAVA, // SURFACE_MATERIAL_LAVA
SURFACE_SFX_OFFSET_GRASS, // SURFACE_MATERIAL_GRASS
SURFACE_SFX_OFFSET_BRIDGE, // SURFACE_MATERIAL_BRIDGE
SURFACE_SFX_OFFSET_WOOD, // SURFACE_MATERIAL_WOOD
SURFACE_SFX_OFFSET_DIRT, // SURFACE_MATERIAL_DIRT_SOFT
SURFACE_SFX_OFFSET_ICE, // SURFACE_MATERIAL_ICE
SURFACE_SFX_OFFSET_CARPET, // SURFACE_MATERIAL_CARPET
};

/**
Expand Down Expand Up @@ -4111,17 +4111,17 @@ u32 SurfaceType_IsHorseBlocked(CollisionContext* colCtx, CollisionPoly* poly, s3
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 31 & 1;
}

u32 SurfaceType_GetSfxType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
u32 SurfaceType_GetMaterial(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 1) & 0xF;
}

u16 SurfaceType_GetSfxId(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
s32 sfxType = SurfaceType_GetSfxType(colCtx, poly, bgId);
u16 SurfaceType_GetSfxOffset(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
s32 surfaceMaterial = SurfaceType_GetMaterial(colCtx, poly, bgId);

if (sfxType < 0 || sfxType >= ARRAY_COUNT(D_80119E10)) {
return NA_SE_PL_WALK_GROUND - SFX_FLAG;
if ((surfaceMaterial < 0) || (surfaceMaterial >= ARRAY_COUNT(sSurfaceMaterialToSfxOffset))) {
return SURFACE_SFX_OFFSET_DIRT;
}
return D_80119E10[sfxType];
return sSurfaceMaterialToSfxOffset[surfaceMaterial];
}

u32 SurfaceType_GetFloorEffect(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
Expand Down
2 changes: 1 addition & 1 deletion src/code/z_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -4501,7 +4501,7 @@ s32 Camera_Subj4(Camera* camera) {
if ((eyeLerp > rwData->eyeLerp) && !rwData->isSfxOff) {
player = camera->player;
rwData->isSfxOff = true;
func_800F4010(&player->actor.projectedPos, NA_SE_PL_CRAWL + player->unk_89E, 4.0f);
func_800F4010(&player->actor.projectedPos, NA_SE_PL_CRAWL + player->floorSfxOffset, 4.0f);
} else if (eyeLerp < rwData->eyeLerp) {
rwData->isSfxOff = false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/code/z_collision_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,11 +1610,11 @@ s32 CollisionCheck_SwordHitAudio(Collider* at, ColliderInfo* acInfo) {
Audio_PlaySfxGeneral(NA_SE_IT_SWORD_STRIKE_HARD, &at->actor->projectedPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} else if (acInfo->elemType == ELEMTYPE_UNK2) {
Audio_PlaySfxGeneral(NA_SE_PL_WALK_GROUND - SFX_FLAG, &at->actor->projectedPos, 4,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
Audio_PlaySfxGeneral(NA_SE_NONE, &at->actor->projectedPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} else if (acInfo->elemType == ELEMTYPE_UNK3) {
Audio_PlaySfxGeneral(NA_SE_PL_WALK_GROUND - SFX_FLAG, &at->actor->projectedPos, 4,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
Audio_PlaySfxGeneral(NA_SE_NONE, &at->actor->projectedPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
}
}
return true;
Expand Down
3 changes: 1 addition & 2 deletions src/code/z_message_PAL.c
Original file line number Diff line number Diff line change
Expand Up @@ -3172,8 +3172,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

msgCtx->stateTimer = 0;
msgCtx->msgMode = MSGMODE_TEXT_BOX_GROWING;
}
Expand Down
6 changes: 3 additions & 3 deletions src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ void func_8088B79C(BgHidanRock* this, PlayState* play) {
}

Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND);
Audio_PlayActorSfx2(
&this->dyna.actor,
SurfaceType_GetSfxId(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + SFX_FLAG);
Audio_PlayActorSfx2(&this->dyna.actor,
NA_SE_PL_WALK_GROUND + SurfaceType_GetSfxOffset(&play->colCtx, this->dyna.actor.floorPoly,
this->dyna.actor.floorBgId));
}

this->unk_16C -= 0.5f;
Expand Down
4 changes: 2 additions & 2 deletions src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2465,7 +2465,7 @@ void BossGanon_HitByLightBall(BossGanon* this, PlayState* play) {
BossGanonEff_SpawnSparkle(play, &this->unk_1FC, &sp50, &sZeroVec, Rand_ZeroFloat(200.0f) + 500.0f,
0x14);
}
Audio_PlayActorSfx2(&this->actor, NA_SE_PL_WALK_WATER2);
Audio_PlayActorSfx2(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_TALL_GRASS);
}

if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) {
Expand Down Expand Up @@ -2647,7 +2647,7 @@ void BossGanon_Vulnerable(BossGanon* this, PlayState* play) {
0x14);
}

Audio_PlayActorSfx2(&this->actor, NA_SE_PL_WALK_WATER2);
Audio_PlayActorSfx2(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_TALL_GRASS);
this->timers[3] = 50;
}

Expand Down
4 changes: 2 additions & 2 deletions src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ void BossGanondrof_CollisionCheck(BossGanondrof* this, PlayState* play) {
}
if (this->flyMode != GND_FLY_PAINTING) {
if (acHit && (this->actionFunc != BossGanondrof_Stunned) && (hurtbox->toucher.dmgFlags & DMG_RANGED)) {
Audio_PlayActorSfx2(&this->actor, NA_SE_PL_WALK_GROUND - SFX_FLAG);
Audio_PlayActorSfx2(&this->actor, NA_SE_NONE);
osSyncPrintf("hit != 0 \n");
} else if (this->actionFunc != BossGanondrof_Charge) {
if (this->returnCount == 0) {
Expand Down Expand Up @@ -1270,7 +1270,7 @@ void BossGanondrof_CollisionCheck(BossGanondrof* this, PlayState* play) {
horse->hitTimer = 20;
Audio_PlayActorSfx2(&this->actor, NA_SE_EN_FANTOM_DAMAGE);
} else {
Audio_PlayActorSfx2(&this->actor, NA_SE_PL_WALK_GROUND - SFX_FLAG);
Audio_PlayActorSfx2(&this->actor, NA_SE_NONE);
}
} else if (acHit && (hurtbox->toucher.dmgFlags & DMG_RANGED)) {
this->work[GND_INVINC_TIMER] = 10;
Expand Down
Loading