Ejemplo n.º 1
0
void gfx_draw_outro(SDL_Surface * screen)
{
    SDL_Surface *logo = NULL;

    int stime = 0, alpha = 0, time_var = 0;
    SDL_Surface *black = gfx_new_surface(320, 240, 1);

    if (!black)
    {
        if (black)
            SDL_FreeSurface(black);

        return;
    }

    logo = gfx_load_image("images/icons/game_run.png", 0);

    stime = SDL_GetTicks();

    time_var = SDL_GetTicks();

    while (stime + 200 > SDL_GetTicks())
    {
        SDL_FillRect(black, NULL,
                     SDL_MapRGBA(black->format, 0, 0, 0, alpha));
        bg_draw(screen);
        gfx_draw_image(black, 0, 0, screen);
        SDL_Flip(screen);

        alpha += (255 / (float) 200) * (SDL_GetTicks() - time_var);
        if (alpha > 255)
            alpha = 255;
        time_var = SDL_GetTicks();
    }

    sfx_play(SFXRUN);

    alpha = 255;
    while (stime + 3000 > SDL_GetTicks())
    {
        SDL_FillRect(black, NULL,
                     SDL_MapRGBA(black->format, 0, 0, 0, alpha));
        gfx_draw_image(black, 0, 0, screen);
        if (logo)
            gfx_draw_image(logo, (screen->w - logo->w) / 2,
                           (screen->h - logo->h) / 2, screen);
        SDL_Flip(screen);
    }
    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
    SDL_Flip(screen);

    SDL_FreeSurface(logo);
}
Ejemplo n.º 2
0
void sub_music_draw(SDL_Surface * screen)
{
    if (music_stage == 1)       /* move left */
    {
        if (!music_xmb_offset_tx)
        {
            music_xmb_offset_ox = music_xmb_offset_x;
            music_xmb_offset_tx = -LIST_columnWidth();
        }
        music_xmb_offset_x -=
            rint(LIST_columnWidth() / ((float) (XMBMOVEDELAY)) *
                 (SDL_GetTicks() - music_animtimer));
    }
    else if (music_stage == 2)  /* move right */
    {
        if (!music_xmb_offset_tx)
        {
            music_xmb_offset_ox = music_xmb_offset_x;
            music_xmb_offset_tx = LIST_columnWidth();
        }
        music_xmb_offset_x +=
            rint(LIST_columnWidth() / ((float) (XMBMOVEDELAY)) *
                 (SDL_GetTicks() - music_animtimer));
    }
    else if (music_stage == 3)  /* move left (inital) */
    {
        if (!music_xmb_offset_tx)
        {
            music_xmb_offset_ox = music_xmb_offset_x;
            music_xmb_offset_tx = -LIST_columnWidth();
        }
        music_xmb_offset_x -=
            rint(LIST_columnWidth() / ((float) (XMBMOVEDELAY)) *
                 (SDL_GetTicks() - music_animtimer));
    }
    else if (music_stage == 4)  /* move right (final) */
    {
        if (!music_xmb_offset_tx)
        {
            music_xmb_offset_ox = music_xmb_offset_x;
            music_xmb_offset_tx = LIST_columnWidth();
        }
        music_xmb_offset_x +=
            rint(LIST_columnWidth() / ((float) (XMBMOVEDELAY)) *
                 (SDL_GetTicks() - music_animtimer));
    }
    else if (music_stage == 5)
    {
        music_stage++;
    }
    else if (music_stage == 6)
    {
        sub_music_browse();
        music_stage = 0;
    }

    if (SDL_GetTicks() - music_animtimer_b > XMBMOVEDELAY && music_stage)
    {
        if (music_stage == 1 || music_stage == 3)
        {
            LIST_setEmptyMsg("Please Wait...");
            music_stage = 5;
        }

        if (music_stage == 4 && music_levels == -1)
        {
            music_xmb_offset_x = 0;
            LIST_destroy();
            sub_music_destroy();
            submenu = NULL;
            sub_music_playing = 0;
            return;
        }

        if (music_stage <= 5)
        {
            music_xmb_offset_x = music_xmb_offset_ox + music_xmb_offset_tx;
            music_xmb_offset_tx = 0;
            music_xmb_offset_ox = 0;
        }

        if (music_stage > 0 && music_stage < 5)
            music_stage = 0;
    }
    music_animtimer = SDL_GetTicks();

    if (music_stage != MUS_FULLSCREEN)
    {
        if (music_stage != 3 && music_stage != 4)
        {
            LIST_draw(screen, (int) music_xmb_offset_x + ICONSCALE_X - 5,
                      0);
        }
    }
    else if (sub_music_playing)
    {
        tlistitem *sel;
        SDL_Rect wrect;
        char textstr[16];
        int minutes = 0, seconds = 0, tmin = 0, tsec = 0;
        textstr[0] = '\0';
        wrect.x = screen->w - 210;
        wrect.y = screen->h - 14;
        wrect.w = 200;
        wrect.h = 4;
        SDL_FillRect(screen, &wrect,
                     SDL_MapRGB(screen->format, 255, 255, 255));
        wrect.w *= mus_getpos() / (float) mus_getlength();
        wrect.w = ceil(wrect.w);
        SDL_FillRect(screen, &wrect,
                     SDL_MapRGB(screen->format, 0, 130, 180));

#ifdef TREMOR
        minutes = ((mus_getpos() / 1000) / 60);
        seconds = ((mus_getpos() / 1000) % 60);
        tmin = ((mus_getlength() / 1000) / 60);
        tsec = ((mus_getlength() / 1000) % 60);
#else
        minutes = ((mus_getpos()) / 60);
        seconds = ((mus_getpos()) % 60);
        tmin = ((mus_getlength()) / 60);
        tsec = ((mus_getlength()) % 60);
#endif

        sprintf(textstr, "%02i:%02i / %02i:%02i", minutes, seconds, tmin,
                tsec);
        gfx_draw_text(screen, font_monospace, 215, 210, USESHADOW, NOGLOW,
                      textstr);

        sel = LIST_getSelected();

        gfx_draw_image(sel->icon, 25, 102, screen);
        gfx_draw_text(screen, font_normal, 71, 100, USESHADOW, NOGLOW,
                      sel->title);
        gfx_draw_text(screen, font_small, 71, 126, USESHADOW, NOGLOW,
                      sel->subtitle);


        if (mus_eof())
        {
            if (LIST_down())
            {
                mus_stop();
                while (!mus_ready());
                sub_music_playsel();
            }
            else
            {
                sub_music_handle_input(GP2X_BUTTON_B);
            }
        }
    }
}
Ejemplo n.º 3
0
void gfx_draw_about(SDL_Surface *screen)
{
	SDL_Surface *about = NULL;
	int stime = 0;
	float offset = -screen->h;
	const static float speed = 50.0/1000.0;
	SDL_Event event;
	int done = 0;

	about = gfx_load_image("images/icons/about_text.png",0);

	if(!about)
		return;

	stime = SDL_GetTicks();

	while(offset < about->h && !done)
	{
		int ttime = SDL_GetTicks()-stime;
		stime = SDL_GetTicks();

		SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));

		gfx_draw_image(about,0,-(int)offset,screen);

		SDL_Flip(screen);

		offset += speed*ttime;

		while (SDL_PollEvent(&event))
        {
			switch (event.type)
            {
            case SDL_KEYDOWN:
                switch (event.key.keysym.sym)
                {
                case SDLK_ESCAPE:
                case SDLK_BACKSPACE:
                case SDLK_RETURN:
                    done = 1;
                    break;
                default:
                    break;
                }
                break;
#ifdef TARGET_GP2X
            case SDL_JOYBUTTONDOWN:
                switch (event.jbutton.button)
                {
                case GP2X_BUTTON_B:
                case GP2X_BUTTON_X:
                    done = 1;
					break;
                default:
                    break;
                }
                break;
#endif
            }
        }

	}

	SDL_FreeSurface(about);
}
Ejemplo n.º 4
0
//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------

	s32 ret;
	u8 gamestatus = 0x03;
	u8 versionnumber = 0x80;
	u32 geckoidcheck;
	u8 oldconfigbytes[2];
	
	ret = sd_init();
	if(!ret){
		sd_found = 0;
	}
	else {
		sd_found = 1;
	}
	
	if (*((u32 *) 0x80001804) == 0x53545542 && *((u32 *) 0x80001808) == 0x48415858)
		loaderhbc = 1;
	
	*(u32*)0xCD00643C = 0x00000000;	// 32Mhz on Bus
	
	gecko_attached = usb_isgeckoalive(EXI_CHANNEL_1);
	if(gecko_attached){	
		gecko_channel = 1;
		if (EXI_GetID(gecko_channel, 0x80, &geckoidcheck) == 1)
		{
			if (geckoidcheck != 0)
			{
				gecko_attached = FALSE;
				goto slota;
			}
		}
		else
		{
			gecko_attached = FALSE;
			goto slota;
		}
		usb_flushnew(gecko_channel);
		goto slotb;
	}
	
slota:
	
	gecko_attached = usb_isgeckoalive(EXI_CHANNEL_0);
	if(gecko_attached){	
		gecko_channel = 0;
		if (EXI_GetID(gecko_channel, 0x80, &geckoidcheck) == 1)
		{
			if (geckoidcheck != 0)
			{
				gecko_attached = FALSE;
				goto slotb;
			}
		}
		else
		{
			gecko_attached = FALSE;
			goto slotb;
		}
		usb_flushnew(gecko_channel);
	}
	
slotb:
	
	sd_load_config();
	
	tempgameconf = (char *) sdbuffer;
	autobootcheck = 1;
	memset(gameidbuffer, 0, 8);
	app_loadgameconfig(gameidbuffer);
	autobootcheck = 0;
	
	loadStartupIOS();
	iosversion = IOS_GetVersion();
	
	if(config_not_loaded == 0){
		menu_load_config();
		config_not_loaded = 1;
	}
	
	if (autoboothbc || !loaderhbc)
	{
		if (autoboot == 1)
		{
			rebooter_thread();
			menu_number = 12;
			rebooter_thread_state = 0;
		}
	}
	else
		autoboot = 0;
	
	WPAD_Init();
	PAD_Init();
	VIDEO_Init();
	AUDIO_Init (NULL);
	
	SYS_SetPowerCallback (power_cb);
    SYS_SetResetCallback (reset_cb);
	
	if (CONF_GetProgressiveScan() > 0 && VIDEO_HaveComponentCable()) {
		progmode = 1;
	}

	if (CONF_GetAspectRatio()) {
		widescreen = 1;
	}
	
	gfx_init();
	gfx_load_gfx();
	
	gfx_load_gfx1();
	if (autoboot == 0 || autobootwait > 1)
		gfx_fade_logo();
	
	VIDEO_WaitVSync();
	
	if(!gecko_attached){	
		gecko_channel = 2;
	}

	gfx_int_stars();
	
	while(1)
	{
		if(gecko_attached){
			usb_recvbuffer(gecko_channel,&gecko_command,1);
			switch(gecko_command)
			{
				//case 0x04:	
				//	gecko_readmem();	
				//break;
				
				case 0x14:		// Load DOL
					load_geckoexe(0);
				break;
					
				case 0x24:		// Load DOL
					load_geckoexe(1);
				break;

				case 0x42:
					// Debugger on, pause start off
					config_bytes[7] = 0x01;
					config_bytes[5] = 0x00;
					usb_recvbuffer_safe(gecko_channel,&oldconfigbytes,2);	// Get config
					config_bytes[0] = oldconfigbytes[0];
					switch (oldconfigbytes[1])
					{
					case 0x00:
						config_bytes[1] = 0x00;
						break;
					case 0x01:
						config_bytes[1] = 0x01;
						break;
					case 0x02:
						config_bytes[1] = 0x00;
						break;
					case 0x03:
						config_bytes[1] = 0x01;
						break;
					case 0x04:
						config_bytes[1] = 0x03;
						break;
					case 0x05:
						config_bytes[1] = 0x03;
						break;
					case 0x06:
						config_bytes[1] = 0x02;
						break;
					case 0x07:
						config_bytes[1] = 0x02;
						break;
					}
					menu_number = 8;
					apploader_thread();
					gecko_command = 0;
				break;
					
				case 0x43:
					// Debugger on, pause start on
					config_bytes[7] = 0x01;
					config_bytes[5] = 0x01;
					usb_recvbuffer_safe(gecko_channel,&oldconfigbytes,2);	// Get config
					config_bytes[0] = oldconfigbytes[0];
					switch (oldconfigbytes[1])
					{
						case 0x00:
							config_bytes[1] = 0x00;
							break;
						case 0x01:
							config_bytes[1] = 0x01;
							break;
						case 0x02:
							config_bytes[1] = 0x00;
							break;
						case 0x03:
							config_bytes[1] = 0x01;
							break;
						case 0x04:
							config_bytes[1] = 0x03;
							break;
						case 0x05:
							config_bytes[1] = 0x03;
							break;
						case 0x06:
							config_bytes[1] = 0x02;
							break;
						case 0x07:
							config_bytes[1] = 0x02;
							break;
					}
					menu_number = 8;
					apploader_thread();
					gecko_command = 0;
				break;

				case 0x50:		
					usb_sendbuffer_safe(gecko_channel,&gamestatus,1);
				break;

				case 0x99:		
					usb_sendbuffer_safe(gecko_channel,&versionnumber,1); 
				break;
			}

		}
		
		if(error_sd || confirm_sd || error_video){
			sleep(1);
			error_sd = 0;
			confirm_sd = 0;
			error_video = 0;
		}

		if(loadedpng && !alphapng){	// if custom backdrop draw bubbles after image
			gfx_draw_image(0, 0, 640, 480, tex_logo1, 0, 1, 1,0xff);
			gfx_draw_stars();
		}
		else{
			gfx_draw_stars(); // else if own back drop do in this order due to border clip
			gfx_draw_image(0, 0, 640, 480, tex_logo1, 0, 1, 1,0xff);
		};
		
		menu_draw();
		gfx_render_direct();
	}

	return 0;
}
Ejemplo n.º 5
0
void sub_shc_draw(SDL_Surface * screen)
{
    int td, animating = 0;
    shc_node *curr = NULL;

    if (shc_init_stage)
    {
        sub_shc_stages(screen);
    }

    if (shc_movereq && !shc_movedir)
    {
        if (shc_movereq < 0)
        {
            sfx_play(SFXMOVE);
            shc_movedir = -1;
            shc_movereq++;
        }
        else if (shc_movereq > 0)
        {
            sfx_play(SFXMOVE);
            shc_movedir = 1;
            shc_movereq--;
        }
        shc_assign_move(shc_movedir);
        shc_timer2 = SDL_GetTicks();
    }

    if (!shc_init_stage)
        gfx_draw_image(shc_arrow, 25, 113, screen);

    curr = shc_root;

    td = (SDL_GetTicks() - shc_timer2);

    shc_timer2 = SDL_GetTicks();

    if (!curr && !shc_init_stage)       /* Did not find anything */
    {
        gfx_draw_text(screen, font_normal, 50, 115, USESHADOW, NOGLOW,
                      "There are no applications.");
    }

    while (curr && !shc_init_stage)
    {
        char t_name[32];
        t_name[0] = '\0';
        strncat(t_name, curr->title, 31);
        if (shc_movedir)
        {
            int move_td_x =
                (int) rint((curr->move_x) / (float) XMBMOVEDELAY * td);
            int move_td_y =
                (int) rint((curr->move_y) / (float) XMBMOVEDELAY * td);

            curr->pos_x += move_td_x;
            curr->pos_y += move_td_y;

            if ((move_td_x > 0 && curr->pos_x > curr->move_tx) ||
                (move_td_x < 0 && curr->pos_x < curr->move_tx))
            {
                curr->pos_x = curr->move_tx;
                curr->move_x = 0;
                curr->move_tx = 0;

                if (curr->pos_x == 50)
                {
                    SDL_FreeSurface(curr->icon_curr);
                    curr->icon_curr =
                        gfx_scaleperc_surface(curr->icon_orig, 1.0, 1.0);
                }
                else
                {
                    SDL_FreeSurface(curr->icon_curr);
                    curr->icon_curr =
                        gfx_scaleperc_surface(curr->icon_orig, 0.5, 0.5);
                }

            }

            if ((move_td_y > 0 && curr->pos_y > curr->move_ty) ||
                (move_td_y < 0 && curr->pos_y < curr->move_ty))
            {
                curr->pos_y = curr->move_ty;
                curr->move_y = 0;
                curr->move_ty = 0;
            }

            if (curr->move_x)
            {
                float bval =
                    ((1.0 / (SHCICONX / 4)) *
                     (curr->pos_x + (curr->move_x - curr->move_tx)) / 2.0);

                if (bval < 0)
                    bval = 0.5 + fabs(bval);
                else if (bval > 0)
                    bval = 0.5 + (0.5 - fabs(bval));

                if (bval)
                {
                    SDL_FreeSurface(curr->icon_curr);
                    curr->icon_curr =
                        gfx_scaleperc_surface(curr->icon_orig, bval, bval);
                }
            }

            if (curr->move_x || curr->move_y)
                animating = 1;
        }
        else if (curr->pos_y == 83)     /* selected ... ugly but it works, for now */
        {
            gfx_draw_text(screen,
                          font_normal,
                          curr->pos_x + SHCICONX + 10,
                          curr->pos_y +
                          ((SHCICONY - SFont_TextHeight(font_normal)) / 2),
                          USESHADOW, NOGLOW, curr->title);
        }

        if ((curr->pos_y + curr->icon_curr->h) > 0 && curr->pos_y < 240)
            gfx_draw_image(curr->icon_curr, curr->pos_x, curr->pos_y,
                           screen);

        curr = curr->next;
    }
    if (!animating)
        shc_movedir = 0;

	if(shc_showpopup)
		POPUP_draw(screen);
}
Ejemplo n.º 6
0
int shc_load(void)
{
    config_setting_t *cfg = config_lookup(&CONFIG, "shortcuts");
    int i;

    if (!cfg)
        return -1;

    for (i = 0; i < config_setting_length(cfg); i++)
    {
        SDL_Surface *icon = NULL;
        config_setting_t *group = config_setting_get_elem(cfg, i);
        config_setting_t *celem = NULL;
        char *filename = NULL;
        char *title = NULL;
        char *pngfile = NULL;

        if (group)
        {
            const char *ctmp;
            celem = config_setting_get_member(group, "path");
            if (celem)
            {
                ctmp = config_setting_get_string(celem);
                if (ctmp)
                {
                    filename = (char *) calloc(1, 1024);
                    strncpy(filename, ctmp, 1023);
                }
            }

            celem = config_setting_get_member(group, "title");
            if (celem)
            {
                ctmp = config_setting_get_string(celem);
                if (ctmp)
                {
                    title = (char *) calloc(1, 1024);
                    strncpy(title, ctmp, 1023);
                }
            }

        }
        else
            continue;

        if (filename && strlen(filename))
        {
            pngfile = (char *) calloc(1, strlen(filename) + 1);

            strncpy(pngfile, filename, strlen(filename));
            strncpy(&pngfile[strlen(pngfile) - 3], "png", 3);
            icon = gfx_load_image(pngfile, 0);
            if (!icon)
                icon = gfx_load_image("images/icons/game_broken.png", 0);
            else if (icon->w < 128 || icon->h < 74)
            {
                SDL_Surface *tmp_icon = gfx_new_surface(128, 74, 0);
                SDL_FillRect(tmp_icon, NULL,
                             SDL_MapRGB((SDL_GetVideoSurface())->format,
                                        255, 255, 255));

                gfx_draw_image(icon, (128 - icon->w) / 2,
                               (74 - icon->h) / 2, tmp_icon);
                SDL_FreeSurface(icon);
                icon = SDL_DisplayFormatAlpha(tmp_icon);
                SDL_FreeSurface(tmp_icon);
            }

            free(pngfile);

            add_shc(filename, title, icon);

            if (title)
                free(title);

            if (filename)
                free(filename);
        }
    }

    return 0;
}