A86: Re: menu style decimal input


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

A86: Re: menu style decimal input



Actually, yes!  Someone need this for an rpg, so I wrote this routine.  The
attached program is the demo on using it.  It could probably be optimized
further, I didn't spend too long on it.  This one allows backspace (delete)
and such.  I actually think it will go all the way to 65535, but I can't
remember :)  No, now that I look at it I think I fixed it so they couldn't
enter a number too large and screw with it.  Or maybe not...  ;-)

; prompt user for number 0-9999 in HL
PromptNumHL:
 ld hl,0
PromptNumHLl:
 push hl
 call _getkey
 pop hl
 cp kDel
 jr nz,PromptNumHLe
 ld a,h
 or l
 jr z,PromptNumHLl
 call _divHLby10
 ex de,hl
 ld hl,_curCol
 dec (hl)
 ex de,hl
 ld a,' '
 call _putmap
 jr PromptNumHLl
PromptNumHLe:
 cp kEnter
 ret z
 ld e,a
 ld a,39
 cp h
 ret c
 ld a,k9
 cp e
 jr c,PromptNumHLl
 ld a,e
 cp k0
 jr c,PromptNumHLl
 ld d,0
 sub k0
 ld e,a
 add a,'0'
 call _putc
 ld a,e
 call _mulHL10
 add hl,de
 jr PromptNumHLl



>
> has anyone made a routine for the ti86 that will allow the user to input a
> value using the number pad and will store the value into a register?  i've
> tried a bunch of different ways but i'm stuck.
>
> even if i had to resort to checking for each key (k0 through k9)
> individually, i don't know how to leave the routine with all the value
> stored in hl.
>
> the best try yet was when i tried to have the user input it as a string
> (which i got working) and then the next routine reads the string and
> subtracts 48 so it's not ascii anymore and then multplies that times 100,
> the next times 10 and the last times 1 and then adds them all.  but that
> failed too.
>
> jimi

promptnum.asm


References: