[TI ASM] Displaying 'Variables'

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

[TI ASM] Displaying 'Variables'

Post by kv83 »

I know that this is pretty standard, but I just don't remember anymore how to display a variable on the screen (small fonts)...

Code: Select all

Poings = saferam2
I know it is something with OP1 ... but I don't know how to do it anymore :cry: Shame on me...

Anyone willing to help?
Image
Kalimero
Regular Member
Posts: 130
Joined: Fri 17 Dec, 2004 1:47 pm

Post by Kalimero »

I don't really remember it either, but I think it was something like this

Code: Select all

bcall _setxxxxop2
bcall _op2toop1
bcall _dispop1a
However, it will be a lot faster if you use your own number-to-string routine and then display that string in whatever way you want.
There's a good routine at http://baze.au.com/misc/z80bits.html. You should bookmark that page by the way.
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

THanks, I used the routine, and it works like a charm... only problem... it converts the integer to a string with the following format

Code: Select all

000160
and it would be nice with a

Code: Select all

   160
... I guess I have to edit the routine to replace all 0 with a " " until it finds something else than a 0
Image
Duck
Sir Posts-A-Lot
Posts: 231
Joined: Sat 18 Dec, 2004 3:38 am

Post by Duck »

I believe remembering that if you set register b to 3, it displays only 3 characters.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

Its 'a', set a to your desired length ... for example:

Code: Select all

    ld hl,(Variable)
    bcall(_setxxxxop2)
    bcall(_op2toop1)
    ld a,3                           ; number of digits to display
    bcall(_dispop1a)
    ret
That will display the contents of HL at PenCol, PenRow, it will most likely destroy your registers too.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
Madskillz
Calc Wizard
Posts: 745
Joined: Fri 17 Dec, 2004 10:22 pm
Location: Wandering around in the Jungle...
Contact:

Post by Madskillz »

yeah...I remember using that for highscore features.
The Revolution is here...
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

I used the routine provided by Kalimero. Also I just did the following to get rid of the 3 0's at the beginning:

Code: Select all

ld hl,temptext+3
Image
Kalimero
Regular Member
Posts: 130
Joined: Fri 17 Dec, 2004 1:47 pm

Post by Kalimero »

If you don't want the leading zeros, you can first do the conversion with leading zeros and then run a small loop that skips them (except the last one in case the number equals zero) or replaces them with a couple spaces (eg if you want to right align the number).
Of course if there are always 3 zeros, your solution is better.
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

My routine I've been using: (no leading zeroes regardless of how long the string is)
The icall is some kind of cross platform ti82/ti83 macro that's specific to my dwedit.inc file, feel free to change that to bcall.

Code: Select all

;==========================================
;  VDispA - Displays A in the small font
;==========================================
vDispA:
	push hl
	ld h,0
	ld l,a
	call vDispHL
	pop hl
	ret
;===========================================
;  VDispHL - Displays hl in the small font
;===========================================
FormatHL:
	ld de,op1+5
	xor a
	ld (de),a
vdhlRepeat:
	icall(_divhlby10)
	add a,'0'
	dec de
	ld (de),a
	ld a,h
	or l
	jr nz,vdhlRepeat
	ex de,hl
	ret

vDispHL:
	push de
	push hl
	call FormatHL
	bcall(_vputs)
	pop hl
	pop de
	ret
You know your hexadecimal output routine is broken when it displays the character 'G'.
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

You could just skip saving the string and display it directly.

Code: Select all

Num2Dec:
	ld b,0
	ld de,-10000
	call Num1
	ld de,-1000
	call Num1
	ld de,-100
	call Num1
	ld de,-10
	call Num1
	ld a,'0'
	add a,l               ;one digit is always displayed
	bcall(_Vputmap)
	ret

Num1:
	ld a,-1
Num2:
	inc a
	add hl,de
	jr c,Num2
	sbc hl,de
	rr b
	jp c,dispnum
	or a
	ret z
dispnum:
	ld b,$ff
	add a,'0'
	bcall(_vputmap)
	ret
it's modified from the z80bits site
Mortal-God
New Member
Posts: 60
Joined: Sun 19 Dec, 2004 10:20 pm
Location: here and there

Post by Mortal-God »

I was wondering where I had gotten the routine I use for displaying variables in small text, thanks for clearing that up Dwedit... oh yeah and for the routine :)
I think I took out some of the variable protection and don't have formathl as a seperate routine :wink:
Post Reply