VOGONS


Need to add MHz simulation

Topic actions

  • This topic is locked. You cannot reply or edit posts.

First post, by videogamer555

User metadata
Rank Member
Rank
Member

For some games and other programs, the timing is not based on a realtime clock timing, but rather on the CPU's clock oscillator frequency. Games and other software that run at the wrong CPU speed will be too fast or to slow. Other programs that use this timing, use it to determine the length of time a splashscreen remains visible at the start of the program. For drawing programs that have a drawing effect that gets stronger the longer you hold the mouse button down (such as airbrush) this timing determines how quickly the effect reaches maximum. All of these types of programs, when the timing is based on CPU clock oscillator frequency, will be way to fast on modern computers, even when running in DOSbox. Unfortunately, despite my best efforts, I can't figure out how to make DOSbox emulate a specific CPU speed. This either means the feature is well hidden (maybe only for DOSbox devs), or is simply not an available feature in DOSbox. If this is not an available feature in DOSbox, it should be. In fact this should have been one of the first features that ANY emulator of DOS pcs would have, as many older DOS programs do indeed use CPU clock frequency for timing.

A simple implementation would be to introduce artificial delays in the emulator software's main loop structure. Adding a delay of 1microsecond would emulate a 1MHz CPU. Adding a 0.5 microsecond delay would emulate a 2MHz CPU. Adding a 0.25 microsecond delay would emulate a 4MHz CPU. And so on.

Please, developers of DOSbox, if you ever actually read these forums, PLEASE consider adding this feature to DOSbox in your next version.

Reply 2 of 18, by leileilol

User metadata
Rank l33t++
Rank
l33t++

That's a huge feature and would mean a major rewrite (along BIOS emulation and I am not sure if DOSBox will ever go down this path).

There's PCem. It's not as compatible as DOSBox but it's the only one I know of that has the MHz target and platform stuff that doesn't involve recompiling a new machine in MESS.

apsosig.png
long live PCem

Reply 3 of 18, by mr_bigmouth_502

User metadata
Rank Oldbie
Rank
Oldbie

The way that CPU instructions work in DOSBox isn't the same as how they work on actual CPUs, as every instruction in DOSBox takes exactly one CPU cycle, whereas on a real CPU an instruction can take several cycles. It would be interesting if someone analyzed various common CPUs and how many cycles they take to execute various instructions, and wrote special CPU cores for DOSBox based on this.

Unfortunately, I can't see the DOSBox team doing this any time soon, though at the least I'd like to see someone add a CPU core to simulate an 8088, and a cycle option to achieve roughly 4.77MHz with this CPU core.

I don't see this being nearly as urgent for other CPUs, as clockspeeds and CPU architectures in IBM compatibles tended to vary a LOT more past the 8088 era.

Reply 4 of 18, by Great Hierophant

User metadata
Rank l33t
Rank
l33t

Specific examples of games and programs would be helpful. DOSBox can fine tune itself so that even the pickiest 8088 games can run at the appropriate speed.

http://nerdlypleasures.blogspot.com/ - Nerdly Pleasures - My Retro Gaming, Computing & Tech Blog

Reply 5 of 18, by Jorpho

User metadata
Rank l33t++
Rank
l33t++
videogamer555 wrote:

For drawing programs that have a drawing effect that gets stronger the longer you hold the mouse button down (such as airbrush) this timing determines how quickly the effect reaches maximum.

DOSBox is presently targeted towards games and not for drawing programs.

In fact this should have been one of the first features that ANY emulator of DOS pcs would have, as many older DOS programs do indeed use CPU clock frequency for timing.

And many older DOS programs running on real machines will run into speed problems if the processor is too fast. In that sense DOSBox is accurate.

In addition to the above-mentioned options, I think MESS is also doing some cycle-accurate x86 emulation.

Reply 6 of 18, by videogamer555

User metadata
Rank Member
Rank
Member

The purpose of DosBox is to emulate every game that has been written for dos, so that even with a modern PC, those games will be able to be played as they were intended to be played. This means that, for example, if game "xyz" is CPU speed sensitive, and is designed to run on a CPU running at exactly 40MHz, then DosBox will need to emulate an exactly 40MHz CPU for that game to run properly. Therefore if DosBox can't emulate a 40MHz CPU, it is unable to run game "xyz" as it was intended, and therefore DoxBox fails its mission to run every game as it was intended to be run, because without game "xyz" running correctly, DosBox is only able to correctly emulate "every DOS game minus one", when it's mission is to be able to emulate "every DOS game".

For this reason alone, it is MANDATORY that DosBox be able to emulate specific CPU speeds.

Reply 7 of 18, by RacoonRider

User metadata
Rank Oldbie
Rank
Oldbie

What do you hide under the "40MHz CPU"? A 386DX-40? 486DX-40? A pentium downclocked to 40MHz via hardware?
I'll give you some facts to consider:

- A 40MHz 386 is roughly the same speed as a 25MHz 486.
- A 100MHz 486 is close to early 60MHz Socket 4 Pentiums.
- A 133MHz 486 is around 75MHz Pentium at integer operations.
- An even among same-generation CPUs: 2200MHz Athlon XP is around 3000MHz Pentium 4.

and so on...

Now which CPU would you simulate MHz for?

On the topic, there's a program called Topbench. It is a real-time benchmark that has a huge list of DOS-compatible PCs. When it runs, it shows 3 closest PCs to any given performance (cycles). To simulate an actual system you adjust cycles until you are close enough to what you need.

Reply 8 of 18, by Jorpho

User metadata
Rank l33t++
Rank
l33t++
videogamer555 wrote:

This means that, for example, if game "xyz" is CPU speed sensitive, and is designed to run on a CPU running at exactly 40MHz, then DosBox will need to emulate an exactly 40MHz CPU for that game to run properly.

Any developer who designed a game to run on a CPU running at exactly 40 MHz would have limited his target audience so severely as to doom himself to complete obscurity. That is not how PC software is written.

For this reason alone, it is MANDATORY that DosBox be able to emulate specific CPU speeds.

Talk like that isn't going to get you anywhere.

Reply 9 of 18, by mr_bigmouth_502

User metadata
Rank Oldbie
Rank
Oldbie

IIRC the only PC games that were targeted towards a specific clockspeed were some of the CGA booter releases from the early-mid 80s. There are later games that have speed issues on faster CPUs, but none of them are targeted at a specific clockspeed like games during the XT era were.

Reply 11 of 18, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Please correct your entitlement issues and everywhere in your text that claims that Dosbox aims at emulating Dos games... It's not and never has been its aim.
It aims to make old Dos games playable but not emulating old dos games. It's not even a fine distinction, it's a huge difference.
And it's aim is not the 100% AFAICT... And which game can't be played because it is running too fast and adjusting cycles won't work?

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 12 of 18, by videogamer555

User metadata
Rank Member
Rank
Member
mr_bigmouth_502 wrote:

IIRC the only PC games that were targeted towards a specific clockspeed were some of the CGA booter releases from the early-mid 80s.

Play the game Dark Ages from Apogee Games, and you'll notice it is WAY too fast on modern CPUs. That's because the old games like that depended on exact clock speed.

Reply 13 of 18, by Jorpho

User metadata
Rank l33t++
Rank
l33t++
videogamer555 wrote:

That's because the old games like that depended on exact clock speed.

No, they do not depend on an exact clock speed. They depend on a slower clock speed, which DOSBox is wholly capable of providing, i.e. by decreasing cycles. By the time Dark Ages came out, PCs were already running at a wide variety of different clock speeds – and the developers would never have told people to only buy their game if and only if the purchaser intended to run it at no more and no less than exactly so-many-MHz, because that would have been very bad for business.

Reply 14 of 18, by mr_bigmouth_502

User metadata
Rank Oldbie
Rank
Oldbie
Jorpho wrote:
videogamer555 wrote:

That's because the old games like that depended on exact clock speed.

No, they do not depend on an exact clock speed. They depend on a slower clock speed, which DOSBox is wholly capable of providing, i.e. by decreasing cycles. By the time Dark Ages came out, PCs were already running at a wide variety of different clock speeds – and the developers would never have told people to only buy their game if and only if the purchaser intended to run it at no more and no less than exactly so-many-MHz, because that would have been very bad for business.

Like I was saying, the ONLY PC games taht require a specific, exact, clockspeed are CGA-era titles optimized for the 4.77MHz 8088. Past that era, so many different CPUs were out there that they didn't optimize for one specific CPU model. Yes, there are tons of DOS games that rely on having a relatively slow clock speed, but other than the CGA era games, almost none, if any, were programmed to run at just ONE speed.

Reply 16 of 18, by mr_bigmouth_502

User metadata
Rank Oldbie
Rank
Oldbie
leileilol wrote:

Also there's lots of games after the XT era that relied on the speed of a slow ISA bus for its timing, and that's less relevant to CPU

I never thought about that, but it makes sense. Programmers back then pretty much had to code down to the bare metal to get any decent performance.

Reply 17 of 18, by awgamer

User metadata
Rank Oldbie
Rank
Oldbie
videogamer555 wrote:

For some games and other programs, the timing is not based on a realtime clock timing, but rather on the CPU's clock oscillator frequency. Games and other software that run at the wrong CPU speed will be too fast or to slow. Other programs that use this timing, use it to determine the length of time a splashscreen remains visible at the start of the program. For drawing programs that have a drawing effect that gets stronger the longer you hold the mouse button down (such as airbrush) this timing determines how quickly the effect reaches maximum. All of these types of programs, when the timing is based on CPU clock oscillator frequency, will be way to fast on modern computers, even when running in DOSbox. Unfortunately, despite my best efforts, I can't figure out how to make DOSbox emulate a specific CPU speed. This either means the feature is well hidden (maybe only for DOSbox devs), or is simply not an available feature in DOSbox. If this is not an available feature in DOSbox, it should be. In fact this should have been one of the first features that ANY emulator of DOS pcs would have, as many older DOS programs do indeed use CPU clock frequency for timing.

A simple implementation would be to introduce artificial delays in the emulator software's main loop structure. Adding a delay of 1microsecond would emulate a 1MHz CPU. Adding a 0.5 microsecond delay would emulate a 2MHz CPU. Adding a 0.25 microsecond delay would emulate a 4MHz CPU. And so on.

Please, developers of DOSbox, if you ever actually read these forums, PLEASE consider adding this feature to DOSbox in your next version.

Someone already came up with this for DOSBox, made a patch and batch files, was told to shut up about it.