Skip to content

Instantly share code, notes, and snippets.

@greg-kennedy
Last active September 6, 2019 17:33
Show Gist options
  • Save greg-kennedy/a44c47d9e04fd4977d1505a1a121cd4b to your computer and use it in GitHub Desktop.
Save greg-kennedy/a44c47d9e04fd4977d1505a1a121cd4b to your computer and use it in GitHub Desktop.
DOSBox 0.74-3 Demo Record hack
--- dosbox-0.74-3/src/gui/sdlmain.cpp 2019-06-26 09:56:44.000000000 -0500
+++ dosbox-0.74-3-dev/src/gui/sdlmain.cpp 2019-09-06 12:05:17.963048000 -0500
@@ -284,6 +284,12 @@
bool startup_state_numlock=false;
bool startup_state_capslock=false;
+#ifdef C_SSHOT
+// demo recording hack
+int demostart = 0;
+int demoend = 0;
+#endif
+
void GFX_SetTitle(Bit32s cycles,Bits frameskip,bool paused){
char title[200]={0};
static Bit32s internal_cycles=0;
@@ -1098,6 +1104,11 @@
sdl.desktop.fullscreen=section->Get_bool("fullscreen");
sdl.wait_on_error=section->Get_bool("waitonerror");
+#ifdef C_SSHOT
+ demostart = section->Get_int("demostart");
+ demoend = section->Get_int("demoend");
+#endif
+
Prop_multival* p=section->Get_multival("priority");
std::string focus = p->GetSection()->Get_string("active");
std::string notfocus = p->GetSection()->Get_string("inactive");
@@ -1451,6 +1462,26 @@
last_check = current_check;
#endif
+#ifdef C_SSHOT
+ // hack for demo timing
+ if (demostart || demoend) {
+ int demotime = GetTicks();
+ if (demostart && (demostart < demotime)) {
+ LOG_MSG("demostart time %u reached, recording",demostart);
+
+ void CAPTURE_VideoEvent(bool pressed);
+ CAPTURE_VideoEvent(true);
+
+ demostart = 0;
+ }
+ if (demoend && (demoend < demotime)) {
+ LOG_MSG("demoend time %u reached, quitting",demoend);
+
+ throw(0);
+ }
+ }
+#endif
+
SDL_Event event;
#if defined (REDUCE_JOYSTICK_POLLING)
static int poll_delay = 0;
@@ -1676,6 +1707,13 @@
Pbool = sdl_sec->Add_bool("waitonerror",Property::Changeable::Always, true);
Pbool->Set_help("Wait before closing the console if dosbox has an error.");
+
+#ifdef C_SSHOT
+ Pint = sdl_sec->Add_int("demostart",Property::Changeable::OnlyAtStart,0);
+ Pint->Set_help("Time delay before recording demo, milliseconds (0 disables)");
+ Pint = sdl_sec->Add_int("demoend",Property::Changeable::OnlyAtStart,0);
+ Pint->Set_help("Time delay before exiting program, milliseconds (0 disables)");
+#endif
Pmulti = sdl_sec->Add_multi("priority", Property::Changeable::Always, ",");
Pmulti->SetValue("higher,normal");
--- dosbox-0.74-3/src/hardware/hardware.cpp 2019-05-02 12:01:18.000000000 -0500
+++ dosbox-0.74-3-dev/src/hardware/hardware.cpp 2019-09-06 12:27:28.805591000 -0500
@@ -161,7 +161,7 @@
#endif
#if (C_SSHOT)
-static void CAPTURE_VideoEvent(bool pressed) {
+void CAPTURE_VideoEvent(bool pressed) {
if (!pressed)
return;
if (CaptureState & CAPTURE_VIDEO) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment