Skip to content

Commit

Permalink
Merge pull request #467 from uyjulian/bdmsettings_mx4sio
Browse files Browse the repository at this point in the history
BDM settings rework and MX4SIO addition
  • Loading branch information
AKuHAK committed Jul 21, 2021
2 parents 70ed88a + 897a837 commit 33bc734
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 17 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ MISC_OBJS = icon_sys_A.o icon_sys_J.o icon_sys_C.o conf_theme_OPL.o \
boot.o cancel.o confirm.o cursor.o message.o transition.o

IOP_OBJS = iomanx.o filexio.o ps2fs.o usbd.o bdmevent.o \
bdm.o bdmfs_vfat.o usbmass_bd.o iLinkman.o IEEE1394_bd.o \
bdm.o bdmfs_vfat.o usbmass_bd.o iLinkman.o IEEE1394_bd.o mx4sio_bd.o \
ps2atad.o hdpro_atad.o poweroff.o ps2hdd.o xhdd.o genvmc.o lwnbdsvr.o \
ps2dev9.o smsutils.o ps2ip.o smap.o isofs.o nbns-iop.o \
sio2man.o padman.o mcman.o mcserv.o \
Expand Down Expand Up @@ -530,13 +530,19 @@ $(EE_ASM_DIR)usbmass_bd.s: $(PS2SDK)/iop/irx/usbmass_bd.irx | $(EE_ASM_DIR)

$(EE_ASM_DIR)IEEE1394_bd.s: $(PS2SDK)/iop/irx/IEEE1394_bd.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ IEEE1394_bd_irx

$(EE_ASM_DIR)mx4sio_bd.s: $(PS2SDK)/iop/irx/mx4sio_bd.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ mx4sio_bd_irx
else
# block device drivers without printf's
$(EE_ASM_DIR)usbmass_bd.s: $(PS2SDK)/iop/irx/usbmass_bd_mini.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ usbmass_bd_irx

$(EE_ASM_DIR)IEEE1394_bd.s: $(PS2SDK)/iop/irx/IEEE1394_bd_mini.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ IEEE1394_bd_irx

$(EE_ASM_DIR)mx4sio_bd.s: $(PS2SDK)/iop/irx/mx4sio_bd_mini.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ mx4sio_bd_irx
endif

modules/bdmevent/bdmevent.irx: modules/bdmevent
Expand Down
1 change: 1 addition & 0 deletions ee_core/include/ee_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ extern char GameID[16];
extern int GameMode;
enum GAME_MODE {
BDM_ILK_MODE,
BDM_M4S_MODE,
BDM_USB_MODE,
ETH_MODE,
HDD_MODE,
Expand Down
3 changes: 3 additions & 0 deletions ee_core/include/modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ enum OPL_MODULE_ID {
OPL_MODULE_ID_ILINK,
OPL_MODULE_ID_ILINKBD,

// mx4sio mode modules
OPL_MODULE_ID_MX4SIOBD,

// SMB mode modules
OPL_MODULE_ID_SMSTCPIP,
OPL_MODULE_ID_SMAP,
Expand Down
3 changes: 3 additions & 0 deletions ee_core/src/iopmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ static void ResetIopSpecial(const char *args, unsigned int arglen)
LoadOPLModule(OPL_MODULE_ID_ILINK, 0, 0, NULL);
LoadOPLModule(OPL_MODULE_ID_ILINKBD, 0, 0, NULL);
break;
case BDM_M4S_MODE:
LoadOPLModule(OPL_MODULE_ID_MX4SIOBD, 0, 0, NULL);
break;
};
}

Expand Down
2 changes: 2 additions & 0 deletions ee_core/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ static int eecoreInit(int argc, char **argv)
p = _strtok(argv[i], " ");
if (!_strncmp(argv[i], "BDM_ILK_MODE", 12))
GameMode = BDM_ILK_MODE;
else if (!_strncmp(argv[i], "BDM_M4S_MODE", 12))
GameMode = BDM_M4S_MODE;
else if (!_strncmp(p, "BDM_USB_MODE", 12))
GameMode = BDM_USB_MODE;
else if (!_strncmp(p, "ETH_MODE", 8))
Expand Down
1 change: 1 addition & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ enum CONFIG_INDEX {
#define CONFIG_OPL_ETH_MODE "eth_mode"
#define CONFIG_OPL_APP_MODE "app_mode"
#define CONFIG_OPL_ENABLE_FW "enable_firewire"
#define CONFIG_OPL_ENABLE_MX4SIO "enable_mx4sio"
#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
3 changes: 3 additions & 0 deletions include/dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum UI_ITEMS {
CFG_ETHMODE,
CFG_APPMODE,
CFG_ENABLEFW,
CFG_ENABLEMX4SIO,
CFG_LASTPLAYED,
CFG_LBL_AUTOSTARTLAST,
CFG_AUTOSTARTLAST,
Expand All @@ -43,6 +44,7 @@ enum UI_ITEMS {
CFG_BDMPREFIX,
CFG_ETHPREFIX,
CFG_HDDSPINDOWN,
BLOCKDEVICE_BUTTON,

ABOUT_TITLE,
ABOUT_BUILD_DETAILS,
Expand Down Expand Up @@ -190,5 +192,6 @@ extern struct UIItem diaAbout[];
extern struct UIItem diaVMC[];
extern struct UIItem diaNetCompatUpdate[];
extern struct UIItem diaParentalLockConfig[];
extern struct UIItem diaBlockDevicesConfig[];

#endif
3 changes: 3 additions & 0 deletions include/extern_irx.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ extern int size_resetspu_irx;
extern void *sio2man_irx;
extern int size_sio2man_irx;

extern void *mx4sio_bd_irx;
extern int size_mx4sio_bd_irx;

extern void *smap_irx;
extern int size_smap_irx;

Expand Down
1 change: 1 addition & 0 deletions include/lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ enum _STR_IDS {
_STR_INFO_DEVELOPER,
_STR_INFO_DESCRIPTION,
_STR_BDM_GAMES,
_STR_BLOCKDEVICE_SETTINGS,

LANG_STR_COUNT
};
Expand Down
1 change: 1 addition & 0 deletions include/opl.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ extern int gETHStartMode;
extern int gAPPStartMode;

extern int gEnableFW;
extern int gEnableMX4SIO;

extern int gAutosort;
extern int gAutoRefresh;
Expand Down
1 change: 1 addition & 0 deletions lng/lang_English.lng
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,4 @@ Release
Developer
Description
BDM Games
Select Block Devices
10 changes: 10 additions & 0 deletions src/bdmsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static base_game_info_t *bdmGames;
static char bdmDriver[5];

static int fireWireModLoaded = 0;
static int mx4sioModLoaded = 0;

// forward declaration
static item_list_t bdmGameList;
Expand Down Expand Up @@ -78,6 +79,13 @@ static void bdmLoadBlockDeviceModules(void)

fireWireModLoaded = 1;
}

if (gEnableMX4SIO && !mx4sioModLoaded) {
// Load MX4SIO Block Device drivers
sysLoadModuleBuffer(&mx4sio_bd_irx, size_mx4sio_bd_irx, 0, NULL);

mx4sioModLoaded = 1;
}
}

void bdmLoadModules(void)
Expand Down Expand Up @@ -378,6 +386,8 @@ static void bdmLaunchGame(int id, config_set_t *configSet)
sysLaunchLoaderElf(filename, "BDM_USB_MODE", irx_size, irx, size_mcemu_irx, &bdm_mcemu_irx, EnablePS2Logo, compatmask);
else if (!strcmp(bdmDriver, "sd") && strlen(bdmDriver) == 2)
sysLaunchLoaderElf(filename, "BDM_ILK_MODE", irx_size, irx, size_mcemu_irx, &bdm_mcemu_irx, EnablePS2Logo, compatmask);
else if (!strcmp(bdmDriver, "sdc") && strlen(bdmDriver) == 3)
sysLaunchLoaderElf(filename, "BDM_M4S_MODE", irx_size, irx, size_mcemu_irx, &bdm_mcemu_irx, EnablePS2Logo, compatmask);
}

static config_set_t *bdmGetConfig(int id)
Expand Down
32 changes: 28 additions & 4 deletions src/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,33 @@ struct UIItem diaNetConfig[] = {
// end of dialog
{UI_TERMINATOR}};

// Block Devices Settings Menu
struct UIItem diaBlockDevicesConfig[] = {
{UI_LABEL, 0, 1, 1, -1, 0, 0, {.label = {NULL, _STR_BLOCKDEVICE_SETTINGS}}},
{UI_SPLITTER},

{UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {"USB", -1}}},
{UI_SPACER},
{UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {NULL, _STR_ON}}},
{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 = {"MX4SIO", -1}}},
{UI_SPACER},
{UI_BOOL, CFG_ENABLEMX4SIO, 1, 1, -1, 0, 0, {.intvalue = {0, 0}}},
{UI_BREAK},

// buttons
{UI_OK, 0, 1, 1, -1, 0, 0, {.label = {NULL, _STR_OK}}},
{UI_BREAK},

// end of dialog
{UI_TERMINATOR}};

// Settings Menu
struct UIItem diaConfig[] = {
{UI_LABEL, 0, 1, 1, -1, 0, 0, {.label = {NULL, _STR_SETTINGS}}},
Expand Down Expand Up @@ -197,11 +224,8 @@ struct UIItem diaConfig[] = {
{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_BUTTON, BLOCKDEVICE_BUTTON, 1, 1, -1, 0, 0, {.label = {NULL, _STR_BLOCKDEVICE_SETTINGS}}},
{UI_BREAK},

{UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {NULL, _STR_HDDMODE}}},
Expand Down
22 changes: 18 additions & 4 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,20 @@ void guiShowNetCompatUpdateSingle(int id, item_list_t *support, config_set_t *co
}
}

static void guiShowBlockDeviceConfig(void)
{
int ret;

diaSetInt(diaBlockDevicesConfig, CFG_ENABLEFW, gEnableFW);
diaSetInt(diaBlockDevicesConfig, CFG_ENABLEMX4SIO, gEnableMX4SIO);

ret = diaExecuteDialog(diaBlockDevicesConfig, -1, 1, NULL);
if (ret) {
diaGetInt(diaBlockDevicesConfig, CFG_ENABLEFW, &gEnableFW);
diaGetInt(diaBlockDevicesConfig, CFG_ENABLEMX4SIO, &gEnableMX4SIO);
}
}

static int guiUpdater(int modified)
{
int showAutoStartLast;
Expand All @@ -427,7 +441,7 @@ static int guiUpdater(int modified)
diaSetVisible(diaConfig, CFG_AUTOSTARTLAST, showAutoStartLast);

diaGetInt(diaConfig, CFG_BDMMODE, &gBDMStartMode);
diaSetEnabled(diaConfig, CFG_ENABLEFW, gBDMStartMode);
diaSetVisible(diaConfig, BLOCKDEVICE_BUTTON, gBDMStartMode);
}
return 0;
}
Expand Down Expand Up @@ -464,12 +478,11 @@ void guiShowConfig()
diaSetInt(diaConfig, CFG_SELECTBUTTON, gSelectButton == KEY_CIRCLE ? 0 : 1);
diaSetInt(diaConfig, CFG_DEFDEVICE, gDefaultDevice);
diaSetInt(diaConfig, CFG_BDMMODE, gBDMStartMode);
diaSetVisible(diaConfig, BLOCKDEVICE_BUTTON, gBDMStartMode);
diaSetInt(diaConfig, CFG_HDDMODE, gHDDStartMode);
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 @@ -492,7 +505,8 @@ void guiShowConfig()
diaGetInt(diaConfig, CFG_ETHMODE, &gETHStartMode);
diaGetInt(diaConfig, CFG_APPMODE, &gAPPStartMode);

diaGetInt(diaConfig, CFG_ENABLEFW, &gEnableFW);
if (ret == BLOCKDEVICE_BUTTON)
guiShowBlockDeviceConfig();

applyConfig(-1, -1);
menuReinitMainMenu();
Expand Down
1 change: 1 addition & 0 deletions src/lang.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ static char *internalEnglish[LANG_STR_COUNT] = {
"Developer",
"Description",
"BDM Games",
"Select Block Devices",
};

static int guiLangID = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/opl.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ int gHDDStartMode;
int gETHStartMode;
int gAPPStartMode;
int gEnableFW;
int gEnableMX4SIO;
int gAutosort;
int gAutoRefresh;
int gEnableNotifications;
Expand Down Expand Up @@ -852,6 +853,7 @@ static void _loadConfig()
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_ENABLE_MX4SIO, &gEnableMX4SIO);
configGetInt(configOPL, CONFIG_OPL_SFX, &gEnableSFX);
configGetInt(configOPL, CONFIG_OPL_BOOT_SND, &gEnableBootSND);
configGetInt(configOPL, CONFIG_OPL_SFX_VOLUME, &gSFXVolume);
Expand Down Expand Up @@ -1002,6 +1004,7 @@ static void _saveConfig()
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_ENABLE_MX4SIO, gEnableMX4SIO);
configSetInt(configOPL, CONFIG_OPL_SFX, gEnableSFX);
configSetInt(configOPL, CONFIG_OPL_BOOT_SND, gEnableBootSND);
configSetInt(configOPL, CONFIG_OPL_SFX_VOLUME, gSFXVolume);
Expand Down Expand Up @@ -1592,6 +1595,7 @@ static void setDefaults(void)
gAPPStartMode = START_MODE_DISABLED;

gEnableFW = 0;
gEnableMX4SIO = 0;

frameCounter = 0;

Expand Down
23 changes: 15 additions & 8 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,15 @@ void sysExecExit(void)
}

// Module bits
#define CORE_IRX_USB 0x01
#define CORE_IRX_ETH 0x02
#define CORE_IRX_SMB 0x04
#define CORE_IRX_HDD 0x08
#define CORE_IRX_VMC 0x10
#define CORE_IRX_DEBUG 0x20
#define CORE_IRX_DECI2 0x40
#define CORE_IRX_ILINK 0x80
#define CORE_IRX_USB 0x01
#define CORE_IRX_ETH 0x02
#define CORE_IRX_SMB 0x04
#define CORE_IRX_HDD 0x08
#define CORE_IRX_VMC 0x10
#define CORE_IRX_DEBUG 0x20
#define CORE_IRX_DECI2 0x40
#define CORE_IRX_ILINK 0x80
#define CORE_IRX_MX4SIO 0x100

typedef struct
{
Expand Down Expand Up @@ -439,6 +440,8 @@ static unsigned int sendIrxKernelRAM(const char *startup, const char *mode_str,
modules |= CORE_IRX_USB;
else if (!strcmp(mode_str, "BDM_ILK_MODE"))
modules |= CORE_IRX_ILINK;
else if (!strcmp(mode_str, "BDM_M4S_MODE"))
modules |= CORE_IRX_MX4SIO;
else if (!strcmp(mode_str, "ETH_MODE"))
modules |= CORE_IRX_ETH | CORE_IRX_SMB;
else
Expand Down Expand Up @@ -482,6 +485,10 @@ static unsigned int sendIrxKernelRAM(const char *startup, const char *mode_str,
irxptr_tab[modcount].info = size_IEEE1394_bd_irx | SET_OPL_MOD_ID(OPL_MODULE_ID_ILINKBD);
irxptr_tab[modcount++].ptr = (void *)&IEEE1394_bd_irx;
}
if (modules & CORE_IRX_MX4SIO) {
irxptr_tab[modcount].info = size_mx4sio_bd_irx | SET_OPL_MOD_ID(OPL_MODULE_ID_MX4SIOBD);
irxptr_tab[modcount++].ptr = (void *)&mx4sio_bd_irx;
}
if (modules & CORE_IRX_ETH) {
irxptr_tab[modcount].info = size_smap_ingame_irx | SET_OPL_MOD_ID(OPL_MODULE_ID_SMAP);
irxptr_tab[modcount++].ptr = (void *)&smap_ingame_irx;
Expand Down

0 comments on commit 33bc734

Please sign in to comment.