Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frame presentation modes (#953, #1167, #1197, #1228, #1363, #1159) #1596

Merged
merged 9 commits into from Mar 30, 2022
3 changes: 0 additions & 3 deletions include/render.h
Expand Up @@ -93,7 +93,6 @@ struct Render_t {
bool active = false;
bool aspect = true;
bool fullFrame = true;
bool forceUpdate = false;
};

extern Render_t render;
Expand All @@ -108,7 +107,5 @@ void RENDER_SetSize(uint32_t width,
bool RENDER_StartUpdate(void);
void RENDER_EndUpdate(bool abort);
void RENDER_SetPal(Bit8u entry,Bit8u red,Bit8u green,Bit8u blue);
bool RENDER_GetForceUpdate(void);
void RENDER_SetForceUpdate(bool);

#endif
30 changes: 27 additions & 3 deletions include/vga.h
Expand Up @@ -59,10 +59,22 @@ enum VGAModes {
M_ERROR = 1 << 31,
};

constexpr auto M_TEXT_MODES = M_TEXT | M_HERC_TEXT | M_TANDY_TEXT | M_CGA_TEXT_COMPOSITE;

constexpr uint16_t EGA_HALF_CLOCK = 1 << 0;
constexpr uint16_t EGA_LINE_DOUBLE = 1 << 1;
constexpr uint16_t VGA_PIXEL_DOUBLE = 1 << 2;

// Refresh rate constants
constexpr auto REFRESH_RATE_MIN = 23;
constexpr auto REFRESH_RATE_DOS_DOUBLED_MAX = 35;
constexpr auto REFRESH_RATE_HOST_VRR_LFC = 48;
constexpr auto REFRESH_RATE_HOST_TV_MAX = 50;
constexpr auto REFRESH_RATE_HOST_DEFAULT = 60;
constexpr auto REFRESH_RATE_DOS_DEFAULT = 70;
constexpr auto REFRESH_RATE_HOST_VRR_MIN = 75;
constexpr auto REFRESH_RATE_MAX = 1000;

#define CLK_25 25175
#define CLK_28 28322

Expand Down Expand Up @@ -135,6 +147,8 @@ struct VGA_Config {

enum Drawmode { PART, DRAWLINE, EGALINE };

enum class VGA_RATE_MODE { DEFAULT, HOST, CUSTOM };

struct VGA_Draw {
bool resizing = false;
Bitu width = 0;
Expand Down Expand Up @@ -167,8 +181,12 @@ struct VGA_Draw {
double vdend = 0, vtotal = 0;
double hdend = 0, htotal = 0;
double parts = 0;
} delay;
} delay = {};
Bitu bpp = 0;
double host_refresh_hz = REFRESH_RATE_HOST_DEFAULT;
double dos_refresh_hz = REFRESH_RATE_DOS_DEFAULT;
double custom_refresh_hz = REFRESH_RATE_DOS_DEFAULT;
VGA_RATE_MODE dos_rate_mode = VGA_RATE_MODE::DEFAULT;
double aspect_ratio = 0;
bool double_scan = false;
bool doublewidth = false;
Expand All @@ -185,8 +203,8 @@ struct VGA_Draw {
Bit8u count = 0;
uint8_t delay = 0;
Bit8u enabled = 0;
} cursor;
Drawmode mode;
} cursor = {};
Drawmode mode = {};
bool vret_triggered = false;
};

Expand Down Expand Up @@ -489,6 +507,12 @@ void VGA_AddCompositeSettings(Config &conf);
/* Some Support Functions */
std::pair<const char *, const char *> VGA_DescribeType(VGAModes type);
void VGA_SetClock(Bitu which, uint32_t target);

// Save, get, and limit refresh and clock functions
void VGA_SetHostRate(const double refresh_hz);
void VGA_SetRatePreference(const std::string &pref);
double VGA_GetPreferredRate();

void VGA_DACSetEntirePalette(void);
void VGA_StartRetrace(void);
void VGA_StartUpdateLFB(void);
Expand Down
1 change: 0 additions & 1 deletion include/video.h
Expand Up @@ -57,7 +57,6 @@ typedef void (*GFX_CallBack_t)( GFX_CallBackFunctions_t function );
bool GFX_Events();

Bitu GFX_GetBestMode(Bitu flags);
int GFX_GetDisplayRefreshRate();
Bitu GFX_GetRGB(Bit8u red,Bit8u green,Bit8u blue);
void GFX_SetShader(const char* src);
Bitu GFX_SetSize(int width, int height, Bitu flags,
Expand Down
10 changes: 10 additions & 0 deletions src/dosbox.cpp
Expand Up @@ -401,6 +401,8 @@ static void DOSBOX_RealInit(Section * sec) {
else
int10.vesa_mode_preference = VESA_MODE_PREF::COMPATIBLE;

VGA_SetRatePreference(section->Get_string("dos_rate"));

CPU_AllowSpeedMods = section->Get_bool("speed_mods");
LOG_MSG("SYSTEM: Speed modifications are %s",
CPU_AllowSpeedMods ? "enabled" : "disabled");
Expand Down Expand Up @@ -478,6 +480,14 @@ void DOSBOX_Init() {
pstring->Set_help(
"Video memory in MiB (1-8) or KiB (256 to 8192). 'auto' uses the default per video adapter.");

pstring = secprop->Add_string("dos_rate", when_idle, "default");
pstring->Set_help(
"Customize the emulated video mode's frame rate, in Hz:\n"
"default: The DOS video mode determines the rate (recommended).\n"
"host: Match the DOS rate to the host rate (see 'host_rate' setting).\n"
"<value>: Sets the rate to an exact value, between 24.000 and 1000.000 (Hz).\n"
"We recommend the 'default' rate; otherwise test and set on a per-game basis.");

const char *vesa_modes_choices[] = {"compatible", "all", 0};
Pstring = secprop->Add_string("vesa_modes", only_at_start, "compatible");
Pstring->Set_values(vesa_modes_choices);
Expand Down
11 changes: 2 additions & 9 deletions src/gui/render.cpp
Expand Up @@ -243,7 +243,8 @@ void RENDER_EndUpdate( bool abort ) {
total += render.frameskip.hadSkip[i];
LOG_MSG( "Skipped frame %d %d", PIC_Ticks, (total * 100) / RENDER_SKIP_CACHE );
#endif
if (RENDER_GetForceUpdate()) GFX_EndUpdate(0);
// If we made it here, then there's nothing new to render.
GFX_EndUpdate(nullptr);
}
render.frameskip.index = (render.frameskip.index + 1) & (RENDER_SKIP_CACHE - 1);
render.updating=false;
Expand Down Expand Up @@ -622,14 +623,6 @@ static void ChangeScaler(bool pressed) {
RENDER_CallBack( GFX_CallBackReset );
} */

bool RENDER_GetForceUpdate(void) {
return render.forceUpdate;
}

void RENDER_SetForceUpdate(bool f) {
render.forceUpdate = f;
}

#if C_OPENGL
static bool RENDER_GetShader(std::string &shader_path, char *old_src)
{
Expand Down