VOGONS


First post, by arablizzard2413

User metadata
Rank Newbie
Rank
Newbie

I'm using the AEP cvs build from today (3/27/09), ok so here's what I've noticed.

Taking a screenshot of an ega game with aspect=false and using alt-printscreen to capture the output from the dosbox window on screen I get a game resolution of 320x200. However when I have aspect=true (which I assume stretches the image to a 4:3 ratio) and do the same thing I get a resolution of 320x239 (1 pixel short of being the 4:3 resolution 320x240).

I'm running Visa Ultimate x64, and I get the same results with output equal to surface, ddraw, and opengl. Windowresolution is set to original, machine is set to svga_s3, and scaler is set to none. The game I tested with was Commander Keen 5.

Reply 1 of 6, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I found an interesting webpage regarding rounding precision with machine-level floating point numbers in gcc. In DOSBox, sdlmain.cpp casts a double to integer, where 240 can end up as 239 because internally the number is something like 239.9999999

As mentioned in the article, compiling with the "-mfpmath=sse -msse2" options forces the use of the SSE floating point unit instead of the x87 FPU. The "-march=pentium4" compile option has the same effect. Of course you need a Pentium 4 or later Intel processor for it to work. I use -march=pentium4 in my own builds, and don't get the rounding problem (i.e. the window size is 320x240, or 640x480 with a 2x scaler)

The article also has an example of how to switch the x87 FPU to using double precision rounding, but it seems kind of awkward to use. Another option is to pass floating point types through a rounding function such as rint() before casting to int, but then you have to modify the code in quite a few places.

Reply 2 of 6, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

maybe add some +0.5 or +0,25 to them by default ? should get rounded correctly then

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

Reply 3 of 6, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

That would work. Adding .5 would be like straight-rounding, but adding a very small amount would be more like compensating for the rounding error. You'd still have to find all the places to apply it. Perhaps a define in a common header would look cleaner:

#define ROUND_ERR 0.0000001

sdl.clip.x=0;sdl.clip.y=0;
sdl.clip.w=(Bit16u)(sdl.draw.width*sdl.draw.scalex+ROUND_ERR);
sdl.clip.h=(Bit16u)(sdl.draw.height*sdl.draw.scaley+ROUND_ERR);
sdl.surface=SDL_SetVideoMode(sdl.clip.w,sdl.clip.h,bpp,sdl_flags);
return sdl.surface;

Instead of:

#include <math.h>

sdl.clip.x=0;sdl.clip.y=0;
sdl.clip.w=(Bit16u)rint(sdl.draw.width*sdl.draw.scalex);
sdl.clip.h=(Bit16u)rint(sdl.draw.height*sdl.draw.scaley);
sdl.surface=SDL_SetVideoMode(sdl.clip.w,sdl.clip.h,bpp,sdl_flags);
return sdl.surface;

Either one has the desired result.