Exemple #1
0
cui_menu menu_home(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); 
	
	UI_button button_loader;
	UI_InitBtn(&button_loader, 200, 200, "Loader");
	button_loader.img = GRRLIB_LoadTexture(button_png);
	button_loader.font = font;
	
	UI_button button_menu;
	UI_InitBtn(&button_menu, 400, 200, "Wii menu");
	button_menu.img = GRRLIB_LoadTexture(button_png);
	button_menu.font = font;
	

	while(!done)
	{		
		GRRLIB_FillScreen(0x000000FF);
		GRRLIB_PrintfTTF (15, 0, font, "HOME Menu", 96, 0xFFFFFFFF);
		GRRLIB_Line(0, 100, 640, 100, 0xFFFFFFFF);
		UI_DrawBtn(&button_loader);
		UI_DrawBtn(&button_menu);
		cui_cursor_display(p_game->cursor);
		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		UI_UpdateBtn(&button_loader, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_menu, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		if ( pressed & WPAD_BUTTON_HOME ){
			done = true;
		}
		
		if(button_loader.click){
			done=true;
			next_state=CUI_MENU_EXIT;
		}
		
		if(button_menu.click){
			SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
		}
		
		GRRLIB_Render();
		
	}
	
	GRRLIB_FreeTexture(button_loader.img);
	GRRLIB_FreeTexture(button_menu.img);
	free(button_loader.text);
	free(button_menu.text);
	
	return next_state;
}
Exemple #2
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;
}
Exemple #3
0
int main() {
    u32 paddown;
    s8 page = 0;

    // Font texture
    GRRLIB_texImg *text_font1 = GRRLIB_LoadTexture(font1);
    GRRLIB_InitTileSet(text_font1, 32, 36, 32);

    // Load the original texture and create empty texture of the same size as the original one
    GRRLIB_texImg *tex_pirate   = GRRLIB_LoadTexture(pirate);
    GRRLIB_texImg *tex_gray     = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_sepia    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_invert   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur1    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur2    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur3    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur4    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur5    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur6    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel1   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel2   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel3   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel4   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel5   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel6   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter1 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter2 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter3 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter4 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter5 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter6 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_fliph    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_flipv    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_fliphv   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);

    // Let's precalculate the grayscale texture
    GRRLIB_BMFX_Grayscale(tex_pirate, tex_gray);
    GRRLIB_FlushTex(tex_gray);

    // Let's precalculate the sepia texture
    GRRLIB_BMFX_Sepia(tex_pirate, tex_sepia);
    GRRLIB_FlushTex(tex_sepia);

    // Let's precalculate the inverted color texture
    GRRLIB_BMFX_Invert(tex_pirate, tex_invert);
    GRRLIB_FlushTex(tex_invert);

    // Let's precalculate 6 differents blur texture with 6 differents blur factor
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur1, 1);
    GRRLIB_FlushTex(tex_blur1);
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur2, 2);
    GRRLIB_FlushTex(tex_blur2);
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur3, 3);
    GRRLIB_FlushTex(tex_blur3);
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur4, 4);
    GRRLIB_FlushTex(tex_blur4);
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur5, 5);
    GRRLIB_FlushTex(tex_blur5);
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur6, 6);
    GRRLIB_FlushTex(tex_blur6);

    // Let's precalculate 6 differents pixelate texture with 6 differents pixelate factor
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel1, 1);
    GRRLIB_FlushTex(tex_pixel1);
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel2, 2);
    GRRLIB_FlushTex(tex_pixel2);
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel3, 3);
    GRRLIB_FlushTex(tex_pixel3);
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel4, 4);
    GRRLIB_FlushTex(tex_pixel4);
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel5, 5);
    GRRLIB_FlushTex(tex_pixel5);
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel6, 6);
    GRRLIB_FlushTex(tex_pixel6);

    // Let's precalculate 6 differents pixelate texture with 6 differents pixelate factor
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter1, 2);
    GRRLIB_FlushTex(tex_pixel1);
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter2, 4);
    GRRLIB_FlushTex(tex_pixel2);
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter3, 6);
    GRRLIB_FlushTex(tex_pixel3);
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter4, 8);
    GRRLIB_FlushTex(tex_pixel4);
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter5, 10);
    GRRLIB_FlushTex(tex_pixel5);
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter6, 12);
    GRRLIB_FlushTex(tex_pixel6);

    // Let's precalculate for flipping the texture
    GRRLIB_BMFX_FlipH(tex_pirate, tex_fliph);
    GRRLIB_FlushTex(tex_fliph);
    GRRLIB_BMFX_FlipV(tex_pirate, tex_flipv);
    GRRLIB_FlushTex(tex_flipv);
    GRRLIB_BMFX_FlipV(tex_fliph, tex_fliphv);
    GRRLIB_FlushTex(tex_fliphv);

    GRRLIB_Init();
    PAD_Init();

    while(1) {
        PAD_ScanPads();
        paddown = PAD_ButtonsDown(0);

        GRRLIB_FillScreen(0xFFFFFFFF);

        switch(page)
        {
            case 1:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "GRAYSCALE FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_gray, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 2:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "SEPIA FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_sepia, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 3:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "INVERT FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_invert, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 4:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "FLIPH AND FLIPV FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_fliph, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_flipv, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*3, 60, tex_fliphv, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 5:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "BLUR FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_blur1, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_blur2, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*3, 60, tex_blur3, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10, 60+tex_pirate->h*1, tex_blur4, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60+tex_pirate->h*1, tex_blur5, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60+tex_pirate->h*1, tex_blur6, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 6:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "PIXELATE FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_pixel1, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_pixel2, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*3, 60, tex_pixel3, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10, 60+tex_pirate->h*1, tex_pixel4, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60+tex_pirate->h*1, tex_pixel5, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60+tex_pirate->h*1, tex_pixel6, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 7:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "SCATTER FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_scatter1, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_scatter2, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*3, 60, tex_scatter3, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10, 60+tex_pirate->h*1, tex_scatter4, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60+tex_pirate->h*1, tex_scatter5, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60+tex_pirate->h*1, tex_scatter6, 0, 1, 1, 0xFFFFFFFF);
                break;
            default:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "WELCOME TO THE");
                GRRLIB_Printf(10, 40, text_font1, 0X000000FF, 1, "GRRLIB FX DEMO.");
                GRRLIB_Printf(10, 80, text_font1, 0X000000FF, 1, "TO QUIT PRESS THE");
                GRRLIB_Printf(10, 120, text_font1, 0X000000FF, 1, "HOME BUTTON.");
                GRRLIB_Printf(10, 160, text_font1, 0X000000FF, 1, "USE + OR - TO MOVE");
                GRRLIB_Printf(10, 200, text_font1, 0X000000FF, 1, "ACROSS PAGES.");
        }

        GRRLIB_Render();
        if(paddown & PAD_BUTTON_START) {
            break;
        }
        if(paddown & PAD_BUTTON_X) {
            page--;
            if(page < 0) page = 7;
        }
        if(paddown & PAD_BUTTON_Y) {
            page++;
            if(page > 7) page = 0;
        }
    }
    GRRLIB_FreeTexture(tex_pirate);
    GRRLIB_FreeTexture(tex_gray);
    GRRLIB_FreeTexture(tex_sepia);
    GRRLIB_FreeTexture(tex_invert);
    GRRLIB_FreeTexture(tex_fliph);
    GRRLIB_FreeTexture(tex_flipv);
    GRRLIB_FreeTexture(tex_fliphv);
    GRRLIB_FreeTexture(tex_blur1);
    GRRLIB_FreeTexture(tex_blur2);
    GRRLIB_FreeTexture(tex_blur3);
    GRRLIB_FreeTexture(tex_blur4);
    GRRLIB_FreeTexture(tex_blur5);
    GRRLIB_FreeTexture(tex_blur6);
    GRRLIB_FreeTexture(tex_pixel1);
    GRRLIB_FreeTexture(tex_pixel2);
    GRRLIB_FreeTexture(tex_pixel3);
    GRRLIB_FreeTexture(tex_pixel4);
    GRRLIB_FreeTexture(tex_pixel5);
    GRRLIB_FreeTexture(tex_pixel6);
    GRRLIB_FreeTexture(tex_scatter1);
    GRRLIB_FreeTexture(tex_scatter2);
    GRRLIB_FreeTexture(tex_scatter3);
    GRRLIB_FreeTexture(tex_scatter4);
    GRRLIB_FreeTexture(tex_scatter5);
    GRRLIB_FreeTexture(tex_scatter6);
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
    return 0;
}
Exemple #4
0
int main(int argc, char **argv)
{
    SYS_SetResetCallback(WiiResetPressed);
    SYS_SetPowerCallback(WiiPowerPressed);
    usleep(250*1000);
    GRRLIB_Init();
    GRRLIB_ttfFont *font = GRRLIB_LoadTTF(verdana_ttf, verdana_ttf_size);
    
    
    WPAD_Init();
    USB_Initialize();
    USB_DeviceChangeNotifyAsync(USB_CLASS_HID, change_notify_cb, NULL);    
    int dev_id = get_device_id();
    int fd = open_device(dev_id);
    
    struct ds4_input data;
    memset(&data, 0, sizeof(data));
    fetch_data(fd, &data);
    random_leds(fd);
    
    int screenW = rmode->fbWidth, screenH = rmode->efbHeight;
    float pos_x = screenW/2, pos_y = screenH/2;
    while (run) {
        WPAD_ScanPads();
        u32 pressed = WPAD_ButtonsDown(0);
        if (pressed & WPAD_BUTTON_B) {
            dev_id = get_device_id();
            fd = open_device(dev_id);
        }
        if (pressed & WPAD_BUTTON_A) {
            random_leds(fd);
        }
        GRRLIB_FillScreen(0x0);
        GRRLIB_PrintfTTF(15, 15, font, "ds4wii by xerpi | L1: center | R1: random color", 15, 0xFFFFFFFF);
        
        u32 color = (r<<24)|(g<<16)|(b<<8)|0xFF;
        GRRLIB_Circle(pos_x, pos_y, 15, color, 0);
        GRRLIB_Circle(pos_x, pos_y, 14, color, 0);
        
        memset(&data, 0, sizeof(data));
        fetch_data(fd, &data);
        if (data.L1) {pos_x = screenW/2, pos_y = screenH/2;}
        if (data.R1) {random_leds(fd);}
        //1920x940
        if (data.finger1active) {
            GRRLIB_Circle((screenW/1920.0f)*data.finger1X, (screenH/940.0f)*data.finger1Y, 10, 0x00FF00FF, 1);
        }
        if (data.finger2active) {
            GRRLIB_Circle((screenW/1920.0f)*data.finger2X, (screenH/940.0f)*data.finger2Y, 10, 0x0000FFFF, 1);
        }
        
        
        /*char buf1[256];
        sprintf(buf1, "aX: %8hi  aY: %8hi  aZ: %8hi", data.accelX, data.accelY, data.accelZ);
        char buf2[256];
        sprintf(buf2, "gyroX: %8hi  gyroY: %8hi  gyroZ: %8hi", data.gyroX, data.gyroY, data.gyroZ);
        GRRLIB_PrintfTTF(15, 30, font, buf1, 14, 0xFFFFFFFF);
        GRRLIB_PrintfTTF(15, 45, font, buf2, 14, 0xFFFFFFFF);
        */
        
        #define THRESHOLD 50.0f
        if (fabs(data.accelX) > THRESHOLD)
            pos_y -= data.accelX/55.0f;
        if (fabs(data.accelY) > THRESHOLD)
            pos_x -= data.accelY/55.0f;
        
        if (pressed & WPAD_BUTTON_HOME) run = 0;
        GRRLIB_Render();
    }
    
    USB_CloseDevice(&fd);
    USB_Deinitialize();
    GRRLIB_FreeTTF (font);
    GRRLIB_Exit();
    exit(0);
    return 0;
}
Exemple #5
0
 int showDOLWindow(int nr)
 { 
         int ret = 1;
         bool doloop = true; 
         int fade = 5; 
         int y, sp; 
         int i;
		 
		 okButton.x = 353;
		 okButton.y = 335;
  
		 switch(nr)
		 {
			case 1:
				CFG_COUNT = CFG_METROID_COUNT;
				for ( i=0; i<CFG_COUNT; i++)
					strcpy(Episode[i], MPT_DOL[i]);
				break;
			case 2:
				CFG_COUNT = CFG_HOD23_COUNT;
				for ( i=0; i<CFG_COUNT; i++)
					strcpy(Episode[i], HOD23_DOL[i]);
				break;
		 }
  
         do{ 
			y = 115; 
			sp = 0; 

			WPAD_ScanPads(); 
			PAD_ScanPads(); 
			GetWiimoteData(); 

			draw_covers(); 
			GRRLIB_2D_Init(); 
			GRRLIB_FillScreen(0x00000000|fade); 

			GRRLIB_Rectangle(40, 106, 560, 276, 0xffffffdd, true);
			GRRLIB_Rectangle(42, 108, 556, 272, 0x737373FF, true);
			GRRLIB_Rectangle(268, 168, 304, 44, 0xffffffdd, true);
			GRRLIB_Rectangle(270, 170, 300, 40, 0x000000FF, true);

			// Get the title info
			struct discHdr *header = NULL;
			header = &self.gameList[self.gameSelected];
			char gameName[MAX_TITLE_LEN]; 

			if(self.usingTitlesTxt)
			{
				// Load a custom title
				sprintf(gameName, "%s", header->title);
				getTitle(titleList, (char*)header->id, gameName);
			}
			else
				sprintf(gameName, "%s", (header->title));

			// Chomp the title to fit
			if(strlen(gameName) >= 22)
			{
				//strncpy(gameName, header->title, 17);
				gameName[19] = '\0';
				strncat(gameName, "...", 3);
			}

			// Display Title, Last Played, and Size
			char tTemp[50];
			sprintf(tTemp,"%s",gameName);
			CFreeTypeGX_DrawText(ttf20pt, 420, 200, tTemp, (GXColor){0xff, 0xff, 0xff, 0xff}, FTGX_JUSTIFY_CENTER);
			CFreeTypeGX_DrawText(ttf20pt, 268, 149, "Episode to play ?", (GXColor){0xff, 0xff, 0xff, 0xff}, FTGX_JUSTIFY_LEFT);

			CFreeTypeGX_DrawText(ttf16pt, 350, 280, "Episode:", (GXColor){0x00, 0x00, 0x00, 0xff}, FTGX_JUSTIFY_RIGHT);
			CFreeTypeGX_DrawText(ttf16pt, 503, 280,  Episode[ret -1], (GXColor){0xff, 0xff, 0xff, 0xff}, FTGX_JUSTIFY_CENTER);


			// Draw the game cover
			if(self.gameSelected < MAX_BUFFERED_COVERS || self.gameSelected >= 0)
			{
				if(BUFFER_IsCoverReady(self.gameSelected))
				{
					pthread_mutex_lock(&buffer_mutex[self.gameSelected]);
					if(_texture_data[self.gameSelected].data)
					{
						if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
						{
							if(settings.covers3d)
							{
								GRRLIB_DrawFlatCoverImg(60, 131, _texture_data[self.gameSelected], 0, AR_16_9, 1, 0xFFFFFFFF);
							}
							else
							{
								GRRLIB_DrawImg(60, 131, _texture_data[self.gameSelected], 0, AR_16_9, 1, 0xFFFFFFFF);
							}
						}
						else
						{
							if(settings.covers3d)
							{
								GRRLIB_DrawFlatCoverImg(60, 131, _texture_data[self.gameSelected], 0, 1, 1, 0xFFFFFFFF);
							}
							else
							{
								GRRLIB_DrawImg(60, 131, _texture_data[self.gameSelected], 0, 1, 1, 0xFFFFFFFF);
							}
						}
					}
					else
					{
						if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
						{
							if(settings.covers3d)
							{
								GRRLIB_DrawFlatCoverImg(60, 131 , cover_texture_3d, 0, AR_16_9, 1, 0xFFFFFFFF);
							}
							else
							{
								GRRLIB_DrawImg(60, 131, cover_texture, 0, AR_16_9, 1, 0xFFFFFFFF);
							}
						}
						else
						{
							if(settings.covers3d)
							{
								GRRLIB_DrawFlatCoverImg(60, 131, cover_texture_3d, 0, 1, 1, 0xFFFFFFFF);
							}
							else
							{
								GRRLIB_DrawImg(60, 131, cover_texture, 0, 1, 1, 0xFFFFFFFF);
							}
						}
					}
					
					pthread_mutex_unlock(&buffer_mutex[self.gameSelected]);
				}
				else
				{	
				if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
				{
					if(settings.covers3d)
					{
						GRRLIB_DrawFlatCoverImg(60, 131, cover_texture_3d, 0, AR_16_9, 1, 0xFFFFFFFF);
					}
					else
					{
						GRRLIB_DrawImg(60, 131, cover_texture, 0, AR_16_9, 1, 0xFFFFFFFF);
					}
				}
				else
				{
					if(settings.covers3d)
					{
						GRRLIB_DrawFlatCoverImg(60, 131, cover_texture_3d, 0, 1, 1, 0xFFFFFFFF);
					}
					else
					{
						GRRLIB_DrawImg(60, 131, cover_texture, 0, 1, 1, 0xFFFFFFFF);
					}
				}
				}
			}
			else
			{
				if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
				{
					if(settings.covers3d)
					{
						GRRLIB_DrawFlatCoverImg(60, 131, cover_texture_3d, 0, AR_16_9, 1, 0xFFFFFFFF);
					}
					else
					{
						GRRLIB_DrawImg(60, 131, cover_texture, 0, AR_16_9, 1, 0xFFFFFFFF);
					}
				}
				else
				{
					if(settings.covers3d)
					{
						GRRLIB_DrawFlatCoverImg(60, 131, cover_texture_3d, 0, 1, 1, 0xFFFFFFFF);
					}
					else
					{
						GRRLIB_DrawImg(60, 131, cover_texture, 0, 1, 1, 0xFFFFFFFF);
					}
				}
			}


			Button_TTF_Paint(&okButton); 
			Button_Paint(&gDOLdownButton);
			Button_Paint(&gDOLupButton);

			DrawCursor(0, pointer.p_x, pointer.p_y, pointer.p_ang, 1, 1, 0xFFFFFFFF); 

			if ( Button_Hover(&okButton, pointer.p_x, pointer.p_y) ||
				 Button_Hover(&gDOLupButton, pointer.p_x, pointer.p_y) ||
			     Button_Hover(&gDOLdownButton, pointer.p_x, pointer.p_y) ) 
			{ 
				 // Should we be rumbling? 
				 if (--self.rumbleAmt > 0) 
						 WPAD_Rumble(0,1); // Turn on Wiimote rumble 
				 else  
						 WPAD_Rumble(0,0); // Kill the rumble 
			} 
			else 
			{ // If no button is being hovered, kill the rumble 
				 WPAD_Rumble(0,0); 
				 self.rumbleAmt = 5; 
			} 
			
			if((WPAD_ButtonsDown(0) & WPAD_BUTTON_A)||(PAD_ButtonsDown(0) & PAD_BUTTON_A))
			{
				if(Button_Select(&okButton, pointer.p_x, pointer.p_y) && WPAD_ButtonsDown(0) & WPAD_BUTTON_A) 
				{
					doloop = false;
				}
				else if (Button_Select(&gDOLdownButton, pointer.p_x, pointer.p_y))
				{ // Clicked on the episodeDOL buttons
					if (ret > 1)
					{
						ret --;
					}
					else
					{
						ret = (CFG_COUNT);
					}
				}
				else if (Button_Select(&gDOLupButton, pointer.p_x, pointer.p_y))
				{
					if (ret < (CFG_COUNT))
					{
						ret ++;
					}
					else
					{
						ret = 1;
					}
				}
			}
			GRRLIB_Render(); 
                  
         }while(doloop); 
  return ret;

}