Initial re-upload of spice2x-24-08-24

This commit is contained in:
2024-08-28 11:10:34 -04:00
commit caa9e02285
1181 changed files with 380065 additions and 0 deletions

246
games/gitadora/gitadora.cpp Normal file
View File

@@ -0,0 +1,246 @@
#include "gitadora.h"
#include <unordered_map>
#include "cfg/configurator.h"
#include "hooks/graphics/graphics.h"
#include "util/cpuutils.h"
#include "util/detour.h"
#include "util/libutils.h"
#include "util/logging.h"
#include "util/sigscan.h"
namespace games::gitadora {
// settings
bool TWOCHANNEL = false;
std::optional<unsigned int> CAB_TYPE = std::nullopt;
/*
* GitaDora checks if the IP address has changed, and if it has it throws 5-1506-0000 like jubeat.
* We don't want this so we patch it out.
*/
static char __cdecl eam_network_detected_ip_change() {
return 0;
}
/*
* GitaDora checks if the server it connects to is in the 192.168.0.0/16 or 169.254.0.0/16 subnet.
* If it is, it downright refuses to use it and errors with no visible indication.
* We don't want this so we patch it out.
*/
static char __cdecl eam_network_settings_conflict() {
return 0;
}
/*
* Prevent GitaDora from changing the volume setting.
*/
static long __cdecl bmsd2_set_windows_volume(int volume) {
return 0;
}
#ifdef SPICE64
/*
* Two Channel Audio Mode
* We proxy bmsd2_boot_hook and modify the last parameter which is apparently the channel count.
* Since this apparently isn't the only thing required we need a signature scan to modify a value as well.
*/
typedef int (__cdecl *bmsd2_boot_t)(long a1, int a2, long a3, char channel_count);
static bmsd2_boot_t bmsd2_boot_orig = nullptr;
static int __cdecl bmsd2_boot_hook(long a1, int a2, long a3, char channel_count) {
return bmsd2_boot_orig(a1, a2, a3, 2);
}
#endif
/*
* Command Line Arguments
* We hook this to override specific values.
* This currently disables the ability to specify your own in the app-config.xml (param/cmdline __type="str")
*/
static bool __cdecl sys_code_get_cmdline(const char *cmdline) {
if (strcmp(cmdline, "-d") == 0) {
return true;
} else if (strcmp(cmdline, "-DM") == 0) {
return true;
} else if (strcmp(cmdline, "-WINDOW") == 0) {
return GRAPHICS_WINDOWED;
} else if (strcmp(cmdline, "-LOGOUT") == 0) {
return false;
} else if (strcmp(cmdline, "-AOU") == 0) {
return false;
} else if (strcmp(cmdline, "-QCMODE") == 0) {
return false;
} else if (strcmp(cmdline, "-FACTORY") == 0) {
return false;
}
return false;
}
/*
* System Setting Parameter Overrides
*/
static std::unordered_map<std::string, long> SYS_SETTINGS;
static std::unordered_map<std::string, long> SYS_DEBUG_DIPS;
static long __cdecl sys_setting_get_param(const char *param) {
// overrides
if (strcmp(param, "PRODUCTION_MODE") == 0) {
return 0;
} else if (strcmp(param, "ENABLE_DISP_ID") == 0) {
return 0;
} else if (CAB_TYPE.has_value() && strcmp(param, "VER_MACHINE") == 0) {
return CAB_TYPE.value() << 12;
}
// map lookup
auto it = SYS_SETTINGS.find(param);
if (it != SYS_SETTINGS.end()) {
return it->second;
}
return -1;
}
static long __cdecl sys_setting_set_param(const char *param, long value) {
SYS_SETTINGS[std::string(param)] = value;
return 1;
}
static long __cdecl sys_debug_dip_get_param(const char *param) {
// overrides
if (strcmp(param, "sysinfo") == 0) {
return 0;
} else if (strcmp(param, "jobbar1") == 0) {
return 0;
} else if (strcmp(param, "jobbar2") == 0) {
return 0;
} else if (strcmp(param, "serial") == 0) {
return 0;
} else if (strcmp(param, "warnvpf") == 0) {
return 0;
} else if (strcmp(param, "scrshot") == 0) {
return 0;
} else if (strcmp(param, "eamxml") == 0) {
return 0;
} else if (strcmp(param, "offset") == 0) {
return 0;
} else if (strcmp(param, "autodbg") == 0) {
return 0;
} else if (strcmp(param, "develop") == 0) {
return 0;
} else if (strcmp(param, "effect_test") == 0) {
return 0;
} else if (strcmp(param, "voice_type2") == 0) {
return 0;
}
// map lookup
auto it = SYS_DEBUG_DIPS.find(param);
if (it != SYS_DEBUG_DIPS.end()) {
return it->second;
}
return -1;
}
static long __cdecl sys_debug_dip_set_param(const char *param, long value) {
SYS_DEBUG_DIPS[std::string(param)] = value;
return 1;
}
GitaDoraGame::GitaDoraGame() : Game("GitaDora") {
}
void GitaDoraGame::pre_attach() {
Game::pre_attach();
if (!cfg::CONFIGURATOR_STANDALONE) {
if (CAB_TYPE.has_value()) {
log_info("gitadora", "cab type: {}", CAB_TYPE.value());
} else {
log_warning("gitadora", "cab type: not set");
}
log_info("gitadora", "applying processor affinity workaround to prevent hangs...");
#ifdef SPICE64
// workaround for hang on title screen, on systems with many SMT threads
// exact cause is unknown; most likely a bad assumption in some video decoder
// 0xFF (first 8 LPs) seems to work well for most people
cpuutils::set_processor_affinity(0xFF, false);
#else
// XG versions ran on ancient dual-core AMD systems
// having more cores cause random hangs on song select screen
cpuutils::set_processor_affinity(0x3, false);
// check invalid cab type
if (CAB_TYPE.has_value() && CAB_TYPE.value() == 3) {
log_fatal("gitadora", "Cabinet type 3 (SD2) not supported on XG series");
}
#endif
}
}
void GitaDoraGame::attach() {
Game::attach();
// modules
HMODULE sharepj_module = libutils::try_module("libshare-pj.dll");
HMODULE bmsd2_module = libutils::try_module("libbmsd2.dll");
HMODULE system_module = libutils::try_module("libsystem.dll");
// patches
detour::inline_hook((void *) eam_network_detected_ip_change, libutils::try_proc(
sharepj_module, "eam_network_detected_ip_change"));
detour::inline_hook((void *) eam_network_settings_conflict, libutils::try_proc(
sharepj_module, "eam_network_settings_conflict"));
detour::inline_hook((void *) bmsd2_set_windows_volume, libutils::try_proc(
bmsd2_module, "bmsd2_set_windows_volume"));
detour::inline_hook((void *) sys_code_get_cmdline, libutils::try_proc(
system_module, "sys_code_get_cmdline"));
detour::inline_hook((void *) sys_setting_get_param, libutils::try_proc(
system_module, "sys_setting_get_param"));
detour::inline_hook((void *) sys_setting_set_param, libutils::try_proc(
system_module, "sys_setting_set_param"));
detour::inline_hook((void *) sys_debug_dip_get_param, libutils::try_proc(
system_module, "sys_debug_dip_get_param"));
detour::inline_hook((void *) sys_debug_dip_set_param, libutils::try_proc(
system_module, "sys_debug_dip_set_param"));
#ifdef SPICE64
HMODULE gdme_module = libutils::try_module("libgdme.dll");
// window patch
if (GRAPHICS_WINDOWED && !replace_pattern(
gdme_module,
"754185ED753D8B4118BF0000CB02",
"9090????9090??????????????12", 0, 0))
{
log_warning("gitadora", "windowed mode failed");
}
HMODULE bmsd_engine_module = libutils::try_module("libbmsd-engine.dll");
HMODULE bmsd_module = libutils::try_module("libbmsd.dll");
// two channel mod
if (TWOCHANNEL) {
bmsd2_boot_orig = detour::iat_try("bmsd2_boot", bmsd2_boot_hook, bmsd_module);
if (!(replace_pattern(bmsd_engine_module, "33000000488D", "03??????????", 0, 0) ||
replace_pattern(bmsd_engine_module, "330000000F10", "03??????????", 0, 0)))
{
log_warning("gitadora", "two channel mode failed");
}
}
#endif
}
}

19
games/gitadora/gitadora.h Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include <optional>
#include "games/game.h"
namespace games::gitadora {
// settings
extern bool TWOCHANNEL;
extern std::optional<unsigned int> CAB_TYPE;
class GitaDoraGame : public games::Game {
public:
GitaDoraGame();
virtual void pre_attach() override;
virtual void attach() override;
};
}

197
games/gitadora/io.cpp Normal file
View File

@@ -0,0 +1,197 @@
#include "io.h"
std::vector<Button> &games::gitadora::get_buttons() {
static std::vector<Button> buttons;
if (buttons.empty()) {
buttons = GameAPI::Buttons::getButtons("GitaDora");
GameAPI::Buttons::sortButtons(&buttons,
"Service",
"Test",
"Coin",
"Guitar P1 Start",
"Guitar P1 Up",
"Guitar P1 Down",
"Guitar P1 Left",
"Guitar P1 Right",
"Guitar P1 Help",
"Guitar P1 Effect 1",
"Guitar P1 Effect 2",
"Guitar P1 Effect 3",
"Guitar P1 Effect Pedal",
"Guitar P1 Button Extra 1",
"Guitar P1 Button Extra 2",
"Guitar P1 Pick Up",
"Guitar P1 Pick Down",
"Guitar P1 R",
"Guitar P1 G",
"Guitar P1 B",
"Guitar P1 Y",
"Guitar P1 P",
"Guitar P1 Knob Up",
"Guitar P1 Knob Down",
"Guitar P1 Wail Up",
"Guitar P1 Wail Down",
"Guitar P2 Start",
"Guitar P2 Up",
"Guitar P2 Down",
"Guitar P2 Left",
"Guitar P2 Right",
"Guitar P2 Help",
"Guitar P2 Effect 1",
"Guitar P2 Effect 2",
"Guitar P2 Effect 3",
"Guitar P2 Effect Pedal",
"Guitar P2 Button Extra 1",
"Guitar P2 Button Extra 2",
"Guitar P2 Pick Up",
"Guitar P2 Pick Down",
"Guitar P2 R",
"Guitar P2 G",
"Guitar P2 B",
"Guitar P2 Y",
"Guitar P2 P",
"Guitar P2 Knob Up",
"Guitar P2 Knob Down",
"Guitar P2 Wail Up",
"Guitar P2 Wail Down",
"Drum Start",
"Drum Up",
"Drum Down",
"Drum Left",
"Drum Right",
"Drum Help",
"Drum Button Extra 1",
"Drum Button Extra 2",
"Drum Hi-Hat",
"Drum Hi-Hat Closed",
"Drum Hi-Hat Half-Open",
"Drum Snare",
"Drum Hi-Tom",
"Drum Low-Tom",
"Drum Right Cymbal",
"Drum Bass Pedal",
"Drum Left Cymbal",
"Drum Left Pedal",
"Drum Floor Tom"
);
}
return buttons;
}
std::vector<Analog> &games::gitadora::get_analogs() {
static std::vector<Analog> analogs;
if (analogs.empty()) {
analogs = GameAPI::Analogs::getAnalogs("GitaDora");
GameAPI::Analogs::sortAnalogs(&analogs,
"Guitar P1 Wail X",
"Guitar P1 Wail Y",
"Guitar P1 Wail Z",
"Guitar P1 Knob",
"Guitar P2 Wail X",
"Guitar P2 Wail Y",
"Guitar P2 Wail Z",
"Guitar P2 Knob"
);
}
return analogs;
}
std::vector<Light> &games::gitadora::get_lights() {
static std::vector<Light> lights;
if (lights.empty()) {
lights = GameAPI::Lights::getLights("GitaDora");
GameAPI::Lights::sortLights(&lights,
"Guitar P1 Motor",
"Guitar P2 Motor",
"P1 Start",
"P1 Menu Up Down (DX)",
"P1 Menu Left Right (DX)",
"P1 Help (DX)",
"P2 Start",
"P2 Menu Up Down (DX)",
"P2 Menu Left Right (DX)",
"P2 Help (DX)",
"Drum Left Cymbal",
"Drum Hi-Hat",
"Drum Snare",
"Drum High Tom",
"Drum Low Tom",
"Drum Floor Tom",
"Drum Right Cymbal",
"Drum Woofer R",
"Drum Woofer G",
"Drum Woofer B",
"Drum Stage R (DX)",
"Drum Stage G (DX)",
"Drum Stage B (DX)",
"Spot Left (DX)",
"Spot Right (DX)",
"Spot Center Left (DX)",
"Spot Center Right (DX)",
"Drum Spot Rear Left (DX)",
"Drum Spot Rear Right (DX)",
"Guitar Lower Left R (DX)",
"Guitar Lower Left G (DX)",
"Guitar Lower Left B (DX)",
"Guitar Lower Right R (DX)",
"Guitar Lower Right G (DX)",
"Guitar Lower Right B (DX)",
"Guitar Left Speaker Upper R (DX)",
"Guitar Left Speaker Upper G (DX)",
"Guitar Left Speaker Upper B (DX)",
"Guitar Left Speaker Mid Up Left R (DX)",
"Guitar Left Speaker Mid Up Left G (DX)",
"Guitar Left Speaker Mid Up Left B (DX)",
"Guitar Left Speaker Mid Up Right R (DX)",
"Guitar Left Speaker Mid Up Right G (DX)",
"Guitar Left Speaker Mid Up Right B (DX)",
"Guitar Left Speaker Mid Low Left R (DX)",
"Guitar Left Speaker Mid Low Left G (DX)",
"Guitar Left Speaker Mid Low Left B (DX)",
"Guitar Left Speaker Mid Low Right R (DX)",
"Guitar Left Speaker Mid Low Right G (DX)",
"Guitar Left Speaker Mid Low Right B (DX)",
"Guitar Left Speaker Lower R (DX)",
"Guitar Left Speaker Lower G (DX)",
"Guitar Left Speaker Lower B (DX)",
"Guitar Right Speaker Upper R (DX)",
"Guitar Right Speaker Upper G (DX)",
"Guitar Right Speaker Upper B (DX)",
"Guitar Right Speaker Mid Up Left R (DX)",
"Guitar Right Speaker Mid Up Left G (DX)",
"Guitar Right Speaker Mid Up Left B (DX)",
"Guitar Right Speaker Mid Up Right R (DX)",
"Guitar Right Speaker Mid Up Right G (DX)",
"Guitar Right Speaker Mid Up Right B (DX)",
"Guitar Right Speaker Mid Low Left R (DX)",
"Guitar Right Speaker Mid Low Left G (DX)",
"Guitar Right Speaker Mid Low Left B (DX)",
"Guitar Right Speaker Mid Low Right R (DX)",
"Guitar Right Speaker Mid Low Right G (DX)",
"Guitar Right Speaker Mid Low Right B (DX)",
"Guitar Right Speaker Lower R (DX)",
"Guitar Right Speaker Lower G (DX)",
"Guitar Right Speaker Lower B (DX)"
);
}
return lights;
}

200
games/gitadora/io.h Normal file
View File

@@ -0,0 +1,200 @@
#pragma once
#include <vector>
#include "cfg/api.h"
namespace games::gitadora {
// all buttons in correct order
namespace Buttons {
enum {
Service,
Test,
Coin,
GuitarP1Start,
GuitarP1Up,
GuitarP1Down,
GuitarP1Left,
GuitarP1Right,
GuitarP1Help,
GuitarP1Effect1,
GuitarP1Effect2,
GuitarP1Effect3,
GuitarP1EffectPedal,
GuitarP1ButtonExtra1,
GuitarP1ButtonExtra2,
GuitarP1PickUp,
GuitarP1PickDown,
GuitarP1R,
GuitarP1G,
GuitarP1B,
GuitarP1Y,
GuitarP1P,
GuitarP1KnobUp,
GuitarP1KnobDown,
GuitarP1WailUp,
GuitarP1WailDown,
GuitarP2Start,
GuitarP2Up,
GuitarP2Down,
GuitarP2Left,
GuitarP2Right,
GuitarP2Help,
GuitarP2Effect1,
GuitarP2Effect2,
GuitarP2Effect3,
GuitarP2EffectPedal,
GuitarP2ButtonExtra1,
GuitarP2ButtonExtra2,
GuitarP2PickUp,
GuitarP2PickDown,
GuitarP2R,
GuitarP2G,
GuitarP2B,
GuitarP2Y,
GuitarP2P,
GuitarP2KnobUp,
GuitarP2KnobDown,
GuitarP2WailUp,
GuitarP2WailDown,
DrumStart,
DrumUp,
DrumDown,
DrumLeft,
DrumRight,
DrumHelp,
DrumButtonExtra1,
DrumButtonExtra2,
DrumHiHat,
DrumHiHatClosed,
DrumHiHatHalfOpen,
DrumSnare,
DrumHiTom,
DrumLowTom,
DrumRightCymbal,
DrumBassPedal,
DrumLeftCymbal,
DrumLeftPedal,
DrumFloorTom
};
}
// all analogs in correct order
namespace Analogs {
enum {
GuitarP1WailX,
GuitarP1WailY,
GuitarP1WailZ,
GuitarP1Knob,
GuitarP2WailX,
GuitarP2WailY,
GuitarP2WailZ,
GuitarP2Knob
};
}
// all lights in correct order
namespace Lights {
typedef enum {
// vibration motors (DX only)
GuitarP1Motor,
GuitarP2Motor,
// P1
P1MenuStart,
// DX only
P1MenuUpDown,
P1MenuLeftRight,
P1MenuHelp,
// P2
P2MenuStart,
// DX only
P2MenuUpDown,
P2MenuLeftRight,
P2MenuHelp,
// drums
DrumLeftCymbal,
DrumHiHat,
DrumSnare,
DrumHighTom,
DrumLowTom,
DrumFloorTom,
DrumRightCymbal,
// drum woofer
DrumWooferR,
DrumWooferG,
DrumWooferB,
// drum stage, DX only
DrumStageR,
DrumStageG,
DrumStageB,
// main spotlights, DX only
SpotFrontLeft,
SpotFrontRight,
SpotCenterLeft,
SpotCenterRight,
// drum rear spotlights, DX only
DrumSpotRearLeft,
DrumSpotRearRight,
// guitar center lower RGB, DX only
GuitarLowerLeftR,
GuitarLowerLeftG,
GuitarLowerLeftB,
GuitarLowerRightR,
GuitarLowerRightG,
GuitarLowerRightB,
// guitar left speaker, DX only
GuitarLeftSpeakerUpperR,
GuitarLeftSpeakerUpperG,
GuitarLeftSpeakerUpperB,
GuitarLeftSpeakerMidUpLeftR,
GuitarLeftSpeakerMidUpLeftG,
GuitarLeftSpeakerMidUpLeftB,
GuitarLeftSpeakerMidUpRightR,
GuitarLeftSpeakerMidUpRightG,
GuitarLeftSpeakerMidUpRightB,
GuitarLeftSpeakerMidLowLeftR,
GuitarLeftSpeakerMidLowLeftG,
GuitarLeftSpeakerMidLowLeftB,
GuitarLeftSpeakerMidLowRightR,
GuitarLeftSpeakerMidLowRightG,
GuitarLeftSpeakerMidLowRightB,
GuitarLeftSpeakerLowerR,
GuitarLeftSpeakerLowerG,
GuitarLeftSpeakerLowerB,
// guitar right speaker, DX only
GuitarRightSpeakerUpperR,
GuitarRightSpeakerUpperG,
GuitarRightSpeakerUpperB,
GuitarRightSpeakerMidUpLeftR,
GuitarRightSpeakerMidUpLeftG,
GuitarRightSpeakerMidUpLeftB,
GuitarRightSpeakerMidUpRightR,
GuitarRightSpeakerMidUpRightG,
GuitarRightSpeakerMidUpRightB,
GuitarRightSpeakerMidLowLeftR,
GuitarRightSpeakerMidLowLeftG,
GuitarRightSpeakerMidLowLeftB,
GuitarRightSpeakerMidLowRightR,
GuitarRightSpeakerMidLowRightG,
GuitarRightSpeakerMidLowRightB,
GuitarRightSpeakerLowerR,
GuitarRightSpeakerLowerG,
GuitarRightSpeakerLowerB
} gitadora_lights_t;
}
// getters
std::vector<Button> &get_buttons();
std::vector<Analog> &get_analogs();
std::vector<Light> &get_lights();
}