modified GUI engine (** still BROKEN**)

This commit is contained in:
ekeeke31 2009-03-30 07:05:34 +00:00
parent 612c512bf4
commit b524f447d9
6 changed files with 223 additions and 199 deletions

View File

@ -100,6 +100,7 @@ int FileSortCallback(const void *f1, const void *f2)
* ROM size is returned * ROM size is returned
* *
****************************************************************************/ ****************************************************************************/
extern s16 ogc_input__getMenuButtons(u32 cnt);
int FileSelector(unsigned char *buffer) int FileSelector(unsigned char *buffer)
{ {
short p; short p;

View File

@ -152,7 +152,7 @@ void WriteCentre_HL( int y, char *string)
DrawTexture(&texture, 0, y-fheight, 640, fheight); DrawTexture(&texture, 0, y-fheight, 640, fheight);
} }
void FONT_WriteLeft(char *string, int size, int x, int y) void FONT_alignLeft(char *string, int size, int x, int y)
{ {
x -= (vmode->fbWidth / 2); x -= (vmode->fbWidth / 2);
y -= (vmode->efbHeight / 2); y -= (vmode->efbHeight / 2);
@ -164,7 +164,7 @@ void FONT_WriteLeft(char *string, int size, int x, int y)
} }
} }
void FONT_WriteRight(char *string, int size, int x, int y) void FONT_alignRight(char *string, int size, int x, int y)
{ {
int i; int i;
u16 width = 0; u16 width = 0;
@ -182,7 +182,7 @@ void FONT_WriteRight(char *string, int size, int x, int y)
} }
} }
void FONT_WriteCenter(char *string, int size, int x1, int x2, int y) void FONT_writeCenter(char *string, int size, int x1, int x2, int y)
{ {
int i; int i;
u16 width = 0; u16 width = 0;
@ -427,7 +427,6 @@ void DrawTexture(png_texture *texture, int x, int y, int w, int h)
GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4);
GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_InvalidateTexAll(); GX_InvalidateTexAll();
DCFlushRange(texture->data, texture->width * texture->height * 4);
/* adjust coordinate system */ /* adjust coordinate system */
x -= (vmode->fbWidth/2); x -= (vmode->fbWidth/2);
@ -445,9 +444,6 @@ void DrawTexture(png_texture *texture, int x, int y, int w, int h)
GX_TexCoord2f32(0.0, 0.0); GX_TexCoord2f32(0.0, 0.0);
GX_End (); GX_End ();
GX_DrawDone(); GX_DrawDone();
/* free texture data array */
free(texture->data);
} }
} }
@ -474,6 +470,8 @@ void ClearScreen (GXColor color)
GX_Flush(); GX_Flush();
} }
extern s16 ogc_input__getMenuButtons(u32 cnt);
void WaitButtonA () void WaitButtonA ()
{ {
s16 p = ogc_input__getMenuButtons(0); s16 p = ogc_input__getMenuButtons(0);

View File

@ -40,9 +40,9 @@ extern void OpenPNGFromMemory(png_texture *texture, 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);
extern void FONT_WriteLeft(char *string, int size, int x, int y); extern void FONT_alignLeft(char *string, int size, int x, int y);
extern void FONT_WriteRight(char *string, int size, int x, int y); extern void FONT_alignRight(char *string, int size, int x, int y);
extern void FONT_WriteCenter(char *string, int size, int x1, int x2, int y); extern void FONT_writeCenter(char *string, int size, int x1, int x2, int y);
extern void WriteCentre_HL( int y, char *string); extern void WriteCentre_HL( int y, char *string);

View File

@ -27,6 +27,7 @@
#define MAXCODES 8 #define MAXCODES 8
extern char menutitle[60]; extern char menutitle[60];
extern s16 ogc_input__getMenuButtons(u32 cnt);
typedef struct typedef struct
{ {

View File

@ -29,6 +29,8 @@
#include "Background_intro_c3.h" #include "Background_intro_c3.h"
#include "Background_intro_c4.h" #include "Background_intro_c4.h"
extern s16 ogc_input__getMenuButtons(u32 cnt);
/* /*
* This is the legal stuff - which must be shown at program startup * This is the legal stuff - which must be shown at program startup
* Any derivative work MUST include the same textual output. * Any derivative work MUST include the same textual output.

View File

@ -86,6 +86,7 @@ typedef struct
u16 keys; u16 keys;
#ifdef HW_RVL #ifdef HW_RVL
struct ir_t ir; struct ir_t ir;
#endif
} gui_input; } gui_input;
/* Item descriptor*/ /* Item descriptor*/
@ -93,7 +94,7 @@ typedef struct
{ {
png_texture *texture; /* temporary texture data */ png_texture *texture; /* temporary texture data */
const u8 *data; /* pointer to png image data (items icon only) */ const u8 *data; /* pointer to png image data (items icon only) */
const char *text; /* item string (items list only) */ char *text; /* item string (items list only) */
char *comment; /* item comment */ char *comment; /* item comment */
u16 x; /* button image or text X position (upper left corner) */ u16 x; /* button image or text X position (upper left corner) */
u16 y; /* button image or text Y position (upper left corner) */ u16 y; /* button image or text Y position (upper left corner) */
@ -140,10 +141,10 @@ typedef struct
u8 max_buttons; /* total number of buttons (not necessary identical) */ u8 max_buttons; /* total number of buttons (not necessary identical) */
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 *frames[2]; /* top and bottom frames */
gui_image *background; /* background image */ gui_image *background; /* background image */
gui_image *logo; /* logo image */ gui_image *logo; /* logo image */
gui_item *helper[2]; /* key helpers */ gui_image *frames[2]; /* top and bottom frames */
gui_item *helpers[2]; /* key helpers */
gui_butn *arrows[2]; /* items list arrows */ gui_butn *arrows[2]; /* items list arrows */
} gui_menu; } gui_menu;
@ -173,12 +174,12 @@ static gui_image top_frame =
static gui_image bottom_frame = static gui_image bottom_frame =
{ {
NULL,Banner_top,0,388,640,92 NULL,Banner_bottom,0,388,640,92
}; };
static gui_image main_frame = static gui_image main_frame =
{ {
NULL,Banner_top,0,356,640,124 NULL,Banner_main,0,356,640,124
}; };
static gui_image background_center = static gui_image background_center =
@ -221,15 +222,8 @@ static butn_data button_icon_data =
/*****************************************************************************/ /*****************************************************************************/
/* Generic Arrow Buttons */ /* Generic Arrow Buttons */
/*****************************************************************************/ /*****************************************************************************/
static gui_butn arrow_up = static gui_butn arrow_up = {&arrow_up_data,172,82,36,36};
{ static gui_butn arrow_down = {&arrow_down_data,172,360,36,36};
&arrow_up_data,172,82,36,36
};
static gui_butn arrow_down =
{
&arrow_down_data,172,360,36,36
};
/*****************************************************************************/ /*****************************************************************************/
/* Generic Items */ /* Generic Items */
@ -265,35 +259,35 @@ static gui_item action_exit =
/* Audio options menu */ /* Audio options menu */
static gui_item items_audio[5] = static gui_item items_audio[5] =
{ {
{NULL,NULL,"PSG Volume:", "Adjust PSG output level", 0,0,0,0}, {NULL,NULL,"PSG Volume: 2.50", "Adjust PSG output level", 0,0,0,0},
{NULL,NULL,"FM Volume:", "Adjust FM output level", 0,0,0,0}, {NULL,NULL,"FM Volume: 1.00", "Adjust FM output level", 0,0,0,0},
{NULL,NULL,"Volume Boost:", "Adjust general output level", 0,0,0,0}, {NULL,NULL,"Volume Boost: 1x", "Adjust general output level", 0,0,0,0},
{NULL,NULL,"LowPass Filter:","Enable/disable sound filtering", 0,0,0,0}, {NULL,NULL,"LowPass Filter: OFF","Enable/disable sound filtering", 0,0,0,0},
{NULL,NULL,"HQ YM2612:", "Adjust FM emulation accuracy level",0,0,0,0} {NULL,NULL,"HQ YM2612: LINEAR", "Enable/disable FM chip interpolation",0,0,0,0}
}; };
/* System options menu */ /* System options menu */
static gui_item items_system[6] = static gui_item items_system[6] =
{ {
{NULL,NULL,"Console Region:","Select system region", 0,0,0,0}, {NULL,NULL,"Console Region: AUTO","Select system region", 0,0,0,0},
{NULL,NULL,"System Lockups:","Enable/disable original system lock-ups",0,0,0,0}, {NULL,NULL,"System Lockups: OFF", "Enable/disable original system lock-ups",0,0,0,0},
{NULL,NULL,"System BIOS:", "Enable/disable TMSS BIOS support", 0,0,0,0}, {NULL,NULL,"System BIOS: OFF", "Enable/disable TMSS BIOS support", 0,0,0,0},
{NULL,NULL,"SVP Cycles", "Adjust SVP chip emulation speed", 0,0,0,0}, {NULL,NULL,"SVP Cycles: 1500", "Adjust SVP chip emulation speed", 0,0,0,0},
{NULL,NULL,"Auto SRAM", "Enable/disable automatic SRAM", 0,0,0,0}, {NULL,NULL,"Auto SRAM: OFF", "Enable/disable automatic SRAM", 0,0,0,0},
{NULL,NULL,"Auto STATE", "Enable/disable automatic Freeze State", 0,0,0,0} {NULL,NULL,"Auto STATE: OFF", "Enable/disable automatic Freeze State", 0,0,0,0}
}; };
/* Video options menu */ /* Video options menu */
static gui_item items_video[8] = static gui_item items_video[8] =
{ {
{NULL,NULL,"Aspect Ratio:", "Select display aspect ratio", 0,0,0,0}, {NULL,NULL,"Aspect: STRETCHED", "Select display aspect ratio", 0,0,0,0},
{NULL,NULL,"Display:", "Select video mode type", 0,0,0,0}, {NULL,NULL,"Display: PROGRESSIVE", "Select video mode type", 0,0,0,0},
{NULL,NULL,"TV mode:", "Select video refresh rate", 0,0,0,0}, {NULL,NULL,"TV mode: 50/60Hz", "Select video refresh rate", 0,0,0,0},
{NULL,NULL,"Bilinear Filter:","Enable/disable hardware filtering", 0,0,0,0}, {NULL,NULL,"Bilinear Filter: OFF", "Enable/disable hardware filtering", 0,0,0,0},
{NULL,NULL,"NTSC Filter:", "Enable/disable NTSC software filtering", 0,0,0,0}, {NULL,NULL,"NTSC Filter: COMPOSITE","Enable/disable NTSC software filtering", 0,0,0,0},
{NULL,NULL,"Borders:", "Enable/disable original overscan emulation",0,0,0,0}, {NULL,NULL,"Borders: OFF", "Enable/disable original overscan emulation",0,0,0,0},
{NULL,NULL,"DISPLAY POSITION","Adjust display position", 0,0,0,0}, {NULL,NULL,"DISPLAY POSITION", "Adjust display position", 0,0,0,0},
{NULL,NULL,"DISPLAY SIZE", "Adjust display size", 0,0,0,0} {NULL,NULL,"DISPLAY SIZE", "Adjust display size", 0,0,0,0}
}; };
/* Main menu */ /* Main menu */
@ -341,48 +335,49 @@ static gui_item items_options[5] =
/* Generic list menu */ /* Generic list menu */
static gui_butn buttons_generic[4] = static gui_butn buttons_generic[4] =
{ {
&button_text_data,52,132,276,48}, {&button_text_data,52,132,276,48},
&button_text_data,52,188,276,48}, {&button_text_data,52,188,276,48},
&button_text_data,52,244,276,48}, {&button_text_data,52,244,276,48},
&button_text_data,52,300,276,48}, {&button_text_data,52,300,276,48}
}; };
/* Main menu */ /* Main menu */
static gui_butn buttons_main[6] = static gui_butn buttons_main[6] =
{ {
&button_icon_data, 80, 50,148,132}, {&button_icon_data, 80, 50,148,132},
&button_icon_data,246, 50,148,132}, {&button_icon_data,246, 50,148,132},
&button_icon_data,412, 50,148,132}, {&button_icon_data,412, 50,148,132},
&button_icon_data, 80,194,148,132}, {&button_icon_data, 80,194,148,132},
&button_icon_data,246,194,148,132}, {&button_icon_data,246,194,148,132},
&button_icon_data,412,194,148,132} {&button_icon_data,412,194,148,132}
}; };
/* Load Game menu */ /* Load Game menu */
#ifdef HW_RVL #ifdef HW_RVL
static gui_butn buttons_load[4] = static gui_butn buttons_load[4] =
{ {
&button_icon_data,246,102,148,132}, {&button_icon_data,246,102,148,132},
&button_icon_data, 80,248,148,132}, {&button_icon_data, 80,248,148,132},
&button_icon_data,246,248,148,132}, {&button_icon_data,246,248,148,132},
&button_icon_data,412,248,148,132} {&button_icon_data,412,248,148,132}
};
#else #else
static gui_butn buttons_load[3] = static gui_butn buttons_load[3] =
{ {
&button_icon_data, 80,180,148,132}, {&button_icon_data, 80,180,148,132},
&button_icon_data,246,180,148,132}, {&button_icon_data,246,180,148,132},
&button_icon_data,412,180,148,132} {&button_icon_data,412,180,148,132}
}; };
#endif #endif
/* Options menu */ /* Options menu */
static gui_butn buttons_options[5] = static gui_butn buttons_options[5] =
{ {
&button_icon_data, 80,120,148,132}, {&button_icon_data, 80,120,148,132},
&button_icon_data,246,120,148,132}, {&button_icon_data,246,120,148,132},
&button_icon_data,412,120,148,132}, {&button_icon_data,412,120,148,132},
&button_icon_data,162,264,148,132}, {&button_icon_data,162,264,148,132},
&button_icon_data,330,264,148,132} {&button_icon_data,330,264,148,132}
}; };
/*****************************************************************************/ /*****************************************************************************/
@ -482,11 +477,11 @@ static gui_menu menu_audio =
/*****************************************************************************/ /*****************************************************************************/
static void menu_initialize(gui_menu *menu) static void menu_initialize(gui_menu *menu)
{ {
int i,j; int i;
png_texture *texture; png_texture *texture;
gui_item *item; gui_item *item;
gui_butn *button;
gui_image *image; gui_image *image;
gui_butn *button;
butn_data *button_data; butn_data *button_data;
#ifdef HW_RVL #ifdef HW_RVL
@ -542,9 +537,9 @@ static void menu_initialize(gui_menu *menu)
texture = (png_texture *)malloc(sizeof(png_texture)); texture = (png_texture *)malloc(sizeof(png_texture));
if (texture) if (texture)
{ {
image = menu->helpers[i]; item = menu->helpers[i];
OpenPNGFromMemory(texture, image->data); OpenPNGFromMemory(texture, item->data);
image->texture = texture; item->texture = texture;
} }
} }
@ -555,23 +550,39 @@ static void menu_initialize(gui_menu *menu)
texture = (png_texture *)malloc(sizeof(png_texture)); texture = (png_texture *)malloc(sizeof(png_texture));
if (texture) if (texture)
{ {
OpenPNGFromMemory(texture, button_data->image); OpenPNGFromMemory(texture, button_data->image[0]);
button_data->texture = texture; 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 */ /* menu buttons */
for (j=0; j<menu->max_buttons; j++) for (i=0; i<menu->max_buttons; i++)
{
button = &menu->buttons[i];
button_data = button->data;
if (button_data->texture[0] == NULL)
{ {
button_data = menu->buttons[j]->data; texture = (png_texture *)malloc(sizeof(png_texture));
if (!button_data->texture[i]) if (texture)
{ {
texture = (png_texture *)malloc(sizeof(png_texture)); OpenPNGFromMemory(texture, button_data->image[0]);
if (texture) button_data->texture[0] = texture;
{ }
OpenPNGFromMemory(texture, buttons_data->image[i]); }
buttons_data->texture[i] = 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;
} }
} }
} }
@ -579,14 +590,14 @@ static void menu_initialize(gui_menu *menu)
/* 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)
{ {
texture = (png_texture *)malloc(sizeof(png_texture)); texture = (png_texture *)malloc(sizeof(png_texture));
if (texture) if (texture)
{ {
OpenPNGFromMemory(texture, item->data); OpenPNGFromMemory(texture, item->data);
items->texture = texture; item->texture = texture;
} }
} }
} }
@ -594,11 +605,10 @@ static void menu_initialize(gui_menu *menu)
static void menu_delete(gui_menu *menu) static void menu_delete(gui_menu *menu)
{ {
int i,j; int i;
png_texture *texture; png_texture *texture;
gui_item *item;
gui_butn *button; gui_butn *button;
gui_image *image; gui_item *item;
butn_data *button_data; butn_data *button_data;
/* free background image texture */ /* free background image texture */
@ -607,7 +617,7 @@ static void menu_delete(gui_menu *menu)
texture = menu->background->texture; texture = menu->background->texture;
if (texture) if (texture)
{ {
if (texture->data) free(texture.data); if (texture->data) free(texture->data);
free(texture); free(texture);
} }
} }
@ -618,7 +628,7 @@ static void menu_delete(gui_menu *menu)
texture = menu->logo->texture; texture = menu->logo->texture;
if (texture) if (texture)
{ {
if (texture->data) free(texture.data); if (texture->data) free(texture->data);
free(texture); free(texture);
} }
} }
@ -632,7 +642,7 @@ static void menu_delete(gui_menu *menu)
texture = menu->frames[i]->texture; texture = menu->frames[i]->texture;
if (texture) if (texture)
{ {
if (texture->data) free(texture.data); if (texture->data) free(texture->data);
free(texture); free(texture);
texture = NULL; texture = NULL;
} }
@ -644,7 +654,7 @@ static void menu_delete(gui_menu *menu)
texture = menu->helpers[i]->texture; texture = menu->helpers[i]->texture;
if (texture) if (texture)
{ {
if (texture->data) free(texture.data); if (texture->data) free(texture->data);
free(texture); free(texture);
texture = NULL; texture = NULL;
} }
@ -653,36 +663,52 @@ static void menu_delete(gui_menu *menu)
/* up/down buttons */ /* up/down buttons */
if (menu->arrows[i]) if (menu->arrows[i])
{ {
texture = menu->arrows[i]->texture; texture = menu->arrows[i]->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; texture = NULL;
} }
} texture = menu->arrows[i]->data->texture[1];
/* menu buttons */
for (j=0; j<menu->max_buttons; j++)
{
button_data = menu->buttons[j]->data;
texture = button_data->texture[i];
if (texture) if (texture)
{ {
if (texture->data) free(texture.data); if (texture->data) free(texture->data);
free(texture); free(texture);
texture = NULL; texture = NULL;
} }
} }
} }
/* menu buttons */
for (i=0; i<menu->max_buttons; i++)
{
button = &menu->buttons[i];
button_data = button->data;
texture = button_data->texture[0];
if (texture)
{
if (texture->data) free(texture->data);
free(texture);
texture = NULL;
}
texture = button_data->texture[1];
if (texture)
{
if (texture->data) free(texture->data);
free(texture);
texture = NULL;
}
}
/* allocate item textures */ /* allocate item textures */
for (i=0; i<menu->max_items; i++) for (i=0; i<menu->max_items; i++)
{ {
texture = menu->items[i]->texture; item = &menu->items[i];
texture = item->texture;
if (texture) if (texture)
{ {
if (texture->data) free(texture.data); if (texture->data) free(texture->data);
free(texture); free(texture);
texture = NULL; texture = NULL;
} }
@ -703,13 +729,6 @@ static void menu_draw(gui_menu *menu)
image = menu->background; image = menu->background;
if (image) DrawTexture(image->texture,image->x,image->y,image->w,image->h); if (image) DrawTexture(image->texture,image->x,image->y,image->w,image->h);
/* draw logo */
image = menu->logo;
if (image) DrawTexture(image->texture,image->x,image->y,image->w,image->h);
/* draw title */
if (menu->title) FONT_alignLeft(menu->title, 22,10,56);
/* draw background frames */ /* draw background frames */
for (i=0; i<2; i++) for (i=0; i<2; i++)
{ {
@ -717,8 +736,15 @@ static void menu_draw(gui_menu *menu)
if (image) DrawTexture(image->texture,image->x,image->y,image->w,image->h); if (image) DrawTexture(image->texture,image->x,image->y,image->w,image->h);
} }
/* draw logo */
image = menu->logo;
if (image) DrawTexture(image->texture,image->x,image->y,image->w,image->h);
/* draw title */
if (menu->title) FONT_alignLeft(menu->title, 22,10,56);
/* draw left helper */ /* draw left helper */
item = menu->helper[0]; item = menu->helpers[0];
if (item) if (item)
{ {
DrawTexture(item->texture, item->x, item->y, item->w, item->h); DrawTexture(item->texture, item->x, item->y, item->w, item->h);
@ -726,7 +752,7 @@ static void menu_draw(gui_menu *menu)
} }
/* draw right helper */ /* draw right helper */
item = menu->helper[1]; item = menu->helpers[1];
if (item) if (item)
{ {
DrawTexture(item->texture, item->x, item->y, item->w, item->h); DrawTexture(item->texture, item->x, item->y, item->w, item->h);
@ -738,12 +764,12 @@ static void menu_draw(gui_menu *menu)
{ {
/* draw button */ /* draw button */
button = &menu->buttons[i]; button = &menu->buttons[i];
DrawTexture(button->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->texture) 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) */
@ -754,11 +780,11 @@ static void menu_draw(gui_menu *menu)
{ {
if (menu->selected == menu->max_buttons + i) if (menu->selected == menu->max_buttons + i)
{ {
DrawTexture(button->texture[1], button->x-2, button->y-2, button->w+4, button->h+4); DrawTexture(button->data->texture[1], button->x-2, button->y-2, button->w+4, button->h+4);
} }
else else
{ {
DrawTexture(button->texture[0], button->x, button->y, button->w, button->h); DrawTexture(button->data->texture[0], button->x, button->y, button->w, button->h);
} }
} }
} }
@ -933,19 +959,19 @@ static int menu_callback(gui_menu *menu)
menu->arrows[1] = NULL; menu->arrows[1] = NULL;
/* update comment */ /* update comment */
if (menu->helper[1]) if (menu->helpers[1])
{ {
gui_item *item = &menu->items[menu->offset + menu->selected]; gui_item *item = &menu->items[menu->offset + menu->selected];
strcpy(menu->helper[1]->comment,item->comment); if (item->comment) strcpy(menu->helpers[1]->comment,item->comment);
} }
} }
} }
void menu_update_inputs(u32 cnt) s16 ogc_input__getMenuButtons(u32 cnt)
{ {
/* get gamepad inputs */ /* get gamepad inputs */
PAD_ScanPads(); PAD_ScanPads();
u16 p = PAD_ButtonsDown(0); s16 p = PAD_ButtonsDown(0);
s8 x = PAD_StickX(0); s8 x = PAD_StickX(0);
s8 y = PAD_StickY(0); s8 y = PAD_StickY(0);
if (x > 70) p |= PAD_BUTTON_RIGHT; if (x > 70) p |= PAD_BUTTON_RIGHT;
@ -957,15 +983,15 @@ void menu_update_inputs(u32 cnt)
/* get wiimote + expansions inputs */ /* get wiimote + expansions inputs */
WPAD_ScanPads(); WPAD_ScanPads();
u32 q = WPAD_ButtonsDown(0); u32 q = WPAD_ButtonsDown(0);
u32 h = WPAD_ButtonsHeld(0); /*u32 h = WPAD_ButtonsHeld(0);*/
x = WPAD_StickX(0, 0); x = WPAD_StickX(0, 0);
y = WPAD_StickY(0, 0); y = WPAD_StickY(0, 0);
/* Wiimote orientation */ /* Wiimote orientation */
WPAD_IR(0, &M_inputs.ir); WPAD_IR(0, &m_input.ir);
/* wiimote directions */ /* wiimote directions */
if (m_inputs.ir.valid) if (m_input.ir.valid)
{ {
if (q & WPAD_BUTTON_UP) p |= PAD_BUTTON_UP; if (q & WPAD_BUTTON_UP) p |= PAD_BUTTON_UP;
else if (q & WPAD_BUTTON_DOWN) p |= PAD_BUTTON_DOWN; else if (q & WPAD_BUTTON_DOWN) p |= PAD_BUTTON_DOWN;
@ -1010,6 +1036,8 @@ void menu_update_inputs(u32 cnt)
#endif #endif
m_input.keys = p; m_input.keys = p;
return p;
} }
/*************************************************************************** /***************************************************************************
@ -1019,9 +1047,9 @@ void menu_update_inputs(u32 cnt)
* selected item :) * selected item :)
***************************************************************************/ ***************************************************************************/
char menutitle[60] = { "" }; char menutitle[60] = { "" };
int menu = 0; static int menu = 0;
void drawmenu (char items[][25], int maxitems, int selected) static void drawmenu (char items[][25], int maxitems, int selected)
{ {
int i; int i;
@ -1045,18 +1073,16 @@ void drawmenu (char items[][25], int maxitems, int selected)
OpenPNGFromMemory(&texture, Main_logo); OpenPNGFromMemory(&texture, Main_logo);
DrawTexture(&texture, 444, 28, 176, 48); DrawTexture(&texture, 444, 28, 176, 48);
// WriteCentre (134, menutitle);
for (i = 0; i < maxitems; i++) for (i = 0; i < maxitems; i++)
{ {
if (i == selected) WriteCentre_HL (i * fheight + ypos, (char *) items[i]); if (i == selected) WriteCentre_HL (i * fheight + ypos, (char *) items[i]);
else WriteCentre (i * fheight + ypos, (char *) items[i]); else WriteCentre (i * fheight + ypos, (char *) items[i]);
} }
SetScreen (); SetScreen ();
} }
int domenu (char items[][25], int maxitems, u8 fastmove) static int domenu (char items[][25], int maxitems, u8 fastmove)
{ {
int redraw = 1; int redraw = 1;
int quit = 0; int quit = 0;
@ -1120,11 +1146,13 @@ int domenu (char items[][25], int maxitems, u8 fastmove)
* Sound Option menu * Sound Option menu
* *
****************************************************************************/ ****************************************************************************/
void soundmenu () static void soundmenu ()
{ {
int ret; int ret, quit = 0;
int quit = 0; gui_menu *m = &menu_audio;
gui_item *items = menu_audio.items; gui_item *items = m->items;
menu_initialize(m);
while (quit == 0) while (quit == 0)
{ {
@ -1136,7 +1164,7 @@ void soundmenu ()
else if (config.hq_fm == 1) sprintf (items[4].text, "HQ YM2612: LINEAR"); else if (config.hq_fm == 1) sprintf (items[4].text, "HQ YM2612: LINEAR");
else sprintf (items[4].text, "HQ YM2612: SINC"); else sprintf (items[4].text, "HQ YM2612: SINC");
ret = MenuCall(&menu_audio); ret = menu_callback(m);
switch (ret) switch (ret)
{ {
case 0: case 0:
@ -1183,27 +1211,29 @@ void soundmenu ()
break; break;
} }
} }
menu_delete(m);
} }
/**************************************************************************** /****************************************************************************
* Misc Option menu * Misc Option menu
* *
****************************************************************************/ ****************************************************************************/
void miscmenu () static void systemmenu ()
{ {
int ret; int ret, quit = 0;
int quit = 0; gui_menu *m = &menu_system;
gui_item *items = menu_system.items; gui_item *items = m->items;
menu_initialize(m);
while (quit == 0) while (quit == 0)
{ {
if (config.region_detect == 0) sprintf (items[0].text, "Region: AUTO"); if (config.region_detect == 0) sprintf (items[0].text, "Console Region: AUTO");
else if (config.region_detect == 1) sprintf (items[0].text, "Region: USA"); else if (config.region_detect == 1) sprintf (items[0].text, "Console Region: USA");
else if (config.region_detect == 2) sprintf (items[0].text, "Region: EUR"); else if (config.region_detect == 2) sprintf (items[0].text, "Console Region: EUR");
else if (config.region_detect == 3) sprintf (items[0].text, "Region: JAP"); else if (config.region_detect == 3) sprintf (items[0].text, "Console Region: JAP");
sprintf (items[1].text, "Force DTACK: %s", config.force_dtack ? "Y" : "N"); sprintf (items[1].text, "System Lockups: %s", config.force_dtack ? "ON" : "OFF");
if (config.bios_enabled & 1) sprintf (items[2].text, "Use BIOS: ON"); sprintf (items[2].text, "System BIOS: %s", (config.bios_enabled & 1) ? "ON":"OFF");
else sprintf (items[2].text, "Use BIOS: OFF");
sprintf (items[3].text, "SVP Cycles: %d", SVP_cycles); sprintf (items[3].text, "SVP Cycles: %d", SVP_cycles);
if (config.sram_auto == 0) sprintf (items[4].text, "Auto SRAM: FAT"); if (config.sram_auto == 0) sprintf (items[4].text, "Auto SRAM: FAT");
else if (config.sram_auto == 1) sprintf (items[4].text, "Auto SRAM: MCARD A"); else if (config.sram_auto == 1) sprintf (items[4].text, "Auto SRAM: MCARD A");
@ -1214,7 +1244,8 @@ void miscmenu ()
else if (config.freeze_auto == 2) sprintf (items[5].text, "Auto FREEZE: MCARD B"); else if (config.freeze_auto == 2) sprintf (items[5].text, "Auto FREEZE: MCARD B");
else sprintf (items[5].text, "Auto FREEZE: OFF"); else sprintf (items[5].text, "Auto FREEZE: OFF");
ret = MenuCall(&menu_system); ret = menu_callback(m);
switch (ret) switch (ret)
{ {
case 0: /*** Region Force ***/ case 0: /*** Region Force ***/
@ -1278,17 +1309,20 @@ void miscmenu ()
break; break;
} }
} }
menu_delete(m);
} }
/**************************************************************************** /****************************************************************************
* Display Option menu * Display Option menu
* *
****************************************************************************/ ****************************************************************************/
void dispmenu () static void videomenu ()
{ {
int ret; int ret, quit = 0;
int quit = 0; gui_menu *m = &menu_video;
gui_item *items = menu_video.items; gui_item *items = m->items;
menu_initialize(m);
while (quit == 0) while (quit == 0)
{ {
@ -1305,10 +1339,8 @@ void dispmenu ()
else if (config.ntsc == 3) sprintf (items[4].text, "NTSC Filter: RGB"); else if (config.ntsc == 3) sprintf (items[4].text, "NTSC Filter: RGB");
else sprintf (items[4].text, "NTSC Filter: OFF"); else sprintf (items[4].text, "NTSC Filter: OFF");
sprintf (items[5].text, "Borders: %s", config.overscan ? " ON" : "OFF"); sprintf (items[5].text, "Borders: %s", config.overscan ? " ON" : "OFF");
strcpy (items[6].text, "DISPLAY POSITION");
strcpy (items[7].text, "DISPLAY SIZE");
ret = MenuCall(&menu_video); ret = menu_callback(m);
switch (ret) switch (ret)
{ {
case 0: /*** config.aspect ratio ***/ case 0: /*** config.aspect ratio ***/
@ -1333,8 +1365,7 @@ void dispmenu ()
break; break;
case 2: /*** tv mode ***/ case 2: /*** tv mode ***/
if (config.render == 2) break; /* 60hz progressive only */ if (config.render != 2) config.tv_mode = (config.tv_mode + 1) % 3;
config.tv_mode = (config.tv_mode + 1) % 3;
break; break;
case 3: /*** bilinear filtering ***/ case 3: /*** bilinear filtering ***/
@ -1383,13 +1414,14 @@ void dispmenu ()
break; break;
} }
} }
menu_delete(m);
} }
/**************************************************************************** /****************************************************************************
* ConfigureJoypads * ConfigureJoypads
****************************************************************************/ ****************************************************************************/
extern int old_system[2]; extern int old_system[2];
void ConfigureJoypads () static void inputsmenu(void)
{ {
int ret, max_players; int ret, max_players;
int i = 0; int i = 0;
@ -1693,27 +1725,29 @@ void ConfigureJoypads ()
* Main Option menu * Main Option menu
* *
****************************************************************************/ ****************************************************************************/
void optionmenu () static void optionmenu(void)
{ {
int ret; int ret, quit = 0;
int quit = 0; gui_menu *m = &menu_options;
while (quit == 0) while (quit == 0)
{ {
ret = MenuCall(&menu_options); menu_initialize(m);
ret = menu_callback(m);
menu_delete(m);
switch (ret) switch (ret)
{ {
case 0: case 0:
miscmenu(); systemmenu();
break; break;
case 1: case 1:
dispmenu(); videomenu();
break; break;
case 2: case 2:
soundmenu(); soundmenu();
break; break;
case 3: case 3:
ConfigureJoypads(); inputsmenu();
break; break;
case 4: case 4:
GetGGEntries(); GetGGEntries();
@ -1733,7 +1767,7 @@ void optionmenu ()
****************************************************************************/ ****************************************************************************/
static u8 device = 0; static u8 device = 0;
int loadsavemenu (int which) static int loadsavemenu (int which)
{ {
int prevmenu = menu; int prevmenu = menu;
int quit = 0; int quit = 0;
@ -1741,8 +1775,6 @@ int loadsavemenu (int which)
int count = 3; int count = 3;
char items[3][25]; char items[3][25];
strcpy (menutitle, "Press B to return");
menu = 2; menu = 2;
if (which == 1) if (which == 1)
@ -1791,7 +1823,7 @@ int loadsavemenu (int which)
* File Manager menu * File Manager menu
* *
****************************************************************************/ ****************************************************************************/
int filemenu () static int filemenu ()
{ {
int prevmenu = menu; int prevmenu = menu;
int ret; int ret;
@ -1833,15 +1865,18 @@ int filemenu ()
****************************************************************************/ ****************************************************************************/
extern char rom_filename[MAXJOLIET]; extern char rom_filename[MAXJOLIET];
static u8 load_menu = 0; static u8 load_menu = 0;
static u8 dvd_on = 0;
int loadmenu () static int loadmenu ()
{ {
int ret,size; int ret,size,quit = 0;
int quit = 0; gui_menu *m = &menu_load;
while (quit == 0) while (quit == 0)
{ {
ret = MenuCall(&menu_load); menu_initialize(m);
ret = menu_callback(m);
menu_delete(m);
switch (ret) switch (ret)
{ {
/*** Button B ***/ /*** Button B ***/
@ -1859,7 +1894,7 @@ int loadmenu ()
size = DVD_Open(cart_rom); size = DVD_Open(cart_rom);
if (size) if (size)
{ {
dvd_on = 1; dvd_motor_off();
genromsize = size; genromsize = size;
memfile_autosave(); memfile_autosave();
reloadrom(); reloadrom();
@ -1870,17 +1905,6 @@ int loadmenu ()
} }
break; break;
/*** Stop DVD Disc ***/
#ifdef HW_RVL
case 4:
#else
case 3:
#endif
dvd_motor_off();
dvd_on = 0;
menu = load_menu;
break;
/*** Load from FAT device ***/ /*** Load from FAT device ***/
default: default:
load_menu = menu; load_menu = menu;
@ -1896,7 +1920,6 @@ int loadmenu ()
return 1; return 1;
} }
break; break;
} }
} }
@ -1906,7 +1929,7 @@ int loadmenu ()
/*************************************************************************** /***************************************************************************
* Show rom info screen * Show rom info screen
***************************************************************************/ ***************************************************************************/
void showrominfo () static void showrominfo ()
{ {
int ypos; int ypos;
u8 i,j,quit,redraw,max; u8 i,j,quit,redraw,max;
@ -2030,9 +2053,8 @@ void showrominfo ()
****************************************************************************/ ****************************************************************************/
void MainMenu (u32 fps) void MainMenu (u32 fps)
{ {
int ret; int ret, quit = 0;
int quit = 0; /* uint32 crccheck;*/
uint32 crccheck;
/* autosave (SRAM only) */ /* autosave (SRAM only) */
int temp = config.freeze_auto; int temp = config.freeze_auto;
@ -2040,15 +2062,19 @@ void MainMenu (u32 fps)
memfile_autosave(); memfile_autosave();
config.freeze_auto = temp; config.freeze_auto = temp;
gui_menu *m = &menu_main;
while (quit == 0) while (quit == 0)
{ {
crccheck = crc32 (0, &sram.sram[0], 0x10000); /* crccheck = crc32 (0, &sram.sram[0], 0x10000);
strcpy (menutitle,""); strcpy (menutitle,"");
if (genromsize && (crccheck != sram.crc)) strcpy (menutitle, "*** SRAM has been modified ***"); if (genromsize && (crccheck != sram.crc)) strcpy (menutitle, "*** SRAM has been modified ***");
else if (genromsize) sprintf (menutitle, "%d FPS",fps); else if (genromsize) sprintf (menutitle, "%d FPS",fps);
*/
menu_initialize(m);
ret = menu_callback(m);
menu_delete(m);
menu_initialize(&menu_main);
ret = menu_callback(&menu_main);
switch (ret) switch (ret)
{ {
case -1: /*** Button B ***/ case -1: /*** Button B ***/
@ -2082,7 +2108,6 @@ void MainMenu (u32 fps)
case 6: /*** SD/PSO/TP Reload ***/ case 6: /*** SD/PSO/TP Reload ***/
menu_delete(&menu_main);
memfile_autosave(); memfile_autosave();
system_shutdown(); system_shutdown();
audio_shutdown(); audio_shutdown();
@ -2096,7 +2121,6 @@ void MainMenu (u32 fps)
break; break;
case 7: /*** Return to Wii System Menu ***/ case 7: /*** Return to Wii System Menu ***/
menu_delete(&menu_main);
memfile_autosave(); memfile_autosave();
system_shutdown(); system_shutdown();
audio_shutdown(); audio_shutdown();
@ -2113,8 +2137,6 @@ void MainMenu (u32 fps)
} }
} }
menu_delete(&menu_main);
/*** 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