Difference between revisions of "Programming:Amstrad CPC plus sprite format"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
Line 1: Line 1:
 +
The sprites of the of the Amstrad CPC plus is always 16 x 16 pixels of size.
 +
 +
== The data ==
 +
 +
Each sprite has the ability to show 15 distinct colours, the pixel colours are indexed #0 - #F.
 +
 +
Index #0 is always transparency, whereas index #1 - #F is the colour index in the sprite palette.
 +
 +
To define a sprite in the ASIC. 16 x 16 (256) bytes must be transferred to the ASIC.
 +
 +
The format of the data is straight forward. The data is organized in a linear manner. Each sprite pixel uses a single byte, the upper nibble is ignored by the ASIC.
 +
 +
== The colour palette ==
 +
 +
 +
== Example ==
 +
 +
Below is shown an example of how a sprite is organized into raw data.
 +
 +
[[Image:Cpcplussprite.png|400px]]
 +
 
<geshi lang=Z80>
 
<geshi lang=Z80>
 
.pac_sprite
 
.pac_sprite
Line 49: Line 70:
 
dw #0000  ; Red = #F Green = #F Blue = #F ; The white in the PAC's eyes
 
dw #0000  ; Red = #F Green = #F Blue = #F ; The white in the PAC's eyes
 
</geshi>
 
</geshi>
 +
 +
== Links ==
  
 
[[Category:CPC Plus]]
 
[[Category:CPC Plus]]

Revision as of 18:59, 14 July 2009

The sprites of the of the Amstrad CPC plus is always 16 x 16 pixels of size.

The data

Each sprite has the ability to show 15 distinct colours, the pixel colours are indexed #0 - #F.

Index #0 is always transparency, whereas index #1 - #F is the colour index in the sprite palette.

To define a sprite in the ASIC. 16 x 16 (256) bytes must be transferred to the ASIC.

The format of the data is straight forward. The data is organized in a linear manner. Each sprite pixel uses a single byte, the upper nibble is ignored by the ASIC.

The colour palette

Example

Below is shown an example of how a sprite is organized into raw data.

Cpcplussprite.png

<geshi lang=Z80> .pac_sprite

The raw sprite data - to be transfered to the ASIC

db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#00,#00,#01,#01,#01,#01,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#01,#01,#01,#01,#01,#01,#01,#01,#00,#00,#00,#00 db #00,#00,#00,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#00,#00,#00 db #00,#00,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#00,#00 db #00,#00,#01,#01,#03,#03,#01,#01,#01,#01,#03,#03,#01,#01,#00,#00 db #00,#00,#01,#03,#03,#03,#03,#01,#01,#03,#03,#03,#03,#01,#00,#00 db #00,#01,#01,#03,#03,#03,#03,#01,#01,#03,#03,#03,#03,#01,#01,#00 db #00,#01,#01,#03,#02,#02,#03,#01,#01,#03,#02,#02,#03,#01,#01,#00 db #00,#01,#01,#01,#02,#02,#01,#01,#01,#01,#02,#02,#01,#01,#01,#00 db #00,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#00 db #00,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#01,#00 db #00,#01,#01,#01,#00,#01,#01,#01,#01,#01,#01,#00,#01,#01,#01,#00 db #00,#00,#01,#00,#00,#00,#01,#01,#01,#01,#00,#00,#00,#01,#00,#00 db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00

Compressed data

db #00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#11,#11,#00,#00,#00 db #00,#00,#11,#11,#11,#11,#00,#00 db #00,#01,#11,#11,#11,#11,#10,#00 db #00,#11,#11,#11,#11,#11,#11,#00 db #00,#11,#33,#11,#11,#33,#11,#00 db #00,#13,#33,#31,#13,#33,#31,#00 db #01,#13,#33,#31,#13,#33,#31,#10 db #01,#13,#22,#31,#13,#22,#31,#10 db #01,#11,#22,#11,#11,#22,#11,#10 db #01,#11,#11,#11,#11,#11,#11,#10 db #01,#11,#11,#11,#11,#11,#11,#10 db #01,#11,#01,#11,#11,#10,#11,#10 db #00,#10,#00,#11,#11,#00,#01,#00 db #00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#00,#00,#00,#00

.pack_sprite_palette

Sprite ink 1

dw #0CDF  ; Red = #D Green = #C Blue = #F ; The gray body

Sprite ink 2

dw #0000  ; Red = #0 Green = #0 Blue = #0 ; The black in the PAC's eyes

Sprite ink 3

dw #0000  ; Red = #F Green = #F Blue = #F ; The white in the PAC's eyes </geshi>

Links