Re: LZ: Re: LZB: MenuText v0.1b
[Prev][Next][Index][Thread]
> I am a newbie zshell programmer, and have started making this
program to
> let me type in menutext. I runs, but quits whenever I hit a key.
Can any
> of you veteran programmers tell me why it won't output in menu text?
Okay, well, that prog _might_ have some errors...
But, first of all, you NEED to know that you can't use "jp" when
programming for ZShell. Use the macro "JUMP_()" instead. The reason
for this is because the TI is CONSTANTLY re-arranging it's mem. When
you use "jp", the address to jump to is specified in the program, and,
since the location of the program changes, the address following the
"jp" instruction will never be accurate. Got that?
Here's a routine that I use in my program, "Key Code Lock 85", that
not only allows you to print menu text, but also allows you to do
some low-level formatting of the text.
If u add a WaitKey function like that used by Magnus Hagander in
Texanoid (?) and modify this slightly, u can use this to print menu
text. Perhaps you could even set it up to do a "carriage-return"
when you press [ENTER] on the calc, but I'll leave that to you to
figure out...
;*********************************************************************
********
;****************** Prints LONG strings in menu-sized text
*******************
;*********************************************************************
********
MenuStrPrinter: ; Remember to point bc to the
string that you want to print!
ld hl,(PROGRAM_ADDR)
add hl,bc ; add the offset to bc so hl ->
string to be printed
dec hl ; dec one since we inc one in the
loop
MenuStrPrinterLoop:
inc hl ; advance the pointer
ld a,(HL) ; put (HL) in the accumulator
cp 0 ; 0 in the string = end the
string, and thus this subroutine
ret z ; DO NOT forget the 0! The
calculator might FREEZE!
cp 254 ; 254 in the string = inc down 1
row of pixels
jr z,IncPixelRow
cp 255 ; 255 in the string = a new line,
char. will not be printed
jr z,NewMenuLine
ROM_CALL(M_CHARPUT) ; prints the character in acc
jr MenuStrPrinterLoop ; loop again
NewMenuLine:
push hl ; save hl, it is the pointer to
the string!
ld a,($8334) ; $8334 is the y value of the
cursor
add a,6 ; Add 6 to the original value of
$8334
ld ($8334),a ; Put the value back into $8334
sub a ; Set a to 0
ld ($8333),a ; $8333 is the x value of the
cursor, this is setting it to zero
pop hl ; get the original value of hl
back, it's on the top of the stack
jr MenuStrPrinterLoop
IncPixelRow:
ld a,($8334) ; Load the value stored in $8334
into the accumulator
inc a ; Increment the value in a
ld ($8334),a ; Load acc back into $8334
jr MenuStrPrinterLoop
Got all that?
Have fun,
____
~Keith
FFNP69C@PRODIGY.COM
References: