Re: A86: String input again
[Prev][Next][Index][Thread]
Re: A86: String input again
On Thu, 26 Nov 1998 20:27:08 -0800 Cassady Roop <croop@oregontrail.net>
writes:
>
>This variation seems to work:
_getkey will kill hl, otherwise very nifty.
here, i've fixed it and added a cursor:
KeyString:
ld hl, string ;load address of string to store to
keyloop:
ld a,(_penCol) ;save cursorpos
ld c,a
ld a,Lblock ;maybe Lunderscore instead?
call _vputmap ;draw cursor
ld a,c ;restore pos
ld (_penCol),a
push hl ;_getkey kills hl
call _getkey ;get keypress
pop hl
cp kEnter ;enter key?
jr z, key_done ;then we're done
cp kExit ;exit key?
jr z, key_quit ;if so, then quit
cp kSpace ;is it space?
jr z, key_space ;if it is a space
sub $1C ;k0
jr c, keyloop ;it's not a known key if negative
sub $0A ;difference between (k9+1) and k0
jr c, key_number ;if neg, assumed to be a number key
sub $02 ;difference between kCapA and (k9+1)
jr c, keyloop ;it's not a known key if negative
sub $1A ;difference between (kCapZ+1) and kCapA
jr c, key_capletter ;if negative, then assume capital letter
sub $1B ;difference between (kz+1) and (kCapZ+1)
jr c, key_lowletter ;if neg, assume lower case letter
jr keyloop ;must be an unknown key at this point
key_space:
ld a, Lspace ;char code for space
key_add:
ld (hl), a ;store
inc hl ;inc string pointer
call _vputmap ;display the key
jr keyloop
key_number:
add a, 20+$26 ;keycode-->char code
jr key_add
key_capletter:
add a, 25+$42 ;keycode-->char code
jr key_add
key_lowletter:
add a, 31+$5d ;keycode-->char code
jr key_add
key_quit:
ld hl,string ;don't leave an unterminated string
;and clear the cursor
key_done:
ld (hl), 0 ;zero-terminate string
ld c,a ;clear cursor
ld a,$20
call _vputmap
ld a,$20
call _vputmap
ld a,$20
call _vputmap
ld a,c ;return with kEnter or kExit
ret ;quit
string:
.db 0
;* remove these if you don't want a cursor
-josh
___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]
Follow-Ups: