Ejemplo n.º 1
0
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);
		}
	}
Ejemplo n.º 2
0
void grlib_Init (void)
	{
	memset (&grlibSettings, 0, sizeof (s_grlibSettings));
	grlibSettings.wiiswitch_poweroff = false;
	grlibSettings.wiiswitch_reset = false;
	
    // Initialise the Wiimotes & Gamecube
	PAD_Init(); 
    WPAD_Init();
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);

	VIDEO_Init();
	VIDEO_SetBlack(true);  // Disable video output during initialisation
	VIDEO_WaitVSync();
	VIDEO_WaitVSync();

    GRRLIB_Init(1,0);

	WPAD_SetVRes(0, 640, 480);
	WPAD_SetPowerButtonCallback( wmpower_cb );
	
	SYS_SetPowerCallback (power_cb);
    SYS_SetResetCallback (reset_cb);
	
	redrawTex = GRRLIB_CreateEmptyTexture (rmode->fbWidth, rmode->efbHeight);
	popPushTex = GRRLIB_CreateEmptyTexture (rmode->fbWidth, rmode->efbHeight);
	
	grlibSettings.RedrawCallback = NULL;
	
	grlibSettings.pointer[0] = NULL;
	grlibSettings.pointer[1] = NULL;
	grlibSettings.pointer[2] = NULL;
	grlibSettings.pointer[3] = NULL;
	}
Ejemplo n.º 3
0
void IN_Init (void)
{
#if FORCE_KEY_BINDINGS
	// Set up the key bindings.
	Cbuf_AddText("bind JOY1 +jump\n");
	Cbuf_AddText("bind JOY2 +speed\n");
	Cbuf_AddText("bind JOY4 \"impulse 10\"\n");
	Cbuf_AddText("bind JOY6 +attack\n");
#endif

	last_irx = -1;
	last_iry = -1;

	in_osk = 0;

	in_pitchangle = .0f;
	in_yawangle = .0f;
	in_rollangle = .0f;

	WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(WPAD_CHAN_ALL, wiimote_ir_res_x, wiimote_ir_res_y);

	Cvar_RegisterVariable(&osk_repeat_delay);
	Cvar_RegisterVariable(&kb_repeat_delay);

	keycode_normal[225] = K_LSHIFT;
	keycode_normal[229] = K_RSHIFT;

	keycode_shifted[225] = K_LSHIFT;
	keycode_shifted[229] = K_RSHIFT;
}
Ejemplo n.º 4
0
static void *wii_poll_thread(void *dud)
{
  WPAD_Init();
  WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS);
  WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);
  WPAD_SetVRes(0, 640 + PTR_BORDER_W * 2, 350 + PTR_BORDER_H * 2);

  PAD_Init();

  KEYBOARD_Init(NULL);
  MOUSE_Init();

  while(1)
  {
    VIDEO_WaitVSync();
    poll_input();
  }

  return 0;
}
Ejemplo n.º 5
0
/****************************************************************************
 * SetupPads
 *
 * Sets up userInput triggers for use
 ***************************************************************************/
void SetupPads()
{
	WPAD_SetIdleTimeout(60);

	// read wiimote accelerometer and IR data
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(WPAD_CHAN_0, screenwidth, screenheight);

	userInput[0].chan = 0;
	userInput[0].wpad = WPAD_Data(0);
}
Ejemplo n.º 6
0
void ogc_input__init(void)
{
  PAD_Init ();

#ifdef HW_RVL
  WPAD_Init();
	WPAD_SetIdleTimeout(60);
  WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
  WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
#endif
}
Ejemplo n.º 7
0
void ogc_input__init(void)
{
  PAD_Init ();

#ifdef HW_RVL
  WPAD_Init();
  WPAD_SetIdleTimeout(60);
  WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
  WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
#endif
  /* register SOFTRESET */
  SYS_SetResetCallback(set_softreset);
}
Ejemplo n.º 8
0
void init_video_and_wpad()
{
	// Video and WPAD initialized?
	if(video_and_wpad_initialized)
	{
		return;
	}
	
	// Initialise the video system
	VIDEO_Init();
	
	// Obtain the preferred video mode from the system
	// This will correspond to the settings in the Wii menu
	rmode = VIDEO_GetPreferredMode(NULL);

	// Allocate memory for the display in the uncached region
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	
	// Set up the video registers with the chosen mode
	VIDEO_Configure(rmode);
	
	// Tell the video hardware where our display memory is
	VIDEO_SetNextFramebuffer(xfb);
	
	// Make the display visible
	VIDEO_SetBlack(FALSE);

	// Flush the video register changes to the hardware
	VIDEO_Flush();

	// Wait for Video setup to complete
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

	// Set console parameters
    int x = 24, y = 32, w, h;
    w = rmode->fbWidth - (32);
    h = rmode->xfbHeight - (48);

    // Initialize the console - CON_InitEx works after VIDEO_ calls
	CON_InitEx(rmode, x, y, w, h);

	// Clear the garbage around the edges of the console
    VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK);
	
	// This function initialises the attached controllers
	WPAD_Init();
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	
	video_and_wpad_initialized = TRUE;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
static void refreshAvailable(void){

	int i;
	u32 expType;
	WPAD_ScanPads();
	for(i=0; i<4; ++i){
		int err = WPAD_Probe(i, &expType);
		if(err == WPAD_ERR_NONE &&
		   expType == WPAD_EXP_CLASSIC){
			controller_Classic.available[i] = 1;
			WPAD_SetDataFormat(i, WPAD_DATA_EXPANSION);
		} else
			controller_Classic.available[i] = 0;
	}
}
Ejemplo n.º 11
0
void Open_Inputs(void)
{
    s32 status = WPAD_GetStatus();
    if(status != WPAD_STATE_ENABLED && status != WPAD_STATE_ENABLING)
    {
        /* Initialize Wiimote subsystem */
        PAD_Init();
        WPAD_Init();

        /* Set POWER button callback */
        WPAD_SetPowerButtonCallback(__Wpad_PowerCallback);

        WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);

        WPAD_SetIdleTimeout(60*5); // idle after 5 minutes
    }
}
Ejemplo n.º 12
0
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;
}
Ejemplo n.º 13
0
/****************************************************************************
 * SetupPads
 *
 * Sets up userInput triggers for use
 ***************************************************************************/
void
SetupPads()
{
	PAD_Init();

	#ifdef HW_RVL
	// read wiimote accelerometer and IR data
	WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
	#endif

	for(int i=0; i < 4; i++)
	{
		userInput[i].chan = i;
		#ifdef HW_RVL
		userInput[i].wpad = WPAD_Data(i);
		#endif
	}
}
Ejemplo n.º 14
0
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;
}
Ejemplo n.º 15
0
   Game::Game()
    : font(0), debugDrawEnabled(false)
   {
      GRRLIB_Init();
      this->font = GRRLIB_LoadTTF(FreeMonoBold_ttf, FreeMonoBold_ttf_size);
      this->console.initialize(this->font);
      Console::log(LOG_INFO, "=============================================================");
      
      // Black background
      GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);

      Console::log(LOG_INFO, "Game::Game() - video initialised"); 
      
      // Initialise Wiimote
      WPAD_Init();
      WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
      Console::log(LOG_INFO, "Game::Game() - wiimote initialized");
      
      Console::log(LOG_INFO, "Game::Game() - end");
   }
Ejemplo n.º 16
0
void initialise(void) 
{
	VIDEO_Init();
	WPAD_Init();
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	vmode = VIDEO_GetPreferredMode(NULL);
	xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
	xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
	console_init(xfb[0],20,20,vmode->fbWidth,vmode->xfbHeight,vmode->fbWidth*VI_DISPLAY_PIX_SZ);
	VIDEO_Configure(vmode);
	VIDEO_SetNextFramebuffer(xfb[0]);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(vmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
	
	printf("\x1b[2;0H"); // start at 2nd row, 0th column

	printf("switch2sneek: simple application to boot to sneek v2\n\n");
}
Ejemplo n.º 17
0
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.");
	}
}
Ejemplo n.º 18
0
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;
};
Ejemplo n.º 19
0
int main(int argc, char **argv) {

  GRRLIB_Init();	
	
  // Initialise the attached controllers
  WPAD_Init();
  WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	
  // Initialise the audio subsystem
  AESND_Init(NULL);
	
  MODPlay_Init(&play);
  MODPlay_SetMOD(&play,bg_music);
  MODPlay_SetVolume(&play,63,63);
  MODPlay_Start(&play);

  cui_cursor cursor;
  cursor.tex[0]=GRRLIB_LoadTexture(player1_point_png);
  cursor.tex[1]=GRRLIB_LoadTexture(player1_grab_png);
  cursor.is_grabbing=false; 
	
  cui_board board;
	
  ENGINE engine = FIRSTCHESS;
  if(engine == TSCP){
    int i;
    for (i=0; i < CUI_TILE_NB; i++) {
      board.piece[i]=init_piece[i];
      if(init_color[i] == 1){
	board.color[i]=CUI_BLACK;
      }else if (init_color[i] == 6){
	board.color[i]=CUI_EMPTY;
      }else if (init_color[i] == 0){
	board.color[i]=CUI_WHITE;
      }
    }
			
    init_hash();
    init_board();
    open_book();
    gen();
  }


  cui_board_read_core(&board, engine);

  GRRLIB_SetBackgroundColour(0x030, 0x30, 0x42, 0xFF);
	
  board.tile_color1 = 0xAAAAAAFF;
  board.tile_color2 = 0x444444FF;
  board.piece_color1 = 0xAAAAAAFF;
  board.piece_color2 = 0x444444FF;
	
  cui_board_init(&board);

  cui_game game;
  game.board = &board;
  game.engine = engine; 
  game.cursor = &cursor;
  game.is_mute = false;
  GRRLIB_texImg *tex_wallpaper = GRRLIB_LoadTexture(wall_jpg);
  game.tex_wallpaper = tex_wallpaper;
			
	
  voice = AESND_AllocateVoice(aesnd_callback);
  AESND_SetVoiceVolume(voice, 0xFF, 0xFF);
  AESND_SetVoiceStream(voice, true);

  cui_menu current_state = CUI_MENU_MAIN;
	 
  while(current_state != CUI_MENU_EXIT) {
    switch(current_state){
    case CUI_MENU_MAIN:	current_state=menu_main(&game);break;
    case CUI_MENU_PLAY:	current_state=menu_play(&game);break;
    case CUI_MENU_OPTION:current_state=menu_option(&game);break;
    case CUI_MENU_OPTION_GENERAL:current_state=menu_option_general(&game);break;
    case CUI_MENU_OPTION_GFX:current_state=menu_option_gfx(&game);break;
    case CUI_MENU_OPTION_SND:current_state=menu_option_snd(&game);break;
    case CUI_MENU_CREDITS:current_state=menu_credits(&game);break;
    case CUI_MENU_PAUSE:current_state=menu_pause(&game);break;
    case CUI_MENU_HOME:current_state=menu_home(&game);break;
    case CUI_MENU_EXIT:current_state=menu_exit(&game);break;
    default:break;
    }
  }
	
  GRRLIB_FreeTexture(tex_wallpaper);
  GRRLIB_FreeTexture(cursor.tex[0]);
  GRRLIB_FreeTexture(cursor.tex[1]);
  GRRLIB_Exit();
  return 0;
}
Ejemplo n.º 20
0
int main() {

    // Initializing GRRLIB
    GRRLIB_Init();

    // Initializing Wiimotes
    WPAD_Init();
    // IR init
    rmode = VIDEO_GetPreferredMode(NULL);
    GXRModeObj *rmode = IR_Init();
    WPAD_SetVRes(WPAD_CHAN_ALL,rmode->fbWidth,rmode->xfbHeight);
    WPAD_SetDataFormat(WPAD_CHAN_0,WPAD_FMT_BTNS_ACC_IR);

    //IR pointer
    ir_t irPointer;

    // Data textures
    GRRLIB_texImg * texFont = GRRLIB_LoadTexture(font_png);
    GRRLIB_InitTileSet(texFont, 8, 16, 0);
    GRRLIB_texImg* pointer = GRRLIB_LoadTexture(pointer_png);
    GRRLIB_SetMidHandle(pointer,true);

    // Objects
    Button left;
    left.initButton(0, maxY/2, 15, 60);
    Button right;
    right.initButton(maxX-15, maxY/2, 15, 60);	
    Circle move;
    move.initCircle(maxX/2, maxY/2, 10);

    // Globals variables
    bool finProgramme = false;	
    int pass = 0;
    float b=0.0;
    float speed = 3;
    int scoreL = 0;
    int scoreR = 0;

    while (!finProgramme){


        WPAD_ScanPads();  //Scan wiimotes
        WPAD_IR(WPAD_CHAN_0, &irPointer);

        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) finProgramme = true;

        //==================== DRAW START ========================
        GRRLIB_Rectangle(left.x, left.y, left.width, left.height, 0xFF0000FF, 1);
        GRRLIB_Rectangle(right.x, right.y, right.width, right.height, 0x00FF00FF, 1);
        GRRLIB_Circle(move.x, move.y, move.radius, CLR_WHITE, 2);	  
        //GRRLIB_DrawImg(irPointer.x, irPointer.y, pointer, 0, 1, 1, CLR_WHITE);

        //GRRLIB_DrawImg(0,0,titlescreen,0,1,1,CLR_UNKNOW);
        char* posX =(char*)malloc(sizeof(char));
        char* posY =(char*)malloc(sizeof(char));
        char* showScoreL = (char*)malloc(sizeof(char));
        char* showScoreR = (char*)malloc(sizeof(char));
        sprintf(posX,"%.3f",irPointer.x);
        sprintf(posY,"%.3f",irPointer.y);
        sprintf(showScoreL, "%d", scoreL);
        sprintf(showScoreR, "%d", scoreR);
        GRRLIB_Printf(20 + 15, 16 + 15, texFont, CLR_WHITE, 2, posX);
        GRRLIB_Printf(20 + 15, 16 + 60, texFont, CLR_WHITE, 2, posY);
        GRRLIB_Printf(300, 50, texFont, 0xFF0000FF, 2, showScoreL);
        GRRLIB_Printf(340, 50, texFont, 0x00FF00FF, 2, showScoreR);
        free(posX);
        free(posY);
        free(showScoreL);
        free(showScoreR);
        GRRLIB_Render();
        //================== DRAW END ==============================

        // Calculate the new positions, speeds, etc…
        isMoving(move, right, left, pass, speed, b);

        // Move the player's pointer
        bMove(right, irPointer);
        // Move the IA player
        ia(left, move, speed);

        // If the ball reaches one side of the screen,
        // Start a new game and count the points !
        if(move.x - move.radius > maxX) {
            scoreL += 1;
            move.x = maxX/2;
            move.y = maxY/2;
            b = 0.0;
            pass = 0;
            speed = 3;
        }
        if (move.x + move.radius < 0) {
            scoreR += 1;
            move.x = maxX/2;
            move.y = maxY/2;
            b = 0.0;
            pass = 0;
            speed = 3;
        }
    }

    // Clean memory
    GRRLIB_Exit();

    exit(0);
}
Ejemplo n.º 21
0
int main(int argc, char* argv[])
{
	int ret;
	u32 pressed;
	u32 pressedGC;	

	Init_Console();
	printf("\x1b[%u;%um", 37, false);

	PAD_Init();
	WPAD_Init();
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);					

	printheadline();


	ret = *((int *)MAGIC1);
	if (ret == MAGIC2) {
		ret = *((int *)MAGIC3);
		if (ret == MAGIC4) {
			ret = *((int *)MAGIC3 + 1);
			printf("\nSo this now makes %d times you've tried to rerun me, pirate.\n", ret);
			printf("I told you before, you need to try harder than that.\n\n");
			printf("Keep trying and I'll give you a hint...\n\n");
			if (ret > 5) {
				printf("You're persistent aren't you?  Here's a hint:\nShow me that you don't pirate all of your Wii games.\n\n");
			}
			if (ret > 10) {
				printf("You're really persistent!  The hint means to play a game normally in your Wii.\n");
				printf("There are other ways around the trap too, but figure them out yourself.\n");
			}
			ret++;
		} else {
			ret = 2;
			printf("\nSo you tell me you're a pirate and you expect that running\n");
			printf("the application a second time is enough for me to forgive you?\n");
			printf("You're going to have to try something harder than that, mate.\n");
			*((int *)MAGIC3) = MAGIC4;
		}
		*((int *)MAGIC3 + 1) = ret;
		sleep(ret*2);
		printf("\nPress any button to exit...\n");
		waitforbuttonpress(NULL, NULL);
	
		Reboot();
	}

	
	
	printf("WARNING: If you are not connected to the Internet, this app might crash.\n");
	printf("If you get a DSI error, rerun the app and be a little quicker.\n\n");
	printf("\nThis Application will install IOS236 onto your Wii.\n");
	printf("It relies on the fact that you launched this app with.\n");
	printf("the AHBPROT flags set, so you must be using HBC 1.07 or\n");
	printf("later.\n");
	printf("\nIOS236 is a patched IOS36 v3351 and this app can be used\n");
	printf("instead of the Trucha Bug Restorer, upon which the app\n");
	printf("was based.\n");
	printf("\nThis application should work on all Wii firmwares 4.3 and below,\n");
	printf("and as long as the HBC supports AHBPROT, it should work on newer\n");
	printf("firmwares too.  It is safe to use this application to reinstall\n");
	printf("IOS236 or replace a different IOS236.\n");
	printf("\nThanks, in no particular order, go to Wiipower, oggzee, Team Twiizers,\n");
	printf("tona, Joseph Jordan and anybody else who has code included in\n");
	printf("the app.  The app was quite a simple job, built upon their\n");
	printf("actual real work.\n");
	/*printf("\nPlease Wait...\n");
	
	time_t t = time(NULL) + 7;
	while (time(NULL) < t)
	{
		WPAD_ScanPads();
		PAD_ScanPads();
		if(WPAD_ButtonsDown(0) || PAD_ButtonsDown(0)) 
		{
			printf("Don't be impatient, press any button to exit...\n");
			waitforbuttonpress(NULL, NULL);
			Reboot();
		}
	}*/

	printf("Press 1 or Start to start the application...\n");

	
	waitforbuttonpress(&pressed, &pressedGC);
	if (pressed != WPAD_BUTTON_1 && pressedGC != PAD_BUTTON_START)
	{
		printf("Other button pressed, press any button to exit...\n");
		waitforbuttonpress(NULL, NULL);
		Reboot();
	}

	printf("Performing Step 1\n");

	printf("Patching IOS\n");
	if (!IOSPATCH_Apply()) {
        printf("Unable to initialise the initial patches.\n");
		printf("This either means you didn't follow the download\n");
		printf("and launching instructions correctly, or your IOS\n");
		printf("is not vulnerable for an unknown reason.\n");
		printf("Perhaps you need to update the Homebrew Channel (HBC).\n");
		printf("Installation cannot continue.  Press any button to exit...\n");
        waitforbuttonpress(NULL, NULL);
		Reboot();
    }
	printf("IOS patched\n");
	printf("About to install IOS236\n");

	ret = Install_patched_IOS(36, IOS36version, true, true, true, true, 236, 65535, false);
	if (ret < 0) {
		printf("IOS236 Install failed.  Press any button to exit...\n");
		waitforbuttonpress(NULL, NULL);
		Reboot();
	}

	printf("\nStep 1 Complete!\n");
	printf("\nStep 2 is an alteration that is only needed if you plan\n");
	printf("to play games you don't own the original disc for.\n");
	printf("Do you need this alteration?\n\n");
	printf("Press the 1 or X button if you want to play pirated games.\n");
	printf("Press the 2 or Y button if you have no need for piracy.\n");
	char found = 0;
	while(!found) {
		waitforbuttonpress(&pressed, &pressedGC);
		if (pressed == WPAD_BUTTON_1 || pressedGC == PAD_BUTTON_X) {
			found = 1;
		}
		if (pressed == WPAD_BUTTON_2 || pressedGC == PAD_BUTTON_Y) {
			found = 2;
		}
	}

	if (found == 1) {
		printf("\nPerforming Step 2\n");
		ISFS_Initialize();
		Uninstall_DeleteTicket(1, 236);
		Uninstall_DeleteTitle(1, 236);
		ISFS_Deinitialize();
		*((int *)MAGIC1) = MAGIC2;
		printf("\nStep 2 Complete!\n");
		printf("\nStep 2 was to delete IOS236.  You will need\n");
		printf("to install it again.\n\n");
		printf("Shame on you for being a pirate!\n");
		printf("Sorry if you were just curious or not paying\n");
		printf("attention, but you need to learn to be careful.\n\n");
		printf("While I can't stop you from lying next time,\n");
		printf("I can at least have the satisfaction that I've\n");
		printf("wasted some of your time.\n");
		printf("\nSeriously, though.  Developers do deserve to be paid\n");
		printf("to provide you with entertainment.  At least consider\n");
		printf("buying any game that you play a lot, or that you enjoy\n");
		printf("enough to finish.\n");
		printf("\nOh, and just be glad I didn't delete your HBC ;)\n");
		sleep(10);
		printf("Press any button to exit\n");
		waitforbuttonpress(NULL, NULL);
		Reboot();
	}

	printf("IOS236 Installation is complete!\n");
	printf("Press any button to exit...\n");
	waitforbuttonpress(NULL, NULL);
	
	Reboot();

	return 0;
}
Ejemplo n.º 22
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;
}
Ejemplo n.º 23
0
/**
 * Taken from the devkitPPC template...
 */
void WiiEnvironment::setup()
{

    // Mtx view;
    Mtx model, modelview;
    GXColor background = {0, 0, 0, 0xff};

    // init the vi.
    VIDEO_Init();
    WPAD_Init();
    WPAD_SetDataFormat( WPAD_CHAN_0, WPAD_FMT_BTNS_ACC );

    rmode = VIDEO_GetPreferredMode(NULL);

    // Attempt to initiate the fat filesystem...
    if ( !fatInitDefault() )
    {
        // TODO: Logging somehow?
        exit( 1 );
    }

    // allocate 2 framebuffers for double buffering
    frameBuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
    frameBuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

    VIDEO_Configure(rmode);
    VIDEO_SetNextFramebuffer(frameBuffer[fb]);
    VIDEO_SetBlack(FALSE);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

    // setup the fifo and then init the flipper
    void *gp_fifo = NULL;
    gp_fifo = memalign(32,DEFAULT_FIFO_SIZE);
    memset(gp_fifo,0,DEFAULT_FIFO_SIZE);

    GX_Init(gp_fifo,DEFAULT_FIFO_SIZE);

    // clears the bg to color and clears the z buffer
    GX_SetCopyClear(background, 0x00ffffff);

    // other gx setup
    GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1);
    yscale = GX_GetYScaleFactor(rmode->efbHeight,rmode->xfbHeight);
    xfbHeight = GX_SetDispCopyYScale(yscale);
    GX_SetScissor(0,0,rmode->fbWidth,rmode->efbHeight);
    GX_SetDispCopySrc(0,0,rmode->fbWidth,rmode->efbHeight);
    GX_SetDispCopyDst(rmode->fbWidth,xfbHeight);
    GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter);
    GX_SetFieldMode(rmode->field_rendering,((rmode->viHeight==2*rmode->xfbHeight)?GX_ENABLE:GX_DISABLE));

    GX_SetCullMode(GX_CULL_NONE);
    GX_CopyDisp(frameBuffer[fb],GX_TRUE);
    GX_SetDispCopyGamma(GX_GM_1_0);


    // setup the vertex descriptor
    // tells the flipper to expect direct data
    GX_ClearVtxDesc();
    GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);

    // setup the vertex attribute table
    // describes the data
    // args: vat location 0-7, type of data, data format, size, scale
    // so for ex. in the first call we are sending position data with
    // 3 values X,Y,Z of size F32. scale sets the number of fractional
    // bits for non float data.
    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGB8, 0);

    GX_SetNumChans(1);
    GX_SetNumTexGens(0);
    GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
    GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);

    // setup our camera at the origin
    // looking down the -z axis with y up
    guVector cam = {0.0F, 0.0F, -100.0F},
             up = {0.0F, 1.0F, 0.0F},
             look = {0.0F, 0.0F, 0.0F};
    guLookAt(view, &cam, &up, &look);


    // setup our projection matrix
    // this creates a perspective matrix with a view angle of 90,
    // and aspect ratio based on the display resolution
    f32 w = rmode->viWidth;
    f32 h = rmode->viHeight;
    guPerspective(perspective, 45, (f32)w/h, 0.1F, 300.0F);
    GX_LoadProjectionMtx(perspective, GX_PERSPECTIVE);

}
Ejemplo n.º 24
0
int main(int argc, char *argv[])
{
	#ifdef HW_DOL
	ipl_set_config(6); // disable Qoob modchip
	#endif

	#ifdef WII_DVD
	DI_Init();	// first
	#endif

	int selectedMenu = -1;

	InitDeviceThread();

	InitGCVideo ();
	ResetVideo_Menu (); // change to menu video mode

	// Controllers
	PAD_Init();

	#ifdef HW_RVL
	WPAD_Init();
	// read wiimote accelerometer and IR data
	WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(WPAD_CHAN_ALL,640,480);

	// Wii Power/Reset buttons
	WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
	SYS_SetPowerCallback(ShutdownCB);
	SYS_SetResetCallback(ResetCB);
	#endif

	// Initialise FreeType
	if (FT_Init ())
	{
		printf ("Cannot initialise font subsystem!\n");
		while (1);
	}

	InitialiseAudio();

	// Initialize libFAT for SD and USB
	MountAllFAT();

	// Initialize DVD subsystem (GameCube only)
	#ifdef HW_DOL
	DVD_Init ();
	#endif

	// allocate memory to store rom
	nesrom = (unsigned char *)malloc(1024*1024*3); // 3 MB should be plenty

	/*** Minimal Emulation Loop ***/
	if ( !FCEUI_Initialize() )
	{
		WaitPrompt("Unable to initialize FCE Ultra\n");
		ExitToLoader();
	}

	FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON

	memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory
	cleanSFMDATA(); // clear state data

	// Set defaults
	DefaultSettings();

	// store path app was loaded from
	sprintf(appPath, "fceugx");
	if(argc > 0 && argv[0] != NULL)
		CreateAppPath(argv[0]);

	// Load preferences
	if(!LoadPrefs())
	{
		WaitPrompt("Preferences reset - check settings!");
		selectedMenu = 1; // change to preferences menu
	}

	FCEUI_SetSoundQuality(1); // 0 - low, 1 - high, 2 - high (alt.)
	FCEUI_SetVidSystem(GCSettings.timing); // causes a small 'pop' in the audio

    while (1) // main loop
    {
		#ifdef HW_RVL
		if(ShutdownRequested)
			ShutdownWii();
		#endif

		// go back to checking if devices were inserted/removed
		// since we're entering the menu
		LWP_ResumeThread (devicethread);

    	MainMenu(selectedMenu);
		selectedMenu = 2; // return to game menu from now on

		// stop checking if devices were removed/inserted
		// since we're starting emulation again
		LWP_SuspendThread (devicethread);

		ResetVideo_Emu();

		setFrameTimer(); // set frametimer method before emulation
		SetPalette();

		static int fskipc=0;

		while(1) // emulation loop
		{
			uint8 *gfx;
			int32 *sound;
			int32 ssize;

			#ifdef FRAMESKIP
			fskipc=(fskipc+1)%(frameskip+1);
			#endif

			FCEUI_Emulate(&gfx, &sound, &ssize, fskipc);

			if(!fskipc)
			{
				xbsave = gfx;
				FCEUD_Update(gfx, sound, ssize);
			}

			if(ResetRequested)
			{
				PowerNES(); // reset game
				ResetRequested = 0;
			}

			if(ConfigRequested)
			{
				ResetVideo_Menu();
				if (GCSettings.AutoSave == 1)
				{
					SaveRAM(GCSettings.SaveMethod, SILENT);
				}
				else if (GCSettings.AutoSave == 2)
				{
					SaveState(GCSettings.SaveMethod, SILENT);
				}
				else if(GCSettings.AutoSave == 3)
				{
					SaveRAM(GCSettings.SaveMethod, SILENT);
					SaveState(GCSettings.SaveMethod, SILENT);
				}

				// save zoom level
				SavePrefs(SILENT);

				ConfigRequested = 0;
				break; // leave emulation loop
			}
		}
    }
}
Ejemplo n.º 25
0
int main (int argc, char **argv) {

	VIDEO_Init();
	WPAD_Init();
	PAD_Init();

	sys_rmode = VIDEO_GetPreferredMode(NULL);

	sys_framebuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode));
	sys_framebuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode));

	sys_frame_count = 0;

	CON_Init(sys_framebuffer[sys_frame_count & 1], 20, 20, sys_rmode->fbWidth, sys_rmode->xfbHeight, sys_rmode->fbWidth * VI_DISPLAY_PIX_SZ);

	VIDEO_Configure(sys_rmode);
	VIDEO_SetNextFramebuffer(sys_framebuffer[sys_frame_count & 1]);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(sys_rmode->viTVMode & VI_NON_INTERLACE)
	{
		VIDEO_WaitVSync();
	};

	sys_frame_count++;

	GXU_Init(sys_rmode, sys_framebuffer[sys_frame_count & 1]);

	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(WPAD_CHAN_0, sys_rmode->fbWidth, sys_rmode->xfbHeight);

	if(!fatInitDefault())
	{
		Sys_Error("Filesystem not enabled");
	};

	sys_previous_time = Sys_Milliseconds();
	do 
	{
		sys_netinit_error = if_config(sys_ipaddress_text, NULL, NULL, true);
	} while((sys_netinit_error == -EAGAIN)&&((Sys_Milliseconds() - sys_previous_time) < 3000));
	if(sys_netinit_error < 0)
	{
		printf("Network not enabled\n");
	};

	if (KEYBOARD_Init(Sys_KeyPress) != 0)
	{
		printf("Keyboard not found\n");
	};

	OSK_LoadKeys(Keys_dat, Keys_dat_size);

	int   len, i;
	char  *cmdline;

	// merge the command line, this is kinda silly
	for (len = 1, i = 1; i < argc; i++)
		len += strlen(argv[i]) + 1;
	cmdline = malloc(len);
	*cmdline = 0;
	for (i = 1; i < argc; i++)
	{
		if (i > 1)
			strcat(cmdline, " ");
		strcat(cmdline, argv[i]);
	}

	Com_Init(cmdline);

	WPAD_SetPowerButtonCallback(Sys_PowerOff);

	while (1) {

		sys_previous_time = Sys_Milliseconds();
		if(MOUSE_IsConnected())
		{
			sys_mouse_valid = MOUSE_GetEvent(&sys_mouse_event);
			if(sys_mouse_valid)	MOUSE_FlushEvents();
		}
		else
		{
			sys_mouse_valid = 0;
			sys_mouse_event.button = 0;
		};

		Com_Frame( );

		if(in_osk->value)
		{
			OSK_Draw(sys_rmode, sys_framebuffer[sys_frame_count & 1]);
		};
		sys_frame_count++;
		GXU_EndFrame(sys_framebuffer[sys_frame_count & 1]);

		KEYBOARD_FlushEvents();
		VIDEO_Flush();
		VIDEO_WaitVSync();

	}
	return 0;
}
Ejemplo n.º 26
0
int
main(int argc, char *argv[])
{
    setlocale(LC_ALL, "en.UTF-8");
    geckoinit = InitGecko();

    if (hbcStubAvailable() || geckoinit)
    {
        InitTextVideo();
    }

    //	DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
    //_break();

    __exception_setreload(5);                     //auto reset code dump nobody gives us codedump info anyways.

    gprintf("\n\n------------------");
    gprintf("\nUSB Loader GX rev%s",GetRev());
    gprintf("\nmain(%d", argc);
    for (int i=0;i<argc;i++)
        gprintf(", %s",argv[i]?argv[i]:"<NULL>");
    gprintf(")");

    // This part is added, because we need a identify patched ios
//    printf("\n\tReloading into ios 236");
    if (IOS_ReloadIOSsafe(236) < 0)
    {
//        printf("\n\tIOS 236 not found, reloading into 36");
        IOS_ReloadIOSsafe(36);
    }

    printf("\n\tStarting up");

    MEM2_init(36);                                // Initialize 36 MB
    MEM2_takeBigOnes(true);

    s32 ret;
    bool startupproblem = false;

    bool bootDevice_found=false;
    if (argc >= 1)
    {
        if (!strncasecmp(argv[0], "usb:/", 5))
        {
            strcpy(bootDevice, "USB:");
            bootDevice_found = true;
        } else if (!strncasecmp(argv[0], "sd:/", 4))
        bootDevice_found = true;
    }

    printf("\n\tInitializing controllers");

    /** PAD_Init has to be before InitVideo don't move that **/
    PAD_Init();                                   // initialize PAD/WPAD

    printf("\n\tInitialize USB (wake up)");

    USBDevice_Init();                             // seems enough to wake up some HDDs if they are in sleep mode when the loader starts (tested with WD MyPassport Essential 2.5")

    gprintf("\n\tChecking for stub IOS");
    ios222rev = getIOSrev(0x00000001000000dell);
    ios249rev = getIOSrev(0x00000001000000f9ll);

    //if we don't like either of the cIOS then scram
    if (!(ios222rev==4 || ios222rev==5 || (ios249rev>=9 && ios249rev<65280)))
    {
        InitTextVideo();
        printf("\x1b[2J");
        if ((ios222rev < 0 && ios222rev != WII_EINSTALL) && (ios249rev < 0 && ios249rev != WII_EINSTALL))
        {
            printf("\n\n\n\tWARNING!");
            printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+");
            printf("\n\n\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.");
            printf("\n\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,");
            printf("\n\tand you should go figure out how to get some cios action going on\n\tin your Wii.");
            printf("\n\n\tThis message will show every time.");
            sleep(5);
        }
        else
        {
            printf("\n\n\n\tERROR!");
            printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+");
            printf("\n\n\tI found \n\t\t222 = %d%s",ios222rev,ios222rev==65280?" (Stubbed by 4.2 update)":"");
            printf("\n\t\t249 = %d%s",ios249rev,ios249rev==65280?" (Stubbed by 4.2 update)":"");
            printf("\n\n\tGo figure out how to get some cIOS action going on\n\tin your Wii and come back and see me.");

            sleep(15);
            printf("\n\n\tBye");

            USBDevice_deInit();
            exit(0);
        }
    }

    printf("\n\tReloading ios 249...");
    ret = IOS_ReloadIOSsafe(249);

    printf("%d", ret);

    if (ret < 0)
    {
        printf("\n\tIOS 249 failed, reloading ios 222...");
        ret = IOS_ReloadIOSsafe(222);
        printf("%d", ret);

        if (ret < 0)
        {
            printf("\n\tIOS 222 failed, reloading ios 250...");
            ret = IOS_ReloadIOSsafe(250);
            printf("%d", ret);

            if(ret < 0)
            {
                printf("\n\tIOS 250 failed, reloading ios 223...");
                ret = IOS_ReloadIOSsafe(223);
                printf("%d", ret);

                if (ret < 0)
                {
                    printf("\n\tERROR: cIOS could not be loaded!\n");
                    sleep(5);
                    SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
                }
            }
        }
        printf("\n\tInitialize sd card");
        SDCard_Init();
        printf("\n\tLoad ehc module");
        load_ehc_module();
        printf("\n\tdeinit sd card");
        SDCard_deInit();
    }

    printf("\n\tInit wbfs...");
    ret = WBFS_Init(WBFS_DEVICE_USB);
    printf("%d", ret);

    if (ret < 0)
    {
        printf("\n\tYou have issues with a slow disc, or a difficult disc\n\tReloading 222...");
        ret = IOS_ReloadIOSsafe(222);
        printf("%d", ret);
        /*if(ret < 0) {
        //			printf("\n\tSleeping for 4 seconds");
        //			sleep(4);

            InitVideo(); // Initialise video
            Menu_Render();
            BootUpProblems();
            startupproblem = true;
            ret = 1;
        }*/
        printf("\n\tInitialize sd card");
        SDCard_Init();
        printf("\n\tLoad ehc module");
        load_ehc_module();
        printf("\n\tdeinit sd card");
        SDCard_deInit();

        printf("\n\tInitialize wbfs...");
        USBDevice_deInit();
        USBDevice_Init();
        ret = WBFS_Init(WBFS_DEVICE_USB);
        printf("%d", ret);

        if(ret < 0)
        {
            //			printf("\n\tSleeping for 4 seconds");
            //			sleep(4);
            InitVideo();                          // Initialise video
            Menu_Render();
            BootUpProblems();
            startupproblem = true;
            ret = 1;
        }
    }

    printf("\n\tInitialize sd card");
    SDCard_Init();                                // mount SD for loading cfg's

    //this should have already been done by now in order to WBFS_Init().
    printf("\n\tInitialize usb device");
    USBDevice_Init();                             // and mount USB:/

    if (!bootDevice_found)
    {
        printf("\n\tSearch for configuration file");

        //try USB
        //left in all the dol and elf files in this check in case this is the first time running the app and they dont have the config
        if (checkfile((char*) "USB:/config/GXglobal.cfg") || (checkfile((char*) "USB:/apps/usbloader_gx/boot.elf"))
            || checkfile((char*) "USB:/apps/usbloadergx/boot.dol") || (checkfile((char*) "USB:/apps/usbloadergx/boot.elf"))
            || checkfile((char*) "USB:/apps/usbloader_gx/boot.dol"))
            strcpy(bootDevice, "USB:");

        printf("\n\tConfiguration file is on %s", bootDevice);
    }

    // Try opening and closing the configuration file here
    // to prevent a crash dump later on - giantpune
    char GXGlobal_cfg[26];
    sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice);
    FILE *fp = fopen(GXGlobal_cfg, "r");
    if (fp)
    {
        fclose(fp);
    }

    gettextCleanUp();
    printf("\n\tLoading configuration...");
    CFG_Load();
    printf("done");
    //	gprintf("\n\tbootDevice = %s",bootDevice);

    /* Load Custom IOS */
    if ((Settings.cios == ios222 && IOS_GetVersion() != 222) ||
        (Settings.cios == ios223 && IOS_GetVersion() != 223))
    {
        printf("\n\tReloading IOS to config setting (%d)...", Settings.cios == ios222 ? 222 : 223);
        SDCard_deInit();                          // unmount SD for reloading IOS
        USBDevice_deInit();                       // unmount USB for reloading IOS
        USBStorage2_Deinit();
        ret = IOS_ReloadIOSsafe(Settings.cios == ios222 ? 222 : 223);
        printf("%d", ret);
        SDCard_Init();
        load_ehc_module();
        if (ret < 0)
        {
            SDCard_deInit();
            Settings.cios = ios249;
            ret = IOS_ReloadIOSsafe(249);
            // now mount SD:/  //no need to keep mindlessly mounting and unmounting SD card
            SDCard_Init();
        }

        USBDevice_Init();                         // and mount USB:/
        WBFS_Init(WBFS_DEVICE_USB);
    } else if ((Settings.cios == ios249 && IOS_GetVersion() != 249) ||
        (Settings.cios == ios250 && IOS_GetVersion() != 250))
    {

        printf("\n\tReloading IOS to config setting (%d)...", ios249 ? 249 : 250);
        SDCard_deInit();                          // unmount SD for reloading IOS
        USBDevice_deInit();                       // unmount USB for reloading IOS
        USBStorage2_Deinit();
        ret = IOS_ReloadIOSsafe(ios249 ? 249 : 250);
        printf("%d", ret);
        if (ret < 0)
        {
            Settings.cios = ios222;
            ret = IOS_ReloadIOSsafe(222);
            SDCard_Init();
            load_ehc_module();
        }

        else SDCard_Init();                       // now mount SD:/  //no need to keep mindlessly mounting and unmounting SD card
        USBDevice_Init();                         // and mount USB:/
        WBFS_Init(WBFS_DEVICE_USB);
    }

    //	Partition_GetList(&partitions);

    if (ret < 0)
    {
        printf("\nERROR: cIOS could not be loaded!");
        sleep(5);
        exit(0);
        //SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
    }
    //gprintf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());//don't need gprintf if sending console shit to gecko, too
    printf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());

    //	printf("Sleeping for 5 seconds\n");
    //	sleep(5);

    //if a ID was passed via args copy it and try to boot it after the partition is mounted
    //its not really a headless mode.  more like hairless.
    if (argc > 1 && argv[1])
    {
        if (strlen(argv[1])==6)
            strncpy(headlessID, argv[1], sizeof(headlessID));
    }

    //! Init the rest of the System
    Sys_Init();
    Wpad_Init();
    if(!startupproblem)
        InitVideo();
    InitAudio();                                  // Initialize audio

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

    // load main font from file, or default to built-in font
    fontSystem = new FreeTypeGX();
    char *fontPath = NULL;
    asprintf(&fontPath, "%sfont.ttf", CFG.theme_path);
    fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0);
    fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
    free(fontPath);

    fontClock = new FreeTypeGX();
    fontClock->loadFont(NULL, clock_ttf, clock_ttf_size, 0);
    fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);

    gprintf("\n\tEnd of Main()");
    InitGUIThreads();
    MainMenu(MENU_CHECK);
    return 0;
}
Ejemplo n.º 27
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;
}
Ejemplo n.º 28
0
int main(int argc, char **argv) {
  //  float a = 0.0f;
    s16 Volume = 255;
    s8 SongNum = 0;
    PLAYLIST PlayList[] = { {(u8 *)music_mp3, music_mp3_size}, // lib compiled to ignore mp3, this line is not used - will do nothing is used!
                            {(u8 *)music_mod, music_mod_size},
                            {(u8 *)music_s3m, music_s3m_size},
                            {(u8 *)music_it, music_it_size},
                            {(u8 *)music_xm, music_xm_size} };

 //   GRRLIB_Init();
    //GRRLIB_texImg *tex_Font = GRRLIB_LoadTexture(Impact_9_png);
    //GRRLIB_InitTileSet(tex_Font, 10, 16, 32);

	VIDEO_Init();
	WPAD_Init();

//    WPAD_Init();
    WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC);

  //  GRRLIB_Settings.antialias = true;
  //  GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);

  
  	 SongNum++;
	 
    GRRMOD_Init(true);
    GRRMOD_SetMOD(PlayList[SongNum].Mem, PlayList[SongNum].Size);
    GRRMOD_Start(255); // start tune
			
			
  
    // Loop forever
    while(1) {
       // GRRLIB_2dMode();
        WPAD_ScanPads();  // Scan the Wiimotes

        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) {
            break;
        }
        if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_PLUS) {
            Volume++;
            GRRMOD_SetVolume(Volume, Volume);
        }
        if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS) {
            Volume--;
            GRRMOD_SetVolume(Volume, Volume);
        }
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) {
            GRRMOD_Pause();
        }
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_1) {
            GRRMOD_Start(255);
        }
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_2) {
            GRRMOD_Stop();
        }
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_LEFT) {
            SongNum--;
            if(SongNum < 0) SongNum = 0;
            GRRMOD_Unload();
            GRRMOD_SetMOD(PlayList[SongNum].Mem, PlayList[SongNum].Size);
            GRRMOD_Start(255);
        }
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_RIGHT) {
            SongNum++;
            if(SongNum > 4) SongNum = 4;
            GRRMOD_Unload();
            GRRMOD_SetMOD(PlayList[SongNum].Mem, PlayList[SongNum].Size);
            GRRMOD_Start(255);
        }
		VIDEO_WaitVSync();
    }

    GRRMOD_End();
  //  GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB

    exit(0);  // Use exit() to exit a program, do not use 'return' from main()
}