Jump to content
IGNORED

Multiple Sprites on a Line


wavemotion

Recommended Posts

OK... I've hit a wall. My program will put up 2 players and 2 missiles and I can move them around and detect collision, etc. So I wanted to create more sprites on screen... I decided to try and replicate the Player 1 sprite but ran into many problems. I can put another copy of the sprite using P1 so long as it is positioned below or above another sprite. But what about if I want to show a sprite next to another - on the same horizontal line? Conceptually I'm not even sure where to begin?! I tried to put out one sprite on one frame and a different sprite (using the same P1 sprite registers) at a different horizontal location on an alternating frame and while it did work, I got flicker. I then tried to output the same sprite in two different horizontal locations (by hitting RESP1 at different times) on alternating scanlines but I couldn't get this to work - in fact, I couldn't get it to display anything even though it looked like I was hitting RESP1 at semi-reasonable places as the pixel line was drawing.

 

Can someone explain - preferably without code - conceptually how something like, say, Space Invaders puts up 6 sprites on a line? Are they using the clone feature of the P0/P1 sprite? It seems unlikely since it would be hard to track when, say, the middle of a set of 3 is blasted out of existance. It certinaly seems like the tops of the invaders are all lined up so I think they must be pulling some magic as the TIA advances across the pixel line?

 

I did a search on multiple sprites on a line and got into some heavy use of RESP1 as the scanline is forming to trick the TIA into re-displaying a new copy of the sprite just after the previous one is drawn (I don't think this advanced technique was known until Galaxian - well after Space Invaders came out). So, in basic terms, how does Space Invaders (or similiar) get more than 1 copy of a sprite on a line?

 

Thanks!

Edited by llabnip
Link to comment
Share on other sites

I tried to put out one Player2 sprite on one frame and a different Player2 sprite at a different horizontal location on an alternating frame and while it did work, I got flicker.

You will always get flicker with this method. Think about it. You're telling the system to display one sprite for one frame, and another sprite for a different frame. Your brain is quite sharp, and will notice this discrepancy.

 

Can someone explain - preferably without code - conceptually how something like, say, Space Invaders puts up 6 sprites on a line?

Try setting NUSIZ0 and NUSIZ1 to show two or three sprites. That will give you the necessary duplication to show up to six sprites per scanline. Things do get tricky, though. If you want the sprites to be different, you have to change the value of the GRPx registers AFTER the current sprite displays, but BEFORE the next sprite displays. Doing this effectively requires understanding the Vertical Delay registers.

 

I then tried to output the same sprite in two different horizontal locations (by hitting RESP1 at different times) on alternating scanlines but I couldn't get this to work - in fact, I couldn't get it to display anything even though it looked like I was hitting RESP1 at semi-reasonable places as the pixel line was drawing.

Ok, consider this for a moment. Let's say we have a TALL sprite that just repeats the same sprite over and over again. Allow me to use smileys to demonstrate:

 

:)

:)

:)

 

Now you don't actually need more than one sprite to show a vertical column of smileys, right? You just have to keep resetting the counter that pulls the sprite data so that it will pull each line again and again. Now consider what happens if we turn off the sprite for a line and RESP0 the sprite. We can then turn the sprite back on and get a result like this:

 

:)

 

:)

:)

 

There will be a gap in the sprite (unavoidable unless you're using HMOVEs instead), but the sprite should now be shifted over. If you change where the sprite pulls its data from, you can make it look like you've got MORE sprites! Again, using smileys to represent the concept:

 

:)

 

:ahoy:

:ahoy:

 

See? :)

 

Are they using the clone feature of the Player1/Player2 sprite? It seems unlikely since it would be hard to track when, say, the middle of a set of 3 is blasted out of existance.

Not at all. If you read the NUSIZx docs, you'll find that there are duplication patterns for 3, 2 near, and 2 far. Using smileys to represent invaders, each setting would look like this:

 

(FYI, the :?: represets empty space.)

 

3 duplicates:

:) :?: :) :?: :)

 

2 near:

:) :?: :) :?: :?:

 

2 far:

:) :?: :?: :?: :)

 

If you get both GRP0 and GRP1 into the action, then you can interweave them like this:

 

:) :( :) :( :) :(

 

The smile is GRP0 and the frown is GRP1. Both sprites are duplicated three times, but aligned to fall within each other's empty space. Turning off the third sprite in the row (presumably because it was shot) would look like this:

 

:) :( :?: :( :) :(

 

Remember the 2 far from above? Well, GRP0 is now 2 far, while GRP1 remains 3 duplicates. So they look like that together, and this apart:

 

:) :?: :?: :?: :)

 

:( :?: :( :?: :(

 

Does that make sense?

 

And that concludes this episode of smiley face theater. Tune in next time when we use LOLs! :lol:

Link to comment
Share on other sites

Read up on NUSIZ0 and NUSIZ1.

 

If you have the Stella Programmer's Guide found here, you'll find that on page 40(page 45 when using a PDF viewer).

I did read that though I didn't put 2 and 2 together (!!). So, outside of the RESPx multi-sprite trick, that's the usual way to reuse a sprite on a line? I see that one can duplicate or triplicate a sprite and using both players you could get 2 sets of 3 identical sprites on a line (total 6 sprites). But I still am having trouble seeing how Space Invaders can use that technique when, say, the first of a set of 3 duplicate invaders is destroyed. Does the code for Space Invaders actually switch from triplicate to duplicate and offset by one invader on the fly? If so, that's impressive but I'd love to know if there are any other ways of doing it.

Edited by llabnip
Link to comment
Share on other sites

If you get both GRP0 and GRP1 into the action, then you can interweave them like this:

 

:) :( :) :( :) :(

 

The smile is GRP0 and the frown is GRP1. Both sprites are duplicated three times, but aligned to fall within each other's empty space.

OK, this is starting to get much clearer for me... thanks. What do you do if you want the first smiley-face-invader to disappear? In addition to reprogramming the NUSIZ0 (assuming the first invader comes from P0) you also need to offset where it is displayed?

Link to comment
Share on other sites

OK, this is starting to get much clearer for me... thanks. What do you do if you want the first smiley-face-invader to disappear? In addition to reprogramming the NUSIZ0 (assuming the first invader comes from P0) you also need to offset where it is displayed?

Yep. Instead of RESPxing to the original location, you'd shift over the starting location to eliminate the missing sprite. :)

Link to comment
Share on other sites

OK, this is starting to get much clearer for me... thanks. What do you do if you want the first smiley-face-invader to disappear? In addition to reprogramming the NUSIZ0 (assuming the first invader comes from P0) you also need to offset where it is displayed?

Yep. Instead of RESPxing to the original location, you'd shift over the starting location to eliminate the missing sprite. :)

Great - that gives me something concrete to wrap my head around. And thanks again for the easy to understand explanation!

Link to comment
Share on other sites

I then tried to output the same sprite in two different horizontal locations (by hitting RESP1 at different times) on alternating scanlines but I couldn't get this to work - in fact, I couldn't get it to display anything even though it looked like I was hitting RESP1 at semi-reasonable places as the pixel line was drawing.

I haven't read through all the other replies yet, so I don't know if this has already been answered, but to get a sprite to display twice at two different locations by hitting RESP0 or RESP1, you have to display two or three copies with NUSIZ0 or NUSIZ1. Let's say you set NUSIZ0 so that two copies of player0 will display. If you hit RESP0 at some point on the scan line, you won't see the first copy of player0 at the new location (on that scan line- it won't show up there until the *next* scan line!), but you *will* see the second copy on the scan line. So if you hit RESP0 twice on a scan line, you can get two copies of player0 at two independent horizontal locations. Or you can keep hitting RESP0 over and over and get a bunch of copies of player0. But keep in mind that you can't get a precise positioning of a player using RESP0 alone-- you must also use HMP0 and HMOVE-- so this trick does have limitations.

 

MR

Edited by SeaGtGruff
Link to comment
Share on other sites

Just wanted to mention the ability to use ALT plus ZXCVBN to toggle P0 P1 M0 M1 BL PF in Z26 and Stella

 

So for example to disable P0 press ALT-Z

To reenable press ALT-Z again.

 

This makes it easier to determine what a particular program for it's display elements. Try it on Space Invaders.

 

Also:

 

ALT . Enable All

ALT / Disable All

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...