Sprite graphics format: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
m (Fixed typo)
No edit summary
Line 7: Line 7:


Informations from Raregame.ru: [[http://www.raregame.ru/file/15/NEO-GEO_Sprite_Tile_Format.gif here]] and [[http://www.raregame.ru/file/15/NEO-GEO_Fix_Layer_Format.gif here]].
Informations from Raregame.ru: [[http://www.raregame.ru/file/15/NEO-GEO_Sprite_Tile_Format.gif here]] and [[http://www.raregame.ru/file/15/NEO-GEO_Fix_Layer_Format.gif here]].
==Decoding==
Pseudocode:
<pre>
    For Tileline = 0 To 7
        For Tilerow = 0 To 7
            For Quarter = 0 To 3
                Select Case Quarter
                    Case 0: xOfs = 8: yOfs = 0
                    Case 1: xOfs = 8: yOfs = 8
                    Case 2: xOfs = 0: yOfs = 0
                    Case 3: xOfs = 0: yOfs = 8
                End Select
                For QuarterLine = 0 To 7
                    BitPlane(0) = ReadByte(1)
                    BitPlane(1) = ReadByte(1)
                    BitPlane(2) = ReadByte(2)
                    BitPlane(3) = ReadByte(2)
                    For Pixels = 0 To 7
                        xPos = (Tilerow * 16) + Pixels + xOfs
                        yPos = (Tileline * 16) + QuarterLine + yOfs
                        for Bitplanes = 0 to 3
                            ColorIndex .= GetBit(Bin(BitPlane(3-Bitplanes)),7-Pixels)
                        next Bitplanes
                        PixelSet (xPos, yPos), Palette[BinToDec(ColorIndex)]
                    Next Pixels
                Next QuarterLine
            Next Quarter
        Next Tilerow
    Next Tileline
</pre>


[[Category:Video system]]
[[Category:Video system]]

Revision as of 10:45, 24 May 2011

File:Spritegfx.png

The 16x16 pixels sprite tiles are divided in 4 8x8 blocks. Each row of these 8x8 blocks are stored backwards in a 4bit planar organization.

  • On cart systems, bitplanes 0 and 1 go in the odd C ROMs (C1, C3...), while bitplanes 2 and 3 go in the even ones (C2, C4...).
  • On CD systems, bitplanes follow a 1/0/3/2 pattern.

Informations from Raregame.ru: [here] and [here].

Decoding

Pseudocode:

    For Tileline = 0 To 7
        For Tilerow = 0 To 7
            For Quarter = 0 To 3
                Select Case Quarter
                    Case 0: xOfs = 8: yOfs = 0
                    Case 1: xOfs = 8: yOfs = 8
                    Case 2: xOfs = 0: yOfs = 0
                    Case 3: xOfs = 0: yOfs = 8
                End Select
                For QuarterLine = 0 To 7
                    BitPlane(0) = ReadByte(1)
                    BitPlane(1) = ReadByte(1)
                    BitPlane(2) = ReadByte(2)
                    BitPlane(3) = ReadByte(2)
                    For Pixels = 0 To 7
                        xPos = (Tilerow * 16) + Pixels + xOfs
                        yPos = (Tileline * 16) + QuarterLine + yOfs
                        for Bitplanes = 0 to 3
                            ColorIndex .= GetBit(Bin(BitPlane(3-Bitplanes)),7-Pixels)
                        next Bitplanes
                        PixelSet (xPos, yPos), Palette[BinToDec(ColorIndex)]
                    Next Pixels
                Next QuarterLine
            Next Quarter
        Next Tilerow
    Next Tileline