Emulating "half speed DOS" to double cycles for video capture?

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

Emulating "half speed DOS" to double cycles for video capture?

Postby jokkebk » 2006-8-28 @ 11:07

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!
jokkebk
Newbie
 
Posts: 3
Joined: 2006-8-28 @ 10:19
Location: Finland

Re: Emulating "half speed DOS" to double cycles for video capture?

Postby wd » 2006-8-28 @ 11:47

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
viewtopic.php?t=12891
to get an idea of where dosbox interfaces with the system clock.

Hope that gets you somewhere, good luck :)
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: Emulating "half speed DOS" to double cycles for video capture?

Postby jokkebk » 2006-8-28 @ 13:29

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...
jokkebk
Newbie
 
Posts: 3
Joined: 2006-8-28 @ 10:19
Location: Finland

Re: Emulating "half speed DOS" to double cycles for video capture?

Postby Qbix » 2006-8-28 @ 14:13

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!
User avatar
Qbix
DOSBox Author
 
Posts: 10596
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Emulating "half speed DOS" to double cycles for video capture?

Postby jokkebk » 2006-8-29 @ 13:06

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

Thanks!
jokkebk
Newbie
 
Posts: 3
Joined: 2006-8-28 @ 10:19
Location: Finland

Re: Emulating "half speed DOS" to double cycles for video capture?

Postby Alkarion » 2006-8-29 @ 17:33

Feel free to post links to the recordings ;)
User avatar
Alkarion
Member
 
Posts: 230
Joined: 2003-9-21 @ 18:07
Location: Bonn/Germany


Return to DOSBox Development

Who is online

Users browsing this forum: No registered users and 3 guests