A85: input routine


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

A85: input routine




Greetings,
	I was going to incorporate an input routine for a high score
option in some of my games.  I picked the source up from Jimmy Mardell's
Zshell School.  The only problem I don't know how to display the initials
that I store?  Do I use TX_CHARPUT? 
D_ZM_STR?  Please help me!
					- Mike

#include "TI-85.H"              
                                
.org 0                  
.db "Input Test",0      

noLet = $80DF                    ; 

InitProg:
     ROM_CALL(CLEARLCD)
DrawStr:
     ld hl, $0003                  ; place title text
     ld ($800C), hl              ;
     ld hl, strstr                    ;
     ld de, (PROGRAM_ADDR)       ;
     add hl, de                  ;
     ROM_CALL(D_ZT_STR)          ; 
                               
loop1:
     call GET_KEY
     cp $37
     ret z
     cp $36
     jr nz, loop1
     ld hl, $0003
     ld ($800C), hl
     ld hl, strstr
     ld a, 3
     CALL_(Input)
     jr loop1     

Input:
     push bc
     push de
     push hl
     set 2,(iy+12)         ; * Turn cursor blinking on
     ld (noLet),a          ; Store the maximum lenght of the string
     ld e,0                ; E = numbers of letters written so far
WaK:
     ld a,32
     ld ($800E),a          ; * Set "character under cursor" to space
     push hl               ; * Save HL since GET_KEY destroys HL
     call GET_KEY
     cp $02                ; $02 = left key
     jr z,BackSpace
     cp $09                ; $09 = enter
     jr z,NameDone
     cp $11                ; $11 = space
     jr nz,CheckLetter
     ld a,32               ; Space is ascii char 32
     pop hl
     jr PutLetter          ; Put the letter on screen and in memory
CheckLetter:
     ld hl,Letters
     ld bc,(PROGRAM_ADDR)
     add hl,bc             ; HL -> letter table
     ld bc,26              ; 26 letters to check
     cpir                  ; Compare A with each letter until match
     ld d,c                ; Then C = the letter. Store in D
     pop hl                ; HL -> current position in string
     jr nz,WaK             ; Wait until valid keystroke
     ld a,65               ; 65 = ascii char for A
     add a,d               ; Now A=ASCII char for the letter pressed
PutLetter:
     ld c,a
     ld a,(noLet)          ; A = max letters
     cp e                  ; Check if max size is reached
     jr z,WaK              ; If so, wait for a new key
     ld (hl),c             ; If not, store the key entered
     inc hl                ; Point to the next byte in the string
     inc e                 ; And increase the letter counter
     ld a,c
     ROM_CALL(TX_CHARPUT)  ; Show the chars pressed on the screen
     jr WaK                ; And jump back and wait for a new key
BackSpace:
     pop hl                ; HL -> current position in string
     ld a,e
     or a                  ; Check if string size = 0
     jr z,WaK              ; If so, backspace not allowed - repeat
     res 2,(iy+12)         ; * Stopp cursor blinking
     dec e                 ; Decrease string size
     dec hl                ; And string pointer
     push hl
     ld hl,$800D           ; HL -> x cursor position
     dec (hl)              ; Decrease it
     ld a,32               ; Overwrite the last letter with a space
     ROM_CALL(TX_CHARPUT)  ; Put the space over the chars
     ROM_CALL(TX_CHARPUT)  ; * And over the blinking cursor
     dec (hl)              ; * Decrease the x coordinate twice
     dec (hl)              ;
     pop hl
     set 2,(iy+12)         ; * Stopp cursor blinking
     jr WaK                ; Wait for a key
NameDone:
     pop hl                ; HL -> current position in string
     ld (hl),0             ; Put a terminating zero at end of string
     res 2,(iy+12)         ; * Stop cursor blinking
     pop hl
     pop de
     pop bc
     ret                                                 
 
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

strstr:
   .db  "XXX",0     
   
.end    


_____________________________________________________________________
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
Or call Juno at (800) 654-JUNO [654-5866]


Follow-Ups: References: