
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;											;
;	police flasher version 1.0				;
;	by brad slattery 2008					;
;											;
;	A two colour alternating flasher		;
;	for the 8x8 game board					;
;											;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;




	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.)

PC equ 0x02						;	The program counter will be refered to as PC

	cblock 0x20					;	start of general purpose registers - this is where we start defining variable names
		counta					;	used in the delay routine
		countb 					;	used in the delay routine
	endc

	org 0x0000					;	org sets the start address of our program 0000 hex


	movlw h'07'					;	turn comparators off				
	movwf CMCON 				;	(this sets are ports to digital)

	bsf STATUS, RP0 			; select bank 1
	movlw b'00000000' 			; set PORTB all outputs
	movwf TRISB					;
	movlw b'00100000' 			; set PORTA all outputs except for bit 5
	movwf TRISA 				;
	bcf STATUS, RP0 			; select bank 0



setup						;	Okay, lets get everything setup.
	movlw b'11011010'		;	This disables all 74373 outputs, and closes
	movwf PORTA				;	all 74373 latches.
	movlw b'11110000'		;	this will turn on all four top rows of red leds
	movwf PORTB				;	put this data on PORTB
	bsf PORTA, 0			;	now that the data is on PORTB, latch it to the red 74373
	bcf PORTA, 0			;	now close the latches (the data will now be held at the output of the 74373)
	movlw b'00001111'		;	this will turn on all four bottom rows of green leds
	movwf PORTB				;	put this data on PORTB
	bsf PORTA, 2			;	now that the data is on PORTB, latch it to the green 74373
	bcf PORTA, 2			;	now close the latches (the data will now be held at the output of the 74373)
	movlw b'11111111'		;	This will enable ALL of the 8 columns of anodes
	movwf PORTB				;	We place the data on PORTB
	bsf PORTA, 4			;	then latch it onto the COLUMN data 74373,
	bcf PORTA, 4			;	then close the latches (the data will now be held there)
	bcf PORTA, 6			;	For this program, we will just leave the COLUMN data enabled the whole time


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;																	;
;	Now that our green led memory, red led memory and COLUMN data	;
;	memory have their respective data, and the COLUMN data output	;
;	is constantly enabled (meaning ALL leds have a ground on their	;
;	cathodes). All we need to do now is either enable or disable	;
;	the green / red led memory output in order to get our flashing	;
;	effect working!													;
;																	;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	
begin						;	Our main program!
	bcf PORTA, 1			;	enable the red led output	
	call delay				;	call the delay to hold the red leds on for a split second
	bsf PORTA, 1			;	now disable the red output
	bcf PORTA, 3			;	enable the green led output
	call delay				;	now call the delay to hold the leds on for a split second
	bsf PORTA, 3			;	disable the green led output
	goto begin				;	do it all again!




delay						
		movlw h'ff'					;	You can make the delay longer by
		movwf counta				;	increasing the decimal value. Or you
		movwf countb				;	can make the delay shorter by decreasing
again	decfsz counta, 1			;	the decimal value.
	goto again						;
		decfsz countb, 1			;
	goto again						;	once counta and countb have reached zero
	return							;	it will return to the main program



	end								;	That's it!
