예제 #1
0
int config_update(ConfigEntry *entry) {
	//print_gecko("config_update: Looking for game with ID %s\r\n",entry->game_id);
	int i;
	for(i = 0; i < configEntriesCount; i++) {
		if(!strncmp(entry->game_id, configEntries[i].game_id, 4)) {
			//print_gecko("config_update: Found %s\r\n",entry->game_id);
			memcpy(&configEntries[i], entry, sizeof(ConfigEntry));
			return config_update_file();	// Write out the file now
		}
	}
	return 0; // should never happen since we add in the game
}
예제 #2
0
/**
	Creates a configuration file on the root of the device "swiss.ini"
	Returns 1 on successful creation, 0 otherwise
*/
int config_create() {
	return config_update_file();
}
예제 #3
0
int show_settings(file_handle *file, ConfigEntry *config) {
    int page = 0, option = 0;

    // Refresh SRAM in case user changed it from IPL
    refreshSRAM();

    // Copy current settings to a temp copy in case the user cancels out
    memcpy((void*)&tempSettings,(void*)&swissSettings, sizeof(SwissSettings));

    // Setup the settings for the current game
    if(config != NULL) {
        page = 2;
    }

    while (PAD_ButtonsHeld(0) & PAD_BUTTON_A) {
        VIDEO_WaitVSync ();
    }
    while(1) {
        settings_draw_page(page, option, file);
        while (!((PAD_ButtonsHeld(0) & PAD_BUTTON_RIGHT)
                 || (PAD_ButtonsHeld(0) & PAD_BUTTON_LEFT)
                 || (PAD_ButtonsHeld(0) & PAD_BUTTON_UP)
                 || (PAD_ButtonsHeld(0) & PAD_BUTTON_DOWN)
                 || (PAD_ButtonsHeld(0) & PAD_BUTTON_B)
                 || (PAD_ButtonsHeld(0) & PAD_BUTTON_A)
                 || (PAD_ButtonsHeld(0) & PAD_TRIGGER_R)
                 || (PAD_ButtonsHeld(0) & PAD_TRIGGER_L)))
        {
            VIDEO_WaitVSync ();
        }
        u16 btns = PAD_ButtonsHeld(0);
        if(btns & PAD_BUTTON_RIGHT) {
            // If we're on a button (Back, Next, Save, Exit), allow left/right movement
            if((page != 1) && (option >= settings_count_pp[page]-2) && option < settings_count_pp[page]) {
                option++;
            }
            else if((page == 1) && (option >= settings_count_pp[page]-3) && option < settings_count_pp[page]) {
                option++;
            }
            else {
                settings_toggle(page, option, 1, file);
            }
        }
        if(btns & PAD_BUTTON_LEFT) {
            // If we're on a button (Back, Next, Save, Exit), allow left/right movement
            if((page != 1) && (option > settings_count_pp[page]-2)) {
                option--;
            }
            else if((page == 1) && (option > settings_count_pp[page]-3)) {
                option--;
            }
            else {
                settings_toggle(page, option, -1, file);
            }
        }
        if((btns & PAD_BUTTON_DOWN) && option < settings_count_pp[page])
            option++;
        if((btns & PAD_BUTTON_UP) && option > 0)
            option--;
        if((btns & PAD_TRIGGER_R) && page < 2) {
            page++;
            option = 0;
        }
        if((btns & PAD_TRIGGER_L) && page > 0) {
            page--;
            option = 0;
        }
        if((btns & PAD_BUTTON_B))
            option = settings_count_pp[page];
        // Handle all options/buttons here
        if((btns & PAD_BUTTON_A)) {
            // Generic Save/Cancel/Back/Next button actions
            if(option == settings_count_pp[page]-1) {
                DrawFrameStart();
                DrawMessageBox(D_INFO,"Saving changes!");
                DrawFrameFinish();
                // Change Swiss video mode if it was modified.
                if(tempSettings.uiVMode != swissSettings.uiVMode) {
                    GXRModeObj *newmode = getModeFromSwissSetting(swissSettings.uiVMode);
                    initialise_video(newmode);
                    vmode = newmode;
                }
                // Save settings to SRAM
                sram = __SYS_LockSram();
                sram->lang = swissSettings.sramLanguage;
                sram->flags = swissSettings.sramStereo ? (sram->flags|0x04):(sram->flags&~0x04);
                sram->flags = (swissSettings.sramVideo&0x03)|(sram->flags&~0x03);
                __SYS_UnlockSram(1);
                while(!__SYS_SyncSram());
                // Update our .ini
                if(config != NULL) {
                    config->gameVMode = swissSettings.gameVMode;
                    config->softProgressive = swissSettings.softProgressive;
                    config->muteAudioStreaming = swissSettings.muteAudioStreaming;
                    config->forceWidescreen = swissSettings.forceWidescreen;
                    config->forceAnisotropy = swissSettings.forceAnisotropy;
                    config->forceEncoding = swissSettings.forceEncoding;
                }
                else {
                    // Save the Swiss system settings since we're called from the main menu
                    if((curDevice == SD_CARD)||(curDevice == IDEEXI)) {
                        DrawFrameStart();
                        DrawMessageBox(D_INFO,"Saving Config ...");
                        DrawFrameFinish();
                        config_copy_swiss_settings(&swissSettings);
                        if(config_update_file()) {
                            DrawFrameStart();
                            DrawMessageBox(D_INFO,"Config Saved Successfully!");
                            DrawFrameFinish();
                        }
                        else {
                            DrawFrameStart();
                            DrawMessageBox(D_INFO,"Config Failed to Save!");
                            DrawFrameFinish();
                        }
                    }
                }
                return 1;
            }
            if(option == settings_count_pp[page]) {
                // Exit without saving (revert)
                memcpy((void*)&swissSettings, (void*)&tempSettings, sizeof(SwissSettings));
                return 0;
            }
            if((page != 2) && (option == settings_count_pp[page]-2)) {
                page++;
                option = 0;
            }
            if((page != 0) && (option == settings_count_pp[page]-(page != 2 ? 3:2))) {
                page--;
                option = 0;
            }
        }
        while ((PAD_ButtonsHeld(0) & PAD_BUTTON_RIGHT)
                || (PAD_ButtonsHeld(0) & PAD_BUTTON_LEFT)
                || (PAD_ButtonsHeld(0) & PAD_BUTTON_UP)
                || (PAD_ButtonsHeld(0) & PAD_BUTTON_DOWN)
                || (PAD_ButtonsHeld(0) & PAD_BUTTON_B)
                || (PAD_ButtonsHeld(0) & PAD_BUTTON_A)
                || (PAD_ButtonsHeld(0) & PAD_TRIGGER_R)
                || (PAD_ButtonsHeld(0) & PAD_TRIGGER_L))
        {
            VIDEO_WaitVSync ();
        }
    }
}