int main() { Initialise(); while(1) { s32 Size; s32 SSize; u32 ID; s32 getIDerr; s32 CARDerr; s32 EXIerr; VIDEO_ClearFrameBuffer(rmode, xfb, 0); // Can't use printf since Dolphin overrides it std::cout<<"\x1b[0;0H"; // Position the cursor (at 0, 0) for (int channel = 0; channel < EXI_CHANNEL_MAX; ++channel) for (int device = 0; device < EXI_DEVICE_MAX; ++device) { if (getIDerr = EXI_GetID(channel, device, &ID) == 1) { std::cout<<"Channel "<<channel<<" Device "<<device<<"\tID = 0x"<<std::setbase(16)<<ID<<std::endl; if ((channel == 0 && device == 0)||(channel == 1 && device == 0)) { // It's a memcard slot if (CARDerr = CARD_ProbeEx(channel, &Size, &SSize) >= 0) { std::cout<<"\tMemcard has a size of "<<std::setbase(10)<<Size<<" and a Sector Size of "<<std::setbase(10)<<SSize<<std::endl; } else if (CARDerr == -2) std::cout<<"\tNot a Memcard!"<<std::endl; else std::cout<<"\tCARD Error "<<CARDerr<<std::endl; } else { // It's not a memcard, what to do? - Just probe for now if (EXIerr = EXI_ProbeEx(channel)){} else std::cout<<"\tEXI Error "<<EXIerr<<std::endl; } } else std::cout<<"Channel "<<channel<<" Device "<<device<<std::endl<<"\tEXI_GetID Error "<<getIDerr<<std::endl; } VIDEO_WaitVSync(); } return 0; }
int usb_isgeckoalive(s32 chn) { u32 id = 0; s32 ret; u16 val; if (EXI_GetID(chn, EXI_DEVICE_0, &id) == 0) return 0; if (id != 0) return 0; __usbgecko_exi_wait(chn); val = 0x9000; ret = __send_command(chn,&val); if(ret==1 && !(val&0x0470)) ret = 0; EXI_Unlock(chn); return ret; }
//--------------------------------------------------------------------------------- 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; }