63b6584706
* initial additions * Move current_blind to game vars * tmp * tmp * tmp * tmp * tmp * tmp * tmp * Compile but is broken * temp fix for token location * tmp * Working, lets clean up * remove todo * Remove odd reroll blind variable * fix skipping blind screen * fix reroll * remove magic for blind token locations * clang format * Cleanup button highlight in blind menu * some cleanup * Add layout file for global UI rects * remove dead code * Clang format * clang format it up * Move reset top left funct to gfx utils * make note of soon-to-be removed vars * Cleanup gamevars declaration * Cleanup layout file * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Add include for stdbool.h in common_ui.h * Cleanup rect declaration * Start moving state machine stuff to new file * quick tmp * oops, add new files * working call list * fixed pointer stuff * working as per norm * working replacement * move defines to static const * fix compile issue * Add some missing "void"s * Working new substates * add statemachine to blind select * Fix game restart statemachine leak * clang-format * Clang format * Rework shop exit logic * Use new state machine in shop * Remove substates entirely * Remove debug stuff * Clang format * document state machine better * update list tests * clang-format * Update for PR * Claaaaang format * another clang-format * Remove extra state in round_end * cleanup docs for removals in lists * clang-format... again * update doxygen format * Clang format * tmp * Update for Pr * clang-format * Cleanup for only supporting losing * bug fix, thanks logs! * Fix dangling pointer bug The control of removing statemachines may call issues if starting the function is done from another state machine call. To remedy this, add a flag to determine if a state machine is registered and return early instead of blindly removing it to re-add. * Fix bug with audio iterations possibly going in reverse * Remove extra includes * Clang-format * Add sound effects for game win/lose * adjust audio steps * tmp * Nice sounding and cleaned up * Fix and cleanup * clang-format * clang-format * clang format again --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
91 lines
2.1 KiB
C
91 lines
2.1 KiB
C
/**
|
|
* @file audio_utils.h
|
|
*
|
|
* @brief Utilities for using maxmod to play sound effects
|
|
*/
|
|
#ifndef AUDIO_UTILS_H
|
|
#define AUDIO_UTILS_H
|
|
|
|
#include "game_variables.h"
|
|
|
|
#include <mm_types.h>
|
|
|
|
/**
|
|
* @def MM_MODULE_FULL_VOLUME
|
|
* @brief The maximum volume for maxmod module volume (main theme)
|
|
*/
|
|
#define MM_MODULE_FULL_VOLUME 1024
|
|
|
|
/**
|
|
* @def MM_SFX_FULL_VOLUME
|
|
* @brief The maximum volume for maxmod mm_sound_effect.volume
|
|
*/
|
|
#define MM_SFX_FULL_VOLUME 255
|
|
|
|
/**
|
|
* @def MM_PAN_CENTER
|
|
* @brief The center pan of stereo audio for maxmod
|
|
*/
|
|
#define MM_PAN_CENTER 128
|
|
|
|
/**
|
|
* @def MM_BASE_PITCH_RATE
|
|
* @brief The default pitch rate for the sound effect played.
|
|
*
|
|
* Increasing the rate increases the pitch, while decreasing lowers the pitch.
|
|
*/
|
|
#define MM_BASE_PITCH_RATE 1024
|
|
|
|
/**
|
|
* @def SFX_DEFAULT_VOLUME
|
|
* @brief Default volume for sound effects
|
|
*/
|
|
#define SFX_DEFAULT_VOLUME MM_SFX_FULL_VOLUME
|
|
|
|
/**
|
|
* @def SFX_DEFAULT_PAN
|
|
* @brief The default stereo pan, will always be center pan.
|
|
*/
|
|
#define SFX_DEFAULT_PAN MM_PAN_CENTER
|
|
|
|
/**
|
|
* @def GBAL_MM_NUM_CHANNELS
|
|
* The number of audio channels to allocate for maxmod,
|
|
* passed to mmInitDefault()
|
|
*/
|
|
#define GBAL_MM_NUM_CHANNELS 14
|
|
|
|
/**
|
|
* @brief Play a sound effect, wrapper for mmEffectEx()
|
|
* See https://maxmod.org/ref/functions/mm_sound_effect.html
|
|
* and https://maxmod.org/ref/functions/mmEffectEx.html
|
|
*
|
|
* @param id the sound id to play, from maxmod compiled soundbank.h header
|
|
* @param rate the pitch rate, the default value is @ref MM_BASE_PTCH_RATE
|
|
* @param volume the volume ranging from 0 (silent) to 255 (loudest)
|
|
*/
|
|
void play_sfx(mm_word id, mm_word rate, mm_byte volume);
|
|
|
|
/**
|
|
* @brief Play music at a low pitch and slow tempo (lose screen)
|
|
*/
|
|
void play_lose_music(void);
|
|
|
|
/**
|
|
* @brief Play music at a normal pitch and tempo
|
|
*/
|
|
void play_regular_music(void);
|
|
|
|
void set_volume(int volume);
|
|
|
|
/**
|
|
* @brief Get MaxMod module audio value from VOLUME_OPTION value
|
|
* @param step VOLUME_OPTION between @ref VOLUME_OPTION_MIN and @ref VOLUME_OPTION_MAX
|
|
*/
|
|
inline int volume_module_step_to_val(unsigned char step)
|
|
{
|
|
return MM_MODULE_FULL_VOLUME * step / VOLUME_OPTION_MAX;
|
|
}
|
|
|
|
#endif
|