diff --git a/src/spice2x/sdk/include/spicesdk.h b/src/spice2x/sdk/include/spicesdk.h index 3ad92065..8c5f5f2e 100644 --- a/src/spice2x/sdk/include/spicesdk.h +++ b/src/spice2x/sdk/include/spicesdk.h @@ -248,6 +248,27 @@ typedef SPICE_SDK_STATUS_CODE (__cdecl spice_sdk_insert_coin_func)( uint8_t amount ); +// get_coin_blocker (v0.6 and up) +// gets the current shared coin blocker state +// insert_coin bypasses the blocker regardless of this state +// +// blocked: receives true when coins are blocked, false when allowed + +typedef SPICE_SDK_STATUS_CODE (__cdecl spice_sdk_get_coin_blocker_func)( + bool *blocked +); + +// set_coin_blocker (v0.6 and up) +// sets the shared coin blocker state used by normal coin input +// this is not a persistent override; the game can change the state again +// insert_coin bypasses the blocker regardless of this state +// +// blocked: true to block coins, false to allow them + +typedef SPICE_SDK_STATUS_CODE (__cdecl spice_sdk_set_coin_blocker_func)( + bool blocked +); + typedef struct SPICE_SDK_MODULE_INFO { uint32_t size; // initialize to sizeof(SPICE_SDK_MODULE_INFO) uintptr_t base; // loaded address, not the preferred PE image base @@ -383,6 +404,9 @@ typedef struct SPICE_SDK_V0 { spice_sdk_hook_library_func *hook_library; + spice_sdk_get_coin_blocker_func *get_coin_blocker; + spice_sdk_set_coin_blocker_func *set_coin_blocker; + } SPICE_SDK_V0; typedef void (__cdecl spice_sdk_destroy_callback_func)( diff --git a/src/spice2x/sdk/sdk.cpp b/src/spice2x/sdk/sdk.cpp index e3294d1f..7de33423 100644 --- a/src/spice2x/sdk/sdk.cpp +++ b/src/spice2x/sdk/sdk.cpp @@ -36,6 +36,8 @@ static spice_sdk_insert_card_func sdk_insert_card; static spice_sdk_set_keypad_func sdk_set_keypad; static spice_sdk_add_toast_func sdk_add_toast; static spice_sdk_insert_coin_func sdk_insert_coin; +static spice_sdk_get_coin_blocker_func sdk_get_coin_blocker; +static spice_sdk_set_coin_blocker_func sdk_set_coin_blocker; static spice_sdk_get_module_info_func sdk_get_module_info; static spice_sdk_get_plugin_directory_func sdk_get_plugin_directory; static spice_sdk_register_d3d9_func sdk_register_d3d9; @@ -211,6 +213,14 @@ sdk_init( } // end of 0.5 + if (v0->size >= RTL_SIZEOF_THROUGH_FIELD(SPICE_SDK_V0, get_coin_blocker)) { + v0->get_coin_blocker = sdk_get_coin_blocker; + } + if (v0->size >= RTL_SIZEOF_THROUGH_FIELD(SPICE_SDK_V0, set_coin_blocker)) { + v0->set_coin_blocker = sdk_set_coin_blocker; + } + // end of 0.6 + // any newer minor iterations will need to check the size { @@ -746,4 +756,37 @@ sdk_insert_coin( return SPICE_SDK_STATUS_SUCCESS; } +SPICE_SDK_STATUS_CODE +__cdecl +sdk_get_coin_blocker( + bool *blocked +) +{ + std::shared_lock lock(sdk_global_mutex); + if (!sdk_initialized) { + return SPICE_SDK_STATUS_TOO_LATE; + } + if (!blocked) { + return SPICE_SDK_STATUS_INVALID_ARGUMENT_1; + } + + *blocked = eamuse_coin_get_block(); + return SPICE_SDK_STATUS_SUCCESS; +} + +SPICE_SDK_STATUS_CODE +__cdecl +sdk_set_coin_blocker( + bool blocked +) +{ + std::shared_lock lock(sdk_global_mutex); + if (!sdk_initialized) { + return SPICE_SDK_STATUS_TOO_LATE; + } + + eamuse_coin_set_block(blocked); + return SPICE_SDK_STATUS_SUCCESS; +} + } // namespace sdk \ No newline at end of file