Tri-colored sprite demo

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Tri-colored sprite demo
by on (#103780)
Normally sprites can only have 2 colours and a black outline, or 3 colours without black outline.

This demo however dynamically updates the VRAM (nametable + pattern table) in order to have the background tiles below the sprite form the black outline. Which makes it possible to have 3 colours + black outline without using multiple layers which would eat on the 8-sprites per line limitation.

Graphics from Dragon Quest IV and Just Breed.
Re: Tri-colored sprite demo
by on (#103787)
This is one i REALLY like, I know how it works, but same technique can't be used for platformers, can it?
It's easy in your demo cause you have grid movement...
Re: Tri-colored sprite demo
by on (#103790)
Say you have a 24x16 pixel character (size of Balloon Fight guy or Mega Man). In a grid-movement game, you'd need up to nine tiles, using method B when moving horizontally or C when moving vertically. In a free movement game, you'd need 12 tiles, and that'd use so much CHR RAM bandwidth that you'd probably need to extend vertical blanking.
Code:
,-------.---.   ,-,-------.-.   ,---+---+---.   ,---+---+---.
|       |   |   | |       | |   ,-------.   |   | ,-------. |
|   +   |---+   +-|   +   |-+   |       |---+   +-|       |-+
|       |   |   | |       | |   |   +   |   |   | |   +   | |
|   +   |---+   +-|   +   |-+   |       |---+   +-|       |-+
|       |   |   | |       | |   |   +   |   |   | |   +   | |
`-------'---+   +-`-------'-+   |       |---+   +-|       |-+
|   |   |   |   |   |   |   |   `-------'   |   | `-------' |
`---+---+---'   `---+---+---'   `---+---+---'   `---+---+---'

A. 6 tiles      B. 9 tiles      C. 8 tiles      D. 12 tiles
Re: Tri-colored sprite demo
by on (#103792)
Does this gracefully deal with multiple tri-colour sprites overlapping?

Also, for platformers.. can't you be cheap and just make sure the background is always black (like most areas in Super Pitfall)
Re: Tri-colored sprite demo
by on (#103794)
This technique will probably only work for RPGs, or any other genre where the main character's sprite is 16x16 and moves only in a direction (vertical or horizontal) at a time on a gird based background.

Reason for this is that I have only 6 tiles for the background which is behind the hero, it is arranged 3x2 when moving horizontally and 2x3 when moving vertically. When you stand still, the last 2 tiles are dummy and are unused.

It could be generalized for arbitrary movement, using 9 tiles, but not only this would need extra blanking time, but also the logic, which is already complex in my demo, would be even much more complex.
Also remember than in an actual game the logic would be more complex than what it is in my demo, because of scrolling and the fact the name table could not be accessed directly like I do in the demo.

Quote:
Does this gracefully deal with multiple tri-colour sprites overlapping?

Nope, this technique can only work for a single sprite, typically the main character's sprite which is what the player will be looking at constantly, so it's worth adding extra colours in it !