fixed GX_MIRROR usage

This commit is contained in:
ekeeke31 2009-04-06 23:01:19 +00:00
parent dadfbe8d4e
commit e109a2f4d0
8 changed files with 92 additions and 71 deletions

View File

@ -490,11 +490,11 @@ void DrawTextureAlpha(png_texture *texture, int x, int y, int w, int h, u8 alpha
GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_InvalidateTexAll(); GX_InvalidateTexAll();
/* adjust coordinate system */ /* vertex coordinate */
x -= (vmode->fbWidth/2); x -= (vmode->fbWidth/2);
y -= (vmode->efbHeight/2); y -= (vmode->efbHeight/2);
/* Draw textured quad */ /* draw textured quad */
GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position2s16(x,y+h); GX_Position2s16(x,y+h);
GX_Color4u8(0xff,0xff,0xff,alpha); GX_Color4u8(0xff,0xff,0xff,alpha);
@ -519,25 +519,29 @@ void DrawTextureRepeat(png_texture *texture, int x, int y, int w, int h)
{ {
/* load texture object */ /* load texture object */
GXTexObj texObj; GXTexObj texObj;
GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_REPEAT, GX_REPEAT, GX_FALSE); GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_MIRROR, GX_MIRROR, GX_FALSE);
GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_InvalidateTexAll(); GX_InvalidateTexAll();
/* adjust coordinate system */ /* vertex coordinate */
x -= (vmode->fbWidth/2); x -= (vmode->fbWidth/2);
y -= (vmode->efbHeight/2); y -= (vmode->efbHeight/2);
/* Draw textured quad */ /* texture coordinates */
f32 s = (f32)vmode->fbWidth / (f32)texture->width;
f32 t = (f32)vmode->efbHeight / (f32)texture->height;
/* draw textured quad */
GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position2s16(x,y+h); GX_Position2s16(x,y+h);
GX_Color4u8(0xff,0xff,0xff,0xff); GX_Color4u8(0xff,0xff,0xff,0xff);
GX_TexCoord2f32(0.0, 1.0); GX_TexCoord2f32(0.0, t);
GX_Position2s16(x+w,y+h); GX_Position2s16(x+w,y+h);
GX_Color4u8(0xff,0xff,0xff,0xff); GX_Color4u8(0xff,0xff,0xff,0xff);
GX_TexCoord2f32(1.0, 1.0); GX_TexCoord2f32(s, t);
GX_Position2s16(x+w,y); GX_Position2s16(x+w,y);
GX_Color4u8(0xff,0xff,0xff,0xff); GX_Color4u8(0xff,0xff,0xff,0xff);
GX_TexCoord2f32(1.0, 0.0); GX_TexCoord2f32(s, 0.0);
GX_Position2s16(x,y); GX_Position2s16(x,y);
GX_Color4u8(0xff,0xff,0xff,0xff); GX_Color4u8(0xff,0xff,0xff,0xff);
GX_TexCoord2f32(0.0, 0.0); GX_TexCoord2f32(0.0, 0.0);

View File

@ -73,7 +73,7 @@ void legal ()
} }
SetScreen (); SetScreen ();
sleep (2); sleep (1);
WriteCentre (ypos, "Press any button to skip intro"); WriteCentre (ypos, "Press any button to skip intro");
SetScreen (); SetScreen ();
int count = 100; int count = 100;

View File

@ -32,8 +32,7 @@
#include "Banner_bottom.h" #include "Banner_bottom.h"
#include "Banner_top.h" #include "Banner_top.h"
#include "Background_main.h" #include "Background_main.h"
#include "Background_overlay_line.h" #include "Background_overlay.h"
#include "Background_overlay_square.h"
#include "Frame_s1.h" #include "Frame_s1.h"
#include "Frame_s2.h" #include "Frame_s2.h"
#include "Main_logo.h" #include "Main_logo.h"
@ -154,7 +153,7 @@ typedef struct
gui_image *overlay; /* overlay image */ gui_image *overlay; /* overlay image */
gui_image *background; /* background image */ gui_image *background; /* background image */
gui_image *logo; /* logo image */ gui_image *logo; /* logo image */
gui_image *frames[2]; /* windows (max. 2) */ gui_image *frames[2]; /* windows (max. 2) */
gui_image *banners[2]; /* bottom & top banners */ gui_image *banners[2]; /* bottom & top banners */
gui_item *helpers[2]; /* left & right key comments */ gui_item *helpers[2]; /* left & right key comments */
gui_butn *arrows[2]; /* items list up & down arrows */ gui_butn *arrows[2]; /* items list up & down arrows */
@ -176,8 +175,7 @@ static gui_image bottom_banner = {NULL,Banner_bottom,0,388,640,92};
static gui_image main_banner = {NULL,Banner_main,0,356,640,124}; static gui_image main_banner = {NULL,Banner_main,0,356,640,124};
static gui_image bg_right = {NULL,Background_main,356,144,348,288}; static gui_image bg_right = {NULL,Background_main,356,144,348,288};
static gui_image bg_center = {NULL,Background_main,146,78,348,288}; static gui_image bg_center = {NULL,Background_main,146,78,348,288};
static gui_image bg_overlay_line = {NULL,Background_overlay_line,0,0,640,480}; static gui_image bg_overlay_line = {NULL,Background_overlay,0,0,640,480};
static gui_image bg_overlay_square = {NULL,Background_overlay_square,0,0,640,480};
static gui_image left_frame = {NULL,Frame_s1,8,72,372,336}; static gui_image left_frame = {NULL,Frame_s1,8,72,372,336};
static gui_image right_frame = {NULL,Frame_s2,384,116,248,296}; static gui_image right_frame = {NULL,Frame_s2,384,116,248,296};
@ -464,7 +462,7 @@ static gui_menu menu_audio =
0,0,5,4,1, 0,0,5,4,1,
items_audio, items_audio,
buttons_generic, buttons_generic,
&bg_overlay_square, &bg_overlay_line,
&bg_right, &bg_right,
&logo_small, &logo_small,
{&left_frame,NULL}, {&left_frame,NULL},
@ -572,7 +570,7 @@ static void menu_delete(gui_menu *menu)
if (menu->banners[i]) if (menu->banners[i])
CloseTexturePNG(&menu->banners[i]->texture); CloseTexturePNG(&menu->banners[i]->texture);
/* banners */ /* frames */
if (menu->frames[i]) if (menu->frames[i])
CloseTexturePNG(&menu->frames[i]->texture); CloseTexturePNG(&menu->frames[i]->texture);
@ -625,13 +623,13 @@ static void menu_draw(gui_menu *menu)
for (i=0; i<2; i++) for (i=0; i<2; i++)
{ {
/* draw top&bottom banners */
image = menu->banners[i];
if (image) DrawTexture(image->texture,image->x,image->y,image->w,image->h);
/* draw frames */ /* draw frames */
image = menu->frames[i]; image = menu->frames[i];
if (image) DrawTextureAlpha(image->texture,image->x,image->y,image->w,image->h, 128); if (image) DrawTextureAlpha(image->texture,image->x,image->y,image->w,image->h, 128);
/* draw top&bottom banners */
image = menu->banners[i];
if (image) DrawTexture(image->texture,image->x,image->y,image->w,image->h);
} }
/* draw logo */ /* draw logo */
@ -657,13 +655,6 @@ static void menu_draw(gui_menu *menu)
FONT_alignRight(item->comment, 16, item->x - 6, item->y+(item->h-16)/2 + 16); FONT_alignRight(item->comment, 16, item->x - 6, item->y+(item->h-16)/2 + 16);
} }
/* draw top&bottom banners */
for (i=0; i<2; i++)
{
image = menu->banners[i];
if (image) DrawTexture(image->texture,image->x,image->y,image->w,image->h);
}
/* draw buttons + items */ /* draw buttons + items */
for (i=0; i<menu->max_buttons; i++) for (i=0; i<menu->max_buttons; i++)
{ {
@ -708,7 +699,6 @@ static int menu_prompt(gui_menu *menu, char *title, char *items[], u8 nb_items)
{ {
int i, ret, quit = 0; int i, ret, quit = 0;
int selected = 0; int selected = 0;
gui_butn button[nb_items];
butn_data *data = &button_text_data; butn_data *data = &button_text_data;
u8 delete_me[2]; u8 delete_me[2];
s16 p; s16 p;
@ -728,22 +718,18 @@ static int menu_prompt(gui_menu *menu, char *title, char *items[], u8 nb_items)
} }
} }
/* get initial yposition */ /* initialize texture window */
int ypos = 140 + ((324 - nb_items*data->texture[0]->height - 20*(nb_items - 1))/2);
/* fill button data */
for (i=0; i<nb_items; i++)
{
button[i].data = data;
button[i].x = 182;
button[i].y = ypos + i*(data->texture[0]->height + 20);
button[i].w = data->texture[0]->width;
button[i].h = data->texture[0]->height;
}
/* texture window */
png_texture *window = OpenTexturePNG(Frame_s1); png_texture *window = OpenTexturePNG(Frame_s1);
/* get initial positions */
int w = data->texture[0]->width;
int h = data->texture[0]->height;
int xwindow = (640 - window->width)/2;
int ywindow = (480 - window->height)/2;
int xpos = xwindow + (window->width - w)/2;
int ypos = (window->height - (h*nb_items) - (nb_items-1)*20)/2;
ypos = ypos + ywindow;
/* menu should have been initiliazed first ! */ /* menu should have been initiliazed first ! */
while (quit == 0) while (quit == 0)
{ {
@ -751,22 +737,22 @@ static int menu_prompt(gui_menu *menu, char *title, char *items[], u8 nb_items)
menu_draw(menu); menu_draw(menu);
/* draw window */ /* draw window */
DrawTexture(window, 134, 72, window->width, window->height); DrawTextureAlpha(window, xwindow, ywindow, window->width, window->height,235);
/* draw title */ /* draw title */
FONT_writeCenter(title, 18,134, 134 + window->width, 92); FONT_writeCenter(title, 20,xwindow, xwindow + window->width, ywindow + 40);
/* draw buttons + text */ /* draw buttons + text */
for (i=0; i<nb_items; i++) for (i=0; i<nb_items; i++)
{ {
if (i==menu->selected) DrawTexture(data->texture[1], button[i].x-2, button[i].y-2, button[i].w+4, button[i].h+4); if (i==selected) DrawTexture(data->texture[1], xpos-2, ypos + i*(20 + h) - 2, w+4, h+4);
else DrawTexture(data->texture[0], button[i].x, button[i].y, button[i].w, button[i].h); else DrawTexture(data->texture[0],xpos, ypos+i*(20 + h), w,h);
if (i==menu->selected) FONT_writeCenter(items[i], 20, button[i].x, button[i].x + button[i].w, button[i].y + (button[i].h - 20)/2 + 20); if (i==selected) FONT_writeCenter(items[i], 20, xpos, xpos + w, ypos + i*(20 + h) + (h - 20)/2 + 20);
else FONT_writeCenter(items[i], 18, button[i].x, button[i].x + button[i].w, button[i].y + (button[i].h - 18)/2 + 18); else FONT_writeCenter(items[i], 18, xpos, xpos + w, ypos+i*(20 + h) + (h - 18)/2 + 18);
} }
#ifdef HW_RVL
p = m_input.keys; p = m_input.keys;
#ifdef HW_RVL
if (Shutdown) if (Shutdown)
{ {
/* autosave SRAM/State */ /* autosave SRAM/State */
@ -787,27 +773,23 @@ static int menu_prompt(gui_menu *menu, char *title, char *items[], u8 nb_items)
png_texture *texture = w_pointer[0]; png_texture *texture = w_pointer[0];
DrawTexture(texture, x-texture->width/2, y-texture->height/2, texture->width, texture->height); DrawTexture(texture, x-texture->width/2, y-texture->height/2, texture->width, texture->height);
gxResetCamera(0.0); gxResetCamera(0.0);
SetScreen ();
/* check for valid buttons */ /* check for valid buttons */
selected = -1; selected = -1;
for (i=0; i<nb_items; i++) for (i=0; i<nb_items; i++)
{ {
if ((x >= button[i].x) && (x <= (button[i].x + button[i].w)) && (y >= button[i].y) && (y <= (button[i].y + button[i].h))) if ((x >= xpos) && (x <= (xpos + w)) && (y >= ypos + i*(20 + h)) && (y <= (ypos + i*(20 + h) + h)))
{ {
selected = i; selected = i;
break; break;
} }
} }
} }
#else #endif
/* copy EFB to XFB */ /* copy EFB to XFB */
SetScreen (); SetScreen ();
/* update inputs */
p = m_input.keys;
#endif
if (p & PAD_BUTTON_UP) if (p & PAD_BUTTON_UP)
{ {
if (selected > 0) selected --; if (selected > 0) selected --;
@ -941,7 +923,7 @@ static void menu_fade(gui_menu *menu, u8 speed, u8 out)
} }
#define MAX_COLORS 6 #define MAX_COLORS 6
#define VERSION "v 1.03" #define VERSION "version 1.03"
static GXColor background_colors[MAX_COLORS]= static GXColor background_colors[MAX_COLORS]=
{ {
@ -972,8 +954,9 @@ static int menu_callback(gui_menu *menu)
{ {
menu_draw(menu); menu_draw(menu);
#ifdef HW_RVL
p = m_input.keys; p = m_input.keys;
#ifdef HW_RVL
if (Shutdown) if (Shutdown)
{ {
/* autosave SRAM/State */ /* autosave SRAM/State */
@ -995,7 +978,6 @@ static int menu_callback(gui_menu *menu)
png_texture *texture = w_pointer[0]; png_texture *texture = w_pointer[0];
DrawTexture(texture, x-texture->width/2, y-texture->height/2, texture->width, texture->height); DrawTexture(texture, x-texture->width/2, y-texture->height/2, texture->width, texture->height);
gxResetCamera(0.0); gxResetCamera(0.0);
SetScreen ();
/* check for valid buttons */ /* check for valid buttons */
for (i=0; i<max_buttons; i++) for (i=0; i<max_buttons; i++)
@ -1038,14 +1020,11 @@ static int menu_callback(gui_menu *menu)
} }
} }
} }
#else #endif
/* copy EFB to XFB */ /* copy EFB to XFB */
SetScreen (); SetScreen ();
/* update inputs */
p = m_input.keys;
#endif
if (p & PAD_BUTTON_UP) if (p & PAD_BUTTON_UP)
{ {
if (menu->selected == 0) if (menu->selected == 0)
@ -1104,11 +1083,13 @@ static int menu_callback(gui_menu *menu)
} }
else if (p & PAD_TRIGGER_L) else if (p & PAD_TRIGGER_L)
{ {
/* swap background overlay (DEBUG !)*/ /* swap menu background color (DEBUG !)*/
if (menu->overlay == &bg_overlay_line) color_cnt--;
menu->overlay = &bg_overlay_square; if (color_cnt < 0) color_cnt = MAX_COLORS - 1;
else if (menu->overlay == &bg_overlay_square) BACKGROUND.r = background_colors[color_cnt].r;
menu->overlay = &bg_overlay_line; BACKGROUND.g = background_colors[color_cnt].g;
BACKGROUND.b = background_colors[color_cnt].b;
BACKGROUND.a = background_colors[color_cnt].a;
} }
if (p & PAD_BUTTON_A) if (p & PAD_BUTTON_A)

View File

@ -0,0 +1,22 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
const unsigned char Background_overlay[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x08, 0x06, 0x00, 0x00, 0x00, 0xc4, 0x0f, 0xbe,
0x8b, 0x00, 0x00, 0x00, 0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0a, 0xf0, 0x00, 0x00, 0x0a,
0xf0, 0x01, 0x42, 0xac, 0x34, 0x98, 0x00, 0x00, 0x00, 0x20, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f,
0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x00, 0x4d, 0x61, 0x63, 0x72, 0x6f, 0x6d, 0x65, 0x64, 0x69,
0x61, 0x20, 0x46, 0x69, 0x72, 0x65, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x20, 0x4d, 0x58, 0xbb, 0x91,
0x2a, 0x24, 0x00, 0x00, 0x00, 0x16, 0x74, 0x45, 0x58, 0x74, 0x43, 0x72, 0x65, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x20, 0x54, 0x69, 0x6d, 0x65, 0x00, 0x30, 0x34, 0x2f, 0x30, 0x36, 0x2f, 0x30, 0x39,
0xb6, 0x25, 0x24, 0x0b, 0x00, 0x00, 0x00, 0x28, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0xf4,
0xf1, 0xf1, 0x71, 0x60, 0xc0, 0x03, 0x18, 0x19, 0x18, 0x18, 0xf0, 0x2a, 0x60, 0xc2, 0x27, 0xc9,
0xc0, 0xc0, 0xc0, 0xc0, 0xe2, 0xe3, 0xe3, 0x83, 0x57, 0x01, 0x41, 0x13, 0xe8, 0xe0, 0x06, 0x00,
0x31, 0x48, 0x03, 0x7e, 0x98, 0x61, 0x89, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
0xae, 0x42, 0x60, 0x82
};
const int Background_overlay_size = sizeof(Background_overlay);

View File

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _Background_overlay_h_
#define _Background_overlay_h_
//---------------------------------------------------------------------------------
extern const unsigned char Background_overlay[];
extern const int Background_overlay_size;
//---------------------------------------------------------------------------------
#endif //_Background_overlay_h_
//---------------------------------------------------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

View File

@ -0,0 +1,2 @@
@ECHO OFF
@FOR /F "delims=/" %%D in ('dir /b *.png') do raw2c "%%~nD".png

View File

@ -1,2 +0,0 @@
@ECHO OFF
@FOR /F "delims=/" %%D in ('dir /b *.png') do raw2c "%%~nD".png