Skip to content

Commit

Permalink
[loader] Adjust the background image for widescreen.
Browse files Browse the repository at this point in the history
If the system's widescreen setting is enabled, scale the background image
to 480x480 and draw it in the center of the screen. This makes it look
correct on widescreen displays. Also, fill the now-unused area with the
same color as the image's primary background color.

Optimized background.png to take up slightly less space.
(91,149 -> 90,813)

(cherry picked from commit e3d878d)

Conflicts:
	loader/source/global.c
  • Loading branch information
GerbilSoft committed Sep 1, 2016
1 parent 9fbeac8 commit 53fc6ef
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
Binary file modified loader/data/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion loader/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <gctypes.h>
#include <stdio.h>
#include <ogc/ipc.h>
#include "background_png.h"
#include "Config.h"
#include "grrlib.h"

Expand Down
44 changes: 41 additions & 3 deletions loader/source/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "dip.h"
#include "unzip/unzip.h"

// Background image.
#include "background_png.h"

GRRLIB_ttfFont *myFont;
GRRLIB_texImg *background;
GRRLIB_texImg *screen_buffer;
bool bg_isWidescreen = false;
static float bg_xScale = 1.0f;
static int bg_xPos = 0;

u32 POffset;

Expand Down Expand Up @@ -168,7 +174,11 @@ void unzip_data(const void *input, const u32 input_size,
static void *font_ttf = NULL;
static u32 font_ttf_size = 0;

void Initialise()
/**
* Initialize the loader.
* This also loads the background image.
*/
void Initialise(void)
{
int i;
AUDIO_Init(NULL);
Expand All @@ -182,9 +192,31 @@ void Initialise()
myFont = GRRLIB_LoadTTF(font_ttf, font_ttf_size);
background = GRRLIB_LoadTexturePNG(background_png);
screen_buffer = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);

// Calculate the background image scale.
bg_isWidescreen = (CONF_GetAspectRatio() == CONF_ASPECT_16_9);
if (bg_isWidescreen)
{
// Widescreen. 0.75x scaling, 80px offset.
bg_xScale = 0.75f;
bg_xPos = 80;
}
else
{
// Standard screen. 1.0x scaling, 0px offset.
bg_xScale = 1.0f;
bg_xPos = 0;
}

for (i=0; i<255; i +=5) // Fade background image in from black screen
{
GRRLIB_DrawImg(0, 0, background, 0, 1, 1, RGBA(255, 255, 255, i)); // Opacity increases as i does
if (bg_isWidescreen)
{
// Clear the sides.
GRRLIB_Rectangle(0, 0, 80, 480, RGBA(222, 223, 224, i), true);
GRRLIB_Rectangle(80+480, 0, 80, 480, RGBA(222, 223, 224, i), true);
}
GRRLIB_DrawImg(bg_xPos, 0, background, 0, bg_xScale, 1, RGBA(255, 255, 255, i)); // Opacity increases as i does
GRRLIB_Render();
}
ClearScreen();
Expand Down Expand Up @@ -314,7 +346,13 @@ bool LoadNinCFG(void)

inline void ClearScreen()
{
GRRLIB_DrawImg(0, 0, background, 0, 1, 1, 0xFFFFFFFF);
if (bg_isWidescreen)
{
// Clear the sides.
GRRLIB_Rectangle(0, 0, 80, 480, RGBA(222, 223, 224, 255), true);
GRRLIB_Rectangle(80+480, 0, 80, 480, RGBA(222, 223, 224, 255), true);
}
GRRLIB_DrawImg(bg_xPos, 0, background, 0, bg_xScale, 1, RGBA(255, 255, 255, 255));
}

static inline char ascii(char s)
Expand Down

0 comments on commit 53fc6ef

Please sign in to comment.