diff --git a/src/decomp/shim.h b/src/decomp/shim.h index c0df3ab..11c762e 100644 --- a/src/decomp/shim.h +++ b/src/decomp/shim.h @@ -4,6 +4,7 @@ #include "game/area.h" #include "game/level_update.h" #include "../libsm64.h" +#include "../play_sound.h" #include "global_state.h" #define COURSE_MIN 0 @@ -36,7 +37,6 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" -static void play_sound(s32 soundBits, f32 *pos) {} static void enable_time_stop() {} static void disable_time_stop() {} static void *segmented_to_virtual(const void *addr) { return (void*)addr; } diff --git a/src/libsm64.c b/src/libsm64.c index 6cd4c5b..f83013c 100644 --- a/src/libsm64.c +++ b/src/libsm64.c @@ -85,6 +85,13 @@ SM64_LIB_FN void sm64_register_debug_print_function( SM64DebugPrintFunctionPtr d g_debug_print_func = debugPrintFunction; } +typedef void (*SM64PlaySoundFunctionPtr)( uint32_t soundBits, f32 *pos ); +SM64_LIB_FN void sm64_register_play_sound_function( SM64PlaySoundFunctionPtr playSoundFunction ) +{ + g_play_sound_func = playSoundFunction; +} + + SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture ) { if( s_init_global ) diff --git a/src/libsm64.h b/src/libsm64.h index ccb3916..51f6b44 100644 --- a/src/libsm64.h +++ b/src/libsm64.h @@ -5,6 +5,8 @@ #include #include +#include "decomp/include/types.h" + #ifdef _WIN32 #ifdef SM64_LIB_EXPORT #define SM64_LIB_FN __declspec(dllexport) @@ -67,9 +69,14 @@ enum SM64_GEO_MAX_TRIANGLES = 1024, }; + typedef void (*SM64DebugPrintFunctionPtr)( const char * ); extern SM64_LIB_FN void sm64_register_debug_print_function( SM64DebugPrintFunctionPtr debugPrintFunction ); +typedef void (*SM64PlaySoundFunctionPtr)( uint32_t soundBits, f32 *pos ); +extern SM64_LIB_FN void sm64_register_play_sound_function( SM64PlaySoundFunctionPtr playSoundFunction ); + + extern SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture ); extern SM64_LIB_FN void sm64_global_terminate( void ); diff --git a/src/play_sound.c b/src/play_sound.c new file mode 100644 index 0000000..0560ba3 --- /dev/null +++ b/src/play_sound.c @@ -0,0 +1,9 @@ +#include "play_sound.h" + +SM64PlaySoundFunctionPtr g_play_sound_func = NULL; + +extern void play_sound( uint32_t soundBits, f32 *pos ) { + if ( g_play_sound_func ) { + g_play_sound_func(soundBits, pos); + } +} \ No newline at end of file diff --git a/src/play_sound.h b/src/play_sound.h new file mode 100644 index 0000000..ab486b3 --- /dev/null +++ b/src/play_sound.h @@ -0,0 +1,9 @@ +#pragma once + +#include "decomp/include/types.h" +#include "libsm64.h" +#include + +extern SM64PlaySoundFunctionPtr g_play_sound_func; + +extern void play_sound( uint32_t soundBits, f32 *pos ); \ No newline at end of file