Skip to content

Commit

Permalink
Add Force VDP Mode option & update option description (ekeeke#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
ds22x authored Jul 20, 2024
1 parent f9f16d7 commit 2fd1885
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
81 changes: 81 additions & 0 deletions libretro/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,87 @@ static void check_variables(bool first_run)
}
}

var.key = "genesis_plus_gx_vdp_mode";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
orig_value = config.vdp_mode;
if (var.value && !strcmp(var.value, "60hz"))
config.vdp_mode = 1;
else if (var.value && !strcmp(var.value, "50hz"))
config.vdp_mode = 2;
else
config.vdp_mode = 0;

if (orig_value != config.vdp_mode)
{
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;
}

update_frameskip = true;
}
}
}

var.key = "genesis_plus_gx_force_dtack";
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
{
Expand Down
15 changes: 15 additions & 0 deletions libretro/libretro_core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ struct retro_core_option_v2_definition option_defs_us[] = {
},
"auto"
},
{
"genesis_plus_gx_vdp_mode",
"Force VDP Mode",
NULL,
"Overrides the VDP mode to force it to run at either NTSC 60Hz or PAL 50Hz, regardless of system region.",
NULL,
"system",
{
{ "auto", "Disabled" },
{ "60hz", "NTSC (60Hz)" },
{ "50hz", "PAL (50Hz)" },
{ NULL, NULL },
},
"auto"
},
{
"genesis_plus_gx_bios",
"System Boot ROM",
Expand Down

0 comments on commit 2fd1885

Please sign in to comment.