Re: A86: Typing in letters


[Prev][Next][Index][Thread]

Re: A86: Typing in letters



That works somewhat, but when you get about halfway across the screen and
press delete (I have code set up for pressing delete it is shown on here)
and then press a letter it starts displaying X does anyone know why this
might be

code for delete:
ld a,(_curCol)
dec a
ld (_curCol),a

-----Original Message-----
From: Jimmy Mårdell <mja@algonet.se>
To: assembly-86@lists.ticalc.org <assembly-86@lists.ticalc.org>
Date: Wednesday, October 29, 1997 6:21 PM
Subject: Re: A86: Typing in letters


Brian wrote:
>
>  Is there an easier way to detect a person pressing a any letter on
> the the calc and then displaying that letter rather than going through
> and checking for every letter like so

Yes, by using CPIR:

NoMatch:
call GET_KEY
ld hl,Letters         ; HL -> Letter table
ld bc,26              ; 26 letters to check
cpir                  ; Compare A with each letter until a match is
found
jr nz,NoMatch
ld a,c
add a,'A'
call _putc

; The keycodes of the alphabet backwards

Letters:
.db $19,$21,$0A,$12,$1A,$22,$0B,$13,$1B,$23,$2B
.db $0C,$14,$1C,$24,$2C,$0D,$15,$1D,$25,$2D,$0E
.db $16,$1E,$26,$2E

The alphabet is stored backwards because BC is decrease from
26 to 0. If you press 'Y', the keycode would $21, and BC
would decrease two times (CPIR decreases BC even though it
finds the matching code on the second try). Thus, 'A'+24 =
65+24 = 89 = 'Y'

--
Jimmy Mårdell                "The nice thing about standards is that
mailto:mja@algonet.se         there are so many of them to choose from."
http://www.algonet.se/~mja
IRC: Yarin                   "Sanity? I'm sure I have it on tape
somewhere!"