Skip to content

Commit

Permalink
BDM: Make loading block device modules other than USB optional
Browse files Browse the repository at this point in the history
  • Loading branch information
KrahJohlito committed Jun 24, 2021
1 parent eed469e commit ba56f2f
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/config.h
Expand Up @@ -87,6 +87,7 @@ enum CONFIG_INDEX {
#define CONFIG_OPL_HDD_MODE "hdd_mode"
#define CONFIG_OPL_ETH_MODE "eth_mode"
#define CONFIG_OPL_APP_MODE "app_mode"
#define CONFIG_OPL_ENABLE_FW "enable_firewire"
#define CONFIG_OPL_SWAP_SEL_BUTTON "swap_select_btn"
#define CONFIG_OPL_PARENTAL_LOCK_PWD "parental_lock_password"
#define CONFIG_OPL_SFX "enable_sfx"
Expand Down
1 change: 1 addition & 0 deletions include/dialogs.h
Expand Up @@ -34,6 +34,7 @@ enum UI_ITEMS {
CFG_HDDMODE,
CFG_ETHMODE,
CFG_APPMODE,
CFG_ENABLEFW,
CFG_LASTPLAYED,
CFG_LBL_AUTOSTARTLAST,
CFG_AUTOSTARTLAST,
Expand Down
2 changes: 1 addition & 1 deletion include/lang.h
Expand Up @@ -65,7 +65,7 @@ enum _STR_IDS {
_STR_SAVING_SETTINGS,
_STR_START_DEVICE,
_STR_REFRESH,
_STR_USBMODE,
_STR_BDMMODE,
_STR_HDDMODE,
_STR_ETHMODE,
_STR_APPMODE,
Expand Down
2 changes: 2 additions & 0 deletions include/opl.h
Expand Up @@ -114,6 +114,8 @@ extern int gHDDStartMode;
extern int gETHStartMode;
extern int gAPPStartMode;

extern int gEnableFW;

extern int gAutosort;
extern int gAutoRefresh;
extern int gEnableNotifications;
Expand Down
20 changes: 17 additions & 3 deletions src/bdmsupport.c
Expand Up @@ -23,6 +23,8 @@ static int bdmGameCount = 0;
static base_game_info_t *bdmGames;
static char bdmDriver[5];

static int fireWireModLoaded = 0;

// forward declaration
static item_list_t bdmGameList;

Expand Down Expand Up @@ -67,6 +69,17 @@ static void bdmEventHandler(void *packet, void *opt)
BdmGeneration++;
}

static void bdmLoadBlockDeviceModules(void)
{
if (gEnableFW && !fireWireModLoaded) {
// Load iLink Block Device drivers
sysLoadModuleBuffer(&iLinkman_irx, size_iLinkman_irx, 0, NULL);
sysLoadModuleBuffer(&IEEE1394_bd_irx, size_IEEE1394_bd_irx, 0, NULL);

fireWireModLoaded = 1;
}
}

void bdmLoadModules(void)
{
LOG("BDMSUPPORT LoadModules\n");
Expand All @@ -81,9 +94,8 @@ void bdmLoadModules(void)
sysLoadModuleBuffer(&usbd_irx, size_usbd_irx, 0, NULL);
sysLoadModuleBuffer(&usbmass_bd_irx, size_usbmass_bd_irx, 0, NULL);

// Load iLink Block Device drivers
sysLoadModuleBuffer(&iLinkman_irx, size_iLinkman_irx, 0, NULL);
sysLoadModuleBuffer(&IEEE1394_bd_irx, size_IEEE1394_bd_irx, 0, NULL);
// Load Optional Block Device drivers
bdmLoadBlockDeviceModules();

sysLoadModuleBuffer(&bdmevent_irx, size_bdmevent_irx, 0, NULL);
SifAddCmdHandler(0, &bdmEventHandler, NULL);
Expand Down Expand Up @@ -119,6 +131,8 @@ static int bdmNeedsUpdate(void)
int result = 0;
struct stat st;

ioPutRequest(IO_CUSTOM_SIMPLEACTION, &bdmLoadBlockDeviceModules);

if (bdmULSizePrev != -2 && OldGeneration == BdmGeneration)
return 0;
OldGeneration = BdmGeneration;
Expand Down
7 changes: 6 additions & 1 deletion src/dialogs.c
Expand Up @@ -194,11 +194,16 @@ struct UIItem diaConfig[] = {
{UI_INT, CFG_HDDSPINDOWN, 1, 1, _STR_HINT_SPINDOWN, 0, 0, {.intvalue = {20, 20, 0, 20}}},
{UI_SPLITTER},

{UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {NULL, _STR_USBMODE}}},
{UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {NULL, _STR_BDMMODE}}},
{UI_SPACER},
{UI_ENUM, CFG_BDMMODE, 1, 1, -1, 0, 0, {.intvalue = {0, 0}}},
{UI_BREAK},

{UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {"- FireWire", -1}}},
{UI_SPACER},
{UI_BOOL, CFG_ENABLEFW, 1, 1, -1, 0, 0, {.intvalue = {0, 0}}},
{UI_BREAK},

{UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {NULL, _STR_HDDMODE}}},
{UI_SPACER},
{UI_ENUM, CFG_HDDMODE, 1, 1, -1, 0, 0, {.intvalue = {0, 0}}},
Expand Down
8 changes: 7 additions & 1 deletion src/gui.c
Expand Up @@ -425,6 +425,9 @@ static int guiUpdater(int modified)
diaGetInt(diaConfig, CFG_LASTPLAYED, &showAutoStartLast);
diaSetVisible(diaConfig, CFG_LBL_AUTOSTARTLAST, showAutoStartLast);
diaSetVisible(diaConfig, CFG_AUTOSTARTLAST, showAutoStartLast);

diaGetInt(diaConfig, CFG_BDMMODE, &gBDMStartMode);
diaSetEnabled(diaConfig, CFG_ENABLEFW, gBDMStartMode);
}
return 0;
}
Expand Down Expand Up @@ -465,6 +468,8 @@ void guiShowConfig()
diaSetInt(diaConfig, CFG_ETHMODE, gETHStartMode);
diaSetInt(diaConfig, CFG_APPMODE, gAPPStartMode);

diaSetInt(diaConfig, CFG_ENABLEFW, gEnableFW);

int ret = diaExecuteDialog(diaConfig, -1, 1, &guiUpdater);
if (ret) {
diaGetInt(diaConfig, CFG_DEBUG, &gDisableDebug);
Expand All @@ -483,11 +488,12 @@ void guiShowConfig()
else
gSelectButton = KEY_CIRCLE;
diaGetInt(diaConfig, CFG_DEFDEVICE, &gDefaultDevice);
diaGetInt(diaConfig, CFG_BDMMODE, &gBDMStartMode);
diaGetInt(diaConfig, CFG_HDDMODE, &gHDDStartMode);
diaGetInt(diaConfig, CFG_ETHMODE, &gETHStartMode);
diaGetInt(diaConfig, CFG_APPMODE, &gAPPStartMode);

diaGetInt(diaConfig, CFG_ENABLEFW, &gEnableFW);

applyConfig(-1, -1);
menuReinitMainMenu();
}
Expand Down
5 changes: 5 additions & 0 deletions src/opl.c
Expand Up @@ -145,6 +145,7 @@ int gBDMStartMode;
int gHDDStartMode;
int gETHStartMode;
int gAPPStartMode;
int gEnableFW;
int gAutosort;
int gAutoRefresh;
int gEnableNotifications;
Expand Down Expand Up @@ -850,6 +851,7 @@ static void _loadConfig()
configGetInt(configOPL, CONFIG_OPL_HDD_MODE, &gHDDStartMode);
configGetInt(configOPL, CONFIG_OPL_ETH_MODE, &gETHStartMode);
configGetInt(configOPL, CONFIG_OPL_APP_MODE, &gAPPStartMode);
configGetInt(configOPL, CONFIG_OPL_ENABLE_FW, &gEnableFW);
configGetInt(configOPL, CONFIG_OPL_SFX, &gEnableSFX);
configGetInt(configOPL, CONFIG_OPL_BOOT_SND, &gEnableBootSND);
configGetInt(configOPL, CONFIG_OPL_SFX_VOLUME, &gSFXVolume);
Expand Down Expand Up @@ -999,6 +1001,7 @@ static void _saveConfig()
configSetInt(configOPL, CONFIG_OPL_HDD_MODE, gHDDStartMode);
configSetInt(configOPL, CONFIG_OPL_ETH_MODE, gETHStartMode);
configSetInt(configOPL, CONFIG_OPL_APP_MODE, gAPPStartMode);
configSetInt(configOPL, CONFIG_OPL_ENABLE_FW, gEnableFW);
configSetInt(configOPL, CONFIG_OPL_SFX, gEnableSFX);
configSetInt(configOPL, CONFIG_OPL_BOOT_SND, gEnableBootSND);
configSetInt(configOPL, CONFIG_OPL_SFX_VOLUME, gSFXVolume);
Expand Down Expand Up @@ -1588,6 +1591,8 @@ static void setDefaults(void)
gETHStartMode = START_MODE_DISABLED;
gAPPStartMode = START_MODE_DISABLED;

gEnableFW = 0;

frameCounter = 0;

gVMode = 0;
Expand Down

0 comments on commit ba56f2f

Please sign in to comment.