standarize core options

This commit is contained in:
radius 2018-02-03 13:59:06 -05:00
parent b74095a2cd
commit a5b182f0fa
1 changed files with 56 additions and 52 deletions

View File

@ -222,10 +222,14 @@ static const struct retro_subsystem_rom_info gb_roms[] = {
}; };
static const struct retro_subsystem_info subsystems[] = { static const struct retro_subsystem_info subsystems[] = {
{ "2 Player Gameboy Link", "gb_link_2p", gb_roms, 2, RETRO_GAME_TYPE_GAMEBOY_LINK_2P | 0x1000 }, { "2 Player Gameboy Link", "gb_link_2p", gb_roms, 2, RETRO_GAME_TYPE_GAMEBOY_LINK_2P },
{ NULL }, { NULL },
}; };
static const struct retro_controller_description controllers[] = {
{ "Nintendo Gameboy", RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0) },
};
static void init_for_current_model(void) static void init_for_current_model(void)
{ {
unsigned i = 0; unsigned i = 0;
@ -363,12 +367,14 @@ static void check_variables(bool link)
new_model = MODEL_CGB; new_model = MODEL_CGB;
else if (strcmp(var.value, "Game Boy Advance") == 0) else if (strcmp(var.value, "Game Boy Advance") == 0)
new_model = MODEL_AGB; new_model = MODEL_AGB;
else if (strcmp(var.value, "Auto") == 0) else
new_model = MODEL_AUTO; new_model = MODEL_AUTO;
if (GB_is_inited(&gameboy[0]) && new_model != model[0]) { if (GB_is_inited(&gameboy[0]) && new_model != model[0]) {
model[0] = new_model; model[0] = new_model;
init_for_current_model(); init_for_current_model();
} }
model[0] = new_model;
} }
} }
else else
@ -436,10 +442,13 @@ static void check_variables(bool link)
new_model = MODEL_CGB; new_model = MODEL_CGB;
else if (strcmp(var.value, "Game Boy Advance") == 0) else if (strcmp(var.value, "Game Boy Advance") == 0)
new_model = MODEL_AGB; new_model = MODEL_AGB;
else
new_model = MODEL_AUTO;
if (GB_is_inited(&gameboy[0]) && new_model != model[0]) { if (GB_is_inited(&gameboy[0]) && new_model != model[0]) {
model[0] = new_model; model[0] = new_model;
init_for_current_model(); init_for_current_model();
} }
model[0] = new_model;
} }
var.key = "sameboy_model_2"; var.key = "sameboy_model_2";
@ -453,10 +462,13 @@ static void check_variables(bool link)
new_model = MODEL_CGB; new_model = MODEL_CGB;
else if (strcmp(var.value, "Game Boy Advance") == 0) else if (strcmp(var.value, "Game Boy Advance") == 0)
new_model = MODEL_AGB; new_model = MODEL_AGB;
else
new_model = MODEL_AUTO;
if (GB_is_inited(&gameboy[1]) && new_model != model[1]) { if (GB_is_inited(&gameboy[1]) && new_model != model[1]) {
model[1] = new_model; model[1] = new_model;
init_for_current_model(); init_for_current_model();
} }
model[1] = new_model;
} }
} }
@ -562,16 +574,6 @@ void retro_set_environment(retro_environment_t cb)
else else
log_cb = fallback_log; log_cb = fallback_log;
static const struct retro_controller_description controllers[] = {
{ "Nintendo Gameboy", RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0) },
};
static const struct retro_controller_info ports[] = {
{ controllers, 1 },
{ controllers, 1 },
{ NULL, 0 },
};
cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
cb(RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO, (void*)subsystems); cb(RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO, (void*)subsystems);
} }
@ -666,9 +668,8 @@ void retro_run(void)
bool retro_load_game(const struct retro_game_info *info) bool retro_load_game(const struct retro_game_info *info)
{ {
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, emulated_devices == 2 ? (void *)vars_link : (void *)vars); environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void *)vars);
check_variables(emulated_devices == 2 ? true : false); check_variables(false);
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, emulated_devices == 2 ? (void *)vars_link : (void *)vars);
frame_buf = (uint32_t*)malloc(emulated_devices * VIDEO_PIXELS * sizeof(uint32_t)); frame_buf = (uint32_t*)malloc(emulated_devices * VIDEO_PIXELS * sizeof(uint32_t));
frame_buf_copy = (uint32_t*)malloc(emulated_devices * VIDEO_PIXELS * sizeof(uint32_t)); frame_buf_copy = (uint32_t*)malloc(emulated_devices * VIDEO_PIXELS * sizeof(uint32_t));
@ -697,9 +698,9 @@ bool retro_load_game(const struct retro_game_info *info)
return false; return false;
} }
auto_model = (info->path[strlen(info->path) - 1] & ~0x20) == 'C' ? MODEL_CGB : MODEL_DMG;
snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path); snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path);
auto_model = (info->path[strlen(info->path) - 1] & ~0x20) == 'C' ? MODEL_CGB : MODEL_DMG;
init_for_current_model(); init_for_current_model();
for (int i = 0; i < emulated_devices; i++) for (int i = 0; i < emulated_devices; i++)
@ -711,25 +712,20 @@ bool retro_load_game(const struct retro_game_info *info)
} }
} }
bool yes = true; bool achievements = true;
environ_cb(RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS, &yes); environ_cb(RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS, &achievements);
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble)) if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble))
log_cb(RETRO_LOG_INFO, "Rumble environment supported.\n"); log_cb(RETRO_LOG_INFO, "Rumble environment supported.\n");
else else
log_cb(RETRO_LOG_INFO, "Rumble environment not supported.\n"); log_cb(RETRO_LOG_INFO, "Rumble environment not supported.\n");
static const struct retro_variable vars[] = { static const struct retro_controller_info ports[] = {
{ "sameboy_color_correction_mode", "Color Correction; off|correct curves|emulate hardware|preserve brightness" }, { controllers, 1 },
{ "sameboy_high_pass_filter_mode", "High Pass Filter; off|accurate|remove dc offset" }, { NULL, 0 },
{ "sameboy_model", "Emulated Model; Auto|Game Boy|Game Boy Color|Game Boy Advance" },
{ "sameboy_link", "Link Cable; disabled|enabled" },
{ "sameboy_link_layout", "Screen Layout; top-down|left-right" },
{ NULL }
}; };
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, emulated_devices == 2 ? (void *)vars_link : (void *)vars); environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
check_variables(emulated_devices == 2 ? true : false);
return true; return true;
} }
@ -746,11 +742,14 @@ unsigned retro_get_region(void)
bool retro_load_game_special(unsigned type, const struct retro_game_info *info, size_t num_info) bool retro_load_game_special(unsigned type, const struct retro_game_info *info, size_t num_info)
{ {
emulated_devices = 2;
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, emulated_devices == 2 ? (void *)vars_link : (void *)vars); if (type == RETRO_GAME_TYPE_GAMEBOY_LINK_2P)
check_variables(emulated_devices == 2 ? true : false); emulated_devices = 2;
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, emulated_devices == 2 ? (void *)vars_link : (void *)vars); else
return false; /* all other types are unhandled for now */
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void *)vars_link);
check_variables(true);
frame_buf = (uint32_t*)malloc(emulated_devices * VIDEO_PIXELS * sizeof(uint32_t)); frame_buf = (uint32_t*)malloc(emulated_devices * VIDEO_PIXELS * sizeof(uint32_t));
frame_buf_copy = (uint32_t*)malloc(emulated_devices * VIDEO_PIXELS * sizeof(uint32_t)); frame_buf_copy = (uint32_t*)malloc(emulated_devices * VIDEO_PIXELS * sizeof(uint32_t));
@ -787,11 +786,12 @@ bool retro_load_game_special(unsigned type, const struct retro_game_info *info,
return false; return false;
} }
auto_model = (info->path[strlen(info->path) - 1] & ~0x20) == 'C' ? MODEL_CGB : MODEL_DMG;
snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path); snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path);
init_for_current_model(); init_for_current_model();
for (int i = 0; i < emulated_devices; i++) for (int i = 0; i < emulated_devices; i++)
{ {
auto_model = (info[i].path[strlen(info[i].path) - 1] & ~0x20) == 'C' ? MODEL_CGB : MODEL_DMG;
if (GB_load_rom(&gameboy[i], info[i].path)) if (GB_load_rom(&gameboy[i], info[i].path))
{ {
log_cb(RETRO_LOG_INFO, "Failed to load ROM\n"); log_cb(RETRO_LOG_INFO, "Failed to load ROM\n");
@ -799,17 +799,21 @@ bool retro_load_game_special(unsigned type, const struct retro_game_info *info,
} }
} }
bool achievements = true;
bool yes = true; environ_cb(RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS, &achievements);
environ_cb(RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS, &yes);
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble)) if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble))
log_cb(RETRO_LOG_INFO, "Rumble environment supported.\n"); log_cb(RETRO_LOG_INFO, "Rumble environment supported.\n");
else else
log_cb(RETRO_LOG_INFO, "Rumble environment not supported.\n"); log_cb(RETRO_LOG_INFO, "Rumble environment not supported.\n");
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, emulated_devices == 2 ? (void *)vars_link : (void *)vars); static const struct retro_controller_info ports[] = {
check_variables(emulated_devices == 2 ? true : false); { controllers, 1 },
{ NULL, 0 },
};
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
return true; return true;
} }