The VGA Test Box: Software

Program Download:

Main Assembly File

Include Files
Software Overview
           The program is divided into 5 files. The main assembly file contains the initializations, vertical & horizontal refresh macros and the core of the vga controller aspect of this project. The include files are all created for drawing that specific object or text with a single call from the main file.
HSync: macro
bcf PORTB, 3 		; horiz sync
nop				;
bsf PORTB, 3 		; horiz sync

VSync: macro
bcf PORTB, 4 		;1 vert sync
nop				;2
nop				;3
nop				;4
nop				;5
nop				;6
call Delay10mkS	;16
call Delay10mkS	;26
nop				;27
bsf PORTB, 4 		; 28 vert sync 0

Horizontal & Vertical Sync
           These functions are the core of simulating the vga timing signals. They are programmed using PIC macros. These are all defined atop the main assembly file for your viewing pleasure or to the left for you lazy people.
           It is important to note that the horizontal sync is only logic 1 for approximately 2 uS. This is not exactly what it should be, however luckily for us the analog electronics in the CRT are very forgiving so long as we prove the correct 60 Hz frequency for the entire field. 1 extra instruction in these macros can alter the entire output onto the CRT.

movlw 0x0F
call intro

call x_prnt

call square_prnt

call circle_prnt

call triangle_prnt

The Main Loop
           Inside the main file there is one loop that is constantly running. This loop makes the decision of what to actually display. I hardcoded 5 different 'states' into the programming code. These are all defined in the include files. The processor checks PORTD. If the value of PORTD is less than 0x0F (Hex), 15 (Decimal) then the processor knows a button has been pressed and displays whichever of the 4 pictures goes with the code that is sent to the processor.
Recap: PORTD is 8 bits, the upper 4 bits are tied directly to ground, the other 4 to the buttons.

PIC ASM instructions are well documented on Microchip's website.

Software: Parting Words
           I've gone through what I feel are the important parts of the code but I suggest you look through the code and understand it yourself. This is the only way you'll ever truely understand what is going on. The program is very simple and holds no tricks. It could definetly have been coded more creatively to save hundreds of instruction cycles, however I wanted the process of simulating VGA timing signals to be as clear as possible.