A83: Text Input routine (with lowerecase!)


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

A83: Text Input routine (with lowerecase!)




Here's my improved text input routine!  It is a adapted version of
Ahmed's port of Jimmy Mardell's routine; I added lowercase.  I might add
numbers some time in the future too (but probably not).  If you don't
know how it works, just use it.  It's pretty self-explanitory.  If your
dying to know, e-mail me.  Basically, every capital letter's lowercase
ASCII code is 32 plus its own code.

BTW:  I'm almost done with Whack-A-Mole 83 ASM!  (That's what I made the
routine for, and the Title Flash routine)

;----------------Name Input----------------

SetupInput:
	ld	a,1
	ld	(CaseFlag),a
	ld	a,0
	ld	(CaseOffset),a

	ld	hl,0B05h
	ld	(currow),hl
	ld	a,226			; 226=Capital ALPHA mode sign
	call	_putmap

	ld	hl,0006h
	ld	(currow),hl
	ld	hl,String 		; Label to store input
	ld	b,0
WaK:
	push	hl
	call	GET_KEY			; Getkey call, from Ahmed
	cp	K_DEL
	jr	z,BackSpace
	cp	K_ALPHA
	jp	z,XORCase
	cp	K_ENTER
	jp	z,NameDone
	cp	K_SPACE
	jr	nz,CheckLetter
	ld	a,32
	pop	hl
	jr	PutLetter
CheckLetter:
	ld	hl,Letters	; Compares key with table to find out
	push	bc		; which letter to display
	ld	bc,26
	cpir
	ld	d,c
	pop	bc
	pop	hl
	jr	nz,WaK
	ld	a,65
	add	a,d
PutLetter:
	ld	c,a
	ld	a,b
	cp	10		; 10 letter limit  IMPORTANT (Change to whatever)
	jr	z,WaK

	ld	a,(CaseOffset)
	ld	d,a
	ld	a,c
	add	a,d
	
	ld	(hl),a
	inc	hl
	inc	b
	call	_putc
	jr	WaK
XORCase:				; I added this part
	push	bc
	ld	bc,(currow)
	ld	hl,0B05h
	ld	(currow),hl
	ld	a,(CaseFlag)
	xor	1
	ld	(CaseFlag),a
	cp	0
	jr	z,LowerCase
	jr	nz,UpperCase
LowerCase:
	ld	a,227			; 227=Lowercase ALPHA mode sign
	call	_putmap
	ld	a,32
	ld	(CaseOffset),a
	jr	EndXorCase
UpperCase:
	ld	a,226			; 226=Capital ALPHA mode sign
	call	_putmap
	ld	a,0
	ld	(CaseOffset),a
EndXorCase:
	ld	(currow),bc
	pop	bc
	pop	hl
	jr	WaK
BackSpace:
	pop	hl
	ld	a,b
	or	a
	jp	z,WaK
	dec	b
	dec	hl
	push	hl
	ld	(hl),32
	ld	hl,$800D
	dec	(hl)
	ld	a,32
	call	_putc
	dec	(hl)
	pop	hl
	jp	WaK
NameDone:
	pop	hl

CaseOffset:
 .db 0
CaseFlag:
 .db 0
String:
 .db 0,0,0,0,0,0,0,0,0,0,0		; Letter limit + 1 zeros ( for
zero-terminated strings)
Letters:
 .db $1A,$22,$2A,$0B,$13,$1B,$23,$2B,$0C,$14,$1C	;Table of letters for
input
 .db $24,$2C,$0D,$15,$1D,$25,$2D,$0E,$16,$1E,$26
 .db $2E,$1F,$27,$2F
_____________________________________________________________________
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]