Skip to content

Commit

Permalink
Add argument to specify path to ROMs
Browse files Browse the repository at this point in the history
  • Loading branch information
nvllsvm committed Apr 28, 2024
1 parent 33d22fd commit c57400f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/mcu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,7 @@ int main(int argc, char *argv[])
{
(void)argc;
std::string basePath;
std::string romPath;

int port = 0;
int audioDeviceIndex = -1;
Expand All @@ -1312,6 +1313,13 @@ int main(int argc, char *argv[])
{
audioDeviceIndex = atoi(argv[i] + 3);
}
else if (!strncmp(argv[i], "-d:", 3))
{
romPath = argv[i] + 3;
while (romPath.find_last_of("/") == romPath.length()-1) {
romPath.erase(romPath.length()-1);
}
}
else if (!strncmp(argv[i], "-ab:", 4))
{
char* pColon = argv[i] + 3;
Expand Down Expand Up @@ -1386,6 +1394,7 @@ int main(int argc, char *argv[])
printf(" -p:<port_number> Set MIDI port.\n");
printf(" -a:<device_number> Set Audio Device index.\n");
printf(" -ab:<page_size>:[page_count] Set Audio Buffer size.\n");
printf(" -d:<rom_path> Set ROM directory.\n");
printf("\n");
printf(" -mk2 Use SC-55mk2 ROM set.\n");
printf(" -st Use SC-55st ROM set.\n");
Expand Down Expand Up @@ -1419,6 +1428,11 @@ int main(int argc, char *argv[])
if(Files::dirExists(basePath + "/../share/nuked-sc55"))
basePath += "/../share/nuked-sc55";

if (romPath.empty()) {
romPath = basePath;
}
printf("ROM path is: %s\n", romPath.c_str());

if (autodetect)
{
for (size_t i = 0; i < ROM_SET_COUNT; i++)
Expand All @@ -1428,8 +1442,9 @@ int main(int argc, char *argv[])
{
if (roms[i][j][0] == '\0')
continue;
std::string path = basePath + "/" + roms[i][j];
std::string path = romPath + "/" + roms[i][j];
auto h = Files::utf8_fopen(path.c_str(), "rb");
printf("Current ROM path is: %s\n", path.c_str());
if (!h)
{
good = false;
Expand Down Expand Up @@ -1487,7 +1502,7 @@ int main(int argc, char *argv[])
rpaths[i] = "";
continue;
}
rpaths[i] = basePath + "/" + roms[romset][i];
rpaths[i] = romPath + "/" + roms[romset][i];
s_rf[i] = Files::utf8_fopen(rpaths[i].c_str(), "rb");
bool optional = mcu_jv880 && i == 4;
r_ok &= optional || (s_rf[i] != nullptr);
Expand Down

0 comments on commit c57400f

Please sign in to comment.