ddr: automatically register codecs on launch (#351)

## Link to GitHub Issue, if one exists
#345 

## Description of change
On launch of spice.exe / spice64.exe, call `regsvr32` on known codecs in
the `com` directory.

Add an option to skip this (`-ddrnocodec`) as a chicken bit.

## Testing
Tested 32 and 64 bit DDR.
This commit is contained in:
bicarus-dev
2025-08-09 20:53:09 -07:00
committed by GitHub
parent 1ad45edd6e
commit f6b63473a0
5 changed files with 66 additions and 0 deletions
+49
View File
@@ -27,6 +27,7 @@ namespace games::ddr {
// settings // settings
bool SDMODE = false; bool SDMODE = false;
bool NO_CODEC_REGISTRATION = false;
uint8_t DDR_TAPELEDS[TAPELED_DEVICE_COUNT][50][3] {}; uint8_t DDR_TAPELEDS[TAPELED_DEVICE_COUNT][50][3] {};
@@ -52,6 +53,50 @@ namespace games::ddr {
DDRGame::DDRGame() : Game("Dance Dance Revolution") { DDRGame::DDRGame() : Game("Dance Dance Revolution") {
} }
void DDRGame::register_codecs() {
// find where spice.exe / spice64.exe is located
const auto &spice_bin_path = libutils::module_file_name(nullptr).parent_path();
// find the com directory
std::filesystem::path dir = "";
if (MODULE_PATH == spice_bin_path) {
// try: \com
dir = spice_bin_path / "com";
} else {
// try: modules\..\com
dir = MODULE_PATH / ".." / "com";
}
if (fileutils::dir_exists(dir)) {
log_info("ddr", "looking for codecs in this directory: {}", dir.string());
} else {
log_info("ddr", "codecs directory not found: {}", dir.string());
return;
}
for (const auto &file : std::filesystem::directory_iterator(dir)) {
const auto &filename = file.path().filename();
const auto extension = strtolower(filename.extension().string());
if (extension != ".dll") {
continue;
}
log_info("ddr", "found DLL: {}", filename.string());
if (filename == "k-clvsd.dll" || filename.string().find("xactengine") == 0) {
const std::string cmd = "regsvr32.exe /s " + file.path().string();
int result = 0;
std::thread t([cmd, &result]() {
result = system(cmd.c_str());
});
t.join();
log_info("ddr", "`{}` returned {}", cmd, result);
}
}
}
void DDRGame::pre_attach() { void DDRGame::pre_attach() {
if (!cfg::CONFIGURATOR_STANDALONE && avs::game::is_model("TDX")) { if (!cfg::CONFIGURATOR_STANDALONE && avs::game::is_model("TDX")) {
log_fatal( log_fatal(
@@ -87,6 +132,10 @@ namespace games::ddr {
"!!! !!!\n\n\n" "!!! !!!\n\n\n"
); );
} }
if (!cfg::CONFIGURATOR_STANDALONE && !NO_CODEC_REGISTRATION) {
this->register_codecs();
}
} }
void DDRGame::attach() { void DDRGame::attach() {
+4
View File
@@ -7,6 +7,7 @@ namespace games::ddr {
// settings // settings
extern bool SDMODE; extern bool SDMODE;
extern bool NO_CODEC_REGISTRATION;
// Buffers to store RGB data for tape LEDs on gold cabinets // Buffers to store RGB data for tape LEDs on gold cabinets
const size_t TAPELED_DEVICE_COUNT = 11; const size_t TAPELED_DEVICE_COUNT = 11;
@@ -18,5 +19,8 @@ namespace games::ddr {
virtual void pre_attach() override; virtual void pre_attach() override;
virtual void attach() override; virtual void attach() override;
virtual void detach() override; virtual void detach() override;
private:
void register_codecs();
}; };
} }
+3
View File
@@ -629,6 +629,9 @@ int main_implementation(int argc, char *argv[]) {
if (options[launcher::Options::DDR43Mode].value_bool()) { if (options[launcher::Options::DDR43Mode].value_bool()) {
games::ddr::SDMODE = true; games::ddr::SDMODE = true;
} }
if (options[launcher::Options::DDRSkipCodecRegisteration].value_bool()) {
games::ddr::NO_CODEC_REGISTRATION = true;
}
if (options[launcher::Options::LoadSteelChronicleModule].value_bool()) { if (options[launcher::Options::LoadSteelChronicleModule].value_bool()) {
attach_sc = true; attach_sc = true;
} }
+9
View File
@@ -809,6 +809,15 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = {
.game_name = "Dance Dance Revolution", .game_name = "Dance Dance Revolution",
.category = "Game Options", .category = "Game Options",
}, },
{
// DDRSkipCodecRegisteration
.title = "DDR Skip Codec Registration",
.name = "ddrnocodec",
.desc = "Prevent automatic registration of codecs in the com folder",
.type = OptionType::Bool,
.game_name = "Dance Dance Revolution",
.category = "Game Options (Advanced)",
},
{ {
.title = "Force Load Pop'n Music Module", .title = "Force Load Pop'n Music Module",
.name = "pnm", .name = "pnm",
+1
View File
@@ -86,6 +86,7 @@ namespace launcher {
spice2x_SDVXSubRedraw, spice2x_SDVXSubRedraw,
LoadDDRModule, LoadDDRModule,
DDR43Mode, DDR43Mode,
DDRSkipCodecRegisteration,
LoadPopnMusicModule, LoadPopnMusicModule,
PopnMusicForceHDMode, PopnMusicForceHDMode,
PopnMusicForceSDMode, PopnMusicForceSDMode,