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
winSharp93


Newbie


Joined: 16 Dec 2008
Posts: 5

Posted: 16 Dec 2008 01:36:42 pm    Post subject:

Hello,

I'm quite new to the TI assembler scene.
My calculator is a TI 84+ (almost equivalent to the TI83+) and I'm using MirageOS, an ION compatible shell.

At the moment I try to write my first small game.

The problem starts with the sprites representing cars. They are quadratically with a size of 16x16 pixels. So I'm using the ionLargeSprite function (alias ilsprite) in order to draw them onto the screen.

As the cars should slowly drive through the screen without appearing suddenly completly at the upper edge of the screen, I wanted them sometimes to be partially out of the screen (and then coming in pixel after pixel).

For this task, I have written follwing code (including some changes for posting here):

Code:
ld a, (car_Position);Variable containing the position of the car between 0 and 112 (Screen height + sprite height)
sub 16   ;Problematic - Subtracts the height of the sprite
ld l, a   ;Register l == y-coordinate
ld b, 16;Register b == height of the sprite to draw
ld c, 2  ;Register c == width of the sprite in bytes (equals 16 pixels)
ld a, 0  ;Register a == x-coordinate (not relevant to the problem)
ld ix, car_sprite ;the sprite
call ilsprite ;calls ionLargeSprite
call ifastcopy ;calls ionFastCopy

The code responsible for updating car_Position seems to work how exspected - it just increments car_Position until the upper bound is reached and then starts at 0 again.

Already having critically thought about the line marked as problematic I ran the code on the emulator. The result was a totally fragmented drawing.
So I commented out the line, changed the upper bound of car_Position to 96 (screen height) and ran it again.
At first there didn't seem to be any problems - the cars slowly disappered at the bottom of the screen having correctly been only partially visible before. (But of course didn't do so at the top if the screen).

However, when I tried to leave my program and return to the shell (in this case MirageOS) my calculator crashed (displaying "RAM cleared" after turning on again) or even displayed nonsense signs all over the screen after the shell itself crashed.

I think using ionLargeSprite with coordinates that let sprites stick out of the screen sowehow overwrites parts of the calculator's memory.

Thus the question to you:
Are there any alternatives to ionLargeSprite that can handle this case?
Or how else can I solve my problem? Ideally fast and simple ;-)

Many Thanks!
Back to top
Iambian


Advanced Member


Joined: 13 Mar 2004
Posts: 423

Posted: 16 Dec 2008 02:07:45 pm    Post subject:

What it seems like you're trying to do is sprite clipping. ionLargeSprite does not perform clipping, nor does it perform any checks to ensure that you are trying to do something it can't do. Look at http://wikiti.denglend.net/index.php?title...hic:largesprite for a routine that can perform large sprite clipping (near the bottom of the page. Look for the title "Version with clipping")

Last edited by Guest on 16 Dec 2008 02:08:45 pm; edited 1 time in total
Back to top
winSharp93


Newbie


Joined: 16 Dec 2008
Posts: 5

Posted: 16 Dec 2008 02:20:03 pm    Post subject:

Iambian wrote:
http://wikiti.denglend.net/index.php?title...hic:largesprite for a routine that can perform large sprite clipping

Thanks for your fast reply.
That seems to be what I was looking for.
Back to top
cjgone
Aw3s0m3


Active Member


Joined: 24 May 2006
Posts: 693

Posted: 16 Dec 2008 09:57:04 pm    Post subject:

Yup, unfortunately in assembler, clipping is actually harder then it sounds and you have to find a specialized routine to do it (at the cost of speed of course). ;o

Last edited by Guest on 16 Dec 2008 09:57:35 pm; edited 1 time in total
Back to top
Galandros


Active Member


Joined: 29 Aug 2008
Posts: 565

Posted: 17 Dec 2008 09:32:53 am    Post subject:

cjgone wrote:
Yup, unfortunately in assembler, clipping is actually harder then it sounds and you have to find a specialized routine to do it (at the cost of speed of course). ;o
[post="130441"]<{POST_SNAPBACK}>[/post]

And size.


Also ion putsprite doesn't clip either.
Back to top
winSharp93


Newbie


Joined: 16 Dec 2008
Posts: 5

Posted: 17 Dec 2008 01:07:53 pm    Post subject:

Quote:
At the cost of speed [...] and size.

Having the choice between the fast and lightweight ionlargesprite / ionputsprite and the ClipBigSprite routine is a good solution in my eyes.

Galandros wrote:
Also ion putsprite doesn't clip either.

I think it is not a disadvantage of the integrated ION routines that they don't perform clipping. Otherwise drawing sprites that don't need to be clipped as they are always completley visible would be slower either.
You just have to know about this behaviour - I do now ;-)

Again: Thanks for your replies!
Back to top
cjgone
Aw3s0m3


Active Member


Joined: 24 May 2006
Posts: 693

Posted: 17 Dec 2008 06:13:31 pm    Post subject:

Yea, have fun coding lol.

The z80 in 15 mhz mode is definitely fast enough to handle clipped sprites so you should be good for a while (unless you have like a gazzilion sprites on screen). But, it's best to use no-clip if you aren't drawing clipped sprites. Very Happy
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