; PIC16F690 Configuration Bit Settings

; Assembly source line config statements

#include "p16F690.inc"

	__CONFIG _FOSC_INTRCIO & _MCLRE_OFF &_WDTE_OFF & _PWRTE_OFF & _BOREN_OFF & _CPD_OFF & _CP_OFF & _IESO_OFF & _FCMEN_OFF
    
    errorlevel    -302    


;******************************************************************
;****************** P R O M E N N E *******************************
;******************************************************************
    
    cblock 0x20
	w_temp
	status_temp
	pclath_temp
	d1			;registry pro cekaci subrutiny
	d2
	d3
	hiByte
	loByte
	i2c_i
	i2c_tmp
	i2c_byte
	tmp
	tmpByte
	nonZeroByte
	numSecs
	numMilis
	index
	i				;writeByte	
	j				;LCD_draw_*
	tens			;desitky - bin2ascii
	ones			;jednotky - bin2ascii
	number			;vypisovana cislice
	dataPointer:2	;Ukazatel do dat fontu
	X
	X_copy
	Y
	Y_copy
	digit1
	expDigit1
	digit2
	expDigit2
	digit3
	expDigit3
	game_over		;T/F
	putCharOnly		;T/F
	ssd1306_X
	ssd1306_X_max
	ssd1306_Y
	ssd1306_Y_max	
	
	;WT588D player
	
	WT588D_i
	WT588D_tmp	
	
    endc

;******************************************************************
;****************** K O N S T A N T Y *****************************
;******************************************************************

FALSE						equ 0x00
TRUE						equ 0x01

;GAME
EXP_DIGIT1				equ .7
EXP_DIGIT2				equ .1
EXP_DIGIT3				equ .5

;SSD1306
I2C_ADDR				equ 0x78	;bin 0111 1000
I2C_CTRL_BYTE_C			equ 0x00	;bin 0000 0000 control byte: cmd
I2C_CTRL_BYTE_D			equ 0x40	;bin 0100 0000 control byte: data

;128x32 size
SSD1306_COLS_NUM			equ .128
SSD1306_PAGES_NUM			equ .4

SSD1306_SETCONTRAST			equ 0x81
SSD1306_DISPLAYALLON_RESUME equ	0xA4
SSD1306_DISPLAYALLON 		equ 0xA5
SSD1306_NORMALDISPLAY 		equ 0xA6
SSD1306_INVERTDISPLAY 		equ 0xA7
SSD1306_DISPLAYOFF 			equ 0xAE
SSD1306_DISPLAYON 			equ 0xAF
SSD1306_SETDISPLAYOFFSET 	equ 0xD3
SSD1306_SETCOMPINS 			equ 0xDA
SSD1306_SETVCOMDETECT 		equ 0xDB
SSD1306_SETDISPLAYCLOCKDIV 	equ 0xD5
SSD1306_SETPRECHARGE 		equ 0xD9
SSD1306_SETMULTIPLEX 		equ 0xA8
SSD1306_SETLOWCOLUMN 		equ 0x00
SSD1306_SETHIGHCOLUMN 		equ 0x10
SSD1306_SETSTARTLINE 		equ 0x40
SSD1306_MEMORYMODE 			equ 0x20
SSD1306_COLUMNADDR 			equ 0x21
SSD1306_PAGEADDR   			equ 0x22
SSD1306_COMSCANINC 			equ 0xC0
SSD1306_COMSCANDEC 			equ 0xC8
SSD1306_SEGREMAP 			equ 0xA0
SSD1306_CHARGEPUMP 			equ 0x8D
SSD1306_EXTERNALVCC 		equ 0x01
SSD1306_SWITCHCAPVCC 		equ 0x02
SSD1306_DEACTIVATE_SCROLL 	equ 0x2E

;WT588D
SOUND_00_CLICK1				equ 0x00
SOUND_01_CLICK2				equ 0x01
SOUND_02_WRONG				equ 0x02
SOUND_03_CORRECT			equ 0x03

;******************************************************************
;****************** D E F I N I C E *******************************
;******************************************************************
   
;Buttons
#define	B_BUTTON1	PORTA, RA0;
#define B_BUTTON2	PORTA, RA1;
#define B_BUTTON3	PORTA, RA2;
#define B_BUTTON4	PORTC, RC0;

;SSD1306
#define DISP_SCL	PORTC, RC7;
#define DISP_SDA	PORTB, RB7;

;WT588D   
#define WT588D_SCK	PORTB, RB6;
#define WT588D_CS	PORTB, RB5;
#define WT588D_SDA	PORTB, RB4;

;******************************************************************
;****************** M A K R A *************************************
;******************************************************************
 
BANK0 macro
    bcf STATUS, RP0 ;Select memory bank 0
    bcf STATUS, RP1 
    endm
    
BANK1 macro
    bsf STATUS, RP0 ;Select memory bank 1
    bcf STATUS, RP1 
    endm   
    
BANK2 macro
    bcf STATUS, RP0 ;Select memory bank 2
    bsf STATUS, RP1 
    endm   
    
BANK3 macro
    bsf STATUS, RP0 ;Select memory bank 3
    bsf STATUS, RP1 
    endm
    
  
;******************************************************************    
;*************************** S T A R T ****************************
;******************************************************************
    
	org 0x00
    goto main
	
	org 0x04
	goto interrupt

; ******************************************************************
; *********************** I N T E R R U P T ************************
; ******************************************************************

interrupt
	movwf w_temp 		;copy W to temp register, could be in either bank
	swapf STATUS,w 		;swap status to be saved into W	
	movwf status_temp 	;save status to bank 0 register


skip
	swapf status_temp,w	;swap status_temp register into W, sets bank to original state
	movwf STATUS 		;move W into STATUS register
	swapf w_temp,f 		;swap w_temp
	swapf w_temp,w 		;swap w_temp into W	
	retfie

; ******************************************************************
; ************************** M A I N *******************************
; ******************************************************************

main

	clrwdt
	nop
		
	BANK1
	movlw b'01100100'	;4MHz internal
	movwf OSCCON
	movlw b'11001000'
	movwf OPTION_REG

	;*** PORTA NASTAVENI ***
	BANK1	
	movlw b'00000111'	;RA2,1,0 = BUTTONy
	movwf TRISA

	BANK2
	clrf ANSEL
	clrf ANSELH
	clrf CM1CON0
	clrf CM2CON0

	BANK0 		
	clrf PORTA

	;*** PORTB NASTAVENI ***
	
	BANK1
	clrf TRISB
	BANK0
	clrf PORTB   
	clrf CCP1CON 		; Turn CCP module off

	;Inicializace Timer0
	clrf INTCON	

	;*** PORTC NASTAVENI ***
	
	BANK1
	movlw b'00000001'	;RC0-BUTTON ENTER
	movwf TRISC
	
	BANK0
	clrf PORTC

	;WT588D				;Nastav SCK a CS na log. 1
	bsf WT588D_SCK		;Pro WT588D
	bsf WT588D_CS	
			
;*******************************************************************
;******************* M A I N   L O O P *****************************
;*******************************************************************

		call ssd1306_init

GAME_START
		
		call GAME_init		
		
		call ssd1306_clearDisplay
		
		call GAME_showDigits
		
GAME_LOOP

		call GAME_handleButtons
		
		btfss game_over, 0
				
		goto GAME_LOOP
		
GAME_OVER
		
		call GAME_showHappy
		
		call WT588D_playCorrect
		
		goto GAME_START

;*******************************************************************
;******************* G A M E   R U T I N Y *************************
;*******************************************************************

GAME_init
	movlw FALSE
	movwf game_over
	
	clrf digit1
	clrf digit2
	clrf digit3	
	
	movlw EXP_DIGIT1
	movwf expDigit1
	movlw EXP_DIGIT2
	movwf expDigit2
	movlw EXP_DIGIT3
	movwf expDigit3
	return
	
GAME_showDigits
	call GAME_showDigit1
	call GAME_showDigit2
	call GAME_showDigit3
	return
	
GAME_computeDataPtr
;{
	movwf tmp
	
GAME_compute0
	
	movf tmp, f
	btfss STATUS, Z
	goto GAME_compute1
	
	movlw HIGH Table_digits
	movwf dataPointer+1
	movlw LOW Table_digits
	movwf dataPointer+0
	return
	
GAME_compute1
	decfsz tmp, f
	goto GAME_compute2
	
	movlw HIGH (Table_digits + .128)
	movwf dataPointer+1
	movlw LOW (Table_digits + .128)
	movwf dataPointer+0
	return	
	
GAME_compute2
	decfsz tmp, f
	goto GAME_compute3
	
	movlw HIGH (Table_digits + .256)
	movwf dataPointer+1
	movlw LOW (Table_digits + .256)
	movwf dataPointer+0
	return	
	
GAME_compute3
	decfsz tmp, f
	goto GAME_compute4
	
	movlw HIGH (Table_digits + .384)
	movwf dataPointer+1
	movlw LOW (Table_digits + .384)
	movwf dataPointer+0
	return	
	
GAME_compute4
	decfsz tmp, f
	goto GAME_compute5
	
	movlw HIGH (Table_digits + .512)
	movwf dataPointer+1
	movlw LOW (Table_digits + .512)
	movwf dataPointer+0
	return	
	
GAME_compute5
	decfsz tmp, f
	goto GAME_compute6
	
	movlw HIGH (Table_digits + .640)
	movwf dataPointer+1
	movlw LOW (Table_digits + .640)
	movwf dataPointer+0
	return	
	
GAME_compute6
	decfsz tmp, f
	goto GAME_compute7
	
	movlw HIGH (Table_digits + .768)
	movwf dataPointer+1
	movlw LOW (Table_digits + .768)
	movwf dataPointer+0
	return	
	
GAME_compute7
	decfsz tmp, f
	goto GAME_compute8
	
	movlw HIGH (Table_digits + .896)
	movwf dataPointer+1
	movlw LOW (Table_digits + .896)
	movwf dataPointer+0
	return	
	
GAME_compute8
	decfsz tmp, f
	goto GAME_compute9
	
	movlw HIGH (Table_digits + .1024)
	movwf dataPointer+1
	movlw LOW (Table_digits + .1024)
	movwf dataPointer+0
	return	
	
GAME_compute9
	decfsz tmp, f
	return
	
	movlw HIGH (Table_digits + .1152)
	movwf dataPointer+1
	movlw LOW (Table_digits + .1152)
	movwf dataPointer+0
	return	
	
;}

GAME_showDigit1
;{		
		movlw	.0	
		movwf	ssd1306_X
		movlw	.31
		movwf 	ssd1306_X_max
		movlw	.0
		movwf	ssd1306_Y
		movlw	.3		
		movwf	ssd1306_Y_max
		
		movf digit1, w
		call GAME_computeDataPtr			
		call ssd1306_sprite	
		return
;}
		
GAME_showDigit2
;{
		movlw	.32
		movwf	ssd1306_X
		movlw	.32 + .31
		movwf 	ssd1306_X_max
		movlw	.0
		movwf	ssd1306_Y
		movlw	.3		
		movwf	ssd1306_Y_max		
		
		movf digit2, w
		call GAME_computeDataPtr			
		call ssd1306_sprite	
		return
;}
		
GAME_showDigit3
;{
		movlw	.64
		movwf	ssd1306_X
		movlw	.64 + .31
		movwf 	ssd1306_X_max
		movlw	.0
		movwf	ssd1306_Y
		movlw	.3		
		movwf	ssd1306_Y_max		
		
		movf digit3, w
		call GAME_computeDataPtr			
		call ssd1306_sprite
		return
;}


GAME_showHappy
;{
		movlw	.96
		movwf	ssd1306_X
		movlw	.96 + .31
		movwf 	ssd1306_X_max
		movlw	.0
		movwf	ssd1306_Y
		movlw	.3		
		movwf	ssd1306_Y_max		
		
		movlw HIGH Table_happy
		movwf dataPointer+1
		movlw LOW Table_happy
		movwf dataPointer+0		
		call ssd1306_sprite			
		return
;}


GAME_handleButtons
;{
	btfss B_BUTTON1
	goto GAME_checkButton2
	
	movlw .5
	call waitMilis
	
	btfss B_BUTTON1
	return
	
GAME_handleB1				;Pockej na uvolneni stisku
	btfsc B_BUTTON1
	goto GAME_handleB1
		
	movf digit1, w
	call GAME_incValue
	movwf digit1
	
	movlw .1
	call GAME_playClick
	
	goto GAME_showDigit1
			
GAME_checkButton2
	btfss B_BUTTON2
	goto GAME_checkButton3
	
	movlw .5
	call waitMilis	
	
	btfss B_BUTTON2
	return
	
GAME_handleB2				;Pockej na uvolneni stisku
	btfsc B_BUTTON2
	goto GAME_handleB2

	movf digit2, w
	call GAME_incValue
	movwf digit2
	
	movlw .2
	call GAME_playClick
		
	goto GAME_showDigit2
	
GAME_checkButton3
	btfss B_BUTTON3
	goto GAME_checkButton4
	
	movlw .5
	call waitMilis	
	
	btfss B_BUTTON3
	return
	
GAME_handleB3				;Pockej na uvolneni stisku
	btfsc B_BUTTON3
	goto GAME_handleB3
	
	movf digit3, w
	call GAME_incValue
	movwf digit3
	
	movlw .4
	call GAME_playClick	
	
	goto GAME_showDigit3
	
GAME_checkButton4

	btfss B_BUTTON4
	return
	
	movlw .5
	call waitMilis	
	
	btfss B_BUTTON4
	return
	
GAME_handleB4				;Pockej na uvolneni stisku
	btfsc B_BUTTON4
	goto GAME_handleB4
		
	call GAME_checkValidity
	
	;Pokud jsme nenastavili game_over, pak byl kod spatne
	
	btfss game_over, 0
	goto WT588D_playWrong	
	return
;}

;Input W-reg - bity 0, 1, 2 = digit 1, 2, 3 
; pokud je dana cislice na dane pozici ta spravna,
; prehrej "trosku" jiny zvuk (click2)
GAME_playClick
;{
	movwf tmp
	
GAME_playClick_d1
	btfss tmp, 0	;digit 1?
	goto GAME_playClick_d2
	movlw EXP_DIGIT1
	subwf digit1, w
	btfss STATUS, Z
	goto GAME_playClickNormal
	goto GAME_playClickSecret

GAME_playClick_d2	
	btfss tmp, 1	;digit 2?
	goto GAME_playClick_d3
	movlw EXP_DIGIT2
	subwf digit2, w
	btfss STATUS, Z
	goto GAME_playClickNormal
	goto GAME_playClickSecret	

GAME_playClick_d3	
	btfss tmp, 2	;digit 3?
	return			;urcite bude jedna z digits
	movlw EXP_DIGIT3
	subwf digit3, w
	btfss STATUS, Z
	goto GAME_playClickNormal
	goto GAME_playClickSecret	
		
GAME_playClickNormal
	goto WT588D_playClick1

GAME_playClickSecret	
	goto WT588D_playClick2

;}

GAME_incValue
;{
	movwf tmp
	incf tmp, f
	movlw .10
	subwf tmp, w
	btfss STATUS, Z
	goto GAME_incNot10
	clrw
	return
	
GAME_incNot10
	movf tmp, w
	return		
;}

GAME_checkValidity
;{
	movf digit1, w
	subwf expDigit1, w
	btfss STATUS, Z
	return
	movf digit2, w
	subwf expDigit2, w
	btfss STATUS, Z
	return
	movf digit3, w
	subwf expDigit3, w
	btfss STATUS, Z
	return
	movlw TRUE
	movwf game_over
	return
;}


WT588D_playClick1
;{
	movlw SOUND_00_CLICK1
	goto WT588D_doSoundFX
;}

WT588D_playClick2
;{
	movlw SOUND_01_CLICK2
	goto WT588D_doSoundFX
;}

WT588D_playWrong
;{
	movlw SOUND_02_WRONG
	call WT588D_doSoundFX
	goto wait1s	
;}

WT588D_playCorrect
;{
	movlw SOUND_03_CORRECT
	call WT588D_doSoundFX
	goto wait1s	
;}


WT588D_doSoundFX
;{
		movwf WT588D_tmp
	
		;Nastav SCK a CS na log. 1
		movlw b'01100000'		;SCK log. 1, CS log. 1
		movwf PORTB
		
		movlw .17
		call waitMilis
		
		movlw b'01000000'		;SCK log. 1, CS log. 0
		movwf PORTB				;Slave Select = LOW (Initiating transmission)
		
		movlw .2
		call waitMilis

		;Ted projdu postupne bit 0, bit 1, bit 2, bit 3 a nastavuju podle toho log 1 nebo log 0

		movlw .8
		movwf WT588D_i
		
cycle	bcf WT588D_SCK		;Clock na log. 0, zaciname prenos dat			

		btfss WT588D_tmp, 0;  bit 0 nastaven?
		goto btNotSet
		bsf WT588D_SDA		 ; ano, posli log 1
		goto tsted
btNotSet bcf WT588D_SDA		; ne, posli log 0 na vystup
tsted	call WT588D_wait30us

		bsf WT588D_SCK		;Clock na log. 1, skoncili jsme prenos 1 bitu	
		call WT588D_wait30us

		rrf WT588D_tmp, f
		decfsz WT588D_i, f
		goto cycle

		movlw b'01100000'	;SDA log. 0, CS log. 1, SCK log. 1
		movwf PORTB			;Slave Select = HI

		return
;}


WT588D_wait30us
;{
			;55 cycles
	movlw	0x12
	movwf	d1
wait30us_0
	decfsz	d1, f
	goto	wait30us_0

			;1 cycle
	nop

			;4 cycles (including call)
	return
;}


; ******************************************************************
; ******************** SSD1306 I2C DISPLAY DRIVER ******************
; ******************************************************************		

ssd1306_init	
;{		
			call wait1s

			movlw SSD1306_DISPLAYOFF			;0xAE
			call i2c_sendCmd

			movlw SSD1306_SETDISPLAYCLOCKDIV 	;0xD5
			call i2c_sendCmd
			movlw 0x80				
			call i2c_sendCmd

			movlw SSD1306_SETMULTIPLEX			;0xA8
			call i2c_sendCmd
			movlw 0x1F		;128x32
			;movlw 0x3F		;128x64
			call i2c_sendCmd
			
			movlw SSD1306_SETDISPLAYOFFSET		;0xD3
			call i2c_sendCmd
			movlw 0x00
			call i2c_sendCmd

			movlw SSD1306_SETSTARTLINE			;0x40
			call i2c_sendCmd

			movlw SSD1306_CHARGEPUMP			;0x8D
			call i2c_sendCmd
			movlw 0x14
			call i2c_sendCmd

			movlw SSD1306_MEMORYMODE			;0x20
			call i2c_sendCmd
			movlw 0x00			;horizontal addressing
			call i2c_sendCmd
			
			movlw SSD1306_SEGREMAP | 0x01		;0xA1			
			call i2c_sendCmd		;rotate screen 180

			movlw SSD1306_COMSCANDEC			;0xC8
			call i2c_sendCmd

			movlw SSD1306_SETCOMPINS			;0xDA
			call i2c_sendCmd
			;movlw 0x12		;128x64		
			movlw 0x02		;128x32
			call i2c_sendCmd			

			movlw SSD1306_SETCONTRAST			;0x81
			call i2c_sendCmd
			movlw 0x8F
			call i2c_sendCmd

			movlw SSD1306_SETPRECHARGE			;0xD9
			call i2c_sendCmd
			movlw 0xF1
			call i2c_sendCmd

			movlw SSD1306_SETVCOMDETECT			;0xDB
			call i2c_sendCmd
			movlw 0x40
			call i2c_sendCmd

			movlw SSD1306_DISPLAYALLON_RESUME	;0xA4
			call i2c_sendCmd

			movlw SSD1306_NORMALDISPLAY			;0xA6
			call i2c_sendCmd

			movlw SSD1306_DEACTIVATE_SCROLL 	;0x2E
			call i2c_sendCmd

			movlw SSD1306_DISPLAYON				;0xAF
			call i2c_sendCmd

			call ssd1306_clearDisplay

			call ssd1306_setHome				;pos 0,0

			return
;}



;Vykresli obdelnik grafickymi daty
;Vstup: dataPointer - ktera data
;Vstup: X, X_max, Y, Y_max - obdelnik, do ktereho se kresli
;Vstup: 128Bytes delka dat (32x32px)
ssd1306_sprite
;{
		call ssd1306_setXY

		call i2c_startCond
		call i2c_sendAddr

		movlw I2C_CTRL_BYTE_D
		call i2c_sendByte2

		movlw .128
		movwf i
looping call getNextByte

		call i2c_sendByte2
			
		decfsz i, f
		goto looping

		call i2c_stopCond
		
		return
;}		


getNextByte
;{
		call getNextByte2 	;To je patch kvuli strankovani
		clrf PCLATH
		incfsz dataPointer+0, f	;Inkrementuj pointer
		goto $+2
		incf dataPointer+1, f
		return 					;Vrat hodnotu (je stale ve W)

getNextByte2
		;Zde se pouze skoci na dvoubajtovou adresu v fontPointer
		movf dataPointer+1, w 	;Zkopiruj HI byte do PCLATHu
		movwf PCLATH
		movf dataPointer+0, w 	;Dej LO byte do PCL
		movwf PCL 				;Skoci na adresu, kam ukazuje fontPointer	
;}
ssd1306_setHome
;{
		movlw SSD1306_COLUMNADDR
		call i2c_sendCmd
		movlw 0x00						;X - pos 0
		call i2c_sendCmd
		movlw SSD1306_COLS_NUM-1		;X - pos max
		call i2c_sendCmd

		movlw SSD1306_PAGEADDR
		call i2c_sendCmd
		movlw 0x00						;Y - pos 0
		call i2c_sendCmd
		movlw SSD1306_PAGES_NUM-1		;Y - pos MAX
		call i2c_sendCmd
		return
;}

ssd1306_setXY
;{
		movlw SSD1306_COLUMNADDR
		call i2c_sendCmd
		movf ssd1306_X, w				
		call i2c_sendCmd
		movf ssd1306_X_max, w			;X - pos max
		call i2c_sendCmd

		movlw SSD1306_PAGEADDR
		call i2c_sendCmd
		movf ssd1306_Y, w
		call i2c_sendCmd
		movf ssd1306_Y_max, w			;Y - pos MAX
		call i2c_sendCmd
		return
;}


ssd1306_clearDisplay
;{
		call ssd1306_setHome

		call i2c_startCond

		call i2c_sendAddr

		movlw I2C_CTRL_BYTE_D
		call i2c_sendByte2

		movlw SSD1306_PAGES_NUM 
		movwf i

ssd1306_i	
		movlw SSD1306_COLS_NUM		
		movwf j

ssd1306_j	
		clrw

		call i2c_sendByte2
					
		decfsz j, f
		goto ssd1306_j
	
		decfsz i, f
		goto ssd1306_i

		call i2c_stopCond
		return
;}

i2c_startCond
;{		
		bsf DISP_SDA
		bsf DISP_SCL
		bcf DISP_SDA
		bcf DISP_SCL

		return
;}
				
; ***** OLED: I2C: SEND STOP CONDITION

i2c_stopCond
;{		
		bcf DISP_SDA
		bsf DISP_SCL
		bsf DISP_SDA
		return
;}

; ***** OLED: I2C: SEND ADDRESS
i2c_sendAddr
;{		
		movlw I2C_ADDR
		call i2c_sendByte2
		return
;}

; ***** OLED: I2C: SEND BYTE

i2c_sendCmd
;{		
		movwf i2c_byte

		call i2c_startCond

		call i2c_sendAddr

		movlw I2C_CTRL_BYTE_C				
		call i2c_sendByte2

		call i2c_sendByte

		call i2c_stopCond
		return					
;}


i2c_sendData
;{		
		movwf i2c_byte
		call i2c_startCond
		call i2c_sendAddr

		movlw I2C_CTRL_BYTE_D
		call i2c_sendByte2

		call i2c_sendByte
		call i2c_stopCond
		return		
;}




; ***** OLED: I2C: SEND
i2c_sendByte		
;{
					movf i2c_byte, w
i2c_sendByte2		movwf i2c_tmp

					movlw .8
					movwf i2c_i
		
i2c_cycle			btfss i2c_tmp, 7		
					goto i2c_bitNotSet
					bcf DISP_SCL ;Abych mel hrany co nejbliz u sebe
					bsf DISP_SDA		
					goto i2c_tested
i2c_bitNotSet 		bcf DISP_SCL
					bcf DISP_SDA	

i2c_tested			bsf DISP_SCL		                  

					rlf i2c_tmp, f
					decfsz i2c_i, f
					goto i2c_cycle

					;ACK BIT
					bcf DISP_SCL
					bcf DISP_SDA					
					bsf DISP_SCL
					bcf DISP_SCL
					return	

	

; *** SUBRUTINA, CEKEJ nuMilis milisekund ***************************

; *** SUBRUTINA, CEKEJ 150us 
wait150us 	
;{
	call wait30us
	call wait30us
	call wait30us
	call wait30us
	call wait30us
	return
;}

; *** SUBRUTINA, CEKEJ 30us (=30 jednotaktovych instrukci)

wait30us	
;{
			nop		;26, 2 na zacatku sezere volani call
			nop
			nop
			nop
			nop
		 	nop
			nop
			nop
			nop
			nop
wait20us	nop
			nop
			nop
			nop
			nop
		 	nop
			nop
			nop
			nop
			nop
wait10us	nop
			nop
			nop
			nop
			nop
wait5us	 	nop
			return;		ta je za 2 cykly
;}

; Delay = 1 seconds
; Clock frequency = 4 MHz

; Actual delay = 1 seconds = 1000000 cycles
; Error = 0 %

wait1s
;{
			;999990 cycles
	movlw	0x07
	movwf	d1
	movlw	0x2F
	movwf	d2
	movlw	0x03
	movwf	d3
wait1s_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	wait1s_0

	;6 cycles
	goto	$+1
	goto	$+1
	goto	$+1

			;4 cycles (including call)
	return
;}

waitMilis
;{
		movwf numMilis
waitM	call wait1ms
		decfsz numMilis, f
		goto waitM
		return
;}

; Delay = 0.001 seconds
; Clock frequency = 4 MHz

; Actual delay = 0.001 seconds = 1000 cycles
; Error = 0 %

wait1ms
;{
			;993 cycles
	movlw	0xC6
	movwf	d1
	movlw	0x01
	movwf	d2
wait1ms_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	wait1ms_0

			;3 cycles
	goto	$+1
	nop

			;4 cycles (including call)
	return	
;}


; *** SUBRUTINY pro 16bitovy counter ********************************	
; *** Nastavi Zero, pokud jsme na nule

incHL	incfsz loByte, f
		return	
		incf hiByte, f
		return

decHL	movf loByte, f
		btfsc STATUS, Z ;je loByte na nule?
		goto decHL2
		decf loByte, w	;kopie pro nasledny OR (test na 0)
		decf loByte, f
		iorwf hiByte, w ;Z flag nastaven pri 0 (loByte OR hiByte)
		return
decHL2	decf loByte, f
		decf hiByte, f
		bcf STATUS, Z	;Potrebuju vynulovat Zero (aby mi pri lo/hi 0/1 predchozi decf Z nenastavil)
		return
	
; *** SUBRUTINA pro prevod 6bit binary to BCD ********************************	
	
bin2ascii
	clrf tens
	addlw .256 - .100
digit100
	addlw .20
	btfss STATUS,C
	goto  digit40
	bsf   tens,3
	addlw .256 - .20
	goto digit10
digit40
	addlw .40
	btfss STATUS,C
	goto  $+3
	bsf   tens,2
	addlw .256 - .40
	addlw .20
	btfss STATUS,C
	goto  $+3
	bsf   tens,1
	addlw .256 - .20
digit10
	addlw .10
	btfss STATUS,C
	goto  $+3
	bsf   tens,0
	addlw .256 - .10
	
	addlw .10
	movwf ones
	
	movlw '0'
	addwf tens, f
	addwf ones, f
	return	

; *****************************************************************	
; ********************** G F X    D A T A *************************
; *****************************************************************

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;POZOR - dt ma OMEZENOU velikost, nejlepe davat 16 hodnot na radek
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

					org 0x0300
					
Table_happy

	dt 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x70, 0x38, 0x1C, 0x0C, 0x0E, 0x06, 0x06, 0x03, 0x03, 0x03, 0x03
	dt 0x03, 0x03, 0x03, 0x03, 0x06, 0x06, 0x0E, 0x0C, 0x1C, 0x38, 0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00 
	dt 0xF0, 0xFE, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x7E, 0x3C, 0x00, 0x00
	dt 0x00, 0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x7E, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0xFE, 0xF0 
	dt 0x0F, 0x7F, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x38, 0xF8, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0x38, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0x7F, 0x0F 
	dt 0x00, 0x00, 0x01, 0x03, 0x07, 0x0E, 0x1C, 0x38, 0x30, 0x71, 0x61, 0x63, 0xC6, 0xC6, 0xC6, 0xC6
	dt 0xC6, 0xC6, 0xC6, 0xC6, 0x63, 0x61, 0x71, 0x30, 0x38, 0x1C, 0x0E, 0x07, 0x03, 0x01, 0x00, 0x00 
				
				
					org 0x0400
Table_digits
	; @0 '0' (31 pixels wide)
	;      #####################     
	;    #########################   
	;   ######################## ##  
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	;   ##                       ##  
	;                                
	;  ####                     #### 
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	;  ### ##################### ##  
	;    #########################   
	;      #####################     
		dt 0xF8, 0xF8, 0xFC, 0xFE, 0xFE, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
		dt 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFA, 0xFE, 0xFC, 0xF8, 0xF8, 0x00
		dt 0x7F, 0x7F, 0xFF, 0xFF, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0xFF, 0xFF, 0x7F, 0x7F, 0x00
		dt 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0x00 
		dt 0x1F, 0x3F, 0x3F, 0x7F, 0x5F, 0xE1, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0
		dt 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE1, 0x5F, 0x7F, 0x3F, 0x1F, 0x1F, 0x00 

	; @124 '1' (31 pixels wide)
	;                                
	;                                
	;                            ##  
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                            ##  
	;                                
	;                           #### 
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                            ##  
	;                                
	;                                
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFC, 0xFC, 0xF8, 0xF8, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0xFF, 0xFF, 0x7F, 0x7F, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1F, 0x3F, 0x3F, 0x1F, 0x1F, 0x00

	; @248 '2' (31 pixels wide)
	;      #####################     
	;    #########################   
	;     ###################### ##  
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;      #########   ######### ##  
	;    #########################   
	;  #############   #########     
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	; #####                          
	; #####                          
	; #####                          
	; #####                          
	;  ### #####################     
	;    #########################   
	;      #####################     
		dt 0x00, 0x00, 0x00, 0x02, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
		dt 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFA, 0xFE, 0xFC, 0xF8, 0xF8, 0x00 
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00
		dt 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0x7F, 0x00
		dt 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01
		dt 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00
		dt 0x1F, 0x3F, 0x3F, 0x7F, 0x5F, 0xE1, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0
		dt 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00

	; @372 '3' (31 pixels wide)
	;      #####################     
	;    ########################    
	;     #########################  
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;      #########   ######### ##  
	;    #########################   
	;      #########   ############# 
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;      ##################### ##  
	;    #########################   
	;      #####################     
		dt 0x00, 0x00, 0x00, 0x02, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
		dt 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00
		dt 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0x7F, 0x00
		dt 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01
		dt 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0x00
		dt 0x00, 0x00, 0x00, 0x40, 0x40, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0
		dt 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE1, 0x5F, 0x7F, 0x3F, 0x1F, 0x1F, 0x00

	; @496 '4' (31 pixels wide)
	;                                
	;                                
	;   ##                       ##  
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	;   ## #########   ######### ##  
	;    #########################   
	;      #########   ############# 
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                            ##  
	;                                
	;                                
		dt 0xF8, 0xF8, 0xFC, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFC, 0xFC, 0xF8, 0xF8, 0x00
		dt 0x7F, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00
		dt 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0x7F, 0x00
		dt 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01
		dt 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1F, 0x3F, 0x3F, 0x1F, 0x1F, 0x00

	; @620 '5' (31 pixels wide)
	;      #####################     
	;    #########################   
	;   ########################     
	; #####                          
	; #####                          
	; #####                          
	; #####                          
	; #####                          
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	;   ## #########   #########     
	;    #########################   
	;      #########   ############# 
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;      ##################### ##  
	;    #########################   
	;      #####################     
		dt 0xF8, 0xF8, 0xFC, 0xFE, 0xFE, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
		dt 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00
		dt 0x7F, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00
		dt 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01
		dt 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0x00
		dt 0x00, 0x00, 0x00, 0x40, 0x40, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0
		dt 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE1, 0x5F, 0x7F, 0x3F, 0x1F, 0x1F, 0x00

	; @744 '6' (31 pixels wide)
	;      #####################     
	;    #########################   
	;   ########################     
	; #####                          
	; #####                          
	; #####                          
	; #####                          
	; #####                          
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	; ######                         
	;   ## #########   #########     
	;    #########################   
	;  #############   ############# 
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	;  ### ##################### ##  
	;    #########################   
	;      #####################     
		dt 0xF8, 0xF8, 0xFC, 0xFE, 0xFE, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
		dt 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00
		dt 0x7F, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00
		dt 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01
		dt 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0x00
		dt 0x1F, 0x3F, 0x3F, 0x7F, 0x5F, 0xE1, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0
		dt 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE1, 0x5F, 0x7F, 0x3F, 0x1F, 0x1F, 0x00

	; @868 '7' (31 pixels wide)
	;      #####################     
	;    ########################    
	;     #########################  
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                            ##  
	;                                
	;                           #### 
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;                            ##  
	;                                
	;                                
		dt 0x00, 0x00, 0x00, 0x02, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
		dt 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0xFF, 0xFF, 0x7F, 0x7F, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1F, 0x3F, 0x3F, 0x1F, 0x1F, 0x00

	; @992 '8' (31 pixels wide)
	;      #####################     
	;    #########################   
	;   ######################## ##  
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	;   ## #########   ######### ##  
	;    #########################   
	;  #############   ############# 
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	;  ### ##################### ##  
	;    #########################   
	;      #####################     
		dt 0xF8, 0xF8, 0xFC, 0xFE, 0xFE, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
		dt 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFA, 0xFE, 0xFC, 0xF8, 0xF8, 0x00
		dt 0x7F, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00
		dt 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0x7F, 0x00
		dt 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01
		dt 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0x00
		dt 0x1F, 0x3F, 0x3F, 0x7F, 0x5F, 0xE1, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0
		dt 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE1, 0x5F, 0x7F, 0x3F, 0x1F, 0x1F, 0x00

	; @1116 '9' (31 pixels wide)
	;      #####################     
	;    #########################   
	;   ######################## ##  
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; #####                     #####
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	; ######                   ######
	;   ## #########   ######### ##  
	;    #########################   
	;      #########   ############# 
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                          ######
	;                           #####
	;                           #####
	;                           #####
	;                           #####
	;      ##################### ##  
	;    #########################   
	;      #####################     
		dt 0xF8, 0xF8, 0xFC, 0xFE, 0xFE, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
		dt 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFA, 0xFE, 0xFC, 0xF8, 0xF8, 0x00		
		dt 0x7F, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00
		dt 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0x7F, 0x00
		dt 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01
		dt 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0x00
		dt 0x00, 0x00, 0x00, 0x40, 0x40, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0
		dt 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE1, 0x5F, 0x7F, 0x3F, 0x1F, 0x1F, 0x00
; *** KONEC SOUBORU *************************************************	
	end