refactored option overrides
This commit is contained in:
parent
343fc0247b
commit
7cd9379734
1 changed files with 30 additions and 30 deletions
|
|
@ -287,6 +287,20 @@ static void State_resume(void) {
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
|
typedef struct OptionOverride {
|
||||||
|
char* core;
|
||||||
|
char* key;
|
||||||
|
char* value;
|
||||||
|
} OptionOverride;
|
||||||
|
|
||||||
|
static OptionOverride option_overrides[] = {
|
||||||
|
{"gpsp", "gpsp_save_method", "libretro"},
|
||||||
|
{"gambatte", "gambatte_gb_colorization", "internal"},
|
||||||
|
{"gambatte", "gambatte_gb_internal_palette", "TWB64 - Pack 1"},
|
||||||
|
{"gambatte", "gambatte_gb_palette_twb64_1", "TWB64 038 - Pokemon mini Ver."},
|
||||||
|
{NULL,NULL,NULL},
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct Option {
|
typedef struct Option {
|
||||||
char* key;
|
char* key;
|
||||||
char* name; // desc
|
char* name; // desc
|
||||||
|
|
@ -299,22 +313,9 @@ typedef struct Option {
|
||||||
char** labels;
|
char** labels;
|
||||||
} Option;
|
} Option;
|
||||||
|
|
||||||
typedef struct Override {
|
|
||||||
char* core;
|
|
||||||
char* key;
|
|
||||||
char* value;
|
|
||||||
} Override;
|
|
||||||
|
|
||||||
static Override overrides[] = {
|
|
||||||
{"gpsp", "gpsp_save_method", "libretro"},
|
|
||||||
{"gambatte", "gambatte_gb_colorization", "internal"},
|
|
||||||
{"gambatte", "gambatte_gb_internal_palette", "TWB64 - Pack 1"},
|
|
||||||
{"gambatte", "gambatte_gb_palette_twb64_1", "TWB64 038 - Pokemon mini Ver."},
|
|
||||||
{NULL,NULL,NULL},
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
int count;
|
int count;
|
||||||
|
int changed;
|
||||||
Option* items;
|
Option* items;
|
||||||
} options;
|
} options;
|
||||||
|
|
||||||
|
|
@ -381,9 +382,10 @@ static void Options_init(const struct retro_core_option_definition *defs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* default_value = def->default_value;
|
const char* default_value = def->default_value;
|
||||||
for (int k=0; overrides[k].core; k++) {
|
for (int k=0; option_overrides[k].core; k++) {
|
||||||
if (!strcmp(overrides[k].key, item->key)) {
|
OptionOverride* override = &option_overrides[k];
|
||||||
default_value = overrides[k].value;
|
if (!strcmp(override->key, item->key)) {
|
||||||
|
default_value = override->value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -446,9 +448,10 @@ static void Options_vars(const struct retro_variable *vars) {
|
||||||
|
|
||||||
// no native default_value support for retro vars
|
// no native default_value support for retro vars
|
||||||
const char* default_value = NULL;
|
const char* default_value = NULL;
|
||||||
for (int k=0; overrides[k].core; k++) {
|
for (int k=0; option_overrides[k].core; k++) {
|
||||||
if (!strcmp(overrides[k].key, item->key)) {
|
OptionOverride* override = &option_overrides[k];
|
||||||
default_value = overrides[k].value;
|
if (!strcmp(override->key, item->key)) {
|
||||||
|
default_value = override->value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -499,12 +502,15 @@ static char* Options_getOptionValue(const char* key) {
|
||||||
// printf("GET %s (%i)\n", item->key, item->value); fflush(stdout);
|
// printf("GET %s (%i)\n", item->key, item->value); fflush(stdout);
|
||||||
return item->values[item->value];
|
return item->values[item->value];
|
||||||
}
|
}
|
||||||
else printf("unknown option %s \n", key); fflush(stdout);
|
else LOG_warn("unknown option %s \n", key);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static void Options_setOption(const char* key, const char* value) {
|
static void Options_setOption(const char* key, const char* value) {
|
||||||
Option* item = Options_getOption(key);
|
Option* item = Options_getOption(key);
|
||||||
if (item) Option_setValue(item, value);
|
if (item) {
|
||||||
|
Option_setValue(item, value);
|
||||||
|
options.changed = 1;
|
||||||
|
}
|
||||||
else printf("unknown option %s \n", key); fflush(stdout);
|
else printf("unknown option %s \n", key); fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -512,11 +518,6 @@ static void Options_setOption(const char* key, const char* value) {
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
// TODO: tmp, naive options
|
// TODO: tmp, naive options
|
||||||
static int tmp_options_changed = 0;
|
|
||||||
static struct {
|
|
||||||
char key[128];
|
|
||||||
char value[128];
|
|
||||||
} tmp_options[128];
|
|
||||||
static bool set_rumble_state(unsigned port, enum retro_rumble_effect effect, uint16_t strength) {
|
static bool set_rumble_state(unsigned port, enum retro_rumble_effect effect, uint16_t strength) {
|
||||||
// TODO: handle other args? not sure I can
|
// TODO: handle other args? not sure I can
|
||||||
POW_setRumble(strength);
|
POW_setRumble(strength);
|
||||||
|
|
@ -610,8 +611,8 @@ static bool environment_callback(unsigned cmd, void *data) { // copied from pico
|
||||||
case RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE: { /* 17 */
|
case RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE: { /* 17 */
|
||||||
bool *out = (bool *)data;
|
bool *out = (bool *)data;
|
||||||
if (out) {
|
if (out) {
|
||||||
*out = tmp_options_changed; // options_changed();
|
*out = options.changed; // options_changed();
|
||||||
tmp_options_changed = 0;
|
options.changed = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -733,7 +734,6 @@ static bool environment_callback(unsigned cmd, void *data) { // copied from pico
|
||||||
const struct retro_variable *var = (const struct retro_variable *)data;
|
const struct retro_variable *var = (const struct retro_variable *)data;
|
||||||
if (var && var->key) {
|
if (var && var->key) {
|
||||||
Options_setOption(var->key, var->value);
|
Options_setOption(var->key, var->value);
|
||||||
tmp_options_changed = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue