Page 1 of 1
VGA magic
Posted: Sat May 12, 2012 9:23 am
by bubach
Hi, I was thinking about the maximum resolution possible with
all of the VGA's 256kb of memory and realized it should work to get
resolutions near to 640x480, and I was right.
Found this old demo googling. It's in Pascal with inline 16bit asm,
a demo using 640x400 px with 256 colors using nothing
but basic VGA registers. It should in other words be possible
to use directly even from long mode.
http://ftp.lanet.lv/ftp/mirror/x2ftp/ms ... ascrol.zip
Does anybody here have any experience working with different "x-modes"
like this one, I think it's pretty cool if it's actually bug free on all VGAs...(?)
Or should modes like these be avoided, is it not compatible across cards?
Re: VGA magic
Posted: Sat May 12, 2012 3:49 pm
by Combuster
Lets see, 640x400x8 means 1280+24 horizontal pixel clocks minimum, and somewhere around 30% more to cover the necessary timings for analog displays. At the fastest pixel clock the VGA provides, the net result is a mode around 40Hz.
That has the following consequences:
1: Many monitors can't do that because the vertical refresh is too low.
2: Many monitors can't do that because the horizontal refresh is too low.
3. People with a CRT don't want it even if they could, because the visible flashing gives you an headache.
4. You can physically break equipment with exceeding the monitor's refresh rate tolerances. Old VGA CRTs may be nonexistant by now, but early LCDs are known for the same class of malfunctioning.
Of course, you see none of these effects if you try that in a VM.
The highest published resolution I've seen on a VGA is 800x600x4. Point 3 still very much applies to this, and so does point 4 if the rates are outside the monitor's tolerances. 400x300x8 is quite a bit better, and due to how a VGA works, weird non-square pixel modes like 320x400x8 and 320x480x8 should actually be universally safe, though not necessarily useful.
Re: VGA magic
Posted: Sat May 12, 2012 5:09 pm
by bubach
ouch, 40hz... didn't know it could have consequences like that. too bad, because the resolution actually fits my small EeePC widescreen perfectly. 400*300 would be cool too, not sure if i've seen any examples of that, will have to google for it.. where would that mode stand on hertz and compatibility - as you seem to know quite a lot more than me on this?
Re: VGA magic
Posted: Sat May 12, 2012 6:22 pm
by Kazinsal
bubach wrote:400*300 would be cool too, not sure if i've seen any examples of that, will have to google for it..
It can be done quite easily.
Re: VGA magic
Posted: Sun May 13, 2012 2:51 am
by Combuster
Blacklight wrote:bubach wrote:400*300 would be cool too, not sure if i've seen any examples of that, will have to google for it..
It can be done quite easily.
Ah, the good ole' tweak program. If you still have a non-emulated dos-capable or win'9x machine you definitely should try that. I wrote a less fancy bit of
test code to check my modesetting routines (and to occasional provide Stanislav with demonstration material of VGA emulation bugs in bochs).
As far as frequencies go, the hardware pixel count equals (dot89mode * horizontal_total * vertical_total). The vertical refresh rate is the pixel clock divided by that, the horizontal refresh is the (pixel_clock * (dot89mode * horizontal_total)), typically written in kHz.
The 400x300x8/800x300x4 mode would roughly be 960x330 hardware pixels, with the 25MHz pixel clock gives 26kHz/78Hz. Depending on your actual CRT, this might or might not fall within tolerances - EDID will tell you if you can get to that (which requires bios or device-specific code). If the horizontal refresh is too low, you can switch the pixelclock and turn it up a bit towards 29kHz/87Hz and try again, hoping that the vertical refresh is not out of range as a consequence.
There's a whole bunch of heavy lecture on the material on the wiki. The only thing you'll have to realize is that the VGA only has two discrete clock sources, and not a configurable PLL clock. Basically that and the fact that it's virtually halved in 256-colour modes is what ends up as the VGA's biggest limit considering actual output.