Skip to content

Commit

Permalink
fix bug when accessing memory address cheat setting before cheat syst…
Browse files Browse the repository at this point in the history
…em initialized ; clean up code in some areas
  • Loading branch information
RetroSven committed Jul 28, 2018
1 parent 89083fd commit 3c0a8c0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ menu/driverspzarch.c
.settings
libretro-super
run.sh
convert_rumble.awk
*~

# Wii U
*.depend
Expand Down
7 changes: 5 additions & 2 deletions managers/cheat_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,11 @@ int cheat_manager_initialize_search(void *data, bool wraparound)
cheat_manager_state.memory_initialized = true ;

runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_INIT_SUCCESS), 1, 180, true);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
if ( !wraparound )
{
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
}

return 0 ;
}
Expand Down
17 changes: 12 additions & 5 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -5157,8 +5157,16 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
info->need_push = true;
break;
case DISPLAYLIST_CHEAT_DETAILS_SETTINGS_LIST:
{
rarch_setting_t *setting = NULL;
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);

if ( !cheat_manager_state.memory_initialized)
cheat_manager_initialize_search(NULL,true) ;

setting = menu_setting_find(msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_ADDRESS));
if ( setting )
setting->max = cheat_manager_state.total_memory_size==0?0:cheat_manager_state.total_memory_size-1;

menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_CHEAT_IDX,
Expand All @@ -5174,11 +5182,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
MENU_ENUM_LABEL_CHEAT_HANDLER,
PARSE_ONLY_UINT, false);
if ( cheat_manager_state.working_cheat.handler == CHEAT_HANDLER_TYPE_EMU)
{
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_CHEAT_CODE,
PARSE_ONLY_STRING, false);
}
else
{
menu_displaylist_parse_settings_enum(menu, info,
Expand Down Expand Up @@ -5250,10 +5256,11 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
info->need_refresh = true;
info->need_push = true;
break;
}
case DISPLAYLIST_CHEAT_SEARCH_SETTINGS_LIST:
{
{
char cheat_label[64];
rarch_setting_t *setting;
rarch_setting_t *setting;
unsigned int address = 0;
unsigned int address_mask = 0;
unsigned int prev_val = 0;
Expand Down Expand Up @@ -5346,8 +5353,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)

info->need_refresh = true;
info->need_push = true;
}
break;
}
case DISPLAYLIST_ONSCREEN_DISPLAY_SETTINGS_LIST:
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
menu_displaylist_parse_settings_enum(menu, info,
Expand Down
52 changes: 23 additions & 29 deletions setting_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
#include "setting_list.h"
#include "retroarch.h"

#define _3_SECONDS 3000000
#define _6_SECONDS 6000000
#define _9_SECONDS 9000000
#define _12_SECONDS 12000000
#define _15_SECONDS 15000000
#define _18_SECONDS 18000000
#define _21_SECONDS 21000000

bool settings_list_append(rarch_setting_t **list,
rarch_setting_info_t *list_info)
{
Expand Down Expand Up @@ -204,52 +212,38 @@ static float recalc_step_based_on_length_of_action(rarch_setting_t *setting)
{
float numsteps = (setting->max-setting->min)/setting->step ;
float multiplier = 1.0f ;
if ( global->menu.action_press_time > 12000000)
{
if ( global->menu.action_press_time > _12_SECONDS)
multiplier = (numsteps/60.0f);
} else if ( global->menu.action_press_time > 9000000)
{
else if ( global->menu.action_press_time > _9_SECONDS)
multiplier = (numsteps/300.0f) ;
} else if ( global->menu.action_press_time > 6000000)
{
else if ( global->menu.action_press_time > _6_SECONDS)
multiplier = (numsteps/750.0f);
} else if ( global->menu.action_press_time > 3000000)
{
else if ( global->menu.action_press_time > _3_SECONDS)
multiplier = (numsteps/3000.0f) ;
} else
{
else
multiplier = 1.0f ;
}

step = setting->step*multiplier;
}
else
#endif
{
if ( global->menu.action_press_time > 21000000)
{
if ( global->menu.action_press_time > _21_SECONDS)
step = setting->step*1000000.0f ;
} else if ( global->menu.action_press_time > 18000000)
{
else if ( global->menu.action_press_time > _18_SECONDS)
step = setting->step*100000.0f ;
else if ( global->menu.action_press_time > _15_SECONDS)
step = setting->step*10000.0f ;
} else if ( global->menu.action_press_time > 15000000)
{
else if ( global->menu.action_press_time > _12_SECONDS)
step = setting->step*1000.0f ;
} else if ( global->menu.action_press_time > 12000000)
{
step = setting->step*100.0f ;
} else if ( global->menu.action_press_time > 9000000)
{
else if ( global->menu.action_press_time > _9_SECONDS)
step = setting->step*100.0f ;
} else if ( global->menu.action_press_time > 6000000)
{
else if ( global->menu.action_press_time > _6_SECONDS)
step = setting->step*10.0f ;
} else if ( global->menu.action_press_time > 3000000)
{
else if ( global->menu.action_press_time > _3_SECONDS)
step = setting->step*5.0f ;
} else
{
else
step = setting->step ;
}
}
}
#endif
Expand Down

0 comments on commit 3c0a8c0

Please sign in to comment.