First post, by vanfanel
- Rank
- Newbie
Hi all,
I have been using a customized version of dosbox on both my Pi3 and X86_64 GNU/Linux systems. It's an SDL2 version (thanks to NY00123's work!) that I manually patch to accept a custom screen refresh rate.
This custom refresh rate is needed so fine-scrolling games like SuperFrog, Pinball Dreams, etc... exhibit the same PERFECTLY smooth scroll they do on a real machine.
This is my patch, it's very simple:
diff -rupN dosboxA/include/vga.h dosboxB/include/vga.h
--- dosboxA/include/vga.h 2018-07-22 12:48:06.811331826 +0200
+++ dosboxB/include/vga.h 2018-07-22 13:03:33.170575180 +0200
@@ -407,6 +407,7 @@ typedef struct {
VGA_Changes changes;
#endif
VGA_LFB lfb;
+ double refreshRate;
} VGA_Type;
diff -rupN dosboxA/src/gui/sdlmain.cpp dosboxB/src/gui/sdlmain.cpp
--- dosboxA/src/gui/sdlmain.cpp 2018-07-22 12:48:29.932580021 +0200
+++ dosboxB/src/gui/sdlmain.cpp 2018-07-22 13:02:40.413114180 +0200
@@ -1881,6 +1881,8 @@ static void GUI_StartUp(Section * sec) {
if (sdl.desktop.full.display_res) {
GFX_ObtainDisplayDimensions();
}
+ vga.refreshRate=atof(section->Get_string("refresh"));
+ LOG_MSG("Physical refresh rate %f \n", vga.refreshRate);
#else // !SDL_VERSION_ATLEAST(2,0,0)
@@ -2662,6 +2664,9 @@ void Config_Add_SDL() {
Pbool->Set_help("Sync to Vblank IF supported by the output device and renderer.\n"
"It can reduce screen flickering, but it can also result in a slow DOSBox.");
+ Pstring = sdl_sec->Add_string("refresh",Property::Changeable::Always,"60.0000");
+ Pstring->Set_help("Screen refresh rate.");
+
#ifndef __ANDROID__
Pstring = sdl_sec->Add_string("fullresolution",Property::Changeable::Always,"0x0");
Pstring->Set_help("What resolution to use for fullscreen: original, desktop or a fixed size (e.g. 1024x768).\n"
diff -rupN dosboxA/src/hardware/vga_draw.cpp dosboxB/src/hardware/vga_draw.cpp
--- dosboxA/src/hardware/vga_draw.cpp 2018-07-22 12:48:06.807330793 +0200
+++ dosboxB/src/hardware/vga_draw.cpp 2018-07-22 13:04:49.909575548 +0200
@@ -1200,7 +1200,9 @@ void VGA_SetupDrawing(Bitu /*val*/) {
if (!vtotal) return;
// The screen refresh frequency
- fps=(double)clock/(vtotal*htotal);
+ // fps=(double)clock/(vtotal*htotal);
+ fps=vga.refreshRate;
+ clock=((double)(vtotal*htotal))*fps;
// Horizontal total (that's how long a line takes with whistles and bells)
vga.draw.delay.htotal = htotal*1000.0/clock; //in milliseconds
// Start and End of horizontal blanking
The relevant part is only this:
fps=vga.refreshRate;
clock=((double)(vtotal*htotal))*fps;
Thing is, it was working fine, but with recent DOSBOX SVN code I am getting sound desynchronized once in a while, which is annoying. So, any ideas on what else should I change so the GUS/SB emulation will produce as many samples per second as needed depending on the custom screen refresh rate? (I suspect that's the problem)