;++++++++matriz 8x8++++++++
;
;
;
;
	list	P=16f648A
	include	<P16f648A.inc>

pcl	equ	0x02
status	equ	0x03
fsr	equ	0x04
pa	equ	0x05
pb	equ	0x06
cmcon	equ	0x1f

#define	dato	pa,0
#define	clock	pa,1
#define	reset	pa,2
	cblock	0x20
	puntero
	dig
	cuen
	cuenta
	reg
	reg1
	reg2
	d1
	d2
	prueba
	total
	general
	guia
	endc
	org	0x00
	goto	inicio
	org	0x05
inicio
	bcf	status,6
	bsf	status,5
	clrf	pa
	clrf	pb	;pb7=fila7-------pb0=fila0
	bcf	status,5
	movlw	0x07
	movwf	cmcon
principio
	clrf	general
comienzo
	movf	general,w
	xorlw	d'22'	
	btfsc	status,2	;pregunta si termino de leer la 
	goto	principio	;tabla_1
	movf	general,w
;++++SELECCION DE EFECTO++++++++
tabla_1
	addwf	pcl,f
	movlw	d'0'
	goto	efecto_0
	movlw	d'8'
	goto	efecto_0
	movlw	d'16'
	goto	efecto_0
	movlw	d'24'
	goto	efecto_0
	movlw	d'16'
	goto	efecto_0
	movlw	d'8'
	goto	efecto_0
	movlw	d'0'
	goto	efecto_0
	movlw	d'32'
	goto	efecto_0
	movlw	d'40'
	goto	efecto_0
	movlw	d'48'
	goto	efecto_0
	movlw	d'56'
	goto	efecto_0


efecto_0			;se carga con 0 para que empieze a leer
	movwf	puntero	;la tabla de la posicion 0
	movwf	guia
	movwf	prueba	
	movlw	d'8'	;se carga este valor xq solo son 8 datos 
	addwf	prueba,f	;los que debe mostrar 
	call	uno
	movlw	d'2'
	addwf	general,f
	goto	comienzo

;++++ BLOQUE QUE CONTROLA LA MATRIZ ++++++
uno	movlw	d'35'	;cargo este reg para retardar la muestra
	movwf	total	;de cada efecto, a mayor valor se demora +
ana	movf	guia,w
	movwf	puntero
	clrf	pa
	movlw	d'1'	;este reg es para la activacion de las filas
	movwf	reg		; osea iniciara b'00000001'y luego rotara
	movlw	d'8'	;este reg es para controlar el muestreo  
	movwf	cuenta	;de las 8 filas
un	clrf	pb
	call	columna
	call	fila
	call	retard
	decfsz	cuenta,f
	goto	un
	decfsz	total,f
	goto	ana
	return
;++++ BLOQUE ENCARGADO DE LAS FILAS +++++
fila
	movf	reg,w
	movwf	pb
	bcf	status,0
	rlf	reg,f
	return	
;++++ BLOQUE ENCARGADO DE LAS COLUMNAS +++
columna	
	movf	puntero,w
	call	tabla
	call	envio_serie
	incf	puntero,f
	movf	puntero,w
	xorwf	prueba,w
	btfsc	status,2
	clrf	puntero
	return	
;++++ TRANSMITE DATOS AL 74164 +++++++
envio_serie
		bcf	reset
		bsf	reset
		movwf	dig
		movlw	0x08	;+
		movwf	cuen	;+
rota	btfss	dig,0
		call	do
		btfsc	dig,0
		call	di
		bcf	status,0
		rrf	dig,f
		decfsz	cuen,f
		goto	rota
		call	rit
		return
di	bsf	dato
	bsf	clock
	bcf	clock
	return
do	bcf	dato
	bsf	clock
	bcf	clock
	return
;++++ VALORES QUE IRAN AL 74164++++++
tabla
	addwf	pcl,f
	retlw	b'11111111'	;0
	retlw	b'10000001'
	retlw	b'10000001'
	retlw	b'10000001'
	retlw	b'10000001'
	retlw	b'10000001'
	retlw	b'10000001'
	retlw	b'11111111'
	retlw	b'00000000'	;8
	retlw	b'01111110'
	retlw	b'01000010'
	retlw	b'01000010'
	retlw	b'01000010'
	retlw	b'01000010'
	retlw	b'01111110'
	retlw	b'00000000'
	retlw	b'00000000'	;16
	retlw	b'00000000'
	retlw	b'00111100'
	retlw	b'00100100'
	retlw	b'00100100'
	retlw	b'00111100'
	retlw	b'00000000'
	retlw	b'00000000'
	retlw	b'00000000'	;24
	retlw	b'00000000'
	retlw	b'00000000'
	retlw	b'00011000'
	retlw	b'00011000'
	retlw	b'00000000'
	retlw	b'00000000'
	retlw	b'00000000'
	retlw	b'11111111'	;32
	retlw	b'11111111'
	retlw	b'00011000'
	retlw	b'00011000'
	retlw	b'00011000'
	retlw	b'00011000'
	retlw	b'00011000'
	retlw	b'00011000'
	retlw	b'00111100'	;40
	retlw	b'01000010'
	retlw	b'11000011'
	retlw	b'11000011'
	retlw	b'11111111'
	retlw	b'11111111'
	retlw	b'11000011'
	retlw	b'11000011'
	retlw	b'11000011'	;48
	retlw	b'11100111'
	retlw	b'01100110'
	retlw	b'00011000'
	retlw	b'00011000'
	retlw	b'01100110'
	retlw	b'11100111'
	retlw	b'11000011'
	retlw	b'01111110'	;56
	retlw	b'01111110'
	retlw	b'00011000'
	retlw	b'00011000'
	retlw	b'00011000'
	retlw	b'00011000'
	retlw	b'01111110'
	retlw	b'01111110'
;++++ RETARDO ++++++++++
retard		;4998 cycles	;retardo de 5ms
	movlw	0xf
	movwf	d1
	movlw	0x04
	movwf	d2
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	Delay_0
	return	;2 cycles
;++++ RETARDO ++++++++++
rit		;998 cycles
	movlw	0xC7
	movwf	d1
	movlw	0x01
	movwf	d2
Delay_5
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	Delay_5
	return	;2 cycles
;+++++++++++++++++++++++++++++++++++
	end