diff --git a/src/spice2x/acioemu/icca.cpp b/src/spice2x/acioemu/icca.cpp index 56fce06..4454177 100644 --- a/src/spice2x/acioemu/icca.cpp +++ b/src/spice2x/acioemu/icca.cpp @@ -2,6 +2,7 @@ #include "acio/icca/icca.h" #include "avs/game.h" +#include "games/sdvx/sdvx.h" #include "misc/eamuse.h" #include "util/logging.h" #include "util/utils.h" @@ -101,13 +102,10 @@ bool ICCADevice::parse_msg(MessageData *msg_in, // send version data auto msg = this->create_msg(msg_in, MSG_VERSION_SIZE); - if ( - avs::game::is_model({"LDJ", "TBS", "UJK", "XIF"}) || - // SDVX Valkyrie cabinet mode - (avs::game::is_model("KFC") && (avs::game::SPEC[0] == 'G' || avs::game::SPEC[0] == 'H')) - ) { + if (avs::game::is_model({"LDJ", "TBS", "UJK", "XIF"}) || + games::sdvx::is_valkyrie_model()) { this->set_version(msg, 0x3, 0, 1, 7, 0, "ICCA"); - } else if (avs::game::is_model({"VFG"})) { + } else if (avs::game::is_model("VFG")) { this->set_version(msg, 0x3, 0, 1, 7, 0, "ICCB"); } else { this->set_version(msg, 0x3, 0, 1, 6, 0, "ICCA"); @@ -520,11 +518,7 @@ void ICCADevice::update_status(int unit) { buffer[1] = felica ? 0x01 : 0x00; buffer[10] = felica ? 0x01 : 0x00; - } else if ( - avs::game::is_model({"LDJ", "TBS", "XIF"}) || - // SDVX Valkyrie cabinet mode - (avs::game::is_model("KFC") && (avs::game::SPEC[0] == 'G' || avs::game::SPEC[0] == 'H'))) { - + } else if (avs::game::is_model({"LDJ", "TBS", "XIF"}) || games::sdvx::is_valkyrie_model()) { // set status to 0 otherwise reader power on fails buffer[0] = 0x00; } else { diff --git a/src/spice2x/games/sdvx/sdvx.cpp b/src/spice2x/games/sdvx/sdvx.cpp index 802b51e..98525d0 100644 --- a/src/spice2x/games/sdvx/sdvx.cpp +++ b/src/spice2x/games/sdvx/sdvx.cpp @@ -2,7 +2,6 @@ #include -#include "avs/game.h" #include "games/shared/lcdhandle.h" #include "games/io.h" #include "hooks/audio/audio.h" @@ -331,9 +330,8 @@ namespace games::sdvx { } #ifdef SPICE64 // SDVX5+ specific code - this->VALKYRIE_MODEL = avs::game::SPEC[0] == 'G' || avs::game::SPEC[0] == 'H'; // check -monitor + UFC mode - if (!GRAPHICS_WINDOWED && D3D9_ADAPTER.has_value() && this->VALKYRIE_MODEL) { + if (!GRAPHICS_WINDOWED && D3D9_ADAPTER.has_value() && is_valkyrie_model()) { SHOW_VM_MONITOR_WARNING = true; log_warning( "sdvx", @@ -370,7 +368,7 @@ namespace games::sdvx { #ifdef SPICE64 // SDVX5+ specific code // LCD handle - if (!this->VALKYRIE_MODEL) { + if (!is_valkyrie_model()) { devicehook_init(); devicehook_add(new games::shared::LCDHandle()); } @@ -409,7 +407,7 @@ namespace games::sdvx { nvapi_hook::initialize(avs::game::DLL_INSTANCE); } - if (this->VALKYRIE_MODEL) { + if (is_valkyrie_model()) { // hook touch window // in windowed mode, game can accept mouse input on the second screen if (!NATIVETOUCH && !GRAPHICS_WINDOWED) { diff --git a/src/spice2x/games/sdvx/sdvx.h b/src/spice2x/games/sdvx/sdvx.h index f2ae34a..239371c 100644 --- a/src/spice2x/games/sdvx/sdvx.h +++ b/src/spice2x/games/sdvx/sdvx.h @@ -4,6 +4,7 @@ #include #include +#include "avs/game.h" #include "games/game.h" namespace games::sdvx { @@ -25,6 +26,13 @@ namespace games::sdvx { // states extern bool SHOW_VM_MONITOR_WARNING; + static inline bool is_valkyrie_model() { + return ( + avs::game::is_model("KFC") && + (avs::game::SPEC[0] == 'G' || avs::game::SPEC[0] == 'H') + ); + } + class SDVXGame : public games::Game { public: SDVXGame(); @@ -33,11 +41,6 @@ namespace games::sdvx { virtual void post_attach() override; virtual void detach() override; private: - // don't be tempted to make this into a public or a global variable - // various modules need to check if VM mode is active and they should - // not depend on the fact that SDVX module is active (since it can be - // inactive on cabs or partial I/O setup) - bool VALKYRIE_MODEL = false; void detect_sound_output_device(); }; } diff --git a/src/spice2x/hooks/graphics/backends/d3d9/d3d9_backend.cpp b/src/spice2x/hooks/graphics/backends/d3d9/d3d9_backend.cpp index 39abd11..00dba18 100644 --- a/src/spice2x/hooks/graphics/backends/d3d9/d3d9_backend.cpp +++ b/src/spice2x/hooks/graphics/backends/d3d9/d3d9_backend.cpp @@ -1362,9 +1362,7 @@ void graphics_d3d9_on_present( } // for IIDX TDJ / SDVX UFC, handle subscreen - const bool is_vm = - avs::game::is_model("KFC") && - (avs::game::SPEC[0] == 'G' || avs::game::SPEC[0] == 'H'); + const bool is_vm = games::sdvx::is_valkyrie_model(); const bool is_tdj = avs::game::is_model("LDJ") && games::iidx::TDJ_MODE; if (is_vm || is_tdj) { graphics_d3d9_ldj_on_present(wrapped_device); diff --git a/src/spice2x/hooks/lang.cpp b/src/spice2x/hooks/lang.cpp index 49fc073..47db9a3 100644 --- a/src/spice2x/hooks/lang.cpp +++ b/src/spice2x/hooks/lang.cpp @@ -10,6 +10,7 @@ #include "avs/game.h" #include "games/iidx/iidx.h" #include "games/gitadora/gitadora.h" +#include "games/sdvx/sdvx.h" #include "util/detour.h" #include "util/logging.h" #include "util/utils.h" @@ -220,8 +221,7 @@ void hooks::lang::early_init() { detour::trampoline_try("kernel32.dll", "GetOEMCP", GetOEMCP_hook, &GetOEMCP_orig); #ifdef SPICE64 // SDVX5+ specific code - bool isValkyrieCabinetMode = avs::game::SPEC[0] == 'G' || avs::game::SPEC[0] == 'H'; - if (avs::game::is_model("KFC") && isValkyrieCabinetMode) { + if (games::sdvx::is_valkyrie_model()) { log_info("hooks::lang", "hooking GetSystemDefaultLCID"); detour::trampoline_try( "kernel32.dll", diff --git a/src/spice2x/overlay/windows/sdvx_sub.cpp b/src/spice2x/overlay/windows/sdvx_sub.cpp index b730f32..a2e88fe 100644 --- a/src/spice2x/overlay/windows/sdvx_sub.cpp +++ b/src/spice2x/overlay/windows/sdvx_sub.cpp @@ -10,8 +10,7 @@ namespace overlay::windows { SDVXSubScreen::SDVXSubScreen(SpiceOverlay *overlay) : GenericSubScreen(overlay) { this->title = "SDVX Subscreen"; - bool isValkyrieCabinetMode = avs::game::SPEC[0] == 'G' || avs::game::SPEC[0] == 'H'; - if (!isValkyrieCabinetMode) { + if (!games::sdvx::is_valkyrie_model()) { this->disabled_message = "Valkyrie Model mode is not enabled!"; } else if (games::sdvx::SHOW_VM_MONITOR_WARNING) { this->disabled_message = "VM mode subscreen overlay is not compatible with -monitor option";