bool retro_load_game(const struct retro_game_info *game) { // Find game index driverIndex = getDriverIndex(game->path); if(driverIndex) { fallbackDir = strdup(game->path); int orientation; unsigned rotateMode; static const int uiModes[] = {ROT0, ROT90, ROT180, ROT270}; /* Get system directory from frontend */ environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY,&systemDir); if (systemDir == NULL || systemDir[0] == '\0') { /* if non set, use old method */ systemDir = normalizePath(fallbackDir); systemDir = peelPathItem(systemDir); } /* Get save directory from frontend */ environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY,&saveDir); if (saveDir == NULL || saveDir[0] == '\0') { /* if non set, use old method */ saveDir = normalizePath(fallbackDir); saveDir = peelPathItem(saveDir); } // Get ROM directory romDir = normalizePath(fallbackDir); romDir = peelPathItem(romDir); // Setup Rotation orientation = drivers[driverIndex]->flags & ORIENTATION_MASK; rotateMode = 0; rotateMode = (orientation == ROT270) ? 1 : rotateMode; rotateMode = (orientation == ROT180) ? 2 : rotateMode; rotateMode = (orientation == ROT90) ? 3 : rotateMode; environ_cb(RETRO_ENVIRONMENT_SET_ROTATION, &rotateMode); // Set all options before starting the game options.samplerate = sample_rate; options.ui_orientation = uiModes[rotateMode]; options.vector_intensity = vector_intensity; options.vector_antialising = vector_antialising; options.beam = vector_beam; options.vector_flicker = vector_flicker; options.vector_translucency = vector_translucency; options.skip_disclaimer = skip_disclaimer; options.skip_warnings = skip_warnings; options.use_samples = samples; options.cheat = cheats; // Boot the emulator return run_game(driverIndex) == 0; } else { return false; } }
bool retro_load_game(const struct retro_game_info *game) { // Find game index driverIndex = getDriverIndex(game->path); if(driverIndex) { fallbackDir = strdup(game->path); int orientation; unsigned rotateMode; static const int uiModes[] = {ROT0, ROT90, ROT180, ROT270}; /* Get system directory from frontend */ environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY,&systemDir); if (systemDir == NULL || systemDir[0] == '\0') { /* if non set, use old method */ systemDir = normalizePath(fallbackDir); systemDir = peelPathItem(systemDir); } /* Get save directory from frontend */ environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY,&saveDir); if (saveDir == NULL || saveDir[0] == '\0') { /* if non set, use old method */ saveDir = normalizePath(fallbackDir); saveDir = peelPathItem(saveDir); } // Get ROM directory romDir = normalizePath(fallbackDir); romDir = peelPathItem(romDir); // Setup Rotation orientation = drivers[driverIndex]->flags & ORIENTATION_MASK; rotateMode = 0; rotateMode = (orientation == ROT270) ? 1 : rotateMode; rotateMode = (orientation == ROT180) ? 2 : rotateMode; rotateMode = (orientation == ROT90) ? 3 : rotateMode; environ_cb(RETRO_ENVIRONMENT_SET_ROTATION, &rotateMode); // Set all options before starting the game options.samplerate = sample_rate; options.ui_orientation = uiModes[rotateMode]; options.vector_intensity = 1.5f; options.skip_disclaimer = skip_disclaimer; options.skip_warnings = skip_warnings; options.use_samples = samples; options.cheat = cheats; #define describe_buttons(INDEX) \ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Joystick Left" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Joystick Right" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Joystick Up" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Joystick Down" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Button 1" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Button 2" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Button 3" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Button 4" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "Button 5" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Button 6" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "Button 7" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "Button 8" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "Button 9" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "Button 10" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Insert Coin" },\ { INDEX, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, struct retro_input_descriptor desc[] = { describe_buttons(0) describe_buttons(1) describe_buttons(2) describe_buttons(3) { 0, 0, 0, 0, NULL } }; environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc); // Boot the emulator return run_game(driverIndex) == 0; } else { return false; } }