int clock_gettime(struct timespec *tp) { u32 gctime; #if defined(HW_RVL) u32 wii_bias = 0; #endif if(!tp) return -1; if(!__SYS_GetRTC(&gctime)) return -1; #if defined(HW_DOL) syssram* sram = __SYS_LockSram(); gctime += sram->counter_bias; __SYS_UnlockSram(0); #else if(CONF_GetCounterBias(&wii_bias)>=0) gctime += wii_bias; #endif gctime += 946684800; tp->tv_sec = gctime; tp->tv_nsec = ticks_to_nanosecs(gettick()); return 0; }
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(); }
void refreshSRAM() { sram = __SYS_LockSram(); swissSettings.sramStereo = sram->flags & 4; swissSettings.sramLanguage = sram->lang; __SYS_UnlockSram(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 (); } } }
void info_draw_page(int page_num) { doBackdrop(); DrawEmptyBox(20,60, vmode->fbWidth-20, 420, COLOR_BLACK); syssram* sram = __SYS_LockSram(); __SYS_UnlockSram(0); // System Info (Page 1/3) if(!page_num) { WriteFont(30, 65, "System Info (1/3):"); // Model if(is_gamecube()) { if(*(u32*)&driveVersion[0] == 0x20010831) { sprintf(topStr, "Panasonic Q SL-GC10-S"); } else if(IPLInfo[0x55]=='M') { // MPAL 1.1 (Brazil) sprintf(topStr, "Nintendo GameCube DOL-002 (BRA)"); } else if((!IPLInfo[0x55]) // NTSC 1.0 || (IPLInfo[0x55] == 'P' && IPLInfo[0x65]=='0') // PAL 1.0 || (IPLInfo[0x55] != 'P' && IPLInfo[0x65]=='1')) { // NTSC 1.1 sprintf(topStr, "Nintendo GameCube DOL-001"); } else if((IPLInfo[0x55] == 'P' && IPLInfo[0x65]=='0') // PAL 1.1 || IPLInfo[0x65]=='2') { // NTSC 1.2 sprintf(topStr, "Nintendo GameCube DOL-101"); } } else { sprintf(topStr, "Nintendo Wii"); } WriteFontStyled(640/2, 110, topStr, 1.0f, true, defaultColor); // IPL version string if(is_gamecube()) { if(!IPLInfo[0x55]) { sprintf(topStr, "NTSC Revision 1.0"); } else { sprintf(topStr, "%s", &IPLInfo[0x55]); } } else { sprintf(topStr, "Wii IPL"); } WriteFontStyled(640/2, 140, topStr, 1.0f, true, defaultColor); if(swissSettings.hasDVDDrive) { if((!__wkfSpiReadId() || (__wkfSpiReadId() == 0xFFFFFFFF))) { sprintf(topStr, "DVD Drive %02X %02X%02X/%02X (%02X)",driveVersion[2],driveVersion[0],driveVersion[1],driveVersion[3],driveVersion[4]); } else { sprintf(topStr, "WKF Serial %s",wkfGetSerial()); } } else sprintf(topStr, "No DVD Drive present"); WriteFontStyled(640/2, 170, topStr, 1.0f, true, defaultColor); sprintf(topStr, "%s",videoStr); WriteFontStyled(640/2, 200, topStr, 1.0f, true, defaultColor); sprintf(topStr,"%s / %s",getSramLang(sram->lang), sram->flags&4 ? "Stereo":"Mono"); WriteFontStyled(640/2, 230, topStr, 1.0f, true, defaultColor); sprintf(topStr,"PVR %08X ECID %08X:%08X:%08X",mfpvr(),mfspr(0x39C),mfspr(0x39D),mfspr(0x39E)); WriteFontStyled(640/2, 260, topStr, 0.75f, true, defaultColor); } else if(page_num == 1) { WriteFont(30, 65, "Device Info (2/3):"); sprintf(topStr,"BBA: %s", bba_exists ? "Installed":"Not Present"); WriteFont(30, 110, topStr); if(exi_bba_exists()) { sprintf(topStr,"IP: %s", net_initialized ? bba_ip:"Not Available"); } else { sprintf(topStr,"IP: Not Available"); } WriteFont(270, 110, topStr); sprintf(topStr,"Component Cable Plugged in: %s",VIDEO_HaveComponentCable()?"Yes":"No"); WriteFont(30, 140, topStr); if(usb_isgeckoalive(0)||usb_isgeckoalive(1)) { sprintf(topStr,"USB Gecko: Installed in %s",usb_isgeckoalive(0)?"Slot A":"Slot B"); } else { sprintf(topStr,"USB Gecko: Not Present"); } WriteFont(30, 170, topStr); if (!deviceHandler_initial) { sprintf(topStr, "Current Device: No Device Selected"); } else if(deviceHandler_initial == &initial_SD0 || deviceHandler_initial == &initial_SD1) { int slot = (deviceHandler_initial->name[2] == 'b'); sprintf(topStr, "Current Device: %s Card in %s @ %s",!SDHCCard?"SDHC":"SD",!slot?"Slot A":"Slot B",!swissSettings.exiSpeed?"16Mhz":"32Mhz"); } else if(deviceHandler_initial == &initial_DVD) { sprintf(topStr, "Current Device: %s DVD Disc",dvdDiscTypeStr); } else if(deviceHandler_initial == &initial_IDE0 || deviceHandler_initial == &initial_IDE1) { int slot = (deviceHandler_initial->name[3] == 'b'); sprintf(topStr, "Current Device: %d GB HDD in %s",ataDriveInfo.sizeInGigaBytes,!slot?"Slot A":"Slot B"); } else if(deviceHandler_initial == &initial_Qoob) { sprintf(topStr, "Current Device: Qoob IPL Replacement"); } else if(deviceHandler_initial == &initial_WODE) { sprintf(topStr, "Current Device: Wode Jukebox"); } else if(deviceHandler_initial == &initial_CARDA || deviceHandler_initial == &initial_CARDB) { sprintf(topStr, "Current Device: Memory Card in %s",!deviceHandler_initial->fileBase?"Slot A":"Slot B"); } else if(deviceHandler_initial == &initial_USBGecko) { sprintf(topStr, "Current Device: USB Gecko"); } else if(deviceHandler_initial == &initial_WKF) { sprintf(topStr, "Current Device: Wiikey Fusion"); } else if(deviceHandler_initial == &initial_SYS) { sprintf(topStr, "Current Device: System"); } WriteFont(30, 200, topStr); } else if(page_num == 2) { WriteFont(30, 65, "Credits (3/3):"); WriteFontStyled(640/2, 115, "Swiss ver 0.4", 1.0f, true, defaultColor); WriteFontStyled(640/2, 140, "by emu_kidid 2015", 0.75f, true, defaultColor); sprintf(txtbuffer, "Commit %s Revision %s SD Gecko Slot B Cheats Mod", GITREVISION, GITVERSION); WriteFontStyled(640/2, 165, txtbuffer, 0.75f, true, defaultColor); WriteFontStyled(640/2, 210, "Thanks to", 0.75f, true, defaultColor); WriteFontStyled(640/2, 228, "Testers & libOGC/dkPPC authors", 0.75f, true, defaultColor); WriteFontStyled(640/2, 246, "sepp256 for GX / FIX94 for Audio Streaming", 0.75f, true, defaultColor); WriteFontStyled(640/2, 264, "Extrems for video patches / Megalomaniac for builds", 0.75f, true, defaultColor); WriteFontStyled(640/2, 282, "Fishaman P for cheats support with all devices", 0.75f, true, defaultColor); WriteFontStyled(640/2, 318, "Web/Support http://www.gc-forever.com/", 0.75f, true, defaultColor); WriteFontStyled(640/2, 336, "Source at https://github.com/emukidid/swiss-gc", 0.75f, true, defaultColor); WriteFontStyled(640/2, 354, "Visit us at #gc-forever on EFNet", 0.75f, true, defaultColor); } if(page_num != 2) { WriteFont(520, 390, "->"); } if(page_num != 0) { WriteFont(100, 390, "<-"); } WriteFontStyled(640/2, 400, "Press A to return", 1.0f, true, defaultColor); DrawFrameFinish(); }