Re: A82: Input Routine


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

Re: A82: Input Routine



I am actually not sure. It is a long time since i found the ruties on the
ti82. If any some one finds errors i the docs mail me and i will correct
the info in 82-rom.

Dines

_______________________________________

Dines Justesen
Email: dines@post1.com or
       c958362@student.dtu.dk
WWW  : http://www.gbar.dtu.dk/~c958362/
_______________________________________

On Thu, 9 Oct 1997 ADAMMAN106@aol.com wrote:

> This is geared mostly for Dines...
> I have probably waited too long to ask this, but the reason the input routine
> wasnt working was because of the blinking cursor.  Are the addresses correct?
> Look for the stars
> TIA, 
> 
> ~Adamman
> 
> 
> ; Input routine  - made by Jimmy Mårdell 97-03-05
> ;
> ; Reads a sentence entered from the keyboard. Only uppercase letters
> ; and space are allowed. Left arrowkey = backspace.
> ;
> ; When calling, HL should point to where the string should be stored
> ; and A should hold the maximum length of the string. Be sure there
> ; are enough space (A+1) to store the nullterminated string at HL!
> ; ($800C) should hold the screen position where the string starts.
> ;
> ; This input routine will also have a flashing cursor. If you don't like
> ; it, remove all rows where the explanation starts with a *.
> ;
> ; IMPORTANT: The input must NOT wrap to a new row! Then it will not work
> ; properly. The last char on a row should not be used either (if cursorcol=0
> ; when calling, the maximum char length is 20). If you have a cursor, the
> ; two last chars should not be used (max length 19 if the screen location
> ; starts to the far left).
> ;
> ; The routine requires one temporary variable, noLet.
> 
> INPUT:
> ; push bc
> ; push de
> ; push hl
>  ei
> ; set 2,(iy+12)         ; * Turn cursor blinking on (interrupts must be
> enabled)
>  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 it's content
> 	ld a, 217
> 	ROM_CALL(TX_CHARPUT)
> 	ld hl, $800D
> 	dec (hl)
>  call GET_KEY
>  cp $02                ; $02 = left key
>  jr z,BackSpace
>  cp $09                ; $09 = enter
>  jr z,NameDone
>  or a
>  jr nz,CheckLetter
>  pop hl
>  jr WaK
> CheckLetter:
>  ld hl,Letters
>  ld bc,26              ; 26 letters to check
>  cpir                  ; Compare A with each letter until a match is found
>  ld d,c                ; Then C = the letter. Store in D
>  pop hl                ; HL -> current position in string
>  jr nz,WaK             ; If not valid keystroke, wait for new key
>  ld a,65               ; 65 = ascii char for A
>  add a,d               ; A now holds the 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 is impossible. Check for new key.
> ; 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 (non) 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 the end of the string
> ; res 2,(iy+12)         ; * Stopp cursor blinking
> ; pop hl
> ; pop de
> ; pop bc
>  ret
> 
> ; The keycodes of the letters A-Z stored backways
> 
> Letters:
>  .db $1A,$22,$2A         ;ZYX
>  .db $0B,$13,$1B,$23,$2B ;WVUTS
>  .db $0C,$14,$1C,$24,$2C ;RQPON
>  .db $0D,$15,$1D,$25,$2D ;MLKJI
>  .db $0E,$16,$1E,$26,$2E ;HGFED
>  .db $1F,$27,$2F         ;CBA
> 
> 


References: