Jump to content
IGNORED

"Z-sorting" of objects?


jrok

Recommended Posts

I was curious about the display priority of the hardware objects. From the look of it P0 and M0 always take priority over P1 and M1, and those four take priority over the playfield by default but that if CTRLPF = $05, the playfield takes priority (and if I'm wrong about any of this, please let me know).

 

What I'd like to do is to sort the z-order of the hardware sprites and the playfield by their y-value. The idea would be that if P0 had a higher (or equal) y value than P1, it would appear "over" P1, and if P1 had the higher value, it would appear over P0. I assume one way to do this would be to swap the playerpointers based on which Y value was higher, so far I have failed in my attempts to do that.

 

Also, I was curious if its possible to have the playfield appear to be in front of one player sprite and behind another one. For instance:

 

 ................................
................................
....................XXXX........
..................XXXXXXXXX.....
.................XXXXXXXXXXX....
................XXXXXXXXXXXXX...
.................XXX.XXX.XXX....
....................X.X.X.......
.....................XXX........
......................X.........
....................1.X........
....................1...........
....................1...........
....................1...........
................................
................................
................................
................................
................................
................................
................................
.................0..............
.........XXXX....0..............
.......XXXXXXXX..0..............
......XXXXXXXXXX.0..............
.....XXXXXXXXXXX................
......XX.XXX.XX.................
........X.X.X...................
.........XXX....................
..........X.....................
..........X.....................
................................

 

In the above screen, the 0's represent a 16px tall P0 and the ones represent a 16px tall P1. If P0 moved left and P1 moved right, would it be possible for P0 to appear behind the his tree and P1 appear in front of his?

 

Jarod.

Edited by jrok
Link to comment
Share on other sites

AFAIK, there are only 3 priority "lists" you can choose from.

 

When bit 2 of CTRLPF is off, the order of printing goes P0/M0, P1/M1, PF/BL, BK. If "score mode" is also active (by setting bit 1), the order goes P0/M0/PF(left), P1/M1/PF(right), BL, BK.

 

When bit 2 of CTRLPF is on, the order of printing goes PF/BL, P0/M0, P1/M1, BK. "Score mode" is ignored here.

 

Priority does not apply if the overlapping objects are the same color (on the overlapping portions).

 

 

So what you propose is only partially supported...in score mode with playfield priority off, P1/M1 being able to move under the left half of PF gfx while P0/M0 is always above PF on both sides. Doesn't help very much...since you lose independant PF color when score mode is active.

 

 

Instead, you need to sort out your objects before printing. Decide which one is "higher" than the other, and assign it to P0/M0. Not much you can do about the playfield, tho (for objects that have full roam of the screen)...other than deciding beforehand whether the object is to be drawn or not.

Link to comment
Share on other sites

BTW from your example, it would be easy enough to reassign CTRLPF between trees (since there is vertical seperation between them). Perhaps have a pointer to a CTRLPF value table if PF gfx is not static.

 

Thanks Nukey. I guess the main limitation against this might be that batari basic draws the entire screen at once with a "drawscreen" command. So on any given drawscreen, it seems to me that both P0 and P1 would have to share the same CTRLPF value. I suppose if I flicker the players at 30Hz, I could assign them their own CTRLPF value based on their Y position, but I was trying to figure out if there was a way to do that without flicker.

Link to comment
Share on other sites

It's possible to create interesting "Z-ordering" by selectively blanking parts of a sprite. Toyshop Trouble blanks the portions of sprites that go "behind" the edges of the conveyor, for example. You'll need enough RAM to hold the sprite that will be partially blanked, and some creativity will be needed to make things work. I'm not sure such an effect would be practical in bB, though if there's room for the sprite it might be workable. Here's a more extreme demo of the approach. Move the man with the left controller and observe that he goes in front of some objects, but behind others.

pop2.bin

Link to comment
Share on other sites

It's possible to create interesting "Z-ordering" by selectively blanking parts of a sprite. Toyshop Trouble blanks the portions of sprites that go "behind" the edges of the conveyor, for example. You'll need enough RAM to hold the sprite that will be partially blanked, and some creativity will be needed to make things work. I'm not sure such an effect would be practical in bB, though if there's room for the sprite it might be workable. Here's a more extreme demo of the approach. Move the man with the left controller and observe that he goes in front of some objects, but behind others.

 

That is a REALLY impressive demo! Wow!!! :cool:

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...