예제 #1
0
	void MEM2_init(unsigned int mem2Size)
	{
		if(&_end + 0x100 > APPLOADER_START) gprintf("ZOMG MOVE THE ENTRYPOINT DOWN!");

		g_mem2gp.init(mem2Size);
		g_mem2gp.clear();

		/* If these are used, they must be cleared before running the apploader */

		/* Below executable */
		g_mem1Lgp.init((void *)0x80004000, &__init_start - 0x100);
		g_mem1Lgp.clear();

		/* Above Executable */
		g_mem1Ugp.init(APPLOADER_START, APPLOADER_END);
		g_mem1Ugp.clear();
		
		/* Protect space reserved for apploader */
		SYS_SetArena1Hi(APPLOADER_START);
	}
예제 #2
0
int main(int argc, char **argv)
{
	set_new_handler(no_memory);
	geckoinit = InitGecko();
	__exception_setreload(5);

	SYS_SetArena1Hi(APPLOADER_START);

	char *gameid = NULL;
	string dolLoc; //(argv[0] != NULL ? argv[0] : "");

	for (int i = 0; i < argc; i++)
	{
		if (argv[i] != NULL && strcasestr(argv[i], "ios=") != NULL && strlen(argv[i]) > 4)
		{
			while(argv[i][0] && !isdigit(argv[i][0])) argv[i]++;
			if (atoi(argv[i]) < 254 && atoi(argv[i]) > 0)
				mainIOS = atoi(argv[i]);
		}
		else if (strlen(argv[i]) == 6)
		{
			gameid = argv[i];
			for (int i=0; i < 5; i++)
				if (!isalnum(gameid[i]))
					gameid = NULL;
		}
	}
	gprintf("Loading cIOS: %d\n", mainIOS);

	ISFS_Initialize();

	// Load Custom IOS
	bool iosOK = loadIOS(mainIOS, false);
	MEM2_init(52);

	u8 mainIOSBase = 0;
	iosOK = iosOK && cIOSInfo::D2X(mainIOS, &mainIOSBase);
	gprintf("Loaded cIOS: %u has base %u\n", mainIOS, mainIOSBase);

	// Init video
	CVideo vid;
	vid.init();
	WIILIGHT_Init();
	vid.waitMessage(0.2f);

	// Init
	Sys_Init();
	Sys_ExitTo(EXIT_TO_HBC);

	int ret = 0;

	do
	{
		Open_Inputs();

		bool deviceAvailable = false;

		u8 timeout = 0;
		while(!deviceAvailable && timeout++ != 20)
		{
			DeviceHandler::Instance()->MountAll();
			sleep(1);

			for(u8 device = SD; device <= USB8; device++)
				if(DeviceHandler::Instance()->IsInserted(device))
					deviceAvailable = true;
		}

		bool dipOK = Disc_Init() >= 0;

		CMenu menu(vid);
		menu.init(dolLoc);
		mainMenu = &menu;
		if(!deviceAvailable)
		{
			menu.error(L"Could not find a device to save configuration files on!");
			break;
		}
		else if(!iosOK)
		{
			menu.error(sfmt("d2x cIOS %i rev6 or later is required", mainIOS));
			break;
		}
		else if(!dipOK)
		{
			menu.error(L"Could not initialize the DIP module!");
			break;
		}
		else
		{
			if (gameid != NULL && strlen(gameid) == 6)
				menu._directlaunch(gameid);
			else
				ret = menu.main();
		}
		vid.cleanup();
		if (bootHB)
		{
			IOS_ReloadIOS(58);
			BootHomebrew();
		}

	} while (ret == 1);

	WifiGecko_Close();

	Nand::Instance()->Disable_Emu();
	Nand::DestroyInstance();

	Sys_Exit();
	return 0;
};
예제 #3
0
파일: main.cpp 프로젝트: smurk-too/wodebrew
int old_main()
{
	geckoinit = InitGecko();
	use_dvdx = 1;
	
	InitDVD();

	SYS_SetArena1Hi((void *)0x81200000);	// See loader/apploader.c
	CVideo vid;
	
	gprintf("WodeFlow started, running with ios %d\n", IOS_GetVersion());

	bool dipOK = false;
	int ret = 0;
	bool hbc;
	bool wodeOK = false;
		
	// MEM2 usage :
	// 36 MB for general purpose allocations
	// 12 MB for covers (and temporary buffers)
	// adds 15 MB from MEM1 to obtain 27 MB for covers (about 150 HQ covers on screen)
	MEM2_init(36, 12);	// Max ~48

	// Launched through the HBC?
    hbc = *((u32 *) 0x80001804) == 0x53545542 && *((u32 *) 0x80001808) == 0x48415858;

	// Init video
	vid.init();
	
	// Init
	STexture texWait;
	texWait.fromPNG(wait_png, GX_TF_RGB565, ALLOC_MALLOC);
	vid.waitMessage(texWait);
	Sys_Init();
	Sys_ExitToWiiMenu(true);

	Fat_Mount();

	WPAD_Init();
	WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);

	dipOK = Disc_Init() >= 0;
	if (dipOK) {
		u32 status = 0;
		if (WDVD_GetCoverStatus(&status) != 0 || (status & 2) == 0) {
			// WDVD_WaitForDisc();
			
			STexture texWaitForDisc;
			texWaitForDisc.fromPNG(wait_disc_png, GX_TF_RGB565, ALLOC_MALLOC);
			vid.waitMessage(texWaitForDisc);
			texWaitForDisc.data.release();
			do
			{
				WPAD_ScanPads();
				s32 padsState = WPAD_ButtonsDown(0);
				if ((padsState & WPAD_BUTTON_B) != 0)
					break;
				usleep(100 * 1000);
			} while (WDVD_GetCoverStatus(&status) != 0 || (status & 2) == 0);
			if ((status & 2) == 0) return -2;
			
			InitDVD();
		}
	}
	
	wodeOK = WBFS_Init() >= 0;
	vid.waitMessage(texWait);
	texWait.data.release();
	
	MEM2_takeBigOnes(true);
	do
	{
		CMenu menu(vid);
		menu.init(hbc);

		if (!dipOK)
			menu.error(L"Could not initialize DIP module!");
		else if (!wodeOK)
			menu.error(L"Wode not found.");
		else
		{
			ret = menu.main();
		}
		vid.cleanup();
	} while (ret == 1);
	
	LaunchISO(0, 0);
	CloseWode();
	
	Fat_Unmount();
	
	return ret;
};
예제 #4
0
int main(void) {
    int ret;
    void *frame_buffer = NULL;
    GXRModeObj *rmode = NULL;
    
    /* The game's boot loader is statically loaded at 0x81200000, so we'd better
     * not start mallocing there! */
    SYS_SetArena1Hi((void *)0x81200000);

    /* initialise all subsystems */
    if (!Event_Init(&main_event_fat_loaded))
        goto exit_error;
    if (!Apploader_Init())
        goto exit_error;
    if (!Module_Init())
        goto exit_error;
    if (!Search_Init())
        goto exit_error;
    
    /* main thread is UI, so set thread prior to UI */
    LWP_SetThreadPriority(LWP_GetSelf(), THREAD_PRIO_UI);

    /* configure the video */
    VIDEO_Init();
    
    rmode = VIDEO_GetPreferredMode(NULL);
    
    frame_buffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
    if (!frame_buffer)
        goto exit_error;
    console_init(
        frame_buffer, 20, 20, rmode->fbWidth, rmode->xfbHeight,
        rmode->fbWidth * VI_DISPLAY_PIX_SZ);

    /* spawn lots of worker threads to do stuff */
    if (!Apploader_RunBackground())
        goto exit_error;
    if (!Module_RunBackground())
        goto exit_error;
    if (!Search_RunBackground())
        goto exit_error;
        
    VIDEO_Configure(rmode);
    VIDEO_SetNextFramebuffer(frame_buffer);
    VIDEO_SetBlack(false);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    if (rmode->viTVMode & VI_NON_INTERLACE)
        VIDEO_WaitVSync();

    /* display the welcome message */
    printf("\x1b[2;0H");
    printf("BrainSlug Wii  v%x.%02x.%04x"
#ifndef NDEBUG
        " DEBUG build"
#endif
        "\n",
        BSLUG_VERSION_MAJOR(BSLUG_LOADER_VERSION),
        BSLUG_VERSION_MINOR(BSLUG_LOADER_VERSION),
        BSLUG_VERSION_REVISION(BSLUG_LOADER_VERSION));
    printf(" by Chadderz\n\n");
   
    if (!__io_wiisd.startup() || !__io_wiisd.isInserted()) {
        printf("Please insert an SD card.\n\n");
        do {
            __io_wiisd.shutdown();
        } while (!__io_wiisd.startup() || !__io_wiisd.isInserted());
    }
    __io_wiisd.shutdown();
    
    if (!fatMountSimple("sd", &__io_wiisd)) {
        fprintf(stderr, "Could not mount SD card.\n");
        goto exit_error;
    }
    
    Event_Trigger(&main_event_fat_loaded);
        
    printf("Waiting for game disk...\n");
    Event_Wait(&apploader_event_disk_id);
    printf("Game ID: %.4s\n", os0->disc.gamename);
        
    printf("Loading modules...\n");
    Event_Wait(&module_event_list_loaded);
    if (module_list_count == 0) {
        printf("No valid modules found!\n");
    } else {
        size_t module;
        
        printf(
            "%u module%s found.\n",
            module_list_count, module_list_count > 1 ? "s" : "");
        
        for (module = 0; module < module_list_count; module++) {
            printf(
                "\t%s %s by %s (", module_list[module]->name,
                module_list[module]->version, module_list[module]->author);
            Main_PrintSize(module_list[module]->size);
            puts(").");
        }
        
        Main_PrintSize(module_list_size);
        puts(" total.");
    }
    
    Event_Wait(&apploader_event_complete);
    Event_Wait(&module_event_complete);
    fatUnmount("sd");
    __io_wiisd.shutdown();
    
    if (module_has_error) {
        printf("\nPress RESET to exit.\n");
        goto exit_error;
    }
    
    if (apploader_game_entry_fn == NULL) {
        fprintf(stderr, "Error... entry point is NULL.\n");
    } else {
        if (module_has_info || search_has_info) {
            printf("\nPress RESET to launch game.\n");
            
            while (!SYS_ResetButtonDown())
                VIDEO_WaitVSync();
            while (SYS_ResetButtonDown())
                VIDEO_WaitVSync();
        }
        
        SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
        apploader_game_entry_fn();
    }

    ret = 0;
    goto exit;
exit_error:
    ret = -1;
exit:
    while (!SYS_ResetButtonDown())
        VIDEO_WaitVSync();
    while (SYS_ResetButtonDown())
        VIDEO_WaitVSync();
    
    VIDEO_SetBlack(true);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    
    free(frame_buffer);
        
    exit(ret);
        
    return ret;
}