Re: A82: dead list?
[Prev][Next][Index][Thread]
Re: A82: dead list?
In a message dated 98-04-26 15:38:55 EDT, you write:
> this is the stupidest message to post, but, WHERE'D EVERYONE GO?!?!?
>
> perhaps the list server is down, if it is, you can't be reading this, ok?
I was wondering the same thing
>
> QUESTION:: does anyone have a function that will print the register A in
> decimal on the screen in normal text format? (if someone says "load 0
> into hl, then a, then do a d_hl_deci", i'll kill them.) i want the # to
> take up as little space as needed. (1-3 columns)
>
> thanks.
>
> -Greg
well, I was going to tell you to load 0 into h, a into l, so don't kill me
because I'll tell you another way. All you have to do is ld h, 0 \ ld l, a
and make a loop that calls UNPACK_HL repeatedly, storing the result in a
buffer each time. here's the code (right from SameGame) that will display hl
in decimal, menu format:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
;;; DM_HL_DECI by Jimmy Mårdell ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DM_HL_DECI:
push de
push hl
ld de,string+5 ;start at the end
xor a ;ld a, 0
ld (de),a ;zero terminated string
Repeat:
call UNPACK_HL ;unpack one digit of hl to a
add a,'0' ;add it with ASCII char 0
dec de ;previous byte
ld (de),a ;load the char
ld a,h ;is hl 0?
or l ;|
jr nz,Repeat ;loop
ex de,hl ;exchange so hl points to string
ROM_CALL(D_ZM_STR) ;display string
pop hl
pop de
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
;;; End of DM_HL_DECI ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
Then make a few changes. First of all, this routine calls for a 5 byte buffer
but you only need 3 bytes (actually it needs 6 bytes and you shorten it to
4...my bad.) and change the "ld de, string+5" to "ld de, string+3". Then to
use text font, change the menu style text displayer to text style text
displayer. Don't forget to load a into hl at the beginning!
a neat thing you can do: in this routine, right before the call to UNPACK_HL,
you can change the base of the number to print by doing a ld a, [base] and
changing call UNPACK_HL to UNPACK_HL+2. And you also have to change the
number of bytes in string accordingly. nice, huh? the ld a, [base] however
HAS to be within the loop, as a gets changed.
WOW that was a much bigger email than I expected it to be!
I really hope it helped!
~Adamman
Follow-Ups: