1
0
mirror of https://github.com/libretro/RetroArch synced 2025-04-03 01:21:10 +00:00

(RMenu) Refactored bloated menu stack code - should use less

memory now
This commit is contained in:
Twinaphex 2012-08-22 01:16:15 +02:00
parent 213823fd84
commit 62aee43228
4 changed files with 40 additions and 24 deletions
console/rmenu
gfx/context
ps3/frontend

@ -2108,15 +2108,19 @@ void menu_loop(void)
context->init_textures(); context->init_textures();
menu current_menu;
menu_stack_force_refresh();
do do
{ {
//first button input frame //first button input frame
uint64_t input_state_first_frame = 0; uint64_t input_state_first_frame = 0;
uint64_t input_state = 0; uint64_t input_state = 0;
static bool first_held = false; static bool first_held = false;
menu *current_menu = menu_stack_get_current_ptr();
rmenu_default_positions_t default_pos; rmenu_default_positions_t default_pos;
menu_stack_get_current_ptr(&current_menu);
context->set_default_pos(&default_pos); context->set_default_pos(&default_pos);
input_ptr.poll(NULL); input_ptr.poll(NULL);
@ -2141,7 +2145,7 @@ void menu_loop(void)
} }
bool analog_sticks_pressed = (input_state & (1 << RMENU_DEVICE_NAV_LEFT_ANALOG_L)) || (input_state & (1 << RMENU_DEVICE_NAV_RIGHT_ANALOG_L)) || (input_state & (1 << RMENU_DEVICE_NAV_UP_ANALOG_L)) || (input_state & (1 << RMENU_DEVICE_NAV_DOWN_ANALOG_L)) || (input_state & (1 << RMENU_DEVICE_NAV_LEFT_ANALOG_R)) || (input_state & (1 << RMENU_DEVICE_NAV_RIGHT_ANALOG_R)) || (input_state & (1 << RMENU_DEVICE_NAV_UP_ANALOG_R)) || (input_state & (1 << RMENU_DEVICE_NAV_DOWN_ANALOG_R)); bool analog_sticks_pressed = (input_state & (1 << RMENU_DEVICE_NAV_LEFT_ANALOG_L)) || (input_state & (1 << RMENU_DEVICE_NAV_RIGHT_ANALOG_L)) || (input_state & (1 << RMENU_DEVICE_NAV_UP_ANALOG_L)) || (input_state & (1 << RMENU_DEVICE_NAV_DOWN_ANALOG_L)) || (input_state & (1 << RMENU_DEVICE_NAV_LEFT_ANALOG_R)) || (input_state & (1 << RMENU_DEVICE_NAV_RIGHT_ANALOG_R)) || (input_state & (1 << RMENU_DEVICE_NAV_UP_ANALOG_R)) || (input_state & (1 << RMENU_DEVICE_NAV_DOWN_ANALOG_R));
bool shoulder_buttons_pressed = ((input_state & (1 << RMENU_DEVICE_NAV_L2)) || (input_state & (1 << RMENU_DEVICE_NAV_R2))) && current_menu->category_id != CATEGORY_SETTINGS; bool shoulder_buttons_pressed = ((input_state & (1 << RMENU_DEVICE_NAV_L2)) || (input_state & (1 << RMENU_DEVICE_NAV_R2))) && current_menu.category_id != CATEGORY_SETTINGS;
bool do_held = analog_sticks_pressed || shoulder_buttons_pressed; bool do_held = analog_sticks_pressed || shoulder_buttons_pressed;
if(do_held) if(do_held)
@ -2161,7 +2165,7 @@ void menu_loop(void)
context->clear(); context->clear();
if(!show_menu_screen || current_menu->enum_id == INGAME_MENU_SCREENSHOT) if(!show_menu_screen || current_menu.enum_id == INGAME_MENU_SCREENSHOT)
{ {
context->render_menu_enable(false); context->render_menu_enable(false);
} }
@ -2175,10 +2179,10 @@ void menu_loop(void)
filebrowser_t * fb = &browser; filebrowser_t * fb = &browser;
switch(current_menu->enum_id) switch(current_menu.enum_id)
{ {
case FILE_BROWSER_MENU: case FILE_BROWSER_MENU:
select_rom(current_menu, trig_state); select_rom(&current_menu, trig_state);
fb = &browser; fb = &browser;
break; break;
case GENERAL_VIDEO_MENU: case GENERAL_VIDEO_MENU:
@ -2188,14 +2192,14 @@ void menu_loop(void)
case EMU_AUDIO_MENU: case EMU_AUDIO_MENU:
case PATH_MENU: case PATH_MENU:
case CONTROLS_MENU: case CONTROLS_MENU:
select_setting(current_menu, trig_state); select_setting(&current_menu, trig_state);
break; break;
case SHADER_CHOICE: case SHADER_CHOICE:
case PRESET_CHOICE: case PRESET_CHOICE:
case BORDER_CHOICE: case BORDER_CHOICE:
case LIBRETRO_CHOICE: case LIBRETRO_CHOICE:
case INPUT_PRESET_CHOICE: case INPUT_PRESET_CHOICE:
select_file(current_menu, trig_state); select_file(&current_menu, trig_state);
fb = &tmpBrowser; fb = &tmpBrowser;
break; break;
case PATH_SAVESTATES_DIR_CHOICE: case PATH_SAVESTATES_DIR_CHOICE:
@ -2205,22 +2209,22 @@ void menu_loop(void)
#endif #endif
case PATH_SRAM_DIR_CHOICE: case PATH_SRAM_DIR_CHOICE:
case PATH_SYSTEM_DIR_CHOICE: case PATH_SYSTEM_DIR_CHOICE:
select_directory(current_menu, trig_state); select_directory(&current_menu, trig_state);
fb = &tmpBrowser; fb = &tmpBrowser;
break; break;
case INGAME_MENU: case INGAME_MENU:
if(g_console.ingame_menu_enable) if(g_console.ingame_menu_enable)
ingame_menu(current_menu, trig_state); ingame_menu(&current_menu, trig_state);
break; break;
case INGAME_MENU_RESIZE: case INGAME_MENU_RESIZE:
ingame_menu_resize(current_menu, trig_state); ingame_menu_resize(&current_menu, trig_state);
break; break;
case INGAME_MENU_SCREENSHOT: case INGAME_MENU_SCREENSHOT:
ingame_menu_screenshot(current_menu, trig_state); ingame_menu_screenshot(&current_menu, trig_state);
break; break;
} }
switch(current_menu->category_id) switch(current_menu.category_id)
{ {
case CATEGORY_FILEBROWSER: case CATEGORY_FILEBROWSER:
browser_render(fb); browser_render(fb);
@ -2270,7 +2274,7 @@ void menu_loop(void)
context->swap_buffers(); context->swap_buffers();
if(current_menu->enum_id == INGAME_MENU_RESIZE && (old_state & (1 << RMENU_DEVICE_NAV_Y)) || current_menu->enum_id == INGAME_MENU_SCREENSHOT) if(current_menu.enum_id == INGAME_MENU_RESIZE && (old_state & (1 << RMENU_DEVICE_NAV_Y)) || current_menu.enum_id == INGAME_MENU_SCREENSHOT)
{ } { }
else else
context->blend(false); context->blend(false);

@ -16,30 +16,36 @@
#include "rmenu_stack.h" #include "rmenu_stack.h"
menu menuStack[10]; static unsigned char menu_stack_enum_array[10];
int stack_idx = 0; static unsigned stack_idx = 0;
static bool need_refresh = false;
static void menu_stack_pop(void) static void menu_stack_pop(void)
{ {
if(stack_idx > 0) if(stack_idx > 0)
{
stack_idx--; stack_idx--;
need_refresh = true;
}
} }
menu *menu_stack_get_current_ptr (void) static void menu_stack_force_refresh(void)
{ {
return &menuStack[stack_idx]; need_refresh = true;
} }
static void menu_stack_push(unsigned menu_id) static void menu_stack_push(unsigned menu_id)
{ {
static bool first_push_do_not_increment = true; menu_stack_enum_array[++stack_idx] = menu_id;
need_refresh = true;
}
if(!first_push_do_not_increment) static void menu_stack_get_current_ptr(menu *current_menu)
stack_idx++; {
else if(!need_refresh)
first_push_do_not_increment = false; return;
menu *current_menu = menu_stack_get_current_ptr(); unsigned menu_id = menu_stack_enum_array[stack_idx];
switch(menu_id) switch(menu_id)
{ {
@ -185,4 +191,6 @@ static void menu_stack_push(unsigned menu_id)
default: default:
break; break;
} }
need_refresh = false;
} }

@ -17,6 +17,8 @@
#ifndef _PS3_CTX_H #ifndef _PS3_CTX_H
#define _PS3_CTX_H #define _PS3_CTX_H
#include "../gl_common.h"
void gfx_ctx_get_available_resolutions (void); void gfx_ctx_get_available_resolutions (void);
int gfx_ctx_check_resolution(unsigned resolution_id); int gfx_ctx_check_resolution(unsigned resolution_id);
float gfx_ctx_get_aspect_ratio(void); float gfx_ctx_get_aspect_ratio(void);

@ -41,6 +41,7 @@
#include <np.h> #include <np.h>
#include <np/drm.h> #include <np/drm.h>
#include "../../gfx/context/ps3_ctx.h"
#include "../ps3_input.h" #include "../ps3_input.h"
#include "../../gfx/gl_common.h" #include "../../gfx/gl_common.h"
@ -285,6 +286,7 @@ int main(int argc, char *argv[])
#endif #endif
video_gl.start(); video_gl.start();
driver.video = &video_gl;
#ifdef HAVE_OSKUTIL #ifdef HAVE_OSKUTIL
oskutil_init(&g_console.oskutil_handle, 0); oskutil_init(&g_console.oskutil_handle, 0);