;directives

	PROCESSOR       16F84A
    RADIX           HEX

;defs

	PCL		EQU 0x02
	OPTREG	EQU	0x01
	TMR		EQU 0x01
	INTCON	EQU 0x0B
	TMR0	EQU	0x01
	TRISB	EQU	0x06
	TRISA	EQU	0x05
	PORTA	EQU	0x05
	PORTB	EQU	0x06
	STATUS	EQU	0x03
	FSR		EQU	0x04
	INDF	EQU	0x00
	Z		EQU	2		; Z flags
	GIE		EQU 7		; GIE bit
	INTF	EQU 1		; INTF flag
	LOWL	EQU	0x20	; bottom layer (8 bit pattern)
	MIDL	EQU	0x21	; middle layer (8 bit pattern)
	HIGL	EQU	0x22	; upper layer (8 bit pattern)
	EXTL	EQU	0x23	; extra layer (9th led for each layer)
	TIME	EQU	0x24	; current frame speed
	TCONT	EQU 0x25	; frame speed counter
	LSEL	EQU 0x26	; layer selector
	BCONT	EQU 0x27	; brightness counter
	BRIG	EQU 0x28	; brightness
	CURL	EQU 0x29	; current layer
	
	

;program start

	ORG     0x0000		; start from address 0x0000

 	goto	Init	

	ORG		0x0004

Interrupt:				; interrupt service routine
	bcf		INTCON,INTF
	bsf		INTCON,GIE	; enabling the interrupt service
	movf	TMR,0		; pick a pattern at random
	andlw	0x07
	addwf	PCL,1		; jump into jump table
	goto	Pattern_treble
	goto	Pattern_updown
	goto	Pattern_twobars
	goto	Pattern_buildframe
	goto	Pattern_rotplane
	goto	Pattern_rlplane
	goto	Pattern_snake
	goto	Pattern_fourface


Init:					; initialization
	bsf		STATUS,5	; select RAM bank 1
	movlw	b'00000001'
	movwf	TRISB
	movlw	b'00000000'
	movwf	TRISA
	bcf		OPTREG,5	; start the TMR module in counter mode
	bcf		STATUS,5	; select RAM bank 0
	movlw	0x00		; all leds off
	movwf	PORTA
	movwf	PORTB
	clrf	LSEL		; no layer selected
	call	IdleCube



;******** ShowLayer **********************************
;
; Shows the layer encoded in W and EXTL for x msec.
; (BRIG/255)% of the time the layer is ON, the 
; remaining (255-BRIG)/255)% of the time the layer
; is OFF. (this is a PWM controlled brightness)
;
;*****************************************************

ShowLayer:	
	; layer on for (255/BRIG)*x msec
	; layer off for (255/(255-BRIG))*x msec
	; where x depends on the osc used

	; set the first seven leds (bit0 of PORTB is used to receive interrupts!) 
	movwf	PORTB		; PORTB <- W

	; set/clear the 8th led
	btfsc	CURL,0
	bsf		PORTA,2

	; test the 9th bit of the current layer and set
	; the 9th led accordingly (9th led = bit3 of PORTA)
	movf	EXTL,0
	andwf	LSEL,0		; W <- EXTL & LSEL
	btfss	STATUS,Z	; is the 9th bit clear (9th led off)?
	bsf		PORTA,3		; no, set the 9th bit
	
	; set the 9th bit of the current layer and turn on
	; the entire layer 
	movf	LSEL,0
	xorwf	PORTA,1		; PORTA <- W ^ LSEL

	; wait (BRIG/255)%
	movf	BRIG,0
	movwf	BCONT
ShowLayer_loop_layeron:
	decfsz	BCONT
	goto	ShowLayer_loop_layeron
	
	; turn off the entire layer
	clrf	PORTA

	; wait ((255-BRIG)/255)%
	movf	BRIG,0
	movwf	BCONT
	decf	BCONT,1
ShowLayer_loop_layeroff:
	incfsz	BCONT
	goto	ShowLayer_loop_layeroff

	return



;******** ShowCube ***********************************
;
; Shows the cube pattern for 0.01 * TIME sec using
; brightness level BRIG. The refresh rate is 100Hz.
;
;*****************************************************

ShowCube:

	; setup counter
	movf	TIME,0
	movwf	TCONT		; TCONT <- TIME

ShowCube_loop:

	; upper layer
	movlw	b'00010000'
	movwf	LSEL		; LSEL = b00010000;
	movf	HIGL,0
	movwf	CURL		; loads upper layer
	call	ShowLayer	; shows upper layer

	; mid layer
	movlw	b'00000010'
	movwf	LSEL		; LSEL = b00000010;
	movf	MIDL,0
	movwf	CURL		; loads mid layer
	call	ShowLayer	; shows mid layer

	; bottom layer
	movlw	b'00000001'
	movwf	LSEL		; LSEL = b00000001;
	movf	LOWL,0
	movwf	CURL		; loads bottom layer
	call	ShowLayer	; shows bottom layer

	; repeat until TCONT>0
	decfsz	TCONT,1
	goto	ShowCube_loop

	return



;******** IDLECUBE ***********************************
;
; The cube is glowing and ready to trigger... 
;
;*****************************************************

IdleCube:

	movlw	b'11111111'
	movwf	LOWL
	movlw	b'11111111'
	movwf	MIDL
	movlw	b'11111111'
	movwf	HIGL
	movlw	b'00010011'
	movwf	EXTL

	movlw	0x01
	movwf	BRIG	; smallest brightness
	movlw	0x02
	movwf	TIME	; smallest pattern duration

	bcf		INTCON,INTF
	bsf		INTCON,4	; enabling the interrupt from the RB0/INT pin
	bsf		INTCON,GIE	; enabling the interrupt service

IdleCube_fadein:				; fade in loop
	call	ShowCube
	incfsz	BRIG
	goto	IdleCube_fadein
IdleCube_fadeout:				; fade out loop
	call	ShowCube
	decfsz	BRIG
	goto	IdleCube_fadeout
	incf	BRIG,1
	goto	IdleCube_fadein



;******** PATTERN BUILDFRAME ************************
;
; Shows a self-building cube frame 
;
;*****************************************************

Pattern_buildframe

	movlw	0x00
	movwf	BRIG
	movlw	0x40
	movwf	TIME

Pattern_buildframe_loop:

	movlw	b'00000000'
	movwf	HIGL
	movlw	b'10000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'10010001'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00010001'
	movwf	HIGL
	movlw	b'10010001'
	movwf	MIDL
	movlw	b'00010001'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00010001'
	movwf	HIGL
	movlw	b'00010001'
	movwf	MIDL
	movlw	b'00010001'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'01110101'
	movwf	HIGL
	movlw	b'00010001'
	movwf	MIDL
	movlw	b'01110101'
	movwf	LOWL
	movlw	b'00010001'
	movwf	EXTL
	call	ShowCube
	movlw	b'01110101'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'01110101'
	movwf	LOWL
	movlw	b'00010001'
	movwf	EXTL
	call	ShowCube
	movlw	b'01110101'
	movwf	HIGL
	movlw	b'01100100'
	movwf	MIDL
	movlw	b'01110101'
	movwf	LOWL
	movlw	b'00010011'
	movwf	EXTL
	call	ShowCube
	movlw	b'01111111'
	movwf	HIGL
	movlw	b'01100100'
	movwf	MIDL
	movlw	b'01111111'
	movwf	LOWL
	movlw	b'00010011'
	movwf	EXTL
	call	ShowCube
	movlw	b'01111111'
	movwf	HIGL
	movlw	b'01100100'
	movwf	MIDL
	movlw	b'01111111'
	movwf	LOWL
	movlw	b'00010011'
	movwf	EXTL
	call	ShowCube
	movlw	b'01111111'
	movwf	HIGL
	movlw	b'01100100'
	movwf	MIDL
	movlw	b'01111111'
	movwf	LOWL
	movlw	b'00010011'
	movwf	EXTL
	call	ShowCube

	decfsz	BRIG
	goto	Pattern_buildframe_loop	
	goto	IdleCube



;******** PATTERN TWO BARS ***************************
;
; Shows two spinning bars
;
;*****************************************************

Pattern_twobars

	movlw	0x00
	movwf	BRIG
	movlw	0x20
	movwf	TIME

Pattern_twobars_loop:

	movlw	b'01000000'
	movwf	HIGL
	movwf	MIDL
	movwf	LOWL
	movlw	b'00010011'
	movwf	EXTL
	call	ShowCube
	movlw	b'00001010'
	movwf	HIGL
	movwf	MIDL
	movwf	LOWL
	clrf	EXTL
	call	ShowCube
	movlw	b'00100100'
	movwf	HIGL
	movwf	MIDL
	movwf	LOWL
	clrf	EXTL
	call	ShowCube
	movlw	b'00010001'
	movwf	HIGL
	movwf	MIDL
	movwf	LOWL
	clrf	EXTL
	call	ShowCube

	decfsz	BRIG
	goto	Pattern_twobars_loop	
	goto	IdleCube



;******** PATTERN UPDOWN *****************************
;
; Shows a layer moving up and down. 
;
;*****************************************************

Pattern_updown:

	movlw	0x00
	movwf	BRIG
	movlw	0x50
	movwf	TIME
	goto	Pattern_treble_loop



;******** PATTERN TREBLE *****************************
;
; Shows a fast flickering cube
;
;*****************************************************

Pattern_treble:

	movlw	0x00
	movwf	BRIG
	movlw	0x10
	movwf	TIME

Pattern_treble_loop:

	movlw	b'11111111'
	movwf	HIGL
	clrf	MIDL
	clrf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube

	clrf	HIGL
	movlw	b'11111111'
	movwf	MIDL
	clrf	LOWL
	movlw	b'00000010'
	movwf	EXTL
	call	ShowCube

	clrf	HIGL
	clrf	MIDL
	movlw	b'11111111'
	movwf	LOWL
	movlw	b'00000001'
	movwf	EXTL
	call	ShowCube

	decfsz	BRIG
	goto	Pattern_treble_loop	
	goto	IdleCube



;******** PATTERN SNAKE *****************************
;
; Shows a snake running across the cube
;
;*****************************************************

Pattern_snake

	movlw	0x00
	movwf	BRIG
	movlw	0x30
	movwf	TIME

Pattern_snake_loop:

	movlw	b'10100010'
	movwf	HIGL
	clrf	MIDL
	clrf	LOWL
	clrf	EXTL
	call	ShowCube
	movlw	b'00110010'
	movwf	HIGL
	clrf	MIDL
	clrf	LOWL
	clrf	EXTL
	call	ShowCube
	movlw	b'01110000'
	movwf	HIGL
	clrf	MIDL
	clrf	LOWL
	clrf	EXTL
	call	ShowCube
	movlw	b'01011000'
	movwf	HIGL
	clrf	MIDL
	clrf	LOWL
	clrf	EXTL
	call	ShowCube
	movlw	b'01001100'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00001101'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000101'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000011'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00100010'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00100010'
	movwf	HIGL
	movlw	b'00100000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00100000'
	movwf	HIGL
	movlw	b'00100000'
	movwf	MIDL
	movlw	b'00100000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00100000'
	movwf	MIDL
	movlw	b'00110000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'01110000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'01011000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'01001100'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00001101'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000001'
	movwf	MIDL
	movlw	b'00000101'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000001'
	movwf	MIDL
	movlw	b'00000001'
	movwf	LOWL
	movlw	b'00000010'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000011'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000010'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00100010'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000010'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00110010'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'01110000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'01011000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'01001100'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000100'
	movwf	HIGL
	movlw	b'00001100'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000101'
	movwf	HIGL
	movlw	b'00000100'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000101'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000011'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00100010'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00100010'
	movwf	HIGL
	movlw	b'00100000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00100000'
	movwf	HIGL
	movlw	b'00100000'
	movwf	MIDL
	movlw	b'00100000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00100000'
	movwf	MIDL
	movlw	b'00110000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'01110000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'01000000'
	movwf	MIDL
	movlw	b'01010000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'01000000'
	movwf	HIGL
	movlw	b'01000000'
	movwf	MIDL
	movlw	b'01000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'01010000'
	movwf	HIGL
	movlw	b'01000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'01110000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00110010'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00100010'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000010'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010010'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010011'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000001'
	movwf	LOWL
	movlw	b'00000011'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000101'
	movwf	LOWL
	movlw	b'00000001'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00001101'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'01001100'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'01000000'
	movwf	MIDL
	movlw	b'01001000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'01000000'
	movwf	HIGL
	movlw	b'01000000'
	movwf	MIDL
	movlw	b'01000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'01001000'
	movwf	HIGL
	movlw	b'01000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'11001000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'10001010'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube

	decfsz	BRIG
	goto	Pattern_snake_loop	
	goto	IdleCube


;******** PATTERN FOURFACE ******}********************
;
; Shows four faces of the cube
;
;*****************************************************

Pattern_fourface

	movlw	0x00
	movwf	BRIG
	movlw	0x30
	movwf	TIME

Pattern_fourface_loop:

	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'11111111'
	movwf	LOWL
	movlw	b'00000001'
	movwf	EXTL
	call	ShowCube
	movlw	b'01001100'
	movwf	HIGL
	movlw	b'01001100'
	movwf	MIDL
	movlw	b'01001100'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'11111111'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00100010'
	movwf	HIGL
	movlw	b'00100010'
	movwf	MIDL
	movlw	b'00100010'
	movwf	LOWL
	movlw	b'00010011'
	movwf	EXTL
	call	ShowCube

	decfsz	BRIG
	goto	Pattern_fourface_loop	
	goto	IdleCube

;******** PATTERN RLPLANE ***}************************
;
; Shows a raising-lowering horizontal plane
;
;*****************************************************

Pattern_rlplane

	movlw	0x00
	movwf	BRIG
	movlw	0x40
	movwf	TIME

Pattern_rlplane_loop:

	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'11111111'
	movwf	LOWL
	movlw	b'00000001'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'01001100'
	movwf	MIDL
	movlw	b'10110011'
	movwf	LOWL
	movlw	b'00000001'
	movwf	EXTL
	call	ShowCube
	movlw	b'01001100'
	movwf	HIGL
	movlw	b'10010001'
	movwf	MIDL
	movlw	b'00100010'
	movwf	LOWL
	movlw	b'00000001'
	movwf	EXTL
	call	ShowCube
	movlw	b'11011101'
	movwf	HIGL
	movlw	b'00100010'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000010'
	movwf	EXTL
	call	ShowCube
	movlw	b'11111111'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'10110011'
	movwf	HIGL
	movlw	b'01001100'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00100010'
	movwf	HIGL
	movlw	b'10010001'
	movwf	MIDL
	movlw	b'01001100'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00100010'
	movwf	MIDL
	movlw	b'11011101'
	movwf	LOWL
	movlw	b'00000010'
	movwf	EXTL
	call	ShowCube
	movlw	b'00000000'
	movwf	HIGL
	movlw	b'00000000'
	movwf	MIDL
	movlw	b'11111111'
	movwf	LOWL
	movlw	b'00000001'
	movwf	EXTL
	call	ShowCube

	decfsz	BRIG
	goto	Pattern_rlplane_loop	
	goto	IdleCube



;******** PATTERN ROTATEPLANE ************************
;
; Shows a rotating plane
;
;*****************************************************

Pattern_rotplane

	movlw	0x00
	movwf	BRIG
	movlw	0x30
	movwf	TIME

Pattern_rotplane_loop:

	movlw	b'00000000'
	movwf	HIGL
	movlw	b'11111111'
	movwf	MIDL
	movlw	b'00000000'
	movwf	LOWL
	movlw	b'00000010'
	movwf	EXTL
	call	ShowCube
	movlw	b'00100010'
	movwf	HIGL
	movlw	b'10010001'
	movwf	MIDL
	movlw	b'01001100'
	movwf	LOWL
	movlw	b'00010000'
	movwf	EXTL
	call	ShowCube
	movlw	b'10010001'
	movwf	HIGL
	movlw	b'10010001'
	movwf	MIDL
	movlw	b'10010001'
	movwf	LOWL
	movlw	b'00000000'
	movwf	EXTL
	call	ShowCube
	movlw	b'01001100'
	movwf	HIGL
	movlw	b'10010001'
	movwf	MIDL
	movlw	b'00100010'
	movwf	LOWL
	movlw	b'00000001'
	movwf	EXTL
	call	ShowCube

	decfsz	BRIG
	goto	Pattern_rotplane_loop	
	goto	IdleCube

	END
