chani
Posts: 7
Joined: Fri Oct 26, 2012 9:37 am

DOS Emulator / Limiting the CPU?

Fri Oct 26, 2012 9:46 am

Hey,

using MIPS I checked how many cycles one would need to set to emulate a compaq 386 on the RPi in Dosbox. The result was 2068. However, this leads to 100% cpu load and reducing the cycles makes some of those old DOS games pretty slow. I'm wondering if that high CPU load is because of SDL, though I disabled all scaling stuff in dosbox already. What settings are you guys using? I read that some people try to make a OpenGL ES on the RPi working in SDL - Maybe that would help and put some calculation to the GPU instead of the CPU? By the way, overclocking to 1 GHz does not change the cycles - It's still 2068 so I assume guides which state that people should use around 1000 cycles (I've seen those) are wrong (or well, not wrong, they're just emulating a box worse than a compaq 386).

Wondering if there's any other emulator than dosbox which works on the RPi. If I remember correct some pages reported about a arm port of dosemu, though I couldn't find it anywhere. I also tried running freedos in qemu. I know that a cpu load of 100% wouldn't harm the box but I'd really like to stay below that.

Tried cpulimit to limit the cpu - for both qemu and dosbox, but that doesn't seem to do what I want. Anyone here tried with cgroups and could give me an example on how to do it with that?

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: DOS Emulator / Limiting the CPU?

Fri Oct 26, 2012 10:25 am

DOS Box is nice and fast on Windows because it emulates the same processor as the host machine and can execute blocks of machine code natively.
Unfortunately the PI is ARM based which means DOS Box must emulate the entire Intel instruction set without it's cheap tricks to speed up code execution.
This is very time consuming which is why your 486 machine behaves more like an underclocked 80186.
The only other emulator that support ARM is Qemu however this is just a slow too for the same reasons as DOS Box, also it required an operating system stored in an image file not as files.
Qemu can run Windows 95, XP, NT4 on the PI (as demonstrated) if you're prepared to wait 10 minutes for them to boot up. :lol:

Richard S.

chani
Posts: 7
Joined: Fri Oct 26, 2012 9:37 am

Re: DOS Emulator / Limiting the CPU?

Fri Oct 26, 2012 10:30 am

Hehe yeah, I read those stuff. I've just been curious if there's anything one can do. My next question would be whether it is possible to use the GPU like a pseudo-coprocessor for such stuff. Just like people use their nvidia for seti@home (including me heh). Hence i was also interested in the SDL thingy (progress on it) - Might make things faster or at least take some work from the cpu.

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am
Contact: Website

Re: DOS Emulator / Limiting the CPU?

Fri Oct 26, 2012 10:38 am

I played a lot with dosbox got Warcraft 1 to almost be playable. The cycles is really set more on the machine you are running and there is no set for what to do I got it down to about 1200 and sound was fine got many low end games to play quite well. The problem with DOS is you are also emulating sound, video, upper memory and all that. The Pi is a 300mhz pc by comparison not a true pc build. Don't think any other emulator will do you any better. Here are the specs for Orcs and Humans

Code: Select all

SYSTEM REQUIREMENTS
MINIMUM PC REQUIREMENTS
Minimum CPU Type: 386DX
Minimum CPU Speed: 20 MHz
Minimum RAM Required: 4 MB
Minimum OS Version: 5.0
Graphics Type: VGA
Graphics Resolution: 320x240
Color Depth: 256 Colors
Since I can get the game to almost play I would conclude that the Pi is close to a 300mHz PC which is less than what is required for the game.

Some of the tweaks I have tried are linking an img file and installing Dos directly to the image this allows adding Himem.sys and soundblaster drivers. In all it did not make much difference I also patched warcraft to use dos32a instead of Dos4g.

The best settings I could get were 1200 cycles. Simple CPU, OpenGl, let the ram default changing it didn't make a difference. Turning all the sound down to 1200 not the 14400 or whatever settings they had. Each game though would want something different like OpenGL might want to change that depending on the game.
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am
Contact: Website

Re: DOS Emulator / Limiting the CPU?

Fri Oct 26, 2012 10:39 am

There was a post here quite some time ago about the SETI stuff haven't heard much about it other than I think they got it working.
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: DOS Emulator / Limiting the CPU?

Fri Oct 26, 2012 1:44 pm

Are you sure that Qemu runs worse ?


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

chani
Posts: 7
Joined: Fri Oct 26, 2012 9:37 am

Re: DOS Emulator / Limiting the CPU?

Fri Oct 26, 2012 8:49 pm

I couldn't see a difference between qemu and dosbox. Wondering if there's anything one could do to improve it. Guess I'll try to compile dosbox.

User avatar
7F20
Posts: 65
Joined: Tue Jul 24, 2012 2:45 am
Location: New York

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 1:39 am

The solution to the Dosbox Performance Problem is definitely getting the GPU in on it.
The only path with which Dosbox can currently interact with the Pi hardware is through SDL, which is currently only running in software on the CPU side of things.
I am hoping that the recent announcement about Broadcom opening up the source code to the GPU will finally result in awesome hardware acceleration goodness in Dosbox.
http://www.raspberrypi.org/archives/2221

I sincerely hope that I did not misinterpret this post, and also that there are people working on this, because I would be unbelievably psyched if I could use my Pi as a retro software box.

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 8:52 am

The point is that somebody has still to do the work. Look at VLC , ffmpeg and gstreamer. They could have worked on HW accel. from
the very beginning with the documented APIs , but it seems that the expertise required is very rare in the FLOSS community.
Or more like "duh , it has a GPU binary , i don't like that" and therefore not putting the effort they would if this was spagetti code of
a FLOSS driver or similar.
The newly released source is undocumented , and a custom implementation of Broadcom. (AFAIK the foundation wants to sponsor some docs.)

ghans
.
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

chani
Posts: 7
Joined: Fri Oct 26, 2012 9:37 am

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 9:37 am

There are a few posts in the board regarding SDL and OpenGL, however, I haven't found any up to date guide on how to try yourself (I'm familiar with compiling and such stuff due to my background as developer at a source based Linux distribution, that'd be the smallest problem).

And regarding the people who don't start to work on that because they dislike the driver - I'm not sure but I believe it's not that they dislike the driver, I think they dislike the way it has been announced because they spent a lot of manpower into their own projects with in their opinion "real" drivers while the broadcom one looks like a bluff package. In fact I don't care - In my opinion both, broadcom and the foundation did a great job and definitely a step in the right direction.

Vanfanel
Posts: 439
Joined: Sat Aug 18, 2012 5:58 pm

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 10:18 am

In the first place, forgive me for my strange english.
I don't get the point: GPU speeding up DosBOX emulation? How is that going to help?
I see no way GPU can speed up x86 CPU, soundblaster or VGA emulation.
All I can see is GPU being able to scale low-res graphics output into the final display: just what dispmanx does. GLES has nothing to do here, as I understand it, nor do GPU computation.

I've a partially working SDL 1.2.x dispmanx backend, and I believe it's the best we will get unless someone proves otherwise.
The idea is to TOTALLY DISABLE any emulator-side scaling: just output DOS graphics into a 320x200 area, for example, then scale that area with cpu-free methods like a dispmanx overlay: there you go, 1920x1080 with ZERO cpu usage.

The other thing that would (in theory) speed up DosBOX would be the ARM dynamic recompiler for X86 code: I believe DosBOX has souch a feature, but I don't know if it's available for Raspberry Pi's ARM version. Do you guys know about it?

User avatar
billb
Posts: 177
Joined: Wed Sep 19, 2012 10:27 pm

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 10:35 am

Vanfanel wrote:The idea is to TOTALLY DISABLE any emulator-side scaling: just output DOS graphics into a 320x200 area, for example, then scale that area with cpu-free methods like a dispmanx overlay: there you go, 1920x1080 with ZERO cpu usage.
If you're running DOSBox from the terminal (without X), would using fbset accomplish basically the same thing?

For example, if you're running at WUXGA (1920x1200) and you want DOSBox to fill the screen without doing any scaling on its own, you use fbset like so:

fbset -xres 320 -yres 200

This seems to change the apparent screen resolution to 320x200 with no loss in speed, though the "virtual resolution" remains at 1920x1200. Then when you're done with DOSBox you change back to whatever resolution you want.

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 12:09 pm

What is the difference between "emulation" and "instruction translation" anyway ?
The latter approach AFAIK is done by qemu , and how i understood it for each x86
instruction a set of ARM imstructions is executed. Is that supposed to be faster ? DosBOX
can do that too , i've heard , but only on x86 hosts. (Direct execution of the code , instead
doing things like bochs does ?)

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Vanfanel
Posts: 439
Joined: Sat Aug 18, 2012 5:58 pm

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 2:50 pm

DosBOX has a "dynamic recompiler": it takes chunks of x86 code, and recompiles them to ARM chunks of code "just in time". I don't know all the details, but it should be way faster than instruction-per-instruction emulation. Other emulators souch as MAME have dramatic speed enhancements with dynamic recompilation.

What I don't know is if DosBox dynamic recompiler is available on the Pi's CPU: there IS an ARM dynamic recompiler in DOSBOX, that's for sure- Here's a thread where dynamic recompiler is activated for the GP32 port. GP32 seems to be ARMV4, so I don't know if it would work for ARMV6 (Rpi):

http://www.gp32x.com/board/index.php?/t ... th-dynrec/

Vanfanel
Posts: 439
Joined: Sat Aug 18, 2012 5:58 pm

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 3:10 pm

Looking at DosBOX sources, it seems there's only an armv4l dynarec, not an armv6 one...
Take a look at /src/cpu/core_dynrec/
but it has a dynarec that uses "thumb", and instruction set (I believe) compatible among various ARM versions...
Its the ARM on the Rpi supposed to have thumb support?

User avatar
billb
Posts: 177
Joined: Wed Sep 19, 2012 10:27 pm

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 4:06 pm

Vanfanel wrote:Its the ARM on the Rpi supposed to have thumb support?
Not that I have any idea what it means or time to check, but it's listed when you check cpuinfo:

Features : swp half thumb fastmult vfp edsp java tls

chani
Posts: 7
Joined: Fri Oct 26, 2012 9:37 am

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 4:33 pm

Not sure but it seems the whole system needs to be compiled with thumb support if you want to use that. I tried compiling dosbox with -mthumb and that wasn't working (no thumb-1 support). However, the above dynreq thing seems to be for another arm version.

Vanfanel
Posts: 439
Joined: Sat Aug 18, 2012 5:58 pm

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 5:52 pm

from Wikipedia:
To improve compiled code-density, processors since the ARM7TDMI (released in 1994[27]) have featured Thumb instruction set, which have their own state. (The "T" in "TDMI" indicates the Thumb feature.) When in this state, the processor executes the Thumb instruction set, a compact 16-bit encoding for a subset of the ARM instruction set.[28] Most of the Thumb instructions are directly mapped to normal ARM instructions. The space-saving comes from making some of the instruction operands implicit and limiting the number of possibilities compared to the ARM instructions executed in the ARM instruction set state.
I've seen the thumb option countless times when compiling ARM linux kernels in Gentoo and similar, so I'll give it a go when I recompile the kernel.
I take thumb is a special mode with an instruction set compatible among different ARM micros, so it could work... correct me if I'm wrong.


But behold! DosBOX on the Pi, with Dynarec enabled has already been released! Just it's working on RiscOS: much better Desktop OS than Linux imho. Check this:

http://www.acornarcade.com/forums/reply ... eid=121342

It's supposed to be 250% faster than a normal build...heh, it makes me hooooorny :D

Just in case, Risc OS runs GREAT on the Raspberry pi, it's way easier to use than Linux and feels fast, responsive and nice. You can download the OS, for free, here:

http://downloads.raspberrypi.org/images ... 10-16-RC5/

User avatar
billb
Posts: 177
Joined: Wed Sep 19, 2012 10:27 pm

Re: DOS Emulator / Limiting the CPU?

Sat Oct 27, 2012 9:24 pm

Vanfanel wrote:Just in case, Risc OS runs GREAT on the Raspberry pi, it's way easier to use than Linux and feels fast, responsive and nice.
Tried RiscOS for the first time today. Managed to get online OK, but couldn't figure out where/if the browser was saving the DOSBox file I downloaded (or not) so I wasn't able to test it. I don't know about the "way easier to use than Linux" part. :P All depends on what you're used to, I suppose.

trevj
Posts: 65
Joined: Fri Oct 28, 2011 6:41 am
Location: Bristol, UK

Re: DOS Emulator / Limiting the CPU?

Mon Oct 29, 2012 12:09 pm

billb wrote:couldn't figure out where/if the browser was saving the DOSBox file I downloaded (or not)
You've probably figured this out by now... but if not, in order to save you open a directory viewer and drag the file icon into it.

User avatar
billb
Posts: 177
Joined: Wed Sep 19, 2012 10:27 pm

Re: DOS Emulator / Limiting the CPU?

Mon Oct 29, 2012 2:18 pm

Actually I didn't figure it out before getting too frustrated with it. The problem I was having is that I'd click on a file to download it from a website, then couldn't figure out where the file went. The download appeared to complete OK. So I never saw an icon for the file.

chani
Posts: 7
Joined: Fri Oct 26, 2012 9:37 am

Re: DOS Emulator / Limiting the CPU?

Mon Oct 29, 2012 9:28 pm

another os is no choice for me (most stuff I'd like to do I do in linux, I'm interested in riscos, but I'd prefer to use linux) - Anyone able to package dosbox with dynrec to raspbian? I tried myself compiling it/finding sources but I failed.

User avatar
7F20
Posts: 65
Joined: Tue Jul 24, 2012 2:45 am
Location: New York

Re: DOS Emulator / Limiting the CPU?

Fri Nov 02, 2012 1:46 am

Vanfanel wrote:In the first place, forgive me for my strange english.
I don't get the point: GPU speeding up DosBOX emulation? How is that going to help?
I see no way GPU can speed up x86 CPU, soundblaster or VGA emulation.
All I can see is GPU being able to scale low-res graphics output into the final display: just what dispmanx does. GLES has nothing to do here, as I understand it, nor do GPU computation.

I've a partially working SDL 1.2.x dispmanx backend, and I believe it's the best we will get unless someone proves otherwise.
The idea is to TOTALLY DISABLE any emulator-side scaling: just output DOS graphics into a 320x200 area, for example, then scale that area with cpu-free methods like a dispmanx overlay: there you go, 1920x1080 with ZERO cpu usage.

The other thing that would (in theory) speed up DosBOX would be the ARM dynamic recompiler for X86 code: I believe DosBOX has souch a feature, but I don't know if it's available for Raspberry Pi's ARM version. Do you guys know about it?

Hello, your English is great. No problems! :)

It seems like you have a pretty good idea here, but I don't exactly see how you are going to exclude the GPU from Dosbox operation using "...cpu-free methods like a dispmanx overlay."
It sounds like a pretty GPU-centric solution to me.

I'm not sure if you were responding specifically to ME, but I didn't write anything about the GPU emulating an x86 processor. I think you were reading into things a little, or maybe I missed something in another post you were reacting to?

In any case, I think that tapping the GPU is the key to reasonable dosbox performance, and from what I understood, progress in that has been held up because Broadcom did not initially release their source code, which they just have, for the GPU.
The exact whys and hows are a little over my head, but I am happy if you or anyone else here can help find a solution.
On that subject, how necessary is SDL in the Dosbox transaction? Is it possilble to output OpenGl from Dosbox without SDL?

Narishma
Posts: 151
Joined: Wed Nov 23, 2011 1:29 pm

Re: DOS Emulator / Limiting the CPU?

Fri Nov 02, 2012 2:05 pm

7F20 wrote:In any case, I think that tapping the GPU is the key to reasonable dosbox performance, and from what I understood, progress in that has been held up because Broadcom did not initially release their source code, which they just have, for the GPU.
That's not correct. You don't need the driver's source code to use the GPU.

User avatar
7F20
Posts: 65
Joined: Tue Jul 24, 2012 2:45 am
Location: New York

Re: DOS Emulator / Limiting the CPU?

Mon Nov 19, 2012 3:26 am

Narishma wrote:
7F20 wrote:In any case, I think that tapping the GPU is the key to reasonable dosbox performance, and from what I understood, progress in that has been held up because Broadcom did not initially release their source code, which they just have, for the GPU.
That's not correct. You don't need the driver's source code to use the GPU.
I didn't say that you needed the driver's source code to use the GPU.

The issue is that no one has gone through the trouble of optimizing dosbox to run on the raspi, specifically to make substantial use of the GPU.
There is no doubt that dosbox could run decently if that was done, and it hasn't been.
I read a discussion last summer that suggested that having the driver source code could make the task easier. Maybe it won't. If you know any details, please lay it down. I am listening.
Thanks for being interested, I really hope this gets sorted.

Return to “Gaming”