コード例 #1
0
ファイル: grlib.c プロジェクト: fagensden/postloader-1
void grlib_Controllers (bool enable)
	{
	if (enable)
		{
		PAD_Init(); 
		WPAD_Init();
		WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
		WPAD_SetVRes(0, 640, 480);
		WPAD_SetPowerButtonCallback( wmpower_cb );
		}
	else
		{
		u8 i;		

		for (i = 0; i < WPAD_MAX_WIIMOTES; i++) 
			{
			if(WPAD_Probe(i,0) < 0) continue;
			
			WPAD_Flush(i);
			WPAD_Disconnect(i);
			}

		WPAD_Shutdown();
		PAD_Reset(0xf0000000);
		}
	}
コード例 #2
0
ファイル: main.c プロジェクト: rp-/wii-mahjong
static void processMenuOption(int menuopt)
{
    switch(menuopt) {
        case EXIT :
            killMenuLanguages();
            MODPlay_Unload (&mod_track);
            Free_Voice();
            WPAD_Shutdown();
            GRRLIB_Stop();
            saveConfig(FILE_CFG);
            // if we have been launched from a channel then reset to menu
            if (!*((u32*) 0x80001800)) {
                WII_Initialize();
                WII_ReturnToMenu();
            }
            else {               // else the homebrew is launched from a loader so exit back to the loader
                exit(0);
            }
            break;
        case ONE_PLAYER_GAME :
        case TWO_PLAYER_COOP :
        case TWO_PLAYER_VERSUS :
            main_mode=GAME;
            initGame(menuopt);
            break;
    }
    if(menuopt>=MUSIC_BAR && menuopt<=(MUSIC_BAR+64)) {
        MODPlay_SetVolume( &mod_track, opt_music, opt_music);
    }
}
コード例 #3
0
ファイル: REV.cpp プロジェクト: THEGITGIT/revolutionengine
void REV_exit()
{
	delete REVConsole;
	WPAD_Flush(WPAD_CHAN_ALL);
	WPAD_Disconnect(WPAD_CHAN_ALL);
	WPAD_Shutdown();
	exit(0);
}
コード例 #4
0
ファイル: sys.c プロジェクト: miigotu/wiiflow-plus
void Close_Inputs(void)
{
    while(WPAD_GetStatus() == WPAD_STATE_ENABLING); //Possible freeze if i keep this here?
    if(WPAD_GetStatus() == WPAD_STATE_ENABLED)
    {
        WPAD_Flush(WPAD_CHAN_ALL);
        WPAD_Shutdown();
    }
}
コード例 #5
0
ファイル: wpad.c プロジェクト: Jeremy-D-Miller/usbloader-gui
void Wpad_Disconnect(void)
{
	u32 cnt;

	/* Disconnect Wiimotes */
	for (cnt = 0; cnt < MAX_WIIMOTES; cnt++)
		WPAD_Disconnect(cnt);

	/* Shutdown Wiimote subsystem */
	WUPC_Shutdown();
	WPAD_Shutdown();
}
コード例 #6
0
ファイル: init.cpp プロジェクト: N4u/WiiCraft
void Deinitialize(void) {
    WPAD_Shutdown();
    Debug("WPAD_Shutdown Passed");

    EndVideo();
    Debug("EndVideo Passed");

//	ASND_End();
//	Debug("ASND_End Passed");

//	MP3Player_Stop();
//	Debug("MP3Player_Stop Passed");

    DebugStop();
    gprintf("DebugStop passed\n");
}
コード例 #7
0
ファイル: sys.cpp プロジェクト: Jeremy-D-Miller/usbloader-gui
void AppCleanUp(void)
{
	static bool app_clean = false;
	if(app_clean)
		return;

	app_clean = true;

	BannerAsync::ThreadExit();

	if(Settings.CacheTitles)
		GameTitles.WriteCachedTitles(Settings.titlestxt_path);
	Settings.Save();

	ExitGUIThreads();
	StopGX();
	wiilight(0);

	delete btnSoundClick;
	delete btnSoundOver;
	delete btnSoundClick2;
	delete bgMusic;
	delete background;
	delete bgImg;
	delete mainWindow;
	for (int i = 0; i < 4; i++)
		delete pointer[i];

	gettextCleanUp();
	Theme::CleanUp();
	NewTitles::DestroyInstance();
	ThreadedTask::DestroyInstance();
	SoundHandler::DestroyInstance();
	GCGames::DestroyInstance();
	DeinitNetwork();
	GameTitles.SetDefault();

	ShutdownAudio();

	ResourceManager::DestroyInstance();

	WPAD_Shutdown();
	ISFS_Deinitialize();
}
コード例 #8
0
ファイル: sys.c プロジェクト: Cyganet/wiicoverflow
int Sys_IosReload(int IOS) {
    s32 ret = -1;

    //shutdown SD and USB before IOS Reload in DiscWait
    SDCard_deInit();
    USBDevice_deInit();

    WPAD_Flush(0);
    WPAD_Disconnect(0);
    WPAD_Shutdown();

    WDVD_Close();

    USBStorage_Deinit();

    if (IOS == 249 || IOS == 222 || IOS == 223) {
        int i;
		for (i = 0; i < 10; i++) {
            ret = IOS_ReloadIOS(IOS);
            if (ret < 0) return ret;
            if (IOS == 222 || IOS == 223) load_ehc_module();
            ret = WBFS_Init(WBFS_DEVICE_USB);
            if (!(ret < 0)) break;
            sleep(1);
            USBStorage_Deinit();
        }
        if (ret>=0) {
            ret = Disc_Init();
            if (ret>=0) {
                ret = WBFS_Open();
            }
        } else Sys_BackToLoader();
    }

    PAD_Init();
    Wpad_Init();
    WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
//    WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
    //reinitialize SD and USB
    SDCard_Init();
    USBDevice_Init();

    return ret;
}
コード例 #9
0
ファイル: disc.c プロジェクト: Captnoord/Wodeflow
s32 Disc_GCBoot()
{
/*
	gprintf("Changing value at address 0xCC03024\n");
	*(volatile unsigned int *)0xCC003024 |= 7;
		
	gprintf("Retrieving Ticket for BC...");
	int retval = ES_GetTicketViews(BC, &view, 1);

	if (retval != 0) {
		gprintf("failed %d\n",retval);
		return -1;
	}
	gprintf("done\n");
	ghexdump(&view, sizeof(tikview));
*/
	gprintf("Disconnecting Wiimotes\n");
	/* Disconnect Wiimote */
    WPAD_Flush(0);
    WPAD_Disconnect(0);
    WPAD_Shutdown();

	gprintf("Setting video to black...");

	VIDEO_SetBlack(TRUE);
	gprintf("flushing...");
	VIDEO_Flush();
	gprintf("wait for sync...");
	VIDEO_WaitVSync();
	gprintf("wait for sync...");
	VIDEO_WaitVSync();
	gprintf("\n");

	gprintf("Launching title\n");
	WII_LaunchTitle(BC);
/*
	retval = ES_LaunchTitle(BC, &view);
	gprintf("Launching title failed: %d\n",retval);	
	while(1);
*/	
	return 0;
}
コード例 #10
0
ファイル: BootHomebrew.c プロジェクト: smurk-too/wodebrew
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;
}
コード例 #11
0
ファイル: sys.cpp プロジェクト: gnils/usbloader-gx
int Sys_ChangeIos(int ios) {
	s32 prevIos = IOS_GetVersion();

	SDCard_deInit();
	USBDevice_deInit();

	WPAD_Flush(0);
	WPAD_Disconnect(0);
	WPAD_Shutdown();

	WDVD_Close();

	USBStorage2_Deinit();

	s32 ret = IOS_ReloadIOSsafe(ios);
	if (ret < 0) {
		ios = prevIos;
	}

	SDCard_Init();

	if (ios == 222 || ios == 223) {
		load_ehc_module();
	}
	USBDevice_Init();

    PAD_Init();
    Wpad_Init();
    WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
    WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);

	WBFS_Init(WBFS_DEVICE_USB);
	Disc_Init();

	if (Sys_IsHermes()) {
		WBFS_OpenNamed((char *) &game_partition);
	} else {
		WBFS_Open();
	}

	return ret;
}
コード例 #12
0
ファイル: sys.cpp プロジェクト: gnils/usbloader-gx
static void _Sys_Shutdown(int SHUTDOWN_MODE) {
    _ExitApp();
    WPAD_Flush(0);
    WPAD_Disconnect(0);
    WPAD_Shutdown();

    /* Poweroff console */
    if ((CONF_GetShutdownMode() == CONF_SHUTDOWN_IDLE &&  SHUTDOWN_MODE != ShutdownToStandby) || SHUTDOWN_MODE == ShutdownToIdle) {
        s32 ret;

        /* Set LED mode */
        ret = CONF_GetIdleLedMode();
        if (ret >= 0 && ret <= 2)
            STM_SetLedMode(ret);

        /* Shutdown to idle */
        STM_ShutdownToIdle();
    } else {
        /* Shutdown to standby */
        STM_ShutdownToStandby();
    }
}
コード例 #13
0
ファイル: tools.c プロジェクト: DarkMatterCore/bluedump-mod
void KeepAccessRightsAndReload(s32 ios, bool verbose)
{
	s32 ret;
	
	if (AHBPROT_DISABLED)
	{
		/* There should be nothing to worry about if this fails, as long as the new IOS is patched */
		if (verbose) printf("\t- Patching IOS%ld to keep hardware access rights... ", IOS_GetVersion());
		ret = IosPatch_AHBPROT(false);
		if (verbose) printf("%s.\n", (ret < 0 ? "FAILED" : "OK"));
	}
	
	if (verbose) printf("\t- Reloading to IOS%ld... ", ios);
	WUPC_Shutdown();
	WPAD_Shutdown();
	IOS_ReloadIOS(ios);
	//sleep(2);
	PAD_Init();
	WUPC_Init();
	WPAD_Init();
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	if (verbose) printf("done.");
	
	if (AHBPROT_DISABLED)
	{
		if (verbose) printf("\n\t- Applying runtime patches to IOS%ld... ", IOS_GetVersion());
		ret = IosPatch_RUNTIME(true, false, vwii, false);
		if (verbose) printf("%s.\n", (ret < 0 ? "FAILED" : "OK"));
	}
	
	if (IsHermesIOS(ios))
	{
		mload_Init();
		if (verbose) printf("\n\t- Hermes cIOS detected! ehcmodule loaded through mload.");
	}
}
コード例 #14
0
ファイル: wc24boottitle.c プロジェクト: Gamer125/wmb-asm
void ProcessArgs(int argc, char **argv, int boothbdirect)
{
	int i;
	s32 retval;
	u32 bootcode = launchcode & ~(0xff<<24);//Mask out the high 8-bits of launchcode, since that's used for options etc.
	char *path = (char*)0x900FFF00;
	void (*entry)() = (void*)0x80001800;
	u64 nandboot_titleid;
	YellHttp_Ctx *ctx;
	int use_wc24http = 0;
	u32 index;
	FILE *fdol;
	struct stat dolstats;

	if(!fatInitDefault())printf("FAT init failed.\n");
	printf("Processing args...\n");
	#ifndef WIILOADAPPDEBUG
	if(argc && !boothbdirect)
	{
		sscanf(argv[0], "%016llx", &nandboot_titleid);
		if(curtitleid!=nandboot_titleid)
		{
			printf("Current titleID and titleID from NANDBOOTINFO don't match: %016llx %s\n", curtitleid, argv[0]);
			argc = 0;
		}
	}
	#endif

	if(argc)
	{
		if(boothbdirect)launchcode = 1;
		if(launchcode & BIT(24))use_wc24http = 1;

		switch(bootcode)
		{
			case 1://Boot homebrew
				if(argc<2)break;
				if(!boothbdirect)printf("Booting homebrew from: %s\n", argv[1]);
				memcpy((void*)0x80001800, loader_bin, loader_bin_size);
				memset(path, 0, 256);
				if(!boothbdirect)
				{
					if(strncmp(argv[1], "http", 4)==0)
					{
						if(!use_wc24http)
						{
							printf("Using libyellhttp to download: %s\n", argv[1]);

							memset(localip, 0, 16);
							memset(netmask, 0, 16);
							memset(gateway, 0, 16);
							printf("Initializing network...\n");
							retval = if_config (localip, netmask, gateway, true);
							if(retval<0)
							{
								printf("Network init failed: %d\n", retval);
								break;
							}
							ctx = YellHttp_InitCtx();
							if(ctx==NULL)
							{
								printf("Failed to init/alloc http ctx.\n");
								break;
							}

							printf("Downloading %s...\n", argv[1]);
							if(launchcode & BIT(26))
							{
								WC24_MountWC24DlVFF();
								chdir("wc24dl.vff:/");
							}
							retval = YellHttp_ExecRequest(ctx, argv[1]);
							YellHttp_FreeCtx(ctx);

							if(retval<0)
							{
								memset(errstr, 0, 256);
								YellHttp_GetErrorStr(retval, errstr, 256);
								printf("retval = %d str: %s", retval, errstr);
								break;
							}
							for(i=strlen(argv[1])-1; i>0; i--)
							{
								if(argv[1][i]=='/')break;
							}
							i++;
							if(launchcode & BIT(26))strncpy(path, "wc24dl.vff:", 255);
							strncat(path, &argv[1][i], 255);
						}
						else
						{
							printf("Using WC24 to download: %s\n", argv[1]);

							printf("Creating record+entry...\n");
							retval = WC24_CreateRecord(&myrec, &myent, 0, 0, 0x4842, WC24_TYPE_TITLEDATA, WC24_RECORD_FLAGS_DEFAULT, WC24_FLAGS_HB, 0x3c, 0x5a0, 0, argv[1], VFFPATH "boot.dol");
							if(retval<0)
							{
								printf("WC24_CreateRecord returned %d\n", retval);
								WC24_Shutdown();
								break;
							}
							index = retval;

							printf("Downloading...\n");
							retval = KD_Download(KD_DOWNLOADFLAGS_MANUAL, (u16)index, 0x0);
							if(retval<0)
							{
								printf("KD_Download returned %d\n", retval);
								WC24_DeleteRecord(index);
								WC24_Shutdown();
								break;
							}

							printf("Deleting record+entry...\n");
							WC24_DeleteRecord(index);

							printf("Mounting VFF...\n");
							retval = WC24_MountWC24DlVFF();
							if(retval<0)
							{
								printf("WC24_MountWC24DlVFF returned %d\n", retval);
								WC24_Shutdown();
								break;
							}

							printf("Reading wc24dl.vff:/" VFFPATH "boot.dol...\n");
							fdol = fopen("wc24dl.vff:/" VFFPATH "boot.dol", "r");
							if(fdol==NULL)
							{
								printf("Failed to open wc24dl.vff:/" VFFPATH "boot.dol\n");
							}
							else
							{
								stat("wc24dl.vff:/" VFFPATH "boot.dol", &dolstats);
								dol_size = dolstats.st_size;
								fread((void*)0x90100000, 1, dolstats.st_size, fdol);
								fclose(fdol);
								unlink("wc24dl.vff:/" VFFPATH "boot.dol");
								DCFlushRange((void*)0x90100000, dolstats.st_size);
							}

							printf("Unmounting VFF...\n");
							VFF_Unmount("wc24dl.vff");
							memset(path, 0, 256);
							boothbdirect = 1;
							WII_SetNANDBootInfoLaunchcode(0);
						}
					}
					else
					{
						strncpy(path, argv[1], 255);
					}

					if(!use_wc24http)
					{
						if(strncmp(path, "dvd", 3)==0)
						{
							DI_Init();
							if(!ISO9660_Mount())
							{
								printf("Failed to mount DVD ISO9660.\n");
								DI_Close();
								break;
							}
						}
						stat(path, &dolstats);
						dol_size = dolstats.st_size;
						fdol = fopen(path, "r");
						if(fdol==NULL)
						{
							printf("Dol doesn't exist: %s\n", argv[1]);
							break;
						}
						else
						{
							fread((void*)0x90100000, 1, dol_size, fdol);
							DCFlushRange((void*)0x90100000, dol_size);
							fclose(fdol);
						}
						memset(path, 0, 256);
						if(strncmp(path, "dvd", 3)==0)
						{
							ISO9660_Unmount();
							DI_Close();
						}

						if(launchcode & BIT(26))
						{
							unlink(path);
							VFF_Unmount("wc24dl.vff");
						}
					}
				}

				SetDolArgv((void*)0x90100000, dol_size, argc, argv);
				DCFlushRange((void*)0x80001800, loader_bin_size);
				DCFlushRange(path, 256);
				if(!boothbdirect)WII_SetNANDBootInfoLaunchcode(0);
				if(!boothbdirect)
				{
					printf("Booting: %s\n", path);
				}
				else
				{
					printf("Booting homebrew directly from RAM buffer.\n");
				}
				WC24_Shutdown();
				WPAD_Shutdown();
				FlushLog();
				//IOS_ReloadIOS(36);
				SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
				entry();
			break;

			case 2://Boot game disc
				memcpy((void*)0x80001800, loader_bin, loader_bin_size);
				memset(path, 0, 256);
				memcpy((void*)0x90100000, tinyload_dol, tinyload_dol_size);
				DCFlushRange((void*)0x80001800, loader_bin_size);
				DCFlushRange(path, 256);
				DCFlushRange((void*)0x90100000, tinyload_dol_size);
				WII_SetNANDBootInfoLaunchcode(0);
				WC24_Shutdown();
				WPAD_Shutdown();
				printf("Booting game disc.\n");
				FlushLog();
				entry();
			break;

			default:
			break;
		}
	}

	printf("Invalid launchcode or argc: %x %x\n", launchcode, argc);
	#ifdef DEBUG
	printf("Press A to contine.\n");
	while(1)
	{
		WPAD_ScanPads();
		if(WPAD_ButtonsDown(0) & WPAD_BUTTON_A)break;
		VIDEO_WaitVSync();
	}
	#endif
	printf("Shutting down...\n");
	printf("Shutting down WC24...\n");
	if(launchcode & BIT(26))VFF_Unmount("wc24dl.vff");
	WC24_Shutdown();
	FlushLog();
	WPAD_Shutdown();
	WII_Shutdown();
}
コード例 #15
0
ファイル: main.c プロジェクト: rp-/wii-mahjong
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;
}
コード例 #16
0
ファイル: main.c プロジェクト: fagensden/postloader-1
void Boot (void)
	{
	printd ("---------------------------------------------------------------------------\n");
	
	if (pln.bootMode == PLN_BOOT_REAL)
		printd ("       You are in REAL NAND mode: Press any key NOW for boot options\n");
	if (pln.bootMode == PLN_BOOT_NEEK)
		printd ("         You are in UNEEK mode: Press any key NOW for boot options\n");
	if (pln.bootMode == PLN_BOOT_SM)
		printd ("      You are in System Menu' mode: Press any key NOW for boot options\n");
	if (pln.bootMode == PLN_BOOT_HBC)
		printd ("     You are in HomeBrewChannel mode: Press any key NOW for boot options\n");

	if (keypressed || WaitForAnyKey ())
		{
		ChooseNewMode ();
		}
		
	printd ("\n");

	SavePLN ();
	
	WPAD_Shutdown();
	PAD_Reset(0xf0000000);

	//if (IsNandFolder ("usb:/") && pln.bootMode == PLN_BOOT_NEEK)
	if (pln.bootMode == PLN_BOOT_NEEK)
		{
		printd ("Booting neek...");
		Fat_Unmount ();
		green_fix ();
		IOS_ReloadIOS (254); 
		}

	if (pln.bootMode == PLN_BOOT_REAL)
		{
		bool found = FALSE;
		
		if (pl_sd)
			{
			if (!found) found = LoadExecFile (POSTLOADER_SD, "priibooter");
			if (!found) found = LoadExecFile (POSTLOADER_SDAPP, "priibooter");
			}
		if (pl_usb)
			{
			if (!found) found = LoadExecFile (POSTLOADER_USB, "priibooter");
			if (!found) found = LoadExecFile (POSTLOADER_USBAPP, "priibooter");
			}

		if (!found) BootToMenu ();
				
		Fat_Unmount ();
		green_fix ();
		BootExecFile ();
		}
		
	if (pln.bootMode == PLN_BOOT_SM)
		{
		green_fix ();
		BootToMenu ();
		}
		
	exit (0); // This isn't really needed...
	}
コード例 #17
0
ファイル: main.c プロジェクト: smurk-too/gadget4sneek
int main(void) 
{
	initialise();
	checkhbc();
	
	printf("Push button [A] to start switching to SD NAND\n");
	printf("Push button [B] to start switching back to real NAND\n");
	printf("Push button [Home] to exit now\n");
	while(1){
		WPAD_ScanPads();
            u32 wpaddown = WPAD_ButtonsDown(0);
		if (wpaddown & WPAD_BUTTON_A){
			switchnow = true;
			break;
		}
		if (wpaddown & WPAD_BUTTON_HOME){
			printf("exiting now...OK\n");
			sleep(5);
			exitme();
		}
		if (wpaddown & WPAD_BUTTON_B){
			switchback = true;
			break;
		}
	}

	initfat();
	checkfiles();
	
	if(switchback == true)
	{
	   printf("\n");

       if((switchmii == false) &&  (switchsneek == true))
       {
		  printf("It seems sneek is not running, check switchtosneek and switchtomii files\n\n");
	      sleep(5);
          exitme();
	   }

	   if(armbootmii == false)
       {
          printf("No sneek v2 file in bootmii directory: armbootmii.bin\n\n");
	      sleep(5);
          exitme();
       }

       printf("You have ");
       if( armbootsneek == true && armbootmii == true ) printf("sneek and bootmii setups");
       if( armbootsneek == false && armbootmii == true ) printf("bootmii setups");

       if( armbootsneek == false && armbootmii == true ) printf(" turn bootmii on");
       if( armbootsneek == true && armbootmii == true ) printf(" switch to bootmii");
       printf("\n");

	   miscinit();
	   
	   renamefilesback();
	   removeswitchmii();
	   createswitchsneek();

	   miscdeinit();
		
	   sleep(5);

	   WPAD_Shutdown();
	   STM_RebootSystem();				
	}
	
	if(switchnow == true)
	{	
	    printf("\n");
	
        if((switchmii == true) &&  (switchsneek == false))
        {
		   printf("It seems bootmii is not running, check switchtosneek and switchtomii files\n\n");
	       sleep(5);
           exitme();
	    }
	   
	    if(armbootsneek == false)
        {
           printf("No sneek v2 file in bootmii directory: armbootsneek.bin\n\n");
	       sleep(5);
           exitme();
        }

        printf("You have ");
        if( armbootsneek == true && armbootmii == true ) printf("sneek and bootmii setups");
        if( armbootsneek == true && armbootmii == false ) printf("sneek setups");

        if( armbootsneek == true && armbootmii == false ) printf(" turn sneek on");
        if( armbootsneek == true && armbootmii == true ) printf(" switch to sneek");
        printf("\n");

        renamefiles();
	    removeswitchsneek();
	    createswitchmii();

        sleep(5);

	    WPAD_Shutdown();
	    STM_RebootSystem();				
	}
		
	return 0;
}
コード例 #18
0
int main(int argc, char* argv[])
{
	__exception_setreload(10);
	
	int i, ret;
	
	Init_Console();
	printf("\x1b[%u;%um", 37, false);
	
	PAD_Init();
	WPAD_Init();
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	
	printheadline();
	
	ret = ahbprot_menu();
	if (ret < 0)
	{
		ret = ios_selectionmenu(236);
		if (ret > 0)
		{
			printf("\t- Reloading to IOS%d... ", ret);
			WPAD_Shutdown();
			IOS_ReloadIOS(ret);
			sleep(2);
			PAD_Init();
			WPAD_Init();
			WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
			printf("done.\n\n");
		} else
		if (ret == 0)
		{
			printf("\t- Proceeding without IOS reload...\n\n");
		} else {
			Reboot();
		}
	}
	
	resetscreen();
	printheadline();
	
	/* Initialize NAND FS */
	ISFS_Initialize();
	
	/* Do our stuff */
	char path[ISFS_MAXPATH];
	char *filenames[10] = { "misc.bin", "nwc24dl.bin", "nwc24fl.bin", "nwc24fls.bin", "nwc24msg.cbk", "nwc24msg.cfg", \
							"mbox/wc24recv.ctl", "mbox/wc24recv.mbx", "mbox/wc24send.ctl", "mbox/wc24send.mbx" };
	
	for (i = 0; i < 10; i++)
	{
		snprintf(path, MAX_CHARACTERS(path), "/shared2/wc24/%s", filenames[i]);
		
		printf("%u. Deleting \"%s\"... ", i + 1, path);
		ret = ISFS_Delete(path);
		if (ret < 0)
		{
			switch (ret)
			{
				case -1:
				case -102:
					printf("\n\t- Error: Permission denied!");
					break;
				case -2:
				case -105:
					printf("\n\t- Error: File exists!");
					break;
				case -4:
				case -101:
					printf("\n\t- Error: Invalid argument!");
					break;
				case -6:
				case -106:
					printf("\n\t- Error: File not found!");
					break;
				case -8:
				case -118:
					printf("\n\t- Error: Resource busy!");
					break;
				case -12:
				case -103:
				case -114:
					printf("\n\t- Error: NAND ECC failure!");
					break;
				case -22:
					printf("\n\t- Error: Memory allocation failed during request!");
					break;
				case -107:
				case -109:
					printf("\n\t- Error: Too many files open!");
					break;
				case -108:
					printf("\n\t- Error: Memory full!");
					break;
				case -110:
					printf("\n\t- Error: Path name is too long!");
					break;
				case -111:
					printf("\n\t- Error: File already open!");
					break;
				case -115:
					printf("\n\t- Error: Directory not empty!");
					break;
				case -116:
					printf("\n\t- Error: Max directory depth exceeded!");
					break;
				default:
					printf("\n\t- FATAL / UNKNOWN ERROR!!!");
			}
			
			printf(" (ret = %d)\n\n", ret);
			
			if (ret <= -119) break;
		} else {
			printf("OK!\n\n");
		}
		
		usleep(2000000); // 2 seconds
	}
	
	/* Unmount NAND FS and exit */
	ISFS_Deinitialize();
	Reboot();
	
	return 0;
}
コード例 #19
0
ファイル: disc.c プロジェクト: smurk-too/wodebrew
s32 Disc_BootPartition(u64 offset, u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u32 rtrn) {
    entry_point p_entry;

    s32 ret;

    /* Open specified partition */
    ret = WDVD_OpenPartition(offset, tmd_buffer);
    if (ret < 0)
        return ret;

	char gameid[8];
	memset(gameid, 0, 8);
	memcpy(gameid, (char*)Disc_ID, 6);

	//kill the SD
    SDCard_deInit();

    /* Disconnect Wiimote */
    WPAD_Flush(0);
    WPAD_Disconnect(0);
    WPAD_Shutdown();
	
	// Load Disc IOS
	u32 disc_ios = tmd_buffer[0x18B];
	if (disc_ios != IOS_GetVersion()) {
		WDVD_ClosePartition();
		WDVD_Close();

		ret = IOS_ReloadIOS(disc_ios);
		if (ret < 0) {
			gprintf("Disc IOS %u could not be loaded! (ret = %d)", disc_ios, ret);
			return ret;
		}
		Disc_Init();
		Disc_Open();
		WDVD_OpenPartition(offset, tmd_buffer);
	}	

    /* Setup low memory */
    __Disc_SetLowMem();

    /* Run apploader */
    ret = Apploader_Run(&p_entry, cheat, videoselected, vipatch, patchcountrystring, rtrn);
    if (ret < 0)
        return ret;

    bool cheatloaded = false;

    if (cheat == 1) {
        /* OCARINA STUFF - FISHEARS*/
		cheatloaded = ocarina_do_code() == 1;
		cheatloaded = true;
    }

    /* Set an appropiate video mode */
    __Disc_SetVMode(videoselected);

    /* Set time */
    __Disc_SetTime();

	// Anti-green screen fix
	VIDEO_SetBlack(TRUE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	gprintf("\n\nUSB Loader GX is done.\n\n");

    /* Shutdown IOS subsystems */
	// fix for PeppaPig (from NeoGamma)
	extern void __exception_closeall();
	IRQ_Disable();
	__IOS_ShutdownSubsystems();
	__exception_closeall();

	appentrypoint = (u32) p_entry;

	if (cheat == 1 && cheatloaded)
	{
		__asm__(
			"lis %r3, appentrypoint@h\n"
			"ori %r3, %r3, appentrypoint@l\n"
			"lwz %r3, 0(%r3)\n"
			"mtlr %r3\n"
			"lis %r3, 0x8000\n"
			"ori %r3, %r3, 0x18A8\n"
			"mtctr %r3\n"
			"bctr\n"
		);
	}
	else
	{
		__asm__(
			"lis %r3, appentrypoint@h\n"
			"ori %r3, %r3, appentrypoint@l\n"
			"lwz %r3, 0(%r3)\n"
			"mtlr %r3\n"
			"blr\n"
		);
	}

    return 0;
}
コード例 #20
0
ファイル: BootHomebrew.c プロジェクト: smurk-too/wodebrew
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;
}
コード例 #21
0
ファイル: disc.c プロジェクト: Captnoord/Wodeflow
s32 Disc_BootPartition(u64 offset, u8 vidMode, const u8 *cheat, u32 cheatSize, bool vipatch, bool countryString, u8 patchVidMode)
{
	entry_point p_entry;

	gprintf("Open partition at offset: 0x%08x\n", offset);
	s32 ret = WDVD_OpenPartition(offset, 0, 0, 0, Tmd_Buffer);
	if (ret < 0) {
		gprintf("Open partition failed: %d\n", ret);
		return ret;
	}
		
	/* Disconnect Wiimote */
    WPAD_Flush(0);
    WPAD_Disconnect(0);
    WPAD_Shutdown();

	/* Reload IOS into the correct IOS */
	u8 ios = Tmd_Buffer[0x18B];
	
	gprintf("Game requires ios %d\n", ios);
	if (ios != IOS_GetVersion()) {
		WDVD_ClosePartition();
		WDVD_Close();
	
		gprintf("Reloading IOS...");
		ret = IOS_ReloadIOS(ios);
		if (ret < 0) {
			gprintf("failed: %d\n", ret);
		} else {
			gprintf("done\n");
		}
		
		if (Disc_Init() < 0) {
			return -4;
		}
		if (Disc_Open() < 0) {
			return -6;
		}
		if (WDVD_OpenPartition(offset, 0, 0, 0, Tmd_Buffer) < 0) {
			return -8;
		}
	}
	

	gprintf("Setting low memory\n");
	
	/* Setup low memory */;
	__Disc_SetLowMem();

	gprintf("Select video mode\n");

	/* Select an appropriate video mode */
	__Disc_SelectVMode(vidMode);

	gprintf("Running apploader\n");

	/* Run apploader */
	ret = Apploader_Run(&p_entry, cheat != 0, vidMode, vmode, vipatch, countryString, patchVidMode);
	if (ret < 0) {
		gprintf("Failed to run apploader\n");
		return ret;
	}

	gprintf("Set video mode\n");

	/* Set an appropriate video mode */
	__Disc_SetVMode();

	if (cheat != 0 && hooktype != 0)
	{
		ocarina_do_code();
	}

	gprintf("Set time\n");

	/* Set time */
	__Disc_SetTime();

	gprintf("Reset video...");

	/* This prevent a green screen (or a flash of green before loading the game) */
	VIDEO_SetBlack(TRUE);
	gprintf("flushing...");
	VIDEO_Flush();
	gprintf("wait for sync...");
	VIDEO_WaitVSync();
	gprintf("wait for sync...");
	VIDEO_WaitVSync();
	gprintf("\n");

	u8 temp_data[4];

	gprintf("Shutting down wii systems\n");

	// fix for PeppaPig
	memcpy((char *) &temp_data, (void*)0x800000F4,4);

	/* Shutdown IOS subsystems */
	SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);

	// fix for PeppaPig
	memcpy((void*)0x800000F4,(char *) &temp_data, 4);

	appentrypoint = (u32) p_entry;

	gprintf("Current IOS: %d\n", IOS_GetVersion());

	gprintf("Starting game\n");

	if (cheat != 0)
	{
		__asm__(
			"lis %r3, appentrypoint@h\n"
			"ori %r3, %r3, appentrypoint@l\n"
			"lwz %r3, 0(%r3)\n"
			"mtlr %r3\n"
			"lis %r3, 0x8000\n"
			"ori %r3, %r3, 0x18A8\n"
			"mtctr %r3\n"
			"bctr\n"
		);
	}
	else
	{
		__asm__(
			"lis %r3, appentrypoint@h\n"
			"ori %r3, %r3, appentrypoint@l\n"
			"lwz %r3, 0(%r3)\n"
			"mtlr %r3\n"
			"blr\n"
		);
	}

	return 0;
}