Skip to content

Commit

Permalink
More robust BDM HDD checks
Browse files Browse the repository at this point in the history
  • Loading branch information
xan1242 committed Feb 24, 2025
1 parent ac96a6f commit a537845
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/opl.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,16 +778,29 @@ static int checkLoadConfigBDM(int types)
{
char path[64];
int value;

hddLoadModules();
int bdm_result;
int is_hdd = 0;

// check USB
if (bdmFindPartition(path, "conf_opl.cfg", 0)) {
bdm_result = bdmFindPartition(path, "conf_opl.cfg", 0);
// if not on USB, check BDM HDD
if (bdm_result == 0) {
hddLoadModules();
bdm_result = bdmFindPartition(path, "conf_opl.cfg", 0);
if (bdm_result)
is_hdd = 1;
}

if (bdm_result) {
configEnd();
configInit(path);
value = configReadMulti(types);
config_set_t *configOPL = configGetByType(CONFIG_OPL);
configSetInt(configOPL, CONFIG_OPL_BDM_MODE, START_MODE_AUTO);
if (is_hdd != 0) {
gEnableBdmHDD = 1;
configSetInt(configOPL, CONFIG_OPL_ENABLE_BDMHDD, gEnableBdmHDD);
}
return value;
}

Expand Down Expand Up @@ -997,10 +1010,17 @@ static void _loadConfig()
static int trySaveConfigBDM(int types)
{
char path[64];
int bdm_result;

hddLoadModules();
// check USB
if (bdmFindPartition(path, "conf_opl.cfg", 1)) {
bdm_result = bdmFindPartition(path, "conf_opl.cfg", 1);
// if not on USB, check BDM HDD
if (bdm_result == 0) {
hddLoadModules();
bdm_result = bdmFindPartition(path, "conf_opl.cfg", 1);
}

if (bdm_result) {
configSetMove(path);
return configWriteMulti(types);
}
Expand Down

0 comments on commit a537845

Please sign in to comment.