This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 11 Jun 2003 09:11:26 am    Post subject:

I'd like to do the equivalent of :
:Text(19, 5, "Score :", S
with S = actual score, of course.

I know how to display text :

Code:
   ld   hl, 19*256+5
   ld   (pencol), hl
   ld   hl, score
   B_CALL(_vputs)

score:   .db   "Score : ", 0


But then, how to add the value of A for exemple ? Have I to use something like DispHL ? If Yes, how do we use that ? Or maybe have I to write something like .db "Score : ", a, 0 to display the value of the register A ?
Thank you to help me.


And by the way, when you write something with Vputs (on the graph screen), is there a way to display a long string on many lines ? If I write "A very long sentence, that cannot be written on only one line", is there soemthing I have to do display it on several lines ? If I just write the same code that above, there is just "A very long sentence, that" which is written on the screen.
I know that when we use the rom call "_puts" (with large characters), the sentence is written on several lines, but "_Vputs" doesn't do it. What I did is creat several strings so that's what I wrote :

Code:
   ld   hl, 19*256+5
   ld   (pencol), hl
   ld   hl, str1
   B_CALL(_vputs)

   ld   hl, 28*256+5
   ld   (pencol), hl
   ld   hl, str2
   B_CALL(_vputs)

   ld   hl, 39*256+0
   ld   (pencol), hl
   ld   hl, str3
   B_CALL(_vputs)


Is there a special character like "tEnter", or a rom call like _Newline that I could use ?

thx all Wink
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 11 Jun 2003 12:55:10 pm    Post subject:


Code:
    ld hl, 19*256+5
    ld (pencol), hl
    ld hl, score
    B_CALL(_vputs)

score: .db "Score : ", 0

to add the score which is in the register a, u must add this RIGHT AFTER the bcall(_VPutS) :

Code:
    bcall(_setxxop1)   ;reg. a to op1
    bcall(_dispop1a)   ;disp op1, at the current pen pos, with the small text, unless the big text flag is set...

does that help any?
Back to top
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 11 Jun 2003 02:03:00 pm    Post subject:

Perfect !
Exactly what I expected !

thank you.
Back to top
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 11 Jun 2003 02:59:35 pm    Post subject:

Oh, and notice that if A=0 (so, if OP1 = 0), it creates a error : "Overflow".
Why ? Did you know it ?
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 11 Jun 2003 03:00:59 pm    Post subject:

it is because of how dispop1a works... it *supposedly* displays a digits of op1... but i think it only does that if op1 is a decimal... so put ld a,1 in between the 2 functions...
Back to top
b__


Member


Joined: 16 Jun 2003
Posts: 173

Posted: 17 Jun 2003 09:08:16 am    Post subject:

I know you can

ld (pencol),hl

and

ld (pencol),a

but can you use bc? Cause i tried to do it, but the coordinates were all screwed up for some reason.
Back to top
Job the GameQuitter


Member


Joined: 04 Jun 2003
Posts: 102

Posted: 17 Jun 2003 10:14:30 am    Post subject:

Are you sure you didn't accidently switch horizontal and vertical coordinates?
Back to top
John Barrus


Member


Joined: 25 May 2003
Posts: 131

Posted: 17 Jun 2003 11:56:11 am    Post subject:

You can only use hl and a to load values into ram addresses...
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 17 Jun 2003 03:55:50 pm    Post subject:

But couldn't you load BC into HL?

Spyderbyte
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 17 Jun 2003 04:28:19 pm    Post subject:

I reccomend bcall(_dispHL)

It works like _putS, but displays the value of hl instead and does not need a label or anything.

Now, for loading register hl with register bc, you would do something like this:

ld h,b
ld l,c

Put simply, you need two 8-bit load instructions because ld hl,bc is not a recognized instruction (no opcode in cpu);

Now, if you wish to load ram, load hl or de with the address.

Now, load a or hl depending if you wish to load a byte or a word.

then do something like:

ld (hl),a
ld (de),a
ld (de),hl

Maybe ld (bc),a might work. I do know that ld (hl),bc will not work.

Think of hl as a 16 bit accumulator.
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 17 Jun 2003 06:07:03 pm    Post subject:

John Barrus wrote:
You can only use hl and a to load values into ram addresses...

Actually that is incorrect.

ld (NN),bc
ld (NN),hl
ld (NN),de
ld (NN),ix
ld (NN),sp
ld (NN),iy
ld (NN),a

Are all valid instructions for loading a value into a ram address. Where NN is any ram address.

appbackupscreen,$8000, ect. ect.


Then you can load a value into (hl) by using any valid register A,B,C,D,E,H, or L or an 8 bit number

ld (hl),$05
ld (hl),A

and yes Jbirk ld (bc),a is a valid instruction.

As well as

ld (de),a
ld (ix+N),a
ld (iy+N),a
ld (NN),a

Where N is any 8 bit number(specifying offsets)

OK I'm done posting commands but you get the point.


Last edited by Guest on 17 Jun 2003 06:14:09 pm; edited 1 time in total
Back to top
b__


Member


Joined: 16 Jun 2003
Posts: 173

Posted: 17 Jun 2003 06:22:11 pm    Post subject:

So then why do the coordinates get all screwed up when I do

ld (pencol),bc

I tried all kinds of different things, but couldn't get it to work right. I tried switching the horizontal and vertical, i tried switching pencol with penrow i tried everything. I finally ended up doing
ld a,b
ld (pencol),a
ld a,c
ld (penrow),a
Oh and i cant use hl because i need to save the address in it. I could push and pop hl, but I think that would be slower.
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 17 Jun 2003 10:51:33 pm    Post subject:

Well my question in turn is how did you load the coordinates into bc?

It should be something to this effect.

ld bc,(column coordinate)*256+(row coordinate)
ld (pencol),bc

So if you wanted to place text at row 10, column 20 you would do this.

ld bc,20*256+10
ld (pencol),bc
ld hl,text
bcall(_vputs)

text:
.db "Hello",0

Now your coodinates will be set. The column coordinate is loaded in front of the row coordinate because pencol comes before penrow in memory. If you need hl then you must push hl before loading the text address into hl and pop it again after the ROM call bcall(_vputs).


Last edited by Guest on 17 Jun 2003 10:54:19 pm; edited 1 time in total
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 17 Jun 2003 10:56:29 pm    Post subject:

very nicely said Justin!
Back to top
b__


Member


Joined: 16 Jun 2003
Posts: 173

Posted: 18 Jun 2003 07:10:13 pm    Post subject:

This is basically what the actual code is:

ld bc,20*256+60
ld hl,text
call puttext

...

puttext:
ld (pencol),bc
bcall(_vputs)
ret

text:
.db "Text",0

Theoretically there is nothing wrong with the code. What it should do is display text that is halfway off the bottom of the screen, but even if you change the coordinates it still doesn't come out right. But this code works:

ld bc,20*256+60
ld hl,text
call puttext

...

puttext:
ld a,b
ld (pencol),a
ld a,c
ld (penrow),a
bcall(_vputs)
ret

text:
.db "Text",0

Anybody know why? I think that you can't use bc to load into pencol.
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 18 Jun 2003 08:42:20 pm    Post subject:

Well for one thing I don't think it should work at all because you are specifying a row coordinate that is not available to display text. Row coordinates are from 0-57.
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 18 Jun 2003 10:57:13 pm    Post subject:

yes, it should not work in either senario! but, then again, maybe we r both wrong, and it is colunm 60, row 20!
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 18 Jun 2003 11:37:13 pm    Post subject:

hmm well it appears that my thinking was incorrect. When you load the value into (pencol) it switches the bytes positions, at the ram address. Therefore you must load the row coordinate first then the column.
Back to top
b__


Member


Joined: 16 Jun 2003
Posts: 173

Posted: 19 Jun 2003 09:20:52 am    Post subject:

That works! Thanks justin. I have no idea why it works, it just does.
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement