VOGONS


First post, by jokkebk

User metadata
Rank Newbie
Rank
Newbie

BACKGROUND: I've been using DOSBox for playing back oldskool PC demos. VBE 2.0 support in the version 0.65 finally made me able to play back some newer ones, which is totally awesome. I would like to capture some demos of mine into video format and burn to DVD to be able to watch them later with minimum hassle. Unfortunately, my machine isn't quite up to the task, as FPS tends to fall between 4 and 10.

CHALLENGE: What I would like to do is to "slow down" DOSBox emulation, so it would use for example 4 seconds of real processor time to perform actions happening in 1 second of emulated processor time. That way there would be 4 times as much cycles available for the demo (which wouldn't know it is being run in slow motion), and I could for example capture a 3-minute demo in 12 minutes, and later speed up the resulting video by 4x to get a decent fluidity of motion. I would think there are two possibilities:

1) Replace SDL function calls in DOSBox used for accessing real hardware to provide a "slowed down time" for DOSBox in the first place. For example, if SDL timer would proceed half as quickly as normally, DOSBox would have twice as much time for its chores. Of course, audio and video routines might need similar tweaking

2) Change the DOSBox "inner loop" to do this slowing down based on the value of some control variable - in addition to frameskip and cycle count, we would have "time scaling factor". This would probably have its uses outside of demo recording.

QUESTION: I would be willing to figure out how the actual changes need to be done to the source code and I could submit a patch once I get it working. But I would really appreciate if someone who understands how DOSBox is structured could point me into right direction. So what do you think, what would be the best way to introduce such a feature? I won't even mind if audio doesn't work, as it can be recorded separately (and I have the original soundtracks as module files).

Thanks!

Reply 1 of 5, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

As a first test you should blindly replace all occurences of SDL_GetTicks()
with (SDL_GetTicks()/4). This should have the effect of the emulated time
(especially the pic/timer scheduling) being slower than the real time.

To get everything synchronized, you'd have to slow down the other time
related functions that use the system clock (rather than SDL_GetTicks()
or and derived timing like the dosbox ticks).
Have a look at the later postings at
CMOS clock patch (dates not changing when left overnight)
to get an idea of where dosbox interfaces with the system clock.

Hope that gets you somewhere, good luck 😀

Reply 2 of 5, by jokkebk

User metadata
Rank Newbie
Rank
Newbie

Thanks a lot, I'll try that!

I don't even mind the date (or even DOS time) proceeding its normal way, I suppose most newer demos rely either on hooking the timer interrupt (is PIC the right term here?) themselves, or polling playing time from music subsystem, which usually hooks the timer.

My only worry is that if SDL uses some type of DMA buffer to do audio transfer from DOSBox to soundcard. It could complicate things when DOSBox application starts to fill the buffer slower than supposed to. In that case, when running a demo that is doing 44.1kHz sound at half speed, I would need to set SDL audio output to 22.05kHz to match the change... I don't know if video updating would pose similar complications, as I haven't quite yet understood how the video subsystem is emulated.

Btw. are there any kinds of architectural or even code layout docs available for DOSBox? Plain source code and debugger makes the path to enlightment rather long...

Reply 3 of 5, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

just put the cycles on 4 times your regular amount.
and enable video capturing.
DOSBox will then switch to a different timer control which will play the demo slower why keeping the video allright. (you can record demos in an overclocked dosbox. during the capture everything will lag. but the resulting video is allright)

Water flows down the stream
How to ask questions the smart way!

Reply 4 of 5, by jokkebk

User metadata
Rank Newbie
Rank
Newbie

Well that is just superb (only minus is, that it seems all the hacking has already been done for me 😉). I already tried it on two demos, and while both took their time, the result is just amazing.

Thanks!