//--------------------------------------------------------------------------------- int main(int argc, char **argv) { //--------------------------------------------------------------------------------- s32 ret; u8 gamestatus = 0x03; u8 versionnumber = 0x80; u32 geckoidcheck; u8 oldconfigbytes[2]; ret = sd_init(); if(!ret){ sd_found = 0; } else { sd_found = 1; } if (*((u32 *) 0x80001804) == 0x53545542 && *((u32 *) 0x80001808) == 0x48415858) loaderhbc = 1; *(u32*)0xCD00643C = 0x00000000; // 32Mhz on Bus gecko_attached = usb_isgeckoalive(EXI_CHANNEL_1); if(gecko_attached){ gecko_channel = 1; if (EXI_GetID(gecko_channel, 0x80, &geckoidcheck) == 1) { if (geckoidcheck != 0) { gecko_attached = FALSE; goto slota; } } else { gecko_attached = FALSE; goto slota; } usb_flushnew(gecko_channel); goto slotb; } slota: gecko_attached = usb_isgeckoalive(EXI_CHANNEL_0); if(gecko_attached){ gecko_channel = 0; if (EXI_GetID(gecko_channel, 0x80, &geckoidcheck) == 1) { if (geckoidcheck != 0) { gecko_attached = FALSE; goto slotb; } } else { gecko_attached = FALSE; goto slotb; } usb_flushnew(gecko_channel); } slotb: sd_load_config(); tempgameconf = (char *) sdbuffer; autobootcheck = 1; memset(gameidbuffer, 0, 8); app_loadgameconfig(gameidbuffer); autobootcheck = 0; loadStartupIOS(); iosversion = IOS_GetVersion(); if(config_not_loaded == 0){ menu_load_config(); config_not_loaded = 1; } if (autoboothbc || !loaderhbc) { if (autoboot == 1) { rebooter_thread(); menu_number = 12; rebooter_thread_state = 0; } } else autoboot = 0; WPAD_Init(); PAD_Init(); VIDEO_Init(); AUDIO_Init (NULL); SYS_SetPowerCallback (power_cb); SYS_SetResetCallback (reset_cb); if (CONF_GetProgressiveScan() > 0 && VIDEO_HaveComponentCable()) { progmode = 1; } if (CONF_GetAspectRatio()) { widescreen = 1; } gfx_init(); gfx_load_gfx(); gfx_load_gfx1(); if (autoboot == 0 || autobootwait > 1) gfx_fade_logo(); VIDEO_WaitVSync(); if(!gecko_attached){ gecko_channel = 2; } gfx_int_stars(); while(1) { if(gecko_attached){ usb_recvbuffer(gecko_channel,&gecko_command,1); switch(gecko_command) { //case 0x04: // gecko_readmem(); //break; case 0x14: // Load DOL load_geckoexe(0); break; case 0x24: // Load DOL load_geckoexe(1); break; case 0x42: // Debugger on, pause start off config_bytes[7] = 0x01; config_bytes[5] = 0x00; usb_recvbuffer_safe(gecko_channel,&oldconfigbytes,2); // Get config config_bytes[0] = oldconfigbytes[0]; switch (oldconfigbytes[1]) { case 0x00: config_bytes[1] = 0x00; break; case 0x01: config_bytes[1] = 0x01; break; case 0x02: config_bytes[1] = 0x00; break; case 0x03: config_bytes[1] = 0x01; break; case 0x04: config_bytes[1] = 0x03; break; case 0x05: config_bytes[1] = 0x03; break; case 0x06: config_bytes[1] = 0x02; break; case 0x07: config_bytes[1] = 0x02; break; } menu_number = 8; apploader_thread(); gecko_command = 0; break; case 0x43: // Debugger on, pause start on config_bytes[7] = 0x01; config_bytes[5] = 0x01; usb_recvbuffer_safe(gecko_channel,&oldconfigbytes,2); // Get config config_bytes[0] = oldconfigbytes[0]; switch (oldconfigbytes[1]) { case 0x00: config_bytes[1] = 0x00; break; case 0x01: config_bytes[1] = 0x01; break; case 0x02: config_bytes[1] = 0x00; break; case 0x03: config_bytes[1] = 0x01; break; case 0x04: config_bytes[1] = 0x03; break; case 0x05: config_bytes[1] = 0x03; break; case 0x06: config_bytes[1] = 0x02; break; case 0x07: config_bytes[1] = 0x02; break; } menu_number = 8; apploader_thread(); gecko_command = 0; break; case 0x50: usb_sendbuffer_safe(gecko_channel,&gamestatus,1); break; case 0x99: usb_sendbuffer_safe(gecko_channel,&versionnumber,1); break; } } if(error_sd || confirm_sd || error_video){ sleep(1); error_sd = 0; confirm_sd = 0; error_video = 0; } if(loadedpng && !alphapng){ // if custom backdrop draw bubbles after image gfx_draw_image(0, 0, 640, 480, tex_logo1, 0, 1, 1,0xff); gfx_draw_stars(); } else{ gfx_draw_stars(); // else if own back drop do in this order due to border clip gfx_draw_image(0, 0, 640, 480, tex_logo1, 0, 1, 1,0xff); }; menu_draw(); gfx_render_direct(); } return 0; }
void __Disc_SetVMode(u8 videoselected) { GXRModeObj *vmode = NULL; u32 progressive, tvmode, vmode_reg = 0; /* Get video mode configuration */ progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable(); tvmode = CONF_GetVideo(); /* Select video mode register */ switch (tvmode) { case CONF_VIDEO_PAL: vmode_reg = (CONF_GetEuRGB60() > 0) ? 5 : 1; break; case CONF_VIDEO_MPAL: vmode_reg = 4; break; case CONF_VIDEO_NTSC: vmode_reg = 0; break; } switch (videoselected) { case 0: /* Select video mode */ switch (diskid[3]) { /* PAL */ case 'P': case 'D': case 'F': case 'I': case 'S': case 'H': case 'X': case 'Y': case 'Z': if (tvmode != CONF_VIDEO_PAL) { vmode_reg = 5; vmode = (progressive) ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf; } break; /* NTSC or unknown */ case 'E': case 'J': case 'K': case 'W': if (tvmode != CONF_VIDEO_NTSC) { vmode_reg = 0; vmode = (progressive) ? &TVNtsc480Prog : &TVNtsc480IntDf; } break; } break; case 1: vmode = &TVPal528IntDf; vmode_reg = (vmode->viTVMode) >> 2; break; case 2: progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable(); vmode = (progressive) ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf; vmode_reg = (vmode->viTVMode) >> 2; break; case 3: progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable(); vmode = (progressive) ? &TVNtsc480Prog : &TVNtsc480IntDf; vmode_reg = (vmode->viTVMode) >> 2; break; case 4: // vmode = VIDEO_GetPreferredMode(NULL); break; } /* Set video mode register */ *Video_Mode = vmode_reg; /* Set video mode */ if (vmode) { VIDEO_Configure(vmode); /* Setup video */ VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); } gprintf("\nVideo mode - %s",((progressive)?"progressive":"interlaced")); }
void config_default(void) { /* version TAG */ strncpy(config.version,CONFIG_VERSION,16); /* sound options */ config.psg_preamp = 150; config.fm_preamp = 100; config.hq_fm = 1; config.psgBoostNoise = 1; config.filter = 1; config.lp_range = 0x9999; /* 0.6 in 16.16 fixed point */ config.low_freq = 880; config.high_freq = 5000; config.lg = 1.0; config.mg = 1.0; config.hg = 1.0; config.dac_bits = 14; config.ym2413 = 2; /* AUTO */ config.mono = 0; /* system options */ config.system = 0; /* AUTO */ config.region_detect = 0; /* AUTO */ config.vdp_mode = 0; /* AUTO */ config.master_clock = 0; /* AUTO */ config.force_dtack = 0; config.addr_error = 1; config.bios = 0; config.lock_on = 0; config.hot_swap = 0; /* video options */ config.xshift = 0; config.yshift = 0; config.xscale = 0; config.yscale = 0; config.aspect = 1; config.overscan = 3; /* FULL */ config.gg_extra = 0; config.ntsc = 0; config.vsync = 1; /* AUTO */ config.bilinear = 1; config.vfilter = 1; if (VIDEO_HaveComponentCable()) { config.render = 2; } else { config.render = 0; } switch (vmode->viTVMode >> 2) { case VI_PAL: config.tv_mode = 1; /* 50hz only */ break; case VI_EURGB60: config.tv_mode = 2; /* 50/60hz */ break; default: config.tv_mode = 0; /* 60hz only */ break; } #ifdef HW_RVL config.trap = 0; config.gamma = VI_GM_1_0 / 10.0; #endif /* controllers options */ config.gun_cursor[0] = 1; config.gun_cursor[1] = 1; config.invert_mouse = 0; /* on-screen options */ config.cd_leds = 0; /* menu options */ config.autoload = 0; config.autocheat = 0; #ifdef HW_RVL config.s_auto = 1; #else config.s_auto = 0; config.v_prog = 1; #endif config.s_default = 1; config.s_device = 0; config.l_device = 0; config.bg_overlay = 0; config.screen_w = 658; config.bgm_volume = 100.0; config.sfx_volume = 100.0; /* default ROM directories */ #ifdef HW_RVL sprintf (config.lastdir[0][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[0][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); #else sprintf (config.lastdir[0][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); #endif /* try to restore user config */ int loaded = config_load(); #ifndef HW_RVL /* detect progressive mode enable/disable requests */ PAD_ScanPads(); if (PAD_ButtonsHeld(0) & PAD_BUTTON_B) { /* swap progressive mode enable flag and play some sound to inform user */ config.v_prog ^= 1; ASND_Pause(0); int voice = ASND_GetFirstUnusedVoice(); ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)intro_pcm,intro_pcm_size,200,200,NULL); sleep (2); ASND_Pause(1); } /* switch into 480p if component cable has been detected and progressive mode is enabled */ if (VIDEO_HaveComponentCable() && config.v_prog) { vmode = &TVNtsc480Prog; VIDEO_Configure (vmode); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); } #endif /* inform user if default config is used */ if (!loaded) { GUI_WaitPrompt("Warning","Default Settings restored"); gx_input_SetDefault(); } /* default emulated inputs */ input.system[0] = SYSTEM_MD_GAMEPAD; input.system[1] = (config.input[1].device != -1) ? SYSTEM_MD_GAMEPAD : NO_SYSTEM; input_init(); }
void config_default(void) { /* version TAG */ strncpy(config.version,CONFIG_VERSION,16); /* sound options */ config.psg_preamp = 150; config.fm_preamp = 100; config.hq_fm = 1; config.psgBoostNoise = 0; config.filter = 1; config.lp_range = 50; config.low_freq = 880; config.high_freq = 5000; config.lg = 1.0; config.mg = 1.0; config.hg = 1.0; config.rolloff = 0.995; config.dac_bits = 14; /* system options */ config.region_detect = 0; config.force_dtack = 0; config.addr_error = 1; config.tmss = 0; config.lock_on = 0; config.romtype = 0; config.hot_swap = 0; /* video options */ config.xshift = 0; config.yshift = 0; config.xscale = 0; config.yscale = 0; config.aspect = 1; config.overscan = 3; config.ntsc = 0; if (VIDEO_HaveComponentCable()) { config.render = 2; config.bilinear = 1; #ifdef HW_RVL config.trap = 1; #endif } else { config.render = 0; config.bilinear = 0; #ifdef HW_RVL config.trap = 0; #endif } #ifdef HW_RVL config.gamma = VI_GM_1_0 / 10.0; #endif /* controllers options */ config.gun_cursor[0] = 1; config.gun_cursor[1] = 1; config.invert_mouse = 0; gx_input_SetDefault(); /* menu options */ config.autoload = 0; config.autocheat = 0; #ifdef HW_RVL config.s_auto = 1; #else config.s_auto = 0; #endif config.s_default = 1; config.s_device = 0; config.bg_type = 0; config.bg_overlay = 1; config.screen_w = 658; config.bgm_volume = 100.0; config.sfx_volume = 100.0; /* default ROM directories */ #ifdef HW_RVL sprintf (config.lastdir[TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); #else sprintf (config.lastdir[TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); #endif /* try to restore settings from config file */ if (!config_load()) GUI_WaitPrompt("Info","Default Settings restored"); /* restore inputs */ input_init(); /* restore menu settings */ menu_configure(); }
void __Disc_SelectVMode(u8 videoselected) { vmode = VIDEO_GetPreferredMode(0); /* Get video mode configuration */ bool progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable(); /* Select video mode register */ switch (CONF_GetVideo()) { case CONF_VIDEO_PAL: if (CONF_GetEuRGB60() > 0) { vmode_reg = VI_EURGB60; vmode = progressive ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf; } else vmode_reg = VI_PAL; break; case CONF_VIDEO_MPAL: vmode_reg = VI_MPAL; break; case CONF_VIDEO_NTSC: vmode_reg = VI_NTSC; break; } switch (videoselected) { case 0: // DEFAULT (DISC/GAME) /* Select video mode */ switch (diskid[3]) { // PAL case 'D': case 'F': case 'P': case 'X': case 'Y': if (CONF_GetVideo() != CONF_VIDEO_PAL) { vmode_reg = VI_PAL; vmode = progressive ? &TVNtsc480Prog : &TVNtsc480IntDf; } break; // NTSC case 'E': case 'J': default: if (CONF_GetVideo() != CONF_VIDEO_NTSC) { vmode_reg = VI_NTSC; vmode = progressive ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf; } break; } break; case 1: // PAL50 vmode = &TVPal528IntDf; vmode_reg = vmode->viTVMode >> 2; break; case 2: // PAL60 vmode = progressive ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf; vmode_reg = progressive ? TVEurgb60Hz480Prog.viTVMode >> 2 : vmode->viTVMode >> 2; break; case 3: // NTSC vmode = progressive ? &TVNtsc480Prog : &TVNtsc480IntDf; vmode_reg = vmode->viTVMode >> 2; break; case 4: // AUTO PATCH TO SYSTEM case 5: // SYSTEM break; case 6: // PROGRESSIVE 480P(NTSC + PATCH ALL) vmode = &TVNtsc480Prog; vmode_reg = vmode->viTVMode >> 2; break; default: break; } }