Re: A86: String input again
[Prev][Next][Index][Thread]
Re: A86: String input again
This is pretty much the routine that someone posted. I fixed a few
capitalization errors. Can someone tell me what is wrong with this, or
comment it a little more thoroughly? It crashes the calc pretty good.
#include "ti86asm.inc"
#include asm86.h
.org _asm_exec_ram
set shiftALock, (IY+shiftflags) ;turn on AlphaLock
ld hl, string ;load address of string
keyloop:
call _getkey ;get keypress
cp kEnter
jp z, key_done ;if enter was pressed
cp kSpace ;is it space?
jp z, key_space ;if it is a space
push af ;preserve the keycode in A
sub $1C ;k0
jp m, keyloop ;it's not a usefull key if negative
pop af ;recall the keycode
push af ;and save it again
sub $26 ;k9 +1
jp m, key_number ;if neg, assumed to be a number key
pop af
push af
sub $28 ;kCapA
jp m, keyloop ;it's not a usefull key if negative
pop af
push af
sub $42 ;kCapZ +1
jp m, key_capletter ;if negative, then assume capital letter
pop af
sub $5C ;kz +1
jp m, key_lowletter ;if neg, assume lower case letter
jp keyloop ;must be a useless key at this point
key_space:
ld a, Lspace ;char code for space
ld (hl), a ;put into storage string at HL
inc hl ;forward pointer to next spot in string
call _vputmap ;display a space at current pen position
jp keyloop ;get next letter or number
key_number:
pop af ;we had a PUSH, we must have a POP
add a, 12 ;keycode-->char code
ld (hl), a ;store it to the string
inc hl ;increment string pointer
call _vputmap ;display the number
jp keyloop ;get next character
key_capletter:
pop af ;we had a PUSH, must have a POP
add a, 25 ;keycode-->char code
ld (hl), a ;store it to string
inc hl ;increment storage string pointer
call _vputmap ;display the letter
jp keyloop ;get next letter or number
key_lowletter:
pop af ;we PUSHED, we have to POP
add a, 31 ;keycode-->char code
ld (hl), a ;store it to string
inc hl ;next string spot
call _vputmap ;display
jp keyloop ;next
key_done:
ld a, 0
ld (hl), a ;zero-terminate the string
ret ;exit
string:
.db 0,0,0,0 ;string storage
.end
Follow-Ups: