Re: A86: displaying a variable


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

Re: A86: displaying a variable




one thing i fogot to mention.  I think I am going to need the variable that I
am displaying saved as a string, so iot doesn't get destroyed everytime the
program reterns to the OS.  right?  so what would my code be like?  I have to
use _createstring,  right?  with the length stored in HL?  could someone help
me out here? i just thought of this, in order to view it I would need to use
some form of VAT, i think.  maybe i should just drop this whole high score
table thing, and focus on the real part of the game......

BlAsTo1414


> To increase your variable, then print it in small font:
>  
>  ...
>   ld hl,MyVar
>   inc (hl)
>   call _ldhlind
>   call DisplayHL
>   ...
>  
>  ;====================================================================
>  ; DisplayHL:  (idea from SCaBBy/Mardell)    [Assembly Coder's Zenith]
>  ;  Display HL as a 5-digit decimal number with no leading zeros
>  ;  out: AF, HL, BC, DE destroyed
>  ;====================================================================
>  DisplayHL:
>   ld c,'0'  				; save ascii value for zero
>   ld de,_OP1+5			; point to end of the buffer
>   xor a				; zero terminate string
>   ld (de),a				; set last byte to zero
>  DisplayHLl:
>   call UNPACK_HL			; next digit
>   dec de				; next position
>   add a,c				; convert to ascii
>   ld (de),a				; save digit
>   ld a,h				; load upper byte
>   or l					; check with lower byte for zero
>   jr nz,DisplayHLl			; loop
>   ex de,hl				; point to buffer
>   call _vputs			; print number
>   ret					; we're done
>  
>  --
>  David Phillips <david@acz.org>
>  http://www.acz.org/