#include "p16F886.inc"

	__CONFIG _CONFIG1, (_FOSC_HS & _DEBUG_OFF & _LVP_OFF & _WDTE_OFF & _MCLRE_OFF & _PWRTE_OFF & _BOREN_OFF & _CP_OFF & _CPD_OFF & _IESO_OFF & _FCMEN_OFF);
	__CONFIG _CONFIG2, (_WRT_OFF & _BOR4V_BOR21V);

    errorlevel    -302

;******************************************************************
;****************** P R O M E N N E *******************************
;******************************************************************

    cblock 0x20

	w_temp
	status_temp
	pclath_temp

	del1			;registry pro cekaci subrutiny
	del2
	del3

	hiByte
	loByte
	tmp				;writeByte

	numSecs
	numMilis

	i				;writeByte
	j				;
	k

	tens			;desitky - bin2ascii
	ones			;jednotky - bin2ascii

	dataPointer: .2	;pointer na gfx data
	textPointer: .2 ;ukazatel do textu

	TFT_i
	TFT_j
	TFT_k
	TFT_tmp
	TFT_byte		;8bit cislo
	TFT_word:	.2	;16bit cislo
	TFT_X:		.2	;pozice pro display window
	TFT_X_COPY: .2
	TFT_X_MAX:	.2
	TFT_Y:		.2
	TFT_Y_COPY: .2
	TFT_Y_MAX:	.2

	TFT_width		;sirka okna
	TFT_height		;vyska okna
	TFT_lineThickness		;tloustka cary v px
	TFT_lineLength: .2		;delka cary v px
	TFT_drawHorizontal		;true/false

	TFT_FGColor:.2		;foreground
	TFT_BGColor:.2		;background
	TFT_hide			;TRUE/FALSE - pro draw/hide operace

	TFT_number: .5	;prostor pro ulozeni vypisovaneho cisla A.BCD

	TFT_putChar		;FALSE/TRUE - vypis text / 1 znak
	TFT_textZoom	;Zoomuj Y/XY FALSE/TRUE

	GAME_round	;kolikaty pokus 0,1,2,3 = 1,2,3,avg
	GAME_timerH		;aktualne namereny cas v ms
	GAME_timerL
	GAME_totalTimeH
	GAME_totalTimeL
	GAME_isTimeout	;2sec uplnynuly?
	GAME_timeoutH	;2000ms counter
	GAME_timeoutL
	GAME_roundCounter
	GAME_top5Achieved	;Mame zapis do TOP5?
	GAME_isCheating	;Podvadi hrac (drzi STOP button pred rozsvicenim LEDky)?
	
	GAME_randH
	GAME_randL		;Pro generovani nahodneho casu

	TOP5_positionTop5	;Kam patri vysledny cas v TOP5 (1-5)
	TOP5_copyFrom
	TOP5_copyTo
	TOP5_char			;Prave vkladany znak

	UTIL_TenK
	UTIL_Thou
	UTIL_Hund
	UTIL_Tens
	UTIL_Ones

	UTIL_NumH
	UTIL_NumL

	UTIL_DividendH
	UTIL_DividendL
	UTIL_QuotientH
	UTIL_QuotientL

	EEPROM_addr
	EEPROM_value

    endc

	;BANK2
	cblock 0x120
		EEPROM_Top5:.25
	endc

;******************************************************************
;****************** K O N S T A N T Y *****************************
;******************************************************************

ADDR_GFX_DATA_START	equ 0x800

TOP5_TABLE_ADDR		equ 0x20 ;v BANK2 (25 bytes)

FALSE				equ 0x00
TRUE				equ 0x01

;TFT 2.4" LCD
TFT_WIDTH 			equ .320	;px
TFT_HEIGHT 			equ .240	;px

;Levy horni roh herniho formu, od nej se odviji vsechny dalsi prvky
FORM_X				equ .18
FORM_Y				equ .72

FORM_GAP			equ .2 		;padding v px

FORM_LINE_THICKNESS equ .2
FORM_HLINE_LENGTH	equ .204
FORM_VLINE_LENGTH 	equ .240

FORM_HLINE1_Y		equ FORM_Y
FORM_HLINE2_Y		equ FORM_Y + .30
FORM_HLINE3_Y		equ FORM_HLINE2_Y + .154
FORM_HLINE4_Y		equ FORM_HLINE3_Y + .54

FORM_VLINE1_X		equ FORM_X
FORM_VLINE2_X		equ FORM_VLINE1_X + .54
FORM_VLINE3_X		equ FORM_VLINE2_X + .150

FORM_START1_LABEL_X	equ .60
FORM_START1_LABEL_Y	equ .34
FORM_START1_WIDTH	equ .120
FORM_START1_HEIGHT	equ .17

FORM_START2_LABEL_X	equ .60
FORM_START2_LABEL_Y	equ FORM_START1_LABEL_Y
FORM_START2_WIDTH	equ .120
FORM_START2_HEIGHT	equ .7

FORM_WAIT1_LABEL_X	equ .60
FORM_WAIT1_LABEL_Y	equ .34
FORM_WAIT1_WIDTH	equ .120
FORM_WAIT1_HEIGHT	equ .17

FORM_WAIT2_LABEL_X	equ .60
FORM_WAIT2_LABEL_Y	equ FORM_WAIT1_LABEL_Y
FORM_WAIT2_WIDTH	equ .120
FORM_WAIT2_HEIGHT	equ .7

FORM_TRY_LABEL_X	equ FORM_X + .4
FORM_TRY_LABEL_Y	equ FORM_Y + .4
FORM_TRY_WIDTH		equ .48 ;px
FORM_TRY_HEIGHT		equ .24 ;px

FORM_TIME_LABEL_X	equ FORM_X + .104
FORM_TIME_LABEL_Y	equ FORM_Y + .4
FORM_TIME_WIDTH		equ .48 ;px
FORM_TIME_HEIGHT	equ .24 ;px

FORM_AVG_LABEL_X	equ FORM_X + .4
FORM_AVG_LABEL_Y	equ FORM_HLINE3_Y + FORM_GAP + .12
FORM_AVG_WIDTH		equ .48 ;px
FORM_AVG_HEIGHT		equ .24 ;px

TIME_DIGIT_WIDTH	equ .24		;v px
TIME_DIGIT_HEIGHT	equ .48		;v px

;Souradnice, kam se vypisuji namerene casy (pod sebe), X je stejna
TIME_X				equ FORM_X + .70

;Y-ova se meni podle kola
TIME1_Y				equ FORM_Y + .34
TIME2_Y				equ TIME1_Y + TIME_DIGIT_HEIGHT + FORM_GAP
TIME3_Y				equ TIME2_Y + TIME_DIGIT_HEIGHT + FORM_GAP
TIME4_Y				equ TIME3_Y + TIME_DIGIT_HEIGHT	+ .6 ;Prumer

TRY_X				equ FORM_X + .4 + .24
TRY1_Y				equ TIME1_Y
TRY2_Y				equ TIME2_Y
TRY3_Y				equ TIME3_Y

FORM_BULLET_WIDTH	equ .24
FORM_BULLET_HEIGHT  equ .24
FORM_BULLET_X		equ FORM_X + .4
FORM_BULLET1_Y		equ TIME1_Y + .14
FORM_BULLET2_Y		equ TIME2_Y + .14
FORM_BULLET3_Y		equ TIME3_Y + .14

TFT_BLACK       	equ 0x0000
TFT_CYAN			equ 0x07FF
TFT_BLUE       		equ 0x1032
TFT_WHITE       	equ 0xFFFF
TFT_RED         	equ 0xF800
TFT_GREEN       	equ 0x07E0
TFT_YELLOW			equ 0xFFE0
TFT_LIGHTGREY   	equ 0xC618
TFT_DARKGREY    	equ 0x5ACB

FONT_CHAR_WIDTH		equ .8	;px
FONT_CHAR_HEIGHT	equ .16 ;px


FORM_HALL_Y			equ .60

FORM_TOP5_X			equ (TFT_HEIGHT - (.2 * FONT_CHAR_WIDTH) * .9) / .2
FORM_TOP5_Y			equ FORM_HALL_Y + .96

GAME_TIMEOUT		equ .2000
GAME_ROUNDS			equ .3

;******************************************************************
;****************** D E F I N I C E *******************************
;******************************************************************

;TFT 2.4" LCD
#define TFT_SCK		PORTC, RC3;		(OUTPUT)
#define TFT_MOSI	PORTC, RC5;		(OUTPUT)
#define TFT_DC		PORTC, RC0;		(OUTPUT)
#define TFT_RESET	PORTC, RC1;		(OUTPUT)
#define TFT_CS		PORTC, RC2;		(OUTPUT)

;BUTTONY
#define BUTTON_START	PORTA, RA0
#define BUTTON_STOP		PORTA, RA1

;LED
#define LED			PORTB, RB7

;******************************************************************
;****************** 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

; ******************************************************************
; *********************** I N T E R R U P T ************************
; ******************************************************************
	org 0x04
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
    movf  PCLATH,w      ;move pclath register into w register
    movwf pclath_temp   ;save off contents of PCLATH register

	clrf PCLATH

INTERRUPT_MAIN
	bcf PIR1, TMR1IF	;Vycisti Timer1 interrupt flag
	incf GAME_timerL, f	;pricti 1ms
	btfsc STATUS, Z
	incf GAME_timerH, f

	call GAME_decTimeoutTimer	;Zkontroluj, jestli uz nebyl prekrocen timeout 2s
	movlw TRUE
	btfss STATUS, Z
	movlw FALSE
	movwf GAME_isTimeout

	call initTimer1Loop

INTERRUPT_SKIP
    movf  pclath_temp,w ;retrieve copy of PCLATH register
    movwf PCLATH        ;restore pre-isr PCLATH register contents
	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'11001000'
	movwf OPTION_REG

	;*** PORTA NASTAVENI ***
	BANK3
	clrf ANSEL
		
	;RA0, RA1 buttony
	movlw b'00000011'
	movwf TRISA

	BANK0
	clrf ADCON0			;Vypni A/D
	clrf PORTA

	;*** PORTB NASTAVENI ***

	BANK1
	clrf TRISB

	BANK0
	clrf PORTB
	clrf CCP1CON 		; Turn CCP module off

	clrf SSPCON  		; Inicializace MSSP modulu
	movlw b'00110000'	; 00, SSPEN=1,CKP=1, 0001 SPI Master Mode = FOSC/4
	movwf SSPCON

	;Inicializace Timer0
	clrf INTCON


	;*** PORTC NASTAVENI - 2.4" TFT ***
	;
	BANK1
	clrf TRISC

	clrf SSPSTAT
  	movlw 0x80			; set up spi port, SPI master,
	movwf SSPSTAT		; CKE = 0 (mode 1,1)

	BANK0
	clrf PORTC
;}

;*******************************************************************
;******************* M A I N   L O O P *****************************
;*******************************************************************

	call EEPROM_readTop5

	call TFT_init

GAME_START

	call TFT_clearScreen
	call TFT_showLogo
	call TFT_showHelp

	call GAME_waitForAnyButton

GAME_LOOP

	call TFT_clearScreen
	call TFT_showLogo
	call TFT_showHallOfFame
	call TFT_drawPressStartLabel

GAME_LOOP2

	call GAME_waitForStartButton

	call TFT_clearScreen

	call GAME_init

	call TFT_showLogo
	call TFT_drawLines
	call TFT_drawTryLabel
	call TFT_drawTimeLabel
	call TFT_drawAvgLabel
	call TFT_drawTryDigits
	call TFT_drawBlankTimes

GAME_ROUNDS_LOOP

	movlw FALSE
	movwf GAME_isCheating			;Hrac nepodvadi

	call TFT_drawBlinkingBullet
	call TFT_drawPressStartLabel
	call GAME_waitForStartButton
	
	call TFT_drawWaitLabel
	call GAME_waitRandomNew
	call GAME_checkCheating			;Hrac drzi stisknuty STOP?
	call GAME_turnLedOn
	
	btfss GAME_isCheating, 0
	goto GAME_notCheating
	
	call GAME_setTimePenalty		;Cheating = 2s penalty
	call TFT_setRedFG				;Vypis cas cervene, pokud hrac podvadel
	goto GAME_CONTINUE
	
GAME_notCheating
		
	call GAME_startStopWatch
	call GAME_waitForStopButton
		
	call GAME_endStopWatch

GAME_CONTINUE

	call GAME_turnLedOff
	
	call TFT_drawMeasuredTime
	call GAME_addMeasuredToTotalTime
	call TFT_hideBullet

	incf GAME_round, f

	decfsz GAME_roundCounter, f
	goto GAME_ROUNDS_LOOP

	;Spocitej Average
	call TFT_hidePressStartLabel
	call GAME_computeAverage
	call TFT_drawAverageTime

	call GAME_checkTimeForTop5	;Mame zaznam v TOP5?
	btfss STATUS, C
	goto GAME_NOT_IN_TOP5
	movwf TOP5_positionTop5		;Jsme v Top5, uloz pozici rekordu

	movlw TRUE
	movwf GAME_top5Achieved

	call TFT_blinkAverageTime

	call wait1s

	call TFT_clearScreen
	call TFT_showLogo
	call TOP5_adjustTop5			;Proved nutne presuny v Top5
	call TOP5_storeScoreToTop5		;Uloz cas do tabulky Top5
	call TFT_showHallOfFame
	call TOP5_enterInitials
	call EEPROM_saveTop5			;Uloz Top5 do EEPROM	
	call TFT_drawPressStartLabel

	goto GAME_LOOP2

GAME_NOT_IN_TOP5

	call TFT_drawPressStartLabel
	call GAME_waitForStartButton

	goto GAME_LOOP

; *******************************************************************
; ************ 2.8" TFT ILI9341   R U T I N Y ***********************
; *******************************************************************

TFT_init
;{
	bsf TFT_RESET
	movlw .200
	call waitMilis
	bcf TFT_RESET
	movlw .200
	call waitMilis
	bsf TFT_RESET
	movlw .200
	call waitMilis

	;Soft RESET command
	movlw 0x01
	call TFT_sendCmd
	movlw .1
	call waitSecs

	;power control A
	movlw 0xCB
	call TFT_sendCmd
	movlw 0x39
	call TFT_sendData
	movlw 0x2C
	call TFT_sendData
	movlw 0x00
	call TFT_sendData
	movlw 0x34
	call TFT_sendData
	movlw 0x02
	call TFT_sendData


	;power control B
	movlw 0xCF
	call TFT_sendCmd
	movlw 0x00
	call TFT_sendData
	movlw 0xC1
	call TFT_sendData
	movlw 0x30
	call TFT_sendData

	;driver timing control A
	movlw 0xE8
	call TFT_sendCmd
	movlw 0x85
	call TFT_sendData
	movlw 0x00
	call TFT_sendData
	movlw 0x78
	call TFT_sendData

	;driver timing control B
	movlw 0xEA
	call TFT_sendCmd
	movlw 0x00
	call TFT_sendData
	movlw 0x00
	call TFT_sendData

	;power on sequence control
	movlw 0xED
	call TFT_sendCmd
	movlw 0x64
	call TFT_sendData
	movlw 0x03
	call TFT_sendData
	movlw 0x12
	call TFT_sendData
	movlw 0x81
	call TFT_sendData

	;pump ratio control
	movlw 0xF7
	call TFT_sendCmd
	movlw 0x20
	call TFT_sendData

	;power control,VRH[5:0]
	movlw 0xC0
	call TFT_sendCmd
	movlw 0x23
	call TFT_sendData

	;Power control,SAP[2:0];BT[3:0]
	movlw 0xC1
	call TFT_sendCmd
	movlw 0x10
	call TFT_sendData

	;vcm control
	movlw 0xC5
	call TFT_sendCmd
	movlw 0x3E
	call TFT_sendData
	movlw 0x28
	call TFT_sendData

	;vcm control 2
	movlw 0xC7
	call TFT_sendCmd
	movlw 0x86
	call TFT_sendData

	;memory access control
	movlw 0x36
	call TFT_sendCmd
	movlw 0x48  ;ORIG
	;movlw 0x28 			;W=320, H=240
	call TFT_sendData

	;pixel format
	movlw 0x3A
	call TFT_sendCmd
	movlw 0x55
	call TFT_sendData

	;frameration control,normal mode full colours
	movlw 0xB1
	call TFT_sendCmd
	movlw 0x00
	call TFT_sendData
	movlw 0x18
	call TFT_sendData

	;display function control
	movlw 0xB6
	call TFT_sendCmd
	movlw 0x08
	call TFT_sendData
	movlw 0x82
	call TFT_sendData
	movlw 0x27
	call TFT_sendData

	;3gamma function disable
	movlw 0xF2
	call TFT_sendCmd
	movlw 0x00
	call TFT_sendData

	;gamma curve selected
	movlw 0x26
	call TFT_sendCmd
	movlw 0x01
	call TFT_sendData

	;set positive gamma correction
	movlw 0xE0
	call TFT_sendCmd
	movlw 0x0F
	call TFT_sendData
	movlw 0x31
	call TFT_sendData
	movlw 0x2B
	call TFT_sendData
	movlw 0x0C
	call TFT_sendData
	movlw 0x0E
	call TFT_sendData
	movlw 0x08
	call TFT_sendData
	movlw 0x4E
	call TFT_sendData
	movlw 0xF1
	call TFT_sendData
	movlw 0x37
	call TFT_sendData
	movlw 0x07
	call TFT_sendData
	movlw 0x10
	call TFT_sendData
	movlw 0x03
	call TFT_sendData
	movlw 0x0E
	call TFT_sendData
	movlw 0x09
	call TFT_sendData
	movlw 0x00
	call TFT_sendData

	;set negative gamma correction
	movlw 0xE1
	call TFT_sendCmd
	movlw 0x00
	call TFT_sendData
	movlw 0x0E
	call TFT_sendData
	movlw 0x14
	call TFT_sendData
	movlw 0x03
	call TFT_sendData
	movlw 0x11
	call TFT_sendData
	movlw 0x07
	call TFT_sendData
	movlw 0x31
	call TFT_sendData
	movlw 0xC1
	call TFT_sendData
	movlw 0x48
	call TFT_sendData
	movlw 0x08
	call TFT_sendData
	movlw 0x0F
	call TFT_sendData
	movlw 0x0C
	call TFT_sendData
	movlw 0x31
	call TFT_sendData
	movlw 0x36
	call TFT_sendData
	movlw 0x0F
	call TFT_sendData

	;exit sleep
	movlw 0x11
	call TFT_sendCmd
	movlw .120
	call waitMilis

	;display on
	movlw 0x29
	call TFT_sendCmd

	return
;}


TFT_sendCmd
;{
	bcf TFT_CS
	;nop
	;nop
	bcf TFT_DC		;Command
	;nop
	;nop

	call TFT_writeByte

	;nop
	;nop
	bsf TFT_CS
	return
;}

TFT_sendData
;{
	bcf TFT_CS
	;nop
	;nop
	bsf TFT_DC		;Data
	;nop
	;nop

	call TFT_writeByte

	;nop
	;nop
	bsf TFT_CS
	return
;}


TFT_writeByte				;HW SPI
;{
	movwf SSPBUF
	BANK1
TFT_wait
    btfss SSPSTAT, BF		; Has data been transmitted?
	goto TFT_wait			; Loop if not transmitted yet
	BANK0
    movf SSPBUF, w			; Empty the receive buffer
	return
;}


TFT_writeWord
;{
	movlw TFT_word
	call TFT_writeByte
	movlw TFT_word+1
	call TFT_writeByte
	return
;}


TFT_clearScreen
;{
	call TFT_setWhiteOnBlue

	;Column Set
	movlw 0x2A
	call TFT_sendCmd
	movlw .0
	call TFT_sendData
	movlw .0
	call TFT_sendData
	movlw .0
	call TFT_sendData
	movlw LOW TFT_HEIGHT
	call TFT_sendData

	;Page Set
	movlw 0x2B
	call TFT_sendCmd
	movlw .0
	call TFT_sendData
	movlw .0
	call TFT_sendData
	movlw HIGH TFT_WIDTH
	call TFT_sendData
	movlw LOW TFT_WIDTH
	call TFT_sendData

	;memory write
	movlw 0x2C
	call TFT_sendCmd

	bcf TFT_CS		;Zacatek write operace
	nop
	nop
	bsf TFT_DC		;Data
	nop
	nop

	movlw HIGH TFT_WIDTH
	movwf hiByte
	movlw LOW TFT_WIDTH
	movwf loByte
TFT_fillR					; Rows
	movlw TFT_HEIGHT
	movwf TFT_i
TFT_fillC					; Columns
	movlw HIGH TFT_BLUE
	movwf SSPBUF
	BANK1
TFT_fillScreenH
    btfss SSPSTAT, BF		; Has data been transmitted?
	goto TFT_fillScreenH	; Loop if not transmitted yet
	BANK0
    movf SSPBUF, w			; Empty the receive buffer

	movlw LOW TFT_BLUE
	movwf SSPBUF
	BANK1
TFT_fillScreenL
    btfss SSPSTAT, BF		; Has data been transmitted?
	goto TFT_fillScreenL	; Loop if not transmitted yet
	BANK0
    movf SSPBUF, w			; Empty the receive buffer

    decfsz TFT_i, f
    goto TFT_fillC

    call decHL
    btfss STATUS, Z
    goto TFT_fillR

	bsf TFT_CS				; Konec write operace
	return
;}


TFT_setGreenBG
;{
	movlw HIGH TFT_GREEN
    movwf TFT_BGColor+0
    movlw LOW TFT_GREEN
    movwf TFT_BGColor+1
    return
;}

TFT_setBlueBG
;{
	movlw HIGH TFT_BLUE
    movwf TFT_BGColor+0
    movlw LOW TFT_BLUE
    movwf TFT_BGColor+1
    return
;}

TFT_setBlackOnGreen
;{
	call TFT_setGreenBG
    call TFT_setBlackFG
	return
;}

TFT_setWhiteOnBlue
;{
	call TFT_setBlueBG
	call TFT_setWhiteFG
    return
;}


TFT_setBlackFG
;{
    movlw HIGH TFT_BLACK
    movwf TFT_FGColor+0
    movlw LOW TFT_BLACK
    movwf TFT_FGColor+1
    return
;}

TFT_setWhiteFG
;{
	movlw HIGH TFT_WHITE
    movwf TFT_FGColor+0
    movlw LOW TFT_WHITE
    movwf TFT_FGColor+1
    return
;}

TFT_setCyanFG
;{
	movlw HIGH TFT_CYAN
    movwf TFT_FGColor+0
    movlw LOW TFT_CYAN
    movwf TFT_FGColor+1
    return
;}

TFT_setRedFG
;{
	movlw HIGH TFT_RED
    movwf TFT_FGColor+0
    movlw LOW TFT_RED
    movwf TFT_FGColor+1
    return
;}

TFT_setGreenFG
;{
	movlw HIGH TFT_GREEN
    movwf TFT_FGColor+0
    movlw LOW TFT_GREEN
    movwf TFT_FGColor+1
    return
;}

TFT_setYellowFG
;{
	movlw HIGH TFT_YELLOW
    movwf TFT_FGColor+0
    movlw LOW TFT_YELLOW
    movwf TFT_FGColor+1
    return
;}

;White on Green
TFT_setWhiteOnGreen
;{
	call TFT_setGreenBG
    call TFT_setWhiteFG
    return
;}

;White on Green
TFT_setYellowOnBlue
;{
	call TFT_setBlueBG
	call TFT_setYellowFG
    return
;}



;Nastavi v displeji okno pro vykreslovani
TFT_setXY
;{
	;Column Set
	movlw 0x2A
	call TFT_sendCmd
	movf TFT_X+0, w
	call TFT_sendData
	movf TFT_X+1, w
	call TFT_sendData
	movf TFT_X_MAX+0, w
	call TFT_sendData
	movf TFT_X_MAX+1, w
	call TFT_sendData

	;Page Set
	movlw 0x2B
	call TFT_sendCmd
	movf TFT_Y+0, w
	call TFT_sendData
	movf TFT_Y+1, w
	call TFT_sendData
	movf TFT_Y_MAX+0, w
	call TFT_sendData
	movf TFT_Y_MAX+1, w
	call TFT_sendData

	;memory write
	movlw 0x2C
	call TFT_sendCmd

	return
;}

;Vstup W-reg ascii kod znaku '.', '/', '0' - '9'
;Vystup: kod znaku - '.' * 256 = page, kde je dany znak
TFT_setDigitPointer
;{
	movwf TFT_tmp

	movlw HIGH Table_font
	movwf dataPointer+0
	movlw LOW Table_font
	movwf dataPointer+1

	movlw '.'
	subwf TFT_tmp, w
	addwf dataPointer+0, f
	return

;}

;Vykresli oddelovace
TFT_drawLines
;{

	;Vykresli horizontalni
	movlw FORM_LINE_THICKNESS
	movwf TFT_lineThickness
	movlw HIGH FORM_HLINE_LENGTH
	movwf TFT_lineLength+0
	movlw LOW FORM_HLINE_LENGTH
	movwf TFT_lineLength+1
	movlw TRUE
	movwf TFT_drawHorizontal
	movlw HIGH FORM_X
	movwf TFT_X+0
	movlw LOW FORM_X
	movwf TFT_X+1
	movlw HIGH FORM_HLINE1_Y
	movwf TFT_Y+0
	movlw LOW FORM_HLINE1_Y
	movwf TFT_Y+1
	call TFT_drawLine

	movlw HIGH FORM_HLINE2_Y
	movwf TFT_Y+0
	movlw LOW FORM_HLINE2_Y
	movwf TFT_Y+1
	call TFT_drawLine

	movlw HIGH FORM_HLINE3_Y
	movwf TFT_Y+0
	movlw LOW FORM_HLINE3_Y
	movwf TFT_Y+1
	call TFT_drawLine

	movlw HIGH FORM_HLINE4_Y
	movwf TFT_Y+0
	movlw LOW FORM_HLINE4_Y
	movwf TFT_Y+1
	call TFT_drawLine

	;Vykresli vertikalni
	movlw HIGH FORM_VLINE_LENGTH
	movwf TFT_lineLength+0
	movlw LOW FORM_VLINE_LENGTH
	movwf TFT_lineLength+1

	movlw FALSE
	movwf TFT_drawHorizontal

	movlw HIGH FORM_VLINE1_X
	movwf TFT_X+0
	movlw LOW FORM_VLINE1_X
	movwf TFT_X+1

	movlw HIGH FORM_Y
	movwf TFT_Y+0
	movlw LOW FORM_Y
	movwf TFT_Y+1
	call TFT_drawLine

	movlw HIGH FORM_VLINE2_X
	movwf TFT_X+0
	movlw LOW FORM_VLINE2_X
	movwf TFT_X+1
	call TFT_drawLine

	movlw HIGH FORM_VLINE3_X
	movwf TFT_X+0
	movlw LOW FORM_VLINE3_X
	movwf TFT_X+1
	call TFT_drawLine

	return
;}

;Vykresli cernou linku
;Vstup: TFT_lineThickness - tloustka cary (1B)
;Vstup: TFT_lineLength - delka v pixelech (2B)
;Vstup: TFT_drawHorizontal - True(horizontal) / False(vertical)
;Vstup: TFT_X, TFT_Y
TFT_drawLine
;{
	clrf hiByte
	clrf loByte

	;1. spocitej X_MAX, Y_MAX a nastav vykreslovaci okno
	btfss TFT_drawHorizontal, 0
	goto TFT_drawVerticalLine

	;X_MAX
	movf TFT_lineLength+0, w
	addwf TFT_X+0, w
	movwf TFT_X_MAX+0
	;movf TFT_lineLength+1, w
	decf TFT_lineLength+1, w
	addwf TFT_X+1, w
	movwf TFT_X_MAX+1
	btfsc STATUS, C
	incf TFT_X_MAX+0, f

	;Y_MAX
	movf TFT_Y+0, w
	movwf TFT_Y_MAX
	decf TFT_lineThickness, w
	addwf TFT_Y+1, w
	movwf TFT_Y_MAX+1
	btfsc STATUS, C
	incf TFT_Y_MAX+0, f

	goto TFT_drawLineCompute

TFT_drawVerticalLine

	;X_MAX
	decf TFT_lineThickness, w
	addwf TFT_X+1, w
	movwf TFT_X_MAX+1
	btfsc STATUS, C
	incf TFT_X_MAX+0, f

	;Y_MAX
	movf TFT_lineLength+0, w
	addwf TFT_Y+0, w
	movwf TFT_Y_MAX+0
	movf TFT_lineLength+1, w
	addwf TFT_Y+1, w
	movwf TFT_Y_MAX+1
	btfsc STATUS, C
	incf TFT_Y_MAX+0, f

TFT_drawLineCompute
	;2. spocitej pocet pixelu, ktere se budou vykreslovat
	;tloustka * delka

	movf TFT_lineThickness, w
	movwf TFT_i
TFT_drawLineL1
	movf TFT_lineLength+0, w
	addwf hiByte, f
	movf TFT_lineLength+1, w
	addwf loByte, f
	btfsc STATUS, C
	incf hiByte, f

	decfsz TFT_i, f
	goto TFT_drawLineL1


	;3. vypln spocitany obdelnik barvou popredi
	call TFT_setXY

TFT_drawLineFill			;hiByte:loByte pixels
	movf TFT_FGColor+0, w
    call TFT_sendData
    movf TFT_FGColor+1, w
    call TFT_sendData
    call decHL
    btfss STATUS, Z
    goto TFT_drawLineFill
    return

;}



;Vypise inicialni prazdne casy (pomlcky)
TFT_drawBlankTimes
;{
	movlw .1
	movwf GAME_round

	;-.---
	movlw '/'
	movwf TFT_number+0
	movwf TFT_number+1
	movwf TFT_number+2
	movwf TFT_number+3
	movwf TFT_number+4

	movlw GAME_ROUNDS
	movwf j
TFT_dblank
	call TFT_drawMeasuredTime2
	incf GAME_round, f

	decfsz j, f
	goto TFT_dblank

	movlw .1
	movwf GAME_round
	return

;}


;Vykresli 5cifefrne 16bit cislo ABCDEF jako C.DEF (cislo < 10000)
;na pozici podle GAME_round
;Vstup: GAME_timerH:GAME_timerL
;Vstup: GAME_round (0,1,2,3 - 0,1,2 namerene, 3 - vysledny prumer
TFT_drawMeasuredTime
;{	
	;Preved namerenou hodnotu <0-6000> na odpovidajici ABCDE
	movf GAME_timerH, w
	movwf UTIL_NumH
	movf GAME_timerL, w
	movwf UTIL_NumL

	call UTIL_populateNumber	;Napln TFT_number

TFT_drawMeasuredTime2		;Pro vypis -.---

	;Levy horni roh [X,Y]
	movlw HIGH TIME_X
	movwf TFT_X+0
	movlw LOW TIME_X
	movwf TFT_X+1

	movf GAME_round, w
	movwf TFT_tmp

TFT_drawAttempt1
	decfsz TFT_tmp, f
	goto TFT_drawAttempt2

	movlw HIGH TIME1_Y
	movwf TFT_Y+0
	movlw LOW TIME1_Y
	movwf TFT_Y+1
	goto TFT_drawMeasuredCommon

TFT_drawAttempt2
	decfsz TFT_tmp, f
	goto TFT_drawAttempt3

	movlw HIGH TIME2_Y
	movwf TFT_Y+0
	movlw LOW TIME2_Y
	movwf TFT_Y+1
	goto TFT_drawMeasuredCommon

TFT_drawAttempt3
	decfsz TFT_tmp, f
	goto TFT_drawAttempt4

	movlw HIGH TIME3_Y
	movwf TFT_Y+0
	movlw LOW TIME3_Y
	movwf TFT_Y+1
	goto TFT_drawMeasuredCommon

TFT_drawAttempt4
	movlw HIGH TIME4_Y
	movwf TFT_Y+0
	movlw LOW TIME4_Y
	movwf TFT_Y+1

TFT_drawMeasuredCommon

    movlw TFT_number
    movwf FSR

    movlw .5
    movwf i
TFT_drawNumberLoop
	movf INDF, w
	call TFT_drawDigit

	incf FSR, f
	decfsz i, f
	goto TFT_drawNumberLoop

	return
;}

TFT_drawAverageTime
;{
	call TFT_setYellowFG
	call TFT_drawMeasuredTime
	call TFT_setWhiteFG
	return
;}

TFT_hideAverageTime
;{
	;Levy horni roh [X,Y]
	movlw HIGH TIME_X
	movwf TFT_X+0
	movlw LOW TIME_X
	movwf TFT_X+1
	movlw HIGH TIME4_Y
	movwf TFT_Y+0
	movlw LOW TIME4_Y
	movwf TFT_Y+1

	movlw .5 * TIME_DIGIT_WIDTH - .1
	movwf TFT_width
	movlw TIME_DIGIT_HEIGHT
	movwf TFT_height

	call TFT_fillBox
	return
;}

;Zablikej pri zapisu do TOP5
TFT_blinkAverageTime
;{
	movlw .3
	movwf j

TFT_blinkAverageLoop

	call wait150ms
	call wait150ms

	call TFT_hideAverageTime

	call wait150ms
	call wait150ms

	call TFT_drawAverageTime

	decfsz j, f
	goto TFT_blinkAverageLoop
	return
;}

TFT_hidePressStartLabel
;{
	movlw HIGH FORM_START1_LABEL_X
	movwf TFT_X+0
	movlw LOW FORM_START1_LABEL_X
	movwf TFT_X+1

	movlw HIGH FORM_START1_LABEL_Y
	movwf TFT_Y+0
	movlw LOW FORM_START1_LABEL_Y
	movwf TFT_Y+1

	movlw FORM_START1_WIDTH - .1
	movwf TFT_width

	movlw FORM_START1_HEIGHT + FORM_START2_HEIGHT - .1
	movwf TFT_height

	call TFT_fillBox
	return
;}

TFT_drawPressStartLabel
;{
	;1.pulka napisu
	movlw HIGH FORM_START1_LABEL_X
	movwf TFT_X+0
	movlw LOW FORM_START1_LABEL_X
	movwf TFT_X+1

	movlw HIGH FORM_START1_LABEL_Y
	movwf TFT_Y+0
	movlw LOW FORM_START1_LABEL_Y
	movwf TFT_Y+1

	movlw FORM_START1_WIDTH - .1
	movwf TFT_width

	movlw FORM_START1_HEIGHT + FORM_START2_HEIGHT - .1
	movwf TFT_height

	call TFT_calculateBoundaries

	movlw HIGH Table_start1
	movwf dataPointer+0
	movlw LOW Table_start1
	movwf dataPointer+1

	movlw start1_len
	call TFT_drawBox

	;2.pulka
	movlw HIGH Table_start2
	movwf dataPointer+0
	movlw LOW Table_start2
	movwf dataPointer+1

	movlw start2_len
	call TFT_drawBox

	return
;}
TFT_drawWaitLabel
;{
	;1.pulka napisu
	movlw HIGH FORM_WAIT1_LABEL_X
	movwf TFT_X+0
	movlw LOW FORM_WAIT1_LABEL_X
	movwf TFT_X+1

	movlw HIGH FORM_WAIT1_LABEL_Y
	movwf TFT_Y+0
	movlw LOW FORM_WAIT1_LABEL_Y
	movwf TFT_Y+1

	movlw FORM_WAIT1_WIDTH - .1
	movwf TFT_width

	movlw FORM_WAIT1_HEIGHT + FORM_WAIT2_HEIGHT - .1
	movwf TFT_height

	call TFT_calculateBoundaries

	movlw HIGH Table_wait1
	movwf dataPointer+0
	movlw LOW Table_wait1
	movwf dataPointer+1

	movlw wait1_len
	call TFT_drawBox

	;2.pulka
	movlw HIGH Table_wait2
	movwf dataPointer+0
	movlw LOW Table_wait2
	movwf dataPointer+1

	movlw wait2_len
	call TFT_drawBox

	return
;}



TFT_drawTryLabel
;{

	movlw HIGH FORM_TRY_LABEL_X
	movwf TFT_X+0
	movlw LOW FORM_TRY_LABEL_X
	movwf TFT_X+1

	movlw HIGH FORM_TRY_LABEL_Y
	movwf TFT_Y+0
	movlw LOW FORM_TRY_LABEL_Y
	movwf TFT_Y+1

	movlw FORM_TRY_WIDTH - .1
	movwf TFT_width

	movlw FORM_TRY_HEIGHT - .1
	movwf TFT_height

	call TFT_calculateBoundaries

	movlw HIGH Table_try
	movwf dataPointer+0
	movlw LOW Table_try
	movwf dataPointer+1

	movlw try_len
	call TFT_drawBox

	return

;}

TFT_drawTimeLabel
;{

	movlw HIGH FORM_TIME_LABEL_X
	movwf TFT_X+0
	movlw LOW FORM_TIME_LABEL_X
	movwf TFT_X+1

	movlw HIGH FORM_TIME_LABEL_Y
	movwf TFT_Y+0
	movlw LOW FORM_TIME_LABEL_Y
	movwf TFT_Y+1

	movlw FORM_TIME_WIDTH - .1
	movwf TFT_width

	movlw FORM_TIME_HEIGHT - .1
	movwf TFT_height

	call TFT_calculateBoundaries

	movlw HIGH Table_time
	movwf dataPointer+0
	movlw LOW Table_time
	movwf dataPointer+1

	movlw time_len
	call TFT_drawBox

	return

;}

TFT_drawAvgLabel
;{
	call TFT_setYellowFG

	movlw HIGH FORM_AVG_LABEL_X
	movwf TFT_X+0
	movlw LOW FORM_AVG_LABEL_X
	movwf TFT_X+1

	movlw HIGH FORM_AVG_LABEL_Y
	movwf TFT_Y+0
	movlw LOW FORM_AVG_LABEL_Y
	movwf TFT_Y+1

	movlw FORM_AVG_WIDTH - .1
	movwf TFT_width

	movlw FORM_AVG_HEIGHT - .1
	movwf TFT_height

	call TFT_calculateBoundaries

	movlw HIGH Table_avg
	movwf dataPointer+0
	movlw LOW Table_avg
	movwf dataPointer+1

	movlw avg_len
	call TFT_drawBox

	return

;}

TFT_drawBullet
;{
	call TFT_setGreenFG

	movlw FALSE
	movwf TFT_hide

TFT_drawBulletB					;"Vymaz" box po bulletu = hide

	;Levy horni roh [X,Y]
	movlw HIGH FORM_BULLET_X
	movwf TFT_X+0
	movlw LOW FORM_BULLET_X
	movwf TFT_X+1

	movf GAME_round, w
	movwf TFT_tmp

TFT_drawBullet1
	decfsz TFT_tmp, f
	goto TFT_drawBullet2

	movlw HIGH FORM_BULLET1_Y
	movwf TFT_Y+0
	movlw LOW FORM_BULLET1_Y
	movwf TFT_Y+1
	goto TFT_drawBulletCommon

TFT_drawBullet2
	decfsz TFT_tmp, f
	goto TFT_drawBullet3

	movlw HIGH FORM_BULLET2_Y
	movwf TFT_Y+0
	movlw LOW FORM_BULLET2_Y
	movwf TFT_Y+1
	goto TFT_drawBulletCommon

TFT_drawBullet3

	movlw HIGH FORM_BULLET3_Y
	movwf TFT_Y+0
	movlw LOW FORM_BULLET3_Y
	movwf TFT_Y+1

TFT_drawBulletCommon

	movlw FORM_BULLET_WIDTH - .1
	movwf TFT_width

	movlw FORM_BULLET_HEIGHT - .1
	movwf TFT_height

	btfsc TFT_hide, 0				;budeme mazat pomoci TFT_fillBox, tady koncime
	return

	call TFT_calculateBoundaries

	movlw HIGH Table_bullet
	movwf dataPointer+0
	movlw LOW Table_bullet
	movwf dataPointer+1

	movlw bullet_len
	call TFT_drawBox

	call TFT_setWhiteFG
	return
;}


;Schova bullet na aktualnim miste, pouzito pri blikani
TFT_hideBullet
;{
	movlw TRUE
	movwf TFT_hide
	call TFT_drawBulletB	;pouze spocitej X,Y, MAXy potrebne pro TFT_fillBox
	call TFT_fillBox
	return
;}

TFT_drawBlinkingBullet
;{

	call TFT_hideBullet

	call wait150ms
	call wait150ms
	call wait150ms

	call TFT_drawBullet

	return
;}

;1,2,3
TFT_drawTryDigits
;{
	call TFT_setYellowFG

	movlw HIGH TRY_X
	movwf TFT_X+0
	movlw LOW TRY_X
	movwf TFT_X+1

	movlw HIGH TRY1_Y
	movwf TFT_Y+0
	movlw LOW TRY1_Y
	movwf TFT_Y+1

	movlw '1'
	call TFT_drawDigit

	movlw HIGH TRY_X
	movwf TFT_X+0
	movlw LOW TRY_X
	movwf TFT_X+1

	movlw HIGH TRY2_Y
	movwf TFT_Y+0
	movlw LOW TRY2_Y
	movwf TFT_Y+1

	movlw '2'
	call TFT_drawDigit

	movlw HIGH TRY_X
	movwf TFT_X+0
	movlw LOW TRY_X
	movwf TFT_X+1

	movlw HIGH TRY3_Y
	movwf TFT_Y+0
	movlw LOW TRY3_Y
	movwf TFT_Y+1

	movlw '3'
	call TFT_drawDigit

	call TFT_setWhiteFG

	return

;}

;Vstup: W-REG ascii kod cislice nebo '/' a '.'
TFT_drawDigit
;{

	call TFT_setDigitPointer	;Spocitej zacatek font dat pro znak

	movlw TIME_DIGIT_WIDTH - .1
	movwf TFT_width
	movlw TIME_DIGIT_HEIGHT - .1
	movwf TFT_height

	call TFT_calculateBoundaries

    movlw digit_len				;Vsechny cisla stejne velka
    call TFT_drawBox

    call TFT_moveDigitBoundaries	;Posun okno o znak doprava

    return
;}



;Vykresli text
;Vstup:
; textPointer:2 - zacatek textu
; TFT_X, TFT_Y - pozice kam
TFT_drawChar
;{
		movwf tmp		;uloz pro vypis 1 znaku

		movlw TRUE
		movwf TFT_putChar
		goto TFT_drawTextBegin

TFT_drawText

		movlw FALSE
		movwf TFT_putChar

TFT_drawTextBegin

		;Zvetsime jen Y-ovou (FALSE), nebo obe (TRUE)?
		movlw FONT_CHAR_WIDTH - .1		;8x16 -> 16x32
		btfsc TFT_textZoom, 0
		movlw .2 * FONT_CHAR_WIDTH - .1	;8x16 -> 8x32
		movwf TFT_width

		movlw .2 * FONT_CHAR_HEIGHT - .1	;Zoomujeme - kazdy radek vykreslim 2x
		movwf TFT_height

		movf tmp, w				;pouze 1 znak
		btfsc TFT_putChar, 0
		goto TFT_processChar

TFT_drawTextLoop
		call TFT_GetNextChar
		iorlw 0x00
		btfsc STATUS, Z
		return
TFT_processChar
		movwf tmp
		movlw .44				;Zaciname az od 46
		subwf tmp, w			;x 1

		movwf loByte
		movwf tmp				;x1 uschovej
		clrf hiByte

		;Najdi graficka data pro pismeno (x 16 pro 8x16 font)
		bcf STATUS, C
		rlf loByte, f
		rlf hiByte, f
		rlf loByte, f
		rlf hiByte, f
		rlf	loByte, f
		rlf hiByte, f
		rlf loByte, f
		rlf hiByte, f

		movlw HIGH Table_font8x16	;8x16
		movwf dataPointer+0
		movlw LOW Table_font8x16
		movwf dataPointer+1		;k dataPointer musime pricit 16x base

		movf loByte, w
		addwf dataPointer+1, f
		btfsc STATUS, C			;soucet >256?
		incf dataPointer+0, f
		movf hiByte, w
		addwf dataPointer+0, f

		call TFT_calculateBoundaries

		movlw FONT_CHAR_HEIGHT
		call TFT_drawBoxZoom

		;Posun se o znak doprava na obrazovce (podle zoomu)
		movlw FONT_CHAR_WIDTH
		btfsc TFT_textZoom, 0
		movlw .2 * FONT_CHAR_WIDTH
		addwf TFT_X+1, f			;vlezeme se do 256, vyssi byte neresime

		btfss TFT_putChar, 0		;0-ne, 1-ano
		goto TFT_drawTextLoop
		return

;}

TFT_GetNextChar
;{
		call TFT_GetNextChar2 		;To je patch kvuli strankovani
		clrf PCLATH
		incfsz textPointer+1, f ;Inkrementuj pointer
		goto $+2
		incf textPointer+0, f
		return 					;Vrat hodnotu (je stale ve W)
TFT_GetNextChar2
		;Zde se pouze skoci na dvoubajtovou adresu v textPointer
		movf textPointer+0,w 	;Zkopiruj HI byte do PCLATHu
		movwf PCLATH
		movf textPointer+1,w 	;Dej LO byte do PCL
		movwf PCL 				;Skoci na adresu, kam ukazuje textPointer
;}

;Posune levy horni roh TFT_X, TFT_Y o velikost cislice doprava
;Vstup: TFT_X_COPY, TFT_Y_COPY
;Vystup: Nastavene TFT_X, TFT_Y
TFT_moveDigitBoundaries
;{
	;TFT_X_COPY -> TFT_X
	movf TFT_X_COPY+0, w
	movwf TFT_X+0
	movf TFT_X_COPY+1, w
	movwf TFT_X+1

	;TFT_Y_COPY -> TFT_Y
	movf TFT_Y_COPY+0, w
	movwf TFT_Y+0
	movf TFT_Y_COPY+1, w
	movwf TFT_Y+1

	;TFT_X += TIME_DIGIT_WIDTH
	movlw TIME_DIGIT_WIDTH
	addwf TFT_X+1, f
	btfsc STATUS, C
	incf TFT_X+0, f

	;TFT_Y zustava stejne pro levy horni roh

	return
;}


;Pro dane TFT_X a TFT_Y spocitej TFT_X_MAX a TFT_Y_MAX
;Vstup: TFT_X, TFT_Y
;Vstup: TFT_width, TFT_height (pocitam, ze jsou < 256)
;Vystup: Nastavene TFT_X_MAX, TFT_Y_MAX
TFT_calculateBoundaries
;{
	;TFT_X -> TFT_X_MAX
	movf TFT_X+0, w
	movwf TFT_X_MAX+0
	movf TFT_X+1, w
	movwf TFT_X_MAX+1

	;TFT_Y -> TFT_Y_MAX
	movf TFT_Y+0, w
	movwf TFT_Y_MAX+0
	movf TFT_Y+1, w
	movwf TFT_Y_MAX+1

	movf TFT_width, w
	addwf TFT_X_MAX+1, f
	btfsc STATUS, C
	incf TFT_X_MAX+0, f

	movf TFT_height, w
	addwf TFT_Y_MAX+1, f
	btfsc STATUS, C
	incf TFT_Y_MAX+0, f

	;TFT_X -> TFT_X_COPY
	movf TFT_X+0, w
	movwf TFT_X_COPY+0
	movf TFT_X+1, w
	movwf TFT_X_COPY+1

	;TFT_Y -> TFT_Y_COPY
	movf TFT_Y+0, w
	movwf TFT_Y_COPY+0
	movf TFT_Y+1, w
	movwf TFT_Y_COPY+1

	call TFT_setXY

	return

;}

;Vypln box vybranou barvou
;Vstup: TFT_X, TFT_Y
;Vstup: TFT_width, TFT_height (oboji max 256)
;Vstup: Nastavene TFT_FGColor
TFT_fillBox
;{
	call TFT_calculateBoundaries	;Spocitej X_MAX, Y_MAX

	movf TFT_height, w
	movwf TFT_i

TFT_fillBR

	movf TFT_width, w
	movwf TFT_j

TFT_fillBC

    movf TFT_BGColor+0, w
    call TFT_sendData
    movf TFT_BGColor+1, w
    call TFT_sendData

	decfsz TFT_j, f
	goto TFT_fillBC

	decfsz TFT_i, f
	goto TFT_fillBR

	return
;}


;Vykresli box na obrazovku
;Vstup: dataPointer - ukazatel na data
;Vstup: WREG - delka v bytech (max 255B)
;Vstup: Predpocitane TFT_X, TFT_Y, TFT_X_MAX, TFT_Y_MAX
TFT_drawBox
;{
	movwf TFT_i

TFT_draw_loop

	call TFT_getNextByte
    movwf TFT_tmp

    movlw .8
    movwf TFT_j

TFT_draw_loopB

    btfss TFT_tmp, 7        ;nejvyssi bit set?
    goto TFT_bitNotSet
    movf TFT_FGColor+0, w
    call TFT_sendData
    movf TFT_FGColor+1, w
    call TFT_sendData
    goto TFT_bitCommon

TFT_bitNotSet
    movf TFT_BGColor+0, w
    call TFT_sendData
    movf TFT_BGColor+1, w
    call TFT_sendData

TFT_bitCommon
    rlf TFT_tmp, f

    decfsz TFT_j, f
    goto TFT_draw_loopB

	decfsz TFT_i, f
    goto TFT_draw_loop

    return
;}

;Vykresli box na obrazovku
;Vstup: dataPointer - ukazatel na data
;Vstup: WREG - delka v bytech (max 255B)
;Vstup: Predpocitane TFT_X, TFT_Y, TFT_X_MAX, TFT_Y_MAX
TFT_drawBoxZoom
;{
	movwf TFT_i

TFT_drawZ_loop

	call TFT_getNextByte
    movwf TFT_tmp
    movwf TFT_byte

	movlw .2
	movwf TFT_k

TFT_drawZ

    movf TFT_byte, w
    movwf TFT_tmp

    movlw .8
    movwf TFT_j

TFT_drawZ_loopB

    btfss TFT_tmp, 7        ;nejvyssi bit set?
    goto TFT_ZbitNotSet

    movf TFT_FGColor+0, w
    call TFT_sendData
    movf TFT_FGColor+1, w
    call TFT_sendData

    btfss TFT_textZoom, 0	;zoomuji i X? - posli pixel 2x
    goto TFT_ZbitCommon		;nezoomuji X

    movf TFT_FGColor+0, w
    call TFT_sendData
    movf TFT_FGColor+1, w
    call TFT_sendData

    goto TFT_ZbitCommon

TFT_ZbitNotSet

    movf TFT_BGColor+0, w
    call TFT_sendData
    movf TFT_BGColor+1, w
    call TFT_sendData

    btfss TFT_textZoom, 0	;zoomuji X?
    goto TFT_ZbitCommon

    movf TFT_BGColor+0, w
    call TFT_sendData
    movf TFT_BGColor+1, w
    call TFT_sendData

TFT_ZbitCommon
    rlf TFT_tmp, f

    decfsz TFT_j, f
    goto TFT_drawZ_loopB

	decfsz TFT_k, f
	goto TFT_drawZ

	decfsz TFT_i, f
    goto TFT_drawZ_loop

    return
;}

TFT_getNextByte
;{
	call TFT_getNextByte2 	;To je patch kvuli strankovani
	clrf PCLATH
	incfsz dataPointer+1, f ;Inkrementuj pointer
	goto $+2
	incf dataPointer+0, f
	return 					;Vrat hodnotu (je stale ve W)
TFT_getNextByte2
	;Zde se pouze skoci na dvoubajtovou adresu v dataPointer
	movf dataPointer+0, w 	;Zkopiruj HI byte do PCLATHu
	movwf PCLATH
	movf dataPointer+1, w 	;Dej LO byte do PCL
	movwf PCL 				;Skoci na adresu, kam ukazuje textPointer
;}


TFT_showLogo
;{
	call TFT_setGreenFG
	
	movlw TRUE
	movwf TFT_textZoom

	movlw HIGH Table_text1
	movwf textPointer+0
	movlw LOW Table_text1
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0

	movlw (TFT_HEIGHT - (.2 * FONT_CHAR_WIDTH) * text1_len) / .2
	movwf TFT_X+1
	movlw .0
	movwf TFT_Y+0
	movwf TFT_Y+1
	call TFT_drawText
	
	call TFT_setWhiteFG
	
	return
;}


TFT_showHallOfFame
;{
	movlw TRUE
	movwf TFT_textZoom

	;***************
	movlw HIGH Table_text12
	movwf textPointer+0
	movlw LOW Table_text12
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw (TFT_HEIGHT - (.2 * FONT_CHAR_WIDTH) * text12_len) / .2
	movwf TFT_X+1
	movlw HIGH FORM_HALL_Y
	movwf TFT_Y+0
	movlw LOW FORM_HALL_Y
	movwf TFT_Y+1
	call TFT_setCyanFG
	call TFT_drawText

	;HALL OF FAME
	movlw HIGH Table_text11
	movwf textPointer+0
	movlw LOW Table_text11
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw (TFT_HEIGHT - (.2 * FONT_CHAR_WIDTH) * text11_len) / .2
	movwf TFT_X+1
	movlw HIGH FORM_HALL_Y + .32
	movwf TFT_Y+0
	movlw LOW FORM_HALL_Y + .32
	movwf TFT_Y+1
	
	call TFT_setYellowFG
	call TFT_drawText

	;***************
	movlw HIGH Table_text12
	movwf textPointer+0
	movlw LOW Table_text12
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw (TFT_HEIGHT - (.2 * FONT_CHAR_WIDTH) * text12_len) / .2
	movwf TFT_X+1
	movlw HIGH FORM_HALL_Y + .64
	movwf TFT_Y+0
	movlw LOW FORM_HALL_Y + .64
	movwf TFT_Y+1
	
	call TFT_setCyanFG
	call TFT_drawText

	call TFT_showTop5

	return
;}

TFT_showTop5
;{
		movlw HIGH FORM_TOP5_Y
		movwf TFT_Y+0
		movlw LOW FORM_TOP5_Y
		movwf TFT_Y+1

		bsf STATUS, IRP			;BANK2 FSR
		movlw TOP5_TABLE_ADDR
		movwf FSR

		movlw .1
		movwf j

		movlw .5				;Top 5
		movwf i

TFT_showTloop

		call TFT_setWhiteFG

		btfss GAME_top5Achieved, 0
		goto TFT_showTloopStart

		;Zvyraznim novy zaznam v TOP5, na spravnem radku (TOP5_positionTop5)
		movf j, w
		xorwf TOP5_positionTop5, w
		btfss STATUS, Z
		goto TFT_showTloopStart
		call TFT_setYellowFG

TFT_showTloopStart

		movlw HIGH FORM_TOP5_X
		movwf TFT_X+0
		movlw LOW FORM_TOP5_X
		movwf TFT_X+1

		;3 znaky inicialy
		movf INDF, w
		call TFT_drawChar
		incf FSR, f
		movf INDF, w
		call TFT_drawChar
		incf FSR, f
		movf INDF, w
		call TFT_drawChar
		incf FSR, f

		;mezera
		movlw '/'
		call TFT_drawChar

		;body (5 znaku)
		movf INDF, w
		movwf UTIL_NumH
		incf FSR, f
		movf INDF, w
		movwf UTIL_NumL
		incf FSR, f

		;NumH:NumL -> TFT_Number (5 znaku)
		call UTIL_populateNumber

		movf TFT_number+0, w
		call TFT_drawChar
		movf TFT_number+1, w
		call TFT_drawChar
		movf TFT_number+2, w
		call TFT_drawChar
		movf TFT_number+3, w
		call TFT_drawChar
		movf TFT_number+4, w
		call TFT_drawChar

		movlw .2 * FONT_CHAR_HEIGHT
		addwf TFT_Y+1, f
		btfsc STATUS, C
		incf TFT_Y+0, f

		incf j, f

		decfsz i, f
		goto TFT_showTloop

		bcf STATUS, IRP		;BANK0/1 FSR
		return
;}


TFT_showHelp
;{

	movlw FALSE
	movwf TFT_textZoom

	;INSTRUCTIONS
	movlw HIGH Table_text3
	movwf textPointer+0
	movlw LOW Table_text3
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw .8
	movwf TFT_X+1
	movlw .32 + .4
	movwf TFT_Y+0
	movwf TFT_Y+1
	call TFT_drawText

	;1) YOU HAVE 3 ATTEMPTS
	movlw HIGH Table_text4
	movwf textPointer+0
	movlw LOW Table_text4
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw .8
	movwf TFT_X+1
	movlw .64 + .8
	movwf TFT_Y+0
	movwf TFT_Y+1
	call TFT_drawText

	;2) WAIT FOR THE GREEN LED
	movlw HIGH Table_text5
	movwf textPointer+0
	movlw LOW Table_text5
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw .8
	movwf TFT_X+1
	movlw .104 + .4
	movwf TFT_Y+0
	movwf TFT_Y+1
	call TFT_drawText

	;AND PRESS THE STOP BUTTON
	movlw HIGH Table_text6
	movwf textPointer+0
	movlw LOW Table_text6
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw .8
	movwf TFT_X+1
	movlw .140
	movwf TFT_Y+0
	movwf TFT_Y+1
	call TFT_drawText

	;AS FAST AS YOU CAN
	movlw HIGH Table_text7
	movwf textPointer+0
	movlw LOW Table_text7
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw .8
	movwf TFT_X+1
	movlw .172
	movwf TFT_Y+0
	movwf TFT_Y+1
	call TFT_drawText

	;3) ENTER YOUR INITIALS
	movlw HIGH Table_text8
	movwf textPointer+0
	movlw LOW Table_text8
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw .8
	movwf TFT_X+1
	movlw .204 + .4
	movwf TFT_Y+0
	movwf TFT_Y+1
	call TFT_drawText

	;IF THE AVERAGE MAKES IT TO
	movlw HIGH Table_text9
	movwf textPointer+0
	movlw LOW Table_text9
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw .8
	movwf TFT_X+1
	movlw HIGH .240
	movwf TFT_Y+0
	movlw LOW .240
	movwf TFT_Y+1
	call TFT_drawText

	;THE *** HALL OF FAME ***
	movlw HIGH Table_text10
	movwf textPointer+0
	movlw LOW Table_text10
	movwf textPointer+1

	movlw .0
	movwf TFT_X+0
	movlw .8
	movwf TFT_X+1
	movlw HIGH .272
	movwf TFT_Y+0
	movlw LOW .272
	movwf TFT_Y+1
	call TFT_drawText

	return
;}

;*******************************************************************
;******************* ZAPINANI/VYPINANI TIMERU1 pro odpocet *********
;*******************************************************************

; *** START TIMER1
startTimer1
;{

	BANK1
	bsf PIE1, TMR1IE
	BANK0

	call initTimer1Init

	bsf INTCON, PEIE		;Peripheral interrupt pro Timer1

	BANK0
	movlw b'00000101'		;Prescaler 1:1, internal, Timer1 ON
	movwf T1CON

	return
;}

; *** STOP TIMER1
stopTimer1
;{

	movlw b'00000100'		;Prescaler 1:1, internal, Timer1 OFF
	movwf T1CON

	bcf INTCON, PEIE		;Peripheral interrupt pro Timer1 - OFF

	BANK1
	bcf PIE1, TMR1IE
	BANK0
	return
;}

; *** INIT TIMER1 - nastav na 2000 = 1ms (pri 8MHz clocku)
;initTimer 0xF856 - 63574 (1962 * 2 = 3924) = 61612 (F0AC)
;loopTimer 0xF850 - 63568 (1968 * 2 = 3936) = 61600 (F0A0)
initTimer1Init
;{
	movlw 0xF0
	movwf TMR1H
	movlw 0xAC
	movwf TMR1L
	return
;}

initTimer1Loop
;{
	movlw 0xF0
	movwf TMR1H
	movlw 0xA0
	movwf TMR1L
	return
;}

;*******************************************************************
;******************* ZAPINANI/VYPINANI PRERUSENI *******************
;*******************************************************************

disableInterrupt
;{
	call stopTimer1			;Zakaz Timer1 preruseni
;	bcf INTCON, T0IE    	;Zakaz Timer0 interrupt
	bcf INTCON, GIE	    	;Zakaz vsechna preruseni
;	clrf TMR0
	clrf T2CON				;Nepouzivej Timer2
	BANK1
	bcf PIE1, TMR2IE
	BANK0
	return
;}

enableInterrupt
;{

	call startTimer1		;Povol Timer1 preruseni - odpocet

;	clrf TMR0
;	bsf INTCON, T0IE    	;Povol Timer0 interrupt

	bsf INTCON, GIE	    	;Povol vsechna preruseni
	return
;}

;*******************************************************************
;******************* H E R N I  R U T I N Y ************************
;*******************************************************************

GAME_init
;{
	movlw .1
	movwf GAME_round	;kolikaty pokus 1,2,3,4 = 1,2,3,4=avg

	movlw GAME_ROUNDS
	movwf GAME_roundCounter

	clrf GAME_timerH	;aktualne namereny cas v ms
	clrf GAME_timerL

	clrf GAME_totalTimeH
	clrf GAME_totalTimeL

	movlw FALSE
	movwf GAME_top5Achieved

	return
;}

GAME_computeAverage
;{
	movf GAME_totalTimeH, w
	movwf UTIL_DividendH
	movf GAME_totalTimeL, w
	movwf UTIL_DividendL
	call Div3Slow

	movf UTIL_QuotientH, w
	movwf GAME_timerH
	movf UTIL_QuotientL, w
	movwf GAME_timerL
	return
;}

GAME_addMeasuredToTotalTime
;{
	movf GAME_timerH, w
	addwf GAME_totalTimeH, f

	movf GAME_timerL, w
	addwf GAME_totalTimeL, f
	btfsc STATUS, C
	incf GAME_totalTimeH, f

	return
;}


;Zjisti, jestli mame stisknuty button STOP, pokud ano hrac podvadi
GAME_checkCheating
;{
	btfss BUTTON_STOP
	return
	movlw TRUE
	movwf GAME_isCheating
	return
;}
	

;Zapni Timer1 a zacni merit uplnunuly cas;
;Vystup GAME_timerH: GAME_timerL v ms, ktery uplynul od povoleni preruseni
GAME_startStopWatch
;{
	clrf GAME_timerH
	clrf GAME_timerL

	clrf GAME_isTimeout

	movlw HIGH GAME_TIMEOUT
	movwf GAME_timeoutH
	movlw LOW GAME_TIMEOUT
	movwf GAME_timeoutL

	call enableInterrupt
	return
;}


;Zastav preruseni
GAME_endStopWatch
;{
	call disableInterrupt
	return
;}


;Pri podvadeni nastav zmereny cas na 2s (timeout)
GAME_setTimePenalty
;{
	movlw HIGH GAME_TIMEOUT
	movwf GAME_timerH
	movlw LOW GAME_TIMEOUT
	movwf GAME_timerL	
	return
;}

GAME_decTimeoutTimer
;{
		movf GAME_timeoutL, f
		btfsc STATUS, Z ;je loByte na nule?
		goto GAME_decTimeoutTimer2
		decf GAME_timeoutL, w	;kopie pro nasledny OR (test na 0)
		decf GAME_timeoutL, f
		iorwf GAME_timeoutH, w ;Z flag nastaven pri 0 (loByte OR hiByte)
		return
GAME_decTimeoutTimer2
		decf GAME_timeoutL, f
		decf GAME_timeoutH, f
		bcf STATUS, Z	;Potrebuju vynulovat Zero (aby mi pri lo/hi 0/1 predchozi decf Z nenastavil)
		return
;}


GAME_waitForAnyButton
;{
		btfsc BUTTON_START		;Pri stisku vyskoc
		goto GAME_waitEnd
		btfsc BUTTON_STOP
		goto GAME_waitEnd
		goto GAME_waitForAnyButton
GAME_waitEnd				;Pockej na konec stisku
		movf PORTA, w
		andlw b'00000011'
		btfss STATUS, Z
		goto GAME_waitEnd
				
		movf TMR0, w		; Uloz nahodnou hodnotu
		movwf GAME_randH			
		
		return
;}

;Cekej na stisk START tlacitka, pote se vrat
GAME_waitForStartButton
;{
	btfss BUTTON_START
	goto GAME_waitForStartButton
GAME_waitStartDebounce
	btfsc BUTTON_START
	goto GAME_waitStartDebounce
	
	movf TMR0, w		; Uloz nahodnou hodnotu
	movwf GAME_randL
			
	return
;}


;Cekej na stisk STOP tlacitka nebo na timeout
GAME_waitForStopButton
;{
	btfsc GAME_isTimeout, 0		;Mame timeout, koncime
	goto GAME_waitStopFinish
	btfsc BUTTON_STOP
	goto GAME_waitStopFinish
	goto GAME_waitForStopButton
	
GAME_waitStopFinish

	movf TMR0, w		; Uloz nahodnou hodnotu
	movwf GAME_randH
	return

;}


;Pockej W-REG milisekund a mezitim testuj na cheating
GAME_waitMilisWithCheatingTest	
;{
	movwf i
GAME_w1
	btfsc BUTTON_STOP
	bsf GAME_isCheating, 0		;Cheatujeme
	movlw .1
	call waitMilis
	decfsz i, f
	goto GAME_w1
	return
;}

; Wait random - s testem na cheating. Pokud behem cekani hrac
; stiskne STOP tlacitko pred rozsvicenim zelene LEDky, nastavim
; GAME_isCheating na TRUE.

; Vstup: GAME_randH, GAME_randL - sesbirane v cekanich na tlacitka

; 1) Nahodne pockam 150ms na zacatku
; 2) Pockam 2secs (abych hrac stihl prehmatnout ze START na STOP tlacitko)
; 3) Z GAME_randH:GAME_randL mam 16bitove cislo, to orezu na 0-4095 (ms), celkovy
;    interval tedy bude <2.150,6.3>s

GAME_waitRandomNew
;{
	;1) nahodne pockej 150ms
	btfss TMR0, 0
	goto GAME_waitNext	
	movlw .150
	call GAME_waitMilisWithCheatingTest
	
GAME_waitNext	
	;2) Pridame 2sec (8x250ms)
	movlw .8
	movwf j
GAME_waitR2s
	movlw .250
	call GAME_waitMilisWithCheatingTest	
	decfsz j, f
	goto GAME_waitR2s
		
	;3) Orez GAME_randH na dolni 4 bity, tj. 8 + 4 = 12 bitu = 0-4095
	movlw b'00001111'
	andwf GAME_randH, w
	movwf hiByte
	movf GAME_randL, w
	movwf loByte
	 
GAME_waitRandomL
	;4) Nyni mam v hiByte:loByte 16bit cislo 0-4095, tolik ms budeme cekat
	movlw .1
	call GAME_waitMilisWithCheatingTest
	call decHL
	btfss STATUS, Z
	goto GAME_waitRandomL
	
	return	
;}


; Wait random (2.5secs - 5.5secs)
;Podle hodnoty TMR0 pockej
;1) vezmi bity 0 a 1 - z nich poskladam 0, 1, 2, 3 dec
;2) prictu 2ku a pockam $vysledek sekund
;3) zjisti bit 2 TMR0
;4) If set, wait dalsich 450ms
;5) else    wait dalsich 150ms
GAME_waitRandom
;{
	movf TMR0, w
	andlw b'00000011'
	addlw .3 ;2 + 1 pro cyklus
	movwf i
waitR
	decfsz i, f
	goto wNonZero
	goto nextWaitR
wNonZero
	call wait1s
	goto waitR
nextWaitR
	btfss TMR0, 2
	goto wNotSet
	call wait150ms
	call wait150ms
wNotSet
	call wait150ms
	return
;}

GAME_turnLedOn
;{
	bsf LED
	return
;}

GAME_turnLedOff
;{
	bcf LED
	return
;}


;Zjisti, jestli neni score na zapis do Top5
;Vrat carry, pokud ano a ve W-REG je cislo pozice v Top5
GAME_checkTimeForTop5
;{

	movlw .5
	movwf j				;maximalne 5 cyklu

	movlw .6			;v i bude ulozene 1-5, pokud mame rekord,
	movwf i				;nebo 6, pokud neni score v top5

	bsf STATUS, IRP		;FSR v BANK2
	movlw LOW(EEPROM_Top5) + .25 - .2
	movwf FSR

GAME_checkScoreLoop		;jedeme v TOP5 odspodu
	movf INDF, w
	movwf hiByte		;hiByte
	incf FSR, f
	movf INDF, w
	movwf loByte		;loByte

	call TOP5_isTimeLower ;porovnej tmp16bit a GAME_timer
	btfss STATUS, C		;game_Score > tmp16bit
	goto GAME_checkScoreFinish
	decf i, f			;posun v top5
	movlw .6
	subwf FSR, f		;posun v tabulce na predchozi zaznam v TOP5
	decfsz j, f
	goto GAME_checkScoreLoop

GAME_checkScoreFinish	;Nastav carry, pokud jsme <6
	bcf STATUS, IRP
	movlw .6
	subwf i, w
	bsf STATUS, C		;Nastav carry, kdyz tak ho shodim
	btfsc STATUS, Z
	bcf STATUS, C		;jsme 6, nejsme v top5
	movf i, w			;Nemeni carry, vrat Wreg s pozici v top5 pri carry
	return
;}


; *******************************************************************************
; ********************** T O P  5   R U T I N Y *********************************
; *******************************************************************************

;Vstup: TOP5_position
TOP5_enterInitials
;{	

	movlw 'A'
	movwf TOP5_char
	
	call TFT_setYellowFG
	
	call TOP5_getTop5PositionOffset	;Ziskej offset v TOP5 tabulce, kam ukladat znaky
	movwf TOP5_copyTo
	
	;Levy horni roh TOP5 zaznamu
	movlw HIGH FORM_TOP5_X
	movwf TFT_X+0
	movwf TFT_X_COPY+0
	movlw LOW FORM_TOP5_X
	movwf TFT_X+1
	movwf TFT_X_COPY+1
		
	movlw HIGH FORM_TOP5_Y
	movwf TFT_Y+0
	movlw LOW FORM_TOP5_Y
	movwf TFT_Y+1
	
	clrf tmp
	
	;Posun se na spravny radek (Y-offset) podle pozice ((Position-1) * 2 * CHAR_HEIGHT)
	decf TOP5_positionTop5, w
	btfsc STATUS, Z
	goto TOP5_noCalc
	
	movwf i
TOP5_computeY
	movlw .2 * FONT_CHAR_HEIGHT
	addwf tmp, f
	decfsz i, f
	goto TOP5_computeY
	
	movf tmp, w
	addwf TFT_Y+1, f
	btfsc STATUS, C
	incf TFT_Y+0, f
	
TOP5_noCalc

	movf TOP5_char, w			;Vypis 'A' na prvni pozici
	call TFT_drawChar
	
	movlw .3					;Vkladame 3 znaky
	movwf k
	
;START_BUTTON(NEXT) - posunuje pismeno +1, STOP_BUTTON(ENTER) vlozi pismeno na pozici
TOP5_enterLoop

	;Mame uz vlozeny 3 znaky?
	movf k, f
	btfsc STATUS, Z
	return
	
	;1. Otestuj ENTER(STOP) button (vloz znak a posun se na dalsi pozici)
	btfss BUTTON_STOP
	goto TOP5_checkStartButton

	;debounce
	movlw .1
	call waitMilis
	btfss BUTTON_STOP
	goto TOP5_checkStartButton
TOP5_stopButtonEnd				;Pockej na konec stisku
	btfsc BUTTON_STOP
	goto TOP5_stopButtonEnd
	
	call TOP5_storeChar			; A uloz aktualni znak do TOP5
	
	movlw .2 * FONT_CHAR_WIDTH	;X-ovou si uchovej, pro presun na dalsi pozici
	addwf TFT_X_COPY+1, f
	btfsc STATUS, C
	incf TFT_X_COPY+0, f
	
	movf TFT_X_COPY+0, w
	movwf TFT_X+0
	movf TFT_X_COPY+1, w
	movwf TFT_X+1
	
	call wait150ms				;Pockej

	decf k, f					;Dekrementuj pocitadlo vkladanych znaku
	btfsc STATUS, Z
	return
	
	movlw 'A'
	movwf TOP5_char				;Vypis 'A' na prvni pozici
	call TFT_drawChar
	
	goto TOP5_enterLoop
					
TOP5_checkStartButton
		
	;2. Otestuj NEXT(START) button
	btfss BUTTON_START
	goto TOP5_enterLoop

	;debounce
	movlw .1
	call waitMilis
	btfss BUTTON_START
	goto TOP5_enterLoop
TOP5_startButtonEnd				;Pockej na konec stisku
	btfsc BUTTON_START
	goto TOP5_startButtonEnd

	call TOP5_incChar
	
	movf TFT_X_COPY+0, w
	movwf TFT_X+0
	movf TFT_X_COPY+1, w
	movwf TFT_X+1
	
	movf TOP5_char, w
	call TFT_drawChar	
	
	call wait150ms	
	
	goto TOP5_enterLoop			

;}

;Uloz vybrany znak do TOP5 tabulky na spravne misto
;Vstup: TOP5_copyTo (adresa do tabulky)
;Vstup: TOP5_char
;Vystup: Vlozi TOP5_char na [TOP5_copyTo] a posune TOP5_copyTo+1
TOP5_storeChar
;{
	
	bsf STATUS, IRP
	movlw LOW(EEPROM_Top5)
	addwf TOP5_copyTo, w	;Nastav se na spravnou pozici v Top5	
	movwf FSR
	
	movf TOP5_char, w
	movwf INDF
	
	incf TOP5_copyTo, f
	
	bcf STATUS, IRP	
	return	
;}

; > 'Z' ? ---> 'A'
TOP5_incChar
;{
	incf TOP5_char, f
	movlw '['  			; 'Z' + .1
	subwf TOP5_char, w
	movlw 'A'
	btfsc STATUS, Z
	movwf TOP5_char
	return
;}

;Vrat CARRY, pokud je GAME_timer < hiByte:loByte
TOP5_isTimeLower
;{
	movf GAME_timerH, w		;vyssi byte
	subwf hiByte, w
	btfss STATUS, C			;je game_timerH >= ?
	return					;Vrat se se shozenym CARRY
	;Jestli je vyssi byte ostre vetsi, uz dale netestuj a nahod CARRY
	btfss STATUS, Z			;pri rovnosti testuj dale
	return
	movf GAME_timerL, w
	subwf loByte, w			;nizsi byte
	btfss STATUS, C			;nizsi byte mensi, konec
	return
	;pokud je nastavene ZERO, mame rovnost, tzn. GAME_timer neni
	;ostre mensi => nenastavim CARRY
	btfsc STATUS, Z
	bcf STATUS, C			;game_timer = hiByte:loByte
	return
;}

;Na pozici positionTop5 v Top5 uloz nove jmeno a score
TOP5_storeScoreToTop5
;{
	call TOP5_getTop5PositionOffset
	movwf tmp

	bsf STATUS, IRP
	movlw LOW(EEPROM_Top5)
	addwf tmp, w		;Nastav se na spravnou pozici v Top5
	movwf FSR
	movlw 'A'			;Vypln pozici 'A  ' <GAME_timer>
	movwf INDF
	incf FSR, f
	movlw '/'
	movwf INDF
	incf FSR, f
	movlw '/'
	movwf INDF
	incf FSR, f
	movf GAME_timerH, w
	movwf INDF
	incf FSR, f
	movf GAME_timerL, w
	movwf INDF

	bcf STATUS, IRP

	return
;}

;1=0,2=5;3=10,4=15,5=20
TOP5_getTop5PositionOffset
;{
	movf TOP5_positionTop5, w
	movwf tmp
getPos1
	decfsz tmp, f
	goto getPos2
	retlw .0
getPos2
	decfsz tmp, f
	goto getPos3
	retlw .5
getPos3
	decfsz tmp, f
	goto getPos4
	retlw .10
getPos4
	decfsz tmp, f
	goto getPos5
	retlw .15
getPos5
	retlw .20
;}

;Proved posuny radku v Top5 (odsun pozice nize)
TOP5_adjustTop5
;{

	;Kopirujeme v poradi 4->5, 3->4, 2->3, 1->2
	;podle ukladane pozice do Top5

	bsf STATUS, IRP			;Pracujeme s FSR v BANK2

	movlw LOW(EEPROM_Top5)+.15	;na 4. pozici v Top5
	movwf TOP5_copyFrom			;uloz FSR

	movlw LOW(EEPROM_Top5)+.20	;5. pozice
	movwf TOP5_copyTo

	movlw .5
	movwf i				;i = 5
	movf TOP5_positionTop5, w
	subwf i, f			;i = 5 - pozice
TOP5_adjustTop5Loop
	movf i, f			;i==0?
	btfsc STATUS, Z
	goto TOP5_adjustTop5Finish	;Hotovo

	call TOP5_copyTop5Line

	decf i, f
	goto TOP5_adjustTop5Loop

TOP5_adjustTop5Finish
	bcf STATUS, IRP
	return
;}

;Kopiruj lajnu copyFrom -> copyTo
TOP5_copyTop5Line
;{
	movlw .5
	movwf j
TOP5_copyTop5Loop
	movf TOP5_copyFrom, w
	movwf FSR
	movf INDF, w
	movwf tmp
	movf TOP5_copyTo, w
	movwf FSR
	movf tmp, w
	movwf INDF
	incf TOP5_copyFrom, f
	incf TOP5_copyTo, f
	decfsz j, f
	goto TOP5_copyTop5Loop
	movlw .10
	subwf TOP5_copyFrom, f		;Posun o pozici v Top5 zaznamech vyse
	subwf TOP5_copyTo, f
	return
;}


; *****************************************************************
; ********************** E E P R O M   R U T I N Y ****************
; *****************************************************************

;Uloz TOP5 do EEPROM PIC
EEPROM_saveTop5
;{
		;Adresa zacatku dat pro zapis do EEPROM data
		bsf STATUS, IRP		;BANK2 FSR
		movlw LOW(EEPROM_Top5)
		movwf FSR

		clrf EEPROM_addr			     ;Od addresy 0
		movlw EEPROM_Top5_init_table_len ;Zapiseme 25 bajtu
		movwf i
EEPROM_iLoop
		movf INDF, w
		movwf EEPROM_value
		call EEPROM_writeByte

		incf EEPROM_addr, f			;Adresa+1

		incf FSR, f

		decfsz i, f
		goto EEPROM_iLoop

		bcf STATUS, IRP		;FSR v BANK0 a BANK1

		return
;}

;EEPROM_readTop5
;Nacte z PIC EEPROM TOP5 do BANK2 od adresy 0x20
EEPROM_readTop5
;{
		clrf EEPROM_addr	; Cteme od addresy 0

		movlw EEPROM_Top5_init_table_len	;Nacteme Top5
		movwf i

		bsf STATUS, IRP		;BANK2 FSR
		movlw TOP5_TABLE_ADDR
		movwf FSR

EEPROM_rLoop
		movf EEPROM_addr, w
		BANK2
		movwf EEADR 		; Address to read
		BANK3
		bcf EECON1, EEPGD 	; Point to Data memory
		bsf EECON1, RD 		; EE Read
		BANK2
		movf EEDATA, w 		; W = EEDATA
		BANK0
		movwf INDF
		incf FSR, f

		incf EEPROM_addr, f
		decfsz i, f
		goto EEPROM_rLoop

		bcf STATUS, IRP		;FSR v BANK0 a BANK1
		return
;}

;EEPROM_writeByte
;Vstup: EEPROM_addr	- pozice v EEPROM
;		EEPROM_value - byte k zapisu
EEPROM_writeByte
;{
		BANK2	
		movf	EEPROM_addr, w	
		movwf 	EEADR				;Address to write
		movf 	EEPROM_value, w		;Data Memory Value to write
		movwf 	EEDATA 
		BANK3		
		bcf 	EECON1,EEPGD	 	;Point to DATA memory
		bsf 	EECON1,WREN 		;Enable writes
		bcf 	INTCON,GIE 			;Disable INTs.
		movlw 	0x55 
		movwf 	EECON2 				;Write 55h
		movlw 	0xAA
		movwf 	EECON2 				;Write AAh
		bsf 	EECON1,WR 			;Set WR bit to begin write
		bsf 	INTCON,GIE 			;Enable INTs.
		bcf 	EECON1,WREN 		;Disable writes
		btfsc	EECON1,WR 			;Wait for write to complete
		GOTO 	$-1 
		BANK0
		return
;}


;EEPROM_readTop5
;;{
;		clrf EEPROM_addr	; Cteme od addresy 0
;
;		movlw HIGH EEPROM_Top5_init_table
;		movwf dataPointer+0
;		movlw LOW EEPROM_Top5_init_table
;		movwf dataPointer+1
;
;		movlw EEPROM_Top5_init_table_len	;Nacteme Top5
;		movwf i
;
;		bsf STATUS, IRP		;BANK2 FSR
;		movlw TOP5_TABLE_ADDR
;		movwf FSR
;
;EEPROM_rLoop
;		call TFT_getNextByte
;		movwf INDF
;
;		incf FSR, f
;
;		decfsz i, f
;		goto EEPROM_rLoop
;
;		bcf STATUS, IRP		;FSR v BANK0 a BANK1
;		return
;;}

UTIL_populateNumber
;{
	call bin16_to_ascii

	;Preved na text B.CDE (cislo je < 10000)
	movf UTIL_Thou, w
	movwf TFT_number+0
	movlw '.'
	movwf TFT_number+1
	movf UTIL_Hund, w
	movwf TFT_number+2
	movf UTIL_Tens, w
	movwf TFT_number+3
	movf UTIL_Ones, w
	movwf TFT_number+4
	return
;}



; *** SUBRUTINA, CEKEJ nuMilis milisekund ***************************

waitSecs
;{
		movwf numSecs
waitS	call wait1s
		decfsz numSecs, f
		goto waitS
		return
;}

waitMilis
;{
		movwf numMilis
waitM	call wait1ms
		decfsz numMilis, f
		goto waitM
		return
;}

wait10ms
;{
		movlw .10
		goto waitMilis
;}

wait100ms
;{
		movlw .100
		goto waitMilis
;}

wait150ms
;{
		movlw .150
		goto waitMilis
;}

wait500ms
;{		
	movlw .250
	call waitMilis
	movlw .250
	goto waitMilis
;}

; Delay = 0.001 seconds
; Clock frequency = 16 MHz

; Actual delay = 0.001 seconds = 4000 cycles
; Error = 0 %

wait1ms
;{
			;3993 cycles
	movlw	0x1E
	movwf	del1
	movlw	0x04
	movwf	del2
wait1ms_0
	decfsz	del1, f
	goto	$+2
	decfsz	del2, f
	goto	wait1ms_0

			;3 cycles
	goto	$+1
	nop

			;4 cycles (including call)
	return
;}

; Delay = 1 seconds
; Clock frequency = 16 MHz

; Actual delay = 1 seconds = 4000000 cycles
; Error = 0 %

wait1s
;{
			;3999994 cycles
	movlw	0x23
	movwf	del1
	movlw	0xB9
	movwf	del2
	movlw	0x09
	movwf	del3
wait1s_0
	decfsz	del1, f
	goto	$+2
	decfsz	del2, f
	goto	$+2
	decfsz	del3, f
	goto	wait1s_0

			;2 cycles
	goto	$+1

			;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
	return
;}

bin16_to_ascii
;{
		swapf	UTIL_NumH,w
        andlw   0x0F
        addlw   0xF0
        movwf   UTIL_Thou
        addwf   UTIL_Thou,f
        addlw   .226
        movwf   UTIL_Hund
        addlw   .50
        movwf   UTIL_Ones

        movf    UTIL_NumH,w
        andlw   0x0F
        addwf   UTIL_Hund,f
        addwf   UTIL_Hund,f
        addwf   UTIL_Ones,f
        addlw   .233
        movwf   UTIL_Tens
        addwf   UTIL_Tens,f
        addwf   UTIL_Tens,f

        swapf   UTIL_NumL,w
        andlw   0x0F
        addwf   UTIL_Tens,f
        addwf   UTIL_Ones,f

        rlf     UTIL_Tens,f
        rlf     UTIL_Ones,f
        comf    UTIL_Ones,f

        rlf     UTIL_Ones,f

        movf    UTIL_NumL,w
        andlw   0x0F
        addwf   UTIL_Ones,f
        rlf     UTIL_Thou,f

        movlw   0x07
        movwf   UTIL_TenK

        movlw   .10
Lb1
        addwf   UTIL_Ones,f
        decf    UTIL_Tens,f
        btfss   3,0
	;skip no carry
         goto   Lb1
	;jmp carry
Lb2
        addwf   UTIL_Tens,f
        decf    UTIL_Hund,f
        btfss   3,0
         goto   Lb2
Lb3
        addwf   UTIL_Hund,f
        decf    UTIL_Thou,f
        btfss   3,0
        goto   Lb3
Lb4
        addwf   UTIL_Thou,f
        decf    UTIL_TenK,f
        btfss   3,0
        goto   Lb4

		;Preved decimal cislice -> ascii hodnoty
		movlw '0'
		addwf UTIL_TenK, f
		addwf UTIL_Thou, f
		addwf UTIL_Hund, f
		addwf UTIL_Tens, f
		addwf UTIL_Ones, f

        return

;}






; Vstup: UTIL_DividendH:UTIL_DividendL
; Vystup: UTIL_QuotientH:UTIL_QuotientL
Div3Slow
;{
    clrf hiByte
    clrf loByte

    clrf UTIL_QuotientH
    clrf UTIL_QuotientL

Div3SlowLoop

    ;if (Dividend - Quotient < 3) then return
    movf UTIL_QuotientH, w
    subwf UTIL_DividendH, w        ;DividendH - QuotientH == 0?
    btfss STATUS, Z
    goto Div3SlowCanAddMore3

    ;if (X < 3) konec
    movf UTIL_QuotientL, w
    subwf UTIL_DividendL, w
    addlw .253
    btfsc STATUS, C
    goto Div3SlowCanAddMore3

    ;Hotovo, nakopiruj vypocet
    movf hiByte, w
    movwf UTIL_QuotientH
    movf loByte, w
    movwf UTIL_QuotientL
    return


Div3SlowCanAddMore3

    ;Pricti 3
    movlw .3
    addwf UTIL_QuotientL, f
    btfsc STATUS, C
    incf UTIL_QuotientH, f

    call incHL

    goto Div3SlowLoop

;}

; Rutina pro deleni 16bit / 3
; Vstup: UTIL_DividendH:UTIL_DividendL
; Vystup: UTIL_QuotientH:UTIL_QuotientL

;x/3 = x/2 - x/4 + x/8 - x/16 + x/32 - x/64...

Div3                    ; Divide Contents of "UTIL_DividendH:UTIL_DividendL" by 3
;{
    clrf UTIL_QuotientH
    clrf UTIL_QuotientL

Div3_Loop               ; Loop Until the UTIL_Dividend == 0

    bcf STATUS, C
    rrf UTIL_DividendH, f      ; UTIL_Dividend /2 (ie "x/2" in Series)
    rrf UTIL_DividendL, f

    movf UTIL_DividendH, w     ; Is it Equal to Zero?
    iorwf UTIL_DividendL, w

    btfsc STATUS, Z
    return                   ;  If it is, then Stop

    movf UTIL_DividendL, w
    addwf UTIL_QuotientL, f    ;  Add the Value to the UTIL_Quotient
    btfss STATUS, C
    goto Div3_noCarry
    incf UTIL_QuotientH, f

Div3_noCarry

    movf UTIL_DividendH, w
    addwf UTIL_QuotientH, f

    bcf STATUS, C
    rrf UTIL_DividendH, f     ;  UTIL_Dividend /2 (ie "x/4" in Series)
    rrf UTIL_DividendL, f

    movf UTIL_DividendH, w
    iorwf UTIL_DividendL, w
    btfsc STATUS, Z
    return

    movf UTIL_DividendL, w       ; UTIL_Quotient = UTIL_Quotient-(UTIL_Dividend / 4)
    subwf UTIL_QuotientL, f

    movf UTIL_DividendH, w
    btfss STATUS, C      ; UTIL_QuotientL > UTIL_DividendL
    decf UTIL_QuotientH, f
    subwf UTIL_QuotientH, f

    goto Div3_Loop
;}


;
; *****************************************************************
; ********************** F O N T  D A T A *************************
; *****************************************************************

		org ADDR_GFX_DATA_START


Table_font

Table_font_point
;{
	;.
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0xFF,0x00
	dt 0x00,0xFF,0x00
	dt 0x00,0xFF,0x00
	dt 0x00,0xFF,0x00
	dt 0x00,0xFF,0x00
	dt 0x00,0xFF,0x00
	dt 0x00,0xFF,0x00
	dt 0x00,0x00,0x00

;}


		org ADDR_GFX_DATA_START + 0x100
	;/ - bude pouzito jako '-'
Table_font_dash
;{
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x0F,0xFF,0xF0
	dt 0x0F,0xFF,0xF0
	dt 0x0F,0xFF,0xF0
	dt 0x0F,0xFF,0xF0
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x00
;}

		org ADDR_GFX_DATA_START + 0x200
	;0
Table_font_0
;{

	dt 0x00,0x00,0x00
	dt 0x0F,0xFF,0xF0
	dt 0x17,0xFF,0xE8
	dt 0x1B,0xFF,0xD8
	dt 0x1D,0xFF,0xB8
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x0E,0x00,0x70
	dt 0x06,0x00,0x60
	dt 0x06,0x00,0x60
	dt 0x0E,0x00,0x70
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1D,0xFF,0xB8
	dt 0x1B,0xFF,0xD8
	dt 0x17,0xFF,0xE8
	dt 0x0F,0xFF,0xF0
	dt 0x00,0x00,0x00
Table_font_0_end
digit_len			equ Table_font_0_end - Table_font_0
;}

		org ADDR_GFX_DATA_START + 0x300

Table_font_1
	;1
;{
	dt 0x00,0x00,0x00
	dt 0x00,0x00,0x30
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x70
	dt 0x00,0x00,0x60
	dt 0x00,0x00,0x60
	dt 0x00,0x00,0x70
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x30
	dt 0x00,0x00,0x00
;}
		org ADDR_GFX_DATA_START + 0x400

Table_font_2
	;2
;{
	dt 0x00,0x00,0x00
	dt 0x0F,0xFF,0xF0
	dt 0x1F,0xFF,0xE8
	dt 0x1F,0xFF,0xD8
	dt 0x0F,0xFF,0xB8
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x0F,0xFF,0xF8
	dt 0x1F,0xFF,0xF8
	dt 0x1F,0xFF,0xF8
	dt 0x1F,0xFF,0xF0
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1D,0xFF,0xF0
	dt 0x1B,0xFF,0xF8
	dt 0x17,0xFF,0xF8
	dt 0x0F,0xFF,0xF0
	dt 0x00,0x00,0x00
;}

		org ADDR_GFX_DATA_START + 0x500

Table_font_3
	;3
;{
	dt 0x00,0x00,0x00
	dt 0x0F,0xFF,0xF0
	dt 0x1F,0xFF,0xE8
	dt 0x1F,0xFF,0xD8
	dt 0x0F,0xFF,0xB8
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0xFF,0xF0
	dt 0x01,0xFF,0xE0
	dt 0x01,0xFF,0xE0
	dt 0x00,0xFF,0xF0
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x0F,0xFF,0xB8
	dt 0x1F,0xFF,0xD8
	dt 0x1F,0xFF,0xE8
	dt 0x0F,0xFF,0xF0
	dt 0x00,0x00,0x00
;}
		org ADDR_GFX_DATA_START + 0x600

Table_font_4
	;4
;{
	dt 0x00,0x00,0x00
	dt 0x0C,0x00,0x30
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1F,0xFF,0xF0
	dt 0x1F,0xFF,0xE0
	dt 0x1F,0xFF,0xE0
	dt 0x0F,0xFF,0xF0
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x30
	dt 0x00,0x00,0x00
;}
		org ADDR_GFX_DATA_START + 0x700

Table_font_5
	;5
;{
	dt 0x00,0x00,0x00
	dt 0x0F,0xFF,0xF0
	dt 0x17,0xFF,0xF8
	dt 0x1B,0xFF,0xF8
	dt 0x1D,0xFF,0xF0
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1F,0xFF,0xF0
	dt 0x1F,0xFF,0xF8
	dt 0x1F,0xFF,0xF8
	dt 0x0F,0xFF,0xF8
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x0F,0xFF,0xB8
	dt 0x1F,0xFF,0xD8
	dt 0x1F,0xFF,0xE8
	dt 0x0F,0xFF,0xF0
	dt 0x00,0x00,0x00
;}
		org ADDR_GFX_DATA_START + 0x800

Table_font_6
	;6
;{
	dt 0x00,0x00,0x00
	dt 0x0F,0xFF,0xF0
	dt 0x17,0xFF,0xF8
	dt 0x1B,0xFF,0xF8
	dt 0x1D,0xFF,0xF0
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1E,0x00,0x00
	dt 0x1F,0xFF,0xF0
	dt 0x1F,0xFF,0xF8
	dt 0x1F,0xFF,0xF8
	dt 0x1F,0xFF,0xF8
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1F,0xFF,0xB8
	dt 0x1F,0xFF,0xD8
	dt 0x1F,0xFF,0xE8
	dt 0x0F,0xFF,0xF0
	dt 0x00,0x00,0x00
;}
		org ADDR_GFX_DATA_START + 0x900

Table_font_7
	;7
;{
	dt 0x00,0x00,0x00
	dt 0x0F,0xFF,0xF0
	dt 0x1F,0xFF,0xE8
	dt 0x1F,0xFF,0xD8
	dt 0x0F,0xFF,0xB8
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x70
	dt 0x00,0x00,0x60
	dt 0x00,0x00,0x60
	dt 0x00,0x00,0x70
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x30
	dt 0x00,0x00,0x00
;}
		org ADDR_GFX_DATA_START + 0xA00

Table_font_8
	;8
;{
	dt 0x00,0x00,0x00
	dt 0x0F,0xFF,0xF0
	dt 0x1F,0xFF,0xE8
	dt 0x1F,0xFF,0xD8
	dt 0x1F,0xFF,0xB8
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x0F,0xFF,0xF0
	dt 0x07,0xFF,0xE0
	dt 0x07,0xFF,0xE0
	dt 0x0F,0xFF,0xF0
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1D,0xFF,0xF8
	dt 0x1B,0xFF,0xF8
	dt 0x17,0xFF,0xF8
	dt 0x0F,0xFF,0xF0
	dt 0x00,0x00,0x00
;}
		org ADDR_GFX_DATA_START + 0xB00

Table_font_9
	;9
;{
	dt 0x00,0x00,0x00
	dt 0x0F,0xFF,0xF0
	dt 0x17,0xFF,0xF8
	dt 0x1B,0xFF,0xF8
	dt 0x1D,0xFF,0xF8
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1E,0x00,0x78
	dt 0x1F,0xFF,0xF8
	dt 0x1F,0xFF,0xF8
	dt 0x1F,0xFF,0xF8
	dt 0x0F,0xFF,0xF8
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x00,0x00,0x78
	dt 0x0F,0xFF,0xB8
	dt 0x1F,0xFF,0xD8
	dt 0x1F,0xFF,0xE8
	dt 0x0F,0xFF,0xF0
	dt 0x00,0x00,0x00
;}


		org ADDR_GFX_DATA_START + 0xC00

Table_avg
;{
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x1F, 0x86, 0x18, 0x7E, 0x00 ;            ######    ##    ##    ######
	dt 0x00, 0x7F, 0xCE, 0x18, 0x7E, 0x00 ;          #########  ###    ##    ######
	dt 0x00, 0x70, 0xCE, 0x19, 0xC0, 0x00 ;          ###    ##  ###    ##  ###
	dt 0x00, 0x71, 0xCE, 0x39, 0xC0, 0x00 ;          ###   ###  ###   ###  ###
	dt 0x00, 0x61, 0xCC, 0x39, 0x80, 0x00 ;          ##    ###  ##    ###  ##
	dt 0x00, 0x61, 0xCC, 0x39, 0x80, 0x00 ;          ##    ###  ##    ###  ##
	dt 0x00, 0xFF, 0x8C, 0x31, 0x9F, 0x00 ;         #########   ##    ##   ##  #####
	dt 0x00, 0xFF, 0x8C, 0xE1, 0x9E, 0x00 ;         #########   ##  ###    ##  ####
	dt 0x00, 0xE1, 0x9D, 0xE3, 0x86, 0x00 ;         ###    ##  ### ####   ###    ##
	dt 0x00, 0xE3, 0x9F, 0xC3, 0x8E, 0x00 ;         ###   ###  #######    ###   ###
	dt 0x00, 0xC3, 0x9F, 0x07, 0x0E, 0x00 ;         ##    ###  #####     ###    ###
	dt 0x00, 0xC3, 0x9E, 0x07, 0x0E, 0x00 ;         ##    ###  ####      ###    ###
	dt 0x01, 0xC3, 0xBC, 0x07, 0xFC, 0x00 ;        ###    ### ####       #########
	dt 0x01, 0xC3, 0x38, 0x03, 0xF8, 0x00 ;        ###    ##  ###         #######
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
;}
Table_avg_end
avg_len			equ Table_avg_end - Table_avg

Table_bullet
;{
	dt 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00 ;
	dt 0x00, 0x7C, 0x00 ;          #####
	dt 0x01, 0xFF, 0x00 ;        #########
	dt 0x03, 0xFF, 0x80 ;       ###########
	dt 0x07, 0xFF, 0xC0 ;      #############
	dt 0x07, 0xFF, 0xC0 ;      #############
	dt 0x0F, 0xFF, 0xE0 ;     ###############
	dt 0x0F, 0xFF, 0xE0 ;     ###############
	dt 0x0F, 0xFF, 0xE0 ;     ###############
	dt 0x0F, 0xFF, 0xE0 ;     ###############
	dt 0x0F, 0xFF, 0xE0 ;     ###############
	dt 0x0F, 0xFF, 0xE0 ;     ###############
	dt 0x07, 0xFF, 0xC0 ;      #############
	dt 0x07, 0xFF, 0xC0 ;      #############
	dt 0x03, 0xFF, 0x80 ;       ###########
	dt 0x01, 0xFF, 0x00 ;        #########
	dt 0x00, 0x7C, 0x00 ;          #####
	dt 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00 ;
;}
Table_bullet_end
bullet_len			equ Table_bullet_end - Table_bullet


		org ADDR_GFX_DATA_START + 0xD00

Table_time
;{
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x03, 0xFC, 0x61, 0xF8, 0x7F, 0x00 ;       ########   ##    ######    #######
	dt 0x03, 0xFC, 0xE3, 0xFC, 0xFF, 0x00 ;       ########  ###   ########  ########
	dt 0x00, 0xE0, 0xE7, 0xFC, 0xE0, 0x00 ;         ###     ###  #########  ###
	dt 0x00, 0xE0, 0xE6, 0xDC, 0xE0, 0x00 ;         ###     ###  ## ## ###  ###
	dt 0x00, 0xE0, 0xC6, 0xDC, 0xC0, 0x00 ;         ###     ##   ## ## ###  ##
	dt 0x00, 0xE0, 0xC6, 0xDC, 0xC0, 0x00 ;         ###     ##   ## ## ###  ##
	dt 0x00, 0xC0, 0xC6, 0x18, 0xFE, 0x00 ;         ##      ##   ##    ##   #######
	dt 0x00, 0xC0, 0xC6, 0x19, 0xFE, 0x00 ;         ##      ##   ##    ##  ########
	dt 0x01, 0xC1, 0xCE, 0x19, 0xC0, 0x00 ;        ###     ###  ###    ##  ###
	dt 0x01, 0xC1, 0xCE, 0x39, 0xC0, 0x00 ;        ###     ###  ###   ###  ###
	dt 0x01, 0xC1, 0x8C, 0x39, 0x80, 0x00 ;        ###     ##   ##    ###  ##
	dt 0x01, 0xC1, 0x8C, 0x39, 0x80, 0x00 ;        ###     ##   ##    ###  ##
	dt 0x01, 0x83, 0x9C, 0x3B, 0xFC, 0x00 ;        ##     ###  ###    ### ########
	dt 0x01, 0x83, 0x9C, 0x33, 0xFC, 0x00 ;        ##     ###  ###    ##  ########
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
;}
Table_time_end
time_len			equ Table_time_end - Table_time


		org ADDR_GFX_DATA_START + 0xE00
Table_try
;{
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x7F, 0x8F, 0xE3, 0x86, 0x00, 0x00 ;  ########   #######   ###    ##
	dt 0x7F, 0x9F, 0xF3, 0x8E, 0x00, 0x6E ;  ########  #########  ###   ###          ## ###
	dt 0x1C, 0x1C, 0x33, 0x8E, 0x00, 0x6E ;    ###     ###    ##  ###   ###          ## ###
	dt 0x1C, 0x1C, 0x77, 0x0E, 0x00, 0x6E ;    ###     ###   ### ###    ###          ## ###
	dt 0x1C, 0x18, 0x77, 0x0E, 0x00, 0xEC ;    ###     ##    ### ###    ###         ### ##
	dt 0x1C, 0x18, 0x77, 0x0C, 0x00, 0xFC ;    ###     ##    ### ###    ##          ######
	dt 0x18, 0x3F, 0xE7, 0xFC, 0x03, 0xFF ;    ##     #########  #########        ##########
	dt 0x18, 0x3F, 0xC3, 0xF8, 0x03, 0xDF ;    ##     ########    #######         #### #####
	dt 0x38, 0x3E, 0x00, 0x1C, 0x00, 0xDC ;   ###     #####            ###          ## ###
	dt 0x38, 0x3F, 0x00, 0x1C, 0x03, 0xD8 ;   ###     ######           ###        #### ##
	dt 0x38, 0x37, 0x00, 0x1C, 0x03, 0xFE ;   ###     ## ###           ###        #########
	dt 0x38, 0x33, 0x80, 0x18, 0x03, 0xFE ;   ###     ##  ###          ##         #########
	dt 0x30, 0x31, 0xC7, 0xF8, 0x01, 0xF8 ;   ##      ##   ###   ########          ######
	dt 0x30, 0x30, 0xC7, 0xF0, 0x01, 0x98 ;   ##      ##    ##   #######           ##  ##
	dt 0x00, 0x00, 0x00, 0x00, 0x01, 0x98 ;                                        ##  ##
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
;}
Table_try_end
try_len			equ Table_try_end - Table_try

		org ADDR_GFX_DATA_START + 0xF00
Table_start1
;{
	dt 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, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 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, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x03, 0xF8, 0x7F, 0x0F, 0xE1, 0xF8, 0x3F, 0x00, 0x1F, 0x8F, 0xF0, 0xFC, 0x3F, 0x8F, 0xF0 ;       #######    #######    #######    ######     ######           ######   ########    ######    #######   ########
	dt 0x07, 0xFC, 0xFF, 0x9F, 0xE7, 0xF8, 0xFF, 0x00, 0x7F, 0x8F, 0xF3, 0xFE, 0x7F, 0xCF, 0xF0 ;      #########  #########  ########  ########   ########         ########   ########  #########  #########  ########
	dt 0x07, 0x0C, 0xE1, 0x9C, 0x07, 0x00, 0xE0, 0x00, 0x70, 0x03, 0x83, 0x86, 0x70, 0xC3, 0x80 ;      ###    ##  ###    ##  ###       ###        ###              ###          ###     ###    ##  ###    ##    ###
	dt 0x07, 0x1C, 0xE3, 0x9C, 0x07, 0x00, 0xE0, 0x00, 0x70, 0x03, 0x83, 0x8E, 0x71, 0xC3, 0x80 ;      ###   ###  ###   ###  ###       ###        ###              ###          ###     ###   ###  ###   ###    ###
	dt 0x06, 0x1C, 0xC3, 0x98, 0x06, 0x00, 0xC0, 0x00, 0x60, 0x03, 0x83, 0x0E, 0x61, 0xC3, 0x80 ;      ##    ###  ##    ###  ##        ##         ##               ##           ###     ##    ###  ##    ###    ###
	dt 0x06, 0x1C, 0xC3, 0x98, 0x06, 0x00, 0xC0, 0x00, 0x60, 0x03, 0x83, 0x0E, 0x61, 0xC3, 0x80 ;      ##    ###  ##    ###  ##        ##         ##               ##           ###     ##    ###  ##    ###    ###
	dt 0x07, 0xF9, 0xFF, 0x1F, 0xCF, 0xF1, 0xFE, 0x00, 0xFF, 0x03, 0x07, 0xFC, 0xFF, 0x83, 0x00 ;      ########  #########   #######  ########   ########         ########      ##     #########  #########     ##
	dt 0x0F, 0xF1, 0xFE, 0x3F, 0xC7, 0xF8, 0xFF, 0x00, 0x7F, 0x83, 0x07, 0xFC, 0xFF, 0x03, 0x00 ;     ########   ########   ########   ########   ########         ########     ##     #########  ########      ##
	dt 0x0E, 0x01, 0xF0, 0x38, 0x00, 0x18, 0x03, 0x00, 0x01, 0x87, 0x07, 0x0C, 0xF8, 0x07, 0x00 ;     ###        #####      ###              ##         ##               ##    ###     ###    ##  #####        ###
	dt 0x0E, 0x01, 0xF8, 0x38, 0x00, 0x38, 0x07, 0x00, 0x03, 0x87, 0x07, 0x1C, 0xFC, 0x07, 0x00 ;     ###        ######     ###             ###        ###              ###    ###     ###   ###  ######       ###
	dt 0x0C, 0x01, 0xB8, 0x30, 0x00, 0x38, 0x07, 0x00, 0x03, 0x87, 0x06, 0x1C, 0xDC, 0x07, 0x00 ;     ##         ## ###     ##              ###        ###              ###    ###     ##    ###  ## ###       ###
	dt 0x0C, 0x01, 0x9C, 0x30, 0x00, 0x38, 0x07, 0x00, 0x03, 0x87, 0x06, 0x1C, 0xCE, 0x07, 0x00 ;     ##         ##  ###    ##              ###        ###              ###    ###     ##    ###  ##  ###      ###
;}
Table_start1_end
start1_len		equ Table_start1_end - Table_start1

		org ADDR_GFX_DATA_START + 0x1000

Table_start2
;{
	dt 0x1C, 0x03, 0x8E, 0x7F, 0x87, 0xF0, 0xFE, 0x00, 0x7F, 0x06, 0x0E, 0x1D, 0xC7, 0x06, 0x00 ;    ###        ###   ###  ########    #######    #######          #######     ##     ###    ### ###   ###     ##
	dt 0x1C, 0x01, 0x86, 0x7F, 0x8F, 0xE1, 0xFC, 0x00, 0xFE, 0x06, 0x0E, 0x18, 0xC3, 0x06, 0x00 ;    ###         ##    ##  ########   #######    #######          #######      ##     ###    ##   ##    ##     ##
	dt 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, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 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, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
;}
Table_start2_end
start2_len		equ Table_start2_end - Table_start2

Table_wait2
;{
	dt 0x07, 0xF9, 0xC3, 0xB8, 0x30, 0x01, 0xC0, 0x7F, 0xC6, 0x38, 0x07, 0xFB, 0xFC, 0xFF, 0x80 ;      ########  ###    ### ###     ##           ###       #########   ##   ###        ######## ########  #########
	dt 0x07, 0xF1, 0xC3, 0x38, 0x30, 0x01, 0xC0, 0x3F, 0x86, 0x18, 0x07, 0xFB, 0xFC, 0xFF, 0x00 ;      #######   ###    ##  ###     ##           ###        #######    ##    ##        ######## ########  ########
	dt 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, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 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, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
;}
Table_wait2_end
wait2_len		equ Table_wait2_end - Table_wait2

		org ADDR_GFX_DATA_START + 0x1100
Table_wait1
;{
	dt 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, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 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, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;
	dt 0x01, 0x86, 0x1F, 0x86, 0x7F, 0x80, 0x7F, 0x87, 0xE1, 0xFC, 0x00, 0xC0, 0x7F, 0x1F, 0xC0 ;        ##    ##    ######    ##  ########        ########    ######    #######          ##       #######   #######
	dt 0x03, 0x86, 0x7F, 0xCE, 0x7F, 0x80, 0x7F, 0x87, 0xF3, 0xFE, 0x01, 0xC0, 0xFF, 0x3F, 0xE0 ;       ###    ##  #########  ###  ########        ########    #######  #########        ###      ########  #########
	dt 0x03, 0x86, 0x70, 0xCE, 0x1C, 0x00, 0x70, 0x1C, 0x33, 0x86, 0x01, 0xC0, 0xE0, 0x38, 0x60 ;       ###    ##  ###    ##  ###    ###           ###       ###    ##  ###    ##        ###      ###       ###    ##
	dt 0x03, 0x8E, 0x71, 0xCE, 0x1C, 0x00, 0x70, 0x1C, 0x73, 0x8E, 0x01, 0xC0, 0xE0, 0x38, 0xE0 ;       ###   ###  ###   ###  ###    ###           ###       ###   ###  ###   ###        ###      ###       ###   ###
	dt 0x03, 0x0E, 0x61, 0xCC, 0x1C, 0x00, 0x60, 0x1C, 0x73, 0x0E, 0x01, 0x80, 0xC0, 0x38, 0xE0 ;       ##    ###  ##    ###  ##     ###           ##        ###   ###  ##    ###        ##       ##        ###   ###
	dt 0x03, 0x0E, 0x61, 0xCC, 0x1C, 0x00, 0x60, 0x18, 0x73, 0x0E, 0x01, 0x80, 0xC0, 0x30, 0xE0 ;       ##    ###  ##    ###  ##     ###           ##        ##    ###  ##    ###        ##       ##        ##    ###
	dt 0x03, 0x0C, 0xFF, 0x8C, 0x18, 0x00, 0xFF, 0x18, 0x67, 0xFC, 0x01, 0x80, 0xFE, 0x30, 0xC0 ;       ##    ##  #########   ##     ##           ########   ##    ##  #########         ##       #######   ##    ##
	dt 0x03, 0x6C, 0xFF, 0x8C, 0x18, 0x00, 0xFF, 0x18, 0x67, 0xF8, 0x03, 0x81, 0xFE, 0x30, 0xC0 ;       ## ## ##  #########   ##     ##           ########   ##    ##  ########         ###      ########   ##    ##
	dt 0x07, 0x6C, 0xE1, 0x9C, 0x38, 0x00, 0xE0, 0x38, 0x67, 0xC0, 0x03, 0x81, 0xC0, 0x70, 0xC0 ;      ### ## ##  ###    ##  ###    ###           ###       ###    ##  #####            ###      ###       ###    ##
	dt 0x06, 0xEC, 0xE3, 0x9C, 0x38, 0x00, 0xE0, 0x38, 0xE7, 0xE0, 0x03, 0x81, 0xC0, 0x71, 0xC0 ;      ## ### ##  ###   ###  ###    ###           ###       ###   ###  ######           ###      ###       ###   ###
	dt 0x06, 0xEC, 0xC3, 0x98, 0x38, 0x00, 0xC0, 0x70, 0xE6, 0xE0, 0x03, 0x01, 0x80, 0x61, 0xC0 ;      ## ### ##  ##    ###  ##     ###           ##       ###    ###  ## ###           ##       ##        ##    ###
	dt 0x06, 0xCC, 0xC3, 0x98, 0x38, 0x00, 0xC0, 0x70, 0xE6, 0x70, 0x03, 0x01, 0x80, 0x61, 0xC0 ;      ## ##  ##  ##    ###  ##     ###           ##       ###    ###  ##  ###          ##       ##        ##    ###
;}
Table_wait1_end
wait1_len		equ Table_wait1_end - Table_wait1

		org ADDR_GFX_DATA_START + 0x1200

Table_text1	dt "REACTION/TIMER", 0x00
Table_text1_end
text1_len	equ Table_text1_end - Table_text1 - .1

Table_text2	dt "PIC/POWERED/GAME", 0x00
Table_text2_end
text2_len	equ Table_text2_end - Table_text2 - .1

Table_text3	dt "INSTRUCTIONS:", 0x00
Table_text3_end
text3_len	equ Table_text3_end - Table_text3 - .1

Table_text4 dt "1>/YOU/HAVE/3/ATTEMPTS.", 0x00
Table_text4_end
text4_len	equ Table_text4_end - Table_text4 - .1

Table_text5 dt "2>/WAIT/FOR/THE/GREEN/LED/AND", 0x00
Table_text5_end
text5_len	equ Table_text5_end - Table_text5 - .1

Table_text6	dt "///PRESS/THE/STOP/BUTTON", 0x00
Table_text6_end
text6_len	equ Table_text6_end - Table_text6 - .1

Table_text7 dt "///AS/FAST/AS/YOU/CAN.", 0x00
Table_text7_end
text7_len	equ Table_text7_end - Table_text7 - .1

Table_text8 dt "3>/ENTER/YOUR/INITIALS/IF", 0x00
Table_text8_end
text8_len	equ Table_text8_end - Table_text8 - .1

Table_text9 dt "///THE/AVERAGE/MAKES/IT/TO", 0x00
Table_text9_end
text9_len	equ Table_text9_end - Table_text9 - .1

Table_text10 dt "///THE/@@@/HALL/OF/FAME/@@@", 0x00
Table_text10_end
text10_len	equ Table_text10_end - Table_text10 - .1

Table_text11 dt "HALL/OF/FAME", 0x00
Table_text11_end
text11_len	equ Table_text11_end - Table_text11 - .1

Table_text12 dt "@@@@@@@@@@@@", 0x00
Table_text12_end
text12_len	equ Table_text12_end - Table_text12 - .1


		org ADDR_GFX_DATA_START + 0x1300

Table_font8x16
;{
	dt 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x30,0x30 ; Code for char num 44
	dt 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; Code for char num 45
	dt 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00 ; Code for char num 46 ' ' misto '/'
	dt 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; Code for char num 47
	dt 0x3C,0x3C,0x66,0x66,0x6E,0x6E,0x7E,0x7E,0x76,0x76,0x66,0x66,0x3C,0x3C,0x00,0x00 ; Code for char num 48
	dt 0x18,0x18,0x38,0x38,0x78,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00 ; Code for char num 49
	dt 0x3C,0x3C,0x66,0x66,0x06,0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x7E,0x7E,0x00,0x00 ; Code for char num 50
	dt 0x3C,0x3C,0x66,0x66,0x06,0x06,0x1C,0x1C,0x06,0x06,0x66,0x66,0x3C,0x3C,0x00,0x00 ; Code for char num 51
	dt 0x1C,0x1C,0x3C,0x3C,0x6C,0x6C,0xCC,0xCC,0xFE,0xFE,0x0C,0x0C,0x0C,0x0C,0x00,0x00 ; Code for char num 52
	dt 0x7E,0x7E,0x60,0x60,0x7C,0x7C,0x06,0x06,0x06,0x06,0x66,0x66,0x3C,0x3C,0x00,0x00 ; Code for char num 53
	dt 0x1C,0x1C,0x30,0x30,0x60,0x60,0x7C,0x7C,0x66,0x66,0x66,0x66,0x3C,0x3C,0x00,0x00 ; Code for char num 54
	dt 0x7E,0x7E,0x06,0x06,0x06,0x06,0x0C,0x0C,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00 ; Code for char num 55
	dt 0x3C,0x3C,0x66,0x66,0x66,0x66,0x3C,0x3C,0x66,0x66,0x66,0x66,0x3C,0x3C,0x00,0x00 ; Code for char num 56
	dt 0x3C,0x3C,0x66,0x66,0x66,0x66,0x3E,0x3E,0x06,0x06,0x0C,0x0C,0x38,0x38,0x00,0x00 ; Code for char num 57
	dt 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00 ; Code for char num 58
	dt 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x30,0x30 ; Code for char num 59
	dt 0x03,0x07,0x0E,0x0C,0x18,0x18,0x18,0x18,0x18,0x18,0x0C,0x0E,0x07,0x03,0x00,0x00 ; Code for char num 60 '('
	dt 0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00 ; Code for char num 61
   	dt 0xC0,0xE0,0x70,0x30,0x18,0x18,0x18,0x18,0x18,0x18,0x30,0x70,0xE0,0xC0,0x00,0x00 ; Code for char num 62 ')'
	dt 0x3C,0x3C,0x66,0x66,0x06,0x06,0x0C,0x0C,0x18,0x18,0x00,0x00,0x18,0x18,0x00,0x00 ; Code for char num 63
	dt 0x00,0x00,0x66,0x66,0x3C,0x3C,0xFF,0xFF,0x3C,0x3C,0x66,0x66,0x00,0x00,0x00,0x00 ; Code for char num 64 '*'
	dt 0x3C,0x3C,0x66,0x66,0x66,0x66,0x7E,0x7E,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00 ; Code for char num 65
	dt 0x7C,0x7C,0x66,0x66,0x66,0x66,0x7C,0x7C,0x66,0x66,0x66,0x66,0x7C,0x7C,0x00,0x00 ; Code for char num 66
	dt 0x1E,0x1E,0x30,0x30,0x60,0x60,0x60,0x60,0x60,0x60,0x30,0x30,0x1E,0x1E,0x00,0x00 ; Code for char num 67
	dt 0x78,0x78,0x6C,0x6C,0x66,0x66,0x66,0x66,0x66,0x66,0x6C,0x6C,0x78,0x78,0x00,0x00 ; Code for char num 68
	dt 0x7E,0x7E,0x60,0x60,0x60,0x60,0x78,0x78,0x60,0x60,0x60,0x60,0x7E,0x7E,0x00,0x00 ; Code for char num 69
	dt 0x7E,0x7E,0x60,0x60,0x60,0x60,0x78,0x78,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00 ; Code for char num 70
	dt 0x3C,0x3C,0x66,0x66,0x60,0x60,0x6E,0x6E,0x66,0x66,0x66,0x66,0x3E,0x3E,0x00,0x00 ; Code for char num 71
	dt 0x66,0x66,0x66,0x66,0x66,0x66,0x7E,0x7E,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00 ; Code for char num 72
	dt 0x3C,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x3C,0x00,0x00 ; Code for char num 73
	dt 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3C,0x3C,0x00,0x00 ; Code for char num 74
	dt 0xC6,0xC6,0xCC,0xCC,0xD8,0xD8,0xF0,0xF0,0xD8,0xD8,0xCC,0xCC,0xC6,0xC6,0x00,0x00 ; Code for char num 75
	dt 0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x7E,0x7E,0x00,0x00 ; Code for char num 76
	dt 0xC6,0xC6,0xEE,0xEE,0xFE,0xFE,0xD6,0xD6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00 ; Code for char num 77
	dt 0xC6,0xC6,0xE6,0xE6,0xF6,0xF6,0xDE,0xDE,0xCE,0xCE,0xC6,0xC6,0xC6,0xC6,0x00,0x00 ; Code for char num 78
	dt 0x3C,0x3C,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x3C,0x00,0x00 ; Code for char num 79
	dt 0x7C,0x7C,0x66,0x66,0x66,0x66,0x7C,0x7C,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00 ; Code for char num 80
	dt 0x78,0x78,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xDC,0xDC,0x7E,0x7E,0x00,0x00 ; Code for char num 81
	dt 0x7C,0x7C,0x66,0x66,0x66,0x66,0x7C,0x7C,0x6C,0x6C,0x66,0x66,0x66,0x66,0x00,0x00 ; Code for char num 82
	dt 0x3C,0x3C,0x66,0x66,0x70,0x70,0x3C,0x3C,0x0E,0x0E,0x66,0x66,0x3C,0x3C,0x00,0x00 ; Code for char num 83
	dt 0x7E,0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00 ; Code for char num 84
	dt 0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x3C,0x00,0x00 ; Code for char num 85
	dt 0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x3C,0x3C,0x3C,0x18,0x18,0x00,0x00 ; Code for char num 86
	dt 0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xD6,0xD6,0xFE,0xFE,0xEE,0xEE,0xC6,0xC6,0x00,0x00 ; Code for char num 87
	dt 0xC3,0xC3,0x66,0x66,0x3C,0x3C,0x18,0x18,0x3C,0x3C,0x66,0x66,0xC3,0xC3,0x00,0x00 ; Code for char num 88
	dt 0xC3,0xC3,0x66,0x66,0x3C,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00 ; Code for char num 89
	dt 0xFE,0xFE,0x0C,0x0C,0x18,0x18,0x30,0x30,0x60,0x60,0xC0,0xC0,0xFE,0xFE,0x00,0x00 ; Code for char num 90
;}


				org 0x2100
				
EEPROM_Top5_init_table
;{
		;TODO vratit zpet dt -> de
		dt "VIT", 0x02, 0xEE	;0750
		dt "VIT", 0x03, 0xE8	;1000
		dt "VIT", 0x04, 0xE2	;1250
		dt "VIT", 0x05, 0xDC	;1500
		dt "VIT", 0x06, 0xD6	;1750
EEPROM_Top5_init_table_end
EEPROM_Top5_init_table_len	equ EEPROM_Top5_init_table_end - EEPROM_Top5_init_table

FILE_END

; *** KONEC SOUBORU *************************************************
	end