Sprites: Difference between revisions
m (10 revisions: Import from wikkii) |
m (Unused bits note) |
||
(12 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
== "Sprites" as defined by SNK == | == "Sprites" as defined by SNK == | ||
[[File:Mutnatsprite.png|right|frame|Structure of a grouped sprite.]] | [[File:Mutnatsprite.png|right|frame|Structure of a grouped sprite. The red sprite drives the other 3.]] | ||
Sprites on the NeoGeo aren't like those on other systems. | Sprites on the NeoGeo aren't like those on other systems. | ||
They're made of tiles (sometimes called characters) coming from the C | They're made of tiles (sometimes called characters) coming from the [[C ROM]]s, or from the .SPR files on the NeoGeo CD. Those tiles are always 16x16 pixels in size and can contain 15 colors (the color index 0 is used for transparency). | ||
Sprites are vertical strips of tiles, with a fixed width of 1 tile (16 pixels), and an adjustable height | Sprites are vertical strips of tiles, with a fixed width of 1 tile (16 pixels), and an adjustable height of up to 32 tiles (512 pixels). | ||
Each sprite has its own | Each sprite has its own tile and attributes map, defining which tile goes in which place, how is it flipped, and which palette to use. | ||
Sprites can be stuck together horizontally to make huge moveable objects. | Sprites can be stuck together horizontally to make huge moveable objects. | ||
== Limitations == | == Limitations == | ||
*No more than 96 sprites can be rendered by scanline. Any others | *No more than 96 sprites can be rendered by scanline. Any others won't be displayed (priority: 1 is in the back ?). | ||
*Even if the VRAM has space for 448 sprites, only 381 can be displayed per frame | *Even if the VRAM has space for 448 sprites, only 381 can be displayed per frame. This is imposed by the GPU's architecture. | ||
*Contrary to common belief | *Contrary to common belief sprites can't be zoomed, they can only be shrunk. Graphics for sprites then have to be drawn to the biggest size needed. | ||
A lot of games contain pre-stretched graphics for sprites which are seen scaled down most of the time (logos in title screens for example). | A lot of games contain pre-stretched graphics for sprites which are seen scaled down most of the time ("crashing" logos in title screens for example). | ||
* | *1048576 tiles can be addressed (20 bits, 128MiB of graphics), if more tiles are needed then the sprites graphics need to be bankswitched. | ||
== Graphics format == | == Graphics format == | ||
Sprite tiles are 16x16 pixels | Sprite tiles are 16x16 pixels in a 4BPP planar format, handled as four 8x8 tiles by the [[GPU]]. See [[sprite graphics format]]. | ||
A sprite tile is 128 bytes. | A sprite tile is 128 bytes. | ||
= | ==Horizontal reduction== | ||
[[ | See [[Sprite shrinking]]. | ||
= Sprite control blocks = | |||
There are 4 Sprite Control Blocks located in VRAM: SCB1, SCB2, SCB3 and SCB4. | |||
They respectively start at VRAM addresses $0000, $8000, $8200 and $8400. They aren't mirrored in any way. | |||
Please see [[VRAM]] to learn more about read/writing to these locations. | |||
Each sprite has a 64 words table, | Sprites wrap around the screen on a 512 pixels X or Y boundary. | ||
<center>[[File:spriteex.png]]</center> | |||
(All sprites are mapped with tiles $01~$21) | |||
Unused bits in SCB2 and SCB4 can be used for any purpose, they can be written and read back like the others. | |||
== SCB1 (VRAM $0000~$6FFF): Tilemaps == | |||
SCB1 is used to store the tilemaps and tile attributes of each sprite. | |||
(Note that the $7000~$7FFF range in VRAM is used for the [[Fix layer]]). | |||
Each sprite has a 64-words table, in which each pair of words correspond to a tile in the sprite, top to bottom. | |||
Even locations are the tile number's 16 lower bits: | |||
{{16BitRegister|Tile number LSBs|16}} | {{16BitRegister|Tile number LSBs|16}} | ||
Odd locations contain the remaining tile number bits, palette index and attributes: | |||
{{16BitRegister|[[Palettes|Palette]]|8|Tile number MSBs|4|3bit Auto-anim|1|2bit Auto-anim|1|Vertical flip|1|Horizontal flip|1}} | {{16BitRegister|[[Palettes|Palette]]|8|Tile number MSBs|4|3bit Auto-anim|1|2bit Auto-anim|1|Vertical flip|1|Horizontal flip|1}} | ||
Line 45: | Line 60: | ||
The 8-frame [[auto animation]] bit has priority over the 4-frame one. | The 8-frame [[auto animation]] bit has priority over the 4-frame one. | ||
== SCB2 ($8000~$81FF): Shrinking coefficients == | == SCB2 (VRAM $8000~$81FF): Shrinking coefficients == | ||
SCB2 is used to specify the shrinking value of each sprite. | |||
The lower byte is the vertical shrinking. $FF is full size. | The lower byte is the vertical shrinking. $FF is full size. | ||
The lower nibble of the upper byte is the horizontal shrinking. $F is full size. | The lower nibble of the upper byte is the horizontal shrinking. $F is full size. | ||
{{16BitRegister| |4|Horizontal|4|Vertical|8}} | {{16BitRegister| |4|Horizontal|4|Vertical|8}} | ||
== SCB3 ($8200~$83FF): vertical positions == | == SCB3 (VRAM $8200~$83FF): vertical positions == | ||
SCB3 is used to specify the | SCB3 is used to specify the sprite's Y position, its [[sticky bit]] and its size (height in tiles). | ||
The actual position is 496-Y, from the top border of the screen. | The actual position is 496-Y, from the top border of the screen. | ||
{{16BitRegister|Y position|9|[[Sticky bit]] | A special sprite size of 33 makes it 32 tiles high, and loops borders when shrinking (see example sprite 6). | ||
The sprite's height is actually the "window" size in which the sprite will be drawn. Shrinking isn't calculated from this. | |||
{{16BitRegister|Y position|9|[[Sticky bit]]|1|Sprite size|6}} | |||
== SCB4 ($8400~$85FF): horizontal positions == | == SCB4 (VRAM $8400~$85FF): horizontal positions == | ||
SCB4 is | SCB4 is used to specify the sprite's X position. | ||
The actual position is from the left border of the screen. | The actual position is from the left border of the screen. | ||
{{16BitRegister|X position|9| | {{16BitRegister|X position|9|-|7}} | ||
[[Category:Video system]] | [[Category:Video system]] |
Latest revision as of 23:54, 7 March 2018
"Sprites" as defined by SNK
Sprites on the NeoGeo aren't like those on other systems.
They're made of tiles (sometimes called characters) coming from the C ROMs, or from the .SPR files on the NeoGeo CD. Those tiles are always 16x16 pixels in size and can contain 15 colors (the color index 0 is used for transparency).
Sprites are vertical strips of tiles, with a fixed width of 1 tile (16 pixels), and an adjustable height of up to 32 tiles (512 pixels). Each sprite has its own tile and attributes map, defining which tile goes in which place, how is it flipped, and which palette to use. Sprites can be stuck together horizontally to make huge moveable objects.
Limitations
- No more than 96 sprites can be rendered by scanline. Any others won't be displayed (priority: 1 is in the back ?).
- Even if the VRAM has space for 448 sprites, only 381 can be displayed per frame. This is imposed by the GPU's architecture.
- Contrary to common belief sprites can't be zoomed, they can only be shrunk. Graphics for sprites then have to be drawn to the biggest size needed.
A lot of games contain pre-stretched graphics for sprites which are seen scaled down most of the time ("crashing" logos in title screens for example).
- 1048576 tiles can be addressed (20 bits, 128MiB of graphics), if more tiles are needed then the sprites graphics need to be bankswitched.
Graphics format
Sprite tiles are 16x16 pixels in a 4BPP planar format, handled as four 8x8 tiles by the GPU. See sprite graphics format.
A sprite tile is 128 bytes.
Horizontal reduction
See Sprite shrinking.
Sprite control blocks
There are 4 Sprite Control Blocks located in VRAM: SCB1, SCB2, SCB3 and SCB4. They respectively start at VRAM addresses $0000, $8000, $8200 and $8400. They aren't mirrored in any way.
Please see VRAM to learn more about read/writing to these locations.
Sprites wrap around the screen on a 512 pixels X or Y boundary.
(All sprites are mapped with tiles $01~$21)
Unused bits in SCB2 and SCB4 can be used for any purpose, they can be written and read back like the others.
SCB1 (VRAM $0000~$6FFF): Tilemaps
SCB1 is used to store the tilemaps and tile attributes of each sprite.
(Note that the $7000~$7FFF range in VRAM is used for the Fix layer).
Each sprite has a 64-words table, in which each pair of words correspond to a tile in the sprite, top to bottom.
Even locations are the tile number's 16 lower bits:
Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Def | Tile number LSBs |
Odd locations contain the remaining tile number bits, palette index and attributes:
Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Def | Palette | Tile number MSBs | 3bit Auto-anim | 2bit Auto-anim | Vertical flip | Horizontal flip |
The 8-frame auto animation bit has priority over the 4-frame one.
SCB2 (VRAM $8000~$81FF): Shrinking coefficients
SCB2 is used to specify the shrinking value of each sprite.
The lower byte is the vertical shrinking. $FF is full size.
The lower nibble of the upper byte is the horizontal shrinking. $F is full size.
Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Def | Horizontal | Vertical |
SCB3 (VRAM $8200~$83FF): vertical positions
SCB3 is used to specify the sprite's Y position, its sticky bit and its size (height in tiles). The actual position is 496-Y, from the top border of the screen.
A special sprite size of 33 makes it 32 tiles high, and loops borders when shrinking (see example sprite 6).
The sprite's height is actually the "window" size in which the sprite will be drawn. Shrinking isn't calculated from this.
Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Def | Y position | Sticky bit | Sprite size |
SCB4 (VRAM $8400~$85FF): horizontal positions
SCB4 is used to specify the sprite's X position. The actual position is from the left border of the screen.
Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Def | X position | - |