Merge pull request #204 from f21red/sgb

libretro: sgb updates
This commit is contained in:
Lior Halphon 2019-11-03 21:05:19 +02:00 committed by GitHub
commit cfc0215089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 5 deletions

View File

@ -92,6 +92,7 @@ static unsigned emulated_devices = 1;
static bool initialized = false; static bool initialized = false;
static unsigned screen_layout = 0; static unsigned screen_layout = 0;
static unsigned audio_out = 0; static unsigned audio_out = 0;
static unsigned sgb_border = 1;
static bool geometry_updated = false; static bool geometry_updated = false;
static bool link_cable_emulation = false; static bool link_cable_emulation = false;
@ -204,6 +205,7 @@ static const struct retro_variable vars_single[] = {
{ "sameboy_color_correction_mode", "Color correction; off|correct curves|emulate hardware|preserve brightness" }, { "sameboy_color_correction_mode", "Color correction; off|correct curves|emulate hardware|preserve brightness" },
{ "sameboy_high_pass_filter_mode", "High-pass filter; off|accurate|remove dc offset" }, { "sameboy_high_pass_filter_mode", "High-pass filter; off|accurate|remove dc offset" },
{ "sameboy_model", "Emulated model; Auto|Game Boy|Game Boy Color|Game Boy Advance|Super Game Boy|Super Game Boy 2" }, { "sameboy_model", "Emulated model; Auto|Game Boy|Game Boy Color|Game Boy Advance|Super Game Boy|Super Game Boy 2" },
{ "sameboy_border", "Super Game Boy border; enabled|disabled" },
{ NULL } { NULL }
}; };
@ -486,7 +488,7 @@ static void check_variables()
{ {
var.key = "sameboy_color_correction_mode"; var.key = "sameboy_color_correction_mode";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && GB_is_cgb(&gameboy[0])) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{ {
if (strcmp(var.value, "off") == 0) if (strcmp(var.value, "off") == 0)
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_DISABLED); GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_DISABLED);
@ -535,12 +537,22 @@ static void check_variables()
init_for_current_model(0); init_for_current_model(0);
} }
} }
var.key = "sameboy_border";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
sgb_border = 1;
else if (strcmp(var.value, "disabled") == 0)
sgb_border = 0;
}
} }
else else
{ {
var.key = "sameboy_color_correction_mode_1"; var.key = "sameboy_color_correction_mode_1";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && GB_is_cgb(&gameboy[0])) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{ {
if (strcmp(var.value, "off") == 0) if (strcmp(var.value, "off") == 0)
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_DISABLED); GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_DISABLED);
@ -554,7 +566,7 @@ static void check_variables()
var.key = "sameboy_color_correction_mode_2"; var.key = "sameboy_color_correction_mode_2";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && GB_is_cgb(&gameboy[1])) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{ {
if (strcmp(var.value, "off") == 0) if (strcmp(var.value, "off") == 0)
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_DISABLED); GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_DISABLED);
@ -880,8 +892,15 @@ void retro_run(void)
} }
else else
{ {
if (model[0] == MODEL_SGB || model[0] == MODEL_SGB2) if (model[0] == MODEL_SGB || model[0] == MODEL_SGB2) {
video_cb(frame_buf, SGB_VIDEO_WIDTH, SGB_VIDEO_HEIGHT, SGB_VIDEO_WIDTH * sizeof(uint32_t)); if (sgb_border == 1)
video_cb(frame_buf, SGB_VIDEO_WIDTH, SGB_VIDEO_HEIGHT, SGB_VIDEO_WIDTH * sizeof(uint32_t));
else {
int crop = SGB_VIDEO_WIDTH * ((SGB_VIDEO_HEIGHT - VIDEO_HEIGHT) / 2) + ((SGB_VIDEO_WIDTH - VIDEO_WIDTH) / 2);
video_cb(frame_buf + crop, VIDEO_WIDTH, VIDEO_HEIGHT, SGB_VIDEO_WIDTH * sizeof(uint32_t));
}
}
else else
video_cb(frame_buf, VIDEO_WIDTH, VIDEO_HEIGHT, VIDEO_WIDTH * sizeof(uint32_t)); video_cb(frame_buf, VIDEO_WIDTH, VIDEO_HEIGHT, VIDEO_WIDTH * sizeof(uint32_t));
} }