There are a fair number of conversion steps to be taken in this process:
- Choose desired width and height and refresh rate
- (see VGA timings) Determine overscan, blank and retrace times and pixel clocks (from established timings, GTF, or its successors)
- (see VGA hardware) In the case of GTF, ask the device for the closest pixel clock, which is either 25MHz or 28MHz for a VGA
- (see VGA timings) In the case of GTF, Determine a new set of blank and retrace times to make sure it works with the actual pixel clock
- (see DDC or ignore at your hardware's peril) Check if the vertical and horizontal refresh are appropriate for the screen
- (see
VGA hardware) convert the resolution, blanks and overscans to register values
- (see VGA Hardware) disable display, write settings, enable display
The VGA is an 8-bit device, so it won't easily store numbers like 640 or 480, but rather has shifted and precalculated versions of those values that are more useful to the internal circuitry. As in, a width of 0 is not meaningful so it's reused to mean "one". Thus, 4F (79) actually means 50 groups (80), shift it by 3 bits (multiply by byte size) to get 280 (= 640 decimal = pixels wide, see?).
The VGA hardware page does have a short description as to how the resolution/blank/retrace registers correspond to actual timings, but it's essentially documented the wrong way around. My OS has an
implementation for the process in the other direction, but it takes a few more things into account than the most basic model. Essentially, it performs the last two steps of the sequence.