PDA

View Full Version : DS2x86 EGA scaling



wraggster
December 12th, 2010, 20:57
Pate has posted more news of his Dos emulator for the DS:

Last week I worked on the EGA opcodes. Currently the great majority of the opcodes (that are supported in DSx86) have been ported to DS2x86, so a couple of EGA games are already running fine. Some string opcodes are still missing, all the BIOS-based character output functions have yet to be coded, and I currently only have a blitting routine for the 320x200 resolution mode, so many games still fail. I just this morning decided to experiment with the EGA mode linear interpolation screen scaling routine. I first coded it by handling the palette calculations while blitting, and after I got that working I switched to a precalculated look-up-table that has the interpolated output pixel colors precalculated for each two input pixels. Since the 16-color EGA mode uses 4 bits per pixel, it is simple to lookup the output pixel value based on an 8-bit input value containing two adjacent pixels. The routine that handles the LUT filling whenever the palette value changes is obviously rather slow now, but since that specific routine is only used in the 16-color modes, and those rarely perform fast palette animations, this will most likely not be much of a problem. The actual blitting routine is almost as fast as the non-scaling routine, so there will be practically no performance penalty in using the scaled screen mode!

I was mainly interested in seeing what the scaling quality would be when scaling screens with some small text, so here below are screen copies of some screens from Duke Nukem 1 and Duke Nukem 2. In my opinion the text is for the most part quite readable, much better than with the hardware scaling as used in the original DSx86.


I also figured out a faster way to handle the separate memory access methods between normal RAM, EGA VRAM and ModeX VRAM. Since the graphics mode memory is organized so that each input byte addresse maps to a word address in the emulated VRAM, I now precalculate the two-bit-shifted memory addresses into the main page mapping table, so that the result address into the graphics memory can be taken simply by shifting the address generated by the common memory address calculation macro. Previously I first had to subtract the logical memory start address, then shift the value, and then add the physical graphics memory start address to the value. This simple change increased the Trekmo framerate by 0.5 fps, which together with some earlier general speedups now give a total framerate of 12.9 fps. Compared to the 11.9 fps value a few blog posts back, that is quite a nice increase. Now DS2x86 runs Trekmo at about the speed of a 40MHz 386 machine. There is most likely still room for improvement in various locations in the code, I just haven't yet figured out proper ways to improve them yet.

I have a two-week Xmas vacation starting on the 20th, so my current plan is to work on DS2x86 adding the most essential missing features, so that I can then release the first alpha version before the new year. Some of the biggest features that exist in DSx86 but are still missing from DS2x86 are:

Mouse support.
CGA graphics mode support.
Other EGA modes besides the 320x200 resolution.
Many Mode-X graphics opcodes are still missing.
All graphics BIOS features besides setting the graphics mode are missing, the most essential being the BIOS character output features.
All audio support (besides 8-bit SB digital audio) is still missing, and even that one still needs improvement.
All the configuration features on the touchscreen (including updating the lower screen upper part based on the current configuration) are still missing.
The blinking cursor in the text mode (command prompt) is missing.
The crash logging feature is still missing.
A lot of other minor things here and there.
I will certainly not be able to add all of these before the new year, so the first alpha version of DS2x86 will be quite limited. It will mostly be meant as a technical demonstration and as a test bench for you DSTwo card owners, so that you can help me in testing various games on it and report the still missing features.

http://dsx86.patrickaalto.com/DSblog.html