Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE]: autoLaunchBDMGame function not working #1327

Open
2 tasks done
CosmicScale opened this issue Sep 17, 2024 · 2 comments
Open
2 tasks done

[ISSUE]: autoLaunchBDMGame function not working #1327

CosmicScale opened this issue Sep 17, 2024 · 2 comments
Labels

Comments

@CosmicScale
Copy link

Checks

Describe the issue

I made the app OPL-Launcher-BDM to make use of OPL's 'autoLaunchBDMGame' function and found that it does not work.

I did some debugging of opl.c:

static void autoLaunchBDMGame(char *argv[])
{
    // SifInitRpc(0);
    init_scr();
    char path[256];
    config_set_t *configSet;

    scr_printf("Initializing BDM Mode...\n");
    sleep(2);
    miniInit(BDM_MODE);

    scr_printf("Allocating memory for gAutoLaunchBDMGame...\n");
    sleep(2);
    gAutoLaunchBDMGame = malloc(sizeof(base_game_info_t));
    if (!gAutoLaunchBDMGame) {
        scr_printf("Error: Memory allocation for gAutoLaunchBDMGame failed!\n");
        sleep(5);
        return; // Exit if memory allocation fails.
    }

    memset(gAutoLaunchBDMGame, 0, sizeof(base_game_info_t));

    scr_printf("Checking ISO name validity...\n");
    sleep(2);
    int nameLen;
    int format = isValidIsoName(argv[1], &nameLen);
    scr_printf("ISO format: %d, name length: %d\n", format, nameLen);
    sleep(2);

    if (format == GAME_FORMAT_OLD_ISO) {
        scr_printf("Handling old ISO format...\n");
        sleep(2);
        strncpy(gAutoLaunchBDMGame->name, &argv[1][GAME_STARTUP_MAX], nameLen);
        gAutoLaunchBDMGame->name[nameLen] = '\0';
        strncpy(gAutoLaunchBDMGame->extension, &argv[1][GAME_STARTUP_MAX + nameLen], sizeof(gAutoLaunchBDMGame->extension));
        gAutoLaunchBDMGame->extension[sizeof(gAutoLaunchBDMGame->extension) - 1] = '\0';
    } else {
        scr_printf("Handling new ISO format...\n");
        sleep(2);
        strncpy(gAutoLaunchBDMGame->name, argv[1], nameLen);
        gAutoLaunchBDMGame->name[nameLen] = '\0';
        strncpy(gAutoLaunchBDMGame->extension, &argv[1][nameLen], sizeof(gAutoLaunchBDMGame->extension));
        gAutoLaunchBDMGame->extension[sizeof(gAutoLaunchBDMGame->extension) - 1] = '\0';
    }

    scr_printf("Game name: %s\n", gAutoLaunchBDMGame->name);
    sleep(2);
    scr_printf("Game extension: %s\n", gAutoLaunchBDMGame->extension);
    sleep(2);

    snprintf(gAutoLaunchBDMGame->startup, sizeof(gAutoLaunchBDMGame->startup), argv[2]);
    scr_printf("Game startup: %s\n", gAutoLaunchBDMGame->startup);
    sleep(2);

    if (strcasecmp("DVD", argv[3]) == 0) {
        gAutoLaunchBDMGame->media = SCECdPS2DVD;
        scr_printf("Media type: DVD\n");
        sleep(2);
    } else if (strcasecmp("CD", argv[3]) == 0) {
        gAutoLaunchBDMGame->media = SCECdPS2CD;
        scr_printf("Media type: CD\n");
        sleep(2);
    } else {
        scr_printf("Error: Invalid media type\n");
        sleep(5);
    }

    gAutoLaunchBDMGame->format = format;
    gAutoLaunchBDMGame->parts = 1; // ul not supported.
    scr_printf("Game format: %d\n", gAutoLaunchBDMGame->format);
    sleep(2);

    if (gBDMPrefix[0] != '\0') {
        snprintf(path, sizeof(path), "mass0:%s/CFG/%s.cfg", gBDMPrefix, gAutoLaunchBDMGame->startup);
    } else {
        snprintf(path, sizeof(path), "mass0:CFG/%s.cfg", gAutoLaunchBDMGame->startup);
    }
    scr_printf("Configuration path: %s\n", path);
    sleep(2);

    scr_printf("Allocating configuration set...\n");
    sleep(2);
    configSet = configAlloc(0, NULL, path);
    if (!configSet) {
        scr_printf("Error: Failed to allocate configSet!\n");
        sleep(5);
        return; // Exit if config allocation fails.
    }

    scr_printf("Reading configuration...\n");
    sleep(2);
    if (configRead(configSet) != 0) {
        scr_printf("Error: Failed to read configuration file: %s\n", path);
        sleep(5);
        return;
    }

    scr_printf("Launching the game...\n");
    sleep(2);
    bdmLaunchGame(NULL, -1, configSet);
}

The output is a follows:

Initializing BDM Mode...
Allocating memory for gAutoLaunchBDMGame...
Checking ISO name validity...
ISO format: 1, name length: 15
Handling old ISO format...
Game name: Mister Mosquito
Game extension: .iso
Game startup: SLUS_203.75
Media type: CD
Game format: 1
Configuration path: mass0:CFG/SLUS_203.75.cfg
Allocating configuration set...
Reading configuration...
Error: Failed to read configuration file: mass0:CFG/SLUS_203.75.cfg

If the configuration file does not exist it continues straight to Launching the game... and then freezes.

All games tested launch without issue from the OPL GUI.

Console model

SCPH-50001

OPL version / revision

OPL beta 1.2.0 2125

In which device(s) have you experienced this issue?

USB

Context and extra information

No response

@KrahJohlito
Copy link
Member

KrahJohlito commented Sep 17, 2024

i didnt think anyone used this feature.. anyway I noticed this also and made a fix a few days ago (but it will only work for mass0) .. it is also untested but logically should work

KrahJohlito@b549602

https://github.com/KrahJohlito/Open-PS2-Loader/actions/runs/10807392546

@CosmicScale
Copy link
Author

I figured I'd be the first to use it lol. This feature will be more widely used in the future. I'm beta testing APA-Jail at the moment. APA-Jail plus autoLaunchBDM and HDD large capacity support would allow launching games from the exFAT partition on the internal HDD, directly from PSBBN or Browser 2.0, just like how OPL-Launcher works today.

I tried that commit. Auto Launch now works but games fail to load from USB on the GUI, it freezes at 'Loading config...'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants