The timing needs of VGA, specifically 800x600 resolution are such that we must program in assembly. Keeping constant and correct timing for the signals output is critical if the monitor is going to receive and display the signal. Since assmembly is crude and not friendly on the eyes, I'm just going to cover same of the main points of the code.
Variables Used
------------« Begin Code »------------
;Delay Counters For Delay Functions And ;For Red, Green and Blue Color Routines delay_cnt equ 0x3F counter1 equ 0x2F counter2 equ 0x1F counter3 equ 0x0F
------------« End Code »------------
Many times delays of 1, 10 or 20 micro or miliseconds become necessary and the delay_cnt variable makes it so that we can have a variable run a for loop the necessary number of times to create the delay we need. The other integers counter1, counter2 and counter3 are used to display 200 lines of red, 200 lines of blue and 200 lines of green. You can play around with these variables in the code and change them to 100/100/400 or whatever combination you like, as long as it adds up to 600 lines.
------------« Begin Code »------------
;200 Horizontal Lines HSync1 HSYNC_short_X 0 decfsz counter1,1 ;1.8uS goto HSync1 ;2.2uS nop ;200 Horizontal Lines HSync2 HSYNC_short_X 1 decfsz counter2,1 ;1.8uS goto HSync2 ;2.2uS nop ;200 Horizontal Lines HSync3 HSYNC_short_X 2 decfsz counter3,1 ;1.8uS goto HSync3 ;2.2uS nop
------------« End Code »------------
This is the section of the code where 3 seperate for loops display 200 lines each of Red, Green or Blue,
denoted by the 0,1 or 2 next to the HSYNC_short_X macro call. All the rest of the code is just keeping the correct vertical syncing, but this section is where the
color output action is happening.