diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b8ec2e..217bc8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake) option(WERROR "Build with warnings as errors" OFF) option(WASM "Build for WebAssembly" OFF) option(RGBDS_LIVE "Build for rgbds-live (Wasm only)" OFF) +option(GBSTUDIO "Build for GB Studio (Wasm only. Sets rgbds-live.)" OFF) if (MSVC) add_definitions(-W3 -D_CRT_SECURE_NO_WARNINGS) @@ -152,8 +153,12 @@ else (EMSCRIPTEN) target_compile_definitions(binjgb PUBLIC RGBDS_LIVE) endif () + if (GBSTUDIO) + # If GBSTUDIO is set, set RGBDS_LIVE too + target_compile_definitions(binjgb PUBLIC GBSTUDIO RGBDS_LIVE) + endif () + set(LINK_FLAGS - --memory-init-file 0 -s EXPORTED_FUNCTIONS=\"@${EXPORTED_JSON}\" -s MALLOC=emmalloc -s ASSERTIONS=0 diff --git a/src/emscripten/exported.json b/src/emscripten/exported.json index 0f79316..0b97ada 100644 --- a/src/emscripten/exported.json +++ b/src/emscripten/exported.json @@ -59,5 +59,6 @@ "_emulator_get_wram_ptr", "_emulator_get_hram_ptr", "_emulator_read_mem", -"_emulator_write_mem" +"_emulator_write_mem", +"_set_audio_channel_mute" ] diff --git a/src/emulator.c b/src/emulator.c index 7985bb7..0329ccf 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -5258,3 +5258,19 @@ void emulator_render_vram(Emulator* e, u32* buffer) {} void emulator_render_background(Emulator* e, u32* buffer, int type) {} #endif + +#ifdef GBSTUDIO +Bool set_audio_channel_mute(Emulator *e, int channel, Bool muted) { + EmulatorConfig emu_config = emulator_get_config(e); + emu_config.disable_sound[channel] = muted; + emulator_set_config(e, &emu_config); + return emu_config.disable_sound[channel]; +} + +#else // !GBSTUDIO + +Bool set_audio_channel_mute(Emulator *e, int channel, Bool muted) { + return FALSE; +} + +#endif