;-------------------
;this program should find scancodes, and output them in Hex format
;Thanks to Rob Taylor for his help!!!!
;-------------------
Key	=$80DF
;-------------------
;VARIABLES
;-------------------

;-------------------
;Title (req. info)
;-------------------
#INCLUDE "TI-85.H"
	.org 0
	.db "Find Scancodes -- rva",0

	ROM_CALL(CLEARLCD)	;clear the screens
	CALL_(GetLoop)		;get a key
	ld	hl,$1010
	ld	($8333),hl
	ld	(Key),a		;Load a into key 
	and	$F0
	sra	a
	sra	a
	sra	a
	sra	a	;get high nybble to low
	add	a,$30	;add 48 for ascii code.
;lame way. but it should work
; else, get the key back again
      	CALL_(PutChar)
	ld	a,(Key)
	and	$0F	;get low nybble
	add	a,$30	;add 48 for ascii code.
	ld	b,$06
	ld	d,$3A
CheckLoop:
	cp	d
	jr	z,Letter
	inc	d
	djnz	CheckLoop		
        ld	a,(Key)
	and	$0F
	add	a,$30
CallTwo:
	CALL_(PutChar)
	CALL_(GetLoop)
	ret

Letter:
	ld	a,(Key)
	and	$0F
	add	a,$37
	jr	CallTwo
	

PutChar:
	ROM_CALL(M_CHARPUT)
	ret
	
GetLoop:
	call GET_KEY
	or	a
	jr	z,GetLoop
	ret

.end

