Skip to content

Commit

Permalink
Update to YC Key Compare (MiSTer-devel#836)
Browse files Browse the repository at this point in the history
- Add an expanded key option to include core pixel freq in key E.g. Corename_FPS_Fpix=PhaseInc
- Fixes issue with matching YC key when Saturn core changes from low res to high res mode, as the FPS remains the same when the pixel clocks change (E.g. 6.71Mhz vs 7.16Mhz)
- Tested with existing yc.txt list as well as new Saturn keys for yc.txt
  • Loading branch information
MikeS11 authored Oct 13, 2023
1 parent 9685215 commit 222d617
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2741,6 +2741,9 @@ static void set_yc_mode()
int pal = fps < 55.f;
double CLK_REF = (pal || (cfg.ntsc_mode == 1)) ? 4.43361875f : (cfg.ntsc_mode == 2) ? 3.575611f : 3.579545f;
double CLK_VIDEO = current_video_info.ctime * 100.f / current_video_info.ptime;

float prate = current_video_info.width * 100.f;
prate /= current_video_info.ptime;

int64_t PHASE_INC = ((int64_t)((CLK_REF / CLK_VIDEO) * 1099511627776LL)) & 0xFFFFFFFFFFLL;

Expand All @@ -2749,12 +2752,14 @@ static void set_yc_mode()
int COLORBURST_RANGE = (COLORBURST_START << 10) | COLORBURST_END;

char yc_key[64];
char yc_key_expand[64];
sprintf(yc_key, "%s_%.1f%s%s", user_io_get_core_name(1), fps, current_video_info.interlaced ? "i" : "", (pal || !cfg.ntsc_mode) ? "" : (cfg.ntsc_mode == 1) ? "s" : "m");
snprintf(yc_key_expand, sizeof(yc_key_expand), "%s_%.2f", yc_key, prate);
printf("Calculated YC parameters for '%s': %s PHASE_INC=%lld, COLORBURST_START=%d, COLORBURST_END=%d\n", yc_key, pal ? "PAL" : (cfg.ntsc_mode == 1) ? "PAL60" : (cfg.ntsc_mode == 2) ? "PAL-M" : "NTSC", PHASE_INC, COLORBURST_START, COLORBURST_END);

for (uint i = 0; i < sizeof(yc_modes) / sizeof(yc_modes[0]); i++)
{
if (!strcasecmp(yc_modes[i].key, yc_key))
if (!strcasecmp(yc_modes[i].key, yc_key) || !strcasecmp(yc_modes[i].key, yc_key_expand))
{
printf("Override YC PHASE_INC with value: %lld\n", yc_modes[i].phase_inc);
PHASE_INC = yc_modes[i].phase_inc;
Expand Down

0 comments on commit 222d617

Please sign in to comment.