Re: LZ: Yet another question
[Prev][Next][Index][Thread]
On 14 Jul 96 at 20:02, Carl Wang wrote:
> Hi! Remember the code I posted not long ago with the problems with the
> (HEALTH) thing? Thanks to all who helped, that code now works. Just
> wondering, is it possible to display HEALTH in menu text? Thanks again
>
I ran into this exact problem when writing TriMounts. I ended up
writing my own routine to unpack hl into a temporary string, then used
D_LM_STR to display it. Here is the routine I used, You can take out
the + and - bit if you don't need it.
;; This Routine Converts HL to a string at the location de
CONV_HL_STR:
push af
push bc
push hl
ex de,hl
ld a,'+' >This is used to determine + or -
rl d > If you don't need to display
jr nc,BefConvLoop > sign you can cut out all the
ld a,'-' > text with these comments
BefConvLoop: > by it.
ld (hl),a >
scf >
ccf >
rr d >
ex de,hl >
cp '-' >
jr nz, SkipAdjust >
push hl >
pop bc >
ld hl,32768 >
sbc hl,bc >
SkipAdjust: >
inc de > And remove 1 inc de statement
inc de
inc de
inc de
inc de
ld b,5
ConvLoop:
call UNPACK_HL
add a,'0'
ld (de),a
dec de
djnz ConvLoop
pop hl
pop bc
pop af
ret
For this routine to work you need to put the address of a 5 or 6 byte
long variable into de, and the number to unpack in hl. After it is
done the variable will contain the value of hl in string format. Here
is an example.
TEMPSTR = $80DF
...
ld de,TEMPSTR
ld hl,$0067
CALL(CONV_HL_STR)
ld hl,TEMPSTR
ld b,6 > or 5 if you took out the sign checking
ld de,0
ld (CURSOR_X),de
ROM_CALL(D_LM_STR)
Hope this is what you wanted!!
Josh Pieper
ppieper@nemonet.com
References: