AuthorTopic: SNES Sprite Restrictions?  (Read 23231 times)

Offline straypixels

  • 0001
  • *
  • Posts: 31
  • Karma: +0/-0
  • SHAZAM!
    • View Profile

SNES Sprite Restrictions?

on: November 03, 2008, 03:03:45 pm
I may be dense, but I can't find this information anywhere. Here or on google. I found a plethra of "OMG! CHANGE THE PALETTE IN YOUR SNES ROMS! OMG!" stuff, but no where that really outlined the restrictions. I want to really push myself to get better at this, so I want to work with some restrictions. I'm working on some sprites done with NES restrictions, but I'd like to upgrade :)

Does anyone know what the SNES palette restrictions are? Is it just like NES, but doubled, or what?

Thanks!

stray...  .
Straying since 1999

Offline PypeBros

  • 0100
  • ***
  • Posts: 1220
  • Karma: +2/-0
  • Pixel Padawan
    • PypeBros
    • View Profile
    • Bilou Homebrew's Blog.

Re: SNES Sprite Restrictions?

Reply #1 on: November 03, 2008, 03:32:04 pm
the best source of information i've found so far was http://en.wikibooks.org/wiki/Super_NES_Programming. (courtesy of http://snesdev.antihero.org/).
Afaik, each palette is now 15 colors + a common "backdrop" color, as usual with nintendo hardware, though early games (SMW and ZLTTP) preferred to encode only 3 bits per pixel and have smaller ROM.

Sorry for not being more precise, but the specs for the SNES PPU (picture processing uint ?) are surprisingly cryptic, so i prefer saying only a few than saying something completely wrong.

Offline ptoing

  • 0101
  • ****
  • Posts: 3063
  • Karma: +0/-0
  • variegated quadrangle arranger
    • the_ptoing
    • http://pixeljoint.com/p/2191.htm
    • View Profile
    • Perpetually inactive website

Re: SNES Sprite Restrictions?

Reply #2 on: November 03, 2008, 03:35:11 pm
Colourdepth on the SNES is 15 bit, 5 bit per channel.
There are no ugly colours, only ugly combinations of colours.

Offline straypixels

  • 0001
  • *
  • Posts: 31
  • Karma: +0/-0
  • SHAZAM!
    • View Profile

Re: SNES Sprite Restrictions?

Reply #3 on: November 03, 2008, 08:04:41 pm
Forgive my lack of knowledge here, ptoing, but what defines a channel? I'm assuming a bit would be a single color? So essentially, 15 colors... 5 bit per scan line?
Straying since 1999

Offline ptoing

  • 0101
  • ****
  • Posts: 3063
  • Karma: +0/-0
  • variegated quadrangle arranger
    • the_ptoing
    • http://pixeljoint.com/p/2191.htm
    • View Profile
    • Perpetually inactive website

Re: SNES Sprite Restrictions?

Reply #4 on: November 03, 2008, 08:15:12 pm
Channel as in Red Green Blue. So you have 5 bit per channel, which means 32 settings for each Red, Green and Blue, which makes a total of 32768 colours to choose from.
There are no ugly colours, only ugly combinations of colours.

Offline straypixels

  • 0001
  • *
  • Posts: 31
  • Karma: +0/-0
  • SHAZAM!
    • View Profile

Re: SNES Sprite Restrictions?

Reply #5 on: November 03, 2008, 09:01:42 pm
Okay, so the most pertinent restrictions to pixel art according to this http://en.wikibooks.org/wiki/Super_NES_Programming/SNES_Specs are:

  • Maximum colors per layer per scanline: 256.
  • Maximum colors on-screen: 32,768 (using color arithmetic for transparency effects).
  • Resolution: between 256x224 and 512x448.
  • Maximum onscreen objects (sprites): 128 (32 per line, up to 34 8x8 tiles per line).
  • Maximum number of sprite pixels on one scanline: 256.

So, allow me to make sure I understand this... You don't have to worry about this as much when you're working on a modern PC lol

assuming 256x224 resolution, you've got 224 scan lines, but I think that's about all I get here lol. Once we  get to onscreen objects and sprite pixels on a scan line, I'm confused.

Also, who do you determine what an acceptable color is? Ptoing, you and that wiki agree that you can use 32,768 colors on screen at a time... is that ANY combination of colors, or a specific combination?

Am I over complicating it? ^_^
Straying since 1999

Offline AlexHW

  • 0100
  • ***
  • Posts: 1037
  • Karma: +0/-0
    • View Profile
    • AlexHW

Re: SNES Sprite Restrictions?

Reply #6 on: November 03, 2008, 09:23:56 pm
if a game exceeds the maximum sprites on one scanline, then the extra sprites get clipped or aren't drawn I think.
as far as i understand, its all about how the tech handles/stores the data. the tech can only do so much based upon how it was designed.

Offline Akira

  • 0010
  • *
  • Posts: 334
  • Karma: +0/-0
  • Heheheh
    • View Profile

Re: SNES Sprite Restrictions?

Reply #7 on: November 04, 2008, 02:02:54 am
Ptoing, you and that wiki agree that you can use 32,768 colors on screen at a time... is that ANY combination of colors, or a specific combination?
I'm not Ptoing but I might be able to help. As mentioned earlier you have 32 settings for each channel. That's like having 0-255 (256 settings) for each RGB channel we use commonly today. The settings will be set equally apart from full off to full on (black to full green for example). Basically if you can only use todays 256 setting RGB channels with values of multiples of 8 (256/32=8) so you could have 0,0,0 - 8,8,8 - 16,16,16 - 24,24,24 - 32,32,32 - 40,40,40 and so on up to 256 and any combination of these (0,16,40 for example).
I hope this makes sense.
thanks Dogmeat!

Offline straypixels

  • 0001
  • *
  • Posts: 31
  • Karma: +0/-0
  • SHAZAM!
    • View Profile

Re: SNES Sprite Restrictions?

Reply #8 on: November 04, 2008, 03:28:43 am
Akira! You rock :) That's exactly what I was trying to figure out.

Next question... what's a scanline? I mean, I know what it does in a TV, but does it basically equal a 1px line?
Straying since 1999

Offline ptoing

  • 0101
  • ****
  • Posts: 3063
  • Karma: +0/-0
  • variegated quadrangle arranger
    • the_ptoing
    • http://pixeljoint.com/p/2191.htm
    • View Profile
    • Perpetually inactive website

Re: SNES Sprite Restrictions?

Reply #9 on: November 04, 2008, 10:14:09 am
Cheers Akira.

Yes a scanline is always a single pixel line afaik.
There are no ugly colours, only ugly combinations of colours.

Offline PypeBros

  • 0100
  • ***
  • Posts: 1220
  • Karma: +2/-0
  • Pixel Padawan
    • PypeBros
    • View Profile
    • Bilou Homebrew's Blog.

Re: SNES Sprite Restrictions?

Reply #10 on: November 04, 2008, 10:31:14 am
You might want to think of the graphic unit of a SNES as a processor of its own that reads sprite and tiles description and has limitted resources to render them. Especially, it renders them "line by line" (yes, these are the scanlines) and will only be able to deal with a fixed number of objects on each line due to its internal limited resources.

So you will have both a maximum number of objects in memory, and a maximum object per scan line.
Similarly, the encoding on tiles and sprite -- which depend on the graphic mode you're using -- constraint how many colors per sprite you might have, but in addition, despite a possibly high number of palette you might have, there is only 256 possible colors per horizontal line, so if you put too many sprites on the same line that all use different colors, you might get into trouble. Some might not display, or display with the wrong color.
You might thus have 256 colors per line, but only 16 colors per 8x8 pixels tile, etc.

But the "per scan line" stuff also means that you might have *more* objects on screen than what the memory can hold, if you reprogram them on the fly (think of shoot'm'up bullets, for instance).

Offline straypixels

  • 0001
  • *
  • Posts: 31
  • Karma: +0/-0
  • SHAZAM!
    • View Profile

Re: SNES Sprite Restrictions?

Reply #11 on: November 04, 2008, 02:13:17 pm
Okay, I'm starting to get a better handle on it now.

Minor point of confusion, though... according to wikipedia, this:


is a 15-bit palette. It looks almost right, but then if you check the RGB values of some of the colors, they're not multiples of 8. Why is that? Is the palette just off, or am I not understanding something?
Straying since 1999

Offline ptoing

  • 0101
  • ****
  • Posts: 3063
  • Karma: +0/-0
  • variegated quadrangle arranger
    • the_ptoing
    • http://pixeljoint.com/p/2191.htm
    • View Profile
    • Perpetually inactive website

Re: SNES Sprite Restrictions?

Reply #12 on: November 04, 2008, 02:32:31 pm
Should be right. The index goes from 0-255, not 256. So they go off at some point.
There are no ugly colours, only ugly combinations of colours.

Offline Akira

  • 0010
  • *
  • Posts: 334
  • Karma: +0/-0
  • Heheheh
    • View Profile

Re: SNES Sprite Restrictions?

Reply #13 on: November 05, 2008, 02:41:39 am
right sorry, all my values should be -1 (so 7,7,7 - 15,15,15 etc). But even so there seems to be colours that shouldn't be there. The palette is likely off. its a pretty small png file, probably has been compressed.
thanks Dogmeat!

Offline straypixels

  • 0001
  • *
  • Posts: 31
  • Karma: +0/-0
  • SHAZAM!
    • View Profile

Re: SNES Sprite Restrictions?

Reply #14 on: November 05, 2008, 01:24:09 pm
Thanks Akira, that's what I was thinking.

It's been about three years since I was on pixelation last :) I'm glad to see that you guys are still just as awesome and helpful :)
Straying since 1999

Offline Ai

  • 0100
  • ***
  • Posts: 1057
  • Karma: +2/-0
  • finti
    • http://pixeljoint.com/pixels/profile.asp?id=1996
    • finticemo
    • View Profile

Re: SNES Sprite Restrictions?

Reply #15 on: December 25, 2008, 09:34:48 am
Everyone's got it almost-right so far.

The main thing you all missed is that the 'whitepoint' of snes is not 255,255,255. This is because CRT-based TV's don't like colors 'hotter'
than a certain amount.

If your RGB values are in the range 0..1, then this is how to convert snes ->sRGB:

Quote from: rephrasing of Pixlab's SNES colorprofile support code
sRGB = snes / 31.9393939393

(keep in mind that snes values only range 0..31 (== 32 levels))

OTOH, here is how to convert sRGB 0..1 to snes:
Quote from: rephrasing of Pixlab's SNES colorprofile support code
snes = round(sRGB.clip (0, 31./31.9393939393) * 31.9393939393)

The maximum result in 0...255 sRGB space attainable with these equations is 248.
When you check this against ZSNES  screenshots, it proves correct.
( http://www.nintendocity.com/screenshots/snes_screenshots/terranigma_screenshots.shtml )


In fact, it's easy to type hex SNES colors, because it only requires you to think of one thing:
You can type any digit in the first place, and only one of 0,8 in the second place. (so 303058 is okay; 333058 is not okay)


Thanks guys, this helped me notice and fix an off-by-one bug in my code; I used to divide and multiply by 32 rather than 31.9393...
(whereas 31.9393.... matches ZSNES behaviour exactly)

(and a corresponding bug in genesis support.)

Quote from: Akira
right sorry, all my values should be -1 (so 7,7,7 - 15,15,15 etc). But even so there seems to be colours that shouldn't be there. The palette is likely off. its a pretty small png file, probably has been compressed.
PNG compression has nothing to do with losing data, okay?
That PNG is for PC 15bpp rgb hicolor, which, as illustrated above, is sufficiently different from snes that the PNG is almost uniformly wrong.
(the PNG is only slightly inaccurate according to my calculations; substituting intensities : 24 -> 25, 57->58, 198 -> 197, 231 ->230
would fix it. )

Rather than subtracting 1 from your values, you needed to use 255/31.9393939393 as your base factor,
which equals approximately 7.9838709677419359

According to my calculations, this is the appropriate set of values for PC 15bpp rgb hicolor:
 0,  8, 16, 25, 33, 41, 49, 58, 66, 74, 82, 90, 99, 107, 115, 123, 132,140,
 148, 156, 165, 173, 181, 189, 197, 206, 214, 222, 230, 239, 247, 255

Or in hex:
00 08 10 19 21 29 31 3a 42 4a 52 5a 63 6b 73 7b 84 8c 94 9c a5 ad b5 bd c5 ce d6 de e6 ef f7 ff

One last thing: Nobody has yet mentioned that 16 colors / sprite is typical. I didn't know the '256 colors/scanline' limitation. 16c sprites make sense in light of this, though; easy way to avoid running out of colors.
In fact,  in FF3/FF6, all the characters' palette colors are chosen from a master palette of.. I guess 64.. could be anywhere between that and 32..
colors, presumably for similar reasons.
« Last Edit: December 25, 2008, 10:44:27 am by Ai »
If you insist on being pessimistic about your own abilities, consider also being pessimistic about the accuracy of that pessimistic judgement.