static void SetGCVideoMode (void) { syssram *sram; sram = __SYS_LockSram(); if(VIDEO_HaveComponentCable()) sram->flags |= 0x80; //set progressive flag else sram->flags &= 0x7F; //clear progressive flag if (config.dmlvideomode == DMLVIDEOMODE_NTSC) { rmode = &TVNtsc480IntDf; sram->flags &= 0xFE; // Clear bit 0 to set the video mode to NTSC sram->ntd &= 0xBF; //clear pal60 flag } else { rmode = &TVPal528IntDf; sram->flags |= 0x01; // Set bit 0 to set the video mode to PAL sram->ntd |= 0x40; //set pal60 flag } __SYS_UnlockSram(1); // 1 -> write changes while(!__SYS_SyncSram()); // TVPal528IntDf u32 *sfb; static GXRModeObj *rmode; //config.dmlvideomode = DMLVIDEOMODE_PAL; if (config.dmlvideomode == DMLVIDEOMODE_PAL) { rmode = &TVPal528IntDf; *(u32*)0x800000CC = VI_PAL; } else { rmode = &TVNtsc480IntDf; *(u32*)0x800000CC = VI_NTSC; } VIDEO_SetBlack(TRUE); VIDEO_Configure(rmode); sfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); VIDEO_ClearFrameBuffer(rmode, sfb, COLOR_BLACK); VIDEO_SetNextFramebuffer(sfb); VIDEO_Flush(); VIDEO_WaitVSync(); if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); VIDEO_SetBlack(FALSE); VIDEO_WaitVSync(); if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); }
void GC_SetVideoMode(u8 videomode) { syssram *sram = __SYS_LockSram(); GXRModeObj *vmode = VIDEO_GetPreferredMode(0); int vmode_reg = 0; if(VIDEO_HaveComponentCable() && (CONF_GetProgressiveScan() > 0)) sram->flags |= 0x80; //set progressive flag else sram->flags &= 0x7F; //clear progressive flag if(videomode == 1) //pal { vmode_reg = 1; sram->flags |= 0x01; // Set bit 0 to set the video mode to PAL sram->ntd |= 0x40; //set pal60 flag } else //ntsc { sram->flags &= 0xFE; // Clear bit 0 to set the video mode to NTSC sram->ntd &= 0xBF; //clear pal60 flag } if(videomode == 1) vmode = &TVPal528IntDf; else vmode = &TVNtsc480IntDf; __SYS_UnlockSram(1); // 1 -> write changes while(!__SYS_SyncSram()); sram = NULL; /* Set video mode register */ *Video_Mode = vmode_reg; DCFlushRange((void*)Video_Mode, 4); /* Set video mode */ if(vmode != 0) VIDEO_Configure(vmode); /* Setup video */ VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); else while(VIDEO_GetNextField()) VIDEO_WaitVSync(); /* Set black and flush */ VIDEO_SetBlack(TRUE); VIDEO_Flush(); VIDEO_WaitVSync(); if(vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); else while(VIDEO_GetNextField()) VIDEO_WaitVSync(); }
void GC_SetLanguage() { u8 lang = get_wii_language(); syssram *sram; sram = __SYS_LockSram(); sram->lang = lang; __SYS_UnlockSram(1); // 1 -> write changes while(!__SYS_SyncSram()); }
void GC_SetVideoMode(u8 videomode, DML_CFG *BooterCFG, u8 DM_Patch) { syssram *sram; sram = __SYS_LockSram(); static GXRModeObj *rmode; int memflag = 0; if((VIDEO_HaveComponentCable() && (CONF_GetProgressiveScan() > 0)) || videomode > 3) sram->flags |= 0x80; //set progressive flag else sram->flags &= 0x7F; //clear progressive flag if(videomode == 1 || videomode == 3 || videomode == 5) { memflag = 1; sram->flags |= 0x01; // Set bit 0 to set the video mode to PAL sram->ntd |= 0x40; //set pal60 flag } else { sram->flags &= 0xFE; // Clear bit 0 to set the video mode to NTSC sram->ntd &= 0xBF; //clear pal60 flag } if(videomode == 1) { if(DM_Patch == VIDEO_PATCH_FORCE) BooterCFG->VideoMode |= DML_VID_FORCE_PAL50; rmode = &TVPal528IntDf; } else if(videomode == 2) { if(DM_Patch == VIDEO_PATCH_FORCE) BooterCFG->VideoMode |= DML_VID_FORCE_NTSC; rmode = &TVNtsc480IntDf; } else if(videomode == 3) { if(DM_Patch == VIDEO_PATCH_FORCE) BooterCFG->VideoMode |= DML_VID_FORCE_PAL60; rmode = &TVEurgb60Hz480IntDf; memflag = 5; } else if(videomode == 4 ||videomode == 6) { if(DM_Patch == VIDEO_PATCH_FORCE) BooterCFG->VideoMode |= DML_VID_FORCE_PROG; rmode = &TVNtsc480Prog; } else if(videomode == 5 || videomode == 7) { if(DM_Patch == VIDEO_PATCH_FORCE) BooterCFG->VideoMode |= DML_VID_FORCE_PROG; rmode = &TVEurgb60Hz480Prog; memflag = 5; } __SYS_UnlockSram(1); // 1 -> write changes while(!__SYS_SyncSram()); /* Set video mode register */ *(vu32 *)0x800000CC = memflag; DCFlushRange((void *)(0x800000CC), 4); /* Set video mode */ if (rmode != 0) VIDEO_Configure(rmode); /* Setup video */ VIDEO_SetBlack(TRUE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); }
/**************************************************************************** * Main ****************************************************************************/ int main () { // Setup defaults (if no config is found) memset(&swissSettings, 0 , sizeof(SwissSettings)); // Register all devices supported (order matters for boot devices) int i = 0; for(i = 0; i < MAX_DEVICES; i++) allDevices[i] = NULL; i = 0; allDevices[i++] = &__device_wkf; allDevices[i++] = &__device_wode; allDevices[i++] = &__device_sd_a; allDevices[i++] = &__device_sd_b; allDevices[i++] = &__device_card_a; allDevices[i++] = &__device_card_b; allDevices[i++] = &__device_dvd; allDevices[i++] = &__device_ide_a; allDevices[i++] = &__device_ide_b; allDevices[i++] = &__device_qoob; allDevices[i++] = &__device_smb; allDevices[i++] = &__device_sys; allDevices[i++] = &__device_usbgecko; allDevices[i++] = &__device_ftp; allDevices[i++] = &__device_fsp; allDevices[i++] = NULL; // Set current devices devices[DEVICE_CUR] = NULL; devices[DEVICE_DEST] = NULL; devices[DEVICE_TEMP] = NULL; devices[DEVICE_CONFIG] = NULL; devices[DEVICE_PATCHES] = NULL; Initialise(); // Sane defaults refreshSRAM(&swissSettings); swissSettings.debugUSB = 0; swissSettings.gameVMode = 0; // Auto video mode swissSettings.exiSpeed = 1; // 32MHz swissSettings.uiVMode = 0; // Auto UI mode swissSettings.aveCompat = 1; swissSettings.enableFileManagement = 0; needsDeviceChange = 1; needsRefresh = 1; //debugging stuff if(swissSettings.debugUSB) { if(usb_isgeckoalive(1)) { usb_flush(1); } print_gecko("Arena Size: %iKb\r\n",(SYS_GetArena1Hi()-SYS_GetArena1Lo())/1024); print_gecko("DVD Drive Present? %s\r\n",swissSettings.hasDVDDrive?"Yes":"No"); print_gecko("GIT Commit: %s\r\n", GITREVISION); print_gecko("GIT Revision: %s\r\n", GITVERSION); } // Go through all devices with FEAT_BOOT_DEVICE feature and set it as current if one is available for(i = 0; i < MAX_DEVICES; i++) { if(allDevices[i] != NULL && (allDevices[i]->features & FEAT_BOOT_DEVICE)) { print_gecko("Testing device %s\r\n", allDevices[i]->deviceName); if(allDevices[i]->test()) { deviceHandler_setDeviceAvailable(allDevices[i], true); devices[DEVICE_CUR] = allDevices[i]; break; } } } if(devices[DEVICE_CUR] != NULL) { print_gecko("Detected %s\r\n", devices[DEVICE_CUR]->deviceName); if(devices[DEVICE_CUR]->init(devices[DEVICE_CUR]->initial)) { if(devices[DEVICE_CUR]->features & FEAT_AUTOLOAD_DOL) { load_auto_dol(); } memcpy(&curFile, devices[DEVICE_CUR]->initial, sizeof(file_handle)); needsDeviceChange = 0; } } // Scan here since some devices would already be initialised (faster) populateDeviceAvailability(); // If there's no default config device, set it to the first writable device available if(swissSettings.configDeviceId == DEVICE_ID_UNK) { for(int i = 0; i < MAX_DEVICES; i++) { if(allDevices[i] != NULL && (allDevices[i]->features & FEAT_WRITE) && deviceHandler_getDeviceAvailable(allDevices[i])) { swissSettings.configDeviceId = allDevices[i]->deviceUniqueId; print_gecko("No default config device found, using [%s]\r\n", allDevices[i]->deviceName); syssramex* sramex = __SYS_LockSramEx(); sramex->__padding0 = swissSettings.configDeviceId; __SYS_UnlockSramEx(1); while(!__SYS_SyncSram()); break; } } } // Try to open up the config .ini in case it hasn't been opened already if(config_init()) { // TODO notification area this print_gecko("Loaded %i entries from the config file\r\n",config_get_count()); } if(swissSettings.initNetworkAtStart) { // Start up the BBA if it exists uiDrawObj_t *msgBox = DrawPublish(DrawProgressBar(true, 0, "Initialising Network")); init_network(); init_httpd_thread(); DrawDispose(msgBox); } // DVD Motor off setting; Always stop the drive if we only started it to read the ID out if((swissSettings.stopMotor && swissSettings.hasDVDDrive) || (swissSettings.hasDVDDrive == 2)) { dvd_motor_off(); } // Swiss video mode force GXRModeObj *forcedMode = getVideoModeFromSwissSetting(swissSettings.uiVMode); if((forcedMode != NULL) && (forcedMode != getVideoMode())) { setVideoMode(forcedMode); } while(1) { menu_loop(); } return 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 (); } } }