mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2025-01-25 17:41:13 +01:00
optimized GUI engine (speed OK now, settings BROKEN)
This commit is contained in:
parent
b524f447d9
commit
38a92d6dba
@ -143,13 +143,13 @@ void WriteCentre( int y, char *string)
|
|||||||
void WriteCentre_HL( int y, char *string)
|
void WriteCentre_HL( int y, char *string)
|
||||||
{
|
{
|
||||||
WriteCentre(y, string);
|
WriteCentre(y, string);
|
||||||
png_texture texture;
|
png_texture *texture = OpenTexturePNG(Overlay_bar);
|
||||||
texture.data = 0;
|
if (texture)
|
||||||
texture.width = 0;
|
{
|
||||||
texture.height = 0;
|
DrawTexture(texture, 0, y-fheight, 640, fheight);
|
||||||
texture.format = 0;
|
if (texture->data) free(texture->data);
|
||||||
OpenPNGFromMemory(&texture, Overlay_bar);
|
free(texture);
|
||||||
DrawTexture(&texture, 0, y-fheight, 640, fheight);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FONT_alignLeft(char *string, int size, int x, int y)
|
void FONT_alignLeft(char *string, int size, int x, int y)
|
||||||
@ -257,7 +257,7 @@ static void png_read_from_mem (png_structp png_ptr, png_bytep data, png_size_t l
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* convert a png file into RGBA8 texture */
|
/* convert a png file into RGBA8 texture */
|
||||||
void OpenPNGFromMemory(png_texture *texture, const u8 *buffer)
|
png_texture *OpenTexturePNG(const u8 *buffer)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
png_file file;
|
png_file file;
|
||||||
@ -271,14 +271,14 @@ void OpenPNGFromMemory(png_texture *texture, const u8 *buffer)
|
|||||||
|
|
||||||
/* create a png read struct */
|
/* create a png read struct */
|
||||||
png_structp png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_structp png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
if (!png_ptr) return;
|
if (!png_ptr) return NULL;
|
||||||
|
|
||||||
/* create a png info struct */
|
/* create a png info struct */
|
||||||
png_infop info_ptr = png_create_info_struct (png_ptr);
|
png_infop info_ptr = png_create_info_struct (png_ptr);
|
||||||
if (!info_ptr)
|
if (!info_ptr)
|
||||||
{
|
{
|
||||||
png_destroy_read_struct (&png_ptr, NULL, NULL);
|
png_destroy_read_struct (&png_ptr, NULL, NULL);
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set callback for the read function */
|
/* set callback for the read function */
|
||||||
@ -313,7 +313,7 @@ void OpenPNGFromMemory(png_texture *texture, const u8 *buffer)
|
|||||||
if (!img_data)
|
if (!img_data)
|
||||||
{
|
{
|
||||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate row pointer data */
|
/* allocate row pointer data */
|
||||||
@ -322,7 +322,7 @@ void OpenPNGFromMemory(png_texture *texture, const u8 *buffer)
|
|||||||
{
|
{
|
||||||
free (img_data);
|
free (img_data);
|
||||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store raw image data */
|
/* store raw image data */
|
||||||
@ -340,12 +340,22 @@ void OpenPNGFromMemory(png_texture *texture, const u8 *buffer)
|
|||||||
free(row_pointers);
|
free(row_pointers);
|
||||||
|
|
||||||
/* initialize texture */
|
/* initialize texture */
|
||||||
|
png_texture *texture = (png_texture *)memalign(32, sizeof(png_texture));
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
free (img_data);
|
||||||
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize texture data */
|
||||||
texture->data = memalign(32, stride * height);
|
texture->data = memalign(32, stride * height);
|
||||||
if (!texture->data)
|
if (!texture->data)
|
||||||
{
|
{
|
||||||
free (img_data);
|
free (img_data);
|
||||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
return;
|
free(texture);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(texture->data, 0, stride * height);
|
memset(texture->data, 0, stride * height);
|
||||||
@ -415,10 +425,18 @@ void OpenPNGFromMemory(png_texture *texture, const u8 *buffer)
|
|||||||
|
|
||||||
/* flush texture data from cache */
|
/* flush texture data from cache */
|
||||||
DCFlushRange(texture->data, height * stride);
|
DCFlushRange(texture->data, height * stride);
|
||||||
|
|
||||||
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTexture(png_texture *texture, int x, int y, int w, int h)
|
void DrawTexture(png_texture *texture, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
FONT_alignLeft("error",16,x,y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (texture->data)
|
if (texture->data)
|
||||||
{
|
{
|
||||||
/* load texture object */
|
/* load texture object */
|
||||||
|
@ -36,7 +36,7 @@ typedef struct
|
|||||||
u8 format;
|
u8 format;
|
||||||
} png_texture;
|
} png_texture;
|
||||||
|
|
||||||
extern void OpenPNGFromMemory(png_texture *texture, const u8 *buffer);
|
extern png_texture *OpenTexturePNG(const u8 *buffer);
|
||||||
extern void DrawTexture(png_texture *texture, int x, int y, int w, int h);
|
extern void DrawTexture(png_texture *texture, int x, int y, int w, int h);
|
||||||
|
|
||||||
extern int FONT_Init(void);
|
extern int FONT_Init(void);
|
||||||
|
@ -40,9 +40,10 @@ extern s16 ogc_input__getMenuButtons(u32 cnt);
|
|||||||
void legal ()
|
void legal ()
|
||||||
{
|
{
|
||||||
int ypos = 64;
|
int ypos = 64;
|
||||||
png_texture texture;
|
png_texture *texture;
|
||||||
|
|
||||||
ClearScreen((GXColor)BLACK);
|
ClearScreen((GXColor)BLACK);
|
||||||
|
|
||||||
WriteCentre (ypos, "Genesis Plus Sega Mega Drive Emulator (v1.2a)");
|
WriteCentre (ypos, "Genesis Plus Sega Mega Drive Emulator (v1.2a)");
|
||||||
ypos += fheight;
|
ypos += fheight;
|
||||||
WriteCentre (ypos, "(C) 1999 - 2003 Charles MacDonald");
|
WriteCentre (ypos, "(C) 1999 - 2003 Charles MacDonald");
|
||||||
@ -62,13 +63,14 @@ void legal ()
|
|||||||
WriteCentre (ypos, "You are free to use it as you wish.");
|
WriteCentre (ypos, "You are free to use it as you wish.");
|
||||||
ypos += 2*fheight;
|
ypos += 2*fheight;
|
||||||
|
|
||||||
texture.data = 0;
|
texture= OpenTexturePNG(Background_intro_c4);
|
||||||
texture.width = 0;
|
if (texture)
|
||||||
texture.height = 0;
|
{
|
||||||
texture.format = 0;
|
DrawTexture(texture, (640-texture->width)/2, ypos, texture->width, texture->height);
|
||||||
OpenPNGFromMemory(&texture, Background_intro_c4);
|
ypos += texture->height + 2 * fheight;
|
||||||
DrawTexture(&texture, (640-texture.width)/2, ypos, texture.width, texture.height);
|
if (texture->data) free(texture->data);
|
||||||
ypos += texture.height + 2 * fheight;
|
free(texture);
|
||||||
|
}
|
||||||
|
|
||||||
SetScreen ();
|
SetScreen ();
|
||||||
sleep (2);
|
sleep (2);
|
||||||
@ -77,35 +79,39 @@ void legal ()
|
|||||||
sleep (2);
|
sleep (2);
|
||||||
if (ogc_input__getMenuButtons(0) & PAD_BUTTON_A) return;
|
if (ogc_input__getMenuButtons(0) & PAD_BUTTON_A) return;
|
||||||
|
|
||||||
|
|
||||||
ClearScreen((GXColor)BLACK);
|
ClearScreen((GXColor)BLACK);
|
||||||
texture.data = 0;
|
texture = OpenTexturePNG(Background_intro_c1);
|
||||||
texture.width = 0;
|
if (texture)
|
||||||
texture.height = 0;
|
{
|
||||||
texture.format = 0;
|
DrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height);
|
||||||
OpenPNGFromMemory(&texture, Background_intro_c1);
|
if (texture->data) free(texture->data);
|
||||||
DrawTexture(&texture, (640-texture.width)/2, (480-texture.height)/2, texture.width, texture.height);
|
free(texture);
|
||||||
|
}
|
||||||
|
|
||||||
SetScreen ();
|
SetScreen ();
|
||||||
sleep (1);
|
sleep (1);
|
||||||
|
|
||||||
ClearScreen((GXColor)WHITE);
|
ClearScreen((GXColor)WHITE);
|
||||||
texture.data = 0;
|
texture = OpenTexturePNG(Background_intro_c2);
|
||||||
texture.width = 0;
|
if (texture)
|
||||||
texture.height = 0;
|
{
|
||||||
texture.format = 0;
|
DrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height);
|
||||||
OpenPNGFromMemory(&texture, Background_intro_c2);
|
if (texture->data) free(texture->data);
|
||||||
DrawTexture(&texture, (640-texture.width)/2, (480-texture.height)/2, texture.width, texture.height);
|
free(texture);
|
||||||
|
}
|
||||||
|
|
||||||
SetScreen ();
|
SetScreen ();
|
||||||
sleep (1);
|
sleep (1);
|
||||||
|
|
||||||
ClearScreen((GXColor)BLACK);
|
ClearScreen((GXColor)BLACK);
|
||||||
texture.data = 0;
|
texture = OpenTexturePNG(Background_intro_c3);
|
||||||
texture.width = 0;
|
if (texture)
|
||||||
texture.height = 0;
|
{
|
||||||
texture.format = 0;
|
DrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height);
|
||||||
OpenPNGFromMemory(&texture, Background_intro_c3);
|
if (texture->data) free(texture->data);
|
||||||
DrawTexture(&texture, (640-texture.width)/2, (480-texture.height)/2, texture.width, texture.height);
|
free(texture);
|
||||||
|
}
|
||||||
|
|
||||||
SetScreen ();
|
SetScreen ();
|
||||||
sleep (2);
|
sleep (2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -135,10 +135,10 @@ typedef struct
|
|||||||
{
|
{
|
||||||
char *title; /* menu title */
|
char *title; /* menu title */
|
||||||
s8 selected; /* index of selected item */
|
s8 selected; /* index of selected item */
|
||||||
u8 shift; /* number of items by line */
|
|
||||||
u8 offset; /* items list offset */
|
u8 offset; /* items list offset */
|
||||||
u8 max_items; /* total number of items */
|
u8 max_items; /* total number of items */
|
||||||
u8 max_buttons; /* total number of buttons (not necessary identical) */
|
u8 max_buttons; /* total number of buttons (not necessary identical) */
|
||||||
|
u8 shift; /* number of items by line */
|
||||||
gui_item *items; /* menu items table */
|
gui_item *items; /* menu items table */
|
||||||
gui_butn *buttons; /* menu buttons table */
|
gui_butn *buttons; /* menu buttons table */
|
||||||
gui_image *background; /* background image */
|
gui_image *background; /* background image */
|
||||||
@ -149,7 +149,7 @@ typedef struct
|
|||||||
} gui_menu;
|
} gui_menu;
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
static png_texture w_pointer = {0,0,0,0};
|
static png_texture *w_pointer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static gui_input m_input;
|
static gui_input m_input;
|
||||||
@ -320,11 +320,11 @@ static gui_item items_load[3] =
|
|||||||
|
|
||||||
static gui_item items_options[5] =
|
static gui_item items_options[5] =
|
||||||
{
|
{
|
||||||
{NULL,Option_system,NULL,"Configure System settings", 114,142,80,92},
|
{NULL,Option_system,NULL,"System settings", 114,142,80,92},
|
||||||
{NULL,Option_video ,NULL,"Configure Video settings", 288,150,64,84},
|
{NULL,Option_video ,NULL,"Video settings", 288,150,64,84},
|
||||||
{NULL,Option_sound ,NULL,"Configure Audio settings", 464,154,44,80},
|
{NULL,Option_sound ,NULL,"Audio settings", 464,154,44,80},
|
||||||
{NULL,Option_ctrl ,NULL,"Configure Input settings", 192,286,88,92},
|
{NULL,Option_ctrl ,NULL,"Input settings", 192,286,88,92},
|
||||||
{NULL,Option_ggenie,NULL,"Configure Game Genie Codes",360,282,88,96}
|
{NULL,Option_ggenie,NULL,"Game Genie Codes",360,282,88,96}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -419,7 +419,7 @@ static gui_menu menu_load =
|
|||||||
/* Options menu */
|
/* Options menu */
|
||||||
static gui_menu menu_options =
|
static gui_menu menu_options =
|
||||||
{
|
{
|
||||||
"Emulator Settings",
|
"Settings",
|
||||||
0,0,5,5,3,
|
0,0,5,5,3,
|
||||||
items_options,
|
items_options,
|
||||||
buttons_options,
|
buttons_options,
|
||||||
@ -441,7 +441,7 @@ static gui_menu menu_system =
|
|||||||
&logo_small,
|
&logo_small,
|
||||||
{&top_frame,&bottom_frame},
|
{&top_frame,&bottom_frame},
|
||||||
{&action_cancel, &action_select},
|
{&action_cancel, &action_select},
|
||||||
{NULL, NULL}
|
{NULL, &arrow_down}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Video Options menu */
|
/* Video Options menu */
|
||||||
@ -455,7 +455,7 @@ static gui_menu menu_video =
|
|||||||
&logo_small,
|
&logo_small,
|
||||||
{&top_frame,&bottom_frame},
|
{&top_frame,&bottom_frame},
|
||||||
{&action_cancel, &action_select},
|
{&action_cancel, &action_select},
|
||||||
{NULL, NULL}
|
{NULL, &arrow_down}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Sound Options menu */
|
/* Sound Options menu */
|
||||||
@ -469,7 +469,7 @@ static gui_menu menu_audio =
|
|||||||
&logo_small,
|
&logo_small,
|
||||||
{&top_frame,&bottom_frame},
|
{&top_frame,&bottom_frame},
|
||||||
{&action_cancel, &action_select},
|
{&action_cancel, &action_select},
|
||||||
{NULL, NULL}
|
{NULL, &arrow_down}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -478,128 +478,57 @@ static gui_menu menu_audio =
|
|||||||
static void menu_initialize(gui_menu *menu)
|
static void menu_initialize(gui_menu *menu)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
png_texture *texture;
|
|
||||||
gui_item *item;
|
gui_item *item;
|
||||||
gui_image *image;
|
gui_image *image;
|
||||||
gui_butn *button;
|
gui_butn *button;
|
||||||
butn_data *button_data;
|
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
/* allocate wiimote pointer data (only done once) */
|
/* allocate wiimote pointer data (only done once) */
|
||||||
if (w_pointer.data == NULL)
|
w_pointer = OpenTexturePNG(generic_point);
|
||||||
{
|
|
||||||
OpenPNGFromMemory(&w_pointer, generic_point);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* allocate background image texture */
|
/* allocate background image texture */
|
||||||
if (menu->background)
|
image = menu->background;
|
||||||
{
|
if (image) image->texture = OpenTexturePNG(image->data);
|
||||||
texture = (png_texture *)malloc(sizeof(png_texture));
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
image = menu->background;
|
|
||||||
OpenPNGFromMemory(texture, image->data);
|
|
||||||
image->texture = texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate logo texture */
|
/* allocate logo texture */
|
||||||
if (menu->logo)
|
image = menu->logo;
|
||||||
{
|
if (image) image->texture = OpenTexturePNG(image->data);
|
||||||
texture = (png_texture *)malloc(sizeof(png_texture));
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
image = menu->logo;
|
|
||||||
OpenPNGFromMemory(texture, image->data);
|
|
||||||
image->texture = texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate background elements textures */
|
/* allocate background elements textures */
|
||||||
for (i=0; i<2; i++)
|
for (i=0; i<2; i++)
|
||||||
{
|
{
|
||||||
/* frames */
|
/* frames */
|
||||||
if (menu->frames[i])
|
image = menu->frames[i];
|
||||||
{
|
if (image) image->texture = OpenTexturePNG(image->data);
|
||||||
texture = (png_texture *)malloc(sizeof(png_texture));
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
image = menu->frames[i];
|
|
||||||
OpenPNGFromMemory(texture, image->data);
|
|
||||||
image->texture = texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* key helpers */
|
/* key helpers */
|
||||||
if (menu->helpers[i])
|
item = menu->helpers[i];
|
||||||
{
|
if (item) item->texture = OpenTexturePNG(item->data);
|
||||||
texture = (png_texture *)malloc(sizeof(png_texture));
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
item = menu->helpers[i];
|
|
||||||
OpenPNGFromMemory(texture, item->data);
|
|
||||||
item->texture = texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* up/down buttons */
|
|
||||||
if (menu->arrows[i])
|
|
||||||
{
|
|
||||||
button_data = menu->arrows[i]->data;
|
|
||||||
texture = (png_texture *)malloc(sizeof(png_texture));
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
OpenPNGFromMemory(texture, button_data->image[0]);
|
|
||||||
button_data->texture[0] = texture;
|
|
||||||
}
|
|
||||||
texture = (png_texture *)malloc(sizeof(png_texture));
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
OpenPNGFromMemory(texture, button_data->image[1]);
|
|
||||||
button_data->texture[1] = texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* menu buttons */
|
/* allocate arrow buttons */
|
||||||
|
if (menu->max_items > menu->max_buttons)
|
||||||
|
{
|
||||||
|
arrow_up_data.texture[0] = OpenTexturePNG(arrow_up_data.image[0]);
|
||||||
|
arrow_up_data.texture[1] = OpenTexturePNG(arrow_up_data.image[1]);
|
||||||
|
arrow_down_data.texture[0] = OpenTexturePNG(arrow_down_data.image[0]);
|
||||||
|
arrow_down_data.texture[1] = OpenTexturePNG(arrow_down_data.image[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate menu buttons */
|
||||||
for (i=0; i<menu->max_buttons; i++)
|
for (i=0; i<menu->max_buttons; i++)
|
||||||
{
|
{
|
||||||
button = &menu->buttons[i];
|
button = &menu->buttons[i];
|
||||||
button_data = button->data;
|
if (!button->data->texture[0]) button->data->texture[0] = OpenTexturePNG(button->data->image[0]);
|
||||||
if (button_data->texture[0] == NULL)
|
if (!button->data->texture[1]) button->data->texture[1] = OpenTexturePNG(button->data->image[1]);
|
||||||
{
|
|
||||||
texture = (png_texture *)malloc(sizeof(png_texture));
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
OpenPNGFromMemory(texture, button_data->image[0]);
|
|
||||||
button_data->texture[0] = texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (button_data->texture[1] == NULL)
|
|
||||||
{
|
|
||||||
texture = (png_texture *)malloc(sizeof(png_texture));
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
OpenPNGFromMemory(texture, button_data->image[1]);
|
|
||||||
button_data->texture[1] = texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate item textures */
|
/* allocate item textures */
|
||||||
for (i=0; i<menu->max_items; i++)
|
for (i=0; i<menu->max_items; i++)
|
||||||
{
|
{
|
||||||
item = &menu->items[i];
|
item = &menu->items[i];
|
||||||
if (item->data)
|
if (item->data) item->texture = OpenTexturePNG(item->data);
|
||||||
{
|
|
||||||
texture = (png_texture *)malloc(sizeof(png_texture));
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
OpenPNGFromMemory(texture, item->data);
|
|
||||||
item->texture = texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,9 +538,18 @@ static void menu_delete(gui_menu *menu)
|
|||||||
png_texture *texture;
|
png_texture *texture;
|
||||||
gui_butn *button;
|
gui_butn *button;
|
||||||
gui_item *item;
|
gui_item *item;
|
||||||
butn_data *button_data;
|
|
||||||
|
|
||||||
/* free background image texture */
|
#ifdef HW_RVL
|
||||||
|
/* free wiimote pointer data */
|
||||||
|
if (w_pointer)
|
||||||
|
{
|
||||||
|
if (w_pointer->data) free(w_pointer->data);
|
||||||
|
free(w_pointer);
|
||||||
|
w_pointer = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* free background image texture */
|
||||||
if (menu->background)
|
if (menu->background)
|
||||||
{
|
{
|
||||||
texture = menu->background->texture;
|
texture = menu->background->texture;
|
||||||
@ -619,10 +557,11 @@ static void menu_delete(gui_menu *menu)
|
|||||||
{
|
{
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
|
menu->background->texture = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate logo texture */
|
/* free logo texture */
|
||||||
if (menu->logo)
|
if (menu->logo)
|
||||||
{
|
{
|
||||||
texture = menu->logo->texture;
|
texture = menu->logo->texture;
|
||||||
@ -630,10 +569,11 @@ static void menu_delete(gui_menu *menu)
|
|||||||
{
|
{
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
|
menu->logo->texture = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate background elements textures */
|
/* free background elements textures */
|
||||||
for (i=0; i<2; i++)
|
for (i=0; i<2; i++)
|
||||||
{
|
{
|
||||||
/* frames */
|
/* frames */
|
||||||
@ -644,7 +584,7 @@ static void menu_delete(gui_menu *menu)
|
|||||||
{
|
{
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
texture = NULL;
|
menu->frames[i]->texture = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,52 +596,48 @@ static void menu_delete(gui_menu *menu)
|
|||||||
{
|
{
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
texture = NULL;
|
menu->helpers[i]->texture = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* up/down buttons */
|
/* up/down arrows */
|
||||||
if (menu->arrows[i])
|
texture = arrow_up_data.texture[i];
|
||||||
|
if (texture)
|
||||||
{
|
{
|
||||||
texture = menu->arrows[i]->data->texture[0];
|
if (texture->data) free(texture->data);
|
||||||
if (texture)
|
free(texture);
|
||||||
{
|
arrow_up_data.texture[i] = NULL;
|
||||||
if (texture->data) free(texture->data);
|
}
|
||||||
free(texture);
|
texture = arrow_down_data.texture[i];
|
||||||
texture = NULL;
|
if (texture)
|
||||||
}
|
{
|
||||||
texture = menu->arrows[i]->data->texture[1];
|
if (texture->data) free(texture->data);
|
||||||
if (texture)
|
free(texture);
|
||||||
{
|
arrow_up_data.texture[i] = NULL;
|
||||||
if (texture->data) free(texture->data);
|
|
||||||
free(texture);
|
|
||||||
texture = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* menu buttons */
|
/* free menu buttons */
|
||||||
for (i=0; i<menu->max_buttons; i++)
|
for (i=0; i<menu->max_buttons; i++)
|
||||||
{
|
{
|
||||||
button = &menu->buttons[i];
|
button = &menu->buttons[i];
|
||||||
button_data = button->data;
|
texture = button->data->texture[0];
|
||||||
texture = button_data->texture[0];
|
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
texture = NULL;
|
button->data->texture[0] = NULL;
|
||||||
}
|
}
|
||||||
texture = button_data->texture[1];
|
texture = button->data->texture[1];
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
texture = NULL;
|
button->data->texture[1] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate item textures */
|
/* free item textures */
|
||||||
for (i=0; i<menu->max_items; i++)
|
for (i=0; i<menu->max_items; i++)
|
||||||
{
|
{
|
||||||
item = &menu->items[i];
|
item = &menu->items[i];
|
||||||
@ -710,7 +646,7 @@ static void menu_delete(gui_menu *menu)
|
|||||||
{
|
{
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
texture = NULL;
|
item->texture = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -767,9 +703,9 @@ static void menu_draw(gui_menu *menu)
|
|||||||
DrawTexture(button->data->texture[i==menu->selected], button->x, button->y, button->w, button->h);
|
DrawTexture(button->data->texture[i==menu->selected], button->x, button->y, button->w, button->h);
|
||||||
|
|
||||||
/* draw item */
|
/* draw item */
|
||||||
/*item = &menu->items[menu->offset +i];
|
item = &menu->items[menu->offset +i];
|
||||||
if (item->data) DrawTexture(item->texture, item->x, item->y, item->w, item->h);
|
if (item->data) DrawTexture(item->texture, item->x, item->y, item->w, item->h);
|
||||||
else FONT_writeCenter(item->text, 18, button->x, button->x + button->w, button->y + (button->h - 18)/2 + 18);*/
|
else FONT_writeCenter(item->text, 18, button->x, button->x + button->w, button->y + (button->h - 18)/2 + 18);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Arrows (Items list only) */
|
/* Arrows (Items list only) */
|
||||||
@ -794,7 +730,7 @@ static void menu_draw(gui_menu *menu)
|
|||||||
{
|
{
|
||||||
/* draw wiimote pointer */
|
/* draw wiimote pointer */
|
||||||
gxResetCamera(m_input.ir.angle);
|
gxResetCamera(m_input.ir.angle);
|
||||||
DrawTexture(&w_pointer, m_input.ir.x, m_input.ir.y, w_pointer.width, w_pointer.height);
|
DrawTexture(w_pointer, m_input.ir.x, m_input.ir.y, w_pointer->width, w_pointer->height);
|
||||||
gxResetCamera(0.0);
|
gxResetCamera(0.0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -968,6 +904,11 @@ static int menu_callback(gui_menu *menu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
s16 ogc_input__getMenuButtons(u32 cnt)
|
s16 ogc_input__getMenuButtons(u32 cnt)
|
||||||
|
{
|
||||||
|
return m_input.keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void menu_updateInputs(u32 cnt)
|
||||||
{
|
{
|
||||||
/* get gamepad inputs */
|
/* get gamepad inputs */
|
||||||
PAD_ScanPads();
|
PAD_ScanPads();
|
||||||
@ -1036,8 +977,6 @@ s16 ogc_input__getMenuButtons(u32 cnt)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_input.keys = p;
|
m_input.keys = p;
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -1059,19 +998,39 @@ static void drawmenu (char items[][25], int maxitems, int selected)
|
|||||||
ypos += 130;
|
ypos += 130;
|
||||||
|
|
||||||
/* reset texture data */
|
/* reset texture data */
|
||||||
png_texture texture;
|
png_texture *texture;
|
||||||
memset(&texture,0,sizeof(png_texture));
|
memset(&texture,0,sizeof(png_texture));
|
||||||
|
|
||||||
/* draw background items */
|
/* draw background items */
|
||||||
ClearScreen ((GXColor)BLACK);
|
ClearScreen ((GXColor)BLACK);
|
||||||
OpenPNGFromMemory(&texture, Background_main);
|
texture= OpenTexturePNG(Background_main);
|
||||||
DrawTexture(&texture, (640-texture.width)/2, (480-124-texture.height)/2, texture.width, texture.height);
|
if (texture)
|
||||||
OpenPNGFromMemory(&texture, Banner_bottom);
|
{
|
||||||
DrawTexture(&texture, 640-texture.width, 480-texture.height, texture.width, texture.height);
|
DrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height);
|
||||||
OpenPNGFromMemory(&texture, Banner_top);
|
if (texture->data) free(texture->data);
|
||||||
DrawTexture(&texture, 640-texture.width, 0, texture.width, texture.height);
|
free(texture);
|
||||||
OpenPNGFromMemory(&texture, Main_logo);
|
}
|
||||||
DrawTexture(&texture, 444, 28, 176, 48);
|
texture= OpenTexturePNG(Banner_bottom);
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
DrawTexture(texture, 0, 480-texture->height, texture->width, texture->height);
|
||||||
|
if (texture->data) free(texture->data);
|
||||||
|
free(texture);
|
||||||
|
}
|
||||||
|
texture= OpenTexturePNG(Banner_top);
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
DrawTexture(texture, 0, 0, texture->width, texture->height);
|
||||||
|
if (texture->data) free(texture->data);
|
||||||
|
free(texture);
|
||||||
|
}
|
||||||
|
texture= OpenTexturePNG(Main_logo);
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
DrawTexture(texture, 444, 28, 176, 48);
|
||||||
|
if (texture->data) free(texture->data);
|
||||||
|
free(texture);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < maxitems; i++)
|
for (i = 0; i < maxitems; i++)
|
||||||
{
|
{
|
||||||
@ -2064,6 +2023,8 @@ void MainMenu (u32 fps)
|
|||||||
|
|
||||||
gui_menu *m = &menu_main;
|
gui_menu *m = &menu_main;
|
||||||
|
|
||||||
|
VIDEO_SetPostRetraceCallback(menu_updateInputs);
|
||||||
|
|
||||||
while (quit == 0)
|
while (quit == 0)
|
||||||
{
|
{
|
||||||
/* crccheck = crc32 (0, &sram.sram[0], 0x10000);
|
/* crccheck = crc32 (0, &sram.sram[0], 0x10000);
|
||||||
@ -2137,6 +2098,8 @@ void MainMenu (u32 fps)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VIDEO_SetPostRetraceCallback(NULL);
|
||||||
|
|
||||||
/*** Remove any still held buttons ***/
|
/*** Remove any still held buttons ***/
|
||||||
while (PAD_ButtonsHeld(0)) PAD_ScanPads();
|
while (PAD_ButtonsHeld(0)) PAD_ScanPads();
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user