
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;												;
;		Generating Video Signals				;
;		By Brad Slattery 2009					;
;												;
;		For more info:							;
;		web - www.bradsprojects.com				;
;		email - brad@bradsprojects.com			;
;												;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	LIST p=16f648a 					; tell assembler what chip we are using
	include "P16f648a.inc"			; include the defaults for the chip
	__config 0x3f18					; sets the configuration settings (oscillator type etc.)

	cblock h'20' 					;	this is where we start defining variables
	
	endc							;	end of variable declarations

	org h'0000'						; 	sets our start address


	movlw h'07'
	movwf CMCON 					; we want all ports to act purely as digital ports

	bsf STATUS, RP0 				; select bank 1
	movlw b'00000000' 				; 
	movwf TRISB						;
	movlw b'00100000' 				; set PORTA all outputs except for bit 5
	movwf TRISA 					;
	bcf STATUS, RP0 				; select bank 0


setup								;	have this here incase anything requires seting up, before we run the main code.





begin

	clrf PORTB						;	clear PORTB so that we send a logic 0 to the tv for our 4us sync pulse	(this is also the first 1us)				
	nop								;	delay 1us
	nop								;	delay 1us

	movlw b'00000001'				;	prepare for the 8us wait pulse (this also takes 1us and is the last of the 4us delays)
	movwf PORTB						;	we will now hold this data on PORTB for 8us (this is the first 1us)
	nop								;	delay 1us
	nop								;	delay 1us
	nop								;	delay 1us
	nop								;	delay 1us
	nop								;	delay 1us
	nop								;	delay 1us

	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	incf PORTB, f					; 	increment PORTB (this takes 1us)
	
	goto begin						;	and now jump back to the beginning (this takes 2us)





	end