in cores/genesis/libretro/libretro.c [797:1230]
static void check_variables(void)
{
unsigned orig_value;
struct retro_system_av_info info;
bool update_viewports = false;
bool reinit = false;
struct retro_variable var = {0};
var.key = "genesis_plus_gx_bram";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
#if defined(_WIN32)
char slash = '\\';
#else
char slash = '/';
#endif
if (!strcmp(var.value, "per bios"))
{
snprintf(CD_BRAM_EU, sizeof(CD_BRAM_EU), "%s%cscd_E.brm", save_dir, slash);
snprintf(CD_BRAM_US, sizeof(CD_BRAM_US), "%s%cscd_U.brm", save_dir, slash);
snprintf(CD_BRAM_JP, sizeof(CD_BRAM_JP), "%s%cscd_J.brm", save_dir, slash);
}
else
{
snprintf(CD_BRAM_EU, sizeof(CD_BRAM_EU), "%s%c%s.brm", save_dir, slash, g_rom_name);
snprintf(CD_BRAM_US, sizeof(CD_BRAM_US), "%s%c%s.brm", save_dir, slash, g_rom_name);
snprintf(CD_BRAM_JP, sizeof(CD_BRAM_JP), "%s%c%s.brm", save_dir, slash, g_rom_name);
}
}
var.key = "genesis_plus_gx_system_hw";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.system;
if (!strcmp(var.value, "sg-1000"))
config.system = SYSTEM_SG;
else if (!strcmp(var.value, "sg-1000 II"))
config.system = SYSTEM_SGII;
else if (!strcmp(var.value, "mark-III"))
config.system = SYSTEM_MARKIII;
else if (!strcmp(var.value, "master system"))
config.system = SYSTEM_SMS;
else if (!strcmp(var.value, "master system II"))
config.system = SYSTEM_SMS2;
else if (!strcmp(var.value, "game gear"))
config.system = SYSTEM_GG;
else if (!strcmp(var.value, "mega drive / genesis"))
config.system = SYSTEM_MD;
else
config.system = 0;
if (orig_value != config.system)
{
if (system_hw)
{
switch (config.system)
{
case 0:
system_hw = romtype; /* AUTO */
break;
case SYSTEM_MD:
system_hw = (romtype & SYSTEM_MD) ? romtype : SYSTEM_PBC;
break;
case SYSTEM_GG:
system_hw = (romtype == SYSTEM_GG) ? SYSTEM_GG : SYSTEM_GGMS;
break;
default:
system_hw = config.system;
break;
}
reinit = true;
}
}
}
var.key = "genesis_plus_gx_bios";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.bios;
if (!strcmp(var.value, "enabled"))
config.bios = 3;
else
config.bios = 0;
if (orig_value != config.bios)
{
if (system_hw)
{
reinit = true;
}
}
}
var.key = "genesis_plus_gx_region_detect";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.region_detect;
if (!strcmp(var.value, "ntsc-u"))
config.region_detect = 1;
else if (!strcmp(var.value, "pal"))
config.region_detect = 2;
else if (!strcmp(var.value, "ntsc-j"))
config.region_detect = 3;
else
config.region_detect = 0;
if (orig_value != config.region_detect)
{
if (system_hw)
{
get_region(NULL);
if ((system_hw == SYSTEM_MCD) || ((system_hw & SYSTEM_SMS) && config.bios))
{
/* system with region BIOS should be reinitialized */
reinit = true;
}
else
{
static const uint16 vc_table[4][2] =
{
/* NTSC, PAL */
{0xDA , 0xF2}, /* Mode 4 (192 lines) */
{0xEA , 0x102}, /* Mode 5 (224 lines) */
{0xDA , 0xF2}, /* Mode 4 (192 lines) */
{0x106, 0x10A} /* Mode 5 (240 lines) */
};
/* framerate might have changed, reinitialize audio timings */
audio_set_rate(44100, 0);
/* reinitialize I/O region register */
if (system_hw == SYSTEM_MD)
{
io_reg[0x00] = 0x20 | region_code | (config.bios & 1);
}
else if (system_hw == SYSTEM_MCD)
{
io_reg[0x00] = region_code | (config.bios & 1);
}
else
{
io_reg[0x00] = 0x80 | (region_code >> 1);
}
/* reinitialize VDP timings */
lines_per_frame = vdp_pal ? 313 : 262;
/* reinitialize NTSC/PAL mode in VDP status */
if (system_hw & SYSTEM_MD)
{
status = (status & ~1) | vdp_pal;
}
/* reinitialize VC max value */
switch (bitmap.viewport.h)
{
case 192:
vc_max = vc_table[0][vdp_pal];
break;
case 224:
vc_max = vc_table[1][vdp_pal];
break;
case 240:
vc_max = vc_table[3][vdp_pal];
break;
}
update_viewports = true;
}
}
}
}
var.key = "genesis_plus_gx_force_dtack";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
if (!strcmp(var.value, "enabled"))
config.force_dtack = 1;
else
config.force_dtack = 0;
}
var.key = "genesis_plus_gx_addr_error";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
if (!strcmp(var.value, "enabled"))
m68k.aerr_enabled = config.addr_error = 1;
else
m68k.aerr_enabled = config.addr_error = 0;
}
var.key = "genesis_plus_gx_lock_on";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.lock_on;
if (!strcmp(var.value, "game genie"))
config.lock_on = TYPE_GG;
else if (!strcmp(var.value, "action replay (pro)"))
config.lock_on = TYPE_AR;
else if (!strcmp(var.value, "sonic & knuckles"))
config.lock_on = TYPE_SK;
else
config.lock_on = 0;
if (orig_value != config.lock_on)
{
if (system_hw == SYSTEM_MD)
reinit = true;
}
}
var.key = "genesis_plus_gx_ym2413";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.ym2413;
if (!strcmp(var.value, "enabled"))
config.ym2413 = 1;
else if (!strcmp(var.value, "disabled"))
config.ym2413 = 0;
else
config.ym2413 = 2;
if (orig_value != config.ym2413)
{
if (system_hw && (config.ym2413 & 2) && ((system_hw & SYSTEM_PBC) != SYSTEM_MD))
{
memcpy(temp, sram.sram, sizeof(temp));
sms_cart_init();
memcpy(sram.sram, temp, sizeof(temp));
}
}
}
var.key = "genesis_plus_gx_audio_filter";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
if (!strcmp(var.value, "Lowpass"))
config.filter = 1;
#if HAVE_EQ
else if (!strcmp(var.value, "EQ"))
config.filter = 2;
#endif
else
config.filter = 0;
}
var.key = "genesis_plus_gx_lowpass_range";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
config.lp_range = (atoi(var.value) * 65536) / 100;
}
#if HAVE_EQ
var.key = "genesis_plus_gx_audio_eq_low";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
uint8_t new_lg = atoi(var.value);
if (new_lg != config.lg) restart_eq = true;
config.lg = new_lg;
}
var.key = "genesis_plus_gx_audio_eq_mid";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
uint8_t new_mg = atoi(var.value);
if (new_mg != config.mg) restart_eq = true;
config.mg = new_mg;
}
var.key = "genesis_plus_gx_audio_eq_high";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
uint8_t new_hg = atoi(var.value);
if (new_hg != config.hg) restart_eq = true;
config.hg = new_hg;
}
#endif
var.key = "genesis_plus_gx_dac_bits";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
if (!strcmp(var.value, "enabled"))
config.dac_bits = 9;
else
config.dac_bits = 14;
YM2612Config(config.dac_bits);
}
var.key = "genesis_plus_gx_blargg_ntsc_filter";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.ntsc;
if (strcmp(var.value, "disabled") == 0)
config.ntsc = 0;
else if (strcmp(var.value, "monochrome") == 0)
{
config.ntsc = 1;
sms_ntsc_init(sms_ntsc, &sms_ntsc_monochrome);
md_ntsc_init(md_ntsc, &md_ntsc_monochrome);
}
else if (strcmp(var.value, "composite") == 0)
{
config.ntsc = 1;
sms_ntsc_init(sms_ntsc, &sms_ntsc_composite);
md_ntsc_init(md_ntsc, &md_ntsc_composite);
}
else if (strcmp(var.value, "svideo") == 0)
{
config.ntsc = 1;
sms_ntsc_init(sms_ntsc, &sms_ntsc_svideo);
md_ntsc_init(md_ntsc, &md_ntsc_svideo);
}
else if (strcmp(var.value, "rgb") == 0)
{
config.ntsc = 1;
sms_ntsc_init(sms_ntsc, &sms_ntsc_rgb);
md_ntsc_init(md_ntsc, &md_ntsc_rgb);
}
if (orig_value != config.ntsc)
update_viewports = true;
}
var.key = "genesis_plus_gx_lcd_filter";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
if (strcmp(var.value, "disabled") == 0)
config.lcd = 0;
else if (strcmp(var.value, "enabled") == 0)
config.lcd = (uint8)(0.80 * 256);
}
var.key = "genesis_plus_gx_overscan";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.overscan;
if (strcmp(var.value, "disabled") == 0)
config.overscan = 0;
else if (strcmp(var.value, "top/bottom") == 0)
config.overscan = 1;
else if (strcmp(var.value, "left/right") == 0)
config.overscan = 2;
else if (strcmp(var.value, "full") == 0)
config.overscan = 3;
if (orig_value != config.overscan)
update_viewports = true;
}
var.key = "genesis_plus_gx_gg_extra";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.gg_extra;
if (strcmp(var.value, "disabled") == 0)
config.gg_extra = 0;
else if (strcmp(var.value, "enabled") == 0)
config.gg_extra = 1;
if (orig_value != config.gg_extra)
update_viewports = true;
}
var.key = "genesis_plus_gx_aspect_ratio";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.aspect_ratio;
if (strcmp(var.value, "NTSC PAR") == 0)
config.aspect_ratio = 1;
else if (strcmp(var.value, "PAL PAR") == 0)
config.aspect_ratio = 2;
else
config.aspect_ratio = 0;
if (orig_value != config.aspect_ratio)
update_viewports = true;
}
var.key = "genesis_plus_gx_render";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.render;
if (strcmp(var.value, "single field") == 0)
config.render = 0;
else
config.render = 1;
if (orig_value != config.render)
update_viewports = true;
}
var.key = "genesis_plus_gx_gun_cursor";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
if (strcmp(var.value, "disabled") == 0)
config.gun_cursor = 0;
else
config.gun_cursor = 1;
}
var.key = "genesis_plus_gx_invert_mouse";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
if (strcmp(var.value, "disabled") == 0)
config.invert_mouse = 0;
else
config.invert_mouse = 1;
}
if (reinit)
{
audio_init(SOUND_FREQUENCY, 0);
memcpy(temp, sram.sram, sizeof(temp));
system_init();
system_reset();
memcpy(sram.sram, temp, sizeof(temp));
update_viewports = true;
}
if (update_viewports)
{
bitmap.viewport.changed = 11;
if ((system_hw == SYSTEM_GG) && !config.gg_extra)
bitmap.viewport.x = (config.overscan & 2) ? 14 : -48;
else
bitmap.viewport.x = (config.overscan & 2) * 7;
}
}