Sprite scaling

From NeoGeo Development Wiki
Jump to: navigation, search
Scaling on a full-screen sprite block

Vertical scaling

Vertical sprite scaling is pretty straightforward. One only has to set the lower byte of the sprite's corresponding shrinking word in SCB2.

Sprites can be scaled from 2 to 512 pixels in height.

For example, a sprite with a height of 64 pixels and a vertical shrink of 128, will be scaled down to 32 pixels.

Vertical scaling propagates through sprites when they're linked together. The first sprite of a block determines all the other sprites heights.

NeoGeo systems use a 64KiB (256 * 256) lookup table in the L0 ROM to know which raster line to skip according to the scaling value.

Horizontal scaling

Horizontal sprite scaling works the same way, except the value is in the upper byte of the shrinking word, and the range is $00 to $0F.

Sprites can then be scaled from 1 to 16 pixels in width.

Horizontal scaling does not propagate through sprites when they're linked together. Shrinking values for each sprite of the block have to be distributed to obtain the desired block width.

Since the L0 ROM isn't accessible by the 68k, this has to be done using (semi-)precalculated values.

TODO: give routine.

    dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
    dc.b 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1
    dc.b 0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1
    dc.b 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1
    dc.b 0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1
    dc.b 0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,1
    dc.b 0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1
    dc.b 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
    dc.b 0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,1
    dc.b 0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1
    dc.b 0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1
    dc.b 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1
    dc.b 0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,1
    dc.b 0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1
    dc.b 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1