Best way to emulate VGA and display?

I currently am working on getting my VGA emulation working. I have several functions in a jumptable for processing different 'signals':

Vtotal
Htotal
Vretrace start
Hretrace start
Vretrace end
Hretrace end
Vblank start
Vblank end
Horizontal Active display pixel
Vertical Active display pixel
Overscan pixel

Currently it works by using a prececalculated table for every horizontal and vertical coordinate (one table with the horizontal timings for a pixel and one with vertical timings for a pixel).

For every current coordinate, the signal is retrieved from the two tables, OR-ed with each other to get the 'signal' for the current coordinate.

This signal is processed by first handling the signal bits by calling the function jumptable for signals (either a NOP function that handles (in the given order):

hblank start
hblank end
vblank start
vblank end
hretrace start
hretrace end
vretrace start
vretrace end
htotal
vtotal

).

Finally the display handler is called using a jumptable, which is either a NOP, active display or overscan. It only processes one pixel.
Active display and overscan write a pixel to the display at the CRTC coordinates and increase the current horizontal coordinate to be processed next, as well as the CRTC coordinate currently rendering (x coordinate only). This is looped until either a vtotal or htotal is encountered (or both).

Active display is only used when both horizontal and vertical active display is set. It defaults to overscan. NOP is executed when both are disabled.

Signal 0 terminates the loop (uninitialised timings) with the signal jumptable. The display jumptable next executes a NOP function.

htotal resets the current coordinate and increases the CRTC and current y coordinate.
vtotal resets the y coordinate and renders the current output buffer to display.
hretrace resets the CRT x coordinate and disables output (during retrace).
vretrace resets the CRT y coordinate and disables output (during retrace).

Btw with NOP function an empty void function is executed (void NOP(){})

Is this a good way of emulating VGA display accurately and fast or is there a better way?
Last edited on
Topic archived. No new replies allowed.