Example #1
0
static inline bool LatestVersion(int *major, int *minor, int *current_line) {
	u32 http_status = 0;
	u8* outbuf = NULL;
	u32 filesize;
	int line = *current_line;

	PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, Downloads[DOWNLOAD_VERSION].text);
	UpdateScreen();
	line++;
	if(!http_request(Downloads[DOWNLOAD_VERSION].url, Downloads[DOWNLOAD_VERSION].max_size)) {
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, "Failed to retrieve version");
		UpdateScreen();
		*current_line = line;
		return false;
	}
	

	http_get_result(&http_status, &outbuf, &filesize);
	
	if (((int)*outbuf & 0xF0000000) == 0xF0000000) 
	{
		if (outbuf != NULL) free(outbuf);
		*current_line = line;
		return false;
	}
	sscanf((char*)outbuf, " #ifndef %*s #define %*s #define NIN_MAJOR_VERSION %i #define NIN_MINOR_VERSION %i", major, minor);
	gprintf("major = %i, minor = %i\r\n", *major, *minor);
	if (outbuf != NULL) free(outbuf);
	if ((*major <= NIN_MAJOR_VERSION) && (*minor <= NIN_MINOR_VERSION)) {
		bool still_download = true;
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, "You already have the latest version");
		line++;
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X, MENU_POS_Y + 20*line, "Download anyway? (A: Yes, B: No)");
		line++;
		UpdateScreen();
		while(true) {
			DrawBuffer();
			FPAD_Update();
			if (FPAD_Cancel(0)) {
				gprintf("Cancelling download\n");
				still_download = false;
				break;
			}
			if (FPAD_OK(0)) {
				gprintf("okay\n");
				break;
			}
			GRRLIB_Render();
		}
		if(!still_download) {
			*current_line = line;
			return false;
		}
	}
	*current_line = line;
	return (*major + *minor) > 0;

}
Example #2
0
int main(){
	SYS_SetResetCallback(WiiResetPressed);
	SYS_SetPowerCallback(WiiPowerPressed);
	WPAD_SetPowerButtonCallback(WiimotePowerPressed);
	
	VIDEO_Init();

	if(CONF_GetAspectRatio())
	{
		SCREEN_WIDTH = 720;
	} else {
		SCREEN_WIDTH = 640;
	}
	
	
	initializeinput();
	initializeworld();
	
	GRRLIB_InitVideo();
	GRRLIB_Start();
	
	startscreen();
		
    while(1){
		if(!fadeout)
		{
			updateinput();
			updateworld();
			updatetiles();
			updateoverlay();
		}
		
		drawworld();
		drawcursor();
		drawoverlay();

		//When hitting home do a slow fade to black,
		//if it is totally black do the actual exit
		if (wpadheld & WPAD_BUTTON_HOME || HWButton) fadeout = true;
		if(fadeout)
		{
			fadeout_opacity += 5;
			if(fadeout_opacity >= 270) {
				if(HWButton)
					SYS_ResetSystem(HWButton, 0, 0);
					
				return 0;
			}
				
			GRRLIB_Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, fadeout_opacity > 255 ? 255 << 24 : fadeout_opacity << 24, true);
			
		}
		
		GRRLIB_Render();
    }
    return 0;
}
Example #3
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;
}
Example #4
0
void grlib_Render (void) 
	{
	// Sometimes same fb are skipped, I do not know why, 
	// but copyng display to tex and redrawing it solves without big effort
	// and loss of performance.
	// In continuos update mode, doesn't heppen, so GRRLIB_Render can be called.
	GRRLIB_Screen2Texture (0, 0, redrawTex, 1);
	grlib_DrawScreenTex (redrawTex);
	GRRLIB_Render ();
	} 
Example #5
0
   void Game::run(const string& initialLevel)
   {
      this->changeLevel(initialLevel);
      int frameCount = 0;
      char framePerSecond[32] = "";
      
      while (!this->levels.empty())
      {
         WPAD_ScanPads();

         Level* level = this->levels.top();
         level->nextStep();
         level->render();

         if (this->debugDrawEnabled)
            level->world->DrawDebugData();

         if (this->console.isEnabled())
           this->console.render();

         // Render FPS
         GRRLIB_PrintfTTF(570, 32, this->font, framePerSecond, 16, GRRLIB_RED);

         GRRLIB_Render();  // Render the frame buffer to the screen


         // If level is finished, resume the previous one
         if (level->isFinished())
         {
            Console::log(LOG_INFO, "Game::run() - resume previous level");
            this->levels.pop();
            delete level;
            
            if (this->levels.top())
               this->levels.top()->loadGraphics();
         }
         
         // WPAD_ButtonsDown tells us which buttons were pressed in this loop
         // this is a "one shot" state which will not fire again until the button has been released
         u32 pressed = WPAD_ButtonsDown(WPAD_CHAN_0);

         // We return to the launcher application via exit
         if (pressed & WPAD_BUTTON_HOME) return;
         if (pressed & WPAD_BUTTON_PLUS) this->console.enable(!this->console.isEnabled());
         if (pressed & WPAD_BUTTON_MINUS) this->debugDrawEnabled = !this->debugDrawEnabled;

         // Count FPS
         frameCount++;
         if (this->fpsTimer.isExpired())
         {
            sprintf(framePerSecond, "%2d FPS", frameCount);
            frameCount = 0;
         }
      }
   }
Example #6
0
cui_menu menu_credits(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_return;
	UI_InitBtn(&button_return, 400, 400, "Return");
	button_return.img = GRRLIB_LoadTexture(button_png);
	button_return.font = font;
	
	while(!done){		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		
		GRRLIB_PrintfTTF2 (20, 60, font, 20, 0xFFFFFFFF, "%s", "ChessUi -- a chess interface for Wii --");
		GRRLIB_PrintfTTF2 (20, 80, font, 20, 0xFFFFFFFF, "%s", "Presented & programmed by TheDrev");
		GRRLIB_PrintfTTF2 (20, 100, font, 20, 0xFFFFFFFF, "%s", "Using the FirstChess engine by Pham Hong Nguyen ");
		GRRLIB_PrintfTTF2 (20, 120, font, 20, 0xFFFFFFFF, "%s", "and piece graphismes by Wapcaplet");
		GRRLIB_PrintfTTF2 (20, 140, font, 20, 0xFFFFFFFF, "%s", "and also the GRRLIB graphic library");
		GRRLIB_PrintfTTF2 (20, 160, font, 20, 0xFFFFFFFF, "%s", "see http://wiibrew.org/wiki/Chessui for more details");
		
		if(button_return.click){
			done=true;
			next_state=CUI_MENU_MAIN;
		}
		
		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}

		UI_DrawBtn(&button_return);
		
		cui_cursor_display(p_game->cursor);
		
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTTF(font);
	free(button_return.text);
	GRRLIB_FreeTexture(button_return.img);
	
	return next_state;
}
Example #7
0
File: main.c Project: capz/GRRLIB
int main() {
    float rot=0;
    float i;
    int circsize=150;
    char text[]="GRRLIB ROXX ";

    GRRLIB_Init();
    PAD_Init();


    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font3d);
    GRRLIB_InitTileSet(tex_font, 64, 64, 32);
    GRRLIB_SetHandle (tex_font, tex_font->tilew/2, tex_font->tileh+circsize);

    GRRLIB_texImg *tex_screen;
    tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth,rmode->efbHeight);

    GRRLIB_Settings.antialias = true;

    while(1) {
        PAD_ScanPads();
        if(PAD_ButtonsDown(0) & PAD_BUTTON_START) exit(0);

// we say thant we will want to capture to a texture all the following
        GRRLIB_CompoStart();

            for(i=0;i<360;i+=30) {
// We draw some letters
                GRRLIB_DrawTile((rmode->fbWidth/2)-(tex_font->tilew/2), (rmode->efbHeight/2)-(tex_font->tileh+circsize), tex_font, rot+i, 1, 1, 0xFFFFFFFF, text[(int)(i/30)]-32);
            }

// we say we want to capture now, (the buffer will be cleared after the capture)
        GRRLIB_CompoEnd(0, 0, tex_screen);

        rot-=0.6;

// we now draw 3 times  the captured buffer playing with color
        GRRLIB_DrawImg(0, 0, tex_screen, 0, 1, 1, 0xFF00FFFF);
        GRRLIB_DrawImg(50, 50, tex_screen, 0, 1, 1, 0xFFFF00FF);
        GRRLIB_DrawImg(100, 100, tex_screen, 0, 1, 1, 0xFFFFFFFF);

        GRRLIB_Render();
    }

    GRRLIB_FreeTexture(tex_screen);
    GRRLIB_FreeTexture(tex_font);
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
    exit(0);
}
Example #8
0
void UpdateNintendont(void) {
	int selected = 0;
	u64 delay = ticks_to_millisecs(gettime()) + 500;
	while(true) {
		ClearScreen();
		PrintInfo();
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*5, "Download Nintendont");
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*6, "Download titles.txt");
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*7, "Download controllers.zip");
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*8, "Return to Settings");
		PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 35, MENU_POS_Y + 20*(5+selected), ARROW_RIGHT);
		GRRLIB_Render();
		FPAD_Update();
		if (delay > ticks_to_millisecs(gettime())) continue;
		if (FPAD_Start(1)) {
			ClearScreen();
			PrintFormat(DEFAULT_SIZE, BLACK, 212, 232, "Returning to loader...");
			ExitToLoader(0);
		}
		if (FPAD_OK(1)) {
			if (selected <= DOWNLOAD_CONTROLLERS)
				Download(selected);
			else
				break;
		}
		if (FPAD_Down(1)) {
			delay = ticks_to_millisecs(gettime()) + 150;
			selected++;
			if (selected > 3) selected = 0;
		}
		if (FPAD_Up(1)) {
			delay = ticks_to_millisecs(gettime()) + 150;
			selected--;
			if (selected < 0) selected = 3;
		}
		if (FPAD_Cancel(1)) {
			break;
		}
	}
	ClearScreen();
	return;
}
Example #9
0
cui_menu menu_main(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size);  
	GRRLIB_texImg *tex_pieces = GRRLIB_LoadTexture(chess_classic_png);
	GRRLIB_texImg *tex_tile = GRRLIB_LoadTexture(keyboard_key_png);
	GRRLIB_texImg *tex_btn = GRRLIB_LoadTexture(button_png);
	
	UI_button button_newgame;
	UI_InitBtn(&button_newgame, 280, 120, "New game");
	button_newgame.img = tex_btn;
	button_newgame.font = font;
	
	UI_button button_options;
	UI_InitBtn(&button_options, 280, 200, "Options");
	button_options.img = tex_btn;
	button_options.font = font;
	
	UI_button button_credit;
	UI_InitBtn(&button_credit, 280, 280, "credit");
	button_credit.img = tex_btn;
	button_credit.font = font;
	
	while(!done){		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		GRRLIB_PrintfTTF (5, 5, font, "ChessUI", 96, 0x424242FF);
		UI_UpdateBtn(&button_newgame, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_options, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_credit, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		if(button_newgame.click){
			done=true;
			next_state=CUI_MENU_PLAY;
		}

		if(button_options.click){
			done=true;
			next_state=CUI_MENU_OPTION;
		}
		
		if(button_credit.click){
			done=true;
			next_state=CUI_MENU_CREDITS;
		}
		
		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}

		
		if ( pressed & WPAD_BUTTON_A ){

			if(voice) AESND_PlayVoice(voice, VOICE_STEREO16, button_click_pcm, button_click_pcm_size, VOICE_FREQ48KHZ, 1, false);
		}
		
		cui_board_demo(p_game->board, tex_pieces, tex_tile, font);
		UI_DrawBtn(&button_newgame);
		UI_DrawBtn(&button_options);
		UI_DrawBtn(&button_credit);
		
		cui_cursor_display(p_game->cursor);
		
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTTF(font);
	GRRLIB_FreeTexture(tex_btn);
	free(button_newgame.text);
	free(button_options.text);
	free(button_credit.text);
	return next_state;
}
Example #10
0
File: main.c Project: capz/GRRLIB
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;
}
Example #11
0
int main(int argc, char **argv) {
	InitSD();
	FILE * file = fopen("sd:/hello.txt", "w");
	if (file == NULL)
		exit(0);
	fprintf(file, "hello, there!\n");
	fclose(file);

	// initialize the sound system.
	//ASND_Init();

	// Initialise the Graphics & Video subsystem
	GRRLIB_Init();
	GRRLIB_Settings.antialias = true;

	tex_Calibri = GRRLIB_LoadTexture(Calibri_18);

	GRRLIB_InitTileSet(tex_Calibri, 27, 37, 32);

	// Initialize the Wiimotes
	WPAD_Init();

	mainMenu();

	Ship *ship;
	ship = (Ship*) malloc(NUM_SHIPS * sizeof(Ship));
	ship = initializeShips(NUM_SHIPS, ship);
	Planet* planet;
	planet = (Planet*) malloc(NUM_PLANETS * sizeof(Planet));

	planet[0].x = 200;
	planet[0].y = 200;
	planet[0].m = 700;
	planet[0].r = 60;
	planet[0].color = 0xFFFFFFFF;
	planet[0].owner = NO_OWNER;
	planet[0].health = PLANET_HEALTH;
	planet[0].currentUpgrade = 0;
	planet[1].x = 400;
	planet[1].y = 400;
	planet[1].m = 300;
	planet[1].r = 30;
	planet[1].color = 0x00FFFFFF;
	planet[1].owner = NO_OWNER;
	planet[1].health = PLANET_HEALTH;
	planet[1].currentUpgrade = 0;
	planet[2].x = 1000;
	planet[2].y = 400;
	planet[2].m = 1000;
	planet[2].r = 200;
	planet[2].color = 0xFF2200FF;
	planet[2].owner = NO_OWNER;
	planet[2].health = PLANET_HEALTH;
	planet[2].currentUpgrade = 0;
	planet[3].x = 1400;
	planet[3].y = 1200;
	planet[3].m = 700;
	planet[3].r = 51;
	planet[3].color = 0x29AF1BFF;
	planet[3].owner = NO_OWNER;
	planet[3].health = PLANET_HEALTH;
	planet[3].currentUpgrade = 0;
	planet[4].x = 1850;
	planet[4].y = 1850;
	planet[4].m = 100;
	planet[4].r = 20;
	planet[4].color = 0xFF7777FF;
	planet[4].owner = NO_OWNER;
	planet[4].health = PLANET_HEALTH;
	planet[4].currentUpgrade = 0;
	// initialize planet's bullet arrays
	int i = 0;
	for (i = 0; i < NUM_PLANETS; i++) {
		planet[i].bullets = (struct Bullet *) malloc(sizeof(Bullet)
				* PLANET_BULLET_NUM);
		if (planet[i].bullets == NULL) {
			exit(0);
		}
		planet[i].numBullets = 0;
	}

	ship = initializeShips(NUM_SHIPS, ship);

	u8 frame_rate;

	initializeTextures();
	int buttons;
	initializeGrid();

	//ASND_Init();
	//ASND_SetVoice(5,VOICE_STEREO_16BIT,8000, 0, &betamaster_raw, betamaster_raw_size, 255, 255, NULL);
	/*
	 MODPlay_Init(&play);
	 MODPlay_SetMOD(&play, paradox_mod);
	 MODPlay_SetVolume(&play, 63, 63);
	 MODPlay_Start(&play);
	 */
	while (1) {

		profiler(1);
		WPAD_ScanPads(); // Scan the Wiimotes
		buttons = WPAD_ButtonsDown(0);
		// If [HOME] was pressed on the first Wiimote, break out of the loop
		if (buttons & WPAD_BUTTON_HOME)
			break;

		update(ship, planet);
		doMechanics(ship, planet);
		render(ship, planet);

		frame_rate = calculateFPS();

		GRRLIB_Printf(20, 20, tex_Calibri, 0xFFFFFFFF, .5, "FPS: %d",
				frame_rate);
		GRRLIB_Printf(20, 40, tex_Calibri, 0xFFFFFFFF, .5, "%d",
		                                ship[0].bullets[0].exploded);
		//int endProfile = profiler(0);
		GRRLIB_Render();
		frameCount++;

	}

	GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
	for (i = 0; i < NUM_SHIPS; i++) {
		free(ship[i].bullets);
	}
	free(ship);
	GRRLIB_FreeTexture(tex_Calibri);
	freeStarMemory();
	exit(0); // Use exit() to exit a program, do not use 'return' from main()
}
Example #12
0
int main() {
    float a = 0;
    float objscal = 0.5f;
    int objqual = 20;

    GRRLIB_Init();
    WPAD_Init();

    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(Rockwell_Condensed_12_Bold);
    GRRLIB_InitTileSet(tex_font, 12, 19, 32);


    GRRLIB_Settings.antialias = true;

    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);


    while(1) {
        GRRLIB_2dMode();
        WPAD_ScanPads();
        if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break;

        GRRLIB_Camera3dSettings(0.0f, 0.0f,13.0f, 0,1,0, 0,0,0);

        GRRLIB_SetLightAmbient(0x333333FF);
        GRRLIB_SetLightDiff(0,(guVector){0.0f,0.0f,0.0f},20.0f,1.0f,0x00FFFFFF);
        GRRLIB_SetLightDiff(1,(guVector){0.0f,13.0f,3.0f},20.0f,1.0f,0xFF00FFFF);
        GRRLIB_SetLightDiff(2,(guVector){0.0f,-13.0f,3.0f},20.0f,1.0f,0xFFFF00FF);
        GRRLIB_SetLightDiff(3,(guVector){13.0f,0.0f,3.0f},20.0f,1.0f,0xFF0000FF);
        GRRLIB_SetLightDiff(4,(guVector){-13.0f,0.0f,3.0f},20.0f,1.0f,0x00FF00FF);

        GRRLIB_3dMode(0.1,1000,45,0,1);

        GRRLIB_ObjectViewInv(1.0f, -1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(-1.0f, -1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(1.0f, 1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(-1.0f, 1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);

        GRRLIB_ObjectViewInv(1.0f, -1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(-1.0f, -1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(1.0f, 1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(-1.0f, 1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);

        GRRLIB_ObjectView(0.0f, 0.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawCube(3.0, true, 0xFFFFFF44);

        a+=0.6f;

        // Switch To 2D Mode to display text
        GRRLIB_2dMode();
        GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "LIGHT SAMPLE CODE 2");

        GRRLIB_Render();
    }
    GRRLIB_FreeTexture(tex_font);
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB

    exit(0);
}
Example #13
0
int main() {
    int startx=0, starty=0;
    int x=0, y=0;
    int dirx=0, diry=0;
    int cptx=0, cpty=0;
    int bgx=-32, bgy=-32;
    float idperso=0;
    int i=0;
    float sinnonameno=0, oldsinnonameno=0;
    float camZ=1400.0f;
    float a=0;

    GRRLIB_Init();
    GRRLIB_Settings.antialias = false;
    WPAD_Init();
    GRRLIB_ClipDrawing(0,0,rmode->fbWidth,rmode->efbHeight);
    GRRLIB_texImg *tex_tile1 = GRRLIB_LoadTexture(tile1);
    GRRLIB_InitTileSet(tex_tile1, TileMap1Width, TileMap1Height, 0);
    GRRLIB_texImg *tex_perso = GRRLIB_LoadTexture(perso);
    GRRLIB_InitTileSet(tex_perso, 64, 64, 0);
    GRRLIB_texImg *tex_bg = GRRLIB_LoadTexture(bg);
    GRRLIB_texImg *tex_nonameno = GRRLIB_LoadTexture(nonameno);
    GRRLIB_InitTileSet(tex_nonameno, 32, 32, 0);

    GRRLIB_texImg *tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);

    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);

    while(1) {
        GRRLIB_2dMode();
        WPAD_ScanPads();
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)  break;
        if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_PLUS)  camZ+=20.0f;
        if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS)  camZ-=20.0f;

        if((dirx==0) && (diry==0)) {
            if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) { diry=-4; idperso=15;}
            else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) { diry=4; idperso=15;}
            else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_DOWN) { dirx=-4 ; idperso=1;}
            else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_UP) { dirx=4 ; idperso=8;}
        }

        if((dirx==0) && (diry==0)) {
            idperso=0;
        }

        if(((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) || ((Map1Info[9+starty][10+startx]==43521) || (Map1Info[9+starty][11+startx]==43521))) {
        }
        else{
            dirx=0;
            diry=-4;
        }

        if(dirx<0) {
            if((Map1Info[7+starty][12+startx]==8) || (Map1Info[7+starty][12+startx]==2) || (Map1Info[8+starty][12+startx]==8) || (Map1Info[8+starty][12+startx]==2)) {
                dirx=0;
            }
            else {
                idperso++;
                if(idperso>7)
                    idperso=1;
            }
        }

        if(dirx>0) {
            if((Map1Info[7+starty][9+startx]==8) || (Map1Info[7+starty][9+startx]==2) || (Map1Info[8+starty][9+startx]==8) || (Map1Info[8+starty][9+startx]==2)) {
                dirx=0;
            }
            else {
                idperso++;
                if(idperso>14)
                    idperso=8;
           }
        }

        if(diry<0) {
            if((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) {
                diry=0;
            }
        }

        if(diry!=0) {
            idperso++;
            if(idperso>22)
                idperso=16;
        }

        cptx+=dirx;
        if(dirx>0)
            bgx++;
        else if(dirx<0)
            bgx--;
        if((bgx>-1) || (bgx<-63))
            bgx=-32;

        if(cptx==32) {
            cptx=0;
            dirx=0;
            startx--;
        }
        else if(cptx==-32) {
            cptx=0;
            dirx=0;
            startx++;
        }

        cpty+=diry;
        if(diry>0)
            bgy++;
        else if(diry<0)
            bgy--;
        if((bgy>-1) ||(bgy<-63))
            bgy=-32;

        if(cpty==32) {
            cpty=0;
            diry=0;
            starty--;
        }
        else if(cpty==-32) {
            cpty=0;
            if(((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) || ((Map1Info[9+starty][10+startx]==43521) || (Map1Info[9+starty][11+startx]==43521))) {
                diry=0;
            }
            starty++;
        }
        GRRLIB_DrawImg(bgx, bgy, tex_bg, 0, 1, 1, 0xFFFFFFFF);

        for(y=0;y<=(17);y++) {
            for(x=0;x<=(21);x++) {
            if(Map1Data[y+starty][x+startx] != 0) {
                GRRLIB_DrawTile(x*TileMap1Width+cptx-TileMap1Width,y*TileMap1Height+cpty-TileMap1Height,tex_tile1,0,1,1,0xFFFFFFFF,Map1Data[y+starty][x+startx]-1);
            }
            }
        }
        GRRLIB_DrawTile(TileMap1Width*9,TileMap1Height*6,tex_perso,0,1,1,0xFFFFFFFF,(int)idperso);

        oldsinnonameno=sinnonameno;
        for(i=0; i<8; i++) {
            GRRLIB_DrawTile(TileMap1Width*(6+i),(TileMap1Height*10)+sin(sinnonameno)*64,tex_nonameno,0,1,1,0xFFFFFFFF,i);
            sinnonameno+=0.4F;
        }
        sinnonameno=oldsinnonameno+0.08F;

        GRRLIB_Screen2Texture(0, 0, tex_screen, GX_TRUE);


        GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0);
        GRRLIB_3dMode(0.1,3000,45,1,0);
        GRRLIB_SetTexture(tex_screen,0);
        GRRLIB_ObjectView(0,0,0, a,a*2,a*3,1,1,1);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 16);
            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();

        a+=0.2f;

        GRRLIB_Render();
    }

    GRRLIB_FreeTexture(tex_tile1);
    GRRLIB_FreeTexture(tex_perso);
    GRRLIB_FreeTexture(tex_bg);
    GRRLIB_FreeTexture(tex_nonameno);
    GRRLIB_FreeTexture(tex_screen);
    GRRLIB_Exit();
    exit(0);
}
Example #14
0
int main() {
    // Perso init position
	int startPosX = 9;
	int startPosY = 6;
	
	// Perso size
	int persoHalfHeight = 1;
	int persoHeight     = 2;
	int persoHalfWidth  = 1;
	int persoWidth      = 2;
	
	// Map position
	int posX = startPosX;
    int posY = startPosY;
	
    int cptx = 0, cpty = 0;
    int bgx = -32, bgy = -32;
	
	
	// Counters used to process each tile of the map
    int x = 0;
    int y = 0;
	
	// Directions X/Y, defined by controls
    int dirx = 0;
    int diry = 0;
	
	// Frame number to draw of the perso
    float idperso = 0;
	
	// Counter of letters displaying on top layer 
    int i = 0;
	// Used to move letters following a sinusoidal signal
    float sinnonameno    = 0;
	float oldsinnonameno = 0;


    ////////////////
	// SYSTEM INITS
	////////////////

    // Init Video mode, aspect ratio, FIFO buffer, FAT system, so on.
    GRRLIB_Init();
		
	// Init Controls (Wiimote, Balance board, Sensor bar, so on.)
    WPAD_Init();
	

    /////////////////////////////
	// LOAD TEXTURES / TILESETS
    /////////////////////////////
		
	// Load texture from image (c array)
    GRRLIB_texImg *tex_tile1 = GRRLIB_LoadTexture(tile1);
	// Handle the texture to be used (set number of tiles, start position, offset position, so on)
    GRRLIB_InitTileSet(tex_tile1, TileMapWidth, TileMapHeight, 0);
	
	// Load texture from image (c array)
    GRRLIB_texImg *tex_perso = GRRLIB_LoadTexture(perso);
	// Handle the texture to be used (set number of tiles, start position, offset position, so on)
    GRRLIB_InitTileSet(tex_perso, 64, 64, 0);
	
	// Load texture from image (c array)
    GRRLIB_texImg *tex_bg = GRRLIB_LoadTexture(bg);
	
	// Load texture from image (c array)
    GRRLIB_texImg *tex_nonameno = GRRLIB_LoadTexture(nonameno);
	// Handle the texture to be used (set number of tiles, start position, offset position, so on)
    GRRLIB_InitTileSet(tex_nonameno, 32, 32, 0);

    // Load texture to draw text (native printf doesn't work with GRRLib)
    GRRLIB_texImg *tex_BMfont1 = GRRLIB_LoadTexture(BMfont1);
	// Handle the texture to be used, in order to draw characters from the fonttype
    GRRLIB_InitTileSet(tex_BMfont1, 32, 32, 32);


    ////////////////
    // ENDLESS LOOP
	////////////////
    while(1) {
	    // Get status of Wii controller
        WPAD_ScanPads();
		
		// If HOME button is pressed, the loop is interrupted. 0 is the Wiimote channel (Wiimote number 1 out of 4).
		// WPAD_ButtonsXXX returns a hexadecimal value representing all buttons down. The mask on HOME button allows to check if this buttons is pressed
		// (HOME button hexadecimal value: 0x0080)
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) {
          break;
		}

        
        // Set directions X/Y values and perso frame to display, depending controls
        
        if ((dirx == 0) && (diry == 0)) {
            if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) { // If LEFT button is held : go bottom
			  diry    = -4; // move perso 4px on bottom
			  idperso = 15; // select frame 15 of the perso (back)
			} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) { // If RIGHT button is held : go top
			  diry    = 4;  // move perso 4px on top
			  idperso = 15; // select frame 15 of the perso (back)
			} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_DOWN) { // If DOWN button is held : go right
			  dirx    = -4; // move perso 4px on right
			  idperso = 1;  // select frame 1 of the perso (watching on his right)
			} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_UP) { // If UP button is held : go left
			  dirx    = 4;  // move perso 4px on left
			  idperso = 8;  // select frame 4 of the perso (watching on his left)
			}
        }


        // If no movement, select frame 0 of the perso (front of the screen)
        if ((dirx == 0) && (diry == 0)) {
            idperso = 0;
        }


        if 	(
		        (
				    // Checks if ground at bottom (grey ground only)
		            (Map1Info[posY + persoHeight + 1][posX + persoWidth] == 1) || (Map1Info[posY + persoHeight + 1][posX + persoHalfWidth] == 1)
			    ) 
			    || 
			    (
				    // Checks if ladder at bottom. Allow to move freely on ladders
					(Map1Info[posY + persoHeight + 1][posX + persoWidth] == 10064) || (Map1Info[posY + persoHeight + 1][posX + persoHalfWidth] == 10064)
				)
		    ) 
		{
			// Does nothing there
        } else { 
		    // Any case: fall
            dirx = 0; 
            diry = -4;
        }


        // Debug (got the values at this step, but printed later)
        int printDirX = dirx;
		int printDirY = diry;
		int printPosX = posX;
		int printPosY = posY;


        if (dirx < 0) { // If goes on RIGHT
		    // Checks collide on right to column
            if 	(
			
					(Map1Info[posY + persoHalfHeight][posX + persoWidth + 1] == 8) 
					|| 
					(Map1Info[posY + persoHalfHeight][posX + persoWidth + 1] == 2) 
					|| 
					(Map1Info[posY + persoHeight][posX + persoWidth + 1] == 8) 
					|| 
					(Map1Info[posY + persoHeight][posX + persoWidth + 1] == 2)
				) 
			{
                dirx = 0;
            } else {
				// Animation walking on right
                idperso++;
                if (idperso > 7) {
                    idperso = 1;
				}
            }
        } else if (dirx > 0) { // If goes on LEFT
			// Checks collide on left to column
            if	(
			
			        (Map1Info[posY + persoHalfHeight][posX] == 8) 
					|| 
					(Map1Info[posY + persoHalfHeight][posX] == 2) 
					|| 
					(Map1Info[posY + persoHeight][posX] == 8) 
					|| 
					(Map1Info[posY + persoHeight][posX] == 2)
				) 
			{
                dirx = 0;
            } else {
				// Animation walking on left
                idperso++;
                if (idperso > 14) {
                    idperso = 8;
				}
           }
        }


        // Jumping
        if (diry < 0) { 
		    // Checks if bottom tile is grey ground
            if ((Map1Info[posY + persoHeight + 1][posX + persoWidth] == 1) || (Map1Info[posY + persoHeight + 1][posX + persoHalfWidth] == 1)) {
                diry = 0;
            }
        }
		
		// Animation while jumping / falling / climbing a ladder
        if (diry != 0) {
            idperso++;
            if (idperso > 22) {
                idperso = 16;
			}
        }



		
		// Move the background horizontally
        if (dirx > 0) {
			bgx++;
        } else if (dirx < 0) {
            bgx--;
		}
        if ((bgx > -1) || (bgx < -63)) {
            bgx = -32;
		}


        // Move the map horizontally depending perso movements.
		// This allows to display map 4pixels per 4pixels, instead of tile per tile
        cptx += dirx;
        if (cptx == TileMapWidth) {
            cptx = 0;
            dirx = 0;
            posX--;
        } else if (cptx == -TileMapWidth) {
            cptx = 0;
            dirx = 0;
            posX++;
        }

        
		// Move the background vertically
        if (diry > 0) {
            bgy++;
        } else if (diry < 0) {
            bgy--;
		}
        if ((bgy > -1) || (bgy < -63)) {
            bgy = -32;
		}


        // Move the map vertically depending perso movements
		// This allows to display map 4pixels per 4pixels, instead of tile per tile
        cpty += diry;
        if (cpty == TileMapHeight) {
            cpty = 0;
            diry = 0;
            posY--;
        } else if (cpty == -TileMapHeight) {
            cpty = 0;
			
			// We check if perso is on the ground or on a ladder.
			// It allows to let the animation of fall/jump to continue to run instead.
            if	(
					(
						(Map1Info[posY + persoHeight + 1][posX + persoWidth] == 1) 
						|| 
						(Map1Info[posY + persoHeight + 1][posX + persoHalfWidth] == 1)
					) 
					|| 
					(
						(Map1Info[posY + persoHeight + 1][posX + persoWidth] == 10064) 
						|| 
						(Map1Info[posY + persoHeight + 1][posX + persoHalfWidth] == 10064)			
					)
				) 
			{
                diry = 0;
            }
			
            posY++;
        }
		
		
		//////////////////////////
		// DRAWING THE BACKGROUND
		//////////////////////////
		
        GRRLIB_DrawImg(bgx,       // X of upper left corner
		               bgy,       // Y of upper left corner
					   tex_bg,    // texture
					   0,         // rotation
					   1,         // scale X
					   1,         // scale Y
					   0xFFFFFFFF // color
					  );


		////////////////////////////////
		// DRAWING EACH TILE OF THE MAP
        ////////////////////////////////

        // Reminder:
		//   TileMapWidth  = 32px
		//   TileMapHeight = 32px

        // Process 17 tiles on height of the screen (17 x 32px = 512px)
        for (y = 0; y <= (16); y++) {
			// Process 22 tiles on width of the screen (22 * 32 = 704px)
            for (x = 0; x <= (21); x++) {
			    // Only displays tiles with content (others are "transparent" on the screen)
                if (Map1Data[y + posY - startPosY][x + posX - startPosX] != 0) {
                    GRRLIB_DrawTile(x * TileMapWidth + cptx - TileMapWidth, 					// X position to draw (upper left)
					                y * TileMapHeight + cpty - TileMapHeight,					// Y position to draw (upper left)
									tex_tile1,													// texture of the tileset
									0,															// rotation
									1,															// scale X
									1,															// scale Y
									0xFFFFFFFF,													// color
									Map1Data[y + posY - startPosY][x + posX - startPosX] - 1 	// Frame to display (from the tileset)
								   );
                }
            }
        }
		
		
		/////////////////////
		// DRAWING THE PERSO
		/////////////////////
		
        GRRLIB_DrawTile(TileMapWidth * startPosX,  // horizontal center of the screen
						TileMapHeight * startPosY, // vertical center of the screen
						tex_perso, 				    // texture of the tileset
						0, 						    // rotation
						1, 						    // scale X
						1, 						    // scale Y
						0xFFFFFFFF, 			    // color
						(int)idperso			    // Frame to display (from the tileset)
					   );

        
		
		///////////////////////////////////
		// LETTERS MOVING ON A SIN SIGNAL
		///////////////////////////////////
		oldsinnonameno = sinnonameno;
        for (i = 0; i < 8; i++) {
            GRRLIB_DrawTile(TileMapWidth * (6 + i), 
			                (TileMapHeight * 10) + sin(sinnonameno) * 64, 
							tex_nonameno, 
							0, 												// rotation
							1, 												// scale X
							1, 												// scale Y
							0xFFFFFFFF, 									// color
							i
						   );
            sinnonameno += 0.4F;
        }
        sinnonameno = oldsinnonameno + 0.08F;
		

        // Debugging
		
		GRRLIB_Printf(0, 0, tex_BMfont1, 0xFFFFFFFF, 1, "X:%d Y:%d SX:%d SY:%d", printDirX, printDirY, printPosX, printPosY);
		GRRLIB_Printf(0, 32, tex_BMfont1, 0xFFFFFFFF, 1, "CX:%d CY:%d", cptx, cpty);
		
				
		/////////////
		// RENDERING
		/////////////
		
		GRRLIB_Render();
    }


    // Free textures
    GRRLIB_FreeTexture(tex_tile1);
    GRRLIB_FreeTexture(tex_perso);
    GRRLIB_FreeTexture(tex_bg);
    GRRLIB_FreeTexture(tex_nonameno);
	GRRLIB_FreeTexture(tex_BMfont1);
	
	
	// Free screen access / frame buffers / FIFO to allow 
	// next app to handle the system without any trouble
    GRRLIB_Exit();

    exit(0);
}
Example #15
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;
}
Example #16
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;

}
Example #17
0
int main(int argc, char **argv)
{
	// Exit after 10 seconds if there is an error
	__exception_setreload(10);
//	u64 timeout = 0;
	CheckForGecko();
	DCInvalidateRange(loader_stub, 0x1800);
	memcpy(loader_stub, (void*)0x80001800, 0x1800);

	RAMInit();

	//Meh, doesnt do anything anymore anyways
	//STM_RegisterEventHandler(HandleSTMEvent);

	Initialise();

	u32 u;
	//Disables MEMPROT for patches
	write16(MEM_PROT, 0);
	//Patches FS access
	for( u = 0x93A00000; u < 0x94000000; u+=2 )
	{
		if( memcmp( (void*)(u), FSAccessPattern, sizeof(FSAccessPattern) ) == 0 )
		{
		//	gprintf("FSAccessPatch:%08X\r\n", u );
			memcpy( (void*)u, FSAccessPatch, sizeof(FSAccessPatch) );
			DCFlushRange((void*)u, sizeof(FSAccessPatch));
			break;
		}
	}

	//for BT.c
	CONF_GetPadDevices((conf_pads*)0x932C0000);
	DCFlushRange((void*)0x932C0000, sizeof(conf_pads));
	*(vu32*)0x932C0490 = CONF_GetIRSensitivity();
	*(vu32*)0x932C0494 = CONF_GetSensorBarPosition();
	DCFlushRange((void*)0x932C0490, 8);

	if(LoadKernel() < 0)
	{
		ClearScreen();
		gprintf("Failed to load kernel from NAND!\r\n");
		PrintFormat(DEFAULT_SIZE, MAROON, MENU_POS_X, 232, "Failed to load kernel from NAND!" );
		ExitToLoader(1);
	}
	InsertModule((char*)kernel_bin, kernel_bin_size);

	memset( (void*)0x92f00000, 0, 0x100000 );
	DCFlushRange( (void*)0x92f00000, 0x100000 );

	DCInvalidateRange( (void*)0x939F02F0, 0x20 );

	memcpy( (void*)0x939F02F0, Boot2Patch, sizeof(Boot2Patch) );

	DCFlushRange( (void*)0x939F02F0, 0x20 );

	//libogc still has that, lets close it
	__ES_Close();
	s32 fd = IOS_Open( "/dev/es", 0 );

	memset( STATUS, 0xFFFFFFFF, 0x20  );
	DCFlushRange( STATUS, 0x20 );

	memset( (void*)0x91000000, 0xFFFFFFFF, 0x20  );
	DCFlushRange( (void*)0x91000000, 0x20 );

	*(vu32*)0xD3003420 = 0; //make sure kernel doesnt reload

	raw_irq_handler_t irq_handler = BeforeIOSReload();
	IOS_IoctlvAsync( fd, 0x1F, 0, 0, &IOCTL_Buf, NULL, NULL );
	AfterIOSReload( irq_handler, FoundVersion );

	while(1)
	{
		DCInvalidateRange( STATUS, 0x20 );
		if((STATUS_LOADING > 0 || abs(STATUS_LOADING) > 1) && STATUS_LOADING < 20)
		{
			gprintf("Kernel sent signal\n");
			break;
		}
	}

	/* For slow USB HDDs */
	time_t timeout = time(NULL);
	while(time(NULL) - timeout < 10)
	{
		if(__io_custom_usbstorage.startup() && __io_custom_usbstorage.isInserted())
			break;
		usleep(50000);
	}
	fatInitDefault();

	gprintf("Nintendont at your service!\r\n%s\r\n", NIN_BUILD_STRING);
	KernelLoaded = 1;

	char* first_slash = strrchr(argv[0], '/');
	if (first_slash != NULL) strncpy(launch_dir, argv[0], first_slash-argv[0]+1);
	gprintf("launch_dir = %s\r\n", launch_dir);

	FPAD_Init();
	FPAD_Update();

	PrintInfo();
	PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + + 430, MENU_POS_Y + 20*0, "Home: Exit");
	PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + + 430, MENU_POS_Y + 20*1, "A   : Select");
	GRRLIB_Render();
	ClearScreen();

	/* Read IPL Font before doing any patches */
	void *fontbuffer = memalign(32, 0x50000);
	__SYS_ReadROM((void*)fontbuffer,0x50000,0x1AFF00);
	memcpy((void*)0xD3100000, fontbuffer, 0x50000);
	DCInvalidateRange( (void*)0x93100000, 0x50000 );
	free(fontbuffer);
	//gprintf("Font: 0x1AFF00 starts with %.4s, 0x1FCF00 with %.4s\n", (char*)0x93100000, (char*)0x93100000 + 0x4D000);

	// Simple code to autoupdate the meta.xml in Nintendont's folder
	FILE *meta = fopen("meta.xml", "w");
	if(meta != NULL)
	{
		fprintf(meta, "%s\r\n<app version=\"1\">\r\n\t<name>%s</name>\r\n", META_XML, META_NAME);
		fprintf(meta, "\t<coder>%s</coder>\r\n\t<version>%d.%d</version>\r\n", META_AUTHOR, NIN_VERSION>>16, NIN_VERSION&0xFFFF);
		fprintf(meta, "\t<release_date>20150531000000</release_date>\r\n");
		fprintf(meta, "\t<short_description>%s</short_description>\r\n", META_SHORT);
		fprintf(meta, "\t<long_description>%s\r\n\r\n%s</long_description>\r\n", META_LONG1, META_LONG2);
		fprintf(meta, "\t<ahb_access/>\r\n</app>");
		fclose(meta);
	}
Example #18
0
File: main.c Project: capz/GRRLIB
int main() {
    int i;
    int screen_index = 0;
    float t=0;
    const int R=81;
    const int r=71;
    const int d=120;
    float f=0;
    float ff=0;
    float spr=0;
    int n=1;
    float a=0;
    float cubeZ=10.0f;
    float camZ=30.0f;;

    GRRLIB_Init();
    PAD_Init();

    GRRLIB_Settings.antialias = false;

    GRRLIB_texImg *tex_screen[9];
    for(i=0; i<9; i++) {
        tex_screen[i] = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);
    }

    GRRLIB_texImg *tex_girl = GRRLIB_LoadTexture(girl);
    GRRLIB_texImg *tex_logo = GRRLIB_LoadTexture(logo);
    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font);
    GRRLIB_InitTileSet(tex_font, 16, 16, 32);


    for(i=0;i<=255;i+=1) {
        GRRLIB_Printf((640-(16*16))/2, 200, tex_font, 0xFFFFFF00|i, 1, "HOW MANY 3D CUBE");
        GRRLIB_Printf((640-(16*20))/2, 216, tex_font, 0xFFFFFF00|i, 1, "CAN YOU DISPLAY WITH");
        GRRLIB_DrawImg((640-352)/2, 248, tex_logo, 0, 1, 1, 0xFFFFFF00|i);
        GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFF00|i, 1, "BY NONAMENO FROM GRRLIB TEAM");
        GRRLIB_Render();
    }
    for(i=255;i>=0;i-=2) {
        GRRLIB_Printf((640-(16*16))/2, 200, tex_font, 0xFFFFFF00|i, 1, "HOW MANY 3D CUBE");
        GRRLIB_Printf((640-(16*20))/2, 216, tex_font, 0xFFFFFF00|i, 1, "CAN YOU DISPLAY WITH");
        GRRLIB_DrawImg((640-352)/2, 248, tex_logo, 0, 1, 1, 0xFFFFFF00|i);
        GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFF00|i, 1, "BY NONAMENO FROM GRRLIB TEAM");
        GRRLIB_Render();
    }

    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);

    while(1) {
        PAD_ScanPads();
        GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0);

        GRRLIB_2dMode();
        GRRLIB_DrawImg(0, 0, tex_screen[screen_index], 0, 1, 1, 0xFFFFFFFF);

        GRRLIB_3dMode(0.1, 1000, 45, 1, 0);
        GRRLIB_SetBlend(GRRLIB_BLEND_ALPHA);


        cubeZ+=0.02f;
        GRRLIB_ObjectView((float)(((R + r-ff)*cos(t-f) - d*cos(((R + r-f)/r)*t)))/20.0f,(float)(((R + r-ff)*sin(t) - d*sin(((R + r)/r)*t)-f))/20.0f,sin(cubeZ)*10, a,a*2,a*3,1,1,1);
        GRRLIB_SetTexture(tex_girl, 0);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();

        a+=0.5f;

        GRRLIB_2dMode();
        GRRLIB_Screen2Texture(0, 0, tex_screen[screen_index], GX_FALSE);
        GRRLIB_Printf((640-(16*6*5))/2+5, 200+5, tex_font, 0x00000088, 5, "%06d",(int)spr);
        GRRLIB_Printf((640-(16*6*5))/2, 200, tex_font, 0xFFEEEE88, 5, "%06d",(int)spr);

        GRRLIB_Render();
        screen_index++;
        screen_index %= 9;
        spr+=0.1f;
        t+=0.01f;

        if(t>n*2*M_PI) {
            n++;
            f+=0.01f;
        }

        if(f>2*M_PI) {
            f=0;
            ff+=0.02f;
        }


        if(PAD_ButtonsDown(0) & PAD_BUTTON_START) exit(0);
    }
    GRRLIB_FreeTexture(tex_logo);
    GRRLIB_FreeTexture(tex_girl);
    GRRLIB_FreeTexture(tex_font);
    for(i=0; i<9; i++) {
        GRRLIB_FreeTexture(tex_screen[i]);
    }
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB

    return 0;
}
Example #19
0
enum e_cui_menu menu_option_snd(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size);  
	GRRLIB_texImg *tex_btn = GRRLIB_LoadTexture(button_png);
	
	UI_button button_sounds;
	UI_InitBtn(&button_sounds, 200, 280, "Mute");
	button_sounds.img = tex_btn;
	button_sounds.font = font;
	
	UI_button button_return;
	UI_InitBtn(&button_return, 400, 400, "Return");
	button_return.img = tex_btn;
	button_return.font = font;
	
	
	
	int i;
	UI_button button_type[4];
	for(i=0;i<4;i++){
		char text[7];
		sprintf(text, "TYPE %c", 'A'+i);
		UI_InitBtn(&button_type[i], 50+150*i, 100, text);
		button_type[i].img = tex_btn;
		button_type[i].font = font;	
	}

	while(!done){		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		for(i=0;i<4;i++){
			UI_UpdateBtn(&button_type[i], p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		}
		
		UI_UpdateBtn(&button_sounds, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		for(i=0;i<4;i++){
			if(button_type[i].click){
				switch(i){
					case 0:MODPlay_SetMOD(&play,bg_music);MODPlay_Start(&play);break;
					case 1:MODPlay_SetMOD(&play,bg_music_b);MODPlay_Start(&play);break;
					case 2:MODPlay_SetMOD(&play,bg_music_c);MODPlay_Start(&play);break;
					case 3:MODPlay_SetMOD(&play,bg_music_d);MODPlay_Start(&play);break;
				}
			}
		}
		
		if(button_sounds.click){
			p_game->is_mute = !p_game->is_mute;
			AESND_Pause(p_game->is_mute);
		}
		
		if(button_return.click){
			done=true;
			next_state=CUI_MENU_MAIN;
		}
		
		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}

		for(i=0;i<4;i++){
			UI_DrawBtn(&button_type[i]);
		}
	
		UI_DrawBtn(&button_sounds);
		UI_DrawBtn(&button_return);
		
		cui_cursor_display(p_game->cursor);
		
		GRRLIB_Render();
	}
	

	free(button_sounds.text);
	free(button_return.text);
	free(button_type[0].text);
	free(button_type[1].text);
	free(button_type[2].text);
	free(button_type[3].text);
	GRRLIB_FreeTexture(tex_btn);
	GRRLIB_FreeTTF(font); 
	
	return next_state;
}
Example #20
0
enum e_cui_menu menu_option(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_general;
	UI_InitBtn(&button_general, 280, 120, "General");
	button_general.img = GRRLIB_LoadTexture(button_png);
	button_general.font = font;
*/	
	UI_button button_graphics;
	UI_InitBtn(&button_graphics, 280, 200, "Graphics");
	button_graphics.img = GRRLIB_LoadTexture(button_png);
	button_graphics.font = font;
	
	UI_button button_sounds;
	UI_InitBtn(&button_sounds, 280, 280, "Sounds");
	button_sounds.img = GRRLIB_LoadTexture(button_png);
	button_sounds.font = font;
	
	UI_button button_return;
	UI_InitBtn(&button_return, 400, 400, "Return");
	button_return.img = GRRLIB_LoadTexture(button_png);
	button_return.font = font;
	
	while(!done){		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		//UI_UpdateBtn(&button_general, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_graphics, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_sounds, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		/*if(button_general.click){
			done=true;
			next_state=CUI_MENU_OPTION_GENERAL;
		}*/

		if(button_graphics.click){
			done=true;
			next_state=CUI_MENU_OPTION_GFX;
		}
		
		if(button_sounds.click){
			done=true;
			next_state=CUI_MENU_OPTION_SND;
		}
		
		if(button_return.click){
			done=true;
			next_state=CUI_MENU_MAIN;
		}
		
		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}

		
		//UI_DrawBtn(&button_general);
		UI_DrawBtn(&button_graphics);
		UI_DrawBtn(&button_sounds);
		UI_DrawBtn(&button_return);
		
		cui_cursor_display(p_game->cursor);
		
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTexture(button_graphics.img);free(button_graphics.text);
	GRRLIB_FreeTexture(button_sounds.img);free(button_sounds.text);
	GRRLIB_FreeTexture(button_return.img);free(button_return.text);
	
	GRRLIB_FreeTTF(font);
	
	//GRRLIB_F(font);
	
	return next_state;
}
Example #21
0
int main() {
    float a=0;
    int cubeZ=5;
    int i=0;
    float sinx=0, oldsinx=0;

    GRRLIB_Init();
    WPAD_Init();

    GRRLIB_texImg *tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth,rmode->efbHeight);
    GRRLIB_InitTileSet(tex_screen, rmode->fbWidth, 1, 0);

    GRRLIB_texImg *tex_girl= GRRLIB_LoadTexture(girl);

    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font);
    GRRLIB_InitTileSet(tex_font, 16, 16, 32);


    GRRLIB_Settings.antialias = true;

    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);
    GRRLIB_Camera3dSettings(0.0f,0.0f,13.0f, 0,1,0, 0,0,0);

    while(1) {
        GRRLIB_2dMode();
        WPAD_ScanPads();
        if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
        if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) cubeZ++;
        if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) cubeZ--;

        GRRLIB_3dMode(0.1,1000,45,1,0);
        GRRLIB_SetTexture(tex_girl,0);
        GRRLIB_ObjectView(0,0,cubeZ, a,a*2,a*3,1,1,1);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();
        GRRLIB_Screen2Texture(0,0,tex_screen,1);
        a+=0.5f;

        // Switch To 2D Mode to display text
        GRRLIB_2dMode();
        oldsinx=sinx;
        for(i=0; i<rmode->efbHeight; i++) {
            GRRLIB_DrawTile(0+sin(sinx)*60,i,tex_screen,0,1,1,0xFFFFFFFF,i);
            sinx+=0.02f;
        }
        sinx=oldsinx+0.02f;

        GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "PRESS A OR B TO ZOOM THE CUBE");

        GRRLIB_Render();
    }
    GRRLIB_FreeTexture(tex_girl);
    GRRLIB_FreeTexture(tex_font);
    GRRLIB_FreeTexture(tex_screen);
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
    exit(0);
}
Example #22
0
enum e_cui_menu menu_option_gfx(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	u32 option_tile_color_1 = p_game->board->tile_color1;
	u32 option_tile_color_2 = p_game->board->tile_color2;
	u32 option_piece_color_1 = p_game->board->piece_color1;
	u32 option_piece_color_2 = p_game->board->piece_color2;
	
	GRRLIB_texImg *tex_tile = GRRLIB_LoadTexture(keyboard_key_png);
	GRRLIB_texImg *tex_pieces = GRRLIB_LoadTexture(chess_classic_png);
	GRRLIB_texImg *tex_up = GRRLIB_LoadTexture(scrollbar_arrowup_png);
	GRRLIB_texImg *tex_down = GRRLIB_LoadTexture(scrollbar_arrowdown_png);
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size);  
	
	int i,j;
	UI_button button_color[4][8];		//tile 1, tile 2, piece 1, piece 2 | R-+, G-+, B-+, A-+,
	for(i=0;i<4;i++){
		for(j=0;j<8;j++){
			UI_InitBtn(&button_color[i][j], 120 + j*64, 64 + i*80, NULL);
			button_color[i][j].img = j%2==0?tex_down:tex_up;
		}
	}
		
	UI_button button_return;
	UI_InitBtn(&button_return, 500, 400, "apply");
	button_return.img = GRRLIB_LoadTexture(button_png);
	button_return.font = font;
	
	UI_button button_cancel;
	UI_InitBtn(&button_cancel, 350, 400, "cancel");
	button_cancel.img = GRRLIB_LoadTexture(button_png);
	button_cancel.font = font;
	
	while(!done){		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		
		u32* color_to_modify=NULL;
		u32 mask;
		for(i=0;i<4;i++){
			for(j=0;j<8;j++){
				UI_UpdateBtn(&button_color[i][j], p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
				if(button_color[i][j].click){
					switch(i){
						case 0:color_to_modify = &option_tile_color_1;break;
						case 1:color_to_modify = &option_tile_color_2;break;
						case 2:color_to_modify = &option_piece_color_1;break;
						case 3:color_to_modify = &option_piece_color_2;break;
					}
					if(j==0 || j==1)mask=0x06000000;
					if(j==2 || j==3)mask=0x00060000;
					if(j==4 || j==5)mask=0x00000600;
					if(j==6 || j==7)mask=0x00000006;
					*color_to_modify+=j%2==0?-mask:mask;
				}
			}
		}


		
		UI_UpdateBtn(&button_cancel, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		if(button_return.click){
			if((option_tile_color_1 != p_game->board->tile_color1) || (option_tile_color_2 != p_game->board->tile_color2)){
				p_game->board->tile_color1 = option_tile_color_1;
				p_game->board->tile_color2 = option_tile_color_2;
				cui_board_init(p_game->board);
			}
			
			if(option_tile_color_1 != p_game->board->piece_color1)p_game->board->piece_color1=option_piece_color_1;
			if(option_tile_color_2 != p_game->board->piece_color2)p_game->board->piece_color2=option_piece_color_2;
					
			done=true;
			next_state=CUI_MENU_MAIN;
		}
		
		if(button_cancel.click){
			done=true;
			next_state=CUI_MENU_MAIN;
		}
		
		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}

		GRRLIB_DrawImg(380, 80+140, tex_tile, 0, 2, 2, option_tile_color_1);
		GRRLIB_DrawImg(380, 180+140, tex_tile, 0, 2, 2, option_tile_color_2);
		GRRLIB_DrawImg(380+80, 80+140, tex_tile, 0, 2, 2, option_tile_color_2);
		GRRLIB_DrawImg(380+80, 180+140, tex_tile, 0, 2, 2, option_tile_color_1);
		GRRLIB_DrawImg(380+160, 80+140, tex_tile, 0, 2, 2, option_tile_color_1);
		GRRLIB_DrawImg(380+160, 180+140, tex_tile, 0, 2, 2, option_tile_color_2);
		GRRLIB_DrawImg(380, 80, tex_pieces, 0, 2, 2, option_piece_color_2);
		GRRLIB_DrawImg(380, 180, tex_pieces, 0, 2, 2, option_piece_color_1);
		
		
		GRRLIB_PrintfTTF (145, 0, font, "RED              GREEN              BLUE             ALPHA", 20, 0xFFFFFFFF);
		GRRLIB_PrintfTTF (15, 40, font, "Tiles color #1", 20, 0xFFFFFFFF);
		GRRLIB_PrintfTTF (15, 40+80, font, "Tiles color #2", 20, 0xFFFFFFFF);
		GRRLIB_PrintfTTF (15, 40+80*2, font, "Pieces color #1", 20, 0xFFFFFFFF);
		GRRLIB_PrintfTTF (15, 40+80*3, font, "Pieces color #2", 20, 0xFFFFFFFF);

		for(i=0;i<4;i++){
			for(j=0;j<8;j++){
				UI_DrawBtn(&button_color[i][j]);
			}
		}


		UI_DrawBtn(&button_return);
		UI_DrawBtn(&button_cancel);
		
		GRRLIB_Line(235, 25, 235, 350, 0xFFFFFFFF);
		GRRLIB_Line(235+64*2, 25, 235+64*2, 350, 0xFFFFFFFF);
		GRRLIB_Line(235+64*4, 25, 235+64*4, 350, 0xFFFFFFFF);
		GRRLIB_Line(235+64*6, 25, 235+64*6, 350, 0xFFFFFFFF);
		
		cui_cursor_display(p_game->cursor);
		
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTexture(tex_tile);
	GRRLIB_FreeTexture(tex_pieces);
	GRRLIB_FreeTexture(tex_up);
	GRRLIB_FreeTexture(tex_down);
	GRRLIB_FreeTTF(font); 
	
	free(button_return.text);
	free(button_cancel.text);
	
	return next_state;	
}
Example #23
0
cui_menu menu_play(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	
	GRRLIB_texImg *tex_pieces = GRRLIB_LoadTexture(chess_classic_png);
	GRRLIB_texImg *tex_tile = GRRLIB_LoadTexture(keyboard_key_png);	
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); 
	bool is_debug = false;

	char coords[5];
	char calculated_coords[5];
	
	strcpy(coords, "d2d20");
	strcpy(calculated_coords, "d2d20");
	
	while(!done){
		WPAD_IR(0, &ir);
		WPAD_ScanPads();
		
		u32 pressed = WPAD_ButtonsDown(0);
		u32 released = WPAD_ButtonsUp(0);
		
		if(egg_check_s1_code(pressed, released)){
			is_debug = true;
			p_game->board->tile_color1 = 0xc66300FF;
			p_game->board->tile_color2 = 0x632100FF;
			p_game->board->piece_color1 = 0x4242CCFF;
			p_game->board->piece_color2 = 0x444411FF;
			cui_board_init(p_game->board);
			if(voice) AESND_PlayVoice(voice, VOICE_STEREO8, warp, warp_size, VOICE_FREQ32KHZ, 1, false);
		}

		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}
		
		if ( pressed & WPAD_BUTTON_MINUS){
			switch(menu_option(p_game)){
				case CUI_MENU_OPTION_GFX:menu_option_gfx(p_game);break;
				case CUI_MENU_OPTION_SND:menu_option_snd(p_game);break;
				default:break;
			}
		}
		
		int index_offset_x = (p_game->cursor->hotspot_x - 40 / 2)/ 40 - 140 / 40;
		int index_offset_y = p_game->cursor->hotspot_y / 40 - 80 / 40;
		
		if (pressed & WPAD_BUTTON_B) {
			p_game->cursor->is_grabbing = true;
			
			if(index_offset_x >= 0 && index_offset_x < 8 && index_offset_y >= 0 && index_offset_y < 8){
				coords[0] = 'a' + index_offset_x;
				coords[1] = '8' - index_offset_y;
			}
				
		}
		else if(released & WPAD_BUTTON_B){
			p_game->cursor->is_grabbing = false;

			if(index_offset_x >= 0 && index_offset_x < 8 && index_offset_y >= 0 && index_offset_y < 8){
				coords[2] = 'a' + index_offset_x;
				coords[3] = '8' - index_offset_y;
				coords[4] = 0;

				if(voice) AESND_PlayVoice(voice, VOICE_STEREO16, move_pcm, move_pcm_size, VOICE_FREQ48KHZ, 1, false);
				
				if(calculate_coords(coords, calculated_coords, p_game->engine)){
					cui_board_read_core(p_game->board, p_game->engine);
				}
				
			}
		}
		
		cui_cursor_update(p_game->cursor, ir.x, ir.y, ir.angle);
		
		
		if(p_game->tex_wallpaper)GRRLIB_DrawImg(0, -50, p_game->tex_wallpaper, 1, 1, 1, 0XFFFFFFFF);
		
		cui_board_display(p_game->board, tex_pieces, tex_tile, font, index_offset_x, index_offset_y);
		cui_cursor_display(p_game->cursor);
		
		if(is_debug){
			GRRLIB_PrintfTTF (20, 00, font, coords, 16, 0x424242FF);
			GRRLIB_PrintfTTF2 (20, 20, font, 16, 0xFFFFFFFF, "x:%.2f y:%.2f", ir.x, ir.y);
			GRRLIB_PrintfTTF2 (20, 40, font, 16, 0xFFFFFFFF, "x:%.2f y:%.2f", ir.x/40, ir.y/40);
			GRRLIB_PrintfTTF2 (20, 60, font, 16, 0xFFFFFFFF, "x:%d y:%d", index_offset_x, index_offset_y);
			GRRLIB_PrintfTTF (20, 80, font, p_game->cursor->is_grabbing?"GRAB":"POINT", 16, 0xFFFFFFFF);
			
			GRRLIB_Rectangle(p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, 4, 4, 0xFF4242FF, 1);
		}
	
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTexture(tex_pieces);
	GRRLIB_FreeTexture(tex_tile);
	GRRLIB_FreeTTF(font);
		
	return next_state;
}
Example #24
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);
}
Example #25
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;
}
Example #26
0
File: main.c Project: capz/GRRLIB
int main() {
    int i;
    int screen_index = 0;
    float t = 0;
    const int R = 81;
    const int r = 71;
    const int d = 120;
    float f = 0;
    float ff = 0;
    float spr = 0;
    int n = 1;


    GRRLIB_Init();
    PAD_Init();

    GRRLIB_Settings.antialias = false;

    GRRLIB_texImg *tex_screen[10];
    for(i=0; i<10; i++) {
        tex_screen[i] = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);
    }

    GRRLIB_texImg *tex_ball = GRRLIB_LoadTexture(ball);
    GRRLIB_texImg *tex_logo = GRRLIB_LoadTexture(logo);
    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font);
    GRRLIB_InitTileSet(tex_font, 16, 16, 32);


    for(i=0;i<=255;i+=1) {
        GRRLIB_Printf((640-(16*16))/2, 200, tex_font, 0xFFFFFF00|i, 1, "HOW MANY SPRITES");
        GRRLIB_Printf((640-(16*20))/2, 216, tex_font, 0xFFFFFF00|i, 1, "CAN YOU DISPLAY WITH");
        GRRLIB_DrawImg((640-352)/2, 248, tex_logo, 0, 1, 1, 0xFFFFFF00|i);
        GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFF00|i, 1, "BY NONAMENO FROM GRRLIB TEAM");
        GRRLIB_Render();
    }
    for(i=255;i>=0;i-=2) {
        GRRLIB_Printf((640-(16*16))/2, 200, tex_font, 0xFFFFFF00|i, 1, "HOW MANY SPRITES");
        GRRLIB_Printf((640-(16*20))/2, 216, tex_font, 0xFFFFFF00|i, 1, "CAN YOU DISPLAY WITH");
        GRRLIB_DrawImg((640-352)/2, 248, tex_logo, 0, 1, 1, 0xFFFFFF00|i);
        GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFF00|i, 1, "BY NONAMENO FROM GRRLIB TEAM");
        GRRLIB_Render();
    }

    while(1) {
        PAD_ScanPads();

        GRRLIB_DrawImg(0, 0, tex_screen[screen_index], 0, 1, 1, 0xFFFFFFFF);
        GRRLIB_DrawImg(((R + r-ff)*cos(t-f) - d*cos(((R + r-f)/r)*t))+rmode->fbWidth/2-32, ((R + r-ff)*sin(t) - d*sin(((R + r)/r)*t)-f)+rmode->efbHeight/2-32, tex_ball, 1, 1, 1, 0xFFFFFFFF);
        GRRLIB_Screen2Texture(0, 0, tex_screen[screen_index], GX_FALSE);
        GRRLIB_Printf((640-(16*6*5))/2+5, 200+5, tex_font, 0x00000088, 5, "%06d",(int)spr);
        GRRLIB_Printf((640-(16*6*5))/2, 200, tex_font, 0xFFEEEE88, 5, "%06d",(int)spr);

        GRRLIB_Render();
        screen_index++;
        screen_index %= 10;
        spr+=0.1f;
        t+=0.01f;

        if(t>n*2*M_PI) {
            n++;
            f+=0.01f;
        }

        if(f>2*M_PI) {
            f=0;
            ff+=0.02f;
        }


        if(PAD_ButtonsDown(0) & PAD_BUTTON_START) exit(0);

    }
    GRRLIB_FreeTexture(tex_logo);
    GRRLIB_FreeTexture(tex_ball);
    GRRLIB_FreeTexture(tex_font);
    for(i=0; i<10; i++) {
        GRRLIB_FreeTexture(tex_screen[i]);
    }
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
    return 0;
}