static void init_machine(void) { /* Allocate cart_rom here ( 10 MBytes ) */ cart.rom = memalign(32, MAXROMSIZE); if (!cart.rom) { FONT_writeCenter("Failed to allocate ROM buffer... Rebooting",18,0,640,200,(GXColor)WHITE); gxSetScreen(); sleep(2); gx_audio_Shutdown(); gx_video_Shutdown(); #ifdef HW_RVL DI_Close(); SYS_ResetSystem(SYS_RESTART,0,0); #else SYS_ResetSystem(SYS_HOTRESET,0,0); #endif } /* BIOS support */ load_bios(); /* allocate global work bitmap */ memset (&bitmap, 0, sizeof (bitmap)); bitmap.width = 720; bitmap.height = 576; bitmap.depth = 16; bitmap.granularity = 2; bitmap.pitch = bitmap.width * bitmap.granularity; bitmap.viewport.w = 256; bitmap.viewport.h = 224; bitmap.viewport.x = 0; bitmap.viewport.y = 0; bitmap.data = texturemem; }
void Reload (void) { if (!GetFileToBoot ()) { // run sm, priiloader on the nand is required *(vu32*)0x8132FFFB = 0x50756E65; DCFlushRange((void*)0x8132FFFB,4); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } struct __argv arg; memset (&arg, 0, sizeof(struct __argv)); memmove(ARGS_ADDR, &arg, sizeof(arg)); DCFlushRange(ARGS_ADDR, sizeof(arg) + arg.length); memcpy(BOOTER_ADDR, booter_dol, booter_dol_size); DCFlushRange(BOOTER_ADDR, booter_dol_size); entrypoint exeEntryPoint; exeEntryPoint = (entrypoint) BOOTER_ADDR; /* cleaning up and load dol */ SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); _CPU_ISR_Disable (cookie); __exception_closeall (); exeEntryPoint (); _CPU_ISR_Restore (cookie); exit (0); }
void Sys_Test(void) { if(reset || shutdown) Close_Inputs(); if (reset) SYS_ResetSystem(SYS_RESTART, 0, 0); else if (shutdown) SYS_ResetSystem(SYS_POWEROFF, 0, 0); }
void Sys_PowerOff(s32 chan) { if(chan == WPAD_CHAN_0) { SYS_ResetSystem(SYS_POWEROFF, 0, 0); }; }
void BootToMenu(void) { // Let's try to start system menu... use magic word, as we may have priiloader behind *(vu32*)0x8132FFFB = 0x50756E65; DCFlushRange((void*)0x8132FFFB,4); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); }
void end() { // In case it's used as a Channel u32 *stub = (u32 *)0x80001800; if( *stub ) exit(0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); }
void Reboot() { #ifdef __wii__ SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); #else #define SOFTRESET_ADR ((volatile u32*)0xCC003024) *SOFTRESET_ADR = 0x00000000; #endif }
int main(){ SYS_SetResetCallback(WiiResetPressed); SYS_SetPowerCallback(WiiPowerPressed); WPAD_SetPowerButtonCallback(WiimotePowerPressed); VIDEO_Init(); if(CONF_GetAspectRatio()) { SCREEN_WIDTH = 720; } else { SCREEN_WIDTH = 640; } initializeinput(); initializeworld(); GRRLIB_InitVideo(); GRRLIB_Start(); startscreen(); while(1){ if(!fadeout) { updateinput(); updateworld(); updatetiles(); updateoverlay(); } drawworld(); drawcursor(); drawoverlay(); //When hitting home do a slow fade to black, //if it is totally black do the actual exit if (wpadheld & WPAD_BUTTON_HOME || HWButton) fadeout = true; if(fadeout) { fadeout_opacity += 5; if(fadeout_opacity >= 270) { if(HWButton) SYS_ResetSystem(HWButton, 0, 0); return 0; } GRRLIB_Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, fadeout_opacity > 255 ? 255 << 24 : fadeout_opacity << 24, true); } GRRLIB_Render(); } return 0; }
void Sys_BackToLoader(void) { ExitApp(); if (hbcStubAvailable()) exit(0); // Channel Version SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); }
void WiiOS::Pump() { OS::Pump(); if (HWButton != -1) { SYS_ResetSystem(HWButton, 0, 0); } }
cui_menu menu_home(cui_game* p_game) { cui_menu next_state = CUI_MENU_MAIN; bool done=false; GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); UI_button button_loader; UI_InitBtn(&button_loader, 200, 200, "Loader"); button_loader.img = GRRLIB_LoadTexture(button_png); button_loader.font = font; UI_button button_menu; UI_InitBtn(&button_menu, 400, 200, "Wii menu"); button_menu.img = GRRLIB_LoadTexture(button_png); button_menu.font = font; while(!done) { GRRLIB_FillScreen(0x000000FF); GRRLIB_PrintfTTF (15, 0, font, "HOME Menu", 96, 0xFFFFFFFF); GRRLIB_Line(0, 100, 640, 100, 0xFFFFFFFF); UI_DrawBtn(&button_loader); UI_DrawBtn(&button_menu); cui_cursor_display(p_game->cursor); cui_game_update_cursor(p_game->cursor); u32 pressed = WPAD_ButtonsDown(0); UI_UpdateBtn(&button_loader, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); UI_UpdateBtn(&button_menu, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); if ( pressed & WPAD_BUTTON_HOME ){ done = true; } if(button_loader.click){ done=true; next_state=CUI_MENU_EXIT; } if(button_menu.click){ SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } GRRLIB_Render(); } GRRLIB_FreeTexture(button_loader.img); GRRLIB_FreeTexture(button_menu.img); free(button_loader.text); free(button_menu.text); return next_state; }
void Reboot() { ExitCleanup(); #ifdef HW_RVL SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); #else #define SOFTRESET_ADR ((volatile u32*)0xCC003024) *SOFTRESET_ADR = 0x00000000; #endif }
int BootHomebrewFromMem() { loadStub(); if (Set_Stub_Split(0x00010001,"UNEO")<0) Set_Stub_Split(0x00010001,"ULNR"); entrypoint entry; u32 cpu_isr; if (!innetbuffer) { SDCard_deInit(); USBDevice_deInit(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } struct __argv args; int ret = valid_elf_image(innetbuffer); if (ret == 1) entry = (entrypoint) load_elf_image(innetbuffer); else entry = (entrypoint) load_dol(innetbuffer, &args); free(innetbuffer); if (!entry) { SDCard_deInit(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } SDCard_deInit(); WPAD_Flush(0); WPAD_Disconnect(0); WPAD_Shutdown(); SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); _CPU_ISR_Disable (cpu_isr); __exception_closeall(); entry(); _CPU_ISR_Restore (cpu_isr); return 0; }
void Gui::draw() { // printf("Gui draw\n"); Input::getInstance().refreshInput(); Cursor::getInstance().updateCursor(); Focus::getInstance().updateFocus(); if(padAutoAssign) auto_assign_controllers(); //Update time?? //Get graphics framework and pass to Frame draw fns? gfx->drawInit(); drawBackground(); FrameList::const_iterator iteration; for (iteration = frameList.begin(); iteration != frameList.end(); ++iteration) { (*iteration)->drawChildren(*gfx); } // menuLogo->drawComponent(*gfx); menuLogo->draw(*gfx); if (MessageBox::getInstance().getActive()) MessageBox::getInstance().drawMessageBox(*gfx); if (LoadingBar::getInstance().getActive()) LoadingBar::getInstance().drawLoadingBar(*gfx); Cursor::getInstance().drawCursor(*gfx); if(shutdown) { Cursor::getInstance().setFreezeAction(true); Focus::getInstance().setFreezeAction(true); gfx->enableBlending(true); gfx->setTEV(GX_PASSCLR); gfx->setDepth(-10.0f); gfx->newModelView(); gfx->loadModelView(); gfx->loadOrthographic(); gfx->setColor((GXColor){0, 0, 0, fade}); if(screenMode) gfx->fillRect(-104, 0, 848, 480); else gfx->fillRect(0, 0, 640, 480); if(fade == 255) { VIDEO_SetBlack(true); VIDEO_Flush(); VIDEO_WaitVSync(); if(shutdown==1) //Power off System SYS_ResetSystem(SYS_POWEROFF); else //Return to Loader _exit(EXIT_SUCCESS); } char increment = 3; fade = fade +increment > 255 ? 255 : fade + increment; } gfx->swapBuffers(); }
void Sys_LoadMenu(void) { /* u32 *stub = (u32 *)0x80001800; //Homebrew Channel stub if (*stub) exit(0); */ /* Return to the Wii system menu */ SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); }
bool BootExecFile (void) { green_fix (); /* cleaning up and load dol */ SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); _CPU_ISR_Disable (cookie); __exception_closeall (); exeEntryPoint (); _CPU_ISR_Restore (cookie); return true; }
void Sys_Exit(void) { if(return_to_disable) return; /* Shutdown Inputs */ Close_Inputs(); if (return_to_menu || return_to_priiloader) Sys_LoadMenu(); else if(return_to_bootmii) IOS_ReloadIOS(254); if(WII_LaunchTitle(HBC_108)<0) if(WII_LaunchTitle(HBC_HAXX)<0) if(WII_LaunchTitle(HBC_JODI)<0) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); }
int main(int argc, char **argv) { void *xfb[2]; u32 type; int fbi = 0; VIDEO_Init(); PAD_Init(); WPAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); // double buffering, prevents flickering (is it needed for LCD TV? i don't have one to test) xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); SYS_SetResetCallback(reload); SYS_SetPowerCallback(shutdown); WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(0, rmode->fbWidth, rmode->xfbHeight); while(!doreload && !dooff) { CON_Init(xfb[fbi],0,0,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); //VIDEO_ClearFrameBuffer(rmode,xfb[fbi],COLOR_BLACK); std::cout<<"\n\n\n"; WPAD_ReadPending(WPAD_CHAN_ALL, countevs); int wiimote_connection_status = WPAD_Probe(0, &type); print_wiimote_connection_status(wiimote_connection_status); std::cout<<" Event count: "<<evctr<<"\n"; if(wiimote_connection_status == WPAD_ERR_NONE) { print_and_draw_wiimote_data(xfb[fbi]); } VIDEO_SetNextFramebuffer(xfb[fbi]); VIDEO_Flush(); VIDEO_WaitVSync(); fbi ^= 1; } if(doreload) return 0; if(dooff) SYS_ResetSystem(SYS_SHUTDOWN,0,0); return 0; }
void press_button_to_reboot() { s32 pressed = 0; while (1) { WPAD_ScanPads(); pressed = WPAD_ButtonsDown(0); if (pressed) { release_storage(); SYS_ResetSystem(SYS_RESTART,0,0); } } }
void Sys_LoadHBC(void) { ExitApp(); WII_Initialize(); // Try launching all known HBC titles in reversed released order WII_LaunchTitle(HBC_LULZ); WII_LaunchTitle(HBC_1_0_7); WII_LaunchTitle(HBC_JODI); WII_LaunchTitle(HBC_HAXX); //Back to system menu if all fails SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); }
s32 Disc_BootPartition(LoaderConfig loaderConfig , u64 offset) { entry_point p_entry; s32 ret; /* Open specified partition */ ret = WDVD_OpenPartition(offset); if (ret < 0) return ret; /* Run apploader */ ret = Apploader_Run(loaderConfig, &p_entry); if (ret < 0) return ret; /* Setup low memory */ __Disc_SetLowMem(); /* Set an appropiate video mode */ __Disc_SetVMode(); /* Set time */ __Disc_SetTime(); /* OCARINA STUFF - FISHEARS*/ if (loaderConfig.ocarinaSelection) //(ocarinaChoice) { if (loaderConfig.verboseLog) printf("Doing sd codes\n"); memset(gameid, 0, 8); memcpy(gameid, (char*)0x80000000, 6); do_sd_code(loaderConfig.verboseLog, gameid); } /* Close subsystems */ Subsystem_Close(); /* Shutdown IOS subsystems */ SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); /* Jump to entry point */ p_entry(); /* Epic failure */ while (1); return 0; }
// WARNING: after we move any data into EXECUTE_ADDR, we can no longer use any // heap memory and are restricted to the stack only static void rarch_console_exec(const char *path) { RARCH_LOG("Attempt to load executable: [%s].\n", path); FILE * fp = fopen(path, "rb"); if (fp == NULL) { RARCH_ERR("Could not open DOL file %s.\n", path); return; } fseek(fp, 0, SEEK_END); size_t size = ftell(fp); fseek(fp, 0, SEEK_SET); // try to allocate a buffer for it. if we can't, fail void *dol = malloc(size); if (!dol) { RARCH_ERR("Could not execute DOL file %s.\n", path); fclose(fp); return; } fread(dol, 1, size, fp); fclose(fp); fatUnmount("carda:"); fatUnmount("cardb:"); fatUnmount("sd:"); fatUnmount("usb:"); __io_wiisd.shutdown(); __io_usbstorage.shutdown(); // luckily for us, newlib's memmove doesn't allocate a seperate buffer for // copying in situations of overlap, so it's safe to do this memmove(EXECUTE_ADDR, dol, size); DCFlushRange(EXECUTE_ADDR, size); dol_copy_argv_path(); size_t booter_size = booter_end - booter_start; memcpy(BOOTER_ADDR, booter_start, booter_size); DCFlushRange(BOOTER_ADDR, booter_size); RARCH_LOG("jumping to %08x\n", (unsigned) BOOTER_ADDR); SYS_ResetSystem(SYS_SHUTDOWN,0,0); __lwp_thread_stopmultitasking((void (*)(void)) BOOTER_ADDR); }
void Sys_LoadMenu(void) { ExitApp(); // Priiloader shutup if (Settings.godmode || !(Settings.ParentalBlocks & BLOCK_PRIILOADER_OVERRIDE)) { *(u32 *)0x8132fffb = 0x50756e65; *(u32 *)0x817feff0 = 0x50756e65; // priiloader 0.8 beta 4+ DCFlushRange((u32 *)0x8132fffb, 4); DCFlushRange((u32 *)0x817feff0, 4); } /* Return to the Wii system menu */ SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); }
int C_App::Launch (const void * Data, const char * CmdLine) { void (*EntryPoint)(); u32 Level = 0; EntryPoint = (void (*)()) this->Load(Data, CmdLine, APP_ACTION_PRELOAD); if (EntryPoint == NULL) { return 0; } EntryPoint = (void(*)()) this->Load (Data, NULL, APP_ACTION_RUN); //BeforeExit(); SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); _CPU_ISR_Disable (Level); EntryPoint(); return 1; }
//--------------------------------------------------------------------------------- int main(int argc, char **argv) { //--------------------------------------------------------------------------------- // Initialise the video system VIDEO_Init(); Video_SetMode(); WPAD_Init(); PAD_Init(); if(AHBPROT_DISABLED) IosPatch_RUNTIME(true, false, false, true); else IOS_ReloadIOS(236); menu(); signed_blob *p_tmd = NULL; u32 len; s32 ret; ret = GetTMD(0x0001000154484246LL, &p_tmd, &len); if(ret < 0) { *(vu32*)0x8132FFFB = 0x50756E65; DCFlushRange((void*)0x8132FFFB, 4); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } else { WII_LaunchTitle(0x0001000154484246); } return 0; }
int main(int argc, char *argv[]) { __exception_setreload(20); #ifdef GDB_DEBUG DEBUG_Init(GDBSTUB_DEVICE_USB, 1); _break(); #endif InitVideo(); if(StartUpProcess::Run(argc, argv)) { Application::Instance()->init(); Application::Instance()->show(); Application::Instance()->exec(); } //! Return to the Wii system menu if not from HBC if(!IsFromHBC()) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); return 0; }
int main(int argc, char **argv) { u32 cookie; FILE *exeFile = NULL; void *exeBuffer = (void *)EXECUTABLE_MEM_ADDR; int exeSize = 0; u32 exeEntryPointAddress = 0; entrypoint exeEntryPoint; /* int videomod */ InitVideo(); /* get imagedata */ u8 * imgdata = GetImageData(); /* fadein of image */ for(int i = 0; i < 255; i = i+10) { if(i>255) i = 255; Background_Show(0, 0, 0, imgdata, 0, 1, 1, i); Menu_Render(); } /* check devices */ SDCard_Init(); USBDevice_Init(); char cfgpath[256]; /* Open dol File and check exist */ sprintf(cfgpath, PATH1); exeFile = fopen (cfgpath ,"rb"); if (exeFile==NULL) { sprintf(cfgpath, PATH2); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH3); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH4); exeFile = fopen (cfgpath ,"rb"); } if (PACK2) { if (exeFile==NULL) { sprintf(cfgpath, PATH5); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH6); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH7); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH8); exeFile = fopen (cfgpath ,"rb"); } } if (PACK3) { if (exeFile==NULL) { sprintf(cfgpath, PATH9); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH10); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH11); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH12); exeFile = fopen (cfgpath ,"rb"); } } if (PACK4) { if (exeFile==NULL) { sprintf(cfgpath, PATH13); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH14); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH15); exeFile = fopen (cfgpath ,"rb"); } if (exeFile==NULL) { sprintf(cfgpath, PATH16); exeFile = fopen (cfgpath ,"rb"); } } // if nothing found exiting if (exeFile==NULL) { printf("\n\n\t\tCan't find DOL File...\n"); Menu_Render(); sleep(3); fclose (exeFile); SDCard_deInit(); USBDevice_deInit(); StopGX(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } fseek (exeFile, 0, SEEK_END); exeSize = ftell(exeFile); fseek (exeFile, 0, SEEK_SET); if(fread (exeBuffer, 1, exeSize, exeFile) != (unsigned int) exeSize) { printf("\n\n\t\tCan't open DOL File...\n"); Menu_Render(); fclose (exeFile); sleep(3); SDCard_deInit(); USBDevice_deInit(); StopGX(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } fclose (exeFile); /* load entry point */ struct __argv args; bzero(&args, sizeof(args)); args.argvMagic = ARGV_MAGIC; args.length = strlen(cfgpath) + 2; args.commandLine = (char*)malloc(args.length); if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); strcpy(args.commandLine, cfgpath); args.commandLine[args.length - 1] = '\0'; args.argc = 1; args.argv = &args.commandLine; args.endARGV = args.argv + 1; int ret = valid_elf_image(exeBuffer); if (ret == 1) exeEntryPointAddress = load_elf_image(exeBuffer); else exeEntryPointAddress = load_dol_image(exeBuffer, &args); /* fadeout of image */ for(int i = 255; i > 1; i = i-7) { if(i < 0) i = 0; Background_Show(0, 0, 0, imgdata, 0, 1, 1, i); Menu_Render(); } SDCard_deInit(); USBDevice_deInit(); StopGX(); if (exeEntryPointAddress == 0) { printf("EntryPointAddress failed...\n"); Menu_Render(); sleep(3); fclose (exeFile); SDCard_deInit(); USBDevice_deInit(); StopGX(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);; } exeEntryPoint = (entrypoint) exeEntryPointAddress; /* cleaning up and load dol */ SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); _CPU_ISR_Disable (cookie); __exception_closeall (); exeEntryPoint (); _CPU_ISR_Restore (cookie); return 0; }
int BootHomebrew(char * path) { loadStub(); if (Set_Stub_Split(0x00010001,"UNEO")<0) Set_Stub_Split(0x00010001,"ULNR"); void *buffer = NULL; u32 filesize = 0; entrypoint entry; u32 cpu_isr; FILE * file = fopen(path, "rb"); if (!file) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); fseek (file, 0, SEEK_END); filesize = ftell(file); rewind(file); buffer = malloc(filesize); if (fread (buffer, 1, filesize, file) != filesize) { fclose (file); free(buffer); SDCard_deInit(); USBDevice_deInit(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } fclose (file); struct __argv args; bzero(&args, sizeof(args)); args.argvMagic = ARGV_MAGIC; args.length = strlen(path) + 2; args.commandLine = (char*)malloc(args.length); if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); strcpy(args.commandLine, path); args.commandLine[args.length - 1] = '\0'; args.argc = 1; args.argv = &args.commandLine; args.endARGV = args.argv + 1; int ret = valid_elf_image(buffer); if (ret == 1) entry = (entrypoint) load_elf_image(buffer); else entry = (entrypoint) load_dol(buffer, &args); free(buffer); SDCard_deInit(); USBDevice_deInit(); if (!entry) { SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } WPAD_Flush(0); WPAD_Disconnect(0); WPAD_Shutdown(); SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); _CPU_ISR_Disable (cpu_isr); __exception_closeall(); entry(); _CPU_ISR_Restore (cpu_isr); return 0; }
int main(int argc, char* argv[]) { u8 *tex_ptrone=GRRLIB_LoadTexture(handpointerred_png); u8 *tex_ptrtwo=GRRLIB_LoadTexture(handpointergreen_png); u8 *tex_back=GRRLIB_LoadJPG(bigmenuback_jpg, bigmenuback_jpg_size); u8 *tex_fore=GRRLIB_LoadTexture(credits_png); fatInitDefault(); GRRLIB_InitVideo(); WPAD_Init(); SYS_SetResetCallback(WiiResetPressed); SYS_SetPowerCallback(WiiPowerPressed); WPAD_SetPowerButtonCallback(WiimotePowerPressed); rmode = VIDEO_GetPreferredMode(NULL); AESND_Init(NULL); MODPlay_Init(&mod_track); Init_Voice(); AESND_Pause(0); // the sound loop is running now // set the MOD song if (MODPlay_SetMOD (&mod_track, dojo_dan_oriental_mod) < 0 ) { MODPlay_Unload (&mod_track); } else { // set the music volume to the minimum so we don't hear the music before saved volume is known MODPlay_SetVolume( &mod_track, 0,0); MODPlay_Start (&mod_track);// Play the MOD } WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL, rmode->fbWidth, rmode->xfbHeight); initMain(); MODPlay_SetVolume( &mod_track, opt_music, opt_music); while( HWButton == 0) { WPAD_ScanPads(); u32 wpad_one_down = WPAD_ButtonsDown(0); u32 wpad_two_down = WPAD_ButtonsDown(1); u32 type; WPADData *wd_one, *wd_two; WPAD_ReadPending(WPAD_CHAN_ALL, countevs); WPAD_Probe(WPAD_CHAN_ALL, &type); wd_one = WPAD_Data(0); wd_two = WPAD_Data(1); switch(main_mode) { case STARTUP : GRRLIB_FillScreen(0xFF000000); GRRLIB_DrawImg(0, 0, 640, 480, tex_back, 0, 1, 1, alpha>255?255:alpha); GRRLIB_DrawImg(68,308, 256, 80, tex_fore, 0, 1, 1, alpha>255?255:alpha); if(alpha++>394 || wpad_one_down > 0) { main_mode=MENU; if(tex_back) free(tex_back); if(tex_fore) free(tex_fore); initMenu(); } break; case MENU : GRRLIB_FillScreen(0xFF000000); int menuopt = menuWiimote(wd_one,wpad_one_down); if(menuopt==EXIT) { if(tex_ptrone) free(tex_ptrone); if(tex_ptrtwo) free(tex_ptrtwo); } if(menuopt>NOTHING) { processMenuOption(menuopt); if(main_mode==GAME) { MODPlay_Unload (&mod_track); if(opt_tileset==SPOOKY) MODPlay_SetMOD (&mod_track, graveyard_mod); else if(opt_tileset==EGYPTIAN) MODPlay_SetMOD (&mod_track, egypt_crap_mod); else if(opt_tileset==SIMPLE) MODPlay_SetMOD (&mod_track, childhood_mod); else if(opt_tileset==SPACE) MODPlay_SetMOD (&mod_track, nebulos_mod); else MODPlay_SetMOD (&mod_track, sushi_mod); MODPlay_SetVolume( &mod_track, opt_music, opt_music); MODPlay_Start (&mod_track); } else drawMenu(wd_one); } else drawMenu(wd_one); break; case GAME : if(gameWiimote(wd_one,wpad_one_down,wd_two,wpad_two_down)) { // we are exiting the game back to the menu main_mode=MENU; MODPlay_Unload (&mod_track); MODPlay_SetMOD (&mod_track, dojo_dan_oriental_mod); MODPlay_SetVolume( &mod_track, opt_music, opt_music); MODPlay_Start (&mod_track); killGame(); initMenu(); } else { drawGame(); } break; } // alternate which pointer is on top every frame to not give the advantage to player one in two player mode static int ticktock=0; ticktock++; if(wd_two->ir.valid && ticktock%2==0) { if(main_mode==GAME && whatGameMode()==ONE_PLAYER_GAME) { // don't display second pointer in one player mode } else GRRLIB_DrawColImg(wd_two->ir.x - 9,wd_two->ir.y - 7,68,80,tex_ptrtwo,0,1,1,0xEEFFFFFF); } if(wd_one->ir.valid) { GRRLIB_DrawColImg(wd_one->ir.x - 9,wd_one->ir.y - 7,68,80,tex_ptrone,0,1,1,0xEEFFFFFF); } if(wd_two->ir.valid && ticktock%2!=0) { if(main_mode==GAME && whatGameMode()==ONE_PLAYER_GAME) { // don't display second pointer in one player mode } else GRRLIB_DrawColImg(wd_two->ir.x - 9,wd_two->ir.y - 7,68,80,tex_ptrtwo,0,1,1,0xEEFFFFFF); } if(wd_one->btns_h & WPAD_BUTTON_1) { GRRLIB_ScrShot("MahjonggWii_Screen_%y%m%d_%H%M%S.png",time(NULL)); } GRRLIB_Render(); } // we are exiting, free the mallocs switch( main_mode) { case GAME: killGame(); } if(tex_ptrone) free(tex_ptrone); if(tex_ptrtwo) free(tex_ptrtwo); killMenuLanguages(); MODPlay_Unload (&mod_track); Free_Voice(); WPAD_Shutdown(); GRRLIB_Stop(); saveConfig(FILE_CFG); SYS_ResetSystem(HWButton, 0, 0); return 0; }
/* WARNING: after we move any data * into EXECUTE_ADDR, we can no longer use any * heap memory and are restricted to the stack only. */ void system_exec_wii(const char *_path, bool should_load_game) { FILE *fp; size_t size, booter_size; void *dol; char path[PATH_MAX_LENGTH]; char game_path[PATH_MAX_LENGTH]; #ifndef IS_SALAMANDER bool *verbose = retro_main_verbosity(); bool original_verbose = *verbose; *verbose = true; #endif /* copy heap info into stack so it survives * us moving the .dol into MEM2. */ strlcpy(path, _path, sizeof(path)); if (should_load_game) { #ifdef IS_SALAMANDER strlcpy(game_path, gx_rom_path, sizeof(game_path)); #else char *fullpath = NULL; runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); strlcpy(game_path, fullpath, sizeof(game_path)); #endif } RARCH_LOG("Attempt to load executable: [%s]\n", path); fp = fopen(path, "rb"); if (fp == NULL) { RARCH_ERR("Could not open DOL file %s.\n", path); goto exit; } fseek(fp, 0, SEEK_END); size = ftell(fp); fseek(fp, 0, SEEK_SET); /* try to allocate a buffer for it. if we can't, fail. */ dol = malloc(size); if (!dol) { RARCH_ERR("Could not execute DOL file %s.\n", path); fclose(fp); goto exit; } fread(dol, 1, size, fp); fclose(fp); fatUnmount("carda:"); fatUnmount("cardb:"); fatUnmount("sd:"); fatUnmount("usb:"); __io_wiisd.shutdown(); __io_usbstorage.shutdown(); /* don't use memcpy, there might be an overlap. */ memmove(EXECUTE_ADDR, dol, size); DCFlushRange(EXECUTE_ADDR, size); dol_copy_argv_path(path, should_load_game ? game_path : NULL); booter_size = booter_end - booter_start; memcpy(BOOTER_ADDR, booter_start, booter_size); DCFlushRange(BOOTER_ADDR, booter_size); RARCH_LOG("jumping to %08x\n", (unsigned) BOOTER_ADDR); SYS_ResetSystem(SYS_SHUTDOWN,0,0); __lwp_thread_stopmultitasking((void (*)(void)) BOOTER_ADDR); exit: (void)0; #ifndef IS_SALAMANDER *verbose = original_verbose; #endif }