Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkcgen <1557255+kcgen@users.noreply.github.com>2020-08-10 04:47:40 +0300
committerkcgen <kcgen@users.noreply.github.com>2022-11-04 06:12:49 +0300
commitb5d657dd4bf174a8fb18c627dae912afa39bab92 (patch)
tree4ae8a9e016b02154d195f3349d943c27dcff43e1
parent37dd4387d0f86338164efc5e363545c063070dc2 (diff)
[WIP] Minimized fixed cycle scheduler
-rw-r--r--src/dosbox.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/dosbox.cpp b/src/dosbox.cpp
index a4c1a5165..688609a71 100644
--- a/src/dosbox.cpp
+++ b/src/dosbox.cpp
@@ -222,23 +222,41 @@ static Bitu Normal_Loop()
void increaseticks_fixed()
{
- auto ticksNew = GetTicks();
+ const auto ticksNew = GetTicks();
if (ticksNew <= ticksLast) {
- ticksAdded = 0;
while (pic_balance < 1)
std::this_thread::sleep_for(usT(50));
std::lock_guard<std::mutex> guard(pic_balance_mutex);
- pic_balance--;
-
- auto timeslept = GetTicks() - ticksNew;
- return; //0
+ pic_balance = 0;
+ return;
}
- ticksRemain = ticksNew-ticksLast;
+ constexpr long int max_ticks_remaing = 20;
+ ticksRemain = std::min(max_ticks_remaing, ticksNew - ticksLast);
ticksLast = ticksNew;
+ /* if (ticksRemain > 20)
+ ticksRemain = 20; */
}
-//For trying other delays
+
+/* uint32_t t_remain = 0;
+uint32_t t_last = 0;
+
+void increaseticks_fixed()
+{
+ const uint32_t t_new = GetTicks();
+ if (t_new <= t_last) {
+ while (pic_balance < 1)
+ std::this_thread::sleep_for(usT(50));
+ std::lock_guard<std::mutex> guard(pic_balance_mutex);
+ pic_balance = 0;
+ return;
+ }
+ t_remain = std::min(20u, t_new - t_last);
+ t_last = t_new;
+} */
+
+// For trying other delays
#define wrap_delay(a) SDL_Delay(a)
void increaseticks() { //Make it return ticksRemain and set it in the function above to remove the global variable.