#include "TI-85.h"

.org 0
.db "MenuText v1.1 by NJLeskiw", 0

Main:
	ROM_CALL(CLEARLCD)
	ld     hl,$0101
	ld ($8333),hl
get:
	call GET_KEY  ;Get the number of the key pressed
	cp     $37
	ret    z
	cp     $0
	jr     z, get
	cp     $36   ;check if 2nd was pressed
	jr     z, gogetsml 
	JUMP_(chara)
gogetsml:
	ld     A, 0; Load 0 into A so gogetlg doesn't come back here 
	JUMP_(getsmall)
	

chara:
	 ld B, $2E     ;Store the Keycode for "A" into B
	 cp B         ;Compare A & B
	 jr NZ, charb  ;If NZ flag is set goto charb (Check if "A" was pressed)
	 ld A, 'A'     ;Load 'A' into A
	 ROM_CALL(M_CHARPUT) ;output 'A' at coord. 1,1
	 JUMP_(get)
charb
		ld B, $26
		cp B         
		jr NZ, charc  
		ld A, 'B'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charc:          
		ld B, $1E     
		cp B         
		jr NZ, chard  
		ld A, 'C'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
chard:          
		ld B, $16     
		cp B         
		jr NZ, chare  
		ld A, 'D'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
chare:          
		ld B, $0E     
		cp B         
		jr NZ, charf  
		ld A, 'E'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charf:          
		ld B, $2D     
		cp B         
		jr NZ, charg  
		ld A, 'F'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charg:          
		ld B, $25     
		cp B         
		jr NZ, charh  
		ld A, 'G'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charh:          
		ld B, $1D     
		cp B         
		jr NZ, chari  
		ld A, 'H'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
chari:          
		ld B, $15     
		cp B         
		jr NZ, charj  
		ld A, 'I'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charj:          
		ld B, $0D   
		cp B         
		jr NZ, chark  
		ld A, 'J'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
chark:          
		ld B, $2C     
		cp B         
		jr NZ, charl  
		ld A, 'K'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charl:          
		ld B, $24     
		cp B         
		jr NZ, charm  
		ld A, 'L'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charm:          
		ld B, $1C     
		cp B         
		jr NZ, charn  
		ld A, 'M'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charn:          
		ld B, $14     
		cp B         
		jr NZ, charo  
		ld A, 'N'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charo:          
		ld B, $0C     
		cp B         
		jr NZ, charp  
		ld A, 'O'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charp:          
		ld B, $2B     
		cp B         
		jr NZ, charq  
		ld A, 'P'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charq:          
		ld B, $23     
		cp B         
		jr NZ, charr  
		ld A, 'Q'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charr:          
		ld B, $1B     
		cp B         
		jr NZ, chars  
		ld A, 'R'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
chars:          
		ld B, $13     
		cp B         
		jr NZ, chart  
		ld A, 'S'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
chart:          
		ld B, $0B     
		cp B         
		jr NZ, charu  
		ld A, 'T'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charu:          
		ld B, $22     
		cp B
		jr NZ, charv  
		ld A, 'U'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charv:          
		ld B, $1A     
		cp B
		jr NZ, charw  
		ld A, 'V'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charw:          
		ld B, $12     
		cp B
		jr NZ, charx  
		ld A, 'W'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charx:          
		ld B, $0A     
		cp B
		jr NZ, chary  
		ld A, 'X'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
chary:          
		ld B, $21     
		cp B
		jr NZ, charz  
		ld A, 'Y'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(get)
charz:          
		ld B, $19     
		cp B
		jr NZ, space
		ld A, 'Z'     
		ROM_CALL(M_CHARPUT)
		JUMP_(get)
space:
		ld B, $03 
		cp B ;see if rt arrow pressed
		jr NZ, creturn ;no, quit
		ld A, ($8333) ;  increase column
		inc A 
		ld ($8333), A
		JUMP_(get)
creturn:
		ld B, $09 
		cp B  ;see if enter pressed
		jr NZ, exitprog ;if not go on
		ld A, ($8334) ;if so store ($8334) -> A
		inc A 
		inc A 
		inc A 
		inc A 
		inc A 
		inc A 
		inc A 
		ld ($8334), A ;put back to address
		ld A, $01 ;set column to 1
		ld ($8333), A
		JUMP_(get)
exitprog:
		ret z

getsmall:
	call GET_KEY  ;Get the number of the key pressed
	cp     $37
	ret    z
	cp     $0
	jr     z, getsmall
	cp     $36
	jr     z, gogetlg
	JUMP_(chara1)
gogetlg:
	ld A, 0
	JUMP_(get)
chara1:
	 ld B, $2E     ;Store the Keycode for "A" into B
	 cp B         ;Compare A & B
	 jr NZ, charb1  ;If NZ flag is set goto charb (Check if "A" was pressed)
	 ld A, 'a'     ;Load 'A' into A
	 ROM_CALL(M_CHARPUT) ;output 'A' at coord. 1,1
	 JUMP_(getsmall)
charb1:
		ld B, $26
		cp B         
		jr NZ, charc1  
		ld A, 'b'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(getsmall)
charc1:          
		ld B, $1E     
		cp B         
		jr NZ, chard1  
		ld A, 'c'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(getsmall)
chard1:          
		ld B, $16     
		cp B         
		jr NZ, chare1  
		ld A, 'd'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(getsmall)
chare1:          
		ld B, $0E     
		cp B         
		jr NZ, charf1  
		ld A, 'e'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(getsmall)
charf1:          
		ld B, $2D     
		cp B         
		jr NZ, charg1  
		ld A, 'f'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(getsmall)
charg1:          
		ld B, $25     
		cp B         
		jr NZ, charh1  
		ld A, 'g'     
		ROM_CALL(M_CHARPUT) 
		JUMP_(getsmall)
charh1:          
		ld B, $1D     
		