Files
HackerOoT/include/sfx.h
Yanis aa0341f97b Merge decomp/main (#141)
* Match retail BSS ordering (#1927)

* Match retail BSS ordering

* Revert moving some global variables to headers

* Adjust block numbers after header changes

* Fix debug build

* Overlay bss ordering

* Fix BSS ordering after header changes

* gc-eu-mq OK

* Implement preprocessor for #pragma increment_block_number

* Transfer usage comment from reencode.sh

* Use temporary directory instead of temporary file

* Move ColChkMassType back

* Player: Document "WaitForPutAway"  (#1936)

* document put away delay

* functions.txt

* add a note on delaying indefinitely

* format

* typo

* delay -> wait for put away

* revert unintended formatting change

* add comment to struct member

* format

* fix functions.txt

* Set up gc-eu and match all code (#1938)

* Set up gc-eu and match all code

* Format

* Mark gc-eu-mq as WIP until it builds OK

* Move original/MQ map mark data to separate files

* Add #includes to .inc.c files to help out VS Code

* Use #if in spec instead of .inc.c files

* Delete disassembly data for gc-eu-mq (#1942)

* Player Docs: "sUpperBodyIsBusy" (#1944)

* document upperbodybusy

* change wording for comment and rename upperanimblendweight

* format

* review

* Fix miscategorized scenes (#1946)

* Fix miscategorized scenes

* Sort includes

* Player Docs: Action Interrupt (#1947)

* document action interrupt

* format

* new function comment

* format

* add a note about items

* format

* Add gc-eu-mq to CI (#1943)

* Add gc-eu-mq to CI

* Give up on scripting

* Revert quotes changes

* Player Docs: Name some high level update calls (#1593)

* name some low hanging fruit

* revert burn and shock, doing in seperate pr

* add some function comments

* yaw func

* adjust comment

* some review

* unname UpdateZTarget

* Player_DetectRumbleSecrets

* fix dive do action name

* Player Docs: Control stick buffers (#1945)

* name vars and add enum

* name some spin attack stuff

* fix right and left

* forward/backward

* format

* fix retail bss

* sControlStickWorldYaw

* Force string.o to be in boot for gcc builds (#1948)

In retail builds, memcpy is linked in code, not boot, but GCC likes to call memcpy when copying structs so currently GCC builds immediately crash in __osInitialize_common.

* Rename yDistToWater -> depthInWater (#1950)

* Rename yDistToWater -> yDistUnderWater

* yDistUnderWater -> depthInWater

* Check baserom hash before decompression (#1952)

* Remove Cygwin support (#1951)

* Document pause page switching (#1550)

* Document pause page switching

* document initial scroll left setup, when opening the pause menu

* `PAUSE_MAIN_STATE_1` -> `PAUSE_MAIN_STATE_SWITCHING_PAGE`

* try a diagram of the pages layout in world space as a comment

* expand `nextPageMode` comment

* touch up pause camera header comments

* expand comment on irrelevant init `mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE`

* expand doc on `sKaleidoSetup*` data

* expand docs on `gPageSwitchNextButtonStatus`

* add some doc on `sPageSwitch*` arrays

* SwitchPage -> PageSwitch

* add `PAGE_SWITCH_NSTEPS`

* `SWITCH_PAGE_*_PT` -> `PAGE_SWITCH_PT_*`

* peepoArtist

---------

Co-authored-by: fig02 <fig02srl@gmail.com>

* Fix LensMode Enum Names (#1954)

* Change linker script so gGameOverTimer can be in z_game_over.c (#1939)

* Change linker script so gGameOverTimer can be in z_game_over.c

* gGameOverTimer -> sGameOverTimer

* include_data_only_with_rodata -> include_data_only_within_rodata

* fix build issues

* Check buffers segment in check_ordering.py (#1960)

* Delete unused yaz0tool (#1959)

* Revamp "AnimationContext" Docs, now called "AnimTaskQueue" (#1941)

* start using task terminology

* more docs

* format

* cleanups

* MoveActor -> ActorMove

* missed a couple

* hopefully the last changes

* comment explaining the group change

* some review

* dragorn review

* remove accidental file

* fix matching issue, now use while loop

* Experiment: remove global.h dependency from sys_math, sys_math3d, z_lib (#1956)

* split sys_math, sys_math3d, z_lib from global.h

* suggestions

* forgot this

* more math stuff

* nit fix

* re-add ichain.h

* resolve tharo's comments

* Fix check_ordering.py checking for shifted/nonmatching-besides-relocs (#1961)

* Run CC_CHECK with the correct CPP defines (#1963)

* Run CC_CHECK with the correct CPP defines

* Add "CPP_DEFINES ?="

---------

Co-authored-by: cadmic <cadmic24@gmail.com>
Co-authored-by: fig02 <fig02srl@gmail.com>
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Co-authored-by: inspectredc <78732756+inspectredc@users.noreply.github.com>
Co-authored-by: mzxrules <mzxrules@gmail.com>
2024-06-22 22:36:26 +02:00

152 lines
4.0 KiB
C

#ifndef SFX_H
#define SFX_H
typedef enum {
/* 0 */ BANK_PLAYER,
/* 1 */ BANK_ITEM,
/* 2 */ BANK_ENV,
/* 3 */ BANK_ENEMY,
/* 4 */ BANK_SYSTEM,
/* 5 */ BANK_OCARINA,
/* 6 */ BANK_VOICE
} SfxBankType;
typedef enum {
/* 0 */ SFX_STATE_EMPTY,
/* 1 */ SFX_STATE_QUEUED,
/* 2 */ SFX_STATE_READY,
/* 3 */ SFX_STATE_PLAYING_REFRESH,
/* 4 */ SFX_STATE_PLAYING_1,
/* 5 */ SFX_STATE_PLAYING_2
} SfxState;
typedef struct {
/* 0x00 */ f32* posX;
/* 0x04 */ f32* posY;
/* 0x08 */ f32* posZ;
/* 0x0C */ u8 token;
/* 0x10 */ f32* freqScale;
/* 0x14 */ f32* vol;
/* 0x18 */ s8* reverbAdd;
/* 0x1C */ f32 dist;
/* 0x20 */ u32 priority; // lower is more prioritized
/* 0x24 */ u8 sfxImportance;
/* 0x26 */ u16 sfxParams;
/* 0x28 */ u16 sfxId;
/* 0x2A */ u8 state; // uses SfxState enum
/* 0x2B */ u8 freshness;
/* 0x2C */ u8 prev;
/* 0x2D */ u8 next;
/* 0x2E */ u8 channelIndex;
/* 0x2F */ u8 unk_2F;
} SfxBankEntry; // size = 0x30
/*
* SFX IDs
*
* index 0000000111111111 observed in audio code
* & 200 0000001000000000 single bit
* & 400 0000010000000000 single bit
* & 800 0000100000000000 single bit, what we currently call SFX_FLAG
* & 600 0000011000000000 2 bits
* & A00 0000101000000000 2 bits
* & C00 0000110000000000 2 bits, observed in audio code
* & E00 0000111000000000 all 3 bits
* bank 1111000000000000 observed in audio code
*/
#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,
#include "tables/sfx/itembank_table.h"
NA_SE_EV_BASE = 0x27FF,
#include "tables/sfx/environmentbank_table.h"
NA_SE_EN_BASE = 0x37FF,
#include "tables/sfx/enemybank_table.h"
NA_SE_SY_BASE = 0x47FF,
#include "tables/sfx/systembank_table.h"
NA_SE_OC_BASE = 0x57FF,
#include "tables/sfx/ocarinabank_table.h"
NA_SE_VO_BASE = 0x67FF,
#include "tables/sfx/voicebank_table.h"
NA_SE_MAX
} SfxId;
#undef DEFINE_SFX
#define SFX_BANK_SHIFT(sfxId) (((sfxId) >> 12) & 0xFF)
#define SFX_BANK_MASK(sfxId) ((sfxId) & 0xF000)
#define SFX_INDEX(sfxId) ((sfxId) & 0x01FF)
#define SFX_BANK(sfxId) SFX_BANK_SHIFT(SFX_BANK_MASK(sfxId))
#define SFX_FLAG 0x800
typedef struct {
u32 priority; // lower is more prioritized
u8 entryIndex;
} ActiveSfx;
// SfxParams bit-packing
#define SFX_PARAM_01_SHIFT 0
#define SFX_PARAM_01_MASK (3 << SFX_PARAM_01_SHIFT)
#define SFX_FLAG_2 (1 << 2)
#define SFX_FLAG_3 (1 << 3)
#define SFX_FLAG_4 (1 << 4)
#define SFX_FLAG_5 (1 << 5)
#define SFX_PARAM_67_SHIFT 6
#define SFX_PARAM_67_MASK (3 << SFX_PARAM_67_SHIFT)
#define SFX_FLAG_9 (1 << 9)
#define SFX_FLAG_10_SHIFT 10
#define SFX_FLAG_10 (1 << SFX_FLAG_10_SHIFT)
#define SFX_FLAG_11 (1 << 11)
#define SFX_FLAG_12 (1 << 12)
#define SFX_FLAG_13 (1 << 13)
#define SFX_FLAG_14 (1 << 14)
#define SFX_FLAG_15 (1 << 15)
typedef struct {
u8 importance;
u16 params;
} SfxParams;
#if IS_DEBUG
#define SFX_DIST_SCALING 1.0f
#else
#define SFX_DIST_SCALING 10.0f
#endif
void Audio_SetSfxBanksMute(u16 muteMask);
void Audio_QueueSeqCmdMute(u8 channelIndex);
void Audio_ClearBGMMute(u8 channelIndex);
void Audio_PlaySfxGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* vol, s8* reverbAdd);
void Audio_ProcessSfxRequest(void);
void Audio_ChooseActiveSfx(u8 bankId);
void Audio_PlayActiveSfx(u8 bankId);
void Audio_StopSfxByBank(u8 bankId);
void func_800F8884(u8 bankId, Vec3f* pos);
void Audio_StopSfxByPosAndBank(u8 bankId, Vec3f* pos);
void Audio_StopSfxByPos(Vec3f* pos);
void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId);
void Audio_StopSfxByTokenAndId(u8 token, u16 sfxId);
void Audio_StopSfxById(u32 sfxId);
void Audio_ProcessSfxRequests(void);
void func_800F8F88(void);
u8 Audio_IsSfxPlaying(u32 sfxId);
void Audio_ResetSfx(void);
extern Vec3f gSfxDefaultPos;
extern f32 gSfxDefaultFreqAndVolScale;
extern s8 gSfxDefaultReverb;
#endif