Sprite shrinking: Difference between revisions
(Created page with "Shrinking (also known as scaling, reduction, zooming...) is a hardware feature of the NeoGeo that reduces the sprites sizes with per-pixel accuracy. It can be seen as subsamp...") |
m (Layout, size details, centering) |
||
Line 1: | Line 1: | ||
Shrinking (also known as scaling, reduction, zooming | Shrinking (also known as scaling, reduction, and "zooming") is a hardware feature of the NeoGeo which allows to scale down the sprites with per-pixel accuracy. | ||
It can be seen as subsampling of the original graphics | It can be seen as a simple subsampling of the original graphics since there's no smooth interpolation at all. | ||
=Vertical shrinking= | =Vertical shrinking= | ||
Vertical shrinking is set by an 8-bit value indicating the final height of the sprite's graphics. This value is set in [[VRAM]], in the [[Sprites|SCB2]]. | |||
Range: $FF is full size, $0 is smallest. | Range: $FF is full size (all 32*16 = 512 pixels shown), $0 is the smallest (only 2 pixels shown out of 512). | ||
See [[Sprites]]. To know which line to skip, the [[GPU]] uses a lookup table stored in the {{Chipname|L0 ROM}}. | |||
[[ | |||
Vertical shrink propagates in chained sprites. | |||
==Caveat== | |||
Note that vertical shrinking does not affect the height setting of the sprite. The graphics are shrunk inside the same "window". | |||
<gallery> | |||
File:spritez_4.png|Sprite height set to 4 tiles, graphics intentionally filling 4 tiles | |||
File:spritez_3.png|The same sprite updated to be only 3 tiles high without clearing the 4th (yellow) tile | |||
File:spritez_anim.gif|The sprite will shrink this way, showing the garbage yellow tile from the previous setup | |||
</gallery> | |||
=Horizontal shrinking= | =Horizontal shrinking= | ||
The horizontal shrinking | The horizontal shrinking is set by a 4-bit value indicating the final width of the sprite graphics +1 (giving 1 to 16 pixels wide sprites). This value is also set in [[Sprites|SCB2]]. | ||
Range: $F is full size (all 16 pixels shown), $0 is the smallest (1 pixel shown out of 16). | |||
Horizontal shrink does '''not''' propagate in chained sprites. | |||
Pixel skipping to render the effect is done by a "bit matrix" lookup table inside the [[GPU]]. This table is '''not''' in the L0 ROM. | |||
For each shrinking value, 1 means the pixel will be drawn | For each shrinking value on a sprite line, 1 means the pixel will be drawn and 0 means it will be skipped (info from MAME's source, matches the real hardware): | ||
[[File:Hshrink.gif|thumb]] | [[File:Hshrink.gif|thumb|Horizontal shrink effect on a multicolored tile, showing how pixels are skipped.]] | ||
*0: 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 ( | *0: 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 (15 pixel skipped, 1 remaining) | ||
*1: 0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0 | *1: 0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0 (14 pixels skipped...) | ||
*2: 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 | *2: 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 | ||
*3: 0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0 | *3: 0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0 | ||
Line 44: | Line 51: | ||
*C: 1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1 | *C: 1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1 | ||
*D: 1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1 | *D: 1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1 | ||
*E: 1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1 | *E: 1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1 (...1 pixel skipped) | ||
*F: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 (no pixels skipped, full size) | *F: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 (no pixels skipped, full size) | ||
= | =Centering= | ||
Centering can be required since the anchor point of sprites is fixed and located at their top left. | |||
The X offset is -((hshrink+1)>>1). The Y offset is -(vshrink+1). | |||
[[Category:Video system]] | [[Category:Video system]] |
Revision as of 20:28, 22 June 2016
Shrinking (also known as scaling, reduction, and "zooming") is a hardware feature of the NeoGeo which allows to scale down the sprites with per-pixel accuracy.
It can be seen as a simple subsampling of the original graphics since there's no smooth interpolation at all.
Vertical shrinking
Vertical shrinking is set by an 8-bit value indicating the final height of the sprite's graphics. This value is set in VRAM, in the SCB2.
Range: $FF is full size (all 32*16 = 512 pixels shown), $0 is the smallest (only 2 pixels shown out of 512).
See Sprites. To know which line to skip, the GPU uses a lookup table stored in the L0 ROM.
Vertical shrink propagates in chained sprites.
Caveat
Note that vertical shrinking does not affect the height setting of the sprite. The graphics are shrunk inside the same "window".
-
Sprite height set to 4 tiles, graphics intentionally filling 4 tiles
-
The same sprite updated to be only 3 tiles high without clearing the 4th (yellow) tile
-
The sprite will shrink this way, showing the garbage yellow tile from the previous setup
Horizontal shrinking
The horizontal shrinking is set by a 4-bit value indicating the final width of the sprite graphics +1 (giving 1 to 16 pixels wide sprites). This value is also set in SCB2.
Range: $F is full size (all 16 pixels shown), $0 is the smallest (1 pixel shown out of 16).
Horizontal shrink does not propagate in chained sprites.
Pixel skipping to render the effect is done by a "bit matrix" lookup table inside the GPU. This table is not in the L0 ROM.
For each shrinking value on a sprite line, 1 means the pixel will be drawn and 0 means it will be skipped (info from MAME's source, matches the real hardware):
- 0: 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 (15 pixel skipped, 1 remaining)
- 1: 0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0 (14 pixels skipped...)
- 2: 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0
- 3: 0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0
- 4: 0,0,1,0,1,0,0,0,1,0,0,0,1,0,1,0
- 5: 0,0,1,0,1,0,1,0,1,0,0,0,1,0,1,0
- 6: 0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0
- 7: 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0
- 8: 1,0,1,0,1,0,1,0,1,1,1,0,1,0,1,0
- 9: 1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,0
- A: 1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1
- B: 1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,1
- C: 1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1
- D: 1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1
- E: 1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1 (...1 pixel skipped)
- F: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 (no pixels skipped, full size)
Centering
Centering can be required since the anchor point of sprites is fixed and located at their top left.
The X offset is -((hshrink+1)>>1). The Y offset is -(vshrink+1).