Sprite graphics format: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
(Created page with "The 16x16 pixels sprite tiles are divided in 4 8x8 blocks, like this: {| border=1 cellpadding=10 |3 |1 |- |4 |2 |} Each row of these 8x8 blocks are stored in a 4bit planar orga…")
 
mNo edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The 16x16 pixels sprite tiles are divided in 4 8x8 blocks, like this:
[[File:spritegfx2.png|center]]


{| border=1 cellpadding=10
The NeoGeo uses 16x16 pixels, 4bpp tiles for sprites.
|3
|1
|-
|4
|2
|}


Each row of these 8x8 blocks are stored in a 4bit planar organization.
They are stored as 4, 8x8 pixels blocks. Each row of these 8x8 blocks is stored '''backwards''' in a 4bit planar organization.
Bitplanes 1 and 2 go in the odd [[C ROM]]s (C1, C3...), while bitplanes 3 and 4 go in the even ones (C2, C4...).


(Need diagrams)
* On cartridge systems, bitplanes 0 and 1 go in the odd [[C ROM]]s (C1, C3...), while bitplanes 2 and 3 go in the even ones (C2, C4...).
* On [[CD systems]], bitplanes follow a 1/0/3/2 order.


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]].
=Size=
 
One tile is 16 * 16 pixels * 4 bits per pixel = 1024 bits = '''128 bytes'''.
 
=Addressing=
 
<pre>
Bit # ...543210
      ...nCLLLL
 
n: Tile number (multiple bits)
C: Block column, 0 = blocks 1 & 2, 1 = blocks 3 & 4
L: Block line # (0~15)
</pre>
 
{{Sig|CA4|CA4}} is "C".
 
="Consolegfx"-style definition=
 
Each group represents one byte.
 
* '''t''' is the 8x8 block number (1 to 4) as shown above.
* '''r''' is the row number in the block (0 to 7).
* '''bp''' is the bitplane number (0 to 3).
 
==Odd C ROMs==
<pre>
  [t1, r0, bp0], [t1, r0, bp1], [t1, r1, bp0], [t1, r1, bp1],
  [t1, r2, bp0], [t1, r2, bp1], [t1, r3, bp0], [t1, r3, bp1],
  [t1, r4, bp0], [t1, r4, bp1], [t1, r5, bp0], [t1, r5, bp1],
  [t1, r6, bp0], [t1, r6, bp1], [t1, r7, bp0], [t1, r7, bp1],
 
  [t2, r0, bp0], [t2, r0, bp1], [t2, r1, bp0], [t2, r1, bp1],
  [t2, r2, bp0], [t2, r2, bp1], [t2, r3, bp0], [t2, r3, bp1],
  [t2, r4, bp0], [t2, r4, bp1], [t2, r5, bp0], [t2, r5, bp1],
  [t2, r6, bp0], [t2, r6, bp1], [t2, r7, bp0], [t2, r7, bp1]
 
  [t3, r0, bp0], [t3, r0, bp1], [t3, r1, bp0], [t3, r1, bp1],
  [t3, r2, bp0], [t3, r2, bp1], [t3, r3, bp0], [t3, r3, bp1],
  [t3, r4, bp0], [t3, r4, bp1], [t3, r5, bp0], [t3, r5, bp1],
  [t3, r6, bp0], [t3, r6, bp1], [t3, r7, bp0], [t3, r7, bp1]
 
  [t4, r0, bp0], [t4, r0, bp1], [t4, r1, bp0], [t4, r1, bp1],
  [t4, r2, bp0], [t4, r2, bp1], [t4, r3, bp0], [t4, r3, bp1],
  [t4, r4, bp0], [t4, r4, bp1], [t4, r5, bp0], [t4, r5, bp1],
  [t4, r6, bp0], [t4, r6, bp1], [t4, r7, bp0], [t4, r7, bp1]
</pre>
 
==Even C ROMs==
<pre>
  [t1, r0, bp2], [t1, r0, bp3], [t1, r1, bp2], [t1, r1, bp3],
  [t1, r2, bp2], [t1, r2, bp3], [t1, r3, bp2], [t1, r3, bp3],
  [t1, r4, bp2], [t1, r4, bp3], [t1, r5, bp2], [t1, r5, bp3],
  [t1, r6, bp2], [t1, r6, bp3], [t1, r7, bp2], [t1, r7, bp3],
 
  [t2, r0, bp2], [t2, r0, bp3], [t2, r1, bp2], [t2, r1, bp3],
  [t2, r2, bp2], [t2, r2, bp3], [t2, r3, bp2], [t2, r3, bp3],
  [t2, r4, bp2], [t2, r4, bp3], [t2, r5, bp2], [t2, r5, bp3],
  [t2, r6, bp2], [t2, r6, bp3], [t2, r7, bp2], [t2, r7, bp3]
 
  [t3, r0, bp2], [t3, r0, bp3], [t3, r1, bp2], [t3, r1, bp3],
  [t3, r2, bp2], [t3, r2, bp3], [t3, r3, bp2], [t3, r3, bp3],
  [t3, r4, bp2], [t3, r4, bp3], [t3, r5, bp2], [t3, r5, bp3],
  [t3, r6, bp2], [t3, r6, bp3], [t3, r7, bp2], [t3, r7, bp3]
 
  [t4, r0, bp2], [t4, r0, bp3], [t4, r1, bp2], [t4, r1, bp3],
  [t4, r2, bp2], [t4, r2, bp3], [t4, r3, bp2], [t4, r3, bp3],
  [t4, r4, bp2], [t4, r4, bp3], [t4, r5, bp2], [t4, r5, bp3],
  [t4, r6, bp2], [t4, r6, bp3], [t4, r7, bp2], [t4, r7, bp3]
</pre>
 
=Decoding=
 
Pseudocode:
<pre>
for block = 0 to 3 {
    select block {
        case 0: xOfs = 8: yOfs = 0
        case 1: xOfs = 8: yOfs = 8
        case 2: xOfs = 0: yOfs = 0
        case 3: xOfs = 0: yOfs = 8
    }
    for row = 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 = pixels + xOfs
            yPos = row + yOfs
            ColorIndex = 0
            for bitplanes = 0 to 3
                ColorIndex .= GetBit(BitPlane(3 - bitplanes)), 7 - pixels)
            PixelSet (xPos, yPos), Palette[ColorIndex]
        }
    }
}
</pre>
 
=Coding=


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

Latest revision as of 06:24, 10 July 2024

The NeoGeo uses 16x16 pixels, 4bpp tiles for sprites.

They are stored as 4, 8x8 pixels blocks. Each row of these 8x8 blocks is stored backwards in a 4bit planar organization.

  • On cartridge 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 order.

Size

One tile is 16 * 16 pixels * 4 bits per pixel = 1024 bits = 128 bytes.

Addressing

Bit # ...543210
      ...nCLLLL

n: Tile number (multiple bits)
C: Block column, 0 = blocks 1 & 2, 1 = blocks 3 & 4
L: Block line # (0~15)

CA4 is "C".

"Consolegfx"-style definition

Each group represents one byte.

  • t is the 8x8 block number (1 to 4) as shown above.
  • r is the row number in the block (0 to 7).
  • bp is the bitplane number (0 to 3).

Odd C ROMs

  [t1, r0, bp0], [t1, r0, bp1], [t1, r1, bp0], [t1, r1, bp1],
  [t1, r2, bp0], [t1, r2, bp1], [t1, r3, bp0], [t1, r3, bp1],
  [t1, r4, bp0], [t1, r4, bp1], [t1, r5, bp0], [t1, r5, bp1],
  [t1, r6, bp0], [t1, r6, bp1], [t1, r7, bp0], [t1, r7, bp1],

  [t2, r0, bp0], [t2, r0, bp1], [t2, r1, bp0], [t2, r1, bp1],
  [t2, r2, bp0], [t2, r2, bp1], [t2, r3, bp0], [t2, r3, bp1],
  [t2, r4, bp0], [t2, r4, bp1], [t2, r5, bp0], [t2, r5, bp1],
  [t2, r6, bp0], [t2, r6, bp1], [t2, r7, bp0], [t2, r7, bp1]

  [t3, r0, bp0], [t3, r0, bp1], [t3, r1, bp0], [t3, r1, bp1],
  [t3, r2, bp0], [t3, r2, bp1], [t3, r3, bp0], [t3, r3, bp1],
  [t3, r4, bp0], [t3, r4, bp1], [t3, r5, bp0], [t3, r5, bp1],
  [t3, r6, bp0], [t3, r6, bp1], [t3, r7, bp0], [t3, r7, bp1]

  [t4, r0, bp0], [t4, r0, bp1], [t4, r1, bp0], [t4, r1, bp1],
  [t4, r2, bp0], [t4, r2, bp1], [t4, r3, bp0], [t4, r3, bp1],
  [t4, r4, bp0], [t4, r4, bp1], [t4, r5, bp0], [t4, r5, bp1],
  [t4, r6, bp0], [t4, r6, bp1], [t4, r7, bp0], [t4, r7, bp1]

Even C ROMs

  [t1, r0, bp2], [t1, r0, bp3], [t1, r1, bp2], [t1, r1, bp3],
  [t1, r2, bp2], [t1, r2, bp3], [t1, r3, bp2], [t1, r3, bp3],
  [t1, r4, bp2], [t1, r4, bp3], [t1, r5, bp2], [t1, r5, bp3],
  [t1, r6, bp2], [t1, r6, bp3], [t1, r7, bp2], [t1, r7, bp3],

  [t2, r0, bp2], [t2, r0, bp3], [t2, r1, bp2], [t2, r1, bp3],
  [t2, r2, bp2], [t2, r2, bp3], [t2, r3, bp2], [t2, r3, bp3],
  [t2, r4, bp2], [t2, r4, bp3], [t2, r5, bp2], [t2, r5, bp3],
  [t2, r6, bp2], [t2, r6, bp3], [t2, r7, bp2], [t2, r7, bp3]

  [t3, r0, bp2], [t3, r0, bp3], [t3, r1, bp2], [t3, r1, bp3],
  [t3, r2, bp2], [t3, r2, bp3], [t3, r3, bp2], [t3, r3, bp3],
  [t3, r4, bp2], [t3, r4, bp3], [t3, r5, bp2], [t3, r5, bp3],
  [t3, r6, bp2], [t3, r6, bp3], [t3, r7, bp2], [t3, r7, bp3]

  [t4, r0, bp2], [t4, r0, bp3], [t4, r1, bp2], [t4, r1, bp3],
  [t4, r2, bp2], [t4, r2, bp3], [t4, r3, bp2], [t4, r3, bp3],
  [t4, r4, bp2], [t4, r4, bp3], [t4, r5, bp2], [t4, r5, bp3],
  [t4, r6, bp2], [t4, r6, bp3], [t4, r7, bp2], [t4, r7, bp3]

Decoding

Pseudocode:

for block = 0 to 3 {
    select block {
        case 0: xOfs = 8: yOfs = 0
        case 1: xOfs = 8: yOfs = 8
        case 2: xOfs = 0: yOfs = 0
        case 3: xOfs = 0: yOfs = 8
    }
    for row = 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 = pixels + xOfs
            yPos = row + yOfs
            ColorIndex = 0
            for bitplanes = 0 to 3
                ColorIndex .= GetBit(BitPlane(3 - bitplanes)), 7 - pixels)
            PixelSet (xPos, yPos), Palette[ColorIndex]
        }
    }
}

Coding